messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "Finish the solution so that it takes an input `n` (integer) and returns a string that is the decimal representation of the number grouped by commas after every 3 digits.\n\nAssume: `0 <= n < 2147483647`\n\n## Examples\n\n```\n 1 -> \"1\"\n 10 -> \"10\"\n 100 ->...
[{"input": "1234567890", "output": "[\"1,234,567,890\"]", "fn_name": "group_by_commas"}, {"input": "123456789", "output": "[\"123,456,789\"]", "fn_name": "group_by_commas"}, {"input": "12345678", "output": "[\"12,345,678\"]", "fn_name": "group_by_commas"}, {"input": "1234567", "output": "[\"1,234,567\"]", "fn_name": "g...
code_functional
[ { "content": "Ivan is a student at Berland State University (BSU). There are n days in Berland week, and each of these days Ivan might have some classes at the university.\n\nThere are m working hours during each Berland day, and each lesson at the university lasts exactly one hour. If at some day Ivan's first ...
[{"input": "4 113 370\n01110100100010110100110000000011001111110000100111111001011001110111110111001011010110000110110010101010110001000\n01101001111110001010001100101100111100111001001001001101110101100110110110001110100010111011101011101110011110100\n0110011000100111101000001010110011110001111101000010101001101111111...
code_stdio
[ { "content": "After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.\n\nThe three friends are very smart so they passed all the challenges very quickly and finally...
[{"input": "727\nbaabbabbbababbbbaaaabaabbaabababaaababaaababbbbababbbbbbbbbbaaabaabbbbbbbbaaaabaabbaaabaabbabaa\nddcdcccccccdccdcdccdddcddcddcddddcdddcdcdccddcdddddccddcccdcdddcdcccdccccccdcdcdccccccdccccccdc\nfffeefeffeefeeeeffefffeeefffeefffefeefefeeeffefefefefefefffffffeeeeeffffeefeeeeffffeeeeeefeffef\n", "output":...
code_stdio
[ { "content": "Vasya is an administrator of a public page of organization \"Mouse and keyboard\" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a list of hashtags to make searching for a particular topic more comfortable. For the purpose of this ...
[{"input": "2\n#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\n#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "Petya once wrote a sad love song and shared it to Vasya. The song is a string consisting of lowercase English letters. Vasya made up $q$ questions about this song. Each question is about a subsegment of the song starting from the $l$-th letter to the $r$-th letter. Vasya considers a substring made...
[{"input": "13 7\nsonokhisumiwo\n1 5\n2 10\n7 10\n1 13\n1 8\n1 9\n3 6\n", "output": "74\n125\n62\n191\n110\n131\n48\n"}, {"input": "13 7\nowimusihkooos\n1 7\n2 10\n7 8\n2 13\n2 8\n2 4\n6 9\n", "output": "109\n128\n17\n177\n102\n45\n47\n"}, {"input": "13 7\nowimusihkooos\n1 7\n2 10\n7 7\n2 13\n2 8\n2 9\n6 9\n", "output"...
code_stdio
[ { "content": "You are given an integer sequence of length N, a_1,a_2,...,a_N.\n\nFor each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing.\n\nAfter these operations, you select an integer X and count the number of i such that a_i=X.\n\nMaximize this count by making optimal choices...
[{"input": "10\n-1 1 2 3 2 8 6 7 14 4", "output": "4\n"}, {"input": "10\n-1 2 1 5 8 2 8 4 20 0", "output": "4\n"}, {"input": "10\n-1 2 1 5 8 4 8 4 20 0", "output": "3\n"}, {"input": "10\n-1 2 1 5 8 4 8 4 17 0", "output": "3\n"}, {"input": "10\n-1 2 1 5 4 4 8 4 17 0", "output": "4\n"}, {"input": "10\n-1 2 1 1 4 4 8 4 17...
code_stdio
[ { "content": "The Berland capital is shaken with three bold crimes committed by the Pihsters, a notorious criminal gang.\n\nThe Berland capital's map is represented by an n × m rectangular table. Each cell of the table on the map represents some districts of the capital. \n\nThe capital's main detective Polycar...
[{"input": "99 3\n**.\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n.....
code_stdio
[ { "content": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit che...
[{"input": "97 -13\n-17 -11 -20 -16 -11 -18 -17 -14 -19 -13 -11 -19 -15 -17 -11 -20 -10 -19 -10 -18 -11 -14 -11 -15 -13 -13 -11 -18 -18 -18 -11 -14 -20 -19 -10 -17 -18 -19 -17 -11 -11 -11 -20 -19 -16 -15 -18 -15 -15 -20 -19 -20 -16 -13 -17 -11 -13 -18 -10 -13 -10 -14 -12 -17 -20 -10 -11 -19 -19 -15 -19 -10 -18 -14 -15 ...
code_stdio
[ { "content": "Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below.\nGiven two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.\n\n-----Constraints-----\n - x and y are integers.\n - 1 ≤ x < y ≤ 12\n\n-----Input--...
[{"input": "12 12", "output": "Yes\n"}, {"input": "1 3\n", "output": "Yes\n"}, {"input": "1 10", "output": "Yes\n"}, {"input": "7 10", "output": "Yes\n"}, {"input": "7 12", "output": "Yes\n"}, {"input": "5 10", "output": "Yes\n"}, {"input": "5 12", "output": "Yes\n"}, {"input": "1 12", "output": "Yes\n"}, {"input": "12...
code_stdio
[ { "content": "N Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.\nThere are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \\cdots, A_{i, {d_i}}.\nTakahashi will walk around this town and make mischief on t...
[{"input": "100 100\n100\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100\n1...
code_stdio
[ { "content": "Kuro is living in a country called Uberland, consisting of $n$ towns, numbered from $1$ to $n$, and $n - 1$ bidirectional roads connecting these towns. It is possible to reach each town from any other. Each road connects two towns $a$ and $b$. Kuro loves walking and he is planning to take a walkin...
[{"input": "70 42 32\n25 50\n51 7\n39 61\n1 33\n20 5\n1 70\n1 63\n42 35\n64 16\n1 11\n39 42\n20 54\n11 14\n57 44\n1 59\n55 40\n25 3\n31 18\n38 68\n57 23\n39 57\n28 10\n39 20\n42 26\n58 6\n20 56\n57 2\n13 21\n15 69\n39 64\n1 39\n62 53\n39 13\n1 41\n22 12\n13 30\n68 67\n20 31\n51 15\n57 32\n59 34\n39 4\n31 65\n58 24\n20 ...
code_stdio
[ { "content": "Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in...
[{"input": "10 10 10 1\n8 10\n2 9\n1 10\n3 1\n8 5\n10 1\n4 10\n10 2\n5 3\n9 3\n", "output": "1787\n"}, {"input": "10 10 10 1\n8 10\n2 9\n1 10\n3 1\n8 5\n10 1\n4 10\n10 2\n5 3\n9 3\n", "output": "1787\n"}, {"input": "10 10 10 1\n1 10\n10 8\n7 4\n7 2\n1 3\n6 6\n10 1\n2 7\n9 3\n3 10\n", "output": "1991\n"}, {"input": "10 ...
code_stdio
[ { "content": "You will receive 3 points for solving this problem.\n\nManao is designing the genetic code for a new type of algae to efficiently produce fuel. Specifically, Manao is focusing on a stretch of DNA that encodes one protein. The stretch of DNA is represented by a string containing only the characters...
[{"input": "CCCTTCACCCGGATCCAAATCCCTTAGAAATAATCCCCGACGGCGTTGTATCACCTCTGCACTTGTTAGTAAGGTCAGGCGTCCATTACGGAAGAACGTA\n", "output": "19\n"}, {"input": "GCATTACATGGGGGGGTCCTACGAGCCCGGCATCCCGGAAACTAGCCGGTTAATTTGGTTTAAACCCTCCCACCCCGGATTGTAACCCCCCTCATTGGTT\n", "output": "17\n"}, {"input": "TTCCCAGAGAAAAAAAGGGGCCCAAATGCCCTAAAAAC...
code_stdio
[ { "content": "You are a programmer on the development team for new recording media. This recording medium can be randomly accessed for reading and erasing data. On the other hand, when writing data, access is always performed in order from the beginning, and only the first free space found can be written.\n\nYo...
[{"input": "6\nW 0 2\nW 0 2\nD 0\nW 2 1\nR 3\nR 2\n1\nR 1000000000\n0", "output": "-1\n-1\n\n-1\n\n"}, {"input": "6\nW 0 3\nW 0 2\nD 0\nW 2 1\nR 4\nR 1\n1\nR 1000000000\n0", "output": "-1\n-1\n\n-1\n\n"}, {"input": "6\nW 0 2\nW 0 2\nD 0\nW 3 1\nR 3\nR 2\n1\nR 1000000000\n0", "output": "-1\n-1\n\n-1\n\n"}, {"input": "6\...
code_stdio
[ { "content": "Pasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same apple), so he decided to distribute the app...
[{"input": "100 1 100\n84\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100\n...
code_stdio
[ { "content": "The number \"zero\" is called \"love\" (or \"l'oeuf\" to be precise, literally means \"egg\" in French), for example when denoting the zero score in a game of tennis. \n\nAki is fond of numbers, especially those with trailing zeros. For example, the number $9200$ has two trailing zeros. Aki thinks...
[{"input": "1000000000000000000 1000000000000\n", "output": "20833333333333332\n"}, {"input": "1000000000000000000 1000000000000\n", "output": "20833333333333332\n"}, {"input": "1000000000000000000 470184984576\n", "output": "33333333333333332\n"}, {"input": "1000000000000000000 743008370688\n", "output": "454545454545...
code_stdio
[ { "content": "Go around the Labyrinth\n\nExplorer Taro got a floor plan of a labyrinth. The floor of this labyrinth is in the form of a two-dimensional grid. Each of the cells on the floor plan corresponds to a room and is indicated whether it can be entered or not. The labyrinth has only one entrance located a...
[{"input": "3 3\n...\n.#.\n...\n5 5\n..#..\n.....\n#....\n.....\n.....\n3 8\n..#.....\n........\n.....#..\n3 5\n..#..\n-....\n..#..\n4 4\n....\n....\n..##\n..#.\n0 0", "output": "YES\nNO\nYES\nNO\nNO\n"}, {"input": "3 3\n...\n.#.\n...\n5 5\n..#..\n.....\n...#.\n.....\n.....\n3 8\n.....#..\n........\n.....#..\n3 5\n..#....
code_stdio
[ { "content": "Some number of chocolate pieces were prepared for a training camp.\nThe camp had N participants and lasted for D days.\nThe i-th participant (1 \\leq i \\leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on.\...
[{"input": "5\n30 44\n26\n18\n81\n18\n6\n", "output": "56\n"}, {"input": "5\n30 44\n26\n18\n81\n18\n10", "output": "54\n"}, {"input": "5\n30 29\n26\n18\n81\n18\n10", "output": "39\n"}, {"input": "5\n30 29\n26\n18\n81\n18\n19", "output": "38\n"}, {"input": "5\n1 113\n25\n21\n13\n16\n7", "output": "118\n"}, {"input": "5\...
code_stdio
[ { "content": "This problem is a version of problem D from the same contest with some additional constraints and tasks.\n\nThere are $n$ candies in a candy box. The type of the $i$-th candy is $a_i$ ($1 \\le a_i \\le n$). \n\nYou have to prepare a gift using some of these candies with the following restriction: ...
[{"input": "3\n8\n1 0\n4 1\n2 0\n4 1\n5 1\n6 1\n3 0\n2 0\n4\n1 1\n1 1\n2 1\n2 1\n9\n2 0\n2 0\n4 1\n4 1\n4 1\n7 0\n7 1\n7 0\n7 1\n", "output": "3 3\n3 3\n9 5\n"}, {"input": "3\n8\n1 0\n4 1\n2 0\n4 1\n5 1\n6 1\n3 0\n2 0\n4\n1 1\n1 1\n2 1\n2 1\n9\n2 0\n2 0\n4 1\n4 1\n4 1\n7 0\n9 1\n7 0\n7 1\n", "output": "3 3\n3 3\n6 5\n"...
code_stdio
[ { "content": "A: Information Search\n\nproblem\n\nThe posting list is a list in which there is a correspondence between the search term and the appearing document ID. For example\n\n* Hokkaido: 1, 2, 4, 9\n* Sightseeing: 1, 3, 4, 7\n\n\n\nAnd so on.\n\nFrom the above posting list, if you search for and, the doc...
[{"input": "4 4\n0 2 10 11\n1 2 4 14", "output": "1 7\n2\n0\n1\n2\n4\n10\n11\n14\n"}, {"input": "4 4\n1 2 5 12\n2 3 4 13", "output": "1 7\n2\n1\n2\n3\n4\n5\n12\n13\n"}, {"input": "4 4\n1 2 4 12\n2 3 4 13", "output": "2 6\n2\n4\n1\n2\n3\n4\n12\n13\n"}, {"input": "4 4\n0 2 4 10\n0 3 4 13", "output": "2 6\n0\n4\n0\n2\n3\n...
code_stdio
[ { "content": "Tavas is a strange creature. Usually \"zzz\" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead.\n\n<image>\n\nToday Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p....
[{"input": "173700 6\nbcabcbcbcbaaacaccaacaccaabacabaacbcacbbccaccbcacbabcaccccccaacacabbbbbacabbaaacbcbbaccaccabbbbaabbacacbabccaabcabbbcacaaccbabbcaaaaaabccbbcabcacbcbcabcbcbbaabacaaccccabacaaaccacaaabbacacabbcccacbaabcacacbbaaaccaccbaccccccbccaabcacaacabaccababacabcccbcbbacbabacbcbabacbbaccaabcabcbbbaaabbacbbbcacccb...
code_stdio
[ { "content": "There are $n$ monsters standing in a row numbered from $1$ to $n$. The $i$-th monster has $h_i$ health points (hp). You have your attack power equal to $a$ hp and your opponent has his attack power equal to $b$ hp.\n\nYou and your opponent are fighting these monsters. Firstly, you and your opponen...
[{"input": "6 2 3 3\n7 10 50 12 1 8\n", "output": "5\n"}, {"input": "6 2 3 2\n7 10 50 12 1 8\n", "output": "4\n"}, {"input": "6 2 3 2\n5 10 50 12 1 8\n", "output": "3\n"}, {"input": "6 2 2 2\n5 10 50 12 1 8\n", "output": "6\n"}, {"input": "6 2 0 3\n1 9 50 12 1 15\n", "output": "6\n"}, {"input": "6 2 3 3\n7 10 51 12 1 8...
code_stdio
[ { "content": "Digits Are Not Just Characters\n\nMr. Manuel Majorana Minore made a number of files with numbers in their names. He wants to have a list of the files, but the file listing command commonly used lists them in an order different from what he prefers, interpreting digit sequences in them as ASCII cod...
[{"input": "2\nfile10\nfi2el0\nfile3", "output": "-\n-\n"}, {"input": "2\nfjle10\nfi2el0\niele3", "output": "-\n+\n"}, {"input": "2\n01eljf\nfi2el0\niele3", "output": "+\n+\n"}, {"input": "2\nflje10\nif3el0\n2elei", "output": "+\n-\n"}, {"input": "2\nfile10\nfi2el0\neile3", "output": "-\n-\n"}, {"input": "2\nfjle10\nfi...
code_stdio
[ { "content": "This is a harder version of the problem with bigger constraints.\n\nKorney Korneevich dag up an array a of length n. Korney Korneevich has recently read about the operation [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR), so he wished to experiment with it. For this purpose, he ...
[{"input": "100\n4845 2410 1317 394 2977 1455 2708 1271 2918 1866 4125 534 4055 1726 1819 790 2526 836 4853 4057 1995 3178 2972 3487 3259 4324 3807 895 2308 1513 3213 3480 1131 2807 1343 3231 1277 2683 1559 825 3667 102 1491 2066 4607 1645 3421 1475 3073 2945 3933 1157 378 3238 4123 2901 2840 483 4274 3463 3676 4011 31...
code_stdio
[ { "content": "You are given an array $a$ consisting of $n$ ($n \\ge 3$) positive integers. It is known that in this array, all the numbers except one are the same (for example, in the array $[4, 11, 4, 4]$ all numbers except one are equal to $4$).\n\nPrint the index of the element that does not equal others. Th...
[{"input": "4\n4\n11 13 11 11\n5\n1 4 4 4 4\n10\n3 3 3 3 10 3 3 3 3 3\n3\n20 20 10\n", "output": "\n2\n1\n5\n3\n"}, {"input": "4\n4\n11 13 11 11\n5\n1 4 4 4 4\n10\n3 3 3 3 10 3 3 3 3 3\n3\n20 20 10\n", "output": "2\n1\n5\n3\n"}, {"input": "4\n4\n11 20 11 11\n5\n1 4 4 4 4\n10\n3 3 3 3 10 3 3 3 3 3\n3\n20 20 10\n", "outp...
code_stdio
[ { "content": "Fennec is fighting with N monsters.\nThe health of the i-th monster is H_i.\nFennec can do the following two actions:\n - Attack: Fennec chooses one monster. That monster's health will decrease by 1.\n - Special Move: Fennec chooses one monster. That monster's health will become 0.\nThere is no wa...
[{"input": "3 0\n1000000000 1000000000 1000000000\n", "output": "3000000000\n"}, {"input": "3 0\n1000000000 1000000000 1010000000", "output": "3010000000\n"}, {"input": "3 0\n1000000000 1000000000 1110000000", "output": "3110000000\n"}, {"input": "3 0\n1100000000 1000000000 1110000000", "output": "3210000000\n"}, {"inp...
code_stdio
[ { "content": "One day, Twilight Sparkle is interested in how to sort a sequence of integers a_1, a_2, ..., a_{n} in non-decreasing order. Being a young unicorn, the only operation she can perform is a unit shift. That is, she can move the last element of the sequence to its beginning:a_1, a_2, ..., a_{n} → a_{n...
[{"input": "9\n4 5 6 7 1 2 3 4 10\n", "output": "-1\n"}, {"input": "9\n4 5 6 7 1 2 3 4 10\n", "output": "-1\n"}, {"input": "9\n4 5 6 7 1 0 3 4 10\n", "output": "-1\n"}, {"input": "9\n4 5 6 7 1 0 3 4 2\n", "output": "-1\n"}, {"input": "9\n4 5 0 7 1 0 3 4 2\n", "output": "-1\n"}, {"input": "9\n4 5 0 7 1 0 0 4 2\n", "outp...
code_stdio
[ { "content": "Vasya is sitting on an extremely boring math class. To have fun, he took a piece of paper and wrote out n numbers on a single line. After that, Vasya began to write out different ways to put pluses (\"+\") in the line between certain digits in the line so that the result was a correct arithmetic e...
[{"input": "200 100\n56988719755815575893282254081467698462485803782142631369385180999746639622554559884281193367342283559238834106917388166048020056852911293394377949964185368886333934084399980368238188117302968424219707\n", "output": "295455656\n"}, {"input": "200 99\n9999999999999999999999999999999999999999999999999...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian. \nChef has N simple polygons (non self intersecting polygons) in which no two of them intersect with each other. For any two polygons P_{1}, P_{2}, either P_{1} lies inside P_{2} or vice versa. \nChef wants you to count number of polygons ...
[{"input": "1\n3\n6\n-2 2 -1 1 2 2 2 -1 1 -2 -2 -2\n3\n-1 -1 1 -1 1 1\n4\n3 3 -3 1 -3 -3 3 -3", "output": "1 0 2\n"}, {"input": "1\n3\n6\n-2 2 -1 1 2 2 2 -1 1 -2 -3 -2\n3\n-1 -1 1 -1 1 1\n4\n3 3 -3 1 -3 -3 3 -3", "output": "1 0 2\n"}, {"input": "1\n3\n6\n-2 2 -1 1 2 2 2 -1 1 -2 -3 -2\n3\n-1 -1 1 -1 1 0\n4\n3 3 -3 1 -3 ...
code_stdio
[ { "content": "The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. \n\nUCDHP stores some secret information about meteors as an n × m table with integers in its cells....
[{"input": "6 5 30\n536048 34640 572197 62457 304174\n194764 325606 270468 784237 551632\n10580 294606 63164 543647 531895\n430397 576813 678878 323394 603231\n534567 804015 403517 886087 981939\n518845 962097 609792 877955 88610\nc 1 5\nc 2 5\nc 2 5\nr 5 3\nc 5 2\nc 4 5\nr 6 5\nc 2 1\nr 3 4\nr 4 3\nc 4 5\nc 2 1\nr 1 5...
code_stdio
[ { "content": "You are a lover of bacteria. You want to raise some bacteria in a box. \n\nInitially, the box is empty. Each morning, you can put any number of bacteria into the box. And each night, every bacterium in the box will split into two bacteria. You hope to see exactly x bacteria in the box at some mome...
[{"input": "1000000000\n", "output": "13\n"}, {"input": "1000000000\n", "output": "13\n"}, {"input": "1000100000\n", "output": "13\n"}, {"input": "1034416188\n", "output": "18\n"}, {"input": "1000100100\n", "output": "13\n"}, {"input": "536870911\n", "output": "29\n"}, {"input": "343000816\n", "output": "14\n"}, {"inpu...
code_stdio
[ { "content": "<image>\n\n\nThere is a container that is bifurcated as shown in the figure. Drop 10 balls numbered from 1 to 10 through the opening A of the container and place the balls in the left cylinder B or the right cylinder C. Since plate D can rotate left and right around the fulcrum E, you can move pla...
[{"input": "2\n1 3 4 0 0 1 17 2 -1 4\n114 21 15 1 1 1 -1 89 2 13", "output": "NO\nNO\n"}, {"input": "2\n1 3 4 1 0 1 17 2 -1 4\n114 21 15 1 1 1 -1 89 2 13", "output": "NO\nNO\n"}, {"input": "2\n1 3 4 1 0 1 17 2 -1 4\n114 21 15 1 1 1 -1 89 2 20", "output": "NO\nNO\n"}, {"input": "2\n1 3 4 1 0 1 17 2 -1 6\n114 21 15 1 1 1...
code_stdio
[ { "content": "Let s be some string consisting of symbols \"0\" or \"1\". Let's call a string t a substring of string s, if there exists such number 1 ≤ l ≤ |s| - |t| + 1 that t = s_l s_{l+1} … s_{l + |t| - 1}. Let's call a substring t of string s unique, if there exist only one such l. \n\nFor example, let s = ...
[{"input": "99985 45273\n", "output": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
code_stdio
[ { "content": "\"QAQ\" is a word to denote an expression of crying. Imagine \"Q\" as eyes with tears and \"A\" as a mouth.\n\nNow Diamond has given Bort a string consisting of only uppercase English letters of length n. There is a great number of \"QAQ\" in the string (Diamond is so cute!). $8$ illustration by 猫...
[{"input": "QCQAQAGAWAQQQAQAVQAQQQQAQAQQQAQAAATQAAVAAAQQQQAAAUUQAQQNQQWQQWAQAAQQKQYAQAAQQQAAQRAQQQWBQQQQAPBAQGQA\n", "output": "13174\n"}, {"input": "QQAQQAKQFAQLQAAWAMQAZQAJQAAQQOACQQAAAYANAQAQQAQAAQQAOBQQJQAQAQAQQQAAAAABQQQAVNZAQQQQAMQQAFAAEAQAQHQT\n", "output": "10420\n"}, {"input": "AQEGQHQQKQAQQPQKAQQQAAAAQQQAQEQA...
code_stdio
[ { "content": "PolandBall is a young, clever Ball. He is interested in prime numbers. He has stated a following hypothesis: \"There exists such a positive integer n that for each positive integer m number n·m + 1 is a prime number\".\n\nUnfortunately, PolandBall is not experienced yet and doesn't know that his h...
[{"input": "1447\n", "output": "1\n"}, {"input": "1127\n", "output": "1\n"}, {"input": "1722\n", "output": "2\n"}, {"input": "1332\n", "output": "1\n"}, {"input": "1261\n", "output": "1\n"}, {"input": "1010\n", "output": "1\n"}, {"input": "1901\n", "output": "1\n"}, {"input": "1865\n", "output": "1\n"}, {"input": "1024...
code_stdio
[ { "content": "The nth triangular number is defined as the sum of the first n positive integers. The nth tetrahedral number is defined as the sum of the first n triangular numbers. It is easy to show that the nth tetrahedral number is equal to n(n+1)(n+2) ⁄ 6. For example, the 5th tetrahedral number is 1+(1+2)+(...
[{"input": "40\n14\n10\n55\n120\n199\n61\n150\n0", "output": "2 6\n2 14\n1 10\n2 21\n1 18\n4 29\n3 27\n3 14\n"}, {"input": "40\n14\n10\n55\n120\n269\n61\n150\n0", "output": "2 6\n2 14\n1 10\n2 21\n1 18\n3 31\n3 27\n3 14\n"}, {"input": "40\n14\n10\n55\n120\n269\n61\n291\n0", "output": "2 6\n2 14\n1 10\n2 21\n1 18\n3 31\...
code_stdio
[ { "content": "Vova is again playing some computer game, now an RPG. In the game Vova's character received a quest: to slay the fearsome monster called Modcrab.\n\nAfter two hours of playing the game Vova has tracked the monster and analyzed its tactics. The Modcrab has h_2 health points and an attack power of a...
[{"input": "1 1 100\n100 99\n", "output": "9901\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nH...
code_stdio
[ { "content": "$n$ fishermen have just returned from a fishing vacation. The $i$-th fisherman has caught a fish of weight $a_i$.\n\nFishermen are going to show off the fish they caught to each other. To do so, they firstly choose an order in which they show their fish (each fisherman shows his fish exactly once,...
[{"input": "10\n319645572 758298525 812547177 459359946 355467212 304450522 807957797 916787906 239781206 242840396\n", "output": "0\n"}, {"input": "10\n319645572 758298525 812547177 459359946 355467212 304450522 807957797 916787906 239781206 242840396\n", "output": "0\n"}, {"input": "10\n319645572 758298525 812547177 ...
code_stdio
[ { "content": "Your program will receive an array of complex numbers represented as strings. Your task is to write the `complexSum` function which have to return the sum as a string.\n\nComplex numbers can be written in the form of `a+bi`, such as `2-3i` where `2` is the real part, `3` is the imaginary part, an...
[{"input": "[\"-1000i\", \"1000i\", \"1234\"]", "output": "[\"1234\"]", "fn_name": "complexSum"}, {"input": "[\"1\", \"10\", \"100\", \"1000\"]", "output": "[\"1111\"]", "fn_name": "complexSum"}, {"input": "[\"10+5i\", \"1-i\", \"-i\"]", "output": "[\"11+3i\"]", "fn_name": "complexSum"}, {"input": "[\"2+i\", \"3+2i\", ...
code_functional
[ { "content": "You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.\n\nThe level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (whe...
[{"input": "53 1 27 3\n44 28 48 60 29 42 59 32 9 58 3 11 7 53 4 19 37 41 36 52 29 9 24 8 31 39 52 41 37 44 26 37 37 48 6 21 20 42 25 3 33 2 35 39 33 23 10 60 48 4 1 28 21\n1 1 11\n1 1 21\n1 1 3\n1 1 42\n1 1 16\n1 1 32\n1 1 52\n1 1 17\n1 1 39\n1 1 22\n1 1 31\n1 1 50\n1 1 23\n1 1 14\n1 1 41\n1 1 53\n1 1 60\n1 1 49\n1 1 7...
code_stdio
[ { "content": "# Task\nA masked number is a string that consists of digits and one asterisk (`*`) that should be replaced by exactly one digit. Given a masked number `s`, find all the possible options to replace the asterisk with a digit to produce an integer divisible by 6.\n\n\n# Input/Output\n\n`[input]` stri...
[{"input": "\"1234567890123456789012345678*0\"", "output": "[[\"123456789012345678901234567800\", \"123456789012345678901234567830\", \"123456789012345678901234567860\", \"123456789012345678901234567890\"]]", "fn_name": "is_divisible_by_6"}, {"input": "\"34234*2\"", "output": "[[\"3423402\", \"3423432\", \"3423462\", \...
code_functional
[ { "content": "There are $n$ dormitories in Berland State University, they are numbered with integers from $1$ to $n$. Each dormitory consists of rooms, there are $a_i$ rooms in $i$-th dormitory. The rooms in $i$-th dormitory are numbered from $1$ to $a_i$.\n\nA postman delivers letters. Sometimes there is no sp...
[{"input": "3 10\n1010000000 1000000000 1000000000\n330201655 567869543 1000000000 1000000001 1500000000 1999999999 2000000000 2000000001 2754432345 3000000000\n", "output": "1 330201655\n1 567869543\n1 1000000000\n1 1000000001\n2 490000000\n2 989999999\n2 990000000\n2 990000001\n3 744432345\n3 990000000\n"}, {"input":...
code_stdio
[ { "content": "This night wasn't easy on Vasya. His favorite team lost, and he didn't find himself victorious either — although he played perfectly, his teammates let him down every time. He had to win at least one more time, but the losestreak only grew longer and longer... It's no wonder he didn't get any slee...
[{"input": "987654320023456789\n", "output": "29340299842560\n"}, {"input": "987654321123456789\n", "output": "33007837322880\n"}, {"input": "987654321123456780\n", "output": "55657759288320\n"}, {"input": "234906817379759421\n", "output": "22773236965920\n"}, {"input": "978691308972024154\n", "output": "33638772575520...
code_stdio
[ { "content": "Kenkoooo is planning a trip in Republic of Snuke. In this country, there are n cities and m trains running. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Any city can be reached from any city by changing trains.\n\nTwo currencies are used in the...
[{"input": "8 12 5 5\n2 8 685087149 1569714306\n6 1 298270585 209942236\n2 4 346080035 234079976\n1 5 131857300 40131411\n1 8 30723332 173476334\n2 6 447829832 706415811\n1 4 181424400 548830121\n4 4 30593148 195056405\n7 8 211146752 588024753\n1 6 127300821 203530153\n3 1 336869679 115858230\n4 4 389775999 199123879",...
code_stdio
[ { "content": "Ghosts live in harmony and peace, they travel the space without any purpose other than scare whoever stands in their way.\n\nThere are $n$ ghosts in the universe, they move in the $OXY$ plane, each one of them has its own velocity that does not change in time: $\\overrightarrow{V} = V_{x}\\overrig...
[{"input": "10 7 -626288749\n795312099 49439844 266151109\n-1357052512 23740808 624973405\n-513221420 -44452680 -391096559\n-350963348 -5068756 -160670209\n690883790 11897718 3356227\n-509035268 -76541374 -210137445\n-121282138 -32581578 230716703\n491731655 9500548 -13423963\n-665038289 48170248 446577586\n495114076 -...
code_stdio
[ { "content": "In the drawing below we have a part of the Pascal's triangle, lines are numbered from **zero** (top).\nThe left diagonal in pale blue with only numbers equal to 1 is diagonal **zero**, then in dark green \n(1, 2, 3, 4, 5, 6, 7) is diagonal 1, then in pale green (1, 3, 6, 10, 15, 21) is\ndiagonal 2...
[{"input": "1291\n1234", "output": "[15478983586799578981605681450735426444083026237083755223526535252775423299626083333014485638841019200]", "fn_name": "diagonal"}, {"input": "1291\n56", "output": "[15478983586799578981605681450735426444083026237083755223526535252775423299626083333014485638841019200]", "fn_name": "dia...
code_functional
[ { "content": "\"Balloons should be captured efficiently\", the game designer says. He is designing an oldfashioned game with two dimensional graphics. In the game, balloons fall onto the ground one after another, and the player manipulates a robot vehicle on the ground to capture the balloons. The player can co...
[{"input": "2\n10 100\n100 270\n2\n12 100\n100 280\n3\n100 150\n10 360\n40 450\n3\n100 150\n17 360\n40 440\n2\n100 10\n50 200\n2\n100 100\n50 110\n1\n15 10\n4\n1 10\n2 20\n3 100\n90 200\n0", "output": "OK 220\nOK 200\nOK 260\nOK 246\nNG 1\nNG 2\nNG 1\nOK 188\n"}, {"input": "2\n10 100\n100 270\n2\n12 100\n100 280\n3\n10...
code_stdio
[ { "content": "You have given tree consist of n vertices. Select a vertex as root vertex that satisfies the condition below.\n\n * For all vertices v_{1} and v_{2}, if distance(root, v_{1}) = distance(root, v_{2}) then degree(v_{1}) = degree(v_{2}), where degree means the number of vertices connected to that ve...
[{"input": "14\n10 12\n8 14\n6 8\n4 10\n2 4\n1 2\n2 3\n3 5\n5 13\n7 9\n9 11\n10 14\n9 13\n", "output": "-1\n"}, {"input": "14\n10 12\n8 14\n6 8\n4 6\n2 4\n1 2\n2 3\n3 5\n5 13\n7 9\n9 11\n10 14\n9 13\n", "output": "-1\n"}, {"input": "14\n10 12\n8 10\n6 8\n7 6\n3 4\n1 2\n1 3\n3 5\n5 11\n7 9\n7 11\n10 14\n9 13\n", "output...
code_stdio
[ { "content": "Alica and Bob are playing a game.\n\nInitially they have a binary string $s$ consisting of only characters 0 and 1.\n\nAlice and Bob make alternating moves: Alice makes the first move, Bob makes the second move, Alice makes the third one, and so on. During each move, the current player must choose...
[{"input": "1\n111111111111111110000000000000000\n", "output": "NET\n"}, {"input": "1\n111111111111111110000000000000000\n", "output": "NET\n"}, {"input": "1\n111111111111101110000000000000000\n", "output": "NET\n"}, {"input": "1\n111111111111101100100000000000000\n", "output": "NET\n"}, {"input": "1\n11111111111100100...
code_stdio
[ { "content": "problem\n\nTo the west of the Australian continent is the wide Indian Ocean. Marine researcher JOI is studying the properties of N species of fish in the Indian Ocean.\n\nFor each type of fish, a rectangular parallelepiped habitat range is determined in the sea. Fish can move anywhere in their hab...
[{"input": "3 2\n26 58 0 50 135 000\n10 24 20 127 126 60\n40 60 20 90 90 131", "output": "60000\n"}, {"input": "1 1\n20 50 -2 50 70 000\n10 102 11 39 90 40\n75 100 36 102 159 8", "output": "1200\n"}, {"input": "1 1\n20 50 -3 50 70 000\n10 102 11 39 90 40\n72 100 36 167 159 8", "output": "1800\n"}, {"input": "3 1\n20 50...
code_stdio
[ { "content": "There are N candles placed on a number line.\nThe i-th candle from the left is placed on coordinate x_i.\nHere, x_1 < x_2 < ... < x_N holds.\nInitially, no candles are burning.\nSnuke decides to light K of the N candles.\nNow, he is at coordinate 0.\nHe can move left and right along the line with ...
[{"input": "8 5\n-9 -7 -4 -3 1 2 3 4\n", "output": "10\n"}, {"input": "8 4\n-14 -7 -4 -11 1 2 3 4", "output": "4\n"}, {"input": "8 4\n-14 -7 -4 -11 1 2 3 8", "output": "8\n"}, {"input": "8 5\n-14 -7 -1 -11 1 2 3 4", "output": "5\n"}, {"input": "8 4\n-14 -7 -1 -11 1 1 3 8", "output": "3\n"}, {"input": "8 4\n-14 -7 -6 -1...
code_stdio
[ { "content": "Toad Ivan has $m$ pairs of integers, each integer is between $1$ and $n$, inclusive. The pairs are $(a_1, b_1), (a_2, b_2), \\ldots, (a_m, b_m)$. \n\nHe asks you to check if there exist two integers $x$ and $y$ ($1 \\leq x < y \\leq n$) such that in each given pair at least one integer is equal to...
[{"input": "10 10\n1 3\n1 3\n1 3\n1 3\n1 3\n2 3\n1 5\n2 6\n2 7\n2 9\n", "output": "YES\n"}, {"input": "10 10\n1 3\n1 3\n1 3\n1 3\n1 3\n2 3\n1 5\n2 7\n2 7\n2 9\n", "output": "YES\n"}, {"input": "10 10\n1 3\n1 3\n1 3\n1 3\n1 3\n2 3\n1 5\n2 3\n2 7\n2 9\n", "output": "YES\n"}, {"input": "10 10\n1 3\n1 3\n1 3\n1 4\n1 3\n2 3...
code_stdio
[ { "content": "You are given $n$ strings. Each string consists of lowercase English letters. Rearrange (reorder) the given strings in such a way that for every string, all strings that are placed before it are its substrings.\n\nString $a$ is a substring of string $b$ if it is possible to choose several consecut...
[{"input": "5\na\naba\nabacaba\nba\naba\n", "output": "YES\na\nba\naba\naba\nabacaba\n"}, {"input": "3\nqwerty\nqwerty\nqwerty\n", "output": "YES\nqwerty\nqwerty\nqwerty\n"}, {"input": "3\nqwerty\nqwerty\nqwerty\n", "output": "YES\nqwerty\nqwerty\nqwerty\n"}, {"input": "5\na\naba\nabacaba\nba\naba\n", "output": "YES\na...
code_stdio
[ { "content": "It is Professor R's last class of his teaching career. Every time Professor R taught a class, he gave a special problem for the students to solve. You being his favourite student, put your heart into solving it one last time.\n\nYou are given two polynomials $f(x) = a_0 + a_1x + \\dots + a_{n-1}x^...
[{"input": "70 11 17929\n10313 427 268935 211 197219 148 357 179290 97 358580 475 343 175 221 286864 429 304793 179290 189 363 221 340651 376509 453 251006 141 304793 358580 235 107574 141 358580 167 181 101469 335 286864 171 107574 105 449 358580 286864 161 286864 349 89645 197219 395 358580 233077 376509 185 199 3944...
code_stdio
[ { "content": "Mishka wants to buy some food in the nearby shop. Initially, he has $s$ burles on his card. \n\nMishka can perform the following operation any number of times (possibly, zero): choose some positive integer number $1 \\le x \\le s$, buy food that costs exactly $x$ burles and obtain $\\lfloor\\frac{...
[{"input": "6\n1\n10\n19\n9876\n12345\n1000000000\n", "output": "1\n11\n21\n10973\n13716\n1111111111\n"}, {"input": "6\n1\n10\n33\n9876\n12345\n1000000000\n", "output": "1\n11\n36\n10973\n13716\n1111111111\n"}, {"input": "6\n1\n10\n24\n9876\n12345\n1000000000\n", "output": "1\n11\n26\n10973\n13716\n1111111111\n"}, {"in...
code_stdio
[ { "content": "You are given an array $A$, consisting of $n$ positive integers $a_1, a_2, \\dots, a_n$, and an array $B$, consisting of $m$ positive integers $b_1, b_2, \\dots, b_m$. \n\nChoose some element $a$ of $A$ and some element $b$ of $B$ such that $a+b$ doesn't belong to $A$ and doesn't belong to $B$. \n...
[{"input": "52\n197 90 23 11 63 198 24 132 68 58 195 100 101 120 96 77 132 155 62 197 170 117 189 160 194 106 172 124 180 75 124 51 51 93 186 93 79 111 161 67 84 183 150 125 25 46 106 29 170 175 4 122\n18\n95 28 20 190 75 89 193 152 53 79 100 3 154 42 67 5 137 60\n", "output": "198 193\n"}, {"input": "52\n197 90 23 11 ...
code_stdio
[ { "content": "The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups.\n\nMeanwhile, crimes keeps occurring within the city. One member of the police force can investigate only one crime during his/her lifetime.\n\n...
[{"input": "146\n4 -1 -1 -1 -1 -1 -1 -1 -1 -1 4 -1 3 -1 3 -1 -1 1 4 -1 2 -1 -1 3 -1 -1 -1 4 1 -1 -1 -1 4 -1 -1 -1 -1 -1 -1 3 2 -1 3 2 4 5 2 4 1 5 -1 -1 2 -1 -1 1 -1 5 3 -1 1 2 2 3 5 3 -1 -1 3 -1 -1 3 5 5 -1 -1 5 -1 4 4 1 -1 -1 -1 2 1 -1 -1 -1 2 5 3 -1 -1 -1 3 -1 5 4 -1 1 -1 -1 3 -1 -1 3 1 1 2 -1 -1 -1 1 3 1 -1 2 -1 -1 ...
code_stdio
[ { "content": "Vasya has a pile, that consists of some number of stones. $n$ times he either took one stone from the pile or added one stone to the pile. The pile was non-empty before each operation of taking one stone from the pile.\n\nYou are given $n$ operations which Vasya has made. Find the minimal possible...
[{"input": "100\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n", "output": "100\n"}, {"input": "100\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n", "output": "100"}, {"input": "100\n---+-----------+-++---+...
code_stdio
[ { "content": "It is known that each weight of 1 gram, 3 gram, 9 gram, and 27 gram can be weighed from 1 gram to 40 gram in 1 gram increments using a balance. For example, if you put a weight of 3 grams and a weight you want to weigh on one plate of the balance and a weight of 27 grams and 1 gram on the other pl...
[{"input": "1204", "output": "+--00--+\n"}, {"input": "1942", "output": "+0-000-+\n"}, {"input": "384", "output": "+---+-0\n"}, {"input": "567", "output": "+-+0000\n"}, {"input": "397", "output": "+--0-0+\n"}, {"input": "373", "output": "+----++\n"}, {"input": "520", "output": "+-0++-+\n"}, {"input": "438", "output": "...
code_stdio
[ { "content": "Note that this is the first problem of the two similar problems. You can hack this problem only if you solve both problems.\n\nYou are given a tree with n nodes. In the beginning, 0 is written on all edges. In one operation, you can choose any 2 distinct leaves u, v and any real number x and add x...
[{"input": "60\n26 6\n59 30\n31 12\n31 3\n38 23\n59 29\n53 9\n38 56\n53 54\n29 21\n17 55\n59 38\n26 16\n24 59\n24 25\n17 35\n24 41\n30 15\n31 27\n8 44\n26 5\n26 48\n8 32\n53 17\n3 34\n3 51\n30 28\n47 10\n53 60\n36 42\n24 53\n59 22\n53 40\n26 52\n36 4\n59 8\n29 37\n36 20\n17 47\n53 18\n3 50\n30 2\n17 7\n8 58\n59 1\n31 1...
code_stdio
[ { "content": "The number ```89``` is the first integer with more than one digit that fulfills the property partially introduced in the title of this kata. \nWhat's the use of saying \"Eureka\"? Because this sum gives the same number.\n\nIn effect: ```89 = 8^1 + 9^2``` \n\nThe next number in having this property...
[{"input": "1\n100", "output": "[[1, 2, 3, 4, 5, 6, 7, 8, 9, 89]]", "fn_name": "sum_dig_pow"}, {"input": "50\n150", "output": "[[89, 135]]", "fn_name": "sum_dig_pow"}, {"input": "10\n150", "output": "[[89, 135]]", "fn_name": "sum_dig_pow"}, {"input": "89\n135", "output": "[[89, 135]]", "fn_name": "sum_dig_pow"}, {"inpu...
code_functional
[ { "content": "Mishka started participating in a programming contest. There are $n$ problems in the contest. Mishka's problem-solving skill is equal to $k$.\n\nMishka arranges all problems from the contest into a list. Because of his weird principles, Mishka only solves problems from one of the ends of the list....
[{"input": "100 90\n90 90 90 90 90 90 55 21 90 90 90 90 90 90 90 90 90 90 69 83 90 90 90 90 90 90 90 90 93 95 92 98 92 97 91 92 92 91 91 95 94 95 100 100 96 97 94 93 90 90 95 95 97 99 90 95 98 91 94 96 99 99 94 95 95 97 99 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 12 90 3 90 90 90 90 90 90 90...
code_stdio
[ { "content": "You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings \"AB\" and \"BA\" (the substrings can go in any order).\n\n\n-----Input-----\n\nThe only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin lett...
[{"input": "AABBBACBBBBBBAACBCCACBBAABBBBBCAACABAACABCACCBCBCCCBCBCABCBBCCBCBBAACBACAABACBBCACCBCCACCABBCBABBAAC\n", "output": "YES\n"}, {"input": "AABBBACBBBBBBAACBCCACBBAABBBBBCAACABAACABCACCBCBCCCBCBCABCBBCCBCBBAACBACAABACBBCACCBCCACCABBCBABBAAC\n", "output": "YES\n"}, {"input": "CAABBABCBBACCACCBCCACBBCABAACABCAABB...
code_stdio
[ { "content": "The King of Flatland will organize a knights' tournament! The winner will get half the kingdom and the favor of the princess of legendary beauty and wisdom. The final test of the applicants' courage and strength will be a fencing tournament. The tournament is held by the following rules: the parti...
[{"input": "847094637 -152905363 -1000000000 -1000000000\n", "output": "FIRST\n-152905363\n"}, {"input": "-1000000000 1000000000 1230987 17135570\n", "output": "FIRST\n-983588156\n"}, {"input": "547686188 61562151 -496372503 -115242932\n", "output": "FIRST\n61562151\n"}, {"input": "-1000000000 1000000000 1230987 987123...
code_stdio
[ { "content": "You are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise OR. \n\nFind the maximum possible value of [Image] after performing at most k...
[{"input": "5 10 8\n1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "1073741825000000000\n"}, {"input": "5 10 8\n1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "1073741825000000000\n"}, {"input": "5 10 8\n1000000000 1010000000 1000000000 1000000000 1000000000\n", "output": "10...
code_stdio
[ { "content": "Space Coconut Crab\n\nSpace coconut crab\n\nEnglish text is not available in this practice contest.\n\nKen Marine Blue is a space hunter who travels through the entire galaxy in search of space coconut crabs. The space coconut crab is the largest crustacean in the universe, and it is said that the...
[{"input": "1\n2\n4\n48\n266\n1236\n0", "output": "1\n2\n2\n12\n14\n36\n"}, {"input": "1\n2\n4\n48\n266\n1300\n0", "output": "1\n2\n2\n12\n14\n38\n"}, {"input": "1\n2\n4\n27\n557\n1250\n0", "output": "1\n2\n2\n3\n23\n44\n"}, {"input": "1\n2\n4\n27\n266\n1250\n0", "output": "1\n2\n2\n3\n14\n44\n"}, {"input": "1\n2\n4\n2...
code_stdio
[ { "content": "You are given a tree (connected graph without cycles) consisting of $n$ vertices. The tree is unrooted — it is just a connected undirected graph without cycles.\n\nIn one move, you can choose exactly $k$ leaves (leaf is such a vertex that is connected to only one another vertex) connected to the s...
[{"input": "4\n8 10\n1 2\n1 5\n7 6\n6 8\n3 1\n8 4\n7 1\n10 1\n1 2\n1 10\n2 3\n1 5\n1 6\n2 4\n7 10\n10 9\n8 10\n7 2\n3 1\n1 5\n4 6\n7 4\n1 2\n1 4\n5 1\n1 4\n2 1\n4 3\n5 3\n", "output": "0\n9\n3\n4\n"}, {"input": "4\n8 10\n1 2\n1 5\n7 6\n6 8\n3 1\n8 4\n4 1\n10 3\n1 2\n1 10\n2 3\n1 5\n1 6\n2 4\n7 10\n10 9\n8 10\n7 2\n3 1\...
code_stdio
[ { "content": "Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.\n\nGiven a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence ...
[{"input": "100\n4 8 10 1 8 8 8 1 10 3 1 8 6 8 6 1 10 3 3 3 3 7 2 1 1 6 10 1 7 9 8 10 3 8 6 2 1 6 5 6 10 8 9 7 4 3 10 5 3 9 10 5 10 8 8 5 7 8 9 5 3 18 9 2 7 8 2 10 4 9 2 8 10 10 5 8 5 1 7 3 4 5 2 2 9 3 2 5 6 2 3 10 1 5 9 6 10 4 10 8\n", "output": "392\n"}, {"input": "100\n4 8 10 1 8 8 8 1 10 3 1 8 6 8 6 1 10 3 3 3 3 7 ...
code_stdio
[ { "content": "Many computer strategy games require building cities, recruiting army, conquering tribes, collecting resources. Sometimes it leads to interesting problems. \n\nLet's suppose that your task is to build a square city. The world map uses the Cartesian coordinates. The sides of the city should be para...
[{"input": "10\n-260530833 169589238\n-681955770 -35391010\n223450511 24504262\n479795061 -26191863\n-291344265 21153856\n714700263 -328447419\n-858655942 161086142\n-270884153 462537328\n-501424901 977460517\n115284904 -151626824\n", "output": "2475449747812002025\n"}, {"input": "10\n-260530833 169589238\n-681955770 -...
code_stdio
[ { "content": "You have an array $a$ of length $n$. For every positive integer $x$ you are going to perform the following operation during the $x$-th second:\n\n Select some distinct indices $i_{1}, i_{2}, \\ldots, i_{k}$ which are between $1$ and $n$ inclusive, and add $2^{x-1}$ to each corresponding position ...
[{"input": "6\n3\n1000000000 -1 -1000000000\n1\n6\n2\n-1000000000 1000000000\n2\n1000000000 -1000000000\n2\n1000000000 1000000000\n2\n-1000000000 -1000000000\n", "output": "31\n0\n0\n31\n0\n0\n"}, {"input": "6\n3\n1000000000 0 -1000000000\n1\n6\n2\n-1000000000 1000000000\n2\n1000000000 -1000000000\n2\n1000000000 100000...
code_stdio
[ { "content": "```if-not:ruby\nCreate a function, that accepts an arbitrary number of arrays and returns a single array generated by alternately appending elements from the passed in arguments. If one of them is shorter than the others, the result should be padded with empty elements.\n```\n```if:ruby\nCreate a ...
[{"input": "[null]\n[null, null]\n[null, null, null]", "output": "[[null, null, null, null, null, null, null, null, null]]", "fn_name": "interleave"}, {"input": "[1, 2, 3]\n[4, 5, 6]\n[7, 8, 9]", "output": "[[1, 4, 7, 2, 5, 8, 3, 6, 9]]", "fn_name": "interleave"}, {"input": "[1, 2, 3]\n[\"c\", \"d\", \"e\"]", "output":...
code_functional
[ { "content": "The Little Elephant enjoys recursive functions.\n\nThis time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's element...
[{"input": "1001\n", "output": "1001 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 9...
code_stdio
[ { "content": "A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.\n\nPolycarpus h...
[{"input": "100 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...
code_stdio
[ { "content": "Find the number of palindromic numbers among the integers between A and B (inclusive).\nHere, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.\n\n-----Constraints-----\n - 10000 \\leq A \\leq B \\leq 9999...
[{"input": "31415 92653\n", "output": "612\n"}, {"input": "31415 97709", "output": "662\n"}, {"input": "53417 77120", "output": "237\n"}, {"input": "44323 77120", "output": "328\n"}, {"input": "44323 83416", "output": "391\n"}, {"input": "15858 40262", "output": "244\n"}, {"input": "31406 46102", "output": "147\n"}, {"...
code_stdio
[ { "content": "While Mike was walking in the subway, all the stuff in his back-bag dropped on the ground. There were several fax messages among them. He concatenated these strings in some order and now he has string s.\n\n [Image] \n\nHe is not sure if this is his own back-bag or someone else's. He remembered th...
[{"input": "uqurdorwgtukbijpzhrpqoazllayzteqmeqhbgwvrgsiegiaaujtnxlzmihqyefraxpgywiauawpexgpazhqblryvremznotyklfiernvusugwlupadltrsbfvezbdbbyeetmwlkblwnidxchmwtzmrwdvlddwzbeswwpkizbqaghtrvalqickozbwfsqbcfjlbgttptlsqitjufjhsnjndvihtcdgsgntlqnzzeqcrmuxmrixmzreysejvrudqurnorhrlseammogstjseshstzxxtfwoajerafngpaalvkpxfimldy...
code_stdio
[ { "content": "Vasya likes everything infinite. Now he is studying the properties of a sequence s, such that its first element is equal to a (s_1 = a), and the difference between any two neighbouring elements is equal to c (s_{i} - s_{i} - 1 = c). In particular, Vasya wonders if his favourite integer b appears i...
[{"input": "-1000000000 1000000000 1000000000\n", "output": "YES\n"}, {"input": "-1000000000 1000000000 1000000000\n", "output": "YES\n"}, {"input": "-1000000000 1001000000 1000000000\n", "output": "NO\n"}, {"input": "119057893 -516914539 -39748277\n", "output": "YES\n"}, {"input": "479823846 -403424770 -653472589\n", ...
code_stdio
[ { "content": "Dr .: Peter. I did.\n\nPeter: See you again? What kind of silly invention is this time?\n\nDr .: You invented the detector for that phantom elementary particle axion.\n\nPeter: Speaking of Axion, researchers such as the European Organization for Nuclear Research (CERN) are chasing with a bloody ey...
[{"input": "1\n0 1 0 0 0 0 0 0 0 0\n1 1 1 0 0 0 0 0 0 0\n0 1 0 0 0 0 0 0 0 0\n0 0 0 0 0 1 0 0 0 0\n0 0 0 1 0 0 1 0 0 0\n0 0 0 0 1 1 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 1 0\n0 0 0 0 0 0 0 1 1 1\n0 0 0 0 0 0 0 0 1 0", "output": "0 0 0 0 1 0 1 0 0 0\n0 1 0 1 1 0 1 1 0 0\n0 0 1 0 1 0 1 0 1 0\n0 1 1 1 0 0 0 1 1 1\...
code_stdio
[ { "content": "Given is a positive integer N.\n\nFind the number of pairs (A, B) of positive integers not greater than N that satisfy the following condition:\n - When A and B are written in base ten without leading zeros, the last digit of A is equal to the first digit of B, and the first digit of A is equal to...
[{"input": "200000\n", "output": "400000008\n"}, {"input": "199972\n", "output": "399904458\n"}, {"input": "199912\n", "output": "399664518\n"}, {"input": "199903\n", "output": "399626757\n"}, {"input": "199927\n", "output": "399715613\n"}, {"input": "199916\n", "output": "399673406\n"}, {"input": "141750", "output": "...
code_stdio
[ { "content": "You are given two strings $a$ and $b$ consisting of lowercase English letters, both of length $n$. The characters of both strings have indices from $1$ to $n$, inclusive. \n\nYou are allowed to do the following changes: Choose any index $i$ ($1 \\le i \\le n$) and swap characters $a_i$ and $b_i$...
[{"input": "7\nabacaba\nbacabaa\n", "output": "4\n"}, {"input": "7\nabacaba\naabacab\n", "output": "4\n"}, {"input": "7\nabacaaa\naabacab\n", "output": "5\n"}, {"input": "7\nabacaaa\naabacaa\n", "output": "4\n"}, {"input": "7\naaacaaa\naabacaa\n", "output": "3\n"}, {"input": "7\naaacaaa\naaaacaa\n", "output": "2\n"}, {...
code_stdio
[ { "content": "You are given a tree that consists of $n$ nodes. You should label each of its $n-1$ edges with an integer in such way that satisfies the following conditions: each integer must be greater than $0$; the product of all $n-1$ numbers should be equal to $k$; the number of $1$-s among all $n-1$ int...
[{"input": "4\n3\n3 1\n2 1\n4\n22861 20707 59627 9293\n3\n3 1\n1 2\n6\n15767 40973 20807 24419 46439 62816\n3\n3 2\n1 2\n6\n31575 54493 10799 37529 59743 30529\n3\n3 1\n2 1\n1\n51618\n", "output": "783349080\n372565328\n603348715\n103238\n"}, {"input": "4\n3\n3 1\n2 1\n4\n22861 20707 59627 9293\n3\n3 1\n1 2\n6\n15767 4...
code_stdio
[ { "content": "Yelisey has an array $a$ of $n$ integers.\n\nIf $a$ has length strictly greater than $1$, then Yelisei can apply an operation called minimum extraction to it:\n\nFirst, Yelisei finds the minimal number $m$ in the array. If there are several identical minima, Yelisey can choose any of them.\n\nThen...
[{"input": "8\n1\n10\n2\n0 0\n3\n-1 2 -1\n4\n2 18 1 -1\n2\n3 6\n5\n3 2 -4 -2 0\n2\n-1 -1\n1\n-2\n", "output": "10\n0\n3\n16\n3\n2\n0\n-2\n"}, {"input": "8\n1\n10\n2\n1 0\n3\n-1 2 -1\n4\n2 18 1 -1\n2\n3 6\n5\n3 2 -4 -2 0\n2\n-1 -1\n1\n-2\n", "output": "10\n1\n3\n16\n3\n2\n0\n-2\n"}, {"input": "8\n1\n10\n2\n1 0\n3\n-1 2 ...
code_stdio
[ { "content": "The only difference between easy and hard versions is constraints.\n\nThe BerTV channel every day broadcasts one episode of one of the $k$ TV shows. You know the schedule for the next $n$ days: a sequence of integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le k$), where $a_i$ is the show, the episo...
[{"input": "30\n4 4 1\n3 3 1 2\n4 4 1\n4 1 4 1\n1 1 1\n1\n3 2 1\n2 1 2\n4 4 2\n3 2 2 2\n4 2 4\n1 2 2 2\n1 4 1\n4\n2 3 1\n2 3\n2 2 1\n2 2\n4 4 2\n1 2 4 2\n4 4 1\n2 4 4 3\n4 3 1\n1 3 1 3\n1 1 1\n1\n2 2 2\n2 1\n2 4 1\n1 4\n2 4 1\n3 4\n1 2 1\n1\n2 4 2\n2 1\n3 1 2\n1 1 1\n2 4 1\n1 4\n2 3 1\n3 3\n4 2 2\n2 1 2 2\n3 2 2\n2 2 1...
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\n# Keyboard\n\nThe screen \"keyboard\" layout looks like this\n\n\n #tvkb {\n width : 400px;\n border: 5px solid gray; border-co...
[{"input": "\"The Quick Brown Fox Jumps Over A Lazy Dog.\"", "output": "[306]", "fn_name": "tv_remote"}, {"input": "\"Pack My Box With Five Dozen Liquor Jugs.\"", "output": "[290]", "fn_name": "tv_remote"}, {"input": "\" x X \"", "output": "[34]", "fn_name": "tv_remote"}, {"input": "\"MISSISSIPPI\"", "output": ...
code_functional
[ { "content": "Write a function named sumDigits which takes a number as input and returns the sum of the absolute value of each of the number's decimal digits. For example:\n\n```python\n sum_digits(10) # Returns 1\n sum_digits(99) # Returns 18\n sum_digits(-32) # Returns 5\n```\n\nLet's assume that all nu...
[{"input": "1234567890", "output": "[45]", "fn_name": "sum_digits"}, {"input": "800000009", "output": "[17]", "fn_name": "sum_digits"}, {"input": "100000002", "output": "[3]", "fn_name": "sum_digits"}, {"input": "666", "output": "[18]", "fn_name": "sum_digits"}, {"input": "99", "output": "[18]", "fn_name": "sum_digits"...
code_functional
[ { "content": "Create a function that accepts 3 inputs, a string, a starting location, and a length. The function needs to simulate the string endlessly repeating in both directions and return a substring beginning at the starting location and continues for length.\n\nExample:\n```python\nendless_string('xyz', ...
[{"input": "\"1x2x3x4x\"\n-1532\n-100", "output": "[\"x2x3x4x1x2x3x4x1x2x3x4x1x2x3x4x1x2x3x4x1x2x3x4x1x2x3x4x1x2x3x4x1x2x3x4x1x2x3x4x1x2x3x4x1x2x3x4x1x2x3\"]", "fn_name": "endless_string"}, {"input": "\"1x2x3x4x\"\n1532\n100", "output": "[\"3x4x1x2x3x4x1x2x3x4x1x2x3x4x1x2x3x4x1x2x3x4x1x2x3x4x1x2x3x4x1x2x3x4x1x2x3x4x1x2...
code_functional
[ { "content": "You're continuing to enjoy your new piano, as described in Piano Kata, Part 1. You're also continuing the exercise where you start on the very first (leftmost, lowest in pitch) key on the 88-key keyboard, which (as shown below) is the note A, with the little finger on your left hand, then the seco...
[{"input": "100", "output": "[\"G#\"]", "fn_name": "which_note"}, {"input": "200", "output": "[\"G#\"]", "fn_name": "which_note"}, {"input": "2017", "output": "[\"F\"]", "fn_name": "which_note"}, {"input": "12", "output": "[\"G#\"]", "fn_name": "which_note"}, {"input": "111", "output": "[\"G\"]", "fn_name": "which_note...
code_functional
[ { "content": "Maxim loves to fill in a matrix in a special manner. Here is a pseudocode of filling in a matrix of size (m + 1) × (m + 1):\n\n[Image]\n\nMaxim asks you to count, how many numbers m (1 ≤ m ≤ n) are there, such that the sum of values in the cells in the row number m + 1 of the resulting matrix equa...
[{"input": "1000000000000 1048576\n", "output": "118606527258\n"}, {"input": "1000000000000 1048576\n", "output": "118606527258\n"}, {"input": "1000000000000 1048576\n", "output": "118606527258\n"}, {"input": "987654321987 1048576\n", "output": "116961880791\n"}, {"input": "987654321987 1048576\n", "output": "116961880...
code_stdio
[ { "content": "Dreamoon has a string s and a pattern string p. He first removes exactly x characters from s obtaining string s' as a result. Then he calculates <image> that is defined as the maximal number of non-overlapping substrings equal to p that can be found in s'. He wants to make this number as big as po...
[{"input": "a\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...
code_stdio
[ { "content": "A magic number is a number formed by concatenation of numbers 1, 14 and 144. We can use each of these numbers any number of times. Therefore 14144, 141414 and 1411 are magic numbers but 1444, 514 and 414 are not.\n\nYou're given a number. Determine if it is a magic number or not.\n\n\n-----Input--...
[{"input": "1000000000\n", "output": "NO\n"}, {"input": "144144144\n", "output": "YES\n"}, {"input": "141414141\n", "output": "YES\n"}, {"input": "114114144\n", "output": "YES\n"}, {"input": "111111111\n", "output": "YES\n"}, {"input": "141441441\n", "output": "YES\n"}, {"input": "141414144\n", "output": "YES\n"}, {"in...
code_stdio
[ { "content": "Jack and Jill are playing a game. They have balls numbered from `0` to `n - 1`. Jack looks the other way and asks Jill to reverse the position of the balls, for instance, to change the order from say, `0,1,2,3` to `3,2,1,0`. He further asks Jill to reverse the position of the balls `n` times, each...
[{"input": "20\n10", "output": "[18]", "fn_name": "solve"}, {"input": "20\n8", "output": "[17]", "fn_name": "solve"}, {"input": "20\n9", "output": "[19]", "fn_name": "solve"}, {"input": "4\n1", "output": "[3]", "fn_name": "solve"}, {"input": "4\n2", "output": "[2]", "fn_name": "solve"}, {"input": "4\n3", "output": "[0]...
code_functional
[ { "content": "We have a large square grid with H rows and W columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the bottom-right cell.\n\nHowever, she cannot enter the cells in the intersection of the bottom A rows and the leftmost B c...
[{"input": "100000 100000 99999 72298", "output": "471980925\n"}, {"input": "100000 100000 43938 55555", "output": "265769345\n"}, {"input": "100000 100000 99999 39553", "output": "199584029\n"}, {"input": "100000 100000 43938 63714", "output": "333427460\n"}, {"input": "100000 100000 99999 39975", "output": "868453532...
code_stdio
[ { "content": "Vanya smashes potato in a vertical food processor. At each moment of time the height of the potato in the processor doesn't exceed h and the processor smashes k centimeters of potato each second. If there are less than k centimeters remaining, than during this second processor smashes all the rema...
[{"input": "25 1000000000 1\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "2...
code_stdio
[ { "content": "Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate.\n\nThe path consists of n consecutive tiles, numbered from 1 to n. Ujan will paint each tile in some color. He will consider the path aesthetic if for any...
[{"input": "930881829259\n", "output": "930881829259\n"}, {"input": "974059904437\n", "output": "974059904437\n"}, {"input": "963201794869\n", "output": "963201794869\n"}, {"input": "912943012301\n", "output": "912943012301\n"}, {"input": "490918125179\n", "output": "490918125179\n"}, {"input": "902076349729\n", "outpu...
code_stdio
[ { "content": "<image>\n\nOne morning the Cereal Guy found out that all his cereal flakes were gone. He found a note instead of them. It turned out that his smart roommate hid the flakes in one of n boxes. The boxes stand in one row, they are numbered from 1 to n from the left to the right. The roommate left hin...
[{"input": "459 16\nTo the right of 15\nTo the right of 148\nTo the left of 406\nTo the left of 335\nTo the right of 240\nTo the left of 409\nTo the left of 365\nTo the left of 426\nTo the left of 416\nTo the right of 247\nTo the left of 284\nTo the right of 187\nTo the right of 134\nTo the right of 128\nTo the right o...
code_stdio
[ { "content": "You are given a permutation of natural integers from 1 to N, inclusive. Initially, the permutation is 1, 2, 3, ..., N.\nYou are also given M pairs of integers, where the i-th is (Li Ri). In a single turn you can choose any of these pairs (let's say with the index j) and arbitrarily shuffle the ele...
[{"input": "2\n7 1\n5 0 4 7 -1 5 12\n0 2\n2 1\n4 6\n1 3\n11 2\n0 2 2 8\n2 6\n2 3", "output": "Impossible\nImpossible\n"}, {"input": "2\n7 1\n5 0 4 7 -1 5 12\n0 2\n2 1\n4 6\n1 3\n11 2\n0 2 2 8\n2 6\n1 3", "output": "Impossible\nImpossible\n"}, {"input": "2\n7 1\n5 0 4 7 -1 5 12\n0 2\n2 1\n4 6\n1 3\n11 2\n0 2 2 8\n2 6\n0...
code_stdio
[ { "content": "The Bitlandians are quite weird people. They have very peculiar customs.\n\nAs is customary, Uncle J. wants to have n eggs painted for Bitruz (an ancient Bitland festival). He has asked G. and A. to do the work.\n\nThe kids are excited because just as is customary, they're going to be paid for the...
[{"input": "10\n2 658\n5 29\n2 558\n1 1275\n2 1177\n1 1033\n1 247\n-1 4605\n0 1170\n-1 999\n", "output": "AAAAAAAAAA\n"}, {"input": "10\n2 658\n5 66\n2 784\n1 1275\n2 1177\n1 999\n1 247\n-1 4605\n0 1170\n-1 999\n", "output": "AAAAAAAAAA\n"}, {"input": "10\n2 658\n5 66\n2 460\n1 1275\n2 1177\n1 999\n1 247\n-1 4605\n0 11...
code_stdio
[ { "content": "# Task\n\nYour task is to write a function for calculating the score of a 10 pin bowling game. The input for the function is a list of pins knocked down per roll for one player. Output is the player's total score.\n\n# Rules\n\n## General rules\nRules of bowling in a nutshell:\n\n* A game consists...
[{"input": "[9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9]", "output": "[190]", "fn_name": "bowling_score"}, {"input": "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 1, 0]", "output": "[11]", "fn_name": "bowling_score"}, {"input": "[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
code_functional
[ { "content": "# Story\n\nDue to lack of maintenance the minute-hand has fallen off Town Hall clock face.\n\nAnd because the local council has lost most of our tax money to a Nigerian email scam there are no funds to fix the clock properly. \n\nInstead, they are asking for volunteer programmers to write some cod...
[{"input": "360", "output": "[\"12:00\"]", "fn_name": "what_time_is_it"}, {"input": "180", "output": "[\"06:00\"]", "fn_name": "what_time_is_it"}, {"input": "270", "output": "[\"09:00\"]", "fn_name": "what_time_is_it"}, {"input": "90", "output": "[\"03:00\"]", "fn_name": "what_time_is_it"}, {"input": "30", "output": "[...
code_functional
[ { "content": "You are given a permutation $p_1, p_2, \\dots, p_n$. Recall that sequence of $n$ integers is called a permutation if it contains all integers from $1$ to $n$ exactly once.\n\nFind three indices $i$, $j$ and $k$ such that: $1 \\le i < j < k \\le n$; $p_i < p_j$ and $p_j > p_k$. Or say that ther...
[{"input": "3\n4\n2 1 4 3\n6\n4 12 1 2 5 3\n5\n5 7 1 2 4\n", "output": "YES\n2 3 4\nYES\n1 2 3\nYES\n1 2 3\n"}, {"input": "3\n4\n2 1 4 3\n6\n4 12 1 2 5 3\n5\n5 8 1 2 4\n", "output": "YES\n2 3 4\nYES\n1 2 3\nYES\n1 2 3\n"}, {"input": "3\n4\n2 1 4 3\n6\n4 10 1 2 5 3\n5\n5 3 1 2 4\n", "output": "YES\n2 3 4\nYES\n1 2 3\nNO...
code_stdio
[ { "content": "Write a function that rearranges an integer into its largest possible value. \n\n```python\nsuper_size(123456) # 654321\nsuper_size(105) # 510\nsuper_size(12) # 21\n```\n``` haskell\nsuperSize 123456 `shouldBe` 654321\nsuperSize 105 `shouldBe` 510\nsuperSize 12 `shouldBe` 21\n...
[{"input": "700000000001", "output": "[710000000000]", "fn_name": "super_size"}, {"input": "123456789", "output": "[987654321]", "fn_name": "super_size"}, {"input": "608719", "output": "[987610]", "fn_name": "super_size"}, {"input": "666666", "output": "[666666]", "fn_name": "super_size"}, {"input": "2017", "output": "...
code_functional