messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
1 value
[ { "content": "Thor is getting used to the Earth. As a gift Loki gave him a smartphone. There are n applications on this phone. Thor is fascinated by this phone. He has only one minor issue: he can't count the number of unread notifications generated by those applications (maybe Loki put a curse on it so he can'...
[{"input": "10 85\n2 2\n1 10\n1 1\n2 6\n1 2\n1 4\n1 7\n2 1\n1 1\n3 3\n1 9\n1 6\n1 8\n1 10\n3 8\n2 8\n1 6\n1 3\n1 9\n1 6\n1 3\n1 8\n1 1\n1 6\n1 10\n2 1\n2 10\n1 10\n1 1\n1 10\n1 6\n2 2\n1 8\n1 3\n1 4\n1 9\n1 5\n1 5\n2 2\n2 4\n1 7\n1 1\n2 4\n2 9\n1 1\n1 7\n1 8\n3 14\n1 10\n2 2\n1 3\n1 10\n1 6\n3 32\n2 3\n1 5\n2 10\n2 2\n...
code_stdio
[ { "content": "The employees of the F company have lots of ways to entertain themselves. Today they invited a famous magician who shows a trick with plastic cups and a marble.\n\nThe point is to trick the spectator's attention. Initially, the spectator stands in front of a line of n plastic cups. Then the magici...
[{"input": "100 50\n11 28\n11 1\n98 58\n38 27\n24 27\n67 37\n90 48\n91 14\n43 29\n3 64\n24 6\n53 19\n97 65\n13 27\n75 53\n37 82\n69 75\n94 99\n1 26\n95 60\n45 27\n100 82\n71 49\n86 99\n74 58\n88 68\n39 63\n38 23\n22 39\n29 58\n62 83\n62 1\n61 58\n2 30\n41 48\n83 90\n1 17\n73 81\n23 53\n71 16\n43 29\n27 78\n54 48\n6 89\...
code_stdio
[ { "content": "Polycarp has $x$ of red and $y$ of blue candies. Using them, he wants to make gift sets. Each gift set contains either $a$ red candies and $b$ blue candies, or $a$ blue candies and $b$ red candies. Any candy can belong to at most one gift set.\n\nHelp Polycarp to find the largest number of gift se...
[{"input": "9\n10 12 1 5\n1 2 2 2\n52 109 13 53\n1000000000 1000000000 1 1\n1000100000 1 1 1000000000\n1 1000000000 1000000001 2\n1 2 1 1\n14 11 2 2\n4 1 2 5\n", "output": "3\n0\n2\n1000000000\n1\n0\n1\n5\n0\n"}, {"input": "9\n10 12 1 16\n1 2 2 3\n52 474 13 53\n1000000000 1001000001 2 1\n1000100000 1 1 1100000000\n1 10...
code_stdio
[ { "content": "You are given an array consisting of all integers from $[l, r]$ inclusive. For example, if $l = 2$ and $r = 5$, the array would be $[2, 3, 4, 5]$. What's the minimum number of elements you can delete to make the bitwise AND of the array non-zero?\n\nA bitwise AND is a binary operation that takes t...
[{"input": "5\n1 1\n1 8\n7 10\n1 10\n100000 186611\n", "output": "0\n4\n1\n5\n31072\n"}, {"input": "5\n1 2\n1 13\n4 5\n4 10\n110000 200000\n", "output": "1\n6\n0\n3\n21072\n"}, {"input": "5\n1 2\n1 13\n4 5\n1 10\n110000 200000\n", "output": "1\n6\n0\n5\n21072\n"}, {"input": "5\n1 1\n1 8\n7 14\n2 16\n100010 186611\n", "...
code_stdio
[ { "content": "Description\n\nSince the cubic equation: ax ^ 3 + bx ^ 2 + cx + d = 0 is given, please check the number of positive real roots and the number of negative real roots, respectively.\n\nThe number of roots shall be counted including the multiple roots.\n\n\n\nInput\n\nThe input consists of multiple t...
[{"input": "2\n1 -1 4 -1\n-1 -10 -2 2", "output": "1 0\n1 2\n"}, {"input": "2\n1 -1 -1 1\n-1 -10 3 1", "output": "2 1\n1 2\n"}, {"input": "2\n1 -2 -1 2\n-2 -10 3 0", "output": "2 1\n1 1\n"}, {"input": "2\n2 -1 -2 0\n-2 -10 1 1", "output": "1 1\n1 2\n"}, {"input": "2\n1 -2 -1 -1\n-5 0 -1 0", "output": "1 0\n0 0\n"}, {"i...
code_stdio
[ { "content": "Let's denote the median of a sequence $s$ with odd length as the value in the middle of $s$ if we sort $s$ in non-decreasing order. For example, let $s = [1, 2, 5, 7, 2, 3, 12]$. After sorting, we get sequence $[1, 2, 2, \\underline{3}, 5, 7, 12]$, and the median is equal to $3$.\n\nYou have a seq...
[{"input": "4\n3 5 1\n1\n13 3 3\n1 4 7\n15 5 3\n2 5 10\n17 18 7\n2 3 5 7 5 11 12\n", "output": "NO\nYES\nYES\nNO\n"}, {"input": "4\n3 5 1\n1\n11 3 3\n1 3 7\n15 5 3\n4 5 6\n13 7 7\n2 3 5 7 9 11 12\n", "output": "NO\nYES\nYES\nYES\n"}, {"input": "4\n3 5 1\n1\n7 3 3\n1 3 7\n15 5 3\n4 5 10\n13 11 7\n2 3 5 7 9 11 12\n", "ou...
code_stdio
[ { "content": "Alternate Escape\n\nAlice House\n\nAlice and Bob are playing board games. This board game is played using a board with squares in rows H and columns and one frame. In this game, the upper left square of the board is set as the 1st row and 1st column, and the rows are counted downward and the colum...
[{"input": "3 3 2 2\n 1 1 1\n0 0 0 0\n 1 1 1\n0 0 0 0\n 1 1 1\n0 0 0 0\n 1 1 1\n3 3 2 1\n 1 0 1\n1 0 1 1\n 1 0 0\n0 0 0 0\n 0 0 1\n1 1 0 1\n 1 0 1\n1 3 1 1\n 1 1 1\n1 0 0 1\n 1 0 1\n2 2 1 1\n 1 0\n1 0 0\n 0 0\n0 0 0\n 0 0\n0 0 0 0", "output": "Yes\nYes\nYes\nNo\n"}, {"input": "3 3 2 3\n 1 1 1\n0 0 0 0\n 1 1 1\n0 0 0 0\...
code_stdio
[ { "content": "You are given a number $n$ and an array $b_1, b_2, \\ldots, b_{n+2}$, obtained according to the following algorithm:\n\nsome array $a_1, a_2, \\ldots, a_n$ was guessed;\n\narray $a$ was written to array $b$, i.e. $b_i = a_i$ ($1 \\le i \\le n$);\n\nThe $(n+1)$-th element of the array $b$ is the su...
[{"input": "1\n12\n400000000 400000000 400000000 400000000 400000000 400000000 400000000 400000000 400000000 400000000 400000000 400000000 400000000 505032704\n", "output": "-1\n"}, {"input": "1\n12\n400000000 400000000 400000000 400000000 400000000 400000000 400000000 400000000 400000000 400000000 400000000 400000000 ...
code_stdio
[ { "content": "Osaki\n\nOsaki\n\nEnglish text is not available in this practice contest.\n\nThe Yamanote Line is a circular railway line laid in the 23 wards of Tokyo. The total route distance is 34.5km, and one lap takes about one hour. There are 29 stations in total. The line color is Uguisu color. The peak co...
[{"input": "3\n05:47:15 04:45:90\n12:12:59 12:13:00\n16:30:20 21:18:53\n6\n00:00:00 03:00:00\n01:00:00 03:00:00\n02:00:00 03:00:00\n03:00:00 04:00:00\n03:00:00 05:00:00\n03:00:00 06:00:00\n0", "output": "1\n3\n"}, {"input": "3\n05:47:15 09:54:40\n12:12:59 12:13:00\n16:30:20 21:18:53\n6\n00:00:00 03:00:00\n01:00:00 03:0...
code_stdio
[ { "content": "In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi:\n\n* If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in hi...
[{"input": "231274241 358979323 84", "output": "393502366 196751183\n"}, {"input": "377378637 358979323 84", "output": "490905292 245452646\n"}, {"input": "7425724 358979323 157", "output": "122135010 244270020\n"}, {"input": "314159265 358979323 84", "output": "448759046 224379523"}, {"input": "7425724 358979323 84", ...
code_stdio
[ { "content": "You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character \"0\" and \"1\") a and b. Then you try to turn a into b using two types of opera...
[{"input": "0\n00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
code_stdio
[ { "content": "Karen is getting ready for a new school day!\n\n [Image] \n\nIt is currently hh:mm, given in a 24-hour format. As you know, Karen loves palindromes, and she believes that it is good luck to wake up when the time is a palindrome.\n\nWhat is the minimum number of minutes she should sleep, such that,...
[{"input": "05:51\n", "output": "250\n"}, {"input": "15:52\n", "output": "250\n"}, {"input": "06:59\n", "output": "182\n"}, {"input": "17:31\n", "output": "151\n"}, {"input": "07:59\n", "output": "122\n"}, {"input": "07:10\n", "output": "171\n"}, {"input": "06:00\n", "output": "241\n"}, {"input": "06:01\n", "output": "...
code_stdio
[ { "content": "During the archaeological research in the Middle East you found the traces of three ancient religions: First religion, Second religion and Third religion. You compiled the information on the evolution of each of these beliefs, and you now wonder if the followers of each religion could coexist in p...
[{"input": "2 12\naa\n+ 1 a\n+ 2 a\n+ 3 a\n- 1\n+ 1 a\n- 2\n+ 2 a\n- 3\n+ 3 a\n+ 2 a\n- 1\n- 3\n", "output": "YES\nYES\nNO\nYES\nNO\nYES\nNO\nYES\nNO\nNO\nNO\nYES\n"}, {"input": "2 12\naa\n+ 1 a\n+ 2 a\n+ 3 a\n- 1\n+ 1 a\n- 2\n+ 2 a\n- 3\n+ 3 a\n+ 2 a\n- 1\n- 3\n", "output": "YES\nYES\nNO\nYES\nNO\nYES\nNO\nYES\nNO\nNO...
code_stdio
[ { "content": "We have a string S of length N consisting of uppercase English letters.\nHow many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?\n\n-----Constraints-----\n - 3 \\leq N \\leq 50\n - S consists of uppercase English letters.\n\n-----Input-----\nInput is given fr...
[{"input": "50\nABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCAB\n", "output": "16\n"}, {"input": "50\nBMZBMWEYYDIADTLCOUEGMDBYFWURPWBPUVHIFNUAPWYNDMHTQV\n", "output": "0\n"}, {"input": "50\nKGKBHTYTSZOTWFLEGSJZZSZFWTZFPNSCGUEMWRCZQXYCIVDQNK\n", "output": "0\n"}, {"input": "50\nABBCACBCCACAAACAACACBCACABBAAABBBBCBAAB...
code_stdio
[ { "content": "Dreamoon is a big fan of the Codeforces contests.\n\nOne day, he claimed that he will collect all the places from $1$ to $54$ after two more rated contests. It's amazing!\n\nBased on this, you come up with the following problem:\n\nThere is a person who participated in $n$ Codeforces rounds. His p...
[{"input": "5\n6 2\n3 1 1 5 7 10\n1 100\n100\n11 1\n1 1 1 1 1 1 1 1 1 1 1\n1 1\n1\n4 57\n80 60 40 20\n", "output": "5\n101\n2\n2\n60\n"}, {"input": "5\n6 2\n3 1 1 5 7 10\n1 100\n100\n11 1\n1 1 1 1 1 1 1 1 1 1 1\n1 1\n1\n4 57\n61 60 40 20\n", "output": "5\n101\n2\n2\n61\n"}, {"input": "5\n6 2\n3 1 1 5 7 10\n1 100\n100\n...
code_stdio
[ { "content": "Reminder: the median of the array $[a_1, a_2, \\dots, a_{2k+1}]$ of odd number of elements is defined as follows: let $[b_1, b_2, \\dots, b_{2k+1}]$ be the elements of the array in the sorted order. Then median of this array is equal to $b_{k+1}$.\n\nThere are $2n$ students, the $i$-th student has...
[{"input": "3\n1\n1 1\n3\n6 5 4 1 2 3\n5\n13 4 10 22 2 5 10 3 16 16\n", "output": "0\n1\n0\n"}, {"input": "3\n1\n-1 2\n3\n11 1 0 2 2 5\n5\n13 2 7 13 1 5 1 3 23 14\n", "output": "3\n0\n2\n"}, {"input": "3\n1\n1 2\n3\n6 5 4 1 2 1\n5\n13 4 7 14 2 10 14 3 34 16\n", "output": "1\n2\n3\n"}, {"input": "3\n1\n1 -1\n3\n6 5 4 1 ...
code_stdio
[ { "content": "Let's arrange a deck of cards. Your task is to sort totally n cards. A card consists of a part of a suit (S, H, C or D) and an number. Write a program which sorts such cards based on the following pseudocode:\n\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x...
[{"input": "6\nD 3\nH 2\nD 1\nS 3\nC 2\nC 1", "output": "Not stable\nD 1\nC 1\nC 2\nH 2\nD 3\nS 3\n"}, {"input": "6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 0", "output": "Not stable\nC 0\nD 1\nH 2\nD 2\nS 3\nD 3\n"}, {"input": "6\nD 3\nH 0\nD 1\nS 3\nC 2\nC 1", "output": "Not stable\nH 0\nD 1\nC 1\nC 2\nS 3\nD 3\n"}, {"input": "6\...
code_stdio
[ { "content": "The Cartesian coordinate system is set in the sky. There you can see n stars, the i-th has coordinates (x_{i}, y_{i}), a maximum brightness c, equal for all stars, and an initial brightness s_{i} (0 ≀ s_{i} ≀ c).\n\nOver time the stars twinkle. At moment 0 the i-th star has brightness s_{i}. Let a...
[{"input": "3 4 5\n1 1 2\n2 3 0\n3 3 1\n0 1 1 100 100\n1 2 2 4 4\n2 2 1 4 7\n1 50 50 51 51\n", "output": "3\n3\n5\n0\n"}, {"input": "3 4 5\n1 1 2\n2 3 0\n3 3 1\n0 1 1 100 100\n1 2 2 4 4\n2 2 1 4 7\n1 60 50 51 51\n", "output": "3\n3\n5\n0\n"}, {"input": "3 4 5\n1 1 2\n2 3 0\n3 3 1\n0 1 1 100 100\n0 2 2 4 4\n2 2 1 4 7\n1...
code_stdio
[ { "content": "The Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below.\n\nThe playing field is a sequence of n non-negative integers ai numbered from 1 to n. The goal of the game is to make numbers a1, a2, ..., ak (i.e. so...
[{"input": "120\n242 524 420 973 816 432 247 666 134 849 145 366 1119 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 223 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 ...
code_stdio
[ { "content": "You are now in a bookshop with your friend Alice to buy a book, \"The Winning Strategy for the Programming Koshien Contest,” just released today. As you definitely want to buy it, you are planning to borrow some money from Alice in case the amount you have falls short of the price. If the amount y...
[{"input": "0111 12618 3831", "output": "3720\n"}, {"input": "0101 15626 3831", "output": "3730\n"}, {"input": "0110 15626 3831", "output": "3721\n"}, {"input": "0111 27455 5699", "output": "5588\n"}, {"input": "0111 27455 8862", "output": "8751\n"}, {"input": "0111 27455 1408", "output": "1297\n"}, {"input": "0111 294...
code_stdio
[ { "content": "Let S be the sum of divisors of an integer N excluding the number itself. When N = S, N is called a perfect number, when N> S, N is called a defendant number, and when N <S, N is called an abundant number. Create a program that determines whether a given integer is a perfect number, a missing numb...
[{"input": "1\n2\n2\n1\n1\n14\n16\n27\n66290451\n187711252\n124798312\n100001000\n0", "output": "deficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\nabundant number\n"}, {"in...
code_stdio
[ { "content": "Recently Max has got himself into popular CCG \"BrainStone\". As \"BrainStone\" is a pretty intellectual game, Max has to solve numerous hard problems during the gameplay. Here is one of them:\n\nMax owns n creatures, i-th of them can be described with two numbers β€” its health hp_{i} and its damag...
[{"input": "10 9 0\n620118469 704168608\n528098892 341451371\n15150469 449838744\n960504540 722185004\n271837337 344050133\n940943201 419522619\n85569623 788965215\n161962866 563795701\n943389281 445744350\n610994199 473866838\n", "output": "5253588583\n"}, {"input": "10 9 0\n620118469 704168608\n528098892 341451371\n1...
code_stdio
[ { "content": "Alyona's mother wants to present an array of n non-negative integers to Alyona. The array should be special. \n\nAlyona is a capricious girl so after she gets the array, she inspects m of its subarrays. Subarray is a set of some subsequent elements of the array. The i-th subarray is described with...
[{"input": "10 10\n1 5\n7 10\n2 10\n2 5\n2 9\n5 9\n3 10\n4 9\n6 9\n2 7\n", "output": "4\n0 1 2 3 0 1 2 3 0 1\n"}, {"input": "10 10\n1 34\n4 4\n4 8\n5 17\n1 9\n3 8\n1 6\n1 9\n1 6\n6 9\n", "output": "1\n0 0 0 0 0 0 0 0 0 0 \n"}, {"input": "10 10\n1 17\n4 8\n4 8\n5 9\n1 9\n3 8\n1 6\n1 9\n1 6\n6 9\n", "output": "4\n0 1 2 3...
code_stdio
[ { "content": "You are given n segments on the Ox-axis. You can drive a nail in any integer point on the Ox-axis line nail so, that all segments containing this point, are considered nailed down. If the nail passes through endpoint of some segment, this segment is considered to be nailed too. What is the smalles...
[{"input": "35\n-47 61\n-73 -15\n9 43\n43 -4\n13 -6\n48 -65\n49 -84\n-6 76\n40 6\n-41 11\n-63 -42\n-7 -7\n47 -98\n-17 61\n79 99\n47 -98\n61 31\n85 72\n-50 -17\n-67 45\n14 -50\n-45 61\n-6 -96\n-47 -83\n56 -58\n-24 -15\n14 20\n-95 -82\n47 93\n-4 -7\n70 9\n91 -18\n-71 31\n55 -20\n81 -8\n", "output": "8\n-82 -42 -15 -7 13 ...
code_stdio
[ { "content": "In this problem you will write a simple generator of Brainfuck (https://en.wikipedia.org/wiki/Brainfuck) calculators.\n\nYou are given an arithmetic expression consisting of integers from 0 to 255 and addition/subtraction signs between them. Output a Brainfuck program which, when executed, will pr...
[{"input": "0-255-255-255-255+255+255+255+255+255\n", "output": "++++++++++++++++++++++++++++++++++++++++++++++++++.>\n+++++++++++++++++++++++++++++++++++++++++++++++++++++.>\n+++++++++++++++++++++++++++++++++++++++++++++++++++++.>\n"}, {"input": "0-255-255-255-255+255+255+255+255+255\n", "output": "+++++++++++++++++++...
code_stdio
[ { "content": "On February, 30th n students came in the Center for Training Olympiad Programmers (CTOP) of the Berland State University. They came one by one, one after another. Each of them went in, and before sitting down at his desk, greeted with those who were present in the room by shaking hands. Each of th...
[{"input": "185\n28 4 4 26 15 21 14 35 22 28 26 24 2 35 21 34 1 23 35 10 6 16 31 0 30 9 18 33 1 22 24 26 22 10 8 27 14 33 16 16 26 22 1 28 32 1 35 12 31 0 21 6 6 5 29 27 1 29 23 22 30 19 37 17 2 2 2 25 3 23 28 0 3 31 34 5 2 23 27 7 26 25 33 27 15 31 31 4 3 21 1 1 23 30 0 13 24 33 26 5 1 17 23 25 36 0 20 0 32 2 2 36 24 ...
code_stdio
[ { "content": "You've got array A, consisting of n integers and a positive integer k. Array A is indexed by integers from 1 to n.\n\nYou need to permute the array elements so that value $\\sum_{i = 1}^{n - k}|A [ i ] - A [ i + k ]|$ became minimal possible. In particular, it is allowed not to change order of ele...
[{"input": "40 4\n600000080 -199999981 -599999907 -199999935 -199999904 -599999919 200000022 600000032 600000046 -999999980 -199999917 600000027 200000075 -999999949 -599999911 -999999969 600000017 -199999999 -999999923 -599999924 600000091 -599999973 -599999936 600000011 -199999951 600000030 -199999900 -1114561877 200...
code_stdio
[ { "content": "One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all the three pairs of coins on pan balance scales ...
[{"input": "A&gt;B\nC&lt;B\nC;tg&A\n", "output": "Impossible\n"}, {"input": "A&lt:B\nB&gt;C\nC&gt;A\n", "output": "Impossible\n"}, {"input": "&Agt;B\nC&lt;B\nC;tg&A\n", "output": "Impossible\n"}, {"input": "B:tl&A\nB&gt;C\nC&gt;A\n", "output": "Impossible\n"}, {"input": "&Agt;B\nC&lt;B\nCgt;&A\n", "output": "Impossible...
code_stdio
[ { "content": "You have an array a consisting of n distinct positive integers, numbered from 1 to n. Define p_k as $$$p_k = βˆ‘_{1 ≀ i, j ≀ k} a_i mod a_j, where x \\bmod y denotes the remainder when x is divided by y. You have to find and print p_1, p_2, \\ldots, p_n$$$. \n\nInput\n\nThe first line contains n β€” t...
[{"input": "100\n15 37 41 48 50 55 62 81 82 101 129 139 141 143 146 154 163 169 170 218 220 237 240 247 249 258 266 271 281 286 288 295 308 328 330 332 338 341 349 392 394 396 408 424 436 440 443 451 452 463 465 469 472 483 484 496 506 512 524 542 550 551 570 574 586 604 610 612 618 629 635 637 638 643 652 672 673 678 ...
code_stdio
[ { "content": "In Absurdistan, there are n towns (numbered 1 through n) and m bidirectional railways. There is also an absurdly simple road network β€” for each pair of different towns x and y, there is a bidirectional road between towns x and y if and only if there is no railway between them. Travelling to a diff...
[{"input": "4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n", "output": "-1\n"}, {"input": "10 5\n2 5\n1 2\n1 4\n1 3\n3 2\n", "output": "-1\n"}, {"input": "4 5\n1 3\n2 1\n3 4\n4 2\n2 3\n", "output": "2\n"}, {"input": "5 5\n2 5\n1 2\n1 4\n1 3\n3 2\n", "output": "2\n"}, {"input": "5 5\n4 5\n1 2\n2 4\n1 3\n3 2\n", "output": "3\n"}, {...
code_stdio
[ { "content": "Consider writing each of the integers from 1 to N \\times M in a grid with N rows and M columns, without duplicates. Takahashi thinks it is not fun enough, and he will write the numbers under the following conditions:\n\n* The largest among the values in the i-th row (1 \\leq i \\leq N) is A_i.\n*...
[{"input": "14 13\n158 167 181 147 178 151 179 182 176 169 180 129 175 168\n181 73 178 179 167 180 176 169 182 177 175 159 173", "output": "146891838\n"}, {"input": "14 13\n158 167 181 147 178 151 179 182 176 169 180 129 175 168\n181 150 178 179 167 180 176 169 182 177 175 159 173", "output": "343772227"}, {"input": "8...
code_stdio
[ { "content": "A continued fraction of height n is a fraction of form $a_{1} + \\frac{1}{a_{2} + \\frac{1}{\\ldots + \\frac{1}{a_{n}}}}$. You are given two rational numbers, one is represented as [Image] and the other one is represented as a finite fraction of height n. Check if they are equal.\n\n\n-----Input--...
[{"input": "633468529243155234 4\n90\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\n", "output": "NO\n"}, {"input": "742143496299253703 2\n90\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian. \n\nChef is judging a game called \"Broken telephone\". There are total N players taking part in the game. They are all sitting in a line. In the start of the game, first player is given a secret message written on a sheet of paper. Then t...
[{"input": "3\n7\n1 1 2 3 3 3 2\n5\n1 -1 1 1 1\n4\n5 5 5 5", "output": "5\n3\n0\n"}, {"input": "3\n7\n1 1 1 3 3 5 3\n5\n1 3 1 1 -1\n4\n1 5 9 5", "output": "5\n5\n4\n"}, {"input": "3\n7\n1 1 2 3 3 3 2\n5\n1 -1 1 1 1\n4\n1 5 5 5", "output": "5\n3\n2\n"}, {"input": "3\n7\n1 1 2 3 3 3 2\n5\n1 -2 1 1 1\n4\n1 7 5 5", "output...
code_stdio
[ { "content": "Neko loves divisors. During the latest number theory lesson, he got an interesting exercise from his math teacher.\n\nNeko has two integers $a$ and $b$. His goal is to find a non-negative integer $k$ such that the least common multiple of $a+k$ and $b+k$ is the smallest possible. If there are mult...
[{"input": "1000000000 264865600\n", "output": "102701600\n"}, {"input": "1000000000 264865600\n", "output": "102701600"}, {"input": "999999973 800000007\n", "output": "199999823\n"}, {"input": "159488527 938932258\n", "output": "100326050\n"}, {"input": "179237079 691088384\n", "output": "332614226\n"}, {"input": "112...
code_stdio
[ { "content": "Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string \"coolmike\", in one move he can transform it into the string \"oolmikec\".\n\...
[{"input": "33\nnkgcmrfvxe\nvxenkgcmrf\nrfvxenkgcm\nvxenkgcmrf\nxenkgcmrfv\nenkgcmrfvx\nenkgcmrfvx\nnkgcmrfvxe\nkgcmrfvxen\ncmrfvxenkg\ncmrfvxenkg\nxenkgcmrfv\nrfvxenkgcm\nrfvxenkgcm\nnkgcmrfvxe\nxenkgcmrfv\nrfvxenkgcm\nxenkgcmrfv\nxenkgcmrfv\ngcmrfvxenk\nmrfvxenkgc\nfvxenkgcmr\nvxenkgcmrf\nenkgcmrfvx\ncmrfvxenkg\ncmrf...
code_stdio
[ { "content": "Arkady decides to observe a river for n consecutive days. The river's water level on each day is equal to some real value.\n\nArkady goes to the riverside each day and makes a mark on the side of the channel at the height of the water level, but if it coincides with a mark made before, no new mark...
[{"input": "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 14 5 8 28 29 30 31 31 31 0 3 15 31 8 33 6 35 35 35 36 36 37 37 38 39 28 0 2 23 75 9 9 0 6 25 41 41 12 42 43 43 36 44 51 45 43 4\n", "output": "2385\n"}, {"input": "100\n0 1...
code_stdio
[ { "content": "Today Adilbek is taking his probability theory test. Unfortunately, when Adilbek arrived at the university, there had already been a long queue of students wanting to take the same test. Adilbek has estimated that he will be able to start the test only $T$ seconds after coming. \n\nFortunately, Ad...
[{"input": "20 25\n1 1 1 1 1 1 2 2 1 1 2 1 2 2 1 2 1 1 2 2\n", "output": "846324940\n"}, {"input": "20 26\n1 2 1 1 1 2 1 1 2 2 2 1 2 1 2 1 1 2 2 1\n", "output": "509799974\n"}, {"input": "20 27\n1 2 1 2 1 2 1 2 2 1 2 2 1 2 2 2 1 1 2 1\n", "output": "867942829\n"}, {"input": "20 29\n2 2 1 2 2 1 1 1 2 2 2 2 2 2 1 1 2 2 2...
code_stdio
[ { "content": "A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.\n\nThe stones are located at integer distance...
[{"input": "100 34\n16 0 10 11 12 13 0 5 4 14 6 15 4 9 1 20 19 14 1 7 14 11 10 20 6 9 12 8 3 19 20 4 17 17 8 11 14 18 5 20 17 0 3 18 14 12 11 12 5 5 11 7 9 17 4 8 4 10 0 0 12 9 15 3 15 14 19 12 6 8 17 19 4 18 19 3 8 3 9 1 6 15 4 16 1 18 13 16 3 5 20 11 10 9 9 17 20 15 12\n", "output": "312\n"}, {"input": "100 34\n16 0 ...
code_stdio
[ { "content": "You are given a string S of length n with each character being one of the first m lowercase English letters. \n\nCalculate how many different strings T of length n composed from the first m lowercase English letters exist such that the length of LCS (longest common subsequence) between S and T is ...
[{"input": "100 26\njysrixyptvsesnapfljeqkytlpeepjopspmkviqdqbdkylvfiawhdjjdvqqvcjmmsgfdmpjwahuwhgsyfcgnefzmqlvtvqqfbfsf\n", "output": "237400\n"}, {"input": "100 27\njysrixyptvsesnapfljeqkytlpeepjopspmkviqdqbdkylvfiawhdjjdvqqvcjmmsgfdmpjwahuwhgsyfcgnefzmqlvtvqqfbfsf\n", "output": "246900\n"}, {"input": "100 30\njysrix...
code_stdio
[ { "content": "Polycarp has recently got himself a new job. He now earns so much that his old wallet can't even store all the money he has.\n\nBerland bills somehow come in lots of different sizes. However, all of them are shaped as rectangles (possibly squares). All wallets are also produced in form of rectangl...
[{"input": "69\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1...
code_stdio
[ { "content": "Chef has a sequence of $N$ integers, $A_1, A_2, ... , A_N$. He likes this sequence if it contains a subsequence of $M$ integers, $B_1, B_2, ... , B_M$ within it.\nA subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of th...
[{"input": "2\n6\n0 2 2 1 11 6\n3\n2 3 0\n6\n22 5 12 19 1 4\n2\n4 15", "output": "No\nNo\n"}, {"input": "2\n6\n1 2 3 4 7 6\n3\n2 3 4\n6\n22 5 6 33 1 4\n2\n4 15", "output": "Yes\nNo\n"}, {"input": "2\n6\n1 2 3 4 5 6\n3\n2 3 4\n6\n22 5 1 33 1 4\n2\n4 15", "output": "Yes\nNo\n"}, {"input": "2\n6\n0 2 3 4 7 6\n3\n2 3 4\n6\...
code_stdio
[ { "content": "You are given an undirected weighted connected graph with $n$ vertices and $m$ edges without loops and multiple edges.\n\nThe $i$-th edge is $e_i = (u_i, v_i, w_i)$; the distance between vertices $u_i$ and $v_i$ along the edge $e_i$ is $w_i$ ($1 \\le w_i$). The graph is connected, i. e. for any pa...
[{"input": "8 10\n1 2 1\n2 3 2\n2 4 5\n1 4 2\n6 3 3\n6 1 3\n3 5 2\n3 7 1\n4 8 1\n6 2 4\n", "output": "1\n"}, {"input": "8 10\n1 2 1\n2 3 4\n2 4 5\n1 4 2\n6 3 3\n6 1 3\n3 5 2\n3 7 1\n4 8 1\n6 2 4\n", "output": "0\n"}, {"input": "8 10\n1 2 1\n2 3 2\n2 4 5\n1 4 2\n6 3 3\n6 1 3\n3 5 2\n3 7 1\n4 8 2\n6 2 4\n", "output": "1\...
code_stdio
[ { "content": "Problem\n\nGiven $ N $ a pair of non-negative integers $ (a_i, b_i) $ and non-negative integers $ A $, $ B $.\nI want to do as many of the following operations as possible.\n\n\n* $ | a_i --b_i | \\ leq A $ or $ B \\ leq | a_i --b_i | \\ leq Take out and delete the element $ i $ that satisfies 2A ...
[{"input": "10 1 12\n15 70\n36 -1\n18 43\n26 46\n33 20\n58 10\n0 -1\n80 5\n98 32\n23 84", "output": "1\n"}, {"input": "10 1 12\n15 70\n36 -1\n18 43\n26 46\n33 20\n58 10\n0 -1\n80 5\n98 32\n23 30", "output": "1\n"}, {"input": "10 1 12\n15 70\n58 -1\n18 43\n26 46\n33 20\n58 10\n0 -1\n80 5\n98 32\n23 30", "output": "1\n"}...
code_stdio
[ { "content": "Taro's summer vacation starts tomorrow, and he has decided to make plans for it now.\n\nThe vacation consists of N days. For each i (1 \\leq i \\leq N), Taro will choose one of the following activities and do it on the i-th day:\n\n* A: Swim in the sea. Gain a_i points of happiness.\n* B: Catch bu...
[{"input": "7\n3 1 176\n0 1 0\n-2 2 0\n2 4 2\n-1 12 1\n0 1 22\n0 1 -4", "output": "215\n"}, {"input": "7\n6 2 176\n1 3 -1\n-2 0 0\n3 9 3\n-1 4 2\n-4 1 4\n0 1 -5", "output": "192\n"}, {"input": "7\n6 2 176\n2 3 -3\n0 0 -1\n6 9 4\n-1 7 2\n-4 1 7\n0 1 -8", "output": "199\n"}, {"input": "7\n9 1 66\n-1 1 2\n-1 2 0\n2 4 1\n0...
code_stdio
[ { "content": "Overall there are m actors in Berland. Each actor has a personal identifier β€” an integer from 1 to m (distinct actors have distinct identifiers). Vasya likes to watch Berland movies with Berland actors, and he has k favorite actors. He watched the movie trailers for the next month and wrote the fo...
[{"input": "50 25\n8 18 41 25 16 39 2 47 49 37 40 23 3 35 15 7 11 28 22 48 10 17 38 46 44\n4\nswyzirxhx\n28\n43 32 14 5 0 17 25 39 0 0 36 0 0 34 27 22 6 13 26 0 0 41 12 16 0 0 0 23\nzyn\n3\n36 12 47\np\n33\n38 0 35 0 6 20 43 9 15 37 17 23 2 0 0 0 0 0 34 0 28 10 33 0 5 4 7 12 36 46 0 0 45\nycaqpkbu\n31\n41 26 16 0 0 36 ...
code_stdio
[ { "content": "Gildong has an interesting machine that has an array $a$ with $n$ integers. The machine supports two kinds of operations:\n\nIncrease all elements of a suffix of the array by $1$.\n\nDecrease all elements of a suffix of the array by $1$.\n\nA suffix is a subsegment (contiguous elements) of the arr...
[{"input": "7\n2\n0 1\n3\n-1 0 2\n4\n110 133 106 95\n4\n-3 -5 -2 1\n6\n1 8 3 8 4 1\n5\n5 0 0 0 5\n9\n-367741579 319422997 -415264583 -125558838 -300860379 721691728 294512916 -383235489 425814447\n", "output": "0\n1\n15\n4\n14\n5\n3449059550\n"}, {"input": "7\n2\n0 1\n3\n-1 0 2\n4\n110 133 106 49\n4\n-3 -5 -2 1\n6\n1 8...
code_stdio
[ { "content": "Caisa is going to have a party and he needs to buy the ingredients for a big chocolate cake. For that he is going to the biggest supermarket in town.\n\nUnfortunately, he has just s dollars for sugar. But that's not a reason to be sad, because there are n types of sugar in the supermarket, maybe h...
[{"input": "69 9\n39 15\n70 44\n90 89\n84 58\n83 97\n24 28\n90 18\n7 96\n43 86\n99 50\n77 12\n12 34\n100 19\n21 86\n55 30\n99 29\n26 92\n82 67\n78 14\n64 16\n98 12\n31 39\n36 86\n73 36\n87 29\n42 23\n58 15\n35 52\n91 56\n39 6\n88 45\n38 36\n57 12\n79 71\n40 33\n98 42\n34 36\n23 79\n69 68\n50 47\n23 6\n22 90\n96 79\n88 ...
code_stdio
[ { "content": "Lunar New Year is approaching, and Bob is planning to go for a famous restaurant β€” \"Alice's\".\n\nThe restaurant \"Alice's\" serves $n$ kinds of food. The cost for the $i$-th kind is always $c_i$. Initially, the restaurant has enough ingredients for serving exactly $a_i$ dishes of the $i$-th kind...
[{"input": "10 15\n132 138 38 75 14 115 129 68 119 118\n728344 513371 120930 757031 137753 453796 348671 185533 966778 521678\n4 58\n1 8\n8 22\n3 98\n2 111\n6 158\n2 82\n1 170\n1 26\n1 4\n4 76\n10 106\n5 100\n4 116\n7 62\n", "output": "43907798\n5826752\n4081726\n15058400\n56984181\n67179393\n33037922\n108948627\n13563...
code_stdio
[ { "content": "Medicine faculty of Berland State University has just finished their admission campaign. As usual, about $80\\%$ of applicants are girls and majority of them are going to live in the university dormitory for the next $4$ (hopefully) years.\n\nThe dormitory consists of $n$ rooms and a single mouse!...
[{"input": "10\n5620 2478 4051 7060 10510 2170 6912 2031 1781 7454\n1 1 1 1 1 1 1 1 1 1\n", "output": "5620\n"}, {"input": "10\n5620 1555 4051 7060 10510 2170 6912 2031 1781 7454\n1 1 1 1 1 1 1 1 1 1\n", "output": "5620\n"}, {"input": "10\n7846 8354 1188 6898 8046 7561 8043 8588 8684 3699\n1 1 2 3 4 5 6 7 8 9\n", "outp...
code_stdio
[ { "content": "You have $n$ gifts and you want to give all of them to children. Of course, you don't want to offend anyone, so all gifts should be equal between each other. The $i$-th gift consists of $a_i$ candies and $b_i$ oranges.\n\nDuring one move, you can choose some gift $1 \\le i \\le n$ and do one of th...
[{"input": "5\n3\n3 5 12\n3 2 3\n5\n1 2 3 4 5\n5 4 1 2 1\n3\n1 1 1\n2 2 2\n6\n1 1000000000 1000000000 1000000000 1000000000 1000000000\n1 1 2 1 1 1\n3\n10 24 8\n7 5 4\n", "output": "12\n16\n0\n4999999995\n19\n"}, {"input": "5\n3\n3 5 12\n3 2 3\n5\n1 2 6 4 5\n5 4 1 2 1\n3\n1 1 1\n2 2 2\n6\n1 1000000000 1000000000 100000...
code_stdio
[ { "content": "Yae joins a journey plan, in which parties will be held several times during the itinerary. She wants to participate in all of them and will carry several dresses with her. But the number of dresses she can carry with her may be smaller than that of the party opportunities. In that case, she has t...
[{"input": "1 118", "output": "118\n"}, {"input": "1 -11", "output": "-11\n"}, {"input": "1 -12", "output": "-12\n"}, {"input": "1 -21", "output": "-21\n"}, {"input": "10 10", "output": "1\n"}, {"input": "1 26", "output": "26\n"}, {"input": "1 43", "output": "43\n"}, {"input": "1 65", "output": "65\n"}, {"input": "1 18...
code_stdio
[ { "content": "For a sequence of integers $A = \\\\{a_0, a_1, ..., a_{n-1}\\\\}$ which is sorted by ascending order, eliminate all equivalent elements.\n\nConstraints\n\n* $1 \\leq n \\leq 100,000$\n* $-1000,000,000 \\leq a_i \\leq 1,000,000,000$\n* $a_0 \\leq a_1 \\leq ... \\leq a_{n-1}$\n\nInput\n\nA sequence ...
[{"input": "4\n-2 -1 1 2", "output": "-2 -1 1 2\n"}, {"input": "4\n-2 -1 0 2", "output": "-2 -1 0 2\n"}, {"input": "4\n-2 -1 0 4", "output": "-2 -1 0 4\n"}, {"input": "4\n-1 0 1 10", "output": "-1 0 1 10\n"}, {"input": "4\n-4 -1 0 1", "output": "-4 -1 0 1\n"}, {"input": "4\n-4 -2 0 1", "output": "-4 -2 0 1\n"}, {"input...
code_stdio
[ { "content": "Andrew often reads articles in his favorite magazine 2Char. The main feature of these articles is that each of them uses at most two distinct letters. Andrew decided to send an article to the magazine, but as he hasn't written any article, he just decided to take a random one from magazine 26Char....
[{"input": "31\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\n", "output": "0\n"}, {"input": "31\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml...
code_stdio
[ { "content": "Polygons are the most fundamental objects in geometric processing. Complex figures are often represented and handled as polygons with many short sides. If you are interested in the processing of geometric data, you'd better try some programming exercises about basic operations on polygons.\n\nYour...
[{"input": "3\n1 1\n3 4\n6 -1\n\n7\n1 -1\n10 10\n-1 20\n3 33\n0 70\n100 40\n100 -1\n\n0", "output": "1 9.5\n2 5426.0\n"}, {"input": "3\n1 1\n3 4\n6 -1\n\n7\n1 -1\n10 10\n-1 20\n3 33\n0 40\n100 40\n100 0\n\n0", "output": "1 9.5\n2 3921.5\n"}, {"input": "3\n2 1\n2 4\n11 0\n\n7\n2 -2\n0 14\n0 28\n3 33\n-2 41\n100 49\n110 ...
code_stdio
[ { "content": "You are given a permutation, p_1, p_2, …, p_n.\n\nImagine that some positions of the permutation contain bombs, such that there exists at least one position without a bomb.\n\nFor some fixed configuration of bombs, consider the following process. Initially, there is an empty set, A.\n\nFor each i ...
[{"input": "10\n7 10 1 8 3 9 2 4 6 5\n7 6 5 3 8 10 4 1 9 2\n", "output": "10 9 8 7 6 6 5 5 5 1 \n"}, {"input": "10\n7 10 1 8 3 9 2 4 6 5\n7 6 5 3 8 10 2 1 9 2\n", "output": "10 9 8 7 6 6 5 5 5 2\n"}, {"input": "10\n7 10 1 8 3 9 2 4 6 5\n7 6 5 3 8 10 4 1 2 2\n", "output": "10 9 8 7 6 6 5 5 5 5\n"}, {"input": "10\n7 10 1...
code_stdio
[ { "content": "The only difference between the easy and the hard versions is the maximum value of $k$.\n\nYou are given an infinite sequence of form \"112123123412345$\\dots$\" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$...
[{"input": "19\n1\n10\n100\n1000\n10000\n100000\n1000000\n10000000\n100000000\n1000000000\n10000000000\n100000000000\n1000000000000\n10000000000000\n100000000000000\n1000000000000000\n10000000000000000\n100000000000000000\n1000000000000000000\n", "output": "1\n4\n1\n4\n9\n2\n6\n2\n6\n8\n1\n1\n9\n8\n3\n7\n6\n1\n1\n"}, {...
code_stdio
[ { "content": "Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to (x - 1, y) or (x, y - 1). Vasiliy can move his pawn from (x...
[{"input": "100000 99999 100000 100000\n", "output": "Polycarp\n"}, {"input": "100000 100000 100000 99999\n", "output": "Vasiliy\n"}, {"input": "55000 60000 55003 60100\n", "output": "Polycarp\n"}, {"input": "23039 21508 54113 76824\n", "output": "Polycarp\n"}, {"input": "32959 49970 75441 55257\n", "output": "Polycarp...
code_stdio
[ { "content": "Two people play the following string game. Initially the players have got some string s. The players move in turns, the player who cannot make a move loses. \n\nBefore the game began, the string is written on a piece of paper, one letter per cell.\n\n<image> An example of the initial situation at ...
[{"input": "tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiogogogogogogogogo...
code_stdio
[ { "content": "Takahashi is distributing N balls to K persons.\n\nIf each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?\n\nConstraints\n\n* 1 \\leq K \\leq N \\leq 100\n...
[{"input": "-2 135", "output": "-137\n"}, {"input": "-2 240", "output": "-242\n"}, {"input": "-4 240", "output": "-244\n"}, {"input": "3 130", "output": "-127\n"}, {"input": "2 130", "output": "-128\n"}, {"input": "2 218", "output": "-216\n"}, {"input": "2 323", "output": "-321\n"}, {"input": "3 323", "output": "-320\n...
code_stdio
[ { "content": "There is a bus route as shown in Figure 1. There are 10 stops, each numbered 0-9. The bus turns back at stop 0, but the other side is a circulation route, which circulates in the order of 5 β†’ 6 β†’ 7 β†’ 8 β†’ 9 β†’ 5 as shown in the figure.\n\n<image>\n\n\nFor this bus route, create a program that inputs...
[{"input": "2\n1 8\n8 0", "output": "1 2 3 4 5 6 7 8\n8 9 5 4 3 2 1 0\n"}, {"input": "2\n1 9\n8 1", "output": "1 2 3 4 5 6 7 8 9\n8 9 5 4 3 2 1\n"}, {"input": "2\n2 8\n6 2", "output": "2 3 4 5 6 7 8\n6 7 8 9 5 4 3 2\n"}, {"input": "2\n1 8\n5 0", "output": "1 2 3 4 5 6 7 8\n5 4 3 2 1 0\n"}, {"input": "2\n0 7\n8 2", "out...
code_stdio
[ { "content": "There are n cities in Berland and some pairs of them are connected by two-way roads. It is guaranteed that you can pass from any city to any other, moving along the roads. Cities are numerated from 1 to n.\n\nTwo fairs are currently taking place in Berland β€” they are held in two different cities a...
[{"input": "3\n7 7 3 5\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 5\n4 5 2 4\n1 2\n2 3\n3 4\n4 1\n4 2\n4 3 2 1\n1 2\n2 3\n4 1\n", "output": "4\n0\n1\n"}, {"input": "3\n7 7 3 5\n1 2\n2 3\n3 4\n2 5\n5 6\n6 7\n7 5\n4 5 2 4\n1 2\n2 3\n3 4\n4 1\n4 2\n4 3 2 1\n1 2\n2 3\n4 1\n", "output": "2\n0\n1\n"}, {"input": "3\n7 7 3 5\n1 2\n2 3\n...
code_stdio
[ { "content": "Limak is a grizzly bear who desires power and adoration. He wants to win in upcoming elections and rule over the Bearland.\n\nThere are n candidates, including Limak. We know how many citizens are going to vote for each candidate. Now i-th candidate would get a_{i} votes. Limak is candidate number...
[{"input": "100\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 100...
code_stdio
[ { "content": "problem\n\nJOI took six subjects: physics, chemistry, biology, earth science, history, and geography. Each test was scored on a 100-point scale.\n\nJOI chooses 3 subjects from 4 subjects of physics, chemistry, biology, and earth science, and 1 subject from 2 subjects of history and geography.\n\nW...
[{"input": "100\n-3\n8\n108\n-12\n-4", "output": "212\n"}, {"input": "100\n-7\n8\n108\n-12\n-1", "output": "215\n"}, {"input": "100\n66\n-13\n-1\n-2\n2", "output": "167\n"}, {"input": "100\n106\n-5\n-1\n-2\n3", "output": "208\n"}, {"input": "100\n106\n-2\n-2\n-2\n3", "output": "207\n"}, {"input": "100\n34\n76\n67\n10\n...
code_stdio
[ { "content": "Last year the world's largest square was built in Berland. It is known that the square can be represented as an infinite plane with an introduced Cartesian system of coordinates. On that square two sets of concentric circles were painted. Let's call the set of concentric circles with radii 1, 2, ....
[{"input": "100000 -100000 100000 100000\n", "output": " 200001\n"}, {"input": "100000 100000 100000 -100000\n", "output": " 200001\n"}, {"input": "99999 100000 100000 -100000\n", "output": " ...
code_stdio
[ { "content": "Alice has got addicted to a game called Sirtet recently.\n\nIn Sirtet, player is given an $n \\times m$ grid. Initially $a_{i,j}$ cubes are stacked up in the cell $(i,j)$. Two cells are called adjacent if they share a side. Player can perform the following operations: stack up one cube in two ad...
[{"input": "1555494676 853938121 172337487 490664825\n", "output": "866256663\n"}, {"input": "885636311 1133047284 232531966 493119835\n", "output": "572179871\n"}, {"input": "1076117758 300009121 565317265 947272048\n", "output": "963831390\n"}, {"input": "795069900 869551950 803936044 1279842333\n", "output": "815573...
code_stdio
[ { "content": "Dima and Inna are doing so great! At the moment, Inna is sitting on the magic lawn playing with a pink pony. Dima wanted to play too. He brought an n Γ— m chessboard, a very tasty candy and two numbers a and b.\n\nDima put the chessboard in front of Inna and placed the candy in position (i, j) on t...
[{"input": "1000000 1000000 1000000 0000000 1000000 1000000\n", "output": "Poor Inna and pony!"}, {"input": "1000100 1000000 1000000 0000000 1000000 1000000\n", "output": "Poor Inna and pony!"}, {"input": "1000100 1000010 1000000 0000000 1000000 1000000\n", "output": "Poor Inna and pony!"}, {"input": "1000000 99999 123...
code_stdio
[ { "content": "Under the command \"Save Sergeant Ryan,\" Aiz's rescue team fought fierce battles with enemy forces in the floating city of Lee, Germany. They successfully joined the sergeant, but there were many enemy tanks and they could not call a rescue herio. So, in order to confuse the enemy tanks, they dec...
[{"input": "7\n1 2 5\n2 3 2\n3 4 3\n1 5 13\n5 6 3\n5 7 11\n0", "output": "27\n"}, {"input": "7\n1 2 4\n2 4 2\n3 4 3\n1 5 13\n5 6 3\n5 7 11\n0", "output": "25\n"}, {"input": "7\n1 3 2\n2 3 1\n7 4 3\n1 5 10\n5 6 4\n5 7 15\n0", "output": "29\n"}, {"input": "7\n1 2 5\n2 3 2\n3 4 3\n2 5 3\n5 6 10\n5 7 12\n0", "output": "12\...
code_stdio
[ { "content": "You are given an array a with n distinct integers. Construct an array b by permuting a such that for every non-empty subset of indices S = {x1, x2, ..., xk} (1 ≀ xi ≀ n, 0 < k < n) the sums of elements on that positions in a and b are different, i. e. \n\n<image>\n\nInput\n\nThe first line contain...
[{"input": "22\n133295371 188010892 71730560 209842234 193069109 184556873 87395258 234247052 230809052 211444018 148989732 17810977 158722706 11753932 100093528 1000000000 43672080 61357581 171830832 13873487 34865589 114340079\n", "output": "148989732 193069109 87395258 211444018 209842234 188010892 100093528 1000000...
code_stdio
[ { "content": "Example\n\nInput\n\nacmicpc\ntsukuba\n\n\nOutput\n\nNo\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your complete solution in a single ```python code block.", "role": "user" } ]
[{"input": "acmicpc\nttukuba", "output": "No\n"}, {"input": "acmpcic\nttukuba", "output": "No\n"}, {"input": "acmpcid\nttukuba", "output": "No\n"}, {"input": "acmpcid\nttakubu", "output": "No\n"}, {"input": "acmqcid\nttakubu", "output": "No\n"}, {"input": "aciqcmd\nttakubu", "output": "No\n"}, {"input": "aciqcmd\ntt`ku...
code_stdio
[ { "content": "Vasya decided to pass a very large integer n to Kate. First, he wrote that number as a string, then he appended to the right integer kΒ β€” the number of digits in n. \n\nMagically, all the numbers were shuffled in arbitrary order while this note was passed to Kate. The only thing that Vasya remember...
[{"input": "11111111111101101111110101011111010101001111001110010011810010110111101101112140110110\n110101100101111101011111111101111111111110111110011111011000111010100111011111000002\n", "output": "110101100101111101011111111101111111111110111110011111011000111010100111011111000002\n"}, {"input": "1111111111110110111...
code_stdio
[ { "content": "You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b' <image> 'a' <image> 'z'. In other words, each character is replaced with the previous character of Eng...
[{"input": "abbbbbbbabbbbbbbbbbbbbbbbbbbbbbbabbabbbbbabbbbbbbbbbbabbbbbbbbabbabbbbbbbbbbbbbbabbabbbaababbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbabbbbbbbbbbbbbbbbabbbbabbbbbbbbbbbbbbbabbbbbbbbbaababbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbabbabbbbbbbbbbbbbbbbabbbabbbbbaabbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbb...
code_stdio
[ { "content": "Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).\n\n-----Constraints-----\n - 1 \\leq N \\leq 10^4\n - 1 \\leq A \\leq B \\leq 36\n - All input values are integers.\n\n-----Input-----\nInput is given from Standard Inpu...
[{"input": "100 4 16\n", "output": "4554\n"}, {"input": "101 0 154", "output": "5151\n"}, {"input": "111 1 181", "output": "6216\n"}, {"input": "110 2 100", "output": "5994\n"}, {"input": "100 2 100", "output": "4939\n"}, {"input": "101 1 011", "output": "2995\n"}, {"input": "101 1 010", "output": "2511\n"}, {"input": ...
code_stdio
[ { "content": "Slava plays his favorite game \"Peace Lightning\". Now he is flying a bomber on a very specific map.\n\nFormally, map is a checkered field of size 1 Γ— n, the cells of which are numbered from 1 to n, in each cell there can be one or several tanks. Slava doesn't know the number of tanks and their po...
[{"input": "11124\n", "output": "16686\n2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 122 124 126 128 130 132 134 136 138 140 142 144 146 148 150 152 154 156 158 160 162 164 166 1...
code_stdio
[ { "content": "We have a graph with N vertices, numbered 0 through N-1. Edges are yet to be added.\n\nWe will process Q queries to add edges. In the i-th (1≦i≦Q) query, three integers A_i, B_i and C_i will be given, and we will add infinitely many edges to the graph as follows:\n\n* The two vertices numbered A_i...
[{"input": "2 1\n0 0 1000000010", "output": "1000000011\n"}, {"input": "2 1\n1 0 1000000010", "output": "1000000010\n"}, {"input": "2 1\n0 0 1000000100", "output": "1000000101\n"}, {"input": "2 1\n0 0 1000001010", "output": "1000001011\n"}, {"input": "2 1\n0 0 1000010100", "output": "1000010101\n"}, {"input": "3 1\n0 0...
code_stdio
[ { "content": "One tradition of ACM-ICPC contests is that a team gets a balloon for every solved problem. We assume that the submission time doesn't matter and teams are sorted only by the number of balloons they have. It means that one's place is equal to the number of teams with more balloons, increased by 1. ...
[{"input": "7\n14000000003 1000000000000000000\n81000000000 88000000000\n5000000000 10778591928\n15000000000 39000000000\n46000000000 51000000000\n0 0000000000\n0 0\n", "output": "3\n"}, {"input": "7\n14000000003 1000000000000000000\n81000000000 88000000000\n5000000000 10778591928\n15000000000 41827794041\n46000000000 ...
code_stdio
[ { "content": "Peter loves any kinds of cheating. A week before ICPC, he broke into Doctor's PC and sneaked a look at all the problems that would be given in ICPC. He solved the problems, printed programs out, and brought into ICPC. Since electronic preparation is strictly prohibited, he had to type these progra...
[{"input": "3\n10 20 47\n7\n56 26 62 143 38 80 7", "output": "117\n1108\n"}, {"input": "3\n10 20 47\n7\n56 44 62 143 38 80 7", "output": "117\n1210\n"}, {"input": "3\n10 20 47\n7\n56 44 62 143 38 80 6", "output": "117\n1203\n"}, {"input": "3\n17 20 47\n7\n56 44 62 143 38 80 6", "output": "138\n1203\n"}, {"input": "3\n1...
code_stdio
[ { "content": "Palindromic characteristics of string s with length |s| is a sequence of |s| integers, where k-th number is the total number of non-empty substrings of s which are k-palindromes.\n\nA string is 1-palindrome if and only if it reads the same backward as forward.\n\nA string is k-palindrome (k > 1) i...
[{"input": "wyemcafatp\n", "output": "11 1 0 0 0 0 0 0 0 0 \n"}, {"input": "wyemcafatp\n", "output": "11 1 0 0 0 0 0 0 0 0 "}, {"input": "wyempafatc\n", "output": "11 1 0 0 0 0 0 0 0 0\n"}, {"input": "wyempaf`tc\n", "output": "10 0 0 0 0 0 0 0 0 0\n"}, {"input": "wyfmpae`tc\n", "output": "10 0 0 0 0 0 0 0 0 0\n"}, {"in...
code_stdio
[ { "content": "Monocarp plays a computer game. There are $n$ different sets of armor and $m$ different weapons in this game. If a character equips the $i$-th set of armor and wields the $j$-th weapon, their power is usually equal to $i + j$; but some combinations of armor and weapons synergize well. Formally, th...
[{"input": "2 10\n20\n2 2\n2 3\n2 4\n1 5\n1 2\n1 6\n1 1\n1 10\n2 10\n1 4\n2 8\n2 1\n1 9\n1 8\n2 5\n1 7\n2 7\n1 3\n2 9\n2 6\n", "output": "4\n"}, {"input": "2 10\n20\n2 6\n2 3\n1 1\n2 1\n2 9\n1 6\n1 2\n1 9\n1 10\n2 7\n2 4\n2 5\n1 5\n2 2\n2 8\n1 3\n1 8\n1 4\n1 7\n2 10\n", "output": "4\n"}, {"input": "2 10\n20\n1 9\n2 3\n...
code_stdio
[ { "content": "There is a grid of size W Γ— H surrounded by walls. Some cells in the grid are occupied by slimes. The slimes want to unite with each other and become a \"King Slime\".\n\nIn each move, a slime can move to east, west, south and north direction until it enters a cell occupied by another slime or hit...
[{"input": "4 3 3\n1 1\n0 3\n3 1\n3 3", "output": "3\n"}, {"input": "4 3 3\n1 1\n1 3\n6 1\n3 2", "output": "4\n"}, {"input": "4 3 3\n1 1\n1 3\n3 1\n3 6", "output": "3\n"}, {"input": "4 6 3\n1 1\n0 3\n3 1\n3 3", "output": "3\n"}, {"input": "4 3 3\n1 1\n1 3\n3 1\n3 2", "output": "3\n"}, {"input": "4 3 3\n1 2\n1 3\n3 1\n3...
code_stdio
[ { "content": "You are given a rectangular table 3 Γ— n. Each cell contains an integer. You can move from one cell to another if they share a side.\n\nFind such path from the upper left cell to the bottom right cell of the table that doesn't visit any of the cells twice, and the sum of numbers written in the cell...
[{"input": "10\n1086100980 -928074266 -409520915 770775361 240764400 108297300 -280070452 588179696 -920283246 736937716\n422602209 -940948979 -483879926 -525886137 -79749893 -958247281 844561102 553768085 269384580 -975129348\n-485518332 -130037110 493465239 494308146 958976404 706037260 154106757 -250914836 -91581406...
code_stdio
[ { "content": "Joisino the magical girl has decided to turn every single digit that exists on this world into 1.\nRewriting a digit i with j (0≀i,j≀9) costs c_{i,j} MP (Magic Points).\nShe is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains...
[{"input": "5 5\n0 999 1966 999 999 999 999 1629 999 790\n999 0 1675 999 1588 1296 1765 999 1373 999\n1262 999 0 999 999 999 999 999 999 999\n999 999 999 0 999 1663 729 999 999 1405\n999 999 999 999 1 999 999 999 1316 999\n999 999 999 999 182 1 251 926 1967 999\n1453 999 974 1903 117 999 0 999 1479 999\n416 999 999 999...
code_stdio
[ { "content": "You are given a tree with n vertices. Each vertex i has a value a_i associated with it.\n\nLet us root the tree at some vertex v. The vertex v is called a distinctive root if the following holds: in all paths that start at v and end at some other node, all the values encountered are distinct. Two ...
[{"input": "12\n7 1 6 1 4 1 0 3 2 5 3 1\n1 2\n2 10\n1 3\n6 4\n7 9\n3 5\n5 7\n11 8\n1 11\n11 12\n3 6\n", "output": "0\n"}, {"input": "12\n4 1 6 1 7 1 1 3 2 5 3 2\n1 2\n1 10\n1 3\n3 4\n7 9\n3 5\n5 7\n7 8\n1 11\n11 12\n3 6\n", "output": "4\n"}, {"input": "12\n4 1 6 1 4 1 1 3 2 5 3 2\n1 2\n2 10\n1 3\n3 4\n7 9\n3 5\n5 7\n7 ...
code_stdio
[ { "content": "In the snake exhibition, there are $n$ rooms (numbered $0$ to $n - 1$) arranged in a circle, with a snake in each room. The rooms are connected by $n$ conveyor belts, and the $i$-th conveyor belt connects the rooms $i$ and $(i+1) \\bmod n$. In the other words, rooms $0$ and $1$, $1$ and $2$, $\\ld...
[{"input": "36\n2\n--\n2\n>-\n2\n<-\n2\n->\n2\n>>\n2\n<>\n2\n-<\n2\n><\n2\n<<\n3\n---\n3\n>--\n3\n<--\n3\n->-\n3\n>>-\n3\n<>-\n3\n-<-\n3\n><-\n3\n<<-\n3\n-->\n3\n>->\n3\n<->\n3\n->>\n3\n>>>\n3\n<>>\n3\n-<>\n3\n><>\n3\n<<>\n3\n--<\n3\n>-<\n3\n<-<\n3\n-><\n3\n>><\n3\n<><\n3\n-<<\n3\n><<\n3\n<<<\n", "output": "2\n2\n2\n2\...
code_stdio
[ { "content": "Recently Polycarp noticed that some of the buttons of his keyboard are malfunctioning. For simplicity, we assume that Polycarp's keyboard contains $26$ buttons (one for each letter of the Latin alphabet). Each button is either working fine or malfunctioning. \n\nTo check which buttons need replace...
[{"input": "1\nammsdsdadasdsadssadassadsadasdsadsadr\n", "output": "adrs\n"}, {"input": "1\nammsdsdadasdsadssadassadsadasdsadsadr\n", "output": "adrs\n"}, {"input": "1\nammsdsdaeasdsadssadassadsadasdsadsads\n", "output": "ades\n"}, {"input": "1\nmlsjmksjfksjfkrjjksfnfksjfsksjdf\n", "output": "dfjklmnrs\n"}, {"input": "...
code_stdio
[ { "content": "Arkady is playing Battleship. The rules of this game aren't really important.\n\nThere is a field of $n \\times n$ cells. There should be exactly one $k$-decker on the field, i.Β e. a ship that is $k$ cells long oriented either horizontally or vertically. However, Arkady doesn't know where it is lo...
[{"input": "19 6\n##..............###\n#......#####.....##\n.....#########.....\n....###########....\n...#############...\n..###############..\n.#################.\n.#################.\n.#################.\n.#################.\n#####....##....####\n####............###\n###............####\n#####...####...####\n.#####.....
code_stdio
[ { "content": "Little Chris knows there's no fun in playing dominoes, he thinks it's too random and doesn't require skill. Instead, he decided to play with the dominoes and make a \"domino show\".\n\nChris arranges n dominoes in a line, placing each piece vertically upright. In the beginning, he simultaneously p...
[{"input": "400\n.L.R.LR.LRL.R.LR.LR..L....RLR.L..R..LRLRLR.LRL..RLR.LRLRLRLR.LR..LRL.RLR...LRLR.LRL.R.LR..LR.LRLR...LRLRL.R.L.....RL..RL.RLRL.RL.RL...RL..R.LRLRL..R.LRL...R..LRL.RLRL...RL..RLRLRLRL.R..LRL.R..LRLRL.R.L.R.L.RL.RLRLRL....R.LR..L..RL.RL.RLRLR.L..RLRL.RLR..LRLR.L.R..L.R.LR.LRL.....RLRL..RL..RLR.......LRLRL...
code_stdio
[ { "content": "There is always an integer in Takahashi's mind.\nInitially, the integer in Takahashi's mind is 0. Takahashi is now going to eat four symbols, each of which is + or -. When he eats +, the integer in his mind increases by 1; when he eats -, the integer in his mind decreases by 1.\nThe symbols Takaha...
[{"input": "-+--\n", "output": "-2\n"}, {"input": "----\n", "output": "-4\n"}, {"input": "--+-\n", "output": "-2\n"}, {"input": "+---\n", "output": "-2\n"}, {"input": "+-++\n", "output": "2\n"}, {"input": "++++\n", "output": "4\n"}, {"input": "++-+\n", "output": "2\n"}, {"input": "-++-\n", "output": "0\n"}, {"input": "...
code_stdio
[ { "content": "Seisu-ya, a store specializing in non-negative integers, sells N non-negative integers. The i-th integer is A_i and has a utility of B_i. There may be multiple equal integers with different utilities.\n\nTakahashi will buy some integers in this store. He can buy a combination of integers whose bit...
[{"input": "7 17\n0 13\n13 1\n11 3\n4 5\n11 6\n-1 1\n2 -1", "output": "27\n"}, {"input": "7 20\n-1 0\n11 3\n35 2\n1 10\n4 6\n-1 0\n3 -1", "output": "18\n"}, {"input": "7 20\n-1 0\n11 5\n35 2\n1 10\n4 6\n-1 0\n3 -1", "output": "20\n"}, {"input": "7 20\n-1 -1\n3 0\n35 4\n1 10\n4 6\n-1 0\n3 -1", "output": "15\n"}, {"input...
code_stdio
[ { "content": "This is the easier version of the problem. In this version, $1 \\le n \\le 10^5$ and $0 \\le a_i \\le 1$. You can hack this problem only if you solve and lock both problems.\n\nChristmas is coming, and our protagonist, Bob, is preparing a spectacular present for his long-time best friend Alice. Th...
[{"input": "100\n1 1 0 1 1 1 1 0 1 0 0 1 1 1 1 1 0 1 0 1 0 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0 1 0 1 0 1 1 0 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 0 1 0 1 1 1 1\n", "output": "1908\n"}, {"input": "100\n1 1 0 1 1 1 1 0 1 0 0 1 1 1 1 1 0 1 0 1 0 1 1 1 1 1 0 1 1 1 1 ...
code_stdio
[ { "content": "Given is a simple undirected graph with N vertices and M edges.\nIts vertices are numbered 1, 2, \\ldots, N and its edges are numbered 1, 2, \\ldots, M.\nOn Vertex i (1 \\leq i \\leq N) two integers A_i and B_i are written.\nEdge i (1 \\leq i \\leq M) connects Vertices U_i and V_i.\nSnuke picks ze...
[{"input": "300 300\n599720 331719 986622 302202 64836 630708 260908 557550 679660 315022 939160 133005 77222 687214 693973 196526 652034 173431 482644 484812 94312 433438 906407 324065 596747 112756 754441 540417 983349 160127 708834 39489 589887 615607 667029 767736 450291 829668 192526 414428 183234 555305 240890 48...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \n\nChef's team is going to participate at the legendary math battles. One of the main task in the competition is to calculate the number of ways to create a number by adding some Chefonacci numbers. A number is called a...
[{"input": "5\n-2 -8\n11 0\n109 35\n0 -2\n-4 0", "output": "0\n0\n4375\n0\n0\n"}, {"input": "5\n-3 0\n11 1\n148 35\n0 -2\n-4 0", "output": "0\n0\n18334\n0\n0\n"}, {"input": "5\n-3 0\n5 1\n148 35\n0 -2\n-4 0", "output": "0\n1\n18334\n0\n0\n"}, {"input": "5\n-2 -8\n5 0\n70 12\n0 -2\n-4 0", "output": "0\n0\n279\n0\n0\n"},...
code_stdio
[ { "content": "Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes.\n\nStrictly speaking, it makes a photo of all points with coordinates (x, y), such that x_1 ≀ x ≀ x_2 and y_1 ≀ y ≀ y_2,...
[{"input": "2\n240945287 28477772 1496174734 106174079\n", "output": "97526692469552229\n"}, {"input": "2\n240945287 28477772 1496174734 174902664\n", "output": "96930557139611326\n"}, {"input": "2\n240945287 45763153 1496174734 174902664\n", "output": "95788985238816963\n"}, {"input": "2\n186213023 151398020 526707498...
code_stdio
[ { "content": "Johnny drives a truck and must deliver a package from his hometown to the district center. His hometown is located at point 0 on a number line, and the district center is located at the point d.\n\nJohnny's truck has a gas tank that holds exactly n liters, and his tank is initially full. As he dri...
[{"input": "281 12 23\n178 650197\n129 288456\n34 924882\n43 472160\n207 957083\n103 724815\n167 308008\n135 906958\n74 242828\n229 146026\n85 241042\n22 39127\n62 47524\n113 760274\n156 562141\n10 209057\n50 714473\n201 164128\n97 624021\n120 102709\n147 388268\n219 933977\n190 950684\n", "output": "-1\n"}, {"input": ...
code_stdio
[ { "content": "Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing h...
[{"input": "119 119 119 119 119\n10 10 10 10 10\n0 20\n", "output": "1310\n"}, {"input": "119 119 119 119 119\n10 10 10 10 10\n0 20\n", "output": "1310\n"}, {"input": "78 119 119 119 119\n10 10 10 10 10\n0 20\n", "output": "1310\n"}, {"input": "78 119 176 119 119\n10 10 10 10 10\n0 20\n", "output": "1310\n"}, {"input":...
code_stdio
[ { "content": "For given integer n, count the totatives of n, that is, the positive integers less than or equal to n that are relatively prime to n.\n\n\n\nInput\n\n\nn\n\n\nAn integer n (1 ≀ n ≀ 1000000000).\n\nOutput\n\nThe number of totatives in a line.\n\nExamples\n\nInput\n\n6\n\n\nOutput\n\n2\n\n\nInput\n\...
[{"input": "1101011", "output": "1084512\n"}, {"input": "1100111", "output": "1097712\n"}, {"input": "1010111", "output": "1003752\n"}, {"input": "1111111", "output": "1106224\n"}, {"input": "1011001", "output": "1011000\n"}, {"input": "1100101", "output": "1100100\n"}, {"input": "1101101", "output": "1037232\n"}, {"in...
code_stdio
[ { "content": "Allen is hosting a formal dinner party. $2n$ people come to the event in $n$ pairs (couples). After a night of fun, Allen wants to line everyone up for a final picture. The $2n$ people line up, but Allen doesn't like the ordering. Allen prefers if each pair occupies adjacent positions in the line,...
[{"input": "86\n33 6 22 8 54 43 57 85 70 41 20 17 35 12 66 25 45 78 67 55 50 19 31 75 77 29 58 78 34 15 40 48 14 82 6 37 44 53 62 23 56 22 34 18 71 83 21 80 47 38 3 42 60 9 73 49 84 7 76 30 5 4 11 28 69 16 26 10 59 48 64 46 32 68 24 63 79 36 13 1 27 61 39 74 2 51 51 2 74 39 61 27 1 13 36 79 86 24 68 32 46 64 63 59 10 2...
code_stdio
[ { "content": "You are given several queries. In the i-th query you are given a single positive integer ni. You are to represent ni as a sum of maximum possible number of composite summands and print this maximum number, or print -1, if there are no such splittings.\n\nAn integer greater than 1 is composite, if ...
[{"input": "100\n611\n513\n544\n463\n38\n778\n116\n317\n848\n664\n440\n108\n718\n54\n334\n876\n234\n22\n944\n305\n159\n245\n513\n691\n639\n65\n308\n324\n813\n459\n164\n116\n331\n993\n184\n224\n853\n769\n121\n687\n93\n930\n751\n308\n485\n1386\n400\n695\n95\n751\n175\n972\n121\n654\n242\n610\n1074\n999\n237\n548\n742\n76...
code_stdio
[ { "content": "This is the easy version of the problem. The difference between the versions is in the constraints on the array elements. You can make hacks only if all versions of the problem are solved.\n\nYou are given an array [a_1, a_2, ..., a_n]. \n\nYour goal is to find the length of the longest subarray o...
[{"input": "100\n21 40 61 74 3 78 72 22 10 5 6 6 7 18 30 52 5 2 74 9 51 20 1 38 2 32 27 9 75 58 53 64 9 4 61 18 4 1 6 40 17 2 2 5 8 1 5 74 6 6 3 75 1 4 25 36 56 68 31 9 1 2 52 2 3 4 46 62 26 11 79 2 11 6 1 64 72 10 8 7 5 4 66 9 5 61 47 53 2 5 15 12 72 77 10 3 4 47 8 1\n", "output": "82\n"}, {"input": "100\n21 40 61 74 ...
code_stdio
[ { "content": "3R2 as DJ Mashiro - Happiness Breeze Ice - DJ Mashiro is dead or alive\n\nNEKO#ΦωΦ has just got a new maze game on her PC!\n\nThe game's main puzzle is a maze, in the forms of a $2 \\times n$ rectangle grid. NEKO's task is to lead a Nekomimi girl from cell $(1, 1)$ to the gate at $(2, n)$ and esca...
[{"input": "10 83\n1 3\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n1 4\n2 2\n2 3\n2 3\n2 3\n2 3\n2 3\n2 3\n1 4\n1 5\n1 7\n2 2\n2 2\n1 5\n2 2\n1 3\n2 1\n2 6\n1 5\n2 6\n2 9\n1 2\n2 5\n1 2\n2 5\n2 4\n2 4\n1 2\n1 2\n1 4\n2 6\n2 6\n2 4\n2 4\n1 2\n1 2\n2 4\n2 4\n2 3\n2 3\n1 2\n2 9\n1 2\n1 2\n1 2\n2 6\n2 6\n2 4\n2 4\n2 3\n2 5\n2 5\n2...
code_stdio
[ { "content": "There is a legend in the IT City college. A student that failed to answer all questions on the game theory exam is given one more chance by his professor. The student has to play a game with the professor.\n\nThe game is played on a square field consisting of n Γ— n cells. Initially all cells are e...
[{"input": "1250846005844530517\n", "output": "1\n"}, {"input": "1000001000000000000\n", "output": "2\n"}, {"input": "2039244416399039339\n", "output": "1\n"}, {"input": "1000001000000001000\n", "output": "2\n"}, {"input": "1172500685464575937\n", "output": "1\n"}, {"input": "1639416648470331605\n", "output": "1\n"}, {...
code_stdio