messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "One day, liouzhou_101 got a chat record of Freda and Rainbow. Out of curiosity, he wanted to know which sentences were said by Freda, and which were said by Rainbow. According to his experience, he thought that Freda always said \"lala.\" at the end of her sentences, while Rainbow always said \"mi...
[{"input": "10\nmiao.vyscfysAtWcPkpFHdwZqAQ,UPPcjhKQTlala.\nmiao.KESqus DybUuYFoWVpo..LWZh.UqEdUsTHFlKfzqkThAUPklala.\nUNoE vfZIAdxkiWKhsHPfsqRPTNQoHgAxooVLYxRzugHjo jaEHWQFF\nCCmdIwr.UkoiYWK.Z,,ZesMpISTXNgnpYnJaWquCyL,gO\n.JvOayhXK_bgoYbfAtnXg\nbvdSzRrXoGxVgWvdXnsjEnEfxDzIQo_aZVGDGrzwuAMtzVAHioMBx_DHuTxyieGbGuSRNUojOR...
code_stdio
[ { "content": "You are given two integers A and B.\nFind the largest value among A+B, A-B and A \\times B.\n\n-----Constraints-----\n - -1000 \\leq A,B \\leq 1000\n - All values in input are integers.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nA B\n\n-----Output-----\nPrint ...
[{"input": "-17 -10", "output": "170\n"}, {"input": "-10 -10", "output": "100\n"}, {"input": "-156 -1", "output": "156\n"}, {"input": "-156 -2", "output": "312\n"}, {"input": "-156 -3", "output": "468\n"}, {"input": "-115 1", "output": "-114\n"}, {"input": "297 -1", "output": "298\n"}, {"input": "-34 15", "output": "-1...
code_stdio
[ { "content": "After Misha's birthday he had many large numbers left, scattered across the room. Now it's time to clean up and Misha needs to put them in a basket. He ordered this task to his pet robot that agreed to complete the task at certain conditions. Before the robot puts a number x to the basket, Misha s...
[{"input": "10\n3035890458\n12148270198\n3004213265\n248593357\n5644084048\n14918970762\n8120649160\n4828464769\n183848555\n8135845959\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n"}, {"input": "10\n3035890458\n12148270198\n5256278021\n248593357\n5644084048\n14918970762\n8120649160\n4828464769\n183848555\n8135845959\n"...
code_stdio
[ { "content": "You are given an array of integers. Vasya can permute (change order) its integers. He wants to do it so that as many as possible integers will become on a place where a smaller integer used to stand. Help Vasya find the maximal number of such integers.\n\nFor instance, if we are given an array [10...
[{"input": "6\n300000000 200000000 300000000 200000000 1000000000 300000000\n", "output": "3\n"}, {"input": "6\n300000000 200000000 173776099 200000000 1000000000 300000000\n", "output": "4\n"}, {"input": "6\n300000000 200000000 173776099 200000000 1000000000 42712044\n", "output": "4\n"}, {"input": "6\n300000000 59981...
code_stdio
[ { "content": "Create a program that reads the sales unit price and sales quantity and outputs the total sales amount and the average sales quantity.\n\n\n\nInput\n\nThe input is given in the following format:\n\n\nSales unit price, sales quantity\nSales unit price, sales quantity\n::\n::\n\n\nA comma-separated ...
[{"input": "02,001\n50,10\n8,531", "output": "4750\n181\n"}, {"input": "0,1000\n01,05\n134,8", "output": "1077\n338\n"}, {"input": "0,1000\n01,05\n134,9", "output": "1211\n338\n"}, {"input": "0,1000\n11,05\n134,9", "output": "1261\n338\n"}, {"input": "0,1000\n12,05\n134,9", "output": "1266\n338\n"}, {"input": "0,1000\n...
code_stdio
[ { "content": "Given is a tree T with N vertices. The i-th edge connects Vertex A_i and B_i (1 \\leq A_i,B_i \\leq N).\nNow, each vertex is painted black with probability 1/2 and white with probability 1/2, which is chosen independently from other vertices. Then, let S be the smallest subtree (connected subgraph...
[{"input": "7\n4 7\n3 1\n2 6\n5 2\n7 1\n2 7\n", "output": "570312505\n"}, {"input": "7\n4 7\n3 1\n2 6\n5 4\n7 1\n2 7", "output": "835937507\n"}, {"input": "7\n4 7\n3 1\n3 6\n5 4\n7 1\n2 7", "output": "679687506\n"}, {"input": "7\n4 7\n3 1\n2 6\n5 1\n7 1\n2 7", "output": "570312505\n"}, {"input": "7\n4 7\n3 1\n3 6\n5 1\...
code_stdio
[ { "content": "Last summer Peter was at his granny's in the country, when a wolf attacked sheep in the nearby forest. Now he fears to walk through the forest, to walk round the forest, even to get out of the house. He explains this not by the fear of the wolf, but by a strange, in his opinion, pattern of the for...
[{"input": "1000000\n", "output": "958220352\n"}, {"input": "972408\n", "output": "377259665\n"}, {"input": "956022\n", "output": "864671299\n"}, {"input": "941322\n", "output": "359985814\n"}, {"input": "908550\n", "output": "307673807\n"}, {"input": "635758\n", "output": "524558133\n"}, {"input": "992164\n", "output"...
code_stdio
[ { "content": "Alex is transitioning from website design to coding and wants to sharpen his skills with CodeWars. \nHe can do ten kata in an hour, but when he makes a mistake, he must do pushups. These pushups really tire poor Alex out, so every time he does them they take twice as long. His first set of redemp...
[{"input": "10\n120", "output": "[3]", "fn_name": "alex_mistakes"}, {"input": "11\n120", "output": "[3]", "fn_name": "alex_mistakes"}, {"input": "20\n120", "output": "[0]", "fn_name": "alex_mistakes"}, {"input": "20\n125", "output": "[1]", "fn_name": "alex_mistakes"}, {"input": "20\n130", "output": "[1]", "fn_name": "a...
code_functional
[ { "content": "In this problem you are to calculate the sum of all integers from 1 to n, but you should take all powers of two with minus in the sum.\n\nFor example, for n = 4 the sum is equal to - 1 - 2 + 3 - 4 = - 4, because 1, 2 and 4 are 2^0, 2^1 and 2^2 respectively.\n\nCalculate the answer for t values o...
[{"input": "60\n536870912\n536870911\n536870913\n1000000000\n999999999\n1\n2\n3\n4\n268435456\n268435455\n268435457\n536870912\n536870911\n536870913\n1000000000\n999999999\n1\n2\n3\n4\n268435456\n268435455\n268435457\n536870912\n536870911\n536870913\n1000000000\n999999999\n1\n2\n3\n4\n268435456\n268435455\n268435457\n5...
code_stdio
[ { "content": "Berland scientists know that the Old Berland language had exactly n words. Those words had lengths of l1, l2, ..., ln letters. Every word consisted of two letters, 0 and 1. Ancient Berland people spoke quickly and didn’t make pauses between the words, but at the same time they could always underst...
[{"input": "100\n17 18 22 15 14 18 9 21 14 19 14 20 12 15 9 23 19 20 19 22 13 22 17 11 21 22 8 17 23 18 21 23 22 23 15 18 21 17 17 9 13 21 23 19 18 23 15 14 17 19 22 23 12 16 23 16 20 9 12 17 18 11 10 17 16 21 8 21 16 19 21 17 12 20 14 16 17 10 22 20 17 13 15 19 9 22 12 20 20 13 19 16 18 7 15 18 6 18 19 21\n", "output"...
code_stdio
[ { "content": "# Introduction and Warm-up (Highly recommended)\n\n# [Playing With Lists/Arrays Series](https://www.codewars.com/collections/playing-with-lists-slash-arrays)\n___\n\n# Task\n\n**_Given_** an *array/list [] of integers* , **_Find_** **_The maximum difference_** *between the successive elements in i...
[{"input": "[-54, 37, 0, 64, -15, 640, 0]", "output": "[576]", "fn_name": "max_gap"}, {"input": "[24, 299, 131, 14, 26, 25]", "output": "[168]", "fn_name": "max_gap"}, {"input": "[-7, -42, -809, -14, -12]", "output": "[767]", "fn_name": "max_gap"}, {"input": "[12, -5, -7, 0, 290]", "output": "[278]", "fn_name": "max_ga...
code_functional
[ { "content": "Leo has developed a new programming language C+=. In C+=, integer variables can only be changed with a \"+=\" operation that adds the right-hand side value to the left-hand side variable. For example, performing \"a += b\" when a = $2$, b = $3$ changes the value of a to $5$ (the value of b does no...
[{"input": "16\n1 1 1\n3 4 6\n4 5 16\n456 123 7890123\n1 1 1000000000\n45 12 782595420\n1 1000000000 1001000000\n1 999999999 1000000100\n1 99999 676497416\n5 6 1409378894\n8 9 1376775908\n500000000 500000000 1000000000\n1000000000 1000000000 1000000000\n999999999 1000000000 1000000000\n1066 1487360 987405273\n12116 537...
code_stdio
[ { "content": "You are given a sorted array $a_1, a_2, \\dots, a_n$ (for each index $i > 1$ condition $a_i \\ge a_{i-1}$ holds) and an integer $k$.\n\nYou are asked to divide this array into $k$ non-empty consecutive subarrays. Every element in the array should be included in exactly one subarray. \n\nLet $max(i...
[{"input": "7 6\n-3 0 -1 -2 -2 -4 -1\n", "output": "-2\n"}, {"input": "8 1\n1 1 2 3 5 8 13 21\n", "output": "20\n"}, {"input": "5 3\n99 101 103 105 107\n", "output": "4\n"}, {"input": "5 3\n99 101 103 105 107\n", "output": "4\n"}, {"input": "8 2\n1 1 2 3 5 8 13 21\n", "output": "12\n"}, {"input": "8 4\n1 1 2 3 5 8 22 1...
code_stdio
[ { "content": "Alice is playing a game with her good friend, Marisa.\n\nThere are n boxes arranged in a line, numbered with integers from 1 to n from left to right. Marisa will hide a doll in one of the boxes. Then Alice will have m chances to guess where the doll is. If Alice will correctly guess the number of ...
[{"input": "8000 100\n7990 4432 5901 5019 423 1200 7760 5752 7422 4337 4802 2570 7354 4912 2185 2344 6538 2783 1473 5311 3987 4739 7159 1677 3438 502 2800 1318 5223 4518 4448 6451 3455 5012 1588 814 4971 5847 3849 6248 6420 3607 2610 6852 1045 3730 757 6905 5248 3738 2382 7251 1305 7380 2476 7346 5721 5946 7599 5321 62...
code_stdio
[ { "content": "In Ancient Berland there were n cities and m two-way roads of equal length. The cities are numbered with integers from 1 to n inclusively. According to an ancient superstition, if a traveller visits three cities ai, bi, ci in row, without visiting other cities between them, a great disaster awaits...
[{"input": "4 4 4\n1 2\n2 3\n3 4\n1 3\n1 2 3\n1 3 4\n1 2 4\n1 3 2\n", "output": "-1\n"}, {"input": "4 4 2\n1 2\n2 3\n3 4\n1 3\n1 2 3\n1 3 4\n", "output": "4\n1 3 2 3 4\n"}, {"input": "4 4 1\n1 2\n2 3\n3 4\n1 3\n1 3 4\n", "output": "3\n1 2 3 4\n"}, {"input": "4 4 1\n1 2\n2 3\n3 4\n2 3\n1 3 4\n", "output": "3\n1 2 3 4 "}...
code_stdio
[ { "content": "Takahashi will play a game using a piece on an array of squares numbered 1, 2, \\cdots, N. Square i has an integer C_i written on it. Also, he is given a permutation of 1, 2, \\cdots, N: P_1, P_2, \\cdots, P_N.\nNow, he will choose one square and place the piece on that square. Then, he will make ...
[{"input": "5000 1000000000\n2736 2472 4235 589 1974 2469 3229 2748 1350 1280 163 2424 391 784 3174 608 3060 2125 3128 1366 1374 4193 4562 2456 2118 1870 2581 879 3424 3886 1917 847 4646 4880 4407 3527 252 770 3405 1122 4272 3227 4221 802 2571 3857 4554 3275 3243 3903 2258 401 2292 1447 1014 1 4210 4719 3693 3181 4044 ...
code_stdio
[ { "content": "You have initially a string of N characters, denoted by A1,A2...AN. You have to print the size of the largest subsequence of string A such that all the characters in that subsequence are distinct ie. no two characters in that subsequence should be same.\n\nA subsequence of string A is a sequence t...
[{"input": "2\nabd\naba", "output": "3\n2\n"}, {"input": "2\nabc\naaa", "output": "3\n1\n"}, {"input": "2\ncca\naaa", "output": "2\n1\n"}, {"input": "2\nccb\naab", "output": "2\n2\n"}, {"input": "2\nccb\ncba", "output": "2\n3\n"}, {"input": "2\nbbb\nbaa", "output": "1\n2\n"}, {"input": "2\nbbb\naaa", "output": "1\n1\n"...
code_stdio
[ { "content": "You talked to Polycarp and asked him a question. You know that when he wants to answer \"yes\", he repeats Yes many times in a row.\n\nBecause of the noise, you only heard part of the answer — some substring of it. That is, if he answered YesYes, then you could hear esY, YesYes, sYes, e, but you c...
[{"input": "12\nYES\nesYes\ncodeforces\nes\nse\nYesY\nesYesYesYesYesYesYe\nseY\nYess\nsY\no\nYes\n", "output": "NO\nYES\nNO\nYES\nNO\nYES\nYES\nNO\nNO\nYES\nNO\nYES\n"}, {"input": "1\nsYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesY\n", "output": "YES\n"}, {"input": "1\nYesYesYesYesYesYesa\n", "output": "NO\n"}, {"in...
code_stdio
[ { "content": "There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in the line. Note that a psycho might kill and get killed at the same step. \n\nYou're giv...
[{"input": "100\n61 96 25 10 50 71 38 77 76 75 59 100 89 66 6 99 2 13 3 23 91 93 22 92 4 86 90 44 39 31 9 47 28 95 18 54 1 73 94 78 60 20 42 84 97 83 16 81 67 64 74 46 82 5 88 80 14 48 53 79 30 11 62 21 41 70 63 58 51 56 57 17 87 72 27 85 68 49 52 8 12 98 43 37 35 69 55 32 26 40 29 65 19 24 34 33 15 45 36 7\n", "output...
code_stdio
[ { "content": "Mr. Matsudaira is always careful about eco-friendliness in his life. Last month's water charge was 4280 yen, which exceeded the usual target of 4000 yen, so we have been trying to save water this month. How much have you saved on your water bill compared to last month?\n\nEnter this month's water ...
[{"input": "29\n104\n0\n-1", "output": "620\n-11360\n3130\n"}, {"input": "29\n112\n0\n-1", "output": "620\n-12640\n3130\n"}, {"input": "29\n130\n1\n-1", "output": "620\n-15520\n3130\n"}, {"input": "29\n97\n0\n-1", "output": "620\n-10240\n3130\n"}, {"input": "29\n96\n1\n-1", "output": "620\n-10080\n3130\n"}, {"input": "...
code_stdio
[ { "content": "You are given n k-digit integers. You have to rearrange the digits in the integers so that the difference between the largest and the smallest number was minimum. Digits should be rearranged by the same rule in all integers.\n\nInput\n\nThe first line contains integers n and k — the number and dig...
[{"input": "8 8\n83239439\n62184887\n58968944\n39808261\n68740623\n38480328\n81965504\n52600488\n", "output": "44481119\n"}, {"input": "8 8\n96805230\n73119021\n06552907\n86283347\n88650846\n19155689\n37032451\n19310120\n", "output": "53604668\n"}, {"input": "8 8\n68785928\n11981277\n32480720\n72495162\n69969623\n42118...
code_stdio
[ { "content": "Let's consider all integers in the range from $1$ to $n$ (inclusive).\n\nAmong all pairs of distinct integers in this range, find the maximum possible greatest common divisor of integers in pair. Formally, find the maximum value of $\\mathrm{gcd}(a, b)$, where $1 \\leq a < b \\leq n$.\n\nThe great...
[{"input": "100\n2\n3\n4\n6\n6\n9\n8\n9\n10\n11\n12\n23\n14\n15\n5\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n11\n20\n35\n36\n37\n38\n65\n40\n41\n42\n43\n44\n70\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\n60\n61\n62\n63\n64\n65\n66\n67\n68\n69\n70\n71\n72\n73\n39\n49\n76\n77\n78\n79\n...
code_stdio
[ { "content": "Bamboo Blossoms\n\nThe bamboos live for decades, and at the end of their lives, they flower to make their seeds. Dr. ACM, a biologist, was fascinated by the bamboos in blossom in his travel to Tsukuba. He liked the flower so much that he was tempted to make a garden where the bamboos bloom annuall...
[{"input": "3 2\n2 6\n10 10\n110 181\n2 371896\n0 0", "output": "5\n17\n21\n379\n5361757\n"}, {"input": "12 1\n3 1\n10 20\n100 50\n3 202868\n0 0", "output": "13\n4\n47\n150\n2792771\n"}, {"input": "2 4\n3 1\n13 35\n100 47\n4 346519\n0 0", "output": "11\n4\n101\n147\n4969351\n"}, {"input": "3 2\n3 4\n10 20\n100 50\n2 50...
code_stdio
[ { "content": "There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.\nWhen the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).\nIn how many ways can the knight reach the square (X, Y)?\nFind the number of ways modulo 10^9 + 7.\n\n-----Constraints...
[{"input": "999999 999999\n", "output": "151840682\n"}, {"input": "803622 615354\n", "output": "984439211\n"}, {"input": "691947 979659\n", "output": "966489110\n"}, {"input": "411938 406831\n", "output": "625271651\n"}, {"input": "329039 389257\n", "output": "766659580\n"}, {"input": "544850 859069\n", "output": "7052...
code_stdio
[ { "content": "Alas, finding one's true love is not easy. Masha has been unsuccessful in that yet. Her friend Dasha told Masha about a way to determine the phone number of one's Prince Charming through arithmancy. \n\nThe phone number is divined like that. First one needs to write down one's own phone numbers. F...
[{"input": "17601120900014764776764048700928872725171605903217\n", "output": "10428170619\n"}, {"input": "78767765544454334445445555455676565433343455432332\n", "output": "11031574582\n"}, {"input": "67676566654565654332111011212211111223433222110012\n", "output": "5882859948\n"}, {"input": "107644873278096903327544821...
code_stdio
[ { "content": "I am a craftsman specialized in interior works. A customer asked me to perform wiring work on a wall whose entire rectangular surface is tightly pasted with pieces of panels. The panels are all of the same size (2 m in width, 1 m in height) and the wall is filled with an x (horizontal) by y (verti...
[{"input": "1 -11", "output": "-10\n"}, {"input": "171 2", "output": "173\n"}, {"input": "120 3", "output": "121\n"}, {"input": "109 1", "output": "110\n"}, {"input": "119 1", "output": "120\n"}, {"input": "150 2", "output": "151\n"}, {"input": "148 1", "output": "149\n"}, {"input": "169 2", "output": "171\n"}, {"input...
code_stdio
[ { "content": "A rabbit who came to the fair found that the prize for a game at a store was a carrot cake. The rules for this game are as follows.\n\nThere is a grid-like field of vertical h squares x horizontal w squares, and each block has at most one block. Each block is a color represented by one of the uppe...
[{"input": "4 6 1\n......\n...Y..\n/..Z..\nYRRRYY", "output": "YES\n"}, {"input": "4 6 1\n......\n...Y..\n..Z../\nYRRRYY", "output": "YES\n"}, {"input": "4 6 1\n......\n...Y./\n/..Z..\nYRRRYY", "output": "YES\n"}, {"input": "0 10 3\n......\n/.Y...\n/..Y..\nRRYRYY", "output": "NO\n"}, {"input": "4 6 1\n......\n...Y..\n....
code_stdio
[ { "content": "Given an array, return the difference between the count of even numbers and the count of odd numbers. `0` will be considered an even number. \n\n```\nFor example:\nsolve([0,1,2,3]) = 0 because there are two even numbers and two odd numbers. Even - Odd = 2 - 2 = 0. \n```\n\nLet's now add two lette...
[{"input": "[5, 15, 16, 10, 6, 4, 16, \"t\", 13, \"n\", 14, \"k\", \"n\", 0, \"q\", \"d\", 7, 9]", "output": "[2]", "fn_name": "solve"}, {"input": "[0, 15, \"z\", 16, \"m\", 13, 14, \"c\", 9, 10, 13, \"u\", 4, 3]", "output": "[0]", "fn_name": "solve"}, {"input": "[1, \"a\", 17, 8, \"e\", 3, \"i\", 12, 1]", "output": "[...
code_functional
[ { "content": "Mr. Infinity has a string S consisting of digits from 1 to 9. Each time the date changes, this string changes as follows:\n - Each occurrence of 2 in S is replaced with 22. Similarly, each 3 becomes 333, 4 becomes 4444, 5 becomes 55555, 6 becomes 666666, 7 becomes 7777777, 8 becomes 88888888 and 9...
[{"input": "3822434535651488671388118263222567477765652247558781154667867787813244635482224781486555517652377271\n150250350450550650\n", "output": "3\n"}, {"input": "111111111111111111117322118756841484815524346474882856582285635434521523587354424471731255584\n975864753642531420\n", "output": "7\n"}, {"input": "1111111...
code_stdio
[ { "content": "_This kata is based on [Project Euler Problem 546](https://projecteuler.net/problem=546)_\n\n# Objective\n\nGiven the recursive sequence \n\nfk(n) =\n\n\n∑\n\ni\n=\n0\n\n\nn\n\n\n\nfk(floor(i / k)) where fk(0) = 1\n\nDefine a function `f` that takes arguments `k` and `n` and returns the nth term i...
[{"input": "3\n50000", "output": "[80887845303700596855]", "fn_name": "f"}, {"input": "100\n500000", "output": "[21469002551]", "fn_name": "f"}, {"input": "2\n1000", "output": "[264830889564]", "fn_name": "f"}, {"input": "97\n100000", "output": "[209497156]", "fn_name": "f"}, {"input": "2\n200", "output": "[7389572]", ...
code_functional
[ { "content": "Summer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the beach. The gym where they go is a matrix a with n lines and m columns. Let number a[i][j] represents the calories burned by performing workout at the cell of gym in the i-th line and the j-th colum...
[{"input": "4 5\n87882 40786 3691 85313 46694\n28884 16067 3242 97367 78518\n4250 35501 9780 14435 19004\n64673 65438 56977 64495 27280\n", "output": "747898\n"}, {"input": "4 5\n2274 40786 3691 98933 46694\n28884 16067 3242 97367 73338\n8377 57682 9780 14435 19004\n64673 65438 103768 64495 27280\n", "output": "717521\...
code_stdio
[ { "content": "Write a simple regex to validate a username. Allowed characters are:\n\n- lowercase letters,\n- numbers,\n- underscore\n\nLength should be between 4 and 16 characters (both included).\n\nWrite Python code to solve this problem. Define a top-level function named `validate_usr` that takes the input ...
[{"input": "\"Hasd_12assssssasasasasasaasasasasas\"", "output": "[false]", "fn_name": "validate_usr"}, {"input": "\"asd43 34\"", "output": "[false]", "fn_name": "validate_usr"}, {"input": "\"asd43_34\"", "output": "[true]", "fn_name": "validate_usr"}, {"input": "\"asddsa\"", "output": "[true]", "fn_name": "validate_usr...
code_functional
[ { "content": "Formula 1 officials decided to introduce new competition. Cars are replaced by space ships and number of points awarded can differ per race.\n\nGiven the current ranking in the competition and points distribution for the next race, your task is to calculate the best possible ranking for a given as...
[{"input": "4 2\n29 16 13 10\n20 10 10 -1\n", "output": "1\n"}, {"input": "4 3\n50 30 20 10\n15 10 7 10\n", "output": "3\n"}, {"input": "4 4\n29 16 13 10\n20 10 8 -1\n", "output": "1\n"}, {"input": "4 3\n51 30 20 10\n15 10 7 10\n", "output": "3\n"}, {"input": "4 2\n29 16 13 10\n20 10 8 -1\n", "output": "1\n"}, {"input"...
code_stdio
[ { "content": "Oranges on Cans\n\nsquare1001 You put a $ N $ can of aluminum on the table.\n\nE869120 You put $ M $ of oranges on each aluminum can on the table.\n\nHow many oranges are on the aluminum can?\n\ninput\n\nInput is given from standard input in the following format.\n\n\n$ N $ $ M $\n\n\noutput\n\nOu...
[{"input": "-17 16", "output": "-272\n"}, {"input": "-17 30", "output": "-510\n"}, {"input": "-17 44", "output": "-748\n"}, {"input": "-2 125", "output": "-250\n"}, {"input": "-1 111", "output": "-111\n"}, {"input": "-2 110", "output": "-220\n"}, {"input": "-2 100", "output": "-200\n"}, {"input": "13 100", "output": "1...
code_stdio
[ { "content": "There are N stones, numbered 1, 2, \\ldots, N. For each i (1 \\leq i \\leq N), the height of Stone i is h_i. Here, h_1 < h_2 < \\cdots < h_N holds.\n\nThere is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N:\n\n* If the frog is current...
[{"input": "2 1000000100100\n1174717 1001000", "output": "1030177696189\n"}, {"input": "2 1000000000100\n1174717 1001000", "output": "1030177596189\n"}, {"input": "2 1000000000000\n1807061 1100100", "output": "1499793855521\n"}, {"input": "2 1000000000000\n1249354 1100100", "output": "1022276756516\n"}, {"input": "2 10...
code_stdio
[ { "content": "Goal\nGiven a list of elements [a1, a2, ..., an], with each ai being a string, write a function **majority** that returns the value that appears the most in the list. \n\nIf there's no winner, the function should return None, NULL, nil, etc, based on the programming language.\n\nExample\nmajority(...
[{"input": "[\"A\", \"A\", \"A\", \"BBBBBBBB\"]", "output": "[\"A\"]", "fn_name": "majority"}, {"input": "[\"A\", \"B\", \"B\", \"A\"]", "output": "[null]", "fn_name": "majority"}, {"input": "[\"A\", \"A\", \"A\", \"A\"]", "output": "[\"A\"]", "fn_name": "majority"}, {"input": "[\"A\", \"B\", \"C\", \"C\"]", "output": ...
code_functional
[ { "content": "Limak is a little polar bear. He loves connecting with other bears via social networks. He has n friends and his relation with the i-th of them is described by a unique integer ti. The bigger this value is, the better the friendship is. No two friends have the same value ti.\n\nSpring is starting ...
[{"input": "20 2 15\n12698951 55128070 116962690 156763505 188535242 332511771 269939893 428710623 802222241 483000923 516768937 552903993 633087286 656092270 671535141 714291344 1397620094 1268000284 879748146 937368929\n2 7\n1 2\n2 4\n2 19\n1 12\n1 5\n2 18\n2 11\n1 16\n2 1\n2 3\n2 19\n1 17\n2 4\n2 11\n", "output": "N...
code_stdio
[ { "content": "Happy new year! The year 2020 is also known as Year Gyeongja (경자년, gyeongja-nyeon) in Korea. Where did the name come from? Let's briefly look at the Gapja system, which is traditionally used in Korea to name the years.\n\nThere are two sequences of $n$ strings $s_1, s_2, s_3, \\ldots, s_{n}$ and $...
[{"input": "10 12\nsin im gye gap eul bynoeg jeong mu gj gyeong\nyu sul hae jb chuk in myo jin as o li sin\n14\n1\n1\n3\n4\n17\n17\n12\n13\n73\n2016\n32\n2018\n2019\n2020\n", "output": "sinyu\nsinyu\ngyehae\ngapjb\njeongchuk\njeongchuk\nimsin\ngyeyu\ngyeyu\nbynoegsin\nimjin\nmusul\ngjhae\ngyeongjb\n"}, {"input": "10 12...
code_stdio
[ { "content": "Recently personal training sessions have finished in the Berland State University Olympiad Programmer Training Centre. By the results of these training sessions teams are composed for the oncoming team contest season. Each team consists of three people. All the students of the Centre possess numbe...
[{"input": "7\n4 19 14 8 21 16 2 18 1 15 3 17 13 5 6 10 9 7 12 11 20\n4 19 10\n14 8 3\n21 17 9\n16 6 12\n2 13 20\n18 1 7\n15 5 11\n21\n", "output": "3 4 8 9 10 14 17 1 2 5 6 7 11 12 13 15 16 18 19 20\n"}, {"input": "6\n6 4 10 16 14 11 13 1 7 17 18 15 5 3 9 12 2 8\n6 10 1\n4 3 9\n16 11 13\n14 15 2\n7 18 5\n17 12 8\n7\n"...
code_stdio
[ { "content": "According to ISO 8601, the first calendar week (1) starts with the week containing the first thursday in january.\nEvery year contains of 52 (53 for leap years) calendar weeks.\n\n**Your task is** to calculate the calendar week (1-53) from a given date.\nFor example, the calendar week for the date...
[{"input": "\"2017-01-01\"", "output": "[52]", "fn_name": "get_calendar_week"}, {"input": "\"2018-12-24\"", "output": "[52]", "fn_name": "get_calendar_week"}, {"input": "\"2015-12-29\"", "output": "[53]", "fn_name": "get_calendar_week"}, {"input": "\"1995-12-31\"", "output": "[52]", "fn_name": "get_calendar_week"}, {"i...
code_functional
[ { "content": "You are given an array $a_1, a_2, \\dots, a_n$ where all $a_i$ are integers and greater than $0$.\n\n In one operation, you can choose two different indices $i$ and $j$ ($1 \\le i, j \\le n$). If $gcd(a_i, a_j)$ is equal to the minimum element of the whole array $a$, you can swap $a_i$ and $a_j$. ...
[{"input": "4\n1\n8\n6\n4 4 6 6 2 9\n4\n4 5 6 10\n5\n10 10 2 2 4\n", "output": "YES\nYES\nYES\nYES\n"}, {"input": "4\n1\n8\n6\n4 4 6 6 2 9\n4\n4 5 6 7\n5\n10 10 2 2 4\n", "output": "YES\nYES\nYES\nYES\n"}, {"input": "4\n1\n8\n6\n4 4 6 6 2 15\n4\n4 5 6 7\n5\n7 10 2 2 3\n", "output": "YES\nYES\nYES\nNO\n"}, {"input": "4\...
code_stdio
[ { "content": "The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations:\n\n\n\n d_1 is the distance between the 1-st and the 2-nd station;\n\n d_2 is the distance between the 2-nd and the 3-rd station;\n\n...\n\n d_{n} - 1 is the distance between the ...
[{"input": "100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100...
code_stdio
[ { "content": "You are given a sequence of $n$ integers $a_1, \\, a_2, \\, \\dots, \\, a_n$.\n\nDoes there exist a sequence of $n$ integers $b_1, \\, b_2, \\, \\dots, \\, b_n$ such that the following property holds?\n\nFor each $1 \\le i \\le n$, there exist two (not necessarily distinct) indices $j$ and $k$ ($1...
[{"input": "20\n5\n6711 19885 -3098 -16272 -10076\n4\n86522 29647 -12464 -9627\n4\n-82555 -5215 -15221 -63129\n4\n-18147 4 5 -5\n5\n-17427 -19079 17427 15043 19079\n5\n15148 5942 361 9206 21087\n3\n-1 -55 1\n5\n47214 53109 39369 11561 -22908\n4\n-74790 54187 -2 30242\n2\n-68120 94070\n3\n-27228 46215 -33546\n2\n75489 9...
code_stdio
[ { "content": "In this problem you have to simulate the workflow of one-thread server. There are n queries to process, the i-th will be received at moment t_{i} and needs to be processed for d_{i} units of time. All t_{i} are guaranteed to be distinct.\n\nWhen a query appears server may react in three possible w...
[{"input": "4 3\n999999996 1000000000\n999999997 1000000000\n999999998 1000000000\n999999999 1000000000\n", "output": "1999999996 2999999996 3999999996 4999999996 \n"}, {"input": "4 3\n999999996 1000000000\n999999997 1000000000\n999999998 1000000000\n999999999 1000000000\n", "output": "1999999996 2999999996 3999999996 ...
code_stdio
[ { "content": "You play a strategic video game (yeah, we ran out of good problem legends). In this game you control a large army, and your goal is to conquer $n$ castles of your opponent.\n\nLet's describe the game process in detail. Initially you control an army of $k$ warriors. Your enemy controls $n$ castles;...
[{"input": "10 10 2\n2 1 1615\n2 1 1326\n0 0 3880\n2 0 1596\n1 2 4118\n0 0 4795\n0 1 814\n0 0 4555\n0 1 3284\n2 2 1910\n10 6\n2 1\n8 3\n8 7\n6 3\n4 1\n7 4\n6 4\n7 2\n10 9\n", "output": "27079\n"}, {"input": "10 10 0\n0 2 1413\n0 0 4466\n0 0 2681\n0 0 2959\n0 2 1182\n0 0 468\n0 1 3347\n0 0 3978\n0 2 2831\n0 3 3138\n5 2\...
code_stdio
[ { "content": "We have three boxes A, B, and C, each of which contains an integer.\n\nCurrently, the boxes A, B, and C contain the integers X, Y, and Z, respectively.\n\nWe will now do the operations below in order. Find the content of each box afterward. \n - Swap the contents of the boxes A and B\n - Swap the...
[{"input": "100 100 100\n", "output": "100 100 100\n"}, {"input": "111 110 110", "output": "110 111 110\n"}, {"input": "110 110 110", "output": "110 110 110\n"}, {"input": "110 110 111", "output": "111 110 110\n"}, {"input": "010 100 100", "output": "100 10 100\n"}, {"input": "011 101 100", "output": "100 11 101\n"}, {...
code_stdio
[ { "content": "You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.\nHow many kinds of items did you get?\n\n-----Constraints-----\n - 1 \\leq N \\leq 2\\times 10^5\n - S_i consists of lowercase English letters and has a length between 1 and 10 (inclusive).\n\n----...
[{"input": "5\ngrape\ngrape\ngrape\ngrape\ngrape\n", "output": "1\n"}, {"input": "5\ngrape\ngrape\ngraoe\ngrape\ngrape", "output": "2\n"}, {"input": "5\negapr\ngrape\ngraoe\ngr`pe\nepaqg", "output": "5\n"}, {"input": "5\ngrape\ngrape\ngraoe\ngrape\neparg", "output": "3\n"}, {"input": "5\ngrape\ngrape\ngraoe\ngrape\nepa...
code_stdio
[ { "content": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-...
[{"input": "5\n999999999 503514429 850382710 999999999 1620498919\n", "output": "4974396056\n"}, {"input": "5\n999999999 503514429 850382710 999999999 1246839866\n", "output": "4097222574\n"}, {"input": "5\n999999999 999999999 850382710 999999999 999999999\n", "output": "4850382706\n"}, {"input": "5\n999999999 50351442...
code_stdio
[ { "content": "Once when Gerald studied in the first year at school, his teacher gave the class the following homework. She offered the students a string consisting of n small Latin letters; the task was to learn the way the letters that the string contains are written. However, as Gerald is too lazy, he has no ...
[{"input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n99\n", "output": "1\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"}, {"input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "Recently, Petya learned about a new game \"Slay the Dragon\". As the name suggests, the player will have to fight with dragons. To defeat a dragon, you have to kill it and defend your castle. To do this, the player has a squad of $n$ heroes, the strength of the $i$-th hero is equal to $a_i$.\n\nAc...
[{"input": "4\n3 0 2 3\n5\n6 12\n2 22\n2 14\n1 7\n14 17\n", "output": "10\n16\n8\n1\n23\n"}, {"input": "4\n3 5 2 3\n5\n6 12\n2 22\n2 14\n1 7\n14 17\n", "output": "5\n11\n3\n0\n18\n"}, {"input": "4\n3 5 2 3\n5\n6 4\n2 22\n2 14\n2 14\n14 17\n", "output": "1\n11\n3\n3\n18\n"}, {"input": "4\n3 5 2 3\n5\n3 12\n2 15\n1 14\n1...
code_stdio
[ { "content": "You are given a special jigsaw puzzle consisting of $n\\cdot m$ identical pieces. Every piece has three tabs and one blank, as pictured below. $\\{3$ \n\nThe jigsaw puzzle is considered solved if the following conditions hold: The pieces are arranged into a grid with $n$ rows and $m$ columns. Fo...
[{"input": "3\n1 10\n001000 100000\n10 2\n", "output": "YES\nNO\nNO\n"}, {"input": "3\n1 10\n001000 100000\n16 2\n", "output": "YES\nNO\nNO\n"}, {"input": "3\n1 12\n110000 101110\n1 2\n", "output": "YES\nNO\nYES\n"}, {"input": "3\n1 15\n001000 100000\n16 2\n", "output": "YES\nNO\nNO\n"}, {"input": "3\n1 12\n110000 1011...
code_stdio
[ { "content": "You have a given picture with size $w \\times h$. Determine if the given picture has a single \"+\" shape or not. A \"+\" shape is described below:\n\n A \"+\" shape has one center nonempty cell. There should be some (at least one) consecutive non-empty cells in each direction (left, right, up, ...
[{"input": "10 10\n..........\n..........\n....*.....\n....*.....\n.*******..\n....*.....\n....*.....\n..........\n....*.....\n..........\n", "output": "NO\n"}, {"input": "10 10\n..........\n..........\n....*.....\n....*.....\n.*******..\n....*.....\n....*.....\n..........\n....**....\n..........\n", "output": "NO\n"},...
code_stdio
[ { "content": "You are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters.\n\nOur objective is to make all these three strings equal. For that, you can repeatedly perform the following operation:\n\n* Operation: Choose one of the strings A, B and C, and ...
[{"input": "9\ncjfferent\ndifferent\ntnereffid", "output": "10\n"}, {"input": "9\ntneredfic\nciffeernt\ndifferent", "output": "11\n"}, {"input": "9\ntnedergia\ncifreefnt\ndifsnfeet", "output": "14\n"}, {"input": "9\ntnedergib\nbifrfegnt\ntcdfmtfhe", "output": "16\n"}, {"input": "9\ntnedeqgib\nbifrfegnt\ngcdfmtfte", "ou...
code_stdio
[ { "content": "Given a string, determine if it's a valid identifier.\n\n## Here is the syntax for valid identifiers:\n* Each identifier must have at least one character.\n* The first character must be picked from: alpha, underscore, or dollar sign. The first character cannot be a digit.\n* The rest of the charac...
[{"input": "\"1ok0okay\"", "output": "[false]", "fn_name": "is_valid"}, {"input": "\"okay_ok1\"", "output": "[true]", "fn_name": "is_valid"}, {"input": "\"myIdentf\"", "output": "[true]", "fn_name": "is_valid"}, {"input": "\"str-str\"", "output": "[false]", "fn_name": "is_valid"}, {"input": "\"str_STR\"", "output": "[t...
code_functional
[ { "content": "Write\n```python\nfunction repeating_fractions(numerator, denominator)\n```\nthat given two numbers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part has repeated digits, replace those digits with a single digit in parentheses. \...
[{"input": "18018018\n80000000000", "output": "[\"0.(0)(2)5(2)5(2)5\"]", "fn_name": "repeating_fractions"}, {"input": "1554\n70", "output": "[\"22.2\"]", "fn_name": "repeating_fractions"}, {"input": "1\n3", "output": "[\"0.(3)\"]", "fn_name": "repeating_fractions"}, {"input": "0\n1", "output": "[\"0.0\"]", "fn_name": "...
code_functional
[ { "content": "A traveler is planning a water hike along the river. He noted the suitable rest points for the night and wrote out their distances from the starting point. Each of these locations is further characterized by its picturesqueness, so for the i-th rest point the distance from the start equals xi, and...
[{"input": "19 2\n1 73\n2 96\n3 24\n5 96\n11 13\n14 96\n16 31\n17 60\n34 69\n39 41\n60 40\n61 96\n66 7\n67 56\n70 28\n73 12\n74 81\n78 77\n95 99\n", "output": "2 3 4 6 7 8 11 12 14 15 17 18 19\n"}, {"input": "20 8\n2 37\n9 28\n13 63\n14 85\n27 27\n29 90\n34 96\n36 60\n41 14\n45 25\n46 95\n48 59\n53 12\n55 69\n61 11\n76...
code_stdio
[ { "content": "It is a simplified version of problem F2. The difference between them is the constraints (F1: $k \\le 2$, F2: $k \\le 10$).\n\nYou are given an integer $n$. Find the minimum integer $x$ such that $x \\ge n$ and the number $x$ is $k$-beautiful.\n\nA number is called $k$-beautiful if its decimal rep...
[{"input": "4\n1 1\n221 2\n177890 2\n998244353 1\n", "output": "1\n221\n181111\n999999999\n"}, {"input": "4\n1 1\n221 2\n177890 1\n998244353 1\n", "output": "1\n221\n222222\n999999999\n"}, {"input": "4\n1 1\n221 2\n108810 1\n998244353 1\n", "output": "1\n221\n111111\n999999999\n"}, {"input": "4\n2 1\n221 2\n177890 2\n9...
code_stdio
[ { "content": "You are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types.\n\n* `0 u v`: Add an edge (u, v).\n* `1 u v`: Print 1 if u and v are in the same connected component, 0 otherwise.\n\nConstraints\n\n* 1 \\leq N \\leq 200,000\n* 1 \\leq Q \\leq 200,000\n* 0 \\...
[{"input": "4 7\n0 0 1\n-1 1 1\n-1 2 3\n1 0 1\n1 2 2\n-1 0 3\n-1 1 1", "output": "1\n0\n1\n1\n0\n1\n"}, {"input": "4 7\n0 0 1\n-1 2 1\n-1 2 3\n1 0 1\n1 2 2\n-1 0 3\n-1 1 1", "output": "0\n0\n1\n1\n0\n1\n"}, {"input": "9 7\n1 1 1\n-1 0 1\n-1 2 3\n1 0 2\n0 0 4\n-1 0 1\n2 1 3", "output": "1\n0\n0\n0\n0\n0\n"}, {"input": "...
code_stdio
[ { "content": "There are n heaps of stone. The i-th heap has h_i stones. You want to change the number of stones in the heap by performing the following process once: \n\n * You go through the heaps from the 3-rd heap to the n-th heap, in this order. \n * Let i be the number of the current heap. \n * You can ...
[{"input": "4\n4\n1 0 18 100\n4\n100 000 100 1\n5\n10 2 1 1 3\n6\n1 4 4 3 5 24\n", "output": "13\n1\n1\n3\n"}, {"input": "4\n4\n1 0 18 100\n4\n100 000 100 1\n5\n10 2 1 1 2\n6\n2 4 4 3 5 24\n", "output": "13\n1\n1\n4\n"}, {"input": "4\n4\n0 0 18 100\n4\n100 000 100 1\n5\n10 2 1 1 2\n6\n2 4 4 3 5 24\n", "output": "12\n1\...
code_stdio
[ { "content": "Your task is to write function which takes string and list of delimiters as an input and returns list of strings/characters after splitting given string.\n\nExample:\n```python\nmultiple_split('Hi, how are you?', [' ']) => ['Hi,', 'how', 'are', 'you?']\nmultiple_split('1+2-3', ['+', '-']) => ['1',...
[{"input": "\"Solve_this|kata-very\\\\quickly!\"\n[\"!\", \"|\", \"\\\\\", \"_\", \"-\"]", "output": "[[\"Solve\", \"this\", \"kata\", \"very\", \"quickly\"]]", "fn_name": "multiple_split"}, {"input": "\"((1+2))*(6-3)^9\"\n[\"+\", \"-\", \"(\", \")\", \"^\", \"*\"]", "output": "[[\"1\", \"2\", \"6\", \"3\", \"9\"]]", "...
code_functional
[ { "content": "Example\n\nInput\n\n3 2\nR1\n\n\nOutput\n\n3 1 2\n4 5 6\n7 8 9\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your complete solution in a single ```python code block.", "role": "user" } ]
[{"input": "73 2\nR2", "output": "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73\n146 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": "There are N islands and M bridges.\nThe i-th bridge connects the A_i-th and B_i-th islands bidirectionally.\nInitially, we can travel between any two islands using some of these bridges.\nHowever, the results of a survey show that these bridges will all collapse because of aging, in the order from...
[{"input": "29 45\n1 3\n2 3\n2 14\n2 19\n2 29\n3 26\n4 5\n4 6\n4 13\n4 17\n5 10\n5 19\n5 24\n6 18\n6 19\n6 24\n6 25\n6 28\n6 29\n8 9\n9 18\n9 25\n10 29\n11 16\n11 22\n12 14\n12 15\n12 26\n12 29\n13 14\n14 20\n14 27\n14 29\n15 16\n15 22\n15 25\n15 29\n16 29\n17 27\n19 26\n20 29\n24 26\n15 23\n1 21\n7 28\n", "output": "5...
code_stdio
[ { "content": "Niwango-kun is an employee of Dwango Co., Ltd.\nOne day, he is asked to generate a thumbnail from a video a user submitted.\nTo generate a thumbnail, he needs to select a frame of the video according to the following procedure:\n\n* Get an integer N and N integers a_0, a_1, ..., a_{N-1} as inputs....
[{"input": "4\n-1 13 12 2", "output": "3\n"}, {"input": "4\n-1 19 12 6", "output": "2\n"}, {"input": "4\n0 10 12 2", "output": "1\n"}, {"input": "4\n0 20 12 2", "output": "2\n"}, {"input": "4\n0 20 12 1", "output": "2\n"}, {"input": "4\n0 13 12 2", "output": "3\n"}, {"input": "4\n0 19 12 2", "output": "2\n"}, {"input":...
code_stdio
[ { "content": "Mike decided to teach programming to children in an elementary school. He knows that it is not an easy task to interest children in that age to code. That is why he decided to give each child two sweets.\n\nMike has $n$ sweets with sizes $a_1, a_2, \\ldots, a_n$. All his sweets have different size...
[{"input": "20\n43 48 38 34 23 18 8 22 12 7 47 1 13 20 3 15 49 6 10 26\n", "output": "5\n"}, {"input": "20\n43 48 38 34 23 18 8 22 12 7 47 1 13 20 3 15 49 6 10 26\n", "output": "5\n"}, {"input": "20\n43 48 38 34 41 18 8 22 12 7 47 1 13 20 3 15 49 6 10 26\n", "output": "6\n"}, {"input": "20\n43 48 38 34 23 18 8 22 12 7 ...
code_stdio
[ { "content": "The hero of the Cut the Rope game is a little monster named Om Nom. He loves candies. And what a coincidence! He also is the hero of today's problem. [Image] \n\nOne day, Om Nom visited his friend Evan. Evan has n candies of two types (fruit drops and caramel drops), the i-th candy hangs at the he...
[{"input": "10 2\n0 2 3\n1 5 2\n0 7 3\n1 15 2\n0 14 3\n1 19 1\n1 5 3\n0 2 2\n0 10 2\n0 10 3\n", "output": "9\n"}, {"input": "10 2\n0 2 3\n1 5 2\n0 7 3\n1 15 2\n0 14 3\n1 19 1\n1 5 3\n0 2 2\n0 10 2\n0 10 3\n", "output": "9"}, {"input": "10 2\n0 2 3\n1 5 2\n0 7 3\n1 15 2\n0 3 3\n1 19 1\n1 5 3\n0 2 2\n0 10 2\n0 10 3\n", "...
code_stdio
[ { "content": "Example\n\nInput\n\n2\n1 2\n\n\nOutput\n\n2\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your complete solution in a single ```python code block.", "role": "user" } ]
[{"input": "2\n-1 -12", "output": "12\n"}, {"input": "2\n-1 12", "output": "-1\n"}, {"input": "2\n-1 24", "output": "-1\n"}, {"input": "2\n-2 24", "output": "-1\n"}, {"input": "2\n-2 22", "output": "-1\n"}, {"input": "2\n-2 -5", "output": "-1\n"}, {"input": "2\n10 16", "output": "-1\n"}, {"input": "2\n2 17", "output": ...
code_stdio
[ { "content": "A chessboard n × m in size is given. During the zero minute we repaint all the black squares to the 0 color. During the i-th minute we repaint to the i color the initially black squares that have exactly four corner-adjacent squares painted i - 1 (all such squares are repainted simultaneously). Th...
[{"input": "5000 5000\n1000000000\n", "output": "0\n"}, {"input": "2085 5000\n1000000000\n", "output": "0\n"}, {"input": "3762 3914\n1073\n", "output": "3386\n"}, {"input": "4583 2774\n1206\n", "output": "2535\n"}, {"input": "3432 4788\n1203\n", "output": "3410\n"}, {"input": "4643 3755\n1381\n", "output": "2876\n"}, {...
code_stdio
[ { "content": "Takahashi has a tower which is divided into N layers. Initially, all the layers are uncolored. Takahashi is going to paint some of the layers in red, green or blue to make a beautiful tower. He defines the beauty of the tower as follows:\n\n* The beauty of the tower is the sum of the scores of the...
[{"input": "121980 33447 90629 11295524182", "output": "643972230\n"}, {"input": "111605 33447 77758 2284871002", "output": "762328834\n"}, {"input": "111605 33447 14069 2284871002", "output": "815838636\n"}, {"input": "42470 60074 125620 6171829514", "output": "334199188\n"}, {"input": "111605 33447 27166 2284871002",...
code_stdio
[ { "content": "Polycarp likes numbers that are divisible by 3.\n\nHe has a huge number $s$. Polycarp wants to cut from it the maximum number of numbers that are divisible by $3$. To do this, he makes an arbitrary number of vertical cuts between pairs of adjacent digits. As a result, after $m$ such cuts, there wi...
[{"input": "1000000000000000000000000000000000\n", "output": "33\n"}, {"input": "1000010000000000000000000000000000\n", "output": "32\n"}, {"input": "1000010000000001000000000000000000\n", "output": "31\n"}, {"input": "1000000001000001000010000000000000\n", "output": "30\n"}, {"input": "10000000010000001000100000000010...
code_stdio
[ { "content": "Vasya the Great Magician and Conjurer loves all kinds of miracles and wizardry. In one wave of a magic wand he can turn an object into something else. But, as you all know, there is no better magic in the Universe than the magic of numbers. That's why Vasya adores math and spends a lot of time tur...
[{"input": "100 -4900 100\n", "output": "1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 1...
code_stdio
[ { "content": "A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.\n\nWrite a program which reads a list of N integers and prints the number of prime numbers in the list.\n\nConstraints\n\n1 ≤ N ≤ 1...
[{"input": "11\n13\n20\n9\n10\n11\n13\n33\n14\n16\n12\n17", "output": "4\n"}, {"input": "11\n25\n20\n9\n10\n11\n13\n33\n14\n16\n12\n17", "output": "3\n"}, {"input": "11\n7\n10\n9\n10\n11\n13\n17\n14\n15\n16\n17", "output": "5\n"}, {"input": "11\n13\n20\n9\n10\n11\n13\n17\n14\n15\n8\n17", "output": "5\n"}, {"input": "11...
code_stdio
[ { "content": "Polycarp likes arithmetic progressions. A sequence $[a_1, a_2, \\dots, a_n]$ is called an arithmetic progression if for each $i$ ($1 \\le i < n$) the value $a_{i+1} - a_i$ is the same. For example, the sequences $[42]$, $[5, 5, 5]$, $[2, 11, 20, 29]$ and $[3, 2, 1, 0]$ are arithmetic progressions,...
[{"input": "4\n1 1000000000 1000000000 1000000000\n", "output": "-1\n"}, {"input": "4\n1 1000000000 1000000000 1000000000\n", "output": "-1\n"}, {"input": "4\n1 1000000000 1010000000 1000000000\n", "output": "-1\n"}, {"input": "4\n0 1000000000 1010000000 1000000000\n", "output": "-1\n"}, {"input": "4\n0 1000000010 1010...
code_stdio
[ { "content": "Gennady owns a small hotel in the countryside where he lives a peaceful life. He loves to take long walks, watch sunsets and play cards with tourists staying in his hotel. His favorite game is called \"Mau-Mau\".\n\nTo play Mau-Mau, you need a pack of $52$ cards. Each card has a suit (Diamonds — D...
[{"input": "AS\n2H 4C TH JH AD\n", "output": "YES\n"}, {"input": "4D\nAS AC AD AH 5H\n", "output": "YES\n"}, {"input": "KH\n3C QD 9S KS 8D\n", "output": "YES\n"}, {"input": "4H\nJH QC 5H 9H KD\n", "output": "YES\n"}, {"input": "QC\nQD KS AH 7S 2S\n", "output": "YES\n"}, {"input": "7H\n4H 6D AC KH 8H\n", "output": "YES\...
code_stdio
[ { "content": "You have an integer variable x.\nInitially, x=0.\nSome person gave you a string S of length N, and using the string you performed the following operation N times.\nIn the i-th operation, you incremented the value of x by 1 if S_i=I, and decremented the value of x by 1 if S_i=D.\nFind the maximum v...
[{"input": "7\nDDIDDII\n", "output": "0\n"}, {"input": "7\nIIDDIDD", "output": "2\n"}, {"input": "7\nDIDDIID", "output": "0\n"}, {"input": "7\nIIIDDDD", "output": "3\n"}, {"input": "7\nDIIDDID", "output": "1\n"}, {"input": "7\nDIIDIDD", "output": "1\n"}, {"input": "7\nDDDIDII", "output": "0\n"}, {"input": "7\nIIDDDID",...
code_stdio
[ { "content": "Alice and Bob play 5-in-a-row game. They have a playing field of size 10 × 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts.\n\nIn current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empt...
[{"input": "XX.XX.....\n.....OOOO.\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n", "output": "YES\n"}, {"input": "XO........\n.XO.......\n..XO......\n....O.....\n....X.....\n..........\n..........\n..........\n..........\n..........\n", "output": "YES\n"}, {"input": "...
code_stdio
[ { "content": "Your friend won't stop texting his girlfriend. It's all he does. All day. Seriously. The texts are so mushy too! The whole situation just makes you feel ill.\nBeing the wonderful friend that you are, you hatch an evil plot. While he's sleeping, you take his phone and change the autocorrect opti...
[{"input": "\"You u youville utube you youyouyou uuu raiyou united youuuu u you\"", "output": "[\"your sister your sister youville utube your sister youyouyou uuu raiyou united your sister your sister your sister\"]", "fn_name": "autocorrect"}, {"input": "\"I want to film the bayou with you and put it on youtube\"", "o...
code_functional
[ { "content": "prison\n\nThere are an infinite number of prisoners. Initially, the prisoners are numbered 0, 1, 2, ....\n\nDo the following N times:\n\n* Release the 0th prisoner and execute the k, 2k, 3k, ... th prisoners.\n* Then renumber the remaining prisoners. At this time, the prisoners with the smallest o...
[{"input": "41 2", "output": "1099511627775\n"}, {"input": "35 2", "output": "17179869183\n"}, {"input": "34 2", "output": "8589934591\n"}, {"input": "56 3", "output": "7854933626\n"}, {"input": "29 2", "output": "268435455\n"}, {"input": "26 2", "output": "33554431\n"}, {"input": "25 2", "output": "16777215\n"}, {"inp...
code_stdio
[ { "content": "# Task\n\n**_Given_** an *array/list [] of n integers* , *find maximum triplet sum in the array* **_Without duplications_** .\n___\n\n# Notes :\n\n* **_Array/list_** size is *at least 3* .\n\n* **_Array/list_** numbers could be a *mixture of positives , negatives and zeros* .\n\n* **_Repetition_...
[{"input": "[-13, -50, 57, 13, 67, -13, 57, 108, 67]", "output": "[232]", "fn_name": "max_tri_sum"}, {"input": "[-7, 12, -7, 29, -5, 0, -7, 0, 0, 29]", "output": "[41]", "fn_name": "max_tri_sum"}, {"input": "[-14, -12, -7, -42, -809, -14, -12]", "output": "[-33]", "fn_name": "max_tri_sum"}, {"input": "[2, 1, 8, 0, 6, 4...
code_functional
[ { "content": "You might have remembered Theatre square from the problem 1A. Now it's finally getting repaved.\n\nThe square still has a rectangular shape of $n \\times m$ meters. However, the picture is about to get more complicated now. Let $a_{i,j}$ be the $j$-th square in the $i$-th row of the pavement.\n\nY...
[{"input": "1\n9 9 9 9\n.........\n.........\n.........\n.........\n.........\n.........\n.........\n.........\n.........\n", "output": "405\n"}, {"input": "1\n9 9 9 9\n.........\n.........\n.........\n.........\n.........\n.........\n.........\n.........\n.........\n", "output": "405\n"}, {"input": "4\n1 1 10 1\n.\n1 ...
code_stdio
[ { "content": "You are given an integer $n$. In one move, you can either multiply $n$ by two or divide $n$ by $6$ (if it is divisible by $6$ without the remainder).\n\nYour task is to find the minimum number of moves needed to obtain $1$ from $n$ or determine if it's impossible to do that.\n\nYou have to answer ...
[{"input": "7\n2\n2\n2\n12\n45568\n15116544\n387420489\n", "output": "-1\n-1\n-1\n-1\n-1\n12\n36\n"}, {"input": "7\n2\n2\n2\n17\n45568\n15116544\n387420489\n", "output": "-1\n-1\n-1\n-1\n-1\n12\n36\n"}, {"input": "7\n5\n2\n4\n17\n60902\n15116544\n387420489\n", "output": "-1\n-1\n-1\n-1\n-1\n12\n36\n"}, {"input": "7\n1\...
code_stdio
[ { "content": "There are two buttons, one of size A and one of size B.\nWhen you press a button of size X, you get X coins and the size of that button decreases by 1.\nYou will press a button twice. Here, you can press the same button twice, or press both buttons once.\nAt most how many coins can you get?\n\n---...
[{"input": "-134 -12", "output": "-25\n"}, {"input": "-134 -8", "output": "-17\n"}, {"input": "-13 -10", "output": "-21\n"}, {"input": "100 100", "output": "200\n"}, {"input": "111 111", "output": "222\n"}, {"input": "101 101", "output": "202\n"}, {"input": "-10 -10", "output": "-20\n"}, {"input": "110 110", "output": ...
code_stdio
[ { "content": "Create a function `isAlt()` that accepts a string as an argument and validates whether the vowels (a, e, i, o, u) and consonants are in alternate order.\n\n```python\nis_alt(\"amazon\")\n// true\nis_alt(\"apple\")\n// false\nis_alt(\"banana\")\n// true\n```\n\nArguments consist of only lowercase l...
[{"input": "\"orange\"", "output": "[false]", "fn_name": "is_alt"}, {"input": "\"helipad\"", "output": "[true]", "fn_name": "is_alt"}, {"input": "\"amazon\"", "output": "[true]", "fn_name": "is_alt"}, {"input": "\"apple\"", "output": "[false]", "fn_name": "is_alt"}, {"input": "\"banana\"", "output": "[true]", "fn_name"...
code_functional
[ { "content": "There is a cube which consists of n × n × n small cubes. Small cubes have marks on their surfaces. An example where n = 4 is shown in the following figure.\n\n\n<image>\n\n\nThen, as shown in the figure above (right), make a hole that penetrates horizontally or vertically from the marked surface t...
[{"input": "12 3\nxy 4 3\nxz 1 2\nyz 2 3\n7 5\nxy 1 1\nxy 3 3\nxz 3 2\nyz 2 1\nyz 3 3\n0 0", "output": "1692\n310\n"}, {"input": "12 3\nxy 4 3\nxz 1 2\nyz 2 3\n7 5\nxy 1 1\nyx 3 3\nxz 3 2\nyz 2 1\nyz 3 3\n0 0", "output": "1692\n315\n"}, {"input": "14 3\nxy 4 3\nxz 1 2\nyz 2 3\n4 5\nxy 1 1\nxy 3 3\nxz 3 2\nyz 2 1\nyz 3 ...
code_stdio
[ { "content": "Constraints\n\n* 1 ≤ |V| ≤ 1000\n* 0 ≤ |E| ≤ 2000\n* -10000 ≤ di ≤ 10000\n* There are no parallel edges\n* There are no self-loops\n\nInput\n\nAn edge-weighted graph G (V, E) and the source r.\n\n\n|V| |E| r\ns0 t0 d0\ns1 t1 d1\n:\ns|E|-1 t|E|-1 d|E|-1\n\n\n|V| is the number of vertices and |E| is...
[{"input": "42 0 1\n2 -1 3\n0 5 55\n1 0 -2\n-2 0 1\n2 4 -1", "output": "INF\n0\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\n"}, {"input": "38 0 1\n2 -2 3\n0 6 55\n1...
code_stdio
[ { "content": "As Valeric and Valerko were watching one of the last Euro Championship games in a sports bar, they broke a mug. Of course, the guys paid for it but the barman said that he will let them watch football in his bar only if they help his son complete a programming task. The task goes like that.\n\nLet...
[{"input": "5\n1000000000 1000000000\n1000000000 1000000000\n1000000000 1000000000\n1000000000 1000000000\n294967296 294967296\n", "output": "1\n"}, {"input": "5\n1000000000 1000000000\n1000000000 1000000000\n1000100000 1000000000\n1000000000 1000000000\n294967296 294967296\n", "output": "2\n"}, {"input": "5\n100000000...
code_stdio
[ { "content": "You are given a sequence $a$, initially consisting of $n$ integers.\n\nYou want to transform this sequence so that all elements in it are equal (i. e. it contains several occurrences of the same element).\n\nTo achieve this, you choose some integer $x$ that occurs at least once in $a$, and then pe...
[{"input": "5\n3\n1 1 1\n5\n1 2 3 4 5\n5\n1 2 3 2 1\n7\n1 2 3 1 2 3 1\n11\n2 2 1 2 3 2 1 2 3 1 2\n", "output": "\n0\n1\n1\n2\n3\n"}, {"input": "5\n3\n1 1 1\n5\n1 2 3 4 5\n5\n1 2 3 2 1\n7\n1 2 3 1 2 3 1\n11\n2 2 1 2 3 2 1 2 3 1 2\n", "output": "0\n1\n1\n2\n3\n"}, {"input": "5\n3\n1 1 1\n5\n1 2 3 4 5\n5\n1 2 3 2 1\n7\n1 ...
code_stdio
[ { "content": "B: Hokkaido University Hard\n\nNote\n\nPlease note that the question settings are the same as question A, except for the constraints.\n\nstory\n\nHomura-chan, who passed Hokkaido University and is excited about the beginning of a new life. But in front of her, a huge campus awaits ...\n\n\"Eh ... ...
[{"input": "3 3\nB.B\nB..\n.BB", "output": "4\n"}, {"input": "2 3\nB.B\nB..\n.BB", "output": "3\n"}, {"input": "1 3\nB-B\n..B\n.BA", "output": "2\n"}, {"input": "1 1\nB-B\n..B\n.BA", "output": "0\n"}, {"input": "1 3\nBB.\nB..\n.AA", "output": "1\n"}, {"input": "3 3\nB.B\nB..\nBB.", "output": "4\n"}, {"input": "3 3\nB.B...
code_stdio
[ { "content": "Implement `String#whitespace?(str)` (Ruby), `String.prototype.whitespace(str)` (JavaScript), `String::whitespace(str)` (CoffeeScript), or `whitespace(str)` (Python), which should return `true/True` if given object consists exclusively of zero or more whitespace characters, `false/False` otherwise....
[{"input": "\"\\t \\n\\r\\n \"", "output": "[true]", "fn_name": "whitespace"}, {"input": "\"\\n\\r\\n\\r 3\"", "output": "[false]", "fn_name": "whitespace"}, {"input": "\"\\n\\r\\n\\r \"", "output": "[true]", "fn_name": "whitespace"}, {"input": "\"\\n\\r\\n\\r\"", "output": "[true]", "fn_name": "whitespace"}, {"input"...
code_functional
[ { "content": "Takahashi is solving quizzes. He has easily solved all but the last one.\nThe last quiz has three choices: 1, 2, and 3.\nWith his supernatural power, Takahashi has found out that the choices A and B are both wrong.\nPrint the correct choice for this problem.\n\n-----Constraints-----\n - Each of th...
[{"input": "3\n001", "output": "2\n"}, {"input": "3\n001", "output": "2\n"}, {"input": "3\n1\n", "output": "2\n"}, {"input": "1\n2\n", "output": "3\n"}, {"input": "1\n3\n", "output": "2\n"}, {"input": "3\n2\n", "output": "1\n"}, {"input": "2\n1\n", "output": "3\n"}, {"input": "2\n3\n", "output": "1\n"}, {"input": "3\n2...
code_stdio
[ { "content": "You are given an array $a[0 \\ldots n-1]$ of length $n$ which consists of non-negative integers. Note that array indices start from zero.\n\nAn array is called good if the parity of each index matches the parity of the element at that index. More formally, an array is good if for all $i$ ($0 \\le ...
[{"input": "4\n4\n6 4 7 6\n3\n3 2 6\n1\n7\n3\n4 14 2 1 18 3 0\n", "output": "-1\n1\n-1\n-1\n"}, {"input": "4\n4\n3 2 0 6\n3\n6 4 4\n1\n7\n7\n7 7 2 1 18 1 2\n", "output": "-1\n-1\n-1\n-1\n"}, {"input": "4\n4\n3 2 7 8\n3\n6 2 8\n1\n7\n7\n6 13 2 1 19 1 1\n", "output": "2\n-1\n-1\n-1\n"}, {"input": "4\n4\n3 2 7 6\n3\n6 2 6...
code_stdio
[ { "content": "The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen -, and the other characters are digits from 0 through 9.\nYou are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.\n\n-----Constraints-----\n - 1≤A,B≤5\n - |S|=A...
[{"input": "3 4\n269-6650\n", "output": "Yes\n"}, {"input": "6 4\n269-6650", "output": "No\n"}, {"input": "6 8\n269-6650", "output": "No\n"}, {"input": "6 1\n269-6650", "output": "No\n"}, {"input": "6 2\n269-6650", "output": "No\n"}, {"input": "6 2\n0566-962", "output": "No\n"}, {"input": "6 3\n0566-962", "output": "No...
code_stdio
[ { "content": "CQXYM found a rectangle A of size n × m. There are n rows and m columns of blocks. Each block of the rectangle is an obsidian block or empty. CQXYM can change an obsidian block to an empty block or an empty block to an obsidian block in one operation.\n\nA rectangle M size of a × b is called a por...
[{"input": "1\n9 9\n001010001\n101110100\n000010011\n100000001\n101010101\n110001111\n000001111\n110100000\n000110000\n", "output": "5\n"}, {"input": "1\n8 9\n101110001\n101110100\n000010001\n001000001\n001011101\n110001111\n000001111\n110100010\n010110000\n", "output": "4\n"}, {"input": "1\n8 9\n101110001\n101110100\n...
code_stdio
[ { "content": "Note that girls in Arpa’s land are really attractive.\n\nArpa loves overnight parties. In the middle of one of these parties Mehrdad suddenly appeared. He saw n pairs of friends sitting around a table. i-th pair consisted of a boy, sitting on the a_{i}-th chair, and his girlfriend, sitting on the ...
[{"input": "26\n8 10\n52 21\n2 33\n18 34\n30 51\n5 19\n22 32\n36 28\n42 16\n13 49\n11 17\n31 39\n43 37\n50 15\n29 20\n35 46\n47 23\n3 1\n44 7\n9 27\n6 48\n40 24\n26 14\n45 4\n12 25\n41 38\n", "output": "2 1\n1 2\n2 1\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n2 1\n1 2\n1 2\n1 2\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n1 2\n2 1\n2 ...
code_stdio
[ { "content": "Mash 2 arrays together so that the returning array has alternating elements of the 2 arrays . Both arrays will always be the same length.\n\neg. [1,2,3] + ['a','b','c'] = [1, 'a', 2, 'b', 3, 'c']\n\nWrite Python code to solve this problem. Define a top-level function named `array_mash` that takes...
[{"input": "[\"h\", \"l\", \"o\", \"o\", \"l\"]\n[\"e\", \"l\", \"w\", \"r\", \"d\"]", "output": "[[\"h\", \"e\", \"l\", \"l\", \"o\", \"w\", \"o\", \"r\", \"l\", \"d\"]]", "fn_name": "array_mash"}, {"input": "[1, 8, \"hello\", \"dog\"]\n[\"fish\", \"2\", 9, 10]", "output": "[[1, \"fish\", 8, \"2\", \"hello\", 9, \"dog...
code_functional
[ { "content": "Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input.\n\nAfter that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. Yo...
[{"input": "10\nvzsxyuyy\n3\n1 0 3\nwwvutuxsuxywut\n2\n0 0\nsuzvsvutvvstuz\n3\n3 1 0\nstyuwsutv\n4\n6 3 0 1\nzsustytvzsyw\n6\n0 9 5 7 7 5\nsvwxwwwyxuvszx\n1\n0\nxuyyvuztxwuuvsxwz\n5\n5 7 0 0 7\nuxuztuwsxz\n5\n4 2 2 0 10\nxystzstwtzwsz\n2\n1 0\nuuzss\n1\n0\n", "output": "yzx\nxx\nuvz\nuvyw\nztwtvy\nz\nywzzx\nuxuzt\nyz\n...
code_stdio
[ { "content": "Just to remind, girls in Arpa's land are really nice.\n\nMehrdad wants to invite some Hoses to the palace for a dancing party. Each Hos has some weight wi and some beauty bi. Also each Hos may have some friends. Hoses are divided in some friendship groups. Two Hoses x and y are in the same friends...
[{"input": "10 5 100\n64 109 3 94 96 97 52 54 82 26\n796554 444893 214351 43810 684158 1060686 686198 339093 383018 699152\n6 8\n8 3\n3 9\n2 3\n10 3\n", "output": "1495706\n"}, {"input": "10 5 100\n48 73 57 46 95 19 171 73 94 24\n501216 675859 843572 565104 879875 828759 80776 766980 213551 492652\n1 2\n6 5\n7 6\n10 5\...
code_stdio
[ { "content": "You are a rebel leader and you are planning to start a revolution in your country. But the evil Government found out about your plans and set your punishment in the form of correctional labor.\n\nYou must paint a fence which consists of $10^{100}$ planks in two colors in the following way (suppose...
[{"input": "5\n1 1000000000 999999998\n1 1000000000 999999999\n1 1000000000 1000000000\n1000000000 1000000000 2\n1000000000 1000000000 1000000000\n", "output": "REBEL\nREBEL\nOBEY\nOBEY\nOBEY\n"}, {"input": "5\n1 1000000000 999999998\n1 1000000000 999999999\n1 1000000000 1000000000\n1000000000 1000000000 2\n1000000000 ...
code_stdio
[ { "content": "Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by IDs $1, 2, ... n$.\n\nConstraints\n\n* $1 \\leq n \\leq 100$\n\nInput\n\nIn the first line, an integer $...
[{"input": "4\n1 2 1 4\n2 -1 4\n0 -1\n4 1 0", "output": "1 0\n2 -1\n3 -1\n4 1\n"}, {"input": "4\n1 2 1 4\n2 0 4\n0 -1\n4 -1 0", "output": "1 0\n2 -1\n3 -1\n4 1\n"}, {"input": "4\n1 2 1 4\n3 0 4\n0 -1\n4 -1 0", "output": "1 0\n2 -1\n3 -1\n4 1\n"}, {"input": "4\n1 2 4 4\n2 0 4\n0 -1\n-1 0 1", "output": "1 0\n2 -1\n3 -1\n...
code_stdio
[ { "content": "The only difference between easy and hard versions is the length of the string. You can hack this problem only if you solve both problems.\n\nKirk has a binary string $s$ (a string which consists of zeroes and ones) of length $n$ and he is asking you to find a binary string $t$ of the same length ...
[{"input": "0111001100111011101000\n", "output": "0011001100001011101000\n"}, {"input": "0111001110111011101000\n", "output": "0011000010001011101000\n"}, {"input": "0111001110101011101000\n", "output": "0011000010101011101000\n"}, {"input": "0111011110101011101000\n", "output": "0001000010101011101000\n"}, {"input": "...
code_stdio
[ { "content": "A university student, Takahashi, has to take N examinations and pass all of them. Currently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.\n\nTakahashi thinks that he...
[{"input": "12\n757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604\n102338863 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212", "output": "5\n"}, {"input": "12\n757232153 372327760 440075441 15...
code_stdio