messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "Xenia lives in a city that has n houses built along the main ringroad. The ringroad houses are numbered 1 through n in the clockwise order. The ringroad traffic is one way and also is clockwise.\n\nXenia has recently moved into the ringroad house number 1. As a result, she's got m things to do. In... | [{"input": "100 100\n48 73 63 16 49 88 36 17 66 6 87 13 94 52 58 70 71 52 7 70 25 42 24 36 57 9 79 26 75 39 13 14 38 26 33 66 88 28 75 98 53 48 67 54 63 25 69 87 88 32 72 17 36 35 29 67 74 89 70 47 20 90 78 13 94 57 32 73 29 74 45 78 85 64 81 56 12 65 19 67 34 86 55 71 41 33 76 13 100 47 44 76 86 78 37 15 26 98 83 98\n... | code_stdio |
[
{
"content": "A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once.\n\nGiven a string S consisting of lowercase English letters, determine if S is a KEYENCE string.\n\nConstraints\n\n* The length of S is between 7 and 100 (inclus... | [{"input": "eeyofscienck", "output": "NO\n"}, {"input": "eeyofsciencj", "output": "NO\n"}, {"input": "eeyofscienci", "output": "NO\n"}, {"input": "eeyofscjenci", "output": "NO\n"}, {"input": "icnejcsfoyee", "output": "NO\n"}, {"input": "icnyjcsfoeee", "output": "NO\n"}, {"input": "icmyjcsfoeee", "output": "NO\n"}, {"in... | code_stdio |
[
{
"content": "In English and programming, groups can be made using symbols such as `()` and `{}` that change meaning. However, these groups must be closed in the correct order to maintain correct syntax.\n\nYour job in this kata will be to make a program that checks a string for correct grouping. For instance, ... | [{"input": "\"{[{}[]()[]{}{}{}{}{}{}()()()()()()()()]{{{[[[((()))]]]}}}}(())[[]]{{}}[][][][][][][]({[]})\"", "output": "[true]", "fn_name": "group_check"}, {"input": "\"{{{{{{{{{{{((((((([])))))))}}}}}}}}}}\"", "output": "[false]", "fn_name": "group_check"}, {"input": "\"[{}{}())\"", "output": "[false]", "fn_name": "gr... | code_functional |
[
{
"content": "In 21XX, humanity finally began a plan to relocate to Mars. Selected as the first group of immigrants to Mars, you are assigned to the Administrative Center of Mars to deal with various problems that occur on Mars. The biggest problem at the moment of the Central Bureau is securing an independent ... | [{"input": "7 5 1 3 4\n1 2 10\n3 6 0\n2 4 5\n1 3 2\n1 4 12\n0 0 0 0 0", "output": "14\n"}, {"input": "6 5 1 2 4\n1 2 5\n4 3 5\n2 3 -1\n1 3 8\n1 4 36\n0 0 0 0 0", "output": "41\n"}, {"input": "6 5 1 3 4\n1 2 5\n3 3 5\n2 3 5\n1 3 8\n1 4 11\n0 0 0 0 0", "output": "19\n"}, {"input": "7 5 1 3 4\n1 2 5\n3 6 9\n2 4 5\n1 3 18\... | code_stdio |
[
{
"content": "Proof of knowledge\n\nThe entrance door of the apartment you live in has a password-type lock. This password consists of exactly four digits, ranging from 0 to 9, and you always use the password P given to you by the apartment manager to unlock this door.\n\nOne day, you wondered if all the reside... | [{"input": "[+c[+a[^bd]]]\n0404\n[*b[*[*cd]a]]\n15341\n[^[^ab][^cd]]\n1295\na\n9876\n[^dd]\n9090\n.", "output": "0 10\n0 8895\n15 544\n9 1000\n0 10000\n"}, {"input": "[+c[+a[^bd]]]\n0404\n[*b[*[*cd]a]]\n15341\n[^[^ab][^cd]]\n1295\na\n4682\n[^dd]\n1131\n.", "output": "0 10\n0 8895\n15 544\n4 1000\n0 10000\n"}, {"input":... | code_stdio |
[
{
"content": "Snuke is buying a lamp.\nThe light of the lamp can be adjusted to m levels of brightness, represented by integers from 1 through m, by the two buttons on the remote control.\nThe first button is a \"forward\" button. When this button is pressed, the brightness level is increased by 1, except when ... | [{"input": "17181 9591\n8631 7910 866 4907 8538 8598 2993 9142 2493 4555 1343 1342 8441 2990 6402 514 8876 7271 3637 2648 8238 2119 5408 6110 6306 1057 3666 5651 9035 1593 7642 2543 4646 669 9090 261 3119 9534 4066 6874 4328 4894 2933 6769 9582 4302 6147 5501 4658 4708 72 1848 815 4682 6712 6890 3507 5336 4979 8575 958... | code_stdio |
[
{
"content": "Oleg's favorite subjects are History and Math, and his favorite branch of mathematics is division.\n\nTo improve his division skills, Oleg came up with $t$ pairs of integers $p_i$ and $q_i$ and for each pair decided to find the greatest integer $x_i$, such that: $p_i$ is divisible by $x_i$; $x_... | [{"input": "10\n238517256500070918 988176216\n363959778883784349 933416507\n631238591652944446 530795521\n557307185726829409 1481431174\n86402035814143715 513728064\n101626841876448103 26556040\n598448092106640578 746411314\n733629261048200000 361714100\n624561301519202735 38\n1062588104563887715 98227203\n", "output":... | code_stdio |
[
{
"content": "Edo has got a collection of n refrigerator magnets!\n\nHe decided to buy a refrigerator and hang the magnets on the door. The shop can make the refrigerator with any size of the door that meets the following restrictions: the refrigerator door must be rectangle, and both the length and the width o... | [{"input": "20 5\n1 12 21 22\n9 10 15 20\n10 12 12 20\n1 1 25 29\n5 10 21 22\n4 9 16 25\n12 10 14 24\n3 3 19 27\n3 4 23 28\n12 1 11 31\n9 14 17 18\n8 12 14 20\n8 11 18 19\n12 3 14 29\n7 8 13 22\n6 4 16 30\n11 3 13 27\n9 16 15 18\n6 13 14 21\n9 12 15 22\n", "output": "4\n"}, {"input": "20 5\n1 12 21 22\n9 10 15 20\n10 1... | code_stdio |
[
{
"content": "You are given a permutation of numbers from 1 to n. Determine whether there's a pair of integers a, b (1 ≤ a, b ≤ n; a ≠ b) such that the element <image> (note, that it is usual division, not integer one) is between a and b in this permutation.\n\nInput\n\nFirst line consists of a single integer n... | [{"input": "100\n1 65 33 97 17 81 49 11 73 41 25 89 57 5 69 39 21 85 53 13 77 45 29 93 61 3 67 60 99 19 83 51 11 75 43 27 91 59 7 71 39 23 87 55 15 79 47 31 2 95 63 66 34 98 18 82 50 10 74 42 26 90 58 6 70 38 22 86 54 14 78 46 30 94 62 4 68 36 100 20 84 52 12 76 44 28 92 60 8 72 40 24 88 56 16 80 48 32 96 64\n", "outpu... | code_stdio |
[
{
"content": "Alice and Bob are playing yet another card game. This time the rules are the following. There are $n$ cards lying in a row in front of them. The $i$-th card has value $a_i$. \n\nFirst, Alice chooses a non-empty consecutive segment of cards $[l; r]$ ($l \\le r$). After that Bob removes a single car... | [{"input": "131\n30 -29 29 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28 -28 28... | code_stdio |
[
{
"content": "Petya has k matches, placed in n matchboxes lying in a line from left to right. We know that k is divisible by n. Petya wants all boxes to have the same number of matches inside. For that, he can move a match from its box to the adjacent one in one move. How many such moves does he need to achieve... | [{"input": "100\n6 3 4 5 3 4 2 4 1 2 4 1 8 5 2 2 4 4 6 8 4 10 4 4 6 8 6 5 5 4 8 4 3 3 6 5 7 2 9 7 6 5 6 3 2 6 8 10 3 6 8 7 2 3 5 4 8 6 5 6 6 8 4 1 5 6 1 8 12 5 3 3 8 2 4 2 4 5 6 6 9 5 1 2 8 8 3 7 5 3 4 5 7 6 3 9 4 6 3 6\n", "output": "867\n"}, {"input": "100\n6 3 4 5 3 4 2 4 1 2 4 1 8 5 2 2 4 4 6 8 4 10 4 4 6 8 6 5 5 4... | code_stdio |
[
{
"content": "You are given a string S consisting of lowercase English letters.\nAnother string T is initially empty.\nDetermine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:\n - Append one of the following at the end of T: dream, dreamer, erase and e... | [{"input": "dreamereraserdreamererasereraseeraserdreamererasereraserdreamdreamerdreamerdreamerdreamererasedreamereraseeraserdreamereraserdreamereraseeraserdreamdreamdreamerdreamerdreamerdreamdreamerdreameraseerasedreamererasererasererasedreamereraseerasererasedreamerasereraserdreamerdreamerasedreamereraseeraserdreamera... | code_stdio |
[
{
"content": "The appearance of the sun is called \"sunrise\" and the hiding is called \"sunset\". What is the exact time when the sun is on the horizon?\n\nAs shown in the figure below, we will represent the sun as a circle and the horizon as a straight line. At this time, the time of \"sunrise\" and \"sunset\... | [{"input": "-12 3", "output": "-1\n"}, {"input": "-15 3", "output": "-1\n"}, {"input": "-23 3", "output": "-1\n"}, {"input": "-10 6", "output": "-1\n"}, {"input": "-2 -1", "output": "-1\n"}, {"input": "-1 -1", "output": "-1\n"}, {"input": "-1 -2", "output": "-1\n"}, {"input": "-1 -4", "output": "-1\n"}, {"input": "-2 -... | code_stdio |
[
{
"content": "There are $n$ houses along the road where Anya lives, each one is painted in one of $k$ possible colors.\n\nAnya likes walking along this road, but she doesn't like when two adjacent houses at the road have the same color. She wants to select a long segment of the road such that no two adjacent ho... | [{"input": "100 100\n82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 109 47 21 78 20 63 13 49 76 36 41 79 16 87 87 69 3 76 80 60 100 62 70 59 72 8 38 71 45 97 71 14 76 54 81 4 59 46 39 29 92 3 49 22 53 99 59 52 74 31 92 43 42 23 44 9 82 47 7 40 12 9 3 55 37 85 46 22 84 52 98 41 21 77 63 17 62 91\n", "o... | code_stdio |
[
{
"content": "Inna loves sleeping very much, so she needs n alarm clocks in total to wake up. Let's suppose that Inna's room is a 100 × 100 square with the lower left corner at point (0, 0) and with the upper right corner at point (100, 100). Then the alarm clocks are points with integer coordinates in this squ... | [{"input": "42\n28 87\n26 16\n59 90\n47 61\n28 83\n36 30\n67 10\n6 95\n9 49\n86 94\n52 24\n74 9\n86 24\n28 51\n25 99\n40 98\n57 33\n18 96\n43 36\n3 79\n4 86\n38 61\n25 61\n6 100\n58 81\n28 19\n64 4\n3 40\n2 56\n41 49\n97 100\n86 34\n42 36\n44 40\n14 85\n21 60\n76 99\n64 47\n69 13\n49 37\n97 37\n3 70\n", "output": "31\n... | code_stdio |
[
{
"content": "Little X has met the following problem recently. \n\nLet's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image>\n\nOf course Little X has solved this problem quickly, has locked it, and then has tried to hack ot... | [{"input": "1000000000000000000\n", "output": "1000000000000000000 1999999999999999999"}, {"input": "1000000000000000000\n", "output": "1000000000000000000 1999999999999999999"}, {"input": "1000000000000000000\n", "output": "1000000000000000000 1999999999999999999"}, {"input": "1000000000000000000\n", "output": "100000... | code_stdio |
[
{
"content": "Wabbit is playing a game with $n$ bosses numbered from $1$ to $n$. The bosses can be fought in any order. Each boss needs to be defeated exactly once. There is a parameter called boss bonus which is initially $0$.\n\nWhen the $i$-th boss is defeated, the current boss bonus is added to Wabbit's sco... | [{"input": "70 2\n1 1 1 1 1 -1 -1 -1 -1 -1 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3\n", "output": "-1685\n"}, {"input": "10 3\n950 882 856 786 677 480 302 258 147 98\n", "output": "... | code_stdio |
[
{
"content": "Recently, a start up by two students of a state university of city F gained incredible popularity. Now it's time to start a new company. But what do we call it?\n\nThe market analysts came up with a very smart plan: the name of the company should be identical to its reflection in a mirror! In othe... | [{"input": "OVWIHIWVYXMVAAAATOXWOIUUHYXHIHHVUIOOXWHOXTUUMUUVHVWWYUTIAUAITAOMHXWMTTOIVMIVOTHOVOIOHYHAOXWAUVWAVIVM\n", "output": "NO\n"}, {"input": "QDPINBMCRFWXPDBFGOZVVOCEMJRUCTOADEWEGTVBVBFWWRPGYEEYGPRWWFBVBVTGEWEDAOTCURJMECOVVZOGFBDPXWFRCMBNIPDQ\n", "output": "NO\n"}, {"input": "OVWIHIWVYXMVAAAATOXWOIUUHYXHIHHVUIOOXW... | code_stdio |
[
{
"content": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints\n\n* The length of S is 2 or 3.\n* S consists of lowercase English letters.\n\nInput\n\nInput... | [{"input": "acc", "output": "cca\n"}, {"input": "acb", "output": "bca\n"}, {"input": "adb", "output": "bda\n"}, {"input": "`cb", "output": "bc`\n"}, {"input": "bc`", "output": "`cb\n"}, {"input": "cb`", "output": "`bc\n"}, {"input": "cba", "output": "abc\n"}, {"input": "cab", "output": "bac\n"}, {"input": "bac", "outpu... | code_stdio |
[
{
"content": "We have a pyramid with N steps, built with blocks. The steps are numbered 1 through N from top to bottom. For each 1≤i≤N, step i consists of 2i-1 blocks aligned horizontally. The pyramid is built so that the blocks at the centers of the steps are aligned vertically.\n\n<image>\n\nA pyramid with N=... | [{"input": "4\n-1 1 0 1 2 18 2", "output": "1\n"}, {"input": "4\n-2 1 0 1 2 18 2", "output": "1\n"}, {"input": "4\n1 12 1 -1 4 5 2", "output": "1\n"}, {"input": "4\n-1 5 5 0 8 2 0", "output": "5\n"}, {"input": "4\n-2 3 3 7 7 5 0", "output": "7\n"}, {"input": "4\n-2 3 3 7 6 1 0", "output": "6\n"}, {"input": "4\n0 2 0 1 ... | code_stdio |
[
{
"content": "## Task:\n\nYou have to write a function `pattern` which returns the following Pattern(See Examples) upto desired number of rows. \n\n* Note:`Returning` the pattern is not the same as `Printing` the pattern.\n\n### Parameters:\n \n pattern( n , x );\n ... | [{"input": "15\n3", "output": "[\"1 1 1 1\\n 2 2 2 2 2 2 \\n 3 3 3 3 3 3 \\n 4 ... | code_functional |
[
{
"content": "You are given two arrays: an array $a$ consisting of $n$ zeros and an array $b$ consisting of $n$ integers.\n\nYou can apply the following operation to the array $a$ an arbitrary number of times: choose some subsegment of $a$ of length $k$ and add the arithmetic progression $1, 2, \\ldots, k$ to t... | [{"input": "17 10\n465 868 29 633 291 357 62 929 22 124 182 995 903 75 71 924 416\n", "output": "611\n"}, {"input": "1 1\n1000000000000\n", "output": "1000000000000\n"}, {"input": "7 4\n1 10000 1 1 1 1 10000\n", "output": "7500\n"}, {"input": "7 3\n50 17 81 25 42 39 96\n", "output": "92\n"}, {"input": "3 3\n14159 26535... | code_stdio |
[
{
"content": "In this problem at each moment you have a set of intervals. You can move from interval (a, b) from our set to interval (c, d) from our set if and only if c < a < d or c < b < d. Also there is a path from interval I_1 from our set to interval I_2 from our set if there is a sequence of successive mo... | [{"input": "20\n1 1208 1583\n1 -258 729\n1 -409 1201\n1 194 1938\n1 -958 1575\n1 -1466 1752\n2 1 2\n2 1 2\n2 6 5\n1 -1870 1881\n1 -2002 2749\n1 -2002 2984\n1 -2002 3293\n2 2 4\n2 8 10\n2 9 6\n1 -2002 3572\n1 -2002 4175\n1 -2002 4452\n1 -2002 4605\n", "output": "YES\nYES\nYES\nYES\nYES\nNO\n"}, {"input": "20\n1 1208 158... | code_stdio |
[
{
"content": "Similarly to the [previous kata](https://www.codewars.com/kata/string-subpattern-recognition-i/), you will need to return a boolean value if the base string can be expressed as the repetition of one subpattern.\n\nThis time there are two small changes:\n\n* if a subpattern has been used, it will b... | [{"input": "\"babababababababa\"", "output": "[true]", "fn_name": "has_subpattern"}, {"input": "\"12aa13a21233A\"", "output": "[false]", "fn_name": "has_subpattern"}, {"input": "\"123A123a123a\"", "output": "[false]", "fn_name": "has_subpattern"}, {"input": "\"123a123a123a\"", "output": "[true]", "fn_name": "has_subpat... | code_functional |
[
{
"content": "Given a matrix (H × W) which contains only 1 and 0, find the area of the largest square matrix which only contains 0s.\n\nConstraints\n\n* 1 ≤ H, W ≤ 1,400\n\nInput\n\n\nH W\nc1,1 c1,2 ... c1,W\nc2,1 c2,2 ... c2,W\n:\ncH,1 cH,2 ... cH,W\n\n\nIn the first line, two integers H and W separated by a s... | [{"input": "1 1\n1 0 -1 -1 1\n1 0 0 0 1\n0 -2 0 1 -1\n0 -1 0 2 0", "output": "0\n"}, {"input": "3 2\n-1 0 1 0 0\n1 0 0 -1 1\n-1 -1 0 1 1\n0 0 0 -2 1", "output": "1\n"}, {"input": "1 1\n0 0 -1 -1 1\n1 0 0 0 1\n0 -2 0 1 -1\n0 -1 0 2 0", "output": "1\n"}, {"input": "3 2\n-1 0 1 0 0\n1 0 0 -1 1\n-1 -1 0 1 2\n0 0 0 -2 1", "... | code_stdio |
[
{
"content": "Drazil is playing a math game with Varda.\n\nLet's define <image> for positive integer x as a product of factorials of its digits. For example, <image>.\n\nFirst, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start wi... | [{"input": "15\n989898989898989\n", "output": "777777777777777333333333333333322222222222222222222222222222\n"}, {"input": "15\n999999999999990\n", "output": "77777777777777333333333333333333333333333322222222222222\n"}, {"input": "15\n987654329876543\n", "output": "777777555533333333332222222222222\n"}, {"input": "12\... | code_stdio |
[
{
"content": "## Overview\nResistors are electrical components marked with colorful stripes/bands to indicate both their resistance value in ohms and how tight a tolerance that value has. While you could always get a tattoo like Jimmie Rodgers to help you remember the resistor color codes, in the meantime, you ... | [{"input": "\"yellow violet brown silver\"", "output": "[\"470 ohms, 10%\"]", "fn_name": "decode_resistor_colors"}, {"input": "\"orange orange yellow gold\"", "output": "[\"330k ohms, 5%\"]", "fn_name": "decode_resistor_colors"}, {"input": "\"yellow violet orange gold\"", "output": "[\"47k ohms, 5%\"]", "fn_name": "dec... | code_functional |
[
{
"content": "A new delivery of clothing has arrived today to the clothing store. This delivery consists of $a$ ties, $b$ scarves, $c$ vests and $d$ jackets.\n\nThe store does not sell single clothing items — instead, it sells suits of two types: a suit of the first type consists of one tie and one jacket; a ... | [{"input": "100000\n100000\n100000\n100000\n1000\n1000\n", "output": "100000000\n"}, {"input": "100000\n100000\n100000\n100000\n1000\n1000\n", "output": "100000000\n"}, {"input": "100000\n100000\n100100\n100000\n1000\n1000\n", "output": "100000000\n"}, {"input": "100000\n100000\n100000\n100000\n1000\n1\n", "output": "1... | code_stdio |
[
{
"content": "You are given n positive integers a_1, a_2, ..., a_{n}.\n\nFor every a_{i} you need to find a positive integer k_{i} such that the decimal notation of 2^{k}_{i} contains the decimal notation of a_{i} as a substring among its last min(100, length(2^{k}_{i})) digits. Here length(m) is the length of ... | [{"input": "100\n822\n991\n907\n729\n120\n707\n197\n280\n444\n45\n590\n951\n338\n740\n502\n345\n969\n240\n710\n476\n530\n674\n327\n187\n890\n530\n626\n767\n178\n831\n819\n406\n413\n119\n855\n13\n17\n460\n708\n30\n364\n974\n32\n615\n231\n758\n39\n731\n288\n955\n897\n897\n365\n246\n209\n17\n836\n496\n916\n610\n961\n181\n... | code_stdio |
[
{
"content": "Among Johnny's numerous hobbies, there are two seemingly harmless ones: applying bitwise operations and sneaking into his dad's office. As it is usually the case with small children, Johnny is unaware that combining these two activities can get him in a lot of trouble.\n\nThere is a set $S$ contai... | [{"input": "6\n4\n1 0 2 5\n6\n10 7 14 16 0 12\n2\n0 1\n3\n1 2 6\n6\n1 4 6 10 11 20\n2\n0 1023\n", "output": "-1\n-1\n1\n-1\n-1\n1023\n"}, {"input": "6\n4\n1 0 2 6\n6\n10 7 27 16 1 12\n2\n0 1\n3\n1 2 6\n6\n0 8 6 10 11 33\n2\n0 1023\n", "output": "-1\n11\n1\n-1\n-1\n1023\n"}, {"input": "6\n4\n1 0 2 5\n6\n10 7 14 16 0 12\... | code_stdio |
[
{
"content": "A group of $n$ dancers rehearses a performance for the closing ceremony. The dancers are arranged in a row, they've studied their dancing moves and can't change positions. For some of them, a white dancing suit is already bought, for some of them — a black one, and for the rest the suit will be bo... | [{"input": "20 53 67\n1 2 1 2 0 0 0 2 2 2 1 0 0 2 0 0 0 1 1 2\n", "output": "413\n"}, {"input": "20 53 67\n1 2 1 2 0 0 0 2 2 2 1 0 0 2 0 0 0 1 1 2\n", "output": "413\n"}, {"input": "20 53 67\n1 2 1 2 0 0 0 2 2 2 1 0 0 2 0 0 1 1 1 2\n", "output": "427\n"}, {"input": "20 53 67\n1 2 1 2 0 0 0 2 2 2 1 0 0 2 0 0 1 2 1 2\n",... | code_stdio |
[
{
"content": "Reziba has many magic gems. Each magic gem can be split into $M$ normal gems. The amount of space each magic (and normal) gem takes is $1$ unit. A normal gem cannot be split.\n\nReziba wants to choose a set of magic gems and split some of them, so the total space occupied by the resulting set of g... | [{"input": "1000000000000000000 100\n", "output": "161502719\n"}, {"input": "1000000000000000000 100\n", "output": "161502719\n"}, {"input": "1000000000000000000 42\n", "output": "683499162\n"}, {"input": "1000000000000000000 69\n", "output": "864131130\n"}, {"input": "1000000000000000000 99\n", "output": "847914677\n"... | code_stdio |
[
{
"content": "'Twas the night before Christmas, and Santa's frantically setting up his new Christmas tree! There are n nodes in the tree, connected by n-1 edges. On each edge of the tree, there's a set of Christmas lights, which can be represented by an integer in binary representation.\n\n<image>\n\nHe has m e... | [{"input": "4\n6 5\n1 2 -1\n1 3 1\n4 2 7\n6 3 0\n2 5 -1\n2 3 1\n2 5 0\n5 6 1\n6 1 1\n4 5 1\n5 3\n1 2 -1\n1 3 -1\n1 4 1\n4 5 -1\n2 4 0\n3 4 1\n2 3 1\n3 3\n1 2 -1\n1 3 -1\n2 2 0\n1 3 1\n2 3 0\n2 0\n1 2 1\n1 2 0\n", "output": "YES\n1 2 0\n1 3 1\n4 2 7\n6 3 0\n2 5 0\nYES\n1 2 1\n1 3 0\n1 4 1\n4 5 1\nYES\n1 2 1\n1 3 1\nYES\... | code_stdio |
[
{
"content": "Count the pairs of length-N sequences consisting of integers between 1 and M (inclusive), A_1, A_2, \\cdots, A_{N} and B_1, B_2, \\cdots, B_{N}, that satisfy all of the following conditions:\n - A_i \\neq B_i, for every i such that 1\\leq i\\leq N.\n - A_i \\neq A_j and B_i \\neq B_j, for every (i... | [{"input": "141421 356237\n", "output": "881613484\n"}, {"input": "500000 500000\n", "output": "869509376\n"}, {"input": "436426 479445\n", "output": "710501305\n"}, {"input": "148772 190081\n", "output": "685499830\n"}, {"input": "190629 433447\n", "output": "627318091\n"}, {"input": "47202 203497\n", "output": "37412... | code_stdio |
[
{
"content": "Polycarp is crazy about round numbers. He especially likes the numbers divisible by 10^{k}.\n\nIn the given number of n Polycarp wants to remove the least number of digits to get a number that is divisible by 10^{k}. For example, if k = 3, in the number 30020 it is enough to delete a single digit ... | [{"input": "1000000001 10\n", "output": "9\n"}, {"input": "1234567890 14\n", "output": "9\n"}, {"input": "1000999999 3\n", "output": "6\n"}, {"input": "1090090090 5\n", "output": "2\n"}, {"input": "1234567890 1\n", "output": "0\n"}, {"input": "1234567890 2\n", "output": "9\n"}, {"input": "1234567890 9\n", "output": "9\... | code_stdio |
[
{
"content": "At Aizu Shingakujuku, students are divided into classes by conducting a proficiency test when they enter the cram school. The test consists of three subjects: Mathematics, English, and Japanese, and students are divided into A, B, and C classes. The level of class A is the highest and then decreas... | [{"input": "4\n100 217 28\n253 43 197\n18 34 24\n19 22 189\n2\n190 106 20\n66 72 171\n0", "output": "A\nA\nC\nB\nA\nA\n"}, {"input": "4\n100 137 28\n143 43 197\n18 34 24\n19 19 65\n2\n196 106 20\n66 72 171\n0", "output": "A\nA\nC\nC\nA\nA\n"}, {"input": "4\n111 273 20\n165 86 15\n80 41 202\n0 88 65\n2\n147 81 12\n119 1... | code_stdio |
[
{
"content": "Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of n light bulbs in a single row. Each bulb has a number from 1 to n (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light b... | [{"input": "100\n13 92 99 100 89 6 64 32 36 40 62 30 53 31 60 4 54 83 10 59 15 67 47 93 70 41 78 34 20 69 1 74 39 16 95 48 25 80 21 85 50 33 88 71 75 73 77 87 7 5 90 28 14 96 49 57 68 22 8 27 37 86 51 94 11 66 55 29 63 91 45 65 97 23 52 17 81 42 46 35 24 19 44 43 9 84 26 82 2 18 76 56 3 38 72 61 58 98 12 79\n", "output... | code_stdio |
[
{
"content": "Dasha logged into the system and began to solve problems. One of them is as follows:\n\nGiven two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}.\n\nAbout sequences a and b we know that their ... | [{"input": "30 100 200\n102 108 122 116 107 145 195 145 119 110 187 196 140 174 104 190 193 181 118 127 157 111 139 175 173 191 181 105 142 166\n30 26 20 23 27 15 2 14 21 25 6 1 17 10 29 5 3 7 22 19 13 24 18 9 11 4 8 28 16 12\n", "output": "100 100 100 100 100 101 100 100 100 100 100 100 100 100 100 100 100 100 100 100... | code_stdio |
[
{
"content": "Levko loves array a1, a2, ... , an, consisting of integers, very much. That is why Levko is playing with array a, performing all sorts of operations with it. Each operation Levko performs is of one of two types:\n\n 1. Increase all elements from li to ri by di. In other words, perform assignments... | [{"input": "97 29\n2 78 82 356152\n2 14 29 430177\n1 59 84 3680\n1 49 89 -2247\n1 92 96 3701\n2 54 89 377271\n1 62 70 -507\n2 94 97 431563\n1 46 55 -9257\n1 51 83 1627\n1 10 20 6633\n1 17 34 -9263\n2 66 92 383251\n1 12 82 3884\n1 78 96 -5379\n2 13 35 424798\n1 68 91 2939\n2 80 84 214725\n1 61 85 -4390\n1 85 96 3106\n2 ... | code_stdio |
[
{
"content": "Chef likes to travel very much. He plans some travel routes and wants to know their lengths. He hired you to make these calculations. But be careful, some of the routes are incorrect. There may be some misspelling in city names or there will be no road between some two consecutive cities in the ro... | [{"input": "5\nDonetsk Kiev New-York Miami Hollywood\n9\nDonetsk Kiev 930\nKiev New-York 7507\nNew-York Miami 1764\nMiami Hollywood 28\nHollywood Miami 30\nMiami New-York 1764\nKiev Donetsk 550\nHollywood New-York 1736\nNew-York Hollywood 1738\n13\n5 Donetsk Kiev New-York Miami Hollywood\n5 Hlolywood Miami New-York Kie... | code_stdio |
[
{
"content": "Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!\n\nThe cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cak... | [{"input": "21\n...CCC.....CC..C..C.C\n..CCC...CC...CC.CCC.C\n....C.C.C..CCC..C.C.C\n....CCC..C..C.CC.CCC.\n...CCC.C..C.C.....CCC\n.CCC.....CCC..C...C.C\nCCCC.C...CCC.C...C.CC\nC..C...C.CCC..CC..C..\nC...CC..C.C.CC..C.CC.\nCC..CCCCCCCCC..C....C\n.C..CCCC.CCCC.CCC...C\nCCC...CCC...CCC.C..C.\n.CCCCCCCC.CCCC.CC.C..\n.C.C.... | code_stdio |
[
{
"content": "You are given a sequence D_1, D_2, ..., D_N of length N.\nThe values of D_i are all distinct.\nDoes a tree with N vertices that satisfies the following conditions exist?\n - The vertices are numbered 1,2,..., N.\n - The edges are numbered 1,2,..., N-1, and Edge i connects Vertex u_i and v_i.\n - F... | [{"input": "15\n57\n62\n47\n45\n42\n74\n90\n75\n54\n50\n66\n63\n77\n87\n51\n", "output": "1 10\n1 11\n2 8\n2 15\n3 5\n3 9\n4 5\n4 10\n5 15\n6 12\n6 14\n7 13\n9 12\n11 13\n"}, {"input": "15\n57\n62\n47\n45\n42\n74\n90\n75\n54\n50\n66\n63\n77\n87\n51", "output": "1 10\n1 11\n2 8\n2 15\n3 5\n3 9\n4 5\n4 10\n5 15\n6 12\n6 ... | code_stdio |
[
{
"content": "Let's define a number ebne (even but not even) if and only if its sum of digits is divisible by 2 but the number itself is not divisible by 2. For example, 13, 1227, 185217 are ebne numbers, while 12, 2, 177013, 265918 are not. If you're still unsure what ebne numbers are, you can look at the samp... | [{"input": "36\n6\n165310\n6\n177978\n6\n211759\n6\n212643\n6\n229540\n6\n250029\n6\n211519\n6\n256097\n6\n163478\n5\n91505\n5\n79280\n6\n260629\n6\n128051\n6\n121972\n6\n261633\n6\n172044\n6\n119055\n6\n208323\n6\n149942\n6\n161236\n6\n177150\n6\n233766\n5\n97949\n6\n230107\n6\n175822\n6\n213545\n6\n232837\n6\n179166\... | code_stdio |
[
{
"content": "# Task\nGiven an integer array `arr`. Your task is to remove one element, maximize the product of elements. \n\nThe result is the element which should be removed. If more than one valid results exist, return the smallest one.\n\n\n# Input/Output\n\n\n`[input]` integer array `arr`\n\nnon-empty unso... | [{"input": "[-1, -2, -3, 0, 1, 2, 3]", "output": "[-3]", "fn_name": "maximum_product"}, {"input": "[-1, -2, -3, 1, 2, 3]", "output": "[-1]", "fn_name": "maximum_product"}, {"input": "[0, -1, -2, -3, -4]", "output": "[0]", "fn_name": "maximum_product"}, {"input": "[0, -1, -2, -3, 4]", "output": "[-3]", "fn_name": "maxim... | code_functional |
[
{
"content": "At an arcade, Takahashi is playing a game called RPS Battle, which is played as follows:\n - The player plays N rounds of Rock Paper Scissors against the machine. (See Notes for the description of Rock Paper Scissors. A draw also counts as a round.)\n - Each time the player wins a round, depending... | [{"input": "99901 2\n3193 1797 2772\nssrprrspsrprsrpsrprsssprrsrssrrprppprrrrrrrsprrrrsprsprsspsspprrrrpprsrprrrrpsspprrrspspsprprprprrpprppsrspprrsssssprsrrsrrsssppsprsrprpprpspppsprrspsspsppsrpspprpprsrsrssrrrrprspprpprrspssprsrrsppsrsrpssprsssprspppspspssrrpsrprpsrpprsrpppsprssssprsrrrrpsrprrrppsrrrrrsssrrsrprrrrrpp... | code_stdio |
[
{
"content": "The next \"Data Structures and Algorithms\" lesson will be about Longest Increasing Subsequence (LIS for short) of a sequence. For better understanding, Nam decided to learn it a few days before the lesson.\n\nNam created a sequence a consisting of n (1 ≤ n ≤ 10^5) elements a_1, a_2, ..., a_{n} (1... | [{"input": "100\n102 157 177 149 138 193 19 74 127 156 128 122 6 101 154 92 24 188 51 89 18 77 112 100 65 11 113 173 79 124 102 81 11 171 114 43 60 168 44 86 87 82 177 8 12 181 139 121 140 28 108 17 173 63 18 4 148 125 117 153 193 180 188 142 46 75 163 126 128 22 32 163 164 1 161 19 162 59 190 14 93 85 93 37 73 64 64 1... | code_stdio |
[
{
"content": "Ahmed and Mostafa used to compete together in many programming contests for several years. Their coach Fegla asked them to solve one challenging problem, of course Ahmed was able to solve it but Mostafa couldn't.\n\nThis problem is similar to a standard problem but it has a different format and co... | [{"input": "14 14\n6 -1 1 1 1 1 1\n6 1 1 1 1 1 1\n6 2 1 1 1 1 1\n6 1 1 1 1 1 1\n6 1 1 1 1 1 1\n6 1 1 1 1 1 1\n6 1 1 1 1 1 1\n6 1 1 1 1 1 1\n6 1 1 1 1 1 1\n6 1 1 1 1 1 1\n6 1 1 1 1 1 1\n6 1 1 1 1 1 1\n6 1 1 1 1 1 1\n6 1 1 1 1 1 -1\n1 2 3 4 5 6 7 8 9 10 11 12 13 14\n", "output": "83\n"}, {"input": "14 14\n6 -1 1 1 1 1 1\... | code_stdio |
[
{
"content": "«Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequence of the document page numbers that he wants to print out (separates them with a comma, without space... | [{"input": "713,572,318,890,577,657,646,146,373,783,392,229,455,871,20,593,573,336,26,381,280,916,907,732,820,713,111,840,570,446,184,711,481,399,788,647,492,15,40,530,549,506,719,782,126,20,778,996,712,761,9,74,812,418,488,175,103,585,900,3,604,521,509,513,145,708,990,361,682,827,791,22,596,780,596,385,450,643,118,496... | code_stdio |
[
{
"content": "Piegirl was asked to implement two table join operation for distributed database system, minimizing the network traffic.\n\nSuppose she wants to join two tables, A and B. Each of them has certain number of rows which are distributed on different number of partitions. Table A is distributed on the ... | [{"input": "10 10\n933168403 308417110 823216696 818565876 448948583 884328249 809244579 473034231 407137956 871269623\n1302355559 145998557 644003076 138712151 839886312 479712343 709513279 138285801 858528549 643830064\n", "output": "11375801438\n"}, {"input": "10 10\n933168403 308417110 823216696 818565876 448948583... | code_stdio |
[
{
"content": "You are given $n$ rectangles, each of height $1$. Each rectangle's width is a power of $2$ (i. e. it can be represented as $2^x$ for some non-negative integer $x$).\n\nYou are also given a two-dimensional box of width $W$. Note that $W$ may or may not be a power of $2$. Moreover, $W$ is at least a... | [{"input": "2\n5 20\n1 2 16 2 8\n6 12\n4 8 8 4 2 8\n", "output": "2\n3\n"}, {"input": "2\n5 13\n2 2 8 2 8\n6 23\n1 16 8 2 2 1\n", "output": "2\n2\n"}, {"input": "2\n5 16\n1 2 8 4 8\n6 10\n2 8 8 2 2 8\n", "output": "\n2\n3\n"}, {"input": "2\n5 16\n1 2 8 4 8\n6 10\n2 8 8 2 2 8\n", "output": "2\n3\n"}, {"input": "2\n5 13\... | code_stdio |
[
{
"content": "A social network for dogs called DH (DogHouse) has k special servers to recompress uploaded videos of cute cats. After each video is uploaded, it should be recompressed on one (any) of the servers, and only after that it can be saved in the social network.\n\nWe know that each server takes one sec... | [{"input": "10 10\n999999991 1000000000\n999999992 1000000000\n999999993 1000000000\n999999994 1000000000\n999999995 1000000000\n999999996 1000000000\n999999997 1000000000\n999999998 1000000000\n999999999 1000000000\n1000000000 1000000000\n", "output": "1999999991\n1999999992\n1999999993\n1999999994\n1999999995\n199999... | code_stdio |
[
{
"content": "Everybody knows that the $m$-coder Tournament will happen soon. $m$ schools participate in the tournament, and only one student from each school participates.\n\nThere are a total of $n$ students in those schools. Before the tournament, all students put their names and the names of their schools i... | [{"input": "100 10 1\n62 68 24 82 66 47 73 43 85 23 78 13 94 14 84 17 27 5 72 48 59 46 97 81 88 9 76 69 11 15 12 61 70 7 91 34 99 52 54 57 56 64 55 67 40 38 74 25 30 4 22 92 33 3 86 45 37 26 87 53 75 71 58 96 98 20 36 1 95 63 10 49 19 41 89 21 39 100 93 42 32 90 28 83 6 29 60 65 44 35 18 16 8 50 80 31 51 2 77 79\n6 6 6... | code_stdio |
[
{
"content": "# Pythagorean Triples\n\nA Pythagorean triplet is a set of three numbers a, b, and c where `a^2 + b^2 = c^2`. In this Kata, you will be tasked with finding the Pythagorean triplets whose product is equal to `n`, the given argument to the function `pythagorean_triplet`.\n\n## Your task\n\nIn this K... | [{"input": "1440600", "output": "[[49, 168, 175]]", "fn_name": "pythagorean_triplet"}, {"input": "907200", "output": "[[42, 144, 150]]", "fn_name": "pythagorean_triplet"}, {"input": "120120", "output": "[[33, 56, 65]]", "fn_name": "pythagorean_triplet"}, {"input": "192720", "output": "[[48, 55, 73]]", "fn_name": "pytha... | code_functional |
[
{
"content": "One very experienced problem writer decided to prepare a problem for April Fools Day contest. The task was very simple - given an arithmetic expression, return the result of evaluating this expression. However, looks like there is a bug in the reference solution...\n\n\n-----Input-----\n\nThe only... | [{"input": "255+255+255+255+255+255+255+255+255+255\n", "output": "-42450\n"}, {"input": "101+200+195+231+107+222+146+254+160+209\n", "output": "-43175\n"}, {"input": "101+200+195+231+107+222+146+254+160+209\n", "output": "-43175\n"}, {"input": "255+255+255+255+255+255+255+255+255+255\n", "output": "-42450\n"}, {"input... | code_stdio |
[
{
"content": "Recently Lynyrd and Skynyrd went to a shop where Lynyrd bought a permutation p of length n, and Skynyrd bought an array a of length m, consisting of integers from 1 to n. \n\nLynyrd and Skynyrd became bored, so they asked you q queries, each of which has the following form: \"does the subsegment o... | [{"input": "3 6 3\n2 1 3\n1 2 3 1 2 3\n1 6\n2 6\n3 5\n", "output": "110\n"}, {"input": "3 6 3\n2 1 3\n1 2 3 2 2 3\n1 5\n2 6\n3 5\n", "output": "100\n"}, {"input": "3 6 3\n2 1 3\n2 2 3 1 2 3\n1 6\n2 6\n3 5\n", "output": "110\n"}, {"input": "3 6 3\n2 1 3\n1 2 1 1 2 3\n1 5\n2 6\n3 5\n", "output": "010\n"}, {"input": "3 6 ... | code_stdio |
[
{
"content": "# Task\n Your task is to find the smallest number which is evenly divided by all numbers between `m` and `n` (both inclusive).\n\n# Example\n\n For `m = 1, n = 2`, the output should be `2`.\n \n For `m = 2, n = 3`, the output should be `6`.\n \n For `m = 3, n = 2`, the output should be `6` too.\n ... | [{"input": "1\n25", "output": "[26771144400]", "fn_name": "mn_lcm"}, {"input": "10\n20", "output": "[232792560]", "fn_name": "mn_lcm"}, {"input": "1\n10", "output": "[2520]", "fn_name": "mn_lcm"}, {"input": "24\n25", "output": "[600]", "fn_name": "mn_lcm"}, {"input": "1\n5", "output": "[60]", "fn_name": "mn_lcm"}, {"in... | code_functional |
[
{
"content": "Petya and Vasya are tossing a coin. Their friend Valera is appointed as a judge. The game is very simple. First Vasya tosses a coin x times, then Petya tosses a coin y times. If the tossing player gets head, he scores one point. If he gets tail, nobody gets any points. The winner is the player wit... | [{"input": "100 100 1 1\n", "output": "4950\n2 1\n3 1\n3 2\n4 1\n4 2\n4 3\n5 1\n5 2\n5 3\n5 4\n6 1\n6 2\n6 3\n6 4\n6 5\n7 1\n7 2\n7 3\n7 4\n7 5\n7 6\n8 1\n8 2\n8 3\n8 4\n8 5\n8 6\n8 7\n9 1\n9 2\n9 3\n9 4\n9 5\n9 6\n9 7\n9 8\n10 1\n10 2\n10 3\n10 4\n10 5\n10 6\n10 7\n10 8\n10 9\n11 1\n11 2\n11 3\n11 4\n11 5\n11 6\n11 7\... | code_stdio |
[
{
"content": "You are given an array of N integers a1, a2, ..., aN and an integer K. Find the number of such unordered pairs {i, j} that \n\n- i ≠ j\n- |ai + aj - K| is minimal possible\n\nOutput the minimal possible value of |ai + aj - K| (where i ≠ j) and the number of such pairs for the given array and the ... | [{"input": "1 \n4 192\n14 -1 2 8", "output": "170 1\n"}, {"input": "1 \n4 279\n14 -1 2 8", "output": "257 1\n"}, {"input": "1 \n4 107\n1 -1 -1 2", "output": "104 1\n"}, {"input": "1 \n4 253\n14 -1 2 8", "output": "231 1\n"}, {"input": "1 \n4 51\n0 -1 -1 13", "output": "38 1\n"}, {"input": "1 \n4 51\n-1 -1 -... | code_stdio |
[
{
"content": "Ksusha the Squirrel is standing at the beginning of a straight road, divided into n sectors. The sectors are numbered 1 to n, from left to right. Initially, Ksusha stands in sector 1. \n\nKsusha wants to walk to the end of the road, that is, get to sector n. Unfortunately, there are some rocks on ... | [{"input": "10 3\n..........\n", "output": "YES\n"}, {"input": "10 3\n..........\n", "output": "YES\n"}, {"input": "10 1\n..........\n", "output": "YES\n"}, {"input": "10 4\n..........\n", "output": "YES\n"}, {"input": "10 2\n..........\n", "output": "YES\n"}, {"input": "8 2\n..........\n", "output": "YES\n"}, {"input"... | code_stdio |
[
{
"content": "Vasya has a sequence a consisting of n integers a_1, a_2, ..., a_n. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform number 6 (... 00000000110_2) into 3 (... 00000000011_2), 12 (.... | [{"input": "5\n1000000000000000000 352839520853234088 165431853141398699 753467583475385837 895062156280564685\n", "output": "4\n"}, {"input": "5\n1000000000000000000 352839520853234088 257894004782222768 753467583475385837 895062156280564685\n", "output": "4\n"}, {"input": "5\n1000000000000000000 352839520853234088 17... | code_stdio |
[
{
"content": "Please notice the unusual memory limit of this problem.\n\nOrac likes games. Recently he came up with the new game, \"Game of Life\".\n\nYou should play this game on a black and white grid with n rows and m columns. Each cell is either black or white.\n\nFor each iteration of the game (the initial... | [{"input": "5 5 3\n01011\n10110\n01101\n11010\n00101\n2 1 -1\n1 2 3\n5 5 3\n", "output": "1\n0\n1\n"}, {"input": "5 5 3\n00011\n10110\n01101\n11010\n00101\n2 1 -1\n1 2 3\n5 5 3\n", "output": "1\n1\n1\n"}, {"input": "5 5 3\n01011\n10110\n01101\n11010\n10101\n2 1 4\n1 2 3\n5 5 3\n", "output": "1\n0\n1\n"}, {"input": "5 5... | code_stdio |
[
{
"content": "The only difference between the two versions is that this version asks the maximal possible answer.\n\nHomer likes arrays a lot. Today he is painting an array $a_1, a_2, \\dots, a_n$ with two kinds of colors, white and black. A painting assignment for $a_1, a_2, \\dots, a_n$ is described by an arr... | [{"input": "15\n3 5 2 5 3 2 2 5 5 4 5 5 1 3 1\n", "output": "14\n"}, {"input": "11\n2 3 10 3 3 8 9 2 11 10 3\n", "output": "11\n"}, {"input": "11\n10 5 8 8 2 7 9 3 5 1 10\n", "output": "11\n"}, {"input": "8\n1 2 4 1 4 5 4 4\n", "output": "8\n"}, {"input": "7\n1 1 2 2 3 3 3\n", "output": "6\n"}, {"input": "7\n1 2 3 4 5 ... | code_stdio |
[
{
"content": "Palindrome\n\nProblem Statement\n\nFind the number of palindromes closest to the integer n.\n\nNote that the non-negative integer x is the number of palindromes, which means that the character string in which x is expressed in decimal notation and the character string in which it is inverted are e... | [{"input": "4752", "output": "4774\n"}, {"input": "8517", "output": "8558\n"}, {"input": "3483", "output": "3443\n"}, {"input": "1868", "output": "1881\n"}, {"input": "2667", "output": "2662\n"}, {"input": "3332", "output": "3333\n"}, {"input": "4989", "output": "4994\n"}, {"input": "5975", "output": "5995\n"}, {"input... | code_stdio |
[
{
"content": "Your Goal is to create a function that takes two strings, a guess and a phone number. \n\nBased on the guess, the function should display a portion of the phone number:\n\n guess_my_number('052', '123-451-2345')\n would return the string: '#2#-#5#-2##5'\n \n or\n \n guess_my_num... | [{"input": "\"012345\"", "output": "[\"123-451-2345\"]", "fn_name": "guess_my_number"}, {"input": "\"01234\"", "output": "[\"123-4#1-234#\"]", "fn_name": "guess_my_number"}, {"input": "\"0123\"", "output": "[\"123-##1-23##\"]", "fn_name": "guess_my_number"}, {"input": "\"012\"", "output": "[\"12#-##1-2###\"]", "fn_name... | code_functional |
[
{
"content": "A and B are preparing themselves for programming contests.\n\nAn important part of preparing for a competition is sharing programming knowledge from the experienced members to those who are just beginning to deal with the contests. Therefore, during the next team training A decided to make teams s... | [{"input": "500000 500000\n", "output": "333333\n"}, {"input": "250000 500000\n", "output": "250000\n"}, {"input": "500000 250000\n", "output": "250000\n"}, {"input": "231646 398487\n", "output": "210044\n"}, {"input": "332019 281112\n", "output": "204377\n"}, {"input": "473686 122443\n", "output": "122443\n"}, {"input... | code_stdio |
[
{
"content": "As the first step in algebra, students learn quadratic formulas and their factorization. Often, the factorization is a severe burden for them. A large number of students cannot master the factorization; such students cannot be aware of the elegance of advanced algebra. It might be the case that th... | [{"input": "2 5 4\n1 0 1\n10 -7 -1\n2 0 -5\n0 0 0", "output": "Impossible\nImpossible\nImpossible\nImpossible\n"}, {"input": "4 5 2\n1 1 1\n11 -10 0\n1 0 -3\n0 0 0", "output": "Impossible\nImpossible\n11 -10 1 0\nImpossible\n"}, {"input": "4 5 4\n2 0 1\n10 -7 1\n1 -1 -1\n0 0 0", "output": "Impossible\nImpossible\n5 -1 ... | code_stdio |
[
{
"content": "It's a Pokemon battle! Your task is to calculate the damage that a particular move would do using the following formula (not the actual one from the game):\n\nWhere:\n\n* attack = your attack power\n* defense = the opponent's defense\n* effectiveness = the effectiveness of the attack based on the ... | [{"input": "\"electric\"\n\"fire\"\n100\n100", "output": "[50]", "fn_name": "calculate_damage"}, {"input": "\"grass\"\n\"electric\"\n57\n19", "output": "[150]", "fn_name": "calculate_damage"}, {"input": "\"grass\"\n\"water\"\n100\n100", "output": "[100]", "fn_name": "calculate_damage"}, {"input": "\"fire\"\n\"electric\... | code_functional |
[
{
"content": "Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two diamonds and one stick.\n\nEach tool can be sold for exact... | [{"input": "4\n4 4\n1000000000 0\n12 15\n8 7\n", "output": "2\n0\n9\n5\n"}, {"input": "4\n4 4\n1010000000 0\n12 15\n8 7\n", "output": "2\n0\n9\n5\n"}, {"input": "4\n4 4\n1000000000 0\n7 15\n8 7\n", "output": "2\n0\n7\n5\n"}, {"input": "4\n4 4\n1000000000 0\n7 15\n8 7\n", "output": "2\n0\n7\n5\n"}, {"input": "1\n1319 17... | code_stdio |
[
{
"content": "Heidi has finally found the mythical Tree of Life – a legendary combinatorial structure which is said to contain a prophecy crucially needed to defeat the undead armies.\n\nOn the surface, the Tree of Life is just a regular undirected tree well-known from computer science. This means that it is a ... | [{"input": "10\n5 1\n1 2\n9 1\n10 8\n6 3\n8 5\n2 7\n2 3\n10 4\n", "output": "10\n"}, {"input": "10\n5 1\n1 2\n9 5\n10 5\n6 3\n8 10\n2 7\n2 3\n1 4\n", "output": "11\n"}, {"input": "10\n5 1\n1 2\n9 5\n10 5\n6 3\n8 10\n2 7\n1 3\n1 4\n", "output": "12\n"}, {"input": "10\n5 1\n1 2\n9 5\n10 5\n6 3\n8 10\n2 7\n1 3\n2 4\n", "o... | code_stdio |
[
{
"content": "A popular reality show is recruiting a new cast for the third season! $n$ candidates numbered from $1$ to $n$ have been interviewed. The candidate $i$ has aggressiveness level $l_i$, and recruiting this candidate will cost the show $s_i$ roubles.\n\nThe show host reviewes applications of all candi... | [{"input": "34 5\n2 2 5 4 3 1 3 5 3 1 3 1 3 5 5 2 1 3 3 3 1 1 1 4 5 1 3 2 5 5 2 1 2 2\n1357 797 4642 4072 3953 4020 207 344 1412 4061 400 214 708 389 567 3294 1336 3746 1513 3539 4220 4720 329 4516 1741 1744 2537 3963 4941 664 1169 4512 3358 4144\n-4668 -1085 109 -899 769 -1132 -2587 1503 760 -2869 4020 -3282 2208 -232... | code_stdio |
[
{
"content": "Polycarp plays a computer game (yet again). In this game, he fights monsters using magic spells.\n\nThere are two types of spells: fire spell of power $x$ deals $x$ damage to the monster, and lightning spell of power $y$ deals $y$ damage to the monster and doubles the damage of the next spell Poly... | [{"input": "6\n1 5\n0 10\n1 -5\n1 14\n1 11\n0 -10\n", "output": "5\n25\n10\n34\n59\n39\n"}, {"input": "6\n1 5\n0 10\n1 -5\n0 14\n1 11\n0 -10\n", "output": "5\n25\n10\n24\n49\n39\n"}, {"input": "6\n1 5\n0 10\n1 -5\n1 14\n1 16\n0 -10\n", "output": "5\n25\n10\n34\n66\n46\n"}, {"input": "6\n1 5\n0 10\n1 -5\n0 5\n1 11\n0 -1... | code_stdio |
[
{
"content": "Let's call an array good if there is an element in the array that equals to the sum of all other elements. For example, the array $a=[1, 3, 3, 7]$ is good because there is the element $a_4=7$ which equals to the sum $1 + 3 + 3$.\n\nYou are given an array $a$ consisting of $n$ integers. Your task i... | [{"input": "4\n500000 500000 1000000 1000000\n", "output": "2\n3 4 \n"}, {"input": "4\n500000 500000 1000000 1000000\n", "output": "2\n3 4\n"}, {"input": "4\n500000 251993 1000000 1000000\n", "output": "0\n\n"}, {"input": "6\n4 7 1 1 1 1\n", "output": "5\n2 3 4 5 6 \n"}, {"input": "4\n2 1000000 1000000 14\n", "output":... | code_stdio |
[
{
"content": "In Aizuwakamatsu Village, which is located far north of Aizuwakamatsu City, a bridge called \"Yabashi\" is the only way to move to the surrounding villages. Despite the large number of passers-by, the bridge is so old that it is almost broken.\n\n<image>\n\n\n\nYabashi is strong enough to withstan... | [{"input": "3\n125 -1 15\n108 12 25\n149 10 50\n3\n32 -1 10\n70 10 41\n22 67 84\n0", "output": "NG\nOK\n"}, {"input": "3\n125 -1 15\n108 8 25\n246 10 42\n3\n32 -1 10\n70 10 41\n22 67 129\n0", "output": "NG\nOK\n"}, {"input": "3\n125 -1 15\n108 7 25\n246 10 42\n3\n32 -1 10\n70 10 41\n22 67 129\n0", "output": "NG\nOK\n"}... | code_stdio |
[
{
"content": "Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.\n\nAfter the c... | [{"input": "1000 1000 1 1000 1000000 1000000\n", "output": "1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 ... | code_stdio |
[
{
"content": "Assume we take a number `x` and perform any one of the following operations:\n```Pearl\na) Divide x by 3 (if it is divisible by 3), or\nb) Multiply x by 2\n```\nAfter each operation, we write down the result. If we start with `9`, we can get a sequence such as:\n```\n[9,3,6,12,4,8] -- 9/3=3 -> 3*2... | [{"input": "[558, 744, 1488, 279, 2232, 1116]", "output": "[[279, 558, 1116, 2232, 744, 1488]]", "fn_name": "solve"}, {"input": "[12, 3, 9, 4, 6, 8]", "output": "[[9, 3, 6, 12, 4, 8]]", "fn_name": "solve"}, {"input": "[4, 8, 6, 3, 12, 9]", "output": "[[9, 3, 6, 12, 4, 8]]", "fn_name": "solve"}, {"input": "[3000, 9000]"... | code_functional |
[
{
"content": "We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.\nFind the maximum number of consecutive rainy day... | [{"input": "RRS\n", "output": "2\n"}, {"input": "SSS\n", "output": "0\n"}, {"input": "RSR\n", "output": "1\n"}, {"input": "SRS\n", "output": "1\n"}, {"input": "SSR\n", "output": "1\n"}, {"input": "RRR\n", "output": "3\n"}, {"input": "RSS\n", "output": "1\n"}, {"input": "SRR\n", "output": "2\n"}, {"input": "SRR", "outpu... | code_stdio |
[
{
"content": "You are given a marine area map that is a mesh of squares, each representing either a land or sea area. Figure B-1 is an example of a map.\n\n<image>\nFigure B-1: A marine area map\n\nYou can walk from a square land area to another if they are horizontally, vertically, or diagonally adjacent to ea... | [{"input": "1 1\n0\n2 1\n0 1\n1 0\n3 2\n1 1 1\n1 1 1\n5 4\n1 0 1 0 0\n1 -1 1 0 0\n1 1 1 0 1\n1 0 0 1 0\n5 4\n1 1 1 0 2\n1 0 1 0 1\n0 0 1 0 1\n2 0 1 1 1\n5 5\n1 0 1 0 1\n0 0 1 0 0\n1 1 1 0 1\n0 0 1 0 0\n1 0 0 1 1\n0 0", "output": "0\n1\n0\n1\n1\n1\n5\n"}, {"input": "1 1\n0\n2 1\n0 1\n1 0\n3 2\n1 1 1\n1 1 1\n5 4\n1 0 1 0... | code_stdio |
[
{
"content": "Vova again tries to play some computer card game.\n\nThe rules of deck creation in this game are simple. Vova is given an existing deck of n cards and a magic number k. The order of the cards in the deck is fixed. Each card has a number written on it; number a_{i} is written on the i-th card in th... | [{"input": "100 72\n8 8 7 9 6 1 4 5 3 7 5 10 5 4 1 3 4 1 3 1 6 6 4 5 4 5 6 1 10 7 9 1 6 10 6 6 9 3 3 4 5 9 4 9 8 1 5 9 3 7 1 8 5 2 1 1 7 7 7 6 6 4 2 9 10 2 8 3 1 1 4 8 5 9 7 10 9 4 2 3 7 7 6 7 8 5 1 3 8 5 1 8 9 10 3 7 1 8 10 5\n", "output": "4549\n"}, {"input": "100 72\n8 8 7 9 6 1 4 5 3 7 5 10 5 4 1 3 4 1 3 1 6 6 4 5 ... | code_stdio |
[
{
"content": "Your job is to build a function which determines whether or not there are double characters in a string (including whitespace characters). For example ```aa```, ``!!`` or ``` ```.\n \n\nYou want the function to return true if the string contains double characters and false if not. The test shoul... | [{"input": "\"a!@\\u20ac\\u00a3#$%^&*()_-+=}]{[|':;?/>.<,~\"", "output": "[false]", "fn_name": "double_check"}, {"input": "\"a b c d e f g h i h k\"", "output": "[false]", "fn_name": "double_check"}, {"input": "\"a 11 c d\"", "output": "[true]", "fn_name": "double_check"}, {"input": "\"AabBcC\"", "output": "[true]", "f... | code_functional |
[
{
"content": "The beauty of a sequence a of length n is defined as a_1 \\oplus \\cdots \\oplus a_n, where \\oplus denotes the bitwise exclusive or (XOR).\n\nYou are given a sequence A of length N. Snuke will insert zero or more partitions in A to divide it into some number of non-empty contiguous subsequences.\... | [{"input": "32\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 1 0 0", "output": "268435465\n"}, {"input": "32\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0", "output": "33554438\n"}, {"input": "32\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", "output": "147483634"}, {... | code_stdio |
[
{
"content": "On a circle lie $2n$ distinct points, with the following property: however you choose $3$ chords that connect $3$ disjoint pairs of points, no point strictly inside the circle belongs to all $3$ chords. The points are numbered $1, \\, 2, \\, \\dots, \\, 2n$ in clockwise order.\n\nInitially, $k$ ch... | [{"input": "4\n6 2\n8 2\n1 4\n1 1\n2 1\n2 0\n10 2\n14 12\n4 20\n9 10\n13 18\n30 18\n11 7\n", "output": "12\n0\n1\n32\n"}, {"input": "4\n5 2\n8 2\n1 4\n1 1\n2 1\n2 0\n15 1\n13 12\n4 20\n9 10\n13 18\n30 18\n13 12\n", "output": "7\n0\n1\n91\n"}, {"input": "4\n7 2\n14 2\n1 4\n1 1\n2 1\n0 0\n10 6\n19 2\n3 20\n8 10\n16 18\n1... | code_stdio |
[
{
"content": "You are given a string s consisting only of characters 0 and 1. A substring [l, r] of s is a string s_{l}s_{l} + 1s_{l} + 2... s_{r}, and its length equals to r - l + 1. A substring is called balanced if the number of zeroes (0) equals to the number of ones in this substring.\n\nYou have to determ... | [{"input": "65\n11001000110001001011011110111100000000101001001010101111000100010\n", "output": "48\n"}, {"input": "65\n11001000110001001011011110111100000000101001001010101111000100010\n", "output": "48\n"}, {"input": "65\n11001000110101001011011110111100000000101001001010101111000100010\n", "output": "56\n"}, {"input... | code_stdio |
[
{
"content": "There is a square matrix n × n, consisting of non-negative integer numbers. You should find such a way on it that \n\n * starts in the upper left cell of the matrix; \n * each following cell is to the right or down from the current cell; \n * the way ends in the bottom right cell. \n\n\n\nMoreo... | [{"input": "10\n10 8 6 5 9 8 2 5 3 2\n3 1 8 10 8 10 5 10 7 8\n5 9 7 7 4 9 7 2 5 2\n5 9 9 5 4 2 6 6 8 1\n10 6 9 9 10 5 6 3 5 9\n6 7 10 3 1 4 3 6 7 6\n10 10 4 7 4 4 8 2 7 4\n10 5 8 2 2 7 4 4 1 4\n8 4 6 10 10 6 1 3 3 1\n9 9 7 2 11 5 1 8 6 3\n", "output": "1\nDRDDDRRDDDRRDRDRRR\n"}, {"input": "10\n10 8 6 5 9 8 2 5 3 2\n3 1... | code_stdio |
[
{
"content": "Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes.\n\nStrictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \\leq x \\leq x_2$ and $y... | [{"input": "2\n282238675 111160538 526707498 169652181\n", "output": "14299383119546189\n"}, {"input": "2\n229872385 40870434 715428884 160550871\n", "output": "46761413035493300\n"}, {"input": "2\n186213023 111160538 526707498 169652181\n", "output": "6881807548140320\n"}, {"input": "2\n229872385 25548581 715428884 16... | code_stdio |
[
{
"content": "In fact, the problems E1 and E2 do not have much in common. You should probably think of them as two separate problems.\n\nYou are given an integer array $a[1 \\ldots n] = [a_1, a_2, \\ldots, a_n]$.\n\nLet us consider an empty deque (double-ended queue). A deque is a data structure that supports a... | [{"input": "6\n4\n2 11 8 -1\n3\n10 2 1\n3\n3 10 2\n4\n1 2 1 -1\n4\n4 0 1 6\n5\n1 5 1 -1 0\n", "output": "1\n0\n0\n0\n1\n1\n"}, {"input": "6\n4\n2 11 8 -1\n3\n10 2 1\n3\n5 10 2\n4\n1 2 1 -1\n4\n1 0 1 6\n5\n1 5 1 -1 0\n", "output": "1\n0\n0\n0\n0\n1\n"}, {"input": "6\n4\n3 7 8 15\n3\n3 2 1\n3\n3 0 0\n4\n-1 2 1 -1\n4\n2 1... | code_stdio |
[
{
"content": "Hiroshi:? D-C'KOPUA\n\nPeter: What's wrong, Dr. David? I'm used to shouting something I don't understand, but I'm not even writing it today.\n\nHiroshi: Here.\n\n<image>\n\n\nPeter: What? This table ... oh, there was something like this in the qualifying question. Replacing characters using a tabl... | [{"input": "?DKC'-OPUB", "output": "PES WP E EIERD\n"}, {"input": "?DKC'-OPUA", "output": "PES WP E EIER\n"}, {"input": ".UPDL'BCN?", "output": "EP.PD IP?DSPP\n"}, {"input": ".UQDL'BCN?", "output": "EPF'K PEWLEPP\n"}, {"input": "?NDBULDQ'.", "output": "PEERED DKT,EE\n"}, {"input": ".'QDLUBDN?", "output": "EPPHD IHLKEPP... | code_stdio |
[
{
"content": "Let’s try a dice puzzle. The rules of this puzzle are as follows.\n\n1. Dice with six faces as shown in Figure 1 are used in the puzzle.\n\n<image>\n\nFigure 1: Faces of a die\n\n2. With twenty seven such dice, a 3 × 3 × 3 cube is built as shown in Figure 2.\n\n<image>\n\nFigure 2: 3 × 3 × 3 cube\... | [{"input": "4\n0 0 1\n0 1 0\n0 2 2\n0 2 2\n1 2 2\n6 -1 0\n0 7 4\n0 4 1\n4 1 0\n6 1 0\n12 -1 0\n4 1 -2\n1 -1 0\n1 2 0\n0 -1 -1\n5 1 2\n10 0 2\n-2 1 -2\n3 -1 -1\n-1 6 -2\n0 0 -1\n0 1 0\n-2 1 0\n3 0 0", "output": "0\n0\n0\n0\n"}, {"input": "4\n0 0 1\n0 1 0\n0 2 2\n0 2 2\n1 2 2\n6 -1 0\n0 7 4\n0 4 1\n4 1 0\n6 1 0\n12 -2 0\... | code_stdio |
[
{
"content": "Implement a function which \ncreates a **[radix tree](https://en.wikipedia.org/wiki/Radix_tree)** (a space-optimized trie [prefix tree]) \nin which each node that is the only child is merged with its parent [unless a word from the input ends there]) \nfrom a given list of words \nusing dictionarie... | [{"input": "\"ape\"\n\"apple\"\n\"applet\"\n\"appendix\"", "output": "[{\"ap\": {\"e\": {}, \"p\": {\"le\": {\"t\": {}}, \"endix\": {}}}}]", "fn_name": "radix_tree"}, {"input": "\"abc\"\n\"def\"\n\"ghi\"\n\"jklm\"\n\"nop\"", "output": "[{\"abc\": {}, \"def\": {}, \"ghi\": {}, \"jklm\": {}, \"nop\": {}}]", "fn_name": "r... | code_functional |
[
{
"content": "Implement a function to calculate the sum of the numerical values in a nested list. For example :\n\n```python\nsum_nested([1, [2, [3, [4]]]]) -> 10\n```\n\nWrite Python code to solve this problem. Define a top-level function named `sum_nested` that takes the input arguments described above and re... | [{"input": "[[[[], [], [[[[[[[[[[]]]]]]]]]]], [], [], [[[], [[]]]]], []]", "output": "[0]", "fn_name": "sum_nested"}, {"input": "[1, [1], [1, [1]], [1, [1], [1, [1]]]]", "output": "[8]", "fn_name": "sum_nested"}, {"input": "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]", "output": "[55]", "fn_name": "sum_nested"}, {"input": "[1, ... | code_functional |
[
{
"content": "Consider the numbers `6969` and `9116`. When you rotate them `180 degrees` (upside down), these numbers remain the same. To clarify, if we write them down on a paper and turn the paper upside down, the numbers will be the same. Try it and see! Some numbers such as `2` or `5` don't yield numbers wh... | [{"input": "60000\n130000", "output": "[55]", "fn_name": "solve"}, {"input": "60000\n70000", "output": "[15]", "fn_name": "solve"}, {"input": "1000\n10000", "output": "[20]", "fn_name": "solve"}, {"input": "10000\n15000", "output": "[6]", "fn_name": "solve"}, {"input": "15000\n20000", "output": "[9]", "fn_name": "solve... | code_functional |
[
{
"content": "Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $a$ minutes to feel refreshed.\n\nPolycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $b$ minutes.\n\nEvery time Polycarp wakes up, h... | [{"input": "7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000\n", "output": "27\n27\n9\n-1\n1\n6471793\n358578060125049\n"}, {"input": "7\n10 3 6 4\n11 3 6 0\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000\n", "out... | code_stdio |
[
{
"content": "Takahashi and Aoki will play a game. They will repeatedly play it until one of them have N wins in total.\n\nWhen they play the game once, Takahashi wins with probability A %, Aoki wins with probability B %, and the game ends in a draw (that is, nobody wins) with probability C %. Find the expected... | [{"input": "100001 31 41 28", "output": "904789367\n"}, {"input": "000001 31 41 28", "output": "388888893\n"}, {"input": "000011 31 41 28", "output": "339871354\n"}, {"input": "010001 31 41 28", "output": "24577229\n"}, {"input": "100000 31 41 28", "output": "104136146"}, {"input": "14 110 0 -10", "output": "545454562\... | code_stdio |
[
{
"content": "You are given three strings $a$, $b$ and $c$ of the same length $n$. The strings consist of lowercase English letters only. The $i$-th letter of $a$ is $a_i$, the $i$-th letter of $b$ is $b_i$, the $i$-th letter of $c$ is $c_i$.\n\nFor every $i$ ($1 \\leq i \\leq n$) you must swap (i.e. exchange) ... | [{"input": "4\naaa\nbbb\nccc\nabc\nbca\nbca\naabb\nbbaa\nbaba\nimi\nmii\niim\n", "output": "NO\nYES\nYES\nNO\n"}, {"input": "4\naaa\nbbb\nccc\nabc\nbca\ncca\naabb\nbbaa\nbaba\niim\nmii\niim\n", "output": "NO\nNO\nYES\nYES\n"}, {"input": "4\naa`\ncbc\ncac\ncba\naca\ncca\nbaab\nbdaa\nabab\niil\nmih\nimj\n", "output": "YE... | code_stdio |
[
{
"content": "Palo Alto is an unusual city because it is an endless coordinate line. It is also known for the office of Lyft Level 5.\n\nLyft has become so popular so that it is now used by all $m$ taxi drivers in the city, who every day transport the rest of the city residents — $n$ riders.\n\nEach resident (i... | [{"input": "1 4\n2 4 6 10 15\n1 1 1 1 0\n", "output": "0 0 0 1 "}, {"input": "1 4\n2 4 6 10 14\n1 1 1 1 0\n", "output": "0 0 0 1\n"}, {"input": "1 4\n3 4 6 10 15\n1 1 1 1 0\n", "output": "0 0 0 1\n"}, {"input": "1 4\n2 4 6 10 27\n1 1 1 1 0\n", "output": "0 0 0 1\n"}, {"input": "1 4\n2 4 6 10 15\n1 1 1 1 0\n", "output":... | code_stdio |
[
{
"content": "There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\n* Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value ... | [{"input": "128 2\n35 6 2 5 0 4 2 5", "output": "127\n"}, {"input": "163 2\n35 6 2 5 0 4 2 5", "output": "162\n"}, {"input": "128 6\n35 6 2 5 0 5 2 5", "output": "26\n"}, {"input": "8 3\n14 3 1 8 4 6 2 5", "output": "4\n"}, {"input": "8 2\n14 5 1 4 2 6 2 5", "output": "7\n"}, {"input": "8 3\n14 5 1 8 4 6 2 5", "output"... | code_stdio |
[
{
"content": "Do you know Just Odd Inventions? The business of this company is to \"just odd inventions\". Here, it is abbreviated as JOI.\n\nJOI is conducting research to confine many microorganisms in one petri dish alive. There are N microorganisms to be investigated, and they are numbered 1, 2, ..., N. When... | [{"input": "6\n12 13\n5 9\n2 4\n10 12\n6 12\n6 11", "output": "5\n"}, {"input": "6\n12 38\n5 9\n2 4\n10 12\n6 12\n11 9", "output": "5\n"}, {"input": "6\n12 13\n5 9\n2 2\n10 12\n6 12\n6 11", "output": "5\n"}, {"input": "6\n12 38\n5 9\n0 4\n10 12\n6 12\n11 9", "output": "5\n"}, {"input": "6\n12 9\n5 9\n2 4\n10 12\n10 12\... | code_stdio |
[
{
"content": "Peter wrote on the board a strictly increasing sequence of positive integers a_1, a_2, ..., a_{n}. Then Vasil replaced some digits in the numbers of this sequence by question marks. Thus, each question mark corresponds to exactly one lost digit.\n\nRestore the the original sequence knowing digits ... | [{"input": "98\n?\n?0\n2?\n6?\n6?\n69\n??\n??\n96\n1?2\n??3\n104\n??4\n1?9\n??2\n18?\n?01\n205\n?19\n244\n??8\n?5?\n?5?\n276\n??3\n???\n???\n?28\n?3?\n3??\n??8\n355\n4?0\n4??\n?10\n??1\n417\n4?9\n?3?\n4?4\n?61\n?8?\n???\n507\n?2?\n???\n??6\n5?7\n540\n5?9\n???\n?7?\n5??\n591\n?9?\n6?0\n620\n??4\n??1\n?35\n65?\n65?\n6?8\... | code_stdio |
[
{
"content": "Example\n\nInput\n\n3\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": "20093", "output": "276\n"}, {"input": "5663", "output": "100\n"}, {"input": "1761", "output": "292\n"}, {"input": "2283", "output": "36\n"}, {"input": "1253", "output": "88\n"}, {"input": "1203", "output": "20\n"}, {"input": "1457", "output": "44\n"}, {"input": "2031", "output": "78\n"}, {"input": "2941", "... | code_stdio |
[
{
"content": "You're given an array $a$ of $n$ integers, such that $a_1 + a_2 + \\cdots + a_n = 0$.\n\nIn one operation, you can choose two different indices $i$ and $j$ ($1 \\le i, j \\le n$), decrement $a_i$ by one and increment $a_j$ by one. If $i < j$ this operation is free, otherwise it costs one coin.\n\n... | [{"input": "7\n4\n-3 5 -3 1\n2\n1 -1\n4\n-3 2 -3 4\n4\n-1 1 1 -1\n7\n-5 7 -6 -4 17 -13 4\n6\n-1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000\n1\n0\n", "output": "3\n0\n4\n1\n8\n3000000000\n0\n"}, {"input": "7\n4\n-3 5 -3 1\n2\n1 -1\n4\n-3 2 -3 4\n4\n-1 1 1 -1\n7\n-5 7 -6 -4 17 -13 4\n6\n-1000000000... | code_stdio |
[
{
"content": "problem\n\nCryptography is all the rage at xryuseix's school. Xryuseix, who lives in a grid of cities, has come up with a new cryptography to decide where to meet.\n\nThe ciphertext consists of the $ N $ character string $ S $, and the $ S_i $ character determines the direction of movement from th... | [{"input": "5\nAMazA", "output": "3\nAAA\n"}, {"input": "5\nAMAza", "output": "3\nAAA\n"}, {"input": "5\nAMBza", "output": "3\nAAA\n"}, {"input": "5\nAaBzM", "output": "3\nAAA\n"}, {"input": "5\nAazBM", "output": "3\nAAA\n"}, {"input": "5\nazAMA", "output": "3\nAAA\n"}, {"input": "5\nALBza", "output": "3\nAAA\n"}, {"in... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.