messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
1 value
[ { "content": "The Little Elephant loves sortings.\n\nHe has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 fo...
[{"input": "47\n703599938 780784195 912005704 957182560 961181825 964876912 996677776 997012583 999004240 999888999 999980718 999997556 999997940 999999989 999999991 999999991 999999999 999999999 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100...
code_stdio
[ { "content": "In one little known, but very beautiful country called Waterland, lives a lovely shark Valerie. Like all the sharks, she has several rows of teeth, and feeds on crucians. One of Valerie's distinguishing features is that while eating one crucian she uses only one row of her teeth, the rest of the t...
[{"input": "54 22 1009\n15 7\n17 7\n11 9\n6 11\n12 9\n13 8\n13 12\n22 11\n20 9\n20 7\n16 11\n19 12\n3 12\n15 9\n1 12\n2 10\n16 10\n16 10\n14 10\n15 11\n11 9\n14 8\n10 10\n16 12\n1 8\n3 8\n21 11\n18 12\n2 6\n9 11\n11 7\n15 9\n20 11\n6 8\n8 8\n19 11\n15 7\n9 9\n22 3\n12 9\n17 9\n17 11\n12 7\n15 9\n5 11\n11 11\n18 8\n7 10...
code_stdio
[ { "content": "For a given polygon g, computes the area of the polygon.\n\ng is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 ≤ i ≤ n-1) are sides of g. The line segment connecting pn and p1 is also a side of the polygon.\n\nNote that the polygon is not necessar...
[{"input": "4\n-1 -2\n-1 0\n-1 14\n-5 2", "output": "32.0\n"}, {"input": "4\n-1 -2\n-1 0\n-1 17\n-5 2", "output": "38.0\n"}, {"input": "4\n0 -1\n10 -3\n71 0\n0 11", "output": "502.0\n"}, {"input": "4\n0 -4\n-1 0\n-1 14\n-6 3", "output": "43.5\n"}, {"input": "4\n0 -4\n-1 0\n-1 14\n-5 3", "output": "34.5\n"}, {"input": "...
code_stdio
[ { "content": "Let N be a positive integer.\nThere is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}).\nSnuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements.\nHere, the score of a' is defined as follows: (...
[{"input": "3\n23 1 2 -2 1 12 -2 -1 3", "output": "37\n"}, {"input": "3\n8 2 2 13 4 6 4 -1 15", "output": "16\n"}, {"input": "3\n7 1 2 18 11 1 2 2 11", "output": "31\n"}, {"input": "3\n13 2 2 13 4 6 4 0 11", "output": "20\n"}, {"input": "3\n7 1 2 18 11 1 2 0 11", "output": "33\n"}, {"input": "3\n7 4 2 26 14 1 1 1 13", ...
code_stdio
[ { "content": "Pashmak's homework is a problem about graphs. Although he always tries to do his homework completely, he can't solve this problem. As you know, he's really weak at graph theory; so try to help him in solving the problem.\n\nYou are given a weighted directed graph with n vertices and m edges. You n...
[{"input": "10 12\n1 2 2\n2 1 2\n1 3 1\n3 1 1\n1 4 1\n4 1 1\n2 3 1\n3 2 1\n2 4 1\n4 2 1\n3 4 2\n4 3 2\n", "output": "2\n"}, {"input": "4 12\n1 2 2\n2 1 2\n1 3 1\n3 1 1\n1 4 1\n4 1 1\n2 3 1\n3 2 1\n2 4 1\n4 2 1\n3 4 2\n4 3 2\n", "output": "2\n"}, {"input": "4 12\n1 2 2\n2 1 2\n1 3 1\n3 1 1\n1 4 1\n4 1 1\n2 3 1\n3 2 1\n2...
code_stdio
[ { "content": "John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly k cycles of length 3. \n\nA cycle of length 3 is an unordered group of three distinct graph vertices a, b and c, such that each pair of them is connected by a graph ...
[{"input": "105906\n", "output": "90\n011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n101111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n110111111111111111111111111111111111111111111111111111111111111111111111111111111111111100\n111011...
code_stdio
[ { "content": "A decimal representation of an integer can be transformed to another integer by rearranging the order of digits. Let us make a sequence using this fact.\n\nA non-negative integer a0 and the number of digits L are given first. Applying the following rules, we obtain ai+1 from ai.\n\n1. Express the ...
[{"input": "2012 8\n83268 3\n1112 9\n0 1\n20 2\n0 0", "output": "13 86526432 3\n5 74943 4\n5 954197541 14\n0 0 1\n2 63 5\n"}, {"input": "245 9\n83268 23\n821 3\n0 0\n99 1\n0 -1", "output": "3 863098632 14\n12 98765433331976666543211 5\n3 495 1\n"}, {"input": "2012 8\n83268 3\n1112 9\n0 1\n17 2\n0 0", "output": "13 8652...
code_stdio
[ { "content": "A matrix of size $n \\times m$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $(a_1, a_2, \\dots , a_k)$ is a palindrome, if for any integer $i$ ($1 \\le i \\le k$) the equality $a_i = a_{k - i + 1}$ holds.\n\nSasha owns a matrix $a$ of size $n \\time...
[{"input": "9\n1 1\n132703760\n1 1\n33227322\n1 1\n943066084\n1 1\n729139464\n1 1\n450488051\n1 1\n206794512\n1 1\n372520051\n1 1\n552003271\n1 1\n319080560\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n"}, {"input": "9\n1 1\n132703760\n1 1\n33227322\n1 1\n943066084\n1 1\n729139464\n1 1\n450488051\n1 1\n206794512\n1 1\n372...
code_stdio
[ { "content": "We have 3N colored balls with IDs from 1 to 3N. A string S of length 3N represents the colors of the balls. The color of Ball i is red if S_i is `R`, green if S_i is `G`, and blue if S_i is `B`. There are N red balls, N green balls, and N blue balls.\n\nTakahashi will distribute these 3N balls to ...
[{"input": "5\nRRRGRBBBBGBGGRG", "output": "12960"}, {"input": "5\nBBRBRRGGRGRGGBB", "output": "11520"}, {"input": "5\nBBBRBGGRBRRGRGG", "output": "25920"}, {"input": "5\nBRRRRGBBGGGBGRB", "output": "1440"}, {"input": "5\nBRRGRBBBBGRGGRG", "output": "1920"}, {"input": "5\nGGBBRBGGBRRGRRB", "output": "2880"}, {"input": ...
code_stdio
[ { "content": "There are N robots numbered 1 to N placed on a number line. Robot i is placed at coordinate X_i. When activated, it will travel the distance of D_i in the positive direction, and then it will be removed from the number line. All the robots move at the same speed, and their sizes are ignorable.\nTa...
[{"input": "20\n-8 1\n26 4\n0 5\n9 1\n19 4\n22 20\n28 27\n11 8\n-3 20\n-25 17\n10 4\n-18 27\n24 28\n-11 19\n2 27\n-2 18\n-1 12\n-24 29\n31 29\n29 7\n", "output": "110\n"}, {"input": "20\n-8 2\n26 0\n0 5\n15 1\n10 4\n22 10\n28 27\n11 8\n-3 61\n-25 17\n13 4\n-18 27\n24 28\n-11 19\n2 27\n-2 18\n-1 12\n-24 29\n31 68\n29 7"...
code_stdio
[ { "content": "Revised\n\nThe current era, Heisei, will end on April 30, 2019, and a new era will begin the next day. The day after the last day of Heisei will be May 1, the first year of the new era.\n\nIn the system developed by the ACM-ICPC OB / OG Association (Japanese Alumni Group; JAG), the date uses the J...
[{"input": "HEISEI 1 0 0\nHEISEI 31 4 2\nIETEIH 31 5 3\nIFISEH 142 12 42\nHEISEI 15 8 30\nIEJSEH 103 2 42\nHEISEI 3 3 14\nHEISEI 28 2 23\n#", "output": "HEISEI 1 0 0\nHEISEI 31 4 2\n? 1 5 3\n? 112 12 42\nHEISEI 15 8 30\n? 73 2 42\nHEISEI 3 3 14\nHEISEI 28 2 23\n"}, {"input": "HEISEI 1 0 0\nHEISEI 31 4 2\nIETEIH 31 5 2\...
code_stdio
[ { "content": "HDD hard drives group data by sectors. All files are split to fragments and each of them are written in some sector of hard drive. Note the fragments can be written in sectors in arbitrary order.\n\nOne of the problems of HDD hard drives is the following: the magnetic head should move from one sec...
[{"input": "100\n11 9 35 34 51 74 16 67 26 21 14 80 84 79 7 61 28 3 53 43 42 5 56 36 69 30 22 88 1 27 65 91 46 31 59 50 17 96 25 18 64 55 78 2 63 24 95 48 93 13 38 76 89 94 15 90 45 81 52 87 83 73 44 49 23 82 85 75 86 33 47 19 58 97 37 20 40 10 92 4 6 68 77 54 71 12 62 60 100 39 41 99 72 29 57 8 70 32 66 98\n", "output...
code_stdio
[ { "content": "Polycarp wants to buy exactly $n$ shovels. The shop sells packages with shovels. The store has $k$ types of packages: the package of the $i$-th type consists of exactly $i$ shovels ($1 \\le i \\le k$). The store has an infinite number of packages of each type.\n\nPolycarp wants to choose one type ...
[{"input": "10\n208790602 104395300\n208790602 104395300\n208790602 104395300\n208790602 104395300\n208790602 104395300\n208790602 104395300\n208790602 104395300\n208790602 104395300\n208790602 104395300\n208790602 104395300\n", "output": "104395301\n104395301\n104395301\n104395301\n104395301\n104395301\n104395301\n104...
code_stdio
[ { "content": "You are given a connected weighted undirected graph without any loops and multiple edges. \n\nLet us remind you that a graph's spanning tree is defined as an acyclic connected subgraph of the given graph that includes all of the graph's vertexes. The weight of a tree is defined as the sum of weigh...
[{"input": "25 25\n17 13 578885\n18 25 860003\n21 12 860003\n16 4 860003\n7 14 752263\n25 11 860003\n11 19 860003\n17 5 752263\n14 25 752263\n8 17 578885\n18 17 860003\n1 16 860003\n6 1 578885\n23 18 752263\n25 10 578885\n5 9 752263\n6 18 752263\n2 15 578885\n19 12 860003\n22 7 578885\n14 5 860003\n15 16 752263\n20 16 ...
code_stdio
[ { "content": "Sereja has two sequences a and b and number p. Sequence a consists of n integers a_1, a_2, ..., a_{n}. Similarly, sequence b consists of m integers b_1, b_2, ..., b_{m}. As usual, Sereja studies the sequences he has. Today he wants to find the number of positions q (q + (m - 1)·p ≤ n; q ≥ 1), such...
[{"input": "82 50 1\n4 2 2 4 4 3 2 2 3 3 4 3 4 1 4 1 4 3 5 3 4 2 4 4 5 2 5 4 2 4 2 5 3 2 3 4 2 5 4 3 3 4 3 4 1 1 5 2 4 1 3 3 2 4 1 2 2 5 4 4 5 3 3 1 2 3 4 5 3 1 2 3 3 5 5 2 4 1 4 2 3 1\n4 3 3 3 4 1 4 4 5 5 5 2 5 4 1 2 2 1 3 3 3 3 2 5 3 2 4 3 2 2 4 4 4 3 4 2 1 2 3 2 1 1 5 2 3 5 4 5 3 4\n", "output": "2\n24 28\n"}, {"inp...
code_stdio
[ { "content": "This is an easier version of the problem. In this version $n \\le 1000$\n\nThe outskirts of the capital are being actively built up in Berland. The company \"Kernel Panic\" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway...
[{"input": "100\n82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 22 49 41 36 41 79 16 87 87 69 3 76 80 60 100 49 70 59 72 8 38 71 45 97 71 14 76 54 81 4 59 46 39 29 92 3 49 22 53 99 59 52 74 31 92 43 42 23 44 9 82 47 7 40 12 9 3 55 37 85 46 22 84 52 98 41 21 77 63 17 62 91\n", "output...
code_stdio
[ { "content": "Raccoon is fighting with a monster.\nThe health of the monster is H.\nRaccoon can use N kinds of special moves. Using the i-th move decreases the monster's health by A_i.\nThere is no other way to decrease the monster's health.\nRaccoon wins when the monster's health becomes 0 or below.\nIf Raccoo...
[{"input": "210 5\n31 41 59 26 53\n", "output": "Yes\n"}, {"input": "211 5\n31 41 59 26 53\n", "output": "No\n"}, {"input": "210 3\n31 41 59 26 53", "output": "Yes\n"}, {"input": "210 3\n31 55 59 26 53", "output": "Yes\n"}, {"input": "211 5\n31 33 59 26 53", "output": "No\n"}, {"input": "211 5\n31 33 59 26 24", "output...
code_stdio
[ { "content": "For some time the program of rounding numbers that had been developed by the Codeforces participants during one of the previous rounds, helped the citizens of Far Far Away to convert numbers into a more easily readable format. However, as time went by, the economy of the Far Far Away developed and...
[{"input": "2567340036354357844391998756110821468858185018763415770617907336824217629234299240638243305079104961\n", "output": "$2,567,340,036,354,357,844,391,998,756,110,821,468,858,185,018,763,415,770,617,907,336,824,217,629,234,299,240,638,243,305,079,104,961.00\n"}, {"input": "16094449032068386105581779066195819551...
code_stdio
[ { "content": "You are given a string $s$ of length $n$ consisting only of the characters 0 and 1.\n\nYou perform the following operation until the string becomes empty: choose some consecutive substring of equal characters, erase it from the string and glue the remaining two parts together (any of them can be e...
[{"input": "3\n3 2 -1\n010\n5 -2 5\n01001\n6 -1 -12\n110111\n", "output": "4\n15\n-30\n"}, {"input": "3\n3 3 -1\n010\n5 -2 5\n01001\n6 -1 -12\n110111\n", "output": "7\n15\n-30\n"}, {"input": "3\n3 3 -2\n011\n5 -2 5\n01001\n6 -1 -12\n110111\n", "output": "5\n15\n-30\n"}, {"input": "3\n3 3 -1\n010\n5 -2 5\n01001\n6 -2 -1...
code_stdio
[ { "content": "You are given an integer m as a product of integers a_1, a_2, ... a_{n} $(m = \\prod_{i = 1}^{n} a_{i})$. Your task is to find the number of distinct decompositions of number m into the product of n ordered positive integers.\n\nDecomposition into n products, given in the input, must also be consi...
[{"input": "50\n675 25000 2025 83 450 31250 3750 225 1350 250 72 187500 12000 281250 187500 30000 45000 90000 90 1200 9000 56250 5760 270000 3125 3796875 2250 101250 40 2500 175781250 1250000 45000 2250 3000 31250 46875 135000 421875000 36000 360 140625000 13500 1406250 1125 250 75000 62500 150 6\n", "output": "6873067...
code_stdio
[ { "content": "Ted has a pineapple. This pineapple is able to bark like a bulldog! At time t (in seconds) it barks for the first time. Then every s seconds after it, it barks twice with 1 second interval. Thus it barks at times t, t + s, t + s + 1, t + 2s, t + 2s + 1, etc.\n\n [Image] \n\nBarney woke up in the m...
[{"input": "749399100 103031711 761562532\n", "output": "NO\n"}, {"input": "749399100 103031711 761562532\n", "output": "NO\n"}, {"input": "178769979 103031711 761562532\n", "output": "NO\n"}, {"input": "4363010 696782227 701145238\n", "output": "YES\n"}, {"input": "8897216 734348516 743245732\n", "output": "YES\n"}, {...
code_stdio
[ { "content": "Consider some square matrix A with side n consisting of zeros and ones. There are n rows numbered from 1 to n from top to bottom and n columns numbered from 1 to n from left to right in this matrix. We'll denote the element of the matrix which is located at the intersection of the i-row and the j-...
[{"input": "100\n", "output": "15\n"}, {"input": "89\n", "output": "15\n"}, {"input": "91\n", "output": "15\n"}, {"input": "76\n", "output": "13\n"}, {"input": "80\n", "output": "13\n"}, {"input": "96\n", "output": "15\n"}, {"input": "72\n", "output": "13\n"}, {"input": "79\n", "output": "13\n"}, {"input": "74\n", "out...
code_stdio
[ { "content": "You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges.\nThe i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i.\nHere, a self-loop is an edge where a_i = b_i (1≤i≤M), and double edges are two edge...
[{"input": "7 1\n1 -1 0\n-1 4 1\n-1 0 4", "output": "0\n"}, {"input": "7 1\n1 -1 0\n-1 4 2\n-1 0 4", "output": "0\n"}, {"input": "7 1\n1 -2 0\n-1 4 2\n-1 0 4", "output": "0\n"}, {"input": "14 -1\n2 0 1\n0 3 1\n0 0 4", "output": "0\n"}, {"input": "7 1\n1 -1 0\n-1 8 1\n0 0 4", "output": "0\n"}, {"input": "7 1\n1 -1 0\n-1...
code_stdio
[ { "content": "Given are N integers A_1,\\ldots,A_N.\nWe will choose exactly K of these elements. Find the maximum possible product of the chosen elements.\nThen, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\n-----Constraints-----\n - 1 \\leq K \\leq N \\leq 2\\...
[{"input": "10 10\n1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1\n", "output": "999983200\n"}, {"input": "16 1\n1000000001 100000100 10000100 1000001 100000 10001 1000 000 18 1", "output": "1000000001\n"}, {"input": "10 10\n1000000000 100000000 10000000 1100010 100000 10000 1000 100 10 1", "output": ...
code_stdio
[ { "content": "A boy PCK is playing with N electric metronomes. The i-th metronome is set to tick every t_i seconds. He started all of them simultaneously.\n\nHe noticed that, even though each metronome has its own ticking interval, all of them tick simultaneously from time to time in certain intervals. To explo...
[{"input": "3\n16\n6\n33", "output": "22\n"}, {"input": "3\n2\n0\n11", "output": "10\n"}, {"input": "2\n3\n206", "output": "100\n"}, {"input": "2\n3\n409", "output": "406\n"}, {"input": "3\n8\n5\n23", "output": "33\n"}, {"input": "2\n2\n409", "output": "407\n"}, {"input": "2\n4\n394", "output": "193\n"}, {"input": "2\n...
code_stdio
[ { "content": "Instructors of Some Informatics School make students go to bed.\n\nThe house contains n rooms, in each room exactly b students were supposed to sleep. However, at the time of curfew it happened that many students are not located in their assigned rooms. The rooms are arranged in a row and numbered...
[{"input": "100 3 30\n20 10 8 3 97 20 40 4 58 24 105 56 26 21 66 1 126 4 21 46 8 2 9 21 0 13 24 53 58 23 3 107 1 22 189 3 31 4 31 0 3 0 9 43 19 74 92 7 71 22 46 26 31 49 18 3 10 9 9 110 30 2 40 21 33 4 11 14 47 4 1 37 3 19 18 63 10 53 19 35 11 57 8 3 11 27 23 5 45 15 127 27 23 48 3 8 20 33 5 28\n", "output": "0\n"}, {"...
code_stdio
[ { "content": "Tax Rate Changed\n\nVAT (value-added tax) is a tax imposed at a certain rate proportional to the sale price.\n\nOur store uses the following rules to calculate the after-tax prices.\n\n* When the VAT rate is x%, for an item with the before-tax price of p yen, its after-tax price of the item is p (...
[{"input": "5 8 105\n8 5 105\n1 2 24\n99 98 24\n12 13 26\n1 22 23\n1 19 201\n13 16 112\n2 24 50\n1 82 61\n1 84 125\n1 99 999\n99 1 3106\n98 99 999\n1 99 11\n99 2 12\n0 0 0", "output": "109\n103\n24\n24\n26\n27\n237\n116\n62\n111\n230\n1972\n1576\n1004\n20\n7\n"}, {"input": "5 8 105\n8 5 105\n1 2 24\n99 98 24\n12 13 26\...
code_stdio
[ { "content": "During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.\n\nIt's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state u...
[{"input": "2 6 3 3 5 5 2 6 1 1 12 4 4 4 2 4 6 5 3 1 2 5 3 1\n", "output": "NO\n"}, {"input": "5 2 6 1 5 3 5 3 1 1 3 6 6 2 4 2 5 4 4 2 1 3 4 10\n", "output": "NO\n"}, {"input": "2 6 3 3 5 5 2 6 2 1 12 4 4 4 2 4 6 5 3 1 2 5 3 1\n", "output": "NO\n"}, {"input": "1 3 5 6 3 4 4 3 5 2 2 2 3 1 5 6 3 4 6 5 1 2 1 10\n", "outpu...
code_stdio
[ { "content": "Om Nom really likes candies and doesn't like spiders as they frequently steal candies. One day Om Nom fancied a walk in a park. Unfortunately, the park has some spiders and Om Nom doesn't want to see them at all. [Image] \n\nThe park can be represented as a rectangular n × m field. The park has k ...
[{"input": "2 100 59\n....................................................................................................\n.DR.D..DLLR.LDRR..L.LDRRRDLD.LDRR.LLR.R...DRLD.RRLL.L.D..R.LD.DL....LR.LR.DRLD.....L.D..RD...D.LL.R.\n", "output": "0 0 0 1 0 0 0 1 1 0 0 2 0 0 0 1 1 1 0 1 0 0 0 1 1 2 0 0 1 0 0 0 1 2 1 0 0 1 0 1 ...
code_stdio
[ { "content": "problem\n\nGiven the sequence $ A $ of length $ N $. Find the maximum value of $ \\ sum B_i $, where $ B $ is one of the longest increasing subsequences of the sequence $ A $.\n\nThe longest increasing subsequence of the sequence $ A $ is the longest subsequence that satisfies $ A_i <A_j $ with al...
[{"input": "4\n14 15 0 10", "output": "29\n"}, {"input": "4\n17 19 0 20", "output": "56\n"}, {"input": "4\n12 23 0 10", "output": "35\n"}, {"input": "4\n14 8 0 10", "output": "18\n"}, {"input": "4\n7 14 0 14", "output": "21\n"}, {"input": "4\n7 15 0 20", "output": "42\n"}, {"input": "4\n5 15 0 20", "output": "40\n"}, {...
code_stdio
[ { "content": "We have a set S of N points in a two-dimensional plane. The coordinates of the i-th point are (x_i, y_i). The N points have distinct x-coordinates and distinct y-coordinates.\nFor a non-empty subset T of S, let f(T) be the number of points contained in the smallest rectangle, whose sides are paral...
[{"input": "10\n19 -11\n-3 -12\n5 3\n3 -15\n8 -14\n-9 -20\n10 -9\n0 2\n-7 17\n6 -6\n", "output": "7222\n"}, {"input": "10\n19 -11\n-3 -12\n5 3\n3 -15\n13 -14\n-9 -20\n10 -9\n0 2\n-7 17\n6 -6", "output": "7246"}, {"input": "10\n19 -11\n-3 -12\n5 3\n3 -15\n8 -19\n-9 -20\n10 -14\n0 2\n-7 17\n6 -6", "output": "7233"}, {"in...
code_stdio
[ { "content": "A bitstring is a string consisting only of the characters 0 and 1. A bitstring is called k-balanced if every substring of size k of this bitstring has an equal amount of 0 and 1 characters (k/2 of each).\n\nYou are given an integer k and a string s which is composed only of characters 0, 1, and ?....
[{"input": "9\n6 4\n100110\n3 2\n1?1\n3 2\n1?0\n4 4\n????\n7 4\n1?0??1?\n10 10\n11??11??11\n4 4\n1??1\n4 4\n?0?0\n6 2\n????00\n", "output": "YES\nYES\nNO\nYES\nYES\nNO\nYES\nYES\nNO\n"}, {"input": "9\n6 4\n100110\n3 2\n1?1\n3 2\n0?1\n4 4\n????\n7 4\n1?0??1?\n10 10\n11???11?11\n4 2\n1??1\n4 4\n?0?0\n6 2\n????10\n", "out...
code_stdio
[ { "content": "Vanya and his friends are walking along the fence of height h and they do not want the guard to notice them. In order to achieve this the height of each of the friends should not exceed h. If the height of some person is greater than h he can bend down and then he surely won't be noticed by the gu...
[{"input": "100 342\n478 143 359 336 162 333 385 515 117 496 310 538 469 539 258 676 466 677 1 296 150 560 26 213 627 221 255 126 617 174 279 178 24 435 70 145 619 46 669 566 300 67 576 251 58 176 441 564 569 194 24 669 73 262 457 259 619 78 400 579 222 626 269 47 80 315 160 194 455 186 315 424 197 246 683 220 68 682 8...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian. \nThis is a very easy warm-up problem.\nYou are given a string. Your task is to determine whether number of occurrences of some character in the string is equal to the sum of the numbers of occurrences of other characters in the string. \...
[{"input": "4\nacab\nzzqzqq\ncba\nkklkwwww", "output": "YES\nYES\nNO\nYES\n"}, {"input": "4\nacab\nzzqzqq\ncba\nkkmkwwww", "output": "YES\nYES\nNO\nYES\n"}, {"input": "4\nacab\nzzqzqq\nbca\nkkmkwwww", "output": "YES\nYES\nNO\nYES\n"}, {"input": "4\nacac\nzzqzqq\nabc\nkklkwwww", "output": "YES\nYES\nNO\nYES\n"}, {"input...
code_stdio
[ { "content": "The little girl loves the problems on array queries very much.\n\nOne day she came across a rather well-known problem: you've got an array of n elements (the elements of the array are indexed starting from 1); also, there are q queries, each one is defined by a pair of integers l_{i}, r_{i} (1 ≤ l...
[{"input": "31 48\n45 19 16 42 38 18 50 7 28 40 39 25 45 14 36 18 27 30 16 4 22 6 1 23 16 47 14 35 27 47 2\n6 16\n11 28\n4 30\n25 26\n11 30\n5 9\n4 17\n15 17\n10 25\n15 26\n1 3\n9 26\n8 29\n16 30\n3 24\n27 30\n9 10\n22 29\n2 6\n15 24\n6 21\n19 21\n4 28\n1 7\n18 21\n10 22\n6 15\n14 28\n4 19\n12 13\n19 29\n5 6\n13 31\n21...
code_stdio
[ { "content": "We have a sequence of N integers: A_1, A_2, \\cdots, A_N.\nYou can perform the following operation between 0 and K times (inclusive):\n - Choose two integers i and j such that i \\neq j, each between 1 and N (inclusive). Add 1 to A_i and -1 to A_j, possibly producing a negative element.\nCompute t...
[{"input": "500 1000000000\n1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000...
code_stdio
[ { "content": "The prison of your city has n prisoners. As the prison can't accommodate all of them, the city mayor has decided to transfer c of the prisoners to a prison located in another city.\n\nFor this reason, he made the n prisoners to stand in a line, with a number written on their chests. The number is ...
[{"input": "57 3 9\n4 5 2 7 12 1 1 3 2 9 4 9 0 6 12 5 -1 6 11 1 0 0 -1 3 1 0 5 1 0 31 8 8 0 1 7 3 1 13 4 4 5 1 4 -2 1 7 1 1 1 4 5 1 24 5 1 9 6\n", "output": "0\n"}, {"input": "57 3 9\n4 5 2 7 12 1 1 0 2 9 4 9 0 6 12 5 -1 6 11 1 0 0 -1 3 1 0 5 1 0 31 8 8 0 1 7 3 1 13 4 4 5 1 4 -2 1 7 1 1 1 4 5 1 24 5 1 9 6\n", "output":...
code_stdio
[ { "content": "In \"Takahashi-ya\", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions).\nA customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the or...
[{"input": "ooo\n", "output": "1000\n"}, {"input": "oxo\n", "output": "900\n"}, {"input": "xxx\n", "output": "700\n"}, {"input": "pxo", "output": "800\n"}, {"input": "yxx", "output": "700\n"}, {"input": "opo", "output": "900\n"}, {"input": "oxp", "output": "800\n"}, {"input": "xyx", "output": "700\n"}, {"input": "opn",...
code_stdio
[ { "content": "I decided to plant vegetables in the vegetable garden. There were n seeds, so I sown n seeds one by one a day over n days. All seeds sprout and grow quickly. I can't wait for the harvest time.\n\nOne day, when I was watering the seedlings as usual, I noticed something strange. There should be n ve...
[{"input": "5\n1 2 3 11 4 5\n6\n1 3 6 9 12 15 18\n4\n5 7 9 11 12\n0", "output": "11\n1\n12\n"}, {"input": "5\n1 2 3 14 4 5\n6\n1 3 6 9 12 15 18\n4\n5 7 9 11 12\n0", "output": "14\n1\n12\n"}, {"input": "5\n1 2 3 25 4 5\n6\n1 3 6 9 12 15 18\n4\n5 7 9 11 12\n0", "output": "25\n1\n12\n"}, {"input": "5\n1 2 3 25 4 5\n6\n1 3...
code_stdio
[ { "content": "The main city magazine offers its readers an opportunity to publish their ads. The format of the ad should be like this:\n\nThere are space-separated non-empty words of lowercase and uppercase Latin letters.\n\nThere are hyphen characters '-' in some words, their positions set word wrapping points...
[{"input": "2\nWjrWBWqKIeSndDHeiVmfChQNsoUiRQHVplnIWkwBtxAJhOdTigAAzKtbNEqcgvbWHOopfCNgWHfwXyzSCfNqGMLnmlIdKQonLsmGSJlPBcYfHNJJDGlKNnOGtrWUhaTWuilHWMUlFEzbJYbeAWvgnSOOOPLxX-eJEKRsKqSnMjrPbFDprCqgbTfwAnPjFapVKiTjCcWEzhahwPRHScfcLnUixnxckQJzuHzshyBFKPwVGzHeJWniiRKynDFQdaazmTZtDGnFVTmTUZCRCpUHFmUHAVtEdweCImRztqrkQInyCsnMn...
code_stdio
[ { "content": "Dr .: Peter, do you know \"Yes, I have a number\"?\n\nPeter: I used to do it on TV the other day. You remember something by the number of characters in each word contained in a sentence. \"Yes, I have a number\", so it means \"the number 3.14\" and is a keyword for remembering pi.\n\nDr .: Peter, ...
[{"input": "Yes I have a number\nHow I wish I could calculate an unused bolor for space\nThank you\nEND OF INPUT", "output": "31416\n31415926535\n53\n"}, {"input": "Yes I have a rebmun\nHow I wish I could calculate an unused bolor for space\nThank you\nEND OF INPUT", "output": "31416\n31415926535\n53\n"}, {"input": "Ye...
code_stdio
[ { "content": "3D Printing\n\nWe are designing an installation art piece consisting of a number of cubes with 3D printing technology for submitting one to Installation art Contest with Printed Cubes (ICPC). At this time, we are trying to model a piece consisting of exactly k cubes of the same size facing the sam...
[{"input": "1 1 100\n100 100 100\n6 4 10\n100 100 100\n106 102 102\n112 110 104\n104 116 102\n100 114 104\n92 107 100\n10 1 10\n-100 101 100\n-108 102 120\n-116 103 100\n-124 100 100\n-132 99 100\n-92 98 100\n-84 100 140\n-76 103 100\n-68 146 100\n-60 101 100\n10 4 10\n100 100 100\n108 101 100\n116 102 100\n124 100 100...
code_stdio
[ { "content": "Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.\n\nConstraints\n\n* The length of the input string < 1200\n\nInput\n\nA string is given in a line.\n\nOutput\n\nPrint the converted string in a line. Note that you do not need to convert any chara...
[{"input": "f@IR, LATER, OCCASIONALLY CLOUDY.", "output": "F@ir, later, occasionally cloudy.\n"}, {"input": "f@IR, LATER, YLLANOISACCO CLOUDY.", "output": "F@ir, later, yllanoisacco cloudy.\n"}, {"input": "f@IR, LATER, OLLANOISACCY CLOUDY.", "output": "F@ir, later, ollanoisaccy cloudy.\n"}, {"input": "f@IR, LATER, OLKA...
code_stdio
[ { "content": "Vasya and Petya are playing a simple game. Vasya thought of number x between 1 and n, and Petya tries to guess the number.\n\nPetya can ask questions like: \"Is the unknown number divisible by number y?\".\n\nThe game is played by the following rules: first Petya asks all the questions that intere...
[{"input": "1000\n", "output": "193\n2 4 8 16 32 64 128 256 512 3 9 27 81 243 729 5 25 125 625 7 49 343 11 121 13 169 17 289 19 361 23 529 29 841 31 961 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 2...
code_stdio
[ { "content": "Bob loves everything sweet. His favorite chocolate bar consists of pieces, each piece may contain a nut. Bob wants to break the bar of chocolate into multiple pieces so that each part would contain exactly one nut and any break line goes between two adjacent pieces.\n\nYou are asked to calculate t...
[{"input": "100\n1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1\n", "output": "5559060566555523\n"}, {"input": "100\n1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 ...
code_stdio
[ { "content": "Example\n\nInput\n\n201\n\n\nOutput\n\n701\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": "148", "output": "648\n"}, {"input": "106", "output": "605\n"}, {"input": "145", "output": "645\n"}, {"input": "225", "output": "725\n"}, {"input": "171", "output": "671\n"}, {"input": "177", "output": "678\n"}, {"input": "116", "output": "615\n"}, {"input": "119", "output": "619\n"}, {"input": "368", "outpu...
code_stdio
[ { "content": "The brothers Hiroshi and Kenjiro came to Lake Inawashiro for fishing. The two decided to score as follows and compete with the total score of the fish they caught.\n\n* One char is a point\n* One yamame trout b points\n* Add c points for every 10 chars\n* Add d points for every 20 yamame trout\n\n...
[{"input": "0 11\n10 0\n-1 1 41 0", "output": "kenjiro\n"}, {"input": "0 11\n10 0\n-1 2 41 0", "output": "kenjiro\n"}, {"input": "0 10\n10 0\n-1 2 41 0", "output": "kenjiro\n"}, {"input": "0 10\n10 1\n-1 2 41 0", "output": "kenjiro\n"}, {"input": "2 1\n19 4\n-1 1 24 -1", "output": "kenjiro\n"}, {"input": "2 1\n19 4\n-1...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian \n\nChef is sitting in a very boring lecture, waiting for it to end. He has recently asked his friend about the time, and instead of the straightforward answer, his friend, being an absolute jerk, told him the absolute value of angle betwe...
[{"input": "2\n11\n26", "output": "00:02\n11:58\n05:32\n06:28\n"}, {"input": "2\n4\n104", "output": "05:28\n06:32\n01:52\n10:08\n"}, {"input": "2\n1\n104", "output": "04:22\n07:38\n01:52\n10:08\n"}, {"input": "2\n1\n116", "output": "04:22\n07:38\n02:32\n09:28\n"}, {"input": "2\n1\n152", "output": "04:22\n07:38\n03:44\n...
code_stdio
[ { "content": "Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.\n\n<image>\n\nFigure D-1: A sample railway network\n\n\nSuppose you are going to station D from station A. Obviously, the path with the shortest distance is A->B->D. Howev...
[{"input": "4 4 2 1 4\n1 2 2 1\n3 3 2 1\n3 1 5 1\n2 4 4 2\n3 1\n3 11\n10 5 3\n\n10\n2 0 1 1 2\n1\n\n1\n4 5 2 4 1\n4 3 10 1\n3 2 2 1\n3 4 1 2\n3 2 5 2\n2 1 10 1\n3 3\n20 30\n3 2 1\n5 10\n4 2 1\n5 5 2 1 5\n2 2 10 2\n1 3 20 2\n1 4 32 1\n3 4 10 1\n4 5 20 1\n2 2\n20\n10 1\n20\n3 1\n0 0 0 0 0", "output": "60\n-1\n40\n232\n"}...
code_stdio
[ { "content": "You are given an integer $n$. Check if $n$ has an odd divisor, greater than one (does there exist such a number $x$ ($x > 1$) that $n$ is divisible by $x$ and $x$ is odd).\n\nFor example, if $n=6$, then there is $x=3$. If $n=4$, then such a number does not exist.\n\n\n-----Input-----\n\nThe first ...
[{"input": "6\n3\n3\n4\n5\n998244353\n1368804034442\n", "output": "YES\nYES\nNO\nYES\nYES\nYES\n"}, {"input": "6\n3\n3\n4\n5\n998244353\n1099511627776\n", "output": "YES\nYES\nNO\nYES\nYES\nNO\n"}, {"input": "6\n3\n3\n4\n5\n998244353\n852815039649\n", "output": "YES\nYES\nNO\nYES\nYES\nYES\n"}, {"input": "6\n2\n6\n7\n4...
code_stdio
[ { "content": "The sequence of n - 1 consecutive composite numbers (positive integers that are not prime and not equal to 1) lying between two successive prime numbers p and p + n is called a prime gap of length n. For example, (24, 25, 26, 27, 28) between 23 and 29 is a prime gap of length 6.\n\nYour mission is...
[{"input": "10\n11\n27\n4\n492170\n0", "output": "4\n0\n6\n2\n114\n"}, {"input": "10\n9\n142\n2\n199792\n0", "output": "4\n4\n10\n0\n16\n"}, {"input": "10\n11\n27\n2\n296421\n0", "output": "4\n0\n6\n0\n60\n"}, {"input": "10\n11\n27\n2\n525306\n0", "output": "4\n0\n6\n0\n14\n"}, {"input": "10\n11\n27\n2\n245198\n0", "ou...
code_stdio
[ { "content": "Ilya is a very good-natured lion. He likes maths. Of all mathematical objects, his favourite one is matrices. Now he's faced a complicated matrix problem he needs to solve.\n\nHe's got a square 2^{n} × 2^{n}-sized matrix and 4^{n} integers. You need to arrange all these numbers in the matrix (put ...
[{"input": "16\n978618343 473608041 799158564 800910753 461479363 520477481 780529176 678879534 118274424 720632652 1126830014 582019792 225578081 537373229 944668919 758615621\n", "output": "15485512030\n"}, {"input": "16\n978618343 473608041 799158564 800910753 461479363 520477481 780529176 678879534 118274424 720632...
code_stdio
[ { "content": "You have an n × m rectangle table, its cells are not initially painted. Your task is to paint all cells of the table. The resulting picture should be a tiling of the table with squares. More formally: each cell must be painted some color (the colors are marked by uppercase Latin letters); we wil...
[{"input": "100 100\n", "output": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...
code_stdio
[ { "content": "Mike wants to prepare for IMO but he doesn't know geometry, so his teacher gave him an interesting geometry problem. Let's define f([l, r]) = r - l + 1 to be the number of integer points in the segment [l, r] with l ≤ r (say that $f(\\varnothing) = 0$). You are given two integers n and k and n clo...
[{"input": "9 6\n-44 -29\n-11 85\n11 84\n-63 1\n75 89\n-37 61\n14 73\n78 88\n-22 -18\n", "output": " 0\n"}, {"input": "2 2\n-93 -22\n12 72\n", "output": " 0\n"}, {"input": "2 2\n26 99\n-56 40\n", ...
code_stdio
[ { "content": "Snuke has N sticks.\nThe length of the i-th stick is l_i.\nSnuke is making a snake toy by joining K of the sticks together.\nThe length of the toy is represented by the sum of the individual sticks that compose it.\nFind the maximum possible length of the toy.\n\n-----Constraints-----\n - 1 \\leq ...
[{"input": "15 14\n50 26 27 21 41 7 42 35 7 5 5 36 39 1 45\n", "output": "386\n"}, {"input": "15 14\n49 26 27 21 41 12 42 35 7 5 5 36 39 1 45", "output": "390\n"}, {"input": "15 14\n49 26 27 21 33 14 42 35 7 5 5 31 39 1 45", "output": "379\n"}, {"input": "15 14\n42 26 27 21 12 14 42 35 7 5 5 31 39 1 45", "output": "351...
code_stdio
[ { "content": "You are asked to watch your nephew who likes to play with toy blocks in a strange way.\n\nHe has $n$ boxes and the $i$-th box has $a_i$ blocks. His game consists of two steps:\n\nhe chooses an arbitrary box $i$;\n\nhe tries to move all blocks from the $i$-th box to other boxes.\n\nIf he can make t...
[{"input": "20\n2\n1000000000 999999999\n2\n1000000000 999999999\n2\n1000000000 999999999\n2\n1000000000 999999999\n2\n1000000000 999999999\n2\n1000000000 999999999\n2\n1000000000 999999999\n2\n1000000000 999999999\n2\n1000000000 999999999\n2\n1000000000 999999999\n2\n1000000000 999999999\n2\n1000000000 999999999\n2\n1...
code_stdio
[ { "content": "You work as a system administrator in a dormitory, which has $n$ rooms one after another along a straight hallway. Rooms are numbered from $1$ to $n$.\n\nYou have to connect all $n$ rooms to the Internet.\n\nYou can connect each room to the Internet directly, the cost of such connection for the $i...
[{"input": "200 10\n10000010101010110011110010100010010000001100101111011001010010001101001011111110011010111101000101011110101001001101101011010011100000100101000010110111000110000010101110110000110000100000101110111100\n", "output": "989\n"}, {"input": "200 10\n10000010101010110011110010100010010000001100101111011001...
code_stdio
[ { "content": "Takahashi is standing on a multiplication table with infinitely many rows and columns.\nThe square (i,j) contains the integer i \\times j. Initially, Takahashi is standing at (1,1).\nIn one move, he can move from (i,j) to either (i+1,j) or (i,j+1).\nGiven an integer N, find the minimum number of m...
[{"input": "613921846801\n", "output": "613921846800\n"}, {"input": "550310490859\n", "output": "550310490858\n"}, {"input": "571704556531\n", "output": "571704556530\n"}, {"input": "472249589291\n", "output": "472249589290\n"}, {"input": "310812811094\n", "output": "155406405547\n"}, {"input": "10000000019\n", "output...
code_stdio
[ { "content": "Takahashi wants to be a member of some web service.\nHe tried to register himself with the ID S, which turned out to be already used by another user.\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\nHe is now trying to register with the I...
[{"input": "aaaaaaaaaa\naaaaaaaaaaa\n", "output": "Yes\n"}, {"input": "vgxgpuamkx\nvgxgpuamkxk\n", "output": "Yes\n"}, {"input": "chokudai\nchokudaiz\n", "output": "Yes\n"}, {"input": "vfjaqmop\nodotkrjzr\n", "output": "No\n"}, {"input": "choktdai\nchokudaiz", "output": "No\n"}, {"input": "choktdai\nbhokudaiz", "output...
code_stdio
[ { "content": "Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.\n\nNote that the order of the points inside the gro...
[{"input": "100 100\n-98 -97 -96 -93 -92 -91 -90 -87 -86 -84 -81 -80 -79 -78 -76 -75 -73 -71 -69 -67 -65 -64 -63 -62 -61 -54 -51 -50 -49 -48 -46 -45 -44 -37 -36 -33 -30 -28 -27 -16 -15 -13 -12 -10 -9 -7 -6 -5 -4 2 3 5 8 9 10 11 13 14 15 16 17 19 22 24 25 26 27 28 30 31 32 36 40 43 45 46 47 50 51 52 53 58 60 63 69 70 73...
code_stdio
[ { "content": "Bear Limak prepares problems for a programming competition. Of course, it would be unprofessional to mention the sponsor name in the statement. Limak takes it seriously and he is going to change some words. To make it still possible to read, he will try to modify each word as little as possible.\n...
[{"input": "75\nVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK\n", "output": "1406\n"}, {"input": "75\nVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK\n", "output": "1406\n"}, {"input": "75\nVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVKVVVVVVVKKKKKKKKKKKKKKKKKKKKKKKKKKVKKKKKKK...
code_stdio
[ { "content": "Today Johnny wants to increase his contribution. His plan assumes writing $n$ blogs. One blog covers one topic, but one topic can be covered by many blogs. Moreover, some blogs have references to each other. Each pair of blogs that are connected by a reference has to cover different topics because...
[{"input": "25 50\n25 2\n6 17\n11 4\n3 18\n11 20\n6 7\n24 15\n1 8\n13 5\n12 25\n15 18\n14 21\n13 6\n5 10\n3 14\n1 2\n23 13\n12 20\n6 4\n8 9\n3 5\n10 7\n20 2\n20 16\n7 4\n8 25\n15 6\n24 14\n2 23\n2 13\n11 3\n16 21\n18 10\n22 1\n5 24\n6 18\n22 23\n4 13\n8 18\n5 20\n22 17\n20 7\n19 15\n10 12\n2 3\n1 20\n2 24\n7 14\n16 17\...
code_stdio
[ { "content": "You have just been put in charge of developing a new shredder for the Shredding Company. Although a ``normal'' shredder would just shred sheets of paper into little pieces so that the contents would become unreadable, this new shredder needs to have the following unusual basic characteristics.\n\n...
[{"input": "50 12346\n712 144139\n927438 667387\n23 3312\n9 3142\n25 1299\n101 63556\n103 862150\n6 1104\n0 0", "output": "43 1 2 34 6\n481 1 441 39\n667387 667387\n18 3 3 12\nerror\n21 1 2 9 9\n97 6 35 56\n103 86 2 15 0\nrejected\n"}, {"input": "50 12346\n712 144139\n1585609 667387\n23 3312\n9 3142\n25 1299\n111 63556...
code_stdio
[ { "content": "An SNS has N users - User 1, User 2, \\cdots, User N.\nBetween these N users, there are some relationships - M friendships and K blockships.\nFor each i = 1, 2, \\cdots, M, there is a bidirectional friendship between User A_i and User B_i.\nFor each i = 1, 2, \\cdots, K, there is a bidirectional b...
[{"input": "10 9 3\n10 1\n6 7\n8 2\n2 5\n8 4\n7 3\n10 9\n6 4\n5 8\n2 6\n7 5\n3 1\n", "output": "1 3 5 4 3 3 3 3 1 0\n"}, {"input": "10 9 3\n10 1\n10 6\n8 2\n2 5\n8 4\n7 3\n10 9\n6 4\n5 8\n2 6\n7 5\n3 1", "output": "6 4 0 5 5 4 0 4 6 4\n"}, {"input": "10 9 3\n10 1\n10 6\n8 2\n2 5\n8 4\n7 3\n10 9\n6 4\n5 8\n2 7\n7 5\n3 1...
code_stdio
[ { "content": "Innopolis University scientists continue to investigate the periodic table. There are n·m known elements and they form a periodic table: a rectangle with n rows and m columns. Each element can be described by its coordinates (r, c) (1 ≤ r ≤ n, 1 ≤ c ≤ m) in the table.\n\nRecently scientists discov...
[{"input": "20 20 80\n5 3\n13 13\n8 5\n2 9\n12 16\n1 11\n15 11\n3 20\n10 7\n5 4\n11 2\n5 20\n14 8\n5 1\n8 13\n11 5\n19 2\n15 12\n12 7\n16 5\n17 3\n12 2\n17 16\n12 3\n12 6\n18 20\n2 20\n9 1\n5 10\n9 18\n17 1\n17 10\n20 1\n12 12\n19 14\n7 8\n2 19\n6 14\n5 6\n15 2\n18 14\n5 7\n14 14\n17 2\n20 20\n11 6\n18 15\n10 5\n20 3\n...
code_stdio
[ { "content": "Vasya owns a cornfield which can be defined with two integers $n$ and $d$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $(0, d), (d, 0), (n, n - d)$ and $(n - d, n)$.\n\n [Image] An example of a cornfield with $n = 7$ and $d = 2$. \n\nVasya also knows th...
[{"input": "9 3\n100\n0 0\n0 1\n0 2\n0 3\n0 4\n0 5\n0 6\n0 7\n0 8\n0 9\n1 0\n1 1\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n2 0\n2 1\n2 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n3 0\n3 1\n3 2\n3 3\n3 4\n3 5\n3 6\n3 7\n3 8\n3 9\n4 0\n4 1\n4 2\n4 3\n4 4\n4 5\n4 6\n4 7\n4 8\n4 9\n5 0\n5 1\n5 2\n5 3\n5 4\n5 5\n5 6\n5 7\n5 8\n5 9...
code_stdio
[ { "content": "Pooja would like to withdraw X US from an ATM. The cash machine will only accept the transaction if X is a multiple of 5, and Pooja's account balance has enough cash to perform the withdrawal transaction (including bank charges). For each successful withdrawal the bank charges 0.50 US.\n\nCalcula...
[{"input": "1013 120.00", "output": "120.00\n"}, {"input": "1676 120.00", "output": "120.00\n"}, {"input": "1038 120.00", "output": "120.00\n"}, {"input": "1022 120.00", "output": "120.00\n"}, {"input": "1471 120.00", "output": "120.00\n"}, {"input": "1808 120.00", "output": "120.00\n"}, {"input": "114 120.00", "output...
code_stdio
[ { "content": "Since Sonya has just learned the basics of matrices, she decided to play with them a little bit.\n\nSonya imagined a new type of matrices that she called rhombic matrices. These matrices have exactly one zero, while all other cells have the Manhattan distance to the cell containing the zero. The c...
[{"input": "20\n1 0 2 3 5 3 2 1 3 2 3 1 4 2 1 4 2 3 2 4\n", "output": "4 5\n2 2\n"}, {"input": "20\n1 0 2 3 5 3 2 1 3 2 3 1 4 2 1 4 2 3 2 4\n", "output": "4 5\n2 2\n"}, {"input": "18\n2 2 3 2 4 3 3 3 0 2 4 2 1 3 2 1 1 1\n", "output": "3 6\n2 3\n"}, {"input": "20\n1 0 2 3 5 10 2 2 5 4 3 2 2 2 1 3 0 3 2 4\n", "output": "...
code_stdio
[ { "content": "Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options:\n\n 1. on this d...
[{"input": "100\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "output": "100\n"}, {"input": "100\n3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0...
code_stdio
[ { "content": "Snuke prepared 6 problems for a upcoming programming contest. For each of those problems, Rng judged whether it can be used in the contest or not.\n\nYou are given a string S of length 6. If the i-th character of s is `1`, it means that the i-th problem prepared by Snuke is accepted to be used; `0...
[{"input": "001011", "output": "3\n"}, {"input": "100000", "output": "1\n"}, {"input": "011011", "output": "4\n"}, {"input": "100100", "output": "2\n"}, {"input": "111011", "output": "5\n"}, {"input": "111111", "output": "6\n"}, {"input": "101100", "output": "3\n"}, {"input": "110100", "output": "3\n"}, {"input": "0100...
code_stdio
[ { "content": "You are given <var>Q</var> tuples of integers <var>(L_i, A_i, B_i, M_i)</var>. For each tuple, answer the following question. \nThere is an arithmetic progression with L terms: s_0, s_1, s_2, ... , s_{L-1}.\nThe initial term is A, and the common difference is B. That is, s_i = A + B \\times i hold...
[{"input": "31940 139378099479290043 26943708742238 1000000000\n", "output": "997629525\n"}, {"input": "1 999999999999999999 999999999999999999 998244353\n", "output": "716070897\n"}, {"input": "345 493299812499659259 1418510335032035 998244353\n", "output": "390889114\n"}, {"input": "18 912087068546306627 316457441004...
code_stdio
[ { "content": "Allen wants to enter a fan zone that occupies a round square and has $n$ entrances.\n\nThere already is a queue of $a_i$ people in front of the $i$-th entrance. Each entrance allows one person from its queue to enter the fan zone in one minute.\n\nAllen uses the following strategy to enter the fan...
[{"input": "30\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 1000000...
code_stdio
[ { "content": "Let's define a multiplication operation between a string $a$ and a positive integer $x$: $a \\cdot x$ is the string that is a result of writing $x$ copies of $a$ one after another. For example, \"abc\" $\\cdot~2~=$ \"abcabc\", \"a\" $\\cdot~5~=$ \"aaaaa\".\n\nA string $a$ is divisible by another s...
[{"input": "13\na\na\na\na\na\na\na\na\na\na\na\na\nb\na\na\na\na\na\na\na\na\na\na\na\nb\na\n", "output": "a\na\na\na\na\na\n-1\na\na\na\na\na\n-1\n"}, {"input": "13\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\nb\na\n", "output": "a\na\na\na\na\na\na\na\na\na\na\na\n-1\n"}, {"input": "13\na...
code_stdio
[ { "content": "You are given a sequence $s$ consisting of $n$ digits from $1$ to $9$.\n\nYou have to divide it into at least two segments (segment — is a consecutive sequence of elements) (in other words, you have to place separators between some digits of the sequence) in such a way that each element belongs to...
[{"input": "21\n3\n123\n3\n123\n3\n123\n3\n123\n3\n123\n3\n213\n3\n123\n3\n123\n3\n123\n3\n321\n3\n123\n3\n321\n3\n132\n3\n322\n3\n321\n3\n341\n3\n123\n3\n421\n3\n421\n3\n421\n3\n421\n", "output": "YES\n2\n1 23\nYES\n2\n1 23\nYES\n2\n1 23\nYES\n2\n1 23\nYES\n2\n1 23\nYES\n2\n2 13\nYES\n2\n1 23\nYES\n2\n1 23\nYES\n2\n1 ...
code_stdio
[ { "content": "During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. \n\nLet's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant...
[{"input": "10 0\n5 9 1 12 4 2 2 4 12 1\n", "output": "2\n3\n4\n5\n6\n7\n8\n9\n"}, {"input": "10 0\n5 16 1 7 4 2 2 5 18 3\n", "output": "2\n3\n4\n5\n6\n7\n8\n9\n"}, {"input": "10 0\n5 16 1 7 4 2 2 4 18 3\n", "output": "2\n3\n4\n5\n6\n7\n8\n9\n"}, {"input": "10 0\n5 16 1 7 7 2 2 4 18 3\n", "output": "2\n3\n4\n5\n6\n7\n8...
code_stdio
[ { "content": "Consider a billiard table of rectangular size $n \\times m$ with four pockets. Let's introduce a coordinate system with the origin at the lower left corner (see the picture). [Image] \n\nThere is one ball at the point $(x, y)$ currently. Max comes to the table and strikes the ball. The ball start...
[{"input": "1000000000 999999999 999999998 999999999 -1 -1\n", "output": "1000000000 999999999\n"}, {"input": "1000000000 999999999 999999998 999999999 -1 -1\n", "output": "1000000000 999999999"}, {"input": "1000000000 999999999 999999998 999999999 -1 1\n", "output": "1000000000 999999999\n"}, {"input": "1000000000 999...
code_stdio
[ { "content": "Valera is a collector. Once he wanted to expand his collection with exactly one antique item.\n\nValera knows n sellers of antiques, the i-th of them auctioned k_{i} items. Currently the auction price of the j-th object of the i-th seller is s_{ij}. Valera gets on well with each of the n sellers. ...
[{"input": "3 999999\n22 1000000 1000000 1250369 623205 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000100 1506663 1001000 1010000 999999 1000000 1000000 1010000 352800 999999 1000000\n14 999999 999999 1521826 1368902 999999 1000000 999999 1556972 999999 999999 418013 999999 1000000 999999\n5 999999 100000...
code_stdio
[ { "content": "You are given a Young diagram. \n\nGiven diagram is a histogram with $n$ columns of lengths $a_1, a_2, \\ldots, a_n$ ($a_1 \\geq a_2 \\geq \\ldots \\geq a_n \\geq 1$). [Image] Young diagram for $a=[3,2,2,2,1]$. \n\nYour goal is to find the largest number of non-overlapping dominos that you can dra...
[{"input": "100\n1980 1932 1906 1898 1892 1883 1877 1858 3146 1833 1777 1710 1689 1678 1660 1653 1648 1647 1644 1639 1635 1635 1593 1571 1534 1470 1440 1435 1389 1272 1269 1268 1263 1255 1249 1237 1174 1174 1128 529 1067 981 1707 979 951 915 911 906 863 826 810 810 802 785 764 752 743 710 705 451 676 661 639 1208 616 5...
code_stdio
[ { "content": "Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers 1, 5, 10 and 50 respectively. The use of other roman digits is not allowed.\n\nNumbers in this system are written as a sequence of one or more digits. We define the value o...
[{"input": "1000000000\n", "output": "48999999753\n"}, {"input": "1000000100\n", "output": "49000004653\n"}, {"input": "1517731607\n", "output": "74368848496\n"}, {"input": "1000001100\n", "output": "49000053653\n"}, {"input": "1000001000\n", "output": "49000048753\n"}, {"input": "600000000\n", "output": "29399999753\n...
code_stdio
[ { "content": "A and B are preparing themselves for programming contests.\n\nB loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.\n\nInitially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some ...
[{"input": "10\n460626451 802090732 277246428 661369649 388684428 784303821 376287098 656422756 9301599 25720377\n277246428 388684428 661369649 460626451 656422756 802090732 9301599 784303821 376287098\n376287098 802090732 388684428 9301599 656422756 784303821 460626451 277246428\n", "output": "25720377\n661369649\n"},...
code_stdio
[ { "content": "Polycarp found a rectangular table consisting of $n$ rows and $m$ columns. He noticed that each cell of the table has its number, obtained by the following algorithm \"by columns\":\n\ncells are numbered starting from one;\n\ncells are numbered from left to right by columns, and inside each column...
[{"input": "5\n1 1 1\n2 2 3\n3 10 11\n100 100 7312\n1001000 1000010 1000000000000\n", "output": "1\n2\n14\n1174\n1000009998991\n"}, {"input": "5\n1 1 1\n2 2 2\n3 10 11\n100 100 7312\n1001000 1000010 1000000000000\n", "output": "1\n3\n14\n1174\n1000009998991\n"}, {"input": "5\n1 1 1\n2 2 2\n3 10 11\n100 100 7312\n100100...
code_stdio
[ { "content": "A tree is an undirected connected graph without cycles.\n\nYou are given a tree of n vertices. Find the number of ways to choose exactly k vertices in this tree (i. e. a k-element subset of vertices) so that all pairwise distances between the selected vertices are equal (in other words, there exis...
[{"input": "8\n\n3 2\n3 1\n1 2\n\n5 5\n4 1\n5 4\n1 3\n2 4\n\n10 2\n2 5\n3 10\n9 4\n7 1\n6 2\n9 6\n3 1\n8 7\n10 2\n\n2 2\n2 1\n\n7 4\n5 1\n1 4\n3 6\n6 4\n3 7\n2 3\n\n10 4\n8 4\n1 6\n7 1\n5 1\n10 2\n8 9\n2 3\n2 4\n6 9\n\n5 5\n1 5\n3 5\n1 2\n4 2\n\n8 3\n1 2\n5 8\n5 4\n2 7\n7 6\n8 7\n3 2\n", "output": "3\n0\n45\n1\n0\n0\n0...
code_stdio
[ { "content": "Nikolay has a lemons, b apples and c pears. He decided to cook a compote. According to the recipe the fruits should be in the ratio 1: 2: 4. It means that for each lemon in the compote should be exactly 2 apples and exactly 4 pears. You can't crumble up, break up or cut these fruits into pieces. T...
[{"input": "1000\n1000\n1000\n", "output": "1750\n"}, {"input": "1000\n1000\n1001\n", "output": "1750\n"}, {"input": "1000\n1010\n1001\n", "output": "1750\n"}, {"input": "1000\n500\n1000\n", "output": "1750\n"}, {"input": "1000\n1000\n1000\n", "output": "1750"}, {"input": "1000\n507\n1000\n", "output": "1750\n"}, {"inp...
code_stdio
[ { "content": "Ziota found a video game called \"Monster Invaders\".\n\nSimilar to every other shooting RPG game, \"Monster Invaders\" involves killing monsters and bosses with guns.\n\nFor the sake of simplicity, we only consider two different types of monsters and three different types of guns.\n\nNamely, the ...
[{"input": "100 5 5 9 3\n3 4 2 3 4 3 8 5 2 1 1 4 1 1 10 10 7 5 2 9 4 2 10 10 8 2 4 9 6 2 6 7 7 5 7 7 1 8 10 9 9 3 10 3 10 1 1 8 3 6 4 5 5 4 9 5 9 4 8 2 10 8 9 1 5 9 7 2 1 7 9 3 2 9 1 5 4 2 3 10 6 7 8 2 10 1 6 2 1 6 10 9 1 2 2 7 2 8 4 4\n", "output": "1597\n"}, {"input": "100 5 5 9 3\n3 4 2 3 4 3 8 5 2 1 1 4 1 1 10 10 7...
code_stdio
[ { "content": "You are given a bracket sequence $s$ consisting of $n$ opening '(' and closing ')' brackets.\n\nA regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters '1' and '+' between the original characters of the sequence. For exa...
[{"input": "20\n(())(()((((()())()((\n", "output": "0\n"}, {"input": "20\n(())(((((((()())()()\n", "output": "0\n"}, {"input": "20\n(()())()((((()(())((\n", "output": "0\n"}, {"input": "20\n(())((((()(((())()()\n", "output": "0\n"}, {"input": "20\n(())(()(((())())()((\n", "output": "0\n"}, {"input": "19\n)(()()()()))((...
code_stdio
[ { "content": "As you might remember from the previous round, Vova is currently playing a strategic game known as Rage of Empires.\n\nVova managed to build a large army, but forgot about the main person in the army - the commander. So he tries to hire a commander, and he wants to choose the person who will be re...
[{"input": "5\n1 1\n1 4\n3 6 3\n1 4\n3 10 3\n", "output": "1\n0\n"}, {"input": "5\n1 3\n1 4\n3 11 3\n2 4\n3 6 2\n", "output": "0\n0\n"}, {"input": "5\n1 3\n1 4\n3 12 3\n1 4\n3 4 3\n", "output": "0\n2\n"}, {"input": "5\n1 3\n1 4\n3 8 3\n2 4\n3 6 3\n", "output": "0\n0\n"}, {"input": "5\n1 3\n1 4\n3 6 3\n1 4\n3 6 3\n", "o...
code_stdio
[ { "content": "You are given a permutation p of length n. Remove one element from permutation to make the number of records the maximum possible.\n\nWe remind that in a sequence of numbers a_1, a_2, ..., a_{k} the element a_{i} is a record if for every integer j (1 ≤ j < i) the following holds: a_{j} < a_{i}. \n...
[{"input": "92\n42 64 33 89 57 9 24 44 87 67 92 84 39 88 26 27 85 62 22 83 23 71 14 13 73 79 15 49 2 12 76 53 81 40 31 3 72 58 1 61 7 82 20 54 46 77 11 16 28 48 6 45 36 43 60 38 18 4 32 74 10 91 19 86 75 51 50 52 78 25 65 8 55 30 90 69 59 63 56 80 29 68 70 17 35 41 37 47 66 34 5 21\n", "output": "1\n"}, {"input": "92\n...
code_stdio
[ { "content": "Alice has a birthday today, so she invited home her best friend Bob. Now Bob needs to find a way to commute to the Alice's home.\n\nIn the city in which Alice and Bob live, the first metro line is being built. This metro line contains $n$ stations numbered from $1$ to $n$. Bob lives near the stati...
[{"input": "10 3\n0 1 1 0 1 0 0 2 -1 0\n1 4 1 2 -1 0 1 1 -1 1\n", "output": "NO\n"}, {"input": "10 10\n1 0 0 0 0 0 0 0 0 1\n0 0 0 0 0 0 0 0 0 0\n", "output": "YES\n"}, {"input": "10 10\n1 0 0 0 0 0 0 0 0 1\n0 0 0 0 0 0 0 0 0 0\n", "output": "YES\n"}, {"input": "10 3\n0 1 1 0 1 0 0 2 -1 0\n1 2 1 1 -1 0 1 1 0 1\n", "outp...
code_stdio
[ { "content": "Little Elephant loves magic squares very much.\n\nA magic square is a 3 × 3 table, each cell contains some positive integer. At that the sums of integers in all rows, columns and diagonals of the table are equal. The figure below shows the magic square, the sum of integers in all its rows, columns...
[{"input": "0 100000 100000\n100000 0 100000\n100000 100000 0\n", "output": "100000 100000 100000\n100000 100000 100000\n100000 100000 100000\n"}, {"input": "0 100000 100000\n100000 0 100000\n100000 100000 0\n", "output": "100000 100000 100000\n100000 100000 100000\n100000 100000 100000\n"}, {"input": "0 98721 99776\n9...
code_stdio
[ { "content": "problem\n\nThere are fine icicles under the eaves of JOI's house in Canada. Because of this, JOI decided to investigate the icicles.\n\nThere are N (2 ≤ N ≤ 100000 = 105) icicles under the eaves of JOI's house. These icicles are aligned and i cm (1 ≤ i ≤ N) from the left edge of the eaves. There a...
[{"input": "1 56\n4\n-1\n-1\n-1", "output": "52\n"}, {"input": "2 71\n14\n6\n0\n0", "output": "122\n"}, {"input": "2 30\n14\n6\n3\n0", "output": "40\n"}, {"input": "2 17\n2\n3\n3\n-1", "output": "29\n"}, {"input": "2 38\n14\n6\n0\n0", "output": "56\n"}, {"input": "4 10\n7\n1\n3\n5", "output": "21\n"}, {"input": "4 11\n...
code_stdio
[ { "content": "Valery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have thought that even in a regular array of numbers Valera manages to see something beautiful and magi...
[{"input": "150\n0 -2 1 -2 0 0 0 0 -2 0 -2 -1 0 0 2 0 1 -2 1 -1 0 0 0 2 -2 2 -1 0 0 -1 -2 0 2 0 1 0 -2 0 -2 -1 0 -2 -2 2 0 0 1 -2 -2 -1 -2 0 2 1 1 -1 1 0 -2 2 0 0 0 1 -1 0 -2 -1 0 -2 1 1 1 0 0 2 0 0 2 -1 0 0 2 0 2 0 -2 -1 1 -2 1 0 0 -2 -1 -1 0 0 2 -1 -1 -1 -1 -2 0 0 2 -1 -1 1 0 0 1 -1 0 0 -1 2 2 0 0 0 -1 -2 0 1 0 -1 -1...
code_stdio
[ { "content": "Jabber ID on the national Berland service «Babber» has a form <username>@<hostname>[/resource], where \n\n * <username> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <username> is between 1 and 16, inclusive. \n * <hostname> — is a...
[{"input": "IGsma3L6YTJRrXS@1g.yR3mC.c.xoCns7Wo1.9C.Oe.5ebkR/_97Ltj3\n", "output": "YES\n"}, {"input": "IGsma3K6YTJRrXS@1g.yR3mC.c.xoCns7Wo1.9C.Oe.5ebkR/_97Ltj3\n", "output": "YES\n"}, {"input": "POTjlYcxAZsbyZPDh@sPm.z6aVaO.H1wEUhD9YvROQFUk/M_jTHS_6!\n", "output": "NO\n"}, {"input": "POTjlYcxAZsbyZPDh9sPm.z6aVaO.H1wEU...
code_stdio
[ { "content": "There is an airplane which has n rows from front to back. There will be m people boarding this airplane.\n\nThis airplane has an entrance at the very front and very back of the plane.\n\nEach person has some assigned seat. It is possible for multiple people to have the same assigned seat. The peop...
[{"input": "1000000 1000000\n", "output": "233176135\n"}, {"input": "1000000 1000000\n", "output": "233176135\n"}, {"input": "1000001 1000000\n", "output": "109334147\n"}, {"input": "1000000 500000\n", "output": "211837745\n"}, {"input": "1000000 500000\n", "output": "211837745\n"}, {"input": "1000000 481032\n", "outpu...
code_stdio
[ { "content": "A boy named Vasya has taken part in an Olympiad. His teacher knows that in total Vasya got at least x points for both tours of the Olympiad. The teacher has the results of the first and the second tour of the Olympiad but the problem is, the results have only points, no names. The teacher has to k...
[{"input": "10 168884\n75796 42057 25891 51127 40493 78380 30331 47660 58338 90812\n50469 28184 75581 61837 25050 90975 98279 81022 90217 31015\n", "output": "1 3\n"}, {"input": "10 168884\n29651 42057 25891 51127 40493 78380 30331 47660 58338 90812\n50469 28184 75581 61837 25050 90975 98279 81022 90217 31015\n", "outp...
code_stdio
[ { "content": "Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...\n\n$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Ye...
[{"input": "10\n10 7 10 10 7 10 7 7 10 10\n", "output": "2 6\n"}, {"input": "10\n10 7 10 10 7 10 7 7 10 10\n", "output": "2 6\n"}, {"input": "10\n10 7 10 10 7 10 7 5 10 10\n", "output": "2 7\n"}, {"input": "10\n1 2 3 4 5 6 7 8 9 10\n", "output": "4 10\n"}, {"input": "10\n1 2 3 4 5 6 7 8 9 10\n", "output": "4 10\n"}, {"...
code_stdio
[ { "content": "Vasya has a non-negative integer n. He wants to round it to nearest integer, which ends up with 0. If n already ends up with 0, Vasya considers it already rounded.\n\nFor example, if n = 4722 answer is 4720. If n = 5 Vasya can round it to 0 or to 10. Both ways are correct.\n\nFor given n find out ...
[{"input": "1000000000\n", "output": "1000000000\n"}, {"input": "1031575393\n", "output": "1031575390\n"}, {"input": "1022742286\n", "output": "1022742290\n"}, {"input": "1259496606\n", "output": "1259496610\n"}, {"input": "1938879055\n", "output": "1938879050\n"}, {"input": "1178556713\n", "output": "1178556710\n"}, {...
code_stdio
[ { "content": "Notes\n\nTemplate in C\n\nConstraints\n\n* 1 ≤ n ≤ 100000\n* 1 ≤ q ≤ 1000\n* 1 ≤ timei ≤ 50000\n* 1 ≤ length of namei ≤ 10\n* 1 ≤ Sum of timei ≤ 1000000\n\nInput\n\nn q\nname1 time1\nname2 time2\n...\nnamen timen\n\n\nIn the first line the number of processes n and the quantum q are given separate...
[{"input": "5 100\np1 150\np2 216\np3 200\np4 548\np5 20", "output": "p5 420\np1 470\np3 670\np2 786\np4 1134\n"}, {"input": "5 100\np1 150\np2 216\no3 200\np4 548\np5 20", "output": "p5 420\np1 470\no3 670\np2 786\np4 1134\n"}, {"input": "5 100\np1 150\np2 216\no3 200\np4 548\nq5 20", "output": "q5 420\np1 470\no3 670...
code_stdio
[ { "content": "N problems have been chosen by the judges, now it's time to assign scores to them!\n\nProblem i must get an integer score A_i between 1 and N, inclusive. The problems have already been sorted by difficulty: A_1 \\le A_2 \\le \\ldots \\le A_N must hold. Different problems can have the same score, t...
[{"input": "157 925309799", "output": "391028716"}, {"input": "134 925309799", "output": "114482723"}, {"input": "134 569368125", "output": "166407741"}, {"input": "134 788899135", "output": "506695346"}, {"input": "48 126674882", "output": "104179983"}, {"input": "45 713052776", "output": "108412121"}, {"input": "90 3...
code_stdio
[ { "content": "You are given a text that consists of lowercase Latin letters, spaces and punctuation marks (dot, comma, exclamation mark and question mark). A word is defined as a sequence of consecutive Latin letters.\n\nYour task is to add spaces to the text by the following rules:\n\n * if there is no punctu...
[{"input": "ajdwlf ibvlfqadt sqdn aoj nsjtivfrsp !mquqfgzrbp w ow aydap ry s . jwlvg ? ocf segwvfauqt kicxdzjsxhi xorefcdtqc v zhvjjwhl bczcvve ayhkkl ujtdzbxg nggh fnuk xsspgvyz aze zjubgkwff?hgj spteldqbdo vkxtgnl uxckibqs vpzeaq roj jzsxme gmfpbjp uz ...
code_stdio
[ { "content": "Snuke has a rooted tree with N+1 vertices.\nThe vertices are numbered 0 through N, and Vertex 0 is the root of the tree.\nThe parent of Vertex i (1 \\leq i \\leq N) is Vertex p_i.\nBesides this tree, Snuke also has an box which is initially empty and many marbles, and playing with them.\nThe play ...
[{"input": "31\n0 1 0 2 4 0 4 1 6 4 3 9 7 3 7 2 15 6 12 10 12 16 5 3 20 1 25 20 23 24 23\n", "output": "730395550\n"}, {"input": "31\n0 1 0 2 4 0 4 1 6 4 3 9 7 3 7 3 15 6 12 10 12 16 5 3 20 1 25 20 23 24 23", "output": "831058846\n"}, {"input": "31\n0 1 0 2 4 0 4 0 6 4 3 9 7 3 7 3 15 6 12 10 12 16 5 3 20 1 25 20 23 24 ...
code_stdio