info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [\"\\\"51230100\\\"\", \"\\\"123\\\"\", \"\\\"61\\\"\", \"\\\"680\\\"\", \"\\\"561\\\"\", \"\\\"563000\\\"\", \"\\\"2400000\\\"\", \"\\\"231400\\\"\", \"\\\"68085000000\\\"\", \"\\\"601626560\\\"\", \"\\\"8438682911711716633214751365219626743737461956719455758661336162737333413873348734551161599... | Given a positive integer num represented as a string, return the integer num without trailing zeros as a string.
Example 1:
Input: num = "51230100"
Output: "512301"
Explanation: Integer "51230100" has 2 trailing zeros, we remove them and return integer "512301".
Example 2:
Input: num = "123"
Output: "123"
Explanat... | 0.375 |
{"tests": "{\"inputs\": [\"[2, 1, 3]\", \"[1, 3, 3, 2]\", \"[1, 1]\", \"[3, 4, 4, 1, 2, 1]\", \"[1, 1]\", \"[1, 2, 2]\", \"[1, 4, 2, 3]\", \"[1, 3, 4, 4, 2]\", \"[3, 2, 5, 5, 1, 4]\", \"[4, 1, 2, 6, 6, 5, 3]\", \"[3, 7, 7, 6, 5, 4, 1, 2]\", \"[10, 9, 2, 7, 1, 4, 8, 5, 11, 3, 6, 11]\", \"[18, 14, 16, 20, 33, 3, 24, 11, ... | You are given an integer array nums. We consider an array good if it is a permutation of an array base[n].
base[n] = [1, 2, ..., n - 1, n, n] (in other words, it is an array of length n + 1 which contains 1 to n - 1 exactly once, plus two occurrences of n). For example, base[1] = [1, 1] and base[3] = [1, 2, 3, 3].
Retu... | 0.75 |
{"tests": "{\"inputs\": [\"[2, 2, 1]\\n4\", \"[2, 1, 3]\\n5\", \"[2, 3, 3, 2, 3]\\n6\", \"[2]\\n114\", \"[17, 17]\\n3\", \"[25, 81]\\n48\", \"[20, 33, 1]\\n4\", \"[33, 89, 9]\\n200\", \"[14, 5, 7, 20]\\n5\", \"[47, 27, 74]\\n200\", \"[68, 46, 28]\\n200\", \"[2, 4, 26, 20, 49, 13, 47, 22, 3, 3, 28, 18, 11, 20, 39, 5, 8,... | You are given an array nums of length n and an integer m. You need to determine if it is possible to split the array into n non-empty arrays by performing a series of steps.
In each step, you can select an existing array (which may be the result of previous steps) with a length of at least two and split it into two sub... | 0 |
{"tests": "{\"inputs\": [\"5\\n2\", \"3\\n3\", \"2\\n5\", \"1\\n7\", \"1\\n4\", \"6\\n2\", \"6\\n1\", \"1\\n1\", \"1\\n3\", \"2\\n1\", \"48\\n42\", \"49\\n41\", \"50\\n49\", \"49\\n48\"], \"outputs\": [\"3\", \"10\", \"6\", \"3\", \"3\", \"1\", \"0\", \"3\", \"3\", \"3\", \"1162\", \"1167\", \"1323\", \"1272\"], \"fn_n... | You are given two positive integers n and limit.
Return the total number of ways to distribute n candies among 3 children such that no child gets more than limit candies.
Example 1:
Input: n = 5, limit = 2
Output: 3
Explanation: There are 3 ways to distribute 5 candies such that no child gets more than 2 candies: (1... | 0.125 |
{"tests": "{\"inputs\": [\"\\\"aaaaa\\\"\", \"\\\"abddez\\\"\", \"\\\"zyxyxyz\\\"\", \"\\\"\\\"\", \"\\\"x\\\"\", \"\\\"k\\\"\", \"\\\"e\\\"\", \"\\\"a\\\"\", \"\\\"i\\\"\", \"\\\"d\\\"\", \"\\\"s\\\"\", \"\\\"b\\\"\", \"\\\"tuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghij... | You are given a 0-indexed string word.
In one operation, you can pick any index i of word and change word[i] to any lowercase English letter.
Return the minimum number of operations needed to remove all adjacent almost-equal characters from word.
Two characters a and b are almost-equal if a == b or a and b are adjacent... | 0 |
{"tests": "{\"inputs\": [\"\\\"accca\\\"\\n2\", \"\\\"aabaab\\\"\\n3\", \"\\\"xxyz\\\"\\n1\", \"\\\"abcde\\\"\\n5\", \"\\\"aaaaaa\\\"\\n2\", \"\\\"wjlcta\\\"\\n5\", \"\\\"eictzzwx\\\"\\n1\", \"\\\"fvcalcqn\\\"\\n3\", \"\\\"zcjvkodq\\\"\\n5\", \"\\\"eifhjtmuj\\\"\\n7\", \"\\\"cxdzvmcbcv\\\"\\n3\", \"\\\"rnqrabcxrh\\\"\\... | You are given a 0-indexed string s and an integer k.
You are to perform the following partitioning operations until s is empty:
Choose the longest prefix of s containing at most k distinct characters.
Delete the prefix from s and increase the number of partitions by one. The remaining characters (if any) in s maintain... | 0 |
{"tests": "{\"inputs\": [\"[1, 2, 3, 4, 5, 6]\\n[1, 1]\", \"[1, 4, 4, 1, 3, 5, 5, 3]\\n[1, 0, -1]\", \"[81, 50]\\n[-1]\", \"[7, 57, 88]\\n[-1]\", \"[28, 53, 21]\\n[0]\", \"[5, 47, 63, 48]\\n[-1, 0]\", \"[46, 60, 80, 98, 90]\\n[0, 1]\", \"[9, 83, 77, 75, 39, 32, 68, 60]\\n[0]\", \"[73, 26, 7, 20, 30, 48, 97]\\n[-1, 1]\"... | You are given a 0-indexed integer array nums of size n, and a 0-indexed integer array pattern of size m consisting of integers -1, 0, and 1.
A subarray nums[i..j] of size m + 1 is said to match the pattern if the following conditions hold for each element pattern[k]:
nums[i + k + 1] > nums[i + k] if pattern[k] == 1.
n... | 0.75 |
{"tests": "{\"inputs\": [\"[8, 4, 2, 30, 15]\", \"[1, 2, 3, 4, 5]\", \"[3, 16, 8, 4, 2]\", \"[29]\", \"[14]\", \"[34]\", \"[99]\", \"[206]\", \"[159]\", \"[249]\", \"[6, 31]\", \"[47, 247]\", \"[9, 148, 121]\", \"[73786976294838206463, 4294967295, 1048575, 4194303, 281474976710655, 75557863725914323419135, 3, 360287970... | You are given a 0-indexed array of positive integers nums.
In one operation, you can swap any two adjacent elements if they have the same number of set bits. You are allowed to do this operation any number of times (including zero).
Return true if you can sort the array, else return false.
Example 1:
Input: nums = [... | 0.5 |
{"tests": "{\"inputs\": [\"[1, 1, 2, 2, 3, 4]\", \"[1, 1, 1, 1]\", \"[5, 9]\", \"[5, 3]\", \"[24, 32]\", \"[2, 1, 1, 2]\", \"[9, 7, 7, 9]\", \"[4, 1, 3, 2]\", \"[1, 1, 3, 2]\", \"[1, 1, 1, 1]\", \"[10, 4, 4, 6]\", \"[1, 1, 1, 2, 3, 4]\", \"[5, 84, 22, 86, 87, 78, 53, 86, 49, 6, 31, 75, 96, 86, 37, 5, 84, 1, 96, 9, 17, ... | You are given an integer array nums of even length. You have to split the array into two parts nums1 and nums2 such that:
nums1.length == nums2.length == nums.length / 2.
nums1 should contain distinct elements.
nums2 should also contain distinct elements.
Return true if it is possible to split the array, and false ot... | 0.125 |
{"tests": "{\"inputs\": [\"3\\n3 5 10\\n4 3 3\\n2 2 6\\n\", \"3\\n3 5 10\\n4 3 3\\n2 2 3\\n\", \"2\\n4 8\\n3 1 100\\n4 10000 100\\n\", \"1\\n1\\n1 1 1\\n1 1 1\\n\", \"1\\n1328\\n1 73192516 779\\n1 468279677 682\\n\", \"1\\n1093\\n1 150127956 237\\n1 905660966 894\\n\", \"1\\n14807\\n43 583824808 729\\n15 917174828 159\... | As the factory manager of Keyence, you want to monitor several sections on a conveyor belt. There are a total of N sections you want to monitor, and the length of the i-th section is D_i meters.
There are two types of sensors to choose from, and below is some information about each sensor.
- Type-j sensor (1\leq j \le... | 0 |
{"tests": "{\"inputs\": [\"4 5\\n1 2 3 4 5\\n6 7 8 9 10\\n11 12 13 14 15\\n16 17 18 19 20\\n1 3 2 5 4\\n11 13 12 15 14\\n6 8 7 10 9\\n16 18 17 20 19\\n\", \"2 2\\n1 1\\n1 1\\n1 1\\n1 1000000000\\n\", \"3 3\\n8 1 6\\n3 5 7\\n4 9 2\\n8 1 6\\n3 5 7\\n4 9 2\\n\", \"5 5\\n710511029 136397527 763027379 644706927 447672230\\n... | You are given two grids, A and B, each with H rows and W columns.
For each pair of integers (i, j) satisfying 1 \leq i \leq H and 1 \leq j \leq W, let (i, j) denote the cell in the i-th row and j-th column. In grid A, cell (i, j) contains the integer A_{i, j}. In grid B, cell (i, j) contains the integer B_{i, j}.
You w... | 0.625 |
{"tests": "{\"inputs\": [\"3 1\\n\", \"2 1\\n\", \"2 2\\n\", \"3 1\\n\", \"3 3\\n\", \"4 1\\n\", \"4 2\\n\", \"4 3\\n\", \"4 4\\n\", \"100 30\\n\", \"100 93\\n\", \"100 89\\n\", \"100 100\\n\"], \"outputs\": [\"2\\n1 2 \\n1 3 \\n2\\n\", \"1\\n1 2 \\n2\\n\", \"1\\n1 2 \\n1\\n\", \"2\\n1 2 \\n1 3 \\n2\\n\", \"2\\n1 2 \\n... | This is an interactive problem (a type of problem where your program interacts with the judge program through Standard Input and Output).
There are N bottles of juice, numbered 1 to N. It has been discovered that exactly one of these bottles has gone bad. Even a small sip of the spoiled juice will cause stomach upset t... | 0 |
{"tests": "{\"inputs\": [\"3 4\\n1 2 5\\n2 1 -3\\n2 3 -4\\n3 1 100\\n\", \"3 2\\n1 2 0\\n2 1 0\\n\", \"5 9\\n1 2 -246288\\n4 5 -222742\\n3 1 246288\\n3 4 947824\\n5 2 -178721\\n4 3 -947824\\n5 4 756570\\n2 5 707902\\n5 1 36781\\n\", \"2 1\\n2 1 0\\n\", \"6 8\\n1 5 -4\\n2 1 -803\\n3 1 -1595\\n3 4 -5960\\n3 5 -1599\\n5 2... | There is a weighted simple directed graph with N vertices and M edges.
The vertices are numbered 1 to N, and the i-th edge has a weight of W_i and extends from vertex U_i to vertex V_i.
The weights can be negative, but the graph does not contain negative cycles.
Determine whether there is a walk that visits each vert... | 0 |
{"tests": "{\"inputs\": [\"2 5\\n\", \"0 0\\n\", \"7 1\\n\", \"1 0\\n\", \"2 0\\n\", \"2 1\\n\", \"1 3\\n\", \"2 3\\n\", \"0 6\\n\", \"3 4\\n\", \"0 8\\n\", \"5 4\\n\"], \"outputs\": [\"2\\n\", \"9\\n\", \"4\\n\", \"2\\n\", \"3\\n\", \"4\\n\", \"5\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"0\\n\"], \"fn_name\": nu... | You are given two integers A and B, each between 0 and 9, inclusive.
Print any integer between 0 and 9, inclusive, that is not equal to A + B.
Input
The input is given from Standard Input in the following format:
A B
Output
Print any integer between 0 and 9, inclusive, that is not equal to A + B.
Constraints
- 0... | 0 |
{"tests": "{\"inputs\": [\"840 84 7\\n\", \"343 34 3\\n\", \"0 0 0\\n\", \"951 154 495\\n\", \"744 621 910\\n\", \"866 178 386\\n\", \"1029 1029 1029\\n\", \"0 0 343\\n\", \"915 51 4\\n\", \"596 176 27\\n\", \"339 210 90\\n\", \"359 245 60\\n\", \"546 210 21\\n\", \"343 343 0\\n\"], \"outputs\": [\"Yes\\n0 0 0 0 6 0 6 ... | In a coordinate space, we want to place three cubes with a side length of 7 so that the volumes of the regions contained in exactly one, two, three cube(s) are V_1, V_2, V_3, respectively.
For three integers a, b, c, let C(a,b,c) denote the cubic region represented by (a\leq x\leq a+7) \land (b\leq y\leq b+7) \land (c... | 0 |
{"tests": "{\"inputs\": [\"3 2 10 20\\n\", \"3 2 20 20\\n\", \"314159265358979323 4 223606797 173205080\\n\", \"1000000000000000000 5 678409449 462213765\\n\", \"1000000000000000000 4 19417779 15359224\\n\", \"1000000000000000000 2 1000000000 1000000000\\n\", \"1000000000000000000 6 1000000000 1\\n\", \"100000000000000... | You are given an integer N. You can perform the following two types of operations:
- Pay X yen to replace N with \displaystyle\left\lfloor\frac{N}{A}\right\rfloor.
- Pay Y yen to roll a die (dice) that shows an integer between 1 and 6, inclusive, with equal probability. Let b be the outcome of the die, and replace N w... | 0.125 |
{"tests": "{\"inputs\": [\"0 0 3 3\\n\", \"-1 -2 1 3\\n\", \"-1000000000 -1000000000 1000000000 1000000000\\n\", \"593578395 -294607744 709130348 746175204\\n\", \"-678601079 -990141434 909949145 506736933\\n\", \"-420376129 -732520502 229097481 -243073819\\n\", \"-1 -1 0 0\\n\", \"-880976965 -698845539 -841240811 7992... | The pattern of AtCoder's wallpaper can be represented on the xy-plane as follows:
-
The plane is divided by the following three types of lines:
-
x = n (where n is an integer)
-
y = n (where n is an even number)
-
x + y = n (where n is an even number)
-
Each region is painted black or white. Any two regions... | 0 |
{"tests": "{\"inputs\": [\"[1, 2, 3, 4]\\n3\", \"[2, 2]\\n2\", \"[4, 3, -1]\\n2\", \"[100000000, 99999999, 99999998, 99999997, 99999996, 99999995, 99999994, 99999993, 99999992, 99999991]\\n10\", \"[3,369009,745365,1129173,1520619,1919958,2327340,2742999,3167043,3599574,4040745,4490808,4950051,5418543,5896347,6383565,68... | You are given an integer array nums of length n, and a positive integer k.
The power of a subsequence is defined as the minimum absolute difference between any two elements in the subsequence.
Return the sum of powers of all subsequences of nums which have length equal to k.
Since the answer may be large, return it mod... | 0.625 |
{"tests": "{\"inputs\": [\"5 0\\n2 5\\n\", \"3 1\\n4 1\\n\", \"2552608206527595 5411232866732612\\n771856005518028 7206210729152763\\n\", \"4781732879448891 183482112471753\\n4781732879448891 9644257416479985\\n\", \"6544605838412317 5090865519680273\\n3731935893323877 2278195574591833\\n\", \"0 0\\n10000000000000000 0... | The coordinate plane is covered with 2\times1 tiles. The tiles are laid out according to the following rules:
- For an integer pair (i,j), the square A _ {i,j}=\lbrace(x,y)\mid i\leq x\leq i+1\wedge j\leq y\leq j+1\rbrace is contained in one tile.
- When i+j is even, A _ {i,j} and A _ {i + 1,j} are contained in the sa... | 0 |
{"tests": "{\"inputs\": [\"363\\n\", \"101\\n\", \"3154625100\\n\", \"146659312800\\n\", \"248961081600\\n\", \"963761198400\\n\", \"936888861285\\n\", \"637822752336\\n\", \"549755813888\\n\", \"240940299600\\n\", \"442597478400\\n\", \"110649369600\\n\", \"39571817593\\n\", \"771852316660\\n\", \"607588581600\\n\", \... | You are given an integer N. Print a string S that satisfies all of the following conditions. If no such string exists, print -1.
- S is a string of length between 1 and 1000, inclusive, consisting of the characters 1, 2, 3, 4, 5, 6, 7, 8, 9, and * (multiplication symbol).
- S is a palindrome.
- The first character of ... | 0 |
{"tests": "{\"inputs\": [\"4 8 4\\n1 5\\n3 2\\n4 1\\n5 3\\n\", \"2 1 1\\n3 2\\n3 2\\n\", \"2 100 100\\n3 2\\n3 2\\n\", \"6 364 463\\n230 381\\n154 200\\n328 407\\n339 94\\n193 10\\n115 309\\n\", \"18 10000 10000\\n5790 8778\\n9995 9908\\n9016 2300\\n2633 3650\\n2312 5582\\n8853 6097\\n8881 8620\\n6427 3925\\n9355 5240\... | Takahashi has prepared N dishes for Snuke.
The dishes are numbered from 1 to N, and dish i has a sweetness of A_i and a saltiness of B_i.
Takahashi can arrange these dishes in any order he likes.
Snuke will eat the dishes in the order they are arranged, but if at any point the total sweetness of the dishes he has eaten... | 0 |
{"tests": "{\"inputs\": [\"3\\n2\\n[1, 3]\\n[5]\", \"2\\n2\\n[7]\\n[4]\", \"10\\n10\\n[420, 1, 597, 1, 905, 1, 261, 1, 681]\\n[101, 1, 333, 1, 502, 1, 409, 1, 787]\", \"6\\n2\\n[1,3,2,3,1]\\n[1]\", \"17\\n18\\n[781, 307, 573, 596, 536, 761, 591, 848, 858, 302, 652, 540, 770, 607, 809, 322]\\n[841, 828, 682, 480, 391, 9... | There is an m x n cake that needs to be cut into 1 x 1 pieces.
You are given integers m, n, and two arrays:
horizontalCut of size m - 1, where horizontalCut[i] represents the cost to cut along the horizontal line i.
verticalCut of size n - 1, where verticalCut[j] represents the cost to cut along the vertical line j.
... | 0 |
{"tests": "{\"inputs\": [\"3\\n[[2, 2], [0, 0]]\", \"3\\n[[2, 2], [1, 1], [0, 0]]\", \"2\\n[[0, 0], [1, 0]]\", \"69\\n[[0, 0], [1, 0], [2, 2], [3, 4], [4, 8], [5, 7], [6, 10], [7, 0], [8, 22], [9, 17], [10, 50], [11, 31], [12, 59], [13, 77], [14, 62], [15, 53], [16, 0], [17, 132], [18, 91], [19, 86], [20, 40], [21, 71]... | You are given an integer n and a 2D array requirements, where requirements[i] = [end_i, cnt_i] represents the end index and the inversion count of each requirement.
A pair of indices (i, j) from an integer array nums is called an inversion if:
i < j and nums[i] > nums[j]
Return the number of permutations perm of [0, ... | 0 |
{"tests": "{\"inputs\": [\"10\\nhttp://abacaba.ru/test\\nhttp://abacaba.ru/\\nhttp://abacaba.com\\nhttp://abacaba.com/test\\nhttp://abacaba.de/\\nhttp://abacaba.ru/test\\nhttp://abacaba.de/test\\nhttp://abacaba.com/\\nhttp://abacaba.com/t\\nhttp://abacaba.com/test\\n\", \"14\\nhttp://c\\nhttp://ccc.bbbb/aba..b\\nhttp:/... | There are some websites that are accessible through several different addresses. For example, for a long time Codeforces was accessible with two hostnames codeforces.com and codeforces.ru.
You are given a list of page addresses being queried. For simplicity we consider all addresses to have the form http://<hostname>[... | 0 |
{"tests": "{\"inputs\": [\"19 29\\n\", \"3 6\\n\", \"39 91\\n\", \"76 134\\n\", \"93 95\\n\", \"17 35\\n\", \"94 95\\n\", \"51 52\\n\", \"47 52\\n\", \"38 98\\n\", \"30 37\\n\", \"56 92\\n\", \"900000000 1000000000\\n\", \"37622224 162971117\\n\", \"760632746 850720703\\n\", \"908580370 968054552\\n\", \"951594860 9535... | Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path.
You are given l and r. For all integers from l to r, inclusive, we wrote down all of their integer divisors except 1. Find the integer that we wrote down the maximum number of times.
Solve... | 0.125 |
{"tests": "{\"inputs\": [\"5 5 20 25\\n1 2 25\\n2 3 25\\n3 4 20\\n4 5 20\\n5 1 20\\n\", \"6 7 13 22\\n1 2 13\\n2 3 13\\n1 4 22\\n3 4 13\\n4 5 13\\n5 6 13\\n6 1 13\\n\", \"2 1 1 2\\n2 1 1\\n\", \"2 1 9999999 10000000\\n1 2 10000000\\n\", \"3 3 78422 6789101\\n3 1 6789101\\n2 1 78422\\n2 3 78422\\n\", \"3 3 2770628 39124... | Codefortia is a small island country located somewhere in the West Pacific. It consists of $n$ settlements connected by $m$ bidirectional gravel roads. Curiously enough, the beliefs of the inhabitants require the time needed to pass each road to be equal either to $a$ or $b$ seconds. It's guaranteed that one can go bet... | 0 |
{"tests": "{\"inputs\": [\"10 5\\n\", \"4 2\\n\", \"4 1\\n\", \"1 1\\n\", \"63 1\\n\", \"98 88\\n\", \"746 173\\n\", \"890 553\\n\", \"883 1000\\n\", \"1 1000\\n\", \"695 188\\n\", \"2060 697\\n\", \"70 3321\\n\", \"6358 1646\\n\", \"15000 1\\n\", \"1048576 1\\n\", \"1000000 1\\n\", \"10009 1\\n\", \"10001 1\\n\"], \"o... | Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | 0 |
{"tests": "{\"inputs\": [\"technocup\\n\", \"tictictactac\\n\", \"bbaabaabbb\\n\", \"cbbbbcaaca\\n\", \"cadbcdddda\\n\", \"bababbdaee\\n\", \"fabbbhgedd\\n\", \"gaejllebhn\\n\", \"bbababaaababaabbbbbabbbbbbaaabbabaaaaabbbbbaaaabbbbabaabaabababbbabbabbabaaababbabbababaaaaabaaaabbb\\n\", \"eaaebccaeacdecaedcaabbbdeebccdc... | Vasya and Kolya play a game with a string, using the following rules. Initially, Kolya creates a string s, consisting of small English letters, and uniformly at random chooses an integer k from a segment [0, len(s) - 1]. He tells Vasya this string s, and then shifts it k letters to the left, i. e. creates a new string ... | 0 |
{"tests": "{\"inputs\": [\"15\\n1/3 2/1\\n3 1\\n6 2\\n4 2\\n2 5\\n4 5\\n6 6\\n3 4\\n1 6\\n2 1\\n7 4\\n9 3\\n5 3\\n1 3\\n15 5\\n12 4\\n\", \"15\\n2/1 2/0\\n3 1\\n6 2\\n9 3\\n12 4\\n15 5\\n2 1\\n4 2\\n5 3\\n7 4\\n1 3\\n3 4\\n2 5\\n4 5\\n1 6\\n6 6\\n\", \"15\\n2/1 2/0\\n3 1\\n6 2\\n9 3\\n12 4\\n15 5\\n2 1\\n4 2\\n5 3\\n7 ... | In the evenings Donkey would join Shrek to look at the stars. They would sit on a log, sipping tea and they would watch the starry sky. The sky hung above the roof, right behind the chimney. Shrek's stars were to the right of the chimney and the Donkey's stars were to the left. Most days the Donkey would just count the... | 0 |
{"tests": "{\"inputs\": [\"3 4\\n2 5 6\\n1 3 6 8\\n\", \"3 3\\n1 2 3\\n1 2 3\\n\", \"1 2\\n165\\n142 200\\n\", \"1 2\\n5000000000\\n1 10000000000\\n\", \"2 4\\n3 12\\n1 7 8 14\\n\", \"3 3\\n1 2 3\\n2 3 4\\n\", \"2 1\\n1 10\\n9\\n\", \"3 19\\n7 10 13\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19\\n\", \"3 3\\n2 3 4\... | Mad scientist Mike does not use slow hard disks. His modification of a hard drive has not one, but n different heads that can read data in parallel.
When viewed from the side, Mike's hard drive is an endless array of tracks. The tracks of the array are numbered from left to right with integers, starting with 1. In the... | 0 |
{"tests": "{\"inputs\": [\"3\\n999999 0\\n0 999999\\n999999 0\\n\", \"1\\n-824590 246031\\n\", \"8\\n-67761 603277\\n640586 -396671\\n46147 -122580\\n569609 -2112\\n400 914208\\n131792 309779\\n-850150 -486293\\n5272 721899\\n\", \"6\\n1000000 0\\n1000000 0\\n-1000000 0\\n0 1000000\\n0 -1000000\\n0 -1000000\\n\", \"8\\... | For a vector $\vec{v} = (x, y)$, define $|v| = \sqrt{x^2 + y^2}$.
Allen had a bit too much to drink at the bar, which is at the origin. There are $n$ vectors $\vec{v_1}, \vec{v_2}, \cdots, \vec{v_n}$. Allen will make $n$ moves. As Allen's sense of direction is impaired, during the $i$-th move he will either move in th... | 0 |
{"tests": "{\"inputs\": [\"6\\n2 1 4 6 2 2\\n\", \"7\\n3 3 3 1 3 3 3\\n\", \"7\\n5128 5672 5805 5452 5882 5567 5032\\n\", \"10\\n1 2 2 3 5 5 5 4 2 1\\n\", \"14\\n20 20 20 20 20 20 3 20 20 20 20 20 20 20\\n\", \"50\\n3 2 4 3 5 3 4 5 3 2 3 3 3 4 5 4 2 2 3 3 4 4 3 2 3 3 2 3 4 4 5 2 5 2 3 5 4 4 2 2 3 5 2 5 2 2 5 4 5 4\\n\"... | Limak is a little bear who loves to play. Today he is playing by destroying block towers. He built n towers in a row. The i-th tower is made of h_{i} identical blocks. For clarification see picture for the first sample.
Limak will repeat the following operation till everything is destroyed.
Block is called internal i... | 0 |
{"tests": "{\"inputs\": [\"3 2\\n1 2 3\\n\", \"5 10\\n0 1 0 2 1\\n\", \"9 0\\n11 22 33 44 55 66 77 88 99\\n\", \"10 100\\n2705446 2705444 2705446 2705445 2705448 2705447 2705444 2705448 2705448 2705449\\n\", \"10 5\\n5914099 5914094 5914099 5914097 5914100 5914101 5914097 5914095 5914101 5914102\\n\", \"12 3\\n7878607 ... | This problem is the most boring one you've ever seen.
Given a sequence of integers a_1, a_2, ..., a_{n} and a non-negative integer h, our goal is to partition the sequence into two subsequences (not necessarily consist of continuous elements). Each element of the original sequence should be contained in exactly one o... | 0 |
{"tests": "{\"inputs\": [\"3\\n4 2 1\\n\", \"1\\n4\\n\", \"2\\n1 1\\n\", \"1\\n2\\n\", \"1\\n3\\n\", \"1\\n5\\n\", \"2\\n2 2\\n\", \"3\\n1 2 4\\n\", \"3\\n3 3 3\\n\", \"3\\n3 3 6\\n\", \"3\\n6 6 6\\n\", \"3\\n6 6 9\\n\", \"26\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\", \"3\\n7 7 21\\n\", \"2\\n95 50\\n\... | Ivan wants to make a necklace as a present to his beloved girl. A necklace is a cyclic sequence of beads of different colors. Ivan says that necklace is beautiful relative to the cut point between two adjacent beads, if the chain of beads remaining after this cut is a palindrome (reads the same forward and backward).
... | 0 |
{"tests": "{\"inputs\": [\"4 2\\n1 2\\n2 3\\n\", \"3 3\\n1 2\\n2 3\\n1 3\\n\", \"5 7\\n3 2\\n5 4\\n3 4\\n1 3\\n1 5\\n1 4\\n2 5\\n\", \"10 11\\n4 10\\n8 10\\n2 3\\n2 4\\n7 1\\n8 5\\n2 8\\n7 2\\n1 2\\n2 9\\n6 8\\n\", \"10 9\\n2 5\\n2 4\\n2 7\\n2 9\\n2 3\\n2 8\\n2 6\\n2 10\\n2 1\\n\", \"10 16\\n6 10\\n5 2\\n6 4\\n6 8\\n5 ... | Recently, Pari and Arya did some research about NP-Hard problems and they found the minimum vertex cover problem very interesting.
Suppose the graph G is given. Subset A of its vertices is called a vertex cover of this graph, if for each edge uv there is at least one endpoint of it in this set, i.e. $u \in A$ or $v \i... | 0 |
{"tests": "{\"inputs\": [\"2 4\\n\", \"2 1\\n\", \"1 1\\n\", \"1 2\\n\", \"1 3\\n\", \"2 2\\n\", \"2 3\\n\", \"3 1\\n\", \"3 2\\n\", \"3 3\\n\", \"1 4\\n\", \"4 1\\n\", \"4 2\\n\", \"100 1\\n\", \"1 100\\n\", \"101 1\\n\", \"1 101\\n\", \"2 20\\n\"], \"outputs\": [\"YES\\n5 4 7 2 \\n3 6 1 8 \\n\", \"NO\\n\", \"YES\\n1\... | Students went into a class to write a test and sat in some way. The teacher thought: "Probably they sat in this order to copy works of each other. I need to rearrange them in such a way that students that were neighbors are not neighbors in a new seating."
The class can be represented as a matrix with n rows and m col... | 0 |
{"tests": "{\"inputs\": [\"4\\n\", \"2\\n\", \"1\\n\", \"3\\n\", \"5\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"10\\n\", \"20\\n\", \"21\\n\", \"22\\n\", \"23\\n\", \"24\\n\", \"25\\n\", \"100\\n\", \"108\\n\"], \"outputs\": [\"3 4 1 2\\n\", \"2 1\\n\", \"1\\n\", \"3 2 1\\n\", \"4 5 2 3 1\\n\", \"5 6 3 4 1 2\\n\",... | Mrs. Smith is trying to contact her husband, John Smith, but she forgot the secret phone number!
The only thing Mrs. Smith remembered was that any permutation of $n$ can be a secret phone number. Only those permutations that minimize secret value might be the phone of her husband.
The sequence of $n$ integers is call... | 0 |
{"tests": "{\"inputs\": [\"nolon\\n\", \"otto\\n\", \"qqqq\\n\", \"kinnikkinnik\\n\", \"nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn... | Reading books is one of Sasha's passions. Once while he was reading one book, he became acquainted with an unusual character. The character told about himself like that: "Many are my names in many countries. Mithrandir among the Elves, Tharkûn to the Dwarves, Olórin I was in my youth in the West that is forgotten, in t... | 0.625 |
{"tests": "{\"inputs\": [\"5 2 3\\n1 2\\n1 3\\n3 4\\n5 3\\n\", \"5 3 2\\n1 2\\n1 3\\n3 4\\n5 3\\n\", \"50 23129 410924\\n18 28\\n17 23\\n21 15\\n18 50\\n50 11\\n32 3\\n44 41\\n50 31\\n50 34\\n5 14\\n36 13\\n22 40\\n20 9\\n9 43\\n19 47\\n48 40\\n20 22\\n33 45\\n35 22\\n33 24\\n9 6\\n13 1\\n13 24\\n49 20\\n1 20\\n29 38\\... | A group of n cities is connected by a network of roads. There is an undirected road between every pair of cities, so there are $\frac{n \cdot(n - 1)}{2}$ roads in total. It takes exactly y seconds to traverse any single road.
A spanning tree is a set of roads containing exactly n - 1 roads such that it's possible to t... | 0 |
{"tests": "{\"inputs\": [\"5 3\\n3 2 2\\n\", \"10 1\\n1\\n\", \"1 1\\n1\\n\", \"2 2\\n1 2\\n\", \"200 50\\n49 35 42 47 134 118 14 148 58 159 33 33 8 123 99 126 75 94 1 141 61 79 122 31 48 7 66 97 141 43 25 141 7 56 120 55 49 37 154 56 13 59 153 133 18 1 141 24 151 125\\n\", \"3 3\\n3 3 1\\n\", \"100000 1\\n100000\\n\",... | Dreamoon likes coloring cells very much.
There is a row of $n$ cells. Initially, all cells are empty (don't contain any color). Cells are numbered from $1$ to $n$.
You are given an integer $m$ and $m$ integers $l_1, l_2, \ldots, l_m$ ($1 \le l_i \le n$)
Dreamoon will perform $m$ operations.
In $i$-th operation, Dre... | 0 |
{"tests": "{\"inputs\": [\"6\\n1 2\\n2 3\\n2 4\\n4 5\\n1 6\\n\", \"7\\n1 2\\n1 3\\n3 4\\n1 5\\n5 6\\n6 7\\n\", \"2\\n1 2\\n\", \"3\\n3 1\\n1 2\\n\", \"10\\n5 10\\n7 8\\n8 3\\n2 6\\n3 2\\n9 7\\n4 5\\n10 1\\n6 4\\n\", \"11\\n11 9\\n6 7\\n7 1\\n8 11\\n5 6\\n3 5\\n9 3\\n10 8\\n2 4\\n4 10\\n\", \"10\\n4 2\\n7 4\\n2 6\\n2 5\... | Vanya wants to minimize a tree. He can perform the following operation multiple times: choose a vertex v, and two disjoint (except for v) paths of equal length a_0 = v, a_1, ..., a_{k}, and b_0 = v, b_1, ..., b_{k}. Additionally, vertices a_1, ..., a_{k}, b_1, ..., b_{k} must not have any neighbours in the tree other t... | 0 |
{"tests": "{\"inputs\": [\"2\\n1 1 1\\n\", \"2\\n1 2 2\\n\", \"10\\n1 1 1 1 1 1 1 1 1 1 1\\n\", \"10\\n1 1 1 1 1 2 1 1 1 1 1\\n\", \"10\\n1 1 1 1 2 2 1 1 1 1 1\\n\", \"10\\n1 1 1 1 1 1 1 2 1 1 2\\n\", \"10\\n1 1 1 3 2 1 2 4 1 3 1\\n\", \"10\\n1 1 1 4 1 1 2 1 5 1 2\\n\", \"10\\n1 1 21 1 20 1 14 1 19 1 20\\n\", \"10\\n1 ... | Sasha is taking part in a programming competition. In one of the problems she should check if some rooted trees are isomorphic or not. She has never seen this problem before, but, being an experienced participant, she guessed that she should match trees to some sequences and then compare these sequences instead of tree... | 0 |
{"tests": "{\"inputs\": [\"4\\n2 4\\n4 3\\n3 0\\n1 3\\n\", \"3\\n0 0\\n0 2\\n2 0\\n\", \"8\\n0 3\\n2 2\\n3 0\\n2 -2\\n0 -3\\n-2 -2\\n-3 0\\n-2 2\\n\", \"4\\n-100000000 -100000000\\n-100000000 100000000\\n100000000 100000000\\n100000000 -100000000\\n\", \"4\\n0 0\\n10 10\\n10 9\\n1 0\\n\", \"4\\n12345678 99999999\\n1234... | You are given $n$ points on the plane. The polygon formed from all the $n$ points is strictly convex, that is, the polygon is convex, and there are no three collinear points (i.e. lying in the same straight line). The points are numbered from $1$ to $n$, in clockwise order.
We define the distance between two points $p... | 0 |
{"tests": "{\"inputs\": [\"3 1\\n6\\n\", \"3 3\\n1 7 8\\n\", \"3 4\\n1 3 5 7\\n\", \"10 10\\n334 588 666 787 698 768 934 182 39 834\\n\", \"2 4\\n3 2 4 1\\n\", \"3 4\\n3 4 1 6\\n\", \"2 0\\n\", \"2 1\\n1\\n\", \"17 0\\n\", \"17 1\\n95887\\n\", \"2 2\\n4 2\\n\", \"2 3\\n2 1 3\\n\", \"3 5\\n7 2 1 4 8\\n\", \"3 6\\n5 4 1 ... | The biggest event of the year – Cota 2 world championship "The Innernational" is right around the corner. $2^n$ teams will compete in a double-elimination format (please, carefully read problem statement even if you know what is it) to identify the champion.
Teams are numbered from $1$ to $2^n$ and will play games on... | 0 |
{"tests": "{\"inputs\": [\"2\\n3 5\\n5 3\\n\", \"2\\n5 3\\n3 5\\n\", \"9\\n1 2\\n2 3\\n3 4\\n4 5\\n5 6\\n6 7\\n7 8\\n8 9\\n9 1\\n\", \"50\\n9 5\\n2 6\\n5 4\\n7 5\\n3 6\\n5 8\\n1 2\\n6 1\\n9 7\\n8 1\\n9 5\\n6 8\\n6 8\\n2 8\\n4 9\\n6 7\\n7 8\\n5 8\\n1 2\\n9 2\\n5 9\\n6 7\\n3 2\\n9 8\\n7 8\\n7 4\\n6 5\\n1 7\\n6 5\\n2 6\\n... | You work in a big office. It is a 9 floor building with an elevator that can accommodate up to 4 people. It is your responsibility to manage this elevator.
Today you are late, so there are queues on some floors already. For each person you know the floor where he currently is and the floor he wants to reach. Also, you... | 0 |
{"tests": "{\"inputs\": [\"2 1\\n1 2\\n\", \"4 3\\n1 2\\n2 3\\n3 1\\n\", \"3 2\\n1 3\\n2 3\\n\", \"6 3\\n1 3\\n2 5\\n4 6\\n\", \"100 50\\n55 13\\n84 2\\n22 63\\n100 91\\n2 18\\n98 64\\n1 86\\n93 11\\n17 6\\n24 97\\n14 35\\n24 74\\n22 3\\n42 5\\n63 79\\n31 89\\n81 22\\n86 88\\n77 51\\n81 34\\n19 55\\n41 54\\n34 57\\n45 ... | Logical quantifiers are very useful tools for expressing claims about a set. For this problem, let's focus on the set of real numbers specifically. The set of real numbers includes zero and negatives. There are two kinds of quantifiers: universal ($\forall$) and existential ($\exists$). You can read more about them her... | 0 |
{"tests": "{\"inputs\": [\"5 3\\n0 0 0 1 2\\n\", \"5 7\\n0 6 1 3 2\\n\", \"10 10\\n5 0 5 9 4 6 4 5 0 0\\n\", \"4 6\\n0 3 5 1\\n\", \"6 4\\n1 3 0 2 1 0\\n\", \"10 1000\\n981 824 688 537 969 72 39 734 929 718\\n\", \"10 300000\\n111862 91787 271781 182224 260248 142019 30716 102643 141870 19206\\n\", \"100 10\\n8 4 4 9 0... | Toad Zitz has an array of integers, each integer is between $0$ and $m-1$ inclusive. The integers are $a_1, a_2, \ldots, a_n$.
In one operation Zitz can choose an integer $k$ and $k$ indices $i_1, i_2, \ldots, i_k$ such that $1 \leq i_1 < i_2 < \ldots < i_k \leq n$. He should then change $a_{i_j}$ to $((a_{i_j}+1) \bm... | 0 |
{"tests": "{\"inputs\": [\"4 2 3 10\\nwwhw\\n\", \"5 2 4 13\\nhhwhh\\n\", \"5 2 4 1000\\nhhwhh\\n\", \"3 1 100 10\\nwhw\\n\", \"10 2 3 32\\nhhwwhwhwwh\\n\", \"1 2 3 3\\nw\\n\", \"100 20 100 10202\\nwwwwhhwhhwhhwhhhhhwwwhhhwwwhwwhwhhwwhhwwwhwwhwwwhwhwhwwhhhwhwhhwhwwhhwhwhwwwhwwwwhwhwwwwhwhhhwhwhwww\\n\", \"20 10 10 1\\n... | Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reach photo n. Similarly, by swiping right from the last photo you reach photo 1. It takes a sec... | 0 |
{"tests": "{\"inputs\": [\"4 5\\n1 2 0 4\\n1 2 0 4\\n5 0 0 3\\n0 5 0 3\\n\", \"1 2\\n1\\n2\\n1\\n2\\n\", \"1 2\\n1\\n1\\n2\\n2\\n\", \"2 2\\n1 0\\n0 2\\n0 1\\n0 2\\n\", \"7 14\\n2 11 1 14 9 8 5\\n12 6 7 1 10 2 3\\n14 13 9 8 5 4 11\\n13 6 4 3 12 7 10\\n\", \"2 1\\n0 0\\n0 0\\n0 1\\n0 1\\n\", \"2 3\\n0 2\\n0 1\\n3 2\\n3 ... | Allen dreams of one day owning a enormous fleet of electric cars, the car of the future! He knows that this will give him a big status boost. As Allen is planning out all of the different types of cars he will own and how he will arrange them, he realizes that he has a problem.
Allen's future parking lot can be repre... | 0 |
{"tests": "{\"inputs\": [\"4 1\\n1 1 4 2\\n\", \"3 1\\n2 2 2\\n\", \"10 20\\n6 4 7 10 4 5 5 3 7 10\\n\", \"30 7\\n3 3 2 2 2 2 3 4 4 5 2 1 1 5 5 3 4 3 2 1 3 4 3 2 2 5 2 5 1 2\\n\", \"2 0\\n182 2\\n\", \"123 54564\\n38 44 41 42 59 3 95 15 45 32 44 69 35 83 94 57 65 85 64 47 24 20 34 86 26 91 98 12 36 96 80 4 70 40 95 38 ... | We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor.
There are n citizens in Kekoland, each person has c_{i} coins. Each day, Robin Hood will take exactly 1 coin from the richest person in the city and he will give it t... | 0.125 |
{"tests": "{\"inputs\": [\"5 2\\n4 2 1 10 2\\n\", \"3 2\\n3 1 2\\n\", \"5 5\\n5 5 9 100 3\\n\", \"1 1\\n1\\n\", \"1 1\\n10000000\\n\", \"6 4\\n85666 52319 21890 51912 90704 10358\\n\", \"10 5\\n66220 81797 38439 54881 86879 94346 8802 59094 57095 41949\\n\", \"8 1\\n3669 11274 87693 33658 58862 78334 42958 30572\\n\", ... | Helen works in Metropolis airport. She is responsible for creating a departure schedule. There are n flights that must depart today, the i-th of them is planned to depart at the i-th minute of the day.
Metropolis airport is the main transport hub of Metropolia, so it is difficult to keep the schedule intact. This is e... | 0.125 |
{"tests": "{\"inputs\": [\"3 1\\n2 2\\n\", \"3 0\\n\", \"4 3\\n3 1\\n3 2\\n3 3\\n\", \"2 1\\n1 1\\n\", \"2 3\\n1 2\\n2 1\\n2 2\\n\", \"5 1\\n3 2\\n\", \"5 1\\n2 3\\n\", \"1000 0\\n\", \"999 0\\n\", \"5 5\\n3 2\\n5 4\\n3 3\\n2 3\\n1 2\\n\", \"5 5\\n3 2\\n1 4\\n5 1\\n4 5\\n3 1\\n\", \"5 5\\n2 2\\n5 3\\n2 3\\n5 1\\n4 4\\n... | Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute moves each chip into an adjacent cell. He moves each chip from its original... | 0 |
{"tests": "{\"inputs\": [\"3 2\\n1 2 1\\n3 4\\n\", \"2 2\\n0 1\\n1 0\\n\", \"2 3\\n1 0\\n1 1 2\\n\", \"2 2\\n0 0\\n100000000 100000000\\n\", \"2 2\\n14419485 34715515\\n45193875 34715515\\n\", \"2 2\\n4114169 4536507\\n58439428 4536507\\n\", \"2 2\\n89164828 36174769\\n90570286 89164829\\n\", \"2 2\\n23720786 67248252\... | $n$ boys and $m$ girls came to the party. Each boy presented each girl some integer number of sweets (possibly zero). All boys are numbered with integers from $1$ to $n$ and all girls are numbered with integers from $1$ to $m$. For all $1 \leq i \leq n$ the minimal number of sweets, which $i$-th boy presented to some g... | 0 |
{"tests": "{\"inputs\": [\"123123\\n1\\n2->00\\n\", \"123123\\n1\\n3->\\n\", \"222\\n2\\n2->0\\n0->7\\n\", \"1000000008\\n0\\n\", \"100\\n5\\n1->301\\n0->013\\n1->013\\n0->103\\n0->103\\n\", \"21222\\n10\\n1->\\n2->1\\n1->1\\n1->1\\n1->1\\n1->22\\n2->2\\n2->1\\n1->21\\n1->\\n\", \"21122\\n10\\n1->\\n2->12\\n1->\\n2->21... | Andrew and Eugene are playing a game. Initially, Andrew has string s, consisting of digits. Eugene sends Andrew multiple queries of type "d_{i} → t_{i}", that means "replace all digits d_{i} in string s with substrings equal to t_{i}". For example, if s = 123123, then query "2 → 00" transforms s to 10031003, and query ... | 0 |
{"tests": "{\"inputs\": [\"5 2\\n50 110 130 40 120\\n\", \"4 1\\n2 3 4 1\\n\", \"1 1\\n4\\n\", \"2 2\\n7 5\\n\", \"3 2\\n34 3 75\\n\", \"5 2\\n932 328 886 96 589\\n\", \"10 4\\n810 8527 9736 3143 2341 6029 7474 707 2513 2023\\n\", \"20 11\\n924129 939902 178964 918687 720767 695035 577430 407131 213304 810868 596349 26... | Evlampiy has found one more cool application to process photos. However the application has certain limitations.
Each photo i has a contrast v_{i}. In order for the processing to be truly of high quality, the application must receive at least k photos with contrasts which differ as little as possible.
Evlampiy alread... | 0 |
{"tests": "{\"inputs\": [\"7\\n-1 3\\n1 2\\n1 1\\n1 4\\n4 5\\n4 3\\n5 2\\n\", \"1\\n-1 42\\n\", \"2\\n-1 3\\n1 2\\n\", \"3\\n-1 3\\n1 1\\n1 2\\n\", \"3\\n-1 1\\n1 2\\n1 3\\n\", \"3\\n-1 3\\n1 2\\n2 1\\n\", \"20\\n-1 100\\n1 10\\n2 26\\n2 33\\n3 31\\n2 28\\n1 47\\n6 18\\n6 25\\n9 2\\n4 17\\n6 18\\n6 2\\n6 30\\n13 7\\n5 ... | One Big Software Company has n employees numbered from 1 to n. The director is assigned number 1. Every employee of the company except the director has exactly one immediate superior. The director, of course, doesn't have a superior.
We will call person a a subordinates of another person b, if either b is an immediate... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 3 2 4\\n\", \"1\\n34688642\\n\", \"2\\n-492673762 -496405053\\n\", \"4\\n-432300451 509430974 -600857890 -140418957\\n\", \"16\\n-15108237 489260742 681810357 -78861365 -416467743 -896443270 904192296 -932642644 173249302 402207268 -329323498 537696045 -899233426 902347982 -595589754 -4... | You are given an array $a$ of $n$ integers.
You want to make all elements of $a$ equal to zero by doing the following operation exactly three times: Select a segment, for each number in this segment we can add a multiple of $len$ to it, where $len$ is the length of this segment (added integers can be different).
It... | 0 |
{"tests": "{\"inputs\": [\"5\\n3 6 9 12 15\\n\", \"4\\n3 7 5 2\\n\", \"1\\n1\\n\", \"16\\n985629174 189232688 48695377 692426437 952164554 243460498 173956955 210310239 237322183 96515847 678847559 682240199 498792552 208770488 736004147 176573082\\n\", \"18\\n341796022 486073481 86513380 593942288 60606166 627385348 7... | Karen has just arrived at school, and she has a math test today! [Image]
The test is about basic addition and subtraction. Unfortunately, the teachers were too busy writing tasks for Codeforces rounds, and had no time to make an actual test. So, they just put one question in the test that is worth all the points.
Th... | 0 |
{"tests": "{\"inputs\": [\"3 1\\n1 1 2 2\\n2 2 3 3\\n3 3 4 4\\n\", \"4 1\\n1 1 2 2\\n1 9 2 10\\n9 9 10 10\\n9 1 10 2\\n\", \"3 0\\n1 1 2 2\\n1 1 1000000000 1000000000\\n1 3 8 12\\n\", \"11 8\\n9 1 11 5\\n2 2 8 12\\n3 8 23 10\\n2 1 10 5\\n7 1 19 5\\n1 8 3 10\\n1 5 3 9\\n1 2 3 4\\n1 2 3 4\\n4 2 12 16\\n8 5 12 9\\n\", \"2... | Edo has got a collection of n refrigerator magnets!
He decided to buy a refrigerator and hang the magnets on the door. The shop can make the refrigerator with any size of the door that meets the following restrictions: the refrigerator door must be rectangle, and both the length and the width of the door must be posit... | 0 |
{"tests": "{\"inputs\": [\"4 5 9\\n2 3 4 5\\n\", \"3 3 4\\n1 2 4\\n\", \"100 8883 915\\n1599 4666 663 3646 754 2113 2200 3884 4082 1640 3795 2564 2711 2766 1122 4525 1779 2678 2816 2182 1028 2337 4918 1273 4141 217 2682 1756 309 4744 915 1351 3302 1367 3046 4032 4503 711 2860 890 2443 4819 4169 4721 3472 2900 239 3551 ... | Little X has n distinct integers: p_1, p_2, ..., p_{n}. He wants to divide all of them into two sets A and B. The following two conditions must be satisfied: If number x belongs to set A, then number a - x must also belong to set A. If number x belongs to set B, then number b - x must also belong to set B.
Help Lit... | 0 |
{"tests": "{\"inputs\": [\"2\\n1 1\\n\", \"2\\n1 2\\n\", \"5\\n0 0 0 0 35\\n\", \"5\\n8 4 2 0 1\\n\", \"5\\n24348 15401 19543 206086 34622\\n\", \"10\\n7758 19921 15137 1138 90104 17467 82544 55151 3999 6781\\n\", \"2\\n0 1\\n\", \"2\\n184931 115069\\n\", \"100\\n9 0 2 8 3 6 55 1 11 12 3 8 32 18 38 16 0 27 6 3 3 4 25 2... | Slime and his $n$ friends are at a party. Slime has designed a game for his friends to play.
At the beginning of the game, the $i$-th player has $a_i$ biscuits. At each second, Slime will choose a biscuit randomly uniformly among all $a_1 + a_2 + \ldots + a_n$ biscuits, and the owner of this biscuit will give it to a ... | 0 |
{"tests": "{\"inputs\": [\"4 5\\n1 2 3 1\\n2 1 2 8\\n2 3 4 7\\n1 1 3 3\\n2 3 4 8\\n\", \"4 5\\n1 2 3 1\\n2 1 2 8\\n2 3 4 7\\n1 1 3 3\\n2 3 4 13\\n\", \"1 4\\n1 1 1 2\\n2 1 1 6\\n1 1 1 1\\n2 1 1 7\\n\", \"1 4\\n1 1 1 2\\n2 1 1 6\\n1 1 1 1\\n2 1 1 8\\n\", \"1 2\\n2 1 1 8\\n2 1 1 7\\n\", \"1 2\\n2 1 1 10\\n2 1 1 5\\n\", \... | Levko loves array a_1, a_2, ... , a_{n}, consisting of integers, very much. That is why Levko is playing with array a, performing all sorts of operations with it. Each operation Levko performs is of one of two types:
Increase all elements from l_{i} to r_{i} by d_{i}. In other words, perform assignments a_{j} = a_{j... | 0 |
{"tests": "{\"inputs\": [\"3\\n2 1\\n1 0\\n0 1\\n\", \"5\\n0 0\\n0 1\\n0 2\\n0 3\\n0 4\\n\", \"10\\n-1 2\\n-3 0\\n5 5\\n4 4\\n-2 1\\n1 1\\n3 3\\n2 2\\n0 0\\n-1000000000 0\\n\", \"10\\n-678318184 2\\n-678318182 3\\n580731357 2\\n-678318182 1\\n-678318184 1\\n-678318183 0\\n-678318181 2\\n580731357 1\\n580731358 0\\n-678... | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 0 |
{"tests": "{\"inputs\": [\"3\\n| 3\\n^ 2\\n| 1\\n\", \"3\\n& 1\\n& 3\\n& 5\\n\", \"3\\n^ 1\\n^ 2\\n^ 3\\n\", \"2\\n| 999\\n^ 689\\n\", \"3\\n& 242\\n^ 506\\n^ 522\\n\", \"2\\n| 56\\n^ 875\\n\", \"3\\n^ 125\\n^ 377\\n& 1019\\n\", \"1\\n& 123\\n\", \"1\\n| 123\\n\", \"1\\n^ 123\\n\", \"10\\n^ 218\\n& 150\\n| 935\\n& 61\\... | Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | 0 |
{"tests": "{\"inputs\": [\"5 4\\n1 2\\n2 3\\n3 4\\n4 5\\n1 3 2\\n3 5 2\\n\", \"5 4\\n1 2\\n2 3\\n3 4\\n4 5\\n1 3 2\\n2 4 2\\n\", \"5 4\\n1 2\\n2 3\\n3 4\\n4 5\\n1 3 2\\n3 5 1\\n\", \"9 9\\n1 2\\n2 3\\n2 4\\n4 5\\n5 7\\n5 6\\n3 8\\n8 9\\n9 6\\n1 7 4\\n3 6 3\\n\", \"9 9\\n1 2\\n2 3\\n2 4\\n4 5\\n5 7\\n5 6\\n3 8\\n8 9\\n9... | In some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numbered with integers from 1 to n. If cities a and b are connected by a road, then in an hour you can go along this road either from city a to city b, or from city b to city a. The road network is such that from any ... | 0 |
{"tests": "{\"inputs\": [\"())(())(())(\\n7\\n1 1\\n2 3\\n1 2\\n1 12\\n8 12\\n5 11\\n2 10\\n\", \"(((((()((((((((((()((()(((((\\n1\\n8 15\\n\", \"((()((())(((((((((()(()(()(((((((((((((((()(()((((((((((((((()(((((((((((((((((((()(((\\n39\\n28 56\\n39 46\\n57 63\\n29 48\\n51 75\\n14 72\\n5 70\\n51 73\\n10 64\\n31 56\\n5... | Sereja has a bracket sequence s_1, s_2, ..., s_{n}, or, in other words, a string s of length n, consisting of characters "(" and ")".
Sereja needs to answer m queries, each of them is described by two integers l_{i}, r_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n). The answer to the i-th query is the length of the maximum correct brack... | 0.125 |
{"tests": "{\"inputs\": [\"5\\n1 3 2 5 4\\n\", \"4\\n4 3 2 1\\n\", \"4\\n10 30 50 101\\n\", \"1\\n1\\n\", \"1\\n200000\\n\", \"2\\n1 2\\n\", \"2\\n2 1\\n\", \"2\\n1 200000\\n\", \"2\\n200000 1\\n\", \"10\\n71550121 446173607 640274071 402690754 802030518 598196518 796619138 96204862 983359971 799843967\\n\", \"3\\n1 10... | Ivan has an array consisting of n different integers. He decided to reorder all elements in increasing order. Ivan loves merge sort so he decided to represent his array with one or several increasing sequences which he then plans to merge into one sorted array.
Ivan represent his array with increasing sequences with h... | 0.5 |
{"tests": "{\"inputs\": [\"4\\n1 2 1\\n2 3 2\\n3 4 3\\n1\\n1\\n1\\n1\\n\", \"4\\n1 2 1\\n2 3 2\\n3 4 3\\n4\\n4\\n4\\n4\\n\", \"10\\n2 1 8760\\n3 1 3705\\n4 1 1862\\n5 2 7332\\n6 3 7015\\n7 5 4866\\n8 3 4465\\n9 7 8886\\n10 3 9362\\n2\\n5\\n5\\n4\\n4\\n5\\n4\\n5\\n1\\n2\\n\", \"10\\n2 1 5297\\n3 2 7674\\n4 1 1935\\n5 2 ... | DZY loves planting, and he enjoys solving tree problems.
DZY has a weighted tree (connected undirected graph without cycles) containing n nodes (they are numbered from 1 to n). He defines the function g(x, y) (1 ≤ x, y ≤ n) as the longest edge in the shortest path between nodes x and y. Specially g(z, z) = 0 for every... | 0 |
{"tests": "{\"inputs\": [\"3 2\\n\", \"3 1\\n\", \"5 2\\n\", \"5 4\\n\", \"10 4\\n\", \"10 3\\n\", \"10 9\\n\", \"2 1\\n\", \"4 1\\n\", \"4 2\\n\", \"9 8\\n\", \"7 5\\n\"], \"outputs\": [\"1 3 2\\n\", \"1 2 3\\n\", \"1 3 2 4 5\\n\", \"1 5 2 4 3\\n\", \"1 10 2 9 8 7 6 5 4 3\\n\", \"1 10 2 3 4 5 6 7 8 9\\n\", \"1 10 2 9 ... | Permutation p is an ordered set of integers p_1, p_2, ..., p_{n}, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p_1, p_2, ..., p_{n}.
Your task is to find such permutation p of length n, that the group of numbers |p_1 - p_2|, |p_2 - p_3|, ..., |p_... | 0 |
{"tests": "{\"inputs\": [\"4\\n7 5 5 7\\n\", \"5\\n7 8 8 10 12\\n\", \"10\\n3 9 5 5 1 7 5 3 8 7\\n\", \"12\\n8 10 4 6 6 4 1 2 2 6 9 5\\n\", \"7\\n765898 894083 551320 290139 300748 299067 592728\\n\", \"13\\n987069 989619 960831 976342 972924 961800 954209 956033 998067 984513 977987 963504 985482\\n\", \"1\\n12345\\n\... | There are $n$ water tanks in a row, $i$-th of them contains $a_i$ liters of water. The tanks are numbered from $1$ to $n$ from left to right.
You can perform the following operation: choose some subsegment $[l, r]$ ($1\le l \le r \le n$), and redistribute water in tanks $l, l+1, \dots, r$ evenly. In other words, repla... | 0 |
{"tests": "{\"inputs\": [\"6 11\\n1 3\\n1 4\\n1 5\\n1 6\\n2 3\\n2 4\\n2 5\\n2 6\\n3 4\\n3 5\\n3 6\\n\", \"3 0\\n\", \"2 0\\n\", \"1 0\\n\", \"2 1\\n1 2\\n\", \"4 2\\n3 2\\n1 4\\n\", \"3 3\\n1 2\\n3 1\\n2 3\\n\", \"7 5\\n7 5\\n1 5\\n3 2\\n2 6\\n3 6\\n\", \"10 10\\n1 5\\n1 8\\n1 9\\n5 8\\n8 9\\n4 7\\n2 3\\n3 10\\n2 6\\n2... | Ujan has a lot of useless stuff in his drawers, a considerable part of which are his math notebooks: it is time to sort them out. This time he found an old dusty graph theory notebook with a description of a graph.
It is an undirected weighted graph on $n$ vertices. It is a complete graph: each pair of vertices is con... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 1 2 3 3\\n\", \"4\\n0 1 2 3\\n\", \"1\\n120287\\n\", \"2\\n28288 0\\n\", \"2\\n95745 95745\\n\", \"13\\n92 194 580495 0 10855 41704 13 96429 33 213 0 92 140599\\n\", \"13\\n688743 688743 1975 688743 688743 688743 688743 688743 688743 0 0 688743 688743\\n\", \"35\\n0 0 0 0 0 0 0 0 0 0 0 ... | Recently, Duff has been practicing weight lifting. As a hard practice, Malek gave her a task. He gave her a sequence of weights. Weight of i-th of them is 2^{w}_{i} pounds. In each step, Duff can lift some of the remaining weights and throw them away. She does this until there's no more weight left. Malek asked her to ... | 0.875 |
{"tests": "{\"inputs\": [\"4\\n0 1 3 2\\n\", \"9\\n10 7 9 10 7 5 5 3 5\\n\", \"3\\n8 10 3\\n\", \"5\\n1000000000 1000000000 1000000000 0 0\\n\", \"1\\n0\\n\", \"3\\n2 24 18\\n\", \"7\\n23 18 5 10 29 33 36\\n\", \"19\\n1 32 25 40 18 32 5 23 38 1 35 24 39 26 0 9 26 37 0\\n\", \"96\\n79 50 37 49 30 58 90 41 77 73 31 10 8 ... | You are given an array $a$ consisting of $n$ non-negative integers. You have to choose a non-negative integer $x$ and form a new array $b$ of size $n$ according to the following rule: for all $i$ from $1$ to $n$, $b_i = a_i \oplus x$ ($\oplus$ denotes the operation bitwise XOR).
An inversion in the $b$ array is a pair... | 0.125 |
{"tests": "{\"inputs\": [\"2\\n1 2\\n\", \"5\\n3 5 2 4 1\\n\", \"16\\n6 15 3 8 7 11 9 10 2 13 4 14 1 16 5 12\\n\", \"9\\n1 7 8 5 3 4 6 9 2\\n\", \"5\\n2 3 4 5 1\\n\", \"9\\n4 1 8 6 7 5 2 9 3\\n\", \"10\\n3 4 1 5 7 9 8 10 6 2\\n\", \"13\\n3 1 11 12 4 5 8 10 13 7 9 2 6\\n\", \"10\\n8 4 1 7 6 10 9 5 3 2\\n\", \"2\\n2 1\\n... | Jeff has become friends with Furik. Now these two are going to play one quite amusing game.
At the beginning of the game Jeff takes a piece of paper and writes down a permutation consisting of n numbers: p_1, p_2, ..., p_{n}. Then the guys take turns to make moves, Jeff moves first. During his move, Jeff chooses two a... | 0 |
{"tests": "{\"inputs\": [\"1 0\\n1\\n\", \"2 1\\n1 2\\n1 2 1\\n\", \"5 6\\n13 56 73 98 17\\n1 2 56\\n1 3 29\\n1 4 42\\n2 3 95\\n2 4 88\\n3 4 63\\n\", \"1 0\\n734135\\n\", \"10 10\\n132402 148489 472187 403302 657890 205188 750668 276911 372190 828796\\n8 10 162\\n1 8 489\\n6 7 279\\n1 10 740\\n5 6 721\\n3 6 862\\n2 3 1... | DZY loves Physics, and he enjoys calculating density.
Almost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph have some values) as follows: $\left\{\begin{array}{ll}{\frac{v}{e}} & {(e > 0)} \\{0} & {(e = 0)} \end{array} \right.$ where v is the sum of th... | 0 |
{"tests": "{\"inputs\": [\"4 4 3\\n1 2 2\\n2 4 1\\n1 3 1\\n3 4 2\\n\", \"5 11 23\\n1 2 3\\n2 3 4\\n3 4 5\\n4 5 6\\n1 3 4\\n2 4 5\\n3 5 6\\n1 4 2\\n2 5 3\\n1 5 2\\n3 2 30\\n\", \"10 16 63\\n1 2 1\\n2 10 1\\n1 3 1\\n3 10 1\\n1 4 1\\n4 10 1\\n1 5 1\\n5 10 1\\n1 6 1\\n6 10 1\\n1 7 1\\n7 10 1\\n1 8 1\\n8 10 1\\n1 9 1\\n9 10... | Niwel is a little golden bear. As everyone knows, bears live in forests, but Niwel got tired of seeing all the trees so he decided to move to the city.
In the city, Niwel took on a job managing bears to deliver goods. The city that he lives in can be represented as a directed graph with n nodes and m edges. Each edge ... | 0.125 |
{"tests": "{\"inputs\": [\"8 10 8\\n1 1 10\\n1 4 13\\n1 7 1\\n1 8 2\\n2 2 0\\n2 5 14\\n2 6 0\\n2 6 1\\n\", \"3 2 3\\n1 1 2\\n2 1 1\\n1 1 5\\n\", \"1 10 10\\n1 8 1\\n\", \"3 4 5\\n1 3 9\\n2 1 9\\n1 2 8\\n\", \"10 500 500\\n2 88 59\\n2 470 441\\n1 340 500\\n2 326 297\\n1 74 45\\n1 302 273\\n1 132 103\\n2 388 359\\n1 97 6... | Wherever the destination is, whoever we meet, let's render this song together.
On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no collisions will happen before one enters the stage.
On the sides of t... | 0 |
{"tests": "{\"inputs\": [\"3 0\\n\", \"4 4\\n1 2 1\\n2 3 1\\n3 4 0\\n4 1 0\\n\", \"4 4\\n1 2 1\\n2 3 1\\n3 4 0\\n4 1 1\\n\", \"100000 0\\n\", \"100 3\\n1 2 0\\n2 3 0\\n3 1 0\\n\", \"9 2\\n1 2 0\\n2 3 0\\n\", \"28567 13\\n28079 24675 1\\n18409 26720 1\\n980 10815 1\\n20794 16571 1\\n7376 19861 1\\n11146 706 1\\n4255 163... | There are many anime that are about "love triangles": Alice loves Bob, and Charlie loves Bob as well, but Alice hates Charlie. You are thinking about an anime which has n characters. The characters are labeled from 1 to n. Every pair of two characters can either mutually love each other or mutually hate each other (the... | 0 |
{"tests": "{\"inputs\": [\"5 7\\n2 4\\n5 1\\n2 3\\n3 4\\n4 1\\n5 3\\n3 5\\n\", \"2 3\\n1 2\\n1 2\\n1 2\\n\", \"5 3\\n2 4\\n5 4\\n3 2\\n\", \"10 3\\n3 4\\n1 3\\n5 2\\n\", \"20 5\\n3 12\\n5 20\\n16 4\\n13 3\\n9 14\\n\", \"50 20\\n4 18\\n39 33\\n49 32\\n7 32\\n38 1\\n46 11\\n8 1\\n3 31\\n30 47\\n24 16\\n33 5\\n5 21\\n3 48... | Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one station at a time and travels around the network of stations in a circular manner. More precisely, the immediate station that the train will visi... | 0.125 |
{"tests": "{\"inputs\": [\"3\\n-1 -1 -1\\n\", \"2\\n2 -1\\n\", \"40\\n3 3 -1 -1 4 4 -1 -1 -1 -1 -1 10 10 10 10 10 10 4 20 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 3 3 3 3 3 3 3 3\\n\", \"8\\n-1 3 -1 -1 -1 3 -1 -1\\n\", \"10\\n3 -1 -1 -1 -1 -1 -1 -1 2 2\\n\", \"50\\n36 36 45 44 -1 -1 13 -1 36 -1 44 36 -1 -1 -1 35 -1 36 36... | There are $n$ startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup.
The following steps happe... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 2\\n1 3\\n2 4\\n\", \"4\\n1 2\\n1 3\\n1 4\\n\", \"6\\n2 1\\n3 2\\n4 1\\n5 4\\n1 6\\n\", \"2\\n2 1\\n\", \"3\\n1 2\\n3 2\\n\", \"5\\n3 5\\n4 3\\n2 4\\n1 2\\n\", \"6\\n4 6\\n1 5\\n5 4\\n5 3\\n2 4\\n\", \"7\\n2 7\\n2 6\\n4 7\\n7 3\\n7 5\\n1 7\\n\", \"8\\n4 5\\n1 2\\n6 3\\n2 3\\n2 8\\n4 7\\... | Nauuo is a girl who loves drawing circles.
One day she has drawn a circle and wanted to draw a tree on it.
The tree is a connected undirected graph consisting of $n$ nodes and $n-1$ edges. The nodes are numbered from $1$ to $n$.
Nauuo wants to draw a tree on the circle, the nodes of the tree should be in $n$ distinc... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 1 1 1\\n1 -1 -1 -1 -1\\n\", \"5\\n1 2 3 1\\n1 -1 2 -1 -1\\n\", \"3\\n1 2\\n2 -1 1\\n\", \"2\\n1\\n0 -1\\n\", \"2\\n1\\n1 -1\\n\", \"5\\n1 2 2 3\\n1 -1 2 3 -1\\n\", \"5\\n1 2 3 4\\n5 -1 5 -1 7\\n\", \"10\\n1 1 1 1 2 3 4 5 1\\n3 -1 -1 -1 -1 3 3 3 3 -1\\n\", \"10\\n1 1 2 4 4 5 6 3 3\\n0 -1... | Mitya has a rooted tree with $n$ vertices indexed from $1$ to $n$, where the root has index $1$. Each vertex $v$ initially had an integer number $a_v \ge 0$ written on it. For every vertex $v$ Mitya has computed $s_v$: the sum of all values written on the vertices on the path from vertex $v$ to the root, as well as $h_... | 0 |
{"tests": "{\"inputs\": [\"7\\nNNESWW\\nSWSWSW\\n\", \"3\\nNN\\nSS\\n\", \"3\\nES\\nNW\\n\", \"5\\nWSSE\\nWNNE\\n\", \"2\\nE\\nE\\n\", \"2\\nW\\nS\\n\", \"2\\nS\\nN\\n\", \"100\\nWNWWSWWSESWWWSSSSWSSEENWNWWWWNNENESWSESSENEENNWWWWWSSWSWSENESWNEENESWWNNEESESWSEEENWWNWNNWWNNWWWWSW\\nEESEESSENWNWWWNWWNWWNWWSWNNWNWNWSWNNEEN... | In the spirit of the holidays, Saitama has given Genos two grid paths of length n (a weird gift even by Saitama's standards). A grid path is an ordered sequence of neighbouring squares in an infinite grid. Two squares are neighbouring if they share a side.
One example of a grid path is (0, 0) → (0, 1) → (0, 2) → (1, 2... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 3 1 0\\n\", \"2\\n4 4\\n\", \"5\\n5 4 3 2 1\\n\", \"10\\n3 3 3 5 6 9 3 1 7 3\\n\", \"100\\n57 5 28 44 99 10 66 93 76 32 67 92 67 81 33 3 6 6 67 10 41 72 5 71 27 22 21 54 21 59 36 62 43 39 28 49 55 65 21 73 87 40 0 62 67 59 40 18 56 71 15 97 73 73 2 61 54 44 6 52 25 34 13 20 18 13 25 51 ... | While discussing a proper problem A for a Codeforces Round, Kostya created a cyclic array of positive integers $a_1, a_2, \ldots, a_n$. Since the talk was long and not promising, Kostya created a new cyclic array $b_1, b_2, \ldots, b_{n}$ so that $b_i = (a_i \mod a_{i + 1})$, where we take $a_{n+1} = a_1$. Here $mod$ i... | 0 |
{"tests": "{\"inputs\": [\"3\\n2 0\\n0 2\\n2 0\\n\", \"5\\n0 1\\n1 3\\n2 1\\n3 0\\n2 0\\n\", \"1\\n0 0\\n\", \"2\\n0 1\\n1 0\\n\", \"2\\n2 0\\n0 0\\n\", \"2\\n2 1\\n0 1\\n\", \"3\\n0 0\\n1 0\\n1 0\\n\", \"3\\n0 1\\n3 0\\n1 0\\n\", \"3\\n3 1\\n1 0\\n0 1\\n\", \"3\\n2 1\\n0 0\\n1 1\\n\"], \"outputs\": [\"YES\\n1 3 2 \\n\... | Evlampiy was gifted a rooted tree. The vertices of the tree are numbered from $1$ to $n$. Each of its vertices also has an integer $a_i$ written on it. For each vertex $i$, Evlampiy calculated $c_i$ — the number of vertices $j$ in the subtree of vertex $i$, such that $a_j < a_i$. [Image]Illustration for the second exam... | 0 |
{"tests": "{\"inputs\": [\"4\\n3 1 7 4\\n2 3 2\\n2 8 5\\n1 10\\n\", \"2\\n2 3 -2\\n2 -1 5\\n\", \"2\\n2 -10 10\\n2 0 -20\\n\", \"1\\n1 0\\n\", \"3\\n1 20\\n2 30 40\\n3 50 60 80\\n\", \"3\\n3 1 3 100\\n2 4 104\\n2 2 102\\n\", \"4\\n3 80 1 10\\n3 52 19 24\\n3 27 46 29\\n3 74 13 25\\n\", \"2\\n5 -1000000000 999999999 -999... | Ujan has a lot of numbers in his boxes. He likes order and balance, so he decided to reorder the numbers.
There are $k$ boxes numbered from $1$ to $k$. The $i$-th box contains $n_i$ integer numbers. The integers can be negative. All of the integers are distinct.
Ujan is lazy, so he will do the following reordering o... | 0 |
{"tests": "{\"inputs\": [\"4 1 3 4 3\\n3 2 5 1\\n\", \"4 2 4 4 1\\n4 5 1 2\\n\", \"2 2 5 7 3\\n4 5\\n\", \"100 4 8 9 1\\n1 8 1 8 7 8 1 8 10 4 7 7 3 2 6 7 3 7 3 7 1 8 5 7 4 10 9 7 3 4 7 7 4 9 6 10 4 5 5 2 5 3 9 2 8 3 7 8 8 8 10 4 7 2 3 6 2 8 9 9 7 4 8 6 5 8 5 2 5 10 3 6 2 8 1 3 3 7 6 1 5 8 9 9 2 2 9 3 7 3 3 3 10 10 3 5 ... | Ziota found a video game called "Monster Invaders".
Similar to every other shooting RPG game, "Monster Invaders" involves killing monsters and bosses with guns.
For the sake of simplicity, we only consider two different types of monsters and three different types of guns.
Namely, the two types of monsters are: a n... | 0 |
{"tests": "{\"inputs\": [\"5\\n11011\\n3\\n1 3 3\\n1 4 2\\n1 2 3\\n\", \"1\\n0\\n1\\n1 1 1\\n\", \"3\\n010\\n3\\n1 3 1\\n1 3 1\\n3 2 1\\n\", \"10\\n0100001001\\n10\\n2 5 4\\n10 2 1\\n5 3 5\\n2 9 2\\n5 3 1\\n3 3 3\\n9 8 1\\n5 3 1\\n9 5 2\\n2 3 6\\n\", \"5\\n00010\\n5\\n5 3 1\\n2 1 2\\n4 1 1\\n3 1 3\\n2 1 3\\n\", \"50\\n... | In this problem, we will deal with binary strings. Each character of a binary string is either a 0 or a 1. We will also deal with substrings; recall that a substring is a contiguous subsequence of a string. We denote the substring of string $s$ starting from the $l$-th character and ending with the $r$-th character as ... | 0 |
{"tests": "{\"inputs\": [\"3\\n\", \"5\\n\", \"4\\n\", \"5\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"10\\n\", \"11\\n\"], \"outputs\": [\"2\\n3 1 2 3\\n3 1 2 3\\n\", \"6\\n3 1 2 3\\n3 2 3 4\\n3 3 4 5\\n3 4 5 1\\n4 2 1 3 5\\n4 5 1 4 2\\n\", \"4\\n3 4 1 2\\n3 2 3 4\\n3 1 2 3\\n3 3 4 1\\n\", \"6\\n3 1 2 3\\n3 2 3 4\... | In order to fly to the Moon Mister B just needs to solve the following problem.
There is a complete indirected graph with n vertices. You need to cover it with several simple cycles of length 3 and 4 so that each edge is in exactly 2 cycles.
We are sure that Mister B will solve the problem soon and will fly to the Mo... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n100 100 100\\n100 1 100\\n100 100 100\\n\", \"4 5\\n87882 40786 3691 85313 46694\\n28884 16067 3242 97367 78518\\n4250 35501 9780 14435 19004\\n64673 65438 56977 64495 27280\\n\", \"3 3\\n3 1 2\\n3 2 0\\n2 3 2\\n\", \"3 3\\n1 10 1\\n1 10 1\\n1 10 1\\n\", \"3 3\\n0 0 0\\n0 10000 0\\n0 0 ... | Summer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the beach. The gym where they go is a matrix a with n lines and m columns. Let number a[i][j] represents the calories burned by performing workout at the cell of gym in the i-th line and the j-th column.
Iahub starts with ... | 0 |
{"tests": "{\"inputs\": [\"8\\n0 0 5 3\\n2 -1 5 0\\n-3 -4 2 -1\\n-1 -1 2 0\\n-3 0 0 5\\n5 2 10 3\\n7 -3 10 2\\n4 -2 7 -1\\n\", \"1\\n0 0 1 1\\n\", \"4\\n0 0 1 1\\n1 0 2 1\\n1 1 2 2\\n0 1 1 2\\n\", \"3\\n0 0 1 3\\n1 0 4 1\\n1 1 2 2\\n\", \"6\\n0 1 1 4\\n0 4 1 7\\n1 0 2 3\\n1 3 2 4\\n1 4 2 5\\n2 3 3 4\\n\", \"25\\n0 0 7 ... | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 2 3 4 5\\n\", \"6\\n15 14 3 13 1 12\\n\", \"6\\n9 7 13 17 5 11\\n\", \"10\\n18 14 19 17 11 7 20 10 4 12\\n\", \"100\\n713 716 230 416 3 2 597 216 779 839 13 156 723 793 168 368 232 316 98 257 170 27 746 9 616 147 792 890 796 362 852 117 993 556 885 73 131 475 121 753 508 158 473 931 527... | You are given a set Y of n distinct positive integers y_1, y_2, ..., y_{n}.
Set X of n distinct positive integers x_1, x_2, ..., x_{n} is said to generate set Y if one can transform X to Y by applying some number of the following two operation to integers in X: Take any integer x_{i} and multiply it by two, i.e. repl... | 0 |
{"tests": "{\"inputs\": [\"7\\n\", \"6\\n\", \"7137\\n\", \"1941\\n\", \"55004\\n\", \"1\\n\", \"2\\n\", \"3\\n\", \"4\\n\", \"5\\n\"], \"outputs\": [\"YES\\n1\\n2\\n5\\n6\\n3\\n4\\n7\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n1\\n\", \"YES\\n1\\n2\\n\", \"YES\\n1\\n2\\n3\\n\", \"YES\\n1\\n3\\n2\\n4\", \... | Consider a sequence [a_1, a_2, ... , a_{n}]. Define its prefix product sequence $[ a_{1} \operatorname{mod} n,(a_{1} a_{2}) \operatorname{mod} n, \cdots,(a_{1} a_{2} \cdots a_{n}) \operatorname{mod} n ]$.
Now given n, find a permutation of [1, 2, ..., n], such that its prefix product sequence is a permutation of [0, 1... | 0 |
{"tests": "{\"inputs\": [\"3 1 5\\n3 2 5\\n2 4 2\\n1 2\\n\", \"4 2 11\\n2 4 6 6\\n6 4 2 1\\n1 2\\n2 3\\n\", \"10 5 100\\n70 67 8 64 28 82 18 61 82 7\\n596434 595982 237932 275698 361351 850374 936914 877996 789231 331012\\n1 7\\n2 4\\n3 6\\n5 7\\n1 5\\n\", \"10 5 100\\n64 90 3 94 96 97 52 54 82 31\\n796554 444893 21435... | Just to remind, girls in Arpa's land are really nice.
Mehrdad wants to invite some Hoses to the palace for a dancing party. Each Hos has some weight w_{i} and some beauty b_{i}. Also each Hos may have some friends. Hoses are divided in some friendship groups. Two Hoses x and y are in the same friendship group if and o... | 0.375 |
{"tests": "{\"inputs\": [\"4\\n1 2\\n1 3\\n1 4\\n\", \"7\\n1 2\\n1 3\\n2 4\\n2 5\\n3 6\\n3 7\\n\", \"1\\n\", \"10\\n9 8\\n7 4\\n10 7\\n6 7\\n1 9\\n4 9\\n9 3\\n2 3\\n1 5\\n\", \"20\\n13 11\\n4 12\\n17 16\\n15 19\\n16 6\\n7 6\\n6 8\\n12 2\\n19 20\\n1 8\\n4 17\\n18 12\\n9 5\\n14 13\\n11 15\\n1 19\\n3 13\\n4 9\\n15 10\\n\"... | Consider a tree $T$ (that is, a connected graph without cycles) with $n$ vertices labelled $1$ through $n$. We start the following process with $T$: while $T$ has more than one vertex, do the following:
choose a random edge of $T$ equiprobably;
shrink the chosen edge: if the edge was connecting vertices $v$ and $... | 0 |
{"tests": "{\"inputs\": [\"000\\n\", \"0101\\n\", \"0001111\\n\", \"00101100011100\\n\", \"0\\n\", \"11\\n\", \"01011111111101101100000100000000100000111001011011110110110010010001011110100011000011100100010001\\n\", \"01001111001001010011011110010111010110011111001101111011100010010101111000100111000110111011110101111... | Koa the Koala has a binary string $s$ of length $n$. Koa can perform no more than $n-1$ (possibly zero) operations of the following form:
In one operation Koa selects positions $i$ and $i+1$ for some $i$ with $1 \le i < |s|$ and sets $s_i$ to $max(s_i, s_{i+1})$. Then Koa deletes position $i+1$ from $s$ (after the rem... | 0 |
{"tests": "{\"inputs\": [\"5\\n2 3 2\\n3 1 2 3\\n\", \"8\\n4 6 2 3 4\\n2 3 6\\n\", \"10\\n3 4 7 5\\n2 8 5\\n\", \"17\\n1 10\\n1 12\\n\", \"23\\n1 20\\n3 9 2 12\\n\", \"2\\n1 1\\n1 1\\n\", \"2\\n1 1\\n1 1\\n\", \"3\\n1 1\\n1 2\\n\", \"20\\n1 1\\n1 11\\n\"], \"outputs\": [\"Lose Win Win Loop\\nLoop Win Win Win\\n\", \"Wi... | Rick and Morty are playing their own version of Berzerk (which has nothing in common with the famous Berzerk game). This game needs a huge space, so they play it with a computer.
In this game there are n objects numbered from 1 to n arranged in a circle (in clockwise order). Object number 1 is a black hole and the oth... | 0 |
{"tests": "{\"inputs\": [\"10 4\\n1 5 2 9 1 3 4 2 1 7\\n2 4\\n3 8\\n7 10\\n1 9\\n\", \"7 6\\n5 7 7 4 6 6 2\\n1 2\\n2 3\\n2 6\\n1 7\\n4 7\\n3 5\\n\", \"2 2\\n0 0\\n1 2\\n1 2\\n\", \"2 2\\n0 100000000\\n1 2\\n1 2\\n\", \"4 6\\n1 2 3 2\\n1 2\\n1 3\\n1 4\\n2 3\\n2 4\\n3 4\\n\", \"3 6\\n10 20 30\\n1 2\\n1 3\\n2 3\\n1 2\\n2 ... | A function $f : R \rightarrow R$ is called Lipschitz continuous if there is a real constant K such that the inequality |f(x) - f(y)| ≤ K·|x - y| holds for all $x, y \in R$. We'll deal with a more... discrete version of this term.
For an array $h [ 1 . . n ]$, we define it's Lipschitz constant $L(h)$ as follows: if n ... | 0.125 |
{"tests": "{\"inputs\": [\"3 6\\n5 3 1\\n\", \"1 4\\n19\\n\", \"1 3\\n1000000\\n\", \"1 1\\n1\\n\", \"10 23\\n343 984 238 758983 231 74 231 548 893 543\\n\", \"20 40\\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\\n\", \"29 99047\\n206580 305496 61753 908376 272137 803885 675070 665109 995787 667887 164508 634877 994427 270... | There are some rabbits in Singapore Zoo. To feed them, Zookeeper bought $n$ carrots with lengths $a_1, a_2, a_3, \ldots, a_n$. However, rabbits are very fertile and multiply very quickly. Zookeeper now has $k$ rabbits and does not have enough carrots to feed all of them. To solve this problem, Zookeeper decided to cut ... | 0 |
{"tests": "{\"inputs\": [\"7 4\\n1 3\\n1 2\\n2 0 1\\n2 1 2\\n\", \"10 9\\n2 2 9\\n1 1\\n2 0 1\\n1 8\\n2 0 8\\n1 2\\n2 1 3\\n1 4\\n2 2 4\\n\", \"10 5\\n2 1 9\\n2 4 10\\n1 1\\n2 0 1\\n2 0 1\\n\", \"10 5\\n1 8\\n1 1\\n1 1\\n1 3\\n1 2\\n\", \"10 10\\n2 5 9\\n2 2 9\\n2 1 7\\n2 3 9\\n2 3 4\\n2 0 6\\n2 3 9\\n2 2 8\\n2 5 9\\n1... | Appleman has a very big sheet of paper. This sheet has a form of rectangle with dimensions 1 × n. Your task is help Appleman with folding of such a sheet. Actually, you need to perform q queries. Each query will have one of the following types: Fold the sheet of paper at position p_{i}. After this query the leftmost p... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.