messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "You came to a local shop and want to buy some chocolate bars. There are $n$ bars in the shop, $i$-th of them costs $a_i$ coins (and you want to buy all of them).\n\nYou have $m$ different coupons that allow you to buy chocolate bars. $i$-th coupon allows you to buy $q_i$ chocolate bars while you h...
[{"input": "9\n7 2 3 3 2 5 6 3 3\n6\n7 5 4 8 9 2\n", "output": "31\n31\n31\n32\n32\n28\n"}, {"input": "9\n7 2 3 3 2 5 6 3 3\n6\n7 5 4 8 9 2\n", "output": "31\n31\n31\n32\n32\n28\n"}, {"input": "9\n7 2 3 3 2 5 6 3 3\n6\n7 5 4 8 9 3\n", "output": "31\n31\n31\n32\n32\n29\n"}, {"input": "9\n7 2 3 3 2 5 5 3 3\n6\n7 5 4 8 9 ...
code_stdio
[ { "content": "Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. \n\nString p is called a substring of string s if you can read it starting from some position in the string s. For example, string \"aba\" has six substrings: \"a\", \"b\", \"a\", \"ab\", \"ba\", \"aba\".\n\nDr. Moriart...
[{"input": "ksmbytfyhhnstlecripupiwdhbkhfpfmimrbqgszohcqnezcybvwasxmkxfupvuecsctcpadccnqexsglwaiyxcoyheefcjmdedesgjqdtqgrvfjonzesffousooutsjumrxl\nhgjqihcfbnmgufonaiudbjegexexthrzcdkuimwogpbyovemztzcmqnrbhabxyyxyfuzpyhjgnioexbezzupcxlyzuuncstiiqsjzdtqppqhxilvqimlpjejiqbwpeekzweeyvthvjffgfvqauqrugajjjzibgzhxphcvtncjzecb...
code_stdio
[ { "content": "During the \"Russian Code Cup\" programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions with the same source code to check.\n\nEach participant is identified...
[{"input": "7\n0 2\n0 3\n0 2\n0 1\n0 10\n1 10\n0 5\n", "output": "YES\n"}, {"input": "7\n0 2\n0 3\n0 2\n0 1\n0 10\n1 10\n0 5\n", "output": "YES\n"}, {"input": "7\n0 2\n0 5\n0 2\n0 1\n0 10\n1 10\n0 5\n", "output": "YES\n"}, {"input": "4\n1 2\n2 100000\n1 2\n-1 100000\n", "output": "NO\n"}, {"input": "4\n0 1\n1 100000\n1...
code_stdio
[ { "content": "Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise.\n\nYou are given geometric progression b defined by two integers b_1 and q. Remind that a geometric progression is a sequence of integers b_1, b_2, b_3, ..., where for each i > 1 the respective term s...
[{"input": "-3 0 92055 36\n-92974174 -486557474 -663622151 695596393 177960746 -563227474 -364263320 -676254242 -614140218 71456762 -764104225 705056581 -106398436 332755134 -199942822 -732751692 658942664 677739866 886535704 183687802 -784248291 -22550621 -938674499 637055091 -704750213 780395802 778342470 -999059668 ...
code_stdio
[ { "content": "Tanya is learning how to add numbers, but so far she is not doing it correctly. She is adding two numbers $a$ and $b$ using the following algorithm:\n\nIf one of the numbers is shorter than the other, Tanya adds leading zeros so that the numbers are the same length.\n\nThe numbers are processed fr...
[{"input": "6\n17236 1106911\n1 5\n108 112\n12345 1023412\n1 11\n1 20\n", "output": "3465\n4\n-1\n90007\n10\n-1\n"}, {"input": "6\n17236 1106911\n1 5\n108 112\n12345 1023412\n1 11\n1 20\n", "output": "3465\n4\n-1\n90007\n10\n-1\n"}, {"input": "6\n17236 1106911\n1 5\n108 112\n7038 799289\n1 11\n1 32\n", "output": "3465\...
code_stdio
[ { "content": "I've got a crazy mental illness.\nI dislike numbers a lot. But it's a little complicated:\nThe number I'm afraid of depends on which day of the week it is...\nThis is a concrete description of my mental illness:\n\nMonday --> 12\n\nTuesday --> numbers greater than 95\n\nWednesday --> 34\n\...
[{"input": "\"Wednesday\"\n35", "output": "[false]", "fn_name": "am_I_afraid"}, {"input": "\"Wednesday\"\n34", "output": "[true]", "fn_name": "am_I_afraid"}, {"input": "\"Saturday\"\n55", "output": "[false]", "fn_name": "am_I_afraid"}, {"input": "\"Tuesday\"\n100", "output": "[true]", "fn_name": "am_I_afraid"}, {"input...
code_functional
[ { "content": "Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?\n\nGiven a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells w...
[{"input": "19\noxoxoxoxooxoooxxoox\nxxxxxxxxoxxoxoooooo\noxoxoxooxxxooxxxooo\nxxoxxxooxooxxxoxxox\noxoxooxxxooooxxoxox\nxxxoooxoxxoxxoxxxoo\noxooxxxoooooxxoooxo\nxxooxooxoxxoxxoxxoo\noxxxxooooxxxooooxxx\nooxooxoxxoxxoxooxoo\nxxxooooxxxooooxoxox\noooxoxooxxoxooxooxx\nxxoooxxxooooxxoooxo\nooxxxooxoxooxooxxxx\nxoxoxxooxo...
code_stdio
[ { "content": "B-Mansion and courier\n\nProblem Statement\n\nTaro lives alone in a mansion. Taro, who loves studying, intends to study in his study in the house today. Taro can't concentrate outside the study, so he always studies in the study.\n\nHowever, on this day, $ N $ of courier service to Taro arrived. $...
[{"input": "1 1 110\n18", "output": "108\n"}, {"input": "1 0 110\n11", "output": "110\n"}, {"input": "1 3 110\n18", "output": "104\n"}, {"input": "1 0 192\n16", "output": "192\n"}, {"input": "1 1 192\n29", "output": "190\n"}, {"input": "1 2 454\n14", "output": "450\n"}, {"input": "1 3 454\n14", "output": "448\n"}, {"in...
code_stdio
[ { "content": "Given is an integer N. Find the number of digits that N has in base K.\n\n-----Notes-----\nFor information on base-K representation, see Positional notation - Wikipedia.\n\n-----Constraints-----\n - All values in input are integers.\n - 1 \\leq N \\leq 10^9\n - 2 \\leq K \\leq 10\n\n-----Input----...
[{"input": "1000000000 2\n", "output": "30\n"}, {"input": "314159265 3\n", "output": "18\n"}, {"input": "282475249 7\n", "output": "11\n"}, {"input": "282475248 7\n", "output": "10\n"}, {"input": "282475250 7\n", "output": "11\n"}, {"input": "801037529 8\n", "output": "10\n"}, {"input": "1568902019 2", "output": "31\n"...
code_stdio
[ { "content": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containi...
[{"input": "nnnnnnnnnneeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeiiiiiiiiiiiiiiiiiiiitttttttttttttttttttt\n", "output": "4\n"}, {"input": "nnnnnnnnnneeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeedeeeeeeeeeeeeeeeeiiiiiiiiiiiiiiiiiiiitttttttttttttttttttt\n", "output": "4\n"}, {"input": "nnnnnnnnnneeeeeeeeeeeeeeeeeeeeeeeedeeeee...
code_stdio
[ { "content": "There is a tree with N vertices, numbered 1, 2, \\ldots, N. For each i (1 \\leq i \\leq N - 1), the i-th edge connects Vertex x_i and y_i.\n\nTaro has decided to paint each vertex in white or black. Here, it is not allowed to paint two adjacent vertices both in black.\n\nFind the number of ways in...
[{"input": "10\n3 5\n10 8\n6 10\n1 5\n4 10\n2 10\n3 6\n9 2\n2 7", "output": "180\n"}, {"input": "10\n3 5\n10 8\n6 10\n1 5\n4 10\n2 10\n3 6\n9 3\n2 7", "output": "184\n"}, {"input": "10\n3 5\n10 8\n6 10\n1 5\n4 10\n2 10\n3 6\n9 2\n3 7", "output": "184\n"}, {"input": "10\n3 5\n10 8\n6 10\n1 5\n4 10\n2 10\n3 6\n9 2\n6 7",...
code_stdio
[ { "content": "You have to create a function,named `insertMissingLetters`, that takes in a `string` and outputs the same string processed in a particular way.\n\nThe function should insert **only after the first occurrence** of each character of the input string, all the **alphabet letters** that:\n\n-**are NOT*...
[{"input": "\"hellllllllllllooooo\"", "output": "[\"hIJKMNPQRSTUVWXYZeFGIJKMNPQRSTUVWXYZlMNPQRSTUVWXYZllllllllllloPQRSTUVWXYZoooo\"]", "fn_name": "insert_missing_letters"}, {"input": "\"hello\"", "output": "[\"hIJKMNPQRSTUVWXYZeFGIJKMNPQRSTUVWXYZlMNPQRSTUVWXYZloPQRSTUVWXYZ\"]", "fn_name": "insert_missing_letters"}, {"i...
code_functional
[ { "content": "In elementary arithmetic a \"carry\" is a digit that is transferred from one column of digits to another column of more significant digits during a calculation algorithm.\n\nThis Kata is about determining the number of carries performed during the addition of multi-digit numbers.\n\nYou will recei...
[{"input": "\"1 9\\n123456789 111111101\\n01 09\\n11 09\\n123 457\"", "output": "[\"1 carry operations\\n1 carry operations\\n1 carry operations\\n1 carry operations\\n1 carry operations\"]", "fn_name": "solve"}, {"input": "\"123 457\\n123 456\\n654 312\\n999 000\\n123 457\"", "output": "[\"1 carry operations\\nNo carr...
code_functional
[ { "content": "Polycarp is a big lover of killing time in social networks. A page with a chatlist in his favourite network is made so that when a message is sent to some friend, his friend's chat rises to the very top of the page. The relative order of the other chats doesn't change. If there was no chat with th...
[{"input": "50\njcg\nvle\njopb\nepdb\nnkef\nfv\nxj\nufe\nfuy\noqta\ngbc\nyuz\nec\nyji\nkuux\ncwm\ntq\nnno\nhp\nzry\nxxpp\ntjvo\ngyz\nkwo\nvwqz\nyaqc\njnj\nwoav\nqcv\ndcu\ngc\nhovn\nop\nevy\ndc\ntrpu\nyb\nuzfa\npca\noq\nnhxy\nsiqu\nde\nhphy\nc\nwovu\nf\nbvv\ndsik\nlwyg\n", "output": "lwyg\ndsik\nbvv\nf\nwovu\nc\nhphy\nd...
code_stdio
[ { "content": "Take a sentence (string) and reverse each word in the sentence. Do not reverse the order of the words, just the letters in each word.\n\nIf there is punctuation, it should be interpreted as a regular character; no special rules.\n\nIf there is spacing before/after the input string, leave them ther...
[{"input": "\"The red pen wrote on the wall\"", "output": "[\"ehT der nep etorw no eht llaw\"]", "fn_name": "reverser"}, {"input": "\"Green trucks drive fast\"", "output": "[\"neerG skcurt evird tsaf\"]", "fn_name": "reverser"}, {"input": "\"Pink trucks drive slow\"", "output": "[\"kniP skcurt evird wols\"]", "fn_name"...
code_functional
[ { "content": "A tennis tournament with n participants is running. The participants are playing by an olympic system, so the winners move on and the losers drop out.\n\nThe tournament takes place in the following way (below, m is the number of the participants of the current round): let k be the maximal power o...
[{"input": "2426 500 665\n", "output": "2427425 1613290\n"}, {"input": "1353 500 665\n", "output": "1353352 899745\n"}, {"input": "500 500 500\n", "output": "499499 250000\n"}, {"input": "500 237 474\n", "output": "237025 237000\n"}, {"input": "456 456 456\n", "output": "415415 207936\n"}, {"input": "500 500 500\n", "o...
code_stdio
[ { "content": "Berland Music is a music streaming service built specifically to support Berland local artist. Its developers are currently working on a song recommendation module.\n\nSo imagine Monocarp got recommended $n$ songs, numbered from $1$ to $n$. The $i$-th song had its predicted rating equal to $p_i$, ...
[{"input": "1\n50\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\n10101010101010101010101010101010101010101010101010\n", "output": "26 1 27 2 28 3 29 4 30 5 31 6 32 7 33 8 34 9 35 10 36 11 37 12 38 13 39 14 40 15 41 16 42 17 ...
code_stdio
[ { "content": "Given an array $a$ of length $n$, tell us whether it has a non-empty subsequence such that the product of its elements is not a perfect square.\n\nA sequence $b$ is a subsequence of an array $a$ if $b$ can be obtained from $a$ by deleting some (possibly zero) elements.\n\n\n-----Input-----\n\nThe ...
[{"input": "1\n69\n1 1 2 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\n", "output": "YES\n"}, {"input": "1\n69\n1 1 2 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 0 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": "You have a large electronic screen which can display up to $998244353$ decimal digits. The digits are displayed in the same way as on different electronic alarm clocks: each place for a digit consists of $7$ segments which can be turned on and off to compose different digits. The following picture...
[{"input": "1\n140047\n", "output": "7111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
code_stdio
[ { "content": "Chef loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nLet F_{d}(x) equals to the number of digits d in decimal representation of th...
[{"input": "3\n-1\n-10\n101", "output": "84589473\n84520290\n1310\n"}, {"input": "3\n-1\n-5\n110", "output": "84589473\n84552155\n1658\n"}, {"input": "3\n-1\n-5\n111", "output": "84589473\n84552155\n1709\n"}, {"input": "3\n-1\n-5\n101", "output": "84589473\n84552155\n1310\n"}, {"input": "3\n-1\n-6\n101", "output": "845...
code_stdio
[ { "content": "There are four towns, numbered 1,2,3 and 4. Also, there are three roads. The i-th road connects different towns a_i and b_i bidirectionally. No two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any othe...
[{"input": "1 1\n3 2\n4 3", "output": "YES\n"}, {"input": "1 2\n3 2\n4 3", "output": "YES\n"}, {"input": "3 2\n2 4\n1 4", "output": "YES\n"}, {"input": "1 4\n2 2\n4 3", "output": "YES\n"}, {"input": "3 2\n3 4\n1 4", "output": "YES\n"}, {"input": "2 1\n3 2\n4 1", "output": "YES\n"}, {"input": "3 2\n1 4\n1 2", "output": ...
code_stdio
[ { "content": "Takahashi is participating in a programming contest, AXC001. He has just submitted his code to Problem A.\n\nThe problem has N test cases, all of which must be passed to get an AC verdict.\n\nTakahashi's submission has passed M cases out of the N test cases.\n\nDetermine whether Takahashi's submis...
[{"input": "22 22\n", "output": "Yes\n"}, {"input": "75 75\n", "output": "Yes\n"}, {"input": "26 26\n", "output": "Yes\n"}, {"input": "45 45\n", "output": "Yes\n"}, {"input": "72 72\n", "output": "Yes\n"}, {"input": "-1 -102", "output": "No\n"}, {"input": "-2 -102", "output": "No\n"}, {"input": "81 69\n", "output": "No...
code_stdio
[ { "content": "There are $n$ segments on a $Ox$ axis $[l_1, r_1]$, $[l_2, r_2]$, ..., $[l_n, r_n]$. Segment $[l, r]$ covers all points from $l$ to $r$ inclusive, so all $x$ such that $l \\le x \\le r$.\n\nSegments can be placed arbitrarily  — be inside each other, coincide and so on. Segments can degenerate into...
[{"input": "4\n2\n-1000000000 1000000000\n-1000000000 1000000000\n2\n-1000000000 -1\n0 1000000000\n2\n-1000000000 -1\n1 1000000000\n2\n-1000000000 1\n-1 1000000000\n", "output": "1\n1\n1\n1\n"}, {"input": "4\n2\n-1000000000 1000000000\n-1000000000 1000000000\n2\n-1000000000 -1\n0 1000000000\n2\n-1000000000 -1\n1 100000...
code_stdio
[ { "content": "Your task is to determine how many files of the copy queue you will be able to save into your Hard Disk Drive. The files must be saved in the order they appear in the queue. \n\n### Input:\n\n* Array of file sizes `(0 <= s <= 100)`\n* Capacity of the HD `(0 <= c <= 500)`\n\n### Output:\n\n* Number...
[{"input": "[4, 8, 15, 16, 23, 42]\n108", "output": "[6]", "fn_name": "save"}, {"input": "[11, 13, 15, 17, 19]\n8", "output": "[0]", "fn_name": "save"}, {"input": "[4, 4, 4, 3, 3]\n12", "output": "[3]", "fn_name": "save"}, {"input": "[4, 4, 4, 3, 3]\n11", "output": "[2]", "fn_name": "save"}, {"input": "[1, 2, 3, 4]\n25...
code_functional
[ { "content": "Takahashi has received an undirected graph with N vertices, numbered 1, 2, ..., N. The edges in this graph are represented by (u_i, v_i). There are no self-loops and multiple edges in this graph.\n\nBased on this graph, Takahashi is now constructing a new graph with N^2 vertices, where each vertex...
[{"input": "19 5\n1 4\n5 4\n4 7\n12 10\n4 6", "output": "320\n"}, {"input": "21 5\n1 2\n3 4\n3 5\n4 1\n6 10", "output": "400\n"}, {"input": "21 5\n1 2\n3 3\n3 5\n4 1\n6 10", "output": "405\n"}, {"input": "21 5\n1 2\n3 5\n3 5\n4 1\n6 10", "output": "410\n"}, {"input": "12 5\n2 2\n3 4\n2 10\n4 1\n2 2", "output": "124\n"}...
code_stdio
[ { "content": "Given is an integer sequence of length N+1: A_0, A_1, A_2, \\ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \\ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1.\n\...
[{"input": "10\n0 -1 1 1 3 3 4 8 13 23 34", "output": "360\n"}, {"input": "10\n-1 0 1 0 2 3 5 8 13 21 34", "output": "421\n"}, {"input": "10\n0 -1 1 1 3 4 4 8 13 23 34", "output": "358\n"}, {"input": "10\n-1 0 1 0 2 3 5 8 13 30 34", "output": "457\n"}, {"input": "10\n-1 0 1 0 2 3 5 8 13 16 34", "output": "401\n"}, {"in...
code_stdio
[ { "content": "You are given a string s of length n.\nDoes a tree with n vertices that satisfies the following conditions exist?\n - The vertices are numbered 1,2,..., n.\n - The edges are numbered 1,2,..., n-1, and Edge i connects Vertex u_i and v_i.\n - If the i-th character in s is 1, we can have a connected ...
[{"input": "1110\n", "output": "1 2\n2 3\n3 4\n"}, {"input": "1010\n", "output": "1 2\n1 3\n1 4\n"}, {"input": "1110", "output": "1 2\n2 3\n3 4"}, {"input": "1010", "output": "1 2\n1 3\n1 4"}, {"input": "1111\n", "output": "-1\n"}, {"input": "1011", "output": "-1\n"}, {"input": "0111", "output": "-1\n"}, {"input": "100...
code_stdio
[ { "content": "A sum of p rubles is charged from Arkady's mobile phone account every day in the morning. Among the following m days, there are n days when Arkady will top up the account: in the day d_{i} he will deposit t_{i} rubles on his mobile phone account. Arkady will always top up the account before the da...
[{"input": "10 1 10\n1 1000000000\n2 1000000000\n3 1000000000\n4 1000000000\n5 1000000000\n6 1000000000\n7 1000000000\n8 1000000000\n9 1000000000\n10 1000000000\n", "output": " 0"}, {"input": "14 4115 100\n18 72959\n20 5578\n28 36578\n32 12797\n33 4242\n42 4...
code_stdio
[ { "content": "Special Agent Smart Beaver works in a secret research department of ABBYY. He's been working there for a long time and is satisfied with his job, as it allows him to eat out in the best restaurants and order the most expensive and exotic wood types there. \n\nThe content special agent has got an i...
[{"input": "1023456789??????????????????????????????????????ABCDIFGHIJ\n", "output": "362880000000000000000000000000000000000000000\n"}, {"input": "B??C?\n", "output": "81000\n"}, {"input": "IJ?GH\n", "output": "45360\n"}, {"input": "??JG?\n", "output": "81000\n"}, {"input": "CDEFG\n", "output": "27216\n"}, {"input": "...
code_stdio
[ { "content": "An elephant decided to visit his friend. It turned out that the elephant's house is located at point 0 and his friend's house is located at point x(x > 0) of the coordinate line. In one step the elephant can move 1, 2, 3, 4 or 5 positions forward. Determine, what is the minimum number of steps he ...
[{"input": "6972384\n", "output": "1394477\n"}, {"input": "5118712\n", "output": "1023743\n"}, {"input": "1000000\n", "output": "200000\n"}, {"input": "1000000\n", "output": "200000\n"}, {"input": "1925720\n", "output": "385144\n"}, {"input": "1093799\n", "output": "218760\n"}, {"input": "1000010\n", "output": "200002\...
code_stdio
[ { "content": "Vasya and Petya take part in a Codeforces round. The round lasts for two hours and contains five problems.\n\nFor this round the dynamic problem scoring is used. If you were lucky not to participate in any Codeforces round with dynamic problem scoring, here is what it means. The maximum point valu...
[{"input": "26\n3 -1 71 -1 42\n85 72 48 38 -1\n-1 -1 66 24 -1\n46 -1 60 99 107\n53 106 51 -1 104\n-1 17 135 54 -1\n44 107 66 65 102\n47 40 62 34 5\n-1 10 -1 98 -1\n-1 69 47 85 75\n12 62 -1 15 -1\n48 63 72 32 99\n116 104 111 -1 -1\n92 -1 52 -1 11\n118 25 97 1 108\n-1 78 97 37 -1\n87 47 -1 -1 21\n79 87 73 82 70\n90 108 1...
code_stdio
[ { "content": "You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y.\n\nYour favorite rational number in the [0;1] range is p / q. Now y...
[{"input": "5\n99999997 999999998 999999998 999999999\n99999996 999999997 999999997 999999999\n99999997 999999998 999999998 999999999\n99999996 999999997 999999997 999999999\n162133301 999999998 999999998 999999999\n", "output": "899999999100000001\n449999999550000002\n899999999100000001\n449999999550000002\n8378666951...
code_stdio
[ { "content": "You might know some pretty large perfect squares. But what about the NEXT one?\n\nComplete the `findNextSquare` method that finds the next integral perfect square after the one passed as a parameter. Recall that an integral perfect square is an integer n such that sqrt(n) is also an integer. \n...
[{"input": "15241383936", "output": "[15241630849]", "fn_name": "find_next_square"}, {"input": "319225", "output": "[320356]", "fn_name": "find_next_square"}, {"input": "342786627", "output": "[-1]", "fn_name": "find_next_square"}, {"input": "121", "output": "[144]", "fn_name": "find_next_square"}, {"input": "625", "ou...
code_functional
[ { "content": "Tsuruga Castle, a symbol of Aizuwakamatsu City, was named \"Tsuruga Castle\" after Gamo Ujisato built a full-scale castle tower. You can overlook the Aizu basin from the castle tower. On a clear day, you can see Tsuruga Castle from the summit of Mt. Iimori, which is famous for Byakkotai.\n\n<image...
[{"input": "8\n106\n29\n127\n11\n41\n39\n2\n5\n4\n67\n81\n78\n65\n0", "output": "2\n1\n1\n1\n1\n0\n2\n0\n0\n0\n0\n0\n0\n4\n"}, {"input": "8\n001\n21\n127\n11\n41\n39\n2\n5\n4\n67\n81\n78\n65\n0", "output": "3\n1\n1\n1\n1\n0\n1\n0\n0\n0\n0\n0\n0\n4\n"}, {"input": "8\n001\n21\n127\n11\n41\n39\n2\n5\n4\n67\n81\n54\n65\n0"...
code_stdio
[ { "content": "Recently, Tokitsukaze found an interesting game. Tokitsukaze had n items at the beginning of this game. However, she thought there were too many items, so now she wants to discard m (1 ≤ m ≤ n) special items of them.\n\nThese n items are marked with indices from 1 to n. In the beginning, the item ...
[{"input": "1000000000000000000 20 365\n31881893160049984 103938857870698567 103962228223609431 140762820261865064 175962215264653912 239086305245565642 354522451098745823 383839975876242372 443471287955807705 478923027151493682 511195154588214957 619570919279066139 677571312513476877 705864797651447277 789633853044745...
code_stdio
[ { "content": "Omkar's most recent follower, Ajit, has entered the Holy Forest. Ajit realizes that Omkar's forest is an n by m grid (1 ≤ n, m ≤ 2000) of some non-negative integers. Since the forest is blessed by Omkar, it satisfies some special conditions:\n\n 1. For any two adjacent (sharing a side) cells, the...
[{"input": "4\n3 4\n0000\n00#0\n0000\n2 1\n#\n#\n1 2\n##\n6 29\n#############################\n#000##0###0##0#0####0####000#\n#0#0##00#00##00####0#0###0#0#\n#0#0##0#0#0##00###00000##00##\n#000##0###0##0#0##0###0##0#0#\n#############################\n", "output": "\n2\n3\n3\n319908071\n"}, {"input": "4\n3 4\n0000\n00#0\...
code_stdio
[ { "content": "A boy named Vasya wants to play an old Russian solitaire called \"Accordion\". In this solitaire, the player must observe the following rules:\n\n * A deck of n cards is carefully shuffled, then all n cards are put on the table in a line from left to right; \n * Before each move the table has se...
[{"input": "52\n2D 5S 4S 4S 4C 2S 4H 4S 4H 4C 3S 4S 4S 4H 5S 4H 4H 5S 2S 4S 4S 2S 4S 4C 4S 4S 9S 4H 4S 3S 3H 4S 4S 7S 3S 3S 2H 3S 7S 4S 2S 7S 2S 2S 3S 3C 2S 3S 3S 2S 5S 3S\n", "output": "YES\n"}, {"input": "52\nAC 4C TC 9C TH AD 3C TC 4S 5C TD QD TH 4C 4D 3H TC 4S TH 8H 7H 4D TH QD 4D 8H QH 4D 4H 8D 4H 4D 8H 3D 9D 8H 9...
code_stdio
[ { "content": "The only difference between this problem and D2 is that you don't have to provide the way to construct the answer in this problem, but you have to do it in D2.\n\nThere's a table of $n \\times m$ cells ($n$ rows and $m$ columns). The value of $n \\cdot m$ is even.\n\nA domino is a figure that cons...
[{"input": "10\n100 100 5000\n100 100 5000\n100 100 5000\n100 100 5000\n100 100 5000\n100 100 5000\n100 100 5000\n100 100 5000\n100 100 5000\n100 100 5000\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "10\n100 100 5000\n100 100 5000\n100 100 5000\n100 100 5000\n100 100 5000\n100 100 500...
code_stdio
[ { "content": "Sample testcase 3 has a mistake, so we erased this case and rejudged all solutions of this problem. (21:01)\n\nSnuke got a sequence $a$ of length $n$ from AtCoder company. All elements in $a$ are distinct.\nHe made a sequence $b$, but actually, he is not remembered it.\nHowever, he is remembered a...
[{"input": "25 250\n13 10 11 20 25 30 35 40 45 50 55 60 65 36 83 80 85 90 95 100 176 110 115 120 125", "output": "322439703\n"}, {"input": "25 127\n5 10 15 20 39 30 35 40 45 50 108 37 81 70 75 80 82 175 58 000 99 110 115 120 125", "output": "712861496\n"}, {"input": "25 127\n5 10 15 20 39 30 35 69 45 50 108 37 81 70 75...
code_stdio
[ { "content": "Monocarp plays \"Rage of Empires II: Definitive Edition\" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.\n\nThe wall consists of $n$ sections, aligned in a row...
[{"input": "71\n76468 749982 526217 695732 169602 557600 719698 698344 105043 522755 113036 693415 502619 741227 932643 534995 954172 87407 742242 172680 901819 194280 523575 413309 242835 918390 108115 823507 810672 916889 407735 504768 301602 942625 742419 779364 595511 775444 721352 115825 451351 182260 478289 63957...
code_stdio
[ { "content": "Polycarp found on the street an array $a$ of $n$ elements.\n\nPolycarp invented his criterion for the beauty of an array. He calls an array $a$ beautiful if at least one of the following conditions must be met for each different pair of indices $i \\ne j$:\n\n$a_i$ is divisible by $a_j$;\n\nor $a_...
[{"input": "10\n5\n4 3 1 5 2\n5\n1 5 1 1 5\n5\n4 1 2 1 2\n5\n5 5 6 1 4\n5\n5 2 4 5 4\n5\n3 1 2 3 4\n5\n1 3 9 4 1\n5\n5 2 10 5 4\n5\n1 1 2 3 2\n4\n2 2 5 1\n", "output": "2\n0\n0\n2\n2\n2\n1\n2\n1\n1\n"}, {"input": "10\n5\n4 3 1 5 1\n5\n1 4 1 1 3\n5\n4 1 2 1 2\n5\n5 5 5 1 4\n5\n5 2 4 5 4\n5\n3 1 2 3 4\n5\n2 3 5 4 1\n5\n5...
code_stdio
[ { "content": "Petya loves football very much. One day, as he was watching a football match, he was writing the players' current positions on a piece of paper. To simplify the situation he depicted it as a string consisting of zeroes and ones. A zero corresponds to players of one team; a one corresponds to playe...
[{"input": "1111111111111111111111111111111111111111011111111111111111111111111111111111111111111111111111111111\n", "output": "YES\n"}, {"input": "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\n", "output": "YES\n"}, {"input": "000110111001110111000000001001111110...
code_stdio
[ { "content": "The main characters have been omitted to be short.\n\nYou are given a directed unweighted graph without loops with $n$ vertexes and a path in it (that path is not necessary simple) given by a sequence $p_1, p_2, \\ldots, p_m$ of $m$ vertexes; for each $1 \\leq i < m$ there is an arc from $p_i$ to ...
[{"input": "20\n01001100001100011011\n00111101001100001101\n01010010000010000110\n10101001000000000110\n00110110111101100000\n00111010110011100011\n01101000111001110100\n11111100011110000100\n11111010011110011000\n10001100000101100101\n11001111010010100011\n00001111001001111111\n10011110000101001110\n100011010100001110...
code_stdio
[ { "content": "Congratulations! That Special Someone has given you their phone number.\n\nBut WAIT, is it a valid number? \n\nYour task is to write a function that verifies whether a given string contains a valid British mobile (cell) phone number or not. \n\nIf valid, return 'In with a chance'.\n\nIf invalid, o...
[{"input": "\"+447+4435512555\"", "output": "[\"Plenty more fish in the sea\"]", "fn_name": "validate_number"}, {"input": "\"+337535512555\"", "output": "[\"Plenty more fish in the sea\"]", "fn_name": "validate_number"}, {"input": "\"075335440555\"", "output": "[\"Plenty more fish in the sea\"]", "fn_name": "validate_n...
code_functional
[ { "content": "Create a program that takes two dates as input and outputs the number of days between the two dates.\n\nDate 1 (y1, m1, d1) is the same as or earlier than date 2 (y2, m2, d2). Date 1 is included in the number of days, not date 2. Also, take the leap year into account when calculating. The leap yea...
[{"input": "2006 9 2 522 9 3\n2006 8 1 1174 11 11\n2004 1 2 1365 1 1\n3334 2 1 2180 1 1\n2000 1 1 2101 1 1\n-1 -1 -1 -1 -1 -1", "output": "-542019\n-303780\n-233390\n-421521\n36890\n"}, {"input": "2006 9 2 522 8 3\n2006 8 1 1174 11 11\n2004 1 2 1365 1 1\n3334 2 1 2180 1 1\n2000 1 1 2101 1 1\n-1 -1 -1 -1 -1 -1", "output...
code_stdio
[ { "content": "Given the number n, find the smallest positive integer which has exactly n divisors. It is guaranteed that for the given n the answer will not exceed 1018.\n\nInput\n\nThe first line of the input contains integer n (1 ≤ n ≤ 1000).\n\nOutput\n\nOutput the smallest positive integer with exactly n di...
[{"input": "118\n", "output": "864691128455135232"}, {"input": "473\n", "output": "259700248434180096"}, {"input": "940\n", "output": "199495389743677440"}, {"input": "265\n", "output": "364791569817010176"}, {"input": "902\n", "output": "324625310542725120"}, {"input": "106\n", "output": "13510798882111488\n"}, {"inpu...
code_stdio
[ { "content": "In this Kata you are a builder and you are assigned a job of building a wall with a specific size (God knows why...).\n\nCreate a function called `build_a_wall` (or `buildAWall` in JavaScript) that takes `x` and `y` as integer arguments (which represent the number of rows of bricks for the wall an...
[{"input": "10\n7", "output": "[\"\\u25a0|\\u25a0\\u25a0|\\u25a0\\u25a0|\\u25a0\\u25a0|\\u25a0\\u25a0|\\u25a0\\u25a0|\\u25a0\\u25a0|\\u25a0\\n\\u25a0\\u25a0|\\u25a0\\u25a0|\\u25a0\\u25a0|\\u25a0\\u25a0|\\u25a0\\u25a0|\\u25a0\\u25a0|\\u25a0\\u25a0\\n\\u25a0|\\u25a0\\u25a0|\\u25a0\\u25a0|\\u25a0\\u25a0|\\u25a0\\u25a0|\\u...
code_functional
[ { "content": "Athenaeus has just finished creating his latest musical composition and will present it tomorrow to the people of Athens. Unfortunately, the melody is rather dull and highly likely won't be met with a warm reception.\n\nHis song consists of $n$ notes, which we will treat as positive integers. The ...
[{"input": "5\n6\n1 2 2 2 5 11\n2\n2 4\n6\n1 1 3 4 4 10\n1\n1\n6\n1 1 1 2 2 2\n", "output": "5\n2\n6\n1\n3\n"}, {"input": "5\n6\n1 2 2 4 6 11\n2\n1 4\n6\n1 1 1 4 4 10\n1\n1\n6\n1 1 2 2 2 2\n", "output": "6\n2\n5\n1\n3\n"}, {"input": "5\n6\n2 2 2 2 9 12\n2\n4 4\n6\n1 1 1 4 4 5\n1\n1\n6\n1 1 2 2 2 2\n", "output": "4\n2\n...
code_stdio
[ { "content": "A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any num...
[{"input": "50\n474421 421097 217233 156339 27075 733996 281778 863492 184707 956857 288561 70997 393786 337382 663642 131184 637 273801 799870 295017 392338 842567 161819 297705 102013 930684 375703 838048 154915 138503 629056 256591 893619 19263 787927 684541 320265 841090 421423 490879 394582 493952 619247 633202 61...
code_stdio
[ { "content": "You can find anything whatsoever in our Galaxy! A cubical planet goes round an icosahedral star. Let us introduce a system of axes so that the edges of the cubical planet are parallel to the coordinate axes and two opposite vertices lay in the points (0, 0, 0) and (1, 1, 1). Two flies live on the ...
[{"input": "1 0 0\n0 0 0\n", "output": "YES\n"}, {"input": "1 1 1\n0 1 1\n", "output": "YES\n"}, {"input": "0 0 1\n1 0 0\n", "output": "YES\n"}, {"input": "1 0 0\n0 1 0\n", "output": "YES\n"}, {"input": "0 0 1\n1 0 1\n", "output": "YES\n"}, {"input": "0 1 0\n0 1 1\n", "output": "YES\n"}, {"input": "1 0 0\n0 0 1\n", "ou...
code_stdio
[ { "content": "For the given integer $n$ ($n > 2$) let's write down all the strings of length $n$ which contain $n-2$ letters 'a' and two letters 'b' in lexicographical (alphabetical) order.\n\nRecall that the string $s$ of length $n$ is lexicographically less than string $t$ of length $n$, if there exists such ...
[{"input": "2\n39776 83767477\n50000 1249975000\n", "output": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "Petya started to attend programming lessons. On the first lesson his task was to write a simple program. The program was supposed to do the following: in the given string, consisting if uppercase and lowercase Latin letters, it: \n\n * deletes all the vowels, \n * inserts a character \".\" befor...
[{"input": "FSNRBXLFQHZXGVMKLQDVHWLDSLKGKFMDRQWMWSSKPKKQBNDZRSCBLRSKCKKFFKRDMZFZGCNSMXNPMZVDLKXGNXGZQCLRTTDXLMXQ\n", "output": ".f.s.n.r.b.x.l.f.q.h.z.x.g.v.m.k.l.q.d.v.h.w.l.d.s.l.k.g.k.f.m.d.r.q.w.m.w.s.s.k.p.k.k.q.b.n.d.z.r.s.c.b.l.r.s.k.c.k.k.f.f.k.r.d.m.z.f.z.g.c.n.s.m.x.n.p.m.z.v.d.l.k.x.g.n.x.g.z.q.c.l.r.t.t.d.x...
code_stdio
[ { "content": "Soon a school Olympiad in Informatics will be held in Berland, n schoolchildren will participate there.\n\nAt a meeting of the jury of the Olympiad it was decided that each of the n participants, depending on the results, will get a diploma of the first, second or third degree. Thus, each student ...
[{"input": "3000000\n1000000 1000000\n1000000 1000000\n1000000 1000000\n", "output": "1000000 1000000 1000000 \n"}, {"input": "3000000\n1000000 1000000\n1000000 1000000\n1000000 1000000\n", "output": "1000000 1000000 1000000\n"}, {"input": "1629279\n267360 999930\n183077 674527\n202618 786988\n", "output": "999930 4267...
code_stdio
[ { "content": "\"We've tried solitary confinement, waterboarding and listening to Just In Beaver, to no avail. We need something extreme.\"\n\n\"Little Alena got an array as a birthday present...\"\n\nThe array b of length n is obtained from the array a of length n and two integers l and r (l ≤ r) using the foll...
[{"input": "98\n-99 -98 -95 -90 97 93 96 95 98 98 -94 -92 -99 -92 -91 -87 -83 -84 -87 -88 -90 -79 -79 -82 -77 -76 92 82 91 91 90 91 -69 -72 -65 -68 -65 -58 -59 -63 -56 -57 -59 -53 -55 -45 -51 -52 73 81 75 71 77 72 67 70 60 70 61 64 -34 -41 -41 -41 -37 -39 -36 -33 -36 -36 -33 -36 54 49 53 51 50 -23 -26 -22 -23 -31 -30 4...
code_stdio
[ { "content": "You are given a tube which is reflective inside represented as two non-coinciding, but parallel to $Ox$ lines. Each line has some special integer points — positions of sensors on sides of the tube.\n\nYou are going to emit a laser ray in the tube. To do so, you have to choose two integer points $A...
[{"input": "13 968288\n0 67108864 134217728 201326592 268435456 335544320 402653184 469762048 536870912 603979776 671088640 738197504 805306368\n13 986214\n33554432 100663296 167772160 234881024 301989888 369098752 436207616 503316480 570425344 637534208 704643072 771751936 838860800\n", "output": "26\n"}, {"input": "1...
code_stdio
[ { "content": "An n × n table a is defined as follows:\n\n The first row and the first column contain ones, that is: a_{i}, 1 = a_{1, }i = 1 for all i = 1, 2, ..., n. Each of the remaining numbers in the table is equal to the sum of the number above it and the number to the left of it. In other words, the rema...
[{"input": "010\n", "output": "48620\n"}, {"input": "10\n", "output": "48620\n"}, {"input": "10\n", "output": "48620"}, {"input": "9\n", "output": "12870\n"}, {"input": "9\n", "output": "12870"}, {"input": "8\n", "output": "3432\n"}, {"input": "8\n", "output": "3432"}, {"input": "7\n", "output": "924\n"}, {"input": "6\...
code_stdio
[ { "content": "A tree is a graph with n vertices and exactly n - 1 edges; this graph should meet the following condition: there exists exactly one shortest (by number of edges) path between any pair of its vertices.\n\nA subtree of a tree T is a tree with both vertices and edges as subsets of vertices and edges ...
[{"input": "12\n1 6\n10 1\n4 1\n7 1\n1 2\n5 1\n1 8\n1 11\n3 1\n12 1\n9 1\n580660007 861441526 -264928594 462352906 253254575 -974301934 1176789404 662215161 87511873 514836444 -774450572 848928657\n", "output": "2529263875\n"}, {"input": "12\n1 6\n10 1\n4 1\n7 1\n1 2\n5 1\n1 8\n1 11\n3 1\n12 1\n9 1\n580660007 152568581...
code_stdio
[ { "content": "Vasya has two arrays $A$ and $B$ of lengths $n$ and $m$, respectively.\n\nHe can perform the following operation arbitrary number of times (possibly zero): he takes some consecutive subsegment of the array and replaces it with a single element, equal to the sum of all elements on this subsegment. ...
[{"input": "49\n18 1 7 2 1 1 50 22 8 2 2 1 30 2 46 10 1 4 5 18 25 21 38 11 2 15 29 8 7 2 45 12 14 16 16 23 11 1 1 4 48 18 3 1 1 23 4 10 7\n50\n5 25 34 22 19 4 4 2 40 52 1 4 1 3 47 9 4 1 8 47 4 5 1 1 9 22 9 2 2 1 1 48 7 2 8 16 4 2 41 12 3 30 21 10 2 2 5 1 31 13\n", "output": "14\n"}, {"input": "49\n18 1 7 2 1 1 50 22 8 ...
code_stdio
[ { "content": "Young Teodor enjoys drawing. His favourite hobby is drawing segments with integer borders inside his huge [1;m] segment. One day Teodor noticed that picture he just drawn has one interesting feature: there doesn't exist an integer point, that belongs each of segments in the picture. Having discove...
[{"input": "43 1319\n750 1030\n857 946\n941 1203\n407 1034\n1052 1290\n546 585\n630 1201\n133 342\n693 1315\n34 719\n176 1097\n39 931\n198 885\n3 1025\n892 1054\n461 1287\n195 1273\n832 1039\n308 955\n642 866\n770 838\n440 777\n289 948\n98 814\n458 768\n82 265\n300 596\n182 706\n368 1225\n237 626\n36 348\n100 222\n46 9...
code_stdio
[ { "content": "Write a program which reads a sequence and prints it in the reverse order.\n\nNote\n\n解説\n\nConstraints\n\n* n ≤ 100\n* 0 ≤ ai < 1000\n\nInput\n\nThe input is given in the following format:\n\n\nn\na1 a2 . . . an\n\n\nn is the size of the sequence and ai is the ith element of the sequence.\n\nOutp...
[{"input": "8\n-2 0 0 32 -1 -2 153 26", "output": "26 153 -2 -1 32 0 0 -2\n"}, {"input": "8\n-2 0 0 32 -2 -2 153 26", "output": "26 153 -2 -2 32 0 0 -2\n"}, {"input": "8\n-2 1 0 32 -2 -2 153 26", "output": "26 153 -2 -2 32 0 1 -2\n"}, {"input": "8\n-2 1 0 32 -2 -1 153 26", "output": "26 153 -1 -2 32 0 1 -2\n"}, {"input...
code_stdio
[ { "content": "«Next please», — the princess called and cast an estimating glance at the next groom.\n\nThe princess intends to choose the most worthy groom, this is, the richest one. Whenever she sees a groom who is more rich than each of the previous ones, she says a measured «Oh...». Whenever the groom is ric...
[{"input": "110 29 15\n", "output": "1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 32769 32770 32771 32772 32773 32774 32775 32776 32777 32778 32779 32780 32781 32782 32783 32784 32785 32786 32787 32788 32789 32790 32791 32792 32793 32794 32795 32796 32797 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": "Read problems statements in Mandarin Chinese , Russian and Vietnamese as well. \n\nTriangle classification is an important problem in modern mathematics. Mathematicians have developed many criteria according to which a triangle can be classified. In this problem, you will be asked to classify some...
[{"input": "2\n6\n0 0 4 1 1 2\n0 -1 1 0 1 4\n1 0 1 1 1 3\n0 0 2 1 1 2\n3 0 0 4 4 7\n0 0 2 1 4 0", "output": "Scalene obtuse triangle\nScalene obtuse triangle\nScalene obtuse triangle\nIsosceles acute triangle\nIsosceles right triangle\nIsosceles obtuse triangle\n"}, {"input": "2\n6\n0 0 4 1 1 2\n0 0 1 0 1 4\n0 0 1 1 1 ...
code_stdio
[ { "content": "Sereja has an array a, consisting of n integers a_1, a_2, ..., a_{n}. The boy cannot sit and do nothing, he decided to study an array. Sereja took a piece of paper and wrote out m integers l_1, l_2, ..., l_{m} (1 ≤ l_{i} ≤ n). For each number l_{i} he wants to know how many distinct numbers are st...
[{"input": "10 10\n1 2 3 4 1 2 3 4 100000 99999\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", "output": "6\n6\n6\n6\n6\n5\n4\n3\n2\n1\n"}, {"input": "10 10\n1 2 3 4 1 2 3 4 100000 99999\n1\n2\n3\n4\n5\n6\n7\n7\n9\n10\n", "output": "6\n6\n6\n6\n6\n5\n4\n4\n2\n1\n"}, {"input": "10 10\n1 2 3 4 1 2 3 6 100000 99999\n1\n2\n3\n4\n5\n6\...
code_stdio
[ { "content": "Amr lives in Lala Land. Lala Land is a very beautiful country that is located on a coordinate line. Lala Land is famous with its apple trees growing everywhere.\n\nLala Land has exactly n apple trees. Tree number i is located in a position x_{i} and has a_{i} apples growing on it. Amr wants to col...
[{"input": "28\n49728 91049\n-42863 4175\n-89214 22191\n77977 16965\n-42960 87627\n-84329 97494\n89270 75906\n-13695 28908\n-72279 13607\n-97327 87062\n-58682 32094\n39108 99936\n29304 93784\n-63886 48237\n-77359 57648\n-87013 79017\n-41086 35033\n-60613 83555\n-48955 56816\n-20568 26802\n52113 25160\n-88885 45294\n226...
code_stdio
[ { "content": "Vanya got an important task — he should enumerate books in the library and label each book with its number. Each of the n books should be assigned with a number from 1 to n. Naturally, distinct books should be assigned distinct numbers.\n\nVanya wants to know how many digits he will have to write ...
[{"input": "1000000000\n", "output": "8888888899\n"}, {"input": "1000000000\n", "output": "8888888899\n"}, {"input": "222222222\n", "output": "1888888896\n"}, {"input": "943006819\n", "output": "8375950269\n"}, {"input": "986747865\n", "output": "8769619683\n"}, {"input": "999999999\n", "output": "8888888889\n"}, {"inp...
code_stdio
[ { "content": "Given an integer, take the (mean) average of each pair of consecutive digits. Repeat this process until you have a single integer, then return that integer. e.g.\n\nNote: if the average of two digits is not an integer, round the result **up** (e.g. the average of 8 and 9 will be 9)\n\n## Examples\...
[{"input": "3700", "output": "[4]", "fn_name": "digits_average"}, {"input": "246", "output": "[4]", "fn_name": "digits_average"}, {"input": "245", "output": "[4]", "fn_name": "digits_average"}, {"input": "345", "output": "[5]", "fn_name": "digits_average"}, {"input": "346", "output": "[5]", "fn_name": "digits_average"}...
code_functional
[ { "content": "Dmitry has an array of $n$ non-negative integers $a_1, a_2, \\dots, a_n$.\n\nIn one operation, Dmitry can choose any index $j$ ($1 \\le j \\le n$) and increase the value of the element $a_j$ by $1$. He can choose the same index $j$ multiple times.\n\nFor each $i$ from $0$ to $n$, determine whether...
[{"input": "5\n3\n0 1 3\n7\n0 2 2 3 4 3 2\n4\n3 0 0 0\n7\n4 6 2 3 5 0 5\n5\n4 0 1 0 4\n", "output": "1 1 0 -1 \n1 0 -1 -1 -1 -1 -1 -1 \n3 0 1 4 3 \n1 0 -1 -1 -1 -1 -1 -1 \n2 1 0 2 -1 -1 \n"}, {"input": "5\n3\n0 1 3\n7\n0 2 2 3 4 3 2\n4\n3 1 0 0\n7\n4 6 2 3 5 0 5\n5\n4 0 1 0 4\n", "output": "1 1 0 -1 \n1 0 -1 -1 -1 -1 -...
code_stdio
[ { "content": "We have a tree with N vertices. Vertex 1 is the root of the tree, and the parent of Vertex i (2 \\leq i \\leq N) is Vertex P_i.\nTo each vertex in the tree, Snuke will allocate a color, either black or white, and a non-negative integer weight.\nSnuke has a favorite integer sequence, X_1, X_2, ...,...
[{"input": "1000\n1 1 2 3 4 5 5 7 8 9 10 11 12 12 14 14 15 16 18 19 20 19 20 23 24 24 25 27 28 29 30 31 32 32 32 35 36 36 38 39 39 41 42 42 43 45 45 47 48 49 50 50 52 52 53 55 56 57 57 59 59 61 62 62 64 64 66 67 67 69 70 70 71 72 73 73 76 77 78 79 79 81 82 83 83 84 86 87 87 88 90 91 91 92 94 95 96 97 98 99 100 101 102 ...
code_stdio
[ { "content": "It's another Start[c]up finals, and that means there is pizza to order for the onsite contestants. There are only 2 types of pizza (obviously not, but let's just pretend for the sake of the problem), and all pizzas contain exactly S slices.\n\nIt is known that the i-th contestant will eat si slice...
[{"input": "25 6\n1 10 5\n1 8 4\n1 8 2\n4 8 9\n3 2 8\n1 9 5\n2 10 10\n3 9 6\n3 5 4\n2 7 8\n2 3 2\n2 6 8\n3 7 8\n4 3 7\n1 8 1\n3 6 4\n3 2 8\n2 2 1\n4 8 8\n4 15 4\n3 10 2\n3 6 6\n2 2 5\n1 6 2\n4 1 5\n", "output": "477\n"}, {"input": "25 6\n1 10 5\n1 8 4\n1 8 2\n4 8 9\n3 2 8\n1 9 5\n2 10 10\n3 9 6\n3 5 4\n2 7 8\n2 3 2\n2 ...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian. \n\nYou have an array of integers A_{1}, A_{2}, ..., A_{N}. The function F(P), where P is a subset of A, is defined as the XOR (represented by the symbol ⊕) of all the integers present in the subset. If P is empty, then F(P)=0.\n\nGiven an...
[{"input": "1\n-1 13\n-1 13 -2", "output": "13\n"}, {"input": "1\n-1 13\n-2 13 -2", "output": "13\n"}, {"input": "1\n-1 13\n-1 8 -2", "output": "13\n"}, {"input": "1\n0 26\n0 14 -2", "output": "26\n"}, {"input": "1\n0 12\n0 14 -2", "output": "12\n"}, {"input": "1\n0 22\n0 14 -2", "output": "24\n"}, {"input": "1\n0 2\n-...
code_stdio
[ { "content": "Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise...
[{"input": "93\n010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010\n", "output": "93\n"}, {"input": "93\n010101000101010101010101010101010101010101010101010101010101010101010101010101010101010101010\n", "output": "93\n"}, {"input": "93\n0100010001010101010101010101010101010101...
code_stdio
[ { "content": "Recently, Vladimir got bad mark in algebra again. To avoid such unpleasant events in future he decided to train his arithmetic skills. He wrote four integer numbers a, b, c, d on the blackboard. During each of the next three minutes he took two numbers from the blackboard (not necessarily adjacent...
[{"input": "1000 1000 999 1000\n* * *\n", "output": "999000000000\n"}, {"input": "720 903 589 804\n* * *\n", "output": "307887168960\n"}, {"input": "573 598 1387 124\n* * *\n", "output": "58932376152\n"}, {"input": "739 903 589 804\n* * *\n", "output": "316011969252\n"}, {"input": "573 598 1256 124\n* * *\n", "output":...
code_stdio
[ { "content": "Takahashi loves numbers divisible by 2.\nYou are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.\nHere, the number of times an integer can be divisible by 2, is how many...
[{"input": "100\n", "output": "64\n"}, {"input": "32\n", "output": "32\n"}, {"input": "101", "output": "64\n"}, {"input": "111", "output": "64\n"}, {"input": "110", "output": "64\n"}, {"input": "121", "output": "64\n"}, {"input": "104", "output": "64\n"}, {"input": "107", "output": "64\n"}, {"input": "113", "output": "...
code_stdio
[ { "content": "The Resistance is trying to take control over all planets in a particular solar system. This solar system is shaped like a tree. More precisely, some planets are connected by bidirectional hyperspace tunnels in such a way that there is a path between every pair of the planets, but removing any tun...
[{"input": "10\n4 3\n2 10\n10 1\n5 7\n9 8\n10 6\n5 10\n1 3\n2 9\n", "output": "4\n"}, {"input": "10\n4 1\n2 10\n10 1\n5 7\n3 8\n10 6\n5 9\n1 3\n1 9\n", "output": "5\n"}, {"input": "10\n4 3\n2 10\n10 1\n5 7\n5 8\n10 6\n5 9\n1 3\n1 9\n", "output": "5\n"}, {"input": "10\n4 3\n2 10\n10 1\n5 7\n5 8\n10 6\n5 9\n1 3\n2 9\n", ...
code_stdio
[ { "content": "You have a computer literacy course in your university. In the computer system, the login/logout records of all PCs in a day are stored in a file. Although students may use two or more PCs at a time, no one can log in to a PC which has been logged in by someone who has not logged out of that PC ye...
[{"input": "6 2\n10\n775 1 1 1\n780 4 2 1\n790 2 1 1\n800 2 1 0\n810 3 1 1\n820 1 1 0\n825 3 1 0\n860 1 1 1\n870 4 2 -1\n880 1 1 0\n1\n780 870 1\n13 15\n12\n540 12 13 1\n600 12 13 0\n650 13 15 1\n660 12 15 1\n665 11 13 1\n670 13 15 0\n675 11 13 0\n680 12 15 0\n1000 11 14 1\n1060 12 14 1\n1060 11 14 0\n1080 12 14 0\n3\n...
code_stdio
[ { "content": "Recently, the bear started studying data structures and faced the following problem.\n\nYou are given a sequence of integers x1, x2, ..., xn of length n and m queries, each of them is characterized by two integers li, ri. Let's introduce f(p) to represent the number of such indexes k, that xk is d...
[{"input": "9\n9999991 9999943 9999883 4658161 4657997 2315407 2315263 1000003 1000033\n13\n9999991 9999991\n9999943 9999943\n9999883 9999883\n4658161 4658161\n4657997 4657997\n2315407 2315407\n2315263 2315263\n1000003 1000003\n1000033 1000033\n2 2000000000\n2000000000 2000000000\n9999992 2000000000\n1000033 9999990\n"...
code_stdio
[ { "content": "You are given the following points with integer coordinates on the plane: M0, A0, A1, ..., An - 1, where n is odd number. Now we define the following infinite sequence of points Mi: Mi is symmetric to Mi - 1 according <image> (for every natural number i). Here point B is symmetric to A according M...
[{"input": "1 900000000000000001\n-1000 -1000\n-1000 -1000\n", "output": "-1000 -1000\n"}, {"input": "1 730435287519116102\n-1000 -1000\n-802 -1000\n", "output": "-1000 -1000\n"}, {"input": "1 1000000000000000000\n-1000 1000\n1000 -1000\n", "output": "-1000 1000\n"}, {"input": "1 1000000000000000000\n-1000 1000\n1001 -...
code_stdio
[ { "content": "Polycarpus develops an interesting theory about the interrelation of arithmetic progressions with just everything in the world. His current idea is that the population of the capital of Berland changes over time like an arithmetic progression. Well, or like multiple arithmetic progressions.\n\nPol...
[{"input": "20\n-1 32 37 -1 -1 -1 57 -1 -1 40 31 33 -1 -1 39 47 43 -1 35 32\n", "output": "5\n"}, {"input": "20\n-1 32 37 -1 -1 -1 57 -1 -1 40 31 33 -1 -1 39 47 43 -1 35 32\n", "output": "5\n"}, {"input": "19\n23 26 -1 -1 35 38 41 -1 -1 -1 53 -1 59 62 6 7 8 9 -1\n", "output": "2\n"}, {"input": "19\n23 26 -1 -1 35 38 41...
code_stdio
[ { "content": "Your task is to calculate the number of arrays such that: each array contains $n$ elements; each element is an integer from $1$ to $m$; for each array, there is exactly one pair of equal elements; for each array $a$, there exists an index $i$ such that the array is strictly ascending before th...
[{"input": "100000 200000\n", "output": "707899035\n"}, {"input": "150000 200000\n", "output": "270223789\n"}, {"input": "200000 200000\n", "output": "668956439\n"}, {"input": "150000 200000\n", "output": "270223789\n"}, {"input": "200000 200000\n", "output": "668956439\n"}, {"input": "113870 200000\n", "output": "8454...
code_stdio
[ { "content": "Dreamoon loves summing up something for no reason. One day he obtains two integers a and b occasionally. He wants to calculate the sum of all nice integers. Positive integer x is called nice if $\\operatorname{mod}(x, b) \\neq 0$ and $\\frac{\\operatorname{div}(x, b)}{\\operatorname{mod}(x, b)} = ...
[{"input": "10000000 10000000\n", "output": "425362313\n"}, {"input": "10000000 10000000\n", "output": "425362313\n"}, {"input": "10000000 11383836\n", "output": "113242098\n"}, {"input": "10000100 10000000\n", "output": "778965806\n"}, {"input": "12520154 17573427\n", "output": "525729623\n"}, {"input": "10000001 1138...
code_stdio
[ { "content": "Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not.\n\nTwo integers x, y are written on the blackboard. It is allowed to erase one of them and replace it wi...
[{"input": "-1000000000000000000 -1000000000000000000 -1000000000000000000\n", "output": " 0\n"}, {"input": "-1000000000 -1000000000 -1000000000\n", "output": " 0\n"}, {"input": "-868993006 -38900...
code_stdio
[ { "content": "You are given a permutation p of numbers 1, 2, ..., n. Let's define f(p) as the following sum:\n\n<image>\n\nFind the lexicographically m-th permutation of length n in the set of permutations having the maximum possible value of f(p).\n\nInput\n\nThe single line of input contains two integers n an...
[{"input": "50 562949953421312\n", "output": "50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 \n"}, {"input": "50 500000000000007\n", "output": "4 5 6 9 11 18 20 22 23 25 26 29 30 31 34 36 37 38 39 40 41 42 43 44 45 46 49 50 48...
code_stdio
[ { "content": "There is a tree with N vertices numbered 1, 2, ..., N. The edges of the tree are denoted by (x_i, y_i).\n\nOn this tree, Alice and Bob play a game against each other. Starting from Alice, they alternately perform the following operation:\n\n* Select an existing edge and remove it from the tree, di...
[{"input": "7\n1 2\n0 7\n4 6\n2 3\n2 4\n1 5", "output": "Alice\n"}, {"input": "7\n2 2\n0 7\n4 6\n2 3\n2 4\n1 5", "output": "Alice\n"}, {"input": "7\n2 1\n0 7\n4 6\n2 3\n2 4\n1 5", "output": "Alice\n"}, {"input": "7\n2 1\n0 7\n4 6\n2 3\n0 4\n1 5", "output": "Alice\n"}, {"input": "7\n1 2\n3 7\n4 6\n2 3\n2 4\n1 5", "outpu...
code_stdio
[ { "content": "A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward. Examples of numerical palindromes are: \n\n2332\n110011\n54322345\n\nFor a given number ```num```, return its closest numerical palindrome which can either be smaller or larger than ``...
[{"input": "\"BGHHGB\"", "output": "[\"Not valid\"]", "fn_name": "palindrome"}, {"input": "\"11029\"", "output": "[\"Not valid\"]", "fn_name": "palindrome"}, {"input": "-1029", "output": "[\"Not valid\"]", "fn_name": "palindrome"}, {"input": "1029", "output": "[1001]", "fn_name": "palindrome"}, {"input": "1221", "outpu...
code_functional
[ { "content": "Now we will confect a reagent. There are eight materials to choose from, numbered 1,2,..., 8 respectively.\n\nWe know the rules of confect:\n```\nmaterial1 and material2 cannot be selected at the same time\nmaterial3 and material4 cannot be selected at the same time\nmaterial5 and material6 must b...
[{"input": "[1, 5, 6, 7, 3]", "output": "[true]", "fn_name": "isValid"}, {"input": "[7, 1, 2, 3]", "output": "[false]", "fn_name": "isValid"}, {"input": "[1, 3, 5, 7]", "output": "[false]", "fn_name": "isValid"}, {"input": "[5, 6, 7, 8]", "output": "[true]", "fn_name": "isValid"}, {"input": "[6, 7, 8]", "output": "[fal...
code_functional
[ { "content": "Everyone knows that hobbits love to organize all sorts of parties and celebrations. There are n hobbits living in the Shire. They decided to organize the Greatest Party (GP) that would last for several days. Next day the hobbits wrote a guest list, some non-empty set containing all the inhabitants...
[{"input": "10000\n", "output": "141\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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 ...
code_stdio
[ { "content": "Have you heard about Megamind? Megamind and Metro Man are two aliens who came to earth. Megamind wanted to destroy the earth, while Metro Man wanted to stop him and protect mankind. After a lot of fighting, Megamind finally threw Metro Man up into the sky. Metro Man was defeated and was never seen...
[{"input": "100000\n1\n50000\n49999", "output": "[2500050000]", "fn_name": "mega_mind"}, {"input": "100000\n100000\n100000\n100000", "output": "[1]", "fn_name": "mega_mind"}, {"input": "100000\n99999\n100000\n100000", "output": "[2]", "fn_name": "mega_mind"}, {"input": "100000\n1\n1000\n999", "output": "[99001000]", "f...
code_functional
[ { "content": "In some other world, today is Christmas Eve.\nThere are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \\leq i \\leq N) is h_i meters.\nHe decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of t...
[{"input": "3 2\n1\n500000000\n1000000000\n", "output": "499999999\n"}, {"input": "5 3\n10\n15\n11\n14\n12\n", "output": "2\n"}, {"input": "3 3\n10\n15\n33\n14\n12", "output": "23\n"}, {"input": "4 3\n10\n21\n21\n-1\n10", "output": "11\n"}, {"input": "4 3\n10\n21\n21\n-2\n10", "output": "11\n"}, {"input": "4 3\n10\n8\n...
code_stdio
[ { "content": "Write a program which computes the area of a shape represented by the following three lines:\n\n$y = x^2$\n$y = 0$\n$x = 600$\n\n\n\nIt is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by addi...
[{"input": "20\n100", "output": "68440000\n55000000\n"}, {"input": "20\n120", "output": "68440000\n51840000\n"}, {"input": "20\n150", "output": "68440000\n47250000\n"}, {"input": "20\n200", "output": "68440000\n40000000\n"}, {"input": "20\n010", "output": "68440000\n70210000\n"}, {"input": "20\n15", "output": "68440000...
code_stdio
[ { "content": "Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other one's existence.\n\nWhen Vasya has some free time, he goes to one of his girlfriends. He descends into ...
[{"input": "999999 1000000\n", "output": "Equal\n"}, {"input": "999997 1000000\n", "output": "Dasha\n"}, {"input": "1000000 999993\n", "output": "Masha\n"}, {"input": "999997 1000001\n", "output": "Dasha\n"}, {"input": "1000000 670055\n", "output": "Masha\n"}, {"input": "782250 1078229\n", "output": "Dasha\n"}, {"input...
code_stdio
[ { "content": "The screen that displays digital numbers that you often see on calculators is called a \"7-segment display\" because the digital numbers consist of seven parts (segments).\n\nThe new product to be launched by Wakamatsu will incorporate a 7-segment display into the product, and as an employee, you ...
[{"input": "3\n0\n5\n1\n1\n1\n-1", "output": "0111111\n1010010\n1101011\n0000110\n"}, {"input": "3\n0\n9\n1\n1\n0\n-1", "output": "0111111\n1010000\n1101001\n0111111\n"}, {"input": "3\n0\n5\n1\n1\n2\n-1", "output": "0111111\n1010010\n1101011\n1011011\n"}, {"input": "3\n1\n9\n1\n1\n0\n-1", "output": "0000110\n1101001\n1...
code_stdio
[ { "content": "Snuke has decided to play a game, where the player runs a railway company.\nThere are M+1 stations on Snuke Line, numbered 0 through M.\nA train on Snuke Line stops at station 0 and every d-th station thereafter, where d is a predetermined constant for each train.\nFor example, if d = 3, the train...
[{"input": "2 22\n1 9\n5 9\n4 5\n4 9\n0 1\n0 12\n2 4", "output": "2\n2\n2\n2\n2\n2\n2\n2\n2\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n"}, {"input": "2 18\n1 9\n5 9\n4 5\n4 9\n0 1\n0 12\n2 4", "output": "2\n2\n2\n2\n2\n2\n2\n2\n2\n0\n0\n0\n0\n0\n0\n0\n0\n0\n"}, {"input": "5 17\n1 2\n5 9\n5 7\n5 12\n1 1\n6 2\n3 4", "output...
code_stdio
[ { "content": "The new operating system BerOS has a nice feature. It is possible to use any number of characters '/' as a delimiter in path instead of one traditional '/'. For example, strings //usr///local//nginx/sbin// and /usr/local/nginx///sbin are equivalent. The character '/' (or some sequence of such char...
[{"input": "/zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\n", "output": "/zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\n"}, {"input": "/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/...
code_stdio
[ { "content": "Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does...
[{"input": "71 57\n9 26 80 10 65 60 63 1 15 85 71 1 58 27 41 97 42 15 42 56 87 22 10 28 34 90 13 70 71 56 65 21 0 78 47 191 56 77 32 83 28 16 10 41 0 18 92 12 27 58 4 67 21 41 99 20 21 52 74 10 83 45 43 65 2 15 1 63 46 97 72\n150\n21\n81\n81\n5\n9\n41\n76\n81\n92\n95\n94\n78\n93\n47\n30\n92\n3\n45\n81\n42\n88\n17\n3\n3...
code_stdio
[ { "content": "While working at DTL, Ela is very aware of her physical and mental health. She started to practice various sports, such as Archery, Yoga, and Football.\n\nSince she started engaging in sports activities, Ela switches to trying a new sport on days she considers being \"Luxury\" days. She counts the...
[{"input": "10\n84693792843120399 722933352461265626\n1054414613006002 919996041213106080\n141147461122848960 215953152568344802\n36758866361588362 220526816065597583\n135781915245644528 740842808859507601\n49755792151684097 147448792408078224\n101352931056782000 386376107245094465\n480981404419876442 57625018137531936...
code_stdio
[ { "content": "Our Chef is very happy that his son was selected for training in one of the finest culinary schools of the world.\nSo he and his wife decide to buy a gift for the kid as a token of appreciation.\nUnfortunately, the Chef hasn't been doing good business lately, and is in no mood on splurging money.\...
[{"input": "3 3\n13 1 11\n0 6 34\n5 10 11", "output": "GUESS\n"}, {"input": "3 3\n9 8 11\n0 6 34\n5 10 11", "output": "GUESS\n"}, {"input": "3 3\n9 1 11\n0 6 34\n5 10 11", "output": "GUESS\n"}, {"input": "3 3\n9 8 11\n0 8 34\n5 10 11", "output": "GUESS\n"}, {"input": "3 3\n18 1 15\n0 6 34\n5 10 9", "output": "GUESS\n"}...
code_stdio
[ { "content": "Consider a sequence of integers $a_1, a_2, \\ldots, a_n$. In one move, you can select any element of the sequence and delete it. After an element is deleted, all elements to the right are shifted to the left by $1$ position, so there are no empty spaces in the sequence. So after you make a move, t...
[{"input": "4\n7 6\n1 1 2 3 4 5 6\n5 2\n5 1 3 2 3\n5 2\n5 5 5 5 4\n8 4\n1 3 3 3 1 2 5 5\n", "output": "1\n2\n-1\n-1\n"}, {"input": "4\n7 6\n1 1 2 3 4 5 6\n5 2\n5 1 3 2 3\n5 2\n5 5 5 5 4\n8 4\n1 2 3 3 2 2 5 5\n", "output": "1\n2\n-1\n2\n"}, {"input": "4\n7 6\n1 1 2 3 4 5 6\n5 2\n5 1 3 2 3\n5 2\n5 5 5 5 4\n8 4\n1 2 3 3 1...
code_stdio
[ { "content": "We held two competitions: Coding Contest and Robot Maneuver.\n\nIn each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives a...
[{"input": "1 001", "output": "1000000\n"}, {"input": "10 001", "output": "300000\n"}, {"input": "11 001", "output": "300000\n"}, {"input": "3 001", "output": "400000\n"}, {"input": "5 001", "output": "300000\n"}, {"input": "1 011", "output": "300000\n"}, {"input": "1 010", "output": "300000\n"}, {"input": "3 111", "ou...
code_stdio
[ { "content": "We have an integer sequence A, whose length is N.\n\nFind the number of the non-empty contiguous subsequences of A whose sums are 0. Note that we are counting the ways to take out subsequences. That is, even if the contents of some two subsequences are the same, they are counted individually if th...
[{"input": "7\n-1 -4 0 -20 -1 0 0", "output": "4\n"}, {"input": "7\n0 -1 1 -1 1 -1 1", "output": "13\n"}, {"input": "7\n0 -1 0 -5 0 -1 -3", "output": "3\n"}, {"input": "7\n0 -1 0 -5 0 -2 -3", "output": "3\n"}, {"input": "7\n0 -1 0 -7 -1 0 -3", "output": "3\n"}, {"input": "7\n0 -1 0 -4 -1 0 -3", "output": "3\n"}, {"inpu...
code_stdio
[ { "content": "Little Petya very much likes playing with little Masha. Recently he has received a game called \"Zero-One\" as a gift from his mother. Petya immediately offered Masha to play the game with him.\n\nBefore the very beginning of the game several cards are lain out on a table in one line from the left...
[{"input": "1110110101111111001111111110111011100001110111011001011111111111011010011111?111111?011111110001010110011111010111100111?111101010011101010?011111101010111111111101111010111?1111111100110110001111101111100100110011101111011110111000111?011110?111110?1011010111101111101111010100111110101111011101110011101001...
code_stdio