messages
listlengths
1
1
ground_truth
stringlengths
88
726k
dataset
stringclasses
2 values
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Petya likes numbers a lot. He found that number 123 in base 16 consists of two digits: the first is 7 and the second is 11. So the sum of digits of 123 in base 16 is equal to 18.\n\nNow he wonders what is an averag...
[{"type": "stdin_stdout", "input": "1209\n", "output": "263450/1207\n"}, {"type": "stdin_stdout", "input": "1869\n", "output": "627063/1867\n"}, {"type": "stdin_stdout", "input": "1865\n", "output": "623876/1863\n"}, {"type": "stdin_stdout", "input": "1343\n", "output": "325366/1341\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n# Task\n\nJohn is a programmer. He treasures his time very much. He lives on the `n` floor of a building. Every morning he will go downstairs as quickly as possible to begin his great work today.\n\nThere are two ways he ...
[{"input": "5\n6\n[1, 2, 3, 10]", "output": "[12]", "fn_name": "shortest_time"}, {"input": "5\n5\n[1, 2, 3, 10]", "output": "[11]", "fn_name": "shortest_time"}, {"input": "2\n2\n[2, 3, 4, 10]", "output": "[10]", "fn_name": "shortest_time"}, {"input": "5\n4\n[1, 2, 3, 10]", "output": "[12]", "fn_name": "shortest_time"},...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnia has a large integer $S$. Its decimal representation has length $n$ and doesn't contain any leading zeroes. Ania is allowed to change at most $k$ digits of $S$. She wants to do it in such a way that $S$ still won't co...
[{"type": "stdin_stdout", "input": "400 224\n34034718296316650556302576767095880542740697596682657060609028712014739414658241556774411582749368771597248873201583574900424227251655547840887764275893533353440635216728376201808545879398359535670372855472971530695051695650262058940466340529417646357776899296790403916961389...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDifference of Big Integers\n\nGiven two integers $A$ and $B$, compute the difference, $A - B$.\n\nInput\n\nTwo integers $A$ and $B$ separated by a space character are given in a line.\n\nOutput\n\nPrint the difference in ...
[{"type": "stdin_stdout", "input": "-2 -1280", "output": "1278\n"}, {"type": "stdin_stdout", "input": "-2 -1243", "output": "1241\n"}, {"type": "stdin_stdout", "input": "-2 -2265", "output": "2263\n"}, {"type": "stdin_stdout", "input": "-1 -2265", "output": "2264\n"}, {"type": "stdin_stdout", "input": "-1 -2368", "outp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe weight of a sequence is defined as the number of unordered pairs of indexes $(i,j)$ (here $i \\lt j$) with same value ($a_{i} = a_{j}$). For example, the weight of sequence $a = [1, 1, 2, 2, 1]$ is $4$. The set of uno...
[{"type": "stdin_stdout", "input": "2\n4\n2 2 2 2\n4\n1 3 3 4\n", "output": "15\n4\n"}, {"type": "stdin_stdout", "input": "2\n4\n2 2 2 2\n4\n1 4 3 4\n", "output": "15\n2\n"}, {"type": "stdin_stdout", "input": "2\n4\n2 2 2 2\n4\n1 2 3 4\n", "output": "15\n0\n"}, {"type": "stdin_stdout", "input": "2\n4\n1 2 3 1\n4\n1 4 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a permutation P[1... N] of integers from 1 to N, function f is defined as follows:\n\n $f(i, j) = \\left\\{\\begin{array}{ll}{P [ i ]} & {\\text{if} j = 1} \\\\{f(P [ i ], j - 1)} & {\\text{otherwise}} \\end{array} \\...
[{"type": "stdin_stdout", "input": "10 7 5\n", "output": "2 3 4 5 1 7 8 9 10 6 "}, {"type": "stdin_stdout", "input": "10 7 5\n", "output": "2 3 4 5 1 7 8 9 10 6 "}, {"type": "stdin_stdout", "input": "9 2 5\n", "output": "2 1 4 3 6 7 8 9 5 "}, {"type": "stdin_stdout", "input": "9 7 9\n", "output": "2 3 4 5 6 7 8 9 1 "},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou'll be given a string, and have to return the total of all the unicode characters as an int. Should be able to handle any characters sent at it. \n\nexamples:\n\nuniTotal(\"a\") == 97\nuniTotal(\"aaa\") == 291\n\nWrite...
[{"input": "\"Mary Had A Little Lamb\"", "output": "[1873]", "fn_name": "uni_total"}, {"input": "\"Mary had a little lamb\"", "output": "[2001]", "fn_name": "uni_total"}, {"input": "\"And so does Strive\"", "output": "[1661]", "fn_name": "uni_total"}, {"input": "\"CodeWars rocks\"", "output": "[1370]", "fn_name": "uni_...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are two bus stops denoted A and B, and there n buses that go from A to B every day. The shortest path from A to B takes t units of time but some buses might take longer paths. Moreover, buses are allowed to overtake...
[{"type": "stdin_stdout", "input": "2 1000000000\n1 1000000000\n2 2\n", "output": "Yes\n 2000000000 2000000001"}, {"type": "stdin_stdout", "input": "2 10\n4 5\n2 2\n", "output": "Yes\n ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n##Task:\n\nYou have to write a function **pattern** which creates the following pattern upto n number of rows. \n\n* If the Argument is 0 or a Negative Integer then it should return \"\" i.e. empty string.\n\n* If any odd...
[{"input": "6", "output": "[\"22\\n4444\\n666666\"]", "fn_name": "pattern"}, {"input": "5", "output": "[\"22\\n4444\"]", "fn_name": "pattern"}, {"input": "2", "output": "[\"22\"]", "fn_name": "pattern"}, {"input": "-25", "output": "[\"\"]", "fn_name": "pattern"}, {"input": "1", "output": "[\"\"]", "fn_name": "pattern"}...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day, Taro received a strange email with only the number \"519345213244\" in the text. The email was from my cousin, who was 10 years older than me, so when I called and asked, \"Oh, I sent it with a pocket bell becaus...
[{"type": "stdin_stdout", "input": "341143514535\n158\n143565553551655311343411652235654535651124615163\n551544654451431564\n4\n3411\n6363636363\n153414", "output": "naruto\nNA\ndo you wanna go to aizu?\nyes sure!\nNA\nna\n?????\nend\n"}, {"type": "stdin_stdout", "input": "341143514535\n158\n143565553551655311343411652...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version.\n\nPolycarp is a very famous freelancer. His current rating is $r$...
[{"type": "stdin_stdout", "input": "50 15000\n142 -300\n20 -298\n560 -300\n1815 -292\n282 -297\n92 -293\n34 -284\n555 -299\n408 -293\n504 -284\n278 -284\n139 -291\n64 -298\n311 -293\n130 -293\n89 -298\n129 -294\n385 -295\n136 -288\n41 -293\n112 -290\n416 -295\n178 -294\n154 -300\n110 -300\n346 -299\n209 -294\n1394 -295...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n[3R2 as DJ Mashiro - Happiness Breeze](https://open.spotify.com/track/2qGqK8GRS65Wlf20qUBEak)\n\n[Ice - DJ Mashiro is dead or alive](https://soundcloud.com/iceloki/dj-mashiro-is-dead-or-alive)\n\nNEKO#ΦωΦ has just got a n...
[{"type": "stdin_stdout", "input": "10 83\n1 3\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n1 4\n2 2\n2 3\n2 3\n2 3\n2 3\n2 3\n2 3\n1 4\n1 5\n1 7\n2 2\n2 2\n1 5\n2 2\n1 3\n2 1\n2 6\n1 5\n2 6\n2 9\n1 2\n2 5\n1 2\n2 5\n2 4\n2 4\n1 2\n1 2\n1 4\n2 6\n2 6\n2 4\n2 4\n1 2\n1 2\n2 4\n2 4\n2 3\n2 3\n1 2\n2 9\n1 2\n1 2\n1 2\n2 6\n2 6\n2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nComplete the function that takes 3 numbers `x, y and k` (where `x ≤ y`), and returns the number of integers within the range `[x..y]` (both ends included) that are divisible by `k`.\n\nMore scientifically: `{ i : x ≤ i ≤...
[{"input": "1005\n9999999999999999999999999999999999999999999\n109", "output": "[91743119266055045871559633027522935779807]", "fn_name": "divisible_count"}, {"input": "101\n9999999999999999999999999999999999999999999\n11", "output": "[909090909090909090909090909090909090909081]", "fn_name": "divisible_count"}, {"input"...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nA newspaper is published in Walrusland. Its heading is s1, it consists of lowercase Latin letters. Fangy the little walrus wants to buy several such newspapers, cut out their headings, glue them one to another in order to...
[{"type": "stdin_stdout", "input": "ehfjaabjfedhddejjfcfijagefhkeahjcddhchahjbagi\nfbfdjbjhibjgjgaaajgdbcfdbhjcajcbbieijhcjgajhgaa\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "ehfjaabjfedhddejjfcfijagefhkeahjcddhchahjbagi\naaghjagjchjieibbcjacjhbdfcbdgjaaagjgjbihjbjdfbf\n", "output": "10\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKsenia has ordinary pan scales and several weights of an equal mass. Ksenia has already put some weights on the scales, while other weights are untouched. Ksenia is now wondering whether it is possible to put all the rema...
[{"type": "stdin_stdout", "input": "CKQHRUZMISGE|FBVWPXDLTJYN\nOA\n", "output": "CKQHRUZMISGEA|FBVWPXDLTJYNO\n"}, {"type": "stdin_stdout", "input": "V|CMOEUTAXBFWSK\nDLRZJGIYNQHP\n", "output": "VDLRZJGIYNQHP|CMOEUTAXBFWSK\n"}, {"type": "stdin_stdout", "input": "QWHNMALDGKTJ|\nPBRYVXZUESCOIF\n", "output": "QWHNMALDGKTJF...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. [Image] \n\nInitially, each hole has $a_i$ stones. When a player makes a move, he chooses a hole which contains a positive n...
[{"type": "stdin_stdout", "input": "297857621 238127103 749085829 139033277 597985489 202617713 1366784327 117968155 278551059 297781685 330124279 338959601 682874531 259895291\n", "output": "5305874892\n"}, {"type": "stdin_stdout", "input": "404418821 993626161 346204297 122439813 461187221 628048227 625919459 6286117...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRoman and Denis are on the trip to the programming competition. Since the trip was long, they soon got bored, and hence decided to came up with something. Roman invented a pizza's recipe, while Denis invented a string mul...
[{"type": "stdin_stdout", "input": "4\nqe\nnd\niqryhukieskfvaeettersinksrmazelxtgvartuz\nvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSeveral ages ago Berland was a kingdom. The King of Berland adored math. That's why, when he first visited one of his many palaces, he first of all paid attention to the floor in one hall. The floor was tiled with hexagon...
[{"type": "stdin_stdout", "input": "1000 1100 1000\n", "output": "3196901\n"}, {"type": "stdin_stdout", "input": "1000 0100 1000\n", "output": "1197901\n"}, {"type": "stdin_stdout", "input": "1000 1000 1000\n", "output": "2997001"}, {"type": "stdin_stdout", "input": "998 999 1001\n", "output": "2993002\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n$n$ people gathered to hold a jury meeting of the upcoming competition, the $i$-th member of the jury came up with $a_i$ tasks, which they want to share with each other.\n\nFirst, the jury decides on the order which they ...
[{"type": "stdin_stdout", "input": "1\n74\n15 4 1 8 1 4 -1 5 9 1 6 3 1 16 2 1 3 6 7 4 1 6 8 9 21 4 0 6 6 4 22 1 8 7 0 1 6 6 4 1 8 9 16 4 10 5 9 2 20 10 0 5 3 8 1 7 7 0 2 10 2 4 8 4 6 9 2 4 9 8 1 11 3 0\n", "output": "210389544\n"}, {"type": "stdin_stdout", "input": "1\n74\n15 4 1 8 1 4 0 5 9 1 6 3 1 16 2 1 3 6 7 4 1 6 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are a paparazzi working in Manhattan.\n\nManhattan has r south-to-north streets, denoted by numbers 1, 2,…, r in order from west to east, and r west-to-east streets, denoted by numbers 1,2,…,r in order from south to n...
[{"type": "stdin_stdout", "input": "500 10\n69 477 122\n73 186 235\n341 101 145\n372 77 497\n404 117 440\n494 471 37\n522 300 498\n682 149 379\n821 486 359\n855 157 386\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "500 10\n69 477 111\n73 186 235\n341 101 145\n372 77 497\n404 117 440\n494 471 37\n522 300 498\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven a permutation $p$ of length $n$, find its subsequence $s_1$, $s_2$, $\\ldots$, $s_k$ of length at least $2$ such that: $|s_1-s_2|+|s_2-s_3|+\\ldots+|s_{k-1}-s_k|$ is as big as possible over all subsequences of $p$ ...
[{"type": "stdin_stdout", "input": "2\n3\n3 4 1\n4\n1 12 4 6\n", "output": "3\n3 4 1\n4\n1 12 4 6\n"}, {"type": "stdin_stdout", "input": "2\n3\n3 4 1\n4\n1 12 3 6\n", "output": "3\n3 4 1\n4\n1 12 3 6\n"}, {"type": "stdin_stdout", "input": "2\n3\n5 14 1\n4\n1 5 16 2\n", "output": "3\n5 14 1\n3\n1 16 2\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have N sticks with negligible thickness.\nThe length of the i-th stick is A_i.\nSnuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides.\nF...
[{"type": "stdin_stdout", "input": "10\n1 1 2 -3 2 8 1 218 -1 8", "output": "16\n"}, {"type": "stdin_stdout", "input": "10\n0 1 0 -2 4 34 1 34 0 4", "output": "136\n"}, {"type": "stdin_stdout", "input": "10\n-1 2 12 15 3 1 0 18 1 1", "output": "0\n"}, {"type": "stdin_stdout", "input": "10\n-2 2 12 1 4 2 1 41 -1 1", "ou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider the following series:\n\n`1, 2, 4, 8, 16, 22, 26, 38, 62, 74, 102, 104, 108, 116, 122`\n\nIt is generated as follows:\n\n* For single digit integers, add the number to itself to get the next element.\n* For other...
[{"input": "5000", "output": "[283]", "fn_name": "convergence"}, {"input": "500", "output": "[29]", "fn_name": "convergence"}, {"input": "10", "output": "[5]", "fn_name": "convergence"}, {"input": "15", "output": "[2]", "fn_name": "convergence"}, {"input": "3", "output": "[5]", "fn_name": "convergence"}, {"input": "5",...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou take your son to the forest to see the monkeys. You know that there are a certain number there (n), but your son is too young to just appreciate the full number, he has to start counting them from 1.\n\nAs a good pare...
[{"input": "20", "output": "[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]", "fn_name": "monkey_count"}, {"input": "10", "output": "[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]", "fn_name": "monkey_count"}, {"input": "9", "output": "[[1, 2, 3, 4, 5, 6, 7, 8, 9]]", "fn_name": "monkey_count"}, {"input": "...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nGalois is one of the strongest chess players of Byteforces. He has even invented a new variant of chess, which he named «PawnChess».\n\nThis new game is played on a board consisting of 8 rows and 8 columns. At the beginni...
[{"type": "stdin_stdout", "input": "........\n........\n.B....B.\n....W...\n........\n..W.....\n........\n........\n", "output": "A\n"}, {"type": "stdin_stdout", "input": "..B.....\n..W.....\n......B.\n........\n.....W..\n......B.\n........\n........\n", "output": "B\n"}, {"type": "stdin_stdout", "input": ".BB.B.B.\nB....
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a program which finds a pattern $p$ in a ring shaped text $s$.\n\n\n<image>\n\nConstraints\n\n* $1 \\leq $ length of $p \\leq $ length of $s \\leq 100$\n* $s$ and $p$ consists of lower-case letters\n\nInput\n\nIn th...
[{"type": "stdin_stdout", "input": "vanceknowledgetoad\nbdvanced", "output": "No\n"}, {"type": "stdin_stdout", "input": "vanceknowledgetoad\ncdvanced", "output": "No\n"}, {"type": "stdin_stdout", "input": "vanceknowmedgetoad\ncdvanced", "output": "No\n"}, {"type": "stdin_stdout", "input": "vbnceknowmedgetoad\ncdvanced"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet $f(i)$ denote the minimum positive integer $x$ such that $x$ is not a divisor of $i$.\n\nCompute $\\sum_{i=1}^n f(i)$ modulo $10^9+7$. In other words, compute $f(1)+f(2)+\\dots+f(n)$ modulo $10^9+7$.\n\n\n-----Input--...
[{"type": "stdin_stdout", "input": "6\n1\n4\n3\n4\n10\n10000000000000000\n", "output": "2\n10\n7\n10\n26\n366580019\n"}, {"type": "stdin_stdout", "input": "6\n1\n2\n3\n4\n10\n10000000000000000\n", "output": "2\n5\n7\n10\n26\n366580019\n"}, {"type": "stdin_stdout", "input": "6\n1\n2\n3\n4\n10\n10000000000000000\n", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Third Doctor Who once correctly said that travel between parallel universes is \"like travelling sideways\". However, he incorrectly thought that there were infinite parallel universes, whereas in fact, as we now all ...
[{"type": "stdin_stdout", "input": "18 16 20 4\n0 0\n0 1\n1 7\n1 7\n", "output": "18 16\n17 15\n18 16\n19 17\n"}, {"type": "stdin_stdout", "input": "18 16 20 4\n0 0\n0 1\n1 7\n1 6\n", "output": "18 16\n17 15\n18 16\n19 17\n"}, {"type": "stdin_stdout", "input": "18 8 20 4\n1 1\n0 1\n1 7\n1 7\n", "output": "19 9\n18 8\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNotes\n\nTemplate in C\n\nConstraints\n\n2 ≤ the number of operands in the expression ≤ 100\n1 ≤ the number of operators in the expression ≤ 99\n-1 × 109 ≤ values in the stack ≤ 109\n\nInput\n\nAn expression is given in a...
[{"type": "stdin_stdout", "input": "1 1 + 5 11 - *", "output": "-12\n"}, {"type": "stdin_stdout", "input": "0 0 + 6 21 - +", "output": "-15\n"}, {"type": "stdin_stdout", "input": "1 12 + 3 8 - *", "output": "-65\n"}, {"type": "stdin_stdout", "input": "1 0 + 6 21 - +", "output": "-14\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSanta Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects that each key is either on it...
[{"type": "stdin_stdout", "input": "dofbgdppdvmwjwtdyphhmqliydxyjfxoopxiscevowleccmhwybrxitvujkfliamvqinlrpytyaqdlbywccprukoisyaseibuqbfqjcabkieimsggsakpnqliwhehnemewhychqrfiuyaecoydnromrh\ndofbgdppdvmwjwtdyphhmqliydxyjfxoopxiscevowleccmhwybsxitvujkfliamvqinlrpytyaqdlbywccprukoisyaseibuqbfqjcabkieimsggsakpnqliwhehnemew...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya works as a PR manager for a successful Berland company BerSoft. He needs to prepare a presentation on the company income growth since 2001 (the year of its founding) till now. Petya knows that in 2001 the company in...
[{"type": "stdin_stdout", "input": "100\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 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem Statement\n\nMr. Takatsuki, who is planning to participate in the Aizu training camp, is enthusiastic about studying and has been studying English recently. She tries to learn as many English words as possible by ...
[{"type": "stdin_stdout", "input": "6\nZI?U -1\nLINFR 14\nKNGE -1\nLCL -1\n@S 2\nKFHD 15\nBSKA\nILIC\nPZRH\nEDLU\n1", "output": "0\n"}, {"type": "stdin_stdout", "input": "6\n[I?U -1\nLINFR 14\nKNGE -1\nLCL -1\n@S 2\nKFHD 15\nBSKA\nILIC\nPZRH\nEDLU\n1", "output": "0\n"}, {"type": "stdin_stdout", "input": "6\n[I?U -1\nRF...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a robot that can move along a number line. At time moment $0$ it stands at point $0$.\n\nYou give $n$ commands to the robot: at time $t_i$ seconds you command the robot to go to point $x_i$. Whenever the robot re...
[{"type": "stdin_stdout", "input": "8\n3\n1 5\n3 0\n6 4\n3\n1 5\n2 4\n10 -5\n5\n2 -5\n3 1\n4 1\n5 1\n6 1\n4\n3 3\n5 -3\n9 2\n12 0\n8\n1 1\n2 -6\n7 2\n8 3\n12 -9\n14 2\n18 -1\n23 9\n5\n1 -4\n4 -7\n6 -1\n7 -3\n8 -7\n2\n1 2\n2 -2\n6\n3 10\n5 5\n8 0\n12 -4\n14 -7\n19 -5\n", "output": "\n1\n2\n0\n2\n1\n1\n0\n2\n"}, {"type":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nArkadiy has lots square photos with size a × a. He wants to put some of them on a rectangular wall with size h × w. \n\nThe photos which Arkadiy will put on the wall must form a rectangular grid and the distances between ...
[{"type": "stdin_stdout", "input": "452081307 790635695 790635695\n", "output": "169277194.00000000000000000000\n"}, {"type": "stdin_stdout", "input": "469568633 681052815 681052815\n", "output": "105742091.00000000000000000000\n"}, {"type": "stdin_stdout", "input": "338084774 564168943 564168943\n", "output": "1130420...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMisha was interested in water delivery from childhood. That's why his mother sent him to the annual Innovative Olympiad in Irrigation (IOI). Pupils from all Berland compete there demonstrating their skills in watering. It...
[{"type": "stdin_stdout", "input": "100 74 20\n9 15 16 18 55 41 64 44 5 1 27 31 36 25 71 28 71 35 47 40 21 53 31 11 24 1 69 67 58 16 19 52 33 17 63 1 49 28 17 52 46 60 53 21 21 60 19 63 11 61 10 27 3 22 38 31 45 69 61 18 58 22 8 71 17 1 64 70 56 10 66 47 70 1 45 8 66 8 66 25 39 45 47 7 41 24 41 72 16 42 28 7 15 10 38 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence $a=[a_1,a_2,\\dots,a_n]$ consisting of $n$ positive integers.\n\nLet's call a group of consecutive elements a segment. Each segment is characterized by two indices: the index of its left end and t...
[{"type": "stdin_stdout", "input": "4\n6\n55 45 30 30 40 100\n4\n10 23 7 13\n5\n10 55 35 30 65\n6\n4 1 1 1 1 4\n", "output": "3\n4\n2\n3\n"}, {"type": "stdin_stdout", "input": "5\n4\n18 6 6 6\n5\n5 5 5 5 5\n3\n12 6 6\n2\n1 1\n1\n1\n", "output": "3\n1\n2\n1\n1\n"}, {"type": "stdin_stdout", "input": "4\n3\n6 6 12\n4\n18 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n - the dogs numbere...
[{"type": "stdin_stdout", "input": "1000000000000001\n", "output": "gbdpxgrzxjm\n"}, {"type": "stdin_stdout", "input": "530000050000000\n", "output": "csoypdctwnh\n"}, {"type": "stdin_stdout", "input": "95678123450002\n", "output": "qpdjiixlxb\n"}, {"type": "stdin_stdout", "input": "1000000000\n", "output": "cfdgsxl\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMove every letter in the provided string forward 10 letters through the alphabet.\n\nIf it goes past 'z', start again at 'a'.\n\nInput will be a string with length > 0.\n\nWrite your solution by modifying this code:\n\n``...
[{"input": "\"returnofthespacecamel\"", "output": "[\"bodebxypdroczkmomkwov\"]", "fn_name": "move_ten"}, {"input": "\"bringonthebootcamp\"", "output": "[\"lbsxqyxdrolyydmkwz\"]", "fn_name": "move_ten"}, {"input": "\"weneedanofficedog\"", "output": "[\"goxoonkxyppsmonyq\"]", "fn_name": "move_ten"}, {"input": "\"examplet...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Bolek has found a picture with n mountain peaks painted on it. The n painted peaks are represented by a non-closed polyline, consisting of 2n segments. The segments go through 2n + 1 points with coordinates (1, y1)...
[{"type": "stdin_stdout", "input": "100 20\n2 3 0 4 0 1 0 6 3 4 3 6 4 6 0 9 0 6 2 7 3 8 7 10 2 9 3 9 5 6 5 10 3 7 1 5 2 8 3 7 2 3 1 6 0 8 3 8 0 4 1 8 3 7 1 9 5 9 5 8 7 8 5 6 5 8 1 9 8 9 8 10 7 10 5 8 6 10 2 6 3 9 2 6 3 10 5 9 3 10 1 3 2 11 8 9 8 10 1 8 7 11 0 9 5 8 4 5 0 7 3 7 5 9 5 10 1 7 1 9 1 6 3 8 2 4 1 4 2 6 0 4 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n## Task:\nYou have to write a function `pattern` which returns the following Pattern(See Pattern & Examples) upto `n` number of rows. \n\n* Note:`Returning` the pattern is not the same as `Printing` the pattern.\n\n#### R...
[{"input": "5", "output": "[\"1\\n22\\n333\\n4444\\n55555\"]", "fn_name": "pattern"}, {"input": "2", "output": "[\"1\\n22\"]", "fn_name": "pattern"}, {"input": "-25", "output": "[\"\"]", "fn_name": "pattern"}, {"input": "1", "output": "[\"1\"]", "fn_name": "pattern"}, {"input": "0", "output": "[\"\"]", "fn_name": "patt...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs it's the first of April, Heidi is suspecting that the news she reads today are fake, and she does not want to look silly in front of all the contestants. She knows that a newspiece is fake if it contains heidi as a sub...
[{"type": "stdin_stdout", "input": "sjvmovplbrnakthytvanvvbscgdcdkdkbgginnbiyczyrkywcuvbgolznifdyiilonvqblbywxzgjnntldeuhhlecubshirsdxugezholvufotprjovwqiitypvaghlcxlrajrtufmysbpegjfvdboewogamnunalynjvwiopqfhndupfqxfatbpklpzdsdmzwvtitvdxkefremodmlferuxyisxmvjydjthekokldjkwoiffmhlquulcbogdnnzqaisoxqpgztuzvbleiitrqbzljbb...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn your garden, there is a long and narrow flowerbed that stretches infinitely to the east. You have decided to plant N kinds of flowers in this empty flowerbed. For convenience, we will call these N kinds of flowers Flow...
[{"type": "stdin_stdout", "input": "1 1000000000\n1000000000000000000 1000000000", "output": "1999999999000000000"}, {"type": "stdin_stdout", "input": "3 17\n22 15\n10 10\n17 10", "output": "70\n"}, {"type": "stdin_stdout", "input": "3 17\n22 19\n10 10\n17 10", "output": "77\n"}, {"type": "stdin_stdout", "input": "3 27...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nC --Misawa's rooted tree\n\nProblem Statement\n\nYou noticed that your best friend Misawa's birthday was near, and decided to give him a rooted binary tree as a gift. Here, the rooted binary tree has the following graph s...
[{"type": "stdin_stdout", "input": "((()[1]())[2]())[5](((()[2]())[6](()[3]()))[8]()(\n(()[4]())[3](((()[2]())[1]())[8](()[4]')))", "output": "(()[6]())[8](((()[4]())[7]())[16]())\n"}, {"type": "stdin_stdout", "input": "((()[8]())[2]())[5](((()[3]())[6](()[3]()))[2]())\n(()[4]())[2](((()[2]())[1]())[8](()[3]())(", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe fundamental idea in the JPEG compression algorithm is to sort coeffi- cient of given image by zigzag path and encode it. In this problem, we don’t discuss about details of the algorithm, but you are asked to make simp...
[{"type": "stdin_stdout", "input": "3\n9\n0", "output": "Case 1:\n 1 2 6\n 3 5 7\n 4 8 9\nCase 2:\n 1 2 6 7 15 16 28 29 45\n 3 5 8 14 17 27 30 44 46\n 4 9 13 18 26 31 43 47 60\n 10 12 19 25 32 42 48 59 61\n 11 20 24 33 41 49 58 62 71\n 21 23 34 40 50 57 63 70 72\n 22 35 39 51 56 64 69 73 78\n 36 38 52...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe bear decided to store some raspberry for the winter. He cunningly found out the price for a barrel of honey in kilos of raspberry for each of the following n days. According to the bear's data, on the i-th (1 ≤ i ≤ n)...
[{"type": "stdin_stdout", "input": "100 9\n66 71 37 41 23 38 77 11 74 13 51 26 93 56 81 17 12 70 85 37 54 100 14 99 12 83 44 16 99 65 13 48 92 32 69 33 100 57 58 88 25 45 44 85 5 41 82 15 37 18 21 45 3 68 33 9 52 64 8 73 32 41 87 99 26 26 47 24 79 93 9 44 11 34 85 26 14 61 49 38 25 65 49 81 29 82 28 23 2 64 38 13 77 68...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn this kata you will have to modify a sentence so it meets the following rules:\n\nconvert every word backwards that is:\n\n longer than 6 characters\n\n OR\n\n has 2 or more 'T' or 't' in it\n\nconvert every word...
[{"input": "\"As Grainier drove along in the wagon behind a wide, slow, sand-colored mare, clusters of orange butterflies exploded off the purple blackish piles of bear sign and winked and winked and fluttered magically like leaves without trees.\"", "output": "[\"AS reiniarG drove along IN the wagon behind 0 WIDE, SLO...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a r × c grid. Each cell on the grid represents a country. Each country has a dominant...
[{"type": "stdin_stdout", "input": "4\n7 8\nAAPAAAAA\nAAAAPPPP\nPPPPAAAA\nAPAAPPPP\nAPAPPAPP\nAAAAPPAP\nAAAAPPAA\n6 5\nAAAAA\nAAAAA\nAAPAA\nAAPAP\nAAAPP\nAAAPP\n4 4\nPPPP\nPPPP\nPPPP\nPPPP\n3 4\nPPPP\nPAAP\nPPPP\n", "output": "2\n1\nMORTAL\n4\n"}, {"type": "stdin_stdout", "input": "4\n7 8\nAAPABAAA\nPPPPAAAA\nPPPPAAAA\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe number 105 is quite special - it is odd but still it has eight divisors.\nNow, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?\n\n-----Constraints---...
[{"type": "stdin_stdout", "input": "105\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "104\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "134\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "135\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "164\n", "output": "2\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a positive integer N. Find the number of the pairs of integers u and v (0≦u,v≦N) such that there exist two non-negative integers a and b satisfying a xor b=u and a+b=v. Here, xor denotes the bitwise exclusiv...
[{"type": "stdin_stdout", "input": "1000000001000000000", "output": "999867657\n"}, {"type": "stdin_stdout", "input": "1100000001000000000", "output": "355035671\n"}, {"type": "stdin_stdout", "input": "1100000001000010000", "output": "391646023\n"}, {"type": "stdin_stdout", "input": "1100000001001010000", "output": "10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $a_1, a_2, \\dots , a_n$ consisting of integers from $0$ to $9$. A subarray $a_l, a_{l+1}, a_{l+2}, \\dots , a_{r-1}, a_r$ is good if the sum of elements of this subarray is equal to the length of t...
[{"type": "stdin_stdout", "input": "11\n1\n0\n1\n1\n1\n2\n1\n3\n1\n4\n1\n5\n1\n6\n1\n7\n1\n8\n1\n9\n26\n11140000000090000000002111\n", "output": "0\n1\n0\n0\n0\n0\n0\n0\n0\n0\n37\n"}, {"type": "stdin_stdout", "input": "11\n1\n0\n1\n1\n1\n2\n1\n3\n1\n4\n1\n5\n1\n6\n1\n7\n1\n8\n1\n9\n26\n11140000000090000000002111\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOnce again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn't stop doing that. That's why Keione told his smart friend, SaDDas to punish him! SaDDas took Tavas' headphones a...
[{"type": "stdin_stdout", "input": "777777777\n", "output": "1022\n"}, {"type": "stdin_stdout", "input": "444444444\n", "output": "511\n"}, {"type": "stdin_stdout", "input": "477477447\n", "output": "728\n"}, {"type": "stdin_stdout", "input": "777744747\n", "output": "996\n"}, {"type": "stdin_stdout", "input": "7777777...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n*This kata is based on [Project Euler Problem #349](https://projecteuler.net/problem=349). You may want to start with solving [this kata](https://www.codewars.com/kata/langtons-ant) first.*\n\n---\n\n[Langton's ant](https...
[{"input": "10000000", "output": "[1153412]", "fn_name": "langtons_ant"}, {"input": "1000000", "output": "[114952]", "fn_name": "langtons_ant"}, {"input": "100000", "output": "[11108]", "fn_name": "langtons_ant"}, {"input": "10000", "output": "[720]", "fn_name": "langtons_ant"}, {"input": "1000", "output": "[118]", "fn...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string $s$, consisting of $n$ letters, each letter is either 'a' or 'b'. The letters in the string are numbered from $1$ to $n$.\n\n$s[l; r]$ is a continuous substring of letters from index $l$ to $r$ of t...
[{"type": "stdin_stdout", "input": "4\n1\na\n6\nabbaba\n6\nabbaba\n9\nbabbabbaa\n", "output": "-1 -1\n1 2\n1 2\n1 2\n"}, {"type": "stdin_stdout", "input": "4\n1\na\n6\nabbaba\n6\nabbaba\n9\nbabbabbaa\n", "output": "-1 -1\n1 2\n1 2\n1 2\n"}, {"type": "stdin_stdout", "input": "4\n1\na\n6\nabbaba\n6\nabbaba\n7\nbabbabbaa\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWabbit is trying to move a box containing food for the rest of the zoo in the coordinate plane from the point $(x_1,y_1)$ to the point $(x_2,y_2)$.\n\nHe has a rope, which he can use to pull the box. He can only pull the ...
[{"type": "stdin_stdout", "input": "5\n1 0 1000000000 1000000000\n1 1 1000000000 1000001100\n1 0 1001000000 1000000000\n1 1 1100010011 1001000000\n2 1 108856 18413\n", "output": "2000000001\n2000001100\n2001000001\n2101010011\n127268\n"}, {"type": "stdin_stdout", "input": "5\n1 0 1000000000 1000000000\n1 1 1001000000 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a permutation: an array $a = [a_1, a_2, \\ldots, a_n]$ of distinct integers from $1$ to $n$. The length of the permutation $n$ is odd.\n\nConsider the following algorithm of sorting the permutation in increasing ...
[{"type": "stdin_stdout", "input": "3\n3\n3 2 1\n7\n4 5 7 1 3 2 6\n5\n1 2 3 4 5\n", "output": "3\n5\n0\n"}, {"type": "stdin_stdout", "input": "3\n3\n3 2 1\n7\n4 5 7 1 3 2 6\n5\n1 3 2 4 5\n", "output": "3\n5\n2\n"}, {"type": "stdin_stdout", "input": "3\n3\n2 3 1\n7\n4 5 7 1 3 2 6\n5\n1 2 3 4 5\n", "output": "3\n5\n0\n"}...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJAG-channel\n\nNathan O. Davis operates an electronic bulletin board called JAG-channel. He is currently working on adding a new feature called Thread View.\n\nLike many other electronic bulletin boards, JAG-channel is th...
[{"type": "stdin_stdout", "input": "6\nhoge\n.fuga\n..foobar\n..jagjag\n...zigzag\n.piyo\n8\njagjag\n.hogehoge\n..fugafuga\n...ponyoponyo\n....evaeva\n....pokemon\n...nowawa\n.buhihi\n8\nhello\n.goodmorning\n..howareyou\n.goodafternoon\n..letshavealunch\n.goodevening\n.goodnight\n..gotobed\n3\ncaution\n.themessagelengt...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:\n\nGiven two binary numbers $a$ and $b$ of length $n$. How many different ways of swapping two digits in $a$ (on...
[{"type": "stdin_stdout", "input": "30\n011110110100010000011001000100\n110111101001011001100001101101\n", "output": "146\n"}, {"type": "stdin_stdout", "input": "30\n011110110100010000011001000100\n110111101001011001100001101101\n", "output": "146\n"}, {"type": "stdin_stdout", "input": "30\n0111101101000100000110010001...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIvan wants to make a necklace as a present to his beloved girl. A necklace is a cyclic sequence of beads of different colors. Ivan says that necklace is beautiful relative to the cut point between two adjacent beads, if t...
[{"type": "stdin_stdout", "input": "3\n33332 19151 47433\n", "output": "0\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day Dima and Alex had an argument about the price and quality of laptops. Dima thinks that the more expensive a laptop is, the better it is. Alex disagrees. Alex thinks that there are two laptops, such that the price ...
[{"type": "stdin_stdout", "input": "4\n4 2\n6 1\n2 6\n-2 11\n", "output": "Happy Alex\n"}, {"type": "stdin_stdout", "input": "4\n4 1\n6 2\n2 5\n-1 4\n", "output": "Happy Alex\n"}, {"type": "stdin_stdout", "input": "4\n4 1\n6 2\n2 5\n-2 4\n", "output": "Happy Alex\n"}, {"type": "stdin_stdout", "input": "4\n4 1\n6 2\n2 9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe new PIN is hard to remember. I was told that I shouldn't take notes, but I don't think I can remember them. Therefore, I decided to embed a numerical value in the text and make a note of the PIN. Here, the sum of all ...
[{"type": "stdin_stdout", "input": "Thereare100yenonthetable.Iam17yearsold.\n.mp6taemohogdluohsI", "output": "123\n"}, {"type": "stdin_stdout", "input": "Thergarn100yeeontgesable-Iam17ye`rsolc.\nIshptkogdhomemt5q`.", "output": "122\n"}, {"type": "stdin_stdout", "input": "Thereare100yenonthetable.Iam17ye`rsold.\n.mp6tae...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAn array is called beautiful if all the elements in the array are equal.\n\nYou can transform an array using the following steps any number of times: \n\n 1. Choose two indices i and j (1 ≤ i,j ≤ n), and an integer x (1 ...
[{"type": "stdin_stdout", "input": "5\n0 11 12 13 14\n", "output": "\n120"}, {"type": "stdin_stdout", "input": "5\n0 12 1 13 14\n", "output": "24\n"}, {"type": "stdin_stdout", "input": "5\n1 3 0 13 48\n", "output": "120\n"}, {"type": "stdin_stdout", "input": "5\n1 18 2 13 26\n", "output": "24\n"}, {"type": "stdin_stdou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nComplete the method which returns the number which is most frequent in the given input array. If there is a tie for most frequent number, return the largest number among them.\n\nNote: no empty arrays will be given.\n\n\n...
[{"input": "[12, 10, 8, 8, 3, 3, 3, 3, 2, 4, 10, 12, 10]", "output": "[3]", "fn_name": "highest_rank"}, {"input": "[12, 10, 8, 12, 7, 6, 4, 10, 12, 10]", "output": "[12]", "fn_name": "highest_rank"}, {"input": "[12, 10, 8, 12, 7, 6, 4, 10, 12]", "output": "[12]", "fn_name": "highest_rank"}, {"input": "[12, 10, 8, 12, 7...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nAccording to rules of the Berland fashion, a jacket should be fastened by all the buttons except only one, but not necessarily it should be the last one. Also if the jacket has only one button, it should be fastened, so t...
[{"type": "stdin_stdout", "input": "231\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a sequence $a$ with $n$ elements $1, 2, 3, \\dots, k - 1, k, k - 1, k - 2, \\dots, k - (n - k)$ ($k \\le n < 2k$).\n\nLet's call as inversion in $a$ a pair of indices $i < j$ such that $a[i] > a[j]$.\n\nSuppose, ...
[{"type": "stdin_stdout", "input": "4\n1 1\n3 3\n5 5\n5 5\n", "output": "1\n1 2 3\n1 2 3 4 5\n1 2 3 4 5\n"}, {"type": "stdin_stdout", "input": "4\n1 1\n2 2\n5 5\n5 5\n", "output": "1\n1 2\n1 2 3 4 5\n1 2 3 4 5\n"}, {"type": "stdin_stdout", "input": "4\n1 1\n3 2\n5 5\n5 5\n", "output": "1\n2 1\n1 2 3 4 5\n1 2 3 4 5\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke is interested in strings that satisfy the following conditions:\n\n* The length of the string is at least N.\n* The first N characters equal to the string s.\n* The last N characters equal to the string t.\n\n\n\nFi...
[{"type": "stdin_stdout", "input": "4\nexpr\nexpq", "output": "8\n"}, {"type": "stdin_stdout", "input": "4\nexpr\nrxep", "output": "7\n"}, {"type": "stdin_stdout", "input": "4\nexpr\nepxq", "output": "8\n"}, {"type": "stdin_stdout", "input": "4\nexpr\npexq", "output": "8\n"}, {"type": "stdin_stdout", "input": "4\nexpr\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are two sisters Alice and Betty. You have $n$ candies. You want to distribute these $n$ candies between two sisters in such a way that: Alice will get $a$ ($a > 0$) candies; Betty will get $b$ ($b > 0$) candies; ...
[{"type": "stdin_stdout", "input": "98\n710\n896\n635\n909\n528\n799\n184\n970\n731\n285\n481\n62\n829\n815\n204\n927\n48\n958\n858\n549\n722\n900\n290\n96\n414\n323\n488\n140\n494\n286\n783\n551\n896\n580\n722\n766\n841\n914\n200\n170\n384\n664\n14\n203\n582\n203\n678\n502\n677\n318\n189\n144\n97\n330\n169\n20\n492\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two sorted arrays that contain only integers. Your task is to find a way to merge them into a single one, sorted in **ascending order**. Complete the function `mergeArrays(arr1, arr2)`, where `arr1` and `arr...
[{"input": "[-8, -3, -2, 4, 5, 6, 7, 15, 42, 90, 134]\n[216, 102, 74, 32, 8, 2, 0, -9, -13]", "output": "[[-13, -9, -8, -3, -2, 0, 2, 4, 5, 6, 7, 8, 15, 32, 42, 74, 90, 102, 134, 216]]", "fn_name": "merge_arrays"}, {"input": "[18, 7, 2, 0, -22, -46, -103, -293]\n[-300, -293, -46, -31, -5, 0, 18, 19, 74, 231]", "output"...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nMayor of city S just hates trees and lawns. They take so much space and there could be a road on the place they occupy!\n\nThe Mayor thinks that one of the main city streets could be considerably widened on account of law...
[{"type": "stdin_stdout", "input": "10\n21005 10850\n27020 13372\n28183 3724\n22874 13564\n27446 11493\n22522 10012\n24819 11529\n24166 11084\n24539 9211\n24152 9235\n", "output": "71869\n31855 31856 31857 31858 31859 31860 31861 31862 31863 31864 \n"}, {"type": "stdin_stdout", "input": "10\n21005 10850\n27020 13372\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies.\nYou will take out the candies from some consecutive boxes and distribute them evenly to M children.\nSuch being the...
[{"type": "stdin_stdout", "input": "43535 7\n5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn his publication Liber Abaci Leonardo Bonacci, aka Fibonacci, posed a problem involving a population of idealized rabbits. These rabbits bred at a fixed rate, matured over the course of one month, had unlimited resource...
[{"input": "100\n3", "output": "[465790837923166086127602033842234887]", "fn_name": "fib_rabbits"}, {"input": "40\n6", "output": "[2431532871909060205]", "fn_name": "fib_rabbits"}, {"input": "11\n33", "output": "[58212793]", "fn_name": "fib_rabbits"}, {"input": "8\n12", "output": "[8425]", "fn_name": "fib_rabbits"}, {"...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nSome time ago Lesha found an entertaining string $s$ consisting of lowercase English letters. Lesha immediately developed an unique algorithm for this string and shared it with you. The algorithm is as follows.\n\nLesha c...
[{"type": "stdin_stdout", "input": "ggaaaawwwxxxxxxrrrrrrrrwwwwwwwwggggggggjjusszzzzqqqqqsssssssbbwwwwwwmmmmtttttttvvvvvvvvssssppppppggggsrrrrrrzzzzzzzyyyyyccccccchhhhhhhhjjrrrrhhhhhhhheeeeeeeaaaaaaaiiiiiuuuuuuuvvvvvjjjjjjjjffbbbbbbbbrrrrrllllllllggggggggooooollssvvvvvvvvvvnnnnnnnnuuuuuuuucccccyyyyyyyyyyzzzzzzzkkkkuuuu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nUnlucky year in Berland is such a year that its number n can be represented as n = x^{a} + y^{b}, where a and b are non-negative integer numbers. \n\nFor example, if x = 2 and y = 3 then the years 4 and 17 are unlucky (4 ...
[{"type": "stdin_stdout", "input": "433333986179614514 1000000000000000000 433333986179614515 726628630292055493\n", "output": "293294644112440978\n"}, {"type": "stdin_stdout", "input": "433333986179614514 1000001000000000000 433333986179614515 726628630292055493\n", "output": "293294644112440978\n"}, {"type": "stdin_s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time l_{i} and the finish time r_{i} ...
[{"type": "stdin_stdout", "input": "20\n22 77\n13 50\n55 64\n16 52\n67 96\n49 51\n59 95\n2 25\n69 91\n2 24\n4 46\n50 74\n45 106\n39 55\n31 33\n9 33\n6 72\n14 67\n56 98\n69 152\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "20\n22 77\n13 50\n55 64\n16 52\n62 96\n49 51\n59 95\n2 25\n69 91\n2 24\n4 46\n50 74\n45...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a set of four (4) balls labeled with different numbers: ball_1 (1), ball_2 (2), ball_3 (3) and ball(4) and we have 3 equal boxes for distribute them. The possible combinations of the balls, without having empty b...
[{"input": "4\n5", "output": "[\"It cannot be possible!\"]", "fn_name": "combs_non_empty_boxes"}, {"input": "20\n8", "output": "[15170932662679]", "fn_name": "combs_non_empty_boxes"}, {"input": "4\n3", "output": "[6]", "fn_name": "combs_non_empty_boxes"}, {"input": "4\n2", "output": "[7]", "fn_name": "combs_non_empty_b...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are standing on top of an amazing Himalayan mountain. The view is absolutely breathtaking! you want to take a picture on your phone, but... your memory is full again! ok, time to sort through your shuffled photos and ...
[{"input": "[\"2016.img1\", \"2013.img3\", \"2016.img2\", \"2015.img3\", \"2012.img7\", \"2016.img4\", \"2013.img5\"]", "output": "[[\"2013.img5\", \"2015.img3\", \"2016.img1\", \"2016.img2\", \"2016.img4\", \"2016.img5\"]]", "fn_name": "sort_photos"}, {"input": "[\"2016.img7\", \"2016.img2\", \"2016.img3\", \"2015.img...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an n × m table, consisting of characters «A», «G», «C», «T». Let's call a table nice, if every 2 × 2 square contains all four distinct characters. Your task is to find a nice table (also consisting of «A», «...
[{"type": "stdin_stdout", "input": "3 5\nGACGA\nAGCAG\nAGCAG\n", "output": "AGCGA\nCTATC\nAGCGA\n"}, {"type": "stdin_stdout", "input": "3 5\nAGGAC\nGACGA\nGACGA\n", "output": "AGAGC\nCTCTA\nAGAGC\n"}, {"type": "stdin_stdout", "input": "3 5\nAGCAG\nAGCAG\nGACGA\n", "output": "AGCGA\nCTATC\nAGCGA\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe new ITone 6 has been released recently and George got really keen to buy it. Unfortunately, he didn't have enough money, so George was going to work as a programmer. Now he faced the following problem at the work.\n\n...
[{"type": "stdin_stdout", "input": "141 12 6\n66 53 86 91 12 27 5 74 79 50 33 2 100 26 2 73 16 14 50 86 75 9 66 48 19 34 25 1 22 50 63 39 38 42 98 71 76 27 80 16 74 21 36 1 32 20 65 28 68 40 41 6 0 77 65 84 0 34 60 0 42 65 2 16 25 85 35 57 74 66 26 33 39 14 0 6 2 15 87 99 47 67 75 63 72 32 93 7 5 63 35 99 89 61 18 25 7...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n# Task\n A robot is standing at the `(0, 0)` point of the Cartesian plane and is oriented towards the vertical (y) axis in the direction of increasing y values (in other words, he's facing up, or north). The robot execute...
[{"input": "[11, 8, 6, 6, 4, 3, 7, 2, 1]", "output": "[true]", "fn_name": "robot_walk"}, {"input": "[10, 3, 10, 2, 5, 1, 2]", "output": "[false]", "fn_name": "robot_walk"}, {"input": "[34241, 23434, 2341]", "output": "[false]", "fn_name": "robot_walk"}, {"input": "[9348, 2188, 9348]", "output": "[false]", "fn_name": "r...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nHow much bigger is a 16-inch pizza compared to an 8-inch pizza? A more pragmatic question is: How many 8-inch pizzas \"fit\" in a 16-incher?\n\nThe answer, as it turns out, is exactly four 8-inch pizzas. For sizes that do...
[{"input": "16", "output": "[\"pizzas: 4, slices: 0\"]", "fn_name": "how_many_pizzas"}, {"input": "12", "output": "[\"pizzas: 2, slices: 2\"]", "fn_name": "how_many_pizzas"}, {"input": "8", "output": "[\"pizzas: 1, slices: 0\"]", "fn_name": "how_many_pizzas"}, {"input": "6", "output": "[\"pizzas: 0, slices: 4\"]", "fn_...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's define `increasing` numbers as the numbers whose digits, read from left to right, are never less than the previous ones: 234559 is an example of increasing number.\n\nConversely, `decreasing` numbers have all the di...
[{"input": "50", "output": "[87959698326]", "fn_name": "total_inc_dec"}, {"input": "20", "output": "[40059819]", "fn_name": "total_inc_dec"}, {"input": "10", "output": "[277033]", "fn_name": "total_inc_dec"}, {"input": "6", "output": "[12952]", "fn_name": "total_inc_dec"}, {"input": "4", "output": "[1675]", "fn_name": ...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo players decided to play one interesting card game.\n\nThere is a deck of $n$ cards, with values from $1$ to $n$. The values of cards are pairwise different (this means that no two different cards have equal values). A...
[{"type": "stdin_stdout", "input": "2\n2 1 1\n2\n-1\n5 2 3\n1 3\n2 11 5\n", "output": "YES\nNO\n"}, {"type": "stdin_stdout", "input": "2\n2 1 1\n2\n-1\n5 2 3\n2 3\n2 2 5\n", "output": "YES\nNO\n"}, {"type": "stdin_stdout", "input": "2\n2 1 1\n2\n1\n5 2 3\n2 3\n-1 6 5\n", "output": "YES\nNO\n"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nGiven a permutation of length $ N $ $ P = \\\\ {P_1, P_2, \\ ldots, P_N \\\\} $ and the integer $ K $.\nDetermine if the permutation $ P $ can be monotonically increased by repeating the following operation any...
[{"type": "stdin_stdout", "input": "0 3\n3 -1 1", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "0 2\n6 11 1", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "1 2\n10 2 2", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "0 2\n10 2 2", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "0 2\n2 -...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese and Russian. \n\nRecently Chef has decided to make some changes in our beloved Codechef. As you know, each problem at Codechef has its memory and time limits. To make problems...
[{"type": "stdin_stdout", "input": "3\n2\n0 4\n5\n0 2 10 2 3\n3\n1 1 1", "output": "4\n11\n1\n"}, {"type": "stdin_stdout", "input": "3\n2\n2 2\n5\n0 0 11 4 3\n3\n0 3 0", "output": "2\n11\n3\n"}, {"type": "stdin_stdout", "input": "3\n2\n0 2\n5\n1 2 12 2 3\n3\n1 0 1", "output": "2\n13\n2\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\n3\naab\nczc\nbaa\n\n\nOutput\n\naac\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.\n\nWrite Python code to solve this problem. Y...
[{"type": "stdin_stdout", "input": "3\naab\nccz\nbaa", "output": "aac\n"}, {"type": "stdin_stdout", "input": "3\nbba\nzcc\nbaa", "output": "aaz\n"}, {"type": "stdin_stdout", "input": "3\nabb\nzbc\nbaa", "output": "aab\n"}, {"type": "stdin_stdout", "input": "3\nbbb\nzcd\nbaa", "output": "abc\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's call an array consisting of n integer numbers a_1, a_2, ..., a_{n}, beautiful if it has the following property:\n\n consider all pairs of numbers x, y (x ≠ y), such that number x occurs in the array a and number y ...
[{"type": "stdin_stdout", "input": "58 38\n6384 48910\n97759 90589\n28947 5031\n45169 32592\n85656 26360\n88538 42484\n44042 88351\n42837 79021\n96022 59200\n485 96735\n98000 3939\n3789 64468\n10894 58484\n26422 26618\n25515 95617\n37452 5250\n39557 66304\n79009 40610\n80703 60486\n90344 37588\n57504 61201\n62619 79797...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n - S is a palindrome.\n - Let N be the length of S. The string formed by the 1-st through ((N-1)...
[{"type": "stdin_stdout", "input": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "kszhkbpphykinkezplvfjaqmpmqajfvlpzeknikyhppbkhzskokszhkbpphykinkezplvfjaqmpmqajfvlpzeknikyhppbkhzsk\n", "output": "Yes\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEveryone loves a freebie. Especially students.\n\nIt is well-known that if in the night before exam a student opens window, opens the student's record-book and shouts loudly three times \"Fly, freebie, fly!\" — then flown...
[{"type": "stdin_stdout", "input": "100\n98 63 672 100 254 218 623 415 426 986 920 915 736 795 407 541 382 213 935 743 961 59 660 512 134 935 248 378 739 356 543 714 28 667 602 596 759 791 103 564 225 520 159 542 966 332 983 655 517 273 95 242 593 940 286 236 41 318 941 727 384 225 319 627 982 359 232 769 854 172 643 5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a program which print coordinates $(x_i, y_i)$ of given $n$ points on the plane by the following criteria.\n\n1. first by $x$-coordinate\n2. in case of a tie, by $y$-coordinate\n\nConstraints\n\n* $1 \\leq n \\leq 1...
[{"type": "stdin_stdout", "input": "5\n-1 3\n1 15\n-1 1\n-1 -1\n-1 -1", "output": "-1 -1\n-1 -1\n-1 1\n-1 3\n1 15\n"}, {"type": "stdin_stdout", "input": "5\n-1 3\n1 15\n-1 0\n-1 -1\n-1 -1", "output": "-1 -1\n-1 -1\n-1 0\n-1 3\n1 15\n"}, {"type": "stdin_stdout", "input": "5\n-1 3\n1 22\n-1 0\n-1 -1\n-1 -1", "output": "-...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMotorist Kojiro spent 10 years saving up for his favorite car brand, Furrari. Finally Kojiro's dream came true! Kojiro now wants to get to his girlfriend Johanna to show off his car to her.\n\nKojiro wants to get to his g...
[{"type": "stdin_stdout", "input": "386 20 29 30\n1 349\n2 482\n1 112\n1 93\n2 189\n1 207\n2 35\n2 -5\n1 422\n1 442\n1 402\n2 238\n3 258\n3 54\n2 369\n2 290\n2 329\n3 74\n3 -62\n2 170\n1 462\n2 15\n2 222\n1 309\n3 150\n1 -25\n3 130\n1 271\n1 -43\n351 250 91 102 0 286 123 93 100 205 328 269 188 83 73 35 188 223 73 215 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N cities. There are also K roads and L railways, extending between the cities. The i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_...
[{"type": "stdin_stdout", "input": "25 4 4\n1 2\n3 3\n2 5\n6 7\n3 5\n4 3\n3 4\n6 7", "output": "1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n"}, {"type": "stdin_stdout", "input": "27 0 1\n0 0\n2 10\n3 -1\n1 0", "output": "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n"}, {"type": "stdin_stdout", "input":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasily the bear has got a sequence of positive integers a_1, a_2, ..., a_{n}. Vasily the Bear wants to write out several numbers on a piece of paper so that the beauty of the numbers he wrote out was maximum. \n\nThe beau...
[{"type": "stdin_stdout", "input": "39\n37749932 37750076 37750391 37750488 37750607 37750812 37750978 37751835 37752173 37752254 75497669 75497829 75497852 75498044 75498061 75498155 75498198 75498341 75498382 75498465 150994988 150994989 150995009 150995019 150995024 150995030 150995031 150995069 150995072 805306369 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA string t is called an anagram of the string s, if it is possible to rearrange letters in t so that it is identical to the string s. For example, the string \"aab\" is an anagram of the string \"aba\" and the string \"aa...
[{"type": "stdin_stdout", "input": "??fb???a??\ndeeefc\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "??fb???a??\ndedefc\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "??fb???a??\ndedefd\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "??a???bf??\ndedefd\n", "output": "0\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nScheme? - Too loudly said. Just a new idea. Now Chef is expanding his business. He wants to make some new restaurants in the big city of Lviv. To make his business competitive he should interest customers. Now he knows ho...
[{"type": "stdin_stdout", "input": "3\n17\n7\n20", "output": "129140160\n2184\n486784383\n"}, {"type": "stdin_stdout", "input": "3\n19\n7\n21", "output": "162261457\n2184\n460353130\n"}, {"type": "stdin_stdout", "input": "3\n12\n13\n11", "output": "531444\n1594320\n177144\n"}, {"type": "stdin_stdout", "input": "3\n17\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the world of birding there are four-letter codes for the common names of birds. These codes are created by some simple rules:\n\n* If the bird's name has only one word, the code takes the first four letters of that wor...
[{"input": "[\"Scarlet Tanager\", \"Great Blue Heron\", \"Eastern Phoebe\", \"American Black Duck\", \"Mallard\", \"Canvasback\", \"Merlin\", \"Ovenbird\"]", "output": "[[\"SCTA\", \"GBHE\", \"EAPH\", \"ABDU\", \"MALL\", \"CANV\", \"MERL\", \"OVEN\"]]", "fn_name": "bird_code"}, {"input": "[\"Fox Sparrow\", \"White-Wing...
code_functional
[ { "content": "Solve the following coding problem using the programming language python:\n\nPermutation p is an ordered set of integers p_1, p_2, ..., p_{n}, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as p_{i}. We'll call number n ...
[{"type": "stdin_stdout", "input": "011\n", "output": "890786230\n"}, {"type": "stdin_stdout", "input": "13\n", "output": "695720788\n"}, {"type": "stdin_stdout", "input": "15\n", "output": "150347555\n"}, {"type": "stdin_stdout", "input": "11\n", "output": "890786230\n"}, {"type": "stdin_stdout", "input": "11\n", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array consisting of $n$ integers $a_1$, $a_2$, ..., $a_n$. Initially $a_x = 1$, all other elements are equal to $0$.\n\nYou have to perform $m$ operations. During the $i$-th operation, you choose two indi...
[{"type": "stdin_stdout", "input": "9\n100 50 6\n1 49\n51 100\n40 60\n30 70\n20 30\n70 80\n100 1 11\n1 1\n1 1\n1 1\n2 2\n2 100\n1 4\n2 3\n3 7\n5 6\n6 100\n4 5\n1 1 5\n1 1\n1 1\n1 1\n1 1\n1 1\n11 6 4\n6 6\n1 5\n7 11\n6 6\n3 3 2\n1 2\n2 3\n1000000000 1 1\n1 1000000000\n1000000000 1 1\n1 999999999\n1000000000 1 1\n2 10000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHardutta is planning an inter college football league. He has invited n teams, including our own team from BPHC. Now, one of the organizers Ramehta was hell bent on knowing one thing : How many matches will all the teams ...
[{"type": "stdin_stdout", "input": "73\n11 46\n78 14\n79 84\n3 7\n77 94\n67 62\n2 12\n12 46\n17 21\n89 35\n68 2\n76 10\n79 19\n58 78\n6 28\n35 16\n73 34\n67 80\n70 59\n53 21\n46 97\n36 80\n32 91\n14 26\n97 92\n42 100\n84 76\n28 32\n80 63\n86 39\n10 63\n66 86\n54 50\n77 71\n87 79\n43 99\n76 87\n82 35\n28 70\n5 37\n15 9\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLuba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly a_{i} each ...
[{"type": "stdin_stdout", "input": "100 100\n2 46 24 18 86 90 31 38 84 49 58 28 15 80 14 24 87 56 62 87 41 87 55 71 87 32 41 56 91 32 24 75 43 42 35 30 72 53 31 26 54 61 87 85 36 75 44 31 7 38 77 57 61 54 70 77 45 96 39 57 11 8 91 42 52 15 42 30 92 41 27 26 34 27 3 80 32 86 26 97 63 91 30 75 14 7 19 23 45 11 8 43 44 73...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Artem has invented a time machine! He could go anywhere in time, but all his thoughts of course are with computer science. He wants to apply this time machine to a well-known data structure: multiset.\n\nArtem want...
[{"type": "stdin_stdout", "input": "10\n1 1 1000000000\n1 4 1000000000\n2 2 1000000000\n1 5 1000000000\n1 8 1000000000\n2 15 1000000000\n3 3 1000000000\n3 10 1000000000\n3 6 1000000000\n3 7 1000000000\n", "output": "0\n3\n2\n2\n"}, {"type": "stdin_stdout", "input": "10\n1 1 1000000000\n1 4 1000000000\n2 2 1000000000\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle boy Gerald studies at school which is quite far from his house. That's why he has to go there by bus every day. The way from home to school is represented by a segment of a straight line; the segment contains exact...
[{"type": "stdin_stdout", "input": "68 74\n51 54\n3 22\n12 24\n3 27\n32 42\n36 55\n60 64\n1 4\n4 23\n11 64\n54 62\n50 56\n21 34\n27 63\n15 54\n28 61\n13 57\n39 53\n12 32\n32 40\n33 67\n55 61\n33 67\n30 37\n15 49\n27 45\n21 41\n8 42\n24 63\n40 48\n28 41\n30 67\n0 4\n7 15\n27 59\n60 62\n25 65\n30 31\n38 67\n24 43\n14 64\...
code_stdio