messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
1 value
[ { "content": "Vasya plays the Geometry Horse.\n\nThe game goal is to destroy geometric figures of the game world. A certain number of points is given for destroying each figure depending on the figure type and the current factor value. \n\nThere are n types of geometric figures. The number of figures of type ki...
[{"input": "16\n196661091 17\n765544213 322\n134522506 115\n914609421 163\n219016066 227\n835576807 856\n682158845 914\n11248128 145\n876496017 854\n141052597 530\n163180278 315\n407245991 60\n294673989 270\n2976249 26\n674132026 519\n347829904 23\n16\n6280951514 53396669509 79113951711 87247958777 121933859963 2190625...
code_stdio
[ { "content": "You are planning to buy an apartment in a $n$-floor building. The floors are numbered from $1$ to $n$ from the bottom to the top. At first for each floor you want to know the minimum total time to reach it from the first (the bottom) floor.\n\nLet: $a_i$ for all $i$ from $1$ to $n-1$ be the time ...
[{"input": "10 2\n7 6 15 6 16 18 2 17 17\n12 11 3 10 9 1 10 1 5\n", "output": "0 7 13 18 24 35 36 38 41 46\n"}, {"input": "10 2\n7 6 18 6 16 18 1 17 17\n6 9 3 10 9 1 10 1 5\n", "output": "0 7 13 18 24 35 36 37 40 45 \n"}, {"input": "10 2\n7 6 18 6 16 18 1 17 17\n6 17 3 10 9 1 10 1 5\n", "output": "0 7 13 18 24 35 36 37...
code_stdio
[ { "content": "How many ways are there to choose two distinct positive integers totaling N, disregarding the order?\n\nConstraints\n\n* 1 \\leq N \\leq 10^6\n* N is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\n\nN\n\n\nOutput\n\nPrint the answer.\n\nExamples\n\nInput\n\n...
[{"input": "3256265", "output": "1628132\n"}, {"input": "1527191", "output": "763595\n"}, {"input": "1743342", "output": "871670\n"}, {"input": "1412384", "output": "706191\n"}, {"input": "1339977", "output": "669988\n"}, {"input": "245898", "output": "122948\n"}, {"input": "235323", "output": "117661\n"}, {"input": "1...
code_stdio
[ { "content": "You are given a string $s$ of 0's and 1's. You are allowed to perform the following operation:\n\nchoose a non-empty contiguous substring of $s$ that contains an equal number of 0's and 1's;\n\nflip all characters in the substring, that is, replace all 0's with 1's, and vice versa;\n\nreverse the ...
[{"input": "64\n0000\n1000\n0100\n1100\n0010\n1010\n0110\n1110\n0001\n1001\n0101\n1101\n0011\n1011\n0111\n1111\n0000\n1000\n0100\n1100\n0010\n1010\n0110\n1110\n0001\n1001\n0101\n1101\n0011\n1011\n0111\n1111\n0000\n1000\n0100\n1100\n0010\n1010\n0110\n1110\n0001\n1001\n0101\n1101\n0011\n1011\n0111\n1111\n0000\n1000\n0100...
code_stdio
[ { "content": "Two players are playing a game. First each of them writes an integer from 1 to 6, and then a dice is thrown. The player whose written number got closer to the number on the dice wins. If both payers have the same difference, it's a draw.\n\nThe first player wrote number a, the second player wrote ...
[{"input": "2 5\n", "output": "3 0 3\n"}, {"input": "2 4\n", "output": "2 1 3\n"}, {"input": "5 3\n", "output": "2 1 3\n"}, {"input": "1 6\n", "output": "3 0 3\n"}, {"input": "5 1\n", "output": "3 1 2\n"}, {"input": "6 3\n", "output": "2 0 4\n"}, {"input": "2 3\n", "output": "2 0 4\n"}, {"input": "5 6\n", "output": "5 ...
code_stdio
[ { "content": "Vasya tries to break in a safe. He knows that a code consists of n numbers, and every number is a 0 or a 1. Vasya has made m attempts to enter the code. After each attempt the system told him in how many position stand the right numbers. It is not said in which positions the wrong numbers stand. V...
[{"input": "35 10\n11101100001010011101100010101111111 5\n11101100010011101100001010101011011 5\n11101100001101111110000011101111010 5\n11101100101001111100000110111111001 5\n11101100001011000100001011101111011 5\n10101000001011111010000010001111011 5\n11101100001011111100010000111110001 0\n1110100000111111110000001010...
code_stdio
[ { "content": "You are given an array $a_1, a_2, \\dots, a_n$ and an integer $k$.\n\nYou are asked to divide this array into $k$ non-empty consecutive subarrays. Every element in the array should be included in exactly one subarray. Let $f(i)$ be the index of subarray the $i$-th element belongs to. Subarrays are...
[{"input": "7 6\n-3 0 -1 -2 -2 -4 -1\n", "output": "-45\n"}, {"input": "7 6\n-6 1 -1 -1 -2 -4 -1\n", "output": "-43\n"}, {"input": "7 7\n-3 0 -1 -2 -2 -4 -1\n", "output": "-55\n"}, {"input": "7 6\n-5 1 -1 -1 -2 -4 -1\n", "output": "-42\n"}, {"input": "7 6\n-3 0 -1 -2 -2 -4 0\n", "output": "-39\n"}, {"input": "7 6\n-6 0...
code_stdio
[ { "content": "In number world, two different numbers are friends if they have a lot in common, but also each one has unique perks.\n\nMore precisely, two different numbers $a$ and $b$ are friends if $gcd(a,b)$, $\\frac{a}{gcd(a,b)}$, $\\frac{b}{gcd(a,b)}$ can form sides of a triangle.\n\nThree numbers $a$, $b$ ...
[{"input": "100\n42 486 341 527 189 740 490 388 989 489 711 174 305 844 971 492 998 954 832 442 424 619 906 154 293 395 439 735 738 915 453 748 786 550 871 932 693 326 53 904 732 835 354 364 691 669 203 719 282 875 573 672 695 640 58 872 732 751 557 779 102 39 213 844 289 137 50 951 284 671 474 829 906 736 395 366 22 1...
code_stdio
[ { "content": "You're given a tree with $n$ vertices.\n\nYour task is to determine the maximum possible number of edges that can be removed in such a way that all the remaining connected components will have even size.\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 10^5$) denoting...
[{"input": "10\n7 1\n8 4\n8 10\n4 7\n6 10\n9 3\n3 5\n2 10\n2 5\n", "output": "4\n"}, {"input": "10\n8 1\n8 4\n8 10\n4 7\n6 10\n9 3\n3 5\n2 10\n2 5\n", "output": "4\n"}, {"input": "10\n4 1\n10 4\n8 10\n4 7\n6 5\n9 2\n3 5\n2 10\n2 5\n", "output": "0\n"}, {"input": "10\n4 1\n10 4\n8 10\n4 7\n6 1\n9 2\n3 5\n2 10\n2 5\n", "...
code_stdio
[ { "content": "Tak has N cards. On the i-th (1 \\leq i \\leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection?\n\nConstraints\n\n* 1 \\leq N \\leq 50\...
[{"input": "33 3\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 3 3 3 3", "output": "4294967295\n"}, {"input": "33 3\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 3 3 3 3 3 3 3 3 3 3 3 1 3 3 3 3", "output": "2147483647\n"}, {"input": "33 3\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 0 3 3 3 3 3 3 3 3 3 3 1 3 3 3 3", "output": ...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \n\nPhantasialand boasts of its famous theme park. The park is frequently visited. It is quite large park that some tourists visit it more than once to fully appreciate its offerings. One day, our Chefs decided to visit ...
[{"input": "4\n1 -1 12 11", "output": "12\n"}, {"input": "4\n1 -2 12 11", "output": "11\n"}, {"input": "4\n-1 -1 0 36", "output": "17\n"}, {"input": "4\n-2 -2 0 36", "output": "16\n"}, {"input": "4\n-1 -1 0 42", "output": "20\n"}, {"input": "4\n1 -2 13 38", "output": "25\n"}, {"input": "4\n2 -2 13 38", "output": "26\n"...
code_stdio
[ { "content": "You are given an array $a$ consisting of $n$ integers.\n\nYour task is to say the number of such positive integers $x$ such that $x$ divides each number from the array. In other words, you have to find the number of common divisors of all elements in the array.\n\nFor example, if the array $a$ wil...
[{"input": "6\n10000100623 10000100623 10000100623 10000100623 10000100623 10000100623\n", "output": "2\n"}, {"input": "6\n10000100623 10000100623 10000100623 10000100623 10000100623 10000100623\n", "output": "2\n"}, {"input": "5\n153965681607 99999999977 99999999977 99999999977 99999999977\n", "output": "1\n"}, {"inpu...
code_stdio
[ { "content": "Count the number of distinct sequences a_1, a_2, ..., a_{n} (1 ≤ a_{i}) consisting of positive integers such that gcd(a_1, a_2, ..., a_{n}) = x and $\\sum_{i = 1}^{n} a_{i} = y$. As this number could be large, print the answer modulo 10^9 + 7.\n\ngcd here means the greatest common divisor.\n\n\n--...
[{"input": "495219 444706662\n", "output": "115165527\n"}, {"input": "495219 444706662\n", "output": "115165527\n"}, {"input": "1000000000 1000000000\n", "output": "1\n"}, {"input": "9357 18255507\n", "output": "745979764\n"}, {"input": "225 315096300\n", "output": "413133630\n"}, {"input": "34601 35742833\n", "output"...
code_stdio
[ { "content": "There is a grid with N rows and N columns of squares. Let (i, j) be the square at the i-th row from the top and the j-th column from the left.\nEach of the central (N-2) \\times (N-2) squares in the grid has a black stone on it.\nEach of the 2N - 1 squares on the bottom side and the right side has...
[{"input": "176527 15\n1 81279\n2 22308\n2 133061\n1 80744\n2 44603\n1 170938\n2 139754\n2 15220\n1 172794\n1 159290\n2 156968\n1 56426\n2 77429\n1 97459\n2 71282\n", "output": "31159505795\n"}, {"input": "176527 15\n2 81279\n2 22308\n2 145342\n1 106634\n2 60988\n1 170938\n2 139754\n2 15220\n1 172794\n1 159290\n2 15696...
code_stdio
[ { "content": "There is an apple tree that bears apples of N colors. The N colors of these apples are numbered 1 to N, and there are a_i apples of Color i.\n\nYou and Lunlun the dachshund alternately perform the following operation (starting from you):\n\n* Choose one or more apples from the tree and eat them. H...
[{"input": "3\n000000\n24912\n20652", "output": "second\n"}, {"input": "3\n100000\n30000\n29639", "output": "first\n"}, {"input": "3\n000000\n30000\n29639", "output": "first\n"}, {"input": "3\n000001\n30000\n29639", "output": "first\n"}, {"input": "3\n000011\n30000\n29639", "output": "first\n"}, {"input": "3\n000010\n3...
code_stdio
[ { "content": "You will be given a contest schedule for D days and M queries of schedule modification. In the i-th query, given integers d_i and q_i, change the type of contest to be held on day d_i to q_i, and then output the final satisfaction at the end of day D on the updated schedule. Note that we do not re...
[{"input": "5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 1...
code_stdio
[ { "content": "These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts $1$ minute.\n\nHe was asked to insert one takeoff in the schedule. The...
[{"input": "66 20\n0 16\n0 45\n0 58\n1 6\n1 19\n2 7\n2 9\n3 9\n3 25\n3 57\n4 38\n4 58\n5 21\n5 40\n6 16\n6 19\n6 58\n7 6\n7 26\n7 51\n8 13\n8 36\n8 55\n9 1\n9 15\n9 33\n10 12\n10 37\n11 15\n11 34\n12 8\n12 37\n12 55\n13 26\n14 0\n14 34\n14 36\n14 48\n15 23\n15 29\n15 43\n16 8\n16 41\n16 45\n17 5\n17 7\n17 15\n17 29\n17...
code_stdio
[ { "content": "For long time scientists study the behavior of sharks. Sharks, as many other species, alternate short movements in a certain location and long movements between locations.\n\nMax is a young biologist. For $n$ days he watched a specific shark, and now he knows the distance the shark traveled in eac...
[{"input": "127\n64 96 63 112 62 95 61 120 60 94 59 111 58 93 57 124 56 92 55 110 54 91 53 119 52 90 51 109 50 89 49 126 48 88 47 108 46 87 45 118 44 86 43 107 42 85 41 123 40 84 39 106 38 83 37 117 36 82 35 105 34 81 33 127 32 80 31 104 30 79 29 116 28 78 27 103 26 77 25 122 24 76 23 102 22 75 21 115 20 74 19 101 18 7...
code_stdio
[ { "content": "A linear congruential generator produces a series R(⋅) of pseudo-random numbers by the following for- mulas:\n\n<image>\n\nwhere S, A, C, and M are all parameters. In this problem, 0 ≤ S, A, C ≤ 15 and M = 256.\n\nNow suppose we have some input string I(⋅), where each character in the string is an...
[{"input": "5\n0 1 3 11 0\n5\n-1 12 2 0 7\n10\n46 2 28 27 203 31 14 81 122 141\n0", "output": "9 15 10\n6 11 13\n6 13 6\n"}, {"input": "5\n10 4 3 3 1\n5\n7 12 2 0 7\n10\n372 8 42 18 176 40 12 56 169 141\n0", "output": "0 1 1\n6 11 13\n0 15 15\n"}, {"input": "5\n5 1 3 11 0\n5\n0 12 2 0 7\n10\n46 2 28 27 203 31 14 81 122...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian. \nLeonid is developing new programming language. The key feature of his language is fast multiplication and raising to a power operations. He is asking you to help with the following task. \nYou have an expression S and positive integer M....
[{"input": "2\n1000 2**3*3**1\n100000 4**2*2**11", "output": "24\n32768\n"}, {"input": "2\n1001 2**3*2**1\n100000 4**2*2**11", "output": "16\n32768\n"}, {"input": "2\n1000 2**4*3**1\n111000 4**2*2**11", "output": "48\n32768\n"}, {"input": "2\n1100 2**3*3**1\n110000 4**1*3**11", "output": "24\n48588\n"}, {"input": "2\n1...
code_stdio
[ { "content": "Many internet protocols these days include the option of associating a\nmedia type with the content being sent.\nThe type is usually inferred from the file extension.\nYou are to write a program that facilitates the lookup of media types for\na number of files.\nYou will be given a table of media ...
[{"input": "3 7\nhtml lmth/txft\nlht text/itml\ngnp image/png\nsug lmx+gvt/ehami\ntxt text/plajn\nindex.html\nthis.file.has.lots.of.dots.txt\nnoaotsdsall\nvires.uxe\ndont.let.the.png.fool.you\ncXT.trettam.esaT", "output": "unknown\nunknown\nlmth/txft\nunknown\nunknown\nunknown\nunknown\n"}, {"input": "2 7\nhmtl text/ht...
code_stdio
[ { "content": "Our brave travelers reached an island where pirates had buried treasure. However as the ship was about to moor, the captain found out that some rat ate a piece of the treasure map.\n\nThe treasure map can be represented as a rectangle n × m in size. Each cell stands for an islands' square (the squ...
[{"input": "20 20\n####################\n############.####.##\n#######..####..#####\n######............##\n######.....#...###.#\n#####E..........##.#\n#.##.#.........#####\n##NR....KO.....#####\n##B........#...#####\n#Y.W...H.......#####\n#####Z.....#...#####\n######...#.#...#####\n#A.......#.#...#####\n######.....#......
code_stdio
[ { "content": "Since the giant heads have appeared in the sky all humanity is in danger, so all Ricks and Mortys from all parallel universes are gathering in groups to find a solution to get rid of them. \n\nThere are n parallel universes participating in this event (n Ricks and n Mortys). I. e. each of n univer...
[{"input": "100 50\n2 62 -62\n2 19 -19\n2 38 -38\n2 -84 84\n2 -16 16\n2 67 -67\n2 41 -41\n2 -32 32\n2 32 -32\n2 -62 62\n2 89 -89\n2 -84 84\n2 96 -96\n2 -11 11\n2 59 -59\n2 -13 13\n2 -70 70\n2 -3 3\n2 -41 41\n2 -74 74\n2 47 -47\n2 87 -87\n2 17 -17\n2 20 -20\n2 -14 14\n2 -67 67\n2 -95 95\n2 -15 15\n2 -49 49\n2 75 -75\n2 ...
code_stdio
[ { "content": "Makoto has a big blackboard with a positive integer $n$ written on it. He will perform the following action exactly $k$ times:\n\nSuppose the number currently written on the blackboard is $v$. He will randomly pick one of the divisors of $v$ (possibly $1$ and $v$) and replace $v$ with this divisor...
[{"input": "1000000000000000 10000\n", "output": "215514159\n"}, {"input": "1000000000000000 10000\n", "output": "215514159\n"}, {"input": "1000000000001000 10000\n", "output": "150774797\n"}, {"input": "1172768550854780 8998\n", "output": "789402181\n"}, {"input": "1292761461062695 8123\n", "output": "574008655\n"}, {...
code_stdio
[ { "content": "YouKn0wWho has two even integers x and y. Help him to find an integer n such that 1 ≤ n ≤ 2 ⋅ 10^{18} and n mod x = y mod n. Here, a mod b denotes the remainder of a after division by b. If there are multiple such integers, output any. It can be shown that such an integer always exists under the g...
[{"input": "4\n4 8\n4 1\n420 420\n167306 42068\n", "output": "8\n5\n420\n209374\n"}, {"input": "4\n4 8\n4 1\n420 420\n167306 11758\n", "output": "8\n5\n420\n179064\n"}, {"input": "4\n6 8\n4 1\n420 420\n167306 11758\n", "output": "7\n5\n420\n179064\n"}, {"input": "4\n4 8\n4 2\n420 420\n83876 42068\n", "output": "8\n6\n4...
code_stdio
[ { "content": "Life is not easy. Sometimes it is beyond your control. Now, as contestants of ACM ICPC, you might be just tasting the bitter of life. But don't worry! Do not look only on the dark side of life, but look also on the bright side. Life may be an enjoyable game of chance, like throwing dice. Do or die...
[{"input": "1\nnorth\n3\nnorth\neasu\nsouth\n0", "output": "5\n1\n"}, {"input": "1\nnorth\n0\nnorth\ntsae\nosuth\n-1", "output": "5\n"}, {"input": "1\nnorth\n0\nmorth\ntsae\nosuth\n-1", "output": "5\n"}, {"input": "1\nnorth\n0\nmorth\ntsae\nostth\n-1", "output": "5\n"}, {"input": "1\nnorth\n0\nntroh\ntsaf\nsouth\n-1", ...
code_stdio
[ { "content": "Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be $n$ participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who...
[{"input": "25\n5 1 1\n5 2 3\n5 5 5\n5 5 1\n5 4 4\n10 1 2\n10 3 7\n10 10 10\n10 3 1\n10 7 6\n1000000 21232 1234\n999999 999999 999999\n1000000 300001 966605\n1000000 290001 679121\n500000 111099 123456\n100 1 1\n1000000000 1 1000000000\n1000000000 1 500000000\n100000000 1 12345678\n1000000000 1 499999999\n1000000000 1 ...
code_stdio
[ { "content": "Since Grisha behaved well last year, at New Year's Eve he was visited by Ded Moroz who brought an enormous bag of gifts with him! The bag contains n sweet candies from the good ol' bakery, each labeled from 1 to n corresponding to its tastiness. No two candies have the same tastiness.\n\nThe choic...
[{"input": "1000000000000000000 1000000000000000000\n", "output": "1152921504606846975\n"}, {"input": "1100000000000000000 1000000000000000000\n", "output": "1152921504606846975\n"}, {"input": "1100000000010000000 1000000000000000000\n", "output": "1152921504606846975\n"}, {"input": "1005016953863700545 145946161059548...
code_stdio
[ { "content": "You are given an undirected graph consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition, each vertex has a label, `A` or `B`. The label of Vertex i is s_i. Edge i bidirectionally connects vertex a_i and b_i.\n\nThe phantom thief Nuso...
[{"input": "13 23\nABAAAABBBBAAB\n7 1\n10 6\n1 11\n2 10\n2 8\n2 11\n11 12\n8 3\n7 11\n11 2\n13 13\n11 9\n4 1\n9 7\n9 6\n8 13\n8 6\n4 10\n8 7\n4 3\n2 1\n8 12\n6 9", "output": "Yes\n"}, {"input": "13 23\nABAAAABBBBAAB\n7 1\n10 6\n1 11\n2 10\n2 8\n2 11\n11 12\n8 3\n7 12\n11 2\n13 13\n11 9\n4 1\n9 7\n9 6\n8 13\n8 6\n4 10\n...
code_stdio
[ { "content": "AtCoDeer has three cards, one red, one green and one blue.\n\nAn integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.\n\nWe will arrange the cards in the order red, green and blue from left to right, and read them as a three-di...
[{"input": "4 3 2\n", "output": "YES\n"}, {"input": "2 3 4\n", "output": "NO\n"}, {"input": "7 3 2", "output": "YES\n"}, {"input": "7 6 0", "output": "YES\n"}, {"input": "2 6 0", "output": "YES\n"}, {"input": "9 6 0", "output": "YES\n"}, {"input": "0 6 0", "output": "YES\n"}, {"input": "5 6 0", "output": "YES\n"}, {"in...
code_stdio
[ { "content": "In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter.\nIt had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those t...
[{"input": "290178 291177\n", "output": "208323\n"}, {"input": "336594 337545\n", "output": "115131\n"}, {"input": "124075 124692\n", "output": "65961\n"}, {"input": "82747 83560\n", "output": "247331\n"}, {"input": "61024 61453\n", "output": "30782\n"}, {"input": "130815 131327\n", "output": "1\n"}, {"input": "498500 ...
code_stdio
[ { "content": "Two boys decided to compete in text typing on the site \"Key races\". During the competition, they have to type a text consisting of s characters. The first participant types one character in v_1 milliseconds and has ping t_1 milliseconds. The second participant types one character in v_2 millisec...
[{"input": "1000 1000 1000 1000 1000\n", "output": "Friendship\n"}, {"input": "1000 1000 1000 1000 1000\n", "output": "Friendship\n"}, {"input": "13 849 819 723 918\n", "output": "Friendship\n"}, {"input": "13 849 819 723 918\n", "output": "Friendship\n"}, {"input": "37 261 207 1 1000\n", "output": "Friendship\n"}, {"i...
code_stdio
[ { "content": "In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is used. The first column has number A, the second — number B, etc. till column 26 that is marked by Z. Then there are two-letter numbers: column 27 has number AA, 28 — AB, column 52 is marked by AZ. Af...
[{"input": "10\nR50C12\nR23C47\nY96\nR44C13\nR19C21\nR95C73\nBK12\nR51C74\nAY34\nR63C25\n", "output": "L50\nAU23\nR96C25\nM44\nU19\nBU95\nR12C63\nBV51\nR34C51\nY63\n"}, {"input": "10\nR50C12\nR23C47\nY96\nR44C13\nR19C21\nR95C73\nBK12\nR51C74\nAY34\nR62C25\n", "output": "L50\nAU23\nR96C25\nM44\nU19\nBU95\nR12C63\nBV51\n...
code_stdio
[ { "content": "You're given Q queries of the form (L, R). \n\nFor each query you have to find the number of such x that L ≤ x ≤ R and there exist integer numbers a > 0, p > 1 such that x = a^{p}.\n\n\n-----Input-----\n\nThe first line contains the number of queries Q (1 ≤ Q ≤ 10^5).\n\nThe next Q lines contains ...
[{"input": "20\n862 928\n758 964\n541 789\n622 943\n328 900\n14 764\n217 1554\n461 847\n442 468\n544 1157\n518 529\n938 993\n620 851\n690 944\n484 601\n320 910\n98 1355\n816 794\n765 880\n551 1280\n", "output": "1\n4\n5\n6\n14\n32\n30\n9\n0\n12\n1\n1\n5\n4\n4\n15\n35\n0\n2\n13\n"}, {"input": "20\n862 928\n758 964\n541 ...
code_stdio
[ { "content": "Having written another programming contest, three Rabbits decided to grab some lunch. The coach gave the team exactly k time units for the lunch break.\n\nThe Rabbits have a list of n restaurants to lunch in: the i-th restaurant is characterized by two integers f_{i} and t_{i}. Value t_{i} shows t...
[{"input": "2 3\n1000000000 1\n2 2\n", "output": "1000000000\n"}, {"input": "2 3\n1000000000 1\n2 2\n", "output": "1000000000\n"}, {"input": "2 4\n1000000000 1\n2 2\n", "output": "1000000000\n"}, {"input": "2 4\n1000000000 1\n2 0\n", "output": "1000000000\n"}, {"input": "2 4\n1000000000 1\n3 0\n", "output": "1000000000...
code_stdio
[ { "content": "For a positive integer n, we denote the integer obtained by reversing the decimal notation of n (without leading zeroes) by rev(n). For example, rev(123) = 321 and rev(4000) = 4.\n\nYou are given a positive integer D. How many positive integers N satisfy rev(N) = N + D?\n\nConstraints\n\n* D is an...
[{"input": "864197532", "output": "1920"}, {"input": "1663355059", "output": "0\n"}, {"input": "3070868988", "output": "0\n"}, {"input": "2599007699", "output": "0\n"}, {"input": "4586279406", "output": "0\n"}, {"input": "1877134154", "output": "0\n"}, {"input": "1149390088", "output": "0\n"}, {"input": "6200730", "out...
code_stdio
[ { "content": "You are given two integer arrays a and b of length n.\n\nYou can reverse at most one subarray (continuous subsegment) of the array a. \n\nYour task is to reverse such a subarray that the sum ∑_{i=1}^n a_i ⋅ b_i is maximized.\n\nInput\n\nThe first line contains one integer n (1 ≤ n ≤ 5000).\n\nThe ...
[{"input": "100\n8 4 3 5 10 9 5 8 5 7 4 9 4 6 8 8 2 6 3 3 10 7 10 8 6 2 7 4 9 7 7 2 4 5 2 4 9 5 10 1 10 5 10 4 1 3 4 2 6 9 9 9 10 6 2 5 3 1 8 10 4 10 3 4 9 5 5 4 10 4 5 3 7 10 2 7 3 8 6 6 1 0 5 5 4 6 6 4 4 1 5 1 6 6 6 8 8 6 2 6\n0 4 0 5 7 5 4 10 4 10 1 2 1 5 8 2 8 7 1 9 9 5 6 9 4 6 9 9 10 17 4 3 7 4 10 10 9 4 4 7 9 1 1...
code_stdio
[ { "content": "After the contest in comparing numbers, Shapur's teacher found out that he is a real genius and that no one could possibly do the calculations faster than him even using a super computer!\n\nSome days before the contest, the teacher took a very simple-looking exam and all his n students took part ...
[{"input": "Iran_\nPersian;\nW_o;n;d;e;r;f;u;l;\n7\nWonderfulPersianIran\nwonderful_PersIAN_IRAN;;_\nWONDERFUL___IRAN__PERSIAN__;;\nIra__Persiann__Wonderful\nWonder;;fulPersian___;I;r;a;n;\n__________IranPersianWonderful__________\nPersianIran_is_Wonderful\n", "output": "ACC\nACC\nACC\nWA\nACC\nACC\nWA\n"}, {"input": "...
code_stdio
[ { "content": "You are developing frog-shaped robots, and decided to race them against each other.\n\nFirst, you placed N robots onto a number line. These robots are numbered 1 through N. The current coordinate of robot i is x_i. Here, all x_i are integers, and 0 < x_1 < x_2 < ... < x_N.\n\nYou will repeatedly p...
[{"input": "13\n4 11 8 9 10 12 14 15 16 18 20 21 22", "output": "311014372\n"}, {"input": "13\n4 16 8 9 10 19 14 24 18 18 20 21 22", "output": "790015972\n"}, {"input": "13\n4 11 8 6 10 19 14 24 16 18 20 21 22", "output": "916006393\n"}, {"input": "13\n4 14 4 9 10 12 14 15 16 18 20 65 22", "output": "437004793\n"}, {"i...
code_stdio
[ { "content": "Based on the information of the time when study started and the time when study ended, check whether the total time studied in one day is t or more, and if not, create a program to find the shortage time. Time is one unit per hour, and minutes and seconds are not considered. The time is expressed ...
[{"input": "10\n3\n6 11\n12 15\n18 22\n14\n2\n6 14\n13 20\n0", "output": "OK\nOK\n"}, {"input": "10\n3\n6 11\n12 15\n34 22\n14\n2\n6 14\n13 20\n0", "output": "14\nOK\n"}, {"input": "10\n3\n20 11\n2 15\n34 22\n13\n2\n4 14\n13 33\n0", "output": "18\nOK\n"}, {"input": "10\n3\n12 11\n2 15\n34 22\n14\n2\n6 14\n13 20\n0", "o...
code_stdio
[ { "content": "Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get from any city to any other one, using only the existing roads.\n\nThe President of Berland decided to mak...
[{"input": "10 45\n3 5\n2 3\n4 8\n2 5\n6 8\n10 7\n2 1\n3 7\n5 10\n6 1\n9 8\n3 1\n2 10\n6 7\n1 7\n7 9\n6 9\n9 3\n4 2\n2 6\n5 6\n5 8\n3 4\n10 8\n7 8\n4 6\n9 1\n5 5\n7 4\n1 10\n9 2\n2 8\n6 10\n9 8\n1 5\n7 2\n10 3\n3 8\n2 10\n1 1\n10 7\n1 3\n1 8\n10 2\n4 10\n", "output": "0\n"}, {"input": "10 45\n3 5\n2 3\n4 8\n2 5\n6 8\n5...
code_stdio
[ { "content": "Three swimmers decided to organize a party in the swimming pool! At noon, they started to swim from the left side of the pool.\n\nIt takes the first swimmer exactly $a$ minutes to swim across the entire pool and come back, exactly $b$ minutes for the second swimmer and $c$ minutes for the third. H...
[{"input": "10\n992222955174044630 49635415 8474 173727148\n618311281854681640 657834994 40173216 75996939\n710602478618400425 332897175 71490165 534449640\n768753872531302819 113476460 449 799174641\n633188994852953277 834175592 3132 788542124\n964246686346975322 539872840 295075 782348226\n683685407217150496 18798310...
code_stdio
[ { "content": "Simon and Antisimon play a game. Initially each player receives one fixed positive integer that doesn't change throughout the game. Simon receives number a and Antisimon receives number b. They also have a heap of n stones. The players take turns to make a move and Simon starts. During a move a pl...
[{"input": "100 100 100\n", "output": "0\n"}, {"input": "100 101 100\n", "output": "0\n"}, {"input": "100 100 10\n", "output": "0\n"}, {"input": "100 110 10\n", "output": "0\n"}, {"input": "34 106 143\n", "output": "1\n"}, {"input": "165 49 110\n", "output": "1\n"}, {"input": "100 1 100\n", "output": "0\n"}, {"input": ...
code_stdio
[ { "content": "There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles c...
[{"input": "30\nRLLRLRLLRRRLRRRLLLLLLRRRLRRLRL\n128 610 1680 2436 2896 2994 3008 3358 3392 4020 4298 4582 4712 4728 5136 5900 6088 6232 6282 6858 6934 7186 7224 7256 7614 8802 8872 9170 9384 9794\n", "output": "7\n"}, {"input": "30\nRLLRLRLLRRRLRRRLLLLLLRRRLRRLRL\n128 610 1680 2436 2896 2994 3008 3358 3392 4020 4298 45...
code_stdio
[ { "content": "You are given an array $a$ of $n$ integers, and another integer $k$ such that $2k \\le n$.\n\nYou have to perform exactly $k$ operations with this array. In one operation, you have to choose two elements of the array (let them be $a_i$ and $a_j$; they can be equal or different, but their positions...
[{"input": "1\n88 38\n9 143 135 72 74 12 120 27 108 183 18 24 163 122 140 155 166 188 197 14 134 66 188 161 79 100 40 55 161 118 121 18 72 141 136 31 39 187 2 98 16 118 120 196 127 66 135 186 49 16 17 50 107 192 50 23 62 110 83 124 197 127 185 129 131 182 45 147 174 115 89 109 177 7 70 43 75 5 157 93 59 26 176 105 32 8...
code_stdio
[ { "content": "Heiankyo is known as a town with a grid of roads.\n\nHokusai, a cat who lives in Heiankyo, has to go from his home to a secret place on the outskirts of town every day for patrol. However, I get tired of following the same path every day, and there is a risk of being followed, so Hokusai wants to ...
[{"input": "4\n0 2\n0\n1 2\n2\n0 0 0 1\n0 0 1 0\n4 0\n4\n1 0 0 0\n3 5 2 3\n4 0 4 0\n0 2 0 4\n15 5\n0", "output": "1\nMiserable Hokusai!\nMiserable Hokusai!\n15504\n"}, {"input": "4\n2 2\n0\n1 2\n2\n0 0 0 1\n0 0 1 0\n4 0\n4\n1 0 0 0\n3 3 2 3\n4 0 4 0\n0 2 0 3\n15 3\n0", "output": "6\nMiserable Hokusai!\nMiserable Hokusa...
code_stdio
[ { "content": "Do you know \"sed,\" a tool provided with Unix? Its most popular use is to substitute every occurrence of a string contained in the input string (actually each input line) with another string β. More precisely, it proceeds as follows.\n\n1. Within the input string, every non-overlapping (but poss...
[{"input": "2\na bb\nb aa\nb\nbbbbbbbb\n1\nb aa\nb\naaaaa\n3\nbb aab\nabc aadc\nad dee\nabc\ndeeeeeeeec\n10\na acb\nb bai\nc acf\nd bec\ne bbh\nf fag\ng abe\nh bag\ni aaj\nj bbb\na\nabaceaabe\n0", "output": "-1\n-1\n-1\n-1\n"}, {"input": "2\na bb\nb aa\nb\nbbbbbbbb\n1\nb aa\nb\naaaaa\n3\nbb aab\nabc aadc\nad dee\nbac\n...
code_stdio
[ { "content": "Top-model Izabella participates in the competition. She wants to impress judges and show her mathematical skills.\n\nHer problem is following: for given string, consisting of only 0 and 1, tell if it's possible to remove some digits in such a way, that remaining number is a representation of some ...
[{"input": "1111111111101111111111111111111111111011111111111111111111111101111011111101111111111101111111111111\n", "output": "yes\n"}, {"input": "0110111111111111111111011111111110110111110111111111111111111111111111111111111110111111111111111111\n", "output": "yes\n"}, {"input": "110011000111101100110110100000111011...
code_stdio
[ { "content": "So the Beautiful Regional Contest (BeRC) has come to an end! $n$ students took part in the contest. The final standings are already known: the participant in the $i$-th place solved $p_i$ problems. Since the participants are primarily sorted by the number of solved problems, then $p_1 \\ge p_2 \\g...
[{"input": "5\n12\n5 4 4 3 2 2 1 1 1 1 1 1\n4\n4 3 2 2\n1\n1000100\n20\n20 19 18 17 16 15 14 13 15 11 10 9 8 7 6 5 4 3 2 1\n32\n125 64 63 58 58 58 58 58 37 37 37 37 34 34 28 28 28 28 28 28 24 24 19 17 17 17 17 16 16 16 16 11\n", "output": "1 2 3\n0 0 0\n0 0 0\n1 2 7\n1 2 11\n"}, {"input": "5\n12\n5 4 4 3 2 2 1 1 1 1 1 ...
code_stdio
[ { "content": "Qwerty the Ranger took up a government job and arrived on planet Mars. He should stay in the secret lab and conduct some experiments on bacteria that have funny and abnormal properties. The job isn't difficult, but the salary is high.\n\nAt the beginning of the first experiment there is a single b...
[{"input": "1000000 1000000 1000000 1000000\n", "output": "1000000\n"}, {"input": "1000000 1001000 1000000 1000000\n", "output": "1000000\n"}, {"input": "100000 100000 1000010 1000000\n", "output": "1000009\n"}, {"input": "100000 100000 1000000 1000000\n", "output": "999999\n"}, {"input": "722229 410423 118215 838505\n...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese . \n\nYou are given two strings A and B of the same length. Each string contains N Lower case Latin character (from 'a' to 'z'). A shift operation will remove the first character of a string and add the same character at the end of that string. For exam...
[{"input": "5\nccade\nbddcc", "output": "3\n"}, {"input": "5\nccade\nccdcb", "output": "0\n"}, {"input": "5\nddacc\nbddcc", "output": "1\n"}, {"input": "5\nddacc\nccddb", "output": "2\n"}, {"input": "5\nccade\nbcdcc", "output": "3\n"}, {"input": "5\ncacde\nccdcb", "output": "0\n"}, {"input": "5\nc`cde\nccdcb", "output"...
code_stdio
[ { "content": "Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is YES or NO.\nWhen he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases.\nThen, he rewrote the code to correctl...
[{"input": "5 13", "output": "195788800\n"}, {"input": "100 5\n", "output": "608000\n"}, {"input": "3 10", "output": "18739200\n"}, {"input": "10 7", "output": "1740800\n"}, {"input": "110 5", "output": "640000\n"}, {"input": "15 7", "output": "1804800\n"}, {"input": "111 4", "output": "292800\n"}, {"input": "111 3", "...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian. \n\nAlok-nath is man of equality. He needs your help to divide his “sanskars” evenly amongst all his followers. By doing this, Alok-nath can create equality amongst his followers and he'll be called a true “sanskari”.\n\nAlok-nath has N sa...
[{"input": "2\n6 3\n1 4 14 4 11\n5 2\n-1 2 0 14 4", "output": "no\nno\n"}, {"input": "2\n6 3\n1 4 14 4 11\n5 4\n-1 2 0 14 4", "output": "no\nno\n"}, {"input": "2\n5 3\n1 2 14 4 11\n5 2\n-1 2 0 8 7", "output": "no\nno\n"}, {"input": "2\n5 3\n1 4 14 4 11\n5 2\n-1 2 0 8 7", "output": "no\nno\n"}, {"input": "2\n1 3\n0 2 12...
code_stdio
[ { "content": "Codehorses has just hosted the second Codehorses Cup. This year, the same as the previous one, organizers are giving T-shirts for the winners.\n\nThe valid sizes of T-shirts are either \"M\" or from $0$ to $3$ \"X\" followed by \"S\" or \"L\". For example, sizes \"M\", \"XXS\", \"L\", \"XXXL\" are...
[{"input": "43\nL\nXXXL\nM\nXS\nL\nXXL\nS\nL\nM\nXXXL\nXXS\nS\nXS\nS\nXS\nXL\nXXL\nXXL\nXS\nXXS\nXXL\nL\nXXXL\nL\nL\nXXL\nXXL\nM\nXXXS\nM\nXXL\nXXXS\nXXXL\nXXS\nL\nL\nXS\nL\nXS\nXS\nL\nXXL\nM\nXXXL\nXXL\nXXL\nXL\nL\nXS\nM\nXL\nXXXS\nXXXS\nS\nXXL\nXXXL\nXXL\nXS\nXXS\nL\nS\nXXXS\nXL\nL\nXL\nXXXS\nM\nL\nXXL\nL\nXL\nM\nM\n...
code_stdio
[ { "content": "You are given three integers $a$, $b$ and $x$. Your task is to construct a binary string $s$ of length $n = a + b$ such that there are exactly $a$ zeroes, exactly $b$ ones and exactly $x$ indices $i$ (where $1 \\le i < n$) such that $s_i \\ne s_{i + 1}$. It is guaranteed that the answer always exi...
[{"input": "80 242 40\n", "output": "1010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
code_stdio
[ { "content": "This time the Berland Team Olympiad in Informatics is held in a remote city that can only be reached by one small bus. Bus has n passenger seats, seat i can be occupied only by a participant from the city a_{i}.\n\nToday the bus has completed m trips, each time bringing n participants. The partici...
[{"input": "1 1000000000 1000000000\n100000\n", "output": " 0"}, {"input": "5 3 2\n1 1 2 1 1\n", "output": " 7"}, {"input": "5 3 3\n1 2 2 1 1\n", "output": " ...
code_stdio
[ { "content": "E869120 has A 1-yen coins and infinitely many 500-yen coins.\n\nDetermine if he can pay exactly N yen using only these coins.\n\n-----Constraints-----\n - N is an integer between 1 and 10000 (inclusive).\n - A is an integer between 0 and 1000 (inclusive).\n\n-----Input-----\nInput is given from St...
[{"input": "2018\n218\n", "output": "Yes\n"}, {"input": "2018\n113", "output": "Yes\n"}, {"input": "2018\n111", "output": "Yes\n"}, {"input": "2018\n101", "output": "Yes\n"}, {"input": "2018\n100", "output": "Yes\n"}, {"input": "2018\n110", "output": "Yes\n"}, {"input": "2763\n-113", "output": "No\n"}, {"input": "2763\...
code_stdio
[ { "content": "There is a square grid of size $n \\times n$. Some cells are colored in black, all others are colored in white. In one operation you can select some rectangle and color all its cells in white. It costs $\\min(h, w)$ to color a rectangle of size $h \\times w$. You are to make all cells white for mi...
[{"input": "1000 24\n190 39 552 958\n539 146 763 587\n31 526 423 673\n208 432 953 442\n263 69 719 635\n162 428 623 797\n49 126 94 963\n749 623 979 919\n190 461 367 855\n211 240 939 914\n169 80 336 203\n684 546 829 582\n80 218 324 327\n560 452 656 637\n316 534 982 642\n521 634 758 686\n514 324 753 437\n342 395 384 995\n...
code_stdio
[ { "content": "Auction\n\nsquare1001 You were watching a certain auction.\n\nAn auction is a transaction in which when there are a large number of buyers and the number of items is limited, the one with the highest price is given the right to buy. (From the 7th edition of the Shinmei Kokugo Dictionary)\n\nThe ru...
[{"input": "5\n-1 -1 -2 -2 3", "output": "4\n5\n"}, {"input": "5\n-1 -1 -3 -2 3", "output": "3\n5\n"}, {"input": "5\n-1 -1 -3 -1 3", "output": "3\n5\n"}, {"input": "5\n-1 -1 -6 -1 3", "output": "3\n5\n"}, {"input": "5\n-1 -2 -6 -1 3", "output": "3\n5\n"}, {"input": "5\n-1 -1 -6 -2 3", "output": "3\n5\n"}, {"input": "5\...
code_stdio
[ { "content": "Tomya is a girl. She loves Chef Ciel very much.\n\nToday, too, Tomya is going to Ciel's restaurant.\nOf course, Tomya would like to go to Ciel's restaurant as soon as possible.\nTherefore Tomya uses one of the shortest paths from Tomya's house to Ciel's restaurant.\nOn the other hand, Tomya is bor...
[{"input": "2\n3 3\n1 2 3\n2 3 11\n1 2 14\n3 3\n2 2 3\n2 3 1\n2 3 9", "output": "1\n0\n"}, {"input": "2\n3 3\n1 1 3\n3 3 11\n1 2 7\n3 3\n2 2 3\n2 3 1\n2 1 9", "output": "0\n1\n"}, {"input": "2\n3 3\n1 2 1\n2 3 6\n1 3 7\n3 3\n2 3 4\n2 3 6\n1 3 12", "output": "2\n1\n"}, {"input": "2\n3 3\n1 2 3\n2 3 4\n1 3 7\n6 3\n2 3 3\...
code_stdio
[ { "content": "Devu is a renowned classical singer. He is invited to many big functions/festivals. Recently he was invited to \"All World Classical Singing Festival\". Other than Devu, comedian Churu was also invited.\n\nDevu has provided organizers a list of the songs and required time for singing them. He will...
[{"input": "100 6000\n41 31 23 17 24 78 26 96 93 48 46 2 49 33 35 9 73 100 34 48 83 36 33 69 43 24 3 74 8 81 27 33 94 38 77 9 76 90 62 90 21 67 22 22 12 2 17 27 102 18 72 85 59 65 71 38 90 75 74 66 60 47 58 50 90 95 75 10 5 100 97 29 83 88 65 26 93 90 22 98 36 55 70 38 50 92 88 72 99 96 25 14 74 16 25 92 67 94 77 96\n"...
code_stdio
[ { "content": "In the $2022$ year, Mike found two binary integers $a$ and $b$ of length $n$ (both of them are written only by digits $0$ and $1$) that can have leading zeroes. In order not to forget them, he wanted to construct integer $d$ in the following way:\n\nhe creates an integer $c$ as a result of bitwise...
[{"input": "5\n1\n0\n3\n011\n3\n110\n6\n111000\n6\n001011\n", "output": "\n1\n110\n100\n101101\n101110\n"}, {"input": "5\n1\n0\n3\n011\n3\n110\n6\n111000\n6\n001011\n", "output": "1\n110\n100\n101101\n101110\n"}, {"input": "5\n1\n0\n3\n011\n3\n110\n6\n111100\n6\n001011\n", "output": "1\n110\n100\n101001\n101110\n"}, {"...
code_stdio
[ { "content": "Consider a simplified penalty phase at the end of a football match.\n\nA penalty phase consists of at most $10$ kicks, the first team takes the first kick, the second team takes the second kick, then the first team takes the third kick, and so on. The team that scores more goals wins; if both team...
[{"input": "4\n1001???0?1\n1111111111\n??????????\n0100001000\n", "output": "8\n10\n6\n10\n"}, {"input": "4\n1?0???1001\n1111111111\n??????????\n0000000000\n", "output": "7\n10\n6\n10\n"}, {"input": "4\n1001?1?0??\n0111111011\n??????????\n1100011000\n", "output": "9\n10\n6\n10\n"}, {"input": "4\n0?0???1001\n1111111111\...
code_stdio
[ { "content": "Given an array $a$ of length $n$ and an integer $k$, find the number of indices $1 \\leq i \\leq n - k$ such that the subarray $[a_i, \\dots, a_{i+k}]$ with length $k+1$ (not with length $k$) has the following property:\n\nIf you multiply the first element by $2^0$, the second element by $2^1$, .....
[{"input": "1\n40 39\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1...
code_stdio
[ { "content": "Takahashi has a string S consisting of lowercase English letters.\nStarting with this string, he will produce a new one in the procedure given as follows.\nThe procedure consists of Q operations. In Operation i (1 \\leq i \\leq Q), an integer T_i is provided, which means the following:\n - If T_i ...
[{"input": "a\n6\n2 2 a\n2 1 b\n1\n2 2 c\n1\n1\n", "output": "aabc\n"}, {"input": "a\n6\n2 2 a\n2 1 b\n1\n2 2 d\n1\n1", "output": "aabd\n"}, {"input": "a\n6\n2 2 b\n2 1 b\n1\n2 2 d\n1\n1", "output": "babd\n"}, {"input": "a\n6\n2 2 a\n2 1 b\n1\n2 1 c\n1\n1", "output": "caab\n"}, {"input": "a\n6\n2 2 a\n2 1 b\n1\n2 1 b\n...
code_stdio
[ { "content": "Let's consider a table consisting of n rows and n columns. The cell located at the intersection of i-th row and j-th column contains number i × j. The rows and columns are numbered starting from 1.\n\nYou are given a positive integer x. Your task is to count the number of cells in a table that con...
[{"input": "100000 1000000000\n", "output": "16\n"}, {"input": "100000 183783600\n", "output": "438\n"}, {"input": "100000 551350800\n", "output": "392\n"}, {"input": "100000 479001600\n", "output": "254\n"}, {"input": "100000 1000000000\n", "output": "16\n"}, {"input": "100000 479001600\n", "output": "254\n"}, {"input...
code_stdio
[ { "content": "Vasily has a deck of cards consisting of n cards. There is an integer on each of the cards, this integer is between 1 and 100 000, inclusive. It is possible that some cards have the same integers on them.\n\nVasily decided to sort the cards. To do this, he repeatedly takes the top card from the de...
[{"input": "100\n12 9 97 55 14 8 55 34 35 67 3 18 73 92 41 49 15 60 18 66 9 26 97 47 43 88 71 97 19 63 48 96 79 53 8 47 69 49 21 23 77 12 21 176 66 9 29 13 61 69 54 77 10 13 4 68 37 74 7 6 29 76 55 72 89 4 78 27 29 82 18 83 12 4 32 69 89 85 66 13 92 54 38 5 26 56 17 55 29 4 17 39 29 94 3 67 85 79 21 14\n", "output": "1...
code_stdio
[ { "content": "Recall that MEX of an array is a minimum non-negative integer that does not belong to the array. Examples: for the array $[0, 0, 1, 0, 2]$ MEX equals to $3$ because numbers $0, 1$ and $2$ are presented in the array and $3$ is the minimum non-negative integer not presented in the array; for the a...
[{"input": "7 3\n0\n1\n2\n2\n0\n0\n10\n", "output": "1\n2\n3\n3\n4\n4\n7\n"}, {"input": "7 5\n0\n1\n2\n2\n0\n0\n10\n", "output": "1\n2\n3\n3\n3\n3\n3\n"}, {"input": "7 3\n0\n1\n2\n2\n0\n0\n10\n", "output": "1\n2\n3\n3\n4\n4\n7\n"}, {"input": "4 4\n0\n1\n2\n2\n0\n0\n10\n", "output": "1\n2\n3\n3\n"}, {"input": "3 3\n0\n1...
code_stdio
[ { "content": "Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at a_1 percent and second one is charged at a_2 percent. You can connect charger to a joystick only at the beginning of each minute. In one minute joystick either discharge...
[{"input": "100 100\n", "output": "197\n"}, {"input": "100 100\n", "output": "197\n"}, {"input": "100 25\n", "output": "122\n"}, {"input": "100 25\n", "output": "122\n"}, {"input": "100 26\n", "output": "124\n"}, {"input": "155 25\n", "output": "178\n"}, {"input": "155 18\n", "output": "171\n"}, {"input": "131 18\n", "...
code_stdio
[ { "content": "Recently Polycarpus has learned the \"bitwise AND\" operation (which is also called \"AND\") of non-negative integers. Now he wants to demonstrate the school IT teacher his superb manipulation with the learned operation.\n\nFor that Polycarpus came to school a little earlier and wrote on the board...
[{"input": "7\n-1 1000000000 999999488 999999488 1000000000 1000000000 999999488\n1000000000 -1 999999488 999999488 1000000000 1000000000 999999488\n999999488 999999488 -1 999999999 999999488 999999488 999999999\n999999488 999999488 999999999 -1 999999488 999999488 999999999\n1000000000 1000000000 999999488 999999488 -...
code_stdio
[ { "content": "Given are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string.\n\n-----Constraints-----\n - S and T are strings consisting of lowercase English letters.\n - The lengths of S and T are between 1 and...
[{"input": "oekdkfjdjgjknbfkwnfnhaoekdkfjdjgjknbfkwnfnhahjekkengkfoekdkfjdjgjknbfkwnfnhaoekdkfjdjgjknbfkwnfnhahj yowkymbmhkkgjjeokdlakbndkkworqotkfnblgpnkkrogjrfnvmbjisnbkzvmbnrrrigeoibgpefjobvmovpqosqoqrgrkengrlk\n", "output": "yowkymbmhkkgjjeokdlakbndkkworqotkfnblgpnkkrogjrfnvmbjisnbkzvmbnrrrigeoibgpefjobvmovpqosqoqr...
code_stdio
[ { "content": "Yet another Armageddon is coming! This time the culprit is the Julya tribe calendar. \n\nThe beavers in this tribe knew math very well. Smart Beaver, an archaeologist, got a sacred plate with a magic integer on it. The translation from Old Beaverish is as follows: \n\n\"May the Great Beaver bless ...
[{"input": "1000000000000000000\n", "output": "113502443819651915\n"}, {"input": "999999899799299198\n", "output": "113502432686240713\n"}, {"input": "999999999999999998\n", "output": "113502443819651913\n"}, {"input": "999999999999999999\n", "output": "113502443819651914\n"}, {"input": "999999999999999997\n", "output"...
code_stdio
[ { "content": "Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have equal number of copybooks for each of the subjects. There are three types of copybook's packs in the shop: it is possible to buy one copybook for a rubles, a pack of two copybooks for b r...
[{"input": "999999999 1000000000 1000000000 1000000000\n", "output": "1000000000\n"}, {"input": "1714658473 1000000000 999999990 1000000000\n", "output": "1000000000\n"}, {"input": "999999999 1000000000 1000000100 1000000000\n", "output": "1000000000\n"}, {"input": "999999999 1000000000 1000000000 1000000000\n", "outpu...
code_stdio
[ { "content": "Creatnx has $n$ mirrors, numbered from $1$ to $n$. Every day, Creatnx asks exactly one mirror \"Am I beautiful?\". The $i$-th mirror will tell Creatnx that he is beautiful with probability $\\frac{p_i}{100}$ for all $1 \\le i \\le n$.\n\nCreatnx asks the mirrors one by one, starting from the $1$-s...
[{"input": "100\n60 79 48 35 18 24 87 1 44 65 60 78 11 43 71 79 90 6 94 49 22 91 58 93 55 21 22 31 7 15 17 65 76 9 100 89 50 96 14 38 27 87 29 93 54 12 99 35 27 51 36 44 6 26 91 1 53 8 49 63 18 4 31 55 95 15 77 1 16 98 75 26 26 43 2 11 18 70 3 65 11 74 64 69 26 54 9 51 25 82 98 12 90 75 19 23 78 93 6 7\n", "output": "2...
code_stdio
[ { "content": "Imagine that your city is an infinite 2D plane with Cartesian coordinate system. The only crime-affected road of your city is the x-axis. Currently, there are n criminals along the road. No police station has been built on this road yet, so the mayor wants to build one.\n\nAs you are going to be i...
[{"input": "44 37298\n-100 -100 -98 -93 -92 -91 -91 -89 -87 -86 -84 -80 -79 -76 -71 -70 -58 -53 -52 -52 -49 -48 -45 -45 -40 -39 -37 -35 -31 -30 -30 -29 -29 -28 -22 -22 -21 -11 -8 -7 -7 -6 -1 0\n", "output": "200\n"}, {"input": "45 45\n-95 -94 -92 -83 -83 -76 -75 -74 -71 -70 -68 -44 -36 -31 -20 -18 -14 -11 -8 -7 -2 -2 -...
code_stdio
[ { "content": "One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far end of the string, jumping only on vowels of the English alphabet. Jump ability is the maxim...
[{"input": "VRPHBNWNWVWBWMFJJDCTJQJDJBKSJRZLVQRVVFLTZFSGCGDXCWQVWWWMFVCQHPKXXVRKTGWGPSMQTPKNDQJHNSKLXPCXDJDQDZZD\n", "output": "101\n"}, {"input": "DZZDQDJDXCPXLKSNHJQDNKPTQMSPGWGTKRVXXKPHQCVFMWWWVQWCXDGCGSFZTLFVVRQVLZRJSKBJDJQJTCDJJFMWBWVWNWNBHPRV\n", "output": "101\n"}, {"input": "VRPHBNWNWVWBWMFJJDCTJQJDJBKSJRZLVQRV...
code_stdio
[ { "content": "Mishka has got n empty boxes. For every i (1 ≤ i ≤ n), i-th box is a cube with side length a_{i}.\n\nMishka can put a box i into another box j if the following conditions are met:\n\n i-th box is not put into another box; j-th box doesn't contain any other boxes; box i is smaller than box j (a_...
[{"input": "100\n981 288 186 186 292 876 341 288 663 360 783 907 292 186 341 292 360 1510 360 360 1230 398 783 288 366 398 876 981 398 907 133 360 288 981 907 186 360 288 186 981 186 288 907 876 288 907 876 360 341 292 907 694 907 783 284 981 907 292 876 398 895 876 154 341 876 33 288 186 981 341 398 595 907 981 208 18...
code_stdio
[ { "content": "Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes:\n\n* Hit his pocket, which magically increases the number of biscuits by one.\n* Exchange A biscuits to 1 yen.\n* Exchange 1 yen to B ...
[{"input": "314159265 35897932 384626433", "output": "48518828981938099"}, {"input": "407766107 9307229 14836778", "output": "1101648954500241\n"}, {"input": "407766107 9307229 25447105", "output": "3215538450316794\n"}, {"input": "296771207 9307229 25447105", "output": "2319816489000594\n"}, {"input": "513602852 93072...
code_stdio
[ { "content": "We have a sequence of length N, a = (a_1, a_2, ..., a_N).\nEach a_i is a positive integer.\nSnuke's objective is to permute the element in a so that the following condition is satisfied:\n - For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.\nDetermine whether Snuke can a...
[{"input": "6\n2 7 1 8 2 8\n", "output": "Yes\n"}, {"input": "6\n4 7 0 -1 6 4", "output": "Yes\n"}, {"input": "6\n2 7 2 12 2 8", "output": "Yes\n"}, {"input": "6\n4 7 2 8 2 10", "output": "Yes\n"}, {"input": "6\n2 7 2 8 2 8", "output": "Yes\n"}, {"input": "6\n4 7 2 8 2 8", "output": "Yes\n"}, {"input": "6\n6 7 2 8 2 8"...
code_stdio
[ { "content": "Find the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.\n\n-----Constraints-----\n - 1 \\leq N < 10^{100}\n - 1 \\leq K \\leq 3\n\n-----Input-----\nInput is given from Standard Input in the following format:\nN\nK\n\n-----Output----...
[{"input": "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n3\n", "output": "117879300\n"}, {"input": "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n3", "output": "117879300"}, {"input": "9999999999999999999999...
code_stdio
[ { "content": "π (spelled pi in English) is a mathematical constant representing the circumference of a circle whose di- ameter is one unit length. The name π is said to come from the first letter of the Greek words περιφέρεια (meaning periphery) and περίμετρος (perimeter).\n\nRecently, the government of some co...
[{"input": "1.1386381399168386\n0.08430864816896695\n0.0", "output": "3/1\n16/5\n"}, {"input": "0.5656950408067312\n0.06616503278329884\n0.0", "output": "3/1\n16/5\n"}, {"input": "0.9300839575225542\n0.09342351193849237\n0.0", "output": "3/1\n16/5\n"}, {"input": "0.7461955408233221\n0.09342351193849237\n0.0", "output":...
code_stdio
[ { "content": "Jack has become a soldier now. Unfortunately, he has trouble with the drill. Instead of marching beginning with the left foot and then changing legs with each step, as ordered, he keeps repeating a sequence of steps, in which he sometimes makes the wrong steps or — horror of horrors! — stops for a...
[{"input": "RXLLRXXLLRLRLLXXXXRXXRLLRRRRXLLRRLXXLRXXLXLRLLLLLRXLRXLXRXLXLRRXXRRLXLXLRLRXRXLXXXLRXLLXLRRRRXRLLXRRLLRRXRRRLRLLRLRXXXRLXLXLLLRXXLLXLRXXLLLRLXRRXRLXLXXXXXXLXRXXRXXXRXLXXRRXLLXRRXLXXRRXLXXRLXLXXLXRXXRLRLLXLXLXLRXLXLXLLLRLXXLXLLRLLLLRLRRRRXRRLLRLXLXXRLRRLXRRXXXRLLXRRRXXRRRXXLRXRLLXRRRXRXRXXLLLRLRXXRLRLXRLLXLX...
code_stdio
[ { "content": "You are playing a game called Guru Guru Gururin. In this game, you can move with the vehicle called Gururin. There are two commands you can give to Gururin: 'R' and 'L'. When 'R' is sent, Gururin rotates clockwise by 90 degrees. Otherwise, when 'L' is sent, Gururin rotates counterclockwise by 90 d...
[{"input": "RRLRRLRRRRLRRLRRRRLRRLRRRRLRRLRR", "output": "4"}, {"input": "RLLRRLLLRRRLLLLRR", "output": "0\n"}, {"input": "RLLRRLLMRRRLLLLRR", "output": "0\n"}, {"input": "RLLRLLLLRRRLLLRRR", "output": "0"}, {"input": "RRRRLLLLRRRR", "output": "2"}, {"input": "RL", "output": "0\n"}, {"input": "QL", "output": "0\n"}, {"...
code_stdio
[ { "content": "You are given $q$ queries in the following form:\n\nGiven three integers $l_i$, $r_i$ and $d_i$, find minimum positive integer $x_i$ such that it is divisible by $d_i$ and it does not belong to the segment $[l_i, r_i]$.\n\nCan you answer all the queries?\n\nRecall that a number $x$ belongs to segm...
[{"input": "30\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n...
code_stdio
[ { "content": "From 1603 to 1867, people call that era the EDO era. EDO stands for Enhanced Driving Operation, the most advanced space navigation technology at the time, and was developed by Dr. Izy in 1603.\n\nYou are a space adventurer, flying around the universe and adventuring on various planets. During that...
[{"input": "2\n10 11\n11 12\n2\nN 2\nE 1\n2\n10 11\n11 12\n2\nN 2\nW 1\n3\n0 15\n5 10\n5 15\n5\nW 20\nS 10\nN 20\nE 10\nS 10\n0", "output": "Yes\nNo\nNo\n"}, {"input": "2\n10 11\n11 12\n2\nN 2\nE 1\n2\n10 11\n11 12\n2\nN 3\nW 1\n3\n0 15\n5 10\n5 15\n5\nW 20\nS 10\nN 20\nE 10\nS 10\n0", "output": "Yes\nNo\nNo\n"}, {"inp...
code_stdio
[ { "content": "Capitalization is writing a word with its first letter as a capital letter. Your task is to capitalize the given word.\n\nNote, that during capitalization all the letters except the first one remains unchanged.\n\n\n-----Input-----\n\nA single line contains a non-empty word. This word consists of ...
[{"input": "lZqBqKeGvNdSeYuWxRiVnFtYbKuJwQtUcKnVtQhAlOeUzMaAuTaEnDdPfDcNyHgEoBmYjZyFePeJrRiKyAzFnBfAuGiUyLrIeLrNhBeBdVcEeKgCcBrQzDsPwGcNnZvTsEaYmFfMeOmMdNuZbUtDoQoNcGwDqEkEjIdQaPwAxJbXeNxOgKgXoEbZiIsVkRrNpNyAkLeHkNfEpLuQvEcMbIoGaDzXbEtNsLgGfOkZaFiUsOvEjVeCaMcZqMzKeAdXxJsVeCrZaFpJtZxInQxFaSmGgSsVyGeLlFgFqTpIbAvPkIfJrVcJ...
code_stdio
[ { "content": "Write a program which reads an integer and prints sum of its digits.\n\n\n\nInput\n\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000.\n\nThe input ends with a line including single zero. Your program should ...
[{"input": "123\n158\n1100\n0", "output": "6\n14\n2\n"}, {"input": "123\n181\n1111\n0", "output": "6\n10\n4\n"}, {"input": "123\n418\n1100\n0", "output": "6\n13\n2\n"}, {"input": "123\n418\n1110\n0", "output": "6\n13\n3\n"}, {"input": "123\n736\n1110\n0", "output": "6\n16\n3\n"}, {"input": "123\n239\n1000\n0", "output"...
code_stdio
[ { "content": "There is data on sales of your company. Your task is to write a program which identifies good workers.\n\nThe program should read a list of data where each item includes the employee ID i, the amount of sales q and the corresponding unit price p. Then, the program should print IDs of employees who...
[{"input": "4\n1001 2000 520\n1002 3520 450\n1003 1600 625\n1001 200 1220\n2\n1001 100 3\n1005 1000 100\n2\n2013 5000 010\n2013 5000 100\n0", "output": "1001\n1002\n1003\nNA\nNA\n"}, {"input": "4\n0110 2000 520\n11 2363 29\n1507 8024 1160\n1101 670 2276\n2\n0001 100 0\n502 1100 100\n2\n715 1354 100\n1668 14106 100\n0",...
code_stdio
[ { "content": "Takahashi, who is A years old, is riding a Ferris wheel.\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charg...
[{"input": "30 100\n", "output": "100\n"}, {"input": "13 298\n", "output": "298\n"}, {"input": "60 654\n", "output": "654\n"}, {"input": "12 100\n", "output": "50\n"}, {"input": "6 482\n", "output": "241\n"}, {"input": "15 100", "output": "100\n"}, {"input": "16 110", "output": "110\n"}, {"input": "17 101", "output": "...
code_stdio
[ { "content": "International Christmas Present Company (ICPC) is a company to employ Santa and deliver presents on Christmas. Many parents request ICPC to deliver presents to their children at specified time of December 24. Although same Santa can deliver two or more presents, because it takes time to move betwe...
[{"input": "3 2 3\n0 1 10\n1 2 15\n0 -1\n1 8\n2 -1\n3 2 4\n0 1 10\n1 2 10\n0 0\n1 19\n2 20\n0 25\n13 10 10\n0 1 39\n2 3 48\n3 5 20\n4 8 25\n3 9 10\n8 9 40\n3 4 5\n5 0 17\n0 7 93\n1 3 13\n0 0\n1 100000000\n2 100\n3 543\n4 500\n5 400\n6 300\n6 200\n8 100\n9 100\n0 0 0", "output": "3\n3\n4\n"}, {"input": "3 2 3\n0 1 10\n1...
code_stdio
[ { "content": "Airport Codes\n\nAirport code\n\nIn the Kingdom of JAG, airport codes are assigned to each domestic airport for identification.\n\nAirport codes are assigned according to the following rules based on the name of the airport in lowercase English alphabet:\n\n1. Extract the first letter of the name ...
[{"input": "3\nhaneda\noookayama\nssu\n2\nazusa\nazishirabe\n2\nsnuke\nsnake\n4\nhaneda\nhonda\nhanamaki\nhawaii\n0", "output": "1\n4\n-1\n3\n"}, {"input": "3\nhaneda\noookayama\nstu\n2\nazusa\nebarihsiza\n2\nsnuke\nsnake\n4\nhaneda\nhonda\nhanamaki\nhawaih\n0", "output": "1\n1\n-1\n3\n"}, {"input": "3\nhaneca\noookaya...
code_stdio
[ { "content": "You are working for an administration office of the International Center for Picassonian Cubism (ICPC), which plans to build a new art gallery for young artists. The center is organizing an architectural design competition to find the best design for the new building.\n\nSubmitted designs will loo...
[{"input": "4 5\n..33\n33..\n2222\n..1.\n.111\n5 7\n....1\n.1..1\n1..1.\n11..1\n.2222\n..111\n...1.\n3 6\n.3.\n233\n23.\n22.\n.11\n.11\n4 3\n2222\n..11\n..11\n4 5\n.3..\n..33\n322.\n2211\n.11.\n3 3\n222\n2.1\n111\n3 4\n11.\n11.\n.2/\n222\n3 4\n.11\n.11\n.2.\n222\n2 7\n11\n.1\n21\n22\n23\n.3\n33\n2 3\n1.\n11\n1.59382700...
code_stdio
[ { "content": "Did you know that the yummy golden triangle was introduced in India as early as 13th century ? By the way, I'm referring to the popular South Asian snack, Samosa. I guess its hard to code while thinking of Samosa, especially if you are very hungry now ; so lets not get in to any recipe or eating g...
[{"input": "1\n4\n10 20 34 89\n4\n10 26\n7 21\n14 21\n7 35", "output": "2\n"}, {"input": "1\n4\n10 20 34 89\n4\n7 14\n7 21\n14 21\n7 35", "output": "2\n"}, {"input": "1\n4\n10 20 34 55\n4\n7 14\n7 21\n14 6\n13 35", "output": "2\n"}, {"input": "1\n4\n10 20 34 89\n4\n7 26\n7 21\n14 21\n7 35", "output": "2\n"}, {"input": ...
code_stdio
[ { "content": "Eshag has an array $a$ consisting of $n$ integers.\n\nEshag can perform the following operation any number of times: choose some subsequence of $a$ and delete every element from it which is strictly larger than $AVG$, where $AVG$ is the average of the numbers in the chosen subsequence.\n\nFor exam...
[{"input": "3\n6\n1 1 1 7 3 1\n6\n17 17 8 11 9 12\n6\n10 2 2 2 1 1\n", "output": "2\n5\n4\n"}, {"input": "3\n6\n1 1 1 7 3 1\n6\n17 17 8 11 9 12\n6\n10 2 2 2 0 1\n", "output": "2\n5\n5\n"}, {"input": "3\n6\n1 1 2 7 3 1\n6\n17 17 8 11 9 12\n6\n10 2 2 2 0 1\n", "output": "3\n5\n5\n"}, {"input": "3\n6\n1 1 1 2 3 3\n6\n9 9 ...
code_stdio
[ { "content": "Rikhail Mubinchik believes that the current definition of prime numbers is obsolete as they are too complex and unpredictable. A palindromic number is another matter. It is aesthetically pleasing, and it has a number of remarkable properties. Help Rikhail to convince the scientific community in th...
[{"input": "10000 239\n", "output": "1168638\n"}, {"input": "10001 239\n", "output": "1168798\n"}, {"input": "10000 239\n", "output": "1168638"}, {"input": "10278 674\n", "output": "204510\n"}, {"input": "15744 9999\n", "output": "1020\n"}, {"input": "10000 10000\n", "output": "40\n"}, {"input": "5858 674\n", "output":...
code_stdio
[ { "content": "Once again, Boris needs the help of Anton in creating a task. This time Anton needs to solve the following problem:\n\nThere are two arrays of integers $a$ and $b$ of length $n$. It turned out that array $a$ contains only elements from the set $\\{-1, 0, 1\\}$.\n\nAnton can perform the following s...
[{"input": "5\n3\n1 -1 0\n1 1 -2\n3\n0 1 1\n0 2 2\n2\n1 -1\n1 44\n2\n-1 0\n-1 -38\n5\n1 1 -1 1 -1\n1 1 -1 1 -1\n", "output": "YES\nNO\nYES\nYES\nYES\n"}, {"input": "5\n3\n0 -1 -1\n1 1 -2\n3\n0 1 1\n0 1 2\n2\n1 0\n1 41\n2\n-1 0\n-1 -41\n5\n0 1 -1 1 -1\n0 1 -1 1 -1\n", "output": "NO\nYES\nYES\nYES\nYES\n"}, {"input": "5\...
code_stdio
[ { "content": "Inna and Dima bought a table of size n × m in the shop. Each cell of the table contains a single letter: \"D\", \"I\", \"M\", \"A\".\n\nInna loves Dima, so she wants to go through his name as many times as possible as she moves through the table. For that, Inna acts as follows:\n\n initially, Inn...
[{"input": "14 34\nDDDDDDDDDDDDIMADDDDDDDDDDDDDDDIMAD\nDDDDDDIMADDDDDDDDDDDDDDDDDDDDDIMAD\nDDDDDDDDDDDDDIDDDDDDDDDDDIDIMIDIMA\nDDDDDDIMDDDDDDDDDDDDDIDDDDDDDDDDDD\nDDDDDDDDDDDDDDDDDMADDDDDDDDDDDDDMD\nDDDDDDIMIDDDDDDDDDDDDIMIDIMIDDDIDD\nDDDDDDDDDDDDDDDDDMIMDDDDIMDDIMADIM\nDDDDDDDDDDDADIMADIDDDDDDIDIMADADDD\nDDDDDDDDIDDDD...
code_stdio
[ { "content": "Let's call beauty of an array $b_1, b_2, \\ldots, b_n$ ($n > 1$)  — $\\min\\limits_{1 \\leq i < j \\leq n} |b_i - b_j|$.\n\nYou're given an array $a_1, a_2, \\ldots a_n$ and a number $k$. Calculate the sum of beauty over all subsequences of the array of length exactly $k$. As this number can be ve...
[{"input": "52 52\n19752 66708 73109 84463 95683 96876 98503 98812 99766 99778 99913 99975 99977 99997 99997 99997 99998 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100...
code_stdio
[ { "content": "Bob came to a cash & carry store, put n items into his trolley, and went to the checkout counter to pay. Each item is described by its price ci and time ti in seconds that a checkout assistant spends on this item. While the checkout assistant is occupied with some item, Bob can steal some other it...
[{"input": "10\n3 512981548\n0 214269975\n2 603901234\n3 772872647\n0 224281389\n4 561877930\n1 809519308\n4 1128067436\n1 114469023\n2 184038037\n", "output": "860384990\n"}, {"input": "10\n3 512981548\n0 214269975\n2 603901234\n3 772872647\n0 224281389\n4 561877930\n1 809519308\n4 1128067436\n1 40056209\n2 184038037\...
code_stdio
[ { "content": "Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute moves each chip into an adjacent cell. He moves each ...
[{"input": "10 5\n2 1\n4 4\n2 2\n4 3\n1 1\n", "output": "11\n"}, {"input": "5 5\n3 2\n5 4\n3 3\n2 3\n1 2\n", "output": "1\n"}, {"input": "5 5\n3 2\n1 4\n5 1\n4 5\n3 1\n", "output": "2\n"}, {"input": "5 5\n2 2\n5 3\n2 3\n5 1\n4 4\n", "output": "1\n"}, {"input": "6 5\n2 6\n6 5\n3 1\n2 2\n1 2\n", "output": "4\n"}, {"input...
code_stdio