messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "There are N cities and M roads.\nThe i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally.\nThere may be more than one road that connects the same pair of two cities.\nFor each city, how many roads are connected to the city?\n\n-----Constraints-----\n - 2≤N,M≤50\n - 1≤a_...
[{"input": "17 1\n2 8\n3 4\n1 5\n2 8\n4 7\n8 2\n4 1\n0 14", "output": "0\n1\n0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n0\n0\n0\n0\n0\n"}, {"input": "13 7\n2 4\n3 4\n1 5\n2 8\n3 7\n5 2\n4 1\n6 8", "output": "2\n3\n2\n3\n2\n0\n1\n1\n0\n0\n0\n0\n0\n"}, {"input": "13 7\n2 4\n3 4\n1 6\n2 8\n3 7\n5 2\n4 1\n6 8", "output": "2\n3\n2\n3\n1...
code_stdio
[ { "content": "Naturally, the magical girl is very good at performing magic. She recently met her master wizard Devu, who gifted her R potions of red liquid, \nB potions of blue liquid, and G potions of green liquid.\n\n- \nThe red liquid potions have liquid amounts given by r[1], ..., r[R] liters. \n\n- \nThe g...
[{"input": "3\n0 0 0 1\n2\n0\n0\n0 -1 -1 0\n3\n4\n-1\n3 1 2 1\n2 1 0\n1 12\n0 15", "output": "1\n4\n12\n"}, {"input": "3\n0 0 0 1\n2\n0\n0\n0 -1 -1 0\n3\n5\n-1\n3 1 2 1\n2 1 0\n1 12\n0 15", "output": "1\n5\n12\n"}, {"input": "3\n0 0 1 0\n1\n0\n0\n2 -1 1 0\n3\n4\n2\n6 2 2 0\n2 1 3\n1 7\n9 15", "output": "1\n4\n15\n"}, {...
code_stdio
[ { "content": "There are N towns numbered 1, 2, \\cdots, N.\n\nSome roads are planned to be built so that each of them connects two distinct towns bidirectionally. Currently, there are no roads connecting towns.\n\nIn the planning of construction, each town chooses one town different from itself and requests the...
[{"input": "10\n2 10 9 -1 6 10 -1 -1 -1 -1", "output": "522237\n"}, {"input": "10\n2 8 9 -1 6 10 -1 -1 -1 -1", "output": "515457\n"}, {"input": "10\n1 9 9 -1 6 10 -1 -1 -1 -1", "output": "473877\n"}, {"input": "10\n4 2 6 -1 10 7 -1 -1 -1 -1", "output": "471888\n"}, {"input": "10\n2 6 9 -1 10 2 -1 -1 -1 -1", "output": "...
code_stdio
[ { "content": "Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task.\n\nTwo matrices $A$ and $B$ are given, each of them has size $n \\times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take an...
[{"input": "4 9\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n", "output": "YES\n"}, {"input": "4 9\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1...
code_stdio
[ { "content": "For an array of non-negative integers $a$ of size $n$, we construct another array $d$ as follows: $d_1 = a_1$, $d_i = |a_i - a_{i - 1}|$ for $2 \\le i \\le n$.\n\nYour task is to restore the array $a$ from a given array $d$, or to report that there are multiple possible arrays.\n\n\n-----Input----...
[{"input": "69\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1...
code_stdio
[ { "content": "Given an integer a as input, print the value a + a^2 + a^3.\n\n-----Constraints-----\n - 1 \\leq a \\leq 10\n - a is an integer.\n\n-----Input-----\nInput is given from Standard Input in the following format:\na\n\n-----Output-----\nPrint the value a + a^2 + a^3 as an integer.\n\n-----Sample Input...
[{"input": "1109", "output": "1365169019\n"}, {"input": "488", "output": "116452904\n"}, {"input": "762", "output": "443032134\n"}, {"input": "767", "output": "451806719\n"}, {"input": "853", "output": "621378939\n"}, {"input": "916", "output": "769415268\n"}, {"input": "249", "output": "15500499\n"}, {"input": "367", ...
code_stdio
[ { "content": "The only difference between easy and hard versions is the size of the input.\n\nYou are given a string $s$ consisting of $n$ characters, each character is 'R', 'G' or 'B'.\n\nYou are also given an integer $k$. Your task is to change the minimum number of characters in the initial string $s$ so tha...
[{"input": "3\n5 2\nBGGGG\n5 3\nRBRGR\n5 5\nBBBRR\n", "output": "1\n0\n3\n"}, {"input": "3\n5 2\nGGBGG\n5 3\nRBRGR\n5 5\nBBBRR\n", "output": "0\n0\n3\n"}, {"input": "3\n5 2\nBGGGG\n5 1\nRBRGR\n5 5\nBBBRR\n", "output": "1\n0\n3\n"}, {"input": "3\n5 2\nBGGGG\n5 2\nRRBGR\n5 5\nBBBRR\n", "output": "1\n1\n3\n"}, {"input": "...
code_stdio
[ { "content": "Nearly each project of the F company has a whole team of developers working on it. They often are in different rooms of the office in different cities and even countries. To keep in touch and track the results of the project, the F company conducts shared online meetings in a Spyke chat.\n\nOne da...
[{"input": "110 5\n- 60\n- 58\n+ 25\n- 32\n+ 86\n", "output": "105\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 27 28 29 30 31 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 59 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 87 88 89 90 91 92 ...
code_stdio
[ { "content": "Little Susie loves strings. Today she calculates distances between them. As Susie is a small girl after all, her strings contain only digits zero and one. She uses the definition of Hamming distance:\n\nWe will define the distance between two strings s and t of the same length consisting of digits...
[{"input": "00001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n1111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
code_stdio
[ { "content": "Section numbers are strings of dot-separated integers. The highest level sections (chapters) are numbered 1, 2, 3, etc. Second level sections are numbered 1.1, 1.2, 1.3, 2.1, 2.2, 2.3, etc. Next level sections are numbered 1.1.1, 1.1.2, 1.1.2, 1.2.1, 1.2.2, erc. There is no bound on the number of ...
[{"input": "\"1.2.3.4\"\n\"1.2.3.4\"", "output": "[0]", "fn_name": "compare"}, {"input": "\"1.2.3\"\n\"1.02.003\"", "output": "[0]", "fn_name": "compare"}, {"input": "\"3.0.0\"\n\"3.1.1\"", "output": "[-1]", "fn_name": "compare"}, {"input": "\"1.2.1\"\n\"1.2.0\"", "output": "[1]", "fn_name": "compare"}, {"input": "\"3....
code_functional
[ { "content": "You are given an array $a$ consisting of $n$ integers.\n\nYou can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$.\n\nYour task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array.\n\nReca...
[{"input": "12\n123654 1 2 3 4 5 6 7 16 9 10 11\n", "output": "10\n"}, {"input": "12\n123654 1 2 3 4 5 6 7 8 9 10 11\n", "output": "11\n"}, {"input": "12\n123654 1 2 6 4 5 6 7 16 9 10 11\n", "output": "7\n"}, {"input": "12\n123654 1 2 6 4 5 6 7 16 9 18 11\n", "output": "7\n"}, {"input": "12\n123654 1 2 6 4 5 6 9 16 9 1...
code_stdio
[ { "content": "For a non-negative integer K, we define a fractal of level K as follows:\n\n* A fractal of level 0 is a grid with just one white square.\n* When K > 0, a fractal of level K is a 3^K \\times 3^K grid. If we divide this grid into nine 3^{K-1} \\times 3^{K-1} subgrids:\n* The central subgrid consists...
[{"input": "2\n3 2 7 8\n12 3 1 15", "output": "10\n23\n"}, {"input": "2\n0 2 7 8\n12 3 1 15", "output": "13\n23\n"}, {"input": "2\n0 2 10 8\n6 3 1 15", "output": "16\n17\n"}, {"input": "2\n15 2 4 4\n7 6 1 26", "output": "13\n26\n"}, {"input": "2\n2 14 2 4\n13 3 2 5", "output": "12\n13\n"}, {"input": "2\n3 2 7 8\n7 3 1 ...
code_stdio
[ { "content": "We saw the little game Marmot made for Mole's lunch. Now it's Marmot's dinner time and, as we all know, Marmot eats flowers. At every dinner he eats some red and white flowers. Therefore a dinner can be represented as a sequence of several flowers, some of them white and some of them red.\n\nBut, ...
[{"input": "3 1\n1 3\n2 3\n4 10\n", "output": "14\n12\n2032\n"}, {"input": "3 1\n1 3\n2 3\n4 6\n", "output": "14\n12\n112\n"}, {"input": "3 1\n2 6\n1 3\n4 4\n", "output": "124\n14\n16\n"}, {"input": "3 1\n1 3\n2 5\n1 6\n", "output": "14\n60\n126\n"}, {"input": "3 1\n1 3\n2 3\n4 4\n", "output": "14\n12\n16\n"}, {"input"...
code_stdio
[ { "content": "## Task:\nYou have to create a function `isPronic` to check whether the argument passed is a Pronic Number and return true if it is & false otherwise.\n\n### Description:\n\n`Pronic Number` -A pronic number, oblong number, rectangular number or heteromecic number, is a number which is the product ...
[{"input": "-27", "output": "[false]", "fn_name": "is_pronic"}, {"input": "-3", "output": "[false]", "fn_name": "is_pronic"}, {"input": "3", "output": "[false]", "fn_name": "is_pronic"}, {"input": "4", "output": "[false]", "fn_name": "is_pronic"}, {"input": "5", "output": "[false]", "fn_name": "is_pronic"}, {"input": "...
code_functional
[ { "content": "What are you doing at the end of the world? Are you busy? Will you save us?\n\n<image>\n\nNephren is playing a game with little leprechauns.\n\nShe gives them an infinite array of strings, f0... ∞.\n\nf0 is \"What are you doing at the end of the world? Are you busy? Will you save us?\".\n\nShe wan...
[{"input": "10\n100000 873326525630182716\n100000 620513733919162415\n100000 482953375281256917\n100000 485328193417229962\n100000 353549227094721271\n100000 367447590857326107\n100000 627193846053528323\n100000 243833127760837417\n100000 287297493528203749\n100000 70867563577617188\n", "output": "o W rlot"}, {"input...
code_stdio
[ { "content": "A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward. Examples of numerical palindromes are:\n\n2332 \n110011 \n54322345\n\nYou'll be given 2 numbers as arguments: ```(num,s)```. Write a function which returns an array of ```s``` number ...
[{"input": "\"ACCDDCCA\"\n3", "output": "[\"Not valid\"]", "fn_name": "palindrome"}, {"input": "773\n\"1551\"", "output": "[\"Not valid\"]", "fn_name": "palindrome"}, {"input": "6\n4", "output": "[[11, 22, 33, 44]]", "fn_name": "palindrome"}, {"input": "-4505\n15", "output": "[\"Not valid\"]", "fn_name": "palindrome"},...
code_functional
[ { "content": "< PREVIOUS KATA\nNEXT KATA >\n \n###Task:\n\nYou have to write a function `pattern` which returns the following Pattern(See Examples) upto (3n-2) rows, where n is parameter.\n\n* Note:`Returning` the pattern is not the same as `Printing` the pattern.\n\n####Rules/Note:\n* The pattern should be cre...
[{"input": "5", "output": "[\" 11111 \\n 22222 \\n 33333 \\n 44444 \\n1234555554321\\n1234555554321\\n1234555554321\\n1234555554321\\n1234555554321\\n 44444 \\n 33333 \\n 22222 \\n 11111 \"]", "fn_name": "pattern"}, {"input": "3", "output": "[\" 111 \\n 222 \\n1233321...
code_functional
[ { "content": "The cows have just learned what a primitive root is! Given a prime p, a primitive root $\\operatorname{mod} p$ is an integer x (1 ≤ x < p) such that none of integers x - 1, x^2 - 1, ..., x^{p} - 2 - 1 are divisible by p, but x^{p} - 1 - 1 is. \n\nUnfortunately, computing primitive roots can be tim...
[{"input": "1583\n", "output": "672\n"}, {"input": "1987\n", "output": "660\n"}, {"input": "1993\n", "output": "656\n"}, {"input": "1997\n", "output": "996\n"}, {"input": "1999\n", "output": "648\n"}, {"input": "1297\n", "output": "432\n"}, {"input": "1259\n", "output": "576\n"}, {"input": "1949\n", "output": "972\n"},...
code_stdio
[ { "content": "Problem Statement\n\nIn the headquarter building of ICPC (International Company of Plugs & Connectors), there are $M$ light bulbs and they are controlled by $N$ switches. Each light bulb can be turned on or off by exactly one switch. Each switch may control multiple light bulbs. When you operate a...
[{"input": "3 10 3\n000 0000000000\n110 0000001011\n101 1111111100\n2 6 0\n1 2 0\n2 1 1\n01 1\n11 11 10\n10000000000 10000000000\n11000000000 00000000000\n01100000000 00100000000\n00110000000 00010000000\n00011000000 00001000000\n00001100000 00000100000\n01000110000 00000010000\n00000011000 00000001000\n00000001100 000...
code_stdio
[ { "content": "Polycarp wants to train before another programming competition. During the first day of his training he should solve exactly $1$ problem, during the second day — exactly $2$ problems, during the third day — exactly $3$ problems, and so on. During the $k$-th day he should solve $k$ problems.\n\nPol...
[{"input": "5\n200000 200000 200000 200000 200000\n", "output": "5\n"}, {"input": "5\n200000 200000 200000 200000 200000\n", "output": "5\n"}, {"input": "5\n200000 200000 200000 200000 329398\n", "output": "5\n"}, {"input": "5\n330358 200000 200000 200000 200000\n", "output": "5\n"}, {"input": "5\n200000 201888 200000 ...
code_stdio
[ { "content": "We have a string S consisting of lowercase English letters.\nIf the length of S is at most K, print S without change.\nIf the length of S exceeds K, extract the first K characters in S, append ... to the end of them, and print the result.\n\n-----Constraints-----\n - K is an integer between 1 and ...
[{"input": "99\nlbyhybgfptdyuqnlszvxoggbjhrjopbevyrzytfhiabtoozntnxxcvmhckjlwxnzniwzzxzvmfiztyirssfeauzncyosgrmsgull\n", "output": "lbyhybgfptdyuqnlszvxoggbjhrjopbevyrzytfhiabtoozntnxxcvmhckjlwxnzniwzzxzvmfiztyirssfeauzncyosgrmsgul...\n"}, {"input": "100\nvefcekrnrodmjprtifxrvjtjgzvuidhbtadwuqxctuwqfxhiuuupmsggdrmpswcq...
code_stdio
[ { "content": "You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side.\n\nUnfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level u...
[{"input": "6\n2 3\n0 0\n2 3\n0 3\n2 3\n3 0\n3 3\n4 0 4\n3 3\n4 0 5\n3 3\n5 0 4\n", "output": "YES\nNO\nNO\nYES\nNO\nNO\n"}, {"input": "6\n2 3\n0 0\n2 3\n0 3\n2 3\n3 0\n3 3\n4 0 4\n3 3\n4 0 5\n3 3\n5 0 4\n", "output": "YES\nNO\nNO\nYES\nNO\nNO\n"}, {"input": "6\n2 3\n0 0\n2 3\n0 3\n2 3\n3 0\n3 3\n4 0 4\n3 3\n4 0 5\n3 3...
code_stdio
[ { "content": "## Task\nTo charge your mobile phone battery, do you know how much time it takes from 0% to 100%? It depends on your cell phone battery capacity and the power of the charger. A rough calculation method is:\n\n```\n0% --> 85% (fast charge)\n(battery capacity(mAh) * 85%) / power of the charger(mA)\...
[{"input": "1000\n5000", "output": "[0.26]", "fn_name": "calculate_time"}, {"input": "3050\n2600", "output": "[1.53]", "fn_name": "calculate_time"}, {"input": "2000\n1000", "output": "[2.6]", "fn_name": "calculate_time"}, {"input": "5000\n1000", "output": "[6.5]", "fn_name": "calculate_time"}, {"input": "1000\n500", "o...
code_functional
[ { "content": "Kavi has 2n points lying on the OX axis, i-th of which is located at x = i.\n\nKavi considers all ways to split these 2n points into n pairs. Among those, he is interested in good pairings, which are defined as follows:\n\nConsider n segments with ends at the points in correspondent pairs. The pai...
[{"input": "1000000\n", "output": "126330412"}, {"input": "372544\n", "output": "214345447\n"}, {"input": "315936\n", "output": "256195953\n"}, {"input": "446167\n", "output": "461428149\n"}, {"input": "797112\n", "output": "121466915\n"}, {"input": "119444\n", "output": "553363384\n"}, {"input": "916542\n", "output": ...
code_stdio
[ { "content": "You are given an array of integers. Vasya can permute (change order) its integers. He wants to do it so that as many as possible integers will become on a place where a smaller integer used to stand. Help Vasya find the maximal number of such integers.\n\nFor instance, if we are given an array $[1...
[{"input": "6\n300000000 200000000 300000000 200000000 1000000000 300000000\n", "output": "3\n"}, {"input": "6\n300000000 200000000 300000000 200000000 1000000000 300000000\n", "output": "3\n"}, {"input": "6\n506233607 200000000 300000000 200000000 1000000000 300000000\n", "output": "4\n"}, {"input": "6\n144373768 2000...
code_stdio
[ { "content": "Have you ever tasted Martian food? Well, you should.\n\nTheir signature dish is served on a completely black plate with the radius of R, flat as a pancake.\n\nFirst, they put a perfectly circular portion of the Golden Honduras on the plate. It has the radius of r and is located as close to the edg...
[{"input": "2\n4 3 1\n5 2 2\n", "output": "0.9230769231\n0.6521739130\n"}, {"input": "2\n8 3 1\n4 2 2\n", "output": "2.4489795918\n0.6666666667\n"}, {"input": "2\n9 3 1\n4 2 2\n", "output": "2.5714285714\n0.6666666667\n"}, {"input": "2\n8 5 1\n4 2 2\n", "output": "2.4489795918\n0.6666666667\n"}, {"input": "2\n4 3 1\n4 ...
code_stdio
[ { "content": "Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white.\n\nConsider a set consisting of k (0 ≤ k < n) edges of Appleman's tree. If Appleman deletes these edges from the tree, then it will split into (k + 1) parts. Note, that ...
[{"input": "100\n0 0 2 2 0 3 5 0 6 2 0 4 0 2 3 7 8 3 15 19 13 8 18 19 3 14 23 9 6 3 6 17 26 24 20 4 4 27 8 5 14 5 35 31 27 3 41 25 20 14 25 31 49 40 0 1 10 5 50 13 29 58 1 6 8 1 40 52 30 15 50 8 66 52 29 71 25 68 36 12 80 60 6 2 11 43 62 27 84 86 71 38 14 50 88 4 8 95 53\n1 0 0 1 0 0 1 0 1 0 0 0 1 0 1 1 0 1 1 1 1 0 0 0...
code_stdio
[ { "content": "You are a given an array $a$ of length $n$. Find a subarray $a[l..r]$ with length at least $k$ with the largest median.\n\nA median in an array of length $n$ is an element which occupies position number $\\lfloor \\frac{n + 1}{2} \\rfloor$ after we sort the elements in non-decreasing order. For ex...
[{"input": "100 16\n14 94 97 89 73 165 11 78 10 30 54 57 88 57 44 6 33 40 17 26 69 100 92 67 22 59 80 67 17 29 76 69 133 7 86 45 1 98 99 25 65 102 94 91 7 24 53 40 53 91 59 32 67 24 25 157 55 46 68 53 2 15 92 5 53 37 76 40 49 94 4 8 76 12 50 2 54 86 49 95 81 5 34 28 21 47 97 73 96 56 32 78 71 38 49 24 64 78 35 18\n", "...
code_stdio
[ { "content": "Snuke lives at position x on a number line.\nOn this line, there are two stores A and B, respectively at position a and b, that offer food for delivery.\nSnuke decided to get food delivery from the closer of stores A and B.\nFind out which store is closer to Snuke's residence.\nHere, the distance ...
[{"input": "1 999 1000\n", "output": "A\n"}, {"input": "1 1455 0000", "output": "B\n"}, {"input": "1 1200 0101", "output": "B\n"}, {"input": "1 999 0000", "output": "B\n"}, {"input": "1 381 1110", "output": "A\n"}, {"input": "1 999 0100", "output": "B\n"}, {"input": "1 999 0101", "output": "B\n"}, {"input": "1 999 0001...
code_stdio
[ { "content": "### What is simplifying a square root?\n\nIf you have a number, like 80, for example, you would start by finding the greatest perfect square divisible by 80. In this case, that's 16. Find the square root of 16, and multiply it by 80 / 16. Answer = 4 √5. \n\n##### The above example:\n\n![simplify_r...
[{"input": "200", "output": "[\"10 sqrt 2\"]", "fn_name": "simplify"}, {"input": "18", "output": "[\"3 sqrt 2\"]", "fn_name": "simplify"}, {"input": "20", "output": "[\"2 sqrt 5\"]", "fn_name": "simplify"}, {"input": "24", "output": "[\"2 sqrt 6\"]", "fn_name": "simplify"}, {"input": "32", "output": "[\"4 sqrt 2\"]", "...
code_functional
[ { "content": "Simple transposition is a basic and simple cryptography technique. We make 2 rows and put first a letter in the Row 1, the second in the Row 2, third in Row 1 and so on until the end. Then we put the text from Row 2 next to the Row 1 text and thats it.\n\nComplete the function that receives a stri...
[{"input": "\"Imagination is more important than knowledge\"", "output": "[\"Iaiaini oeipratta nwegmgnto smr motn hnkolde\"]", "fn_name": "simple_transposition"}, {"input": "\"The better part of valor is discretion\"", "output": "[\"Tebte ato ao sdsrtoh etrpr fvlri icein\"]", "fn_name": "simple_transposition"}, {"input...
code_functional
[ { "content": "You have received data from a Bubble bot. You know your task is to make factory facilities, but before you even start, you need to know how big the factory is and how many rooms it has. When you look at the data you see that you have the dimensions of the construction, which is in rectangle shape:...
[{"input": "4 5\n9 14 11 12 13\n5 15 11 6 7\n5 8 14 9 14\n3 2 14 3 14\n", "output": "9 4 4 2 1 \n"}, {"input": "4 5\n9 14 9 12 13\n5 15 11 6 7\n5 9 14 9 14\n3 2 14 3 14\n", "output": "9 4 4 2 1 \n"}, {"input": "4 5\n9 14 11 12 13\n5 15 3 6 7\n5 9 14 9 14\n3 2 14 3 14\n", "output": "9 4 4 2 1 \n"}, {"input": "4 5\n9 14 ...
code_stdio
[ { "content": "Example\n\nInput\n\n2 2 2 1\n0 0 0\n\n\nOutput\n\n24\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your complete solution in a single ```python code block.", "role": "user" } ]
[{"input": "26 2 22 0\n-1 2 0", "output": "1336\n"}, {"input": "36 2 22 0\n-1 2 0", "output": "1816\n"}, {"input": "36 2 43 0\n-1 2 0", "output": "3412\n"}, {"input": "3 8 88 0\n-2 8 -1", "output": "1984\n"}, {"input": "3 9 88 0\n-2 8 -1", "output": "2166\n"}, {"input": "3 9 82 0\n-2 8 -1", "output": "2022\n"}, {"input...
code_stdio
[ { "content": "Recently Vova found $n$ candy wrappers. He remembers that he bought $x$ candies during the first day, $2x$ candies during the second day, $4x$ candies during the third day, $\\dots$, $2^{k-1} x$ candies during the $k$-th day. But there is an issue: Vova remembers neither $x$ nor $k$ but he is sure...
[{"input": "53\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n", "output": "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\...
code_stdio
[ { "content": "You are given a string of length N. Calculate the number of distinct substrings of S.\n\nConstraints\n\n* 1 \\leq N \\leq 500,000\n* S consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\n\nS\n\n\nOutput\n\nPrint the answer.\n\nExamples\...
[{"input": "mjssissippi", "output": "57\n"}, {"input": "mjssisrippi", "output": "61\n"}, {"input": "mjssisripph", "output": "62\n"}, {"input": "hppirsitsjm", "output": "63\n"}, {"input": "mjsthspiroh", "output": "64\n"}, {"input": "hnripohtqgm", "output": "65\n"}, {"input": "hppirsissjm", "output": "62\n"}, {"input": "...
code_stdio
[ { "content": "Snuke has decided to use a robot to clean his room.\n\nThere are N pieces of trash on a number line. The i-th piece from the left is at position x_i. We would like to put all of them in a trash bin at position 0.\n\nFor the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} \\leq 10^{9}...
[{"input": "16 10\n1 12 12 27 52 132 731 18298 395504 534840 1276551 903860 9384806 19108104 82684732 535447408", "output": "3248775590\n"}, {"input": "16 10\n0 12 12 27 52 132 731 18298 395504 534840 1276551 903860 9384806 19108104 82684732 535447408", "output": "3248775585\n"}, {"input": "16 10\n0 12 12 27 52 132 731...
code_stdio
[ { "content": "The winner of the card game popular in Berland \"Berlogging\" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one....
[{"input": "12\natrtthfpcvishmqbakprquvnejr 185\natrtthfpcvishmqbakprquvnejr -699\natrtthfpcvishmqbakprquvnejr -911\natrtthfpcvishmqbakprquvnejr -220\nfcgslzkicjrpbqaifgweyzreajjfdo 132\nfcgslzkicjrpbqaifgweyzreajjfdo -242\nm 177\nm -549\natrtthfpcvishmqbakprquvnejr -242\nm 38\natrtthfpcvishmqbakprquvnejr -761\nfcgslzk...
code_stdio
[ { "content": "Problem statement\n\n2D, who is good at cooking, is trying to make lunch. Cooking requires all N ingredients a_ {0}, a_ {1},…, a_ {N−1}.\n\nNow, 2D's refrigerator doesn't contain any ingredients, so I have to go to the supermarket to buy it. At the supermarket, you can buy the material a_ {i} for ...
[{"input": "2\npaks 0\naxii -1\n-1\nnkua hx`j", "output": "-1\n"}, {"input": "2\ntako -1\njiay -1\n0\npuja yakh", "output": "-2\n"}, {"input": "2\npaks -2\nayhi -1\n0\nmauk j`xh", "output": "-3\n"}, {"input": "2\npaks 1\naxii -1\n-3\nokua hx`j", "output": "0\n"}, {"input": "2\npaks 1\naxii -1\n-1\nokua hx`j", "output":...
code_stdio
[ { "content": "Your friend gave you a dequeue D as a birthday present.\nD is a horizontal cylinder that contains a row of N jewels.\nThe values of the jewels are V_1, V_2, ..., V_N from left to right. There may be jewels with negative values.\nIn the beginning, you have no jewel in your hands.\nYou can perform a...
[{"input": "50 100\n-10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 ...
code_stdio
[ { "content": "A permutation p of size n is an array such that every integer from 1 to n occurs exactly once in this array.\n\nLet's call a permutation an almost identity permutation iff there exist at least n - k indices i (1 ≤ i ≤ n) such that p_{i} = i.\n\nYour task is to count the number of almost identity p...
[{"input": "1000 4\n", "output": "373086956251\n"}, {"input": "1000 4\n", "output": "373086956251\n"}, {"input": "800 4\n", "output": "152620985001\n"}, {"input": "800 4\n", "output": "152620985001\n"}, {"input": "792 4\n", "output": "146597632567\n"}, {"input": "850 4\n", "output": "194577888126\n"}, {"input": "600 4\...
code_stdio
[ { "content": "problem\n\nYou are a traveler traveling on the JOI Highway. The JOI Highway is a road that extends straight from east to west, and there are n post towns on the JOI Highway. Numbered. The westernmost post town on the JOI highway is post town 1, and the easternmost post town is post town n.\n\nYou ...
[{"input": "7 5\n2\n0\n1\n1\n2\n-1\n2\n-1\n2\n2\n-3", "output": "10\n"}, {"input": "7 0\n1\n-1\n1\n3\n1\n-1\n3\n-2\n-1\n1\n0", "output": "0\n"}, {"input": "7 0\n1\n-1\n1\n2\n1\n-1\n3\n-2\n-1\n1\n0", "output": "0\n"}, {"input": "7 5\n2\n0\n1\n-1\n2\n-1\n2\n-1\n1\n2\n-3", "output": "2\n"}, {"input": "7 5\n4\n0\n1\n0\n2\n...
code_stdio
[ { "content": "Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nPetya calls a mask of a positive integer n the number that is obtained aft...
[{"input": "100000 77777\n", "output": "177777\n"}, {"input": "150234 77777\n", "output": "177777\n"}, {"input": "77777 77777\n", "output": "177777\n"}, {"input": "47774 47774\n", "output": "147774\n"}, {"input": "145251 7474\n", "output": "157474\n"}, {"input": "100832 7474\n", "output": "107474\n"}, {"input": "56081 ...
code_stdio
[ { "content": "You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters.\n\nA string X is called a good string when the following conditions are all met:\n\n* Let L be the length of X. L is divisible by both N and M.\n* Concatenating the 1-st, (\\f...
[{"input": "15 16\ndnausrayukusiia\ndujrunuma", "output": "240\n"}, {"input": "16 9\ndnsusrayukuaiia\ndujrunuma", "output": "144\n"}, {"input": "15 8\ndnausrayukusii`\ndujrunuma", "output": "120\n"}, {"input": "12 10\ndnsusrayukuaiia\nrujdunuma", "output": "-1\n"}, {"input": "12 10\ndnsussayukuaiia\nrujdunuma", "output...
code_stdio
[ { "content": "# Task\n You are given a string consisting of `\"D\", \"P\" and \"C\"`. A positive integer N is called DPC of this string if it satisfies the following properties: \n \n ```\n For each i = 1, 2, ... , size of the string:\n\n If i-th character is \"D\", then N can be divided by i\n If i-th characte...
[{"input": "\"DDDDPDDCCCDDPDCCPCDCDDPCPCCDDCD\"", "output": "[15782844]", "fn_name": "DPC_sequence"}, {"input": "\"DPCPDPPPDCPDPDPC\"", "output": "[-1]", "fn_name": "DPC_sequence"}, {"input": "\"DDDDDDPCCDPDPP\"", "output": "[-1]", "fn_name": "DPC_sequence"}, {"input": "\"DDDDDDCD\"", "output": "[-1]", "fn_name": "DPC_...
code_functional
[ { "content": "Kilani is playing a game with his friends. This game can be represented as a grid of size $n \\times m$, where each cell is either empty or blocked, and every player has one or more castles in some cells (there are no two castles in one cell).\n\nThe game is played in rounds. In each round players...
[{"input": "4 7 2\n13 1\n....###\n.#..1..\n.#.###.\n2#.....\n", "output": "18 1 \n"}, {"input": "4 7 2\n13 1\n###....\n..1..#.\n.###.#.\n.....#2\n", "output": "18 1 \n"}, {"input": "4 7 2\n13 1\n###....\n..1..#.\n.###.#.\n.....#2\n", "output": "18 1 \n"}, {"input": "4 7 2\n13 1\n....###\n.#..1..\n.#.###.\n2#.....\n", "...
code_stdio
[ { "content": "Our master carpenter is designing a condominium called Bange Hills Mansion. The condominium is constructed by stacking up floors of the same height. The height of each floor is designed so that the total height of the stacked floors coincides with the predetermined height of the condominium. The h...
[{"input": "000 12 208", "output": "197\n"}, {"input": "000 9 208", "output": "200\n"}, {"input": "000 4 120", "output": "117\n"}, {"input": "000 16 106", "output": "91\n"}, {"input": "000 26 106", "output": "81\n"}, {"input": "000 1 165", "output": "165\n"}, {"input": "000 1 120", "output": "120\n"}, {"input": "000 1 ...
code_stdio
[ { "content": "Vladik often travels by trains. He remembered some of his trips especially well and I would like to tell you about one of these trips:\n\nVladik is at initial train station, and now n people (including Vladik) want to get on the train. They are already lined up in some order, and for each of them ...
[{"input": "100\n931 4584 2116 3004 3813 62 2819 2998 2080 4906 3198 2443 2952 3793 1958 3864 3985 3169 3134 4011 4525 995 4163 308 4362 1148 4906 3092 1647 244 1370 1424 2753 84 2997 1197 2606 425 3501 2606 683 4747 3884 4787 2166 3017 3080 4303 3352 1667 2636 3994 757 2388 870 1788 988 1303 0 1230 1455 4213 2113 2908...
code_stdio
[ { "content": "The Smart Beaver from ABBYY decided to have a day off. But doing nothing the whole day turned out to be too boring, and he decided to play a game with pebbles. Initially, the Beaver has n pebbles. He arranges them in a equal rows, each row has b pebbles (a > 1). Note that the Beaver must use all t...
[{"input": "1000000000\n", "output": "1998535156\n"}, {"input": "999161856\n", "output": "1998319610\n"}, {"input": "999936000\n", "output": "1999743134\n"}, {"input": "999999948\n", "output": "1833697140\n"}, {"input": "999999000\n", "output": "1936337207\n"}, {"input": "999989760\n", "output": "1998828039\n"}, {"inpu...
code_stdio
[ { "content": "Our world is one-dimensional, and ruled by two empires called Empire A and Empire B.\nThe capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y.\nOne day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and ...
[{"input": "99 99 -22 62\n-9 -54 -13 -39 -79 -88 -6 -14 -41 -29 -2 -69 -30 -20 -33 -8 -24 -80 -19 -87 -32 -60 -40 -59 -44 -52 -3 -67 -18 -51 -56 -12 -7 -31 -48 -27 -68 -78 -21 -11 -49 -93 -1 -64 -82 -66 -70 -58 -84 -26 -57 -37 -53 -89 -50 -34 -61 -46 -92 -95 -99 -63 -65 -28 -10 -16 -73 -55 -98 -94 -77 -75 -62 -74 -42 -...
code_stdio
[ { "content": "There is a river of width $n$. The left bank of the river is cell $0$ and the right bank is cell $n + 1$ (more formally, the river can be represented as a sequence of $n + 2$ cells numbered from $0$ to $n + 1$). There are also $m$ wooden platforms on a river, the $i$-th platform has length $c_i$ (...
[{"input": "1000 232 105\n4 3 4 4 6 1 4 3 4 1 4 1 4 2 2 3 2 6 3 2 6 1 1 4 1 2 4 2 3 2 5 2 3 4 3 3 3 2 5 4 2 5 4 2 4 4 4 2 4 1 3 5 4 4 5 3 6 5 3 3 4 4 2 3 3 3 1 4 4 3 2 3 2 5 4 3 2 4 3 1 2 5 6 2 4 6 3 2 2 2 2 2 6 4 4 5 5 1 4 2 5 1 6 4 3 2 3 7 2 3 3 2 4 4 2 3 2 3 3 4 1 3 2 3 2 7 7 3 3 3 4 2 2 3 2 3 4 2 8 3 4 3 3 5 2 3 1 ...
code_stdio
[ { "content": "Berland State University invites people from all over the world as guest students. You can come to the capital of Berland and study with the best teachers in the country.\n\nBerland State University works every day of the week, but classes for guest students are held on the following schedule. You...
[{"input": "3\n4\n0 1 0 0 0 0 0\n100000000\n1 0 0 0 1 0 1\n1\n1 0 0 0 0 0 0\n", "output": "22\n233333332\n1\n"}, {"input": "3\n4\n0 1 0 0 0 0 0\n100000000\n1 1 0 0 1 0 1\n1\n1 0 0 0 0 0 0\n", "output": "22\n174999998\n1\n"}, {"input": "3\n4\n0 1 0 0 0 0 0\n100010000\n1 1 0 0 1 0 1\n1\n1 0 0 0 0 0 0\n", "output": "22\n1...
code_stdio
[ { "content": "Let's call an array $a$ consisting of $n$ positive (greater than $0$) integers beautiful if the following condition is held for every $i$ from $1$ to $n$: either $a_i = 1$, or at least one of the numbers $a_i - 1$ and $a_i - 2$ exists in the array as well.\n\nFor example:\n\nthe array $[5, 3, 1]$ ...
[{"input": "4\n1\n12\n13\n35\n", "output": "1\n4\n4\n6\n"}, {"input": "4\n1\n12\n11\n14\n", "output": "1\n4\n4\n4\n"}, {"input": "4\n1\n12\n22\n35\n", "output": "1\n4\n5\n6\n"}, {"input": "4\n2\n12\n11\n14\n", "output": "2\n4\n4\n4\n"}, {"input": "4\n2\n5\n13\n87\n", "output": "2\n3\n4\n10\n"}, {"input": "4\n1\n12\n7\n...
code_stdio
[ { "content": "We define the function `f1(n,k)`, as the least multiple of `n` that has all its digits less than `k`. \n\nWe define the function `f2(n,k)`, as the least multiple of `n` that has all the digits that are less than `k`.\n\nEach digit may occur more than once in both values of `f1(n,k)` and `f2(n,k)`....
[{"input": "9567100\n8", "output": "[9567115]", "fn_name": "find_f1_eq_f2"}, {"input": "568525\n7", "output": "[568531]", "fn_name": "find_f1_eq_f2"}, {"input": "14990\n7", "output": "[14996]", "fn_name": "find_f1_eq_f2"}, {"input": "30500\n3", "output": "[30501]", "fn_name": "find_f1_eq_f2"}, {"input": "62550\n5", "ou...
code_functional
[ { "content": "Alice guesses the strings that Bob made for her.\n\nAt first, Bob came up with the secret string $a$ consisting of lowercase English letters. The string $a$ has a length of $2$ or more characters. Then, from string $a$ he builds a new string $b$ and offers Alice the string $b$ so that she can gues...
[{"input": "11\nabbaac\nabbaac\nabbaac\nabbaac\nabbaac\nabbaac\nabbaac\nabbaac\nac\nbccddaaf\nzzzzzzzzzz\n", "output": "abac\nabac\nabac\nabac\nabac\nabac\nabac\nabac\nac\nbcdaf\nzzzzzz\n"}, {"input": "10\nabbaac\nac\nbccddaaf\nzzzzzzzzzz\nabbaac\nac\nbccddaaf\nzzzzzzzzzz\nbccddaaf\nzzzzzzzzzz\n", "output": "abac\nac\n...
code_stdio
[ { "content": "Nicholas has an array a that contains n distinct integers from 1 to n. In other words, Nicholas has a permutation of size n.\n\nNicholas want the minimum element (integer 1) and the maximum element (integer n) to be as far as possible from each other. He wants to perform exactly one swap in order ...
[{"input": "100\n76 70 67 54 40 1 48 63 64 36 42 90 99 27 47 17 93 7 13 84 16 57 74 5 83 61 19 56 52 92 38 91 82 79 34 66 71 28 37 98 35 94 77 53 73 10 26 80 15 32 8 81 3 95 44 46 72 6 33 11 21 85 4 30 24 51 49 96 87 55 14 31 12 60 45 9 29 22 58 18 88 2 50 59 20 86 23 41 100 39 62 68 69 97 78 43 25 89 65 75\n", "output...
code_stdio
[ { "content": "Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a...
[{"input": "2000 2000\n", "output": "585712681"}, {"input": "1544 1794\n", "output": "933285446"}, {"input": "1639 1056\n", "output": "467464129"}, {"input": "2000 1000\n", "output": "228299266"}, {"input": "1903 1612\n", "output": "620810276"}, {"input": "1707 1117\n", "output": "237674323"}, {"input": "1722 1474\n", ...
code_stdio
[ { "content": "Have you ever had an infinite loop when you ran a hard-working program? It would be convenient to be able to determine in advance whether a program will stop executing without having to execute it.\n\nUnfortunately, it is not possible to make such a decision for any program in the programming lang...
[{"input": "6\n10 SET d 1\n20 SET h 5\n100 ADD s s i\n110 SUB i i c\n120 IF i 100\n124 HALT", "output": "c=0\nd=1\nh=5\ni=0\ns=0\n"}, {"input": "6\n10 SET c 1\n20 SET h 5\n100 ADD s s i\n110 SUB i i c\n209 IF j 100\n200 HALT", "output": "c=1\nh=5\ni=0\nj=0\ns=0\n"}, {"input": "6\n10 SET c 1\n20 SET h 7\n100 ADD s s j\n...
code_stdio
[ { "content": "Finally, a basketball court has been opened in SIS, so Demid has decided to hold a basketball exercise session. $2 \\cdot n$ students have come to Demid's exercise session, and he lined up them into two rows of the same size (there are exactly $n$ people in each row). Students are numbered from $1...
[{"input": "100\n4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1\n1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 ...
code_stdio
[ { "content": "There is a rectangular grid of n rows of m initially-white cells each.\n\nArkady performed a certain number (possibly zero) of operations on it. In the i-th operation, a non-empty subset of rows R_{i} and a non-empty subset of columns C_{i} are chosen. For each row r in R_{i} and each column c in ...
[{"input": "50 8\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": "Takahashi is standing on a two-dimensional plane, facing north. Find the minimum positive integer K such that Takahashi will be at the starting position again after he does the following action K times:\n\n* Go one meter in the direction he is facing. Then, turn X degrees counter-clockwise.\n\nCon...
[{"input": "1329", "output": "120\n"}, {"input": "1162", "output": "180\n"}, {"input": "1369", "output": "360\n"}, {"input": "1527", "output": "120\n"}, {"input": "1874", "output": "180\n"}, {"input": "2383", "output": "360\n"}, {"input": "2579", "output": "360\n"}, {"input": "643", "output": "360\n"}, {"input": "1780"...
code_stdio
[ { "content": "Number of tanka\n\nWishing to die in the spring under the flowers\n\nThis is one of the famous tanka poems that Saigyo Hoshi wrote. Tanka is a type of waka poem that has been popular in Japan for a long time, and most of it consists of five phrases and thirty-one sounds of 5, 7, 5, 7, and 7.\n\nBy...
[{"input": "1\n1\n3\n1531\n2317\n714\n225725068861419081\n0", "output": "10\n10\n13\n55955\n155155\n7277\n3223333233333322222322232232233222323233333233223332\n"}, {"input": "1\n1\n4\n1531\n2317\n714\n225725068861419081\n0", "output": "10\n10\n14\n55955\n155155\n7277\n322333323333332222232223223223322232323333323322333...
code_stdio
[ { "content": "Paladin Manao caught the trail of the ancient Book of Evil in a swampy area. This area contains n settlements numbered from 1 to n. Moving through the swamp is very difficult, so people tramped exactly n - 1 paths. Each of these paths connects some pair of settlements and is bidirectional. Moreove...
[{"input": "50 2 5\n9 14\n46 34\n40 35\n44 30\n32 16\n1 38\n48 2\n17 14\n50 25\n6 1\n45 19\n21 15\n22 11\n15 33\n8 28\n2 32\n10 22\n37 3\n43 39\n25 16\n9 19\n16 3\n28 32\n20 45\n24 32\n4 18\n49 39\n13 45\n26 4\n11 33\n14 37\n42 19\n31 45\n38 3\n34 8\n18 29\n35 34\n29 16\n7 46\n19 28\n27 33\n30 9\n33 16\n36 45\n47 1\n41...
code_stdio
[ { "content": "Polycarp has found a table having an infinite number of rows and columns. The rows are numbered from $1$, starting from the topmost one. The columns are numbered from $1$, starting from the leftmost one.\n\nInitially, the table hasn't been filled and Polycarp wants to fix it. He writes integers fr...
[{"input": "100\n1\n2\n2\n3\n4\n5\n6\n13\n15\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n35\n20\n21\n22\n23\n24\n25\n26\n27\n28\n23\n30\n31\n32\n33\n34\n35\n36\n19\n38\n60\n40\n41\n42\n43\n44\n119\n46\n47\n77\n49\n44\n51\n45\n53\n54\n55\n56\n57\n58\n87\n60\n61\n42\n63\n64\n65\n66\n67\n68\n69\n70\n124\n72\n73\n74\n75\n76\n2...
code_stdio
[ { "content": "The Little Elephant loves chess very much. \n\nOne day the Little Elephant and his friend decided to play chess. They've got the chess pieces but the board is a problem. They've got an 8 × 8 checkered board, each square is painted either black or white. The Little Elephant and his friend know that...
[{"input": "WBWBWBWB\nBWBWBWBW\nBWBWBWBW\nBWBWBWBW\nWBWBWBWB\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB\n", "output": "YES\n"}, {"input": "BWBWBWBW\nWBWBWBWB\nBWBWBWBW\nBWBWBWBW\nWBWBWBWB\nWBWBWBWB\nWBWBWBWB\nWBWBWBWB\n", "output": "YES\n"}, {"input": "BWBWBWBW\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB\nWBWBWBWB\nWBWBWBWB\n...
code_stdio
[ { "content": "The semester is already ending, so Danil made an effort and decided to visit a lesson on harmony analysis to know how does the professor look like, at least. Danil was very bored on this lesson until the teacher gave the group a simple task: find 4 vectors in 4-dimensional space, such that every c...
[{"input": "8\n", "output": "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+...
code_stdio
[ { "content": "Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance...
[{"input": "50\n67 1\n89 2\n83 1\n-26 1\n88 2\n-22 2\n-98 2\n-83 1\n58 2\n26 2\n-37 1\n-51 2\n29 1\n47 2\n-70 1\n81 2\n36 1\n52 2\n93 2\n-12 2\n-12 1\n5 2\n91 1\n3 1\n-27 1\n18 1\n-60 1\n-15 1\n17 1\n-33 1\n-74 2\n5 2\n-62 2\n72 1\n-22 1\n-58 1\n-9 1\n57 1\n-18 2\n-11 1\n-103 2\n74 2\n-20 2\n21 1\n-19 2\n-77 1\n50 2\n9...
code_stdio
[ { "content": "Reca company makes monitors, the most popular of their models is AB999 with the screen size a × b centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ratio x: y became popular with users. That's why the company wants to reduce mo...
[{"input": "2000000000 2000000000 1999999998 1999999999\n", "output": "1999999998 1999999999"}, {"input": "2000000000 2000000000 1999999999 1999999998\n", "output": "1999999999 1999999998"}, {"input": "1688112099 1875662241 198852947 116042960\n", "output": "1590823576 928343680\n"}, {"input": "1143276347 1875662241 17...
code_stdio
[ { "content": "Recall that the permutation is an array consisting of $n$ distinct integers from $1$ to $n$ in arbitrary order. For example, $[2,3,1,5,4]$ is a permutation, but $[1,2,2]$ is not a permutation ($2$ appears twice in the array) and $[1,3,4]$ is also not a permutation ($n=3$ but there is $4$ in the ar...
[{"input": "250000 993244853\n", "output": "872048421\n"}, {"input": "244435 994838543\n", "output": "634651929\n"}, {"input": "234324 994631069\n", "output": "720229385\n"}, {"input": "249996 997202249\n", "output": "633673455\n"}, {"input": "249998 990040613\n", "output": "108188702\n"}, {"input": "249999 992509109\n...
code_stdio
[ { "content": "The Cybermen solved that first test much quicker than the Daleks. Luckily for us, the Daleks were angry (shocking!) and they destroyed some of the Cybermen.\n\nAfter the fighting stopped, Heidi gave them another task to waste their time on.\n\nThere are $n$ points on a plane. Given a radius $r$, f...
[{"input": "5 0\n2 1\n-2 -1\n-1 1\n-2 -2\n2 2\n", "output": "1\n"}, {"input": "5 1\n1 1\n-1 -1\n-1 1\n-2 -2\n2 0\n", "output": "2\n"}, {"input": "5 1\n2 1\n-1 -1\n-1 1\n-2 -2\n2 0\n", "output": "2\n"}, {"input": "5 1\n2 1\n-1 -1\n-1 1\n-2 -2\n2 1\n", "output": "2\n"}, {"input": "5 1\n2 1\n-2 -1\n-1 1\n-2 -2\n2 1\n", "o...
code_stdio
[ { "content": "Programmer Sasha has recently begun to study data structures. His coach Stas told him to solve the problem of finding a minimum on the segment of the array in <image>, which Sasha coped with. For Sasha not to think that he had learned all, Stas gave him a new task. For each segment of the fixed le...
[{"input": "10 3\n-20\n-63\n-64\n45\n-84\n-13\n79\n-31\n70\n-100\n", "output": "-20\n45\n45\n45\n79\n79\n79\n70\n"}, {"input": "10 3\n-20\n-52\n-64\n45\n-139\n-13\n79\n-31\n89\n-100\n", "output": "-20\n45\n45\n45\n79\n79\n89\n89"}, {"input": "10 3\n-20\n-35\n-64\n45\n-139\n-20\n24\n-31\n89\n-100\n", "output": "-20\n45\...
code_stdio
[ { "content": "If we alternate the vowels and consonants in the string `\"have\"`, we get the following list, arranged alphabetically:\n`['ahev', 'aveh', 'ehav', 'evah', 'vahe', 'veha']`. These are the only possibilities in which vowels and consonants are alternated. The first element, `ahev`, is alphabetically ...
[{"input": "\"acidity\"", "output": "[\"caditiy\"]", "fn_name": "solve"}, {"input": "\"codewars\"", "output": "[\"failed\"]", "fn_name": "solve"}, {"input": "\"orudere\"", "output": "[\"ederoru\"]", "fn_name": "solve"}, {"input": "\"oruder\"", "output": "[\"edorur\"]", "fn_name": "solve"}, {"input": "\"zodiac\"", "outp...
code_functional
[ { "content": "Division of Big Integers\n\nGiven two integers $A$ and $B$, compute the quotient, $\\frac{A}{B}$. Round down to the nearest decimal.\n\nInput\n\nTwo integers $A$ and $B$ separated by a space character are given in a line.\n\nOutput\n\nPrint the quotient in a line.\n\nConstraints\n\n* $-1 \\times 1...
[{"input": "12 -1", "output": "-12\n"}, {"input": "10 -1", "output": "-10\n"}, {"input": "20 -1", "output": "-20\n"}, {"input": "11 -1", "output": "-11\n"}, {"input": "15 -1", "output": "-15\n"}, {"input": "16 -1", "output": "-16\n"}, {"input": "14 -1", "output": "-14\n"}, {"input": "23 -1", "output": "-23\n"}, {"input...
code_stdio
[ { "content": "Vasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weights wi kilograms.\n\nVasya needs to collect all these items, however he won't...
[{"input": "2 100 100 10000 10000\n100 100\n", "output": "20000\n"}, {"input": "2 110 100 10000 10000\n100 100\n", "output": "21000\n"}, {"input": "2 110 100 10000 11101\n100 000\n", "output": "11000\n"}, {"input": "2 110 100 00000 11101\n110 000\n", "output": "12100\n"}, {"input": "2 110 100 10000 11000\n100 100\n", "...
code_stdio
[ { "content": "Write a function that checks the braces status in a string, and return `True` if all braces are properly closed, or `False` otherwise. Available types of brackets: `()`, `[]`, `{}`.\n\n**Please note, you need to write this function without using regex!**\n\n## Examples\n```python\n'([[some](){text...
[{"input": "\"([[some](){text}here]...)\"", "output": "[true]", "fn_name": "braces_status"}, {"input": "\"()[]{}()\"", "output": "[true]", "fn_name": "braces_status"}, {"input": "\"[()]{(\"", "output": "[false]", "fn_name": "braces_status"}, {"input": "\"{[()]}\"", "output": "[true]", "fn_name": "braces_status"}, {"inp...
code_functional
[ { "content": "Rng is going to a festival.\n\nThe name of the festival is given to you as a string S, which ends with `FESTIVAL`, from input. Answer the question: \"Rng is going to a festival of what?\" Output the answer.\n\nHere, assume that the name of \"a festival of s\" is a string obtained by appending `FES...
[{"input": "CODEFESTIVALFERTIVAL", "output": "CODEFESTIVAL\n"}, {"input": "CODEFESTIWALFESTIWAL", "output": "CODEFESTIWAL\n"}, {"input": "LAWITSEFLAWITSEFEDOC", "output": "LAWITSEFLAWI\n"}, {"input": "CODEFWSTIWALFESTIEAL", "output": "CODEFWSTIWAL\n"}, {"input": "COCEFWSTIWALFESTIEAL", "output": "COCEFWSTIWAL\n"}, {"in...
code_stdio
[ { "content": "problem\n\nI want to put as many rectangular tiles as possible on a rectangular wall with a size of $ h $ in height and $ w $ in width, and a size of $ a $ in height and $ b $ in width.\n\nThe following conditions must be met when attaching tiles.\n\n\n* Do not stack tiles.\n* Do not apply tiles d...
[{"input": "87 15\n12 66", "output": "1305\n"}, {"input": "87 29\n12 66", "output": "2523\n"}, {"input": "27 27\n16 16", "output": "473\n"}, {"input": "27 32\n16 16", "output": "352\n"}, {"input": "-1 18\n10 49", "output": "-18\n"}, {"input": "27 32\n20 16", "output": "224\n"}, {"input": "27 18\n20 16", "output": "166\...
code_stdio
[ { "content": "You are given three integers $a$, $b$, and $c$. Determine if one of them is the sum of the other two.\n\n\n-----Input-----\n\nThe first line contains a single integer $t$ ($1 \\leq t \\leq 9261$) — the number of test cases.\n\nThe description of each test case consists of three integers $a$, $b$, ...
[{"input": "47\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1...
code_stdio
[ { "content": "As a strict big brother, I do limit my young brother Vasya on time he spends on computer games. I define a prime-time as a time period till which Vasya have a permission to play computer games. I specify start hour and end hour as pair of integers.\n\nI need a function which will take three number...
[{"input": "9\n10\n11", "output": "[false]", "fn_name": "can_i_play"}, {"input": "12\n12\n13", "output": "[true]", "fn_name": "can_i_play"}, {"input": "13\n10\n15", "output": "[true]", "fn_name": "can_i_play"}, {"input": "14\n9\n14", "output": "[false]", "fn_name": "can_i_play"}, {"input": "15\n8\n12", "output": "[fals...
code_functional
[ { "content": "As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon.\n\nElections are coming. You know the number of voters and the number of parties — n and m res...
[{"input": "10 10\n7 29\n10 31\n9 40\n5 17\n5 30\n6 85\n2 53\n7 23\n4 57\n10 9\n", "output": "49\n"}, {"input": "10 10\n5 81\n7 68\n7 48\n1 10\n5 37\n7 97\n8 54\n7 41\n7 56\n5 21\n", "output": "110\n"}, {"input": "10 10\n7 29\n10 54\n9 40\n5 17\n5 30\n6 85\n2 53\n7 23\n4 57\n10 9\n", "output": "49\n"}, {"input": "10 10...
code_stdio
[ { "content": "You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so as to meet the following conditions:\n\n1. Each domino co...
[{"input": "14 16\n", "output": "112\n"}, {"input": "15 16\n", "output": "120\n"}, {"input": "16 16\n", "output": "128\n"}, {"input": "14 15\n", "output": "105\n"}, {"input": "15 15\n", "output": "112\n"}, {"input": "11 13\n", "output": "71\n"}, {"input": "14 14\n", "output": "98\n"}, {"input": "10 16\n", "output": "80...
code_stdio
[ { "content": "Ringo Mart, a convenience store, sells apple juice.\n\nOn the opening day of Ringo Mart, there were A cans of juice in stock in the morning. Snuke buys B cans of juice here every day in the daytime. Then, the manager checks the number of cans of juice remaining in stock every night. If there are C...
[{"input": "24\n2 2 3 4\n1 2 4 3\n1 3 2 4\n1 3 4 2\n1 4 2 3\n1 4 3 2\n2 1 3 4\n2 1 4 3\n2 3 1 4\n2 3 4 1\n2 4 1 3\n2 4 3 1\n3 1 2 4\n3 1 4 2\n3 2 1 4\n3 2 4 1\n3 4 1 2\n3 4 2 1\n4 1 2 3\n4 1 3 2\n4 2 1 3\n4 2 3 1\n4 3 1 2\n4 3 2 1", "output": "Yes\nNo\nNo\nNo\nNo\nNo\nYes\nYes\nNo\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo...
code_stdio
[ { "content": "Jack decides to invite Emma out for a dinner. Jack is a modest student, he doesn't want to go to an expensive restaurant. Emma is a girl with high taste, she prefers elite places.\n\nMunhattan consists of n streets and m avenues. There is exactly one restaurant on the intersection of each street a...
[{"input": "10 10\n256 72 455 45 912 506 235 68 951 92\n246 305 45 212 788 621 449 876 459 899\n732 107 230 357 370 610 997 669 61 192\n131 93 481 527 983 920 825 540 435 54\n777 682 984 20 337 480 264 137 249 502\n51 467 479 228 923 752 714 436 199 973\n3 91 612 571 631 212 751 84 886 948\n252 130 583 23 194 985 234 9...
code_stdio
[ { "content": "You are going to be given an array of integers. Your job is to take that array and find an index N where the sum of the integers to the left of N is equal to the sum of the integers to the right of N. If there is no index that would make this happen, return `-1`.\n\n__For example:__\n\nLet's say y...
[{"input": "[-100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -...
code_functional
[ { "content": "Today there is going to be an unusual performance at the circus — hamsters and tigers will perform together! All of them stand in circle along the arena edge and now the trainer faces a difficult task: he wants to swap the animals' positions so that all the hamsters stood together and all the tige...
[{"input": "178\nTTTTTTHTHHHTHHTHHHHTTTHTHTTHTHHHTHTTTTHHTTHHHTTHHTTHHTTHHHHHTHHTTHTHHTTHHTTTTTTTTTHTHTTHTHHTHHHHHHTTTHTHHHHTHHTTHHHHTTTTTTTTHHHTHHHTHTHHHTTTTTHTHTTTHTHHTTHTTTHHHHHTTHTTHTTTHTHHHT\n", "output": "40\n"}, {"input": "178\nTTTTTTHTHHHTHHTHHHHTTTHTHTTHTHHHTHTTTTHHTTHHHTTHHTTHHTTHHTHHTHHTTHTHHTTHHTTTTTTTTTHTH...
code_stdio
[ { "content": "A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt.\n\nCreate a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the...
[{"input": "6\n1 14\n2 17\n3 131\n4 11\n4 61\n6 66", "output": "3 131\n"}, {"input": "6\n1 14\n2 25\n3 126\n4 11\n4 40\n6 66", "output": "3 126\n"}, {"input": "6\n1 14\n2 17\n3 169\n4 11\n4 61\n6 66", "output": "3 169\n"}, {"input": "6\n1 12\n4 25\n3 72\n0 11\n2 101\n6 29", "output": "2 101\n"}, {"input": "6\n1 12\n4 2...
code_stdio
[ { "content": "We have a string S of length N consisting of A, T, C, and G.\nStrings T_1 and T_2 of the same length are said to be complementary when, for every i (1 \\leq i \\leq l), the i-th character of T_1 and the i-th character of T_2 are complementary. Here, A and T are complementary to each other, and so ...
[{"input": "5000 GCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCG...
code_stdio
[ { "content": "You have a garden consisting entirely of grass and weeds. Your garden is described by an n × m grid, with rows numbered 1 to n from top to bottom, and columns 1 to m from left to right. Each cell is identified by a pair (r, c) which means that the cell is located at row r and column c. Each cell m...
[{"input": "3 150\nGGGWGGGGWWGGGGGGGGGGGGGWGGWGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGWGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGWGGGGGGGWGGGGGGGGGGGGGGGGGWGGGGGGGGGGGGGGGGGGW\nGGGGGGGGGGGGWGGGGGGGGGWGGGGGGGGGGGGWGGGGGWGGGGGGGWGGGGGGGWGGGGGWGGGGGGGGGGGGGGGGGGGGGGGGWGGGGWGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGWGGWGG...
code_stdio
[ { "content": "Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function ...
[{"input": "100\n23 64 60 -45 -36 -64 -59 15 -75 69 -30 -7 -20 17 -77 58 93 -76 -121 -34 -31 16 -50 6 -20 -85 1 64 -88 -8 -15 -6 -57 25 91 10 2 -90 74 -66 -42 73 28 49 -85 30 96 79 -25 49 -59 -89 -75 14 -96 -33 -65 -8 -100 -81 17 99 -91 -5 7 -21 1 85 63 86 -26 85 -31 11 -75 35 -82 15 98 93 -55 24 70 36 -38 8 92 -63 -5 ...
code_stdio
[ { "content": "Your task is to calculate the distance between two $n$ dimensional vectors $x = \\\\{x_1, x_2, ..., x_n\\\\}$ and $y = \\\\{y_1, y_2, ..., y_n\\\\}$.\n\nThe Minkowski's distance defined below is a metric which is a generalization of both the Manhattan distance and the Euclidean distance.\n\\\\[ D_...
[{"input": "3\n109 25 10\n-1 -3 -3", "output": "151.000000\n114.249726\n110.661278\n110.000000\n"}, {"input": "3\n109 25 10\n0 -3 -3", "output": "150.000000\n113.287246\n109.673356\n109.000000\n"}, {"input": "3\n109 25 10\n-1 -3 0", "output": "148.000000\n113.947356\n110.628687\n110.000000\n"}, {"input": "3\n198 141 20...
code_stdio
[ { "content": "Let's consider a simplified version of order book of some stock. The order book is a list of orders (offers) from people that want to buy or sell one unit of the stock, each order is described by direction (BUY or SELL) and price.\n\nAt every moment of time, every SELL offer has higher price than ...
[{"input": "15\nADD 14944938\nADD 40032655\nACCEPT 14944938\nACCEPT 40032655\nADD 79373162\nACCEPT 79373162\nADD 55424250\nACCEPT 55424250\nADD 67468892\nACCEPT 67468892\nADD 51815959\nADD 13976252\nADD 2040654\nADD 74300637\nACCEPT 51815959\n", "output": "32\n"}, {"input": "15\nADD 14944938\nADD 40032655\nACCEPT 14944...
code_stdio
[ { "content": "Alice and Bob are playing a game of coins. N coins are placed on the table in a row. \n\nThe game begins with Alice and afterwards they alternate the moves.\n\nA valid move is defined as follows:\n\nYou pick one coin or two adjacent coins and remove them.\n\nThe game is over if anyone is not able ...
[{"input": "100\n90287615\n75096686\n621537351\n337906787\n932379178\n576368174\n614524887\n381393352\n683734903\n357312092\n45953951\n11885544\n659581459\n649281842\n360919237\n468202152\n348705142\n433071763\n766393082\n957639054\n492279795\n441607546\n238769590\n287864255\n240825138\n413652652\n556513880\n942947637\...
code_stdio
[ { "content": "The cat Snuke wants to play a popular Japanese game called ÅtCoder, so Iroha has decided to teach him Japanese.\nWhen counting pencils in Japanese, the counter word \"本\" follows the number. The pronunciation of this word varies depending on the number. Specifically, the pronunciation of \"本\" in ...
[{"input": "183\n", "output": "bon\n"}, {"input": "999\n", "output": "hon\n"}, {"input": "440\n", "output": "pon\n"}, {"input": "438\n", "output": "pon\n"}, {"input": "575\n", "output": "hon\n"}, {"input": "16\n", "output": "pon\n"}, {"input": "73\n", "output": "bon\n"}, {"input": "24\n", "output": "hon\n"}, {"input": ...
code_stdio
[ { "content": "Given a standard english sentence passed in as a string, write a method that will return a sentence made up of the same words, but sorted by their first letter. However, the method of sorting has a twist to it:\n* All words that begin with a lower case letter should be at the beginning of the sort...
[{"input": "\"Only themselves understand themselves and the like of themselves, As souls only understand souls\"", "output": "[\"and like of only souls souls the themselves themselves themselves understand understand Only As\"]", "fn_name": "pseudo_sort"}, {"input": "\"I, habitan of the Alleghanies, treating of him as ...
code_functional
[ { "content": "There are 3^N people dancing in circle. We denote with 0,1,\\dots, 3^{N}-1 the positions in the circle, starting from an arbitrary position and going around clockwise. Initially each position in the circle is occupied by one person.\n\nThe people are going to dance on two kinds of songs: salsa and...
[{"input": "3\nRRRRSRRRSRRSRS", "output": "23 9 4 8 3 16 20 24 1 5 18 13 17 12 25 2 6 10 14 0 22 26 21 7 11 15 19 "}, {"input": "3\nRSRRSRRRSRRSRR", "output": "17 12 7 11 24 19 5 9 4 26 21 16 20 6 1 14 18 13 8 3 25 2 15 10 23 0 22 "}, {"input": "3\nRRRRSRRRRRRSRS", "output": "13 0 11 10 15 26 25 21 5 4 18 2 1 6 17 16 1...
code_stdio
[ { "content": "You are given a sequence $a$ consisting of $n$ integers $a_1, a_2, \\dots, a_n$, and an integer $x$. Your task is to make the sequence $a$ sorted (it is considered sorted if the condition $a_1 \\le a_2 \\le a_3 \\le \\dots \\le a_n$ holds).\n\nTo make the sequence sorted, you may perform the follo...
[{"input": "6\n4 1\n2 3 5 4\n5 6\n1 1 3 4 4\n1 10\n2\n2 10\n11 9\n2 10\n12 11\n5 18\n81 324 218 413 324\n", "output": "\n3\n0\n0\n-1\n1\n3\n"}, {"input": "6\n4 1\n2 3 5 4\n5 6\n1 1 3 4 4\n1 10\n2\n2 10\n11 9\n2 10\n12 11\n5 18\n81 324 218 413 324\n", "output": "3\n0\n0\n-1\n1\n3\n"}, {"input": "6\n4 1\n2 3 5 4\n5 6\n1 ...
code_stdio
[ { "content": "Consider the following numbers (where `n!` is `factorial(n)`):\n```\nu1 = (1 / 1!) * (1!)\nu2 = (1 / 2!) * (1! + 2!)\nu3 = (1 / 3!) * (1! + 2! + 3!)\n...\nun = (1 / n!) * (1! + 2! + 3! + ... + n!)\n```\n\nWhich will win: `1 / n!` or `(1! + 2! + 3! + ... + n!)`?\n\nAre these numbers going to `0` be...
[{"input": "10110", "output": "[1.000098]", "fn_name": "going"}, {"input": "113", "output": "[1.008929]", "fn_name": "going"}, {"input": "200", "output": "[1.005025]", "fn_name": "going"}, {"input": "523", "output": "[1.001915]", "fn_name": "going"}, {"input": "1011", "output": "[1.00099]", "fn_name": "going"}, {"input...
code_functional
[ { "content": "[Image] \n\nIt's the end of July – the time when a festive evening is held at Jelly Castle! Guests from all over the kingdom gather here to discuss new trends in the world of confectionery. Yet some of the things discussed here are not supposed to be disclosed to the general public: the informatio...
[{"input": "433 3\nFZDDHMJGBZCHFUXBBPIEBBEFDWOMXXEPOMDGSMPIUZOMRZQNSJAVNATGIWPDFISKFQXJNVFXPHOZDAEZFDAHDXXQKZMGNSGKQNWGNGJGJZVVITKNFLVCPMZSDMCHBTVAWYVZLIXXIADXNYILEYNIQHKMOGMVOCWGHCWIYMPEPADSJAAKEGTUSEDWAHMNYJDIHBKHVUHLYGNGZDBULRXLSAJHPCMNWCEAAPYMHDTYWPADOTJTXTXUKLCHWKUSZRHEKQEFPVJEJJHRWCKYOIWALRTIBUMNOCRXLSIKQCJVQXEPG...
code_stdio
[ { "content": "To get money for a new aeonic blaster, ranger Qwerty decided to engage in trade for a while. He wants to buy some number of items (or probably not to buy anything at all) on one of the planets, and then sell the bought items on another planet. Note that this operation is not repeated, that is, the...
[{"input": "5 10 15\nDdunkjly\n13 12 4\n83 26 1\n63 42 3\n83 22 2\n57 33 0\n59 10 1\n89 31 1\n57 17 2\n98 79 5\n46 41 3\nFbpbc\n28 21 0\n93 66 5\n66 21 0\n68 58 0\n59 17 3\n57 23 1\n72 71 1\n55 51 2\n58 40 5\n70 67 2\nKeiotmh\n73 44 4\n98 14 0\n19 7 0\n55 10 5\n30 25 4\n66 48 2\n66 51 4\n82 79 3\n73 63 4\n87 46 5\nNksd...
code_stdio
[ { "content": "You are given a table consisting of n rows and m columns.\n\nNumbers in each row form a permutation of integers from 1 to m.\n\nYou are allowed to pick two elements in one row and swap them, but no more than once for each row. Also, no more than once you are allowed to pick two columns and swap th...
[{"input": "20 8\n4 3 2 1 5 6 7 8\n1 2 3 4 8 7 6 5\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7...
code_stdio
[ { "content": "Write a function that returns the number of '2's in the factorization of a number. \nFor example,\n```python\ntwo_count(24)\n```\nshould return 3, since the factorization of 24 is 2^3 x 3\n```python\ntwo_count(17280)\n```\nshould return 7, since the factorization of 17280 is 2^7 x 5 x 3^3 \nThe ...
[{"input": "482848428248882482", "output": "[1]", "fn_name": "two_count"}, {"input": "7777777777777777", "output": "[0]", "fn_name": "two_count"}, {"input": "222222222222", "output": "[1]", "fn_name": "two_count"}, {"input": "84934656", "output": "[20]", "fn_name": "two_count"}, {"input": "17280", "output": "[7]", "fn_...
code_functional