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\nVova decided to clean his room. The room can be represented as the coordinate axis OX. There are n piles of trash in the room, coordinate of the i-th pile is the integer p_i. All piles have different coordinates.\n\nLet's...
[{"type": "stdin_stdout", "input": "5 8\n5 1 2 4 3\n0 1\n0 2\n0 3\n0 4\n0 5\n1 1000000000\n1 1\n1 500000000\n", "output": "3\n2\n1\n0\n0\n0\n0\n0\n499999999\n"}, {"type": "stdin_stdout", "input": "5 4\n5 1 2 4 3\n0 1\n0 2\n0 3\n0 4\n0 5\n1 1000000000\n1 1\n1 500000000\n", "output": "3\n2\n1\n0\n0\n"}, {"type": "stdin_s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAndrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find ...
[{"type": "stdin_stdout", "input": "1000 1000 999\n", "output": "756641425"}, {"type": "stdin_stdout", "input": "1000 501 347\n", "output": "385628187\n"}, {"type": "stdin_stdout", "input": "1000 500 671\n", "output": "385628187\n"}, {"type": "stdin_stdout", "input": "1000 888 888\n", "output": "644649893"}, {"type": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou and your friends live in n houses. Each house is located on a 2D plane, in a point with integer coordinates. There might be different houses located in the same point. The mayor of the city is asking you for places fo...
[{"type": "stdin_stdout", "input": "2\n2\n0 0\n1000000000 1000000000\n4\n0 1000000000\n0 0\n1000000000 1000000000\n1000000000 0\n", "output": "1000000002000000001\n1000000002000000001\n"}, {"type": "stdin_stdout", "input": "2\n2\n0 1\n1000000000 1000000000\n4\n0 1000000000\n0 0\n1000000000 1000000000\n1000000000 0\n", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt is well known that Berland has n cities, which form the Silver ring β€” cities i and i + 1 (1 ≀ i < n) are connected by a road, as well as the cities n and 1. The goverment have decided to build m new roads. The list of ...
[{"type": "stdin_stdout", "input": "100 50\n79 24\n65 69\n44 6\n49 53\n26 22\n24 76\n10 2\n19 44\n44 10\n87 82\n91 87\n23 92\n69 66\n95 30\n90 24\n95 20\n76 36\n82 24\n63 80\n70 72\n34 76\n42 40\n17 100\n66 64\n85 96\n34 30\n36 69\n45 56\n36 62\n26 38\n31 28\n79 64\n78 69\n41 62\n36 40\n64 67\n21 13\n90 88\n28 30\n59 6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYaroslav has an array, consisting of (2Β·n - 1) integers. In a single operation Yaroslav can change the sign of exactly n elements in the array. In other words, in one operation Yaroslav can select exactly n array elements...
[{"type": "stdin_stdout", "input": "56\n-157 136 457 598 -138 -586 -338 752 -566 -718 -333 -965 309 -125 -938 -188 -390 17 -75 -902 -320 163 820 -970 -525 -329 81 488 -412 978 138 344 305 -358 -273 -967 253 -665 -245 187 602 252 -825 -511 828 764 -402 278 995 541 542 549 612 -536 527 -884 225 800 160 -409 -926 -795 -32...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nValera's finally decided to go on holiday! He packed up and headed for a ski resort.\n\nValera's fancied a ski trip but he soon realized that he could get lost in this new place. Somebody gave him a useful hint: the resor...
[{"type": "stdin_stdout", "input": "100\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 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 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n38 2 49 55 6 42 12 100 25 69 85 76 13 22 78 73 37 64 5 21 0 23 61 87 4 16 44 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nInna and Dima bought a table of size n Γ— m in the shop. Each cell of the table contains a single letter: \"D\", \"I\", \"M\", \"A\".\n\nInna loves Dima, so she wants to go through his name as many times as possible as she...
[{"type": "stdin_stdout", "input": "14 34\nDDDDDDDDDDDDIMADDDDDDDDDDDDDDDIMAD\nDDDDDDIMADDDDDDDDDDDDDDDDDDDDDIMAD\nDDDDDDDDDDDDDIDDDDDDDDDDDIDIMIDIMA\nDDDDDDIMDDDDDDDDDDDDDIDDDDDDDDDDDD\nDDDDDDDDDDDDDDDDDMADDDDDDDDDDDDDMD\nDDDDDDIMIDDDDDDDDDDDDIMIDIMIDDDIDD\nDDDDDDDDDDDDDDDDDMIMDDDDIMDDIMADIM\nDDDDDDDDDDDADIMADIDDDDDDI...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little: it is spelled (an...
[{"type": "stdin_stdout", "input": "vxpqullmcbegsdskddortcvxyqlbvxmmkhevovnezubvpvnrcajpxraeaxizgaowtfkzywvhnbgzsxbhkaipcmoumtikkiyyaivg\ngviayyikkitmuomcpiakhbxszgbnhvwyzkftwoagzixaearxpjacrnvpvbuzenvovehkmmxvblqyxvctroddksdsgebcmlluqpxv\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "dgxmzbqofstzcdgthbaewb...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nScrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock.\n\n<image>\n\nThe combinatio...
[{"type": "stdin_stdout", "input": "125\n23269567683904664184142384849516523616863461607751021071772615078579713054027902974007001544768640273491193035874486891541257\n47635110303703399505805044019026243695451609639556649012447370081552870340011971572363458960190590266459684717415349529509024\n", "output": "305\n"}, {"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Johnny has recently learned about set theory. Now he is studying binary relations. You've probably heard the term \"equivalence relation\". These relations are very important in many areas of mathematics. For examp...
[{"type": "stdin_stdout", "input": "3000\n", "output": "949793998\n"}, {"type": "stdin_stdout", "input": "3789\n", "output": "397160465\n"}, {"type": "stdin_stdout", "input": "2999\n", "output": "634360769\n"}, {"type": "stdin_stdout", "input": "1234\n", "output": "845807965\n"}, {"type": "stdin_stdout", "input": "3999...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe year 2015 is almost over.\n\nLimak is a little polar bear. He has recently learnt about the binary system. He noticed that the passing year has exactly one zero in its representation in the binary system β€” 201510 = 11...
[{"type": "stdin_stdout", "input": "500000000000000000 1000000000000000000\n", "output": "58\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "500000000000000000 1000000010000000000\n", "output": "58\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIT City administration has no rest because of the fame of the Pyramids in Egypt. There is a project of construction of pyramid complex near the city in the place called Emerald Walley. The distinction of the complex is th...
[{"type": "stdin_stdout", "input": "1000 1000 0000\n", "output": "353553390.59327376\n"}, {"type": "stdin_stdout", "input": "1000 1000 1000\n", "output": "655056222.9890983\n"}, {"type": "stdin_stdout", "input": "1071 524 357\n", "output": "192408357.83681697\n"}, {"type": "stdin_stdout", "input": "1137 328 550\n", "ou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asleep during history lessons, and his magical quill writes the lectures for him. Professo...
[{"type": "stdin_stdout", "input": "50\n1230\n6040\n1035\n1973\n9096\n5133\n1146\n1164\n9195\n5211\n6212\n1313\n1953\n1560\n1382\n2324\n1343\n1481\n1555\n1363\n1487\n1414\n1525\n1564\n1561\n9585\n7590\n1663\n5625\n1630\n1630\n3644\n1164\n1665\n7678\n1282\n1626\n1798\n9755\n7801\n8809\n1762\n1867\n1861\n1826\n1809\n8902...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTheater stage is a rectangular field of size n Γ— m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cell or not.\n\nYou are to pla...
[{"type": "stdin_stdout", "input": "10 20\n0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 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\nThere are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote.\n\nEach of the employees belong...
[{"type": "stdin_stdout", "input": "100\nRRDRRDDDDDDDRDRRRDRDRDDDRDDDRDDRDRRDRRRDRRDRRRRRRRDRRRRRRDDDRRDDRRRDRRRDDRRDRRDDDDDRRDRDDRDDRRRDRRDD\n", "output": "R\n"}, {"type": "stdin_stdout", "input": "100\nRDRRDRDDDDRDRRDDRDRRDDRRDDRRRDRRRDDDRDDRDDRRDRDRRRDRDRRRDRRDDDRDDRRRDRDRRRDDRDRDDDDDDDRDRRDDDDDDRRDD\n", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a convex polygon P with n distinct vertices p1, p2, ..., pn. Vertex pi has coordinates (xi, yi) in the 2D plane. These vertices are listed in clockwise order.\n\nYou can choose a real number D and move each ...
[{"type": "stdin_stdout", "input": "19\n449447997 711296339\n530233434 692216537\n535464528 613140435\n535533467 100893188\n530498867 -265063956\n519107979 -271820709\n482156929 -287792333\n-303730271 -287970295\n-416935204 -263348201\n-443613873 -249980523\n-453444829 -173903413\n-462102798 -80789280\n-462064673 -1322...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given sequence a1, a2, ..., an of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subseq...
[{"type": "stdin_stdout", "input": "59\n8593 5929 3016 -859 4366 -6842 8435 -3910 -2458 -8503 -3612 -9793 -5360 -9791 -362 -7180 727 -6245 -8869 -7316 8214 -7944 7098 3788 -5436 -6626 -1131 -2410 -5647 -7981 263 -5879 8786 709 6489 5316 -4039 4909 -4340 7979 -89 9844 -906 172 -7674 -3371 -6828 9505 3284 5895 3646 6680 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a consisting of n elements. The imbalance value of some subsegment of this array is the difference between the maximum and minimum element from this segment. The imbalance value of the array is the ...
[{"type": "stdin_stdout", "input": "100\n9 9 72 55 14 7 55 58 35 104 3 18 73 92 41 49 15 60 18 66 9 26 97 47 43 88 71 97 19 34 48 96 79 53 8 24 69 49 12 23 77 12 21 88 66 9 29 13 61 69 54 77 41 13 4 68 37 74 7 6 29 76 55 72 89 4 78 27 29 82 18 83 12 4 32 69 89 100 66 13 92 54 38 5 42 56 17 55 29 4 17 39 29 94 3 67 85 9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday at the lesson Vitya learned a very interesting function β€” mex. Mex of a sequence of numbers is the minimum non-negative number that is not present in the sequence as element. For example, mex([4, 33, 0, 1, 1, 5]) = ...
[{"type": "stdin_stdout", "input": "17 30\n4194 1990 2257 1363 2798 386 3311 3152 1808 1453 3874 4388 1268 3924 3799 1269 968\n11\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n0\n8\n8\n8\n8\n8\n8\n8\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a of size n, and q queries to it. There are queries of two types: \n\n * 1 li ri β€” perform a cyclic shift of the segment [li, ri] to the right. That is, for every x such that li ≀ x < ri new value ...
[{"type": "stdin_stdout", "input": "6 3 5\n1 2 3 4 10 6\n2 1 3\n2 3 6\n1 1 6\n2 2 1 5 3\n", "output": "3 3 1 10 2\n"}, {"type": "stdin_stdout", "input": "6 3 5\n1 2 3 4 5 12\n2 1 3\n2 3 6\n1 1 6\n2 2 1 5 4\n", "output": "3 3 1 5 12\n"}, {"type": "stdin_stdout", "input": "6 3 5\n1 2 3 4 10 6\n2 2 3\n2 3 6\n1 1 6\n2 2 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.\n\nCatacombs consist of several rooms and bidirectional pa...
[{"type": "stdin_stdout", "input": "100\n0 0 0 0 0 0 1 4 4 0 2 2 4 1 7 1 11 0 8 4 12 12 3 0 3 2 2 4 3 9 1 5 4 6 9 14 6 2 4 18 7 7 19 11 20 13 17 16 0 34 2 6 12 27 9 4 29 22 4 20 20 17 17 20 37 53 17 3 3 15 1 46 11 24 31 6 12 6 11 18 13 1 5 0 19 10 24 41 16 41 18 52 46 39 16 30 18 23 53 13\n", "output": "66\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA has a string consisting of some number of lowercase English letters 'a'. He gives it to his friend B who appends some number of letters 'b' to the end of this string. Since both A and B like the characters 'a' and 'b', ...
[{"type": "stdin_stdout", "input": "aaaaabbbbbb\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "aaaaabbabbb\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "bbbabbaaaaa\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "aabbaacccc\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "cabba...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs we all know that power sets of any set are formed by taking i elements (where i is from 1 to n) and then random shuffling them like this power set of {1,2,3} are {EMPTY SET},{1},{2},{3},{1,2}{1,3}{2,3}{1,2,3} .\nNow w...
[{"type": "stdin_stdout", "input": "2\nabcde\nabc\n\nSAMPLE", "output": "15\n6\n"}, {"type": "stdin_stdout", "input": "2\nabcde\nabc\n\nSAMPEL", "output": "15\n6\n"}, {"type": "stdin_stdout", "input": "2\nabcdf\nacc\n\nASMPEL", "output": "15\n3\n"}, {"type": "stdin_stdout", "input": "2\nfdcca\n`dc\n\nASLPLD", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven are a sequence of N positive integers A_1, A_2, \\ldots, A_N, and a positive integer K.\n\nFind the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K...
[{"type": "stdin_stdout", "input": "10 3\n14 26 111 65 35 89 184 32 38 46", "output": "4\n"}, {"type": "stdin_stdout", "input": "10 11\n14 26 111 0 35 27 95 13 38 63", "output": "12\n"}, {"type": "stdin_stdout", "input": "10 13\n14 15 101 65 35 89 95 32 38 46", "output": "6\n"}, {"type": "stdin_stdout", "input": "10 7\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a permutation p = {p_1,\\ p_2,\\ ...,\\ p_n} of {1,\\ 2,\\ ...,\\ n}.\n\nPrint the number of elements p_i (1 < i < n) that satisfy the following condition:\n\n* p_i is the second smallest number among the three nu...
[{"type": "stdin_stdout", "input": "9\n14 18 0 2 5 14 11 4 -1", "output": "4\n"}, {"type": "stdin_stdout", "input": "9\n14 12 -1 2 5 26 7 4 -1", "output": "5\n"}, {"type": "stdin_stdout", "input": "9\n14 18 0 2 5 14 11 3 -1", "output": "4\n"}, {"type": "stdin_stdout", "input": "9\n14 12 3 2 5 14 7 4 -1", "output": "5\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDetermine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.\n\nConstraints\n\n* 1\\leq N,K\\leq 100\n* N and K are integers.\n\nInput\n\nInput is given from Standard Inp...
[{"type": "stdin_stdout", "input": "135 27", "output": "YES\n"}, {"type": "stdin_stdout", "input": "135 47", "output": "YES\n"}, {"type": "stdin_stdout", "input": "149 47", "output": "YES\n"}, {"type": "stdin_stdout", "input": "149 50", "output": "YES\n"}, {"type": "stdin_stdout", "input": "151 50", "output": "YES\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is an N-car train.\n\nYou are given an integer i. Find the value of j such that the following statement is true: \"the i-th car from the front of the train is the j-th car from the back.\"\n\nConstraints\n\n* 1 \\le...
[{"type": "stdin_stdout", "input": "-108 -1", "output": "-106\n"}, {"type": "stdin_stdout", "input": "-108 71", "output": "-178\n"}, {"type": "stdin_stdout", "input": "-159 71", "output": "-229\n"}, {"type": "stdin_stdout", "input": "-116 71", "output": "-186\n"}, {"type": "stdin_stdout", "input": "-74 36", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi has an N \\times M grid, with N horizontal rows and M vertical columns. Determine if we can place A 1 \\times 2 tiles (1 vertical, 2 horizontal) and B 2 \\times 1 tiles (2 vertical, 1 horizontal) satisfying the ...
[{"type": "stdin_stdout", "input": "44 6 13 3", "output": "YES\n^^^<>.\nvvv<>.\n<><><>\n<><><>\n<><><>\n<><>..\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke 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`...
[{"type": "stdin_stdout", "input": "001011", "output": "3\n"}, {"type": "stdin_stdout", "input": "100000", "output": "1\n"}, {"type": "stdin_stdout", "input": "011011", "output": "4\n"}, {"type": "stdin_stdout", "input": "100100", "output": "2\n"}, {"type": "stdin_stdout", "input": "111011", "output": "5\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays ...
[{"type": "stdin_stdout", "input": "7\n-1 -1 1 0 1 31150610 0000000101", "output": "3\n"}, {"type": "stdin_stdout", "input": "7\n1 2 3 2 1 999999999 1000000100", "output": "3\n"}, {"type": "stdin_stdout", "input": "7\n1 4 3 2 1 999999999 1000000100", "output": "3\n"}, {"type": "stdin_stdout", "input": "7\n1 4 3 4 1 999...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nZhinΓΌ was a child of the Emperor, but he was weaving the machine even if he opened it at the request of his father.\n\nIt was a pleasure of the Emperor to wear clothes made of a splendid cloth called Unnishiki woven by Zh...
[{"type": "stdin_stdout", "input": "5\n0 4 0 2 9 3 4 8 2 -1\n3 8 -1 0 0 3 1 2 17 54\n1 2 1 2 41 2 17 21 11 0\n-2 2 14 24 0 21 1 14 20 4\n7 6 30 0 10 1 22 -2 8 -1", "output": "NG\nNG\nNG\nOK\nNG\n"}, {"type": "stdin_stdout", "input": "5\n0 4 -1 2 7 3 4 8 2 -1\n3 5 -1 0 0 3 0 6 8 62\n1 4 1 0 76 4 17 2 11 0\n-2 2 14 24 -1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nOne day, Taro, who lives in JOI town, decided to take a walk as a daily routine to improve his health. In JOI town, where Taro lives, he runs in the east-west direction as shown in the figure (H + 1). The road ...
[{"type": "stdin_stdout", "input": "3 4 2\n1 -1 1 1\n0 1 1 -2\n0 0 -1 1\n0 0 0", "output": "4 1\n"}, {"type": "stdin_stdout", "input": "3 4 3\n1 0 1 1\n0 1 -1 -1\n1 0 1 1\n0 0 0", "output": "1 5\n"}, {"type": "stdin_stdout", "input": "3 4 3\n1 0 1 1\n0 1 1 -2\n0 0 -1 1\n0 0 0", "output": "1 5\n"}, {"type": "stdin_stdou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDescription\n\nKMC sells CDs every year at a coterie spot sale called Comic Market. F was supposed to sell CDs at the comic market, but due to the popularity of F, the KMC sales floor was flooded with people, and the calc...
[{"type": "stdin_stdout", "input": "500 1000\n100 10000\n400 1006\n1029 5000\n10000 10000\n0 0", "output": "0 1 0\n4 1 9\n1 1 0\n4 1 3\n0 0 0\n"}, {"type": "stdin_stdout", "input": "500 1001\n001 10100\n400 1047\n429 5000\n10000 10000\n0 0", "output": "0 1 0\n0 0 10\n1 1 0\n0 1 4\n0 0 0\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTunnel formula\n\nOne day while exploring an abandoned mine, you found a long formula S written in the mine. If you like large numbers, you decide to take out the choke and add `(` or `)` so that the result of the formula...
[{"type": "stdin_stdout", "input": "2-(2-3+4+5)", "output": "12\n"}, {"type": "stdin_stdout", "input": "3+(2-4-4+5)", "output": "10\n"}, {"type": "stdin_stdout", "input": "2-(2-3+4+6)", "output": "13\n"}, {"type": "stdin_stdout", "input": "3+(2-4-4+6)", "output": "11\n"}, {"type": "stdin_stdout", "input": "4-(2+5-0+2)"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor given two sequences $X$ and $Y$, a sequence $Z$ is a common subsequence of $X$ and $Y$ if $Z$ is a subsequence of both $X$ and $Y$. For example, if $X = \\\\{a,b,c,b,d,a,b\\\\}$ and $Y = \\\\{b,d,c,a,b,a\\\\}$, the se...
[{"type": "stdin_stdout", "input": "3\nabcbdab\nbdcaba\nabc\nabc\nacb\nbc", "output": "4\n3\n1\n"}, {"type": "stdin_stdout", "input": "3\nabcbdab\nbdcaba\nabc\nabc\nbcb\nbc", "output": "4\n3\n2\n"}, {"type": "stdin_stdout", "input": "3\nabcbdab\nbdcaba\n`bc\nabc\nbcb\nbc", "output": "4\n2\n2\n"}, {"type": "stdin_stdout...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn.\n\nThe variance Ξ±2 is defined by\n\nΞ±2 = (βˆ‘ni=1(si - m)2)/n\n\nwhere m is an average of si. The standard de...
[{"type": "stdin_stdout", "input": "5\n70 115 100 90 20\n3\n74 80 117\n0", "output": "32.9241552663\n19.0146142626\n"}, {"type": "stdin_stdout", "input": "5\n70 115 100 90 20\n3\n74 82 117\n0", "output": "32.9241552663\n18.6726180989\n"}, {"type": "stdin_stdout", "input": "5\n70 115 100 90 20\n3\n74 80 80\n0", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMishka got an integer array a of length n as a birthday present (what a surprise!).\n\nMishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it \"Mishka's Adjacent Replac...
[{"type": "stdin_stdout", "input": "10\n10100 18 108515962 1 16 111 2 999999999 60506056 1000000000\n", "output": "10099 17 108515961 1 15 111 1 999999999 60506055 999999999\n"}, {"type": "stdin_stdout", "input": "10\n10100 12 108515962 1 5 101 2 999999999 60506056 1000000000\n", "output": "10099 11 108515961 1 5 101 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is an infinite board of square tiles. Initially all tiles are white.\n\nVova has a red marker and a blue marker. Red marker can color a tiles. Blue marker can color b tiles. If some tile isn't white then you can't u...
[{"type": "stdin_stdout", "input": "99999999999962 99999999999973\n", "output": "133333333333296\n"}, {"type": "stdin_stdout", "input": "99999999999973 99999999999971\n", "output": "199999999999948\n"}, {"type": "stdin_stdout", "input": "99999999999973 99999999999930\n", "output": "399999999999808\n"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string s, consisting of n lowercase Latin letters.\n\nA substring of string s is a continuous segment of letters from s. For example, \"defor\" is a substring of \"codeforces\" and \"fors\" is not. \n\nThe...
[{"type": "stdin_stdout", "input": "25\nbbaaaaabaaaabbabaaaababaa\n", "output": "YES\nba\n"}, {"type": "stdin_stdout", "input": "25\nbbaaaaabaaaabbabaaaabab`a\n", "output": "YES\nba\n"}, {"type": "stdin_stdout", "input": "25\nbbaaaaabaaaabbabaaaacab`a\n", "output": "YES\nba\n"}, {"type": "stdin_stdout", "input": "25\na...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently Vasya learned that, given two points with different x coordinates, you can draw through them exactly one parabola with equation of type y = x^2 + bx + c, where b and c are reals. Let's call such a parabola an U-s...
[{"type": "stdin_stdout", "input": "5\n1 0\n1 -1\n0 -1\n-1 0\n-1 -1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1\n-100138 -1274857\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1\n-136202 -1274857\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1\n-211197 -1274857\n", "output": "0\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAmugae has a sentence consisting of n words. He want to compress this sentence into one word. Amugae doesn't like repetitions, so when he merges two words into one word, he removes the longest prefix of the second word th...
[{"type": "stdin_stdout", "input": "9\nL M5 M5D M5DAYBl0r6gmttCTR M5DAYBl0r6gmttCTRoKdM9EFrX22qBZpAc M5DAYBl0r6gmttCTRoKdM9EFrX22qBZpAczv7fKrVgg0xe M5DAYBl0r6gmttCTRoKdM9EFrX22qBZpAczv7fKrVhg0xe09re M5DAYBl0r6gmttCTRoKdM9EFrX22qBZpAczv7fKrVhg0xe09re M5DAYBl0r6gmttCTRoKdM9EFrX22qBZpAczv7fKrVhg0xe09re\n", "output": "LM5D...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYour program fails again. This time it gets \"Wrong answer on test 233\"\n\n.\n\nThis is the easier version of the problem. In this version 1 ≀ n ≀ 2000. You can hack this problem only if you solve and lock both problems....
[{"type": "stdin_stdout", "input": "100 100\n82 51 81 14 37 17 78 123 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 13 49 41 36 41 79 16 87 87 69 3 76 80 60 100 49 70 59 72 8 38 75 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 16 3 55 37 85 46 22 159 52 98 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp has decided to decorate his room because the New Year is soon. One of the main decorations that Polycarp will install is the garland he is going to solder himself.\n\nSimple garlands consisting of several lamps c...
[{"type": "stdin_stdout", "input": "100\n25 100 32 34 25 99 19 99 84 52 20 83 34 12 59 89 51 86 5 63 57 2 61 23 48 27 90 28 29 65 31 73 40 79 89 29 18 86 49 14 48 84 100 17 65 79 37 71 52 47 98 100 40 20 71 94 90 53 41 54 47 2 40 36 35 63 14 66 35 11 2 97 23 90 26 88 17 79 2 59 12 22 14 61 78 15 7 62 7 38 43 94 43 12 7...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYour company was appointed to lay new asphalt on the highway of length n. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.\n\nSkipping...
[{"type": "stdin_stdout", "input": "3\n10 1 1\n11 4 10\n1000000 1 1000100\n", "output": "10\n16\n500049499900\n"}, {"type": "stdin_stdout", "input": "3\n10 1 1\n16 4 10\n1000000 1 1000100\n", "output": "10\n18\n500049499900\n"}, {"type": "stdin_stdout", "input": "3\n10 1 1\n16 4 10\n1000001 1 1000100\n", "output": "10\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya has a rectangular Board of size n Γ— m. Initially, k chips are placed on the board, i-th chip is located in the cell at the intersection of sx_i-th row and sy_i-th column.\n\nIn one action, Petya can move all the chi...
[{"type": "stdin_stdout", "input": "10 10 20\n7 5\n4 5\n5 4\n7 4\n1 5\n6 7\n9 10\n8 4\n1 4\n2 10\n3 10\n4 10\n0 6\n5 7\n6 2\n1 1\n10 9\n7 6\n1 4\n11 4\n8 2\n10 3\n5 1\n10 8\n4 2\n1 9\n1 10\n9 5\n2 2\n6 7\n8 6\n8 9\n2 2\n7 1\n3 3\n1 2\n6 20\n9 4\n10 2\n7 7\n", "output": "117\nUUUUUUUUULLLLLLLLLRRRRRRRRRDLLLLLLLLLDRRRRRR...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBerland year consists of m months with d days each. Months are numbered from 1 to m. Berland week consists of w days. The first day of the year is also the first day of the week. Note that the last week of the year might ...
[{"type": "stdin_stdout", "input": "5\n6 7 1\n10 12 11\n12 30 6\n1 1 1\n3247834 10298779 625324\n", "output": "15\n45\n6\n0\n116461800\n"}, {"type": "stdin_stdout", "input": "5\n6 7 4\n10 9 16\n12 17 4\n0 1 1\n7341628 25065973 296620\n", "output": "6\n16\n66\n0\n359753922\n"}, {"type": "stdin_stdout", "input": "5\n6 10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs meticulous Gerald sets the table, Alexander finished another post on Codeforces and begins to respond to New Year greetings from friends. Alexander has n friends, and each of them sends to Alexander exactly one e-card....
[{"type": "stdin_stdout", "input": "10\n5 1 6 2 8 3 4 10 9 7\n3 1 10 6 8 5 2 7 9 4\n2 9 1 4 10 6 8 7 3 5\n10 1 7 8 3 2 4 6 5 9\n3 2 10 4 7 8 5 6 1 9\n5 6 3 10 8 7 2 9 4 1\n6 5 1 3 2 7 9 10 8 4\n1 10 9 3 7 8 4 2 6 5\n6 8 4 5 9 1 2 10 7 3\n9 6 8 5 10 3 1 7 2 4\n5 7 4 8 9 6 1 10 3 2\n", "output": "5 1 1 1 4 5 5 1 4 5 \n"}...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently you've discovered a new shooter. They say it has realistic game mechanics.\n\nYour character has a gun with magazine size equal to k and should exterminate n waves of monsters. The i-th wave consists of a_i monst...
[{"type": "stdin_stdout", "input": "10 79\n2 2 70\n2 10 35\n10 10 76\n11 11 66\n12 12 75\n12 14 88\n15 16 76\n17 18 97\n19 20 105\n20 20 46\n", "output": "862\n"}, {"type": "stdin_stdout", "input": "10 79\n2 2 70\n2 10 35\n10 10 76\n11 11 66\n12 12 75\n12 14 88\n1 16 76\n17 18 97\n19 20 105\n20 20 46\n", "output": "862...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a game called \"Unique Bid Auction\". You can read more about it here: https://en.wikipedia.org/wiki/Unique_bid_auction (though you don't have to do it to solve this problem).\n\nLet's simplify this game a bit. F...
[{"type": "stdin_stdout", "input": "8\n12\n10 1 3 3 11 5 12 11 12 12 9 4\n11\n10 9 7 6 6 3 8 4 1 7 9\n12\n3 11 8 4 5 9 6 5 11 12 8 1\n15\n12 6 13 12 7 6 1 7 14 12 14 13 11 3 11\n40\n31 32 2 37 19 39 21 19 18 14 17 11 33 7 17 30 33 27 16 37 37 29 19 32 20 32 24 20 20 24 32 2 7 33 30 25 23 11 35 39\n16\n11 9 16 2 10 5 10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSoroush and Keshi each have a labeled and rooted tree on n vertices. Both of their trees are rooted from vertex 1.\n\nSoroush and Keshi used to be at war. After endless decades of fighting, they finally became allies to p...
[{"type": "stdin_stdout", "input": "4\n4\n1 2 3\n1 2 3\n5\n1 2 3 4\n1 1 1 1\n6\n1 1 1 1 2\n1 2 1 2 2\n7\n1 1 3 4 4 5\n1 2 1 4 2 5\n", "output": "\n1\n4\n1\n3\n"}, {"type": "stdin_stdout", "input": "4\n4\n1 2 3\n1 2 3\n5\n1 2 3 4\n1 1 1 1\n6\n1 2 1 1 2\n1 2 1 2 2\n7\n1 1 3 4 4 5\n1 2 1 4 2 5\n", "output": "1\n4\n1\n3\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya is the most responsible worker in the Research Institute. So he was asked to make a very important experiment: to melt the chocolate bar with a new laser device. The device consists of a rectangular field of n Γ— m c...
[{"type": "stdin_stdout", "input": "20\n100 200 100 1 100 100\n100 200 1 100 100 100\n2 2 1 1 2 2\n100 100 50 50 1 1\n10 10 5 5 1 1\n100 100 99 1 1 99\n100 100 1 99 99 1\n100 100 1 10 10 1\n100 100 1 1 10 10\n9 6 1 3 3 1\n1000000000 1000000000 1 1 1000000000 1000000000\n9 4 1 4 4 1\n6 4 1 1 5 4\n6 2 1 1 5 2\n8 2 1 1 5 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOnce n people simultaneously signed in to the reception at the recently opened, but already thoroughly bureaucratic organization (abbreviated TBO). As the organization is thoroughly bureaucratic, it can accept and cater f...
[{"type": "stdin_stdout", "input": "12\n11 4\n9 2\n10000 100\n1000000000 2345\n123456 1234567\n123456 65536\n5 55\n5 3\n2323 10\n999111000 232323\n999888777 284079058\n999888777 777\n", "output": " 4\n ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHarry Potter has a difficult homework. Given a rectangular table, consisting of n Γ— m cells. Each cell of the table contains the integer. Harry knows how to use two spells: the first spell change the sign of the integers ...
[{"type": "stdin_stdout", "input": "10 20\n0 -7 2 -3 3 5 10 4 -8 7 1 -2 8 9 8 9 -4 -5 8 4\n-4 -1 0 0 8 6 4 8 10 0 5 5 9 5 10 1 8 1 1 9\n-8 9 7 2 9 7 5 -1 8 9 -7 9 4 2 2 -4 8 8 0 9\n7 9 10 6 -1 10 -4 6 3 1 9 4 7 -1 10 4 10 -6 -7 7\n-9 7 -2 10 2 1 1 4 5 6 6 10 7 11 9 1 8 9 5 -6\n5 5 10 6 9 3 0 5 1 2 8 3 3 9 5 7 8 -4 4 10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAn IPv6-address is a 128-bit number. For convenience, this number is recorded in blocks of 16 bits in hexadecimal record, the blocks are separated by colons β€” 8 blocks in total, each block has four hexadecimal digits. Her...
[{"type": "stdin_stdout", "input": "20\n0:0:9e39:9:b21:c9b:c:0\n0:0:0:0:0:a27:6b:cb0a\n2:7:4d:b:0:3:2:f401\n17:2dc6::0:89e3:0:dc:0\nca:4:0:0:d6:b999:e:0\n4af:553:b29:dd7:2:5b:0:7\n0:c981:8f:a4d:0:d4:0:f61\n0:0:1:0:dc33:0:1964:0\n84:da:0:6d6:0ecc:1:f:0\n4:fb:4d37:0:8c:4:4a52:24\nc:e:a:0:0:0:e:0\n0:3761:72ed:b7:3b0:ff7:f...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolar bears like unique arrays β€” that is, arrays without repeated elements.\n\nYou have got a unique array s with length n containing non-negative integers. Since you are good friends with Alice and Bob, you decide to spl...
[{"type": "stdin_stdout", "input": "102\n101 56 11 51 38 12 4 53 99 27 90 19 109 26 63 83 15 33 29 40 77 2 39 58 97 70 50 24 32 0 89 37 98 86 71 16 61 20 34 42 45 8 5 25 54 57 1 91 84 67 96 31 76 64 22 65 9 48 18 88 60 46 23 10 43 92 52 75 95 74 78 73 94 68 14 79 41 81 100 6 69 80 30 35 72 17 158 47 49 36 59 44 55 66 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following mo...
[{"type": "stdin_stdout", "input": "10\n100000000 200000000 300000000 400000000 500000000 600000000 700000000 800000000 900000000 1000000000\n", "output": "Bob\n"}, {"type": "stdin_stdout", "input": "10\n101000000 200000000 300000000 400000000 500000000 600000000 700000000 800000000 900000000 1000000000\n", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe last product of the R2 company in the 2D games' field is a new revolutionary algorithm of searching for the shortest path in a 2 Γ— n maze.\n\nImagine a maze that looks like a 2 Γ— n rectangle, divided into unit squares...
[{"type": "stdin_stdout", "input": "4 7\n.X..\n...X\n5 1\n1 3\n7 7\n1 4\n6 1\n4 7\n5 7\n", "output": "1\n4\n0\n5\n2\n2\n2\n"}, {"type": "stdin_stdout", "input": "4 7\n.X..\n...X\n5 1\n1 3\n7 7\n1 4\n6 1\n4 6\n5 7\n", "output": "1\n4\n0\n5\n2\n3\n2\n"}, {"type": "stdin_stdout", "input": "4 7\n.X..\n...X\n5 1\n1 3\n7 3\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya has k matches, placed in n matchboxes lying in a line from left to right. We know that k is divisible by n. Petya wants all boxes to have the same number of matches inside. For that, he can move a match from its box...
[{"type": "stdin_stdout", "input": "100\n6 3 4 5 3 4 2 4 1 2 4 1 8 5 2 2 4 4 6 8 4 10 4 4 6 8 6 5 5 4 8 4 3 3 6 5 7 2 9 7 6 5 6 3 2 6 8 10 3 6 8 7 2 3 5 4 8 6 5 6 6 8 4 1 5 6 1 8 12 5 3 3 8 2 4 2 4 5 6 6 9 5 1 2 8 8 3 7 5 3 4 5 7 6 3 9 4 6 3 6\n", "output": "867\n"}, {"type": "stdin_stdout", "input": "20\n1000000000 10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow ke...
[{"type": "stdin_stdout", "input": "198 10\ntuxqalctjyegbvouezfiqoeoazizhmjhpcmvyvjkyrgxkeupwcmvzcosdrrfgtdmxwfttxjxsbaspjwftgpnvsfyfqsrmyjmypdwonbzwsftepwtjlgbilhcsqyfzfzrfvrvfqiwoemthwvqpvqnflqqspvqrnmvucnspexpijnivqpavqxjyucufculletaedlvut\n", "output": "695\n"}, {"type": "stdin_stdout", "input": "198 14\ntuxqalctjy...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that\n\n1. 1 ≀ i, j ≀ N\n\n2. S[i] = S[j], that is the i-th symbol of string S is equal to the j...
[{"type": "stdin_stdout", "input": "abcdefghijklmnopqrstuvwxyz0987654321abcdefghijklmnopqrstuvwxyz0987654321abcdefghijklmnopqrstuvwxyz0987654321\n", "output": "324\n"}, {"type": "stdin_stdout", "input": "1234567890zyxwvutsrqponmlkjihgfedcba1234567890zyxwvutsrqponmlkjihgfedcba1234567890zyxwvutsrqponmlkjihgfedcba\n", "ou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOn February, 30th n students came in the Center for Training Olympiad Programmers (CTOP) of the Berland State University. They came one by one, one after another. Each of them went in, and before sitting down at his desk,...
[{"type": "stdin_stdout", "input": "185\n28 4 4 26 15 21 14 35 22 28 26 24 2 35 21 34 1 23 35 10 6 16 31 0 30 9 18 33 1 22 24 26 22 10 8 27 14 33 16 16 26 22 1 28 32 1 35 12 31 0 21 6 6 5 29 27 1 29 23 22 30 19 37 17 2 2 2 25 3 23 28 0 3 31 34 5 2 23 27 7 26 25 33 27 15 31 31 4 3 21 1 1 23 30 0 13 24 33 26 5 1 17 23 25...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe mobile application store has a new game called \"Subway Roller\".\n\nThe protagonist of the game Philip is located in one end of the tunnel and wants to get out of the other one. The tunnel is a rectangular field cons...
[{"type": "stdin_stdout", "input": "1\n100 26\ns................PPPP.CCCCC..UUUUUU.........YYYQQQQQQQ...GGGGG............MMM.....JJJJ..............\n.OOOOOO....EEE....................................................SSSSSS........LLLLLL......NNNIIII.\n......FFFFFF...VVVV..ZZZBBB...KKKKK..WWWWWWWXXX..RRRRRRR......AAAAADD...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGenos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.\n\n...
[{"type": "stdin_stdout", "input": "50\n22 19 14 22 20 11 16 28 23 15 3 23 6 16 30 15 15 10 24 28 19 19 22 30 28 1 27 12 12 14 17 30 17 26 21 26 27 1 11 23 9 30 18 19 17 29 11 20 29 24\n", "output": "25\n"}, {"type": "stdin_stdout", "input": "50\n22 19 14 22 20 11 16 28 43 15 3 23 6 16 30 15 15 10 24 28 19 19 22 30 28 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDoor's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!\n\nThe cake is a n Γ— n square consisting of equal squares with side length 1. Each ...
[{"type": "stdin_stdout", "input": "21\n...CCC.....CC..C..C.C\n..CCC...CC...CC.CCC.C\n....C.C.C..CCC..C.C.C\n....CCC..C..C.CC.CCC.\n...CCC.C..C.C.....CCC\n.CCC.....CCC..C...C.C\nCCCC.C...CCC.C...C.CC\nC..C...C.CCC..CC..C..\nC...CC..C.C.CC..C.CC.\nCC..CCCCCCCCC..C....C\n.C..CCCC.CCCC.CCC...C\nCCC...CCC...CCC.C..C.\n.CCC...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLimak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd'...
[{"type": "stdin_stdout", "input": "6 36\nac a\naf a\ndb a\nab a\ncb a\nef a\nad a\nbd a\nfe a\nde a\nbe a\nbb a\naa a\nae a\ndf a\nbc a\nbf a\nce a\nba a\nfd a\ndc a\neb a\ncd a\nca a\nee a\ncc a\ncf a\ndd a\nda a\nec a\nfc a\nfa a\nea a\ned a\nff a\nfb a\n", "output": "46656\n"}, {"type": "stdin_stdout", "input": "6 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nModern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters.\n\nIn this problem you should implement the simila...
[{"type": "stdin_stdout", "input": "255\ngB(ZKoVzD_WVZaYCzXGJYiTHB_XpOcKuLmclmw)UmpgxadtSQ(jGo)KQfXT(Yr_fP_CPbdIv)(AAmaGwrvN)(_Zg)dw(q_O_yLXQzdf)cVN_hd__EaTKwvYNte(_NmFs_)d_KOCp(UWUuGkuMJ)IXwulpMrJwBqdprtLcOE_JSnifGNBBQnuB_(_rhlesFvqglyJ_OYr_WpRM)_fjIfYdXpEbSOZCvk()x_YLygRDpOOZrjycBG_NEa_KjII_Db\n", "output": "20 17\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.\n\nHongcow has decided to try to make new words fr...
[{"type": "stdin_stdout", "input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz\n", "output": "50\n"}, {"type": "stdin_stdout", "input": "zyzzzyyzyyyzyyzyzyzyzyzzzyyyzzyzyyzzzzzyyyzzzzyzyy\n", "output": "50\n"}, {"type": "stdin_stdout", "input": "aaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaab\n", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white wal...
[{"type": "stdin_stdout", "input": "119 12 653\n877 938 872 962 590 500 422 249 141 163 609 452 594 768 316 530 838 945 658 636 997 938 941 272 102 8 713 862 572 809 301 462 282 478 12 544 157 204 367 789 136 251 754 43 349 355 560 325 463 659 666 644 992 603 799 597 364 234 903 377 896 92 971 308 617 712 480 772 170 6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSagheer is working at a kindergarten. There are n children and m different toys. These children use well-defined protocols for playing with the toys:\n\n * Each child has a lovely set of toys that he loves to play with. ...
[{"type": "stdin_stdout", "input": "13 18 27 13\n1 1\n1 2\n1 3\n1 4\n1 17\n2 5\n2 1\n3 6\n3 2\n5 14\n5 3\n4 4\n6 9\n6 3\n7 8\n7 3\n8 7\n8 9\n10 11\n10 14\n11 10\n11 15\n11 11\n9 12\n9 11\n12 10\n13 15\n6 8\n6 14\n6 1\n6 17\n6 18\n11 12\n11 1\n11 1\n11 17\n1 18\n1 12\n1 7\n1 14\n", "output": "3\n0\n0\n0\n0\n4\n0\n0\n0\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere 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...
[{"type": "stdin_stdout", "input": "1000000 1000000\n", "output": "233176135\n"}, {"type": "stdin_stdout", "input": "1000001 1000000\n", "output": "109334147\n"}, {"type": "stdin_stdout", "input": "1000000 500000\n", "output": "211837745\n"}, {"type": "stdin_stdout", "input": "1000000 481032\n", "output": "454735861\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis year, as in previous years, MemSQL is inviting the top 25 competitors from the Start[c]up qualification round to compete onsite for the final round. Not everyone who is eligible to compete onsite can afford to travel...
[{"type": "stdin_stdout", "input": "25\n1000000 999999 999998 999997 999996 999995 999994 999993 999992 999991 999990 999989 999988 999987 999986 999985 999984 999983 999982 999981 999980 999979 999978 999977 999976\n", "output": "999975"}, {"type": "stdin_stdout", "input": "25\n58115 794098 753382 484882 238434 674285...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp takes part in a quadcopter competition. According to the rules a flying robot should:\n\n * start the race from some point of a field, \n * go around the flag, \n * close cycle returning back to the starting p...
[{"type": "stdin_stdout", "input": "-100 100\n-100 -192\n", "output": "590\n"}, {"type": "stdin_stdout", "input": "101 -100\n-100 -100\n", "output": "408\n"}, {"type": "stdin_stdout", "input": "-100 -100\n100 -199\n", "output": "602\n"}, {"type": "stdin_stdout", "input": "-100 100\n-100 -100\n", "output": "406"}, {"typ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of a...
[{"type": "stdin_stdout", "input": "10 5\nsomer\nandom\nnoise\nmayth\neforc\nebewi\nthyou\nhctwo\nagain\nooise\nsomermayth\nandomeforc\nnoiseebewi\nagainthyou\nnoisehctwo\n", "output": "4 6\n"}, {"type": "stdin_stdout", "input": "10 5\nsomer\nmodna\nnoise\nmayth\neforc\nebewi\nthyou\nhctwo\nagain\nooise\nsomermayth\nan...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given several queries. Each query consists of three integers p, q and b. You need to answer whether the result of p/q in notation with base b is a finite fraction.\n\nA fraction in notation with base b is finite i...
[{"type": "stdin_stdout", "input": "11\n1 1000000000000000000 10000000\n4 692 9\n1 2272 333111\n1 9 7\n25 31 1\n13 906830565560158478 22\n1971402979058461 750473176484995605 54\n14 19 23\n4 42409608949005314 23\n3 21914624432020321 46\n3 21914624432020321 47\n", "output": "Finite\nInfinite\nInfinite\nInfinite\nInfinite...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a directed graph with N vertices and M edges, not necessarily simple. The i-th edge is oriented from the vertex a_i to the vertex b_i. Divide this graph into strongly connected components and print them in t...
[{"type": "stdin_stdout", "input": "23 0\n0 4\n5 3\n3 0\n1 5\n0 2\n0 0\n5 4", "output": "23\n1 22 \n1 21 \n1 20 \n1 19 \n1 18 \n1 17 \n1 16 \n1 15 \n1 14 \n1 13 \n1 12 \n1 11 \n1 10 \n1 9 \n1 8 \n1 7 \n1 6 \n1 5 \n1 4 \n1 3 \n1 2 \n1 1 \n1 0 \n"}, {"type": "stdin_stdout", "input": "21 0\n0 2\n2 1\n4 0\n2 0\n1 2\n0 3\n5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).\n\nConsider a sequence A satisfying the following conditions:\n\n* A is a sequence of N positive integers.\n* 1 \\leq A_1 \\leq ...
[{"type": "stdin_stdout", "input": "4 6 10\n2 4 2 67809\n1 4 0 90629\n2 2 -1 29125\n4 4 1 2716\n3 4 1 114896\n1 4 2 13595\n2 2 1 66038\n1 1 2 2156\n0 3 0 24162\n1 4 3 148470", "output": "331175\n"}, {"type": "stdin_stdout", "input": "4 6 10\n2 4 2 86568\n1 4 0 90629\n2 3 0 29125\n3 4 1 1368\n3 4 1 114896\n1 4 2 13595\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is a string S. Each character in S is either a digit (`0`, ..., `9`) or `?`.\n\nAmong the integers obtained by replacing each occurrence of `?` with a digit, how many have a remainder of 5 when divided by 13? An int...
[{"type": "stdin_stdout", "input": "?6?42???8??29?06243????9??3???7258??5??7???????774????4?1??17?????5?70???76???", "output": "153716829\n"}, {"type": "stdin_stdout", "input": "???67???07?5?????71??1?4????477???????7??5??8527???3??9????34260?92??8???24?6?", "output": "153716660\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N stones arranged in a row. The i-th stone from the left is painted in the color C_i.\n\nSnuke will perform the following operation zero or more times:\n\n* Choose two stones painted in the same color. Repaint a...
[{"type": "stdin_stdout", "input": "7\n1\n2\n10\n2\n1\n6\n2", "output": "5\n"}, {"type": "stdin_stdout", "input": "7\n1\n2\n1\n2\n3\n3\n2", "output": "6\n"}, {"type": "stdin_stdout", "input": "7\n1\n3\n1\n2\n1\n3\n2", "output": "7\n"}, {"type": "stdin_stdout", "input": "7\n1\n3\n1\n2\n4\n3\n2", "output": "5\n"}, {"type...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCat Snuke is learning to write characters. Today, he practiced writing digits `1` and `9`, but he did it the other way around.\n\nYou are given a three-digit integer n written by Snuke. Print the integer obtained by repla...
[{"type": "stdin_stdout", "input": "191", "output": "919\n"}, {"type": "stdin_stdout", "input": "111", "output": "999\n"}, {"type": "stdin_stdout", "input": "199", "output": "911\n"}, {"type": "stdin_stdout", "input": "111", "output": "999\n"}, {"type": "stdin_stdout", "input": "199", "output": "911\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upp...
[{"type": "stdin_stdout", "input": "6\n5 30 290 0 -1 25\n106 2 21 1619 34 5\n1103 1563 -1 0 26 885", "output": "58\n"}, {"type": "stdin_stdout", "input": "6\n5 26 290 0 -1 25\n106 4 8 1619 60 5\n1103 1563 0 0 26 1803", "output": "64\n"}, {"type": "stdin_stdout", "input": "6\n4 43 290 -1 6 27\n106 13 11 837 28 8\n1103 7...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a r...
[{"type": "stdin_stdout", "input": "100100 100000", "output": "50000\n"}, {"type": "stdin_stdout", "input": "100100 110000", "output": "50050\n"}, {"type": "stdin_stdout", "input": "100111 100001", "output": "83371\n"}, {"type": "stdin_stdout", "input": "100100 100010", "output": "50005\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWelcome to CODE FESTIVAL 2016! In order to celebrate this contest, find a string s that satisfies the following conditions:\n\n* The length of s is between 1 and 5000, inclusive.\n* s consists of uppercase letters.\n* s c...
[{"type": "stdin_stdout", "input": "1441", "output": "FESTIVALLLLLLLFESTIVAFESTIVALLFESTIVALLFESTIVALFESTIVALFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAFESTIVAF...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have N pieces of ropes, numbered 1 through N. The length of piece i is a_i.\n\nAt first, for each i (1≀i≀N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie a...
[{"type": "stdin_stdout", "input": "5 50\n10 20 29 51 104", "output": "Possible\n1\n2\n4\n3\n"}, {"type": "stdin_stdout", "input": "5 30\n10 20 29 51 104", "output": "Possible\n4\n3\n2\n1\n"}, {"type": "stdin_stdout", "input": "5 50\n10 20 30 51 104", "output": "Possible\n1\n4\n3\n2\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day, the lord ordered a carpenter to \"build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake.\" However, large thick pillars are needed to complete the sturdy a...
[{"type": "stdin_stdout", "input": "6\n4\n1,2,2,2\n1,3,4,3\n1,4,4,2\n2,5,3,2\n3,4,4,2\n3,6,1,2\n4,6,1,1\n5,6,1,2\n2,4,50,30", "output": "-11\n"}, {"type": "stdin_stdout", "input": "6\n8\n1,1,2,2\n3,4,3,0\n1,4,4,2\n2,3,5,2\n3,4,4,2\n3,6,1,2\n4,6,1,1\n5,6,2,2\n2,4,5,030", "output": "-36\n"}, {"type": "stdin_stdout", "inp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.\n\nOne of the jobs of Aika, a waitress, is to deliver the scones that are baked one after anot...
[{"type": "stdin_stdout", "input": "5 11\n7 36 34 14 94\n8 10\n-1 2 1 5 6 6 8 2\n5 4\n2 4 2 4 6\n10 18\n10 15 12 56 12 33 11 1 22 181\n1 101\n10\n0 0", "output": "10\n9\n2\n17\n10\n"}, {"type": "stdin_stdout", "input": "5 11\n7 36 34 45 94\n8 10\n-1 2 1 5 4 6 8 2\n5 2\n2 4 2 4 6\n10 18\n10 15 12 56 12 67 11 6 22 181\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the ...
[{"type": "stdin_stdout", "input": "7\n1 3\n3 4\n1 4\n1 7\n5 7\n6 7\n1 7\n6\n1 2\n2 3\n3 4\n4 6\n1 5\n2 6\n1\n1 3\n2 4\n3 5\n4 3\n6 7\n2 6\n4 7\n0", "output": "5\n6\n2\n3\n4\n"}, {"type": "stdin_stdout", "input": "7\n1 3\n3 4\n1 7\n4 10\n5 6\n6 7\n1 7\n6\n1 2\n2 2\n1 4\n4 5\n1 10\n2 6\n7\n2 3\n2 4\n5 5\n4 6\n6 7\n2 6\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIto joined the Kyudo club after entering high school. At first, I had a hard time because the arrow didn't reach the target, but in the fall of my first year of high school, I managed to improve to the point where the arr...
[{"type": "stdin_stdout", "input": "20\n1\n11\n1\n-1\n0\n8\n-2\n1\n0", "output": "12\n-1\n"}, {"type": "stdin_stdout", "input": "20\n1\n10\n1\n-1\n0\n8\n-2\n1\n0", "output": "11\n-1\n"}, {"type": "stdin_stdout", "input": "20\n3\n2\n0\n1\n12\n8\n-1\n-1\n0", "output": "18\n-2\n"}, {"type": "stdin_stdout", "input": "20\n5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnchored Balloon\n\nA balloon placed on the ground is connected to one or more anchors on the ground with ropes. Each rope is long enough to connect the balloon and the anchor. No two ropes cross each other. Figure E-1 sh...
[{"type": "stdin_stdout", "input": "3\n10 10 20\n10 -10 25\n-10 10 120\n1\n10 10 16\n2\n10 10 20\n10 -10 20\n2\n100 0 101\n-90 0 91\n2\n0 0 53\n40 40 102\n3\n10 10 20\n10 -10 20\n-10 -10 20\n3\n1 5 13\n5 -3 13\n-3 -2 13\n3\n98 97 168\n-82 -80 193\n-170 -160 211\n4\n90 -100 160\n-80 -80 150\n90 137 150\n80 80 245\n4\n85...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIncreasing E869120 (Ninja E869120)\n\nE869120 You are good at alter ego.\n\nHere are $ N $ members of the PA Lab. But some of them may be E869120.\n\nSo you asked all the $ N $ members of the PA Lab for their names. As a ...
[{"type": "stdin_stdout", "input": "5\nE869120\nTMJN\nE869120\nASIAT\nYNYMXIAOLONGBAO", "output": "2\n"}, {"type": "stdin_stdout", "input": "5\nE869120\nTMJN\nE809126\nATIAT\nYNYMXIAOGONLBAO", "output": "1\n"}, {"type": "stdin_stdout", "input": "5\nE86912/\nTMJN\n621908E\nIATSA\nYNYMXIBOGONLBAO", "output": "0\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA group of n dancers rehearses a performance for the closing ceremony. The dancers are arranged in a row, they've studied their dancing moves and can't change positions. For some of them, a white dancing suit is already b...
[{"type": "stdin_stdout", "input": "20 53 67\n1 2 1 2 0 0 0 2 2 2 1 0 0 2 0 0 0 1 1 2\n", "output": "413\n"}, {"type": "stdin_stdout", "input": "20 53 67\n1 2 1 2 0 0 0 2 2 2 1 0 0 2 0 0 1 1 1 2\n", "output": "427\n"}, {"type": "stdin_stdout", "input": "20 53 67\n1 2 1 2 0 0 0 2 2 2 1 0 0 2 0 0 1 2 1 2\n", "output": "4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, \"abcba\", \"a\", and \"abba\" are palindromes, while \"abab\" and \"xy\" are not.\n\nA...
[{"type": "stdin_stdout", "input": "21\narozauprlanalapuazoaa\n", "output": "aaaaaaaallnoopprruuzz\n"}, {"type": "stdin_stdout", "input": "21\narozbuprlanalapuazoaa\n", "output": "aaaaaaabllnoopprruuzz\n"}, {"type": "stdin_stdout", "input": "21\narozbuarlpnalapuayoaa\n", "output": "aaaaaaabllnoopprruuyz\n"}, {"type": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a 4x4 grid. You play a game β€” there is a sequence of tiles, each of them is either 2x1 or 1x2. Your task is to consequently place all tiles from the given sequence in the grid. When tile is placed, each cell...
[{"type": "stdin_stdout", "input": "011110\n", "output": "1 1\n4 3\n4 1\n4 3\n4 1\n3 1\n"}, {"type": "stdin_stdout", "input": "011111\n", "output": "1 1\n1 2\n2 2\n3 2\n4 2\n1 2\n"}, {"type": "stdin_stdout", "input": "001111\n", "output": "1 1\n3 1\n1 2\n2 2\n3 2\n4 2\n"}, {"type": "stdin_stdout", "input": "101111\n", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA string is called bracket sequence if it does not contain any characters other than \"(\" and \")\". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expression by inserting characte...
[{"type": "stdin_stdout", "input": "1000000000\n1000000000\n1000000000\n1000000000\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1000000000\n1000000000\n1000000000\n999999999\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1000000000\n999999999\n1000000000\n1000000000\n", "output": "1\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNeko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire bag of catnip into the toys...
[{"type": "stdin_stdout", "input": "1000\n", "output": "143886430"}, {"type": "stdin_stdout", "input": "590\n", "output": "219553034\n"}, {"type": "stdin_stdout", "input": "170\n", "output": "127251691\n"}, {"type": "stdin_stdout", "input": "261\n", "output": "151729335\n"}, {"type": "stdin_stdout", "input": "295\n", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou're given an array a of length n. You can perform the following operation on it as many times as you want:\n\n * Pick two integers i and j (1 ≀ i,j ≀ n) such that a_i+a_j is odd, then swap a_i and a_j. \n\n\n\nWhat is...
[{"type": "stdin_stdout", "input": "36\n398353608 662365068 456456182 594572278 958026500 524977116 903404403 382220192 142092809 137516115 522872496 527845939 116437661 423289717 907151540 961740613 981968938 143206666 773454188 691188206 95402302 602570397 986508327 617421132 46091276 866348540 485487643 843511039 76...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMarcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.\n\nLet's focus on the stud...
[{"type": "stdin_stdout", "input": "10\n206158430208 206162624513 68719476737 137506062337 206162624513 4194305 68719476737 206225539072 137443147777 68719476736\n202243898 470292528 170057449 290025540 127995253 514454151 607963029 768676450 611202521 68834463\n", "output": "2773043292\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a large electronic screen which can display up to 998244353 decimal digits. The digits are displayed in the same way as on different electronic alarm clocks: each place for a digit consists of 7 segments which ca...
[{"type": "stdin_stdout", "input": "1\n140047\n", "output": "7111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nn students are taking an exam. The highest possible score at this exam is m. Let a_{i} be the score of the i-th student. You have access to the school database which stores the results of all students.\n\nYou can change e...
[{"type": "stdin_stdout", "input": "27\n1 1\n0\n1 2\n0\n1 5\n0\n1 10\n0\n1 50\n0\n1 100\n0\n1 500\n0\n1 1000\n0\n1 5000\n0\n1 10000\n0\n1 50000\n0\n1 100000\n0\n1 5\n4\n1 5\n5\n1 10\n9\n1 10\n10\n1 100000\n9999\n1 100000\n100000\n1 4999\n386\n1 100000\n1\n4 5\n1 0 0 0\n4 5\n0 1 0 0\n4 5\n0 0 0 0\n4 5\n5 5 5 5\n4 5\n4 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWriting light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the q...
[{"type": "stdin_stdout", "input": "20 2\n9 7\n3 7\n15 9\n1 3\n11 12\n18 7\n17 18\n20 1\n4 11\n2 11\n12 18\n8 18\n13 2\n19 2\n10 11\n6 13\n5 8\n14 1\n16 13\n", "output": "16\n"}, {"type": "stdin_stdout", "input": "20 7\n9 7\n3 13\n15 9\n1 3\n11 9\n18 7\n17 18\n20 1\n4 11\n2 11\n12 18\n8 18\n13 2\n19 1\n10 14\n6 13\n5 8...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Petya learns how to write. The teacher gave pupils the task to write the letter A on the sheet of paper. It is required to check whether Petya really had written the letter A.\n\nYou are given three segments on the...
[{"type": "stdin_stdout", "input": "3\n6 5 6 -1\n4 1 5 2\n4 -1 3 9\n-1 0 0 0\n1 5 2 -4\n2 1 -1 3\n-1 0 -2 0\n2 0 2 -2\n1 2 -1 1\n", "output": "NO\nNO\nNO\n"}, {"type": "stdin_stdout", "input": "3\n6 5 6 -1\n4 1 5 2\n4 -1 3 9\n-1 0 0 0\n0 5 2 -4\n2 1 -1 3\n-1 0 -2 0\n2 0 2 -2\n1 2 -1 1\n", "output": "NO\nNO\nNO\n"}, {"t...
code_stdio