messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"content": "When preparing a tournament, Codeforces coordinators try treir best to make the first problem as easy as possible. This time the coordinator had chosen some problem and asked $n$ people about their opinions. Each person answered whether this problem is easy or hard.\n\nIf at least one of these $n$... | [{"input": "100\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 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\n", "output": "EASY\n"}, {"input": "100\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 ... | code_stdio |
[
{
"content": "Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process.\n\nThere are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that ... | [{"input": "10 10 1\n351 0 3 7\n214 0 9 9\n606 0 7 8\n688 0 9 3\n188 3 0 9\n994 0 1 7\n372 5 0 14\n957 0 3 6\n458 8 0 7\n379 0 4 7\n", "output": "-1\n"}, {"input": "4 10 1\n988 0 1 1\n507 1 0 9\n798 1 0 9\n400 0 3 7\n242 2 0 8\n574 4 0 7\n458 0 4 9\n330 0 2 9\n303 2 0 8\n293 0 3 13\n", "output": "-1\n"}, {"input": "10 ... | code_stdio |
[
{
"content": "Pay attention to the non-standard memory limit in this problem.\n\nIn order to cut off efficient solutions from inefficient ones in this problem, the time limit is rather strict. Prefer to use compiled statically typed languages (e.g. C++). If you use Python, then submit solutions on PyPy. Try to ... | [{"input": "7\n2\n1 1\n2\n1 2\n2\n2 1\n2\n2 2\n12\n5 8 10 1 1 10 7 3 12 3 3 7\n5\n2 1 3 1 3\n4\n4 3 4 3\n", "output": "0\n0\n0\n0\n3\n2\n0\n"}, {"input": "7\n2\n1 1\n2\n1 2\n2\n2 1\n2\n2 2\n12\n5 8 10 1 1 10 7 3 12 3 3 7\n5\n2 1 3 1 3\n4\n4 3 4 3\n", "output": "0\n0\n0\n0\n3\n2\n0\n"}, {"input": "7\n2\n1 1\n2\n1 2\n2\n... | code_stdio |
[
{
"content": "Katsusando loves omelette rice.\nBesides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.\nTo prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.\nThe i-th person answe... | [{"input": "30 30\n30 18 27 26 17 24 6 29 5 10 4 16 2 30 14 12 3 11 19 1 21 28 20 23 15 25 9 8 7 22 13\n30 2 18 10 9 23 8 13 12 6 3 4 19 15 16 29 22 21 7 25 5 20 17 14 28 24 11 27 30 26 1\n30 18 23 13 19 10 2 12 21 11 28 1 17 26 27 22 29 14 3 15 9 8 5 6 25 30 16 20 7 24 4\n30 16 12 23 7 20 17 25 8 2 10 28 5 6 21 13 19 ... | code_stdio |
[
{
"content": "Gildong is experimenting with an interesting machine Graph Traveler. In Graph Traveler, there is a directed graph consisting of n vertices numbered from 1 to n. The i-th vertex has m_i outgoing edges that are labeled as e_i[0], e_i[1], β¦, e_i[m_i-1], each representing the destination vertex of the... | [{"input": "4\n4 -9 -1 -1\n2\n2 3\n1\n2\n3\n2 4 1\n4\n3 1 2 1\n6\n1 -1\n3 -1\n3 -1\n4 -4\n2 1\n1 5\n", "output": "1\n1\n1\n1\n1\n1\n"}, {"input": "4\n4 -9 -1 -1\n2\n2 3\n1\n2\n3\n2 4 1\n4\n3 1 2 1\n6\n1 -1\n3 0\n3 -1\n4 -4\n2 1\n1 5\n", "output": "1\n1\n1\n1\n1\n1\n"}, {"input": "4\n4 -5 -3 -1\n2\n2 3\n1\n2\n3\n2 4 1\n... | code_stdio |
[
{
"content": "After all the events in Orlando we all know, Sasha and Roma decided to find out who is still the team's biggest loser. Thankfully, Masha found somewhere a revolver with a rotating cylinder of n bullet slots able to contain exactly k bullets, now the boys have a chance to resolve the problem once a... | [{"input": "15 10 15\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n", "output": ".X.X.X.X.XXXXXX\n"}, {"input": "15 10 15\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n1\n14\n15\n", "output": ".X.X.X.X.XXX.XX"}, {"input": "15 10 15\n1\n2\n3\n3\n5\n6\n7\n8\n9\n10\n11\n12\n1\n14\n15\n", "output": ".X...X.X.XXX.XX"}, {"in... | code_stdio |
[
{
"content": "Folding a Ribbon\n\nThink of repetitively folding a very long and thin ribbon. First, the ribbon is spread out from left to right, then it is creased at its center, and one half of the ribbon is laid over the other. You can either fold it from the left to the right, picking up the left end of the ... | [{"input": "4 3 2\n30 578 1954\n59 471605241352156968 431565444592236940\n0 0 0", "output": "LRRR\nLLLLLRLLRLLLLLLLLLLRRRRLRLLLLL\nLRRRLRRLLRRRRLLLLRLLRRRLRRLLRLLLLLLRLRLLRLRLLLRLRLLRLLRRRLL\n"}, {"input": "4 3 2\n20 578 1954\n59 471605241352156968 431565444592236940\n0 0 0", "output": "LRRR\nLLLLLRLLRRRRRLRLLLLL\nLRRR... | code_stdio |
[
{
"content": "Ehab has an array $a$ of length $n$. He has just enough free time to make a new array consisting of $n$ copies of the old array, written back-to-back. What will be the length of the new array's longest increasing subsequence?\n\nA sequence $a$ is a subsequence of an array $b$ if $a$ can be obtaine... | [{"input": "4\n7\n6 6 12 8 6 6 6\n1\n2\n5\n4 5 9 2 7\n7\n1 2 7 1 6 20 2\n", "output": "3\n1\n5\n5\n"}, {"input": "4\n7\n6 6 12 8 6 5 6\n1\n2\n5\n4 5 9 2 7\n7\n1 2 7 1 6 20 2\n", "output": "4\n1\n5\n5\n"}, {"input": "4\n7\n6 6 8 8 6 6 6\n1\n2\n5\n4 5 9 8 7\n7\n1 2 7 1 6 10 2\n", "output": "2\n1\n5\n5\n"}, {"input": "4\n... | code_stdio |
[
{
"content": "Not so long ago company R2 bought company R1 and consequently, all its developments in the field of multicore processors. Now the R2 laboratory is testing one of the R1 processors.\n\nThe testing goes in n steps, at each step the processor gets some instructions, and then its temperature is measur... | [{"input": "100 99 1 2\n2 1 1 1 2 2 1 1 1 2 2 2 1 2 1 1 2 1 1 2 1 2 2 1 2 1 2 1 2 1 2 2 2 2 1 1 1 1 1 2 1 2 2 1 2 2 2 1 1 1 1 1 2 2 2 2 1 2 2 1 1 1 2 1 1 2 1 1 2 1 2 1 2 1 1 1 1 2 1 1 0 1 1 2 2 2 1 1 1 1 2 2 2 2 1 1 2 2 2\n", "output": "Incorrect\n"}, {"input": "100 99 1 2\n2 1 1 1 2 2 1 1 1 2 2 2 1 2 1 1 2 1 1 2 1 2 2... | code_stdio |
[
{
"content": "Zane the wizard had never loved anyone before, until he fell in love with a girl, whose name remains unknown to us.\n\n [Image] \n\nThe girl lives in house m of a village. There are n houses in that village, lining in a straight line from left to right: house 1, house 2, ..., house n. The village ... | [{"input": "100 1 100\n0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 110 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100... | code_stdio |
[
{
"content": "In BerSoft $n$ programmers work, the programmer $i$ is characterized by a skill $r_i$.\n\nA programmer $a$ can be a mentor of a programmer $b$ if and only if the skill of the programmer $a$ is strictly greater than the skill of the programmer $b$ $(r_a > r_b)$ and programmers $a$ and $b$ are not i... | [{"input": "10 35\n322022227 751269818 629795150 369443545 344607287 250044294 476897672 184054549 986884572 917181121\n6 3\n7 3\n1 9\n7 9\n10 7\n3 4\n8 6\n7 4\n6 10\n7 2\n3 5\n6 9\n3 10\n8 7\n6 5\n8 1\n8 5\n1 7\n8 10\n8 2\n1 5\n10 4\n6 7\n4 6\n2 6\n5 4\n9 10\n9 2\n4 8\n5 9\n4 1\n3 2\n2 1\n4 2\n9 8\n", "output": "1 1 2... | code_stdio |
[
{
"content": "There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.\n\nLimak is a police officer. He lives in a city a. His job is to catch criminals. It's hard because he doesn't know in which cities criminals are. Th... | [{"input": "100 100\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 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 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 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", "output": "100\n"}, {"input": "100 100\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 1 1... | code_stdio |
[
{
"content": "Yurii is sure he can do everything. Can he solve this task, though?\n\nHe has an array $a$ consisting of $n$ positive integers. Let's call a subarray $a[l...r]$ good if the following conditions are simultaneously satisfied: $l+1 \\leq r-1$, i.Β e. the subarray has length at least $3$; $(a_l \\op... | [{"input": "10\n997230370 58052053 240970544 715275815 250707702 156801523 44100666 64791577 43523002 480196854\n", "output": "2\n"}, {"input": "10\n997230370 58052053 240970544 715275815 250707702 156801523 44100666 64791577 43523002 480196854\n", "output": "2"}, {"input": "10\n997230370 58052053 240970544 715275815 2... | code_stdio |
[
{
"content": "The tram in Berland goes along a straight line from the point 0 to the point s and back, passing 1 meter per t_1 seconds in both directions. It means that the tram is always in the state of uniform rectilinear motion, instantly turning around at points x = 0 and x = s.\n\nIgor is at the point x_1.... | [{"input": "1000 812 976\n230 1000\n1006 -1\n", "output": "164000\n"}, {"input": "1000 394 798\n155 1242\n954 -1\n", "output": "271560\n"}, {"input": "1000 812 976\n230 1000\n696 -1\n", "output": "164000\n"}, {"input": "1000 394 798\n155 1242\n934 -1\n", "output": "268460\n"}, {"input": "1000 812 976\n230 1000\n453 -1\... | code_stdio |
[
{
"content": "N tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N.\nThe i-th tile from the left is painted black if the i-th character of S is 0, and painted white if that character is 1.\nYou want to repaint some of the tiles black or white,... | [{"input": "01010000100110111100010011111100001010101111001100001010101000100101100011110011111110100011000001111011010011100010010111011001011000010110011100111010111111010100010111100100110000100010010011101001001110000100110101011001100000010111101101100100010011110010110010101100100011001010110010000101010101011000... | code_stdio |
[
{
"content": "Given are a sequence of N positive integers A_1, A_2, \\ldots, A_N, and a positive integer K.\nFind 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... | [{"input": "10 3\n14 26 111 65 35 89 184 32 38 46", "output": "4\n"}, {"input": "10 11\n14 26 111 0 35 27 95 13 38 63", "output": "12\n"}, {"input": "10 13\n14 15 101 65 35 89 95 32 38 46", "output": "6\n"}, {"input": "10 7\n14 15 92 65 35 89 79 32 38 46\n", "output": "8\n"}, {"input": "10 7\n14 15 101 65 35 89 79 32 3... | code_stdio |
[
{
"content": "There are $n$ slimes in a row. Each slime has an integer value (possibly negative or zero) associated with it.\n\nAny slime can eat its adjacent slime (the closest slime to its left or to its right, assuming that this slime exists). \n\nWhen a slime with a value $x$ eats a slime with a value $y$, ... | [{"input": "10\n-20 1 3 -5 -27 18 -3 -9 -7 9\n", "output": "102\n"}, {"input": "10\n-20 0 3 -5 -18 15 -3 -9 -7 9\n", "output": "89\n"}, {"input": "10\n-20 0 3 -5 -27 15 -3 -9 -7 9\n", "output": "98\n"}, {"input": "10\n-20 1 3 -5 -27 15 -3 -9 -7 9\n", "output": "99\n"}, {"input": "10\n-20 0 3 -5 -18 15 -3 -9 -7 9\n", "o... | code_stdio |
[
{
"content": "The sequence of $m$ integers is called the permutation if it contains all integers from $1$ to $m$ exactly once. The number $m$ is called the length of the permutation.\n\nDreamoon has two permutations $p_1$ and $p_2$ of non-zero lengths $l_1$ and $l_2$.\n\nNow Dreamoon concatenates these two perm... | [{"input": "6\n5\n1 4 3 2 1\n6\n2 4 1 3 3 1\n4\n2 1 1 2\n4\n1 3 3 1\n12\n2 1 3 5 5 6 7 8 9 1 10 2\n3\n1 2 1\n", "output": "2\n1 4\n4 1\n0\n1\n2 2\n0\n0\n2\n1 2\n2 1\n"}, {"input": "6\n5\n1 4 3 2 1\n6\n2 4 1 3 2 1\n4\n2 1 1 3\n4\n1 3 3 1\n12\n2 1 3 4 5 6 7 8 9 1 10 2\n3\n1 1 1\n", "output": "2\n1 4\n4 1\n1\n4 2\n0\n0\n1... | code_stdio |
[
{
"content": "There are N pieces of sushi. Each piece has two parameters: \"kind of topping\" t_i and \"deliciousness\" d_i.\nYou are choosing K among these N pieces to eat.\nYour \"satisfaction\" here will be calculated as follows:\n - The satisfaction is the sum of the \"base total deliciousness\" and the \"v... | [{"input": "1916 1626\n876 259545863\n275 561842149\n426 683968511\n234 568067978\n1649 76930683\n904 347657912\n1805 554767907\n151 166599168\n1652 995819129\n66 696036303\n1623 580173203\n739 759362608\n1877 78935906\n279 464616918\n217 367427797\n815 68145141\n1050 546297174\n1817 150025584\n508 799430434\n1766 6014... | code_stdio |
[
{
"content": "Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white.\n\nConsider a set consisting of k (0 β€ k < n) edges of Appleman's tree. If Appleman deletes these edges from the tree, then it will split into (k + 1) parts. Note, that ... | [{"input": "100\n0 0 2 2 0 3 5 0 6 2 0 4 0 2 3 7 8 3 15 19 13 8 18 19 3 14 23 9 6 3 6 17 26 24 20 6 4 27 8 5 14 5 35 31 27 3 41 25 20 14 25 31 49 40 0 1 10 5 50 13 29 58 1 6 8 1 40 52 30 15 50 8 66 52 29 71 25 68 36 7 80 60 6 2 11 43 62 27 84 86 71 38 14 50 88 4 8 95 53\n1 0 0 1 0 0 1 0 1 0 0 0 1 0 1 1 0 1 1 1 1 0 0 0 ... | code_stdio |
[
{
"content": "Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.\n\nConstraints\n\n* $0 < n \\leq 10000$\n* $-1000000 \\leq a_i \\leq 1000000$\n\nInput\n\nIn the first line, an integer $n$ is given. In the next lin... | [{"input": "5\n114 0 -15 -1 2", "output": "-15 114 100\n"}, {"input": "5\n114 -1 -15 -1 2", "output": "-15 114 99\n"}, {"input": "5\n112 -1 -15 -1 2", "output": "-15 112 97\n"}, {"input": "5\n112 1 -14 -1 2", "output": "-14 112 100\n"}, {"input": "5\n112 0 -15 -1 2", "output": "-15 112 98\n"}, {"input": "5\n112 1 -15 -... | code_stdio |
[
{
"content": "Madoka wants to enter to \"Novosibirsk State University\", but in the entrance exam she came across a very difficult task:\n\nGiven an integer $n$, it is required to calculate $\\sum{\\operatorname{lcm}(c, \\gcd(a, b))}$, for all triples of positive integers $(a, b, c)$, where $a + b + c = n$.\n\n... | [{"input": "100000\n", "output": "454535891\n"}, {"input": "69228\n", "output": "778304278\n"}, {"input": "94874\n", "output": "584783437\n"}, {"input": "99413\n", "output": "461761995\n"}, {"input": "99913\n", "output": "550761256\n"}, {"input": "1337\n", "output": "425608851\n"}, {"input": "228\n", "output": "3369368... | code_stdio |
[
{
"content": "The server in company A has a structure where N devices numbered 1, 2, ..., N are connected with N - 1 cables. The i-th cable connects Device U_i and Device V_i. Any two different devices are connected through some number of cables.\n\nEach device v (1 \\leq v \\leq N) has a non-zero integer A_v, ... | [{"input": "10\n5 4 15 5 1 5 -1 10 -10 -20\n10 4\n5 6\n8 1\n9 5\n7 1\n10 3\n2 8\n2 10\n9 1", "output": "1\n"}, {"input": "10\n3 4 9 6 1 10 -1 10 -10 -10\n7 4\n5 6\n8 1\n9 5\n7 1\n10 3\n2 8\n4 10\n9 2", "output": "4\n"}, {"input": "10\n3 4 9 6 0 10 -1 10 -10 -10\n7 4\n5 6\n8 1\n9 5\n7 1\n10 3\n2 8\n4 10\n9 2", "output":... | code_stdio |
[
{
"content": "Floating-Point Numbers\n\nIn this problem, we consider floating-point number formats, data representation formats to approximate real numbers on computers.\n\nScientific notation is a method to express a number, frequently used for numbers too large or too small to be written tersely in usual deci... | [{"input": "1\n0000000000100000000000000000000000000000000000000000\n2\n0000000000000000000000000000000000000000000000000000\n2\n0000000000000000001000000000000000000000000000000000\n11\n0000000000000000000000000000000000000000000000000000\n7\n1101000000000000000000000000000000000000000000000000\n100\n11000110101000011... | code_stdio |
[
{
"content": "You are given n integer numbers a_1, a_2, ..., a_n. Consider graph on n nodes, in which nodes i, j (iβ j) are connected if and only if, a_i AND a_jβ 0, where AND denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_operation#AND).\n\nFind the length of the shortest cycle in th... | [{"input": "150\n0 0 0 0 0 0 0 2537672836907008 0 0 0 0 0 0 16384 0 0 0 0 34360787232 0 0 70871155232 0 0 0 0 0 0 0 0 0 0 0 2256197860262016 0 0 0 0 0 0 0 0 0 0 536872961 0 0 0 0 0 0 0 0 0 0 33619968 0 0 0 0 0 0 0 0 0 0 0 0 37189881297899520 0 18031990695526400 0 0 1099511627776 0 0 0 0 0 0 0 0 2097152 0 0 0 134217984 ... | code_stdio |
[
{
"content": "Chain Disappearance Puzzle\n\nWe are playing a puzzle. An upright board with H rows by 5 columns of cells, as shown in the figure below, is used in this puzzle. A stone engraved with a digit, one of 1 through 9, is placed in each of the cells. When three or more stones in horizontally adjacent cel... | [{"input": "1\n6 9 9 9 9\n5\n3 9 6 0 12\n5 6 6 9 9\n4 6 3 10 15\n3 2 2 14 9\n2 2 1 1 1\n10\n3 10 6 5 6\n2 4 1 8 3\n6 2 7 9 2\n8 7 7 6 1\n7 9 6 4 9\n8 9 1 1 10\n5 6 1 8 0\n6 8 2 1 2\n9 6 3 3 5\n5 3 8 8 8\n5\n1 2 3 4 5\n6 7 8 9 1\n2 3 4 5 6\n7 8 9 1 2\n4 4 1 6 12\n3\n2 2 4 7 4\n6 5 7 7 7\n8 8 2 9 9\n0", "output": "36\n9\... | code_stdio |
[
{
"content": "Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.\n\nOne day Vasya decided to collect the results of all contests where his favorite coder participated and track the progres... | [{"input": "100\n9999 9999 9999 9998 9998 9998 9997 9996 9996 9995 9993 9993 9991 9990 9989 9986 9984 9984 9983 9981 9981 10079 9980 9980 9979 9977 9977 9977 9977 9977 9976 9976 9975 9975 9973 9972 9972 9972 9972 9971 9969 9969 9969 9968 9967 9965 9962 9962 9962 9962 9960 9958 9958 9955 9954 9954 9954 9954 9950 9949 99... | code_stdio |
[
{
"content": "It is known that the area of a regular dodecagon inscribed in a circle of radius a is 3a^2.\nGiven an integer r, find the area of a regular dodecagon inscribed in a circle of radius r.\n\n-----Constraints-----\n - 1 \\leq r \\leq 100\n - r is an integer.\n\n-----Input-----\nInput is given from Sta... | [{"input": "100\n", "output": "30000\n"}, {"input": "270", "output": "218700\n"}, {"input": "256", "output": "196608\n"}, {"input": "203", "output": "123627\n"}, {"input": "196", "output": "115248\n"}, {"input": "251", "output": "189003\n"}, {"input": "397", "output": "472827\n"}, {"input": "239", "output": "171363\n"}... | code_stdio |
[
{
"content": "Berland has a long and glorious history. To increase awareness about it among younger citizens, King of Berland decided to compose an anthem.\n\nThough there are lots and lots of victories in history of Berland, there is the one that stand out the most. King wants to mention it in the anthem as ma... | [{"input": "????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????\nrcmcsc... | code_stdio |
[
{
"content": "In olden days finding square roots seemed to be difficult but nowadays it can be easily done using in-built functions available across many languages \n.\n\nAssume that you happen to hear the above words and you want to give a try in finding the square root of any given integer using in-built func... | [{"input": "3\n18\n10\n10000", "output": "4\n3\n100\n"}, {"input": "3\n17\n16\n10010", "output": "4\n4\n100\n"}, {"input": "3\n10\n5\n10010", "output": "3\n2\n100\n"}, {"input": "3\n1\n11\n10000", "output": "1\n3\n100\n"}, {"input": "3\n10\n2\n10100", "output": "3\n1\n100\n"}, {"input": "3\n1\n12\n11100", "output": "1\... | code_stdio |
[
{
"content": "Some time ago Mister B detected a strange signal from the space, which he started to study.\n\nAfter some transformation the signal turned out to be a permutation p of length n or its cyclic shift. For the further investigation Mister B need some basis, that's why he decided to choose cyclic shift... | [{"input": "108\n1 102 33 99 6 83 4 20 61 100 76 71 44 9 24 87 57 2 81 82 90 85 12 30 66 53 47 36 43 29 31 64 96 84 77 23 93 78 58 68 42 55 13 70 62 19 92 14 10 65 63 75 91 48 11 105 37 50 32 94 18 26 52 89 104 106 86 97 80 95 17 72 40 22 79 103 25 101 35 51 15 98 67 5 34 69 54 27 45 88 56 16 46 60 74 108 21 41 73 39 1... | code_stdio |
[
{
"content": "We have two distinct integers A and B.\nPrint the integer K such that |A - K| = |B - K|.\nIf such an integer does not exist, print IMPOSSIBLE instead.\n\n-----Constraints-----\n - All values in input are integers.\n - 0 \\leq A,\\ B \\leq 10^9\n - A and B are distinct.\n\n-----Input-----\nInput is... | [{"input": "999999999 1000000000\n", "output": "IMPOSSIBLE\n"}, {"input": "369673908 845644227\n", "output": "IMPOSSIBLE\n"}, {"input": "232334010 962483782\n", "output": "597408896\n"}, {"input": "274100628 29096111\n", "output": "IMPOSSIBLE\n"}, {"input": "467793935 691627457\n", "output": "579710696\n"}, {"input": "... | code_stdio |
[
{
"content": "Of the real numbers, those with a circular decimal part and those with a finite number of digits can be expressed as fractions.\n\n\n\n\nGiven a real number that can be represented by a fraction, write a program that outputs an irreducible fraction equal to that real number (a fraction that cannot... | [{"input": "3.2(145)", "output": "32113/9990\n"}, {"input": "3.3(145)", "output": "16556/4995\n"}, {"input": "5.21(43)", "output": "25811/4950\n"}, {"input": "3.3(155)", "output": "16561/4995\n"}, {"input": "4.21(43)", "output": "20861/4950\n"}, {"input": "4.21(42)", "output": "13907/3300\n"}, {"input": "4.21(32)", "ou... | code_stdio |
[
{
"content": "Vasiliy is fond of solving different tasks. Today he found one he wasn't able to solve himself, so he asks you to help.\n\nVasiliy is given n strings consisting of lowercase English letters. He wants them to be sorted in lexicographical order (as in the dictionary), but he is not allowed to swap a... | [{"input": "10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\naaaaaaaaaaab\nab\naab\naaab\naaaab\naaaaab\naaaaaab\naaaaaaab\naaaaaaaab\naaaaaaaaab\n", "output": "8000000000\n"}, {"input": "10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000... | code_stdio |
[
{
"content": "You are given $n$ one-dimensional segments (each segment is denoted by two integers β its endpoints).\n\nLet's define the function $f(x)$ as the number of segments covering point $x$ (a segment covers the point $x$ if $l \\le x \\le r$, where $l$ is the left endpoint and $r$ is the right endpoint ... | [{"input": "9\n4 3\n1 3\n7 9\n2 5\n3 6\n2 9\n1 4\n3 7\n1 3\n2 4\n3 5\n1 4\n6 7\n5 5\n4 3\n1 3\n7 9\n2 5\n3 6\n2 9\n1 4\n3 7\n1 3\n2 4\n3 5\n1 4\n6 7\n5 5\n1 4\n3 7\n", "output": "YES\nNO\nNO\nYES\nYES\nNO\nNO\nYES\nNO\n"}, {"input": "4\n4 3\n1 3\n7 9\n2 5\n3 6\n2 9\n1 4\n3 7\n1 3\n2 4\n3 5\n1 4\n6 7\n5 5\n", "output": ... | code_stdio |
[
{
"content": "The restaurant AtCoder serves the following five dishes:\n - ABC Don (rice bowl): takes A minutes to serve.\n - ARC Curry: takes B minutes to serve.\n - AGC Pasta: takes C minutes to serve.\n - APC Ramen: takes D minutes to serve.\n - ATC Hanbagu (hamburger patty): takes E minutes to serve.\nHere,... | [{"input": "123\n123\n123\n123\n123\n", "output": "643\n"}, {"input": "123\n123\n161\n123\n123", "output": "681\n"}, {"input": "123\n123\n161\n123\n163", "output": "721\n"}, {"input": "123\n123\n161\n123\n263", "output": "821\n"}, {"input": "101\n86\n119\n108\n57\n", "output": "481\n"}, {"input": "123\n123\n40\n123\n26... | code_stdio |
[
{
"content": "Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integers (positive, negative and zero). At the beginning she is standing at the cell 0.\n\nThere are also n cards, each card has 2 attributes: length li and cost ci. If she pays ci dollars then she can ap... | [{"input": "35\n512 172290165 12 128 134217728 8192 33554432 33554432 536870912 512 65536 1048576 32768 512 524288 1024 536870912 536870912 16 32 33554432 134217728 2 16 16777216 8192 262144 65536 33554432 128 4096 2097152 33554432 2097152 2\n36157 67877 79710 63062 13319 36255 61053 83828 93590 74236 5281 28143 7350 4... | code_stdio |
[
{
"content": "Xenia is a girl being born a noble. Due to the inflexibility and harshness of her family, Xenia has to find some ways to amuse herself.\n\nRecently Xenia has bought $n_r$ red gems, $n_g$ green gems and $n_b$ blue gems. Each of the gems has a weight.\n\nNow, she is going to pick three gems.\n\nXeni... | [{"input": "1\n10 10 10\n761 829 1037 1818 133 576 705 131 935 821\n896 163 569 957 169 475 342 1074 760 434\n131 383 243 247 908 799 56 1929 360 189\n", "output": "1928\n"}, {"input": "1\n10 10 10\n761 829 1037 1818 133 576 705 131 935 821\n896 163 569 656 169 475 342 1074 760 434\n131 383 243 247 908 799 56 1929 360 ... | code_stdio |
[
{
"content": "Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.\n\nDuring all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several... | [{"input": "100\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 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\n", "output": "100\n"}, {"input": "100\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 1 1 1 1 1 1... | code_stdio |
[
{
"content": "You want to make change for $ n $ cents. Assuming that you have infinite supply of coins of 1, 5, 10 and / or 25 cents coins respectively, find the minimum number of coins you need.\n\nConstraints\n\n* $ 1 \\ le n \\ le 10 ^ 9 $\n\nInput\n\n\n$ n $\n\n\nThe integer $ n $ is given in a line.\n\nout... | [{"input": "251195", "output": "10049\n"}, {"input": "467454", "output": "18702\n"}, {"input": "698278", "output": "27934\n"}, {"input": "323456", "output": "12940\n"}, {"input": "164898", "output": "6600\n"}, {"input": "122288", "output": "4895\n"}, {"input": "111927", "output": "4479\n"}, {"input": "163537", "output"... | code_stdio |
[
{
"content": "You are given strings s and t, consisting of lowercase English letters.\nYou will create a string s' by freely rearranging the characters in s.\nYou will also create a string t' by freely rearranging the characters in t.\nDetermine whether it is possible to satisfy s' < t' for the lexicographic or... | [{"input": "ratcode\natlas\n", "output": "Yes\n"}, {"input": "ratcode\nsalta", "output": "Yes\n"}, {"input": "ratcode\nsalt`", "output": "Yes\n"}, {"input": "rdtcoae\nsalt`", "output": "Yes\n"}, {"input": "eaoctdr\nsalt`", "output": "Yes\n"}, {"input": "rdtcoae\nsalta", "output": "Yes\n"}, {"input": "rdtcoae\natlas", "... | code_stdio |
[
{
"content": "This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the shape of a rectangle (which possibly can be... | [{"input": "1\n1\n34\n- 1\n+ 1\n+ 1\n+ 1\n+ 1\n+ 1\n+ 1\n+ 1\n+ 1\n+ 1\n- 1\n- 1\n- 1\n- 1\n- 1\n+ 2\n+ 2\n+ 2\n+ 2\n- 1\n+ 2\n+ 2\n- 1\n+ 2\n- 1\n+ 3\n+ 3\n+ 1\n- 1\n- 2\n- 2\n- 2\n+ 1\n+ 3\n", "output": "NO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\nYES... | code_stdio |
[
{
"content": "Your task is to shuffle a deck of n cards, each of which is marked by a alphabetical letter.\n\nA single shuffle action takes out h cards from the bottom of the deck and moves them to the top of the deck.\n\nThe deck of cards is represented by a string as follows.\n\n\nabcdeefab\n\n\nThe first cha... | [{"input": "caaa\n3\n1\n-1\n2\nvwxyz\n2\n3\n4\n-", "output": "aaca\nxyzvw\n"}, {"input": "caaa\n3\n1\n-2\n2\nwwxyz\n2\n3\n4\n-", "output": "aaac\nxyzww\n"}, {"input": "caaa\n3\n1\n-2\n2\nwwxyz\n2\n4\n4\n-", "output": "aaac\nyzwwx\n"}, {"input": "caaa\n3\n0\n0\n2\nvxxyz\n2\n1\n10\n-", "output": "aaca\nxxyzv\n"}, {"input... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \n\nYou are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.\n\nYou want to maximize the value of interaction of the arrays... | [{"input": "2\n2 2\n2 2\n-4 6\n3 9\n1 2 -3\n-2 -1 -4", "output": "16\n44\n"}, {"input": "2\n2 4\n0 2\n-1 10\n3 3\n1 2 -3\n-4 3 -5", "output": "60\n32\n"}, {"input": "2\n2 4\n0 2\n-1 10\n3 1\n1 2 -3\n-4 3 -5", "output": "60\n22\n"}, {"input": "2\n2 4\n0 2\n-1 10\n3 1\n1 3 -3\n-4 3 -5", "output": "60\n25\n"}, {"input": "... | code_stdio |
[
{
"content": "Your friend is developing a computer game. He has already decided how the game world should look like β it should consist of n locations connected by m two-way passages. The passages are designed in such a way that it should be possible to get from any location to any other location.\n\nOf course,... | [{"input": "50 72\n35 38\n19 46\n35 12\n27 30\n23 41\n50 16\n31 6\n20 33\n38 1\n10 35\n13 43\n29 25\n25 4\n1 13\n4 20\n36 29\n13 47\n48 5\n30 21\n30 38\n28 50\n41 45\n25 43\n40 36\n19 47\n31 32\n26 28\n8 13\n43 24\n27 35\n14 29\n14 38\n50 9\n34 49\n12 34\n43 42\n41 15\n46 29\n48 11\n48 7\n40 29\n48 21\n18 26\n15 11\n12... | code_stdio |
[
{
"content": "Sometimes Mister B has free evenings when he doesn't know what to do. Fortunately, Mister B found a new game, where the player can play against aliens.\n\nAll characters in this game are lowercase English letters. There are two players: Mister B and his competitor.\n\nInitially the players have a ... | [{"input": "12 12 876543210 1000000000\n", "output": "13\n"}, {"input": "12 12 876543210 1000000000\n", "output": "13"}, {"input": "10 12 220000011 220000032\n", "output": "11\n"}, {"input": "5 10 1000000000 1000000000\n", "output": "1\n"}, {"input": "11 3 378541409 1077499882\n", "output": "19\n"}, {"input": "10 12 22... | code_stdio |
[
{
"content": "<image>\n\n\nThere used to be a game called Joseph's potatoes. Let's say n people are participating. Participants form a circle facing the center and are numbered starting from 1. One hot potato is given to participant n (the large number 30 inside the figure on the left). Participants who are giv... | [{"input": "44 3\n45 10\n0 0", "output": "40\n33\n"}, {"input": "75 2\n16 14\n0 0", "output": "23\n10\n"}, {"input": "18 3\n45 10\n0 0", "output": "14\n33\n"}, {"input": "26 3\n45 10\n0 0", "output": "17\n33\n"}, {"input": "75 2\n16 17\n0 0", "output": "23\n12\n"}, {"input": "13 2\n16 17\n0 0", "output": "11\n12\n"}, {... | code_stdio |
[
{
"content": "There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will l... | [{"input": "17\n.......RRRRR.....\n", "output": "8 13\n"}, {"input": "17\n.....RRRRR.......\n", "output": "6 11\n"}, {"input": "17\n......RRRRR......\n", "output": "7 12\n"}, {"input": "13\n....LLLLLL...\n", "output": "10 4\n"}, {"input": "13\n...LLLLLL....\n", "output": "9 3\n"}, {"input": "11\n.RRRLLLLL..\n", "output... | code_stdio |
[
{
"content": "You have a new professor of graph theory and he speaks very quickly. You come up with the following plan to keep up with his lecture and make notes.\n\nYou know two languages, and the professor is giving the lecture in the first one. The words in both languages consist of lowercase English charact... | [{"input": "10 22\nazbrll oen\ngh vdyayei\njphveblohx vfglv\nmfyxib jepnvhcuwo\nrpikazqj uam\nl rx\nokjenof qpnyi\nj tixqrno\nod itozmfct\nikkdxmirx ev\nqexftojc p\nkdazb zjs\nmbk ykvqjrxaxu\nhbcwhouzq pwt\nmirpsz zfaegpl\nuhkkvcj rlvwj\nef iqnnwtolrc\npjzfcpmeag ecdayth\nsa qcthz\ncbfhfxi qrnbvdryz\nwqel tj\natx smkbi... | code_stdio |
[
{
"content": "Iβm planning to have a party on my birthday. Many of my friends will come to the party. Some of them will come with one or more pieces of cakes, but it is not certain if the number of the cakes is a multiple of the number of people coming.\n\nI wish to enjoy the cakes equally among the partiers. S... | [{"input": "0 5\n11 7 4 -1 15", "output": "36\n"}, {"input": "0 1\n15 0 -1 -1 1", "output": "15\n"}, {"input": "0 1\n45 -3 -1 1 2", "output": "45\n"}, {"input": "0 2\n56 -3 -1 1 2", "output": "53\n"}, {"input": "0 5\n11 7 4 0 15", "output": "37\n"}, {"input": "0 1\n11 7 4 0 15", "output": "11\n"}, {"input": "0 3\n-2 97... | code_stdio |
[
{
"content": "There are N bags, each containing two white balls. The i-th box contains two balls with integers x_i and y_i written on them, respectively.\nFor each of these bags, you will paint one of the balls red, and paint the other blue.\nAfterwards, the 2N balls will be classified according to color.\nThen... | [{"input": "2\n1 1\n1000000000 1000000000\n", "output": "999999998000000001\n"}, {"input": "2\n1 1\n1000000000 1000000100", "output": "1000000097999999901\n"}, {"input": "2\n1 1\n1000000000 1000100100", "output": "1000100097999899901\n"}, {"input": "2\n1 1\n1100000000 1000000000", "output": "1099999997900000001\n"}, {"... | code_stdio |
[
{
"content": "Moamen and Ezzat are playing a game. They create an array $a$ of $n$ non-negative integers where every element is less than $2^k$.\n\nMoamen wins if $a_1 \\,\\&\\, a_2 \\,\\&\\, a_3 \\,\\&\\, \\ldots \\,\\&\\, a_n \\ge a_1 \\oplus a_2 \\oplus a_3 \\oplus \\ldots \\oplus a_n$.\n\nHere $\\&$ denotes... | [{"input": "5\n200000 200000\n200000 200000\n200000 200000\n200000 200000\n200000 200000\n", "output": "226490044\n226490044\n226490044\n226490044\n226490044\n"}, {"input": "5\n200000 200000\n200000 200000\n200000 200000\n200000 200000\n200000 200000\n", "output": "226490044\n226490044\n226490044\n226490044\n226490044\... | code_stdio |
[
{
"content": "Given is a positive integer N. Consider repeatedly applying the operation below on N:\n - First, choose a positive integer z satisfying all of the conditions below:\n - z can be represented as z=p^e, where p is a prime number and e is a positive integer;\n - z divides N;\n - z is different from al... | [{"input": "1000000000000\n", "output": "8\n"}, {"input": "200560490130\n", "output": "11\n"}, {"input": "755827200000\n", "output": "10\n"}, {"input": "366735600000\n", "output": "10\n"}, {"input": "997764507000\n", "output": "7\n"}, {"input": "549755813888\n", "output": "8\n"}, {"input": "999999999989\n", "output": "... | code_stdio |
[
{
"content": "In the evening Polycarp decided to analyze his today's travel expenses on public transport.\n\nThe bus system in the capital of Berland is arranged in such a way that each bus runs along the route between two stops. Each bus has no intermediate stops. So each of the buses continuously runs along t... | [{"input": "27 8 1 0 1\nBcd A\nA b\nb BcDc\ndc dbaC\ndbaC dcCB\nB d\nd BbAc\nCBC b\nDBDca d\ncAbb AA\nAA Ba\ncAccb DBDca\ncb DdaB\nAAcBc Ba\nBa dc\ndc DDCd\nbcBDA da\nbDD ADD\nAA b\nb cb\ncb CCBbd\nCCBbd bcDdb\nbcDdb ddc\nddc C\nC Adc\nAdc BbAc\nBbAc DD\n", "output": "111\n"}, {"input": "27 8 1 0 1\nBcd A\nA b\nb BcDc\... | code_stdio |
[
{
"content": "Evlampiy has found one more cool application to process photos. However the application has certain limitations.\n\nEach 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 po... | [{"input": "101 9\n3 2 2 1 4 1 3 2 3 4 3 2 3 1 4 4 1 1 4 1 3 3 4 1 2 1 1 3 1 2 2 4 3 1 4 3 1 1 4 4 1 2 1 1 4 2 3 4 1 2 1 4 4 1 4 3 1 4 2 1 2 1 4 3 4 3 4 2 2 4 3 2 1 3 4 3 2 2 4 3 3 2 4 1 3 2 2 4 1 3 4 2 1 3 3 2 2 1 1 3 1\n", "output": "0\n"}, {"input": "101 9\n3 2 2 1 4 1 3 2 3 4 3 2 3 1 4 4 1 1 4 1 3 3 4 1 2 1 1 3 1 2... | code_stdio |
[
{
"content": "Vladimir would like to prepare a present for his wife: they have an anniversary! He decided to buy her exactly $n$ flowers.\n\nVladimir went to a flower shop, and he was amazed to see that there are $m$ types of flowers being sold there, and there is unlimited supply of flowers of each type. Vladi... | [{"input": "1\n7 7\n873108721 195635452\n42649954 997221147\n873108721 1003477544\n1087176458 873108721\n1130734166 858693746\n1309378041 372607189\n1000000000 427003887\n", "output": "7410830018\n"}, {"input": "1\n7 7\n873108721 195635452\n66631086 997221147\n1700956320 1570665517\n1087176458 779474384\n596405150 5023... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \nZombies zombies everywhere!!Β \nIn a parallel world of zombies, there are N zombies. There are infinite number of unused cars, each of same model only differentiated by the their colors. The cars are of K colors.\n\nA z... | [{"input": "2\n2 6\n16 17", "output": "30\n118740505\n"}, {"input": "2\n2 6\n19 17", "output": "30\n361105078\n"}, {"input": "2\n2 6\n29 17", "output": "30\n684841218\n"}, {"input": "2\n2 6\n19 34", "output": "30\n525446287\n"}, {"input": "2\n3 6\n9 17", "output": "150\n14443521\n"}, {"input": "2\n1 6\n16 17", "output"... | code_stdio |
[
{
"content": "Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.\n\nConstraints\n\n* $0 \\leq S \\leq 86400$\n\nInput\n\nAn integer $S$ is given in a line.\n\nOutput\n\nPrint $h$, $m$ an... | [{"input": "71983", "output": "19:59:43\n"}, {"input": "-1025", "output": "-1:42:55\n"}, {"input": "-144", "output": "-1:57:36\n"}, {"input": "-274", "output": "-1:55:26\n"}, {"input": "-399", "output": "-1:53:21\n"}, {"input": "-694", "output": "-1:48:26\n"}, {"input": "-650", "output": "-1:49:10\n"}, {"input": "-469"... | code_stdio |
[
{
"content": "You are given four integer values $a$, $b$, $c$ and $m$.\n\nCheck if there exists a string that contains:\n\n$a$ letters 'A';\n\n$b$ letters 'B';\n\n$c$ letters 'C';\n\nno other letters;\n\nexactly $m$ pairs of adjacent equal letters (exactly $m$ such positions $i$ that the $i$-th letter is equal ... | [{"input": "3\n2 2 1 0\n2 1 1 1\n1 2 3 2\n", "output": "YES\nYES\nYES\n"}, {"input": "3\n2 2 1 0\n1 1 1 1\n1 2 3 2\n", "output": "YES\nNO\nYES\n"}, {"input": "3\n3 2 1 0\n1 1 1 1\n1 2 3 2\n", "output": "YES\nNO\nYES\n"}, {"input": "3\n3 2 1 0\n1 1 1 1\n1 2 3 3\n", "output": "YES\nNO\nYES\n"}, {"input": "3\n2 2 1 0\n1 1... | code_stdio |
[
{
"content": "Your mission in this problem is to write a computer program that manipulates molecular for- mulae in virtual chemistry. As in real chemistry, each molecular formula represents a molecule consisting of one or more atoms. However, it may not have chemical reality.\n\nThe following are the definition... | [{"input": "H 1\neI 5\nC 12\nO 16\nF 22\nNe 24\nEu 64\nCc 241\nEND_OF_FIRST_PART\nG2C\n(MhF)2As\nCu(OH)2\nH((CO)2F)99\n0", "output": "UNKNOWN\nUNKNOWN\nUNKNOWN\n7723\n"}, {"input": "H 0\nHe 4\nC 12\nO 26\nF 2\nOe 36\nvC 64\nCc 603\nEND_OF_FIRST_PART\nH2B\n(MgF)2As\nBu(OH)2\nH((CO)2F)99\n0", "output": "UNKNOWN\nUNKNOWN\... | code_stdio |
[
{
"content": "Valera is a lazy student. He has m clean bowls and k clean plates. \n\nValera has made an eating plan for the next n days. As Valera is lazy, he will eat exactly one dish per day. At that, in order to eat a dish, he needs exactly one clean plate or bowl. We know that Valera can cook only two types... | [{"input": "233 100 1\n2 2 1 1 1 2 2 2 2 1 1 2 2 2 1 2 2 1 1 1 2 2 1 1 1 1 2 1 2 2 1 1 2 2 1 2 2 1 2 1 2 1 2 2 2 1 1 1 1 2 1 2 1 1 2 1 1 2 2 1 2 1 2 1 1 1 1 1 1 1 1 1 2 1 2 2 2 1 1 2 2 1 1 1 1 2 1 1 2 1 2 2 2 1 1 1 2 2 2 1 1 1 1 2 1 2 1 1 1 1 2 2 2 1 1 2 1 2 1 1 1 1 1 2 1 1 1 1 1 2 1 1 2 2 1 2 1 1 2 2 1 1 2 2 1 1 1 2 2... | code_stdio |
[
{
"content": "Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cine... | [{"input": "4 13 400 600\n13 30\n1 19\n1 160\n1 113\n58 73 15 319 194 362 128 157 336 162 77 90 96\n", "output": "1\n"}, {"input": "4 13 400 600\n13 30\n1 19\n1 160\n1 113\n58 73 15 319 209 362 128 157 336 162 77 90 96\n", "output": "1\n"}, {"input": "4 13 400 600\n13 30\n1 19\n2 160\n1 113\n58 73 15 319 209 362 128 15... | code_stdio |
[
{
"content": "Burenka came to kindergarden. This kindergarten is quite strange, so each kid there receives two fractions ($\\frac{a}{b}$ and $\\frac{c}{d}$) with integer numerators and denominators. Then children are commanded to play with their fractions.\n\nBurenka is a clever kid, so she noticed that when sh... | [{"input": "7\n1000000000 999999999 999999999 999999998\n999999997 999999996 999999996 999999995\n999999994 999999993 999999993 999999992\n999999991 999999990 999999990 999999989\n999999988 999999987 999999987 999999986\n999999985 999999984 999999984 999999983\n999999982 999999981 999999981 999999980\n", "output": "2\n... | code_stdio |
[
{
"content": "Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n.\n\nThanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two citi... | [{"input": "7 13\n6 1\n7 2\n3 7\n6 5\n3 6\n7 4\n3 5\n4 1\n3 1\n1 5\n1 6\n4 2\n2 4\n", "output": "7\n"}, {"input": "7 13\n6 1\n7 2\n3 7\n6 5\n3 6\n7 4\n3 7\n4 1\n3 1\n1 5\n1 6\n4 2\n2 4\n", "output": "7\n"}, {"input": "7 13\n6 1\n7 2\n3 7\n6 5\n3 6\n7 4\n3 4\n4 1\n3 1\n1 5\n1 6\n4 2\n2 4\n", "output": "7\n"}, {"input": ... | code_stdio |
[
{
"content": "Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.)\nHere, the price before tax must be a positive integer, and the amount of consum... | [{"input": "80 100\n", "output": "1000\n"}, {"input": "68 85\n", "output": "850\n"}, {"input": "24 30\n", "output": "300\n"}, {"input": "25 32\n", "output": "320\n"}, {"input": "27 34\n", "output": "340\n"}, {"input": "56 71\n", "output": "710\n"}, {"input": "58 72\n", "output": "725\n"}, {"input": "34 43\n", "output":... | code_stdio |
[
{
"content": "Every year, hundreds of people come to summer camps, they learn new algorithms and solve hard problems.\n\nThis is your first year at summer camp, and you are asked to solve the following problem. All integers starting with 1 are written in one line. The prefix of these line is \"12345678910111213... | [{"input": "1000\n", "output": "3\n"}, {"input": "1000\n", "output": "3\n"}, {"input": "999\n", "output": "9\n"}, {"input": "100\n", "output": "5\n"}, {"input": "123\n", "output": "6\n"}, {"input": "157\n", "output": "3\n"}, {"input": "289\n", "output": "1\n"}, {"input": "179\n", "output": "4\n"}, {"input": "942\n", "o... | code_stdio |
[
{
"content": "A sequence a0, a1, ..., at - 1 is called increasing if ai - 1 < ai for each i: 0 < i < t.\n\nYou are given a sequence b0, b1, ..., bn - 1 and a positive integer d. In each move you may choose one element of the given sequence and add d to it. What is the least number of moves required to make the ... | [{"input": "100 3\n329 226 331 909 962 112 837 1005 194 818 506 416 125 648 367 459 400 582 989 547 329 438 234 121 272 226 821 376 834 427 718 164 834 113 654 177 737 212 169 696 744 180 89 944 233 147 667 990 809 1072 1085 1093 814 265 1067 312 833 572 303 901 1032 504 185 817 389 158 613 723 239 269 911 352 769 404 ... | code_stdio |
[
{
"content": "AtCoDeer the deer recently bought three paint cans.\nThe color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c.\nHere, the color of each paint can is represented by an integer between 1 and 100, inclusive.\nSince ... | [{"input": "11 12 -1", "output": "3\n"}, {"input": "11 20 -1", "output": "3\n"}, {"input": "3 3 33\n", "output": "2\n"}, {"input": "5 -1 33", "output": "3\n"}, {"input": "5 -2 33", "output": "3\n"}, {"input": "3 17 -1", "output": "3\n"}, {"input": "3 12 -1", "output": "3\n"}, {"input": "6 12 -1", "output": "3\n"}, {"in... | code_stdio |
[
{
"content": "Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected with the first one again. Cycle may consist of a single isolate... | [{"input": "10\n1378238141 598196518 640274071 983359971 23484317 96204862 799843967 446173607 613537551 402690754\n", "output": "2\n1\n1\n1\n1\n2\n2\n2\n2\n1\n"}, {"input": "10\n1378238141 870151580 640274071 983359971 42771579 67907111 799843967 446173607 613537551 402690754\n", "output": "2\n1\n1\n1\n1\n1\n1\n1\n1\n... | code_stdio |
[
{
"content": "There are N towns on a plane. The i-th town is located at the coordinates (x_i,y_i). There may be more than one town at the same coordinates.\n\nYou can build a road between two towns at coordinates (a,b) and (c,d) for a cost of min(|a-c|,|b-d|) yen (the currency of Japan). It is not possible to b... | [{"input": "6\n7 0\n0 4\n14 51\n2 1\n19 4\n4 20", "output": "10\n"}, {"input": "6\n1 -1\n4 5\n14 54\n1 2\n38 0\n4 5", "output": "14\n"}, {"input": "6\n7 0\n0 5\n14 31\n2 1\n19 4\n4 20", "output": "11\n"}, {"input": "6\n7 0\n0 5\n14 51\n2 1\n19 4\n4 20", "output": "11\n"}, {"input": "6\n13 0\n0 4\n14 51\n2 1\n19 4\n4 20... | code_stdio |
[
{
"content": "You've decided to carry out a survey in the theory of prime numbers. Let us remind you that a prime number is a positive integer that has exactly two distinct positive integer divisors.\n\nConsider positive integers a, a + 1, ..., b (a β€ b). You want to find the minimum integer l (1 β€ l β€ b - a + ... | [{"input": "100000 1000000 7821\n", "output": "108426\n"}, {"input": "10000 1000000 60000\n", "output": "793662\n"}, {"input": "10000 1000000 60000\n", "output": "793662"}, {"input": "100000 1000000 7821\n", "output": "108426"}, {"input": "100000 1000000 8225\n", "output": "114000"}, {"input": "100001 1000000 8225\n", ... | code_stdio |
[
{
"content": "Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the company.\n\nTo settle this problem, they've decided to play a game. The company name will consist of n l... | [{"input": "tinkoff\nzscoder\n", "output": "fzfsirk\n"}, {"input": "tinkoff\nzscoder\n", "output": "fzfsirk\n"}, {"input": "tinkogf\nzscoder\n", "output": "fzgsirk"}, {"input": "thnkogf\nzscoder\n", "output": "fzgshrk"}, {"input": "ffoknht\nzscoder\n", "output": "fzfshrk"}, {"input": "ffojnht\nzscoder\n", "output": "fz... | code_stdio |
[
{
"content": "Vasya likes to solve equations. Today he wants to solve $(x~\\mathrm{div}~k) \\cdot (x \\bmod k) = n$, where $\\mathrm{div}$ and $\\mathrm{mod}$ stand for integer division and modulo operations (refer to the Notes below for exact definition). In this equation, $k$ and $n$ are positive integer para... | [{"input": "999983 1000\n", "output": "999983001\n"}, {"input": "999995 1000\n", "output": "199999005\n"}, {"input": "1709131 435\n", "output": "743471986\n"}, {"input": "232207 1179\n", "output": "273772054\n"}, {"input": "652411 1010\n", "output": "658935111\n"}, {"input": "1000000 1000\n", "output": "1250800\n"}, {"... | code_stdio |
[
{
"content": "Little C loves number Β«3Β» very much. He loves all things about it.\n\nNow he has a positive integer $n$. He wants to split $n$ into $3$ positive integers $a,b,c$, such that $a+b+c=n$ and none of the $3$ integers is a multiple of $3$. Help him to find a solution.\n\n\n-----Input-----\n\nA single li... | [{"input": "1582786060\n", "output": "1 1 1582786058\n"}, {"input": "1000100000\n", "output": "1 2 1000099997\n"}, {"input": "1000071476\n", "output": "1 2 1000071473\n"}, {"input": "1042579470\n", "output": "1 1 1042579468\n"}, {"input": "1187564933\n", "output": "1 2 1187564930\n"}, {"input": "1455962944\n", "output"... | code_stdio |
[
{
"content": "The R1 company wants to hold a web search championship. There were n computers given for the competition, each of them is connected to the Internet. The organizers believe that the data transfer speed directly affects the result. The higher the speed of the Internet is, the faster the participant ... | [{"input": "80 50\n15160 6853 20254 11358 19535 27691 2983 31650 9219 11833 32053 31695 21511 4320 4384 24843 1454 31543 18796 13815 1546 27926 16276 14315 12542 25370 24890 29647 3584 17867 12446 15072 19852 30207 16361 7964 5343 398 10837 31114 9252 12767 15098 22562 32637 31823 8160 12658 6422 19142 12448 6765 7373 ... | code_stdio |
[
{
"content": "Problem\n\nMr. ukuku1333 is a little sloppy, so when I expanded the product of the linear expressions of x, I couldn't figure out the original linear expression.\nGiven the nth degree polynomial of x, factor it into the product of the original linear expressions of x.\n\nThe nth degree polynomial ... | [{"input": "x^5+15x^4+85x^3+225x^2+274x+120", "output": "(x+1)(x+2)(x+3)(x+4)(x+5)"}, {"input": "x^3-81x^2-1882x-1800", "output": "(x-100)(x+1)(x+18)"}, {"input": "x^2+4x+3", "output": "(x+1)(x+3)\n"}, {"input": "x^2+3x+2", "output": "(x+1)(x+2)"}, {"input": "x^2-4", "output": "(x-2)(x+2)\n"}, {"input": "x^2-4", "outpu... | code_stdio |
[
{
"content": "When a boy was cleaning up after his grand father passing, he found an old paper:\n\n<image>\n\n\n\nIn addition, other side of the paper says that \"go ahead a number of steps equivalent to the first integer, and turn clockwise by degrees equivalent to the second integer\".\n\nHis grand mother say... | [{"input": "56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n87,-86\n55,-6\n89,34\n5,59\n0,0", "output": "181\n-212\n"}, {"input": "56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n77,-86\n55,-6\n89,34\n95,5\n0,0", "output": "180\n-297\n"}, {"input": "56,65\n97,54\n64,-4\n65,76\n42,-27\n43,80\n77,-86\n55,-6\n89,34\n95,5\n0,0", "ou... | code_stdio |
[
{
"content": "Problem Statement\n\n\"Everlasting -One-\" is an award-winning online game launched this year. This game has rapidly become famous for its large number of characters you can play.\n\nIn this game, a character is characterized by attributes. There are $N$ attributes in this game, numbered $1$ throu... | [{"input": "12 2\n2 2\n4 12\n6 0\n100000 0\n0 0", "output": "2049\n64\n607723520\n"}, {"input": "12 2\n1 2\n4 3\n6 0\n100000 0\n0 0", "output": "1025\n64\n607723520\n"}, {"input": "12 2\n2 2\n4 3\n6 0\n100000 0\n0 0", "output": "2049\n64\n607723520\n"}, {"input": "4 0\n4 1\n2 3\n7 0\n100000 0\n0 0", "output": "16\n9\n1... | code_stdio |
[
{
"content": "One day Vasya got hold of information on the Martian dollar course in bourles for the next n days. The buying prices and the selling prices for one dollar on day i are the same and are equal to ai. Vasya has b bourles. He can buy a certain number of dollars and then sell it no more than once in n ... | [{"input": "93 867\n131 1270 616 1027 1685 27 1662 947 1480 20 1394 1528 191 1348 37 1694 1772 1706 1394 49 1391 878 1474 307 101 1129 1064 116 143 1239 261 651 1534 1348 1604 636 793 1188 1293 36 1729 1204 1656 1579 1644 661 1470 341 1709 1860 1081 1539 5 1892 1732 1049 419 25 1086 1263 967 1284 1229 1013 1348 1046 92... | code_stdio |
[
{
"content": "Toad Rash has a binary string s. A binary string consists only of zeros and ones.\n\nLet n be the length of s.\n\nRash needs to find the number of such pairs of integers l, r that 1 β€ l β€ r β€ n and there is at least one pair of integers x, k such that 1 β€ x, k β€ n, l β€ x < x + 2k β€ r, and s_x = s_... | [{"input": "1101111000011110111111110101100111111110111100001111011010111001101100010110000001010101101010111000\n", "output": "4672\n"}, {"input": "1101111000011110111111110101100111111110111100001111011010111001101100010110000001010101101010101000\n", "output": "4669\n"}, {"input": "1101111000001110111111110101100011... | code_stdio |
[
{
"content": "To get money for a new aeonic blaster, ranger Qwerty decided to engage in trade for a while. He wants to buy some number of items (or probably not to buy anything at all) on one of the planets, and then sell the bought items on another planet. Note that this operation is not repeated, that is, the... | [{"input": "5 10 15\nDdunkjly\n13 12 4\n83 26 1\n63 42 3\n83 22 2\n57 33 0\n59 10 1\n89 31 1\n57 17 2\n98 79 5\n46 41 3\nFbpbc\n28 21 0\n93 66 5\n66 21 0\n68 58 0\n59 17 3\n57 23 1\n72 71 1\n55 51 2\n58 40 5\n70 67 2\nKeiotmh\n73 44 4\n98 14 0\n19 7 0\n55 10 5\n30 25 4\n66 48 2\n66 51 4\n82 79 3\n73 63 4\n87 46 5\nNksd... | code_stdio |
[
{
"content": "You are given a Young diagram. \n\nGiven diagram is a histogram with n columns of lengths a_1, a_2, β¦, a_n (a_1 β₯ a_2 β₯ β¦ β₯ a_n β₯ 1).\n\n<image> Young diagram for a=[3,2,2,2,1].\n\nYour goal is to find the largest number of non-overlapping dominos that you can draw inside of this histogram, a domi... | [{"input": "100\n1980 1932 1906 1898 1892 1883 1877 1858 1842 1833 1777 1710 1689 1678 1660 1653 1648 1647 1644 1639 1635 1635 1593 1571 1534 1470 1440 1435 1389 1272 1269 1268 1263 1255 1249 1237 1174 1174 1128 1069 1067 981 979 979 951 915 911 906 863 826 810 810 802 785 764 752 743 710 705 696 676 661 639 619 616 57... | code_stdio |
[
{
"content": "Young Timofey has a birthday today! He got kit of n cubes as a birthday present from his parents. Every cube has a number a_{i}, which is written on it. Timofey put all the cubes in a row and went to unpack other presents.\n\nIn this time, Timofey's elder brother, Dima reordered the cubes using th... | [{"input": "42\n-557774624 828320986 -345782722 -62979938 -681259411 -945983652 -139095040 832293378 -82572118 432027535 88438103 568183540 961782904 73543295 615958219 -5050584 322982437 -146046730 759453379 129267920 -819827396 -348156048 805080102 390723009 -771277251 -79011872 -592313207 528489973 656201270 -127795... | code_stdio |
[
{
"content": "You are given an undirected tree consisting of $n$ vertices. An undirected tree is a connected undirected graph with $n - 1$ edges.\n\nYour task is to add the minimum number of edges in such a way that the length of the shortest path from the vertex $1$ to any other vertex is at most $2$. Note tha... | [{"input": "7\n1 2\n2 3\n2 4\n4 5\n4 6\n5 7\n", "output": "2\n"}, {"input": "7\n1 2\n1 3\n2 4\n2 5\n3 6\n1 7\n", "output": "0\n"}, {"input": "7\n1 2\n2 3\n3 4\n3 5\n3 6\n3 7\n", "output": "1\n"}, {"input": "7\n1 2\n2 3\n2 4\n2 5\n3 6\n1 7\n", "output": "1\n"}, {"input": "7\n1 2\n2 3\n2 4\n2 5\n2 6\n1 7\n", "output": "0... | code_stdio |
[
{
"content": "Emacs is a text editor which is widely used by many programmers.\n\nThe advantage of Emacs is that we can move a cursor without arrow keys and the mice. For example, the cursor can be moved right, left, down, and up by pushing f, b, n, p with the Control Key respectively. In addition, cut-and-past... | [{"input": "hyo\nnh\nEND_OF_TEXT\ne\nd\nf\nf\nk\np\np\ne\ny\na\nk\ny\ny\nn\ny\n-", "output": "hyonhhyonhhyonh\n"}, {"input": "hyn\nnh\nEND_OF_TEXT\ne\nd\nf\nf\nk\np\np\ne\nx\na\nk\ny\ny\nn\ny\n-", "output": "hynnhhynnhhynnh\n"}, {"input": "oyh\nni\nEND_OF_TEXT\nf\nd\nf\nf\nk\np\np\ne\ny\na\nk\ny\ny\nn\ny\n-", "output":... | code_stdio |
[
{
"content": "Santa Claus likes palindromes very much. There was his birthday recently. k of his friends came to him to congratulate him, and each of them presented to him a string s_{i} having the same length n. We denote the beauty of the i-th string by a_{i}. It can happen that a_{i} is negativeΒ β that means... | [{"input": "10 20\njvyxocgomfmrtllgmagp 13\ngvtjnyaofrswcnnifzfq 17\nqisxpseggpjfoijmqnel -5\nlenqmjiofjpggespxsiq 14\nqfzfinncwsrfoaynjtvg 14\ncaayidazlylxyisihdhx 14\npgamglltrmfmogcoxyvj 11\nxhdhisiyxlylzadiyaac 2\ntbirihfpjgbbtclpxwhv 19\nvhwxplctbbgjpfhiribt 10\n", "output": "109\n"}, {"input": "10 20\njvyxocgomfm... | code_stdio |
[
{
"content": "Alice lives on a line. Today, she will travel to some place in a mysterious vehicle.\nInitially, the distance between Alice and her destination is D. When she input a number x to the vehicle, it will travel in the direction of the destination by a distance of x if this move would shorten the dista... | [{"input": "6 15\n4 3 5 4 0 1\n6\n1 2 1 4 4 6", "output": "YES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "6 15\n4 3 5 4 0 1\n6\n1 2 3 4 5 6", "output": "YES\nYES\nYES\nYES\nNO\nYES\n"}, {"input": "6 15\n4 3 5 8 2 1\n6\n1 3 3 0 5 5", "output": "YES\nYES\nYES\nNO\nYES\nYES\n"}, {"input": "6 15\n4 3 5 4 0 1\n6\n1 2 0 4 4 6"... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nSuraj, the Chief Prankster is back in action now and this time he has stolen the valentine's day gift given by Ashi (the love of Chef) to the Chef and ran away with it to Byteland.\nByteland is a not a regular place like Chef's town. T... | [{"input": "3\n10\n2 1 4 16 2\n0\n12\n2 1 0 8 17\n0\n10\n2 2 2 3 3\n10 2 2 1 4 3 2 9 1 1", "output": "7\n18\n5\n"}, {"input": "3\n10\n2 1 4 16 2\n0\n10\n2 1 0 8 11\n0\n10\n2 2 2 3 4\n10 2 2 1 4 3 2 9 1 0", "output": "7\n12\n6\n"}, {"input": "3\n10\n2 1 1 8 0\n0\n10\n2 0 3 13 7\n0\n10\n2 1 4 3 15\n3 0 2 1 5 5 2 9 1 1", ... | code_stdio |
[
{
"content": "There are n stone quarries in Petrograd.\n\nEach quarry owns mi dumpers (1 β€ i β€ n). It is known that the first dumper of the i-th quarry has xi stones in it, the second dumper has xi + 1 stones in it, the third has xi + 2, and the mi-th dumper (the last for the i-th quarry) has xi + mi - 1 stones... | [{"input": "30\n53 12\n13 98\n21 60\n76 58\n39 5\n62 58\n73 80\n13 75\n37 45\n44 86\n1 85\n13 33\n17 50\n12 26\n97 48\n52 40\n2 71\n95 79\n38 76\n24 54\n91 39\n97 92\n94 80\n50 61\n33 56\n22 91\n39 94\n31 56\n28 16\n20 44\n", "output": "tolik\n"}, {"input": "30\n53 12\n13 98\n21 60\n76 58\n39 5\n62 58\n73 80\n13 75\n37... | code_stdio |
[
{
"content": "You are given an array of integers $a$ of length $n$. The elements of the array can be either different or the same.\n\nEach element of the array is colored either blue or red. There are no unpainted elements in the array. One of the two operations described below can be applied to an array in a s... | [{"input": "8\n4\n1 2 5 2\nBRBR\n2\n1 2\nBB\n5\n3 1 4 2 5\nBRRBR\n5\n4 1 3 1 4\nRBRRB\n5\n5 1 5 1 10\nRBRRA\n4\n2 2 2 2\nBRBR\n2\n1 -3\nBR\n4\n-2 -1 4 0\nRRRR\n", "output": "YES\nYES\nYES\nYES\nNO\nYES\nYES\nYES\n"}, {"input": "8\n4\n1 2 5 2\nBRBR\n2\n1 2\nBB\n5\n3 1 4 2 5\nBRRBR\n5\n4 1 5 1 4\nRBRRB\n5\n5 1 5 1 10\nRB... | code_stdio |
[
{
"content": "D: Arrow / Arrow\n\nproblem\n\nrodea is in a one-dimensional coordinate system and stands at x = 0. From this position, throw an arrow of positive integer length that always moves at speed 1 towards the target at x = N. However, rodea is powerless, so we have decided to put a total of M blowers in... | [{"input": "11 1\n11\n1\n16", "output": "1\n"}, {"input": "11 1\n11\n1\n6", "output": "-1\n"}, {"input": "15 1\n3\n1\n2", "output": "13\n"}, {"input": "15 1\n6\n1\n5", "output": "10\n"}, {"input": "15 1\n3\n1\n3", "output": "12\n"}, {"input": "15 1\n1\n1\n0", "output": "15\n"}, {"input": "15 1\n1\n1\n1", "output": "14\... | code_stdio |
[
{
"content": "Given a set of $N$ axis-aligned rectangles in the plane, find the area of regions which are covered by at least one rectangle.\n\nConstraints\n\n* $ 1 \\leq N \\leq 2000 $\n* $ β10^9 \\leq x1_i < x2_i\\leq 10^9 $\n* $ β10^9 \\leq y1_i < y2_i\\leq 10^9 $\n\nInput\n\nThe input is given in the follow... | [{"input": "4\n0 0 3 1\n-1 0 1 3\n-1 2 4 3\n3 0 3 3", "output": "11\n"}, {"input": "4\n0 0 3 1\n-1 0 1 3\n-1 0 4 3\n2 0 3 2", "output": "15\n"}, {"input": "4\n0 0 3 2\n-1 0 1 3\n-1 0 8 3\n2 0 3 2", "output": "27\n"}, {"input": "4\n0 -1 3 2\n0 2 1 5\n-1 0 0 5\n2 0 3 0", "output": "17\n"}, {"input": "4\n0 0 3 1\n0 0 0 3\... | code_stdio |
[
{
"content": "There are three cells on an infinite 2-dimensional grid, labeled $A$, $B$, and $F$. Find the length of the shortest path from $A$ to $B$ if:\n\nin one move you can go to any of the four adjacent cells sharing a side;\n\nvisiting the cell $F$ is forbidden (it is an obstacle).\n\n\n-----Input-----\n... | [{"input": "7\n\n2 2\n0 3\n-1 2\n\n2 5\n2 2\n0 3\n\n1000 144\n1000 2\n1000 0000\n\n0 2\n3 10\n2 10\n\n0 13\n12 8\n2 10\n\n0 1\n4 1\n1 2\n\n2 413\n0 10\n1 0\n", "output": "3\n3\n142\n11\n17\n4\n405\n"}, {"input": "7\n\n2 2\n1 3\n-1 2\n\n2 5\n2 1\n2 3\n\n1000 144\n1000 1\n1000 0000\n\n0 2\n3 10\n2 10\n\n0 13\n12 8\n2 7\n... | code_stdio |
[
{
"content": "After a team finished their training session on Euro football championship, Valeric was commissioned to gather the balls and sort them into baskets. Overall the stadium has n balls and m baskets. The baskets are positioned in a row from left to right and they are numbered with numbers from 1 to m,... | [{"input": "10894 92356\n", "output": "46178\n46179\n46177\n46180\n46176\n46181\n46175\n46182\n46174\n46183\n46173\n46184\n46172\n46185\n46171\n46186\n46170\n46187\n46169\n46188\n46168\n46189\n46167\n46190\n46166\n46191\n46165\n46192\n46164\n46193\n46163\n46194\n46162\n46195\n46161\n46196\n46160\n46197\n46159\n46198\n4... | code_stdio |
[
{
"content": "You are given a rooted tree with vertices numerated from $1$ to $n$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.\n\nAncestors of the vertex $i$ are all vertices on the path from the root to the vertex $i$, except the vertex $i$ itself. The parent of t... | [{"input": "8\n2 1\n-1 0\n1 1\n1 1\n1 1\n4 0\n5 1\n7 1\n", "output": "1 3 5 7 8\n"}, {"input": "8\n2 1\n-1 0\n1 1\n1 1\n1 1\n4 0\n5 1\n7 0\n", "output": "1 3 5\n"}, {"input": "8\n2 1\n-1 0\n1 0\n1 1\n2 1\n4 0\n5 1\n7 1\n", "output": "5 7 8\n"}, {"input": "8\n2 0\n-1 0\n1 1\n1 1\n1 1\n4 0\n2 1\n7 0\n", "output": "3 5\n"... | code_stdio |
[
{
"content": "Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum ... | [{"input": "5\n3 24 14 10 13", "output": "1\n"}, {"input": "5\n3 24 16 10 13", "output": "1\n"}, {"input": "5\n3 36 16 10 13", "output": "1\n"}, {"input": "5\n3 36 16 14 13", "output": "1\n"}, {"input": "5\n3 34 14 10 13", "output": "1\n"}, {"input": "5\n3 24 16 16 13", "output": "2\n"}, {"input": "5\n3 36 18 14 13", "... | code_stdio |
[
{
"content": "This is the easy version of the problem. The only difference is the constraints on $n$ and $k$. You can make hacks only if all versions of the problem are solved.\n\nYou have a string $s$, and you can do two types of operations on it:\n\nDelete the last character of the string.\n\nDuplicate the st... | [{"input": "8 20\nccaccaca\n", "output": "ccaccacaccaccacaccac\n"}, {"input": "8 16\ndbcadabc\n", "output": "dbcadabcdbcadabc\n"}, {"input": "5 10\ndcdcd\n", "output": "dcdcdcdcdc\n"}, {"input": "5 10\ncbcbc\n", "output": "cbcbcbcbcb\n"}, {"input": "4 11\nddcd\n", "output": "ddcddcddcdd\n"}, {"input": "4 11\nzzaz\n", "... | code_stdio |
[
{
"content": "Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multiset with integers. Friends give her t queries, each of one of the following type:\n\n 1. + ai β add non-negative integer ai to the multiset. Note, that she has a multiset, thus... | [{"input": "10\n+ 870566619432760298\n+ 869797178280285214\n+ 609920823721618090\n+ 221159591436767023\n+ 730599542279836538\n? 101001100111001011\n? 001111010101010011\n? 100010100011101110\n? 100110010110001100\n? 110000011101110011\n", "output": "0\n0\n0\n0\n0\n"}, {"input": "10\n+ 870566619432760298\n+ 869797178280... | code_stdio |
[
{
"content": "In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\nCity i is established in year Y_i and belongs to Prefecture P_i.\nYou can assume that there are no multiple cities that are established in the same year.\nIt is decided to allocate a 12-digi... | [{"input": "75634 912\n18125 601244640\n58230 951349939\n4017 753730550\n23636 124912128\n45120 23758881\n51811 316477853\n19326 139861106\n48018 406348942\n68864 391719264\n1850 712458521\n2796 385027567\n12731 564315721\n43367 828330253\n30104 102450015\n64351 340641907\n19781 414658282\n53502 122572188\n11063 262174... | code_stdio |
[
{
"content": "Prof. Hachioji has devised a new numeral system of integral numbers with four lowercase letters \"m\", \"c\", \"x\", \"i\" and with eight digits \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\". He doesn't use digit \"0\" nor digit \"1\" in this system.\n\nThe letters \"m\", \"c\", \"x\" and... | [{"input": "10\nxi x8i\ni 9i\nc2x2i 5c9x8i\nm2ci 4m7c9x8i\n8c9x8i i\ni 9m9c9x8i\nm i\ni m\nm9i i\n8m9c7xi c1x8i", "output": "2x9i\nx\n7c2x\n5m9c9x9i\n8c9x9i\n9m9c9x9i\nmi\nmi\nmx\n9m8x9i\n"}, {"input": "10\nxi x8i\ni 9i\nc2x3i 5c8x8i\nm2ci 4m7c9x8i\n9c8x9i i\ni 9m9c9x8i\nm i\ni m\nm9i i\n9m8c7xi c2x8i", "output": "2x9i... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.