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\nSelection of Participants of an Experiment\n\nDr. Tsukuba has devised a new method of programming training. In order to evaluate the effectiveness of this method, he plans to carry out a control experiment. Having two stu...
[{"type": "stdin_stdout", "input": "5\n10 0 1 10 14\n5\n1 5 25 9 11\n7\n10 20 83 43 143 31 62\n0", "output": "0\n2\n10\n"}, {"type": "stdin_stdout", "input": "5\n10 10 10 10 10\n5\n1 5 8 9 11\n7\n11 34 83 47 44 29 70\n0", "output": "0\n1\n3\n"}, {"type": "stdin_stdout", "input": "5\n10 10 10 1 10\n5\n1 5 8 13 11\n7\n11...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTaro has decided to move. Taro has a lot of luggage, so I decided to ask a moving company to carry the luggage. Since there are various weights of luggage, I asked them to arrange them in order from the lightest one for e...
[{"type": "stdin_stdout", "input": "8\n7 2 1 3 8 5 4 6", "output": "20\n"}, {"type": "stdin_stdout", "input": "8\n5 2 1 3 8 6 4 7", "output": "18\n"}, {"type": "stdin_stdout", "input": "8\n6 4 1 1 8 5 4 7", "output": "20\n"}, {"type": "stdin_stdout", "input": "8\n6 2 1 3 8 5 4 7", "output": "19"}, {"type": "stdin_stdou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCurry making\n\nAs the ACM-ICPC domestic qualifying is approaching, you who wanted to put more effort into practice decided to participate in a competitive programming camp held at a friend's house. Participants decided t...
[{"type": "stdin_stdout", "input": "10 5 3 4\n1 6 2 3\n150 13 7 62\n10 1 3 5\n20 100 3 20\n2 14 13 1\n0 0 0 0", "output": "2\n4\n0\n0\n14\n180\n"}, {"type": "stdin_stdout", "input": "10 5 3 4\n1 5 2 3\n150 13 12 62\n10 1 11 5\n20 100 3 20\n3 14 3 1\n0 0 0 0", "output": "2\n3\n1\n1\n14\n39\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRevised\n\nThe current era, Heisei, will end on April 30, 2019, and a new era will begin the next day. The day after the last day of Heisei will be May 1, the first year of the new era.\n\nIn the system developed by the A...
[{"type": "stdin_stdout", "input": "HEISEI 1 0 0\nHEISEI 31 4 2\nIETEIH 31 5 3\nIFISEH 142 12 42\nHEISEI 15 8 30\nIEJSEH 103 2 42\nHEISEI 3 3 14\nHEISEI 28 2 23\n#", "output": "HEISEI 1 0 0\nHEISEI 31 4 2\n? 1 5 3\n? 112 12 42\nHEISEI 15 8 30\n? 73 2 42\nHEISEI 3 3 14\nHEISEI 28 2 23\n"}, {"type": "stdin_stdout", "inpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nGiven the strings $ s $, $ t $.\nFirst, let the string set $ A = $ {$ s $}, $ B = \\ phi $.\nAt this time, I want to perform the following operations as much as possible.\n\noperation\n\nstep1\n\nPerform the fo...
[{"type": "stdin_stdout", "input": "abaabbabaab`abbabbabaabbab\nab", "output": "2\n"}, {"type": "stdin_stdout", "input": "abaabbbbaab`abbabbabaabaab\nab", "output": "2\n"}, {"type": "stdin_stdout", "input": "abaabbbbaab`abbabbabaabaab\n`b", "output": "1\n"}, {"type": "stdin_stdout", "input": "abaabbbbaaa`abbabbabbabaab...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.\n\nConstraints\n\n* The length of the input string < 1200\n\nInput\n\nA string is given in a line.\n\nOutput\n\nPrint t...
[{"type": "stdin_stdout", "input": "f@IR, LATER, OCCASIONALLY CLOUDY.", "output": "F@ir, later, occasionally cloudy.\n"}, {"type": "stdin_stdout", "input": "f@IR, LATER, YLLANOISACCO CLOUDY.", "output": "F@ir, later, yllanoisacco cloudy.\n"}, {"type": "stdin_stdout", "input": "f@IR, LATER, OLLANOISACCY CLOUDY.", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nChef has a box full of infinite number of identical coins. One day while playing, he made N piles each containing equal number of coins. Chef suddenly remembered an important task and left the room for sometime. While he ...
[{"type": "stdin_stdout", "input": "1\n4\n1 -1 2 2", "output": "2\n"}, {"type": "stdin_stdout", "input": "1\n4\n1 1 -1 4", "output": "2\n"}, {"type": "stdin_stdout", "input": "1\n4\n1 2 2 -1", "output": "2\n"}, {"type": "stdin_stdout", "input": "1\n4\n0 2 2 -1", "output": "2\n"}, {"type": "stdin_stdout", "input": "1\n4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe sequence of integers a_1, a_2, ..., a_k is called a good array if a_1 = k - 1 and a_1 > 0. For example, the sequences [3, -1, 44, 0], [1, -99] are good arrays, and the sequences [3, 7, 8], [2, 5, 4, 1], [0] — are not....
[{"type": "stdin_stdout", "input": "4\n-2 0 4 -1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "4\n-2 0 1 -1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "4\n-2 1 5 0\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "4\n-1 0 4 1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "4\n-2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a card game called \"Durak\", which means \"Fool\" in Russian. The game is quite popular in the countries that used to form USSR. The problem does not state all the game's rules explicitly — you can find them lat...
[{"type": "stdin_stdout", "input": "H\nQH 9S\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "S\n8D 6D\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "D\n9S 8S\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "H\nTH 8H\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "H\nAH KH\n",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n houses along the road where Anya lives, each one is painted in one of k possible colors.\n\nAnya likes walking along this road, but she doesn't like when two adjacent houses at the road have the same color. Sh...
[{"type": "stdin_stdout", "input": "100 100\n82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 109 47 21 78 20 63 13 49 76 36 41 79 16 87 87 69 3 76 80 60 100 62 70 59 72 8 38 71 45 97 71 14 76 54 81 4 59 46 39 29 92 3 49 22 53 99 59 52 74 31 92 43 42 23 44 9 82 47 7 40 12 9 3 55 37 85 46 22 84 52 98 41 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\...
[{"type": "stdin_stdout", "input": "544958\n", "output": "4477777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMonocarp has got two strings s and t having equal length. Both strings consist of lowercase Latin letters \"a\" and \"b\". \n\nMonocarp wants to make these two strings s and t equal to each other. He can do the following ...
[{"type": "stdin_stdout", "input": "101\nbabbbbabbbbaabbbbbbbabbbababababbbbbbbbabaababbababbaaabbababbbbbbbbbaabbbababbbbbabbbbbabbbaabbbaabb\nbbabbbbbbabbbbbbbbbbbabbbbbbbbbbabbabbbbbbbbbbbabbababbbabbabbbbbbbbbbbbbaabbbabbbbabbabbbbababbbbbab\n", "output": "20\n2 7\n12 13\n21 25\n27 29\n31 40\n42 43\n45 50\n54 55\n5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a password which you often type — a string s of length n. Every character of this string is one of the first m lowercase Latin letters.\n\nSince you spend a lot of time typing it, you want to buy a new keyboard.\...
[{"type": "stdin_stdout", "input": "44 20\nbcdefghijklmnopqrstabcdefghijklmnopqrstatata\n", "output": "61\n"}, {"type": "stdin_stdout", "input": "44 20\ncdefghijklmnopqrstabcdefghijklmnopqrstabtata\n", "output": "62\n"}, {"type": "stdin_stdout", "input": "44 20\natatbatsrqponmlkjihgfedcbatsrqponmlkjihgfedc\n", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two strings s and t both of length n and both consisting of lowercase Latin letters.\n\nIn one move, you can choose any length len from 1 to n and perform the following operation: \n\n * Choose any contiguo...
[{"type": "stdin_stdout", "input": "4\n4\nabcd\nabdc\n5\nababa\nbaaba\n4\nasdf\nasdg\n4\nabcd\nbadc\n", "output": "NO\nYES\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "4\n4\nabcd\nabdc\n5\nababa\nabaab\n4\nasdf\nasdg\n4\nabcd\nbadc\n", "output": "NO\nYES\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "4\n4\ndabb\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe start with a string s consisting only of the digits 1, 2, or 3. The length of s is denoted by |s|. For each i from 1 to |s|, the i-th character of s is denoted by s_i. \n\nThere is one cursor. The cursor's location ℓ i...
[{"type": "stdin_stdout", "input": "9\n1500\n1212\n1500\n1221\n1500\n122\n1500\n12121\n1500\n22\n1500\n1111112111111112\n1500\n1111111111221111111\n1500\n111111122\n1500\n11111121111121111111\n", "output": "1504\n1599\n1502\n1598\n1502\n1510\n1657\n1502\n1763\n"}, {"type": "stdin_stdout", "input": "9\n1500\n1212\n1500\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given some Tetris field consisting of n columns. The initial height of the i-th column of the field is a_i blocks. On top of these columns you can place only figures of size 2 × 1 (i.e. the height of this figure i...
[{"type": "stdin_stdout", "input": "4\n3\n1 3 3\n4\n2 2 2 2\n2\n11 15\n1\n111\n", "output": "YES\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "4\n3\n1 1 3\n4\n1 1 2 1\n2\n11 11\n1\n100\n", "output": "YES\nNO\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "4\n3\n1 3 3\n4\n2 2 2 2\n2\n11 12\n1\n111\n", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAshish and Vivek play a game on a matrix consisting of n rows and m columns, where they take turns claiming cells. Unclaimed cells are represented by 0, while claimed cells are represented by 1. The initial state of the m...
[{"type": "stdin_stdout", "input": "4\n2 2\n0 0\n0 0\n2 2\n1 0\n0 0\n2 3\n0 0 0\n1 1 0\n3 3\n1 0 0\n0 0 0\n1 0 0\n", "output": "Vivek\nAshish\nAshish\nAshish\n"}, {"type": "stdin_stdout", "input": "4\n2 2\n1 0\n0 0\n2 2\n0 0\n0 1\n2 3\n1 0 1\n1 1 0\n3 3\n1 0 0\n0 0 0\n1 0 0\n", "output": "Ashish\nAshish\nVivek\nAshish\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence of n integers a_1, a_2, …, a_n.\n\nYou have to construct two sequences of integers b and c with length n that satisfy:\n\n * for every i (1≤ i≤ n) b_i+c_i=a_i \n * b is non-decreasing, which mea...
[{"type": "stdin_stdout", "input": "6\n-18 -12 -9 -10 -6 4\n3\n1 6 -9\n1 3 -10\n6 6 -3\n", "output": "3\n-2\n-2\n-4\n"}, {"type": "stdin_stdout", "input": "6\n-9 -12 -9 -6 -6 4\n3\n1 6 -9\n1 2 -10\n4 6 -3\n", "output": "4\n-1\n-1\n-2\n"}, {"type": "stdin_stdout", "input": "6\n-9 -12 -9 -10 -6 4\n3\n1 6 -9\n1 3 -10\n6 6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou found a useless array a of 2n positive integers. You have realized that you actually don't need this array, so you decided to throw out all elements of a.\n\nIt could have been an easy task, but it turned out that you...
[{"type": "stdin_stdout", "input": "6\n4\n5 6 9 13 36 42 47 60\n3\n1 2 3 4 5 6\n3\n1 2 3 3 5 6\n4\n5 22 42 47 49 54 69 123\n2\n1 1 2 2\n3\n1000000 1000000 990000 10000 900000 90000\n", "output": "YES\n69\n60 9\n47 13\n42 5\n36 6\nYES\n10\n6 4\n5 1\n3 2\nYES\n9\n6 3\n5 1\n3 2\nYES\n172\n123 49\n69 54\n47 22\n42 5\nYES\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBy 2312 there were n Large Hadron Colliders in the inhabited part of the universe. Each of them corresponded to a single natural number from 1 to n. However, scientists did not know what activating several colliders simul...
[{"type": "stdin_stdout", "input": "1 100\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Smart Beaver from ABBYY invented a new message encryption method and now wants to check its performance. Checking it manually is long and tiresome, so he decided to ask the ABBYY Cup contestants for help.\n\nA message...
[{"type": "stdin_stdout", "input": "20 15 17\n4 9 14 11 15 16 15 4 0 10 7 12 10 1 8 6 7 14 1 13\n6 3 14 8 8 11 16 4 5 9 2 13 6 14 15\n", "output": "10 1 3 8 3 15 7 14 1 12 3 10 15 16 16 5 4 15 13 11 "}, {"type": "stdin_stdout", "input": "20 15 17\n4 9 14 11 15 16 15 4 0 10 7 12 10 1 8 6 7 14 1 13\n6 3 14 8 8 11 16 4 6 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps:\n\n 1. Find the number that goes k-th in the current sequen...
[{"type": "stdin_stdout", "input": "20 20\n20 1 19 2 18 3 17 4 16 5 15 6 14 7 13 8 12 9 11 10\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "20 10\n1 2 3 4 8 6 7 10 9 10 1 1 1 1 1 1 1 1 1 1\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "20 10\n1 2 3 4 8 6 7 10 9 10 1 1 1 1 0 1 1 1 1 1\n", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nShaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is ti and its pages' width is equal to wi. The thickness o...
[{"type": "stdin_stdout", "input": "100\n2 2\n1 2\n1 5\n1 5\n1 2\n1 4\n2 3\n1 2\n1 5\n2 1\n2 2\n2 4\n1 2\n2 3\n1 1\n1 1\n2 5\n2 3\n2 2\n1 2\n2 1\n2 2\n1 5\n2 1\n2 4\n1 4\n1 4\n2 2\n1 1\n2 4\n1 4\n2 4\n1 2\n2 3\n2 3\n1 5\n1 5\n2 3\n1 4\n1 5\n2 2\n1 3\n2 2\n2 2\n1 1\n2 1\n2 5\n1 1\n2 3\n2 5\n1 5\n1 3\n1 5\n2 4\n1 5\n2 3\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have array a1, a2, ..., an. Segment [l, r] (1 ≤ l ≤ r ≤ n) is good if ai = ai - 1 + ai - 2, for all i (l + 2 ≤ i ≤ r).\n\nLet's define len([l, r]) = r - l + 1, len([l, r]) is the length of the segment [l, r]. Segment ...
[{"type": "stdin_stdout", "input": "51\n1 -1 1 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 -1 0 -1 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0\n", "output": "16\n"}, {"type": "stdin_stdout", "input": "51\n1 -1 1 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 -1 0 -1 0 0 0 0 0 0 -1 1 0 0 0 0 0 0 0\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFox Ciel is playing a game with numbers now. \n\nCiel has n positive integers: x1, x2, ..., xn. She can do the following operation as many times as needed: select two different indexes i and j such that xi > xj hold, and ...
[{"type": "stdin_stdout", "input": "100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rejoiced at the ...
[{"type": "stdin_stdout", "input": "11\n", "output": "0"}, {"type": "stdin_stdout", "input": "15\n", "output": "1"}, {"type": "stdin_stdout", "input": "13\n", "output": "1"}, {"type": "stdin_stdout", "input": "14\n", "output": "0"}, {"type": "stdin_stdout", "input": "16\n", "output": "0"}, {"type": "stdin_stdout", "inp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday Vasya visited a widely known site and learned that the continuation of his favourite game Codecraft II will appear after exactly k months. He looked at the calendar and learned that at the moment is the month number...
[{"type": "stdin_stdout", "input": "September\n0\n", "output": "September\n"}, {"type": "stdin_stdout", "input": "November\n46\n", "output": "September\n"}, {"type": "stdin_stdout", "input": "December\n240\n", "output": "December\n"}, {"type": "stdin_stdout", "input": "December\n81\n", "output": "September\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarpus got an internship in one well-known social network. His test task is to count the number of unique users who have visited a social network during the day. Polycarpus was provided with information on all user re...
[{"type": "stdin_stdout", "input": "10 3 30000\n00:06:54\n00:42:06\n03:49:45\n04:38:35\n05:33:30\n05:51:46\n10:46:34\n14:34:59\n14:40:06\n14:53:13\n", "output": "6\n1\n2\n3\n3\n3\n3\n4\n5\n6\n6\n"}, {"type": "stdin_stdout", "input": "10 3 30000\n00:06:54\n00:42:06\n03:49:45\n04:38:35\n05:33:30\n05:51:56\n10:46:34\n14:3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAndrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art.\n\nThe main exhibit is a construction of n matryoshka dolls that can be nested one in...
[{"type": "stdin_stdout", "input": "100 19\n6 62 72 83 91 94 97\n3 61 84 99\n1 63\n5 46 53 56 69 78\n5 41 43 49 74 89\n5 55 57 79 85 87\n3 47 59 98\n3 64 76 82\n3 48 66 75\n2 60 88\n2 67 77\n4 40 51 73 95\n41 1 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 44 71 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.\n...
[{"type": "stdin_stdout", "input": "sosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosos\nsos\n", "output": "20"}, {"type": "stdin_stdout", "input": "sosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosos\nsor\n", "output": "0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBearland has n cities, numbered 1 through n. Cities are connected via bidirectional roads. Each road connects two distinct cities. No two roads connect the same pair of cities.\n\nBear Limak was once in a city a and he wa...
[{"type": "stdin_stdout", "input": "1000 1577\n698 459 326 404\n", "output": "698 326 1 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 72 73 74 75 76 77 78 79 80 81 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSometimes some words like \"localization\" or \"internationalization\" are so long that writing them many times in one text is quite tiresome.\n\nLet's consider a word too long, if its length is strictly more than 10 char...
[{"type": "stdin_stdout", "input": "20\nlkpmx\nkovxmxorlgwaomlswjxlpnbvltfv\nhykasjxqyjrmybejnmeumzha\ntuevlumpqbbhbww\nqgqsphvrmupxxc\ntrissbaf\nqfgrlinkzvzqdryckaizutd\nzzqtoaxkvwoscyx\noswytrlnhpjvvnwookx\nlpuzqgec\ngyzqfwxggtvpjhzmzmdw\nrlxjgmvdftvrmvbdwudra\nvsntnjpepnvdaxiporggmglhagv\nxlvcqkqgcrbgtgglj\nlyxwxbis...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYoung Timofey has a birthday today! He got kit of n cubes as a birthday present from his parents. Every cube has a number ai, which is written on it. Timofey put all the cubes in a row and went to unpack other presents.\n...
[{"type": "stdin_stdout", "input": "42\n-557774624 828320986 -345782722 -62979938 -681259411 -945983652 -139095040 832293378 -82572118 432027535 88438103 568183540 961782904 73543295 615958219 -5050584 322982437 -146046730 759453379 129267920 -819827396 -348156048 805080102 390723009 -771277251 -79011872 -592313207 528...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMaxim wants to buy an apartment in a new house at Line Avenue of Metropolis. The house has n apartments that are numbered from 1 to n and are arranged in a row. Two apartments are adjacent if their indices differ by 1. So...
[{"type": "stdin_stdout", "input": "1000000000 333333333\n", "output": "1 666666666\n"}, {"type": "stdin_stdout", "input": "1000000000 333333334\n", "output": "1 666666666\n"}, {"type": "stdin_stdout", "input": "1000000000 596874994\n", "output": "1 403125006\n"}, {"type": "stdin_stdout", "input": "1000000000 114283913...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a rooted tree with n vertices. The vertices are numbered from 1 to n, the root is the vertex number 1.\n\nEach vertex has a color, let's denote the color of vertex v by cv. Initially cv = 0.\n\nYou have to c...
[{"type": "stdin_stdout", "input": "7\n1 1 2 3 1 4\n3 3 1 1 1 2 6\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "7\n1 1 2 3 1 5\n3 3 1 1 1 2 6\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "7\n1 1 1 3 1 5\n3 3 1 1 1 2 6\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "7\n1 1 1 3 1 5\n3 5 1 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne very experienced problem writer decided to prepare a problem for April Fools Day contest. The task was very simple - given an arithmetic expression, return the result of evaluating this expression. However, looks like...
[{"type": "stdin_stdout", "input": "101+200+195+231+107+222+146+254+160+209\n", "output": "-43175\n"}, {"type": "stdin_stdout", "input": "255+255+255+255+255+255+255+255+255+255\n", "output": "-42450\n"}, {"type": "stdin_stdout", "input": "101+200+195+230+117+222+146+254+160+209\n", "output": "-43166\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasilisa the Wise from a far away kingdom got a present from her friend Helga the Wise from a farther away kingdom. The present is a surprise box, yet Vasilisa the Wise doesn't know yet what the surprise actually is becau...
[{"type": "stdin_stdout", "input": "ROYGBV\n", "output": "30\n"}, {"type": "stdin_stdout", "input": "RRYOGB\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "YROVBG\n", "output": "30\n"}, {"type": "stdin_stdout", "input": "RYGOBG\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "VOBYGO\n", "output": "15...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJesse and Walter recently got a into a problem. They need to check if a compound can be converted to the other one.\nA compound is decoded into a binary strings of 0s and 1s. They have 2 binary strings. First string conta...
[{"type": "stdin_stdout", "input": "200\n01?0001?0??1100000000110???1011010111101010?100?11??010?1???0000000110???1010010??00\n101010000011110111111110000100111101110110010111101110000100010100010110101100111100\n?101??0101?1000??????10011????0?100111?10?01\n11011000000100010011100100100100001110101110\n?1?0????001?11?...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n\"RMS Lusitania\" was one of the world biggest ship of her time.On the outbreak of the First World War in 1914, she was commandeered by the Admiralty as an armed merchant cruiser. When Lusitania left New York for Liverpoo...
[{"type": "stdin_stdout", "input": "2\n3 \n2\n2 0 1 \n2 7 5\n4 \n7\n2 3 7 11\n4 16 26 6\n\nSOAPDL", "output": "12\n26\n"}, {"type": "stdin_stdout", "input": "2\n3 \n3\n2 0 5 \n2 4 5\n4 \n7\n2 3 7 11\n4 16 26 5\n\nSNAPEL", "output": "6\n26\n"}, {"type": "stdin_stdout", "input": "2\n3 \n3\n2 0 5 \n2 7 5\n4 \n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMarut loves good strings. According to him, good strings are those which contain either all alphabets of uppercase or lowercase.\nWhile he is preparing for his exams, he finds many bad strings in his book and wants to con...
[{"type": "stdin_stdout", "input": "1\n13054", "output": "Invalid Input\n"}, {"type": "stdin_stdout", "input": "1\n12538", "output": "Invalid Input\n"}, {"type": "stdin_stdout", "input": "1\n17004", "output": "Invalid Input\n"}, {"type": "stdin_stdout", "input": "1\n22207", "output": "Invalid Input\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRahul has set upon the quest for a new logo of his company. He has created the following continuous logo:\n\n /\\\n / \\\n / /\\ \\\n / / \\ \\\n/ / /\\ \\ \\\n \\ \\ \\/ / /\n \\ \\ / /\n \\ \\/ /\n \\...
[{"type": "stdin_stdout", "input": "81", "output": " /\\\n / \\\n / /\\ \\\n ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBangalore City, where peace prevails most of the time. Not everyone is a huge fan of peace, though. Certainly not Mr. XYZ, whose identity is not known to us - yet. Mr. XYZ has somehow managed to bring vampires and zombies...
[{"type": "stdin_stdout", "input": "100\n353 503 929 824 501 802 61 72 1170 605 837 182 175 650 241 1129 680 700 733 644 171 196 101 952 773 157 278 538 1 123 78 1091 105 188 327 51 210 388 548 184 652 4 2 549 27 769 113 710 1159 1059 40 183 350 50 514 47 904 759 385 383 971 770 273 817 209 655 268 1500 957 798 1346 27...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have an H \\times W grid, where each square is painted white or black in the initial state. Given are strings A_1, A_2, ..., A_H representing the colors of the squares in the initial state. For each pair (i, j) (1 \\le...
[{"type": "stdin_stdout", "input": "6 7\n.......\n.......\n.#.....\n..#....\n.#.#...\n.......", "output": "203949910"}, {"type": "stdin_stdout", "input": "6 2\n.......\n.......\n.#.....\n..#....\n.#.#...\n.......", "output": "1394\n"}, {"type": "stdin_stdout", "input": "6 2\n.......\n.......\n.#.....\n..#....\n.#.#/..\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \\leq i \\leq N - 1) connects Vertex a_i and b_i.\n\nEach of the vertices has a counter installed. Initially, the counters...
[{"type": "stdin_stdout", "input": "6 2\n1 2\n1 3\n2 4\n3 6\n2 5\n2 10\n1 10", "output": "10 20 10 20 20 10\n"}, {"type": "stdin_stdout", "input": "6 1\n1 2\n1 3\n2 4\n3 6\n2 5\n1 10\n1 10", "output": "10 10 10 10 10 10\n"}, {"type": "stdin_stdout", "input": "6 2\n1 2\n1 3\n2 4\n3 6\n2 5\n1 14\n1 10", "output": "24 24 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nN tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N.\n\nThe i-th tile from the left is painted black if the i-th character of S is `0`, and painted whi...
[{"type": "stdin_stdout", "input": "10110010", "output": "2\n"}, {"type": "stdin_stdout", "input": "10110110", "output": "3\n"}, {"type": "stdin_stdout", "input": "00110110", "output": "4\n"}, {"type": "stdin_stdout", "input": "10100110", "output": "2\n"}, {"type": "stdin_stdout", "input": "01110110", "output": "3\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day, Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He is interested in properties of the sequence a.\n\nFor a nonempty contiguous subsequence a_l, ..., a_r (1 \\l...
[{"type": "stdin_stdout", "input": "8 2\n13 0 11 2 14 4 11 8", "output": "55\n"}, {"type": "stdin_stdout", "input": "8 4\n10 2 18 7 21 1 10 1", "output": "58\n"}, {"type": "stdin_stdout", "input": "8 4\n10 2 28 7 23 0 10 3", "output": "70\n"}, {"type": "stdin_stdout", "input": "8 2\n18 0 28 5 17 1 16 1", "output": "84\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke has two boards, each divided into a grid with N rows and N columns. For both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j).\n\nThere is a lowercase...
[{"type": "stdin_stdout", "input": "5\nabcde\nfghij\nklmno\npqrst\nuvvxy", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\nabcde\nfghij\nonmlk\npqrst\nuvwxy", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\nedcba\nfghij\nonmlk\npqrst\nuvwxy", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\nedcba...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke can change a string t of length N into a string t' of length N - 1 under the following rule:\n\n* For each i (1 ≤ i ≤ N - 1), the i-th character of t' must be either the i-th or (i + 1)-th character of t.\n\n\n\nThe...
[{"type": "stdin_stdout", "input": "whcrjpbyhtxywkrlxnbrbaojmr", "output": "10\n"}, {"type": "stdin_stdout", "input": "smjoabjdoxmrjwypugydyqrchv", "output": "11\n"}, {"type": "stdin_stdout", "input": "xwwwnajdrxmrqwzpugnhlojced", "output": "12\n"}, {"type": "stdin_stdout", "input": "xpwzglbjquntrci{axpdikofyw", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA tetromino is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively:\n\na60bcb8e9e8f22e3af51049eda063392.pn...
[{"type": "stdin_stdout", "input": "10 1 2 0 0 -1 0", "output": "11\n"}, {"type": "stdin_stdout", "input": "1 13 1 0 1 -1 2", "output": "13\n"}, {"type": "stdin_stdout", "input": "10 2 0 0 4 -1 0", "output": "16\n"}, {"type": "stdin_stdout", "input": "1 26 1 0 1 -1 2", "output": "26\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke and Ciel went to a strange stationery store. Each of them got a transparent graph paper with H rows and W columns.\n\nSnuke painted some of the cells red in his paper. Here, the cells painted red were 4-connected, t...
[{"type": "stdin_stdout", "input": "7 13\n.............\n.###.###.###.\n.#.#.#...#...\n.###.#...#...\n.#.#.#.#.#...\n.#.#.###.###.\n.............", "output": ".............\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\nCreate a program that outputs all leap years between the year a and year b.\n\nThe leap year conditions are as follows. However, 0 <a ≤ b <3,000. If there is no leap year in the given period, output \"NA\".\n\n* The year ...
[{"type": "stdin_stdout", "input": "265 2171\n1686 3636\n2001 2275\n0 0", "output": "268\n272\n276\n280\n284\n288\n292\n296\n304\n308\n312\n316\n320\n324\n328\n332\n336\n340\n344\n348\n352\n356\n360\n364\n368\n372\n376\n380\n384\n388\n392\n396\n400\n404\n408\n412\n416\n420\n424\n428\n432\n436\n440\n444\n448\n452\n456\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRelative B man came to A child's house. He is 3 years old and loves singing. He is singing the song \"Kobutanuki Tsuneko\" (written and composed by Naozumi Yamamoto), which he learned from kindergarten. In this song, the ...
[{"type": "stdin_stdout", "input": "5\napple\nyellow\ngeorgia\ngnik\nemail\n7\napple\nyellow\ngeorgia\nking\nemail\nwink\nlucky\n0", "output": "NG\nOK\n"}, {"type": "stdin_stdout", "input": "5\napple\nyellow\ngeorgia\ngnik\nemail\n7\napple\nzellow\ngeorgia\nking\nemail\nwink\nlucky\n0", "output": "NG\nNG\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are a number of ways to shuffle a deck of cards. Riffle shuffle is one such example. The following is how to perform riffle shuffle.\n\nThere is a deck of n cards. First, we divide it into two decks; deck A which co...
[{"type": "stdin_stdout", "input": "17 1\n1\n28 4\n1 1 6 4", "output": "16\n19\n"}, {"type": "stdin_stdout", "input": "17 1\n1\n28 4\n1 2 6 4", "output": "16\n12\n"}, {"type": "stdin_stdout", "input": "6 1\n3\n18 4\n2 1 11 11", "output": "2\n13\n"}, {"type": "stdin_stdout", "input": "10 1\n3\n18 4\n2 2 12 4", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne of the oddest traditions of the town of Gameston may be that even the town mayor of the next term is chosen according to the result of a game. When the expiration of the term of the mayor approaches, at least three ca...
[{"type": "stdin_stdout", "input": "3 3\n1 2\n3 50\n10 29\n146 32\n39 2\n50 50\n0 0", "output": "0\n0\n1\n5\n31\n1\n13\n"}, {"type": "stdin_stdout", "input": "3 2\n1 2\n3 10\n10 29\n142 48\n39 2\n50 50\n0 0", "output": "1\n0\n2\n5\n63\n1\n13\n"}, {"type": "stdin_stdout", "input": "4 3\n3 3\n3 105\n10 29\n31 32\n27 5\n5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKarakuri Doll\n\nKarakuri doll\n\nEnglish text is not available in this practice contest.\n\nAfter many years of research, Karakuri puppeteer JAG has succeeded in developing a wonderful tea-drawing doll that combines trad...
[{"type": "stdin_stdout", "input": "5 3\n#####\n#K.M#\n#####\n9 5\n#########\n#...#.#.#\n#.###..M#\n#K#######\n#########\n9 5\n#########\n#K......#\n####.####\n####M####\n#########\n9 5\n#########\n#M......#\n####.####\n####K####\n#########\n7 9\n#######\n#####M#\n#####.#\n#.....#\n#.###.#\n#.....#\n#.#####\n#K#####\n#...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA tatami mat, a Japanese traditional floor cover, has a rectangular form with aspect ratio 1:2. When spreading tatami mats on a floor, it is prohibited to make a cross with the border of the tatami mats, because it is bel...
[{"type": "stdin_stdout", "input": "6 12\n2 18\n0 0", "output": "4\n872\n"}, {"type": "stdin_stdout", "input": "5 18\n18 4\n0 0", "output": "10\n25\n"}, {"type": "stdin_stdout", "input": "14 14\n8 3\n0 0", "output": "2\n10\n"}, {"type": "stdin_stdout", "input": "8 10\n18 4\n0 0", "output": "1\n25\n"}, {"type": "stdin_s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Kingdom of Neva is home to two ethnic groups, the Totata and the Tutete. The biggest feature of the Totata tribe is that they eat sweet and sour pork with pineapple. However, the Tutete tribe eats vinegared pork in pi...
[{"type": "stdin_stdout", "input": "5 2\n-1 2\n0 13\n-2 3\n-1 1\n1 2\n0 6\n-1 0", "output": "17.128123547485479605256841750815510749816894531250000000000000000000000000000000000000000000000000000\n"}, {"type": "stdin_stdout", "input": "5 2\n-2 2\n0 13\n-2 3\n-1 1\n1 2\n0 6\n-1 0", "output": "17.263102417797167476010145...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPalindrome\n\nProblem Statement\n\nFind the number of palindromes closest to the integer n.\n\nNote that the non-negative integer x is the number of palindromes, which means that the character string in which x is express...
[{"type": "stdin_stdout", "input": "4752", "output": "4774\n"}, {"type": "stdin_stdout", "input": "8517", "output": "8558\n"}, {"type": "stdin_stdout", "input": "3483", "output": "3443\n"}, {"type": "stdin_stdout", "input": "1868", "output": "1881\n"}, {"type": "stdin_stdout", "input": "2667", "output": "2662\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis year too, the time has come for the National Programming Championships. In the district tournament where the right to participate in the national tournament is bet, 2n teams will face each other in a one-on-one winni...
[{"type": "stdin_stdout", "input": "0 2\n-1 -1\n1", "output": "0\n"}, {"type": "stdin_stdout", "input": "1 1\n-1 15\n1", "output": "1\n"}, {"type": "stdin_stdout", "input": "0 1\n-1 13\n0", "output": "0\n"}, {"type": "stdin_stdout", "input": "0 1\n-1 11\n0", "output": "0\n"}, {"type": "stdin_stdout", "input": "0 1\n-1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nThere are $ N $ propositions, named $ 1, 2, \\ cdots, N $, respectively. Also, $ M $ information about the propositions is given. The $ i $ th information is \"$ a_i $$\". Given in the form \"b_i $\", which mea...
[{"type": "stdin_stdout", "input": "211 0\n4 2\n0 3", "output": "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\n60\n61\n62\n63\n64\n65\n66\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFind the difference of two sets $A = \\\\{a_0, a_1, ..., a_{n-1}\\\\}$ and $B = \\\\{b_0, b_1, ..., b_{m-1}\\\\}$, $A - B$.\n\nConstraints\n\n* $1 \\leq n, m \\leq 200,000$\n* $0 \\leq a_0 < a_1 < ... < a_{n-1} \\leq 10^9...
[{"type": "stdin_stdout", "input": "5\n-1 2 4 13 17\n1\n-2 2", "output": "-1\n2\n4\n13\n17\n"}, {"type": "stdin_stdout", "input": "5\n-1 2 4 13 25\n1\n-2 1", "output": "-1\n2\n4\n13\n25\n"}, {"type": "stdin_stdout", "input": "5\n-2 2 3 9 14\n0\n-1 28", "output": "-2\n2\n3\n9\n14\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA Little Elephant and his friends from the Zoo of Lviv like candies very much.\n\nThere are N elephants in the Zoo. The elephant with number K (1 ≤ K ≤ N) will be happy if he receives at least AK candies. There are C cand...
[{"type": "stdin_stdout", "input": "2\n2 1\n2 2\n3 13\n-1 2 2", "output": "No\nYes\n"}, {"type": "stdin_stdout", "input": "2\n2 1\n4 2\n3 13\n-1 2 2", "output": "No\nYes\n"}, {"type": "stdin_stdout", "input": "2\n2 1\n4 2\n3 13\n-1 2 1", "output": "No\nYes\n"}, {"type": "stdin_stdout", "input": "2\n2 0\n4 2\n3 13\n-1 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are a given a list of integers a_1, a_2, …, a_n and s of its segments [l_j; r_j] (where 1 ≤ l_j ≤ r_j ≤ n).\n\nYou need to select exactly m segments in such a way that the k-th order statistic of the multiset of a_i, ...
[{"type": "stdin_stdout", "input": "5 10 1 1\n1000000000 1000000000 1000000000 1 1000000000\n1 1\n1 3\n5 5\n1 1\n2 3\n3 3\n3 4\n1 2\n2 2\n3 3\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "5 10 1 1\n1000000000 1000000000 1000000000 1 1000000000\n1 1\n1 3\n5 5\n1 1\n2 3\n3 3\n3 4\n1 2\n2 2\n3 5\n", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is the constraints.\n\nVova likes pictures with kittens. The news feed in the social network he uses can be represented as an array of n consecutive pictures (with kitten...
[{"type": "stdin_stdout", "input": "200 103 37\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a weighted tree with n nodes and n-1 edges. The nodes are conveniently labeled from 1 to n. The weights are positive integers at most 100. Define the distance between two nodes to be the sum of edges on the uniqu...
[{"type": "stdin_stdout", "input": "2\n5\n17\n12\n10\n9\n10\n2\n99\n", "output": "3 2 1 3 5 2 4\n2 3 2 3 1 4 5\n2 3 4 5 1 2 3\n-1 17\n5 4 1 3 5 7 9 2 4 6 8\n4 5 2 3 6 7 1 4 5 8 9\n4 5 4 5 6 7 1 2 3 8 9\n2 7 8 9 1 2 3 4 5 6 7\n-1 99\n"}, {"type": "stdin_stdout", "input": "2\n5\n9\n12\n10\n9\n10\n2\n99\n", "output": "3 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn some social network, there are n users communicating with each other in m groups of friends. Let's analyze the process of distributing some news between users.\n\nInitially, some user x receives the news from some sour...
[{"type": "stdin_stdout", "input": "14 5\n3 2 1 7\n0\n2 2 2\n1 1\n2 10 11\n", "output": "3 3 1 1 1 1 3 1 1 2 2 1 1 1\n"}, {"type": "stdin_stdout", "input": "14 5\n3 2 1 7\n0\n2 2 2\n1 1\n2 10 6\n", "output": "3 3 1 1 1 2 3 1 1 2 1 1 1 1\n"}, {"type": "stdin_stdout", "input": "14 5\n3 2 5 10\n0\n2 2 2\n1 0\n2 1 3\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA company of n friends wants to order exactly two pizzas. It is known that in total there are 9 pizza ingredients in nature, which are denoted by integers from 1 to 9.\n\nEach of the n friends has one or more favorite ing...
[{"type": "stdin_stdout", "input": "5 5\n8 5 3 8 4 1 9 7 6\n4 6 7 8 2\n4 8 4 1 3\n1 7\n9 9 4 7 6 5 8 3 1 2\n1 5 8 2 4 5 3\n1 9 2 6 9 5 8 4 3 1 7\n1 8 1 6 2 7 9 5 4 3\n1 3 7 9 6\n1 7 6 9 2 1 5 8 7\n", "output": "1 3\n"}, {"type": "stdin_stdout", "input": "5 5\n9 7 3 2 9 4 6 1 5 8\n3 1 9 8\n4 1 3 8 9\n5 7 5 6 9 3\n8 5 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is the length of the string. You can hack this problem only if you solve both problems.\n\nKirk has a binary string s (a string which consists of zeroes and ones) of leng...
[{"type": "stdin_stdout", "input": "0111001100111011101000\n", "output": "0011001100001011101000\n"}, {"type": "stdin_stdout", "input": "0111001110111011101000\n", "output": "0011000010001011101000\n"}, {"type": "stdin_stdout", "input": "0111001110101011101000\n", "output": "0011000010101011101000\n"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a chess board with n rows and n columns. Initially all cells of the board are empty, and you have to put a white or a black knight into each cell of the board.\n\nA knight is a chess piece that can attack a ...
[{"type": "stdin_stdout", "input": "104\n", "output": "WBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWB\nBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBW\nWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBW...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet a be a matrix of size r × c containing positive integers, not necessarily distinct. Rows of the matrix are numbered from 1 to r, columns are numbered from 1 to c. We can construct an array b consisting of r + c intege...
[{"type": "stdin_stdout", "input": "1223 12\n", "output": "2 3 4 5 6 7 8 9 10 11 12 13\n28 42 56 70 84 98 112 126 140 154 168 182\n30 45 60 75 90 105 120 135 150 165 180 195\n32 48 64 80 96 112 128 144 160 176 192 208\n34 51 68 85 102 119 136 153 170 187 204 221\n36 54 72 90 108 126 144 162 180 198 216 234\n38 57 76 95...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis problem is different with hard version only by constraints on total answers length\n\nIt is an interactive problem\n\nVenya joined a tour to the madhouse, in which orderlies play with patients the following game. Ord...
[{"type": "stdin_stdout", "input": "100\noooooooooooooooooooooooooooooooooooooooooooooooooovvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvwvvvvvvvvvvvvvvvv\n", "output": "? 1 100\n? 1 99\n! 8aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"}, {"type": "stdin_stdout", "input": "100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter a successful year of milk production, Farmer John is rewarding his cows with their favorite treat: tasty grass!\n\nOn the field, there is a row of n units of grass, each with a sweetness s_i. Farmer John has m cows,...
[{"type": "stdin_stdout", "input": "20 8\n7 4 9 6 4 10 5 12 6 13 20 16 11 1 12 10 11 2 3 18\n6 1\n20 4\n10 6\n2 9\n10 17\n13 19\n1 5\n3 1\n", "output": "2 3"}, {"type": "stdin_stdout", "input": "20 8\n7 4 9 6 4 10 5 12 6 13 20 2 11 1 12 10 11 2 3 18\n6 1\n20 4\n10 6\n2 9\n10 17\n13 19\n1 5\n3 1\n", "output": "2 3"}, {"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDrazil likes heap very much. So he created a problem with heap:\n\nThere is a max heap with a height h implemented on the array. The details of this heap are the following:\n\nThis heap contains exactly 2^h - 1 distinct p...
[{"type": "stdin_stdout", "input": "2\n3 1\n7 6 3 5 4 2 1\n3 1\n23 6 5 4 3 2 1\n", "output": "1\n1 1 1 1 1 1\n1\n1 1 1 1 1 1\n"}, {"type": "stdin_stdout", "input": "2\n3 1\n14 10 3 5 4 2 1\n3 2\n23 12 9 4 3 2 1\n", "output": "1\n1 1 1 1 1 1\n8\n1 1 1 3\n"}, {"type": "stdin_stdout", "input": "2\n3 2\n14 6 3 5 4 2 1\n3 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA penguin Rocher has n sticks. He has exactly one stick with length i for all 1 ≤ i ≤ n.\n\nHe can connect some sticks. If he connects two sticks that have lengths a and b, he gets one stick with length a + b. Two sticks,...
[{"type": "stdin_stdout", "input": "4\n1\n2\n3\n20\n", "output": "1\n1\n2\n10\n"}, {"type": "stdin_stdout", "input": "4\n1\n3\n3\n20\n", "output": "1\n2\n2\n10\n"}, {"type": "stdin_stdout", "input": "4\n3\n2\n12\n15\n", "output": "2\n1\n6\n8\n"}, {"type": "stdin_stdout", "input": "4\n1\n3\n1\n20\n", "output": "1\n2\n1\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCarousel Boutique is busy again! Rarity has decided to visit the pony ball and she surely needs a new dress, because going out in the same dress several times is a sign of bad manners. First of all, she needs a dress patt...
[{"type": "stdin_stdout", "input": "5 5\nzbacg\nbaaac\naaaaa\ndaaae\nweadd\n", "output": "31\n"}, {"type": "stdin_stdout", "input": "5 5\nzbacf\nbcaaa\naaaaa\neaaad\nveadd\n", "output": "28\n"}, {"type": "stdin_stdout", "input": "5 5\nabzcg\nbaaac\naaaaa\neaabd\nwdaed\n", "output": "27\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou and your friend are playing the game Mortal Kombat XI. You are trying to pass a challenge tower. There are n bosses in this tower, numbered from 1 to n. The type of the i-th boss is a_i. If the i-th boss is easy then ...
[{"type": "stdin_stdout", "input": "6\n8\n1 0 1 1 0 1 1 1\n5\n1 1 1 1 0\n7\n1 1 1 1 0 0 1\n6\n1 1 1 1 1 1\n1\n1\n1\n0\n", "output": "2\n2\n2\n2\n1\n0\n"}, {"type": "stdin_stdout", "input": "6\n8\n1 0 1 1 0 1 1 1\n5\n1 1 1 1 1\n7\n1 1 1 1 0 0 1\n6\n1 1 1 1 1 1\n1\n1\n1\n0\n", "output": "2\n2\n2\n2\n1\n0\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSasha likes investigating different math objects, for example, magic squares. But Sasha understands that magic squares have already been studied by hundreds of people, so he sees no sense of studying them further. Instead...
[{"type": "stdin_stdout", "input": "10\n65\n70\n66\n68\n69\n62\n64\n92\n61\n67\n", "output": "9 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n1 9 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have n stacks of blocks. The i-th stack contains h_i blocks and it's height is the number of blocks in it. In one move you can take a block from the i-th stack (if there is at least one block) and put it to the i + 1-...
[{"type": "stdin_stdout", "input": "1\n30\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe tycoon of a winery empire in Mondstadt, unmatched in every possible way. A thinker in the Knights of Favonius with an exotic appearance.\n\nThis time, the brothers are dealing with a strange piece of wood marked with ...
[{"type": "stdin_stdout", "input": "10\n9\nDDDDDDKDD\n10\nKKDDDDKKDK\n7\nKKDDKDK\n13\nKKKDDKDDDKKKD\n14\nKDDDDKDDKDKDKK\n9\nKKDDKDDKD\n14\nDKDKKKKKDDDKKK\n10\nKDKKDKKKKD\n11\nDDKDKKDDKKD\n3\nKKK\n", "output": "1 2 3 4 5 6 1 1 1 \n1 2 1 1 1 1 1 2 1 3 \n1 2 1 1 1 2 1 \n1 2 3 1 1 1 1 1 1 2 1 1 1 \n1 1 1 1 1 2 1 2 3 1 1 4 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGoa'uld Apophis captured Jack O'Neill's team again! Jack himself was able to escape, but by that time Apophis's ship had already jumped to hyperspace. But Jack knows on what planet will Apophis land. In order to save his ...
[{"type": "stdin_stdout", "input": "8 10\n1 2 3\n2 8 3\n1 4 1\n4 3 6\n3 7 7\n4 5 5\n7 7 2\n7 8 1\n1 6 8\n6 8 7\n0\n4 1 2 3 4\n0\n0\n0\n0\n0\n0\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "8 10\n1 2 3\n2 8 3\n1 4 1\n4 3 6\n3 7 7\n4 5 5\n5 7 2\n7 8 1\n1 6 8\n6 8 7\n0\n4 1 2 3 4\n0\n0\n0\n0\n0\n0\n", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFurlo and Rublo play a game. The table has n piles of coins lying on it, the i-th pile has ai coins. Furlo and Rublo move in turns, Furlo moves first. In one move you are allowed to:\n\n * choose some pile, let's denote ...
[{"type": "stdin_stdout", "input": "50\n153423475 434636879 773155924 97361082 413127059 154467262 26144388 172617533 117328815 312150912 45081238 438413693 686165576 490651756 383872273 601349776 181594954 624158354 48886108 1456962211 631306840 58389993 403293668 405970047 308352764 293917056 430837844 571889516 6763...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe sequence is called ordered if it is non-decreasing or non-increasing. For example, sequnces [3, 1, 1, 0] and [1, 2, 3, 100] are ordered, but the sequence [1, 3, 3, 1] is not. You are given a sequence of numbers. You a...
[{"type": "stdin_stdout", "input": "5\n834472 -373089 441294 -633071 -957672\n", "output": "3\n1 2 3\n"}, {"type": "stdin_stdout", "input": "5\n834472 -373089 441294 -633071 -1240121\n", "output": "3\n1 2 3"}, {"type": "stdin_stdout", "input": "5\n834472 -373089 441294 -401384 -1240121\n", "output": "3\n1 2 3"}, {"type...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEugeny loves listening to music. He has n songs in his play list. We know that song number i has the duration of ti minutes. Eugeny listens to each song, perhaps more than once. He listens to song number i ci times. Eugen...
[{"type": "stdin_stdout", "input": "10 10\n3 1\n2 7\n5 1\n7 2\n9 10\n9 5\n2 5\n4 8\n9 9\n1 9\n26 34 37 141 146 201 239 245 296 299\n", "output": "4\n4\n5\n6\n6\n8\n9\n9\n10\n10\n"}, {"type": "stdin_stdout", "input": "10 10\n3 1\n2 7\n5 1\n7 2\n9 10\n9 5\n2 5\n4 10\n9 15\n1 9\n26 34 37 141 146 201 239 245 296 299\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nI have an undirected graph consisting of n nodes, numbered 1 through n. Each node has at most two incident edges. For each pair of nodes, there is at most an edge connecting them. No edge connects a node to itself.\n\nI w...
[{"type": "stdin_stdout", "input": "65 55\n54 57\n33 10\n58 33\n26 38\n22 38\n50 22\n47 32\n32 65\n65 55\n55 42\n6 62\n3 62\n56 3\n56 37\n19 37\n1 61\n21 1\n39 21\n39 40\n20 40\n20 29\n18 53\n16 53\n2 9\n2 24\n25 24\n60 25\n60 43\n13 51\n13 59\n59 23\n7 23\n7 17\n5 17\n5 36\n30 36\n45 28\n28 64\n64 63\n63 8\n35 8\n46 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nValera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.\n\nValera has written n correct solutions. For each correct solution, he knows its running time (in se...
[{"type": "stdin_stdout", "input": "68 85\n43 55 2 4 72 45 19 56 53 81 18 90 11 87 47 8 94 88 24 4 67 9 21 70 25 66 65 27 46 13 8 51 65 99 37 77 71 59 71 79 22 56 49 43 57 85 95 81 40 28 60 36 72 81 60 40 16 78 61 37 29 26 15 95 70 27 50 97\n6 6 48 72 54 31 1 50 29 64 93 9 29 93 66 63 25 90 52 1 66 13 70 44 24 87 32 90...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nInna loves digit 9 very much. That's why she asked Dima to write a small number consisting of nines. But Dima must have misunderstood her and he wrote a very large number a, consisting of digits from 1 to 9.\n\nInna wants...
[{"type": "stdin_stdout", "input": "44444444444444544444444445444444444444444444444444554444444444444444444444444444444444444444455444444444444444444444444444444444444444545444444444444444444444444444444444444445444444444444444444444444444444444444544444444444444444444444444444444444444444444544444444444444444444444444...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDZY loves Physics, and he enjoys calculating density.\n\nAlmost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph have some values) as follows: \n\n<image> w...
[{"type": "stdin_stdout", "input": "20 20\n265918 744212 196368 74731 293587 679367 460805 632939 453630 565881 835276 606327 181087 721045 219431 849838 370939 582350 335676 32244\n2 16 989\n14 19 628\n1 9 483\n5 8 733\n13 19 556\n10 17 911\n1 7 599\n13 17 390\n10 20 965\n17 11 449\n3 15 310\n3 6 557\n14 18 225\n1 18 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter you had helped Fedor to find friends in the «Call of Soldiers 3» game, he stopped studying completely. Today, the English teacher told him to prepare an essay. Fedor didn't want to prepare the essay, so he asked Ale...
[{"type": "stdin_stdout", "input": "2\nABBABAABBAABABBABAABABBAABBABAABBAABABBAABBABAABABBABAABBAABABBA ABBABAABBAABABBABAABABBAABBABAABBAABABBAABBABAABABBABAABBAABABA\n2\nABBABAABBAABABBABAABABBAABBABAAABAABABBAABBABAABABBABAABBAABABA neuzaiheshi\nABBABAABBAABABBABAABABBAABBABAABBAABABBAABBABAABABBABAABBAABABBA ABBABA...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a permutation of n numbers p1, p2, ..., pn. We perform k operations of the following type: choose uniformly at random two indices l and r (l ≤ r) and reverse the order of the elements pl, pl + 1, ..., pr. Yo...
[{"type": "stdin_stdout", "input": "30 153\n18 5 24 7 12 6 25 14 21 20 27 4 30 8 23 19 11 13 17 1 29 28 15 22 16 9 2 10 26 3\n", "output": "217.500536909325035\n"}, {"type": "stdin_stdout", "input": "30 136\n1 29 20 25 15 2 3 16 24 30 17 14 7 10 11 22 6 8 23 18 12 5 19 9 26 21 28 13 27 4\n", "output": "217.499666343987...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLife in Bertown has become hard. The city has too many roads and the government spends too much to maintain them. There are n junctions and m two way roads, at which one can get from each junction to any other one. The ma...
[{"type": "stdin_stdout", "input": "10 45 4\n8 6\n10 2\n9 5\n1 7\n8 7\n7 10\n2 5\n5 10\n10 1\n1 8\n4 1\n10 9\n6 9\n3 7\n10 4\n5 6\n1 5\n4 7\n7 9\n10 3\n4 3\n6 4\n2 1\n5 3\n10 6\n1 9\n8 2\n3 8\n6 3\n8 5\n3 9\n4 2\n7 5\n2 9\n4 5\n2 7\n2 6\n6 7\n8 4\n8 10\n3 2\n4 9\n9 8\n6 1\n3 1\n", "output": "40219200\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRikhail Mubinchik believes that the current definition of prime numbers is obsolete as they are too complex and unpredictable. A palindromic number is another matter. It is aesthetically pleasing, and it has a number of r...
[{"type": "stdin_stdout", "input": "10001 239\n", "output": "1168798\n"}, {"type": "stdin_stdout", "input": "10000 239\n", "output": "1168638"}, {"type": "stdin_stdout", "input": "10278 674\n", "output": "204510\n"}, {"type": "stdin_stdout", "input": "15744 9999\n", "output": "1020\n"}, {"type": "stdin_stdout", "input"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA long time ago (probably even in the first book), Nicholas Flamel, a great alchemist and the creator of the Philosopher's Stone, taught Harry Potter three useful spells. The first one allows you to convert a grams of san...
[{"type": "stdin_stdout", "input": "911 728 910 407 833 594\n", "output": "Hermione\n"}, {"type": "stdin_stdout", "input": "632 446 352 317 522 451\n", "output": "Hermione\n"}, {"type": "stdin_stdout", "input": "542 11 820 850 1201 738\n", "output": "Hermione\n"}, {"type": "stdin_stdout", "input": "911 728 910 180 833 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters.\n\nThere is a filler wor...
[{"type": "stdin_stdout", "input": "100\nggogogoooggogooggoggogggggogoogoggooooggooggoooggogoooggoggoogggoogoggogggoooggoggoggogggogoogggoooo\n", "output": "gg***oogg***oggoggoggggg******ggooooggooggooogg***ooggoggoogggo***ggogggoooggoggoggoggg***ogggoooo\n"}, {"type": "stdin_stdout", "input": "100\nggogogoooggogooggog...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have n devices that you want to use simultaneously.\n\nThe i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device curre...
[{"type": "stdin_stdout", "input": "20 16807\n75250 50074\n43659 8931\n11273 27545\n50879 77924\n37710 64441\n61647 84493\n43043 7988\n22504 82328\n31730 78841\n42613 44304\n33170 17710\n97158 29561\n70934 93100\n80279 51817\n95336 99098\n7827 13513\n29268 23811\n77634 80980\n79150 36580\n58822 11968\n", "output": "0.2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven a positive integer n, find k integers (not necessary distinct) such that all these integers are strictly greater than 1, and their product is equal to n.\n\nInput\n\nThe first line contains two integers n and k (2 ≤...
[{"type": "stdin_stdout", "input": "100000 10\n", "output": "2 2 2 2 2 5 5 5 5 5\n"}, {"type": "stdin_stdout", "input": "2048 11\n", "output": "2 2 2 2 2 2 2 2 2 2 2\n"}, {"type": "stdin_stdout", "input": "1024 10\n", "output": "2 2 2 2 2 2 2 2 2 2\n"}, {"type": "stdin_stdout", "input": "100000 8\n", "output": "2 2 2 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIvan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (...
[{"type": "stdin_stdout", "input": "1000000000000000000 100000000000000000\n", "output": "899999999999999991\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 200000000000000000\n", "output": "799999999999999991\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 101000000000000000\n", "output": "8989...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIlya is working for the company that constructs robots. Ilya writes programs for entertainment robots, and his current project is \"Bob\", a new-generation game robot. Ilya's boss wants to know his progress so far. Especi...
[{"type": "stdin_stdout", "input": "129341234876124184 1 2\n1 3 3\n1 1 2\n1 2 3\n3 1 1\n3 1 3\n3 2 3\n", "output": "64670617438062091 64670617438062093\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 2 1\n3 1 2\n2 3 3\n1 2 3\n2 2 3\n1 1 3\n2 3 2\n", "output": "1000000000000000000 0\n"}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's suppose you have an array a, a stack s (initially empty) and an array b (also initially empty).\n\nYou may perform the following operations until both a and s are empty:\n\n * Take the first element of a, push it i...
[{"type": "stdin_stdout", "input": "40 39\n25 4 26 34 35 11 22 23 21 2 1 28 20 8 36 5 27 15 39 7 24 14 17 19 33 6 38 16 18 3 32 10 30 13 37 31 29 9 12\n", "output": "-1"}, {"type": "stdin_stdout", "input": "40 38\n32 35 36 4 22 6 15 21 40 13 33 17 5 24 28 9 1 23 25 14 26 3 8 11 37 30 18 16 19 20 27 12 39 2 10 38 29 31\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFirecrackers scare Nian the monster, but they're wayyyyy too noisy! Maybe fireworks make a nice complement.\n\nLittle Tommy is watching a firework show. As circular shapes spread across the sky, a splendid view unfolds on...
[{"type": "stdin_stdout", "input": "3\n-10 4 10\n10 4 10\n0 -7 10\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "3\n-3 -2 3\n-4 -12 3\n-6 -4 9\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "3\n-5 -6 5\n-2 -2 10\n-3 4 3\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "3\n1 -7 10\n-7 9 10\n-2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt is the middle of 2018 and Maria Stepanovna, who lives outside Krasnokamensk (a town in Zabaikalsky region), wants to rent three displays to highlight an important problem.\n\nThere are n displays placed along a road, a...
[{"type": "stdin_stdout", "input": "20\n804301132 586588704 822785255 552472140 16115810 148658854 66743034 628305150 677780684 931815125 208050516 401554301 954478790 571480982 387546138 832279893 641889899 80960260 717802881 172455365\n61699500 83254572 29028223 27833657 55743179 118122387 94729965 147554867 62937826...
code_stdio