messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. \nThe AND operation is the Bitwise AND operation, defined as in here. \n\n------ Input ------ \n\nThe first line of input consists of the integer N. \n\nThe second line conta...
[{"input": "5\n2 14 11 2 0", "output": "20\n"}, {"input": "5\n13 2 12 4 2", "output": "22\n"}, {"input": "5\n11 1 29 8 2", "output": "29\n"}, {"input": "5\n4 2 5 15 12", "output": "35\n"}, {"input": "5\n4 2 5 28 12", "output": "32\n"}, {"input": "5\n2 3 11 6 9", "output": "23\n"}, {"input": "5\n2 3 11 9 9", "output": "...
code_stdio
[ { "content": "The only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version.\n\nPolycarp is a very famous freelancer. His current rating is $r$ units.\n\nSome very rich customers asked him to complete some projects for t...
[{"input": "50 15000\n142 -300\n20 -298\n560 -300\n1815 -292\n282 -297\n92 -293\n34 -284\n555 -299\n408 -293\n504 -284\n278 -284\n139 -291\n64 -298\n311 -293\n130 -293\n89 -298\n129 -294\n385 -295\n136 -288\n41 -293\n112 -290\n416 -295\n178 -294\n154 -300\n110 -300\n346 -299\n209 -294\n1394 -295\n209 -299\n16 -297\n592...
code_stdio
[ { "content": "A string is a palindrome if it reads the same from the left to the right and from the right to the left. For example, the strings \"kek\", \"abacaba\", \"r\" and \"papicipap\" are palindromes, while the strings \"abb\" and \"iq\" are not.\n\nA substring $s[l \\ldots r]$ ($1 \\leq l \\leq r \\leq |...
[{"input": "wobervhvvkihcuyjtmqhaaigvvgiaahqmtjyuchikvvhvrebow\n", "output": "49\n"}, {"input": "wobervhvvkihcuyjtmqhaaigvahheoqleromusrartldojsjvy\n", "output": "50\n"}, {"input": "wobervhvvkihcuyjtmqhaaigvvgiaahqmtjyuchikvvhvrebow\n", "output": "49\n"}, {"input": "wobervhvvkihcuyjtmqhaaigvahheoqleromusrartldojsjvy\n"...
code_stdio
[ { "content": "Есть n-подъездный дом, в каждом подъезде по m этажей, и на каждом этаже каждого подъезда ровно k квартир. Таким образом, в доме всего n·m·k квартир. Они пронумерованы естественным образом от 1 до n·m·k, то есть первая квартира на первом этаже в первом подъезде имеет номер 1, первая квартира на вто...
[{"input": "1000 1000 1000\n1000000000 990000001\n", "output": "1144\n"}, {"input": "491 980 907\n253658701 421137262\n", "output": "3985\n"}, {"input": "200 970 827\n113595903 145423943\n", "output": "1484\n"}, {"input": "841 727 726\n101540521 305197765\n", "output": "6264\n"}, {"input": "727 645 804\n101269988 37448...
code_stdio
[ { "content": "They say \"years are like dominoes, tumbling one after the other\". But would a year fit into a grid? I don't think so.\n\nLimak is a little polar bear who loves to play. He has recently got a rectangular grid with h rows and w columns. Each cell is a square, either empty (denoted by '.') or forbi...
[{"input": "7 39\n.......................................\n.###..###..#..###.....###..###..#..###.\n...#..#.#..#..#.........#..#.#..#..#...\n.###..#.#..#..###.....###..#.#..#..###.\n.#....#.#..#....#.....#....#.#..#..#.#.\n.###..###..#..###.....###..###..#..###.\n.......................................\n6\n1 1 3 20\n2 ...
code_stdio
[ { "content": "For a given weighted directed graph G(V, E), find the distance of the shortest route that meets the following criteria:\n\n* It is a closed cycle where it ends at the same point it starts.\n* It visits each vertex exactly once.\n\nConstraints\n\n* 2 ≤ |V| ≤ 15\n* 0 ≤ di ≤ 1,000\n* There are no mul...
[{"input": "2 -1\n-1 2 8\n-1 15 4\n-1 0 12\n1 -2 3\n-1 0 4\n3 -1 1", "output": "-1\n"}, {"input": "2 -1\n-1 2 8\n-1 10 4\n-1 0 12\n1 -2 3\n-1 0 4\n3 -1 1", "output": "-1\n"}, {"input": "2 -1\n-1 2 8\n-1 10 4\n-1 0 12\n1 -2 3\n-1 0 4\n3 -1 2", "output": "-1\n"}, {"input": "2 -1\n-1 2 8\n-1 10 2\n-1 0 12\n1 -2 3\n-1 0 4\...
code_stdio
[ { "content": "You are given N positive integers a_1, a_2, ..., a_N.\nFor a non-negative integer m, let f(m) = (m\\ mod\\ a_1) + (m\\ mod\\ a_2) + ... + (m\\ mod\\ a_N).\nHere, X\\ mod\\ Y denotes the remainder of the division of X by Y.\nFind the maximum value of f.\n\n-----Constraints-----\n - All values in in...
[{"input": "3000\n68281 84761 81533 73757 80783 82723 93949 79397 68399 85061 99103 81671 82231 90073 83639 82813 68389 92767 94999 69931 85087 99487 72893 72269 76129 77719 69313 74471 96911 89917 98713 87011 66359 96479 88427 95873 97987 89021 75133 73189 83791 68483 75329 78929 99787 87181 75011 87281 75149 94889 76...
code_stdio
[ { "content": "Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirrel Liss occupies an interval [0, 1]. Next, n stones will fall and Liss will escape from the stones. The stones are numbered from 1 to n in order.\n\nThe stones always fall to th...
[{"input": "rrlllrrrlrrlrrrlllrlrlrrrlllrllrrllrllrrlrlrrllllrlrrrrlrlllrlrrrlrlrllrlrlrrlrrllrrrlrlrlllrrllllrl\n", "output": "1\n2\n6\n7\n8\n10\n11\n13\n14\n15\n19\n21\n23\n24\n25\n29\n32\n33\n36\n39\n40\n42\n44\n45\n50\n52\n53\n54\n55\n57\n61\n63\n64\n65\n67\n69\n72\n74\n76\n77\n79\n80\n83\n84\n85\n87\n89\n93\n94\n9...
code_stdio
[ { "content": "Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is hig...
[{"input": "501\noilesjbgowlnayckhpoaitijewsyhgavnthycaecwnvzpxgjqfjyxnjcjknvvsmjbjwtcoyfbegmnnheeamvtfjkigqoanhvgdfrjchdqgowrstlmrjmcsuuwvvoeucfyhnxivosrxblfoqwikfxjnnyejdiihpenfcahtjwcnzwvxxseicvdfgqhtvefswznuyohmmljlnxubhevywpmnitnkhecsgccpstxkmdzabsnwxkokdfsogzbpnfvgudvqlstxojzfzugxbfrozveaiofrzksegdelxsdhcjlqwqlgj...
code_stdio
[ { "content": "Takahashi has N cards. The i-th of these cards has an integer A_i written on it.\nTakahashi will choose an integer K, and then repeat the following operation some number of times:\n - Choose exactly K cards such that the integers written on them are all different, and eat those cards. (The eaten c...
[{"input": "5\n1 2 3 4 5\n", "output": "5\n2\n1\n1\n1\n"}, {"input": "5\n1 2 3 3 5", "output": "5\n2\n1\n1\n0\n"}, {"input": "5\n2 2 3 3 5", "output": "5\n2\n1\n0\n0\n"}, {"input": "5\n4 2 2 4 4", "output": "5\n2\n0\n0\n0\n"}, {"input": "5\n4 4 5 4 4", "output": "5\n1\n0\n0\n0\n"}, {"input": "5\n5 1 2 3 4", "output": "...
code_stdio
[ { "content": "There are k sensors located in the rectangular room of size n × m meters. The i-th sensor is located at point (x_{i}, y_{i}). All sensors are located at distinct points strictly inside the rectangle. \n\nOpposite corners of the room are located at points (0, 0) and (n, m). Walls of the room are pa...
[{"input": "11 17 10\n1 8\n1 7\n2 3\n3 2\n4 8\n5 3\n2 15\n8 6\n6 3\n3 1\n", "output": "-1\n109\n-1\n-1\n26\n71\n-1\n74\n-1\n69\n"}, {"input": "10 17 10\n1 8\n1 7\n2 3\n7 2\n4 8\n10 3\n2 8\n8 6\n6 3\n3 1\n", "output": "-1\n41\n-1\n-1\n76\n-1\n42\n28\n-1\n103\n"}, {"input": "11 17 10\n1 8\n1 7\n0 3\n3 2\n4 8\n5 3\n2 15\n...
code_stdio
[ { "content": "Calvin the robot lies in an infinite rectangular grid. Calvin's source code contains a list of n commands, each either 'U', 'R', 'D', or 'L' — instructions to move a single square up, right, down, or left, respectively. How many ways can Calvin execute a non-empty contiguous substrings of commands...
[{"input": "200\nUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUD\n", "output": "10000\n"}, {"input": "200\nDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDU...
code_stdio
[ { "content": "Consider an array $a$ of length $n$ with elements numbered from $1$ to $n$. It is possible to remove the $i$-th element of $a$ if $gcd(a_i, i) = 1$, where $gcd$ denotes the greatest common divisor. After an element is removed, the elements to the right are shifted to the left by one position.\n\nA...
[{"input": "1337 424242424242\n", "output": "119112628\n"}, {"input": "300000 1000000000\n", "output": "590856313\n"}, {"input": "2 1000000000000\n", "output": "138131255\n"}, {"input": "17957 2\n", "output": "653647969\n"}, {"input": "300000 1\n", "output": "299999\n"}, {"input": "4 6\n", "output": "1494\n"}, {"input"...
code_stdio
[ { "content": "A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer h_{i}. The tourist pick smooth enough route for his hike, meaning that the between any two consecutive days height ch...
[{"input": "190877881 20\n3 100000000\n14 100000000\n22 100000000\n24 100000000\n31 100000000\n41 100100000\n46 100000000\n84 100000000\n94 100000000\n98 100000000\n99999912 100000000\n99999915 100000000\n99999916 100000000\n99999923 100000000\n99999935 100000000\n99999937 100000000\n99999954 100000000\n99999955 100000...
code_stdio
[ { "content": "We have a sequence A of N non-negative integers.\nCompute the sum of \\prod _{i = 1} ^N \\dbinom{B_i}{A_i} over all sequences B of N non-negative integers whose sum is at most M, and print it modulo (10^9 + 7).\nHere, \\dbinom{B_i}{A_i}, the binomial coefficient, denotes the number of ways to choo...
[{"input": "2000 4000001\n2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000...
code_stdio
[ { "content": "Write a function that when given a URL as a string, parses out just the domain name and returns it as a string. For example:\n```python\ndomain_name(\"http://github.com/carbonfive/raygun\") == \"github\" \ndomain_name(\"http://www.zombie-bites.com\") == \"zombie-bites\"\ndomain_name(\"https://www....
[{"input": "\"http://www.codewars.com/kata/\"", "output": "[\"codewars\"]", "fn_name": "domain_name"}, {"input": "\"https://hyphen-site.org\"", "output": "[\"hyphen-site\"]", "fn_name": "domain_name"}, {"input": "\"http://codewars.com\"", "output": "[\"codewars\"]", "fn_name": "domain_name"}, {"input": "\"https://youtu...
code_functional
[ { "content": "There are n vertical lines in the Amidakuji. This Amidakuji meets the following conditions.\n\n* Draw a horizontal line right next to it. Do not pull diagonally.\n* Horizontal lines always connect adjacent vertical lines. In other words, the horizontal line does not cross the vertical line.\n* For...
[{"input": "5\n2\n3\n9\n1010\n1001\n0100\n1001\n0010\n1000\n0000\n0101\n1010\n0", "output": "6 4\n"}, {"input": "5\n2\n3\n9\n1010\n1001\n1000\n1001\n0010\n1000\n0000\n0101\n1001\n0", "output": "5 1\n"}, {"input": "5\n2\n3\n9\n1010\n0001\n0000\n1001\n0010\n1000\n0000\n0101\n1001\n0", "output": "2 1\n"}, {"input": "5\n3\...
code_stdio
[ { "content": "A dragon symbolizes wisdom, power and wealth. On Lunar New Year's Day, people model a dragon with bamboo strips and clothes, raise them with rods, and hold the rods high and low to resemble a flying dragon.\n\nA performer holding the rod low is represented by a 1, while one holding it high is repr...
[{"input": "200\n2 1 1 2 1 2 2 2 2 2 1 2 2 1 1 2 2 1 1 1 2 1 1 2 2 2 2 2 1 1 2 1 2 1 1 2 1 1 1 1 2 1 2 2 1 2 1 1 1 2 1 1 1 2 2 2 1 1 1 1 2 2 2 1 2 2 2 1 2 2 2 1 2 1 2 1 2 1 1 1 1 2 2 2 1 1 2 1 2 1 2 1 2 2 1 1 1 2 2 2 2 1 2 2 2 1 1 1 1 2 1 1 1 2 2 1 2 1 2 2 2 1 2 1 2 1 2 1 2 2 2 1 2 2 2 1 1 1 1 2 1 2 1 1 1 2 1 2 2 2 1 2...
code_stdio
[ { "content": "You are given a range of positive integers from $l$ to $r$.\n\nFind such a pair of integers $(x, y)$ that $l \\le x, y \\le r$, $x \\ne y$ and $x$ divides $y$.\n\nIf there are multiple answers, print any of them.\n\nYou are also asked to answer $T$ independent queries.\n\n\n-----Input-----\n\nThe ...
[{"input": "3\n6969 696969\n11103 49805\n6969 696969\n", "output": "6969 13938\n11103 22206\n6969 13938\n"}, {"input": "3\n9989 359575\n11103 49805\n6969 253442\n", "output": "9989 19978\n11103 22206\n6969 13938\n"}, {"input": "3\n6787 359575\n11103 49805\n6969 465579\n", "output": "6787 13574\n11103 22206\n6969 13938\...
code_stdio
[ { "content": "Throughout Igor K.'s life he has had many situations worthy of attention. We remember the story with the virus, the story of his mathematical career and of course, his famous programming achievements. However, one does not always adopt new hobbies, one can quit something as well.\n\nThis time Igor...
[{"input": "446237720 920085248 296916273 439113596\n", "output": "1\n"}, {"input": "491259590 529594367 305425951 326414536\n", "output": "1\n"}, {"input": "733405771 1387069059 19971607 389270995\n", "output": "1\n"}, {"input": "446237720 920085248 296916273 296925221\n", "output": "1\n"}, {"input": "733405771 830380...
code_stdio
[ { "content": "Consider the function p(x), where x is an array of m integers, which returns an array y consisting of m + 1 integers such that y_{i} is equal to the sum of first i elements of array x (0 ≤ i ≤ m).\n\nYou have an infinite sequence of arrays A^0, A^1, A^2..., where A^0 is given in the input, and for...
[{"input": "4 1000000000000000000\n612929642 983621174 279363954 332455288\n", "output": "2137\n"}, {"input": "4 1000000000000000000\n612929642 983621174 279363954 332455288\n", "output": "2137\n"}, {"input": "4 1000000000000000000\n612929642 983621174 97116392 332455288\n", "output": "2137\n"}, {"input": "18 100000000...
code_stdio
[ { "content": "You have a string $s$ of length $n$ consisting of only characters > and <. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character >, the character that comes right after it is deleted (if the cha...
[{"input": "14\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n<\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n"}, {"input": "14\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n<\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n"}, {...
code_stdio
[ { "content": "Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time. \n\nDuring the last lesson the teacher has provided two strings s and t to Vitaly. The strings have the same length, they consis...
[{"input": "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyzyyyyyyyyyyyyyyyyyyyyyy\nzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\n", "output": "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyzyyyyyyyyyyyy...
code_stdio
[ { "content": "You wrote all your unit test names in camelCase.\nBut some of your colleagues have troubles reading these long test names.\nSo you make a compromise to switch to underscore separation.\n\nTo make these changes fast you wrote a class to translate a camelCase name\ninto an underscore separated name....
[{"input": "\"_IfATestStartAndEndsWithUnderscore_ItShouldBeTheSame_\"", "output": "[\"_If_A_Test_Start_And_Ends_With_Underscore_It_Should_Be_The_Same_\"]", "fn_name": "toUnderScore"}, {"input": "\"ThisShouldBeSplittedCorrectIntoUnderscore\"", "output": "[\"This_Should_Be_Splitted_Correct_Into_Underscore\"]", "fn_name":...
code_functional
[ { "content": "Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.\n\nOverall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.\n\nLet's consider ...
[{"input": "92 3\n418\n665\n861\n766\n529\n416\n476\n676\n561\n995\n415\n185\n291\n176\n776\n631\n556\n488\n118\n188\n437\n496\n466\n131\n914\n118\n766\n365\n113\n897\n386\n639\n276\n946\n759\n169\n494\n837\n338\n351\n783\n311\n261\n862\n598\n132\n246\n982\n575\n364\n615\n347\n374\n368\n523\n132\n774\n161\n552\n492\n59...
code_stdio
[ { "content": "You would like to get the 'weight' of a name by getting the sum of the ascii values. However you believe that capital letters should be worth more than mere lowercase letters. Spaces, numbers, or any other character are worth 0.\n\nNormally in ascii\n\n a has a value of 97\n A has a value of...
[{"input": "\"George Washington\"", "output": "[1275]", "fn_name": "get_weight"}, {"input": "\"King George II\"", "output": "[1012]", "fn_name": "get_weight"}, {"input": "\"Billy Bob Joe\"", "output": "[909]", "fn_name": "get_weight"}, {"input": "\"r2d2\"", "output": "[150]", "fn_name": "get_weight"}, {"input": "\"R2D2...
code_functional
[ { "content": "Do you know that The Chef has a special interest in palindromes? Yes he does! Almost all of the dishes in his restaurant is named by a palindrome strings. The problem is that a name of a dish should not be too long, so The Chef has only limited choices when naming a new dish.\n\nFor the given posi...
[{"input": "5\n1\n2\n15\n10\n100", "output": "26\n52\n533228165\n24713260\n508533804\n"}, {"input": "5\n1\n1\n15\n10\n100", "output": "26\n26\n533228165\n24713260\n508533804\n"}, {"input": "5\n1\n2\n8\n10\n110", "output": "26\n52\n950508\n24713260\n316452997\n"}, {"input": "5\n1\n2\n8\n10\n100", "output": "26\n52\n9505...
code_stdio
[ { "content": "Little chef has just been introduced to the world of numbers! While experimenting with addition and multiplication operations, the little chef came up with the following problem:\n\nGiven an array A of non-negative integers, how many pairs of indices i and j exist such that A[i]*A[j] > A[i]+A[j] ...
[{"input": "2\n3\n3 16 10\n4\n1 1 0 1", "output": "3\n0\n"}, {"input": "2\n3\n3 8 10\n4\n1 1 0 -1", "output": "3\n0\n"}, {"input": "2\n3\n3 16 10\n4\n0 1 0 1", "output": "3\n0\n"}, {"input": "2\n3\n3 16 10\n4\n0 2 0 1", "output": "3\n0\n"}, {"input": "2\n3\n9 10 5\n4\n4 1 1 2", "output": "3\n1\n"}, {"input": "2\n3\n0 3...
code_stdio
[ { "content": "There were $n$ types of swords in the theater basement which had been used during the plays. Moreover there were exactly $x$ swords of each type. $y$ people have broken into the theater basement and each of them has taken exactly $z$ swords of some single type. Note that different people might hav...
[{"input": "10\n100000000 200000000 300000000 20 500000000 600000000 700000000 800000000 900000000 1000000000\n", "output": "244999999 20\n"}, {"input": "10\n100000000 200000000 300000000 20 500000000 600000000 700000000 800000000 900000000 1000000000\n", "output": "244999999 20\n"}, {"input": "10\n100000000 200000000 ...
code_stdio
[ { "content": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"gold...
[{"input": "1000000000000000000000000000000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111000000000000000000000000000000000000000000000000\n11111111111111111111111111111111111111111111111111111111111...
code_stdio
[ { "content": "Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes:\n\n* Red boxes, each containing R red balls\n* Green boxes, each containing G green balls\n* Blue boxes, each containing B blue balls\n\n\n\nSnuke wants to get a total of exactly N ball...
[{"input": "13 2 1 3000", "output": "174001\n"}, {"input": "13 1 1 3000", "output": "347886\n"}, {"input": "13 2 1 3118", "output": "187920\n"}, {"input": "22 2 1 3118", "output": "111399\n"}, {"input": "13 2 4 3000", "output": "43732\n"}, {"input": "8 2 1 3000", "output": "282376\n"}, {"input": "7 2 1 3000", "output":...
code_stdio
[ { "content": "One player came to a casino and found a slot machine where everything depends only on how he plays. The rules follow.\n\nA positive integer $a$ is initially on the screen. The player can put a coin into the machine and then add $1$ to or subtract $1$ from any two adjacent digits. All digits must r...
[{"input": "66\n909090909090909090909090909090909909090909090909090909090909090909\n190909090909090909090909090909090090909090909090909090909090909091\n", "output": " 9736\n33 -1\n32 1\n31 -1\n30 1\n29 -1\n28 1\n27 -1\n26 1\n25 -1\n24 1\n23 -1\n22 1\n21 -1\n20 ...
code_stdio
[ { "content": "You are given a tree (an undirected connected acyclic graph) consisting of n vertices. You are playing a game on this tree.\n\nInitially all vertices are white. On the first turn of the game you choose one vertex and paint it black. Then on each turn you choose a white vertex adjacent (connected b...
[{"input": "52\n1 52\n2 52\n3 18\n4 52\n5 52\n6 52\n7 52\n8 52\n9 52\n10 52\n11 52\n12 52\n13 52\n14 52\n15 52\n16 52\n17 52\n18 52\n19 52\n20 52\n21 52\n22 52\n23 52\n24 52\n25 52\n26 52\n27 52\n28 52\n29 52\n30 52\n31 52\n32 52\n33 52\n34 52\n35 52\n36 52\n37 52\n38 52\n39 52\n40 52\n41 52\n42 52\n43 52\n44 52\n45 52...
code_stdio
[ { "content": "If you like Taco Bell, you will be familiar with their signature doritos locos taco. They're very good.\n\n\nWhy can't everything be a taco? We're going to attempt that here, turning every word we find into the taco bell recipe with each ingredient.\n\n\nWe want to input a word as a string, and re...
[{"input": "\"Alex is Super Cool\"", "output": "[[\"shell\", \"beef\", \"lettuce\", \"beef\", \"beef\", \"salsa\", \"salsa\", \"beef\", \"beef\", \"cheese\", \"beef\", \"beef\", \"lettuce\", \"shell\"]]", "fn_name": "tacofy"}, {"input": "\"abtlcgs\"", "output": "[[\"shell\", \"beef\", \"tomato\", \"lettuce\", \"cheese\...
code_functional
[ { "content": "Alice and Bob are meeting after a long time. As usual they love to play some math games. This times Alice takes the call and decides the game. The game is very simple, Alice says out an integer and Bob has to say whether the number is prime or not. Bob as usual knows the logic but since Alice does...
[{"input": "5\n23\n13\n20\n1100\n99991", "output": "yes\nyes\nno\nno\nyes\n"}, {"input": "5\n31\n17\n7\n1100\n99991", "output": "yes\nyes\nyes\nno\nyes\n"}, {"input": "5\n29\n21\n31\n1100\n99991", "output": "yes\nno\nyes\nno\nyes\n"}, {"input": "5\n23\n23\n20\n1000\n99991", "output": "yes\nyes\nno\nno\nyes\n"}, {"input...
code_stdio
[ { "content": "Makes solves problems on Decoforces and lots of other different online judges. Each problem is denoted by its difficulty — a positive integer number. Difficulties are measured the same across all the judges (the problem with difficulty d on Decoforces is as hard as the problem with difficulty d on...
[{"input": "100 10\n246 286 693 607 87 612 909 312 621 37 801 558 504 914 416 762 187 974 976 123 635 488 416 659 988 998 93 662 92 749 889 78 214 786 735 625 921 372 713 617 975 119 402 411 878 138 548 905 802 762 940 336 529 373 745 835 805 880 816 94 166 114 475 699 974 462 61 337 555 805 968 815 392 746 591 558 740...
code_stdio
[ { "content": "Rock... Paper!\n\nAfter Karen have found the deterministic winning (losing?) strategy for rock-paper-scissors, her brother, Koyomi, comes up with a new game as a substitute. The game works as follows.\n\nA positive integer n is decided first. Both Koyomi and Karen independently choose n distinct p...
[{"input": "30\n1143673 436496 1214486 1315862 148404 724601 1430740 1433008 1654610 1635673 614673 1713408 1270999 1697 1463796 50027 525482 1659078 688200 842647 518551 877506 1017082 1807856 3280 759698 1208220 470180 829800 1960886\n1312613 1965095 967255 1289012 1950383 582960 856825 49684 808824 319418 1968270 19...
code_stdio
[ { "content": "You are given an H \\times W grid. The square at the top-left corner will be represented by (0, 0), and the square at the bottom-right corner will be represented by (H-1, W-1).\n\nOf those squares, N squares (x_1, y_1), (x_2, y_2), ..., (x_N, y_N) are painted black, and the other squares are paint...
[{"input": "1000000 1000000\n0\n0 0", "output": "333218986"}, {"input": "1000000 1000000\n1\n0 0", "output": "333211937"}, {"input": "1000001 1000000\n0\n0 1", "output": "40554683"}, {"input": "4 4\n4\n0 1\n1 1\n2 1\n2 2", "output": "268"}, {"input": "14 13\n0\n-1 -2", "output": "148239"}, {"input": "14 14\n0\n0 -1", "...
code_stdio
[ { "content": "There is a robot staying at $X=0$ on the $Ox$ axis. He has to walk to $X=n$. You are controlling this robot and controlling how he goes. The robot has a battery and an accumulator with a solar panel.\n\nThe $i$-th segment of the path (from $X=i-1$ to $X=i$) can be exposed to sunlight or not. The a...
[{"input": "100 1 1\n0 0 0 1 1 0 1 0 1 0 1 0 -1 1 0 0 1 1 0 1 2 0 1 1 1 1 1 1 1 0 1 1 1 0 -1 0 0 0 -1 0 1 0 0 1 1 0 1 0 0 1 0 1 1 0 0 1 0 0 0 1 1 1 1 1 0 0 1 0 0 1 0 0 0 0 1 0 0 0 1 1 0 1 1 0 1 1 1 0 1 1 -1 1 1 0 0 1 1 0 1 1\n", "output": "2\n"}, {"input": "100 1 1\n0 0 0 1 1 0 1 0 1 0 1 0 -1 1 0 0 1 1 0 1 2 0 1 1 1 1 ...
code_stdio
[ { "content": "You are given a matrix $a$ of size $n \\times m$ consisting of integers.\n\nYou can choose no more than $\\left\\lfloor\\frac{m}{2}\\right\\rfloor$ elements in each row. Your task is to choose these elements in such a way that their sum is divisible by $k$ and this sum is the maximum.\n\nIn other ...
[{"input": "10 20 69\n7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7\n7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7\n7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7\n7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7\n7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7\n7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7\n7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7\n7 7 7 7 7 7...
code_stdio
[ { "content": "A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.\n\nThis new device is equipped with specially designed artificial intelligence...
[{"input": "sosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosos\nsos\n", "output": "20"}, {"input": "sosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosos\nsos\n", "output": "20"}, {"input": "sosossosossosossosossosossososso...
code_stdio
[ { "content": "In the middle of Tyrrhenian Sea, there is a small volcanic island called Chronus. The island is now uninhabited but it used to be a civilized island. Some historical records imply that the island was annihilated by an eruption of a volcano about 800 years ago and that most of the people in the isl...
[{"input": "3\n8 8 28\n32 34 32\n57 2 108\n5\n49 3 49\n7 46 44\n27 21 21\n33 56 56\n21 46 4\n3\n45 52 28\n46 26 36\n40 55 62\n10\n33 8 39\n50 57 43\n61 21 12\n21 17 11\n16 22 106\n45 40 53\n45 30 53\n39 1 8\n24 48 30\n7 48 15\n0", "output": "03:16:36 03:21:07\n06:14:56 06:32:09\n02:18:54 02:21:01\n02:17:21 02:20:00\n"}...
code_stdio
[ { "content": "Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 poin...
[{"input": "9 846678 205000\n102282 593538\n246630 24854\n545346 409737\n334264 443193\n37717 191227\n154582 913095\n97105 345066\n65504 578960\n163348 394257\n", "output": "2441209588\n"}, {"input": "9 846678 205000\n102282 593538\n246630 24854\n545346 409737\n334264 443193\n37717 191227\n154582 913095\n97105 345066\n...
code_stdio
[ { "content": "We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand.\nHow many grams of sand will the upper bulb contains after t seconds?\n\n-----Constraints-----\n - 1≤X≤10^9\n - 1≤t≤10^9\n - X...
[{"input": "1111100011 0101011000", "output": "1010089011\n"}, {"input": "1111100111 0101011000", "output": "1010089111\n"}, {"input": "1100001110 0010011100", "output": "1089990010\n"}, {"input": "1110001110 0010011100", "output": "1099990010\n"}, {"input": "1110001100 0010011100", "output": "1099990000\n"}, {"input":...
code_stdio
[ { "content": "Given are integers N and X. For each integer k between 0 and X (inclusive), find the answer to the following question, then compute the sum of all those answers, modulo 998244353.\n\n* Let us repeat the following operation on the integer k. Operation: if the integer is currently odd, subtract 1 fr...
[{"input": "30\n001110011011011101010101011100", "output": "549313318"}, {"input": "30\n001010011011011101010101011100", "output": "515761610"}, {"input": "30\n001010011010011101010101011100", "output": "500033010"}, {"input": "30\n001010011010011111010101011100", "output": "500524530"}, {"input": "30\n0011100110100111...
code_stdio
[ { "content": "A group of n schoolboys decided to ride bikes. As nobody of them has a bike, the boys need to rent them.\n\nThe renting site offered them m bikes. The renting price is different for different bikes, renting the j-th bike costs p_{j} rubles.\n\nIn total, the boys' shared budget is a rubles. Besides...
[{"input": "40 40 61\n28 59 8 27 45 67 33 32 61 3 29 2 3 37 8 8 10 61 1 2 65 28 34 27 8 35 45 49 30 49 10 23 23 53 20 48 14 74 16 6\n69 56 34 66 42 73 45 49 29 70 26 77 73 26 78 11 50 69 64 72 78 66 66 29 80 40 50 75 58 47 78 113 41 70 52 52 69 22 69 66\n", "output": "23 960\n"}, {"input": "40 40 61\n28 59 8 27 45 67 3...
code_stdio
[ { "content": "Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: in the one it was directed originally and in the reversed direction.\n\nPavel has a plan: a permutation p...
[{"input": "100\n87 69 49 86 96 12 10 79 29 66 48 77 73 62 70 52 22 28 97 35 91 5 33 82 65 85 68 80 64 8 38 23 94 34 75 53 57 6 100 2 56 50 55 58 74 9 18 44 40 3 43 45 99 51 21 92 89 36 88 54 42 14 78 71 25 76 13 11 27 72 7 32 93 46 83 30 26 37 39 31 95 59 47 24 67 16 4 15 1 98 19 81 84 61 90 41 17 20 63 60\n1 1 1 0 1 ...
code_stdio
[ { "content": "Oh no! Ghosts have reportedly swarmed the city. It's your job to get rid of them and save the day!\n\nIn this kata, strings represent buildings while whitespaces within those strings represent ghosts.\n\nSo what are you waiting for? Return the building(string) without any ghosts(whitespaces)!\n\nE...
[{"input": "\"BusStation\"", "output": "[\"You just wanted my autograph didn't you?\"]", "fn_name": "ghostbusters"}, {"input": "\"YourHouse\"", "output": "[\"You just wanted my autograph didn't you?\"]", "fn_name": "ghostbusters"}, {"input": "\"O f fi ce\"", "output": "[\"Office\"]", "fn_name": "ghostbusters"}, {"inpu...
code_functional
[ { "content": "You are given two strings $s$ and $t$. Both strings have length $n$ and consist of lowercase Latin letters. The characters in the strings are numbered from $1$ to $n$.\n\nYou can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) char...
[{"input": "50\naabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyz\nzyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\n", "output": "1201\n49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 49 48 47 46 45 44 43 42 41 40 39 38 37 36 ...
code_stdio
[ { "content": "A message from humans to extraterrestrial intelligence was sent through the Arecibo radio telescope in Puerto Rico on the afternoon of Saturday November l6, l974. The message consisted of l679 bits and was meant to be translated to a rectangular picture with 23 × 73 pixels. Since both 23 and 73 ar...
[{"input": "5 1 2\n99999 999 999\n1680 10 16\n1970 1 2\n2002 4 11\n0 0 0", "output": "2 2\n313 313\n37 43\n37 53\n37 53\n"}, {"input": "10 1 9\n99999 999 1768\n1495 5 16\n973 1 2\n2002 4 11\n0 0 0", "output": "2 5\n257 389\n31 47\n31 31\n37 53\n"}, {"input": "12 1 5\n99999 999 1356\n1680 5 16\n973 1 2\n2002 4 11\n0 0 0...
code_stdio
[ { "content": "Write a function that takes an arbitrary number of strings and interlaces them (combines them by alternating characters from each string).\n\nFor example `combineStrings('abc', '123')` should return `'a1b2c3'`.\n\nIf the strings are different lengths the function should interlace them until each s...
[{"input": "\"abcd\"\n\"123\"\n\"$%^&\"\n\"qwertyuiop\"\n\"X\"", "output": "[\"a1$qXb2%wc3^ed&rtyuiop\"]", "fn_name": "combine_strings"}, {"input": "\"abcd\"\n\"123\"\n\"$%^&\"\n\"qwertyuiop\"", "output": "[\"a1$qb2%wc3^ed&rtyuiop\"]", "fn_name": "combine_strings"}, {"input": "\"abcd\"\n\"123\"\n\"$%^&\"", "output": "[...
code_functional
[ { "content": "Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes.\n\nA particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay ...
[{"input": "37\n30 16\n22 37\n37 43\n25 31\n12 12\n15 30\n42 11\n29 28\n26 32\n12 32\n18 12\n11 48\n24 25\n15 40\n40 38\n17 12\n22 27\n35 32\n11 29\n35 24\n42 35\n21 14\n25 11\n16 14\n28 31\n49 45\n48 24\n28 20\n21 19\n43 49\n42 24\n14 21\n23 19\n19 16\n32 35\n28 10\n14 22\n", "output": "500692159\n20910845\n885314984\...
code_stdio
[ { "content": "A group of people played a game. All players had distinct scores, which are positive integers.\n\nTakahashi knows N facts on the players' scores. The i-th fact is as follows: the A_i-th highest score among the players is B_i.\n\nFind the maximum possible number of players in the game.\n\nConstrain...
[{"input": "2\n-1 0011111111\n1100001111 -1", "output": "1100001110\n"}, {"input": "2\n-1 0011111111\n1100001111 -2", "output": "1100001109\n"}, {"input": "2\n-2 0011111111\n1100001111 -3", "output": "1100001108\n"}, {"input": "2\n-1 1000000011\n1100001010 0", "output": "1100001010\n"}, {"input": "2\n-1 1000000011\n110...
code_stdio
[ { "content": "There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either . or *. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}.\nExtend this image vertically so that its height is d...
[{"input": "9 20\n.....***....***.....\n....*...*..*...*....\n...*.....**.....*...\n...*.....*......*...\n....*.....*....*....\n.....**..*...**.....\n.......*..*.*.......\n........**.*........\n.........**.........\n", "output": ".....***....***.....\n.....***....***.....\n....*...*..*...*....\n....*...*..*...*....\n.....
code_stdio
[ { "content": "Witua is a little student from the University of Lviv. He enjoys studying math. Witua knows a lot of famous mathematicians like Eratosthenes, Pythagoras, Fermat, Diophantus, Furko, Gauss and so on. However, his favorite one is Euler. The only thing Witua likes more than Euler is Euler’s totient fu...
[{"input": "3\n12\n27\n11", "output": "11\n23\n11\n"}, {"input": "3\n12\n27\n16", "output": "11\n23\n13\n"}, {"input": "3\n12\n27\n23", "output": "11\n23\n23\n"}, {"input": "3\n6\n17\n11", "output": "5\n17\n11\n"}, {"input": "3\n6\n27\n11", "output": "5\n23\n11\n"}, {"input": "3\n6\n37\n11", "output": "5\n37\n11\n"}, {...
code_stdio
[ { "content": "There is a double-track line (up and down are separate lines and pass each other everywhere). There are 11 stations on this line, including the terminal station, and each station is called by the section number shown in the figure.\n\n<image>\n\n\nTrains depart from both terminal stations on this ...
[{"input": "06,04,1,2,1,1,1,1,1,1,1,2\n1,1,1,1,1,4,3,3,3,3,505,0\n10,10,10,10,10,10,10,10,10,10,50,49", "output": "2\n10\n6\n"}, {"input": "06,14,1,1,0,1,1,1,1,1,1,0\n1,1,1,1,1,3,3,3,3,3,40,50\n10,10,10,10,10,10,10,20,10,10,59,40", "output": "10\n7\n7\n"}, {"input": "06,01,0,1,1,4,1,2,1,1,1,1\n05,05,3,3,3,3,3,1,1,1,1,1...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian. \n\nYou are given a multiset of N integers. Please find such a nonempty subset of it that the sum of the subset's elements is divisible by N. Otherwise, state that this subset doesn't exist.\n\n------ Input ------ \n\nThe first line of the...
[{"input": "1\n3\n4 4 4", "output": "3\n1 2 3 \n"}, {"input": "1\n3\n2 5 2", "output": "3\n1 2 3 \n"}, {"input": "1\n3\n4 11 3", "output": "2\n1 2 \n"}, {"input": "1\n3\n1 11 3", "output": "2\n1 2 \n"}, {"input": "1\n3\n4 20 3", "output": "2\n1 2 \n"}, {"input": "1\n3\n7 11 3", "output": "2\n1 2 \n"}, {"input": "...
code_stdio
[ { "content": "A coordinate line has n segments, the i-th segment starts at the position l_{i} and ends at the position r_{i}. We will denote such a segment as [l_{i}, r_{i}].\n\nYou have suggested that one of the defined segments covers all others. In other words, there is such segment in the given set, which c...
[{"input": "55\n3 4\n6 8\n9 10\n3 9\n9 9\n2 5\n4 8\n3 8\n8 10\n1 1\n4 9\n10 10\n6 6\n8 8\n1 8\n5 5\n4 5\n5 9\n2 2\n3 10\n4 6\n3 6\n1 6\n1 7\n6 10\n2 6\n3 7\n2 4\n4 4\n5 10\n1 4\n2 9\n1 3\n7 9\n7 8\n1 9\n1 10\n2 8\n8 9\n6 7\n1 2\n6 9\n7 7\n4 7\n3 3\n2 7\n4 10\n7 10\n2 3\n2 10\n5 7\n3 5\n5 8\n1 5\n5 6\n", "output": "37\n...
code_stdio
[ { "content": "In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.\n\nTwo antennas can communicate directly if the distance between them is k or less, and they cannot if the dis...
[{"input": "6\n13\n29\n48\n105\n100\n", "output": "Yay!\n"}, {"input": "25\n26\n27\n28\n29\n91\n", "output": "Yay!\n"}, {"input": "0\n7\n9\n52\n123\n123\n", "output": "Yay!\n"}, {"input": "15\n18\n26\n35\n36\n18\n", "output": ":(\n"}, {"input": "5\n12\n29\n46\n75\n69\n", "output": ":(\n"}, {"input": "2\n22\n25\n32\n35\...
code_stdio
[ { "content": "Complete the method so that it formats the words into a single comma separated value. The last word should be separated by the word 'and' instead of a comma. The method takes in an array of strings and returns a single formatted string. Empty string values should be ignored. Empty arrays or null/n...
[{"input": "[\"one\", \"two\", \"three\", \"four\"]", "output": "[\"one, two, three and four\"]", "fn_name": "format_words"}, {"input": "[\"one\", \"\", \"three\"]", "output": "[\"one and three\"]", "fn_name": "format_words"}, {"input": "[\"one\", \"two\", \"\"]", "output": "[\"one and two\"]", "fn_name": "format_words...
code_functional
[ { "content": "Today at the lesson Vitya learned a very interesting function — mex. Mex of a sequence of numbers is the minimum non-negative number that is not present in the sequence as element. For example, mex([4, 33, 0, 1, 1, 5]) = 2 and mex([1, 2, 3]) = 0.\n\nVitya quickly understood all tasks of the teache...
[{"input": "17 30\n4194 1990 2257 1363 2798 386 3311 3152 1808 1453 3874 4388 1268 3924 3799 1269 968\n11\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n0\n8\n8\n8\n8\n8\n8\n8\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n"}, {"input": "17 30\n...
code_stdio
[ { "content": "As Gerald sets the table, Alexander sends the greeting cards, and Sergey and his twins create an army of clone snowmen, Gennady writes a New Year contest.\n\nThe New Year contest begins at 18:00 (6.00 P.M.) on December 31 and ends at 6:00 (6.00 A.M.) on January 1. There are n problems for the cont...
[{"input": "100\n46 353 325 357 342 31 186 689 447 377 484 297 517 92 408 336 389 651 346 464 521 670 353 577 73 477 21 84 659 180 454 386 274 425 274 8 306 131 688 313 342 144 589 277 225 520 442 704 72 376 334 200 92 180 205 602 138 286 668 39 714 447 477 684 491 38 44 186 274 614 127 5 585 566 242 578 361 445 550 31...
code_stdio
[ { "content": "You have unlimited number of coins with values $1, 2, \\ldots, n$. You want to select some set of coins having the total value of $S$. \n\nIt is allowed to have multiple coins with the same value in the set. What is the minimum number of coins required to get sum $S$?\n\n\n-----Input-----\n\nThe o...
[{"input": "100000 1000000000\n", "output": "10000\n"}, {"input": "1 1000000000\n", "output": "1000000000\n"}, {"input": "1 1010000000\n", "output": "1010000000\n"}, {"input": "1 1452428327\n", "output": "1452428327\n"}, {"input": "15666 1840331709\n", "output": "117473\n"}, {"input": "1 1000000000\n", "output": "10000...
code_stdio
[ { "content": "Ivan has n different boxes. The first of them contains some balls of n different colors.\n\nIvan wants to play a strange game. He wants to distribute the balls into boxes in such a way that for every i (1 ≤ i ≤ n) i-th box will contain all balls with color i.\n\nIn order to do this, Ivan will make...
[{"input": "8\n1517404878 380061316 129207228 90851747 825473738 704702117 365421523 251930836\n", "output": "7232760863\n"}, {"input": "8\n1517404878 75235306 129207228 90851747 861687101 1031974081 365421523 251930836\n", "output": "6811358611\n"}, {"input": "8\n1517404878 75235306 129207228 90851747 861687101 149707...
code_stdio
[ { "content": "How many strings can be obtained by applying the following operation on a string S exactly K times: \"choose one lowercase English letter and insert it somewhere\"?\nThe answer can be enormous, so print it modulo (10^9+7).\n\n-----Constraints-----\n - K is an integer between 1 and 10^6 (inclusive)...
[{"input": "37564\nwhydidyoudesertme\n", "output": "318008117\n"}, {"input": "37564\nwhydidzoudesertme", "output": "318008117\n"}, {"input": "37564\nwhxdidzoudesertme", "output": "318008117\n"}, {"input": "37564\nwhxdidzoudesertne", "output": "318008117\n"}, {"input": "37564\nwhxdiczoudesertne", "output": "318008117\n"...
code_stdio
[ { "content": "Your boss decided to save money by purchasing some cut-rate optical character recognition software for scanning in the text of old novels to your database. At first it seems to capture words okay, but you quickly notice that it throws in a lot of numbers at random places in the text. For example:\...
[{"input": "\"My \\\"me3ssy\\\" d8ata issues2! Will1 th4ey ever, e3ver be3 so0lved?\"", "output": "[\"My \\\"messy\\\" data issues! Will they ever, ever be solved?\"]", "fn_name": "string_clean"}, {"input": "\"Wh7y can't we3 bu1y the goo0d software3? #cheapskates3\"", "output": "[\"Why can't we buy the good software? #...
code_functional
[ { "content": "After returned from forest, Alyona started reading a book. She noticed strings s and t, lengths of which are n and m respectively. As usual, reading bored Alyona and she decided to pay her attention to strings s and t, which she considered very similar.\n\nAlyona has her favourite positive integer...
[{"input": "120 362 6\ncaaccbbbabbbcbaacbaccacaaccacaaababccaccaabaccacccbbaaaaababbccbbacccaacabacbaaacabbacbabcccbccbcbbcaabaaabaabcccaabacbb\nabcbbaaccbbcabbcbbcacbabaacbaaacabcbabcabbabccbcaaacaccaaabbcbaacccccbcabacaacabbbcabaabcbbccabacbaaaacbbbbbccabccccbababcbacbbbcbbaabcaabcacbaaaaaccbaabbabacbcbbbaabbbcabcaac...
code_stdio
[ { "content": "Bear Limak has n colored balls, arranged in one long row. Balls are numbered 1 through n, from left to right. There are n possible colors, also numbered 1 through n. The i-th ball has color t_{i}.\n\nFor a fixed interval (set of consecutive elements) of balls we can define a dominant color. It's a...
[{"input": "150\n28 124 138 71 71 18 78 136 138 93 145 93 18 15 71 47 47 64 18 72 138 72 18 150 7 71 109 149 18 115 149 52 15 106 124 27 72 124 28 108 138 109 108 111 148 138 78 27 28 150 138 100 15 145 109 47 102 62 28 7 115 108 102 149 150 27 111 64 149 124 13 21 108 64 7 15 72 72 124 47 102 28 109 18 124 28 111 138 ...
code_stdio
[ { "content": "You are given an array $a$ consisting of $n$ integers. Initially all elements of $a$ are either $0$ or $1$. You need to process $q$ queries of two kinds:\n\n1 x : Assign to $a_x$ the value $1 - a_x$.\n\n2 k : Print the $k$-th largest value of the array.\n\nAs a reminder, $k$-th largest value of th...
[{"input": "5 5\n0 1 0 1 0\n2 3\n2 2\n2 3\n2 1\n2 5\n", "output": "0\n1\n0\n1\n0\n"}, {"input": "5 5\n0 0 0 1 0\n2 3\n2 2\n2 3\n2 2\n2 5\n", "output": "0\n0\n0\n0\n0\n"}, {"input": "5 5\n1 0 1 0 0\n2 3\n2 3\n2 3\n2 1\n2 5\n", "output": "0\n0\n0\n1\n0\n"}, {"input": "5 5\n0 0 1 1 0\n2 1\n2 4\n2 3\n2 2\n2 1\n", "output":...
code_stdio
[ { "content": "Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction.\nLet us define a function f(r, c) as follows:\n - f(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace b...
[{"input": "1000000 1000000 1000000 1000000\n", "output": "192151600\n"}, {"input": "799999 789898 979797 999999\n", "output": "50188529\n"}, {"input": "53245 34234 643323 948342\n", "output": "574642047\n"}, {"input": "33400 31000 33400 593020\n", "output": "67962523\n"}, {"input": "349 602 998593 983904\n", "output":...
code_stdio
[ { "content": "Mislove had an array $a_1$, $a_2$, $\\cdots$, $a_n$ of $n$ positive integers, but he has lost it. He only remembers the following facts about it:\n\n\n\n The number of different numbers in the array is not less than $l$ and is not greater than $r$;\n\n For each array's element $a_i$ either $a_i = ...
[{"input": "1000 20 20\n", "output": "1049555 514850815\n"}, {"input": "1000 20 20\n", "output": "1049555 514850815\n"}, {"input": "114 18 19\n", "output": "262239 25427967\n"}, {"input": "879 17 17\n", "output": "131933 56623103\n"}, {"input": "114 18 19\n", "output": "262239 25427967\n"}, {"input": "879 17 17\n", "ou...
code_stdio
[ { "content": "Recently a Golden Circle of Beetlovers was found in Byteland. It is a circle route going through n ⋅ k cities. The cities are numerated from 1 to n ⋅ k, the distance between the neighboring cities is exactly 1 km.\n\nSergey does not like beetles, he loves burgers. Fortunately for him, there are n ...
[{"input": "98752 97209\n41218 39020\n", "output": "21427641 3199861056\n"}, {"input": "65536 32768\n6427 13573\n", "output": "67108864 1073741824\n"}, {"input": "100000 100000\n10 1\n", "output": "10000000000 10000000000\n"}, {"input": "100000 99737\n34242 43667\n", "output": "99737 9973700000\n"}, {"input": "100000 1...
code_stdio
[ { "content": "Phoenix is playing with a new puzzle, which consists of $n$ identical puzzle pieces. Each puzzle piece is a right isosceles triangle as shown below.\n\nA puzzle piece\n\nThe goal of the puzzle is to create a square using the $n$ pieces. He is allowed to rotate and move the pieces around, but none ...
[{"input": "3\n524304\n61032704\n61560720\n", "output": "NO\nNO\nNO\n"}, {"input": "3\n524304\n61032704\n61560720\n", "output": "NO\nNO\nNO\n"}, {"input": "3\n524304\n61032704\n10950212\n", "output": "NO\nNO\nNO\n"}, {"input": "3\n524304\n61032704\n14778357\n", "output": "NO\nNO\nNO\n"}, {"input": "3\n524304\n61032704\...
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 4 10 1 7 9 8 10 3 8 6 2 2 6 7 6 10 8 9 11 2 3 10 5 3 9 10 5 10 8 8 5 7 8 2 5 3 9 9 2 7 8 1 10 4 9 2 8 10 19 5 8 5 1 7 3 4 5 2 5 9 3 2 5 6 2 3 10 1 5 9 6 10 4 10 8\n", "output": "383\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": "A word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices.\n\nYou are given a string consisting of lowercase and uppercase Latin le...
[{"input": "100\nmKtsiDRJypUieHIkvJaMFkwaKxcCIbBszZQLIyPpCDCjhNpAnYFngLjRpnKWpKWtGnwoSteeZXuFHWQxxxOpFlNeYTwKocsXuCoa\n", "output": "YES\n"}, {"input": "100\nmKtsiDRJypUieHIkvJaMFkwaKxcCIbBszZQLIyPpCDCjhNpAnYFngLjRpnKWpKWtGnwoSteeZXuFHWQxxxOpFlNeYTwKocsXuCoa\n", "output": "YES\n"}, {"input": "100\naoCuXscoKwTYeNlFpOxxx...
code_stdio
[ { "content": "Smart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One of his favorite warm-up exercises is throwing balls. Students line up. Each one gets a single ...
[{"input": "200\n1 2 1 1 2 2 1 1 1 1 1 1 2 1 2 2 2 2 2 1 2 2 1 1 2 2 2 2 2 1 2 1 1 2 2 2 1 2 2 2 1 1 2 2 2 1 2 2 1 2 1 2 2 1 2 2 2 2 2 1 2 2 1 2 1 1 2 2 2 2 2 2 2 1 2 2 2 1 1 2 2 2 2 1 1 2 2 1 1 1 2 2 1 1 2 2 1 1 2 2 2 1 2 2 2 1 2 1 2 2 2 2 2 2 2 1 1 1 2 2 2 2 1 2 2 2 1 1 2 2 2 2 2 1 2 1 2 1 1 1 2 2 2 1 2 1 2 2 1 2 2 1...
code_stdio
[ { "content": "Where do odds begin, and where do they end? Where does hope emerge, and will they ever break?\n\nGiven an integer sequence a_1, a_2, ..., a_{n} of length n. Decide whether it is possible to divide it into an odd number of non-empty subsegments, the each of which has an odd length and begins and en...
[{"input": "100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100...
code_stdio
[ { "content": "The campus has $m$ rooms numbered from $0$ to $m - 1$. Also the $x$-mouse lives in the campus. The $x$-mouse is not just a mouse: each second $x$-mouse moves from room $i$ to the room $i \\cdot x \\mod{m}$ (in fact, it teleports from one room to another since it doesn't visit any intermediate room...
[{"input": "100000000000000 99999999999999\n", "output": "50000000000001\n"}, {"input": "100000000000000 99999999999999\n", "output": "50000000000001\n"}, {"input": "97821761637600 97821761637493\n", "output": "11943039006\n"}, {"input": "97821761637600 97821761637493\n", "output": "11943039006\n"}, {"input": "97821761...
code_stdio
[ { "content": "You decide to develop a game with your friends. The title of the game is \"Battle Town\". This is a game with the theme of urban warfare with tanks. As the first step in game development, we decided to develop the following prototype.\n\nIn this prototype, the only tanks that appear are the player...
[{"input": "4\n4 6\n*.*..*\n*.....\n...-..\n^.*#..\n10\nSRSSRRUSSR\n2 2\n<.\n..\n12\nDDSRRSUUSLLS\n3 5\n>-#**\n.-*#*\n.-**#\n15\nSSSDRSSSDRSSSUU\n5 5\nv****\n*****\n*****\n*****\n*****\n44\nSSSSDDRSDRSRDSULUURSSSSRRRRDSSSSDDLSDLSDLSSD", "output": "*....*\n......\n..>-..\n...#..\n\n<.\n..\n\n^-#**\n.-.#*\n.-..#\n\n........
code_stdio
[ { "content": "Two participants are each given a pair of distinct numbers from 1 to 9 such that there's exactly one number that is present in both pairs. They want to figure out the number that matches by using a communication channel you have access to without revealing it to you.\n\nBoth participants communica...
[{"input": "12 12\n1 6 2 6 8 3 6 4 4 8 7 2 7 5 9 4 2 4 9 5 8 5 3 6\n2 8 6 15 2 6 7 4 6 5 6 3 5 8 7 8 7 1 1 9 9 7 7 3\n", "output": "-1\n"}, {"input": "12 12\n7 6 3 8 8 4 4 7 1 9 9 5 7 5 4 9 8 6 2 7 7 3 3 6\n9 1 2 4 9 8 5 3 6 7 3 8 2 7 5 9 6 4 3 1 2 6 1 4\n", "output": "-1\n"}, {"input": "12 12\n1 6 2 6 8 3 6 4 4 8 7 2 ...
code_stdio
[ { "content": "There are two rectangles.\nThe lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B.\nThe lengths of the vertical sides of the second rectangle are C, and the lengths of the horizontal sides of the second rectangle are D.\...
[{"input": "100 600 200 300\n", "output": "60000\n"}, {"input": "100 600 200 300", "output": "60000"}, {"input": "100 600 200 6", "output": "60000\n"}, {"input": "100 480 244 6", "output": "48000\n"}, {"input": "100 169 362 6", "output": "16900\n"}, {"input": "100 311 362 6", "output": "31100\n"}, {"input": "110 222 18...
code_stdio
[ { "content": "There is a grid with N rows and N columns of squares. Let (i,j) be the square at the i-th row from the top and the j-th column from the left.\nThese squares have to be painted in one of the C colors from Color 1 to Color C. Initially, (i,j) is painted in Color c_{i,j}.\nWe say the grid is a good g...
[{"input": "153 17\n0 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1 1 1 1000 1000\n1000 0 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1 1 1 1000 1000\n1000 1000 0 1000 1000 1000 1000 1000 1000 1000 1000 1000 1 1 1 1000 1000\n1000 1000 1000 0 1000 1000 1000 1000 1000 1000 1000 1000 1 1 1 1000 1000\n1000...
code_stdio
[ { "content": "There is a directed graph G with N vertices and M edges. The vertices are numbered 1, 2, \\ldots, N, and for each i (1 \\leq i \\leq M), the i-th directed edge goes from Vertex x_i to y_i. G does not contain directed cycles.\n\nFind the length of the longest directed path in G. Here, the length of...
[{"input": "5 8\n5 3\n2 3\n2 4\n5 2\n5 1\n1 4\n4 3\n1 3", "output": "3"}, {"input": "4 -1\n2 2\n1 0\n3 2\n2 6\n11 8", "output": "0\n"}, {"input": "4 -1\n2 2\n1 0\n3 2\n2 5\n11 8", "output": "0\n"}, {"input": "8 -1\n2 2\n1 0\n3 2\n2 5\n11 8", "output": "0\n"}, {"input": "4 0\n2 2\n1 0\n3 2\n2 6\n11 8", "output": "0\n"},...
code_stdio
[ { "content": "There is a set A = \\\\{ a_1, a_2, \\ldots, a_N \\\\} consisting of N positive integers. Taro and Jiro will play the following game against each other.\n\nInitially, we have a pile consisting of K stones. The two players perform the following operation alternately, starting from Taro:\n\n* Choose ...
[{"input": "-1 100000\n1", "output": "Second\n"}, {"input": "1 100000\n2", "output": "Second\n"}, {"input": "1 100000\n4", "output": "Second\n"}, {"input": "3 36\n1 1 3", "output": "Second\n"}, {"input": "0 100000\n1", "output": "Second\n"}, {"input": "3 21\n2 1 4", "output": "Second\n"}, {"input": "1 100010\n1", "outp...
code_stdio
[ { "content": "This is the easy version of the problem. The only difference is that in this version q = 1. You can make hacks only if both versions of the problem are solved.\n\nThere is a process that takes place on arrays a and b of length n and length n-1 respectively. \n\nThe process is an infinite sequence ...
[{"input": "100\n45 21 34 56 15 0 46 59 40 39 78 83 29 77 19 30 60 39 90 64 11 47 10 47 35 79 30 13 21 31 26 68 0 67 52 43 29 94 100 76 16 61 74 34 62 63 4 41 78 31 77 21 90 2 43 70 53 15 53 29 47 87 33 20 23 30 55 57 13 25 19 89 10 17 92 24 47 6 4 91 52 9 11 25 81 14 82 75 46 49 66 62 28 84 88 57 0 19 34 94\n0 0 0 0 0...
code_stdio
[ { "content": "Blackjack is a type of card game played in casinos, where the game is played using cards with numbers from 1 to 13. The score of each card is decided as follows.\n\n* 1 is 1 point or 11 points\n* From 2 to 9, the score is as written.\n* 10 points from 10 to 13\n\n\n\nThere are several participants...
[{"input": "1\n3 7 4\n13 7 13\n10 2\n10 1 1\n0", "output": "11\n14\n0\n12\n12\n"}, {"input": "1\n11 3 4\n1 7 8\n2 1\n10 3 1\n0", "output": "11\n17\n16\n13\n14\n"}, {"input": "1\n7 7 3\n11 10 8\n8 1\n10 2 1\n0", "output": "11\n17\n0\n19\n13\n"}, {"input": "1\n7 7 4\n11 10 8\n1 1\n10 2 1\n0", "output": "11\n18\n0\n12\n13...
code_stdio
[ { "content": "A new innovative ticketing systems for public transport is introduced in Bytesburg. Now there is a single travel card for all transport. To make a trip a passenger scan his card and then he is charged according to the fare.\n\nThe fare is constructed in the following manner. There are three types ...
[{"input": "10\n13\n45\n46\n60\n103\n115\n126\n150\n256\n516\n", "output": "20\n20\n10\n0\n20\n0\n0\n20\n20\n10\n"}, {"input": "7\n000\n138\n279\n308\n381\n718\n1185\n", "output": "20\n20\n20\n20\n20\n20\n0\n"}, {"input": "7\n100\n138\n279\n308\n396\n412\n1265\n", "output": "20\n20\n20\n20\n20\n20\n0\n"}, {"input": "7\...
code_stdio
[ { "content": "Little Vasya's uncle is a postman. The post offices are located on one circular road. Besides, each post office has its own gas station located next to it. Petya's uncle works as follows: in the morning he should leave the house and go to some post office. In the office he receives a portion of le...
[{"input": "20\n10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10\n10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10\n", "output": "20\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \n"}, {"input": "20\n31 16 20 30 19 35 8 11 20 45 10 26 21 39 29 52 8 10 37 49\n16 33 41 32 43 24 35 48 19 37 28 ...
code_stdio
[ { "content": "Create a function that takes a string and an integer (`n`).\n\nThe function should return a string that repeats the input string `n` number of times.\n\nIf anything other than a string is passed in you should return `\"Not a string\"`\n\n\n## Example\n\n```\n\"Hi\", 2 --> \"HiHi\"\n1234, 5 --> \"N...
[{"input": "\"243624\"\n22", "output": "[\"243624243624243624243624243624243624243624243624243624243624243624243624243624243624243624243624243624243624243624243624243624243624\"]", "fn_name": "repeat_it"}, {"input": "\"Hello\"\n11", "output": "[\"HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello\"]", "fn_name": "...
code_functional
[ { "content": "Little Petya loves presents. His mum bought him two strings of the same size for his birthday. The strings consist of uppercase and lowercase Latin letters. Now Petya wants to compare those two strings lexicographically. The letters' case does not matter, that is an uppercase letter is considered ...
[{"input": "AanbDfbZNlUodtBQlvPMyomStKNhgvSGhSbTdabxGFGGXCdpsJDimsAykKjfBDPMulkhBMsqLmVKLDoesHZsRAEEdEzqigueXInY\ncwfyjoppiJNrjrOLNZkqcGimrpTsiyFBVgMWEPXsMrxLJDDbtYzerXiFGuLBcQYitLdqhGHBpdjRnkUegmnwhGHAKXGyFtscWDSI\n", "output": "-1\n"}, {"input": "sSvpcITJAwghVfJaLKBmyjOkhltTGjYJVLWCYMFUomiJaKQYhXTajvZVHIMHbyckYROGQZz...
code_stdio
[ { "content": "Alice and Bob play a game. They have a binary string $s$ (a string such that each character in it is either $0$ or $1$). Alice moves first, then Bob, then Alice again, and so on.\n\nDuring their move, the player can choose any number (not less than one) of consecutive equal characters in $s$ and d...
[{"input": "5\n01111001\n0000\n111111\n101010101\n011011110111\n", "output": "4\n0\n6\n3\n6\n"}, {"input": "5\n01111101\n0000\n111111\n101010101\n011011110111\n", "output": "5\n0\n6\n3\n6\n"}, {"input": "5\n01111101\n0000\n111111\n101010101\n011001110111\n", "output": "5\n0\n6\n3\n5\n"}, {"input": "5\n01111101\n0000\n1...
code_stdio
[ { "content": "'Jeopardy!' is an intellectual game where players answer questions and earn points. Company Q conducts a simplified 'Jeopardy!' tournament among the best IT companies. By a lucky coincidence, the old rivals made it to the finals: company R1 and company R2. \n\nThe finals will have n questions, m o...
[{"input": "50 30\n6015200 8643865 4116771 6555197 304415 8580071 8414182 3089212 5684567 7595481 1272699 7127763 3309618 1410297 4349070 2027355 136702 6863504 1800751 5585842 5924142 5188269 4805201 9313209 8941399 5137060 4983630 8467668 1646260 7804684 8646497 7067118 6896291 9109696 6197162 1366002 1703718 3852639...
code_stdio
[ { "content": "You are given a text consisting of $n$ space-separated words. There is exactly one space character between any pair of adjacent words. There are no spaces before the first word and no spaces after the last word. The length of text is the number of letters and spaces in it. $w_i$ is the $i$-th word...
[{"input": "250\nf r s d b f f k d e k v m b t k k j t t a o m m s n d w l v g e k x d w k v a j h c a g x s d e t z z w q z d h n r i k b z k u s q l k c v o d o w w c y i a q v r i g i m l b x z h t a i j t h q u e v j o h w m o v k g r r x j a c m z z i s i r a p p i i l e i g m f f f y v k m c l p n n n j j u t t q...
code_stdio
[ { "content": "Polycarp was gifted an array $a$ of length $n$. Polycarp considers an array beautiful if there exists a number $C$, such that each number in the array occurs either zero or $C$ times. Polycarp wants to remove some elements from the array $a$ to make it beautiful.\n\nFor example, if $n=6$ and $a = ...
[{"input": "1\n36\n1 2 2 3 3 11 14 4 4 10 5 5 6 8 6 10 7 2 7 7 13 8 8 15 9 9 9 9 10 17 10 10 12 12 12 19\n", "output": "16\n"}, {"input": "1\n36\n1 2 2 3 2 38 14 4 1 10 5 2 2 8 6 6 16 4 7 7 13 8 5 9 9 2 2 9 10 17 10 10 24 12 29 37\n", "output": "17\n"}, {"input": "1\n36\n1 2 2 3 2 21 14 4 4 10 5 5 6 8 12 6 8 2 7 7 13 8...
code_stdio
[ { "content": "You have a string $s$ consisting of $n$ characters. Each character is either 0 or 1.\n\nYou can perform operations on the string. Each operation consists of two steps: select an integer $i$ from $1$ to the length of the string $s$, then delete the character $s_i$ (the string length gets reduced b...
[{"input": "5\n6\n111010\n1\n0\n1\n1\n2\n11\n6\n101010\n", "output": "3\n1\n1\n1\n3\n"}, {"input": "5\n6\n111010\n1\n1\n1\n1\n2\n11\n6\n101010\n", "output": "3\n1\n1\n1\n3\n"}, {"input": "5\n6\n111000\n1\n1\n1\n1\n2\n11\n6\n101010\n", "output": "2\n1\n1\n1\n3\n"}, {"input": "5\n6\n011011\n1\n0\n1\n1\n2\n11\n6\n111000\n...
code_stdio
[ { "content": "Draw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'.\n\nConstraints\n\n* 1 ≤ H ≤ 300\n* 1 ≤ W ≤ 300\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with t...
[{"input": "8 2\n5 22\n4 -2\n0 0", "output": "##\n##\n##\n##\n##\n##\n##\n##\n\n######################\n######################\n######################\n######################\n######################\n\n\n\n\n\n\n"}, {"input": "3 4\n15 6\n2 4\n0 0", "output": "####\n####\n####\n\n######\n######\n######\n######\n######\n...
code_stdio
[ { "content": "You are given an undirected graph consisting of $n$ vertices and $n$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.\n\nYour task is to calculate the number of si...
[{"input": "3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3\n", "output": "\n6\n11\n18\n"}, {"input": "3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3\n", "output": "6\n11\n18\n"}, {"input": "3\n3\n1 2\n2 3\n1 3\n4\n1 4\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3\n", "output...
code_stdio
[ { "content": "Chef loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nChef has a positive integer N. He can apply any of the following operations a...
[{"input": "3\n25\n46\n102", "output": "2\n1\n3\n"}, {"input": "3\n103\n46\n32", "output": "3\n1\n2\n"}, {"input": "3\n15\n162\n19", "output": "2\n3\n2\n"}, {"input": "3\n15\n162\n17", "output": "2\n3\n1\n"}, {"input": "3\n61\n65\n010", "output": "2\n2\n3\n"}, {"input": "3\n2\n110\n150", "output": "1\n3\n3\n"}, {"input...
code_stdio
[ { "content": "G: Tree\n\nproblem\n\nGiven a tree consisting of N vertices. Each vertex of the tree is numbered from 1 to N. Of the N-1 edges, the i \\ (= 1, 2, ..., N-1) edge connects the vertex u_i and the vertex v_i.\n\nWrite a program to find the number of K non-empty subgraph sets of this tree, each of whic...
[{"input": "1 2\n2 3\n-1 3", "output": "0\n"}, {"input": "1 2\n4 3\n-1 3", "output": "0\n"}, {"input": "1 4\n-1 2\n1 2", "output": "0\n"}, {"input": "1 1\n3 0\n-1 5", "output": "1\n"}, {"input": "1 1\n3 0\n-1 2", "output": "1\n"}, {"input": "1 1\n3 0\n-1 0", "output": "1\n"}, {"input": "1 2\n2 3\n-1 2", "output": "0\n"...
code_stdio
[ { "content": "Polycarp has an integer $n$ that doesn't contain the digit 0. He can do the following operation with his number several (possibly zero) times:\n\nReverse the prefix of length $l$ (in other words, $l$ leftmost digits) of $n$. So, the leftmost digit is swapped with the $l$-th digit from the left, th...
[{"input": "4\n3876\n387\n4489\n3\n", "output": "0\n2\n1\n-1\n"}, {"input": "1\n77771449\n", "output": "2\n"}, {"input": "1\n841419\n", "output": "1\n"}, {"input": "1\n21328\n", "output": "0\n"}, {"input": "1\n87454\n", "output": "0\n"}, {"input": "1\n77778\n", "output": "0\n"}, {"input": "1\n77774\n", "output": "0\n"}...
code_stdio