messages
listlengths
1
1
ground_truth
stringlengths
88
726k
dataset
stringclasses
1 value
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo people are playing a game with a string s, consisting of lowercase latin letters. \n\nOn a player's turn, he should choose two consecutive equal letters in the string and delete them. \n\nFor example, if the string is...
[{"type": "stdin_stdout", "input": "axxxxbbaaa\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "pogfjssywv\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "aaabbxxxxa\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "pogfjssywu\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "axab...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNeko 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 ...
[{"type": "stdin_stdout", "input": "1000000000 264865600\n", "output": "102701600\n"}, {"type": "stdin_stdout", "input": "999999973 800000007\n", "output": "199999823\n"}, {"type": "stdin_stdout", "input": "159488527 938932258\n", "output": "100326050\n"}, {"type": "stdin_stdout", "input": "179237079 691088384\n", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou're given an array a of length 2n. Is it possible to reorder it in such way so that the sum of the first n elements isn't equal to the sum of the last n elements?\n\nInput\n\nThe first line contains an integer n (1 ≤ n...
[{"type": "stdin_stdout", "input": "97\n13 8 5 4 7 4 10 3 8 10 2 10 9 9 8 1 17 1 8 8 5 6 4 8 7 1 9 10 6 3 9 5 8 3 3 8 9 8 4 2 10 9 5 4 1 10 8 4 2 3 2 10 6 1 4 5 1 2 9 5 4 9 1 5 5 8 10 1 10 6 5 8 8 8 5 4 5 7 8 8 6 2 7 10 4 2 1 6 5 9 1 8 6 7 5 2 3 4 1 10 4 5 4 3 10 8 9 9 9 8 6 5 8 7 8 10 4 4 7 5 8 8 1 10 6 9 5 9 8 4 9 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n points on the plane, the i-th of which is at (x_i, y_i). Tokitsukaze wants to draw a strange rectangular area and pick all the points in the area.\n\nThe strange area is enclosed by three lines, x = l, y = a a...
[{"type": "stdin_stdout", "input": "35\n8 1\n6 8\n4 1\n1 2\n1 4\n5 10\n10 8\n9 1\n9 9\n10 2\n6 5\n8 8\n7 6\n10 6\n9 4\n4 9\n3 2\n1 8\n3 9\n7 3\n3 7\n2 7\n3 8\n3 1\n2 2\n5 5\n7 2\n4 10\n6 3\n5 1\n8 10\n4 3\n9 8\n9 7\n3 10\n", "output": "316"}, {"type": "stdin_stdout", "input": "35\n4 2\n9 6\n3 10\n2 5\n7 9\n6 9\n10 7\n6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnadi has a set of dominoes. Every domino has two parts, and each part contains some dots. For every a and b such that 1 ≤ a ≤ b ≤ 6, there is exactly one domino with a dots on one half and b dots on the other half. The s...
[{"type": "stdin_stdout", "input": "7 21\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n2 3\n2 4\n2 5\n2 6\n2 7\n3 4\n3 5\n3 6\n3 7\n4 5\n4 6\n4 7\n5 6\n5 7\n6 7\n", "output": "16\n"}, {"type": "stdin_stdout", "input": "7 21\n3 5\n7 2\n2 3\n6 5\n5 2\n4 7\n2 6\n2 4\n6 7\n5 1\n1 4\n4 5\n5 7\n4 6\n3 1\n1 2\n3 4\n7 1\n3 7\n6 1\n3 6\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAt first, let's define function f(x) as follows: $$$ \\begin{matrix} f(x) & = & \\left\\{ \\begin{matrix} x/2 & \\mbox{if } x is even \\\\\\ x - 1 & \\mbox{otherwise } \\end{matrix} \\right. \\end{matrix} $$$\n\nWe can s...
[{"type": "stdin_stdout", "input": "1000000000000000000 100\n", "output": "31249999999999998\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 100000000\n", "output": "29802322386\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 10000000000\n", "output": "232830642\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKana was just an ordinary high school girl before a talent scout discovered her. Then, she became an idol. But different from the stereotype, she is also a gameholic. \n\nOne day Kana gets interested in a new adventure ga...
[{"type": "stdin_stdout", "input": "7\n100 3 2\n189 3 4\n28 2 3\n63 2 3\n30 27 14\n10 9 1\n69117 21 2\n", "output": "NO\nNO\nYES\nYES\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "7\n100 3 2\n189 4 4\n64 2 3\n18 2 3\n19 27 14\n10 9 1\n69117 21 2\n", "output": "NO\nYES\nNO\nYES\nYES\nYES\nYES\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarpus has postcards and photos hung in a row on the wall. He decided to put them away to the closet and hang on the wall a famous painter's picture. Polycarpus does it like that: he goes from the left to the right an...
[{"type": "stdin_stdout", "input": "CPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCP\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "PPPPPPPPPPPPPPPPPPPPPPPCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCPPPPPCCCPPPPCCCCCPCC\n", "output": "23\n"}, ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Petya likes numbers a lot. He found that number 123 in base 16 consists of two digits: the first is 7 and the second is 11. So the sum of digits of 123 in base 16 is equal to 18.\n\nNow he wonders what is an averag...
[{"type": "stdin_stdout", "input": "1209\n", "output": "263450/1207\n"}, {"type": "stdin_stdout", "input": "1869\n", "output": "627063/1867\n"}, {"type": "stdin_stdout", "input": "1865\n", "output": "623876/1863\n"}, {"type": "stdin_stdout", "input": "1343\n", "output": "325366/1341\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Bubble Cup hypothesis stood unsolved for 130 years. Who ever proves the hypothesis will be regarded as one of the greatest mathematicians of our time! A famous mathematician Jerry Mao managed to reduce the hypothesis ...
[{"type": "stdin_stdout", "input": "100\n891 894 462 899 163 868 418 903 31 333 670 32 705 561 505 920 414 81 723 603 513 25 896 879 703 415 799 271 440 8 596 207 296 116 458 646 781 842 963 174 157 747 207 996 361 371 721 447 566 438 566 449 522 176 79 740 757 156 436 296 23 704 542 572 455 886 962 194 219 301 437 315...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya is preparing for his birthday. He decided that there would be n different dishes on the dinner table, numbered from 1 to n. Since Petya doesn't like to cook, he wants to order these dishes in restaurants.\n\nUnfortu...
[{"type": "stdin_stdout", "input": "4\n4\n3 7 4 5\n2 1 2 4\n4\n1 2 3 4\n3 3 3 3\n2\n1 2\n10 10\n2\n10 10\n1 2\n", "output": "5\n3\n2\n3\n"}, {"type": "stdin_stdout", "input": "4\n4\n3 11 4 2\n2 1 2 4\n4\n1 2 3 4\n3 3 3 3\n2\n1 2\n10 10\n2\n10 10\n1 2\n", "output": "3\n3\n2\n3"}, {"type": "stdin_stdout", "input": "4\n4\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSuppose you have a sequence of k integers A = [a_1, a_2, ... , a_k] where each a_i ≥ 2. A sequence of prime integers P = [p_1, p_2, ..., p_k] is called suitable for the sequence A if a_1 is divisible by p_1, a_2 is divisi...
[{"type": "stdin_stdout", "input": "95 95\n6636 6466 83 4661 3 354 6148 217 427 8192 9699 31 1162 9381 27 3403 166 841 3599 318 1403 413 6557 49 371 6254 4096 4819 3127 7316 498 2419 6241 2562 3782 158 961 3813 79 4209 1643 2291 3074 5002 3444 3481 4897 177 1909 61 53 9796 1891 59 1681 529 1357 2173 3233 2407 1537 2573...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is an interactive problem.\n\nThere exists a matrix a of size n × m (n rows and m columns), you know only numbers n and m. The rows of the matrix are numbered from 1 to n from top to bottom, and columns of the matrix...
[{"type": "stdin_stdout", "input": "36 6\n1 1 1 1 1 1\n1 1 1 1 1 1\n1 1 1 1 1 1\n1 1 1 1 1 1\n1 1 1 1 2 1\n1 1 1 1 1 1\n1 1 1 1 1 1\n1 1 1 1 1 1\n1 1 1 1 1 1\n1 1 1 1 1 1\n1 1 1 1 1 1\n1 1 1 1 1 1\n1 1 1 1 1 1\n1 1 1 1 1 1\n1 1 1 1 1 1\n1 1 1 1 1 1\n1 1 1 1 1 2\n1 1 1 1 1 1\n1 1 1 1 1 1\n1 1 1 1 1 1\n1 1 1 1 1 1\n1 1 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBaby Ehab was toying around with arrays. He has an array a of length n. He defines an array to be good if there's no way to partition it into 2 subsequences such that the sum of the elements in the first is equal to the s...
[{"type": "stdin_stdout", "input": "100\n2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is the easy version of the problem. The only difference is that here k=2. You can make hacks only if both the versions of the problem are solved.\n\nThis is an interactive problem.\n\nEvery decimal number has a base ...
[{"type": "stdin_stdout", "input": "32\n8581 2\n6058 2\n3019 2\n2151 2\n4140 2\n4553 2\n5920 2\n9883 2\n9170 2\n318 2\n1527 2\n6945 2\n5345 2\n5007 2\n6709 2\n7960 2\n7659 2\n7507 2\n7188 2\n3939 2\n4849 2\n3336 2\n7426 2\n9064 2\n4765 2\n9262 2\n9265 2\n8162 2\n8985 2\n2298 2\n9285 2\n7280 2\n", "output": "0\n0\n0\n0\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThey say that Berland has exactly two problems, fools and roads. Besides, Berland has n cities, populated by the fools and connected by the roads. All Berland roads are bidirectional. As there are many fools in Berland, b...
[{"type": "stdin_stdout", "input": "5\n3 4\n4 5\n1 4\n2 4\n3\n2 3\n1 3\n3 5\n", "output": "3 1 1 1\n"}, {"type": "stdin_stdout", "input": "5\n3 4\n4 5\n1 2\n2 4\n3\n2 3\n1 3\n3 5\n", "output": "3 1 1 2\n"}, {"type": "stdin_stdout", "input": "5\n3 1\n4 5\n1 4\n2 4\n3\n2 3\n1 3\n3 5\n", "output": "3 1 2 1\n"}, {"type": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle penguin Polo adores strings. But most of all he adores strings of length n.\n\nOne day he wanted to find a string that meets the following conditions:\n\n 1. The string consists of n lowercase English letters (tha...
[{"type": "stdin_stdout", "input": "93563 25\n", "output": "abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIlya is a very clever lion, he lives in an unusual city ZooVille. In this city all the animals have their rights and obligations. Moreover, they even have their own bank accounts. The state of a bank account is an integer...
[{"type": "stdin_stdout", "input": "-1000000000\n", "output": "-100000000\n"}, {"type": "stdin_stdout", "input": "-1015555150\n", "output": "-101555510\n"}, {"type": "stdin_stdout", "input": "-1620057635\n", "output": "-162005763\n"}, {"type": "stdin_stdout", "input": "-1246147339\n", "output": "-124614733\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. \n\nDima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She line...
[{"type": "stdin_stdout", "input": "8\n7 3 3 10 9 9 8 1\n8 2 6 6 0 3 8 0\n1 2 5 1 9 4 7 8\n", "output": "52\n"}, {"type": "stdin_stdout", "input": "8\n7 3 3 10 9 9 8 1\n8 2 4 6 0 3 8 0\n1 2 5 1 9 4 7 8\n", "output": "52\n"}, {"type": "stdin_stdout", "input": "8\n7 3 3 10 9 9 6 1\n8 2 4 6 0 3 8 0\n1 2 5 1 9 4 7 8\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSereja loves number sequences very much. That's why he decided to make himself a new one following a certain algorithm.\n\nSereja takes a blank piece of paper. Then he starts writing out the sequence in m stages. Each tim...
[{"type": "stdin_stdout", "input": "7\n1 53989\n1 47249\n1 71935\n2 1 3\n1 84520\n1 142367\n2 6 2\n14\n1 2 3 4 5 6 7 8 9 10 11 12 13 14\n", "output": "53989 47249 71935 53989 53989 53989 84520 142367 53989 47249 71935 53989 53989 53989\n"}, {"type": "stdin_stdout", "input": "7\n1 53989\n1 47249\n1 71935\n2 1 3\n1 84520...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Queen of England has n trees growing in a row in her garden. At that, the i-th (1 ≤ i ≤ n) tree from the left has height ai meters. Today the Queen decided to update the scenery of her garden. She wants the trees' hei...
[{"type": "stdin_stdout", "input": "50 5\n232 6 17 6 21 26 27 36 41 88 665 56 61 66 71 76 602 86 28 712 101 106 111 116 121 126 131 136 141 146 151 156 161 166 755 176 181 186 191 196 201 206 211 216 5 226 172 236 241 246\n", "output": "12\n- 1 231\n- 3 6\n+ 4 10\n+ 7 4\n- 10 42\n- 11 614\n- 17 521\n+ 19 63\n- 20 616\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRight now you are to solve a very, very simple problem — to crack the safe. Four positive integers stand one by one on a circle protecting the safe. You know that to unlock this striking safe you have to make all four num...
[{"type": "stdin_stdout", "input": "84618709 232259095 877021269 101998945\n", "output": "+4\n+3\n+2\n+4\n+3\n+1\n+2\n+3\n/4\n+4\n/3\n+1\n+3\n+4\n+1\n/4\n/2\n+3\n+4\n/2\n/3\n/3\n+3\n+2\n+4\n/1\n+3\n/2\n+4\n/1\n+2\n/3\n+1\n/4\n/3\n+2\n/3\n+4\n+1\n+2\n/3\n+3\n/1\n+2\n+1\n/4\n+1\n+3\n/2\n+2\n/2\n/1\n/3\n+3\n/3\n+1\n/4\n/3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are organizing a cycling race on the streets of the city. The city contains n junctions, some pairs of them are connected by roads; on each road you can move in any direction. No two roads connect the same pair of int...
[{"type": "stdin_stdout", "input": "65 69\n20 23\n18 33\n16 19\n9 22\n48 11\n5 57\n39 37\n60 38\n12 32\n39 49\n50 8\n55 56\n17 29\n8 24\n11 58\n38 61\n14 48\n22 15\n46 49\n51 41\n64 47\n20 6\n19 12\n51 10\n28 23\n6 45\n13 34\n53 40\n34 31\n63 19\n33 17\n47 2\n57 42\n45 60\n43 37\n24 14\n54 7\n7 31\n56 2\n46 4\n65 44\n4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time li and the finish time ri (li ≤ ...
[{"type": "stdin_stdout", "input": "20\n22 77\n13 50\n55 64\n16 52\n67 96\n49 51\n59 95\n2 25\n69 91\n2 24\n4 46\n50 74\n45 106\n39 55\n31 33\n9 33\n6 72\n14 67\n56 98\n69 152\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "20\n22 77\n13 50\n55 64\n16 52\n62 96\n49 51\n59 95\n2 25\n69 91\n2 24\n4 46\n50 74\n45...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA group of n cities is connected by a network of roads. There is an undirected road between every pair of cities, so there are <image> roads in total. It takes exactly y seconds to traverse any single road.\n\nA spanning ...
[{"type": "stdin_stdout", "input": "50 23129 410924\n18 28\n17 25\n21 15\n18 50\n50 11\n32 3\n44 41\n50 31\n50 34\n5 14\n36 13\n22 40\n20 9\n9 43\n19 47\n48 40\n20 22\n33 45\n35 22\n33 24\n9 6\n13 1\n13 24\n49 20\n1 20\n29 38\n10 35\n25 23\n49 30\n42 8\n20 18\n32 15\n32 1\n27 10\n20 47\n41 7\n20 14\n18 26\n4 20\n20 2\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA tree is a connected undirected graph consisting of n vertices and n - 1 edges. Vertices are numbered 1 through n.\n\nLimak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stol...
[{"type": "stdin_stdout", "input": "11244 7 5\n", "output": "1 2\n2 3\n3 4\n4 5\n5 6\n1 7\n7 8\n1 9\n1 10\n1 11\n1 12\n1 13\n1 14\n1 15\n1 16\n1 17\n1 18\n1 19\n1 20\n1 21\n1 22\n1 23\n1 24\n1 25\n1 26\n1 27\n1 28\n1 29\n1 30\n1 31\n1 32\n1 33\n1 34\n1 35\n1 36\n1 37\n1 38\n1 39\n1 40\n1 41\n1 42\n1 43\n1 44\n1 45\n1 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multiset with integers. Friends give her t queries, each of one of the following type:\n\n 1. + ai — add...
[{"type": "stdin_stdout", "input": "10\n+ 870566619432760298\n+ 869797178280285214\n+ 609920823721618090\n+ 221159591436767023\n+ 730599542279836538\n? 101001100111001011\n? 001111010101010011\n? 100010100011101110\n? 100110010110001100\n? 110000011101110011\n", "output": "0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe academic year has just begun, but lessons and olympiads have already occupied all the free time. It is not a surprise that today Olga fell asleep on the Literature. She had a dream in which she was on a stairs. \n\nTh...
[{"type": "stdin_stdout", "input": "50\nUUUUUUUUUUUUUUUUUUUUUUUUUDDDDDDDDDDDDDDDDDDDDDDDDD\n", "output": "51 102 153 204 255 306 357 408 459 510 561 612 663 714 765 816 867 918 969 1020 1071 1122 1173 1224 1275 1275 1224 1173 1122 1071 1020 969 918 867 816 765 714 663 612 561 510 459 408 357 306 255 204 153 102 51\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIgor found out discounts in a shop and decided to buy n items. Discounts at the store will last for a week and Igor knows about each item that its price now is ai, and after a week of discounts its price will be bi.\n\nNo...
[{"type": "stdin_stdout", "input": "50 45\n80 125 152 122 85 62 123 195 157 73 8 127 47 193 70 132 131 38 98 115 185 98 68 166 114 53 144 106 141 106 191 123 44 199 35 18 84 169 46 52 129 102 155 130 63 169 116 145 154 41\n155 187 79 106 136 173 17 146 9 47 173 21 37 183 110 74 185 14 82 156 147 25 162 195 26 25 22 80 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Floral Clock has been standing by the side of Mirror Lake for years. Though unable to keep time, it reminds people of the passage of time and the good old days.\n\nOn the rim of the Floral Clock are 2n flowers, number...
[{"type": "stdin_stdout", "input": "23333\n", "output": "259575428\n"}, {"type": "stdin_stdout", "input": "49997\n", "output": "645043850\n"}, {"type": "stdin_stdout", "input": "10492\n", "output": "914991759\n"}, {"type": "stdin_stdout", "input": "30000\n", "output": "583465411\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou 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...
[{"type": "stdin_stdout", "input": "100\n611\n513\n544\n463\n38\n778\n347\n317\n848\n1308\n382\n108\n718\n33\n544\n876\n234\n22\n944\n305\n159\n245\n513\n691\n639\n135\n435\n324\n813\n459\n304\n116\n331\n993\n184\n224\n853\n769\n121\n687\n93\n930\n751\n308\n485\n914\n400\n695\n95\n981\n175\n972\n121\n1007\n242\n610\n61...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n— Thanks a lot for today.\n\n— I experienced so many great things.\n\n— You gave me memories like dreams... But I have to leave now...\n\n— One last request, can you...\n\n— Help me solve a Codeforces problem?\n\n— .........
[{"type": "stdin_stdout", "input": "100000 1000000000\n", "output": "495495496\n"}, {"type": "stdin_stdout", "input": "91454 1017443433\n", "output": "794092041\n"}, {"type": "stdin_stdout", "input": "77809 868097296\n", "output": "440411873\n"}, {"type": "stdin_stdout", "input": "67298 349286579\n", "output": "1564352...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs Will is stuck in the Upside Down, he can still communicate with his mom, Joyce, through the Christmas lights (he can turn them on and off with his mind). He can't directly tell his mom where he is, because the monster ...
[{"type": "stdin_stdout", "input": ")?(??((???????()?(?????????)??(????????((?)?????)????)??????(?????)?)?????)??????(??()??????)????????)?)()??????????????())????????(???)??)????????????????????(?????)??)???)??(???????????????)???)??)?\n", "output": "8314\n"}, {"type": "stdin_stdout", "input": "?)??)???)??????????????...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnd where the are the phone numbers?\n\nYou are given a string s consisting of lowercase English letters and an integer k. Find the lexicographically smallest string t of length k, such that its set of letters is a subset...
[{"type": "stdin_stdout", "input": "3 99948\nttt\n", "output": "tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRachel, being an awesome android programmer, just finished an App that will let us draw a triangle by selecting three points on the touch-plane.Now She asks her friend Bruce to draw a Right-Angled Triangle (we'll call it ...
[{"type": "stdin_stdout", "input": "15\n27 44 85 12 100 99\n-97 -25 17 45 38 -116\n53 -15 86 32 14 -41\n-66 24 20 -29 34 17\n-83 40 -137 52 -71 114\n-34 67 -62 37 -49 75\n58 45 6 22 13 88\n75 86 -82 89 -31 -35\n34 74 -3 -113 63 -61\n-7 63 78 111 -31 -25\n-49 -49 3 92 61 -28\n-90 90 42 -92 -75 -26\n-100 -100 100 -100 0 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday, you have been given the task of handling the entire Taxi Network of Berland City. Berland city has a huge number of taxi travellers, and you need to help them in transportation in the most efficient manner. \n\nTo ...
[{"type": "stdin_stdout", "input": "1000 100\n899 100000\n202 100000\n401 100000\n45 100000\n389 100000\n551 100000\n997 100000\n920 100000\n430 100000\n534 100000\n739 100000\n320 100000\n309 100000\n641 100000\n318 100000\n665 100000\n462 100000\n635 100000\n39 100000\n331 100000\n898 100000\n711 100000\n334 100000\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMax feels lonely after shifting to a new locality, as he does not have any friend there. So his parents bought him a new number from the Integers SuperMarket! Every child in the locality has bought a number from the same ...
[{"type": "stdin_stdout", "input": "507\n887\n778 916 794 336 387 493 650 422 363 28 691 60 764 511 541 427 173 737 125 369 568 430 783 531 863 124 83 136 930 803 23 59 70 168 394 457 12 43 230 374 422 1145 785 538 199 325 316 371 414 510 92 981 957 874 863 171 997 282 306 926 85 328 337 506 847 730 314 858 125 896 583...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHow many strings can be obtained by applying the following operation on a string S exactly K times: \"choose one lowercase English letter and insert it somewhere\"?\n\nThe answer can be enormous, so print it modulo (10^9+...
[{"type": "stdin_stdout", "input": "37564\nwhydidzoudesertme", "output": "318008117\n"}, {"type": "stdin_stdout", "input": "37564\nwhxdidzoudesertme", "output": "318008117\n"}, {"type": "stdin_stdout", "input": "37564\nwhxdidzoudesertne", "output": "318008117\n"}, {"type": "stdin_stdout", "input": "37564\nwhxdiczoudese...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nN friends of Takahashi has come to a theme park.\n\nTo ride the most popular roller coaster in the park, you must be at least K centimeters tall.\n\nThe i-th friend is h_i centimeters tall.\n\nHow many of the Takahashi's ...
[{"type": "stdin_stdout", "input": "5 1\n100 200 300 467 500", "output": "5\n"}, {"type": "stdin_stdout", "input": "5 2\n000 200 300 467 500", "output": "4\n"}, {"type": "stdin_stdout", "input": "5 2\n100 200 300 467 500", "output": "5\n"}, {"type": "stdin_stdout", "input": "5 2\n100 200 476 467 500", "output": "5\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N men and N women, both numbered 1, 2, \\ldots, N.\n\nFor each i, j (1 \\leq i, j \\leq N), the compatibility of Man i and Woman j is given as an integer a_{i, j}. If a_{i, j} = 1, Man i and Woman j are compatib...
[{"type": "stdin_stdout", "input": "21\n0 0 0 0 0 0 0 1 1 0 1 1 1 1 0 0 0 1 0 0 1\n1 1 1 0 1 1 0 0 0 1 0 0 0 0 1 1 1 0 1 1 0\n0 0 1 1 1 1 0 1 1 0 0 1 0 0 1 1 0 0 0 1 1\n0 1 1 0 1 1 0 1 0 1 0 0 1 0 0 0 0 0 1 1 0\n1 1 0 0 1 0 1 0 0 1 1 1 1 0 0 0 0 0 0 0 0\n0 1 1 0 1 1 1 0 1 1 1 0 0 0 1 1 1 1 0 0 1\n0 1 0 0 0 1 0 1 0 0 0 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn Takahashi's mind, there is always an integer sequence of length 2 \\times 10^9 + 1: A = (A_{-10^9}, A_{-10^9 + 1}, ..., A_{10^9 - 1}, A_{10^9}) and an integer P.\n\nInitially, all the elements in the sequence A in Taka...
[{"type": "stdin_stdout", "input": "48\n-+><<><><><>>>+-<<>->>><<><<-+<>><+<<>+><-+->><<", "output": "475"}, {"type": "stdin_stdout", "input": "48\n<<>>-+-<>+><<+<>><+-<<><<>>>-><<-+>>><><><><<>+-", "output": "475"}, {"type": "stdin_stdout", "input": "48\n<<>>-+-<>+><<+<>><+-<<><<>>>-><<-+>>><><><><<>-+", "output": "47...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe say that a odd number N is similar to 2017 when both N and (N+1)/2 are prime.\n\nYou are given Q queries.\n\nIn the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such t...
[{"type": "stdin_stdout", "input": "6\n1 53\n7 129\n37 55\n19 51\n103 169\n13 33", "output": "4\n4\n1\n1\n1\n1\n"}, {"type": "stdin_stdout", "input": "6\n1 53\n7 129\n65 55\n19 51\n17 169\n13 49", "output": "4\n4\n-1\n1\n4\n2\n"}, {"type": "stdin_stdout", "input": "6\n1 53\n7 119\n37 55\n19 83\n73 39\n13 49", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke, who loves animals, built a zoo.\n\nThere are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle. The animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and ...
[{"type": "stdin_stdout", "input": "10\nxooxoxooxo", "output": "SWWSSSWWSS\n"}, {"type": "stdin_stdout", "input": "10\nxxooxoxooo", "output": "SWSWWWSSSS\n"}, {"type": "stdin_stdout", "input": "10\noxooooxxox", "output": "SSWWSWWWWS\n"}, {"type": "stdin_stdout", "input": "10\nxoxxooooxo", "output": "SWWWWSWWSS\n"}, {"t...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two gestures, Rock and Paper, as in Rock-paper-scissors, under the following condition...
[{"type": "stdin_stdout", "input": "ggpgggppgg", "output": "2\n"}, {"type": "stdin_stdout", "input": "ggggggpppg", "output": "2\n"}, {"type": "stdin_stdout", "input": "ggppgpgggg", "output": "2\n"}, {"type": "stdin_stdout", "input": "ggppggpggg", "output": "2\n"}, {"type": "stdin_stdout", "input": "gggpggppgg", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWith the motto \"Creating your own path,\" a shrine created a fortune-telling fortune with its own hands. Ask the person who draws the lottery to throw six stones first, then the line segment connecting the first and seco...
[{"type": "stdin_stdout", "input": "-1 -2 9 6\n3 -2 7 6\n-1 0 9 0\n2 2 0 -1\n1 2 2 0\n-3 -1 3 1\n0 0 0 0", "output": "syo-kichi\nsyo-kichi\n"}, {"type": "stdin_stdout", "input": "-1 -2 22 6\n3 -2 7 10\n-1 0 9 0\n3 2 0 -1\n1 1 2 1\n-3 -1 3 1\n0 0 0 0", "output": "syo-kichi\nkyo\n"}, {"type": "stdin_stdout", "input": "-1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nN different natural numbers are given. If you select four different ones and set them as $ A $, $ B $, $ C $, $ D $, the following formula\n\n$ \\ Frac {A + B} {C --D} $\n\n\n\nI want to find the maximum value of.\n\n\n\n...
[{"type": "stdin_stdout", "input": "4\n100010 140474 4 -1", "output": "48096.8000000000\n"}, {"type": "stdin_stdout", "input": "4\n100010 215427 4 -1", "output": "63087.4000000000\n"}, {"type": "stdin_stdout", "input": "4\n100101 3026 -1 -2", "output": "103127.0000000000\n"}, {"type": "stdin_stdout", "input": "4\n11010...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCarving the cake 2 (Cake 2)\n\nJOI-kun and IOI-chan are twin brothers and sisters. JOI has been enthusiastic about making sweets lately, and JOI tried to bake a cake and eat it today, but when it was baked, IOI who smelle...
[{"type": "stdin_stdout", "input": "5\n-1\n3\n2\n132\n24", "output": "134\n"}, {"type": "stdin_stdout", "input": "5\n2\n27\n-1\n12\n87", "output": "113\n"}, {"type": "stdin_stdout", "input": "5\n2\n27\n-1\n12\n88", "output": "114\n"}, {"type": "stdin_stdout", "input": "5\n-1\n6\n2\n101\n27", "output": "106\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are many caves deep in mountains found in the countryside. In legend, each cave has a treasure hidden within the farthest room from the cave's entrance. The Shogun has ordered his Samurais to explore these caves wit...
[{"type": "stdin_stdout", "input": "3\n1 0\n0 1\n-2 0\n1 0\n0 8\n-1 0\n0 -1\n5 0\n0 1\n0 -4\n1 0\n0 -5\n-3 0\n0 3\n2 0\n-1 -1\n-2 1\n0 1\n0 -1\n1 0\n0 2\n-2 -1\n0 -3\n3 1\n-1 0\n-4 0\n0 0\n-2 0\n1 0\n0 0\n-3 0\n0 0\n2 0\n0 1\n-1 0\n-1 1\n-1 0\n0 -2\n0 0", "output": "4 9\n-2 0\n-3 0\n"}, {"type": "stdin_stdout", "input"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the year 2020, a race of atomically energized cars will be held. Unlike today’s car races, fueling is not a concern of racing teams. Cars can run throughout the course without any refueling. Instead, the critical facto...
[{"type": "stdin_stdout", "input": "2\n2 3\n1.1946563976133233\n1 2.557093764182385 0.48719322387595776 0.3\n5\n5 6 15 20 25\n0.15\n1 1.0 0.04 1.0346326402545585\n10\n1783 3640 3991 4623 5465 5481 6369 6533 6865 8425\n5.110816362691462\n72 59.4705 0.6319554453888588 0.12728810127294996\n0", "output": "1.317231571615\n-...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFair Chocolate-Cutting\n\nYou are given a flat piece of chocolate of convex polygon shape. You are to cut it into two pieces of precisely the same amount with a straight knife.\n\nWrite a program that computes, for a give...
[{"type": "stdin_stdout", "input": "4\n0 0\n10 0\n14 10\n-1 10", "output": "10.0000000000\n16.4359024361\n"}, {"type": "stdin_stdout", "input": "4\n0 0\n10 0\n14 10\n0 10", "output": "10.0000000000\n16.4155227683\n"}, {"type": "stdin_stdout", "input": "4\n0 0\n10 0\n14 10\n0 19", "output": "12.9141922507\n21.3018147823...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBoolean Expression Compressor\n\nYou are asked to build a compressor for Boolean expressions that transforms expressions to the shortest form keeping their meaning.\n\nThe grammar of the Boolean expressions has terminals ...
[{"type": "stdin_stdout", "input": "0\n(a*(0*b))\n(1^a)\n(-(-a*-b)*a)\n(a^(b^(c^d)))\n.", "output": "1\n1\n2\n1\n13\n"}, {"type": "stdin_stdout", "input": "0\n(a*(1*b))\n(1^b)\n(-(-a*-b)*a)\n(a^(b^(c^d)))\n.", "output": "1\n5\n2\n1\n13\n"}, {"type": "stdin_stdout", "input": "0\n(a*(1*b))\n(0^a)\n(-(-b*-c)*a)\nca^(b^((^...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIkta has an extraordinary feeling for undirected graphs. Ikta likes the undirected graph G and its two-point s, t pair (G, s, t) that has the greatest \"beauty\". The \"beauty\" of a pair (G, s, t) is the edge e = \\\\ {u...
[{"type": "stdin_stdout", "input": "9 8 7 8\n2 6\n4 9\n8 6\n9 2\n3 8\n2 8\n8 5\n7 9", "output": "5\n"}, {"type": "stdin_stdout", "input": "9 8 7 8\n2 6\n4 9\n8 6\n9 2\n3 8\n2 8\n8 5\n7 4", "output": "6\n"}, {"type": "stdin_stdout", "input": "9 8 7 8\n2 6\n4 9\n8 6\n9 2\n3 8\n1 8\n4 1\n7 9", "output": "7\n"}, {"type": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA: Isono, let's do that! --Sendame -\n\nstory\n\nNakajima \"Isono ~, let's do that!\"\n\nIsono \"What is that, Nakajima\"\n\nNakajima \"Look, that's that. It's hard to explain because I have to express it in letters for s...
[{"type": "stdin_stdout", "input": "3\ntameru\ntameru\nuremat\ntameru\nkougekida\ntameru", "output": "Nakajima-kun\n"}, {"type": "stdin_stdout", "input": "3\ntameru\ntameru\nuremat\ntameru\nadikeguok\ntameru", "output": "Hikiwake-kun\n"}, {"type": "stdin_stdout", "input": "3\ntameru\ntameru\nuremat\ntameru\nadikeguok\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPrint all subsets of a set $S$, which contains $0, 1, ... n-1$ as elements. Note that we represent $0, 1, ... n-1$ as 00...0001, 00...0010, 00...0100, ..., 10...0000 in binary respectively and the integer representation o...
[{"type": "stdin_stdout", "input": "8", "output": "0:\n1: 0\n2: 1\n3: 0 1\n4: 2\n5: 0 2\n6: 1 2\n7: 0 1 2\n8: 3\n9: 0 3\n10: 1 3\n11: 0 1 3\n12: 2 3\n13: 0 2 3\n14: 1 2 3\n15: 0 1 2 3\n16: 4\n17: 0 4\n18: 1 4\n19: 0 1 4\n20: 2 4\n21: 0 2 4\n22: 1 2 4\n23: 0 1 2 4\n24: 3 4\n25: 0 3 4\n26: 1 3 4\n27: 0 1 3 4\n28: 2 3 4\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAsmany strings are strings of '0's and '1's that have as many 00 as 11. A string such as 00110001 consists of 3 \"00\" and\n1 \"11\". Of course this is not an Asmany string. 0011, 1100, 000111000111 are Asmany strings. An...
[{"type": "stdin_stdout", "input": "2\n12\n12", "output": "YES\nYES\n"}, {"type": "stdin_stdout", "input": "2\n12\n4", "output": "YES\nYES\n"}, {"type": "stdin_stdout", "input": "2\n18\n12", "output": "NO\nYES\n"}, {"type": "stdin_stdout", "input": "2\n12\n6", "output": "YES\nYES\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's start from some definitions.\n\nStrings A and B are called anagrams if it's possible to rearrange the letters of string A using all the original letters exactly once and achieve string B; in other words A and B are ...
[{"type": "stdin_stdout", "input": "3\nmpei\nelepgaot\nitco", "output": "no such string\n"}, {"type": "stdin_stdout", "input": "3\nmpei\nglepeaot\nitco", "output": "no such string\n"}, {"type": "stdin_stdout", "input": "3\niepm\nglepeaot\nitco", "output": "no such string\n"}, {"type": "stdin_stdout", "input": "3\niepm\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBob and Alice are often participating in various programming competitions. Like many competitive programmers, Alice and Bob have good and bad days. They noticed, that their lucky and unlucky days are repeating with some p...
[{"type": "stdin_stdout", "input": "372839920 992839201 1000000000\n100293021 1262614379 999999993\n", "output": "619999282\n"}, {"type": "stdin_stdout", "input": "372839920 992839201 1000000000\n100293021 773829394 999999993\n", "output": "619999282\n"}, {"type": "stdin_stdout", "input": "111111111 888888889 164509949...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMiyako came to the flea kingdom with a ukulele. She became good friends with local flea residents and played beautiful music for them every day.\n\nIn return, the fleas made a bigger ukulele for her: it has n strings, and...
[{"type": "stdin_stdout", "input": "10\n13 18 10 3 9 19 20 4 10 5\n20\n0 9\n5 11\n1 5\n1 16\n3 3\n0 7\n10 19\n14 20\n6 15\n11 12\n13 16\n11 13\n3 9\n7 10\n2 2\n10 11\n17 20\n17 18\n0 15\n0 6\n", "output": "27 24 22 33 9 25 27 24 27 13 20 17 24 20 9 13 20 13 33 24\n"}, {"type": "stdin_stdout", "input": "10\n13 18 10 3 9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice has a string s. She really likes the letter \"a\". She calls a string good if strictly more than half of the characters in that string are \"a\"s. For example \"aaabb\", \"axaa\" are good strings, and \"baca\", \"aw...
[{"type": "stdin_stdout", "input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "50\n"}, {"type": "stdin_stdout", "input": "ababababababababababababababababababababababababav\n", "output": "49\n"}, {"type": "stdin_stdout", "input": "ababababababababababababababababababababbbabaaabav\n", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA telephone number is a sequence of exactly 11 digits, where the first digit is 8. For example, the sequence 80011223388 is a telephone number, but the sequences 70011223388 and 80000011223388 are not.\n\nYou are given a ...
[{"type": "stdin_stdout", "input": "2\n13\n7818005553535\n11\n31415926535\n", "output": "YES\nNO\n"}, {"type": "stdin_stdout", "input": "2\n13\n14222439333841\n11\n31415926535\n", "output": "NO\nNO\n"}, {"type": "stdin_stdout", "input": "2\n13\n3872943379171\n11\n45489461254\n", "output": "YES\nNO\n"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMislove had an array a_1, a_2, ⋅⋅⋅, a_n of n positive integers, but he has lost it. He only remembers the following facts about it:\n\n * The number of different numbers in the array is not less than l and is not greater...
[{"type": "stdin_stdout", "input": "1000 20 20\n", "output": "1049555 514850815\n"}, {"type": "stdin_stdout", "input": "114 18 19\n", "output": "262239 25427967\n"}, {"type": "stdin_stdout", "input": "879 17 17\n", "output": "131933 56623103\n"}, {"type": "stdin_stdout", "input": "1000 1 20\n", "output": "1000 51485081...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are working for the Gryzzl company, headquartered in Pawnee, Indiana.\n\nThe new national park has been opened near Pawnee recently and you are to implement a geolocation system, so people won't get lost. The concept ...
[{"type": "stdin_stdout", "input": "4\n0 0\n0 1\n1 0\n1 1\n2\n0 1 1 2\n2 5 5 8\n", "output": "4 0 0 0 1 1 0 1 1\n4 -1 -1 -1 2 2 -1 2 2\n"}, {"type": "stdin_stdout", "input": "4\n0 0\n0 1\n1 0\n1 1\n2\n0 1 1 2\n2 3 5 8\n", "output": "4 0 0 0 1 1 0 1 1 \n0 \n"}, {"type": "stdin_stdout", "input": "4\n-1 0\n0 1\n0 0\n1 1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBob is a competitive programmer. He wants to become red, and for that he needs a strict training regime. He went to the annual meeting of grandmasters and asked n of them how much effort they needed to reach red.\n\n\"Oh,...
[{"type": "stdin_stdout", "input": "15\n5318008\n379009\n06\n79153975193751375917591379919397337913333535330\n791539751937513759175913799193973379133301353533\n123456789023487138475693874561834576138495713485673485364857638475673465873457346581495713641\n7915397519375137511917591379919397337913333535330\n31553555535353...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside.\n\nThe text is a string s of lowercase Latin letters. She considers a...
[{"type": "stdin_stdout", "input": "abcdefghijklyyyyyyymnopqrstuvwxabcdefghijklyyyyyyymnopqrstuvwxabcdefghijklyyyyyyymnopqrstuvwxabcdefghijklyyyyyyymnopqrstuvwxabcdefghijklyyyyyyymnopqrstuvwxabcdefghijklzzzzzzzmnopqrstuvwxabcdefghijklzzzzzzzmnopqrstuvwxabcdefghijklzzzzzzzmnopqrstuvwxabcdefghijklzzzzzzzmnopqrstuvwxabcde...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor the multiset of positive integers s=\\\\{s_1,s_2,...,s_k\\}, define the Greatest Common Divisor (GCD) and Least Common Multiple (LCM) of s as follow:\n\n * \\gcd(s) is the maximum positive integer x, such that all in...
[{"type": "stdin_stdout", "input": "10\n972 972 324 972 324 648 1944 243 324 474\n", "output": "162\n"}, {"type": "stdin_stdout", "input": "10\n61 1677 535 769 324 1309 1589 243 324 184\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "10\n61 1677 535 769 627 1309 1589 243 324 184\n", "output": "1\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape o...
[{"type": "stdin_stdout", "input": "1\n1\n34\n- 1\n+ 1\n+ 1\n+ 1\n+ 1\n+ 1\n+ 1\n+ 1\n+ 1\n+ 1\n- 1\n- 1\n- 1\n- 1\n- 1\n+ 2\n+ 2\n+ 2\n+ 2\n- 1\n+ 2\n+ 2\n- 1\n+ 2\n- 1\n+ 3\n+ 3\n+ 1\n- 1\n- 2\n- 2\n- 2\n+ 1\n+ 3\n", "output": "NO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\nYE...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft k torches. One torch can be crafted using one stick and one coal.\n\nHopefully, you've met a very handsome wandering tr...
[{"type": "stdin_stdout", "input": "5\n2 1 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000\n", "output": "14\n33\n25\n2000000003\n1000000001999999999\n"}, {"type": "stdin_stdout", "input": "5\n2 2 5\n42 13 24\n12 11 12\n1000000000 1000000000 1000000000\n2 1000000000 1000000000\n", "outp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\...
[{"type": "stdin_stdout", "input": "20 7\n1 4 5 8 47 777777777 1 5 4 8 5 9 5 4 7 4 5 7 7 44474\n", "output": "29172\n"}, {"type": "stdin_stdout", "input": "20 7\n1 2 5 8 47 777777777 1 5 4 8 5 9 5 4 7 4 5 7 7 44474\n", "output": "39468\n"}, {"type": "stdin_stdout", "input": "13 5\n44 44 49 44 44 44 44 44 77 102 66 99 5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given n - 1 integers a_2, ..., a_n and a tree with n vertices rooted at vertex 1. The leaves are all at the same distance d from the root. \n\nRecall that a tree is a connected undirected graph without cycles. The...
[{"type": "stdin_stdout", "input": "4\n14\n1 1 1 2 3 4 4 5 5 6 7 8 8\n2 3 7 7 6 9 5 9 7 3 6 6 5\n6\n1 2 2 3 4\n32 54 124 5 41\n15\n1 15 1 10 4 9 11 2 4 1 8 6 10 11\n62 13 12 43 39 65 42 86 25 38 19 19 43 62\n15\n11 2 7 6 9 8 10 1 1 1 5 3 15 2\n50 19 30 35 9 45 13 24 8 44 20 26 10 40\n", "output": "14\n106\n163\n123\n"}...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOmkar has received a message from Anton saying \"Your story for problem A is confusing. Just make a formal statement.\" Because of this, Omkar gives you an array a = [a_1, a_2, …, a_n] of n distinct integers. An array b =...
[{"type": "stdin_stdout", "input": "40\n2\n18 79\n3\n-95 0 95\n2\n92 85\n2\n10 22\n3\n39 66 11\n3\n99 39 87\n2\n48 46\n2\n56 2\n3\n73 76 -11\n3\n14 -34 49\n3\n83 31 10\n3\n97 28 -143\n2\n-19 -99\n3\n64 25 95\n3\n56 21 14\n2\n61 75\n2\n95 21\n2\n78 72\n2\n-111 99\n3\n9 55 -54\n2\n16 -48\n3\n84 45 76\n2\n23 78\n3\n86 90 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSensation, sensation in the two-dimensional kingdom! The police have caught a highly dangerous outlaw, member of the notorious \"Pihters\" gang. The law department states that the outlaw was driving from the gang's headqu...
[{"type": "stdin_stdout", "input": "10\nUR\nDR\nUL\nDR\nUL\nULDR\nUR\nUL\nULDR\nUL\n", "output": "45\n"}, {"type": "stdin_stdout", "input": "10\nUL\nUL\nUL\nUL\nUL\nUL\nUL\nUL\nUL\nUL\n", "output": "11\n"}, {"type": "stdin_stdout", "input": "10\nUL\nUR\nUR\nDR\nDR\nDR\nDL\nDL\nDL\nDL\n", "output": "35\n"}, {"type": "st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.\n\nYou are given an...
[{"type": "stdin_stdout", "input": "22\n1 2 3 4 5 6 7 13 14 10 12752041 64 121 144 55063932582 124 42550 23756 135153365 25235235235 42351351 81\n", "output": "NO \nNO \nNO \nYES\nNO \nNO \nNO \nNO \nNO \nNO \nYES\nNO \nYES\nNO \nNO \nNO \nNO \nNO \nNO \nNO \nNO \nNO \n"}, {"type": "stdin_stdout", "input": "22\n1 2 3 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGena loves sequences of numbers. Recently, he has discovered a new type of sequences which he called an almost arithmetical progression. A sequence is an almost arithmetical progression, if its elements can be represented...
[{"type": "stdin_stdout", "input": "73\n531 626 701 57 708 511 54 441 297 697 411 253 397 652 21 59 851 561 539 461 629 894 275 417 127 960 433 243 963 247 5 368 969 541 408 485 319 117 441 131 265 357 1 659 267 983 643 285 913 782 813 569 99 781 297 636 645 341 6 17 601 129 509 197 226 105 241 737 86 128 762 647 849\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n«Polygon» is a system which allows to create programming tasks in a simple and professional way. When you add a test to the problem, the corresponding form asks you for the test index. As in most cases it is clear which i...
[{"type": "stdin_stdout", "input": "10\n1 7 13 6 10 10 3 8 2 4\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "10\n1 7 13 6 10 10 4 8 2 4\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "10\n1 7 13 6 10 10 4 8 2 8\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "10\n1 7 13 6 5 10 3 8 2 4\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are an adventurer currently journeying inside an evil temple. After defeating a couple of weak zombies, you arrived at a square room consisting of tiles forming an n × n grid. The rows are numbered 1 through n from to...
[{"type": "stdin_stdout", "input": "17\n.EEEEE...EEEE..EE\nEEE..E...EEEEE..E\n.E..E..EEE.EE...E\n.EEE.EE..EE...E..\nE..EEEEEE.EE.....\nE.EE...EEEEEEE.E.\nEEEE....EE..E.EEE\n...EEEEE.E..EE...\nEEE.E..EEEE.EEE..\n..E.E....EEE.....\nEE..E..E.E..EEEEE\nEEE..E.EEEEE.E...\n..EEEEE.E..EE.EE.\nEE.E...E..E..E.EE\n..E.EEE.EE..EE...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n cities in Berland. Each city has its index — an integer number from 1 to n. The capital has index r1. All the roads in Berland are two-way. The road system is such that there is exactly one path from the capit...
[{"type": "stdin_stdout", "input": "100 62 42\n45 66 13 18 93 47 83 19 41 66 5 70 16 29 54 28 65 91 92 24 90 54 7 40 77 53 68 58 70 65 68 30 94 80 16 18 69 21 94 1 99 61 97 2 69 15 79 38 61 46 88 32 57 84 35 18 17 77 38 91 84 2 53 54 68 19 13 78 62 16 63 17 76 49 28 45 94 13 35 69 37 56 12 41 95 70 57 24 45 84 87 65 14...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's assume that \n\n * v(n) is the largest prime number, that does not exceed n;\n * u(n) is the smallest prime number strictly greater than n. \n\n\n\nFind <image>.\n\nInput\n\nThe first line contains integer t (1 ≤ ...
[{"type": "stdin_stdout", "input": "6\n885\n419\n821\n635\n63\n480\n", "output": "781453/1566442\n175559/352798\n674039/1351366\n403199/808942\n3959/8174\n232303/466546\n"}, {"type": "stdin_stdout", "input": "6\n1656\n419\n821\n635\n63\n480\n", "output": "1655/3314\n175559/352798\n674039/1351366\n403199/808942\n3959/81...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhile resting on the ship after the \"Russian Code Cup\" a boy named Misha invented an interesting game. He promised to give his quadrocopter to whoever will be the first one to make a rectangular table of size n × m, con...
[{"type": "stdin_stdout", "input": "100 100\n", "output": "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 49 \n\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDZY loves chessboard, and he enjoys playing with it.\n\nHe has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a chessman on it. Each ches...
[{"type": "stdin_stdout", "input": "8 35\n......................-............\n...-..........-........-...........\n...........-.......................\n-..................................\n...................................\n...........-............-.........-\n.........-.........-.--............\n......................
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter you had helped George and Alex to move in the dorm, they went to help their friend Fedor play a new computer game «Call of Soldiers 3».\n\nThe game has (m + 1) players and n types of soldiers in total. Players «Call...
[{"type": "stdin_stdout", "input": "13 27 7\n1893\n370\n7320\n5753\n4418\n2146\n2702\n5013\n5959\n1929\n7611\n7013\n540\n3454\n4271\n2887\n4724\n3520\n2111\n5845\n1868\n7659\n3040\n3775\n6507\n4917\n7506\n2515\n", "output": "20\n"}, {"type": "stdin_stdout", "input": "13 27 7\n1893\n370\n7320\n5753\n4418\n2146\n2702\n50...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBerland has n cities, the capital is located in city s, and the historic home town of the President is in city t (s ≠ t). The cities are connected by one-way roads, the travel time for each of the road is a positive integ...
[{"type": "stdin_stdout", "input": "2 9 1 2\n1 2 1000000\n1 2 1000000\n1 2 1100000\n1 2 1000000\n1 2 2\n1 2 1000000\n1 2 1000000\n1 2 1000000\n1 2 1000000\n", "output": "CAN 999999\nCAN 999999\nCAN 1099999\nCAN 999999\nYES\nCAN 999999\nCAN 999999\nCAN 999999\nCAN 999999\n"}, {"type": "stdin_stdout", "input": "2 9 1 2\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Department of economic development of IT City created a model of city development till year 2100.\n\nTo prepare report about growth perspectives it is required to get growth estimates from the model.\n\nTo get the gro...
[{"type": "stdin_stdout", "input": "-1678 -814 10\n", "output": "0.011988724652885814\n-0.49709003573751037\n"}, {"type": "stdin_stdout", "input": "1000 1000 -1322\n", "output": "0.7537942414925983\n-1.7537942414925982\n"}, {"type": "stdin_stdout", "input": "1000 1000 -2375\n", "output": "1.1201851746019649\n-2.1201851...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.\n\nThe gi...
[{"type": "stdin_stdout", "input": "39\n100 110 92 26 10 63 56 85 14 64 25 50 75 51 11 41 78 53 52 96 63 12 48 88 57 57 25 52 69 45 4 97 5 87 58 15 72 59 100\n35 -60\n33 -39\n1 65\n11 -65\n34 -63\n38 84\n4 76\n22 -9\n4 -91\n23 -65\n18 7\n2 -17\n29 -15\n19 26\n29 23\n14 -12\n30 -72\n9 14\n12 -1\n27 -21\n32 -67\n7 -3\n26...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCaptain Bill the Hummingbird and his crew recieved an interesting challenge offer. Some stranger gave them a map, potion of teleportation and said that only this potion might help them to reach the treasure. \n\nBottle wi...
[{"type": "stdin_stdout", "input": "-100000 -100000 100000 100000\n100000 100000\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "-100000 -100000 100000 100000\n100000 101000\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "-100000 -100000 100000 110000\n100000 101000\n", "output": "NO\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKirill plays a new computer game. He came to the potion store where he can buy any potion. Each potion is characterized by two integers — amount of experience and cost. The efficiency of a potion is the ratio of the amoun...
[{"type": "stdin_stdout", "input": "6134912 6134912 10000000 10000000 999869\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "9222174 9829060 9418763 14615160 9092468\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "6134912 8670745 10000000 10000000 999869\n", "output": "NO\n"}, {"type": "stdin_stdout...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string. \n\nString t is called a palindrome, if it reads the same from left to right and from right t...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1000010000\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "999999999\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "213443120\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "153882...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a consisting of n integers, and additionally an integer m. You have to choose some sequence of indices b1, b2, ..., bk (1 ≤ b1 < b2 < ... < bk ≤ n) in such a way that the value of <image> is maximiz...
[{"type": "stdin_stdout", "input": "35 1001000000\n723631245 190720106 931659134 503095294 874181352 712517040 800614682 904895364 256863800 39366772 763190862 770183843 774794919 55669976 329106527 513566505 207828535 258356470 816288168 657823769 5223226 1556305467 655737365 278677545 880429272 718852999 810522025 22...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMishka is decorating the Christmas tree. He has got three garlands, and all of them will be put on the tree. After that Mishka will switch these garlands on.\n\nWhen a garland is switched on, it periodically changes its s...
[{"type": "stdin_stdout", "input": "1500 1500 1500\n", "output": "NO"}, {"type": "stdin_stdout", "input": "1499 1498 1500\n", "output": "NO"}, {"type": "stdin_stdout", "input": "1493 1489 1487\n", "output": "NO"}, {"type": "stdin_stdout", "input": "992 1498 1500\n", "output": "No\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA dragon symbolizes wisdom, power and wealth. On Lunar New Year's Day, people model a dragon with bamboo strips and clothes, raise them with rods, and hold the rods high and low to resemble a flying dragon.\n\nA performer...
[{"type": "stdin_stdout", "input": "200\n2 1 1 2 1 2 2 2 2 2 1 2 2 1 1 2 2 1 1 1 2 1 1 2 2 2 2 2 1 1 2 1 2 1 1 2 1 1 1 1 2 1 2 2 1 2 1 1 1 2 1 1 1 2 2 2 1 1 1 1 2 2 2 1 2 2 2 1 2 2 2 1 2 1 2 1 2 1 1 1 1 2 2 2 1 1 2 1 2 1 2 1 2 2 1 1 1 2 2 2 2 1 2 2 2 1 1 1 1 2 1 1 1 2 2 1 2 1 2 2 2 1 2 1 2 1 2 1 2 2 2 1 2 2 2 1 1 1 1 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya loves volleyball very much. One day he was running late for a volleyball match. Petya hasn't bought his own car yet, that's why he had to take a taxi. The city has n junctions, some of which are connected by two-way...
[{"type": "stdin_stdout", "input": "15 29\n6 6\n7 12 7\n11 3 7\n4 5 18\n13 9 18\n3 8 12\n6 1 7\n4 1 4\n12 5 18\n10 8 15\n2 10 1\n9 7 11\n2 4 10\n2 14 3\n15 12 14\n1 13 8\n11 4 1\n15 11 2\n1 5 9\n5 2 5\n9 10 5\n15 2 17\n11 5 1\n14 15 14\n10 1 16\n15 9 2\n13 15 6\n13 5 1\n7 12 6\n12 5 13\n8 26\n35 17\n16 14\n12 13\n21 1\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou took a peek on Thanos wearing Infinity Gauntlet. In the Gauntlet there is a place for six Infinity Gems:\n\n * the Power Gem of purple color, \n * the Time Gem of green color, \n * the Space Gem of blue color, \n ...
[{"type": "stdin_stdout", "input": "4\ngreen\nyellow\norange\npurple\n", "output": "2\nSpace\nReality\n"}, {"type": "stdin_stdout", "input": "4\ngreen\nyellow\norange\npurple\n", "output": "2\nSpace\nReality\n"}, {"type": "stdin_stdout", "input": "3\norange\nyellow\ngreen\n", "output": "3\nPower\nSpace\nReality\n"}, {"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLily Aldrin, as the slap bet commissioner, needs to resolve issues regarding slap bets due with Barney and Marshall. She has mandated that there be a fixed period of time in which the slaps may be used.\n\nSo, she draws ...
[{"type": "stdin_stdout", "input": "3\n3 1 0 7\n-1 2 -3 7\n-1 0 0 16\n\nSBMLPD", "output": "Nothing\nNothing\nPoint\n"}, {"type": "stdin_stdout", "input": "3\n-1 1 8 0\n2 3 1 5\n1 2 1 6\n\nAPMSLE", "output": "Nothing\nNothing\nNothing\n"}, {"type": "stdin_stdout", "input": "3\n-1 -1 7 5\n1 2 -1 13\n1 2 0 3\n\nSAMPLE", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDG (Departmental Gathering) is coming….\n\nAs one of the most famous girls in the college everybody is smitten with Harshada and wants to give \n\nher roses. But Harshada is only into coders , therefore she sends out word...
[{"type": "stdin_stdout", "input": "3\n1\n16\n20\n\nEPKNCT", "output": "1\n139202068568601568785946949658348\n375476495794069216556083980357827284230304438004757733143079647458896478567196763060223492177681649114455351865758513944997504748\n"}, {"type": "stdin_stdout", "input": "3\n1\n19\n12\n\nEKRNCS", "output": "1\n3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem :\n\nThe Starks(S),Lannisters(L) and the Baratheons(B) are fighting for the\nIron Throne. These three houses are fighting from ages to capture the\nthrone.\n\nThe N th battle goes on for N days before a winner\nem...
[{"type": "stdin_stdout", "input": "2421\n30818\n4399\n6718\n14365\n22792\n21922\n5364\n32273\n14894\n6502\n4931\n10384\n17321\n30287\n21441\n6061\n16849\n413\n26555\n25679\n17277\n16932\n24777\n10107\n21551\n20906\n31910\n18134\n9867\n11665\n17215\n27237\n17166\n31414\n19210\n32664\n3836\n16536\n6041\n28039\n16282\n24...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKaran has decided to give stickers to all the attendees of the last day of Google Week. The stickers will be given such that the last person to enter the hall gets a single sticker. The second last person entering the hal...
[{"type": "stdin_stdout", "input": "2\n-1\n153", "output": "0\n11781\n"}, {"type": "stdin_stdout", "input": "2\n-1\n145", "output": "0\n10585\n"}, {"type": "stdin_stdout", "input": "2\n4\n48", "output": "10\n1176\n"}, {"type": "stdin_stdout", "input": "2\n4\n82", "output": "10\n3403\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have N strings of lowercase English letters: S_1, S_2, \\cdots, S_N.\n\nTakahashi wants to make a string that is a palindrome by choosing one or more of these strings - the same string can be chosen more than once - an...
[{"type": "stdin_stdout", "input": "4\nba 5\ncba 3\na 12\nab 10", "output": "12\n"}, {"type": "stdin_stdout", "input": "4\nba 2\ncba 5\nb 21\nba 10", "output": "21\n"}, {"type": "stdin_stdout", "input": "4\nba 2\ncba 5\nb 19\nba 18", "output": "19\n"}, {"type": "stdin_stdout", "input": "4\nba 1\ncba 3\nb 15\nba 24", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have held a popularity poll for N items on sale. Item i received A_i votes.\n\nFrom these N items, we will select M as popular items. However, we cannot select an item with less than \\dfrac{1}{4M} of the total number ...
[{"type": "stdin_stdout", "input": "12 3\n4 56 78 901 2 345 67 1556 123 45 6 789", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "12 3\n4 56 78 104 2 345 67 1145 123 45 3 789", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "12 3\n4 56 78 104 2 345 23 1145 123 45 3 789", "output": "Yes\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an odd number.\n\nBetween these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \\leq i \\l...
[{"type": "stdin_stdout", "input": "3\n0000000000 1010000000 0", "output": "-1010000000 1010000000 1010000000\n"}, {"type": "stdin_stdout", "input": "3\n0000000000 1110000000 0", "output": "-1110000000 1110000000 1110000000\n"}, {"type": "stdin_stdout", "input": "3\n0000000000 1110000010 0", "output": "-1110000010 1110...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given integers N and K. Find the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K. The order of a,b,c does matter, and some of them can be the same...
[{"type": "stdin_stdout", "input": "150607 162", "output": "1606122089\n"}, {"type": "stdin_stdout", "input": "101525 92", "output": "2687492591\n"}, {"type": "stdin_stdout", "input": "101525 162", "output": "491806259\n"}, {"type": "stdin_stdout", "input": "35897 92", "output": "118638000\n"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j).\n\nThe integers from 1 through H×W are written throughout the grid, and the integer written in Square (...
[{"type": "stdin_stdout", "input": "5 5 4\n13 25 7 15 17\n16 22 20 2 9\n14 11 12 1 19\n10 6 23 8 18\n3 21 5 24 4\n3\n13 13\n0 10\n13 13", "output": "0\n5\n0\n"}, {"type": "stdin_stdout", "input": "5 5 7\n13 25 7 15 17\n16 22 20 2 9\n14 11 12 1 19\n10 6 23 8 18\n3 21 5 24 4\n3\n13 13\n0 10\n13 13", "output": "0\n1\n0\n"...
code_stdio