messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.\n\nLet's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters \"a\", \"e\", \"i\", \"o\", \"u\" are considered ... | [{"input": "7 3\nferwljzwakxedlgwl\noerwljzwakxedlgwl\nhyqombizhuhxedprb\netptjrizhuhxedprb\nurtuckar\ndkartmwramklcmi\nrurtuckar\nnurartmwramklcmi\niraziomsv\nsaziomsv\nbprapiqpayzurgij\nusyemayzurgij\nztstmeecvmkvuu\nquexlecvmkvuu\nrlhwecvmkvuu\nzecvmkvuu\niikymgbncljtub\nqiikymgbncljtub\nbcavhexqamyszgfya\nojexqamys... | code_stdio |
[
{
"content": "The 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 know, there will never be more than 250.\n\nHeidi recently got her hands on a... | [{"input": "18 16 20 4\n0 0\n0 1\n1 7\n1 7\n", "output": "18 16\n17 15\n18 16\n19 17\n"}, {"input": "18 16 20 4\n0 0\n0 1\n1 7\n1 6\n", "output": "18 16\n17 15\n18 16\n19 17\n"}, {"input": "18 8 20 4\n1 1\n0 1\n1 7\n1 7\n", "output": "19 9\n18 8\n19 9\n20 10\n"}, {"input": "18 5 20 4\n1 4\n0 11\n1 7\n1 7\n", "output": ... | code_stdio |
[
{
"content": "Notes\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 line. Two consequtive symbols (operand or operator) are separated by a space... | [{"input": "1 1 + 5 11 - *", "output": "-12\n"}, {"input": "0 0 + 6 21 - +", "output": "-15\n"}, {"input": "1 12 + 3 8 - *", "output": "-65\n"}, {"input": "1 0 + 6 21 - +", "output": "-14\n"}, {"input": "1 12 + 3 5 - *", "output": "-26\n"}, {"input": "2 0 + 6 21 - +", "output": "-13\n"}, {"input": "0 11 + 2 5 - *", "ou... | code_stdio |
[
{
"content": "Santa 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 its place, or on the place of another key, which is located exactly where the f... | [{"input": "dofbgdppdvmwjwtdyphhmqliydxyjfxoopxiscevowleccmhwybrxitvujkfliamvqinlrpytyaqdlbywccprukoisyaseibuqbfqjcabkieimsggsakpnqliwhehnemewhychqrfiuyaecoydnromrh\ndofbgdppdvmwjwtdyphhmqliydxyjfxoopxiscevowleccmhwybsxitvujkfliamvqinlrpytyaqdlbywccprukoisyaseibuqbfqjcabkieimsggsakpnqliwhehnemewhychqrfiuyaecoydnromrh\n... | code_stdio |
[
{
"content": "Petya 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 income amounted to a1 billion bourles, in 2002 — to a2 billion, ..., and in the... | [{"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 97 98 99 100\n", "output... | code_stdio |
[
{
"content": "Problem 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 playing the following games on her mobile phone. The mobile phone she has is ... | [{"input": "6\nZI?U -1\nLINFR 14\nKNGE -1\nLCL -1\n@S 2\nKFHD 15\nBSKA\nILIC\nPZRH\nEDLU\n1", "output": "0\n"}, {"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"}, {"input": "6\n[I?U -1\nRFNIL 14\nKNGE -1\nLCL -1\n@S 2\nKFHD 15\nBSKA\nILIC\nPZRH\nEDLU\n1", "out... | code_stdio |
[
{
"content": "You 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 receives a command, it starts moving towards the point $x_i$ with the speed of ... | [{"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"}, {"input": "8\n3\n1 5\n3 0\n6 4\n... | code_stdio |
[
{
"content": "Misha 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 is extremely expensive to host such an olympiad, so after the first $n$ olym... | [{"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 29 50 4 37 11\n123\n140\n... | code_stdio |
[
{
"content": "You 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 the index of its right end. Denote by $a[l,r]$ a segment of the sequence $a$ w... | [{"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"}, {"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"}, {"input": "4\n3\n6 6 12\n4\n18 6 6 6\n5\n1 1 1 1 1\n3\n12 6 6\n", "output": "2\n3\n1\n2\n"}, {"input": ... | code_stdio |
[
{
"content": "Snuke is giving cookies to his three goats.\nHe has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).\nYour task is to determine whether Snuke can give cookies to his three goats s... | [{"input": "-4 -10", "output": "Impossible\n"}, {"input": "-1 14", "output": "Impossible\n"}, {"input": "-2 28", "output": "Impossible\n"}, {"input": "-2 40", "output": "Impossible\n"}, {"input": "-1 -1", "output": "Impossible\n"}, {"input": "-2 -2", "output": "Impossible\n"}, {"input": "11 -1", "output": "Impossible\n... | code_stdio |
[
{
"content": "There are five people playing a game called \"Generosity\". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one player to some other player.\n\nYour task ... | [{"input": "100 100 100 100 100\n", "output": "100\n"}, {"input": "100 100 100 100 100\n", "output": "100\n"}, {"input": "180 100 100 100 100\n", "output": "116\n"}, {"input": "203 100 101 000 101\n", "output": "101\n"}, {"input": "100 000 100 100 100\n", "output": "80\n"}, {"input": "180 000 100 100 100\n", "output": ... | code_stdio |
[
{
"content": "Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that he has no ready creations, and decided to write a program for rectangles detection. According ... | [{"input": "-155221108 -190475340 -155221108 -819044368\n-155221108 -190475340 -155875856 -190475340\n-155875856 -190475340 -155875856 -819044368\n-155875856 -819044368 -155221108 -819044368\n", "output": "YES\n"}, {"input": "-985236057 -809433993 -985236057 -225363622\n-484344733 -225363622 -484344733 -225363622\n-985... | code_stdio |
[
{
"content": "Your task is to construct a building which will be a pile of n cubes.\nThe cube at the bottom will have a volume of n^3, the cube above \nwill have volume of (n-1)^3 and so on until the top which will have a volume of 1^3.\n\nYou are given the total volume m of the building.\nBeing given m can yo... | [{"input": "10252519345963644753025", "output": "[450010]", "fn_name": "find_nb"}, {"input": "102525193459636447530260", "output": "[-1]", "fn_name": "find_nb"}, {"input": "10252519345963644753026", "output": "[-1]", "fn_name": "find_nb"}, {"input": "1025292944081385001", "output": "[45001]", "fn_name": "find_nb"}, {"i... | code_functional |
[
{
"content": "1000000000000001 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 numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n - the dogs... | [{"input": "1000000000000001\n", "output": "gbdpxgrzxjm\n"}, {"input": "530000050000000\n", "output": "csoypdctwnh\n"}, {"input": "95678123450002\n", "output": "qpdjiixlxb\n"}, {"input": "1000000000\n", "output": "cfdgsxl\n"}, {"input": "1000000001\n", "output": "cfdgsxm\n"}, {"input": "321272416\n", "output": "aaaaaaj... | code_stdio |
[
{
"content": "Move 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 Python code to solve this problem. Define a top-level function named `move_ten` that takes the input arguments described... | [{"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": "Little 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), (2, y2), ..., (2n + 1, y2n + 1), with the i-th segment connecting the point... | [{"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 4 2 7 6 9 -1 1 0 4 0 4 ... | code_stdio |
[
{
"content": "As 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 subsequence. Help Heidi assess whether the given piece is true, but please be di... | [{"input": "sjvmovplbrnakthytvanvvbscgdcdkdkbgginnbiyczyrkywcuvbgolznifdyiilonvqblbywxzgjnntldeuhhlecubshirsdxugezholvufotprjovwqiitypvaghlcxlrajrtufmysbpegjfvdboewogamnunalynjvwiopqfhndupfqxfatbpklpzdsdmzwvtitvdxkefremodmlferuxyisxmvjydjthekokldjkwoiffmhlquulcbogdnnzqaisoxqpgztuzvbleiitrqbzljbbjzugwthffpsolefofaqrpkce... | code_stdio |
[
{
"content": "In 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 Flower 1, 2, …, N. Also, we will call the position that is p centimeters from the... | [{"input": "1 1000000000\n1000000000000000000 1000000000", "output": "1999999999000000000"}, {"input": "3 17\n22 15\n10 10\n17 10", "output": "70\n"}, {"input": "3 17\n22 19\n10 10\n17 10", "output": "77\n"}, {"input": "3 27\n22 19\n10 10\n1 10", "output": "110\n"}, {"input": "3 27\n22 35\n10 10\n1 10", "output": "120\... | code_stdio |
[
{
"content": "The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of interse... | [{"input": "10\n22290 75956\n-66905 -22602\n-88719 12654\n-191 -81032\n0 -26057\n-39609 0\n0 51194\n2648 88230\n90584 15544\n0 23060\n-29107 26878\n", "output": "NO\n"}, {"input": "10\n22290 75956\n-66905 -22602\n-88719 12654\n-191 -81032\n0 -26057\n-39609 0\n0 51194\n4903 88230\n90584 15544\n0 23060\n-29107 26878\n", ... | code_stdio |
[
{
"content": "C --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 structure. (Figure 1)\n\n* Each vertex has exactly one vertex called the paren... | [{"input": "((()[1]())[2]())[5](((()[2]())[6](()[3]()))[8]()(\n(()[4]())[3](((()[2]())[1]())[8](()[4]')))", "output": "(()[6]())[8](((()[4]())[7]())[16]())\n"}, {"input": "((()[8]())[2]())[5](((()[3]())[6](()[3]()))[2]())\n(()[4]())[2](((()[2]())[1]())[8](()[3]())(", "output": "(()[6]())[7](((()[5]())[7]())[10]())\n"},... | code_stdio |
[
{
"content": "The 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 simple pro- gram. You are given single integer N , and you must output zigzag pat... | [{"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 55 65 68 74 77 79\n 37 ... | code_stdio |
[
{
"content": "The 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) day, the price for one barrel of honey is going to is x_{i} kilos of raspber... | [{"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 67 23 58 57 83 46\n", "... | code_stdio |
[
{
"content": "In 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 uppercase that is:\n\n exactly 2 characters long\n\n OR\n\n before a ... | [{"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": "You 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 religion. There are only two religions in your world. One of the religions i... | [{"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"}, {"input": "4\n7 8\nAAPABAAA\nPPPPAAAA\nPPPPAAAA\nAQAAPPPP\nAPAPPAPP\nAAAAPPAP\nAAABPPAA\n6 5\nAA... | code_stdio |
[
{
"content": "There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of the i-th vessel is a_{i} liters. [Image] \n\nInitially, all the vessels are empty. In some vessels ... | [{"input": "50\n57 122 98 44 22 63 5 65 36 69 49 54 61 15 58 79 50 30 43 155 18 105 46 92 72 67 67 51 34 40 50 77 91 53 79 72 72 34 91 75 83 67 71 93 11 51 85 20 6 2\n20\n2 40\n1 14 102\n2 4\n2 15\n2 43\n1 29 532\n2 27\n2 47\n1 24 107\n1 20 720\n1 21 315\n2 20\n1 2 787\n1 27 909\n2 38\n1 32 445\n1 38 17\n1 26 450\n2 40... | code_stdio |
[
{
"content": "The 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-----\n - N is an integer between 1 and 200 (inclusive).\n\n-----Input-----\nInp... | [{"input": "105\n", "output": "1\n"}, {"input": "104\n", "output": "0\n"}, {"input": "134\n", "output": "1\n"}, {"input": "135\n", "output": "2\n"}, {"input": "164\n", "output": "2\n"}, {"input": "165\n", "output": "3\n"}, {"input": "188\n", "output": "3\n"}, {"input": "189\n", "output": "4\n"}, {"input": "194\n", "out... | code_stdio |
[
{
"content": "You 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 exclusive OR. Since it can be extremely large, compute the answer modulo 10^9+7.\n\nC... | [{"input": "1000000001000000000", "output": "999867657\n"}, {"input": "1100000001000000000", "output": "355035671\n"}, {"input": "1100000001000010000", "output": "391646023\n"}, {"input": "1100000001001010000", "output": "103347644\n"}, {"input": "1100000011001010000", "output": "194416284\n"}, {"input": "1100000001001... | code_stdio |
[
{
"content": "You 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 this subarray ($\\sum\\limits_{i=l}^{r} a_i = r - l + 1$).\n\nFor example, if ... | [{"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"}, {"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"}, {... | code_stdio |
[
{
"content": "You will be given a contest schedule for D days. For each d=1,2,\\ldots,D, calculate the satisfaction at the end of day d.\n\n\n\nInput\n\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\n\n\nD\nc_1 c_2 \\cdots c_{26}\ns_{1,1} s_{1,2} \... | [{"input": "5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 121\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 ... | code_stdio |
[
{
"content": "Chef has decided to arrange the free shuttle service for his employees. City of Bhiwani has a strange layout - all of its N shuttle boarding points are arranged in a circle, numbered from 1 to N in clockwise direction. Chef's restaurant is at boarding point number 1. There is a single ring road th... | [{"input": "3\n2\n181\n2", "output": "1\n180\n1\n"}, {"input": "3\n2\n132\n1", "output": "1\n40\n1\n"}, {"input": "3\n2\n166\n1", "output": "1\n82\n1\n"}, {"input": "3\n2\n1\n106", "output": "1\n1\n52\n"}, {"input": "3\n4\n1\n106", "output": "2\n1\n52\n"}, {"input": "3\n5\n1\n106", "output": "4\n1\n52\n"}, {"input": "3... | code_stdio |
[
{
"content": "Let's call the string beautiful if it does not contain a substring of length at least $2$, which is a palindrome. Recall that a palindrome is a string that reads the same way from the first character to the last and from the last character to the first. For example, the strings a, bab, acca, bcabc... | [{"input": "10 3\naaabababaa\n1 1\n2 10\n1 2\n", "output": "0\n6\n1\n"}, {"input": "10 3\naaabababaa\n1 1\n3 10\n1 2\n", "output": "0\n5\n1\n"}, {"input": "10 3\naaabababaa\n1 1\n2 10\n1 4\n", "output": "0\n6\n2\n"}, {"input": "10 3\naaabababaa\n1 1\n2 10\n1 8\n", "output": "0\n6\n5\n"}, {"input": "10 3\naaabababaa\n1 ... | code_stdio |
[
{
"content": "Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$.\n\nThere are three values about each exam: $s_i$ — the day, when questions for the $i$-th exam... | [{"input": "100 43\n76 77 1\n24 25 1\n2 3 1\n85 86 1\n49 50 1\n15 16 1\n30 31 1\n78 79 1\n54 55 1\n58 59 1\n17 18 1\n67 68 1\n21 22 1\n80 81 1\n35 36 1\n8 9 1\n83 84 1\n44 45 1\n62 63 1\n64 65 1\n72 73 1\n27 28 1\n56 57 1\n12 13 1\n40 41 1\n32 33 1\n52 53 1\n70 71 1\n97 98 1\n37 38 1\n87 88 1\n46 47 1\n89 90 1\n4 5 1\n... | code_stdio |
[
{
"content": "The only difference between the easy and hard versions are the locations you can teleport to.\n\nConsider the points $0,1,\\dots,n+1$ on the number line. There is a teleporter located on each of the points $1,2,\\dots,n$. At point $i$, you can do the following:\n\nMove left one unit: it costs $1$ ... | [{"input": "1\n100 123\n398 282 403 364 468 174 143 360 217 340 354 195 84 253 114 421 494 370 104 214 149 469 446 362 108 106 115 402 253 461 483 59 365 94 281 84 248 321 228 196 96 360 321 357 151 250 496 207 425 397 114 345 252 489 30 345 182 310 440 392 111 361 49 307 328 84 201 339 351 459 372 50 72 223 246 215 46... | code_stdio |
[
{
"content": "Since I got tired to write long problem statements, I decided to make this problem statement short. For given positive integer L, how many pairs of positive integers a, b (a ≤ b) such that LCM(a, b) = L are there? Here, LCM(a, b) stands for the least common multiple of a and b.\n\nConstraints\n\n*... | [{"input": "12\n7\n24\n0", "output": "8\n2\n11\n"}, {"input": "12\n11\n2\n0", "output": "8\n2\n2\n"}, {"input": "12\n15\n2\n0", "output": "8\n5\n2\n"}, {"input": "12\n11\n4\n0", "output": "8\n2\n3\n"}, {"input": "12\n15\n1\n0", "output": "8\n5\n1\n"}, {"input": "12\n16\n4\n0", "output": "8\n5\n3\n"}, {"input": "12\n11\... | code_stdio |
[
{
"content": "Min Element\n\nGiven the sequence a_1, a_2, .., a_N.\n\nFind the minimum number in this sequence.\n\nIf the minimum value is in more than one place, answer the one with the lowest number.\n\ninput\n\n\nN\na_1 a_2 ... a_N\n\n\noutput\n\nOutput the smallest i such that a_i is the minimum value in th... | [{"input": "6\n10 17 3 2 6 -1", "output": "6\n"}, {"input": "6\n3 33 0 2 10 -1", "output": "6\n"}, {"input": "6\n3 55 0 2 10 -1", "output": "6\n"}, {"input": "6\n3 55 0 4 10 -1", "output": "6\n"}, {"input": "6\n10 59 0 0 10 1", "output": "3\n"}, {"input": "6\n10 37 0 0 10 1", "output": "3\n"}, {"input": "6\n10 60 0 0 1... | code_stdio |
[
{
"content": "Soon after the Chunga-Changa island was discovered, it started to acquire some forms of civilization and even market economy. A new currency arose, colloquially called \"chizhik\". One has to pay in chizhiks to buy a coconut now.\n\nSasha and Masha are about to buy some coconuts which are sold at ... | [{"input": "500000000000000000 500000000000000000 1000000000000000000\n", "output": "1 500000000000000000\n"}, {"input": "500000000000000000 500000000000000000 1000000000000000000\n", "output": "1 500000000000000000\n"}, {"input": "350919308160677995 916982339945800203 1000000000000001000\n", "output": "1 8301766005420... | code_stdio |
[
{
"content": "Implement function which will return sum of roots of a quadratic equation rounded to 2 decimal places, if there are any possible roots, else return **None/null/nil/nothing**. If you use discriminant,when discriminant = 0, x1 = x2 = root => return sum of both roots. There will always be valid argum... | [{"input": "1\n-1.6666666666666667\n-26", "output": "[1.67]", "fn_name": "roots"}, {"input": "8\n47\n41", "output": "[-5.88]", "fn_name": "roots"}, {"input": "1\n-35\n-23", "output": "[35]", "fn_name": "roots"}, {"input": "3\n11\n6", "output": "[-3.67]", "fn_name": "roots"}, {"input": "7\n-2\n-5", "output": "[0.29]", "... | code_functional |
[
{
"content": "Vasya claims that he had a paper square. He cut it into two rectangular parts using one vertical or horizontal cut. Then Vasya informed you the dimensions of these two rectangular parts. You need to check whether Vasya originally had a square. In other words, check if it is possible to make a squa... | [{"input": "3\n2 3\n3 1\n3 2\n1 3\n3 3\n1 3\n", "output": "Yes\nYes\nNo\n"}, {"input": "3\n2 3\n3 1\n3 2\n1 3\n3 6\n1 3\n", "output": "Yes\nYes\nNo\n"}, {"input": "3\n2 3\n3 1\n3 2\n1 3\n3 6\n1 0\n", "output": "Yes\nYes\nNo\n"}, {"input": "3\n2 3\n3 1\n3 2\n1 3\n3 3\n1 3\n", "output": "Yes\nYes\nNo\n"}, {"input": "3\n2... | code_stdio |
[
{
"content": "You are given a sequence of a journey in London, UK. The sequence will contain bus **numbers** and TFL tube names as **strings** e.g.\n\n```python\n['Northern', 'Central', 243, 1, 'Victoria']\n```\nJourneys will always only contain a combination of tube names and bus numbers. Each tube journey cos... | [{"input": "[\"Northern\", \"Central\", \"Circle\"]", "output": "[\"\\u00a37.20\"]", "fn_name": "london_city_hacker"}, {"input": "[12, \"Central\", \"Circle\", 21]", "output": "[\"\\u00a37.80\"]", "fn_name": "london_city_hacker"}, {"input": "[\"Piccidilly\", 56, 93, 243]", "output": "[\"\\u00a35.40\"]", "fn_name": "lon... | code_functional |
[
{
"content": "In the advanced algorithm class, n2 students sit in n rows and n columns. One day, a professor who teaches this subject comes into the class, asks the shortest student in each row to lift up his left hand, and the tallest student in each column to lift up his right hand. What is the height of the ... | [{"input": "3\n1 2 5\n11 3 6\n12 5 9\n3\n1 11 3\n13 11 14\n4 8 6\n0", "output": "5\n11\n"}, {"input": "3\n2 1 3\n4 2 11\n7 0 4\n3\n1 4 12\n14 10 18\n4 8 10\n0", "output": "2\n10\n"}, {"input": "3\n1 2 10\n11 3 6\n12 9 15\n3\n1 11 3\n13 11 9\n7 8 1\n0", "output": "9\n9\n"}, {"input": "3\n2 1 3\n4 2 1\n7 -1 4\n3\n0 4 12\... | code_stdio |
[
{
"content": "You are given $n$ positive integers $a_1, \\ldots, a_n$, and an integer $k \\geq 2$. Count the number of pairs $i, j$ such that $1 \\leq i < j \\leq n$, and there exists an integer $x$ such that $a_i \\cdot a_j = x^k$.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $k$ ($2 \\... | [{"input": "100 3\n94 94 149 27 80 73 61 38 34 139 72 96 59 36 113 15 83 78 39 22 21 57 54 20 9 32 81 64 55 90 67 41 18 57 93 76 44 62 77 66 31 70 39 73 81 57 43 31 20 104 62 26 44 26 23 23 66 53 3 14 10 170 53 19 43 81 98 12 91 15 122 90 89 86 58 30 67 73 46 69 68 47 30 7 89 35 17 93 45 6 4 23 73 36 10 34 73 25 45 27\... | code_stdio |
[
{
"content": "You are given a regular polygon with $n$ vertices labeled from $1$ to $n$ in counter-clockwise order. The triangulation of a given polygon is a set of triangles such that each vertex of each triangle is a vertex of the initial polygon, there is no pair of triangles such that their intersection has... | [{"input": "500\n", "output": "41666498\n"}, {"input": "497\n", "output": "40920990\n"}, {"input": "494\n", "output": "40184428\n"}, {"input": "491\n", "output": "39456758\n"}, {"input": "488\n", "output": "38737926\n"}, {"input": "485\n", "output": "38027878\n"}, {"input": "482\n", "output": "37326560\n"}, {"input": "... | code_stdio |
[
{
"content": "A binary string is a string that consists of characters $0$ and $1$. A bi-table is a table that has exactly two rows of equal length, each being a binary string.\n\nLet $\\operatorname{MEX}$ of a bi-table be the smallest digit among $0$, $1$, or $2$ that does not occur in the bi-table. For example... | [{"input": "4\n7\n0001000\n1101100\n5\n01001\n10110\n2\n01\n01\n6\n010000\n011111\n", "output": "10\n10\n2\n10\n"}, {"input": "4\n7\n0101000\n1100100\n5\n01100\n10101\n2\n01\n01\n6\n000100\n111111\n", "output": "10\n8\n2\n10\n"}, {"input": "4\n7\n0001000\n1101100\n5\n01001\n10101\n2\n01\n01\n6\n010000\n001111\n", "outp... | code_stdio |
[
{
"content": "You're in ancient Greece and giving Philoctetes a hand in preparing a training exercise for Hercules! You've filled a pit with two different ferocious mythical creatures for Hercules to battle!\n\nThe formidable **\"Orthus\"** is a 2 headed dog with 1 tail. The mighty **\"Hydra\"** has 5 heads an... | [{"input": "5455\n54956", "output": "[\"No solutions\"]", "fn_name": "beasts"}, {"input": "25\n555", "output": "[\"No solutions\"]", "fn_name": "beasts"}, {"input": "54\n956", "output": "[\"No solutions\"]", "fn_name": "beasts"}, {"input": "12\n25", "output": "[\"No solutions\"]", "fn_name": "beasts"}, {"input": "-1\n-... | code_functional |
[
{
"content": "A tutorial for this problem is now available on our blog. Click here to read it. \n\nYou are asked to calculate factorials of some small positive integers.\n\n------ Input ------ \n\nAn integer t, 1≤t≤100, denoting the number of testcases, followed by t lines, each containing a single integer n, ... | [{"input": "4\n1\n2\n4\n57", "output": "1\n2\n24\n40526919504877216755680601905432322134980384796226602145184481280000000000000\n"}, {"input": "4\n5\n3\n10\n29", "output": "120\n6\n3628800\n8841761993739701954543616000000\n"}, {"input": "4\n5\n4\n4\n29", "output": "120\n24\n24\n8841761993739701954543616000000\n"}, {"in... | code_stdio |
[
{
"content": "There are N people, conveniently numbered 1 through N.\nWe want to divide them into some number of groups, under the following two conditions:\n - Every group contains between A and B people, inclusive.\n - Let F_i be the number of the groups containing exactly i people. Then, for all i, either F_... | [{"input": "1000 1 1000 1 1000\n", "output": "465231251\n"}, {"input": "1000 1 1000 2 1000", "output": "860178665\n"}, {"input": "1000 1 1000 3 1000", "output": "980205027\n"}, {"input": "1000 1 1000 1 1001", "output": "465231251\n"}, {"input": "1000 1 1001 5 1010", "output": "354813907\n"}, {"input": "1000 1 1000 3 10... | code_stdio |
[
{
"content": "Today in the scientific lyceum of the Kingdom of Kremland, there was a biology lesson. The topic of the lesson was the genomes. Let's call the genome the string \"ACTG\".\n\nMaxim was very boring to sit in class, so the teacher came up with a task for him: on a given string $s$ consisting of upper... | [{"input": "50\nROWGGKNUITVHOBMKZXOZNBZMQGSFERNCZDFKLRBCFVVDXJEFLP\n", "output": "13\n"}, {"input": "50\nALWLSFLXYPQYMIWXMYMXFYMIVFYJDTJAIGVOAUDAIIAHKNNVTX\n", "output": "13\n"}, {"input": "50\nHKKUWHLYYKBLLEHKVNIRYAPVFTAPRIFUZELKGRDXZNCNWHSAFG\n", "output": "14\n"}, {"input": "50\nVKRGXLUWYURTRNGAODFLYCKAPHGPHGDLWIGXE... | code_stdio |
[
{
"content": "Your task is very simple. Just write a function `isAlphabetic(s)`, which takes an input string `s` in lowercase and returns `true`/`false` depending on whether the string is in alphabetical order or not.\n\nFor example, `isAlphabetic('kata')` is False as 'a' comes after 'k', but `isAlphabetic('ant... | [{"input": "\"codewars\"", "output": "[false]", "fn_name": "alphabetic"}, {"input": "\"asd\"", "output": "[false]", "fn_name": "alphabetic"}, {"input": "\"door\"", "output": "[true]", "fn_name": "alphabetic"}, {"input": "\"cell\"", "output": "[true]", "fn_name": "alphabetic"}, {"input": "\"z\"", "output": "[true]", "fn... | code_functional |
[
{
"content": "You wrote down all integers from $0$ to $10^n - 1$, padding them with leading zeroes so their lengths are exactly $n$. For example, if $n = 3$ then you wrote out 000, 001, ..., 998, 999.\n\nA block in an integer $x$ is a consecutive segment of equal digits that cannot be extended to the left or to... | [{"input": "2352\n", "output": "388795058 433322746 541969001 523323201 867893102 537695799 837561050 990678065 688882179 577079614 937069914 960273782 761665782 282484628 787581089 314410468 983373531 353249698 130693309 82500826 144964998 247781749 108001361 947489703 358119467 770902487 739563471 529518967 368034134... | code_stdio |
[
{
"content": "Yaroslav thinks that two strings s and w, consisting of digits and having length n are non-comparable if there are two numbers, i and j (1 ≤ i, j ≤ n), such that s_{i} > w_{i} and s_{j} < w_{j}. Here sign s_{i} represents the i-th digit of string s, similarly, w_{j} represents the j-th digit of st... | [{"input": "10\n?8?528?91?\n1???60??54\n", "output": "1000000000\n"}, {"input": "10\n?8?258?91?\n1???60??54\n", "output": "1000000000\n"}, {"input": "10\n0????19?01\n????164759\n", "output": "1000000000\n"}, {"input": "10\n219?85??8?\n45??06???1\n", "output": "1000000000\n"}, {"input": "10\n???0?19?01\n957461????\n", "... | code_stdio |
[
{
"content": "You are an immigration officer in the Kingdom of AtCoder. The document carried by an immigrant has some number of integers written on it, and you need to check whether they meet certain criteria.\nAccording to the regulation, the immigrant should be allowed entry to the kingdom if and only if the ... | [{"input": "100\n768 125 109 300 471 697 999 760 529 42 373 15 59 387 75 823 850 330 756 661 700 610 99 156 367 481 720 588 477 65 513 600 569 531 970 97 456 223 963 625 823 612 421 633 774 529 190 835 245 263 861 456 893 293 762 270 955 457 65 941 787 700 617 813 550 70 807 217 683 935 732 320 815 821 397 445 807 439 ... | code_stdio |
[
{
"content": "Nearly each project of the F company has a whole team of developers working on it. They often are in different rooms of the office in different cities and even countries. To keep in touch and track the results of the project, the F company conducts shared online meetings in a Spyke chat.\n\nOne da... | [{"input": "100 5\n- 60\n- 58\n+ 25\n- 32\n+ 86\n", "output": "95\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 27 28 29 30 31 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 59 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 87 88 89 90 91 92 9... | code_stdio |
[
{
"content": "There is a 120 minute videotape with standard recording. When I set the VCR counter to 00:00:00 with the tape completely rewound and recorded in standard recording mode, I got a certain counter value. Enter this counter value (hours, minutes, seconds), find the length of the remaining tape (record... | [{"input": "1 36 0\n-1 -1 -1", "output": "00:24:00\n01:12:00\n"}, {"input": "0 30 0\n-1 -1 -1", "output": "01:30:00\n04:30:00\n"}, {"input": "0 32 0\n-1 -1 -1", "output": "01:28:00\n04:24:00\n"}, {"input": "1 16 0\n-1 -1 -1", "output": "00:44:00\n02:12:00\n"}, {"input": "0 36 0\n-1 -1 -1", "output": "01:24:00\n04:12:00... | code_stdio |
[
{
"content": "The zombies are gathering in their secret lair! Heidi will strike hard to destroy them once and for all. But there is a little problem... Before she can strike, she needs to know where the lair is. And the intel she has is not very good.\n\nHeidi knows that the lair can be represented as a rectang... | [{"input": "10\n0000000000\n0000000000\n0000000000\n0000000000\n0000000000\n0000000000\n0012100000\n0024200000\n0012100000\n0000000000\n", "output": "Yes\n"}, {"input": "10\n0000000000\n0122210000\n0244420100\n0122210000\n0000000000\n0000000000\n0000000000\n0000000000\n0000000000\n0000000000\n", "output": "No\n"}, {"in... | code_stdio |
[
{
"content": "The start of the new academic year brought about the problem of accommodation students into dormitories. One of such dormitories has a a × b square meter wonder room. The caretaker wants to accommodate exactly n students there. But the law says that there must be at least 6 square meters per stude... | [{"input": "1000000000 1000000000 1000000000\n", "output": "1000000000000000000\n1000000000 1000000000\n"}, {"input": "1000000000 1000000000 1000000000\n", "output": "1000000000000000000\n1000000000 1000000000\n"}, {"input": "1000001000 1000000000 1000000000\n", "output": "1000000000000000000\n1000000000 1000000000\n"}... | code_stdio |
[
{
"content": "N programmers are going to participate in the preliminary stage of DDCC 20XX. Due to the size of the venue, however, at most 9 contestants can participate in the finals.\n\nThe preliminary stage consists of several rounds, which will take place as follows:\n\n* All the N contestants will participa... | [{"input": "3\n1 0\n0 10\n7 2", "output": "12\n"}, {"input": "3\n1 0\n0 17\n7 2", "output": "19\n"}, {"input": "3\n1 1\n0 17\n7 2", "output": "20\n"}, {"input": "3\n1 0\n0 27\n7 2", "output": "29\n"}, {"input": "3\n1 1\n0 10\n7 2", "output": "13\n"}, {"input": "3\n1 0\n1 17\n7 2", "output": "21\n"}, {"input": "3\n1 2\n... | code_stdio |
[
{
"content": "There are n points on the plane, the i-th of which is at (x_i, y_i). Tokitsukaze wants to draw a strange rectangular area and pick all the points in the area.\n\nThe strange area is enclosed by three lines, x = l, y = a and x = r, as its left side, its bottom side and its right side respectively, ... | [{"input": "35\n8 1\n6 8\n4 1\n1 2\n1 4\n5 10\n10 8\n9 1\n9 9\n10 2\n6 5\n8 8\n7 6\n10 6\n9 4\n4 9\n3 2\n1 8\n3 9\n7 3\n3 7\n2 7\n3 8\n3 1\n2 2\n5 5\n7 2\n4 10\n6 3\n5 1\n8 10\n4 3\n9 8\n9 7\n3 10\n", "output": "316"}, {"input": "35\n4 2\n9 6\n3 10\n2 5\n7 9\n6 9\n10 7\n6 6\n5 4\n4 10\n5 9\n8 1\n2 4\n9 9\n5 7\n6 5\n10 ... | code_stdio |
[
{
"content": "There are N towns in the State of Atcoder, connected by M bidirectional roads.\nThe i-th road connects Town A_i and B_i and has a length of C_i.\nJoisino is visiting R towns in the state, r_1,r_2,..,r_R (not necessarily in this order).\nShe will fly to the first town she visits, and fly back from ... | [{"input": "4 6 3\n2 3 4\n1 2 4\n2 3 3\n4 3 1\n1 4 1\n4 2 2\n3 1 6\n", "output": "3\n"}, {"input": "4 6 3\n2 3 4\n1 2 4\n2 3 6\n4 3 1\n1 4 1\n4 2 2\n3 1 6", "output": "3\n"}, {"input": "4 6 3\n2 3 4\n1 2 4\n2 3 6\n4 3 1\n1 4 1\n4 1 2\n3 1 6", "output": "7\n"}, {"input": "4 6 3\n2 3 4\n1 2 4\n2 3 6\n4 4 1\n1 4 1\n4 2 2\... | code_stdio |
[
{
"content": "There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.\n\nInput\n\nThe first line contains an integer n (1 ≤ n ≤ 106). The second ... | [{"input": "30\n2 1 3 2 3 2 2 2 2 3 2 2 3 2 1 1 3 1 3 2 1 2 3 1 1 3 3 1 3 1\n", "output": "19\n"}, {"input": "30\n2 1 3 2 3 2 2 2 2 3 2 2 1 2 1 1 3 1 3 2 1 2 3 1 1 3 3 1 3 1\n", "output": "19\n"}, {"input": "30\n2 1 3 2 3 2 2 2 2 3 2 2 1 2 1 1 3 1 3 2 1 2 3 1 1 3 2 1 3 1\n", "output": "18\n"}, {"input": "30\n2 1 3 2 3 ... | code_stdio |
[
{
"content": "A very easy task for you!\n\nYou have to create a method, that corrects a given date string.\nThere was a problem in addition, so many of the date strings are broken.\nDate-Format is european. That means \"DD.MM.YYYY\".\n\n\nSome examples:\n\n\"30.02.2016\" -> \"01.03.2016\"\n\"40.06.2015\" -> \"1... | [{"input": "\"03.12.2016\"", "output": "[\"03.12.2016\"]", "fn_name": "date_correct"}, {"input": "\"30.02.2016\"", "output": "[\"01.03.2016\"]", "fn_name": "date_correct"}, {"input": "\"40.06.2015\"", "output": "[\"10.07.2015\"]", "fn_name": "date_correct"}, {"input": "\"11.13.2014\"", "output": "[\"11.01.2015\"]", "fn... | code_functional |
[
{
"content": "Nowadays it is becoming increasingly difficult to park a car in cities successfully. Let's imagine a segment of a street as long as L meters along which a parking lot is located. Drivers should park their cars strictly parallel to the pavement on the right side of the street (remember that in the ... | [{"input": "50 3 1\n30\n1 9\n2 1\n1 6\n1 5\n1 8\n1 1\n2 6\n1 7\n2 3\n2 8\n1 7\n2 4\n2 5\n2 11\n1 2\n2 15\n1 6\n1 3\n2 17\n1 9\n1 3\n2 18\n1 3\n2 23\n2 21\n1 8\n1 2\n2 27\n1 8\n2 29\n", "output": "0\n0\n9\n17\n28\n28\n0\n0\n0\n9\n15\n0\n6\n0\n11\n27\n"}, {"input": "50 3 2\n30\n1 9\n2 1\n1 6\n1 5\n1 8\n1 1\n2 6\n1 7\n2 3... | code_stdio |
[
{
"content": "You are given two integers a and b. Moreover, you are given a sequence s_0, s_1, ..., s_{n}. All values in s are integers 1 or -1. It's known that sequence is k-periodic and k divides n+1. In other words, for each k ≤ i ≤ n it's satisfied that s_{i} = s_{i - k}.\n\nFind out the non-negative remain... | [{"input": "904132655 827386249 118827660 334\n+++-+++++--+++----+-+-+-+-+--+-+---++--++--++--+-+-+++-+++--+-+-+----+-+-++++-----+--++++------+++-+-+-++-++++++++-+-++-+++--+--++------+--+-+++--++--+---++-++-+-+-++---++-++--+-+-++-+------+-+----+++-+++--+-+-+--+--+--+------+--+---+--+-++--+++---+-+-++--------+-++--++-+-... | code_stdio |
[
{
"content": "Karl is developing a key storage service. Each user has a positive integer key.\n\nKarl knows that storing keys in plain text is bad practice. So, instead of storing a key, he decided to store a fingerprint of a key. However, using some existing fingerprint algorithm looked too boring to him, so h... | [{"input": "100\n1\n3\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n14\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n19\n42\n43\n44\n45\n46\n47\n20\n49\n50\n65\n52\n53\n54\n55\n56\n57\n58\n59\n60\n61\n62\n63\n64\n65\n66\n67\n68\n69\n70\n71\n72\n73\n123\n75\n76\n77\n78\... | code_stdio |
[
{
"content": "Once 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 and told him: \"If you solve the following problem, I'll return it to you.\" [... | [{"input": "777777777\n", "output": "1022\n"}, {"input": "444444444\n", "output": "511\n"}, {"input": "477477447\n", "output": "728\n"}, {"input": "777744747\n", "output": "996\n"}, {"input": "777777777\n", "output": "1022"}, {"input": "477477447\n", "output": "728"}, {"input": "777744747\n", "output": "996"}, {"input"... | code_stdio |
[
{
"content": "*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://en.wikipedia.org/wiki/Langton%27s_ant) moves on a regular grid of squares ... | [{"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": "You 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 the string inclusive.\n\nA string is called balanced if the number of letters ... | [{"input": "4\n1\na\n6\nabbaba\n6\nabbaba\n9\nbabbabbaa\n", "output": "-1 -1\n1 2\n1 2\n1 2\n"}, {"input": "4\n1\na\n6\nabbaba\n6\nabbaba\n9\nbabbabbaa\n", "output": "-1 -1\n1 2\n1 2\n1 2\n"}, {"input": "4\n1\na\n6\nabbaba\n6\nabbaba\n7\nbabbabbaa\n", "output": "-1 -1\n1 2\n1 2\n1 2\n"}, {"input": "4\n1\na\n6\nababba\n... | code_stdio |
[
{
"content": "There are $n$ players sitting at the card table. Each player has a favorite number. The favorite number of the $j$-th player is $f_j$.\n\nThere are $k \\cdot n$ cards on the table. Each card contains a single integer: the $i$-th card contains number $c_i$. Also, you are given a sequence $h_1, h_2,... | [{"input": "50 1\n995 1815 941 1716 725 1098 747 627 1728 1007 34 1001 679 1742 22 1495 1299 1696 507 631 1971 775 1052 1665 1035 203 1564 1329 1592 1295 983 177 734 1442 172 943 33 486 1078 946 947 592 1524 563 396 1541 1670 326 543 79\n176 214 1601 1758 1468 972 628 1524 1506 425 746 309 387 1761 1002 625 496 1638 18... | code_stdio |
[
{
"content": "Valera runs a 24/7 fast food cafe. He magically learned that next day n people will visit his cafe. For each person we know the arrival time: the i-th person comes exactly at h_{i} hours m_{i} minutes. The cafe spends less than a minute to serve each client, but if a client comes in and sees that ... | [{"input": "50\n0 23\n1 21\n2 8\n2 45\n3 1\n4 19\n4 37\n7 7\n7 40\n8 43\n9 51\n10 13\n11 2\n11 19\n11 30\n12 37\n12 37\n12 37\n12 37\n12 37\n12 37\n12 37\n12 37\n12 54\n13 32\n13 42\n14 29\n14 34\n14 48\n15 0\n15 27\n16 22\n16 31\n17 25\n17 26\n17 33\n18 14\n18 16\n18 20\n19 0\n19 5\n19 56\n20 22\n21 26\n22 0\n22 10\n2... | code_stdio |
[
{
"content": "You have a nuts and lots of boxes. The boxes have a wonderful feature: if you put x (x ≥ 0) divisors (the spacial bars that can divide a box) to it, you get a box, divided into x + 1 sections.\n\nYou are minimalist. Therefore, on the one hand, you are against dividing some box into more than k sec... | [{"input": "1201 495 438 1293\n", "output": "1\n"}, {"input": "241 1202 830 417\n", "output": "1\n"}, {"input": "1201 492 438 690\n", "output": "1\n"}, {"input": "241 1247 830 417\n", "output": "1\n"}, {"input": "1201 495 438 690\n", "output": "1\n"}, {"input": "477 492 438 690\n", "output": "1\n"}, {"input": "461 790 ... | code_stdio |
[
{
"content": "Wabbit 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 box if he stands exactly $1$ unit away from the box in the direction of one o... | [{"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"}, {"input": "5\n1 0 1000000000 1000000000\n1 1 1001000000 1000001100\n1 0 1001000000 1000000000\n1 1 110001... | code_stdio |
[
{
"content": "You 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 order.\n\nA helper procedure of the algorithm, $f(i)$, takes a single argumen... | [{"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"}, {"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"}, {"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"}, {"input": "3\n3\n3 2 1\n7\n4 5 6 1 3 2 7\n5\n1 2 3 4 5\n", "output": "... | code_stdio |
[
{
"content": "JAG-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 thread-based. Here, a thread refers to a group of conversations consisting of a... | [{"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.themessagelengthislessthanorequaltofift... | code_stdio |
[
{
"content": "Rudolf 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$ (only in $a$, not $b$) so that bitwise OR of these two numbers will be changed? ... | [{"input": "30\n011110110100010000011001000100\n110111101001011001100001101101\n", "output": "146\n"}, {"input": "30\n011110110100010000011001000100\n110111101001011001100001101101\n", "output": "146\n"}, {"input": "30\n011110110100010000011001000100\n110111101000011001100001101101\n", "output": "153\n"}, {"input": "30... | code_stdio |
[
{
"content": "One 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 of the first laptop is less (strictly smaller) than the price of the second l... | [{"input": "4\n4 2\n6 1\n2 6\n-2 11\n", "output": "Happy Alex\n"}, {"input": "4\n4 1\n6 2\n2 5\n-1 4\n", "output": "Happy Alex\n"}, {"input": "4\n4 1\n6 2\n2 5\n-2 4\n", "output": "Happy Alex\n"}, {"input": "4\n4 1\n6 2\n2 9\n-2 4\n", "output": "Happy Alex\n"}, {"input": "4\n4 1\n6 1\n2 9\n-2 4\n", "output": "Happy Ale... | code_stdio |
[
{
"content": "You've got string s, consisting of small English letters. Some of the English letters are good, the rest are bad.\n\nA substring s[l...r] (1 ≤ l ≤ r ≤ |s|) of string s = s_1s_2...s_{|}s| (where |s| is the length of string s) is string s_{l}s_{l} + 1...s_{r}.\n\nThe substring s[l...r] is good, i... | [{"input": "dcijflpluxgeqlroaktzcujfaaidnrdzgogzhobhsmbwmjpschtvjmivfapddsmxfvlhhgguymgtdjxpiezbnlmnlvdnuaohqskdbcjlyfdrzicflveffvpeyzhwqqdaenbsghuvetpxvqcutjxbelbfzuqpwlfvveebnmkoryxgodpccanzwhziiiumgtwskxhrhwdkwmyreefwmoedcvaokvetcgundyiidsqkolpqkarpszrrmagrfvpnwharotashtwcnrcnhapdwrbltgkpkkmlrpapfizonyttrikh\n110110... | code_stdio |
[
{
"content": "The 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 the numbers is the PIN.\n\nCreate a program that reads the memorandum and out... | [{"input": "Thereare100yenonthetable.Iam17yearsold.\n.mp6taemohogdluohsI", "output": "123\n"}, {"input": "Thergarn100yeeontgesable-Iam17ye`rsolc.\nIshptkogdhomemt5q`.", "output": "122\n"}, {"input": "Thereare100yenonthetable.Iam17ye`rsold.\n.mp6taemohogdluohsI", "output": "123\n"}, {"input": "Thereare100yenonthesable.I... | code_stdio |
[
{
"content": "An 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 ≤ x ≤ a_i). Let i be the source index and j be the sink index. \n 2. Decreas... | [{"input": "5\n0 11 12 13 14\n", "output": "\n120"}, {"input": "5\n0 12 1 13 14\n", "output": "24\n"}, {"input": "5\n1 3 0 13 48\n", "output": "120\n"}, {"input": "5\n1 18 2 13 26\n", "output": "24\n"}, {"input": "5\n0 11 14 13 14\n", "output": "0\n"}, {"input": "5\n-1 20 2 13 14\n", "output": "0\n"}, {"input": "5\n0 1... | code_stdio |
[
{
"content": "You are given a sequence of numbers a_1, a_2, ..., a_{n}, and a number m.\n\nCheck if it is possible to choose a non-empty subsequence a_{i}_{j} such that the sum of numbers in this subsequence is divisible by m.\n\n\n-----Input-----\n\nThe first line contains two numbers, n and m (1 ≤ n ≤ 10^6, 2... | [{"input": "100 968\n966 966 967 966 967 967 967 967 966 1446 966 967 966 966 966 967 967 966 966 967 967 967 967 966 967 967 967 967 563 967 967 967 600 967 967 966 967 1750 967 966 967 966 967 966 966 966 967 966 967 966 966 967 967 193 966 966 967 966 1294 967 967 966 967 966 966 580 966 967 966 966 967 966 966 966 ... | code_stdio |
[
{
"content": "Complete 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## Examples\n\n```\n[12, 10, 8, 12, 7, 6, 4, 10, 12] --> 12\n[1... | [{"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": "There is a grass field that stretches infinitely.\nIn this field, there is a negligibly small cow. Let (x, y) denote the point that is x\\ \\mathrm{cm} south and y\\ \\mathrm{cm} east of the point where the cow stands now. The cow itself is standing at (0, 0).\nThere are also N north-south lines a... | [{"input": "1000 1000\n-994461514 -985306778 -517708279\n-994461514 -985306778 -232175991\n-991585642 -983349857 -817377920\n-991585642 -983349857 -769081289\n-983107981 -980980057 -973401374\n-997908939 -980980057 -857139401\n-978282897 -966923595 -81201061\n-997908939 -966923595 45414533\n-962515169 -962345576 -98681... | code_stdio |
[
{
"content": "According 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 the jacket will not swinging open.\n\nYou are given a jacket with n buttons. D... | [{"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 0 0 0 0 0 0 0 0 0 0 0 0... | code_stdio |
[
{
"content": "We have a grid with H rows and W columns. At first, all cells were painted white.\nSnuke painted N of these cells. The i-th ( 1 \\leq i \\leq N ) cell he painted is the cell at the a_i-th row and b_i-th column.\nCompute the following:\n - For each integer j ( 0 \\leq j \\leq 9 ), how many subrecta... | [{"input": "10 28 20\n0 1\n2 4\n1 9\n2 5\n0 6\n4 1\n1 7\n5 9\n6 4\n6 6\n6 5\n2 2\n10 3\n7 8\n16 1\n3 5\n11 10\n10 5\n17 4\n4 7", "output": "152\n28\n18\n10\n0\n0\n0\n0\n0\n0\n"}, {"input": "10 28 20\n0 1\n2 4\n1 9\n2 5\n0 6\n4 1\n1 7\n5 9\n6 4\n6 6\n6 5\n2 2\n10 1\n7 8\n16 1\n3 5\n11 10\n10 5\n17 4\n4 7", "output": "15... | code_stdio |
[
{
"content": "Snuke 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\nFind the length of the shortest string that satisfies the conditions.\n\nConstr... | [{"input": "4\nexpr\nexpq", "output": "8\n"}, {"input": "4\nexpr\nrxep", "output": "7\n"}, {"input": "4\nexpr\nepxq", "output": "8\n"}, {"input": "4\nexpr\npexq", "output": "8\n"}, {"input": "4\nexpr\nqxep", "output": "8\n"}, {"input": "4\nexqr\nrxep", "output": "7\n"}, {"input": "4\nexqr\nrxeo", "output": "7\n"}, {"in... | code_stdio |
[
{
"content": "Furik loves writing all sorts of problems, especially such that he can't solve himself. You've got one of his problems, the one Furik gave to Rubik. And Rubik asks you to solve it.\n\nThere is integer n and array a, consisting of ten integers, indexed by numbers from 0 to 9. Your task is to count ... | [{"input": "100\n100 100 100 100 100 100 100 100 100 100\n", "output": "0\n"}, {"input": "100\n100 100 100 100 100 100 100 100 101 100\n", "output": "0\n"}, {"input": "82\n100 100 100 100 100 100 100 100 100 100\n", "output": "0\n"}, {"input": "55\n100 100 100 100 100 100 100 100 100 100\n", "output": "0\n"}, {"input":... | code_stdio |
[
{
"content": "There 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; each sister will get some integer number of candies; Alice will get a greate... | [{"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\n233\n198\n876\n697\n691\n... | code_stdio |
[
{
"content": "You 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 `arr2` are the original sorted arrays.\n\nYou don't need to worry about validatio... | [{"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": "Andrey's favourite number is n. Andrey's friends gave him two identical numbers n as a New Year present. He hung them on a wall and watched them adoringly.\n\nThen Andrey got bored from looking at the same number and he started to swap digits first in one, then in the other number, then again in t... | [{"input": "10802611971893001160947949048137125257663360973350362557151889546818281691354280360512029669737944667993533147136817951837479019430773307929092792540144287240690218353482990299029694493198951486742073494255017372881972567810450854959208991586907060759736152497682999322253656832611644507455595270340103399952... | code_stdio |
[
{
"content": "Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit... | [{"input": "100\n1 1 0 0 1 1 1 1 0 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 0 1 0 0 0 0 1 1 1 1 0 0 1 0 0 1 1 0 1 1 1 1 1 1 0 0 0 0 1 1 0 0 0 0 0 1 1 0 1 0 0 1 0 0 1 0 1 0 0 0 0 1 0 1 1 0 1 1 1 1 0 0 1 1 0 0 0 0 1 1 1 0 0 1 0 0\n", "output": "1446"}, {"input": "50\n1 1 0 1 1 1 1 1 1 0 0 1 1 0 1 1 0 0 1 0 1 1 0 1 1 1 1 0 1 0 1 1 1... | code_stdio |
[
{
"content": "Mayor 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 lawn nobody needs anyway. Moreover, that might help reduce the car jams which ha... | [{"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"}, {"input": "10\n21005 10850\n27020 13372\n28183 3724\n22874 13564\n27446 11493\n22522 10012... | code_stdio |
[
{
"content": "Jeff got 2n real numbers a1, a2, ..., a2n as a birthday present. The boy hates non-integer numbers, so he decided to slightly \"adjust\" the numbers he's got. Namely, Jeff consecutively executes n operations, each of them goes as follows:\n\n * choose indexes i and j (i ≠ j) that haven't been cho... | [{"input": "10\n8003.867 4368.000 2243.298 3340.000 5384.489 1036.000 3506.115 4463.317 1477.000 2420.314 9391.186 1696.000 5857.833 244.314 8220.000 5879.647 5424.482 2631.000 7111.130 9157.536\n", "output": "0.472\n"}, {"input": "10\n8003.000 4368.194 2243.000 3340.287 5384.000 1036.456 3506.000 4463.000 1477.787 242... | code_stdio |
[
{
"content": "There 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 case, find the number of the pairs (l, r) that satisfy the following:\n - l ... | [{"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 5 1 1 5 1 1 5 1 1 5 1 1... | code_stdio |
[
{
"content": "In 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 resources, and were immortal.\n\nBeginning with one immature pair of these idealized ... | [{"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": "Joisino has a formula consisting of N terms: A_1 op_1 A_2 ... op_{N-1} A_N. Here, A_i is an integer, and op_i is an binary operator either `+` or `-`. Because Joisino loves large numbers, she wants to maximize the evaluated value of the formula by inserting an arbitrary number of pairs of parenthe... | [{"input": "5\n2 - 159 - 13 + 21 - 5", "output": "-118\n"}, {"input": "5\n1 - 157 - 13 + 14 - 5", "output": "-124\n"}, {"input": "5\n2 - 119 - 13 + 14 - 5", "output": "-85\n"}, {"input": "5\n2 - 119 - 13 + 19 - 5", "output": "-80\n"}, {"input": "5\n1 - 119 - 13 + 19 - 5", "output": "-81\n"}, {"input": "5\n1 - 119 - 13 ... | code_stdio |
[
{
"content": "Some 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 chooses an arbitrary (possibly zero) number of pairs on positions $(i, i + 1)$... | [{"input": "ggaaaawwwxxxxxxrrrrrrrrwwwwwwwwggggggggjjusszzzzqqqqqsssssssbbwwwwwwmmmmtttttttvvvvvvvvssssppppppggggsrrrrrrzzzzzzzyyyyyccccccchhhhhhhhjjrrrrhhhhhhhheeeeeeeaaaaaaaiiiiiuuuuuuuvvvvvjjjjjjjjffbbbbbbbbrrrrrllllllllggggggggooooollssvvvvvvvvvvnnnnnnnnuuuuuuuucccccyyyyyyyyyyzzzzzzzkkkkuuuuuunnnnnnnqnnnnnnggggdddd... | code_stdio |
[
{
"content": "Unlucky 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 = 2^0 + 3^1, 17 = 2^3 + 3^2 = 2^4 + 3^0) and year 18 isn't unlucky as there i... | [{"input": "433333986179614514 1000000000000000000 433333986179614515 726628630292055493\n", "output": "293294644112440978\n"}, {"input": "433333986179614514 1000001000000000000 433333986179614515 726628630292055493\n", "output": "293294644112440978\n"}, {"input": "239838434825939759 805278168279318096 2023378499191046... | code_stdio |
[
{
"content": "A 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} (l_{i} ≤ r_{i}).\n\nRestaurant management can accept and reject orders. What ... | [{"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"}, {"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 106\n39 55\n31 33\n9 33\n6 72\n14 67\n56 98\n69... | code_stdio |
[
{
"content": "You 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 boxes, are:\n\n```\n (1) (2) (3)(4) \n______ ____... | [{"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": "The 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\nGiven a sequence of n integers p_1, p_2, ..., p_{n}. You are to choose k pair... | [{"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 76 5 39 80 37 17 78 23 61... | code_stdio |
[
{
"content": "# 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 executes several commands each of which is a single positive integer. When the robot... | [{"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": "You are given n integers a_1, a_2, …, a_n and an integer k. Find the maximum value of i ⋅ j - k ⋅ (a_i | a_j) over all pairs (i, j) of integers with 1 ≤ i < j ≤ n. Here, | is the [bitwise OR operator](https://en.wikipedia.org/wiki/Bitwise_operation#OR).\n\nInput\n\nThe first line contains a single... | [{"input": "4\n3 3\n1 1 3\n2 2\n2 2\n4 3\n0 1 2 3\n6 6\n3 2 0 0 5 6\n", "output": "-1\n-2\n3\n12\n"}, {"input": "4\n3 3\n1 1 3\n2 2\n0 2\n4 3\n0 1 2 3\n6 6\n3 2 0 0 5 6\n", "output": "-1\n-2\n3\n12\n"}, {"input": "4\n3 3\n1 1 3\n2 2\n0 2\n4 3\n0 1 2 3\n6 9\n3 2 0 0 5 6\n", "output": "-1\n-2\n3\n12\n"}, {"input": "4\n3 ... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.