messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "It's finally summer in Chefland! So our chef is looking forward to prepare some of the best \"beat-the-heat\" dishes to attract more customers. He summons the Wizard of Dessert to help him with one such dish.\nThe wizard provides the chef with a sequence of N ingredients where the i^{th} ingredien...
[{"input": "2\n5\n1 -1 0 1 10\n4\n2 1 -2 -1", "output": "12\n6\n"}, {"input": "2\n5\n0 0 3 10 5\n4\n4 1 0 -5", "output": "18\n10\n"}, {"input": "2\n5\n1 2 3 11 10\n4\n2 1 0 -1", "output": "25\n4\n"}, {"input": "2\n5\n1 2 3 11 10\n4\n4 1 0 -1", "output": "25\n6\n"}, {"input": "2\n5\n1 0 0 1 10\n4\n1 1 -2 -1", "output": ...
code_stdio
[ { "content": "There is an Amidakuji that consists of w vertical bars and has a height (the number of steps to which horizontal bars can be added) of h. w is an even number. Of the candidates for the place to add the horizontal bar of this Amidakuji, the ath from the top and the bth from the left are called (a, ...
[{"input": "10 8 10\n10 4\n4 4\n5 1\n6 2\n3 3\n1 3\n2 4\n8 2\n7 5\n7 1", "output": "1\n2\n3\n7\n8\n5\n4\n6\n"}, {"input": "10 6 10\n10 4\n4 4\n5 1\n4 2\n7 3\n1 3\n2 4\n8 2\n3 5\n7 1", "output": "1\n4\n3\n5\n6\n2\n"}, {"input": "10 6 10\n10 4\n4 4\n5 1\n6 2\n7 3\n1 3\n2 4\n8 2\n7 5\n7 1", "output": "4\n2\n3\n1\n5\n6\n"}...
code_stdio
[ { "content": "You are given two arithmetic progressions: a_1k + b_1 and a_2l + b_2. Find the number of integers x such that L ≤ x ≤ R and x = a_1k' + b_1 = a_2l' + b_2, for some integers k', l' ≥ 0.\n\n\n-----Input-----\n\nThe only line contains six integers a_1, b_1, a_2, b_2, L, R (0 < a_1, a_2 ≤ 2·10^9, - 2...
[{"input": "1789433851 -633540112 1286318222 -1728151682 1438333624 1538194890\n", "output": "0\n"}, {"input": "1789433851 -633540112 1286318222 -1728151682 1438333624 1538194890\n", "output": "0\n"}, {"input": "1955378240 -837482305 1743607821 -1623988108 -653286850 178227154\n", "output": "0\n"}, {"input": "195537824...
code_stdio
[ { "content": "You are given a sequence $a_1, a_2, \\dots, a_n$, consisting of integers.\n\nYou can apply the following operation to this sequence: choose some integer $x$ and move all elements equal to $x$ either to the beginning, or to the end of $a$. Note that you have to move all these elements in one direct...
[{"input": "3\n7\n3 1 6 6 3 1 1\n8\n1 1 4 4 4 7 8 8\n7\n4 2 5 2 6 2 7\n", "output": "2\n0\n1\n"}, {"input": "3\n7\n3 1 6 6 3 1 1\n8\n1 1 4 4 4 7 8 8\n7\n4 2 5 2 6 2 5\n", "output": "2\n0\n2\n"}, {"input": "3\n7\n3 1 6 6 3 1 1\n8\n1 1 4 4 4 7 8 8\n7\n4 2 5 3 6 2 5\n", "output": "2\n0\n3\n"}, {"input": "3\n7\n3 1 6 6 3 1...
code_stdio
[ { "content": "Suppose you are given a string s of length n consisting of lowercase English letters. You need to compress it using the smallest possible number of coins.\n\nTo compress the string, you have to represent s as a concatenation of several non-empty strings: s = t_{1} t_{2} … t_{k}. The i-th of these ...
[{"input": "255 3880 4590\nwgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwewgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwkwgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwewgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwawgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwewgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwkwgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwewgwzwgwuwgwzwgwxwgwzwgwuwgwzwgw\n", "output": "62460"}, {"input": "13...
code_stdio
[ { "content": "Screen resolution of Polycarp's monitor is $a \\times b$ pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates $(x, y)$ ($0 \\le x < a, 0 \\le y < b$). You can consider columns of pixels to be numbered from $0$ to $a-1$, and rows — from $0$ to $b-1$.\n\nPolycarp wants to...
[{"input": "6\n8 8 0 0\n1 11 0 3\n17 10 10 4\n2 4 0 0\n4 10 3 9\n15 18 3 12\n", "output": "56\n7\n100\n6\n36\n198\n"}, {"input": "6\n8 8 0 0\n1 11 0 3\n17 10 10 4\n2 4 0 0\n4 10 3 6\n15 18 3 12\n", "output": "56\n7\n100\n6\n30\n198\n"}, {"input": "6\n8 8 0 0\n1 11 0 3\n17 10 10 4\n2 4 0 0\n4 10 3 6\n15 18 0 12\n", "out...
code_stdio
[ { "content": "You have a long stick, consisting of $m$ segments enumerated from $1$ to $m$. Each segment is $1$ centimeter long. Sadly, some segments are broken and need to be repaired.\n\nYou have an infinitely long repair tape. You want to cut some pieces from the tape and use them to cover all of the broken ...
[{"input": "2 1000000000 1\n1 1000000000\n", "output": "1000000000\n"}, {"input": "2 1000000000 1\n1 1001000000\n", "output": "1001000000\n"}, {"input": "2 1000000000 1\n1 1000001000\n", "output": "1000001000\n"}, {"input": "2 1000000000 1\n1 1000000000\n", "output": "1000000000"}, {"input": "2 1000000000 2\n1 10000000...
code_stdio
[ { "content": "Little Johnny Bubbles enjoys spending hours in front of his computer playing video games. His favorite game is Bubble Strike, fast-paced bubble shooting online game for two players.\n\nEach game is set in one of the N maps, each having different terrain configuration. First phase of each game deci...
[{"input": "504 0.47945891424701503\n", "output": "168\n"}, {"input": "1000 0.4721875056593412\n", "output": "327\n"}, {"input": "444 0.34094493029760853\n", "output": "103\n"}, {"input": "743 0.47945891424701503\n", "output": "247\n"}, {"input": "444 0.49265183917195776\n", "output": "152\n"}, {"input": "550 0.3318234...
code_stdio
[ { "content": "Brief\n=====\nSometimes we need information about the list/arrays we're dealing with. You'll have to write such a function in this kata. Your function must provide the following informations: \n\n* Length of the array\n* Number of integer items in the array\n* Number of float items in the array\n...
[{"input": "[11, 22, 33.33, 44.44, \"hasan\", \"ahmad\"]", "output": "[[[6], [2], [2], [2], [null]]]", "fn_name": "array_info"}, {"input": "[1, 2, 3.33, 4, 5.01, \"bass\", \"kick\", \" \"]", "output": "[[[8], [3], [2], [2], [1]]]", "fn_name": "array_info"}, {"input": "[1, 2, 3, 4, 5, 6, 7, 8, 9]", "output": "[[[9], [9]...
code_functional
[ { "content": "You are given a tree (an undirected connected acyclic graph) consisting of $n$ vertices and $n - 1$ edges. A number is written on each edge, each number is either $0$ (let's call such edges $0$-edges) or $1$ (those are $1$-edges).\n\nLet's call an ordered pair of vertices $(x, y)$ ($x \\ne y$) val...
[{"input": "7\n2 1 1\n3 2 0\n4 2 1\n5 2 0\n6 7 1\n7 2 1\n", "output": "34\n"}, {"input": "7\n2 1 1\n3 2 0\n4 2 1\n5 4 0\n6 7 1\n7 2 1\n", "output": "32\n"}, {"input": "7\n2 1 1\n3 2 1\n4 2 1\n5 2 0\n6 7 1\n7 2 1\n", "output": "37\n"}, {"input": "7\n2 1 1\n3 2 0\n4 2 1\n5 2 0\n6 7 0\n7 2 1\n", "output": "29\n"}, {"input...
code_stdio
[ { "content": "We have a weighted directed graph with N vertices numbered 0 to N-1.\n\nThe graph initially has N-1 edges. The i-th edge (0 \\leq i \\leq N-2) is directed from Vertex i to Vertex i+1 and has a weight of 0.\n\nSnuke will now add a new edge (i → j) for every pair i, j (0 \\leq i,j \\leq N-1,\\ i \\n...
[{"input": "10\n190587 2038070 142162180 88207341 215145790 38 2 5 20\n32047998 21426 4177178 52 734621629 2596 102224223 5 1864\n49 481241221 1518272 51 772 146 8805349 3243297 449\n918151 126080576 5186563 46354 6646 491776 5750138 2897 161\n3656 7551068 2919714 43035419 495 3408 26 3317 2698\n455357 3 12 1857 5459 7...
code_stdio
[ { "content": "You are given an array of unique numbers. The numbers represent points. The higher the number the higher the points. \nIn the array [1,3,2] 3 is the highest point value so it gets 1st place. 2 is the second highest so it gets second place. 1 is the 3rd highest so it gets 3rd place. \n\nYour task ...
[{"input": "[22, 33, 18, 9, 110, 4, 1, 88, 6, 50]", "output": "[[5, 4, 6, 7, 1, 9, 10, 2, 8, 3]]", "fn_name": "rankings"}, {"input": "[10, 20, 40, 50, 30]", "output": "[[5, 4, 2, 1, 3]]", "fn_name": "rankings"}, {"input": "[1, 2, 3, 4, 5]", "output": "[[5, 4, 3, 2, 1]]", "fn_name": "rankings"}, {"input": "[3, 4, 1, 2, ...
code_functional
[ { "content": "You are given a prime number p, n integers a_1, a_2, …, a_n, and an integer k. \n\nFind the number of pairs of indexes (i, j) (1 ≤ i < j ≤ n) for which (a_i + a_j)(a_i^2 + a_j^2) ≡ k mod p.\n\nInput\n\nThe first line contains integers n, p, k (2 ≤ n ≤ 3 ⋅ 10^5, 2 ≤ p ≤ 10^9, 0 ≤ k ≤ p-1). p is gua...
[{"input": "7 7 3\n4 0 5 3 1 2 6\n", "output": "0"}, {"input": "6 11 2\n1 2 3 4 5 6\n", "output": "1\n"}, {"input": "6 10 2\n1 2 3 4 5 6\n", "output": "1\n"}, {"input": "6 10 2\n1 2 3 4 5 0\n", "output": "1\n"}, {"input": "6 17 2\n1 2 3 4 5 0\n", "output": "0\n"}, {"input": "6 17 2\n1 2 3 4 8 0\n", "output": "1\n"}, {"...
code_stdio
[ { "content": "The goal is to write a pair of functions the first of which will take a string of binary along with a specification of bits, which will return a numeric, signed complement in two's complement format. The second will do the reverse. It will take in an integer along with a number of bits, and return...
[{"input": "\"1010 1010 0010 0010 1110 1010 0010 1110\"\n32", "output": "[-1440552402]", "fn_name": "to_twos_complement"}, {"input": "\"1000 0000 1110 1111 0011 0100 1100 1010\"\n32", "output": "[-2131807030]", "fn_name": "to_twos_complement"}, {"input": "\"10110001000100000101100011111000\"\n32", "output": "[-13243287...
code_functional
[ { "content": "You and your friend are participating in a TV show \"Run For Your Prize\".\n\nAt the start of the show n prizes are located on a straight line. i-th prize is located at position a_{i}. Positions of all prizes are distinct. You start at position 1, your friend — at position 10^6 (and there is no pr...
[{"input": "10\n3934 38497 42729 45023 51842 68393 77476 82414 91465 98055\n", "output": "98054\n"}, {"input": "10\n3934 38497 42729 45023 51842 68393 77476 82414 91465 98055\n", "output": "98054\n"}, {"input": "6\n2 3 500000 999997 999998 999999\n", "output": "499999\n"}, {"input": "6\n2 3 500000 999997 999998 999999\...
code_stdio
[ { "content": "The fearless Ikta has finally hunted down the infamous Count Big Bridge! Count Bigbridge is now trapped in a rectangular room w meters wide and h meters deep, waiting for his end.\n\nIf you select a corner of the room and take the coordinate system so that the width direction is the x-axis and the...
[{"input": "1 3 1000 1000 1 0 0 4", "output": "1047197552288\n"}, {"input": "1 2 1000 1000 1 0 0 4", "output": "1570796325024\n"}, {"input": "1 3 1000 1000 0 0 0 4", "output": "1047197542296\n"}, {"input": "1 3 1001 1000 1 0 0 4", "output": "1049292990824\n"}, {"input": "2 3 1001 1000 1 1 1 2", "output": "524646496019\...
code_stdio
[ { "content": "# Background\n\nMy TV remote control has arrow buttons and an `OK` button.\n\nI can use these to move a \"cursor\" on a logical screen keyboard to type \"words\"...\n\nThe screen \"keyboard\" layout looks like this\n\n\n #tvkb {\n width : 300px;\n border: 5px solid gray; border-collapse: co...
[{"input": "\"mississippi\"", "output": "[35]", "fn_name": "tv_remote"}, {"input": "\"codewars\"", "output": "[36]", "fn_name": "tv_remote"}, {"input": "\"solution\"", "output": "[33]", "fn_name": "tv_remote"}, {"input": "\"these\"", "output": "[27]", "fn_name": "tv_remote"}, {"input": "\"words\"", "output": "[25]", "f...
code_functional
[ { "content": "The circle line of the Roflanpolis subway has $n$ stations.\n\nThere are two parallel routes in the subway. The first one visits stations in order $1 \\to 2 \\to \\ldots \\to n \\to 1 \\to 2 \\to \\ldots$ (so the next stop after station $x$ is equal to $(x+1)$ if $x < n$ and $1$ otherwise). The se...
[{"input": "100 26 63 60 23\n", "output": "YES\n"}, {"input": "100 26 63 60 20\n", "output": "YES\n"}, {"input": "100 26 77 60 20\n", "output": "YES\n"}, {"input": "100 45 77 77 20\n", "output": "YES\n"}, {"input": "100 45 90 77 20\n", "output": "YES\n"}, {"input": "100 45 10 77 20\n", "output": "YES\n"}, {"input": "10...
code_stdio
[ { "content": "Orac is studying number theory, and he is interested in the properties of divisors.\n\nFor two positive integers $a$ and $b$, $a$ is a divisor of $b$ if and only if there exists an integer $c$, such that $a\\cdot c=b$.\n\nFor $n \\ge 2$, we will denote as $f(n)$ the smallest positive divisor of $n...
[{"input": "5\n497347 19283\n2568 1000000000\n499979 123987\n93 19\n13 5\n", "output": "536584\n2000002568\n1247930\n132\n34\n"}, {"input": "5\n497347 19283\n2568 1000000000\n499979 123987\n93 19\n13 5\n", "output": "536584\n2000002568\n1247930\n132\n34\n"}, {"input": "5\n497347 19283\n2568 1000000000\n499979 202537\n9...
code_stdio
[ { "content": "<image>\n\nYou can preview the image in better quality by the link: [http://assets.codeforces.com/files/656/without-text.png](//assets.codeforces.com/files/656/without-text.png)\n\nInput\n\nThe only line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be...
[{"input": "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\n", "output": "-1300\n"}, {"input": "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzyzzzzzzzzzzzzzzzzzz\n", "output": "-1299\n"}, {"input": "zzzzzzyzzzzzzzzzzzzzzzzzzzzzzzzyzzzzzzzzzzzzzzzzzz\n", "output": "-1298\n"}, {"input": "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ...
code_stdio
[ { "content": "Grigoriy, like the hero of one famous comedy film, found a job as a night security guard at the museum. At first night he received embosser and was to take stock of the whole exposition.\n\nEmbosser is a special devise that allows to \"print\" the text of a plastic tape. Text is printed sequential...
[{"input": "dqcpcobpcobnznamznamzlykxkxlxlylzmaobnaobpbnanbpcoaobnboaoboanzlymzmykylymylzlylymanboanaocqdqesfrfs\n", "output": "1236\n"}, {"input": "uhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuh\n", "output": "1293\n"}, {"input": "uhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuh...
code_stdio
[ { "content": "Nastya received one more array on her birthday, this array can be used to play a traditional Byteland game on it. However, to play the game the players should first select such a subsegment of the array that $\\frac{p}{s} = k$, where p is the product of all integers on the given array, s is their ...
[{"input": "94 58\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 29 58 1 1 1 29 58 58 1 1 29 1 1 1 1 2 1 58 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 29 1 1 1 1 1 58 1 29 1 1 1 1 1 1 1 1 1 1 1 1 58 1 1 1 1 1 2 1 1 1\n", "output": "5\n"}, {"input": "94 58\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 29 58 1 1 1 29 58 58...
code_stdio
[ { "content": "Tonight is brain dinner night and all zombies will gather together to scarf down some delicious brains. The artful Heidi plans to crash the party, incognito, disguised as one of them. Her objective is to get away with at least one brain, so she can analyze the zombies' mindset back home and gain a...
[{"input": "1000000000\n", "output": "500000000\n"}, {"input": "1000000000\n", "output": "500000000\n"}, {"input": "1001000000\n", "output": "500500000\n"}, {"input": "1393488002\n", "output": "696744001\n"}, {"input": "1001000100\n", "output": "500500050\n"}, {"input": "1001000110\n", "output": "500500055\n"}, {"input...
code_stdio
[ { "content": "Takahashi and Aoki will take N exams numbered 1 to N. They have decided to compete in these exams. The winner will be determined as follows:\n\n* For each exam i, Takahashi decides its importance c_i, which must be an integer between l_i and u_i (inclusive).\n\n* Let A be \\sum_{i=1}^{N} c_i \\tim...
[{"input": "10 1000\n451 4593 6263\n324 310 6991\n225 1431 7068\n133 1757 4072\n204 3676 4328\n840 6600 9080\n415 1545 15200\n709 5467 8674\n862 6504 9835\n283 4965 9980", "output": "2373\n"}, {"input": "10 1000\n451 4593 6263\n324 310 9662\n378 1431 7068\n120 1757 9218\n204 3676 4328\n840 6221 9080\n684 1545 8511\n709...
code_stdio
[ { "content": "Takahashi has decided to give a string to his mother.\n\nThe value of a string T is the length of the longest common subsequence of T and T', where T' is the string obtained by reversing T. That is, the value is the longest length of the following two strings that are equal: a subsequence of T (po...
[{"input": "ssgtnscdnaqreedocoa\n14", "output": "19"}, {"input": "tsetnocdnargredocta\n3", "output": "15"}, {"input": "tsetnocdnargredocta\n2", "output": "13"}, {"input": "tsetnocdnargredocta\n1", "output": "11"}, {"input": "atcodergrandcontest\n6", "output": "17"}, {"input": "atcodergrandcontest\n5", "output": "16"}, ...
code_stdio
[ { "content": "Since most contestants do not read this part, I have to repeat that Bitlandians are quite weird. They have their own jobs, their own working method, their own lives, their own sausages and their own games!\n\nSince you are so curious about Bitland, I'll give you the chance of peeking at one of the...
[{"input": "3\n184 222 102\n", "output": "BitAryo\n"}, {"input": "3\n101 186 223\n", "output": "BitAryo\n"}, {"input": "3\n101 186 223\n", "output": "BitAryo\n"}, {"input": "3\n184 222 102\n", "output": "BitAryo\n"}, {"input": "3\n103 286 100\n", "output": "BitLGM\n"}, {"input": "3\n244 241 295\n", "output": "BitLGM\n"...
code_stdio
[ { "content": "Lеt's create function to play cards. Our rules:\n\nWe have the preloaded `deck`:\n\n```\ndeck = ['joker','2♣','3♣','4♣','5♣','6♣','7♣','8♣','9♣','10♣','J♣','Q♣','K♣','A♣',\n '2♦','3♦','4♦','5♦','6♦','7♦','8♦','9♦','10♦','J♦','Q♦','K♦','A♦',\n '2♥','3♥','4♥','5♥','6♥',...
[{"input": "\"3\\u2663\"\n\"Q\\u2663\"\n\"\\u2666\"", "output": "[\"The second card won.\"]", "fn_name": "card_game"}, {"input": "\"A\\u2660\"\n\"2\\u2666\"\n\"\\u2666\"", "output": "[\"The second card won.\"]", "fn_name": "card_game"}, {"input": "\"Q\\u2663\"\n\"3\\u2663\"\n\"\\u2666\"", "output": "[\"The first card w...
code_functional
[ { "content": "A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, \"abcba\", \"a\", and \"abba\" are palindromes, while \"abab\" and \"xy\" are not.\n\nA string is called a substring of another string, if it can be obtained from t...
[{"input": "21\narozauprlanalapuazoaa\n", "output": "aaaaaaaallnoopprruuzz\n"}, {"input": "21\narozbuprlanalapuazoaa\n", "output": "aaaaaaabllnoopprruuzz\n"}, {"input": "21\narozbuarlpnalapuayoaa\n", "output": "aaaaaaabllnoopprruuyz\n"}, {"input": "21\naaoyaupalanplrbubzora\n", "output": "aaaaaabbllnoopprruuyz\n"}, {"i...
code_stdio
[ { "content": "This is the performance version of [this kata](https://www.codewars.com/kata/59afff65f1c8274f270020f5).\n\n---\n\nImagine two rings with numbers on them. The inner ring spins clockwise and the outer ring spins anti-clockwise. We start with both rings aligned on 0 at the top, and on each move we sp...
[{"input": "16777216\n14348907", "output": "[23951671]", "fn_name": "spinning_rings"}, {"input": "2\n10", "output": "[13]", "fn_name": "spinning_rings"}, {"input": "10\n2", "output": "[10]", "fn_name": "spinning_rings"}, {"input": "5\n5", "output": "[3]", "fn_name": "spinning_rings"}, {"input": "7\n9", "output": "[4]",...
code_functional
[ { "content": "Consider a 32-bit real type with 7 bits from the right as the decimal part, the following 24 bits as the integer part, and the leftmost 1 bit as the sign part as shown below (b1, ..., b32). Represents 0 or 1).\n\n<image>\n\n\nTo translate this format into a decimal representation that is easy for ...
[{"input": "8\n00101110\n66920828\n00000080\n00000040\n000000c0\n00100110\n45306216\n07f00009", "output": "8226.125\n13444112.3125\n1.0\n0.5\n1.5\n8194.125\n9068740.171875\n1040384.0703125\n"}, {"input": "8\n00100100\n45780507\n00000080\n00000040\n0c000000\n00000101\n15330257\n80000f70", "output": "8194.0\n9105418.0546...
code_stdio
[ { "content": "You are given an integer N. Consider an infinite N-ary tree as shown below:\n\n<image>\n\nFigure: an infinite N-ary tree for the case N = 3\n\nAs shown in the figure, each vertex is indexed with a unique positive integer, and for every positive integer there is a vertex indexed with it. The root o...
[{"input": "3 3\n11 11\n1 15\n3 15", "output": "11\n1\n1\n"}, {"input": "2 3\n7 7\n8 59\n5 16", "output": "7\n1\n2\n"}, {"input": "10 2\n7 5\n23 23\n0 3", "output": "1\n23\n"}, {"input": "2 3\n7 7\n5 83\n5 16", "output": "7\n5\n2\n"}, {"input": "3 3\n7 7\n5 83\n5 16", "output": "7\n1\n5\n"}, {"input": "3 3\n7 2\n5 83\n...
code_stdio
[ { "content": "You are given a number $n$ (divisible by $3$) and an array $a[1 \\dots n]$. In one move, you can increase any of the array elements by one. Formally, you choose the index $i$ ($1 \\le i \\le n$) and replace $a_i$ with $a_i + 1$. You can choose the same index $i$ multiple times for different moves....
[{"input": "4\n6\n0 2 5 5 4 1\n6\n2 0 2 0 0 0\n9\n14 1 3 4 2 10 3 1 12\n6\n1 1 2 3 4 5\n", "output": "1\n2\n1\n2\n"}, {"input": "4\n6\n0 2 1 4 4 1\n6\n0 0 2 1 0 0\n9\n7 1 3 0 2 12 2 13 5\n6\n1 0 2 10 1 8\n", "output": "3\n3\n0\n2\n"}, {"input": "4\n6\n0 2 1 4 4 1\n6\n0 0 2 1 0 0\n9\n7 1 3 0 2 12 2 13 9\n6\n1 0 2 10 1 8...
code_stdio
[ { "content": "Have a look at the following numbers.\n\n```\n n | score\n---+-------\n 1 | 50\n 2 | 150\n 3 | 300\n 4 | 500\n 5 | 750\n```\n\nCan you find a pattern in it? If so, then write a function `getScore(n)`/`get_score(n)`/`GetScore(n)` which returns the score for any positive number `n`:\n\n```c++\n...
[{"input": "10000", "output": "[2500250000]", "fn_name": "get_score"}, {"input": "12345", "output": "[3810284250]", "fn_name": "get_score"}, {"input": "1000", "output": "[25025000]", "fn_name": "get_score"}, {"input": "1234", "output": "[38099750]", "fn_name": "get_score"}, {"input": "100", "output": "[252500]", "fn_na...
code_functional
[ { "content": "There is a very long bench. The bench is divided into M sections, where M is a very large integer.\n\nInitially, the bench is vacant. Then, M people come to the bench one by one, and perform the following action:\n\n* We call a section comfortable if the section is currently unoccupied and is not ...
[{"input": "100\n-X-X-X--X-X--X--X-X--X-X-X--X-X-X--X--X-X-X-X--X--X-X-X-X-X-X-X-X-X-X-X-X-X-X-X--X-X-X-X-X-X-X-X-X-X", "output": "0 0 435664291\n"}, {"input": "100\nX-X-X-X-X-X-X-X-X-X--X-X-X-X-X-X-X-X-X-X-X-X-X-X-X--X--X-X-X-X--X--X-X-X--X-X-X--X-X--X--X-X--X-X-X-", "output": "0 0 435664291"}, {"input": "20\nX-X-X--X...
code_stdio
[ { "content": "[Chopsticks (singular: chopstick) are short, frequently tapered sticks used in pairs of equal length, which are used as the traditional eating utensils of China, Japan, Korea and Vietnam. Originated in ancient China, they can also be found in some areas of Tibet and Nepal that are close to Han Chi...
[{"input": "5 3\n13\n-2\n3\n9\n1", "output": "1\n"}, {"input": "5 3\n13\n-3\n3\n9\n1", "output": "1\n"}, {"input": "5 3\n13\n-3\n3\n1\n1", "output": "1\n"}, {"input": "5 4\n17\n-1\n3\n9\n2", "output": "1\n"}, {"input": "5 1\n13\n-3\n3\n1\n1", "output": "1\n"}, {"input": "5 2\n10\n-1\n3\n9\n6", "output": "1\n"}, {"input...
code_stdio
[ { "content": "It is nighttime and Joe the Elusive got into the country's main bank's safe. The safe has n cells positioned in a row, each of them contains some amount of diamonds. Let's make the problem more comfortable to work with and mark the cells with positive numbers from 1 to n from the left to the right...
[{"input": "95 97575868 5\n4612 1644 3613 5413 5649 2419 5416 3926 4610 4419 2796 5062 2112 1071 3790 4220 3955 2142 4638 2832 2702 2115 2045 4085 3599 2452 5495 4767 1368 2344 4625 4132 5755 5815 2581 6259 1330 4938 815 5430 1628 3108 4342 3692 2928 1941 3714 4498 4471 4842 1822 867 3395 2587 3372 6394 6423 3728 3720 ...
code_stdio
[ { "content": "Problem statement\n\nThere is a tree consisting of $ N $ vertices $ N-1 $ edges, and the $ i $ th edge connects the $ u_i $ and $ v_i $ vertices.\n\nEach vertex has a button, and the button at the $ i $ th vertex is called the button $ i $.\n\nFirst, the beauty of the button $ i $ is $ a_i $.\n\nE...
[{"input": "4\n1 2\n2 3\n1 4\n1 3 2 -1\n-5 2 9 -1", "output": "33\n"}, {"input": "4\n1 2\n2 3\n1 4\n0 3 0 -1\n-4 2 5 -1", "output": "23\n"}, {"input": "4\n1 2\n1 4\n3 4\n-1 3 2 0\n-8 4 8 -1", "output": "27\n"}, {"input": "4\n1 2\n2 4\n3 4\n1 5 2 1\n-4 1 10 -1", "output": "38\n"}, {"input": "4\n1 2\n2 3\n1 4\n1 5 0 -1\n...
code_stdio
[ { "content": "You are given an integer x of n digits a_1, a_2, …, a_n, which make up its decimal notation in order from left to right.\n\nAlso, you are given a positive integer k < n.\n\nLet's call integer b_1, b_2, …, b_m beautiful if b_i = b_{i+k} for each i, such that 1 ≤ i ≤ m - k.\n\nYou need to find the s...
[{"input": "20 19\n19999999999999999999\n", "output": "20\n20000000000000000002\n"}, {"input": "20 10\n21474836472147483648\n", "output": "20\n21474836482147483648\n"}, {"input": "20 10\n19999999999999999999\n", "output": "20\n20000000002000000000\n"}, {"input": "20 10\n30583716933544117071\n", "output": "20\n305837169...
code_stdio
[ { "content": "You are given array a with n elements and the number m. Consider some subsequence of a and the value of least common multiple (LCM) of its elements. Denote LCM as l. Find any longest subsequence of a with the value l ≤ m.\n\nA subsequence of a is an array we can get by erasing some elements of a. ...
[{"input": "100 343\n999 284 486 785 176 742 856 415 992 601 600 122 460 214 338 92 627 913 376 835 384 914 335 179 409 957 96 784 531 43 584 206 971 799 592 801 870 978 437 517 466 952 1 327 731 689 816 681 383 969 452 298 114 687 314 436 267 154 827 197 805 207 284 550 351 700 94 567 524 329 414 561 284 666 702 226 7...
code_stdio
[ { "content": "Denis, after buying flowers and sweets (you will learn about this story in the next task), went to a date with Nastya to ask her to become a couple. Now, they are sitting in the cafe and finally... Denis asks her to be together, but ... Nastya doesn't give any answer.\n\nThe poor boy was very upse...
[{"input": "10 10\n1101001\n0110000\n0111010\n0010000\n1010000\n0111000\n1011011\n1010010\n1101011\n1111110\n", "output": "9941743758\n"}, {"input": "10 10\n0101111\n0000000\n1111011\n1011011\n1011011\n1111011\n0010010\n1010010\n1101111\n0000000\n", "output": "8993391761\n"}, {"input": "10 10\n1101001\n0110000\n0111010...
code_stdio
[ { "content": "n children are standing in a circle and playing a game. Children's numbers in clockwise order form a permutation a_1, a_2, ..., a_{n} of length n. It is an integer sequence such that each integer from 1 to n appears exactly once in it.\n\nThe game consists of m steps. On each step the current lead...
[{"input": "100 100\n96 73 23 74 35 44 75 13 62 50 76 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63...
code_stdio
[ { "content": "Consider a long corridor which can be divided into $n$ square cells of size $1 \\times 1$. These cells are numbered from $1$ to $n$ from left to right.\n\nThere are two people in this corridor, a hooligan and a security guard. Initially, the hooligan is in the $a$-th cell, the guard is in the $b$-...
[{"input": "3\n25 2 3 5\n2 7\n11 2 11 10\n1 1\n4 2 3 6\n4 4\n", "output": "1\n0\n1\n"}, {"input": "3\n11 2 3 20\n4 4\n7 2 3 -1\n5 1\n1 2 4 10\n0 1\n", "output": "2\n2\n2\n"}, {"input": "3\n13 2 3 1\n1 8\n7 2 1 6\n13 2\n7 2 3 12\n2 4\n", "output": "1\n1\n2\n"}, {"input": "3\n25 2 3 7\n2 7\n11 2 3 10\n1 1\n4 2 3 6\n4 4\n...
code_stdio
[ { "content": "It is well known that Berland has n cities, which form the Silver ring — cities i and i + 1 (1 ≤ i < n) are connected by a road, as well as the cities n and 1. The goverment have decided to build m new roads. The list of the roads to build was prepared. Each road will connect two cities. Each road...
[{"input": "100 50\n79 24\n65 69\n44 6\n49 53\n26 22\n24 76\n10 2\n19 44\n44 10\n87 82\n91 87\n23 92\n69 66\n95 30\n90 24\n95 20\n76 36\n82 24\n63 80\n70 72\n34 76\n42 40\n17 100\n66 64\n85 96\n34 30\n36 69\n45 56\n36 62\n26 38\n31 28\n79 64\n78 69\n41 62\n36 40\n64 67\n21 13\n90 88\n28 30\n59 6\n59 56\n63 1\n24 91\n12...
code_stdio
[ { "content": "There are two rectangles whose bases are parallel to the x-axis. Read the lower left coordinates (xa1, ya1) and upper right coordinates (xa2, ya2) of rectangle A, the lower left coordinates (xb1, yb1) and upper right coordinates (xb2, yb2) of rectangle B, and rectangle A and B Create a program tha...
[{"input": "2.223070606524155 1.4960198812761343 6.988386378768428 7.000508921833194 4.205136917017809 2.2424931885142083 5.1569216527923185 5.191516114177997\n1.1891195386027824 2.2619900314452366 6.37960763673212 8.721050113941343 1.5944937676218054 1.5944269037686163 7.4405536026925985 7.593208053380714\n1.948236149...
code_stdio
[ { "content": "Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not.\n\nTwo integers x, y are written on the blackboard. It is allowed to erase one of them and replace it wi...
[{"input": "-1000000000000000000 -1000000000000000000 -1000000000000000000\n", "output": "0\n"}, {"input": "-1000000000000000000 -1000000000000000000 -999999999999999999\n", "output": "-1\n"}, {"input": "-1000000000000000000 -1000000000000000000 -1000000000000000000\n", "output": "0\n"}, {"input": "-1000000000000000000...
code_stdio
[ { "content": "На тренировку по подготовке к соревнованиям по программированию пришли n команд. Тренер для каждой команды подобрал тренировку, комплект задач для i-й команды занимает a_{i} страниц. В распоряжении тренера есть x листов бумаги, у которых обе стороны чистые, и y листов, у которых только одна сторон...
[{"input": "100 1019 35\n34 50 60 47 49 49 59 60 37 51 3 86 93 33 78 31 75 87 26 74 32 30 52 57 44 10 33 52 78 16 36 77 53 49 98 82 93 85 16 86 19 57 17 24 73 93 37 46 27 87 35 76 33 91 96 55 34 65 97 66 7 30 45 68 18 51 77 43 99 76 35 47 6 1 83 49 67 85 89 17 20 7 49 33 43 59 53 71 86 71 3 47 65 59 40 34 35 44 46 64\n...
code_stdio
[ { "content": "Takahashi is playing with N cards.\n\nThe i-th card has an integer X_i on it.\n\nTakahashi is trying to create as many pairs of cards as possible satisfying one of the following conditions:\n\n* The integers on the two cards are the same.\n* The sum of the integers on the two cards is a multiple o...
[{"input": "15 10\n1 5 6 10 11 11 11 20 21 25 25 26 99 124 99", "output": "6\n"}, {"input": "15 10\n0 5 6 10 11 11 11 20 21 25 25 26 99 131 99", "output": "5\n"}, {"input": "15 10\n0 5 6 10 11 11 11 20 21 46 25 26 99 131 99", "output": "5\n"}, {"input": "15 10\n0 5 6 10 11 11 17 20 21 46 25 26 99 131 99", "output": "5\...
code_stdio
[ { "content": "There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.\nFor each square, you will perform either of the following operations once:\n - Decrease the height of the square by 1.\n - Do nothing.\nDetermine if it is possible to perform the operatio...
[{"input": "1\n1000000000\n", "output": "Yes\n"}, {"input": "5\n1 2 1 1 3\n", "output": "Yes\n"}, {"input": "5\n1 2 3 4 5\n", "output": "Yes\n"}, {"input": "1\n1000010000", "output": "Yes\n"}, {"input": "1\n1000011000", "output": "Yes\n"}, {"input": "1\n1000011100", "output": "Yes\n"}, {"input": "1\n1000001100", "outpu...
code_stdio
[ { "content": "Given are an N \\times N matrix and an integer K. The entry in the i-th row and j-th column of this matrix is denoted as a_{i, j}. This matrix contains each of 1, 2, \\dots, N^2 exactly once.\nSigma can repeat the following two kinds of operation arbitrarily many times in any order.\n - Pick two i...
[{"input": "49 4643\n1 50 99 148 197 246 295 344 393 442 491 540 589 638 687 736 785 834 883 932 981 1030 1079 1128 1177 1226 1275 1324 1373 1422 1471 1520 1569 1618 1667 1716 1765 1814 1863 1912 1961 2010 2059 2108 2157 2185 2255 2304 2353\n2 51 742 149 198 247 296 345 394 443 1148 541 590 639 688 737 786 835 1431 933...
code_stdio
[ { "content": "Alice and Bob are playing a game with n piles of stones. It is guaranteed that n is an even number. The i-th pile has a_i stones.\n\nAlice and Bob will play a game alternating turns with Alice going first.\n\nOn a player's turn, they must choose exactly n/2 nonempty piles and independently remove ...
[{"input": "50\n42 31 49 11 28 38 49 32 15 22 10 18 43 39 46 32 10 19 13 32 19 40 34 28 28 39 19 3 1 47 10 18 19 31 21 7 39 37 34 45 19 21 35 46 10 24 45 33 20 40\n", "output": "Alice\n"}, {"input": "50\n42 31 49 11 28 13 49 32 15 22 10 18 43 39 46 32 10 19 13 32 19 40 34 28 28 39 19 3 1 47 10 18 19 31 21 7 39 37 34 45...
code_stdio
[ { "content": "There are $n$ block towers in a row, where tower $i$ has a height of $a_i$. You're part of a building crew, and you want to make the buildings look as nice as possible. In a single day, you can perform the following operation:\n\nChoose two indices $i$ and $j$ ($1 \\leq i, j \\leq n$; $i \\neq j$)...
[{"input": "3\n3\n10 14 10\n4\n4 1 1 2\n5\n2 1 3 1 10\n", "output": "1\n0\n1\n"}, {"input": "3\n3\n10 10 10\n4\n3 2 1 2\n5\n1 2 3 1 5\n", "output": "0\n0\n1\n"}, {"input": "3\n3\n10 10 10\n4\n3 2 0 2\n5\n1 2 3 1 5\n", "output": "0\n1\n1\n"}, {"input": "3\n3\n10 10 10\n4\n3 2 1 2\n5\n1 2 3 1 4\n", "output": "0\n0\n1\n"}...
code_stdio
[ { "content": "There is a complete graph of m vertices. Initially, the edges of the complete graph are uncolored. Sunuke did the following for each i (1 ≤ i ≤ n): Select ai vertices from the complete graph and color all edges connecting the selected vertices with color i. None of the sides were painted in multip...
[{"input": "5\n2\n3\n4\n10\n6", "output": "17\n"}, {"input": "5\n2\n3\n3\n5\n6", "output": "11\n"}, {"input": "5\n2\n3\n5\n5\n6", "output": "13\n"}, {"input": "5\n2\n3\n3\n2\n6", "output": "9\n"}, {"input": "5\n2\n3\n4\n5\n6", "output": "12"}, {"input": "2\n80\n22", "output": "101\n"}, {"input": "2\n139\n5", "output": ...
code_stdio
[ { "content": "Given are two strings S and T.\nLet us change some of the characters in S so that T will be a substring of S.\nAt least how many characters do we need to change?\nHere, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but not a substring of xxyxx.\n\n-----Constra...
[{"input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "You are trying to cross a river by jumping along stones. Every time you land on a stone, you hop forwards by the value of that stone. If you skip *over* a stone then its value doesn't affect you in any way. Eg:\n\n```\n x--x-----x-->\n[1][2][5][1]\n\n```\n\nOf course, crossing from the other side ...
[{"input": "[2, 2, 3, 1, 1, 2, 1]", "output": "[7]", "fn_name": "hop_across"}, {"input": "[1, 2, 1, 2]", "output": "[5]", "fn_name": "hop_across"}, {"input": "[1, 2, 5, 1]", "output": "[5]", "fn_name": "hop_across"}, {"input": "[2, 1, 1]", "output": "[5]", "fn_name": "hop_across"}, {"input": "[1, 1]", "output": "[4]", ...
code_functional
[ { "content": "Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.\n\nSergey gives Nastya the word t and wants to get the word p out of it. Nastya remov...
[{"input": "aaaaaaaadbaaabbbbbddaaabdadbbbbbdbbabbbabaabdbbdababbbddddbdaabbddbbbbabbbbbabadaadabaaaadbbabbbaddb\naaaaaaaaaaaaaa\n61 52 5 43 53 81 7 96 6 9 34 78 79 12 8 63 22 76 18 46 41 56 3 20 57 21 75 73 100 94 35 69 32 4 70 95 88 44 68 10 71 98 23 89 36 62 28 51 24 30 74 55 27 80 38 48 93 1 19 84 13 11 86 60 87 33...
code_stdio
[ { "content": "Example\n\nInput\n\n6 3\n1 0 0 1 0 1\n1 3 2\n\n\nOutput\n\n1\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": "1 3\n1 -1 0 1 -1 1\n2 1 -1", "output": "0\n"}, {"input": "1 3\n1 -1 0 1 0 1\n-1 3 2", "output": "0\n"}, {"input": "1 3\n1 0 -1 1 0 1\n-1 3 2", "output": "0\n"}, {"input": "1 3\n1 -1 0 1 0 1\n-1 1 2", "output": "0\n"}, {"input": "1 3\n1 -1 0 1 -1 1\n2 1 0", "output": "0\n"}, {"input": "1 3\n1 0 0 1 0 1\n-1 3...
code_stdio
[ { "content": "## Task:\n\nYou have to write a function `pattern` which returns the following Pattern(See Examples) upto n number of rows. \n\n* Note:```Returning``` the pattern is not the same as ```Printing``` the pattern.\n\n### Rules/Note:\n\n* The pattern should be created using only unit digits.\n* If `n <...
[{"input": "27", "output": "[\"777777777777777777777777777\\n766666666666666666666666666\\n765555555555555555555555555\\n765444444444444444444444444\\n765433333333333333333333333\\n765432222222222222222222222\\n765432111111111111111111111\\n765432100000000000000000000\\n765432109999999999999999999\\n7654321098888888888...
code_functional
[ { "content": "Emuskald is an avid horticulturist and owns the world's longest greenhouse — it is effectively infinite in length.\n\nOver the years Emuskald has cultivated n plants in his greenhouse, of m different plant species numbered from 1 to m. His greenhouse is very narrow and can be viewed as an infinite...
[{"input": "20 15\n6 8719.787178\n10 13066.663722\n15 58623.690996\n9 184321.819759\n3 227999.294560\n2 279836.330518\n9 282806.308675\n8 311056.507765\n1 312315.562927\n5 459200.373445\n14 563454.265947\n7 647364.984868\n13 679762.0281866578\n4 684192.647497\n1 733119.607626\n7 748637.778398\n12 828048.945890\n11 8936...
code_stdio
[ { "content": "One day the Codeforces round author sat exams. He had n exams and he needed to get an integer from 2 to 5 for each exam. He will have to re-sit each failed exam, i.e. the exam that gets mark 2. \n\nThe author would need to spend too much time and effort to make the sum of his marks strictly more t...
[{"input": "45 104\n", "output": "31\n"}, {"input": "50 100\n", "output": "50\n"}, {"input": "47 128\n", "output": "13\n"}, {"input": "46 127\n", "output": "11\n"}, {"input": "42 104\n", "output": "22\n"}, {"input": "56 128\n", "output": "40\n"}, {"input": "50 101\n", "output": "49\n"}, {"input": "53 116\n", "output": ...
code_stdio
[ { "content": "The Rebel fleet is afraid that the Empire might want to strike back again. Princess Heidi needs to know if it is possible to assign R Rebel spaceships to guard B bases so that every base has exactly one guardian and each spaceship has exactly one assigned base (in other words, the assignment is a ...
[{"input": "10 10\n8530 -3814\n-9330 -6035\n3951 -217\n-9276 8291\n636 -3118\n5024 -2403\n4601 7977\n-3620 -1428\n4954 -9632\n-9852 6553\n-3457 5430\n-8866 -7343\n1020 -5748\n5043 -3820\n-2832 1528\n-5058 -825\n2406 -3530\n9152 -7463\n-8547 7108\n2492 8953\n", "output": "Yes\n"}, {"input": "10 10\n8530 -3814\n-9330 -60...
code_stdio
[ { "content": "Fox Ciel is playing a card game with her friend Fox Jiro. There are n piles of cards on the table. And there is a positive integer on each card.\n\nThe players take turns and Ciel takes the first turn. In Ciel's turn she takes a card from the top of any non-empty pile, and in Jiro's turn he takes ...
[{"input": "3\n3 1000 1000 1000\n6 1000 1000 1000 1000 1000 1000\n5 1000 1000 1000 1000 1000\n", "output": "7000 7000\n"}, {"input": "3\n3 1000 1000 1001\n6 1000 1000 1000 1000 1000 1000\n5 1000 1000 1000 1000 1000\n", "output": "7000 7001\n"}, {"input": "3\n3 1000 1000 1001\n6 1000 1000 1000 1000 1000 1001\n5 1000 100...
code_stdio
[ { "content": "Input Format\n\n\nN K\na_1 a_2 a_3 ... a_N\n\n\nOutput Format\n\nPrint the minimum cost in one line. In the end put a line break.\n\n\nConstraints\n\n* 1 ≤ K ≤ N ≤ 15\n* 1 ≤ a_i ≤ 10^9\n\n\n\nScoring\n\nSubtask 1 [120 points]\n\n\n* N = K\n\nSubtask 2 [90 points]\n\n\n* N ≤ 5\n* a_i ≤ 7\n\nSubtask...
[{"input": "5 5\n11683 3774 3598 4173 3424", "output": "31773\n"}, {"input": "5 4\n11683 3774 3598 4173 3424", "output": "23510\n"}, {"input": "5 5\n3949 3208 13644 3469 3424", "output": "21140\n"}, {"input": "5 5\n4931 3208 13644 3469 3424", "output": "22122\n"}, {"input": "5 5\n2312 3208 13644 3469 3424", "output": "...
code_stdio
[ { "content": "Make a function that returns the value multiplied by 50 and increased by 6. If the value entered is a string it should return \"Error\".\n\nNote: in `C#`, you'll always get the input as a string, so the above applies if the string isn't representing a double value.\n\nWrite Python code to solve th...
[{"input": "\"RyanIsCool\"", "output": "[\"Error\"]", "fn_name": "problem"}, {"input": "\"hello\"", "output": "[\"Error\"]", "fn_name": "problem"}, {"input": "1.2", "output": "[66]", "fn_name": "problem"}, {"input": "5", "output": "[256]", "fn_name": "problem"}, {"input": "3", "output": "[156]", "fn_name": "problem"}, ...
code_functional
[ { "content": "Let's play Amidakuji.\n\nIn the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.\n\n<image>\n\n\nIn the starting points (top of the figure), numbers are assigned to vertical lines in ascending order fro...
[{"input": "5\n-1\n1,4\n4,5\n,12\n43,", "output": "1\n2\n3\n4\n5\n"}, {"input": "5\n-1\n1,4\n5,4\n,12\n43,", "output": "1\n2\n3\n4\n5\n"}, {"input": "5\n-1\n1,4\n5,4\n-12\n43,", "output": "1\n2\n3\n4\n5\n"}, {"input": "5\n4\n2,4\n3,5\n2,1\n3,4", "output": "4\n1\n2\n5\n3\n"}, {"input": "5\n4\n2,4\n4,5\n2,1\n3,4", "outpu...
code_stdio
[ { "content": "Implement `String#parse_mana_cost`, which parses [Magic: the Gathering mana costs](http://mtgsalvation.gamepedia.com/Mana_cost) expressed as a string and returns a `Hash` with keys being kinds of mana, and values being the numbers.\n\nDon't include any mana types equal to zero.\n\nFormat is:\n\n* ...
[{"input": "\"1wubrg\"", "output": "[{\"*\": 1, \"w\": 1, \"u\": 1, \"b\": 1, \"r\": 1, \"g\": 1}]", "fn_name": "parse_mana_cost"}, {"input": "\"3wubrg\"", "output": "[{\"*\": 3, \"w\": 1, \"u\": 1, \"b\": 1, \"r\": 1, \"g\": 1}]", "fn_name": "parse_mana_cost"}, {"input": "\"wwuubbrrgg\"", "output": "[{\"w\": 2, \"u\":...
code_functional
[ { "content": "Consider a table G of size n × m such that G(i, j) = GCD(i, j) for all 1 ≤ i ≤ n, 1 ≤ j ≤ m. GCD(a, b) is the greatest common divisor of numbers a and b.\n\nYou have a sequence of positive integer numbers a_1, a_2, ..., a_{k}. We say that this sequence occurs in table G if it coincides with consec...
[{"input": "1000000000000 1000000000000 116\n1587924000 7 2 3 4 5 6 1 56 9 10 1 12 13 2 105 16 1 18 1 620 3 14 1 24 25 26 27 4 203 30 1 32 3 2 5 252 1 2 39 40 1 6 7 4 45 2 1 48 1 350 93 52 1 54 5 8 21 58 1 60 1 2 9 224 65 6 1 4 3 10 7 72 1 2 75 4 1 546 1 80 81 62 1 12 35 2 87 8 1 90 13 28 3 2 5 96 1 2 63 100 1 6 1 104 ...
code_stdio
[ { "content": "You are given three integers, A, B and C.\n\nAmong them, two are the same, but the remaining one is different from the rest.\n\nFor example, when A=5,B=7,C=5, A and C are the same, but B is different.\n\nFind the one that is different from the rest among the given three integers. \n\n-----Constra...
[{"input": "-100 100 100\n", "output": "-100\n"}, {"input": "-123 100 100", "output": "-123\n"}, {"input": "-157 100 100", "output": "-157\n"}, {"input": "-100 100 100", "output": "-100"}, {"input": "-25 100 100", "output": "-25\n"}, {"input": "-19 100 100", "output": "-19\n"}, {"input": "-27 100 100", "output": "-27\n...
code_stdio
[ { "content": "You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b.\n\nThe i-th operation is as follows:\n\n1. Append a_i to the end of b.\n2. Reverse the order of the elements in b.\n\n\n\nFind the sequence b obtained after t...
[{"input": "6\n-1 22 1 75 15 0", "output": "0 75 22 -1 1 15\n"}, {"input": "6\n2 20 0 59 10 1", "output": "1 59 20 2 0 10\n"}, {"input": "6\n2 20 0 59 10 0", "output": "0 59 20 2 0 10\n"}, {"input": "6\n2 20 0 59 12 0", "output": "0 59 20 2 0 12\n"}, {"input": "6\n0 20 0 59 12 0", "output": "0 59 20 0 0 12\n"}, {"input...
code_stdio
[ { "content": "This is yet another problem dealing with regular bracket sequences.\n\nWe should remind you that a bracket sequence is called regular, if by inserting «+» and «1» into it we can get a correct mathematical expression. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «((...
[{"input": "())(((((())())((((()))(())))())())(((()(()()()())(())()))((()(())())()()))()(()())))))(()))((())((((\n", "output": "80 1\n"}, {"input": ")(()(((((())))))(((()))))))((()(((((((())())()))))((((((((())))((((((())))))(()((((()))))(()))))))))\n", "output": "68 1\n"}, {"input": "))(((((((()((((())(((((((((()())))...
code_stdio
[ { "content": "Find the number of integers between 1 and K (inclusive) satisfying the following condition, modulo 10^9 + 7:\n\n* The sum of the digits in base ten is a multiple of D.\n\nConstraints\n\n* All values in input are integers.\n* 1 \\leq K < 10^{10000}\n* 1 \\leq D \\leq 100\n\nInput\n\nInput is given ...
[{"input": "98765432109876543210\n66", "output": "678072802\n"}, {"input": "98765432109876543210\n18", "output": "852803440\n"}, {"input": "98765432109876543210\n11", "output": "501683936\n"}, {"input": "98765432109876543210\n12", "output": "209841644\n"}, {"input": "98765432109876543210\n10", "output": "851852334\n"},...
code_stdio
[ { "content": "In Dwango Co., Ltd., there is a content distribution system named 'Dwango Media Cluster', and it is called 'DMC' for short.\nThe name 'DMC' sounds cool for Niwango-kun, so he starts to define DMC-ness of a string.\n\nGiven a string S of length N and an integer k (k \\geq 3), he defines the k-DMC n...
[{"input": "54\nDIALUPWIDEAREADETWORKGAMINGOPERATIONCORPORATIONLIMITEN\n3\n20 30 40", "output": "0\n2\n3\n"}, {"input": "54\nDIALUPWIDEAREADETWORKGAMINGOPERATIONCORPORATIONLIMITEN\n3\n20 38 40", "output": "0\n3\n3\n"}, {"input": "54\nDIALUPWIDEAREADETWORKGAMINGOPERATIONCORPORATIONLIMITEN\n3\n20 30 32", "output": "0\n2\...
code_stdio
[ { "content": "# Task\n Let's say that `\"g\" is happy` in the given string, if there is another \"g\" immediately to the right or to the left of it.\n \n Find out if all \"g\"s in the given string are happy.\n\n# Example\n For `str = \"gg0gg3gg0gg\"`, the output should be `true`.\n \n For `str = \"gog\"`, the o...
[{"input": "\"A half of a half is a quarter.\"", "output": "[true]", "fn_name": "happy_g"}, {"input": "\"bigger is ggooder\"", "output": "[true]", "fn_name": "happy_g"}, {"input": "\"ggg ggg g ggg\"", "output": "[false]", "fn_name": "happy_g"}, {"input": "\"gg0gg3gg0gg\"", "output": "[true]", "fn_name": "happy_g"}, {"i...
code_functional
[ { "content": "Read problems statements in Mandarin Chinese here \n\n------ Problem Statement ------ \n\nMaxim likes dividers of the numbers. Also Maxim is fond of lucky numbers of small elephant from Lviv city.\n \nIf you remember, lucky numbers are positive integers whose decimal representation contains only t...
[{"input": "10\n1\n2\n1\n10\n5\n11\n10\n8\n14\n4", "output": "0\n0\n0\n0\n0\n0\n0\n1\n2\n1\n"}, {"input": "10\n2\n2\n1\n7\n5\n13\n14\n8\n18\n5", "output": "0\n0\n0\n1\n0\n0\n2\n1\n0\n0\n"}, {"input": "10\n2\n2\n1\n10\n5\n11\n7\n8\n14\n4", "output": "0\n0\n0\n0\n0\n0\n1\n1\n2\n1\n"}, {"input": "10\n2\n2\n2\n9\n7\n13\n14...
code_stdio
[ { "content": "# Let's play Psychic \n\nA box contains green, red, and blue balls. The total number of balls is given by `n` (`0 < n < 50`).\n\nEach ball has a mass that depends on the ball color. Green balls weigh `5kg`, red balls weigh `4kg`, and blue balls weigh `3kg`.\n\nGiven the total number of balls in th...
[{"input": "50\n180", "output": "[[[0, 30, 20], [1, 28, 21], [2, 26, 22], [3, 24, 23], [4, 22, 24], [5, 20, 25], [6, 18, 26], [7, 16, 27], [8, 14, 28], [9, 12, 29], [10, 10, 30], [11, 8, 31], [12, 6, 32], [13, 4, 33], [14, 2, 34], [15, 0, 35]]]", "fn_name": "Guess_it"}, {"input": "50\n172", "output": "[[[0, 22, 28], [1...
code_functional
[ { "content": "She is an extraordinary girl. She works for a library. Since she is young and cute, she is forced to do a lot of laborious jobs. The most annoying job for her is to put returned books into shelves, carrying them by a cart. The cart is large enough to carry many books, but too heavy for her. Since ...
[{"input": "2\n2\nYYZNNNNY\n4\nNNNYYNYNNNYYONYN", "output": "6\n10\n"}, {"input": "2\n2\nYYZNYNNN\n4\nNNNYYNYNNNYYNNYN", "output": "5\n10\n"}, {"input": "2\n2\nYYZNNNNY\n4\nNNNYNNYNYNYYONYN", "output": "6\n11\n"}, {"input": "2\n2\nYYZLXNNN\n3\nNYNNYNYNNNYYNNYN", "output": "4\n10\n"}, {"input": "2\n2\nNNONYZYY\n4\nNNNYY...
code_stdio
[ { "content": "Today, hedgehog Filya went to school for the very first time! Teacher gave him a homework which Filya was unable to complete without your help.\n\nFilya is given an array of non-negative integers a_1, a_2, ..., a_{n}. First, he pick an integer x and then he adds x to some elements of the array (no...
[{"input": "10\n1 1 1 1 1 2 2 2 2 2\n", "output": "YES\n"}, {"input": "10\n1 1 1 1 1 2 2 2 2 2\n", "output": "YES\n"}, {"input": "10\n1 1 1 1 1 3 2 2 2 2\n", "output": "YES\n"}, {"input": "3\n99999999 1 50000000\n", "output": "YES\n"}, {"input": "2\n100000001 100000003\n", "output": "YES\n"}, {"input": "2\n100000001 10...
code_stdio
[ { "content": "Note : Issues Fixed with python 2.7.6 , Use any one you like :D , ( Thanks to \n\nTime , time , time . Your task is to write a function that will return the degrees on a analog clock from a digital time that is passed in as parameter . The digital time is type string and will be in the format 00:0...
[{"input": "\"-09:00\"", "output": "[\"Check your time !\"]", "fn_name": "clock_degree"}, {"input": "\"26:78\"", "output": "[\"Check your time !\"]", "fn_name": "clock_degree"}, {"input": "\"24:00\"", "output": "[\"Check your time !\"]", "fn_name": "clock_degree"}, {"input": "\"00:00\"", "output": "[\"360:360\"]", "fn_...
code_functional
[ { "content": "AtCoder Mart sells 1000000 of each of the six items below:\n\n* Riceballs, priced at 100 yen (the currency of Japan) each\n* Sandwiches, priced at 101 yen each\n* Cookies, priced at 102 yen each\n* Cakes, priced at 103 yen each\n* Candies, priced at 104 yen each\n* Computers, priced at 105 yen eac...
[{"input": "386", "output": "0\n"}, {"input": "115", "output": "0\n"}, {"input": "173", "output": "0\n"}, {"input": "145", "output": "0\n"}, {"input": "192", "output": "0\n"}, {"input": "160", "output": "0\n"}, {"input": "604", "output": "1\n"}, {"input": "248", "output": "0\n"}, {"input": "368", "output": "0\n"}, {"in...
code_stdio
[ { "content": "It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the curr...
[{"input": "10\n100000000 200000000 300000000 400000000 500000000 600000000 555489806 1596475927 1262387014 1000000000\n", "output": "Alice\n"}, {"input": "10\n100000000 200000000 300000000 400000000 500000000 600000000 555489806 1596475927 1262387014 1000000100\n", "output": "Alice\n"}, {"input": "10\n100000000 200000...
code_stdio
[ { "content": "Real stupidity beats artificial intelligence every time.\n\n— Terry Pratchett, Hogfather, Discworld\n\nYou are given a string $s$ of length $n$ and a number $k$. Let's denote by $rev(s)$ the reversed string $s$ (i.e. $rev(s) = s_n s_{n-1} ... s_1$). You can apply one of the two kinds of operations...
[{"input": "4\n3 2\naab\n3 3\naab\n7 1\nabacaba\n2 0\nab\n", "output": "2\n2\n1\n1\n"}, {"input": "1\n4 1\nabcd\n", "output": "2\n"}, {"input": "1\n4 2\nabca\n", "output": "2\n"}, {"input": "1\n3 1\naab\n", "output": "2\n"}, {"input": "1\n3 1\nabc\n", "output": "2\n"}, {"input": "1\n2 1\nab\n", "output": "2\n"}]
code_stdio
[ { "content": "There are n pictures delivered for the new exhibition. The i-th painting has beauty a_{i}. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.\n\nWe are allowed to arranged pictures in any order. What is the maximum possible number of times the visito...
[{"input": "100\n9 9 49 55 14 8 55 58 35 67 3 6 106 169 41 49 15 60 18 66 3 26 97 47 43 88 71 98 12 34 48 17 134 53 8 24 69 49 12 23 77 12 21 88 66 9 29 13 61 69 54 77 41 20 4 65 37 74 7 6 24 210 55 72 89 4 78 27 29 82 13 83 18 4 32 69 89 91 66 13 92 54 38 5 26 56 17 98 29 4 17 39 29 181 3 67 85 98 21 26\n", "output": ...
code_stdio
[ { "content": "In a kindergarten, the children are being divided into groups. The teacher put the children in a line and associated each child with his or her integer charisma value. Each child should go to exactly one group. Each group should be a nonempty segment of consecutive children of a line. A group's so...
[{"input": "2\n-1000000000 1000000000\n", "output": "2000000000\n"}, {"input": "2\n-1000000000 1000000100\n", "output": "2000000100\n"}, {"input": "2\n-1000000000 1000010100\n", "output": "2000010100\n"}, {"input": "2\n-1000000000 1010010100\n", "output": "2010010100\n"}, {"input": "2\n-1000000000 1010011100\n", "outpu...
code_stdio
[ { "content": "Vasya had three strings $a$, $b$ and $s$, which consist of lowercase English letters. The lengths of strings $a$ and $b$ are equal to $n$, the length of the string $s$ is equal to $m$. \n\nVasya decided to choose a substring of the string $a$, then choose a substring of the string $b$ and concaten...
[{"input": "100 200\ndddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\ndddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\nddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd...
code_stdio
[ { "content": "Mad scientist Mike is building a time machine in his spare time. To finish the work, he needs a resistor with a certain resistance value.\n\nHowever, all Mike has is lots of identical resistors with unit resistance R_0 = 1. Elements with other resistance can be constructed from these resistors. In...
[{"input": "999999999999999999 1000000000000000000\n", "output": "1000000000000000000\n"}, {"input": "999999999999999999 1000000000000000000\n", "output": "1000000000000000000\n"}, {"input": "999999999999999991 1000000000000000000\n", "output": "111111111111111120\n"}, {"input": "999999999999999991 1000000000000000000\...
code_stdio
[ { "content": "Petya has n positive integers a_1, a_2, ..., a_{n}. \n\nHis friend Vasya decided to joke and replaced all digits in Petya's numbers with a letters. He used the lowercase letters of the Latin alphabet from 'a' to 'j' and replaced all digits 0 with one letter, all digits 1 with another letter and so...
[{"input": "50\ng\nha\nhd\ndi\nac\nfdhhb\ng\nhgeag\nafafb\nb\nb\najjj\ncaiadi\nhciifa\nhb\ncaih\ncdbbi\ngjff\nbfe\neddci\ndijfie\nacjj\nef\ng\njdc\nahg\ne\nhbbh\ncdc\njifdc\ne\nffaehj\nhjhi\ng\neag\nfbbc\nchg\njhahfg\nbb\njd\njchh\nbefifj\nejac\ne\nh\njfhb\nedhe\nf\nag\nca\n", "output": "2673136\n"}, {"input": "50\ng\n...
code_stdio
[ { "content": "Polycarp has $n$ coins, the value of the $i$-th coin is $a_i$. Polycarp wants to distribute all the coins between his pockets, but he cannot put two coins with the same value into the same pocket.\n\nFor example, if Polycarp has got six coins represented as an array $a = [1, 2, 4, 3, 3, 2]$, he ca...
[{"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 two integers $a$ and $b$.\n\nIn one move, you can choose some integer $k$ from $1$ to $10$ and add it to $a$ or subtract it from $a$. In other words, you choose an integer $k \\in [1; 10]$ and perform $a := a + k$ or $a := a - k$. You may use different values of $k$ in different move...
[{"input": "11\n5 5\n13 42\n18 4\n1337 420\n123456789 1000000000\n100500 9000\n5 5\n13 42\n18 4\n2524 420\n123456789 1000000000\n", "output": "0\n3\n2\n92\n87654322\n9150\n0\n3\n2\n211\n87654322\n"}, {"input": "11\n10 5\n4 42\n17 4\n1337 420\n123456789 1000000000\n100500 9000\n5 5\n13 42\n18 4\n2524 420\n123456789 1000...
code_stdio
[ { "content": "Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. F...
[{"input": "30 3 50 32 1 18\n46 60\n66 94\n99 141\n162 239\n309 334\n400 550\n594 630\n659 663\n664 701\n735 736\n741 755\n756 801\n823 854\n865 915\n937 964\n984 986\n990 1007\n1008 1031\n1052 1064\n1073 1080\n1190 1191\n1192 1254\n1265 1266\n1272 1273\n1274 1277\n1284 1302\n1308 1312\n1358 1383\n1388 1389\n1390 1401\...
code_stdio
[ { "content": "This problem is same as the next one, but has smaller constraints.\n\nIt was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large power ...
[{"input": "42\n-5391 -2932\n-5391 -2868\n-5391 1744\n-5391 2236\n-5391 4148\n-5391 5217\n-5391 6188\n-3584 -2932\n-3584 -2868\n-3584 1744\n-3584 2236\n-3584 4148\n-3584 5217\n-3584 6188\n-1657 -2932\n-1657 -2868\n-1657 1744\n-1657 2236\n-1657 4148\n-1657 5217\n-1657 6188\n3218 -2932\n3218 -2868\n3218 1744\n3218 2236\n...
code_stdio
[ { "content": "In the rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that some even stand in queues to several rooms at the same time in the clinic, running from one queue to another.\n\n(Cultural note: standing in huge and disorganized queue...
[{"input": "20 20\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "output": "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n"}, {"input": "20 20\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1\n", "output": "2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n"}, {"input": "10 1\n0 7 0 10 ...
code_stdio
[ { "content": "Takahashi is organizing a party.\nAt the party, each guest will receive one or more snack pieces.\nTakahashi predicts that the number of guests at this party will be A or B.\nFind the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted.\nWe assume t...
[{"input": "100000 99999\n", "output": "9999900000\n"}, {"input": "110000 99999", "output": "10999890000\n"}, {"input": "110001 118998", "output": "4363299666\n"}, {"input": "110000 138162", "output": "7598910000\n"}, {"input": "110000 121574", "output": "6686570000\n"}, {"input": "111001 118998", "output": "1200808818...
code_stdio
[ { "content": "A widely known among some people Belarusian sport programmer Yura possesses lots of information about cars. That is why he has been invited to participate in a game show called \"Guess That Car!\".\n\nThe game show takes place on a giant parking lot, which is 4n meters long from north to south and...
[{"input": "10 10\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 1585 1564 3603 1095 1364 1029 3189 1331\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 1749\n0 3495 1540 641 1093 702 2249 983 1218 2108\n0 1397 1105 3119 1194 839 1286 2979 2941 1911\n0 1818 2264 631 3342 3511 2434 2960...
code_stdio
[ { "content": "There are $n$ cities in Berland and some pairs of them are connected by two-way roads. It is guaranteed that you can pass from any city to any other, moving along the roads. Cities are numerated from $1$ to $n$.\n\nTwo fairs are currently taking place in Berland — they are held in two different ci...
[{"input": "3\n7 7 3 5\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 5\n4 5 2 3\n1 2\n2 3\n3 4\n4 1\n4 2\n4 3 2 1\n1 2\n2 3\n4 1\n", "output": "4\n0\n1\n"}, {"input": "3\n7 7 3 5\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 5\n4 5 2 3\n1 2\n2 3\n4 4\n4 1\n4 2\n4 3 2 1\n1 2\n2 3\n4 1\n", "output": "4\n0\n1\n"}, {"input": "3\n7 7 3 5\n1 2\n2 3\n...
code_stdio
[ { "content": "Constanze is the smartest girl in her village but she has bad eyesight.\n\nOne day, she was able to invent an incredible machine! When you pronounce letters, the machine will inscribe them onto a piece of paper. For example, if you pronounce 'c', 'o', 'd', and 'e' in that order, then the machine w...
[{"input": "nnnnnnnnnnnnnnnnnnnnnuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuunnnnnnnnnnnnnnnnnnnnnuuuuuuuuuunnunnu\n", "output": "281595619\n"}, {"input": "nnnnnnnnnnnnnnnnnnnnnuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuunnnnnnnnnnnnnnnnnnnnnuuuuuuuuuunnunnu\n", "output": "281595619\n"}, {"input": "unnunnuuuuuuuuuunnnnnnnn...
code_stdio
[ { "content": "Lengths are measures in Baden in inches and feet. To a length from centimeters it is enough to know that an inch equals three centimeters in Baden and one foot contains 12 inches.\n\nYou are given a length equal to n centimeters. Your task is to convert it to feet and inches so that the number of ...
[{"input": "10000\n", "output": "277 9\n"}, {"input": "18864\n", "output": "524 0\n"}, {"input": "13473\n", "output": "374 3\n"}, {"input": "25368\n", "output": "704 8\n"}, {"input": "9999\n", "output": "277 9\n"}, {"input": "9876\n", "output": "274 4\n"}, {"input": "01000\n", "output": "27 9\n"}, {"input": "1233\n", "...
code_stdio
[ { "content": "Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from ...
[{"input": "10\n18 18\n71 471\n121 362\n467 107\n138 254\n13 337\n499 373\n337 387\n147 417\n76 417\n", "output": "4\n"}, {"input": "10\n18 18\n71 471\n121 362\n467 107\n138 254\n13 337\n499 373\n337 387\n147 417\n76 417\n", "output": "4\n"}, {"input": "10\n18 30\n71 471\n121 362\n467 107\n170 127\n13 337\n499 373\n337...
code_stdio
[ { "content": "ICPC Ranking\n\nYour mission in this problem is to write a program which, given the submission log of an ICPC (International Collegiate Programming Contest), determines team rankings.\n\nThe log is a sequence of records of program submission in the order of submission. A record has four fields: el...
[{"input": "300 19 8 5\n50 5 2 1\n70 5 2 0\n75 1 1 0\n100 3 1 0\n150 2 2 0\n240 5 5 7\n50 1 1 0\n60 2 2 0\n41 2 3 0\n90 1 3 0\n120 3 5 0\n196 4 1 0\n150 2 4 1\n180 3 5 4\n15 2 2 1\n20 2 2 1\n25 2 2 0\n60 1 1 0\n120 5 5 4\n15 5 4 1\n20 5 4 0\n40 1 1 0\n40 2 2 0\n120 2 3 4\n30 1 1 0\n40 2 1 0\n13 2 2 0\n60 1 2 0\n120 6 3...
code_stdio
[ { "content": "We have a sequence of N integers: x=(x_0,x_1,\\cdots,x_{N-1}). Initially, x_i=0 for each i (0 \\leq i \\leq N-1).\n\nSnuke will perform the following operation exactly M times:\n\n* Choose two distinct indices i, j (0 \\leq i,j \\leq N-1,\\ i \\neq j). Then, replace x_i with x_i+2 and x_j with x_j...
[{"input": "100001 50000", "output": "546347865\n"}, {"input": "100001 27098", "output": "949668337\n"}, {"input": "101000 27098", "output": "277745716\n"}, {"input": "101000 14296", "output": "338861381\n"}, {"input": "100011 27098", "output": "506486948\n"}, {"input": "101101 27098", "output": "454736313\n"}, {"input...
code_stdio
[ { "content": "In this Kata, you will create a function that converts a string with letters and numbers to the inverse of that string (with regards to Alpha and Numeric characters). So, e.g. the letter `a` will become `1` and number `1` will become `a`; `z` will become `26` and `26` will become `z`.\n\nExample: ...
[{"input": "\"1a2b3c4d5e6f7g8h9i10j11k12l13m14n15o16p17q18r19s20t21u22v23w24x25y26z\"", "output": "[\"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\"]", "fn_name": "AlphaNum_NumAlpha"}, {"input": "\"abcdefghijklmnopqrstuvwxyz\"", "output": "[\"1234567891011121314151617181920212223242526\"]", "fn...
code_functional
[ { "content": "A bracketed sequence is called correct (regular) if by inserting \"+\" and \"1\" you can get a well-formed mathematical expression from it. For example, sequences \"(())()\", \"()\" and \"(()(()))\" are correct, while \")(\", \"(()\" and \"(()))(\" are not.\n\nThe teacher gave Dmitry's class a ver...
[{"input": "100\n)()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()(\n", "output": "100\n"}, {"input": "101\n(())))))()))()())(()))((())))((())(()()()(()()((()()((()((())))((()))()(())(()(())((()))(()))()(((()(\n", "output": "-1\n"}, {"input": "100\n)()()()()()()()()()()...
code_stdio