messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "Given is a string S. Let T be the concatenation of K copies of S. We can repeatedly perform the following operation: choose a character in T and replace it with a different character. Find the minimum number of operations required to satisfy the following condition: any two adjacent characters in ...
[{"input": "cooooooooonteeeeeeeedest\n1894324309", "output": "15154594472\n"}, {"input": "coonoooooonteeeeeeeedest\n1894324309", "output": "15154594472\n"}, {"input": "tsedeeeeeeeetnoooooonooc\n1894324309", "output": "15154594472\n"}, {"input": "cooooooooonteeeeeeeedest\n999993333", "output": "7999946664\n"}, {"input":...
code_stdio
[ { "content": "You are given an array $a$ consisting of $n$ integers. You have to find the length of the smallest (shortest) prefix of elements you need to erase from $a$ to make it a good array. Recall that the prefix of the array $a=[a_1, a_2, \\dots, a_n]$ is a subarray consisting several first elements: the ...
[{"input": "5\n4\n1 2 3 4\n7\n4 8 3 16 4 10 2\n3\n0 1 1\n7\n1 3 1 4 5 3 2\n5\n5 3 3 2 5\n", "output": "0\n4\n0\n2\n3\n"}, {"input": "5\n4\n1 2 3 4\n7\n13 3 4 8 4 5 2\n3\n1 1 1\n7\n1 3 1 7 5 0 2\n5\n5 4 3 2 3\n", "output": "0\n4\n0\n5\n3\n"}, {"input": "5\n4\n1 2 3 4\n7\n4 8 3 16 4 5 2\n3\n0 1 1\n7\n1 3 1 4 5 3 2\n5\n5 ...
code_stdio
[ { "content": "This is the hard version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.\n\nPikachu is a cute and friendly pokémon living in the wild pikachu herd.\n\nBut it has become known rec...
[{"input": "5\n2 0\n1 2\n2 1\n1 2\n1 2\n2 1\n2 1\n1 2\n3 9\n1 2 3\n1 2\n1 3\n2 3\n1 2\n1 3\n2 3\n1 2\n1 3\n2 3\n3 0\n3 2 1\n", "output": "2\n2\n2\n2\n2\n3\n4\n4\n3\n3\n3\n3\n4\n4\n3\n3\n"}, {"input": "5\n2 0\n1 2\n2 1\n1 2\n1 2\n2 1\n2 1\n1 2\n3 9\n1 2 3\n1 2\n1 3\n2 3\n1 2\n1 3\n2 3\n1 2\n1 3\n2 3\n3 0\n3 2 1\n", "out...
code_stdio
[ { "content": "G --Derangement / Derangement\n\nStory\n\nPerson D is doing research on permutations. At one point, D found a permutation class called \"Derangement\". \"It's cool to have a perfect permutation !!! And it starts with D !!!\", the person of D who had a crush on Chunibyo decided to rewrite all the p...
[{"input": "5\n4 0 0 10 12", "output": "0\n"}, {"input": "5\n4 1 0 10 12", "output": "0\n"}, {"input": "5\n4 1 0 10 19", "output": "0\n"}, {"input": "5\n4 1 0 10 38", "output": "0\n"}, {"input": "5\n4 1 0 10 11", "output": "0\n"}, {"input": "5\n4 0 0 10 6", "output": "0\n"}, {"input": "5\n4 0 0 10 3", "output": "0\n"},...
code_stdio
[ { "content": "Snuke received a triangle as a birthday present. The coordinates of the three vertices were (x_1, y_1), (x_2, y_2), and (x_3, y_3).\n\nHe wants to draw two circles with the same radius inside the triangle such that the two circles do not overlap (but they may touch). Compute the maximum possible r...
[{"input": "-1 -1\n1 1\n2 0", "output": "0.402627528107\n"}, {"input": "3 -1\n2 5\n1 16", "output": "0.143556168892\n"}, {"input": "-3 1\n1 1\n2 -1", "output": "0.548232156368\n"}, {"input": "6 -2\n2 5\n1 18", "output": "0.976523677728\n"}, {"input": "0 -1\n1 1\n2 -1", "output": "0.398016099934\n"}, {"input": "-1 -1\n0...
code_stdio
[ { "content": "Find the number, modulo 998244353, of sequences of length N consisting of 0, 1 and 2 such that none of their contiguous subsequences totals to X.\n\nConstraints\n\n* 1 \\leq N \\leq 3000\n* 1 \\leq X \\leq 2N\n* N and X are integers.\n\nInput\n\nInput is given from Standard Input in the following ...
[{"input": "102 205", "output": "214138673\n"}, {"input": "169 205", "output": "909969555\n"}, {"input": "613 159", "output": "832714847\n"}, {"input": "325 205", "output": "688557253\n"}, {"input": "613 201", "output": "958022812\n"}, {"input": "325 289", "output": "665901367\n"}, {"input": "613 216", "output": "57367...
code_stdio
[ { "content": "Once little Vasya read an article in a magazine on how to make beautiful handmade garland from colored paper. Vasya immediately went to the store and bought n colored sheets of paper, the area of each sheet is 1 square meter.\n\nThe garland must consist of exactly m pieces of colored paper of arbi...
[{"input": "hvewdvwdwudrwarwmddwnazmwauzatrmwptwwevavpmwrtruwnpwantewrnwmepdwvtmnveanunrvrtwpvhhnuhnmpptdttzmmndtvudmzhhannmmnahdpzamuvhzaavnhtnumwrwvttdetvuewaaennddwuvzvaptdzrzhtetwwzmzedrwuvrwznprhdvnavrruvvhzuwpdtmpwmzrwvermrhdamv\nuvzhwtpuputnahwwarduzddhpnwwvettprwavdmnztdnrddmarmvuevtdezndnezvarhmppwwnmvnrtddzhh...
code_stdio
[ { "content": "In the pet store on sale there are:\n\n$a$ packs of dog food;\n\n$b$ packs of cat food;\n\n$c$ packs of universal food (such food is suitable for both dogs and cats).\n\nPolycarp has $x$ dogs and $y$ cats. Is it possible that he will be able to buy food for all his animals in the store? Each of hi...
[{"input": "7\n1 1 4 2 3\n0 0 0 0 0\n5 5 0 4 6\n1 1 1 1 1\n50000000 50000000 100000000 100000000 100000000\n0 0 0 100000000 100000000\n1 3 2 2 5\n", "output": "YES\nYES\nNO\nYES\nYES\nNO\nNO\n"}, {"input": "3\n0 0 0 0 0\n2 1 0 2 2\n60 600 609 700 500\n", "output": "YES\nNO\nNO\n"}, {"input": "1\n114514 114514 114514 11...
code_stdio
[ { "content": "There are $n$ distinct points on a coordinate line, the coordinate of $i$-th point equals to $x_i$. Choose a subset of the given set of points such that the distance between each pair of points in a subset is an integral power of two. It is necessary to consider each pair of points, not only adjac...
[{"input": "3\n0 -536870912 536870912\n", "output": "3\n-536870912 0 536870912 \n"}, {"input": "3\n0 -536870912 536870912\n", "output": "3\n-536870912 0 536870912\n"}, {"input": "3\n-1 -536870912 536870912\n", "output": "2\n-536870912 536870912 \n"}, {"input": "2\n536870912 -536870912\n", "output": "2\n-536870912 53687...
code_stdio
[ { "content": "Ehab is interested in the bitwise-xor operation and the special graphs. Mahmoud gave him a problem that combines both. He has a complete graph consisting of n vertices numbered from 0 to n - 1. For all 0 ≤ u < v < n, vertex u and vertex v are connected with an undirected edge that has weight $u \\...
[{"input": "1000000000000\n", "output": "20140978692096\n"}, {"input": "1000100000000\n", "output": "20142429742080\n"}, {"input": "1000100000010\n", "output": "20142429742357\n"}, {"input": "1001100000010\n", "output": "20161739809813\n"}, {"input": "1000000000000\n", "output": "20140978692096"}, {"input": "9999999999...
code_stdio
[ { "content": "Do you like summer? Residents of Berland do. They especially love eating ice cream in the hot summer. So this summer day a large queue of n Berland residents lined up in front of the ice cream stall. We know that each of them has a certain amount of berland dollars with them. The residents of Berl...
[{"input": "10\n536259132 536259132 536259132 536259132 536259132 536259132 536259132 536259132 536259132 536259132\n", "output": "536259132 536259132 536259132 536259132 536259132 536259132 536259132 536259132 536259132 536259132 "}, {"input": "10\n876584065 876584063 876584061 876584059 876584057 876584055 876584053 ...
code_stdio
[ { "content": "You are given an integer array $a_1, a_2, \\dots, a_n$ and integer $k$.\n\nIn one step you can\n\neither choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);\n\nor choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).\n\nWhat is the minimum number of st...
[{"input": "1\n98 282\n103 948 349 26 241 933 394 546 476 785 441 397 658 308 801 940 760 29 717 343 99 530 389 797 955 322 662 763 654 781 1814 185 622 960 363 84 375 998 331 572 236 837 604 874 376 362 649 482 860 718 54 298 574 1726 16 943 71 292 615 829 460 301 358 245 585 438 24 561 252 416 88 81 86 571 805 67 862...
code_stdio
[ { "content": "Estimating the Flood Risk\n\nMr. Boat is the owner of a vast extent of land. As many typhoons have struck Japan this year, he became concerned of flood risk of his estate and he wants to know the average altitude of his land. The land is too vast to measure the altitude at many spots. As no steep ...
[{"input": "20 5 2\n3 1 0\n6 2 -1", "output": "-781\n"}, {"input": "16 5 2\n2 2 3\n1 2 3", "output": "-397\n"}, {"input": "10 5 2\n1 1 10\n5 2 6", "output": "199\n"}, {"input": "16 5 2\n2 2 3\n1 2 4", "output": "-392\n"}, {"input": "12 5 2\n8 2 10\n1 5 3", "output": "331\n"}, {"input": "5 5 2\n1 1 10\n5 4 3", "output":...
code_stdio
[ { "content": "# Write Number in Expanded Form - Part 2\n\nThis is version 2 of my ['Write Number in Exanded Form' Kata](https://www.codewars.com/kata/write-number-in-expanded-form).\n\nYou will be given a number and you will need to return it as a string in [Expanded Form](https://www.mathplacementreview.com/ar...
[{"input": "693.230459", "output": "[\"600 + 90 + 3 + 2/10 + 3/100 + 4/10000 + 5/100000 + 9/1000000\"]", "fn_name": "expanded_form"}, {"input": "7.3004", "output": "[\"7 + 3/10 + 4/10000\"]", "fn_name": "expanded_form"}, {"input": "7.304", "output": "[\"7 + 3/10 + 4/1000\"]", "fn_name": "expanded_form"}, {"input": "1.2...
code_functional
[ { "content": "An X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top i...
[{"input": "7\n50\n30\n50\n100\n50\n80\n30\n", "output": "4\n"}, {"input": "7\n50\n30\n50\n100\n50\n80\n35", "output": "5\n"}, {"input": "7\n50\n40\n91\n110\n50\n34\n59", "output": "6\n"}, {"input": "7\n50\n30\n50\n100\n50\n80\n59", "output": "5\n"}, {"input": "7\n50\n40\n50\n100\n50\n80\n59", "output": "5\n"}, {"input...
code_stdio
[ { "content": "For integers b (b \\geq 2) and n (n \\geq 1), let the function f(b,n) be defined as follows:\n\n* f(b,n) = n, when n < b\n* f(b,n) = f(b,\\,{\\rm floor}(n / b)) + (n \\ {\\rm mod} \\ b), when n \\geq b\n\n\n\nHere, {\\rm floor}(n / b) denotes the largest integer not exceeding n / b, and n \\ {\\rm...
[{"input": "31415926535\n13", "output": "15707963262\n"}, {"input": "31415926535\n2", "output": "31415926534\n"}, {"input": "31415926535\n4", "output": "31415926532\n"}, {"input": "31415926535\n3", "output": "15707963267\n"}, {"input": "31415926535\n6", "output": "31415926530\n"}, {"input": "31415926535\n5", "output": ...
code_stdio
[ { "content": "Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, value 2 into the value p2 and so on.\n\nKyota Ootori has just learned about cyclic representation of a p...
[{"input": "50 20365011074\n", "output": "2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 22 21 24 23 26 25 28 27 30 29 32 31 34 33 36 35 38 37 40 39 42 41 44 43 46 45 48 47 50 49 "}, {"input": "50 5608642004\n", "output": "1 2 4 3 5 6 8 7 9 10 11 13 12 15 14 17 16 18 20 19 22 21 23 24 25 26 28 27 30 29 31 32 33 34 ...
code_stdio
[ { "content": "The aim of the kata is to try to show how difficult it can be to calculate decimals of an irrational number with a certain precision. We have chosen to get a few decimals of the number \"pi\" using\nthe following infinite series (Leibniz 1646–1716): \n\nPI / 4 = 1 - 1/3 + 1/5 - 1/7 + ... which giv...
[{"input": "1e-06", "output": "[[1000001, 3.1415936536]]", "fn_name": "iter_pi"}, {"input": "0.0001", "output": "[[10000, 3.1414926536]]", "fn_name": "iter_pi"}, {"input": "1e-05", "output": "[[100001, 3.1416026535]]", "fn_name": "iter_pi"}, {"input": "0.001", "output": "[[1000, 3.1405926538]]", "fn_name": "iter_pi"}, ...
code_functional
[ { "content": "Given a set of integers (it can contain equal elements).\n\nYou have to split it into two subsets $A$ and $B$ (both of them can contain equal elements or be empty). You have to maximize the value of $mex(A)+mex(B)$.\n\nHere $mex$ of a set denotes the smallest non-negative integer that doesn't exis...
[{"input": "1\n100\n0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99\n", "outpu...
code_stdio
[ { "content": "Description\n\nIn 200X, the mysterious circle K, which operates at K University, announced K Poker, a new game they created on the 4th floor of K East during the university's cultural festival.\nAt first glance, this game is normal poker, but it is a deeper game of poker with the addition of basic...
[{"input": "3\n0 1 0 1 0 0 0 -1 0 1 0 -1 0\n1 0 0 0 0 0 1 0 0 0 0 0 2\n0 1 1 0 1 1 1 0 1 0 0 5 5\n3 1 1 1 0 1 0 0 1 0 3 -1 1\n1 1 2 7 5 10 20 50 100\n7H 6H 2H 5H 3H\n9S 9C 9H 8H 8D\nKS KH QH JD TS\n10\n1 1 1 1 1 1 1 1 1 0 1 1 1\n0 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 2 1 1 1 1 1 1 1 0\n1 1 1 1 1 1 1 1 1 1 1 1 1\n1 2 3 4 5 ...
code_stdio
[ { "content": "One day, $n$ people ($n$ is an even number) met on a plaza and made two round dances, each round dance consists of exactly $\\frac{n}{2}$ people. Your task is to find the number of ways $n$ people can make two round dances if each round dance consists of exactly $\\frac{n}{2}$ people. Each person ...
[{"input": "20\n", "output": "12164510040883200\n"}, {"input": "20\n", "output": "12164510040883200\n"}, {"input": "18\n", "output": "39520825344000\n"}, {"input": "18\n", "output": "39520825344000\n"}, {"input": "16\n", "output": "163459296000\n"}, {"input": "16\n", "output": "163459296000\n"}, {"input": "14\n", "outp...
code_stdio
[ { "content": "Takahashi has N balls. Initially, an integer A_i is written on the i-th ball.\n\nHe would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls.\n\nFind the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nCo...
[{"input": "10 3\n5 1 3 2 4 1 2 2 3 4", "output": "3\n"}, {"input": "10 3\n5 1 3 4 8 1 2 2 3 4", "output": "4\n"}, {"input": "10 3\n3 2 3 4 8 1 2 2 3 4", "output": "2\n"}, {"input": "10 1\n5 1 3 2 4 1 2 2 3 8", "output": "7\n"}, {"input": "10 1\n5 2 3 2 4 1 2 2 3 8", "output": "6\n"}, {"input": "10 3\n5 1 3 4 4 1 2 2 3...
code_stdio
[ { "content": "Summer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the beach. The gym where they go is a matrix a with n lines and m columns. Let number a[i][j] represents the calories burned by performing workout at the cell of gym in the i-th line and the j-th colum...
[{"input": "4 5\n22972 40786 3691 85313 46694\n33077 16067 3134 97367 68508\n4250 35501 17327 14435 32518\n64673 65438 56977 123599 27280\n", "output": "753143\n"}, {"input": "4 5\n22972 40786 3691 85313 46694\n33077 16067 3134 97367 129038\n4250 35501 17327 14435 32518\n64673 65438 56977 123599 3213\n", "output": "789...
code_stdio
[ { "content": "Rng is baking cookies.\n\nInitially, he can bake one cookie per second.\n\nHe can also eat the cookies baked by himself. When there are x cookies not yet eaten, he can choose to eat all those cookies. After he finishes eating those cookies, the number of cookies he can bake per second becomes x. N...
[{"input": "1000000000000 1000000100000", "output": "1000000000000\n"}, {"input": "1000010000000 1000100100001", "output": "1000010000000\n"}, {"input": "1000110000000 1000100100001", "output": "1000102100111\n"}, {"input": "1000100000000 1000100100001", "output": "1000100000000\n"}, {"input": "1000101000000 1000110100...
code_stdio
[ { "content": "You are given a positive integer $n$.\n\nLet $S(x)$ be sum of digits in base 10 representation of $x$, for example, $S(123) = 1 + 2 + 3 = 6$, $S(0) = 0$.\n\nYour task is to find two integers $a, b$, such that $0 \\leq a, b \\leq n$, $a + b = n$ and $S(a) + S(b)$ is the largest possible among all s...
[{"input": "1000000000000\n", "output": "109\n"}, {"input": "1000000000000\n", "output": "109\n"}, {"input": "999999999992\n", "output": "200\n"}, {"input": "290687942106\n", "output": "153\n"}, {"input": "324278748889\n", "output": "160\n"}, {"input": "110884501982\n", "output": "146\n"}, {"input": "999999999999\n", "...
code_stdio
[ { "content": "You are given an array of positive integers a_1, a_2, ..., a_{n} × T of length n × T. We know that for any i > n it is true that a_{i} = a_{i} - n. Find the length of the longest non-decreasing sequence of the given array.\n\n\n-----Input-----\n\nThe first line contains two space-separated integer...
[{"input": "100 10000000\n300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 30...
code_stdio
[ { "content": "Divisors of 42 are : 1, 2, 3, 6, 7, 14, 21, 42.\nThese divisors squared are: 1, 4, 9, 36, 49, 196, 441, 1764.\nThe sum of the squared divisors is 2500 which is 50 * 50, a square!\n\nGiven two integers m, n (1 <= m <= n) we want to find all integers \nbetween m and n whose sum of squared divisors i...
[{"input": "5000\n10000", "output": "[[[6237, 45024100], [9799, 96079204], [9855, 113635600]]]", "fn_name": "list_squared"}, {"input": "600\n1500", "output": "[[[728, 722500], [1434, 2856100]]]", "fn_name": "list_squared"}, {"input": "1\n250", "output": "[[[1, 1], [42, 2500], [246, 84100]]]", "fn_name": "list_squared"}...
code_functional
[ { "content": "Fangy collects cookies. Once he decided to take a box and put cookies into it in some way. If we take a square k × k in size, divided into blocks 1 × 1 in size and paint there the main diagonal together with cells, which lie above it, then the painted area will be equal to the area occupied by one...
[{"input": "1000\n", "output": "691074\n"}, {"input": "696\n", "output": "695035\n"}, {"input": "928\n", "output": "794863\n"}, {"input": "589\n", "output": "889192\n"}, {"input": "657\n", "output": "874011\n"}, {"input": "617\n", "output": "247876\n"}, {"input": "298\n", "output": "999535\n"}, {"input": "823\n", "outp...
code_stdio
[ { "content": "You are given a program you want to execute as a set of tasks organized in a dependency graph. The dependency graph is a directed acyclic graph: each task can depend on results of one or several other tasks, and there are no directed circular dependencies between tasks. A task can only be executed...
[{"input": "10 39\n0 1 0 1 0 1 1 0 1 1\n0 1\n0 2\n0 3\n0 4\n0 5\n0 6\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n3 4\n3 6\n3 7\n3 8\n3 9\n4 5\n4 6\n4 7\n4 9\n5 6\n5 7\n5 8\n5 9\n6 8\n6 9\n7 8\n7 9\n8 9\n", "output": "4\n"}, {"input": "10 39\n1 1 1 1 1 1 1 1 1 1\n0 1\n0 2\n0 3\n0 5\n0 6\n...
code_stdio
[ { "content": "Given a positive integer n, find k integers (not necessary distinct) such that all these integers are strictly greater than 1, and their product is equal to n.\n\nInput\n\nThe first line contains two integers n and k (2 ≤ n ≤ 100000, 1 ≤ k ≤ 20).\n\nOutput\n\nIf it's impossible to find the represe...
[{"input": "100000 10\n", "output": "2 2 2 2 2 5 5 5 5 5\n"}, {"input": "2048 11\n", "output": "2 2 2 2 2 2 2 2 2 2 2\n"}, {"input": "1024 10\n", "output": "2 2 2 2 2 2 2 2 2 2\n"}, {"input": "100000 8\n", "output": "2 2 2 2 2 5 5 125 "}, {"input": "1024 9\n", "output": "2 2 2 2 2 2 2 2 4 "}, {"input": "99999 4\n", "ou...
code_stdio
[ { "content": "Email address in Berland is a string of the form A@B, where A and B are arbitrary strings consisting of small Latin letters. \n\nBob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as a large string, where all addresses are wr...
[{"input": "c@ir@xf@ap@fk@sp@wm@ec@qw@vg@by@iu@tr@wu@pv@lj@dd@tc@qj@ok@hm@bs@ul@ez@cg@ht@xf@ag@tr@hz@ap@tx@ly@dg@hu@nd@uv@il@ii@cn@nc@nb@cy@kp@dk@xa@da@ta@yr@yv@qg@db@je@wz@rn@yh@xi@mj@kc@uj@yu@cf@ps@ao@fo@le@d\n", "output": "c@i,r@x,f@a,p@f,k@s,p@w,m@e,c@q,w@v,g@b,y@i,u@t,r@w,u@p,v@l,j@d,d@t,c@q,j@o,k@h,m@b,s@u,l@e,z@...
code_stdio
[ { "content": "In 2013, the writers of Berland State University should prepare problems for n Olympiads. We will assume that the Olympiads are numbered with consecutive integers from 1 to n. For each Olympiad we know how many members of the jury must be involved in its preparation, as well as the time required t...
[{"input": "40\n10 23 54 73\n11 10 58 84\n11 9 65 84\n11 20 45 92\n11 11 35 96\n11 6 66 16\n11 12 1 13\n11 15 8 18\n11 18 72 86\n10 24 62 38\n10 27 79 12\n11 11 24 59\n11 14 6 99\n11 6 33 100\n11 10 37 60\n11 10 67 8\n11 6 73 25\n11 8 91 3\n10 28 45 32\n11 14 64 37\n11 21 15 79\n10 29 79 53\n11 13 29 29\n10 23 76 76\n1...
code_stdio
[ { "content": "Read problems statements in Russian here \nThe Head Chef is studying the motivation and satisfaction level of his chefs . The motivation and satisfaction of a Chef can be represented as an integer . The Head Chef wants to know the N th smallest sum of one satisfaction value and one motivation va...
[{"input": "1\n6 1\n0 12 11\n7 5 10\n7", "output": "19\n"}, {"input": "1\n6 1\n0 10 11\n7 5 10\n7", "output": "18\n"}, {"input": "1\n10 1\n1 5 -1\n6 -1 2\n1", "output": "-2\n"}, {"input": "1\n10 1\n1 5 -2\n6 -1 2\n1", "output": "-3\n"}, {"input": "1\n1 1\n-2 5 12\n-3 1 2\n0", "output": "14\n"}, {"input": "1\n10 1\n1 4 ...
code_stdio
[ { "content": "For each positive integer n consider the integer ψ(n) which is obtained from n by replacing every digit a in the decimal notation of n with the digit (9 - a). We say that ψ(n) is the reflection of n. For example, reflection of 192 equals 807. Note that leading zeros (if any) should be omitted. So ...
[{"input": "1000000000 1000000000\n", "output": "8999999999000000000\n"}, {"input": "999999999 1000000000\n", "output": "8999999999000000000\n"}, {"input": "733403773 763985558\n", "output": "195522678015960698\n"}, {"input": "862630595 866814866\n", "output": "118499050707315380\n"}, {"input": "609160934 909699101\n",...
code_stdio
[ { "content": "The game of billiards involves two players knocking 3 balls around\non a green baize table. Well, there is more to it, but for our\npurposes this is sufficient.\nThe game consists of several rounds and in each round both players\nobtain a score, based on how well they played. Once all the rounds\n...
[{"input": "5\n140 82\n141 134\n90 110\n339 106\n88 90", "output": "1 278\n"}, {"input": "5\n140 82\n176 134\n90 110\n289 106\n88 90", "output": "1 263\n"}, {"input": "5\n140 147\n141 71\n172 110\n339 30\n40 90", "output": "1 434\n"}, {"input": "5\n140 82\n89 134\n90 110\n289 106\n88 90", "output": "1 176\n"}, {"input"...
code_stdio
[ { "content": "Aka Beko, trying to escape from 40 bandits, got lost in the city of A. Aka Beko wants to go to City B, where the new hideout is, but the map has been stolen by a bandit.\n\nKobborg, one of the thieves, sympathized with Aka Beko and felt sorry for him. So I secretly told Aka Beko, \"I want to help ...
[{"input": "0100\n0101\n10100\n10000\n0101011\n1011\n011111\n#", "output": "Yes\nNo\nYes\nNo\nYes\nYes\nYes\n"}, {"input": "0100\n0100\n10100\n10000\n0101011\n1001\n011111\n#", "output": "Yes\nYes\nYes\nNo\nYes\nNo\nYes\n"}, {"input": "0100\n0100\n10100\n10000\n0101011\n1011\n011110\n#", "output": "Yes\nYes\nYes\nNo\nY...
code_stdio
[ { "content": "A positive integer may be expressed as a sum of different prime numbers (primes), in one way or another. Given two positive integers n and k, you should count the number of ways to express n as a sum of k different primes. Here, two ways are considered to be the same if they sum up the same set of...
[{"input": "24 3\n24 2\n2 1\n1 1\n4 2\n18 3\n17 1\n17 3\n17 4\n110 5\n1000 10\n1120 14\n0 0", "output": "2\n3\n1\n0\n0\n2\n1\n0\n1\n79\n200102899\n2079324314\n"}, {"input": "24 3\n24 2\n2 1\n1 1\n4 2\n33 3\n17 1\n17 3\n17 4\n100 5\n1000 10\n1120 14\n0 0", "output": "2\n3\n1\n0\n0\n4\n1\n0\n1\n55\n200102899\n2079324314\...
code_stdio
[ { "content": "Your aged grandfather is tragically optimistic about Team GB's chances in the upcoming World Cup, and has enlisted you to help him make [Union Jack](https://en.wikipedia.org/wiki/Union_Jack) flags to decorate his house with. \n\n## Instructions\n* Write a function which takes as a parameter a numb...
[{"input": "109.1", "output": "[\"X-----------------------------------------------------XX-----------------------------------------------------X\\n-X----------------------------------------------------XX----------------------------------------------------X-\\n--X---------------------------------------------------XX----...
code_functional
[ { "content": "You are given circle $A$ with radius $r_a$ and with central coordinate $(x_a, y_a)$ and circle $B$ with radius $r_b$ and with central coordinate $(x_b, y_b)$.\n\nWrite a program which prints:\n\n* \"2\" if $B$ is in $A$,\n* \"-2\" if $A$ is in $B$,\n* \"1\" if circumference of $A$ and $B$ intersec...
[{"input": "2\n1.3018830993798196 1.1804991696233216 6.678597997840617 2.1321559253491804 2.072303142011048 4.898405435743801\n1.6154186783950772 0.39921226227011497 2.512872370263131 5.273208013897418 2.169775861927481 3.924014997809771", "output": "2\n1\n"}, {"input": "2\n1.3018830993798196 1.1804991696233216 6.67859...
code_stdio
[ { "content": "User ainta has a stack of n red and blue balls. He can apply a certain operation which changes the colors of the balls inside the stack.\n\n While the top ball inside the stack is red, pop the ball from the top of the stack. Then replace the blue ball on the top with a red ball. And finally pus...
[{"input": "50\nBRRRBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\n", "output": "1125899906842609\n"}, {"input": "50\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\n", "output": "1125899906842623\n"}, {"input": "50\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\n", "output": "1125899906842623\n"}, {"input": ...
code_stdio
[ { "content": "A trick of fate caused Hatsumi and Taku to come to know each other. To keep the encounter in memory, they decided to calculate the difference between their ages. But the difference in ages varies depending on the day it is calculated. While trying again and again, they came to notice that the diff...
[{"input": "1505 13 9\n2619 11 3", "output": "1114\n"}, {"input": "2137 -1 28\n1419 -2 1", "output": "719\n"}, {"input": "2137 -1 28\n1818 -1 1", "output": "320\n"}, {"input": "2137 -1 28\n3039 -1 1", "output": "902\n"}, {"input": "167 -1 28\n3039 -1 0", "output": "2872\n"}, {"input": "167 -2 19\n3039 -1 0", "output": ...
code_stdio
[ { "content": "Better things, cheaper. There is a fierce battle at the time sale held in some supermarkets today. \"LL-do\" here in Aizu is one such supermarket, and we are holding a slightly unusual time sale to compete with other chain stores. In a general time sale, multiple products are cheaper at the same t...
[{"input": "6 5\n1 1 . 0 0 4\n1 . . . . .\n. . 2 2 . .\n. . 2 2 3 3\nP . - . . .\n5\n0 50 5 10\n1 20 0 10\n2 10 5 15\n3 150 3 10\n4 100 8 9\n0 0", "output": "330\n"}, {"input": "6 5\n1 0 . 0 0 4\n1 . . . . .\n. . 2 2 . .\n. . 2 2 3 3\nP . . . . .\n5\n0 50 8 10\n1 20 0 10\n2 10 5 15\n3 150 3 5\n4 100 8 27\n0 0", "output...
code_stdio
[ { "content": "There is a grid, consisting of n rows and m columns. Each cell of the grid is either free or blocked. One of the free cells contains a lab. All the cells beyond the borders of the grid are also blocked.\n\nA crazy robot has escaped from this lab. It is currently in some free cell of the grid. You ...
[{"input": "1\n3 31\n############################..#\n.............................L.\n############################..#\n", "output": "############################++#\n+++++++++++++++++++++++++++++L+\n############################++#\n"}, {"input": "1\n3 31\n#############################..\n.............................L...
code_stdio
[ { "content": "You are given several queries. Each query consists of three integers p, q and b. You need to answer whether the result of p/q in notation with base b is a finite fraction.\n\nA fraction in notation with base b is finite if it contains finite number of numerals after the decimal point. It is also p...
[{"input": "11\n1 1000000000000000000 10000000\n2 999 9\n2 999 333111\n0 15 14\n17 128 2\n13 311992186885373952 18\n1971402979058461 97576870171850009 100\n14 19 23\n3 21914624432020321 23\n0 21914624432020321 46\n3 21914624432020321 47\n", "output": "Finite\nInfinite\nFinite\nFinite\nFinite\nFinite\nInfinite\nInfinite...
code_stdio
[ { "content": "Vasya studies positional numeral systems. Unfortunately, he often forgets to write the base of notation in which the expression is written. Once he saw a note in his notebook saying a + b = ?, and that the base of the positional notation wasn’t written anywhere. Now Vasya has to choose a base p an...
[{"input": "1000 1000\n", "output": "5\n"}, {"input": "1000 539\n", "output": "4\n"}, {"input": "999 1000\n", "output": "4\n"}, {"input": "1000 999\n", "output": "4\n"}, {"input": "998 1000\n", "output": "4\n"}, {"input": "1000 998\n", "output": "4\n"}, {"input": "247 1000\n", "output": "4\n"}, {"input": "208 997\n", "...
code_stdio
[ { "content": "There are N piles of candies on the table. The piles are numbered 1 through N. At first, pile i contains a_i candies.\n\nSnuke and Ciel are playing a game. They take alternating turns. Snuke goes first. In each turn, the current player must perform one of the following two operations:\n\n1. Choose...
[{"input": "3\n-1 -1 1", "output": "Second\n"}, {"input": "3\n2 -1 4", "output": "Second\n"}, {"input": "3\n-1 -2 4", "output": "First\n"}, {"input": "3\n0 -1 1", "output": "Second\n"}, {"input": "3\n-1 0 1", "output": "Second\n"}, {"input": "3\n1 -1 0", "output": "Second\n"}, {"input": "3\n-2 -2 4", "output": "First\n...
code_stdio
[ { "content": "Chef has an array of N integers. He wants to play a special game. In this game he needs to make all the integers in the array greater than or equal to 0. \nChef can use two types of operations. The first type is to increase all the integers of the given array by 1, but it costs X coins. The opera...
[{"input": "3\n-10 -1 -2\n2", "output": "12\n"}, {"input": "3\n-10 -1 -4\n2", "output": "14\n"}, {"input": "3\n-6 -3 -2\n3", "output": "11\n"}, {"input": "3\n-8 -3 -2\n3", "output": "13\n"}, {"input": "3\n1 -2 -10\n1", "output": "10\n"}, {"input": "3\n-15 0 -1\n9", "output": "16\n"}, {"input": "3\n-24 0 -1\n9", "output...
code_stdio
[ { "content": "Two strings ```a``` and b are called isomorphic if there is a one to one mapping possible for every character of ```a``` to every character of ```b```. And all occurrences of every character in ```a``` map to same character in ```b```.\n\n## Task\n\nIn this kata you will create a function that ret...
[{"input": "\"RAMBUNCTIOUSLY\"\n\"THERMODYNAMICS\"", "output": "[true]", "fn_name": "isomorph"}, {"input": "\"DISCRIMINATIVE\"\n\"SIMPLIFICATION\"", "output": "[true]", "fn_name": "isomorph"}, {"input": "\"abcdefghijk\"\n\"abcdefghijba\"", "output": "[false]", "fn_name": "isomorph"}, {"input": "\"ABCBACCBA\"\n\"ABCBACC...
code_functional
[ { "content": "There are n seats in the train's car and there is exactly one passenger occupying every seat. The seats are numbered from 1 to n from left to right. The trip is long, so each passenger will become hungry at some moment of time and will go to take boiled water for his noodles. The person at seat i ...
[{"input": "100 1000000000\n12 803 439 918 435 300 497 520 718 573 782 523 328 88 275 159 128 389 920 869 503 80 490 289 22 889 353 799 29 131 587 123 405 221 727 135 248 348 299 833 19 943 471 410 635 626 784 712 213 724 550 661 860 536 718 173 406 832 520 748 512 29 466 982 574 848 11 693 915 965 177 479 63 498 484 1...
code_stdio
[ { "content": "Mishka is trying really hard to avoid being kicked out of the university. In particular, he was doing absolutely nothing for the whole semester, miraculously passed some exams so that just one is left.\n\nThere were $n$ classes of that subject during the semester and on $i$-th class professor ment...
[{"input": "200\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
code_stdio
[ { "content": "Alice and Bob are playing a fun game of tree tag.\n\nThe game is played on a tree of n vertices numbered from 1 to n. Recall that a tree on n vertices is an undirected, connected graph with n-1 edges.\n\nInitially, Alice is located at vertex a, and Bob at vertex b. They take turns alternately, and...
[{"input": "10\n10 9 10 6 6\n6 1\n7 6\n4 2\n4 10\n5 1\n9 5\n6 8\n3 4\n4 5\n2 1 2 1 1\n2 1\n9 7 4 2 3\n5 1\n2 4\n4 8\n8 6\n8 9\n7 8\n1 8\n1 3\n11 2 11 6 8\n1 10\n6 11\n8 2\n11 3\n1 7\n11 4\n5 8\n11 7\n1 9\n1 8\n5 3 2 1 2\n3 1\n2 1\n4 5\n1 5\n2 1 2 1 1\n2 1\n2 2 1 1 1\n2 1\n2 2 1 1 1\n1 2\n2 2 1 1 1\n2 1\n5 4 5 4 2\n2 1\...
code_stdio
[ { "content": "During their New Year holidays, Alice and Bob play the following game using an array $a$ of $n$ integers:\n\nPlayers take turns, Alice moves first.\n\nEach turn a player chooses any element and removes it from the array.\n\nIf Alice chooses even value, then she adds it to her score. If the chosen ...
[{"input": "4\n4\n5 0 6 3\n3\n1 2 1\n4\n2 4 2 2\n2\n14 2\n", "output": "Alice\nAlice\nAlice\nAlice\n"}, {"input": "4\n4\n5 0 6 3\n3\n1 2 1\n4\n2 4 2 2\n2\n14 3\n", "output": "Alice\nAlice\nAlice\nAlice\n"}, {"input": "4\n4\n5 2 10 3\n3\n6 2 0\n4\n2 2 2 0\n2\n10 11\n", "output": "Alice\nAlice\nAlice\nTie\n"}, {"input": ...
code_stdio
[ { "content": "problem\n\nAOR Ika wants to create a strong password that consists only of lowercase letters. AOR Ika-chan, who was given an example of $ N $ of dangerous passwords by a friend, decided to create a password that meets all of the following conditions.\n\n1. The length is at least one character.\n2....
[{"input": "5\npassword\nlogin\nnimda\nroot\nmaster", "output": "b\n"}, {"input": "5\nbraprswp\nlofho\nojdma\nsnnt\nfuarsm", "output": "c\n"}, {"input": "5\nbraprsxp\noofhk\nojcma\nsnnt\nfuarsm", "output": "d\n"}, {"input": "5\napssword\nlogin\nnimda\nroot\nmaster", "output": "b\n"}, {"input": "5\nopssward\nlogin\nnimd...
code_stdio
[ { "content": "A factory produces thimbles in bulk. Typically, it can produce up to a thimbles a day. However, some of the machinery is defective, so it can currently only produce b thimbles each day. The factory intends to choose a k-day period to do maintenance and construction; it cannot produce any thimbles ...
[{"input": "5 2 2 1 8\n1 1 2\n1 5 3\n1 2 1\n2 2\n1 4 0\n1 3 2\n2 1\n2 3\n", "output": "3\n4\n4\n"}, {"input": "5 2 2 1 8\n1 1 1\n1 5 3\n1 2 1\n2 2\n1 4 2\n1 3 2\n2 1\n2 3\n", "output": "3\n6\n4\n"}, {"input": "5 2 2 1 8\n1 1 2\n1 5 3\n1 2 1\n2 2\n1 4 2\n1 3 2\n2 1\n2 2\n", "output": "3\n6\n5\n"}, {"input": "5 4 2 1 8\n...
code_stdio
[ { "content": "Let's play the game using a bag containing several cards with integers written on it. In each game, participants first declare one of their favorite number n. Then, take out an appropriate number of cards from the bag at a time, and if the sum of the numbers written on those cards is equal to n, y...
[{"input": "5\n1 10\n10 3\n10 4\n25 2\n50 2\n4\n120\n500\n100\n168\n7\n1 10\n3 10\n5 10\n10 10\n25 10\n50 10\n100 10\n3\n452\n574\n787\n0", "output": "20\n0\n20\n10\n9789\n13658\n17466\n"}, {"input": "5\n1 10\n5 3\n10 3\n25 2\n50 2\n4\n120\n500\n100\n168\n7\n1 10\n3 10\n5 10\n10 10\n25 10\n10 10\n100 10\n3\n452\n574\n7...
code_stdio
[ { "content": "Three friends are going to meet each other. Initially, the first friend stays at the position $x = a$, the second friend stays at the position $x = b$ and the third friend stays at the position $x = c$ on the coordinate axis $Ox$.\n\nIn one minute each friend independently from other friends can c...
[{"input": "8\n4 6 16\n7 6 35\n12 5 1\n2 15 3\n1 1000000000 0000000000\n1 1000000000 459694946\n2 0 9\n4 2 6\n", "output": "20\n54\n18\n22\n1999999996\n1999999994\n14\n4\n"}, {"input": "8\n4 6 16\n7 6 35\n12 5 1\n2 15 3\n1 1000000000 0000000000\n1 1000000000 459694946\n1 0 9\n0 2 6\n", "output": "20\n54\n18\n22\n199999...
code_stdio
[ { "content": "The only difference between easy and hard versions is constraints.\n\nThe BerTV channel every day broadcasts one episode of one of the $k$ TV shows. You know the schedule for the next $n$ days: a sequence of integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le k$), where $a_i$ is the show, the episo...
[{"input": "4\n5 2 2\n1 2 1 2 2\n9 3 3\n3 3 3 2 2 4 1 1 1\n4 18 4\n10 8 6 4\n16 10 8\n3 1 7 1 5 4 2 6 7 6 5 8 9 8 11 3\n", "output": "1\n1\n4\n6\n"}, {"input": "4\n5 2 4\n1 2 1 2 1\n9 3 3\n3 3 3 2 2 4 1 1 1\n4 18 4\n10 8 6 4\n16 10 8\n3 1 4 2 5 4 2 6 5 6 5 10 9 8 9 3\n", "output": "2\n1\n4\n4\n"}, {"input": "4\n5 2 4\n...
code_stdio
[ { "content": "Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.\n\nIn the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are sugges...
[{"input": "10\nW22kb1L1 0 39 0 465 0 1961 865\n1MCXiVYmu5ys0afl 0 38 0 0 0 1982 1241\nCxg706kUJtQ 0 23 211 0 0 1785 1056\nmzEY 0 16 0 0 0 1988 1404\nv8JUjmam5SFP 0 48 0 788 1199 1426 0\n7giq 0 21 0 780 1437 1363 1930\nsXsUGbAulj6Lbiq 0 32 205 0 0 603 0\nRepIrY1Er4PgK 0 13 381 872 927 1488 0\nleKBdKHLnLFz 0 29 220 0 0 ...
code_stdio
[ { "content": "# Scenario \n\n*Now that the competition gets tough it will* **_Sort out the men from the boys_** . \n\n**_Men_** are the **_Even numbers_** and **_Boys_** are the **_odd_** ![!alt](https://i.imgur.com/mdX8dJP.png) ![!alt](https://i.imgur.com/mdX8dJP.png) \n\n___\n# Task\n\n**_Given_** an *array...
[{"input": "[-17, -45, -15, -33, -85, -56, -86, -30]", "output": "[[-86, -56, -30, -15, -17, -33, -45, -85]]", "fn_name": "men_from_boys"}, {"input": "[49, 818, -282, 900, 928, 281, -282, -1]", "output": "[[-282, 818, 900, 928, 281, 49, -1]]", "fn_name": "men_from_boys"}, {"input": "[-53, -26, -53, -27, -49, -51, -14]"...
code_functional
[ { "content": "Vasya used to be an accountant before the war began and he is one of the few who knows how to operate a computer, so he was assigned as the programmer.\n\nWe all know that programs often store sets of integers. For example, if we have a problem about a weighted directed graph, its edge can be repr...
[{"input": "56\npair pair pair int int pair pair pair pair pair int pair int int pair pair int pair pair pair int pair int int pair int pair int pair pair pair pair int pair pair int int pair int int pair int int int int int pair pair pair pair pair pair pair pair pair int pair pair int pair pair pair pair int int int ...
code_stdio
[ { "content": "Polycarpus adores TV series. Right now he is ready to finish watching a season of a popular sitcom \"Graph Theory\". In total, the season has n episodes, numbered with integers from 1 to n.\n\nPolycarpus watches episodes not one by one but in a random order. He has already watched all the episodes...
[{"input": "10\n3 8 10 1 7 9 6 5 2\n", "output": " 4"}, {"input": "5\n5 2 4 3\n", "output": " 1"}, {"input": "5\n5 4 3 2\n", "output": " ...
code_stdio
[ { "content": "Famous Brazil city Rio de Janeiro holds a tennis tournament and Ostap Bender doesn't want to miss this event. There will be n players participating, and the tournament will follow knockout rules from the very first game. That means, that if someone loses a game he leaves the tournament immediately...
[{"input": "1000000000000000000\n", "output": "85\n"}, {"input": "1000000000001000000\n", "output": "85\n"}, {"input": "1008361188500224528\n", "output": "85\n"}, {"input": "1000000000001001000\n", "output": "85\n"}, {"input": "679891637638612258\n", "output": "85\n"}, {"input": "123456789123456789\n", "output": "81\n"...
code_stdio
[ { "content": "Did you know that there are over 40,000 varieties of Rice in the world ? There are so many dishes that can be prepared with Rice too. A famous chef from Mumbai, Tid Gusto prepared a new dish and named it 'Tid Rice'. He posted the recipe in his newly designed blog for community voting, where a user...
[{"input": "3\n4\ntilak +\ntilak +\ntilak -\ntilaj +\n3\nratna +\nshashi -\nratna -\n3\nbhavani -\nbhavani +\nbhavani -", "output": "0\n-2\n-1\n"}, {"input": "3\n4\ntilak +\nkalit +\ntilak -\ntilak +\n3\nratna +\nshashi -\nratna -\n3\nbhavani -\nbhavani +\nbhavani -", "output": "2\n-2\n-1\n"}, {"input": "3\n4\nuilak +\...
code_stdio
[ { "content": "Amicable numbers are two different numbers so related that the sum of the proper divisors of each is equal to the other number. (A proper divisor of a number is a positive factor of that number other than the number itself. For example, the proper divisors of 6 are 1, 2, and 3.) \n\nFor example, t...
[{"input": "220221\n282224", "output": "[false]", "fn_name": "amicable_numbers"}, {"input": "122265\n139815", "output": "[true]", "fn_name": "amicable_numbers"}, {"input": "299920\n9284", "output": "[false]", "fn_name": "amicable_numbers"}, {"input": "999220\n2849", "output": "[false]", "fn_name": "amicable_numbers"}, ...
code_functional
[ { "content": "One day Vasya decided to have a look at the results of Berland 1910 Football Championship’s finals. Unfortunately he didn't find the overall score of the match; however, he got hold of a profound description of the match's process. On the whole there are n lines in that description each of which d...
[{"input": "89\nH\nVOCI\nVOCI\nH\nVOCI\nH\nH\nVOCI\nVOCI\nVOCI\nH\nH\nH\nVOCI\nVOCI\nVOCI\nH\nVOCI\nVOCI\nH\nVOCI\nVOCI\nVOCI\nH\nVOCI\nH\nVOCI\nH\nVOCI\nH\nVOCI\nVOCI\nH\nVOCI\nVOCI\nVOCI\nVOCI\nVOCI\nVOCI\nH\nVOCI\nVOCI\nVOCI\nVOCI\nH\nVOCI\nH\nH\nVOCI\nH\nVOCI\nH\nVOCI\nVOCI\nVOCI\nVOCI\nVOCI\nVOCI\nVOCI\nH\nH\nVOCI...
code_stdio
[ { "content": "Your friend has invited you to a party, and tells you to meet them in the line to get in. The one problem is it's a masked party. Everyone in line is wearing a colored mask, including your friend. Find which people in line could be your friend.\n\nYour friend has told you that he will be wearing a...
[{"input": "[\"blue\", \"green\", \"red\", \"green\", \"blue\", \"blue\", \"red\"]", "output": "[1]", "fn_name": "friend_find"}, {"input": "[\"blue\", \"blue\", \"blue\", \"blue\", \"blue\", \"blue\", \"blue\"]", "output": "[0]", "fn_name": "friend_find"}, {"input": "[\"blue\", \"red\", \"blue\", \"blue\", \"red\", \"b...
code_functional
[ { "content": "Monocarp wrote down two numbers on a whiteboard. Both numbers follow a specific format: a positive integer $x$ with $p$ zeros appended to its end.\n\nNow Monocarp asks you to compare these two numbers. Can you help him?\n\n\n-----Input-----\n\nThe first line contains a single integer $t$ ($1 \\le ...
[{"input": "23\n1 3\n100 1\n2 3\n200 1\n3 3\n300 1\n4 3\n400 1\n5 3\n500 1\n6 3\n600 1\n1 7\n1000000 4\n10 9\n1000000 4\n100 14\n1000010 4\n1000 7\n1000000 4\n10000 6\n1000000 4\n100000 5\n1000000 4\n1000000 4\n1000000 4\n1000000 4\n100000 5\n1000000 4\n10000 6\n1000000 4\n1000 7\n1000000 4\n100 8\n1000000 4\n10 9\n100...
code_stdio
[ { "content": "There are N points on the 2D plane, i-th of which is located on (x_i, y_i).\nThere can be multiple points that share the same coordinate.\nWhat is the maximum possible Manhattan distance between two distinct points?\nHere, the Manhattan distance between two points (x_i, y_i) and (x_j, y_j) is defi...
[{"input": "3\n-2 -2\n2 -1\n-29 1", "output": "33\n"}, {"input": "3\n-1 -4\n1 -1\n-23 4", "output": "30\n"}, {"input": "3\n-1 -4\n1 -1\n-23 0", "output": "26\n"}, {"input": "3\n-2 -2\n-2 0\n11 3", "output": "18\n"}, {"input": "3\n-2 -2\n-2 0\n16 3", "output": "23\n"}, {"input": "3\n-3 -1\n0 6\n14 0", "output": "20\n"},...
code_stdio
[ { "content": "Twilight Sparkle once got a crystal from the Crystal Mine. A crystal of size n (n is odd; n > 1) is an n × n matrix with a diamond inscribed into it.\n\nYou are given an odd integer n. You need to draw a crystal of size n. The diamond cells of the matrix should be represented by character \"D\". A...
[{"input": "101\n", "output": "**************************************************D**************************************************\n*************************************************DDD*************************************************\n************************************************DDDDD******************************...
code_stdio
[ { "content": "Take an input string and return a string that is made up of the number of occurences of each english letter in the input followed by that letter, sorted alphabetically. The output string shouldn't contain chars missing from input (chars with 0 occurence); leave them out.\n\nAn empty string, or one...
[{"input": "\"The quick brown fox jumps over the lazy dog.\"", "output": "[\"1a1b1c1d3e1f1g2h1i1j1k1l1m1n4o1p1q2r1s2t2u1v1w1x1y1z\"]", "fn_name": "string_letter_count"}, {"input": "\"abccdefgdhijklmno_pqrsTuvwxYz\"", "output": "[\"1a1b2c2d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z\"]", "fn_name": "string_letter_count...
code_functional
[ { "content": "Sagheer is walking in the street when he comes to an intersection of two roads. Each road can be represented as two parts where each part has 3 lanes getting into the intersection (one for each direction) and 3 lanes getting out of the intersection, so we have 4 parts in total. Each part has 4 lig...
[{"input": "1 0 0 1\n0 0 0 0\n0 0 -1 0\n0 -1 0 0\n", "output": "YES\n"}, {"input": "0 1 0 0\n0 0 0 -1\n0 0 0 1\n0 0 0 0\n", "output": "YES\n"}, {"input": "1 1 0 1\n0 -1 0 0\n0 0 0 0\n0 0 0 0\n", "output": "YES\n"}, {"input": "0 0 0 0\n0 0 1 1\n0 0 0 0\n-1 0 0 0\n", "output": "YES\n"}, {"input": "0 0 0 0\n0 0 0 1\n0 0 0...
code_stdio
[ { "content": "Mobile Display Keystrokes\n\nDo you remember the old mobile display keyboards? Do you also remember how inconvenient it was to write on it?\nWell, here you have to calculate how much keystrokes you have to do for a specific word.\n\nThis is the layout:\n\n\n\nReturn the amount of keystrokes of inp...
[{"input": "\"longwordwhichdontreallymakessense\"", "output": "[107]", "fn_name": "mobile_keyboard"}, {"input": "\"thisisasms\"", "output": "[37]", "fn_name": "mobile_keyboard"}, {"input": "\"codewars\"", "output": "[26]", "fn_name": "mobile_keyboard"}, {"input": "\"zruf\"", "output": "[16]", "fn_name": "mobile_keyboar...
code_functional
[ { "content": "A prime number n (11, 19, 23, etc.) that divides by 4 and has 3 has an interesting property. The results of calculating the remainder of the square of a natural number (1, 2, ..., n -1) of 1 or more and less than n divided by n are the same, so they are different from each other. The number is (n ...
[{"input": "11\n173\n0", "output": "4\n4\n4\n4\n4\n84\n86\n86\n84\n86\n84\n86\n86\n84\n84\n86\n86\n84\n84\n84\n84\n86\n86\n86\n86\n84\n84\n84\n84\n84\n86\n86\n86\n84\n86\n84\n86\n84\n84\n84\n84\n84\n84\n86\n84\n84\n86\n84\n86\n86\n86\n84\n86\n84\n86\n84\n84\n86\n84\n84\n84\n84\n86\n86\n84\n86\n86\n86\n84\n86\n86\n84\n8...
code_stdio
[ { "content": "At a geometry lesson Bob learnt that a triangle is called right-angled if it is nondegenerate and one of its angles is right. Bob decided to draw such a triangle immediately: on a sheet of paper he drew three points with integer coordinates, and joined them with segments of straight lines, then he...
[{"input": "-100 -100 100 100 -100 100\n", "output": "RIGHT\n"}, {"input": "-100 -100 100 -100 0 73\n", "output": "NEITHER\n"}, {"input": "-45 -87 -34 -79 -60 -62\n", "output": "NEITHER\n"}, {"input": "-45 -87 -44 -79 -60 -62\n", "output": "NEITHER\n"}, {"input": "-50 -37 -93 -12 -30 -80\n", "output": "NEITHER\n"}, {"i...
code_stdio
[ { "content": "AquaMoon and Cirno are playing an interesting game with arrays. Cirno has prepared two arrays $a$ and $b$, both consist of $n$ non-negative integers. AquaMoon can perform the following operation an arbitrary number of times (possibly zero):\n\nShe chooses two indices $i$ and $j$ ($1 \\le i, j \\le...
[{"input": "4\n25\n0 0 0 0 0 8 1 0 9 0 8 8 0 0 11 0 0 0 9 3 10 4 10 4 0\n2 0 0 1 10 0 10 6 0 4 0 2 0 3 11 1 2 11 0 7 6 0 0 9 0\n25\n0 0 6 0 6 2 0 0 4 1 0 0 8 1 0 9 6 6 7 0 5 4 3 0 6\n8 0 0 2 0 9 0 6 5 0 4 9 9 0 0 3 0 6 0 6 7 0 0 0 0\n25\n4 0 7 0 5 0 0 0 0 0 5 2 1 5 5 9 7 0 0 0 0 0 0 2 1\n5 0 0 1 7 1 0 0 5 1 2 0 0 0 3 0...
code_stdio
[ { "content": "Tanya has $n$ candies numbered from $1$ to $n$. The $i$-th candy has the weight $a_i$.\n\nShe plans to eat exactly $n-1$ candies and give the remaining candy to her dad. Tanya eats candies in order of increasing their numbers, exactly one candy per day.\n\nYour task is to find the number of such c...
[{"input": "105\n5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 4 5 5 5 6\n", "output": "100\n"}, {"input": "105\n5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5...
code_stdio
[ { "content": "Description overhauled by V\n\n---\n\nI've invited some kids for my son's birthday, during which I will give to each kid some amount of candies.\n\nEvery kid hates receiving less amount of candies than any other kids, and I don't want to have any candies left - giving it to my kid would be bad for...
[{"input": "101", "output": "[7041757898200960193617914702466542659236800]", "fn_name": "candies_to_buy"}, {"input": "100", "output": "[69720375229712477164533808935312303556800]", "fn_name": "candies_to_buy"}, {"input": "61", "output": "[591133442051411133755680800]", "fn_name": "candies_to_buy"}, {"input": "60", "out...
code_functional
[ { "content": "Ilya lives in a beautiful city of Chordalsk.\n\nThere are $n$ houses on the street Ilya lives, they are numerated from $1$ to $n$ from left to right; the distance between every two neighboring houses is equal to $1$ unit. The neighboring houses are $1$ and $2$, $2$ and $3$, ..., $n-1$ and $n$. The...
[{"input": "41\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1\n", "output": "39\n"}, {"input": "41\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1\n", "output": "39\n"}, {"input": "41\n1 2 3 4 5 6 7 8 9 10...
code_stdio
[ { "content": "The bear has a string s = s_1s_2... s_{|}s| (record |s| is the string's length), consisting of lowercase English letters. The bear wants to count the number of such pairs of indices i, j (1 ≤ i ≤ j ≤ |s|), that string x(i, j) = s_{i}s_{i} + 1... s_{j} contains at least one string \"bear\" as a sub...
[{"input": "pbearjbearbebearnbabcffbearbearwubearjezpiorrbearbearjbdlbearbearqbearjbearwipmsbearoaftrsebearzsnqb\n", "output": "4419\n"}, {"input": "pbearjbearbebearnbabcffbearbearwubearjezpiorrbearbearjbdlbearbearqbearjbearwipmsbearoaftrsebearzsnqb\n", "output": "4419\n"}, {"input": "pbearjbearbebfarnbabcffbearbearwub...
code_stdio
[ { "content": "In 2937, DISCO creates a new universe called DISCOSMOS to celebrate its 1000-th anniversary.\n\nDISCOSMOS can be described as an H \\times W grid. Let (i, j) (1 \\leq i \\leq H, 1 \\leq j \\leq W) denote the square at the i-th row from the top and the j-th column from the left.\n\nAt time 0, one r...
[{"input": "1486 120 1001", "output": "960152848\n"}, {"input": "328 102 1011", "output": "261361566\n"}, {"input": "328 102 1111", "output": "647647330\n"}, {"input": "328 117 1011", "output": "407646568\n"}, {"input": "117 102 1111", "output": "841656819\n"}, {"input": "141 120 1001", "output": "236970719\n"}, {"inpu...
code_stdio
[ { "content": "Kamil likes streaming the competitive programming videos. His MeTube channel has recently reached 100 million subscribers. In order to celebrate this, he posted a video with an interesting problem he couldn't solve yet. Can you help him?\n\nYou're given a tree — a connected undirected graph consis...
[{"input": "32\n402528994560 0 0 0 0 0 0 932646223872 893192888700 0 813583026900 0 0 0 0 143521875000 0 177570054144 186624000000 0 517655600000 202145625000 341007975000 0 116252718750 0 148561875000 0 304819200000 248474688000 0 103125000000\n29 25\n20 24\n8 21\n23 3\n32 14\n29 30\n31 24\n28 12\n7 10\n18 1\n11 7\n29...
code_stdio
[ { "content": "Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered from 1 to |s| from left to right, where |s| is the length of the given string.\n\nPasha didn't like his present very much so he decided to change it. After h...
[{"input": "xwcxggxvfqbdklewbxkjzibmufnaywuxsqvwakefxbbkfandvigasbhbatsxyqxicrosatfsfybedklsaztyyiuurfbrzmwumujy\n100\n14 43 30 13 8 19 33 7 16 14 15 35 5 18 44 1 35 1 18 7 50 47 9 49 28 29 39 37 27 17 19 12 5 24 37 42 37 23 35 31 10 26 5 38 40 34 42 47 2 40 43 32 16 25 14 45 35 38 46 48 49 27 49 38 10 49 5 7 3 3 41 25...
code_stdio
[ { "content": "FizzBuzz is a game in which integers of 1 or more are spoken in order according to the following rules.\n\n* \"Fizz\" when divisible by 3\n\n* \"Buzz\" when divisible by 5\n\n* \"FizzBuzz\" when divisible by both 3 and 5\n\n* At other times, that number\n\n\n\n\nAn example of the progress of the g...
[{"input": "10010000000", "output": "990079BuzzFizz141999\n"}, {"input": "10010000001", "output": "90079BuzzFizz1419990\n"}, {"input": "10000000001", "output": "3FizzBuzz1418650796F\n"}, {"input": "10000001001", "output": "418650928FizzBuzz141\n"}, {"input": "10000000010", "output": "1418650796Fizz141865\n"}, {"input":...
code_stdio
[ { "content": "Sometimes some words like \"localization\" or \"internationalization\" are so long that writing them many times in one text is quite tiresome.\n\nLet's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.\n\...
[{"input": "20\nlkpmx\nkovxmxorlgwaomlswjxlpnbvltfv\nhykasjxqyjrmybejnmeumzha\ntuevlumpqbbhbww\nqgqsphvrmupxxc\ntrissbaf\nqfgrlinkzvzqdryckaizutd\nzzqtoaxkvwoscyx\noswytrlnhpjvvnwookx\nlpuzqgec\ngyzqfwxggtvpjhzmzmdw\nrlxjgmvdftvrmvbdwudra\nvsntnjpepnvdaxiporggmglhagv\nxlvcqkqgcrbgtgglj\nlyxwxbiszyhlsrgzeedzprbmcpduvq\n...
code_stdio
[ { "content": "Iahub and Sorin are the best competitive programmers in their town. However, they can't both qualify to an important contest. The selection will be made with the help of a single problem. Blatnatalag, a friend of Iahub, managed to get hold of the problem before the contest. Because he wants to mak...
[{"input": "100\n-57 -64 83 76 80 27 60 76 -80 -56 52 72 -17 92 -96 87 41 -88 94 89 12 42 36 34 -100 -43 -42 62 3 87 -69 -6 -27 -59 -7 5 -90 -23 63 -87 -60 -92 -40 54 -16 -47 67 -64 10 33 -19 53 -7 -62 16 -74 -36 4 -75 -55 92 3 -22 43 -30 48 -27 88 -58 41 36 8 -40 -30 -18 16 22 -66 -91 -46 48 -60 -45 -89 37 -76 52 81 8...
code_stdio
[ { "content": "Taro had his own personal computer and set a password for login. However, Taro inadvertently forgot the password. Then, remembering that there was a piece of paper with the password written down, Taro found the paper and was surprised to see it. The paper was cut and there were only fragments, and...
[{"input": "KUSATSU\nLSATSU", "output": "No\n"}, {"input": "RUPCUAOC\n__PC", "output": "Yes\n"}, {"input": "KUSATSU\nLSATRU", "output": "No\n"}, {"input": "RUPCUAOC\n__OC", "output": "Yes\n"}, {"input": "KUSATSU\nLRATSU", "output": "No\n"}, {"input": "KUSATSU\nLRAUSU", "output": "No\n"}, {"input": "KTSATSU\nLRAUSU", "o...
code_stdio
[ { "content": "There is one card each with the numbers from \"1\" to \"10\", for a total of 10 cards. This card has numbers on the front and nothing on the back. Using this card, you and your opponent will play the game according to the following rules.\n\n1. You and your opponent are dealt a total of two cards,...
[{"input": "1 2 3\n4 1 10\n5 1 10", "output": "YES\nYES\nYES\n"}, {"input": "1 2 3\n5 6 10\n4 9 10", "output": "YES\nYES\nYES\n"}, {"input": "1 2 3\n7 1 10\n5 1 10", "output": "YES\nYES\nYES\n"}, {"input": "1 4 3\n5 6 10\n4 9 10", "output": "YES\nYES\nYES\n"}, {"input": "1 2 3\n7 2 10\n5 1 10", "output": "YES\nYES\nYES...
code_stdio
[ { "content": "The map of Bertown can be represented as a set of $n$ intersections, numbered from $1$ to $n$ and connected by $m$ one-way roads. It is possible to move along the roads from any intersection to any other intersection. The length of some path from one intersection to another is the number of roads ...
[{"input": "20 50\n20 3\n5 16\n1 3\n10 11\n10 15\n15 9\n20 9\n14 6\n16 5\n13 4\n11 5\n3 20\n13 17\n11 8\n11 6\n12 14\n16 18\n17 13\n18 7\n3 1\n8 10\n17 15\n7 2\n9 13\n5 11\n6 1\n2 16\n8 18\n10 8\n4 13\n9 15\n14 12\n1 6\n9 20\n7 18\n6 14\n7 6\n18 16\n2 7\n3 11\n15 17\n3 12\n14 10\n4 14\n19 4\n11 10\n4 19\n8 12\n17 8\n12...
code_stdio
[ { "content": "For a given array $a_1, a_2, a_3, ... , a_N$ of $N$ elements and $Q$ integers $x_i$ as queries, for each query, print the number of combinations of two integers $(l, r)$ which satisfies the condition: $1 \\leq l \\leq r \\leq N$ and $a_l + a_{l+1} + ... + a_{r-1} + a_r \\leq x_i$.\n\nConstraints\n...
[{"input": "6 5\n1 2 3 2 7 6\n12 12 12 21 15", "output": "14\n14\n14\n21\n18\n"}, {"input": "6 5\n1 4 3 2 12 6\n10 1 22 25 23", "output": "11\n1\n18\n19\n19\n"}, {"input": "6 5\n1 4 3 2 12 1\n10 1 22 25 23", "output": "11\n2\n20\n21\n21\n"}, {"input": "6 5\n1 2 3 0 7 6\n6 17 16 21 29", "output": "11\n19\n19\n21\n21\n"}...
code_stdio
[ { "content": "Currently, XXOC's rap is a string consisting of zeroes, ones, and question marks. Unfortunately, haters gonna hate. They will write $x$ angry comments for every occurrence of subsequence 01 and $y$ angry comments for every occurrence of subsequence 10. You should replace all the question marks wit...
[{"input": "?00?0?0??00100?00?001111?11???1010110100?00?0?1?1?1001??001010?011???0000???????1111?1?101100110?001\n801448 0\n", "output": "819079856\n"}, {"input": "10001?0011?0??1?1001??001?001?0100??00???0???011?00111???1?1?0?0?0??1?1?1?1?1010?1101?0000?1??11?101\n0 1\n", "output": "680\n"}, {"input": "0101010??01???1...
code_stdio
[ { "content": "Pasha has many hamsters and he makes them work out. Today, n hamsters (n is even) came to work out. The hamsters lined up and each hamster either sat down or stood up.\n\nFor another exercise, Pasha needs exactly $\\frac{n}{2}$ hamsters to stand up and the other hamsters to sit down. In one minute...
[{"input": "200\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n", "output": "100\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
code_stdio
[ { "content": "During the quarantine, Sicromoft has more free time to create the new functions in \"Celex-2021\". The developers made a new function GAZ-GIZ, which infinitely fills an infinite table to the right and down from the upper left corner as follows:\n\n [Image] The cell with coordinates $(x, y)$ is at...
[{"input": "1\n118730819 699217111 1229905591 978426672\n", "output": "310250620284395093\n"}, {"input": "1\n118730819 699217111 995255402 1762535216\n", "output": "932024458581475216\n"}, {"input": "1\n118730819 699217111 1571293294 978426672\n", "output": "405569330969823476\n"}, {"input": "1\n159574671 699217111 157...
code_stdio
[ { "content": "Peter has a sequence of integers a_1, a_2, ..., a_{n}. Peter wants all numbers in the sequence to equal h. He can perform the operation of \"adding one on the segment [l, r]\": add one to all elements of the sequence with indices from l to r (inclusive). At that, Peter never chooses any element as...
[{"input": "99 1999\n1999 1998 1997 1996 1995 1994 1993 1992 1991 1990 1989 1988 1987 1986 1985 1984 1983 1982 1981 1980 1979 1978 1977 1976 1975 1974 1973 1972 1971 1970 1969 1968 1967 1966 1965 1964 1963 1962 1961 1960 1959 1958 1957 1956 1955 1954 1953 1952 1951 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960...
code_stdio
[ { "content": "Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.\nThere are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.\nWhat is the minimum amount of mone...
[{"input": "1 100000\n1000000000 100000\n", "output": "100000000000000\n"}, {"input": "1 100000\n1000000100 100000", "output": "100000010000000\n"}, {"input": "1 100000\n1000000110 100010", "output": "100000011000000\n"}, {"input": "1 100000\n1000000101 100000", "output": "100000010100000\n"}, {"input": "1 100000\n1000...
code_stdio
[ { "content": "Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nOne day Petya encountered a tree with n vertexes. Besides, the tree was weig...
[{"input": "10\n4 8 480392999\n3 4 32525297\n9 7 417904789\n6 2 836294777\n5 3 616099185\n1 7 830574407\n8 10 838073755\n6 10 547050646\n2 1 12607780\n", "output": "0"}, {"input": "5\n1 2 1000000000\n2 3 747774\n3 4 4\n4 5 8447854\n", "output": " 36\n"}, {"in...
code_stdio
[ { "content": "Pig is visiting a friend.\n\nPig's house is located at point 0, and his friend's house is located at point m on an axis.\n\nPig can use teleports to move along the axis.\n\nTo use a teleport, Pig should come to a certain point (where the teleport is located) and choose where to move: for each tele...
[{"input": "70 100\n0 99\n1 87\n1 94\n1 4\n2 72\n3 39\n3 69\n4 78\n5 85\n7 14\n8 59\n12 69\n14 15\n14 76\n17 17\n19 53\n19 57\n19 21\n21 35\n21 83\n24 52\n24 33\n27 66\n27 97\n30 62\n30 74\n30 64\n32 63\n35 49\n37 60\n40 99\n40 71\n41 83\n42 66\n42 46\n45 83\n51 76\n53 69\n54 82\n54 96\n54 88\n55 91\n56 88\n58 62\n62 8...
code_stdio
[ { "content": "In graph theory, a graph is a collection of nodes with connections between them.\nAny node can be connected to any other node exactly once, and can be connected to no nodes, to some nodes, or to every other node.\nNodes cannot be connected to themselves\nA path through a graph is a sequence of nod...
[{"input": "[[1], [0, 2, 3], [1], [1], [5], [4, 6, 7], [5], [5]]", "output": "[false]", "fn_name": "isTree"}, {"input": "[[1], [0, 2], [1, 3, 5], [2, 4], [3, 5], [4, 2]]", "output": "[false]", "fn_name": "isTree"}, {"input": "[[1, 2], [0, 3], [0, 3], [1, 2, 4], [3]]", "output": "[false]", "fn_name": "isTree"}, {"input"...
code_functional
[ { "content": "The weather is fine today and hence it's high time to climb the nearby pine and enjoy the landscape.\n\nThe pine's trunk includes several branches, located one above another and numbered from 2 to y. Some of them (more precise, from 2 to p) are occupied by tiny vile grasshoppers which you're at wa...
[{"input": "1000000000 1000100000\n", "output": "1000099999\n"}, {"input": "1000000000 1000101000\n", "output": "1000100999\n"}, {"input": "1013025570 1803009236\n", "output": "1803009227\n"}, {"input": "649229491 1684787431\n", "output": "1684787413\n"}, {"input": "171837140 1253572168\n", "output": "1253572147\n"}, {...
code_stdio
[ { "content": "Ivan had string s consisting of small English letters. However, his friend Julia decided to make fun of him and hid the string s. Ivan preferred making a new string to finding the old one. \n\nIvan knows some information about the string s. Namely, he remembers, that string ti occurs in string s a...
[{"input": "18\nabacab 2 329 401\nabadabacabae 1 293\nbacab 1 2\nabacabadabacabaga 1 433\nc 1 76\nbaca 1 26\ndab 1 72\nabagabaca 1 445\nabaea 1 397\ndabac 1 280\nab 2 201 309\nca 1 396\nabacabadab 1 497\nac 1 813\ncaba 1 444\nad 1 167\nbadab 1 358\naba 1 421\n", "output": "abacabaaaaaaaaaaaaaaaaaaabacaaaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.\n\nKolya remembers that at the beginning of the game his game-coin score wa...
[{"input": "1000000000\n", "output": "YES\n"}, {"input": "1000000000\n", "output": "YES"}, {"input": "999129999\n", "output": "YES\n"}, {"input": "917261049\n", "output": "YES\n"}, {"input": "803219200\n", "output": "YES\n"}, {"input": "908000000\n", "output": "YES\n"}, {"input": "999999987\n", "output": "YES\n"}, {"in...
code_stdio