problem_id
stringlengths
16
16
statement
stringlengths
29
9.15k
tests_json
stringlengths
70
5.27M
time_limit_s
float64
1
10
origin_json
stringlengths
82
233
16b13af8e9dfdb57
You are given two strings $s$ and $t$ both of length $n$ and both consisting of lowercase Latin letters. In one move, you can choose any length $len$ from $1$ to $n$ and perform the following operation: Choose any contiguous substring of the string $s$ of length $len$ and reverse it; at the same time choose any con...
[["4\n4\nabcd\nabdc\n5\nababa\nbaaba\n4\nasdf\nasdg\n4\nabcd\nbadc\n", "NO\nYES\nNO\nYES\n"], ["4\n4\nabcd\nabdc\n5\nababa\nbaaba\n4\nasdf\nasdg\n4\nabdd\nbadc\n", "NO\nYES\nNO\nNO\n"], ["4\n4\nabcd\nabdc\n5\nababa\nabaab\n4\nasdf\nasdg\n4\nabcd\nbadc\n", "NO\nYES\nNO\nYES\n"], ["4\n4\nabcd\nabdc\n5\naaabc\nbabaa\n4\nf...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#596"}
16bc509a56db31e9
You are given an array $a$, consisting of $n$ positive integers. Let's call a concatenation of numbers $x$ and $y$ the number that is obtained by writing down numbers $x$ and $y$ one right after another without changing the order. For example, a concatenation of numbers $12$ and $3456$ is a number $123456$. Count the...
[["6 11\n45 1 10 12 11 7\n", "7\n"], ["4 2\n2 78 4 10\n", "12\n"], ["5 2\n3 7 19 3 3\n", "0\n"], ["100 2\n38 415 2960 8618 8531 6194 6811 4778 3955 1056 7147 9144 8424 5766 4492 2994 978 1102 2028 3569 8960 6106 9363 7714 5179 7801 4768 9025 6562 4469 5578 5224 6845 362 3229 4769 4191 7895 7490 2200 6215 3458 5037 8201...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#544"}
16dba2583a5cb53e
Of course our child likes walking in a zoo. The zoo has n areas, that are numbered from 1 to n. The i-th area contains ai animals in it. Also there are m roads in the zoo, and each road connects two distinct areas. Naturally the zoo is connected, so you can reach any area of the zoo from any other area using the roads....
[["4 3\n10 20 30 40\n1 3\n2 3\n4 3\n", "16.6666666667\n"], ["7 8\n40 20 10 30 20 50 40\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n1 4\n5 7\n", "18.5714285714\n"], ["3 3\n10 20 30\n1 2\n2 3\n3 1\n", "13.3333333333\n"], ["10 19\n15704 19758 26631 25050 22778 15041 8487 26418 5136 4199\n1 2\n1 3\n1 4\n2 5\n1 6\n2 7\n2 8\n7 9\n6 10\n7...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#1414"}
16ef4cfa2e1201c5
In the 2050 Conference, some people from the competitive programming community meet together and are going to take a photo. The n people form a line. They are numbered from 1 to n from left to right. Each of them either holds a cardboard with the letter 'C' or a cardboard with the letter 'P'. Let C=\\{c_1,c_2,...,c_m\...
[["3\n5\n2 1 2 1 1\n4\n11 2 2 2\n1\n998244353\n", "10\n7\n1\n"], ["3\n5\n1 1 2 1 1\n4\n11 2 2 2\n1\n998244353\n", "9\n7\n1\n"], ["3\n5\n2 2 2 1 1\n4\n11 2 2 2\n1\n998244353\n", "8\n7\n1\n"], ["3\n5\n1 1 1 1 1\n4\n11 2 3 2\n1\n998244353\n", "11\n7\n1\n"], ["3\n5\n1 1 0 1 1\n4\n11 2 2 3\n1\n998244353\n", "6\n7\n1\n"], ["...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1180"}
16fde82e81785548
J - Tree Reconstruction Problem Statement You have a directed graph. Some non-negative value is assigned on each edge of the graph. You know that the value of the graph satisfies the flow conservation law That is, for every node v, the sum of values on edges incoming to v equals to the sum of values of edges outgoing...
[["9 13\n1 2\n1 3\n2 9\n3 4\n3 5\n3 6\n4 9\n5 8\n6 7\n6 8\n7 9\n8 9\n9 1", "5\n"], ["9 13\n1 2\n1 3\n1 9\n1 4\n3 5\n5 6\n4 9\n5 7\n6 7\n8 8\n7 9\n5 9\n9 1", "6\n"], ["9 1\n1 1\n1 3\n1 9\n1 4\n3 5\n5 6\n4 9\n5 7\n6 7\n6 8\n7 9\n5 9\n9 1", "1\n"], ["9 10\n1 2\n1 3\n2 9\n1 4\n3 5\n4 6\n3 9\n5 7\n6 7\n6 8\n7 9\n5 9\n9 1", ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1214"}
171df0dfcceef45e
You like playing chess tournaments online. In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ...
[["8\n5 2\nWLWLL\n6 5\nLLLWWL\n7 1\nLWLWLWL\n15 5\nWWWLLLWWWLLLWWW\n40 7\nLLWLWLWWWLWLLWLWWWLWLLWLLWLLLLWLLWWWLWWL\n1 0\nL\n1 1\nL\n6 1\nWLLWLW\n", "7\n11\n6\n26\n46\n0\n1\n6\n"], ["8\n5 2\nWLWLL\n6 5\nLLLWWL\n7 2\nLWLWLWL\n15 5\nWWWLLLWWWLLLWWW\n40 7\nLLWLWLWWWLWLLWLWWWLWLLWLLWLLLLWLLWWWLWWL\n1 0\nL\n1 1\nL\n6 1\nWLLW...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#284"}
172650f7c813587a
Dreamoon has a string s and a pattern string p. He first removes exactly x characters from s obtaining string s' as a result. Then he calculates <image> that is defined as the maximal number of non-overlapping substrings equal to p that can be found in s'. He wants to make this number as big as possible. More formally...
[["abxxxaxbxaxxxba\naba\n", "0 0 1 1 1 1 2 2 2 2 1 1 1 0 0 0 \n"], ["ababababababababa\naba\n", "4 4 4 4 4 4 3 3 3 2 2 2 1 1 1 0 0 0 \n"], ["aaaaaaaaaaa\nb\n", "0 0 0 0 0 0 0 0 0 0 0 0 \n"], ["a\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1169"}
172924ec82bc294a
Professor GukiZ likes programming contests. He especially likes to rate his students on the contests he prepares. Now, he has decided to prepare a new contest. In total, n students will attend, and before the start, every one of them has some positive integer rating. Students are indexed from 1 to n. Let's denote the...
[["8\n153 100 87 14 10 8 6 5\n", "1 2 3 4 5 6 7 8 "], ["70\n11 54 37 62 1 46 13 17 38 47 28 15 63 5 61 34 49 66 32 59 3 41 58 28 23 62 41 64 20 5 14 41 10 37 51 32 65 46 61 8 15 19 16 44 31 42 19 46 66 25 26 58 60 5 19 18 69 53 20 40 45 27 24 41 32 23 57 56 62 10\n", "62 18 35 7 70 23 61 56 34 22 42 58 6 66 10 37 21 2 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1036"}
172af3fd1195e596
You are given an array $a_1, a_2, \dots, a_n$. You can perform the following operation any number of times: Choose a pair of two neighboring equal elements $a_i = a_{i + 1}$ (if there is at least one such pair). Replace them by one element with value $a_i + 1$. After each such operation, the length of the array wil...
[["5\n4 3 2 2 3\n", "2\n"], ["7\n3 3 4 4 4 3 3\n", "2\n"], ["3\n1 3 5\n", "3\n"], ["1\n1000\n", "1\n"], ["15\n67 67 65 65 66 66 66 68 67 67 67 65 65 66 70\n", "2\n"], ["15\n17 17 18 17 16 16 17 17 15 15 13 12 12 14 15\n", "2\n"], ["20\n10 6 25 38 8 4 22 40 28 45 23 33 18 39 28 26 40 4 14 47\n", "20\n"], ["20\n6 5 5 7 1...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#4"}
172e688621fa5835
Giant chess is quite common in Geraldion. We will not delve into the rules of the game, we'll just say that the game takes place on an h × w field, and it is painted in two colors, but not like in chess. Almost all cells of the field are white and only some of them are black. Currently Gerald is finishing a game of gia...
[["3 4 2\n2 2\n2 3\n", "2\n"], ["1000 1000 4\n50 50\n51 50\n50 51\n51 51\n", "899660737\n"], ["2 2 2\n2 1\n1 2\n", "0\n"], ["100 10 30\n40 4\n15 3\n75 3\n88 10\n32 1\n16 5\n81 8\n45 2\n72 8\n11 6\n86 4\n50 2\n9 4\n11 1\n20 3\n47 3\n2 4\n68 3\n90 5\n85 2\n88 1\n88 5\n86 3\n70 9\n49 3\n34 4\n5 7\n77 5\n50 1\n87 5\n", "40...
2.08
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1489"}
1740d14a635e0e20
There are H rows and W columns of white square cells. You will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns. How many white cells will remain? It can be proved that this count does not depend on what rows and columns are chosen. -----Constraints----- - All v...
[["3 2\n2 1\n", "1\n"], ["5 5\n2 3\n", "6\n"], ["2 4\n2 4\n", "0\n"], ["4 8\n2 3\n", "10\n"], ["3 15\n2 11\n", "4\n"], ["10 18\n7 3\n", "45\n"], ["13 13\n8 10\n", "15\n"], ["20 20\n19 19\n", "1\n"], ["19 19\n5 3\n", "224\n"], ["20 3\n1 3\n", "0\n"], ["15 10\n4 4\n", "66\n"], ["18 6\n13 4\n", "10\n"], ["20 20\n1 1\n", "...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1150"}
1743c22612042eee
Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock. <image> The combination lock is represented by n rotating disks with digits from 0 to 9 written on them. Scrooge McDuck has t...
[["5\n82195\n64723\n", "13\n"], ["1\n9\n2\n", "3\n"], ["1\n7\n9\n", "2\n"], ["125\n23269567683904664184142384849516523616863461607751021071772615078579713054027902974007001544768640273491193035874486891541257\n47635110303703399505805044019026243695451609639556649012447370081552870340011971572363458960190590266459684717...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#2559"}
1746e1ef0b501f8f
A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many applications in science and engineering. Vasya liked the idea of the method very much, and he decided to try it in practi...
[["4\n0 0 1 1\n", "0\n0 0 1 1\n"], ["5\n0 1 0 1 0\n", "2\n0 0 0 0 0\n"], ["3\n1 0 0\n", "0\n1 0 0\n"], ["4\n1 0 0 1\n", "0\n1 0 0 1\n"], ["7\n1 0 1 1 1 0 1\n", "1\n1 1 1 1 1 1 1\n"], ["14\n0 1 0 0 0 1 1 0 1 0 1 0 1 0\n", "3\n0 0 0 0 0 1 1 1 1 1 0 0 0 0\n"], ["3\n1 0 1\n", "1\n1 1 1\n"], ["3\n0 0 1\n", "0\n0 0 1\n"], ["...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00004-of-00005.parquet#1195"}
174e73e815f7c331
In this problem you have to solve a simple classification task: given an image, determine whether it depicts a Fourier doodle. You are given a set of 50 images with ids 1 through 50. You are also given a text file labels.txt containing the labels for images with ids 1 through 20, which comprise the learning data set....
[["0\n", "0\n1\n1\n0\n1\n1\n0\n1\n1\n1\n1\n1\n0\n1\n0\n1\n1\n1\n0\n1\n1\n1\n1\n1\n0\n1\n0\n1\n1\n1\n"], ["-1\n", "0\n1\n1\n0\n1\n1\n0\n1\n1\n1\n1\n1\n0\n1\n0\n1\n1\n1\n0\n1\n1\n1\n1\n1\n0\n1\n0\n1\n1\n1\n"], ["1\n", "0\n1\n1\n0\n1\n1\n0\n1\n1\n1\n1\n1\n0\n1\n0\n1\n1\n1\n0\n1\n1\n1\n1\n1\n0\n1\n0\n1\n1\n1\n"], ["-2\n", ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#839"}
17553655fa3f6b27
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. Constraints * 1 ≤ a,b ≤ 10000 * a and b are integers. Input Input is given from Standard Input in the following format: a b Output If the product is odd, print `Odd`; if it is even, print `Even`. E...
[["3 4", "Even"], ["1 21", "Odd"], ["4 4", "Even\n"], ["1 15", "Odd\n"], ["2 4", "Even\n"], ["2 15", "Even\n"], ["3 0", "Even\n"], ["2 26", "Even\n"], ["3 -1", "Odd\n"], ["2 32", "Even\n"], ["0 -1", "Even\n"], ["1 32", "Even\n"], ["0 -2", "Even\n"], ["1 17", "Odd\n"], ["-1 -2", "Even\n"], ["0 17", "Even\n"], ["-2 -2", ...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00000-of-00005.parquet#2784"}
1756c7ab3c0f980b
Any resemblance to any real championship and sport is accidental. The Berland National team takes part in the local Football championship which now has a group stage. Let's describe the formal rules of the local championship: * the team that kicked most balls in the enemy's goal area wins the game; * the victor...
[["CRWEYDMET BERLAND 6:2\nJ CRWEYDMET 5:4\nLYUTZZCGW BERLAND 8:4\nLYUTZZCGW CRWEYDMET 3:4\nLYUTZZCGW J 2:2\n", "IMPOSSIBLE"], ["AERLAND DERLAND 1:0\nDERLAND CERLAND 0:0\nCERLAND AERLAND 1:0\nAERLAND BERLAND 0:0\nDERLAND BERLAND 1:0\n", "1:0"], ["QHA BERLAND 7:2\nVROOBFARVCFK QHA 5:7\nZLRZXLRDUKGQM BERLAND 9:3\nZLRZXLRD...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#721"}
17617ae9b5e48cfa
The only difference between easy and hard versions is the length of the string. You are given a string $s$ and a string $t$, both consisting only of lowercase Latin letters. It is guaranteed that $t$ can be obtained from $s$ by removing some (possibly, zero) number of characters (not necessary contiguous) from $s$ wit...
[["bbaba\nbb\n", "3\n"], ["baaba\nab\n", "2\n"], ["abcde\nabcde\n", "0\n"], ["asdfasdf\nfasd\n", "3\n"], ["zywmerhahxlqsjekpqsdqxnjiduyjrytswiweohctztgpiorwimhjmdfofqynyggcrtzslbyvkuvqrsgwyacyvcuathplliwwshusluiqwuhutnzwvuchfedhwwfdzizltdxibtsaocpnqezstblgkfdcvfsjjyzwalkksumsaljqljmmkcyejwwdkolmcgmodoiclte\nzywmehahxlq...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#80"}
1779b05eedd8c188
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them ca...
[["4 5", "Possible"], ["1 1", "Impossible"], ["4 0", "Possible\n"], ["-1 2", "Impossible\n"], ["1 2", "Possible\n"], ["7 0", "Possible\n"], ["0 2", "Possible\n"], ["7 -1", "Possible\n"], ["7 -2", "Impossible\n"], ["-1 4", "Possible\n"], ["7 -4", "Possible\n"], ["-1 8", "Impossible\n"], ["5 -4", "Impossible\n"], ["-1 14...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#1215"}
179cfbc80bd1c445
Read problems statements in Mandarin Chinese and Russian. Today is Chef's birthday. His mom gifted him a truly lovable gift, a permutation of first N positive integers. She placed the permutation on a very long table in front of Chef and left it for him to play with it. But as there was a lot of people coming and w...
[["2\n5 2\n3 5\n5 1\n1", "Mom\nChef"], ["2\n5 2\n3 5\n7 1\n1", "Mom\nChef\n"], ["2\n5 2\n3 3\n7 1\n1", "Chef\nChef\n"], ["2\n6 2\n1 3\n7 1\n2", "Chef\nMom\n"], ["2\n6 0\n1 3\n7 0\n1", "Mom\nMom\n"], ["2\n5 2\n3 3\n7 0\n1", "Chef\nChef\n"], ["2\n5 2\n1 3\n7 0\n1", "Chef\nChef\n"], ["2\n6 2\n1 3\n7 0\n1", "Chef\nChef\n"]...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#530"}
17a055c7a896a5b4
There are N rabbits on a number line. The rabbits are conveniently numbered 1 through N. The coordinate of the initial position of rabbit i is x_i. The rabbits will now take exercise on the number line, by performing sets described below. A set consists of M jumps. The j-th jump of a set is performed by rabbit a_j (2≤...
[["3\n1 0 1\n2 2\n2 2", "1\n0\n1\n"], ["5\n0 1 3 6 17\n3 10\n2 3 4", "0\n3\n14\n15\n17\n"], ["3\n2 0 1\n2 2\n2 2", "2\n0\n1\n"], ["5\n0 1 3 6 17\n3 10\n3 3 4", "0\n1\n3\n6\n17\n"], ["5\n0 1 3 6 17\n3 1\n3 3 4", "0\n1\n3\n14\n17\n"], ["3\n1 -1 1\n2 3\n2 2", "1\n-1\n1\n"], ["3\n0 0 2\n1 1\n2", "0\n2\n2\n"], ["5\n0 1 3 6 ...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00004-of-00005.parquet#2215"}
17a4bff0397a763b
Contest T-shirts Segtree has $ M $ contest T-shirts. He decided to spend $ N $ days on the contest T-shirt alone, and told $ i = 1, 2, 3, \ dots, N $ "$ A_i $ T-shirt on the $ i $ day." I made a plan for $ N $ to wear. However, if you keep the current plan, you may not be able to do the laundry in time, so I would l...
[["2 0\n2 2 1", "0\n"], ["-2 2\n2 2 1", "1\n"], ["2 0\n2 0 1", "0\n"], ["2 0\n2 0 0", "0\n"], ["2 0\n1 0 0", "0\n"], ["4 0\n1 0 0", "0\n"], ["0 0\n2 2 1", "0\n"], ["2 1\n2 0 1", "0\n"], ["3 0\n2 0 0", "0\n"], ["2 1\n1 0 0", "0\n"], ["0 0\n2 2 0", "0\n"], ["1 1\n2 0 1", "0\n"], ["6 0\n2 0 0", "0\n"], ["1 1\n1 0 0", "0\n...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#764"}
17a67f57a80ccd2a
For a given polygon g, print "1" if g is a convex polygon, "0" otherwise. Here, in a convex polygon, all interior angles are less than or equal to 180 degrees. g is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 ≤ i ≤ n-1) are sides of the polygon. The line segment con...
[["5\n0 0\n2 1\n1 1\n2 2\n0 2", "0\n"], ["4\n0 0\n3 0\n2 1\n0 3", "1\n"], ["4\n0 0\n3 1\n2 1\n0 3", "0\n"], ["5\n0 0\n3 1\n1 1\n2 2\n0 2", "0\n"], ["5\n0 0\n3 1\n1 1\n3 2\n0 2", "0\n"], ["4\n0 0\n3 0\n2 0\n0 3", "0\n"], ["5\n0 0\n3 1\n1 1\n3 2\n1 2", "0\n"], ["4\n0 0\n3 1\n2 0\n0 3", "0\n"], ["5\n0 0\n3 1\n1 1\n5 2\n1 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1727"}
17a92ef69a0df1cf
In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had center coordinates (C_X, C_Y) and height H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the cente...
[["4\n2 3 5\n2 1 5\n1 2 5\n3 2 5\n", "2 2 6\n"], ["2\n0 0 100\n1 1 98\n", "0 0 100\n"], ["3\n99 1 191\n100 1 192\n99 0 192\n", "100 0 193\n"], ["2\n0 0 180291302\n20 20 180291262\n", "0 0 180291302\n"], ["4\n47 59 314159265\n59 47 314159265\n59 59 314159265\n47 47 314159265\n", "53 53 314159277\n"], ["3\n67 85 41410618...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1061"}
17abd4b48e30e5cc
You survived several months of exam wars and were able to enter ICPC University on a sunny day. On the day of admission, there was an enthusiastic recruitment of circles on the campus of the university, and you received a large number of pamphlets and returned. When you return to your room, you find one of the pamphlet...
[["9\n256\n0", "2\n0\n"], ["9\n160\n0", "2\n1\n"], ["9\n213\n0", "2\n3\n"], ["9\n200\n0", "2\n2\n"], ["9\n135\n0", "2\n7\n"], ["9\n350\n0", "2\n5\n"], ["9\n0\n-1", "2\n"], ["9\n162\n0", "2\n4\n"], ["9\n315\n0", "2\n11\n"], ["9\n225\n0", "2\n8\n"], ["9\n166\n0", "2\n1\n"], ["9\n190\n0", "2\n3\n"], ["9\n235\n0", "2\n3\n"...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#310"}
17b48536db526037
A prime number n (11, 19, 23, etc.) that divides by 4 and has 3 has an interesting property. The results of calculating the remainder of the square of a natural number (1, 2, ..., n -1) of 1 or more and less than n divided by n are the same, so they are different from each other. The number is (n -1) / 2. The set of n...
[["11\n23\n0", "4\n4\n4\n4\n4\n10\n10\n10\n10\n10\n10\n10\n10\n10\n10\n10\n"], ["11\n45\n0", "4\n4\n4\n4\n4\n4\n2\n6\n4\n6\n12\n2\n2\n16\n6\n4\n6\n2\n4\n18\n4\n2\n8\n4\n6\n12\n2\n"], ["11\n77\n0", "4\n4\n4\n4\n4\n10\n12\n12\n10\n12\n10\n22\n12\n10\n10\n22\n12\n10\n22\n10\n10\n10\n12\n10\n12\n22\n22\n10\n10\n10\n12\n12\...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#895"}
17b598c140042f5b
You are given a chessboard of size $n \times n$. It is filled with numbers from $1$ to $n^2$ in the following way: the first $\lceil \frac{n^2}{2} \rceil$ numbers from $1$ to $\lceil \frac{n^2}{2} \rceil$ are written in the cells with even sum of coordinates from left to right from top to bottom. The rest $n^2 - \lceil...
[["4 5\n1 1\n4 4\n4 3\n3 2\n2 4\n", "1\n8\n16\n13\n4\n"], ["5 4\n2 1\n4 2\n3 3\n3 4\n", "16\n9\n7\n20\n"], ["1 1\n1 1\n", "1\n"], ["2 4\n1 1\n2 1\n1 2\n2 2\n", "1\n4\n3\n2\n"], ["1 1\n1 1\n", "1\n"], ["2 4\n1 1\n2 1\n1 2\n2 2\n", "1\n4\n3\n2\n"], ["2 4\n1 1\n2 2\n1 2\n2 2\n", "1\n2\n3\n2\n"], ["5 4\n2 1\n4 4\n3 3\n3 4\...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1343"}
17b920b0074f205d
We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle. Constraints * 4 \leq N \leq 10^5 * 1 \leq A_i \leq ...
[["10\n3 3 3 3 4 4 4 5 5 5", "20"], ["6\n3 1 2 4 2 1", "2"], ["4\n1 2 3 4", "0"], ["10\n3 3 3 3 4 4 2 5 5 5", "20\n"], ["6\n3 1 2 4 2 2", "0\n"], ["6\n3 2 2 4 2 2", "4\n"], ["6\n3 2 2 4 3 2", "6\n"], ["10\n3 3 6 3 4 4 1 6 5 5", "30\n"], ["10\n3 3 6 3 4 3 1 6 5 6", "18\n"], ["6\n3 4 2 3 4 3", "12\n"], ["10\n3 3 6 6 4 3 ...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#3077"}
17c5a07fb98ead22
Recently Johnny have learned bogosort sorting algorithm. He thought that it is too ineffective. So he decided to improve it. As you may know this algorithm shuffles the sequence randomly until it is sorted. Johnny decided that we don't need to shuffle the whole sequence every time. If after the last shuffle several fir...
[["3\n2\n6\n10", "2\n1826/189\n877318/35343"], ["3\n2\n4\n10", "2\n5\n877318/35343\n"], ["3\n2\n6\n12", "2\n1826/189\n19455868963/549972423\n"], ["3\n4\n6\n12", "5\n1826/189\n19455868963/549972423\n"], ["3\n4\n6\n19", "5\n1826/189\n260073418750644288862/2955241273022663625\n"], ["3\n2\n4\n19", "2\n5\n260073418750644288...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#828"}
17d49a3bddbf7acb
Bessie is out grazing on the farm, which consists of $n$ fields connected by $m$ bidirectional roads. She is currently at field $1$, and will return to her home at field $n$ at the end of the day. The Cowfederation of Barns has ordered Farmer John to install one extra bidirectional road. The farm has $k$ special field...
[["5 5 3\n1 3 5\n1 2\n2 3\n3 4\n3 5\n2 4\n", "3\n"], ["5 4 2\n2 4\n1 2\n2 3\n3 4\n4 5\n", "3\n"], ["10 15 8\n6 9 8 1 2 7 4 5\n9 5\n3 6\n10 7\n7 4\n5 3\n8 2\n10 9\n3 4\n4 6\n5 4\n1 2\n7 3\n1 3\n7 6\n7 8\n", "3\n"], ["42 41 20\n8 34 12 13 38 3 9 10 18 16 2 26 24 17 32 21 4 27 15 39\n1 35\n35 8\n1 31\n31 34\n1 40\n40 12\n...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#326"}
17d7e8c80188f0bd
This contest is `CODE FESTIVAL`. However, Mr. Takahashi always writes it `CODEFESTIVAL`, omitting the single space between `CODE` and `FESTIVAL`. So he has decided to make a program that puts the single space he omitted. You are given a string s with 12 letters. Output the string putting a single space between the fi...
[["ETAUDARGTSOP", "ETAU DARGTSOP\n"], ["AACDEFGHIJKL", "AACD EFGHIJKL\n"], ["COCEFESTIVAL", "COCE FESTIVAL\n"], ["POSTGRADUATF", "POST GRADUATF\n"], ["ALCDEFGHIJKA", "ALCD EFGHIJKA\n"], ["COCEFESTIV@L", "COCE FESTIV@L\n"], ["POSTGRAUDATF", "POST GRAUDATF\n"], ["AKJIHGFEDCLA", "AKJI HGFEDCLA\n"], ["L@VITSEFECOC", "L@VI ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#880"}
17dd8b73857a6c6f
Mr. Bender has a digital table of size n × n, each cell can be switched on or off. He wants the field to have at least c switched on squares. When this condition is fulfilled, Mr Bender will be happy. We'll consider the table rows numbered from top to bottom from 1 to n, and the columns — numbered from left to right f...
[["6 4 3 1\n", "0\n"], ["9 3 8 10\n", "2\n"], ["9 4 3 10\n", "2\n"], ["9 8 2 10\n", "2\n"], ["1 1 1 1\n", "0\n"], ["10 7 2 7\n", "2\n"], ["8 2 6 10\n", "2\n"], ["8 1 2 10\n", "3\n"], ["6 1 4 10\n", "3\n"], ["1000000 951981 612086 60277\n", "174\n"], ["1000000 587964 232616 62357\n", "177\n"], ["1000000 948438 69861 891...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#895"}
17e2dafdc3da0042
The robot is placed in the top left corner of a grid, consisting of $n$ rows and $m$ columns, in a cell $(1, 1)$. In one step, it can move into a cell, adjacent by a side to the current one: $(x, y) \rightarrow (x, y + 1)$; $(x, y) \rightarrow (x + 1, y)$; $(x, y) \rightarrow (x, y - 1)$; $(x, y) \rightarrow (x - ...
[["3\n2 3 1 3 0\n2 3 1 3 1\n5 5 3 4 1\n", "3\n-1\n8\n"], ["1\n776 123 5 7 3\n", "897\n"], ["1\n1000 1000 99 99 2\n", "1998\n"], ["1\n1000 1000 99 9 21\n", "1998\n"], ["1\n1000 1000 10 10 0\n", "1998\n"], ["1\n2 3 1 3 0\n", "3\n"], ["2\n2 3 1 3 0\n2 3 1 3 1\n", "3\n-1\n"], ["1\n2 3 1 3 1\n", "-1\n"], ["2\n3 3 2 2 1\n5 5...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1613"}
17e7e9d3de379c40
Pasha has a positive integer a without leading zeroes. Today he decided that the number is too small and he should make it larger. Unfortunately, the only operation Pasha can do is to swap two adjacent decimal digits of the integer. Help Pasha count the maximum number he can get if he has the time to make at most k sw...
[["1990 1\n", "9190\n"], ["300 0\n", "300\n"], ["1034 2\n", "3104\n"], ["9090000078001234 6\n", "9907000008001234\n"], ["1234 3\n", "4123\n"], ["5 100\n", "5\n"], ["1234 5\n", "4312\n"], ["1234 6\n", "4321\n"], ["9022 2\n", "9220\n"], ["66838 4\n", "86863\n"], ["39940894417248510 10\n", "99984304417248510\n"], ["5314 4...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1623"}
17f19c9bcc08afa8
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get? -----Constraints----- - 1 \leq N \leq 2\times 10^5 - S_i consists of lowercase English letters and has a length between 1 and 10 (inclusive). -----Input----- Input is given from ...
[["3\napple\norange\napple\n", "2\n"], ["5\ngrape\ngrape\ngrape\ngrape\ngrape\n", "1\n"], ["4\naaaa\na\naaa\naa\n", "4\n"], ["4\na`aa\na\naaa\naa", "4\n"], ["3\nbpple\norange\napple", "3\n"], ["5\ngrape\ngrape\ngraoe\ngrape\ngrape", "2\n"], ["5\negapr\ngrape\ngraoe\ngr`pe\nepaqg", "5\n"], ["4\na`ab\na\naaa\naa", "4\n"]...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#728"}
17f9c7e23158b360
Some natural number was written on the board. Its sum of digits was not less than k. But you were distracted a bit, and someone changed this number to n, replacing some digits with others. It's known that the length of the number didn't change. You have to find the minimum number of digits in which these two numbers c...
[["3\n11\n", "1\n"], ["3\n99\n", "0\n"], ["10\n5205602270\n", "0\n"], ["70\n3326631213\n", "6\n"], ["200\n1000000010000000000000000000010000000000000001000001000000000000000000000000000000000000000000000000\n", "22\n"], ["500\n189933717045853169376453960095894324827067481124719131045293851107765606623984070343249935753...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1480"}
17fa129bf0bbd844
There are n heaps of stone. The i-th heap has h_i stones. You want to change the number of stones in the heap by performing the following process once: * You go through the heaps from the 3-rd heap to the n-th heap, in this order. * Let i be the number of the current heap. * You can choose a number d (0 ≤ 3 ⋅...
[["4\n4\n1 2 10 100\n4\n100 100 100 1\n5\n5 1 1 1 8\n6\n1 2 3 6 5 6\n", "7\n1\n1\n3\n"], ["4\n4\n0 2 10 100\n4\n100 000 100 1\n5\n5 2 1 1 3\n6\n1 4 4 3 5 12\n", "6\n1\n1\n3\n"], ["4\n4\n1 2 10 100\n4\n100 100 100 1\n5\n5 1 1 1 8\n6\n1 2 2 3 5 6\n", "7\n1\n1\n1\n"], ["4\n4\n0 2 14 100\n4\n100 000 100 1\n5\n5 2 2 1 3\n6\...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#740"}
17fc21678971a7e6
Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K. Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from ...
[["5 4\n1 4 2 3 5\n", "4\n"], ["8 4\n4 2 4 2 4 2 4 2\n", "7\n"], ["10 7\n14 15 92 65 35 89 79 32 38 46\n", "8\n"], ["5 1\n1 4 2 3 5", "0\n"], ["10 7\n14 15 101 65 35 89 79 32 38 46", "5\n"], ["10 8\n14 26 111 65 35 89 95 32 38 46", "6\n"], ["10 3\n14 26 111 65 35 89 95 32 38 46", "3\n"], ["5 8\n1 4 2 3 5", "1\n"], ["10...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1198"}
18069acf2d351a2f
You are given a string s consisting of lowercase Latin letters. Let the length of s be |s|. You may perform several operations on this string. In one operation, you can choose some index i and remove the i-th character of s (s_i) if at least one of its adjacent characters is the previous letter in the Latin alphabet f...
[["6\nabbbbb\n", "5\n"], ["4\nbcda\n", "3\n"], ["8\nbacabcab\n", "4\n"], ["7\ncddcbcb\n", "5\n"], ["100\nmxjrojjwtrauhhccftvjsyfyfsnbdnwjfltyjetsylbddrkoqjxbmientcowknrecfqcvxfgsbymwyvakmbulhvrxzvzbygajtgc\n", "2\n"], ["8\naaaaaaaa\n", "0\n"], ["100\nyltrygcqmgjzsxoahbvovspancmoaltdrxgjnxwxbrehubvradguoqgiodzanljxtszdu...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#548"}
1811f006d988f874
In the final of CODE FESTIVAL in some year, there are N participants. The height and power of Participant i is H_i and P_i, respectively. Ringo is hosting a game of stacking zabuton (cushions). The participants will line up in a row in some order, and they will in turn try to add zabuton to the stack of zabuton. Init...
[["3\n2 4\n3 1\n4 2", "2\n"], ["10\n1 3\n8 4\n8 3\n10 1\n6 4\n2 3\n4 2\n9 2\n8 3\n0 1", "5\n"], ["3\n0 2\n1 0\n3 4", "3\n"], ["10\n1 3\n8 4\n8 3\n10 1\n12 4\n2 3\n4 2\n9 2\n8 3\n0 1", "6\n"], ["10\n1 3\n0 4\n15 3\n10 1\n8 4\n2 3\n4 2\n9 1\n8 3\n0 1", "7\n"], ["10\n2 3\n0 4\n15 3\n10 1\n8 4\n2 1\n4 2\n9 1\n8 0\n0 1", "8...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1037"}
1816f0ae1d20de55
There are some animals in a garden. Each of them is a crane with two legs or a turtle with four legs. Takahashi says: "there are X animals in total in the garden, and they have Y legs in total." Determine whether there is a combination of numbers of cranes and turtles in which this statement is correct. Constraints ...
[["1 2", "Yes"], ["3 8", "Yes"], ["2 100", "No"], ["2 2", "No\n"], ["6 12", "Yes\n"], ["6 8", "No\n"], ["1 100", "No\n"], ["3 2", "No\n"], ["1 110", "No\n"], ["3 1", "No\n"], ["6 3", "No\n"], ["1 111", "No\n"], ["5 1", "No\n"], ["3 3", "No\n"], ["1 101", "No\n"], ["5 2", "No\n"], ["4 3", "No\n"], ["2 111", "No\n"], ["5...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#1995"}
181ad72ab24b7987
Read problems statements in Mandarin Chinese and Russian Chef is sitting in a very boring lecture, waiting for it to end. He has recently asked his friend about the time, and instead of the straightforward answer, his friend, being an absolute jerk, told him the absolute value of angle between hour and minute hands...
[["2\n0\n30", "00:00\n01:00\n11:00"], ["2\n1\n30", "04:22\n07:38\n01:00\n11:00\n"], ["2\n2\n30", "03:16\n08:44\n01:00\n11:00\n"], ["2\n2\n41", "03:16\n08:44\n00:58\n11:02\n"], ["2\n2\n54", "03:16\n08:44\n04:12\n07:48\n"], ["2\n4\n54", "05:28\n06:32\n04:12\n07:48\n"], ["2\n4\n13", "05:28\n06:32\n03:14\n08:46\n"], ["2\n7...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#160"}
181d6ed6fd76e4af
Cirno_9baka has a tree with $n$ nodes. He is willing to share it with you, which means you can operate on it. Initially, there are two chess pieces on the node $1$ of the tree. In one step, you can choose any piece, and move it to the neighboring node. You are also given an integer $d$. You need to ensure that the dis...
[["4 2\n1 2\n1 3\n2 4\n1 3\n1 4\n", "6"], ["4 2\n1 2\n2 3\n3 4\n4 1 2 3 4\n1 1\n", "8"], ["2 2\n2 1\n1 2\n1 1\n", "2"], ["2 2\n2 1\n1 1\n2 1 2\n", "2"], ["10 2\n5 6\n4 7\n7 1\n8 2\n6 9\n4 8\n10 5\n9 2\n3 5\n5 5 1 3 2 7\n3 7 8 4\n", "28"], ["10 10\n9 1\n5 4\n4 6\n2 7\n1 4\n8 3\n10 8\n8 6\n10 7\n4 9 3 4 8\n10 8 3 1 6 9 1...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1368"}
18243db727bb94be
We have held a popularity poll for N items on sale. Item i received A_i votes. From these N items, we will select M as popular items. However, we cannot select an item with less than \dfrac{1}{4M} of the total number of votes. If M popular items can be selected, print Yes; otherwise, print No. -----Constraints----- -...
[["4 1\n5 4 2 1\n", "Yes\n"], ["3 2\n380 19 1\n", "No\n"], ["12 3\n4 56 78 901 2 345 67 890 123 45 6 789\n", "Yes\n"], ["10 3\n100 99 1 2 3 4 5 6 9 22\n", "Yes\n"], ["10 3\n100 99 1 2 3 4 5 6 10 22\n", "Yes\n"], ["10 3\n100 99 1 2 3 4 5 8 19 22\n", "Yes\n"], ["10 3\n100 99 1 2 3 4 5 9 19 22\n", "Yes\n"], ["10 3\n100 99...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1295"}
1829d46d0b829e58
Consider the following arithmetic progression with n terms: * x, x + d, x + 2d, \ldots, x + (n-1)d What is the product of all terms in this sequence? Compute the answer modulo 1\ 000\ 003. You are given Q queries of this form. In the i-th query, compute the answer in case x = x_i, d = d_i, n = n_i. Constraints *...
[["2\n7 2 4\n12345 17991 2019", "9009\n379039\n"], ["2\n7 2 4\n12345 17991 226", "9009\n873413\n"], ["2\n7 2 1\n9796 17991 2755", "7\n488970\n"], ["2\n7 3 4\n12345 17991 226", "14560\n873413\n"], ["2\n7 1 1\n9796 17991 1485", "7\n424707\n"], ["2\n7 3 4\n12345 30036 63", "14560\n487009\n"], ["2\n12 2 4\n23706 239950 201...
1.31
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1774"}
182c00bf5489b199
Find the number of integers between 1 and K (inclusive) satisfying the following condition, modulo 10^9 + 7: * The sum of the digits in base ten is a multiple of D. Constraints * All values in input are integers. * 1 \leq K < 10^{10000} * 1 \leq D \leq 100 Input Input is given from Standard Input in the following ...
[["98765432109876543210\n66", "678072802\n"], ["30\n1", "30\n"], ["1000000009\n2", "500000004\n"], ["98765432109876543210\n18", "852803440\n"], ["1000000009\n4", "250000009\n"], ["98765432109876543210\n11", "501683936\n"], ["1000000009\n5", "200000001\n"], ["98765432109876543210\n12", "209841644\n"], ["1000000009\n9", ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#510"}
182f8b9a90131490
Gildong has bought a famous painting software cfpaint. The working screen of cfpaint is square-shaped consisting of $n$ rows and $n$ columns of square cells. The rows are numbered from $1$ to $n$, from top to bottom, and the columns are numbered from $1$ to $n$, from left to right. The position of a cell at row $r$ and...
[["4 2\nBWWW\nWBBW\nWBBW\nWWWB\n", "4\n"], ["3 1\nBWB\nWWB\nBWB\n", "2\n"], ["5 3\nBWBBB\nBWBBB\nBBBBB\nBBBBB\nWBBBW\n", "2\n"], ["2 2\nBW\nWB\n", "4\n"], ["2 1\nWW\nWW\n", "4\n"], ["1 1\nB\n", "2\n"], ["1 1\nW\n", "2\n"], ["2 1\nBB\nWW\n", "2\n"], ["2 1\nBB\nBB\n", "0\n"], ["4 2\nWBBB\nBBWB\nWBWW\nWWBW\n", "2\n"], ["6...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1282"}
1843fc5888729f8d
The only difference between easy and hard versions is constraints. Ivan plays a computer game that contains some microtransactions to make characters look cooler. Since Ivan wants his character to be really cool, he wants to use some of these microtransactions — and he won't start playing until he gets all of them. E...
[["5 6\n1 2 0 2 0\n2 4\n3 3\n1 5\n1 2\n1 5\n2 3\n", "8\n"], ["5 3\n4 2 1 3 2\n3 5\n4 2\n2 5\n", "20\n"], ["78 36\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0\n1 52\n2 6\n9 43\n10 52\n4 63\n9 35\n10 67\n9 17\n...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#778"}
1845de3684b17052
Polycarp has just attempted to pass the driving test. He ran over the straight road with the signs of four types. speed limit: this sign comes with a positive integer number — maximal speed of the car after the sign (cancel the action of the previous sign of this type); overtake is allowed: this sign means that aft...
[["11\n1 100\n3 70\n4\n2\n3 120\n5\n3 120\n6\n1 150\n4\n3 300\n", "2\n"], ["5\n1 100\n3 200\n2\n4\n5\n", "0\n"], ["7\n1 20\n2\n6\n4\n6\n6\n2\n", "2\n"], ["1\n1 100\n", "0\n"], ["2\n1 100\n2\n", "0\n"], ["10\n1 37\n6\n5\n2\n5\n6\n5\n2\n4\n2\n", "2\n"], ["10\n1 5\n4\n5\n4\n1 21\n6\n1 10\n1 1\n2\n3 1\n", "1\n"]]
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00000-of-00005.parquet#1958"}
185241a31f527157
Bessie and the cows are playing with sequences and need your help. They start with a sequence, initially containing just the number 0, and perform n operations. Each operation is one of the following: 1. Add the integer xi to the first ai elements of the sequence. 2. Append an integer ki to the end of the sequenc...
[["5\n2 1\n3\n2 3\n2 1\n3\n", "0.500000\n0.000000\n1.500000\n1.333333\n1.500000\n"], ["6\n2 1\n1 2 20\n2 2\n1 2 -3\n3\n3\n", "0.500000\n20.500000\n14.333333\n12.333333\n17.500000\n17.000000\n"], ["1\n1 1 1\n", "1.000000\n"], ["5\n2 -980\n1 2 -156\n2 641\n2 -253\n2 -514\n", "-490.000000\n-646.000000\n-217.000000\n-226.0...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#3091"}
1858456e447d2605
The first algorithm for detecting a face on the image working in realtime was developed by Paul Viola and Michael Jones in 2001. A part of the algorithm is a procedure that computes Haar features. As part of this task, we consider a simplified model of this concept. Let's consider a rectangular image that is represent...
[["3 3\nWBW\nBWW\nWWW\n", "4\n"], ["3 6\nWWBBWW\nWWBBWW\nWWBBWW\n", "3\n"], ["6 8\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\n", "2\n"], ["4 4\nBBBB\nBBBB\nBBBB\nBBBW\n", "4\n"], ["1 52\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\n", "1\n"], ["2 10\nBBWBWWBWBB\nBBBBBBBBBW\n", "10\n"], ["4 5\n...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#1374"}
185b0f1a8737566d
Om Nom is the main character of a game "Cut the Rope". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image] The park consists of 2^{n} + 1 - 1 squares connected by ro...
[["2\n1 2 3 4 5 6\n", "5\n"], ["2\n1 2 3 3 2 2\n", "0\n"], ["1\n39 52\n", "13\n"], ["2\n59 96 34 48 8 72\n", "139\n"], ["3\n87 37 91 29 58 45 51 74 70 71 47 38 91 89\n", "210\n"], ["5\n39 21 95 89 73 90 9 55 85 32 30 21 68 59 82 91 20 64 52 70 6 88 53 47 30 47 34 14 11 22 42 15 28 54 37 48 29 3 14 13 18 77 90 58 54 38 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1332"}
185dc566ba2127e4
One day, the teacher came up with the following game. The game uses n cards with one number from 1 to 10 and proceeds as follows. 1. The teacher pastes n cards on the blackboard in a horizontal row so that the numbers can be seen, and declares an integer k (k ≥ 1) to the students. For n cards arranged in a horizontal...
[["4 2\n4\n3\n7\n5\n0 0", "0\n"], ["4 2\n1\n6\n4\n5\n0 0", "6\n"], ["4 2\n8\n3\n10\n5\n0 0", "30\n"], ["4 2\n4\n3\n7\n1\n0 0", "7\n"], ["4 2\n4\n1\n14\n3\n0 0", "14\n"], ["4 2\n8\n3\n16\n5\n0 0", "48\n"], ["4 2\n4\n3\n11\n1\n0 0", "11\n"], ["4 2\n9\n5\n16\n5\n0 0", "64\n"], ["4 2\n2\n2\n1\n5\n0 0", "5\n"], ["4 2\n1\n6\...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#814"}
1865f120a5b1ca7c
You are given n k-digit integers. You have to rearrange the digits in the integers so that the difference between the largest and the smallest number was minimum. Digits should be rearranged by the same rule in all integers. Input The first line contains integers n and k — the number and digit capacity of numbers cor...
[["6 7\n4565736\n9842969\n1412800\n6411011\n5744909\n3791659\n", "4066781\n"], ["2 4\n7694\n6577\n", "712\n"], ["4 1\n0\n7\n5\n1\n", "7\n"], ["5 4\n7411\n3080\n9578\n5902\n3225\n", "6498\n"], ["4 4\n8851\n6190\n0521\n1659\n", "6596\n"], ["2 5\n07259\n51985\n", "23657\n"], ["7 2\n53\n74\n84\n62\n14\n77\n59\n", "69\n"], ...
1.42
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#702"}
186dd1e0b48989da
Serval is fighting with a monster. The health of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the number of attacks Serval needs to make before winning. Constrai...
[["10 4", "3"], ["1 10000", "1"], ["10000 1", "10000"], ["14 4", "4\n"], ["2 10000", "1\n"], ["11000 1", "11000\n"], ["14 3", "5\n"], ["11 2", "6\n"], ["4 3", "2\n"], ["14 5", "3\n"], ["10010 1", "10010\n"], ["26 4", "7\n"], ["10001 1", "10001\n"], ["20 2", "10\n"], ["15 2", "8\n"], ["10010 2", "5005\n"], ["10000 2", "...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#403"}
1871407ac58cb60e
A monopole magnet is a magnet that only has one pole, either north or south. They don't actually exist since real magnets have two poles, but this is a programming contest problem, so we don't care. There is an $n\times m$ grid. Initially, you may place some north magnets and some south magnets into the cells. You are...
[["3 3\n.#.\n###\n##.\n", "1\n"], ["4 2\n##\n.#\n.#\n##\n", "-1\n"], ["4 5\n....#\n####.\n.###.\n.#...\n", "2\n"], ["2 1\n.\n#\n", "-1\n"], ["3 5\n.....\n.....\n.....\n", "0\n"], ["4 4\n..##\n..#.\n##..\n##..\n", "2\n"], ["1 1\n#\n", "1\n"], ["10 10\n.........#\n........##\n#####.....\n####......\n#.........\n#...........
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00000-of-00005.parquet#2327"}
18735a35ec8756d4
Vova is playing a computer game. There are in total $n$ turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of the game) is $k$. During each turn Vova can choose what to do: If the current charge of his laptop battery is strictly gre...
[["6\n15 5 3 2\n15 5 4 3\n15 5 2 1\n15 5 5 1\n16 7 5 2\n20 5 7 3\n", "4\n-1\n5\n2\n0\n1\n"], ["1\n1000000000 499999999 3 2\n", "1\n"], ["10\n1000000000 499999999 2 1\n1000000000 499999999 2 1\n1000000000 499999999 2 1\n1000000000 499999999 2 1\n1000000000 499999999 2 1\n1000000000 499999999 2 1\n1000000000 499999999 2 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#280"}
187e4042607ef85e
You are given an integer n. In one move, you can either multiply n by two or divide n by 6 (if it is divisible by 6 without the remainder). Your task is to find the minimum number of moves needed to obtain 1 from n or determine if it's impossible to do that. You have to answer t independent test cases. Input The fi...
[["7\n1\n2\n3\n12\n12345\n15116544\n387420489\n", "0\n-1\n2\n-1\n-1\n12\n36\n"], ["1\n999838675\n", "-1\n"], ["1\n782058266\n", "-1\n"], ["7\n1\n2\n4\n12\n12345\n15116544\n387420489\n", "0\n-1\n-1\n-1\n-1\n12\n36\n"], ["7\n1\n2\n4\n24\n12345\n2324038\n387420489\n", "0\n-1\n-1\n-1\n-1\n-1\n36\n"], ["7\n1\n2\n4\n24\n1234...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00000-of-00005.parquet#2862"}
1883b71cbdd00368
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...
[["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", "4\n"], ["5\n0/17 74/0\n68877 18122\n96115 84747\n71027 43746\n31622 3444\n93281 34803\n", "4\n"], ["5\n3/18 18/17\n49797 95131\n5075 96918\n91898 7865\n91852 41070\n12076 45049\n", "1\n"], ["15\n1/4 2/1\n3 1\n6 2\n9 3\n12 4...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#447"}
1888a387436164f3
Problem Given the integer n, output the smallest m such that nCm (the number of combinations that choose m out of n different ones) is even. Constraints The input satisfies the following conditions. * 1 ≤ n ≤ 1018 Input The input is given in the following format. n Output Output the minimum m such that nCm i...
[["4", "1\n"], ["11", "4\n"], ["101", "2\n"], ["7", "8\n"], ["15", "16\n"], ["31", "32\n"], ["63", "64\n"], ["127", "128\n"], ["255", "256\n"], ["110", "1\n"], ["6", "1\n"], ["010", "1\n"], ["16", "1\n"], ["011", "4\n"], ["5", "2\n"], ["000", "1\n"], ["0", "1\n"], ["-2", "1\n"], ["8", "1\n"], ["100", "1\n"], ["10", "1\...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1716"}
1891fd361583e399
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold: * For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of weights of all edges on the simple path between v_...
[["3\n1 2\n2 3\n", "1 1\n"], ["5\n1 2\n2 3\n1 4\n4 5\n", "1 4\n"], ["4\n1 2\n2 3\n3 4\n", "3 3\n"], ["5\n1 5\n2 5\n3 5\n4 5\n", "1 1\n"], ["5\n1 2\n2 3\n1 4\n3 5\n", "1 4\n"], ["4\n1 2\n2 3\n2 4\n", "1 1\n"], ["6\n1 6\n2 3\n3 4\n4 5\n5 6\n", "3 5\n"], ["4\n1 4\n2 3\n3 4\n", "3 3\n"], ["6\n1 6\n2 6\n3 4\n4 5\n5 6\n", "1...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#116"}
18cbdf166bacb686
Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise. You are given geometric progression b defined by two integers b_1 and q. Remind that a geometric progression is a sequence of integers b_1, b_2, b_3, ..., where for each i > 1 the respective term satisfies the condition b...
[["3 2 30 4\n6 14 25 48\n", "3"], ["123 1 2143435 4\n123 11 -5453 141245\n", "0"], ["123 1 2143435 4\n54343 -13 6 124\n", "inf"], ["3 2 25 2\n379195692 -69874783\n", "4"], ["3 2 30 3\n-691070108 -934106649 -220744807\n", "4"], ["3 3 104 17\n9 -73896485 -290898562 5254410 409659728 -916522518 -435516126 94354167 2629810...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1503"}
18d47c4c78c8ce29
You are given an array a_1, a_2, ..., a_{n} consisting of n integers, and an integer k. You have to split the array into exactly k non-empty subsegments. You'll then compute the minimum integer on each subsegment, and take the maximum integer over the k obtained minimums. What is the maximum possible integer you can ge...
[["5 2\n1 2 3 4 5\n", "5\n"], ["5 1\n-4 -5 -3 -2 -1\n", "-5\n"], ["10 2\n10 9 1 -9 -7 -9 3 8 -10 5\n", "10\n"], ["10 4\n-8 -1 2 -3 9 -8 4 -3 5 9\n", "9\n"], ["1 1\n504262064\n", "504262064\n"], ["3 3\n-54481850 -878017339 -486296116\n", "-54481850\n"], ["2 2\n-333653905 224013643\n", "224013643\n"], ["14 2\n-14 84 44 4...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#438"}
18d5019aa39fd1dc
A never-ending, fast-changing and dream-like world unfolds, as the secret door opens. A world is an unordered graph G, in whose vertex set V(G) there are two special vertices s(G) and t(G). An initial world has vertex set {s(G), t(G)} and an edge between them. A total of n changes took place in an initial world. In e...
[["4 4\n", "3\n"], ["31 8\n", "64921457\n"], ["3 2\n", "6\n"], ["3 1\n", "0\n"], ["3 4\n", "1\n"], ["50 50\n", "3\n"], ["6 6\n", "3\n"], ["8 5\n", "566\n"], ["3 3\n", "3\n"], ["10 4\n", "55564\n"], ["6 7\n", "1\n"], ["7 6\n", "19\n"], ["2 2\n", "2\n"], ["4 5\n", "1\n"], ["50 49\n", "19\n"], ["2 1\n", "0\n"], ["5 2\n", ...
3.55
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#1306"}
18d9ce253496b550
You are given two squares, one with sides parallel to the coordinate axes, and another one with sides at 45 degrees to the coordinate axes. Find whether the two squares intersect. The interior of the square is considered to be part of the square, i.e. if one square is completely inside another, they intersect. If the ...
[["0 0 6 0 6 6 0 6\n1 3 3 5 5 3 3 1\n", "YES\n"], ["0 0 6 0 6 6 0 6\n7 3 9 5 11 3 9 1\n", "NO\n"], ["6 0 6 6 0 6 0 0\n7 4 4 7 7 10 10 7\n", "YES\n"], ["0 0 6 0 6 6 0 6\n8 4 4 8 8 12 12 8\n", "YES\n"], ["2 2 4 2 4 4 2 4\n0 3 3 6 6 3 3 0\n", "YES\n"], ["-5 -5 5 -5 5 5 -5 5\n-5 7 0 2 5 7 0 12\n", "YES\n"], ["-5 -5 5 -5 5 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#967"}
190162d537c9a332
You have to restore the wall. The wall consists of $N$ pillars of bricks, the height of the $i$-th pillar is initially equal to $h_{i}$, the height is measured in number of bricks. After the restoration all the $N$ pillars should have equal heights. You are allowed the following operations: put a brick on top of one p...
[["3 1 100 100\n1 3 8\n", "12\n"], ["3 100 1 100\n1 3 8\n", "9\n"], ["3 100 100 1\n1 3 8\n", "4\n"], ["5 1 2 4\n5 5 3 6 5\n", "4\n"], ["5 1 2 2\n5 5 3 6 5\n", "3\n"], ["10 7 8 3\n3 10 4 9 2 7 6 10 4 8\n", "57\n"], ["10 7122 8827 3205\n452685204 144160553 743427456 403576146 888744473 313727757 22025193 886601085 576370...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#472"}
19018a3f36ac1af8
Some dwarves that are finishing the StUDY (State University for Dwarven Youngsters) Bachelor courses, have been told "no genome, no degree". That means that all dwarves should write a thesis on genome. Dwarven genome is far from simple. It is represented by a string that consists of lowercase Latin letters. Dwarf Mish...
[["acaa\nabca\n", "NO\n"], ["aab\naa\n", "NO\n"], ["a\nza\n", "NO\n"], ["aab\naaa\n", "NO\n"], ["ed\nab\n", "NO\n"], ["ba\na\n", "NO\n"], ["aaaabcccca\naaaadccccb\n", "NO\n"], ["a\naa\n", "NO\n"], ["abc\nab\n", "NO\n"], ["vvea\nvvae\n", "YES\n"], ["abab\nbaba\n", "NO\n"], ["rtfabanpc\natfabrnpc\n", "YES\n"], ["ab\nca\n...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1768"}
1913f95af983c831
You are given $n$ strings. Each string consists of lowercase English letters. Rearrange (reorder) the given strings in such a way that for every string, all strings that are placed before it are its substrings. String $a$ is a substring of string $b$ if it is possible to choose several consecutive letters in $b$ in su...
[["5\na\naba\nabacaba\nba\naba\n", "YES\na\nba\naba\naba\nabacaba\n"], ["5\na\nabacaba\nba\naba\nabab\n", "NO\n"], ["3\nqwerty\nqwerty\nqwerty\n", "YES\nqwerty\nqwerty\nqwerty\n"], ["1\nwronganswer\n", "YES\nwronganswer\n"], ["3\na\nb\nab\n", "NO\n"], ["2\nababaab\nabaab\n", "YES\nabaab\nababaab\n"], ["2\nq\nqq\n", "YE...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1134"}
191c6b460023fd0c
You were lucky enough to get a map just before entering the legendary magical mystery world. The map shows the whole area of your planned exploration, including several countries with complicated borders. The map is clearly drawn, but in sepia ink only; it is hard to recognize at a glance which region belongs to which ...
[["6\nBlizid\n0 0\n60 0\n60 60\n0 60\n0 50\n50 50\n50 10\n0 10\n-1\nBlizid\n0 10\n10 10\n10 50\n0 50\n-1\nWindom\n10 10\n50 10\n40 20\n20 20\n20 40\n10 50\n-1\nAccent\n50 10\n50 50\n35 50\n35 25\n-1\nPilot\n35 25\n35 50\n10 50\n-1\nBlizid\n20 20\n40 20\n20 40\n-1\n4\nA1234567890123456789\n0 0\n0 100\n100 100\n100 0\n-1...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1374"}
191ce92e2a3f2cdc
Given is an integer N. Find the minimum possible positive integer k such that (1+2+\cdots+k) is a multiple of N. It can be proved that such a positive integer k always exists. Constraints * 1 \leq N \leq 10^{15} * All values in input are integers. Input Input is given from Standard Input in the following format: ...
[["39730771", "39730770\n"], ["5", "4\n"], ["36307133", "3157141\n"], ["71266519", "17269679\n"], ["3807301", "928609\n"], ["3003457", "295422\n"], ["3532816", "220800\n"], ["6261239", "914563\n"], ["8870499", "328536\n"], ["11036793", "3678930\n"], ["14439956", "4972248\n"], ["4590540", "858600\n"], ["4427953", "10499...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#33"}
19203e73889f45ab
— This is not playing but duty as allies of justice, Nii-chan! — Not allies but justice itself, Onii-chan! With hands joined, go everywhere at a speed faster than our thoughts! This time, the Fire Sisters — Karen and Tsukihi — is heading for somewhere they've never reached — water-surrounded islands! There are three...
[["1 1 1\n", "8\n"], ["1 2 2\n", "63\n"], ["1 3 5\n", "3264\n"], ["6 2 9\n", "813023575\n"], ["7 3 7\n", "807577560\n"], ["135 14 39\n", "414849507\n"], ["5000 5000 5000\n", "986778560\n"], ["2 1 1\n", "18\n"], ["1 1 3\n", "32\n"], ["1 2 3\n", "156\n"], ["4 1 2\n", "315\n"], ["5 9 4\n", "661093467\n"], ["4 2 5\n", "326...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#109"}
1924c7184c2b4e88
You have probably registered on Internet sites many times. And each time you should enter your invented password. Usually the registration form automatically checks the password's crypt resistance. If the user's password isn't complex enough, a message is displayed. Today your task is to implement such an automatic che...
[["abacaba\n", "Too weak\n"], ["X12345\n", "Too weak\n"], ["CONTEST_is_STARTED!!11\n", "Correct\n"], ["1zA__\n", "Correct\n"], ["1zA_\n", "Too weak\n"], ["zA___\n", "Too weak\n"], ["1A___\n", "Too weak\n"], ["z1___\n", "Too weak\n"], ["0\n", "Too weak\n"], ["_\n", "Too weak\n"], ["a\n", "Too weak\n"], ["D\n", "Too weak...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#88"}
192850f351a23b8f
You are given a string $s$ consisting of lowercase Latin letters and $q$ queries for this string. Recall that the substring $s[l; r]$ of the string $s$ is the string $s_l s_{l + 1} \dots s_r$. For example, the substrings of "codeforces" are "code", "force", "f", "for", but not "coder" and "top". There are two types o...
[["abacaba\n5\n2 1 4\n1 4 b\n1 5 b\n2 4 6\n2 1 7\n", "3\n1\n2\n"], ["dfcbbcfeeedbaea\n15\n1 6 e\n1 4 b\n2 6 14\n1 7 b\n1 12 c\n2 6 8\n2 1 6\n1 7 c\n1 2 f\n1 10 a\n2 7 9\n1 10 a\n1 14 b\n1 1 f\n2 1 11\n", "5\n2\n5\n2\n6\n"], ["aaab\n1\n2 4 4\n", "1\n"], ["aaab\n1\n2 4 4\n", "1\n"], ["abacaba\n5\n2 1 4\n1 4 b\n1 5 b\n2 4...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#295"}
1938d95d7a1b06ce
A sequence of non-negative integers a1, a2, ..., an of length n is called a wool sequence if and only if there exists two integers l and r (1 ≤ l ≤ r ≤ n) such that <image>. In other words each wool sequence contains a subsequence of consecutive elements with xor equal to 0. The expression <image> means applying the o...
[["86232 41348\n", "77566161\n"], ["2 2\n", "6\n"], ["100000 17\n", "614965071\n"], ["1 1\n", "1\n"], ["4 2\n", "0\n"], ["1 99999\n", "833014736\n"], ["4 3\n", "840\n"], ["21857 94145\n", "689996210\n"], ["1 29\n", "536870911\n"], ["5444 31525\n", "637906839\n"], ["50664 46559\n", "425318276\n"], ["2 1\n", "0\n"], ["76...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#399"}
1947b1536859506a
Takahashi is going to set a 3-character password. How many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)? Constraints * 1 \leq N \leq 9 * N is an integer. Input Input is given from Standard Input in the following format: N Output Print the number of possibl...
[["2", "8"], ["1", "1"], ["4", "64\n"], ["0", "0\n"], ["3", "27\n"], ["-1", "-1\n"], ["5", "125\n"], ["-2", "-8\n"], ["-4", "-64\n"], ["-3", "-27\n"], ["8", "512\n"], ["-5", "-125\n"], ["11", "1331\n"], ["-6", "-216\n"], ["6", "216\n"], ["-7", "-343\n"], ["10", "1000\n"], ["-9", "-729\n"], ["13", "2197\n"], ["-16", "-4...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#1828"}
1950b96e72bcda5d
You are given an array of n integers a1... an. The cost of a subsegment is the number of unordered pairs of distinct indices within the subsegment that contain equal elements. Split the given array into k non-intersecting non-empty subsegments so that the sum of their costs is minimum possible. Each element should be p...
[["128 5\n116 8 116 116 119 39 116 116 119 116 8 119 119 119 39 116 39 119 39 119 119 39 8 39 8 119 8 116 116 116 119 119 8 39 39 8 116 119 119 119 119 8 8 8 119 39 119 116 119 119 39 39 119 8 116 116 116 116 116 119 116 116 119 116 39 39 119 8 8 119 39 116 39 39 119 119 116 116 119 119 119 119 8 8 116 116 116 39 119 3...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#178"}
1962266285ae873b
Как известно, в теплую погоду многие жители крупных городов пользуются сервисами городского велопроката. Вот и Аркадий сегодня будет добираться от школы до дома, используя городские велосипеды. Школа и дом находятся на одной прямой улице, кроме того, на той же улице есть n точек, где можно взять велосипед в прокат или...
[["4 4\n3 6 8 10\n", "2\n"], ["2 9\n10 20\n", "-1\n"], ["12 3\n4 6 7 9 10 11 13 15 17 18 20 21\n", "6\n"], ["2 1\n11164 11165\n", "1\n"], ["3 7\n45823 45825 45829\n", "1\n"], ["2 100000\n0 100000\n", "1\n"], ["50 15001\n1269 1580 5431 5916 6642 14145 15760 19922 20589 22062 24138 33454 33505 35916 37012 42577 43140 494...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1312"}
196451129458fff8
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
[["70\n1 0 0 0 1 0 1 0 0 0 1 1 0 1 0 0 1 1 1 0 1 1 0 0 1 1 1 3 1 1 0 1 2 0 2 1 0 0 0 1 1 1 1 1 0 0 1 0 0 0 1 1 1 3 0 0 1 0 0 0 1 0 0 0 0 0 1 0 1 1\n", "43\n"], ["25\n2 3 1 3 3 2 1 3 3 3 1 3 3 1 3 2 3 3 1 3 3 3 2 3 3\n", "3\n"], ["30\n1 2 3 2 2 3 3 3 3 3 3 3 3 3 3 1 2 2 3 2 3 3 3 2 1 3 3 3 1 3\n", "2\n"], ["2\n0 2\n", "...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#184"}
19651874382e85b7
n participants of the competition were split into m teams in some manner so that each team has at least one participant. After the competition each pair of participants from the same team became friends. Your task is to write a program that will find the minimum and the maximum number of pairs of friends that could ha...
[["5 1\n", "10 10\n"], ["3 2\n", "1 1\n"], ["6 3\n", "3 6\n"], ["5 3\n", "2 3\n"], ["10 2\n", "20 36\n"], ["10 6\n", "4 10\n"], ["1000000000 1\n", "499999999500000000 499999999500000000\n"], ["5000000 12\n", "1041664166668 12499942500066\n"], ["1833 195\n", "7722 1342341\n"], ["1000000000 1000000000\n", "0 0\n"], ["100...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#449"}
196703f16b3dda57
Mike received an array $a$ of length $n$ as a birthday present and decided to test how pretty it is. An array would pass the $i$-th prettiness test if there is a way to get an array with a sum of elements totaling $s_i$, using some number (possibly zero) of slicing operations. An array slicing operation is conducted ...
[["2\n5 5\n1 2 3 4 5\n1\n8\n9\n12\n6\n5 5\n3 1 3 1 3\n1\n2\n3\n9\n11\n", "Yes\nNo\nYes\nNo\nYes\nNo\nYes\nNo\nYes\nYes\n"], ["2\n5 5\n1 2 3 4 5\n1\n8\n9\n12\n6\n5 5\n0 1 3 1 3\n1\n2\n3\n9\n11\n", "Yes\nNo\nYes\nNo\nYes\nNo\nYes\nNo\nNo\nNo\n"], ["2\n5 5\n1 2 3 4 5\n1\n8\n9\n12\n6\n5 5\n0 1 3 1 3\n1\n2\n3\n2\n11\n", "Ye...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#282"}
19686905e54db234
Arya has n opponents in the school. Each day he will fight with all opponents who are present this day. His opponents have some fighting plan that guarantees they will win, but implementing this plan requires presence of them all. That means if one day at least one of Arya's opponents is absent at the school, then Arya...
[["2 2\n10\n00\n", "2\n"], ["4 1\n0100\n", "1\n"], ["4 5\n1101\n1111\n0110\n1011\n1111\n", "2\n"], ["3 2\n110\n110\n", "2\n"], ["10 6\n1111111111\n0100110101\n1111111111\n0000011010\n1111111111\n1111111111\n", "1\n"], ["10 10\n1111111111\n0001001000\n1111111111\n1111111111\n1111111111\n1000000100\n1111111111\n000001110...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#283"}
19732f19f8e4a91c
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child e...
[["4\n1 3 4 2\n", "20\n"], ["6\n5 5 6 1 1 1\n", "58\n"], ["6\n8 6 9 1 2 1\n", "85\n"], ["2000\n791 533 625 608 500 723 843 274 119 37 558 560 229 643 626 763 707 192 81 794 429 73 534 421 927 688 891 780 193 6 153 801 674 547 362 91 900 116 806 116 836 594 859 949 368 544 640 217 541 516 848 33 786 771 669 301 60 629 9...
4
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#479"}
19791d747f012e5f
Vasya is a CEO of a big construction company. And as any other big boss he has a spacious, richly furnished office with two crystal chandeliers. To stay motivated Vasya needs the color of light at his office to change every day. That's why he ordered both chandeliers that can change its color cyclically. For example: r...
[["4 2 4\n4 2 3 1\n2 1\n", "5\n"], ["3 8 41\n1 3 2\n1 6 4 3 5 7 2 8\n", "47\n"], ["1 2 31\n1\n1 2\n", "62\n"], ["2 2 2\n2 1\n1 2\n", "2\n"], ["10 10 10\n2 7 10 4 1 5 9 8 6 3\n9 7 6 2 4 10 1 3 5 8\n", "11\n"], ["1 2 1\n1\n2 1\n", "1\n"], ["20 1 100\n1 9 19 13 7 4 12 14 20 2 8 3 5 17 6 18 15 16 11 10\n1\n", "106\n"], ["1...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1594"}
197c30acd5c49d1a
Vasya has started watching football games. He has learned that for some fouls the players receive yellow cards, and for some fouls they receive red cards. A player who receives the second yellow card automatically receives a red card. Vasya is watching a recorded football match now and makes notes of all the fouls tha...
[["MC\nCSKA\n9\n28 a 3 y\n62 h 25 y\n66 h 42 y\n70 h 25 y\n77 a 4 y\n79 a 25 y\n82 h 42 r\n89 h 16 y\n90 a 13 r\n", "MC 25 70\nMC 42 82\nCSKA 13 90\n"], ["REAL\nBARCA\n3\n27 h 7 y\n44 a 10 y\n87 h 3 r\n", "REAL 3 87\n"], ["MASFF\nSAFBDSRG\n5\n1 h 1 y\n15 h 1 r\n27 a 1 y\n58 a 1 y\n69 h 10 y\n", "MASFF 1 15\nSAFBDSRG 1 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#34"}
198705200e0f1383
You are given a keyboard that consists of $26$ keys. The keys are arranged sequentially in one row in a certain order. Each key corresponds to a unique lowercase Latin letter. You have to type the word $s$ on this keyboard. It also consists only of lowercase Latin letters. To type a word, you need to type all its let...
[["5\nabcdefghijklmnopqrstuvwxyz\nhello\nabcdefghijklmnopqrstuvwxyz\ni\nabcdefghijklmnopqrstuvwxyz\ncodeforces\nqwertyuiopasdfghjklzxcvbnm\nqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\nqwertyuiopasdfghjklzxcvbnm\nabacaba\n", "13\n0\n68\n0\n74\n"], ["1\nabcdefghijklmnopqrstuvwxyz\nacsacnkjanscjanjkcanc\n", "164\n...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1295"}
19963bf1a8a5b08d
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes...
[["5 4 0.30\naxe 350\nimpaler 9000\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost\n", "6\naxe 105\nheal 0\nimpaler 2700\nmagicboost 0\nmegafire 0\nshield 0\n"], ["3 3 0.10\naa 900\nbb 990\ncc 999\naa\nbb\ncc\n", "3\naa 0\nbb 0\ncc 0\n"], ["1 1 0.01\na 9999\na\n", "1\na 0\n"], ["5 2 0.73\nj...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00004-of-00005.parquet#1279"}
19995749247a8e4b
The Saratov State University Olympiad Programmers Training Center (SSU OPTC) has n students. For each student you know the number of times he/she has participated in the ACM ICPC world programming championship. According to the ACM ICPC rules, each person can participate in the world championship at most 5 times. The ...
[["6 4\n0 1 2 3 4 5\n", "0\n"], ["6 5\n0 0 0 0 0 0\n", "2\n"], ["5 2\n0 4 5 1 0\n", "1\n"], ["12 2\n0 1 2 3 4 0 1 2 3 4 0 1\n", "3\n"], ["3 4\n0 2 0\n", "0\n"], ["3 4\n0 1 0\n", "1\n"], ["20 1\n5 0 4 2 2 3 2 1 2 4 1 3 5 5 5 4 4 1 3 0\n", "5\n"], ["13 1\n5 0 5 0 1 5 0 4 1 1 1 4 1\n", "3\n"], ["1 4\n1\n", "0\n"], ["6 3\n...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#1977"}
199b2959cd39beb5
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes incline...
[["3 2 10 20\n8 15 13\n16 22\n", "No War\n"], ["4 2 -48 -1\n-20 -35 -91 -23\n-22 66\n", "War\n"], ["5 3 6 8\n-10 3 1 5 -100\n100 6 14\n", "War\n"], ["1 1 -100 100\n-99\n99\n", "No War\n"], ["1 1 -100 100\n99\n-99\n", "War\n"], ["99 99 -20 74\n-51 -77 -13 -11 -45 47 -33 13 17 -58 -93 -72 -76 -22 -53 59 -97 53 -47 -64 0 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#971"}
19a6f8f0c1113024
There are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i). We will repeat the following operation as long as possible: * Choose four integers a, b, c, d (a \neq c, b \neq d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b) and (c, d), and add a dot at...
[["3\n1 1\n5 1\n5 5", "1"], ["3\n1 1\n5 1\n5 4", "1\n"], ["9\n1 1\n2 1\n3 1\n4 1\n7 1\n1 2\n1 3\n1 4\n1 5", "16\n"], ["2\n10 10\n20 1", "0\n"], ["9\n1 1\n3 1\n3 1\n4 1\n7 1\n1 2\n2 3\n1 4\n1 5", "8\n"], ["9\n1 1\n2 1\n6 1\n4 1\n7 1\n1 2\n2 3\n1 6\n1 6", "11\n"], ["9\n1 1\n2 1\n6 1\n4 1\n7 1\n1 2\n2 2\n1 6\n1 6", "6\n"]...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#3230"}
19a810e2250dff07
Find the minimum prime number greater than or equal to X. -----Notes----- A prime number is an integer greater than 1 that cannot be evenly divided by any positive integer except 1 and itself. For example, 2, 3, and 5 are prime numbers, while 4 and 6 are not. -----Constraints----- - 2 \le X \le 10^5 - All values ...
[["20\n", "23\n"], ["2\n", "2\n"], ["99992\n", "100003\n"], ["36\n", "37\n"], ["30\n", "31\n"], ["37\n", "37\n"], ["89\n", "89\n"], ["59\n", "59\n"], ["64993\n", "64997\n"], ["90371\n", "90371\n"], ["92227\n", "92227\n"], ["59054\n", "59063\n"], ["56588\n", "56591\n"], ["1130\n", "1151\n"], ["1328\n", "1361\n"], ["9552...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#425"}
19a93e0b67f18e97
Valera has array a, consisting of n integers a0, a1, ..., an - 1, and function f(x), taking an integer from 0 to 2n - 1 as its single argument. Value f(x) is calculated by formula <image>, where value bit(i) equals one if the binary representation of number x contains a 1 on the i-th position, and zero otherwise. For ...
[["5\n17 0 10 2 1\n11010\n", "27\n"], ["2\n3 8\n10\n", "3\n"], ["1\n1\n1\n", "1\n"], ["43\n475 2165 8771 7146 8980 7209 9170 9006 6278 6661 4740 6321 7532 6869 3788 7918 1707 5070 3809 5189 2494 8255 1123 3197 190 5712 9873 3286 9997 133 9030 3067 8043 5297 5398 4240 8315 2141 1436 3297 247 8438 2300\n01110111001000111...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#61"}
19ab809fa29f7cc4
Kirito is stuck on a level of the MMORPG he is playing now. To move on in the game, he's got to defeat all n dragons that live on this level. Kirito and the dragons have strength, which is represented by an integer. In the duel between two opponents the duel's outcome is determined by their strength. Initially, Kirito'...
[["10 1\n10 10\n", "NO\n"], ["4 2\n2 1\n10 3\n", "NO\n"], ["2 5\n5 1\n2 1\n3 1\n1 1\n4 1\n", "YES\n"], ["1 2\n100 1\n100 1\n", "NO\n"], ["2 3\n1 1\n1 10\n17 2\n", "NO\n"], ["10 10\n2 10\n3 10\n4 10\n2 20\n3 20\n3 20\n100 50\n100 30\n150 30\n200 10\n", "NO\n"], ["6 2\n496 0\n28 8128\n", "NO\n"], ["50 3\n39 0\n38 0\n37 0...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#51"}
19aff0dc96768562
You are given n integers a_1, a_2, ..., a_{n}. Find the number of pairs of indexes i, j (i < j) that a_{i} + a_{j} is a power of 2 (i. e. some integer x exists so that a_{i} + a_{j} = 2^{x}). -----Input----- The first line contains the single positive integer n (1 ≤ n ≤ 10^5) — the number of integers. The second li...
[["4\n7 3 2 1\n", "2\n"], ["3\n1 1 1\n", "3\n"], ["1\n1000000000\n", "0\n"], ["10\n2827343 1373647 96204862 723505 796619138 71550121 799843967 5561265 402690754 446173607\n", "2\n"], ["10\n6 6 7 3 9 14 15 7 2 2\n", "9\n"], ["100\n3 6 12 1 16 4 9 5 4 4 5 8 12 4 6 14 5 1 2 2 2 1 7 1 9 10 6 13 7 8 3 11 8 11 7 5 15 6 14 1...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#514"}
19b69bfa88c313f7
You have array a that contains all integers from 1 to n twice. You can arbitrary permute any numbers in a. Let number i be in positions xi, yi (xi < yi) in the permuted array a. Let's define the value di = yi - xi — the distance between the positions of the number i. Permute the numbers in array a to minimize the valu...
[["1\n", "1 1 "], ["2\n", "1 1 2 2 "], ["10\n", "1 3 5 7 9 9 7 5 3 1 2 4 6 8 10 8 6 4 2 10 "], ["100\n", "1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 99 97 95 93 91 89 87 85 83 81 79 77 75 73 71 69 67 65 63 61 59 57 55 ...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#1636"}
19c1aef79ea867c6
In the probability theory the following paradox called Benford's law is known: "In many lists of random numbers taken from real sources, numbers starting with digit 1 occur much more often than numbers starting with any other digit" (that's the simplest form of the law). Having read about it on Codeforces, the Hedgeho...
[["1\n1 1000000000000000000\n50\n", "0.111111111111111\n"], ["1\n1 1\n100\n", "1.000000000000000\n"], ["15\n11 20\n16 18\n10 17\n11 17\n2 19\n12 20\n5 24\n17 17\n16 18\n22 23\n3 17\n4 5\n14 21\n23 25\n14 15\n73\n", "0.377283950617284\n"], ["1\n1000000000000000000 1000000000000000000\n100\n", "1.000000000000000\n"], ["1...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00003-of-00005.parquet#86"}
19c2986c96e0cc6b
Almost every text editor has a built-in function of center text alignment. The developers of the popular in Berland text editor «Textpad» decided to introduce this functionality into the fourth release of the product. You are to implement the alignment in the shortest possible time. Good luck! Input The input file c...
[["8\n\n\n\ny\nW\n\n\n\n3B\n\nw\nV\n\n\n\nL\nSr\n\n\nV\n\n5\n\nAq\n\n\n\nJ\nR\n\n04\nJ\nv\nhU\n\n\n\nY\nG\n4\n\nG\nb\n\n\n9\n\n6\nd\n\n2\n\n\nE\n7\n\nr\n\n\n\n\nKC\ns\nE\n\nab\n4\nx\n\n\n\n\n\nEe\n4\n\nl\n\np\n\nG\nM\n\n\nn\n\n\nm0\n\nw\n\n\nP\n\n\n\n0\n\n\n", "****\n*8 *\n* *\n* *\n* *\n* y*\n*W *\n* *\n* *\n* *...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1394"}
19d7e7f4af611c8e
There is an empty array. The following N operations will be performed to insert integers into the array. In the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array. Find the K-th smallest integer in the array after the N operations. For example, the 4-th smallest integer in the array \{1,2,...
[["3 4\n1 1\n2 2\n3 3\n", "3\n"], ["10 500000\n1 100000\n1 100000\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n", "1\n"], ["3 4\n1 1\n2 2\n3 2", "3\n"], ["10 500000\n1 100000\n1 100001\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1660"}
19df90f2e686b6fa
You have a string of decimal digits s. Let's define bij = si·sj. Find in matrix b the number of such rectangles that the sum bij for all cells (i, j) that are the elements of the rectangle equals a in each rectangle. A rectangle in a matrix is a group of four integers (x, y, z, t) (x ≤ y, z ≤ t). The elements of the r...
[["1\n39568795337451783387623217888229492030389256605973002137\n", "9\n"], ["1\n0\n", "0\n"], ["0\n0\n", "1\n"], ["0\n3123232011321302332331322102332011002122123113023032320333332330233131131123012232200000120323200110\n", "322176\n"], ["4\n111\n", "4\n"], ["3\n0130301201202102033203302203131122023031112010202333033033...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1829"}
19e642fd3168adf7
The student council is preparing for the relay race at the sports festival. The council consists of n members. They will run one after the other in the race, the speed of member i is s_i. The discrepancy d_i of the i-th stage is the difference between the maximum and the minimum running speed among the first i members...
[["3\n3 1 2\n", "\n3\n"], ["6\n1 6 3 3 6 3\n", "\n11\n"], ["6\n104 943872923 6589 889921234 1000000000 69\n", "\n2833800505\n"], ["1\n5\n", "\n0\n"], ["100\n9135 4978 1897 347 918 9160 9413 1712 2884 347 8724 4978 7037 7498 9022 814 6342 927 8180 1712 1897 9022 6046 6305 3146 6598 8489 9227 4319 4016 6046 4978 1712 411...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#1915"}
19ed6639706553c0
You have a string s — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands: * 'W' — move one cell up; * 'S' — move one cell down; * 'A' — move one cell left; * 'D' — move one cell right. Let Grid(s) be the grid of minimum possibl...
[["3\nDSAWWAW\nD\nWA\n", "8\n2\n4\n"], ["3\nDSAWWAW\nD\nAW\n", "8\n2\n4\n"], ["3\nWSAWDAW\nD\nAW\n", "4\n2\n4\n"], ["3\nDAAWWSW\nD\nAW\n", "6\n2\n4\n"], ["3\nWAWWASD\nD\nWA\n", "8\n2\n4\n"], ["3\nASAWWDW\nD\nWA\n", "8\n2\n4\n"], ["3\nWAWWASD\nD\nAW\n", "8\n2\n4\n"], ["3\nWSAWDAW\nD\nWA\n", "4\n2\n4\n"], ["3\nWDWWASA\nD...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00000-of-00005.parquet#2908"}
1a05787456b58642
You've got a positive integer sequence a_1, a_2, ..., a_{n}. All numbers in the sequence are distinct. Let's fix the set of variables b_1, b_2, ..., b_{m}. Initially each variable b_{i} (1 ≤ i ≤ m) contains the value of zero. Consider the following sequence, consisting of n operations. The first operation is assigning...
[["5\n1 2 3 6 8\n", "2\n"], ["3\n3 6 5\n", "-1\n"], ["6\n2 4 8 6 10 18\n", "3\n"], ["7\n1 2 4 5 3 6 7\n", "3\n"], ["10\n11 22 44 88 132 264 66 33 165 55\n", "5\n"], ["10\n201 402 804 603 1608 2010 1206 2412 4824 2211\n", "3\n"], ["16\n92 184 368 276 552 1104 1196 736 1472 1288 1012 2576 5152 1840 3680 1656\n", "5\n"], ...
1.19
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1561"}