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\nFrom the childhood we are taught that a comes before b then b comes before c and so on.So whenever we try to sort any given string we sort it in that manner only placing a before b and so on.But what happens if we initial...
[{"type": "stdin_stdout", "input": "10\nihpcfylbjskmxqogaetnwzdvur\nlvjiwjvzlybrlmclbyxpopnuxlzbqxrvhnizyipzqrvsztylptnwbsvcxegtfwawvradfryklqlezbbowsuqtsyoxrkwcbmmgngaefavwoikahtllsbvowqogdripwevhayxyyjuwcdyuatiwikdoxhkutlvtdkkfjnxatmaxqkokmxpwueiatziwkocrciyvegwshapgpvrispsbsppnxjtursjfymnosbsxkntoawyjezwobphtyimtkhg...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nShinchan and Kazama both are playing with numbers. Shinchan gives Kazama an array of numbers and asks him to tell the minimum possible last number of a non decreasing sequence of length L. \nNote- Check the sample I/O for...
[{"type": "stdin_stdout", "input": "10\n41\n467 334 500 169 999 478 358 962 464 705 145 249 827 961 491 995 942 827 206 391 604 902 153 292 508 421 716 718 895 447 726 771 538 869 1338 667 299 35 894 703 811 \n23\n333\n673 664 141 711 253 868 547 644 662 1295 37 859 723 741 529 355 316 35 190 842 288 106 40 942 264 648...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTanmay is a legendary spammer - everyone in the spamming world knows and admires his abilities to spam anyone, anytime, anywhere. He decided to guide one of his mentors, named Arjit, as part of the Apex body of spamming. ...
[{"type": "stdin_stdout", "input": "500\n18\n8 5 5 -9 -8 0 0 -3 -7 2 0 4 2 -6 1 -9 2 -6 \n18\n9 9 -7 -6 -2 -3 -4 4 -6 5 -4 7 -4 -6 2 -10 -5 2 \n18\n-1 3 7 2 -8 -3 -7 2 -1 2 4 10 6 0 8 10 4 -6 \n18\n-6 10 8 -2 2 -8 -8 6 -4 4 6 -1 -7 -8 -9 -10 5 -6 \n18\n-5 6 6 2 -2 -3 -1 -7 7 -3 -8 0 1 -6 -3 -4 2 7 \n18\n-2 3 2 2 -6 -4 ...
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 another positive integer S.\nFor a non-empty subset T of the set \\\\{1, 2, \\ldots , N \\\\}, let us define f(T) as follows:\n\n\n* f(T) is the numbe...
[{"type": "stdin_stdout", "input": "10 10\n3 1 7 1 10 13 2 6 5 11", "output": "1536\n"}, {"type": "stdin_stdout", "input": "10 10\n3 1 7 1 10 13 2 6 5 3", "output": "2272\n"}, {"type": "stdin_stdout", "input": "10 10\n3 1 7 1 13 13 2 6 5 3", "output": "1760\n"}, {"type": "stdin_stdout", "input": "10 10\n3 1 6 1 13 13 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N. Find the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\n* For any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\...
[{"type": "stdin_stdout", "input": "8\n5 14 4 2 6 8 1 3", "output": "4\n"}, {"type": "stdin_stdout", "input": "8\n5 28 4 2 6 8 1 3", "output": "4\n"}, {"type": "stdin_stdout", "input": "8\n5 14 4 2 6 4 1 3", "output": "4\n"}, {"type": "stdin_stdout", "input": "8\n5 28 4 2 8 8 1 3", "output": "4\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.\n\nYou can perform the following operation on this integer sequence any number of times:\n\nOperation: Choose an integer i satisfying 1 \\leq i \\...
[{"type": "stdin_stdout", "input": "11\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000", "output": "10000000000"}, {"type": "stdin_stdout", "input": "11\n-1000000000 1000000000 -364513171 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn some other world, today is December D-th.\n\nWrite a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22.\n\nConstraints\n\n* 22 \\l...
[{"type": "stdin_stdout", "input": "-1279", "output": "Christmas Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one.\n\nA substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `a...
[{"type": "stdin_stdout", "input": "atcoderamdatcodeer\n5", "output": "amdat\n"}, {"type": "stdin_stdout", "input": "roddadtadmaoefectr\n5", "output": "admao\n"}, {"type": "stdin_stdout", "input": "atcoderamdascodeer\n5", "output": "amdas\n"}, {"type": "stdin_stdout", "input": "atcoderandatcodeer\n5", "output": "andat"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b.\n\nThe i-th operation is as follows:\n\n1. Append a_i to the end of b.\n2. Revers...
[{"type": "stdin_stdout", "input": "6\n-1 22 1 75 15 0", "output": "0 75 22 -1 1 15\n"}, {"type": "stdin_stdout", "input": "6\n2 20 0 59 10 1", "output": "1 59 20 2 0 10\n"}, {"type": "stdin_stdout", "input": "6\n2 20 0 59 10 0", "output": "0 59 20 2 0 10\n"}, {"type": "stdin_stdout", "input": "6\n2 20 0 59 12 0", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nInternet search engines, such as Google, automatically sort and categorize web pages around the world to create a huge database. It also parses the search keywords entered by the user and creates an inquiry statement for ...
[{"type": "stdin_stdout", "input": "niW todax's premiminary contest `nd eb eqjgilaue ot vhsit Uniwersity of Aizu-", "output": "niW `nd vhsit Aizu-\n"}, {"type": "stdin_stdout", "input": "pUi sod'xsa yqnlibiocro tsfsloc `cn bg fualhgdpj pv hjssv Umjweqsity dn vyjA-", "output": "pUi `cn hjssv vyjA-\n"}, {"type": "stdin_s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMr. Matsudaira is always careful about eco-friendliness in his life. Last month's water charge was 4280 yen, which exceeded the usual target of 4000 yen, so we have been trying to save water this month. How much have you ...
[{"type": "stdin_stdout", "input": "29\n104\n0\n-1", "output": "620\n-11360\n3130\n"}, {"type": "stdin_stdout", "input": "29\n112\n0\n-1", "output": "620\n-12640\n3130\n"}, {"type": "stdin_stdout", "input": "29\n130\n1\n-1", "output": "620\n-15520\n3130\n"}, {"type": "stdin_stdout", "input": "29\n97\n0\n-1", "output": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt’s still hot every day, but September has already come. It’s autumn according to the calendar. Looking around, I see two red dragonflies at rest on the wall in front of me. It’s autumn indeed.\n\nWhen two red dragonflie...
[{"type": "stdin_stdout", "input": "-7 1028", "output": "1035\n"}, {"type": "stdin_stdout", "input": "-2 1028", "output": "1030\n"}, {"type": "stdin_stdout", "input": "-2 1094", "output": "1096\n"}, {"type": "stdin_stdout", "input": "-2 1349", "output": "1351\n"}, {"type": "stdin_stdout", "input": "-3 1349", "output": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOn a clear night, a boy, Campanella looked up at the sky, there were many stars which have different colors such as red, yellow, green, blue, purple, etc. He was watching the stars and just lost track of time. Presently, ...
[{"type": "stdin_stdout", "input": "8\n1 0 3 3 0 1 14 5\n7\n1 2 -1 8 12 1 5\n0", "output": "NO COLOR\nNO COLOR\n"}, {"type": "stdin_stdout", "input": "8\n1 0 3 3 0 1 14 5\n7\n1 2 -1 8 22 1 5\n0", "output": "NO COLOR\nNO COLOR\n"}, {"type": "stdin_stdout", "input": "8\n1 0 3 3 0 1 14 5\n7\n1 2 -1 8 13 1 5\n0", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday is the birthday of Mr. Bon Vivant, who is known as one of the greatest patissiers in the world. Those who are invited to his birthday party are gourmets from around the world. They are eager to see and eat his extre...
[{"type": "stdin_stdout", "input": "3 8 6\n1 48\n1 31\n1 3\n3 7 2\n1 1\n2 0\n1 2\n0 2 10\n0 0 0", "output": "2 10 18 18\n0 1 1 12\n20\n"}, {"type": "stdin_stdout", "input": "3 10 6\n1 35\n2 16\n1 2\n3 4 1\n1 1\n2 0\n3 1\n0 2 5\n0 0 0", "output": "6 12 18 24\n0 1 1 2\n10\n"}, {"type": "stdin_stdout", "input": "3 10 6\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe amount of information on the World Wide Web is growing quite rapidly. In this information explosion age, we must survive by accessing only the Web pages containing information relevant to our own needs. One of the key...
[{"type": "stdin_stdout", "input": "3 1\naa\nb\nccc\naabccczbaacccbaazaabbcccaa\n3 1\na\nb\nc\ncbbcbcbabaacabccaccbaacbccbcaaaccccbcbcbbcacbaacccaccbbcaacbbabbabaccc\n3 4\naaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPeace, which was supposed to last forever, suddenly ended. The Demon King, who had been sealed long ago, has finally revived. But when the world was about to be covered in darkness, a brave man appeared. The hero then set...
[{"type": "stdin_stdout", "input": "2 -1 0 13 10\n2 1\n4 0\n2 0 -1 15 18\n1 1\n6 6\n4 0 0 10 10\n1 1\n10 5\n0 0 0 0 0", "output": "YES\nYES\nNO\n"}, {"type": "stdin_stdout", "input": "2 -1 0 13 10\n2 1\n4 0\n2 0 -1 15 18\n1 1\n6 6\n4 0 0 10 10\n1 1\n5 5\n0 0 0 0 0", "output": "YES\nYES\nNO\n"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA robot in a two-dimensional maze again. The maze has an entrance and an exit this time, though.\n\nJust as in the previous problem, the maze is made up of H × W grid cells, its upper side faces north, and each cell is ei...
[{"type": "stdin_stdout", "input": "2 5 1\nL\nG.\n#S\n2 2 3\nRS\n.G\nS.\n3 6 10\nLLLLLL\nG$.\n...\n.#S\n0 0 0", "output": "Yes\nYes\nYes\n"}, {"type": "stdin_stdout", "input": "2 2 1\nL\nG.\n#S\n2 2 2\nRR\nG.\nS.\n3 3 10\nLLLLKL\nG#.\n...\n.#S\n0 0 0", "output": "Yes\nYes\nYes\n"}, {"type": "stdin_stdout", "input": "2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nK: Relief (Angel Relief)\n\nTenma, an angel, decides to save a city.\n\nThe city has a rectangular shape divided into north-south $ H $ parcels x east-west $ W $ parcels, with houses in each parcel.\n\nThe $ X $ th sectio...
[{"type": "stdin_stdout", "input": "2 2\n0 0\n-2 27", "output": "100\n"}, {"type": "stdin_stdout", "input": "1 4\n1 2\n-5 41", "output": "150\n"}, {"type": "stdin_stdout", "input": "1 4\n1 2\n-7 41", "output": "138\n"}, {"type": "stdin_stdout", "input": "1 4\n1 0\n-7 41", "output": "126\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor given a circle $c$ and a line $l$, print the coordinates of the cross points of them.\n\nConstraints\n\n* $p1$ and $p2$ are different\n* The circle and line have at least one cross point\n* $1 \\leq q \\leq 1,000$\n* ...
[{"type": "stdin_stdout", "input": "2 0 3\n2\n-1 -1 11 0\n1 -1 12 3", "output": "-0.83330025 -0.98610835 4.95743818 -0.50354682\n-0.55841103 -1.56669492 4.96717016 0.44260733\n"}, {"type": "stdin_stdout", "input": "2 -1 3\n2\n0 -1 14 0\n1 0 10 11", "output": "-0.99915098 -1.07136793 4.97884641 -0.64436811\n-0.76686667 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNatasha travels around Mars in the Mars rover. But suddenly it broke down, namely — the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the vertex 1, in which every leaf...
[{"type": "stdin_stdout", "input": "60\nAND 20 4\nNOT 42\nAND 48 59\nOR 17 7\nIN 0\nAND 36 37\nIN 1\nIN 0\nIN 1\nNOT 47\nAND 52 49\nOR 44 35\nIN 0\nIN 1\nAND 33 56\nIN 0\nIN 0\nIN 0\nAND 31 41\nOR 15 3\nOR 43 46\nIN 1\nXOR 22 28\nIN 1\nIN 1\nIN 1\nAND 34 21\nIN 1\nIN 1\nIN 0\nXOR 51 23\nXOR 10 54\nOR 57 40\nIN 0\nNOT 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill lev...
[{"type": "stdin_stdout", "input": "20 1 0.78\nxc 6799\nztrfjsq 3023\nkhbcbsaztwigxeidh 2974\nkksvbmtjiiqlguwv 188\nwvqzzjrpmxsdbfvua 4547\niqkqqwtqifdpxfhslpv 6264\nwarmknju 9472\nfheisuiufwmtagl 292\nwge 4338\nzaklermeji 6733\nfcn 6282\nbjyjzgzkgzy 1778\ngufpvhdnsesyfuegef 4998\nxnhuhwzzxqbaphktqbc 8485\ncokabaqahfw ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nArkady coordinates rounds on some not really famous competitive programming platform. Each round features n problems of distinct difficulty, the difficulties are numbered from 1 to n.\n\nTo hold a round Arkady needs n new...
[{"type": "stdin_stdout", "input": "11000 10\n10000 9999 9998 1967 4502 9995 9994 10823 9992 9991\n", "output": "0000000000\n"}, {"type": "stdin_stdout", "input": "11000 10\n10000 9999 9998 1967 4502 9995 3707 10823 9992 9991\n", "output": "0000000000\n"}, {"type": "stdin_stdout", "input": "11010 10\n10000 9999 9998 19...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a consisting of 500000 integers (numbered from 1 to 500000). Initially all elements of a are zero.\n\nYou have to process two types of queries to this array:\n\n * 1 x y — increase a_x by y; \n * ...
[{"type": "stdin_stdout", "input": "5\n1 3 4\n2 3 0\n2 4 3\n1 500000 1\n2 800 0\n", "output": "4\n4\n1\n"}, {"type": "stdin_stdout", "input": "5\n1 3 4\n2 3 0\n2 4 3\n1 4 -4\n2 1 0\n", "output": "4\n4\n0\n"}, {"type": "stdin_stdout", "input": "5\n1 3 4\n1 3 0\n2 4 3\n1 4 -4\n2 1 0\n", "output": "4\n0\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given n k-digit integers. You have to rearrange the digits in the integers so that the difference between the largest and the smallest number was minimum. Digits should be rearranged by the same rule in all intege...
[{"type": "stdin_stdout", "input": "8 8\n83239439\n62184887\n58968944\n39808261\n68740623\n38480328\n81965504\n52600488\n", "output": "44481119\n"}, {"type": "stdin_stdout", "input": "8 8\n96805230\n73119021\n06552907\n86283347\n88650846\n19155689\n37032451\n19310120\n", "output": "53604668\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two positive integers a and b.\n\nIn one move, you can change a in the following way:\n\n * Choose any positive odd integer x (x > 0) and replace a with a+x; \n * choose any positive even integer y (y > 0)...
[{"type": "stdin_stdout", "input": "5\n2 3\n10 10\n2 4\n7 4\n9 3\n", "output": "1\n0\n2\n2\n1\n"}, {"type": "stdin_stdout", "input": "5\n2 3\n10 10\n2 4\n4 4\n9 3\n", "output": "1\n0\n2\n0\n1\n"}, {"type": "stdin_stdout", "input": "5\n2 3\n10 10\n2 7\n4 4\n9 3\n", "output": "1\n0\n1\n0\n1\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string s such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of s such that it contains each of these three characters at least once.\n\nA contiguous sub...
[{"type": "stdin_stdout", "input": "12\n11111122222222222223\n122222222222222222333\n33333333331111111122\n11111111133333333333333332\n111111111123333333333\n1\n2\n3\n12\n23\n123\n1111111111111111211111111111111111111111111111111113\n", "output": "15\n19\n10\n18\n3\n0\n0\n0\n0\n0\n3\n36\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a chessboard consisting of n rows and n columns. Rows are numbered from bottom to top from 1 to n. Columns are numbered from left to right from 1 to n. The cell at the intersection of the x-th column and the...
[{"type": "stdin_stdout", "input": "5 3 5\n4 4\n3 5\n2 4\n3 4\n3 5\n", "output": "0\n1\n2\n2\n1\n"}, {"type": "stdin_stdout", "input": "5 5 5\n4 4\n3 5\n2 4\n3 4\n3 5\n", "output": "0\n2\n3\n3\n2\n"}, {"type": "stdin_stdout", "input": "5 5 5\n4 4\n3 5\n2 3\n3 3\n3 5\n", "output": "0\n2\n2\n3\n2\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given n strings s_1, s_2, …, s_n consisting of lowercase Latin letters.\n\nIn one operation you can remove a character from a string s_i and insert it to an arbitrary position in a string s_j (j may be equal to i)...
[{"type": "stdin_stdout", "input": "4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc\n", "output": "YES\nNO\nYES\nNO\n"}, {"type": "stdin_stdout", "input": "1\n26\na\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nw\nx\ny\nz\n", "output": "NO\n"}, {"type": "stdin_stdout...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is the hard version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.\n\nYou are ...
[{"type": "stdin_stdout", "input": "5\n2 2\n10\n11\n3 3\n011\n101\n110\n4 4\n1111\n0100\n0100\n1110\n5 5\n00011\n11011\n01010\n11011\n10000\n2 3\n001\n101\n", "output": "1\n1 1 2 1 2 2\n6\n1 2 2 1 2 2\n1 3 2 2 2 3\n3 1 2 2 3 2\n2 2 3 2 3 3\n2 2 2 3 3 3\n2 2 2 3 3 2\n9\n1 1 1 2 2 1\n1 3 1 4 2 3\n2 1 2 2 3 1\n2 3 3 3 3 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nArgus was charged with guarding Io, which is not an ordinary cow. Io is quite an explorer, and she wanders off rather frequently, making Argus' life stressful. So the cowherd decided to construct an enclosed pasture for I...
[{"type": "stdin_stdout", "input": "8\n4\n1 2 4 5\n3\n1 3 5\n3\n2 6 8\n2\n1 2\n1\n50\n5\n3 4 5 6 8\n3\n1 25 26\n6\n1 2 4 8 16 32\n", "output": "\n4\n2\n3\n1\n0\n5\n3\n15\n"}, {"type": "stdin_stdout", "input": "8\n4\n1 2 4 5\n3\n1 3 5\n3\n2 6 8\n2\n1 2\n1\n50\n5\n3 4 5 6 8\n3\n1 4 26\n6\n1 2 4 8 16 32\n", "output": "4\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a number n (divisible by 3) and an array a[1 ... n]. In one move, you can increase any of the array elements by one. Formally, you choose the index i (1 ≤ i ≤ n) and replace a_i with a_i + 1. You can choose ...
[{"type": "stdin_stdout", "input": "4\n6\n0 2 5 5 4 1\n6\n2 0 2 0 0 0\n9\n14 1 3 4 2 10 3 1 12\n6\n1 1 2 3 4 5\n", "output": "1\n2\n1\n2\n"}, {"type": "stdin_stdout", "input": "4\n6\n0 2 1 4 4 1\n6\n0 0 2 1 0 0\n9\n7 1 3 0 2 12 2 13 5\n6\n1 0 2 10 1 8\n", "output": "3\n3\n0\n2\n"}, {"type": "stdin_stdout", "input": "4\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn some country live wizards. They love to ride trolleybuses.\n\nA city in this country has a trolleybus depot with n trolleybuses. Every day the trolleybuses leave the depot, one by one and go to the final station. The f...
[{"type": "stdin_stdout", "input": "10 7 8\n2 4\n3 13\n4 7\n5 1\n6 16\n10 9\n12 18\n16 4\n17 16\n20 6\n", "output": "4.285714285714286\n4.511857892036909\n5.642857142857143\n13.071428571428573\n13.071428571428573\n13.071428571428573\n13.51185789203691\n18.28571428571429\n18.511857892036907\n21.761904761904763\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nScientists say a lot about the problems of global warming and cooling of the Earth. Indeed, such natural phenomena strongly influence all life on our planet.\n\nOur hero Vasya is quite concerned about the problems. He dec...
[{"type": "stdin_stdout", "input": "100\n-485 365 -283 769 -58 224 1000 983 13 595 -963 -267 -934 -187 -609 693 -316 431 859 -753 865 -421 861 -728 -793 621 -311 414 -101 -196 120 84 633 -362 989 94 206 19 -949 -629 489 376 -391 165 50 22 -209 735 565 61 -321 -256 890 34 343 -326 984 -268 -609 385 717 81 372 -391 271 -...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPhone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-3...
[{"type": "stdin_stdout", "input": "100\n4004223124942730640235383244438257614581534320356060987241659784249551110165034719443327659510644224\n", "output": "40-04-22-31-24-94-27-30-64-02-35-38-32-44-43-82-57-61-45-81-53-43-20-35-60-60-98-72-41-65-97-84-24-95-51-11-01-65-03-47-19-44-33-27-65-95-10-64-42-24\n"}, {"type":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFarmer John has just given the cows a program to play with! The program contains two integer variables, x and y, and performs the following operations on a sequence a1, a2, ..., an of positive integers:\n\n 1. Initially,...
[{"type": "stdin_stdout", "input": "98\n94 24 17 92 275858941 58 91 57 13 468038892 42 195790073 494005784 8 468106970 518962936 33 27 61 72 42 206673418 10 82 23 34 29 77 90 39 9 67 34 71 29 95 49 48 60 69 86 64 94 77 48 74 19 96700186 5 67 881058074 663483223 64 64 78 23 8 60 7 17 96 71 70 20 5 63 35 34 63 30 86 76 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo players are playing a game. First each of them writes an integer from 1 to 6, and then a dice is thrown. The player whose written number got closer to the number on the dice wins. If both payers have the same differen...
[{"type": "stdin_stdout", "input": "2 5\n", "output": "3 0 3\n"}, {"type": "stdin_stdout", "input": "2 4\n", "output": "2 1 3\n"}, {"type": "stdin_stdout", "input": "6 5\n", "output": "1 0 5\n"}, {"type": "stdin_stdout", "input": "1 4\n", "output": "2 0 4\n"}, {"type": "stdin_stdout", "input": "4 1\n", "output": "4 0 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of A. Also there are m roads connecting the cities. One can go from city ui to vi (and vise versa) using t...
[{"type": "stdin_stdout", "input": "3 3 6\n1 2 499999999\n2 3 500000000\n1 3 999999999\n2 499999999\n2 500000000\n2 499999999\n3 999999999\n3 1000000000\n3 1000000000\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "3 3 6\n1 2 499999999\n2 3 500000000\n2 3 999999999\n2 499999999\n2 500000000\n2 499999999\n3 999...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya decided to learn to play chess. Classic chess doesn't seem interesting to him, so he plays his own sort of chess.\n\nThe queen is the piece that captures all squares on its vertical, horizontal and diagonal lines. I...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "white\n1 2\n"}, {"type": "stdin_stdout", "input": "1000000010\n", "output": "white\n1 2\n"}, {"type": "stdin_stdout", "input": "1823733270\n", "output": "white\n1 2\n"}, {"type": "stdin_stdout", "input": "1381061568\n", "output": "white\n1 2\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnya has bought a new smartphone that uses Berdroid operating system. The smartphone menu has exactly n applications, each application has its own icon. The icons are located on different screens, one screen contains k ic...
[{"type": "stdin_stdout", "input": "71 96 75634\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71\n27 26 27 26 27 26 27 26 27 26 27 26 27 26 27 26 27 26 27 26 27 26 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVector Willman and Array Bolt are the two most famous athletes of Byteforces. They are going to compete in a race with a distance of L meters today.\n\n<image>\n\nWillman and Bolt have exactly the same speed, so when they...
[{"type": "stdin_stdout", "input": "5000000000000000000 4999999999999999837 4999999999999999963\n", "output": "1249999999999999959/1250000000000000000\n"}, {"type": "stdin_stdout", "input": "5000000000000000000 2229502307241477700 4999999999999999963\n", "output": "2229502307241477699/5000000000000000000\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.\n\nOnce upon a time, he found a huge snowflake that has a form of the tree (...
[{"type": "stdin_stdout", "input": "7 4\n1 1 3 3 5 3\n1\n2\n3\n5\n", "output": "3\n2\n3\n6\n"}, {"type": "stdin_stdout", "input": "7 4\n1 1 3 3 4 3\n1\n2\n3\n5\n", "output": "3\n2\n3\n5\n"}, {"type": "stdin_stdout", "input": "7 4\n1 1 3 3 4 3\n1\n4\n3\n5\n", "output": "3\n6\n3\n5\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFox Ciel saw a large field while she was on a bus. The field was a n × m rectangle divided into 1 × 1 cells. Some cells were wasteland, and other each cell contained crop plants: either carrots or kiwis or grapes. \n\nAft...
[{"type": "stdin_stdout", "input": "31 31 31 4\n15 26\n29 15\n17 31\n29 21\n21 3\n9 27\n19 20\n8 19\n5 4\n1 16\n6 17\n5 24\n1 4\n27 30\n16 24\n14 29\n24 31\n6 20\n2 20\n12 26\n26 15\n23 8\n29 10\n11 8\n3 7\n2 26\n15 10\n15 24\n6 10\n31 22\n12 2\n10 3\n6 24\n23 12\n19 1\n", "output": "Grapes\nCarrots\nCarrots\nCarrots\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAttention: we lost all the test cases for this problem, so instead of solving the problem, we need you to generate test cases. We're going to give you the answer, and you need to print a test case that produces the given ...
[{"type": "stdin_stdout", "input": "100000\n", "output": "199998 2\n1 2"}, {"type": "stdin_stdout", "input": "99971\n", "output": "199940 2\n1 2\n"}, {"type": "stdin_stdout", "input": "65535\n", "output": "131068 2\n1 2\n"}, {"type": "stdin_stdout", "input": "65537\n", "output": "131072 2\n1 2\n"}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a with n distinct integers. Construct an array b by permuting a such that for every non-empty subset of indices S = {x1, x2, ..., xk} (1 ≤ xi ≤ n, 0 < k < n) the sums of elements on that positions i...
[{"type": "stdin_stdout", "input": "22\n133295371 188010892 71730560 209842234 193069109 184556873 87395258 234247052 230809052 211444018 148989732 17810977 158722706 11753932 100093528 1000000000 43672080 61357581 171830832 13873487 34865589 114340079\n", "output": "148989732 193069109 87395258 211444018 209842234 188...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBash likes playing with arrays. He has an array a1, a2, ... an of n integers. He likes to guess the greatest common divisor (gcd) of different segments of the array. Of course, sometimes the guess is not correct. However,...
[{"type": "stdin_stdout", "input": "5\n2 4 3 4 5\n6\n1 1 4 2\n2 3 12\n1 1 4 4\n1 1 5 2\n2 5 10\n1 1 5 2\n", "output": "YES\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "5\n2 2 3 4 5\n6\n1 1 4 2\n2 3 6\n1 1 4 2\n1 1 5 2\n2 5 10\n1 1 5 2\n", "output": "YES\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe weather is fine today and hence it's high time to climb the nearby pine and enjoy the landscape.\n\nThe pine's trunk includes several branches, located one above another and numbered from 2 to y. Some of them (more pr...
[{"type": "stdin_stdout", "input": "1000000000 1000100000\n", "output": "1000099999\n"}, {"type": "stdin_stdout", "input": "1000000000 1000101000\n", "output": "1000100999\n"}, {"type": "stdin_stdout", "input": "1013025570 1803009236\n", "output": "1803009227\n"}, {"type": "stdin_stdout", "input": "649229491 1684787431...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array of positive integers. While there are at least two equal elements, we will perform the following operation. We choose the smallest value x that occurs in the array 2 or more times. Take the first tw...
[{"type": "stdin_stdout", "input": "34\n967614464 967614464 1000000000 1000000000 1000000000 1000000000 1000000000 1010000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Monk wants to buy some cities. To buy two cities, he needs to buy the road connecting those two cities. Now, you are given a list of roads, bought by the Monk. You need to tell how many cities did the Monk buy.\n\nInp...
[{"type": "stdin_stdout", "input": "1\n3\n1 2\n2 3\n1 3\n\nSAMPLE", "output": "3\n"}, {"type": "stdin_stdout", "input": "1\n3\n2 2\n2 3\n1 3\n\nSAMPLE", "output": "3\n"}, {"type": "stdin_stdout", "input": "1\n3\n2 3\n2 3\n1 3\n\nSAMPLE", "output": "3\n"}, {"type": "stdin_stdout", "input": "1\n3\n2 3\n2 3\n1 2\n\nSAMPLE...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRoy frequently needs to use his old Nokia cell phone for texting whose keypad looks exactly as shown below. \n\nYou may be already familiar with the working of the keypad, however if you're not we shall see a few example...
[{"type": "stdin_stdout", "input": "10\no3fmci,o2p\nc8tllmhzg7\n747kdw9lo3\nsj8cz3cvmo\ns3szaonxca\npir_be2g1p\n23?behplex\nd4hiyu65r6\n6rtnnrjj0!\n7u7mlvsfd0", "output": "36\n35\n42\n39\n36\n33\n35\n38\n31\n38\n"}, {"type": "stdin_stdout", "input": "10\no3fmci,o2p\nc8tllmhzg7\n747kdw9lo3\nsj8cz3cvmo\ns3szaonxca\npir_b...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:\n\n* 1 \\leq x,y,z\n* x^2 + y^2 + z^2 + xy + yz + zx = n\n\n\n\nGiven an integer N, find each of f(1),f(2),f(3),\\ldots,...
[{"type": "stdin_stdout", "input": "743", "output": "0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n0\n0\n0\n1\n6\n0\n3\n0\n0\n0\n0\n0\n3\n3\n6\n0\n0\n3\n0\n0\n0\n0\n3\n3\n6\n0\n6\n0\n0\n0\n3\n0\n0\n1\n6\n0\n6\n6\n0\n0\n6\n0\n0\n0\n0\n3\n3\n3\n6\n0\n6\n3\n6\n0\n0\n0\n6\n0\n0\n0\n3\n3\n9\n0\n6\n3\n6\n0\n3\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven are a positive integer N and a sequence of length 2^N consisting of 0s and 1s: A_0,A_1,\\ldots,A_{2^N-1}. Determine whether there exists a closed curve C that satisfies the condition below for all 2^N sets S \\subse...
[{"type": "stdin_stdout", "input": "2\n1110", "output": "Possible\n20\n0 0\n1 0\n1 1\n2 1\n2 0\n1 0\n0 0\n0 1\n1 1\n1 0\n0 0\n1 0\n2 0\n2 1\n1 1\n1 0\n0 0\n1 0\n1 1\n0 1\n0 0\n"}, {"type": "stdin_stdout", "input": "2\n1100", "output": "Possible\n6\n0 0\n1 0\n1 1\n2 1\n2 0\n1 0\n0 0\n"}, {"type": "stdin_stdout", "input"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe squirrel Chokudai has N acorns. One day, he decides to do some trades in multiple precious metal exchanges to make more acorns.\n\nHis plan is as follows:\n\n1. Get out of the nest with N acorns in his hands.\n2. Go t...
[{"type": "stdin_stdout", "input": "23\n1 2 1\n20 1 10", "output": "920\n"}, {"type": "stdin_stdout", "input": "23\n1 2 4\n10 1 4", "output": "460\n"}, {"type": "stdin_stdout", "input": "23\n1 12 1\n1 1 1", "output": "276\n"}, {"type": "stdin_stdout", "input": "23\n2 11 1\n2 1 2", "output": "506\n"}, {"type": "stdin_st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have three tasks, all of which need to be completed.\n\nFirst, you can complete any one task at cost 0.\n\nThen, just after completing the i-th task, you can complete the j-th task at cost |A_j - A_i|.\n\nHere, |x| de...
[{"type": "stdin_stdout", "input": "100 100 000", "output": "100\n"}, {"type": "stdin_stdout", "input": "100 111 000", "output": "111\n"}, {"type": "stdin_stdout", "input": "100 111 001", "output": "110\n"}, {"type": "stdin_stdout", "input": "100 111 010", "output": "101\n"}, {"type": "stdin_stdout", "input": "110 001 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total?\n\nCoins of the same kind cannot be distingu...
[{"type": "stdin_stdout", "input": "30\n40\n77\n6000", "output": "293\n"}, {"type": "stdin_stdout", "input": "30\n47\n77\n6000", "output": "319\n"}, {"type": "stdin_stdout", "input": "30\n112\n134\n6415", "output": "0\n"}, {"type": "stdin_stdout", "input": "30\n112\n134\n8208", "output": "0\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N towns in the State of Atcoder, connected by M bidirectional roads.\n\nThe i-th road connects Town A_i and B_i and has a length of C_i.\n\nJoisino is visiting R towns in the state, r_1,r_2,..,r_R (not necessari...
[{"type": "stdin_stdout", "input": "4 6 3\n2 3 4\n1 2 4\n2 3 6\n4 3 1\n1 4 1\n4 2 2\n3 1 6", "output": "3\n"}, {"type": "stdin_stdout", "input": "4 6 3\n2 3 4\n1 2 4\n2 3 6\n4 3 1\n1 4 1\n4 1 2\n3 1 6", "output": "7\n"}, {"type": "stdin_stdout", "input": "4 6 3\n2 3 4\n1 2 4\n2 3 6\n4 4 1\n1 4 1\n4 2 2\n3 1 6", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe will call a string x good if it satisfies the following condition:\n\n* Condition: x can be represented as a concatenation of two copies of another string y of length at least 1.\n\n\n\nFor example, `aa` and `bubobubo`...
[{"type": "stdin_stdout", "input": "2014", "output": "38\n19 17 15 13 11 8 6 4 2 1 3 5 7 9 10 12 14 16 18 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19\n"}, {"type": "stdin_stdout", "input": "3302", "output": "36\n18 16 14 10 8 6 2 1 3 4 5 7 9 11 12 13 15 17 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a permutation p of the set {1, 2, ..., N}. Please construct two sequences of positive integers a_1, a_2, ..., a_N and b_1, b_2, ..., b_N satisfying the following conditions:\n\n* 1 \\leq a_i, b_i \\leq 10^9 ...
[{"type": "stdin_stdout", "input": "3\n2 3 1", "output": "5 10 100\n100 10 1"}, {"type": "stdin_stdout", "input": "3\n0 -1 -2", "output": "3 5 6\n6 3 1\n"}, {"type": "stdin_stdout", "input": "3\n-2 -1 0", "output": "1 3 6\n6 5 3\n"}, {"type": "stdin_stdout", "input": "3\n0 -2 -1", "output": "2 5 6\n6 4 1\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a program that extracts n different numbers from the numbers 0 to 9 and outputs the number of combinations that add up to s. Each n number is from 0 to 9, and the same number cannot be used in one combination. For e...
[{"type": "stdin_stdout", "input": "4 14\n3 1\n0 0", "output": "13\n0\n"}, {"type": "stdin_stdout", "input": "3 10\n5 -2\n0 0", "output": "8\n0\n"}, {"type": "stdin_stdout", "input": "2 -1\n13 1\n0 0", "output": "0\n0\n"}, {"type": "stdin_stdout", "input": "3 -1\n13 1\n0 0", "output": "0\n0\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAn autumn sports festival is held. There are four events: foot race, ball-carrying, obstacle race, and relay. There are n teams participating, and we would like to commend the team with the shortest total time in this 4th...
[{"type": "stdin_stdout", "input": "8\n65541 3 20 3 8 6 27 2 25\n20941 3 5 2 41 7 19 2 42\n90585 4 8 3 12 11 46 2 34\n92201 3 28 2 47 6 37 2 58\n10001 3 50 2 42 7 12 4 54\n63812 4 11 3 11 6 98 2 22\n54092 3 33 2 54 6 18 2 19\n25012 3 44 2 58 6 45 2 46\n4\n1 3 23 1 23 1 34 4 69\n2 5 12 2 12 3 41 2 29\n3 5 24 1 24 2 0 3 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nAt the JOI pasta shop, the recommended pasta for lunch and the set menu of freshly squeezed juice are popular. When ordering this set menu, choose one from each of the three pasta and two juices of the day. The...
[{"type": "stdin_stdout", "input": "800\n1126\n900\n198\n330", "output": "948\n"}, {"type": "stdin_stdout", "input": "800\n1126\n900\n132\n330", "output": "882\n"}, {"type": "stdin_stdout", "input": "800\n1126\n206\n132\n330", "output": "288\n"}, {"type": "stdin_stdout", "input": "800\n1126\n180\n132\n330", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter having drifted about in a small boat for a couple of days, Akira Crusoe Maeda was finally cast ashore on a foggy island. Though he was exhausted and despaired, he was still fortunate to remember a legend of the fogg...
[{"type": "stdin_stdout", "input": "2 1 1\n1 1 nn\n2 1 np\n3 2 1\n1 1 yes\n2 2 yes\n3 1 yes\n2 4 1\n1 2 yes\n2 3 no\n5 4 3\n1 2 yes\n1 3 no\n4 5 yes\n5 6 yes\n6 7 no\n0 0 0", "output": "no\n1\n3\nend\n1\n2\n4\n5\nend\n3\n4\n5\n6\nend\n"}, {"type": "stdin_stdout", "input": "2 1 1\n1 1 nn\n2 1 np\n3 2 1\n1 1 yes\n2 2 yes...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\n4 3\n1000 1\n2000 2\n3000 3\n\n\nOutput\n\n2 3 4 4\n\nThe input will be given via stdin and the output should be printed to stdout by your code.\n\nNow solve the problem by providing the code.\n\nWrite...
[{"type": "stdin_stdout", "input": "25 1\n1010 1\n3784 7\n3000 6", "output": "2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n"}, {"type": "stdin_stdout", "input": "25 2\n1011 2\n2889 1\n308 2", "output": "3 3 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n"}, {"type": "stdin_stdout", "input": "20 3\n0010 1\n4107 3\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nC: Acrophobia\n\nYayoi Takasugi is a super-selling idol. There is one thing she is not good at. It's a high place ... She is extremely afraid of heights. This time, due to the producer's inadequacy, she decided to take on...
[{"type": "stdin_stdout", "input": "3 4\nM.S\n...\n...\nM.G", "output": "7\n"}, {"type": "stdin_stdout", "input": "3 4\nM.S\n...\n...\nG.M", "output": "9\n"}, {"type": "stdin_stdout", "input": "3 4\nS.N\n...\n...\nM.G", "output": "5\n"}, {"type": "stdin_stdout", "input": "3 4\nM.S\n...\n...\nMG.", "output": "6\n"}, {"t...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nC --Dowsing Machine\n\nStory\n\nPeople make noise with X and Y, but the coming era will be \"D\". \"Paklin Monster D\" is a very popular game in which \"D people\" search for treasure using the \"D machine\" developed by ...
[{"type": "stdin_stdout", "input": "6 10 3 4\n##########\n#........#\n#...D....\"\n\"....-...#\n#........#\n####\"#####\n2 4 11\n3 0 -1\n7 10 2\n15 4 3\n0 8 1", "output": "Broken\n"}, {"type": "stdin_stdout", "input": "6 10 -1 4\n##########\n#........#\n#...D....\"\n\"....-...#\n#........#\n####\"#####\n2 4 11\n3 0 0\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nB: 階層的計算機 (Hierarchical Calculator)\n\nProblem\n\nEbi-chan has N formulae: y = a_i x for i =1, ..., N (inclusive). Now she considers a subsequence of indices with length k: s_1, s_2, ..., s_k. At first, let x_0 be 1 and e...
[{"type": "stdin_stdout", "input": "4\n-1 2 -2 2", "output": "4\n1\n2\n3\n4\n"}, {"type": "stdin_stdout", "input": "4\n2 -1 -2 -1", "output": "3\n1\n2\n3\n"}, {"type": "stdin_stdout", "input": "4\n2 -1 -2 1", "output": "3\n1\n2\n3\n"}, {"type": "stdin_stdout", "input": "4\n-1 -2 0 2", "output": "3\n1\n2\n4\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDraw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'.\n\nConstraints\n\n* 1 ≤ H ≤ 300\n* 1 ≤ W ≤ 300\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists ...
[{"type": "stdin_stdout", "input": "8 2\n5 22\n4 -2\n0 0", "output": "##\n##\n##\n##\n##\n##\n##\n##\n\n######################\n######################\n######################\n######################\n######################\n\n\n\n\n\n\n"}, {"type": "stdin_stdout", "input": "3 4\n15 6\n2 4\n0 0", "output": "####\n####\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKattapa, as you all know was one of the greatest warriors of his time. The kingdom of Maahishmati had never lost a battle under him (as army-chief), and the reason for that was their really powerful army, also called as M...
[{"type": "stdin_stdout", "input": "5\n12 -1 -2 -2 -2", "output": "READY FOR BATTLE\n"}, {"type": "stdin_stdout", "input": "5\n2 -1 -2 -2 -2", "output": "READY FOR BATTLE\n"}, {"type": "stdin_stdout", "input": "5\n2 -1 -1 -2 -2", "output": "READY FOR BATTLE\n"}, {"type": "stdin_stdout", "input": "5\n4 -1 -1 -2 -2", "ou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer sequence a_1, a_2, ..., a_n.\n\nFind the number of pairs of indices (l, r) (1 ≤ l ≤ r ≤ n) such that the value of median of a_l, a_{l+1}, ..., a_r is exactly the given number m.\n\nThe median of a...
[{"type": "stdin_stdout", "input": "15 2\n1 2 3 1 2 3 1 2 3 1 2 3 1 2 3\n", "output": "97\n"}, {"type": "stdin_stdout", "input": "15 1\n1 2 3 1 2 3 1 2 3 1 2 3 1 2 3\n", "output": "18\n"}, {"type": "stdin_stdout", "input": "15 1\n1 2 3 0 2 3 1 2 3 1 2 3 1 2 3\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "15...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a, consisting of n positive integers.\n\nLet's call a concatenation of numbers x and y the number that is obtained by writing down numbers x and y one right after another without changing the order....
[{"type": "stdin_stdout", "input": "100 3\n14717 1461 5753 7023 6804 1826 8793 9148 9920 240 8768 15059 11439 2732 794 959 9744 2253 3273 4685 4730 6873 11982 2875 1303 2535 4901 147 8587 339 4792 154 3104 6020 10358 5537 2686 6208 9494 1826 8083 1269 1841 6210 538 3105 4092 5163 9696 9013 2153 3985 2787 4471 1170 4991...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...\n\nWhereas on the other end of the world Pentagon is ac...
[{"type": "stdin_stdout", "input": "100 66\n41 14\n19 13\n70 43\n79 62\n9 62\n71 40\n53 86\n80 4\n34 33\n72 68\n40 96\n84 59\n36 77\n55 50\n40 3\n79 81\n3 83\n33 47\n22 98\n33 90\n56 49\n69 28\n73 30\n65 22\n98 20\n9 52\n69 20\n32 70\n51 80\n63 12\n21 48\n35 17\n48 87\n25 43\n65 80\n42 3\n86 17\n95 98\n43 59\n51 46\n66...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has got an array consisting of n integers, and two integers k and len in addition. All numbers in the array are either between 1 and k (inclusive), or equal to -1. The array is good if there is no segment of len con...
[{"type": "stdin_stdout", "input": "10 42 7\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1\n", "output": "645711643\n"}, {"type": "stdin_stdout", "input": "10 32 7\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1\n", "output": "61884984"}, {"type": "stdin_stdout", "input": "10 32 1\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1\n", "output": "0"}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently a Golden Circle of Beetlovers was found in Byteland. It is a circle route going through n ⋅ k cities. The cities are numerated from 1 to n ⋅ k, the distance between the neighboring cities is exactly 1 km.\n\nSerg...
[{"type": "stdin_stdout", "input": "100000 100000\n50000 6424\n", "output": "1250000000 1250000000\n"}, {"type": "stdin_stdout", "input": "100000 101000\n50000 6424\n", "output": "39453125 1262500000\n"}, {"type": "stdin_stdout", "input": "98752 97209\n41218 39020\n", "output": "21427641 3199861056\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice and Bob are playing a game on a line with n cells. There are n cells labeled from 1 through n. For each i from 1 to n-1, cells i and i+1 are adjacent.\n\nAlice initially has a token on some cell on the line, and Bob...
[{"type": "stdin_stdout", "input": "50 75\n2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "50 75\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n products in the shop. The price of the i-th product is a_i. The owner of the shop wants to equalize the prices of all products. However, he wants to change prices smoothly.\n\nIn fact, the owner of the shop ca...
[{"type": "stdin_stdout", "input": "5\n8 19551489\n31131899 17585660 3913937 14521321 9846714 96097161 115568124 35051437\n1 93900441\n15578410\n7 19560555\n124492495 53703939 20259503 99698023 98868060 83313210 5487534\n6 72321938\n59271765 72426489 16625497 51598082 31475864 20946400\n7 44965081\n49955408 62397026 39...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAmugae is in a very large round corridor. The corridor consists of two areas. The inner area is equally divided by n sectors, and the outer area is equally divided by m sectors. A wall exists between each pair of sectors ...
[{"type": "stdin_stdout", "input": "1 1 10\n1 1 1 1\n1 1 1 1\n1 1 2 1\n1 1 1 1\n2 1 2 1\n2 1 1 1\n1 1 2 1\n1 1 2 1\n2 1 1 1\n2 1 1 1\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "999999937 999999874000003969 1\n1 1940776430 2 983249032983207370\n", "output": "NO...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nUjan has a lot of useless stuff in his drawers, a considerable part of which are his math notebooks: it is time to sort them out. This time he found an old dusty graph theory notebook with a description of a graph.\n\nIt ...
[{"type": "stdin_stdout", "input": "15 10\n2 3\n5 4\n5 6\n5 7\n3 8\n3 10\n11 12\n12 13\n13 14\n14 15\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "15 10\n2 3\n5 4\n5 4\n5 7\n3 8\n3 10\n11 12\n12 13\n13 14\n14 15\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "15 10\n2 3\n5 4\n5 4\n5 7\n3 7\n3 10\n11...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two integers n and k. Your task is to find if n can be represented as a sum of k distinct positive odd (not divisible by 2) integers or not.\n\nYou have to answer t independent test cases.\n\nInput\n\nThe fi...
[{"type": "stdin_stdout", "input": "11\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "11\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n8 2\n4 2\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLeo has developed a new programming language C+=. In C+=, integer variables can only be changed with a \"+=\" operation that adds the right-hand side value to the left-hand side variable. For example, performing \"a += b\...
[{"type": "stdin_stdout", "input": "16\n1 1 1\n3 4 6\n4 5 16\n456 123 7890123\n1 1 1000000000\n45 12 782595420\n1 1000000000 1001000000\n1 999999999 1000000100\n1 99999 676497416\n5 6 1409378894\n8 9 1376775908\n500000000 500000000 1000000000\n1000000000 1000000000 1000000000\n999999999 1000000000 1000000000\n1066 1487...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's call left cyclic shift of some string t_1 t_2 t_3 ... t_{n - 1} t_n as string t_2 t_3 ... t_{n - 1} t_n t_1.\n\nAnalogically, let's call right cyclic shift of string t as string t_n t_1 t_2 t_3 ... t_{n - 1}.\n\nLet...
[{"type": "stdin_stdout", "input": "3\n142345\n100120013\n253858690946\n", "output": "4\n5\n8\n"}, {"type": "stdin_stdout", "input": "3\n175995\n155501496\n289014129764\n", "output": "4\n6\n8\n"}, {"type": "stdin_stdout", "input": "3\n142345\n100120013\n339309424207\n", "output": "4\n5\n8\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a string s consisting of n characters. Each character is either 0 or 1.\n\nYou can perform operations on the string. Each operation consists of two steps:\n\n 1. select an integer i from 1 to the length of the s...
[{"type": "stdin_stdout", "input": "5\n6\n111010\n1\n0\n1\n1\n2\n11\n6\n101010\n", "output": "3\n1\n1\n1\n3\n"}, {"type": "stdin_stdout", "input": "5\n6\n111010\n1\n1\n1\n1\n2\n11\n6\n101010\n", "output": "3\n1\n1\n1\n3\n"}, {"type": "stdin_stdout", "input": "5\n6\n111000\n1\n1\n1\n1\n2\n11\n6\n101010\n", "output": "2\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a binary string a of length n. In one operation, you can select any prefix of a with an equal number of 0 and 1 symbols. Then all symbols in the prefix are inverted: each 0 becomes 1 and each 1 becomes 0.\n\nFor ...
[{"type": "stdin_stdout", "input": "5\n10\n0111010000\n0100101100\n4\n0000\n0000\n3\n001\n000\n12\n010101010101\n100110011010\n6\n000111\n110100\n", "output": "\nYES\nYES\nNO\nYES\nNO\n"}, {"type": "stdin_stdout", "input": "5\n10\n0111010000\n0100101100\n4\n0000\n0000\n3\n000\n000\n12\n010101010101\n100110011010\n6\n00...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nParsa has a humongous tree on n vertices.\n\nOn each vertex v he has written two integers l_v and r_v.\n\nTo make Parsa's tree look even more majestic, Nima wants to assign a number a_v (l_v ≤ a_v ≤ r_v) to each vertex v ...
[{"type": "stdin_stdout", "input": "3\n2\n2 10\n6 6\n1 2\n3\n1 3\n13 6\n7 15\n1 2\n2 3\n6\n10 14\n12 20\n21 19\n2 12\n10 17\n3 17\n3 2\n6 5\n1 5\n2 6\n4 6\n", "output": "4\n18\n48\n"}, {"type": "stdin_stdout", "input": "3\n2\n0 6\n3 13\n1 2\n3\n1 3\n10 6\n12 9\n1 2\n2 3\n6\n3 14\n9 20\n12 19\n1 12\n11 17\n3 17\n3 3\n6 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n piles of stones of sizes a1, a2, ..., an lying on the table in front of you.\n\nDuring one move you can take one pile and add it to the other. As you add pile i to pile j, the size of pile j increases by the c...
[{"type": "stdin_stdout", "input": "2\n2 9\n5\n4 10 7 3 4\n", "output": " 2 2 2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLenny is playing a game on a 3 × 3 grid of lights. In the beginning of the game all lights are switched on. Pressing any of the lights will toggle it and all side-adjacent lights. The goal of the game is to switch all the...
[{"type": "stdin_stdout", "input": "62 74 119\n116 74 189\n2 47 95\n", "output": "101\n110\n010\n"}, {"type": "stdin_stdout", "input": "68 79 52\n51 39 100\n29 14 26\n", "output": "110\n000\n111\n"}, {"type": "stdin_stdout", "input": "68 79 52\n67 39 100\n29 14 26\n", "output": "110\n000\n111\n"}, {"type": "stdin_stdou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe city Valera lives in is going to hold elections to the city Parliament.\n\nThe city has n districts and n - 1 bidirectional roads. We know that from any district there is a path along the roads to any other district. ...
[{"type": "stdin_stdout", "input": "10\n1 10 2\n10 7 2\n10 8 2\n9 7 2\n8 6 2\n7 5 2\n6 4 2\n5 3 2\n4 2 2\n", "output": "3\n2 3 9\n"}, {"type": "stdin_stdout", "input": "10\n3 9 1\n2 10 2\n1 7 1\n3 4 1\n7 8 2\n1 2 1\n5 3 1\n5 6 2\n2 3 2\n", "output": "3\n6 8 10\n"}, {"type": "stdin_stdout", "input": "10\n1 9 1\n3 2 2\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n'Jeopardy!' is an intellectual game where players answer questions and earn points. Company Q conducts a simplified 'Jeopardy!' tournament among the best IT companies. By a lucky coincidence, the old rivals made it to the...
[{"type": "stdin_stdout", "input": "50 30\n6015200 8643865 4116771 6555197 304415 8580071 8414182 3089212 5684567 7595481 1272699 7127763 3309618 1410297 4349070 2027355 136702 6863504 1800751 5585842 5924142 5188269 4805201 9313209 8941399 5137060 4983630 8467668 1646260 7804684 8646497 7067118 6896291 9109696 6197162...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday s kilometer long auto race takes place in Berland. The track is represented by a straight line as long as s kilometers. There are n cars taking part in the race, all of them start simultaneously at the very beginnin...
[{"type": "stdin_stdout", "input": "9 81812\n8 31 410 547 18 22 77 449 5 491 8 10 382 746 21 61 523\n1 452 181\n1 724 113\n1 113 724\n1 226 362\n46 5 257 2 126 373 6 6 491 9 7 137 23 93 73 163 13 17 106 3 100 5 415 270 2 7 723 597 4 176 3 274 18 1 852 334 14 7 25 163 1 3 199 29 140 32 32 191 2 583 3 23 11 22 23 250 1 7...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAppleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each To...
[{"type": "stdin_stdout", "input": "100 100\nMQSBDAJABILIBCUEOWGWCEXMUTEYQKAIWGINXVQEOFDUBSVULROQHQRZZAALVQFEFRAAAYUIMGCAFQGIAEFBETRECGSFQJNXHHDN\n", "output": "514\n"}, {"type": "stdin_stdout", "input": "100 90\nFAFAOOAOOAFAOTFAFAFFATAAAOFAAOAFBAAAFBOAOFFFOAOAFAPFOFAOFAAFOAAAAFAAFOFAAOFPPAAOOAAOOFFOFFFOFAOTOFAF\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a positive integer n let's define a function f:\n\nf(n) = - 1 + 2 - 3 + .. + ( - 1)nn\n\nYour task is to calculate f(n) for a given integer n.\n\nInput\n\nThe single line contains the positive integer n (1 ≤ n ≤ 1015)...
[{"type": "stdin_stdout", "input": "1000000000000000\n", "output": "500000000000000\n"}, {"type": "stdin_stdout", "input": "999999999999999\n", "output": "-500000000000000\n"}, {"type": "stdin_stdout", "input": "1000000000000100\n", "output": "500000000000050\n"}, {"type": "stdin_stdout", "input": "1100000000000100\n",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v1 meters per second, and in the end it is v2 meters per second. We know that this section of the rou...
[{"type": "stdin_stdout", "input": "100 100\n100 10\n", "output": "34500\n"}, {"type": "stdin_stdout", "input": "100 100\n100 0\n", "output": "10000\n"}, {"type": "stdin_stdout", "input": "100 100\n100 1\n", "output": "12450\n"}, {"type": "stdin_stdout", "input": "100 101\n100 1\n", "output": "12500\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases: \n\n 1. They are equal. \n 2. If we split string...
[{"type": "stdin_stdout", "input": "yhwepqwyhwepqwyhwepqweahnqtueahnqtueahnqtuyhwepqwyhwepqwyhwepqwyhwepqweahnqtueahnqtuyhwepqweahnqtueahnqtueahnqtueahnqtueahnqtueahnqtu\neahnqtueahnqtueahnqtuyhwepqweahnqtuyhwepqwyhwepqweahnqtuyhwepqweahnqtuyhwepqweahnqtueahnqtuyhwepqweahnqtueahnqtuyhwepqwyhwepqwyhwepqw\n", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMikhail the Freelancer dreams of two things: to become a cool programmer and to buy a flat in Moscow. To become a cool programmer, he needs at least p experience points, and a desired flat in Moscow costs q dollars. Mikha...
[{"type": "stdin_stdout", "input": "10 468662 93838\n589910 727627\n279516 867207\n470524 533177\n467834 784167\n295605 512137\n104422 629804\n925609 728473\n922365 500342\n998983 958315\n425628 935048\n", "output": "0.46913911413370062986\n"}, {"type": "stdin_stdout", "input": "10 468662 93838\n589910 727627\n279516 8...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider a linear function f(x) = Ax + B. Let's define g(0)(x) = x and g(n)(x) = f(g(n - 1)(x)) for n > 0. For the given integer values A, B, n and x find the value of g(n)(x) modulo 109 + 7.\n\nInput\n\nThe only line con...
[{"type": "stdin_stdout", "input": "1377612828 606974665 846646545585165081 745145208\n", "output": "891861122\n"}, {"type": "stdin_stdout", "input": "978837295 606974665 846646545585165081 745145208\n", "output": "154788991\n"}, {"type": "stdin_stdout", "input": "1 1000000000 1000000000000000000 1000000000\n", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n\"Night gathers, and now my watch begins. It shall not end until my death. I shall take no wife, hold no lands, father no children. I shall wear no crowns and win no glory. I shall live and die at my post. I am the sword ...
[{"type": "stdin_stdout", "input": "205\n5 5 3 3 6 2 9 3 8 9 6 6 10 8 1 5 3 3 1 2 9 9 9 3 9 10 3 9 8 3 5 6 6 4 6 9 2 9 10 9 5 6 6 7 4 2 6 3 4 1 10 1 7 2 7 7 3 2 6 5 5 2 9 3 8 8 7 6 6 4 2 2 6 2 3 5 7 2 2 10 1 4 6 9 2 3 7 2 2 7 4 4 9 10 7 5 8 6 5 3 6 10 2 7 5 6 6 8 3 3 9 4 3 5 7 9 3 2 1 1 3 2 1 9 3 1 4 4 10 2 5 5 8 1 4 8...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSome people leave the lights at their workplaces on when they leave that is a waste of resources. As a hausmeister of DHBW, Sagheer waits till all students and professors leave the university building, then goes and turns...
[{"type": "stdin_stdout", "input": "6 77\n0111111110101011111111111111111111111111111111111111100111111111101111111111110\n0111111111111111111101111101111111111011111111011111111001011111111111101111110\n0111101111111111111111111111111111111110110011111111111011111111101111111111110\n01111101111111111111111111111111111...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMayor of city S just hates trees and lawns. They take so much space and there could be a road on the place they occupy!\n\nThe Mayor thinks that one of the main city streets could be considerably widened on account of law...
[{"type": "stdin_stdout", "input": "10\n21005 10850\n27020 13372\n28183 3724\n22874 13564\n27446 11493\n22522 10012\n24819 11529\n24166 11084\n24539 9211\n24152 9235\n", "output": "71869\n31855 31856 31857 31858 31859 31860 31861 31862 31863 31864 \n"}, {"type": "stdin_stdout", "input": "10\n21005 10850\n27020 13372\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider a [billiard table](https://en.wikipedia.org/wiki/Billiard_table) of rectangular size n × m with four pockets. Let's introduce a coordinate system with the origin at the lower left corner (see the picture). \n\n<i...
[{"type": "stdin_stdout", "input": "1000000000 999999999 999999998 999999999 -1 -1\n", "output": "1000000000 999999999\n"}, {"type": "stdin_stdout", "input": "1000000000 999999999 999999998 999999999 -1 1\n", "output": "1000000000 999999999\n"}, {"type": "stdin_stdout", "input": "1000000000 999999999 999999998 30402322...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAshima's mid term exams are just over. Since, its raining heavily outside, she can't go shopping.\nSo, she and her best friend Aishwarya have now decided to chill out by eating pizza, chocolates, biscuits, etc.. and playi...
[{"type": "stdin_stdout", "input": "1272\n4 65 44\n5 47 2\n0 59 20\n2 41 14\n2 30 17\n2 26 22\n3 44 6\n4 65 10\n5 27 1\n6 0 31\n3 47 1\n6 16 26\n3 30 2\n7 49 12\n1 6 34\n7 48 9\n4 23 4\n7 7 7\n6 38 22\n3 34 32\n6 66 28\n3 61 2\n1 33 6\n3 11 33\n2 62 17\n7 52 29\n5 48 30\n2 30 18\n3 60 15\n7 38 5\n2 26 24\n7 51 29\n4 25...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRufus wants to go to the Lily's birthday party to surprise Lily. But Lily's party invitation has a unique code on it which is in the form X-Y(e.g. 123-456). So Rufus need a invitation but he fails to get the invitation.\n...
[{"type": "stdin_stdout", "input": "2\n3 10\n1 16\n\nSAMPLE", "output": "INVALID\nINVALID\n"}, {"type": "stdin_stdout", "input": "2\n1 16\n2 14\n\nSAMPLE", "output": "INVALID\nINVALID\n"}, {"type": "stdin_stdout", "input": "2\n7 11\n1 20\n\nELPMAS", "output": "INVALID\nINVALID\n"}, {"type": "stdin_stdout", "input": "2\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a grid of N rows and M columns. The square at the i-th row and j-th column will be denoted as (i,j). A nonnegative integer A_{i,j} is written for each square (i,j).\n\nYou choose some of the squares so that ...
[{"type": "stdin_stdout", "input": "3 1\n10 10 1\n10 10 1\n1 1 10", "output": "30\nX..\n.X.\n..X\n"}, {"type": "stdin_stdout", "input": "3 2\n10 10 1\n10 10 1\n2 1 10", "output": "50\nXX.\nXX.\n..X\n"}, {"type": "stdin_stdout", "input": "3 2\n10 10 1\n10 10 1\n1 1 17", "output": "57\nXX.\nXX.\n..X\n"}, {"type": "stdin_...
code_stdio