messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "Beaches are filled with sand, water, fish, and sun. Given a string, calculate how many times the words `\"Sand\"`, `\"Water\"`, `\"Fish\"`, and `\"Sun\"` appear without overlapping (regardless of the case).\n\n## Examples\n\n```python\nsum_of_a_beach(\"WAtErSlIde\") ==> 1\nsum_...
[{"input": "\"saNdsandwaterwAterfishfishsunsunsandwatersandsandwaterwaterfishfishsunsunsandwatersandsandwaterwaterfishfishsunsunsandwatersandsandwaterwaterfishfishsunsunsandwatersandsandwaterwaterfishfishsunsunsandwatersandsandwaterwaterfishfishsunsunsandwatersandsandwaterwaterfishfishsunsunsandwatersandsandwaterwaterf...
code_functional
[ { "content": "Maksim walks on a Cartesian plane. Initially, he stands at the point $(0, 0)$ and in one move he can go to any of four adjacent points (left, right, up, down). For example, if Maksim is currently at the point $(0, 0)$, he can go to any of the following points in one move: $(1, 0)$; $(0, 1)$; $...
[{"input": "39\n27 47\n30 9\n18 28\n49 16\n10 12\n25 13\n44 11\n13 9\n3 8\n30 2\n8 30\n38 32\n7 29\n38 43\n27 37\n6 13\n21 25\n31 18\n17 26\n51 52\n27 40\n10 43\n50 27\n41 41\n2 11\n38 45\n37 43\n20 52\n36 11\n43 46\n4 39\n22 32\n42 11\n8 37\n9 17\n38 8\n41 1\n24 50\n47 7\n", "output": "861\n"}, {"input": "39\n27 47\n3...
code_stdio
[ { "content": "Ayush, Ashish and Vivek are busy preparing a new problem for the next Codeforces round and need help checking if their test cases are valid.\n\nEach test case consists of an integer $n$ and two arrays $a$ and $b$, of size $n$. If after some (possibly zero) operations described below, array $a$ can...
[{"input": "24\n4\n1 2 3 4\n1 2 3 4\n4\n1 2 3 4\n1 2 4 3\n4\n1 2 3 4\n1 3 2 4\n4\n1 2 3 4\n1 3 4 2\n4\n1 2 3 4\n1 4 2 3\n4\n1 2 3 4\n1 4 3 2\n4\n1 2 3 4\n2 1 3 4\n4\n1 2 3 4\n2 1 4 3\n4\n1 2 3 4\n2 3 1 4\n4\n1 2 3 4\n2 3 4 1\n4\n1 2 3 4\n2 4 1 3\n4\n1 2 3 4\n2 4 3 1\n4\n1 2 3 4\n3 1 2 4\n4\n1 2 3 4\n3 1 4 2\n4\n1 2 3 4...
code_stdio
[ { "content": "You are given a tree consisting of n nodes. You generate an array from the tree by marking nodes one by one.\n\nInitially, when no nodes are marked, a node is equiprobably chosen and marked from the entire tree. \n\nAfter that, until all nodes are marked, a node is equiprobably chosen and marked f...
[{"input": "6\n2 1\n2 3\n6 1\n2 4\n2 5\n", "output": "583333343\n"}, {"input": "6\n2 1\n2 3\n6 1\n2 4\n1 5\n", "output": "500000009\n"}, {"input": "6\n3 1\n2 3\n6 1\n2 4\n1 5\n", "output": "875000012\n"}, {"input": "6\n2 1\n1 3\n6 1\n1 4\n2 5\n", "output": "416666675\n"}, {"input": "6\n2 1\n1 3\n6 1\n1 4\n4 5\n", "outp...
code_stdio
[ { "content": "Snuke is having a barbeque party.\nAt the party, he will make N servings of Skewer Meal.\nExample of a serving of Skewer Meal\nHe has a stock of 2N skewers, all of which will be used in Skewer Meal. The length of the i-th skewer is L_i.\nAlso, he has an infinite supply of ingredients.\nTo make a s...
[{"input": "100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100...
code_stdio
[ { "content": "Little Vasya went to the supermarket to get some groceries. He walked about the supermarket for a long time and got a basket full of products. Now he needs to choose the cashier to pay for the products.\n\nThere are n cashiers at the exit from the supermarket. At the moment the queue for the i-th ...
[{"input": "1\n90\n90 90 90 90 51 90 88 90 112 67 90 90 90 13 90 48 164 172 98 102 73 90 90 90 90 124 90 90 46 139 90 84 85 90 90 18 52 30 90 90 90 87 47 90 146 30 90 97 153 90 90 227 248 90 90 28 174 139 90 90 62 90 23 124 90 36 81 90 90 82 90 54 90 163 105 147 90 14 90 90 151 90 90 82 90 90 90 56 90 90\n", "output": ...
code_stdio
[ { "content": "Find the number of k-divisible numbers on the segment [a, b]. In other words you need to find the number of such integer values x that a ≤ x ≤ b and x is divisible by k.\n\n\n-----Input-----\n\nThe only line contains three space-separated integers k, a and b (1 ≤ k ≤ 10^18; - 10^18 ≤ a ≤ b ≤ 10^18...
[{"input": "1 -1000000000000000000 1000000000000000000\n", "output": "2000000000000000001\n"}, {"input": "2 -1000000000000000000 1000000000000000000\n", "output": "1000000000000000001\n"}, {"input": "1000000000000000000 -1000000000000000000 1000000000000000000\n", "output": "3\n"}, {"input": "100000000000000321 -100000...
code_stdio
[ { "content": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his gl...
[{"input": "4 4\n1000000000 1000000000 1000000000 1000000000\n", "output": "999999999\n"}, {"input": "4 4\n1000000000 1000000000 1000000000 1000000000\n", "output": "999999999\n"}, {"input": "4 4\n1000000000 1000000100 1000000000 1000000000\n", "output": "1000000000"}, {"input": "4 4\n1000000000 1000000100 1000000000 1...
code_stdio
[ { "content": "n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out a_{i} people in clockwise order, starting from the n...
[{"input": "101 30\n1122517 913885 829106 127375 848316 278798 520469 1178427 61045 916519 767861 370006 75224 321506 124981 1042689 131175 689748 422800 181309 1322 2845106 1285852 60402 766045 1676905 513021 206603 979480 962688\n", "output": "4 90 71 46 100 15 77 24 63 81 85 3 26 72 31 58 84 13 11 21 52 37 97 38 101...
code_stdio
[ { "content": "Linear Kingdom has exactly one tram line. It has n stops, numbered from 1 to n in the order of tram's movement. At the i-th stop ai passengers exit the tram, while bi passengers enter it. The tram is empty before it arrives at the first stop. Also, when the tram arrives at the last stop, all passe...
[{"input": "100\n0 1\n0 0\n0 0\n1 0\n0 0\n0 1\n0 1\n1 1\n0 0\n0 0\n1 1\n0 0\n1 1\n0 1\n1 1\n0 1\n1 1\n1 0\n1 0\n0 0\n1 0\n0 0\n1 0\n0 0\n0 1\n1 1\n1 1\n0 1\n0 0\n1 0\n1 1\n0 1\n1 0\n1 1\n0 1\n1 1\n1 0\n0 0\n0 0\n0 1\n0 0\n-1 1\n1 1\n0 0\n1 1\n1 1\n0 0\n0 1\n1 0\n0 1\n0 0\n0 1\n0 1\n1 1\n1 1\n1 1\n0 0\n0 0\n1 1\n0 1\n0 ...
code_stdio
[ { "content": "The Fair Nut is going to travel to the Tree Country, in which there are $n$ cities. Most of the land of this country is covered by forest. Furthermore, the local road system forms a tree (connected graph without cycles). Nut wants to rent a car in the city $u$ and go by a simple path to city $v$. ...
[{"input": "10\n81 34 31 38 69 62 54 18 72 29\n4 8 12\n2 9 25\n4 5 17\n5 7 35\n10 1 13\n9 3 53\n7 6 22\n1 6 82\n3 10 42\n", "output": " 187\n"}, {"input": "10\n11 43 11 96 18 53 25 89 31 41\n2 4 41\n7 1 88\n3 2 19\n10 3 38\n8 4 97\n7 5 21\n7 2 71\n3 6 69\n9 5 ...
code_stdio
[ { "content": "For two sequences S and T of length N consisting of 0 and 1, let us define f(S, T) as follows:\n - Consider repeating the following operation on S so that S will be equal to T. f(S, T) is the minimum possible total cost of those operations.\n - Change S_i (from 0 to 1 or vice versa). The cost of t...
[{"input": "5\n52 67 72 25 79\n", "output": "269312\n"}, {"input": "5\n52 103 72 25 79", "output": "292096\n"}, {"input": "5\n63 103 72 25 79", "output": "306176\n"}, {"input": "1\n1000000000\n", "output": "999999993\n"}, {"input": "5\n20 67 72 25 79", "output": "227072\n"}, {"input": "5\n2 124 30 25 55", "output": "17...
code_stdio
[ { "content": "You have $n \\times n$ square grid and an integer $k$. Put an integer in each cell while satisfying the conditions below. All numbers in the grid should be between $1$ and $k$ inclusive. Minimum number of the $i$-th row is $1$ ($1 \\le i \\le n$). Minimum number of the $j$-th column is $1$ ($1 ...
[{"input": "250 1000000000\n", "output": "770503193\n"}, {"input": "250 1000000000\n", "output": "770503193\n"}, {"input": "216 1142401243\n", "output": "820247611\n"}, {"input": "246 1140071398\n", "output": "783102336\n"}, {"input": "218 1771958988\n", "output": "699159875\n"}, {"input": "244 315404017\n", "output": ...
code_stdio
[ { "content": "Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he win...
[{"input": "186\n2 1 2 1 1 1 1 1 2 1 1 2 2 2 1 1 2 2 1 1 1 2 1 1 2 2 1 1 1 2 2 1 1 1 1 1 2 1 1 1 2 1 2 1 1 2 1 1 1 2 2 2 2 2 2 2 1 2 1 2 1 1 2 1 2 2 1 1 1 1 1 2 2 1 2 2 1 2 2 1 1 1 2 2 1 1 2 2 1 2 2 1 2 2 2 2 2 1 1 1 1 2 1 1 2 2 2 2 2 2 1 1 1 1 1 2 1 1 2 2 1 2 2 1 1 1 1 1 2 2 1 1 2 2 1 2 2 2 1 2 1 2 1 1 2 1 2 2 2 2 1 2...
code_stdio
[ { "content": "Due to the coronavirus pandemic, city authorities obligated citizens to keep a social distance. The mayor of the city Semyon wants to light up Gluharniki park so that people could see each other even at night to keep the social distance.\n\nThe park is a rectangular table with $n$ rows and $m$ col...
[{"input": "5\n2 1\n1 3\n2 2\n1 3\n5 4\n", "output": "1\n2\n2\n2\n10\n"}, {"input": "2\n461 5299\n118 177\n", "output": "1221420\n10443\n"}, {"input": "2\n461 5299\n176 177\n", "output": "1221420\n15576\n"}, {"input": "5\n5 1\n1 3\n2 4\n1 3\n7 3\n", "output": "3\n2\n4\n2\n11\n"}, {"input": "2\n461 5299\n176 213\n", "ou...
code_stdio
[ { "content": "Mike and !Mike are old childhood rivals, they are opposite in everything they do, except programming. Today they have a problem they cannot solve on their own, but together (with you) — who knows? \n\nEvery one of them has an integer sequences a and b of length n. Being given a query of the form o...
[{"input": "17\n714413739 -959271262 714413739 -745891378 926207665 -404845105 -404845105 -959271262 -189641729 -670860364 714413739 -189641729 192457837 -745891378 -670860364 536388097 -959271262\n-417715348 -959271262 -959271262 714413739 -189641729 571055593 571055593 571055593 -417715348 -417715348 192457837 -74589...
code_stdio
[ { "content": "Little town Nsk consists of n junctions connected by m bidirectional roads. Each road connects two distinct junctions and no two roads connect the same pair of junctions. It is possible to get from any junction to any other junction by these roads. The distance between two junctions is equal to th...
[{"input": "5 6 1 5\n1 2\n1 3\n1 4\n4 5\n3 5\n2 5\n", "output": "3\n"}, {"input": "5 6 1 5\n1 2\n1 3\n1 4\n4 5\n3 5\n1 5\n", "output": "4\n"}, {"input": "5 6 1 5\n1 2\n1 3\n2 4\n4 5\n3 5\n2 5\n", "output": "3\n"}, {"input": "5 6 1 5\n1 2\n1 3\n1 4\n1 5\n3 5\n2 5\n", "output": "4\n"}, {"input": "5 6 1 5\n1 2\n1 5\n1 4\n...
code_stdio
[ { "content": "Sereja loves number sequences very much. That's why he decided to make himself a new one following a certain algorithm.\n\nSereja takes a blank piece of paper. Then he starts writing out the sequence in m stages. Each time he either adds a new number to the end of the sequence or takes l first ele...
[{"input": "7\n1 53989\n1 47249\n1 71935\n2 1 3\n1 84520\n1 84185\n2 6 1\n14\n1 2 3 4 5 6 7 8 9 10 11 12 13 14\n", "output": "53989 47249 71935 53989 53989 53989 84520 84185 53989 47249 71935 53989 53989 53989\n"}, {"input": "7\n1 53989\n1 47249\n1 71935\n2 1 3\n1 84520\n1 84185\n2 6 1\n14\n1 2 3 4 5 6 7 8 9 10 11 12 1...
code_stdio
[ { "content": "Ancient Egyptians are known to have used a large set of symbols $\\sum$ to write on the walls of the temples. Fafa and Fifa went to one of the temples and found two non-empty words S_1 and S_2 of equal lengths on the wall of temple written one below the other. Since this temple is very ancient, so...
[{"input": "107 100000\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 0 0 0 0 0 0 0\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...
code_stdio
[ { "content": "-----Problem Statement-----\nSereja has a sequence of n integers a[1], a[2], ..., a[n]. Sereja can do following transformation of the array:\n\n- create a new sequence of n integers b[1], b[2], ..., b[n]in this way: (1 ≤ i ≤ n)\n\n- Replace the sequence a by b, i.e., a[i] = b[i] for all i in [1...
[{"input": "3\n0 1 -1 0\n5 0 -1 1\n7 2 -1 1", "output": "0\n999999977\n999999629\n"}, {"input": "3\n-24 12 0 -1\n-1 -6 1 -2\n102 1 -1 1", "output": "0\n0\n810970227\n"}, {"input": "3\n-24 12 0 -1\n-1 -6 1 -2\n198 1 -1 1", "output": "0\n0\n249722532\n"}, {"input": "3\n-24 12 0 -1\n-1 -2 1 -2\n198 0 -1 1", "output": "0\n...
code_stdio
[ { "content": "Is the number even?\n\nIf the numbers is even return `true`. If it's odd, return `false`. \n\n\nOh yeah... the following symbols/commands have been disabled!\n\n use of ```%```\n use of ```.even?``` in Ruby\n use of ```mod``` in Python\n\nWrite Python code to solve this problem. Define a top-level...
[{"input": "15", "output": "[false]", "fn_name": "is_even"}, {"input": "27", "output": "[false]", "fn_name": "is_even"}, {"input": "3", "output": "[false]", "fn_name": "is_even"}, {"input": "14", "output": "[true]", "fn_name": "is_even"}, {"input": "26", "output": "[true]", "fn_name": "is_even"}, {"input": "2", "output...
code_functional
[ { "content": "Given a random string consisting of numbers, letters, symbols, you need to sum up the numbers in the string. \n\nNote:\n\n- Consecutive integers should be treated as a single number. eg, `2015` should be treated as a single number `2015`, NOT four numbers\n- All the numbers should be treaded as po...
[{"input": "\"aHR0cDovL3d3dy5jb2Rld2Fycy5jb20va2F0YS9uZXcvamF2YXNjcmlwdA==\"", "output": "[53]", "fn_name": "sum_from_string"}, {"input": "\"In 2015, I want to know how much does iPhone 6+ cost?\"", "output": "[2021]", "fn_name": "sum_from_string"}, {"input": "\"a30561ff4fb19170aa598b1431b52edad1fcc3e0\"", "output": "[...
code_functional
[ { "content": "Alice is playing with some stones.\n\nNow there are three numbered heaps of stones. The first of them contains $a$ stones, the second of them contains $b$ stones and the third of them contains $c$ stones.\n\nEach time she can do one of two operations: take one stone from the first heap and two st...
[{"input": "64\n0 0 0\n0 0 1\n0 0 2\n0 0 3\n0 1 0\n0 1 1\n0 1 2\n0 1 3\n0 2 0\n0 2 1\n0 2 2\n0 2 3\n0 3 0\n0 3 1\n0 3 2\n0 3 3\n1 0 0\n1 0 1\n1 0 2\n1 0 3\n1 1 0\n1 1 1\n1 1 2\n1 1 3\n1 2 0\n1 2 1\n1 2 2\n1 2 3\n1 3 0\n1 3 1\n1 3 2\n1 3 3\n2 0 0\n2 0 1\n2 0 2\n2 0 3\n2 1 0\n2 1 1\n2 1 2\n2 1 3\n2 2 0\n2 2 1\n2 2 2\n2 2...
code_stdio
[ { "content": "You are given an integer $n$. In $1$ move, you can do one of the following actions:\n\nerase any digit of the number (it's acceptable that the number before the operation has exactly one digit and after the operation, it is \"empty\");\n\nadd one digit to the right.\n\nThe actions may be performed...
[{"input": "12\n825\n8888\n4\n157\n146\n1\n301\n19634\n1504\n10521\n1000000000\n687194767\n", "output": "2\n3\n0\n2\n1\n0\n2\n3\n3\n3\n9\n2\n"}, {"input": "12\n825\n4320\n12\n75\n113\n1\n186\n10133\n2180\n12699\n1000000000\n687194767\n", "output": "2\n2\n1\n3\n2\n0\n1\n4\n3\n3\n9\n2\n"}, {"input": "12\n825\n8888\n4\n15...
code_stdio
[ { "content": "Recently Luba learned about a special kind of numbers that she calls beautiful numbers. The number is called beautiful iff its binary representation consists of k + 1 consecutive ones, and then k consecutive zeroes.\n\nSome examples of beautiful numbers: 1_2 (1_10); 110_2 (6_10); 1111000_2 (12...
[{"input": "32640\n", "output": "32640\n"}, {"input": "97920\n", "output": "32640\n"}, {"input": "32640\n", "output": "32640\n"}, {"input": "97920\n", "output": "32640\n"}, {"input": "12096\n", "output": "2016\n"}, {"input": "38304\n", "output": "2016\n"}, {"input": "89408\n", "output": "8128\n"}, {"input": "10080\n", ...
code_stdio
[ { "content": "Given two words and a letter, return a single word that's a combination of both words, merged at the point where the given letter first appears in each word. The returned word should have the beginning of the first word and the ending of the second, with the dividing letter in the middle. You can ...
[{"input": "\"JiOdIdA4\"\n\"oopopopoodddasdfdfsd\"\n\"d\"", "output": "[\"JiOdddasdfdfsd\"]", "fn_name": "string_merge"}, {"input": "\"abcdefxxxyzz\"\n\"abcxxxyyyxyzz\"\n\"x\"", "output": "[\"abcdefxxxyyyxyzz\"]", "fn_name": "string_merge"}, {"input": "\"apowiejfoiajsf\"\n\"iwahfeijouh\"\n\"j\"", "output": "[\"apowiejo...
code_functional
[ { "content": "Given are positive integers N and K.\n\nDetermine if the 3N integers K, K+1, ..., K+3N-1 can be partitioned into N triples (a_1,b_1,c_1), ..., (a_N,b_N,c_N) so that the condition below is satisfied. Any of the integers K, K+1, ..., K+3N-1 must appear in exactly one of those triples.\n\n* For every...
[{"input": "1 -12", "output": "-12 -11 -10\n"}, {"input": "1 -20", "output": "-20 -19 -18\n"}, {"input": "1 -33", "output": "-33 -32 -31\n"}, {"input": "1 -36", "output": "-36 -35 -34\n"}, {"input": "1 -26", "output": "-26 -25 -24\n"}, {"input": "1 -16", "output": "-16 -15 -14\n"}, {"input": "1 -10", "output": "-10 -9 ...
code_stdio
[ { "content": "Ridbit starts with an integer $n$.\n\nIn one move, he can perform one of the following operations:\n\ndivide $n$ by one of its proper divisors, or\n\nsubtract $1$ from $n$ if $n$ is greater than $1$.\n\nA proper divisor is a divisor of a number, excluding itself. For example, $1$, $2$, $4$, $5$, a...
[{"input": "6\n1\n2\n3\n10\n10\n18\n", "output": "0\n1\n2\n2\n2\n2\n"}, {"input": "6\n1\n2\n3\n14\n6\n45\n", "output": "0\n1\n2\n2\n2\n3\n"}, {"input": "6\n2\n2\n3\n11\n4\n45\n", "output": "1\n1\n2\n3\n2\n3\n"}, {"input": "6\n2\n1\n3\n11\n4\n45\n", "output": "1\n0\n2\n3\n2\n3\n"}, {"input": "6\n1\n2\n1\n10\n1\n16\n", "...
code_stdio
[ { "content": "Arkady coordinates rounds on some not really famous competitive programming platform. Each round features $n$ problems of distinct difficulty, the difficulties are numbered from $1$ to $n$.\n\nTo hold a round Arkady needs $n$ new (not used previously) problems, one for each difficulty. As for now,...
[{"input": "11000 10\n10000 9999 9998 1967 4502 9995 9994 10823 9992 9991\n", "output": "0000000000\n"}, {"input": "11000 10\n10000 9999 9998 1967 4502 9995 3707 10823 9992 9991\n", "output": "0000000000\n"}, {"input": "11010 10\n10000 9999 9998 1967 4502 9995 3707 10823 9992 9991\n", "output": "0000000000\n"}, {"input...
code_stdio
[ { "content": "You're given a list of n strings a_1, a_2, ..., a_{n}. You'd like to concatenate them together in some order such that the resulting string would be lexicographically smallest.\n\nGiven the list of strings, output the lexicographically smallest concatenation.\n\n\n-----Input-----\n\nThe first line...
[{"input": "13\nclgknjjojyuvdtv\nclgknjjojyuvdtvzxz\nclgknjjojyuvdtvzxzxradqhm\ngvzpnckalbaubfviyhijosiixvxaydxagvymq\nclgknjjojyuvdtvjgcwarwvgilcctdiytmvmvfxxkezymt\nbvwzpuut\nclgknjjojyuvdtvjgcwarwvgilcctdiytmvmvfxxkezymth\nclgknjjojyuvdtvjgcwarwvgilcctdiytmvmvfxxkezymtlkdl\nrbwvaayhhunlvmwexvkmqbquypsnjbdkkeytthektt...
code_stdio
[ { "content": "The Smart Beaver from ABBYY invented a new message encryption method and now wants to check its performance. Checking it manually is long and tiresome, so he decided to ask the ABBYY Cup contestants for help.\n\nA message is a sequence of n integers a1, a2, ..., an. Encryption uses a key which is ...
[{"input": "20 15 17\n4 9 14 11 15 16 15 4 0 10 7 12 10 1 8 6 7 14 1 13\n6 3 14 8 8 11 16 4 5 9 2 13 6 14 15\n", "output": "10 1 3 8 3 15 7 14 1 12 3 10 15 16 16 5 4 15 13 11 "}, {"input": "20 15 17\n4 9 14 11 15 16 15 4 0 10 7 12 10 1 8 6 7 14 1 13\n6 3 14 8 8 11 16 4 6 9 2 13 6 14 15\n", "output": "10 1 3 8 3 15 7 14...
code_stdio
[ { "content": "In this problem, your task is to use ASCII graphics to paint a cardiogram. \n\nA cardiogram is a polyline with the following corners:$(0 ; 0),(a_{1} ; a_{1}),(a_{1} + a_{2} ; a_{1} - a_{2}),(a_{1} + a_{2} + a_{3} ; a_{1} - a_{2} + a_{3}), \\ldots,(\\sum_{i = 1}^{n} a_{i} ; \\sum_{i = 1}^{n}(- 1)^{...
[{"input": "23\n33 42 55 36 73 42 36 39 35 38 38 65 31 33 26 40 20 32 45 32 31 35 36\n", "output": " ...
code_stdio
[ { "content": "A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.\n\nCatacombs consist of several rooms and bidirectional passages between some pairs of them. Some passages can connect a room to itself...
[{"input": "100\n0 0 0 0 0 0 1 4 4 0 2 2 4 1 7 1 11 0 8 4 12 12 3 0 3 2 2 4 3 9 1 5 4 6 9 14 6 2 4 18 7 7 19 11 20 13 17 16 0 34 2 6 12 27 9 4 29 22 4 20 20 17 17 20 37 53 17 3 3 15 1 46 11 24 31 6 12 6 11 18 13 1 5 0 19 10 24 41 16 41 18 52 46 39 16 30 18 23 53 13\n", "output": "66\n"}, {"input": "100\n0 0 0 0 0 0 1 4...
code_stdio
[ { "content": "One of the oddest traditions of the town of Gameston may be that even the town mayor of the next term is chosen according to the result of a game. When the expiration of the term of the mayor approaches, at least three candidates, including the mayor of the time, play a game of pebbles, and the wi...
[{"input": "3 3\n1 2\n3 50\n10 29\n146 32\n39 2\n50 50\n0 0", "output": "0\n0\n1\n5\n31\n1\n13\n"}, {"input": "3 2\n1 2\n3 10\n10 29\n142 48\n39 2\n50 50\n0 0", "output": "1\n0\n2\n5\n63\n1\n13\n"}, {"input": "4 3\n3 3\n3 105\n10 29\n31 32\n27 5\n50 50\n0 0", "output": "3\n0\n1\n5\n30\n7\n13\n"}, {"input": "4 3\n3 3\n3...
code_stdio
[ { "content": "You are given a matrix, consisting of n rows and m columns. The rows are numbered top to bottom, the columns are numbered left to right.\n\nEach cell of the matrix can be either free or locked.\n\nLet's call a path in the matrix a staircase if it: \n\n * starts and ends in the free cell; \n * vi...
[{"input": "9 10 30\n5 3\n5 5\n5 10\n1 3\n5 7\n1 8\n4 9\n2 10\n4 10\n3 1\n2 5\n3 8\n1 7\n2 2\n1 5\n2 3\n3 2\n3 10\n3 2\n2 7\n2 4\n1 4\n4 8\n2 8\n4 1\n5 3\n4 6\n5 8\n1 5\n1 1\n", "output": "1027\n857\n829\n783\n664\n648\n619\n611\n606\n595\n548\n527\n521\n486\n480\n469\n462\n458\n465\n458\n451\n450\n420\n417\n404\n470\n...
code_stdio
[ { "content": "Compute A \\times B, truncate its fractional part, and print the result as an integer.\n\n-----Constraints-----\n - 0 \\leq A \\leq 10^{15}\n - 0 \\leq B < 10\n - A is an integer.\n - B is a number with two digits after the decimal point.\n\n-----Input-----\nInput is given from Standard Input in t...
[{"input": "1000000000000000 9.99\n", "output": "9990000000000000\n"}, {"input": "1010000000000101 9.99", "output": "10089900000001008\n"}, {"input": "1010000000100101 9.99", "output": "10089900001000008\n"}, {"input": "1010000100000101 9.99", "output": "10089900999001008\n"}, {"input": "1010010100000101 9.99", "output...
code_stdio
[ { "content": "Ivan wants to have a good dinner. A good dinner should consist of a first course, a second course, a drink, and a dessert.\n\nThere are $n_1$ different types of first courses Ivan can buy (the $i$-th of them costs $a_i$ coins), $n_2$ different types of second courses (the $i$-th of them costs $b_i...
[{"input": "5 5 5 5\n836 776 809 618 397\n121 629 373 169 333\n589 439 410 388 446\n936 472 433 647 791\n25\n1 2\n4 5\n5 4\n4 1\n3 5\n5 2\n2 4\n3 4\n3 3\n3 2\n4 4\n4 3\n1 1\n1 4\n5 1\n2 3\n1 5\n5 5\n2 5\n3 1\n2 1\n2 2\n1 3\n5 3\n4 2\n25\n1 1\n5 4\n4 1\n1 2\n1 4\n2 3\n3 3\n4 3\n2 2\n5 3\n2 1\n1 3\n5 5\n3 5\n2 4\n3 1\n5 ...
code_stdio
[ { "content": "There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i.\n\nSnuke can perform the following operation zero or more times:\n\n* Choose two distinct cities that are not directly connected by a road, and build a new road between t...
[{"input": "103 1\n6 8", "output": "101\n"}, {"input": "164 1\n6 8", "output": "162\n"}, {"input": "109 1\n5 9", "output": "107\n"}, {"input": "56 1\n12 11", "output": "54\n"}, {"input": "129 1\n4 6", "output": "127\n"}, {"input": "129 1\n6 6", "output": "128\n"}, {"input": "110 1\n3 1", "output": "108\n"}, {"input": "...
code_stdio
[ { "content": "Dima's got a staircase that consists of n stairs. The first stair is at height a_1, the second one is at a_2, the last one is at a_{n} (1 ≤ a_1 ≤ a_2 ≤ ... ≤ a_{n}). \n\nDima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width...
[{"input": "5\n1 2 3 6 6\n25\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 10000000...
code_stdio
[ { "content": "You are given a line of $n$ colored squares in a row, numbered from $1$ to $n$ from left to right. The $i$-th square initially has the color $c_i$.\n\nLet's say, that two squares $i$ and $j$ belong to the same connected component if $c_i = c_j$, and $c_i = c_k$ for all $k$ satisfying $i < k < j$. ...
[{"input": "93\n2805 3621 1888 921 2394 2426 3424 739 4404 1923 2043 1106 305 788 546 1396 2252 4915 1857 1833 2601 3148 1768 1079 893 4669 1939 1231 1019 4578 3202 3645 352 4730 2074 1251 736 168 1377 4630 1542 3083 222 2864 1 4838 1319 1037 4297 552 304 2638 3278 518 4563 513 4313 4620 4907 4990 4785 2808 4135 4171 1...
code_stdio
[ { "content": "You are given an integer $x$ of $n$ digits $a_1, a_2, \\ldots, a_n$, which make up its decimal notation in order from left to right.\n\nAlso, you are given a positive integer $k < n$.\n\nLet's call integer $b_1, b_2, \\ldots, b_m$ beautiful if $b_i = b_{i+k}$ for each $i$, such that $1 \\leq i \\l...
[{"input": "20 10\n21474836472147483648\n", "output": "20\n21474836482147483648\n"}, {"input": "20 19\n19999999999999999999\n", "output": "20\n20000000000000000002\n"}, {"input": "20 19\n19999999999999999999\n", "output": "20\n20000000000000000002\n"}, {"input": "20 10\n21474836472147483648\n", "output": "20\n214748364...
code_stdio
[ { "content": "In Chef's house there are N apples lying in a row on the floor. These apples are numbered from 1 (left most one) to N (right most one). The types of apples are also numbered by positive integers, and the type of apple i is Ti.\nChef has recently brought two trained dogs. Both of the dogs are too i...
[{"input": "5 12\n1 4 4 2 -1", "output": "-1\n"}, {"input": "5 24\n1 4 4 2 -1", "output": "-1\n"}, {"input": "5 24\n1 7 4 2 -1", "output": "-1\n"}, {"input": "5 24\n1 6 4 2 -1", "output": "-1\n"}, {"input": "5 24\n1 6 2 2 -1", "output": "-1\n"}, {"input": "5 16\n1 4 4 2 1", "output": "-1\n"}, {"input": "5 16\n1 4 4 2 0...
code_stdio
[ { "content": "You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.\n\nIn one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the p...
[{"input": "100\nyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\n", "output": "99\n"}, {"input": "100\naaaaaabbcccccccddffffhhhhhhhhiiiiiikkkkkkkkmmmmmmooooooopppprrrrrrrrrttttttvvvvvvvvvvvvxxxxxxxzzzzzz\n", "output": "21\n"}, {"input": "100\nbabaababbaabbabababbabb...
code_stdio
[ { "content": "The numbers 1 to n x n are contained in the n x n square squares one by one, and the sum of the squares in any vertical column and the sum of the squares in any horizontal column are diagonal squares. Those with the same sum of eyes are called magic squares.\n\nThere are the following methods to c...
[{"input": "3\n29\n0", "output": " 4 9 2\n 3 5 7\n 8 1 6\n 407 828 379 800 351 772 323 744 295 716 267 688 239 660 211 632 183 604 155 576 127 548 99 520 71 492 43 464 15\n 16 408 829 380 801 352 773 324 745 296 717 268 689 240 661 212 633 184 605 156 577 128 549 100 521 72 493 44 436\n 437 17...
code_stdio
[ { "content": "Write a program which manipulates a sequence A = {a0, a1, . . . , an-1} with the following operations:\n\n* find(s, t): report the minimum element in as, as+1, . . . ,at.\n* update(i, x): change ai to x.\n\n\n\nNote that the initial values of ai (i = 0, 1, . . . , n−1) are 231-1.\n\nConstraints\n\...
[{"input": "5 5\n0 0 0\n1 2 4\n1 0 0\n1 1 9\n1 1 2", "output": "2147483647\n0\n2147483647\n2147483647\n"}, {"input": "6 5\n1 0 0\n0 1 2\n1 2 3\n1 0 2\n1 2 2", "output": "2147483647\n2147483647\n2\n2147483647\n"}, {"input": "3 5\n0 0 1\n1 1 2\n1 2 2\n1 0 3\n1 0 8", "output": "2147483647\n2147483647\n1\n1\n"}, {"input": ...
code_stdio
[ { "content": "The last stage of Football World Cup is played using the play-off system.\n\nThere are n teams left in this stage, they are enumerated from 1 to n. Several rounds are held, in each round the remaining teams are sorted in the order of their ids, then the first in this order plays with the second, t...
[{"input": "256 128 256\n", "output": "Final!\n"}, {"input": "256 128 129\n", "output": "Final!\n"}, {"input": "256 255 128\n", "output": "Final!\n"}, {"input": "256 107 129\n", "output": "Final!\n"}, {"input": "256 107 240\n", "output": "Final!\n"}, {"input": "256 128 129\n", "output": "Final!"}, {"input": "256 128 25...
code_stdio
[ { "content": "Reverse every other word in a given string, then return the string. Throw away any leading or trailing whitespace, while ensuring there is exactly one space between each word. Punctuation marks should be treated as if they are a part of the word in this kata.\n\nWrite Python code to solve this pro...
[{"input": "\"I really hope it works this time...\"", "output": "[\"I yllaer hope ti works siht time...\"]", "fn_name": "reverse_alternate"}, {"input": "\"Reverse this string, please!\"", "output": "[\"Reverse siht string, !esaelp\"]", "fn_name": "reverse_alternate"}, {"input": "\"This is not a test \"", "output": "[\"...
code_functional
[ { "content": "Dr .: Peter, I've finally done it.\n\nPeter: See you again? What kind of silly invention is this time?\n\nDr .: I finally came up with a revolutionary way to process mathematical formulas on a computer. Look at this table.\n\nOrdinary notation | Dr.'s \"breakthrough\" notation\n--- | ---\n1 + 2 | ...
[{"input": "10 0 82 - /\n4 5 - 31 1 5 * * *\n0 -2 1 + +", "output": "-0.121951\n-155.000000\n-1.000000\n"}, {"input": "10 0 82 - /\n4 5 - 60 1 5 * * *\n0 -2 1 + +", "output": "-0.121951\n-300.000000\n-1.000000\n"}, {"input": "10 0 82 - /\n4 0 - 60 1 5 * * *\n0 -2 1 + +", "output": "-0.121951\n1200.000000\n-1.000000\n"}...
code_stdio
[ { "content": "Given a string of integers, count how many times that integer repeats itself, then return a string showing the count and the integer.\n\n\nExample: `countMe('1123')` (`count_me` in Ruby)\n\n- Here 1 comes twice so `` will be `\"21\"`\n- then 2 comes once so `` will be `\"12\"`\n- then 3 comes once...
[{"input": "\"12322212223443\"", "output": "[\"111213321132132413\"]", "fn_name": "count_me"}, {"input": "\"1123\"", "output": "[\"211213\"]", "fn_name": "count_me"}, {"input": "\"1211\"", "output": "[\"111221\"]", "fn_name": "count_me"}, {"input": "\"21\"", "output": "[\"1211\"]", "fn_name": "count_me"}, {"input": "\"...
code_functional
[ { "content": "n participants of the competition were split into m teams in some manner so that each team has at least one participant. After the competition each pair of participants from the same team became friends.\n\nYour task is to write a program that will find the minimum and the maximum number of pairs ...
[{"input": "1011000000 0001000\n", "output": "511059994500000 511059489505999500\n"}, {"input": "1011100000 0001000\n", "output": "511161099450000 511160594406049500\n"}, {"input": "1011110000 0001000\n", "output": "511171210495000 511170705446054500\n"}, {"input": "1011110000 0001100\n", "output": "464701054490500 511...
code_stdio
[ { "content": "Shapur was an extremely gifted student. He was great at everything including Combinatorics, Algebra, Number Theory, Geometry, Calculus, etc. He was not only smart but extraordinarily fast! He could manage to sum 1018 numbers in a single second.\n\nOne day in 230 AD Shapur was trying to find out if...
[{"input": "1010000011010110011101001101110001110010000111011101110010110110111111001001110100101100010101010001\n0111101000111100101100000101111010100100001000011101010100110011100011010011010101000100101011100011\n", "output": "110110101110101011000100100000101101011000111100000010011000010101110001101010000110100011...
code_stdio
[ { "content": "problem\n\nAt the JOI pasta shop, the recommended pasta for lunch and the set menu of freshly squeezed juice are popular. When ordering this set menu, choose one from each of the three pasta and two juices of the day. The price is the total price of pasta and juice minus 50 yen.\n\nGiven the price...
[{"input": "800\n1126\n900\n198\n330", "output": "948\n"}, {"input": "800\n1126\n900\n132\n330", "output": "882\n"}, {"input": "800\n1126\n206\n132\n330", "output": "288\n"}, {"input": "800\n1126\n180\n132\n330", "output": "262\n"}, {"input": "800\n1126\n180\n29\n330", "output": "159\n"}, {"input": "800\n1126\n280\n29\...
code_stdio
[ { "content": "Jeff has become friends with Furik. Now these two are going to play one quite amusing game.\n\nAt the beginning of the game Jeff takes a piece of paper and writes down a permutation consisting of n numbers: p1, p2, ..., pn. Then the guys take turns to make moves, Jeff moves first. During his move,...
[{"input": "95\n68 56 24 89 79 20 74 69 49 59 85 67 95 66 15 34 2 13 92 25 84 77 70 71 17 93 62 81 1 87 76 38 75 31 63 51 35 33 37 11 36 52 23 10 27 90 12 6 45 32 86 26 60 47 91 65 58 80 78 88 50 9 44 4 28 29 22 8 48 7 19 57 14 54 55 83 5 30 72 18 82 94 43 46 41 3 61 53 73 39 40 16 64 42 21\n", "output": "5076"}, {"inp...
code_stdio
[ { "content": "An array is called `centered-N` if some `consecutive sequence` of elements of the array sum to `N` and this sequence is preceded and followed by the same number of elements. \n\nExample:\n```\n[3,2,10,4,1,6,9] is centered-15\nbecause the sequence 10,4,1 sums to 15 and the sequence \nis preceded by...
[{"input": "[0, 0, 0, -1, 1, 1, -1, 0, 0, 0]\n0", "output": "[true]", "fn_name": "is_centered"}, {"input": "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n0", "output": "[true]", "fn_name": "is_centered"}, {"input": "[3, 2, 10, 4, 1, 6, 9]\n15", "output": "[true]", "fn_name": "is_centered"}, {"input": "[2, 10, 4, 1, 6, 9]\n15", "outp...
code_functional
[ { "content": "Little Artem found a grasshopper. He brought it to his house and constructed a jumping area for him.\n\nThe area looks like a strip of cells 1 × n. Each cell contains the direction for the next jump and the length of that jump. Grasshopper starts in the first cell and follows the instructions writ...
[{"input": "10\n>>>>>>>>><\n1 1 1 1 1 1 1 1 1 6\n", "output": "INFINITE\n"}, {"input": "10\n>>>>>>>>><\n2 1 1 1 1 1 1 1 1 5\n", "output": "INFINITE\n"}, {"input": "10\n>>>>>>>>>>\n1 1 1 1 1 1 2 1 1 100\n", "output": "FINITE\n"}, {"input": "10\n>>>>>>>>><\n1 1 1 1 1 1 1 1 1 4\n", "output": "INFINITE\n"}, {"input": "10\n...
code_stdio
[ { "content": "Dreamoon loves summing up something for no reason. One day he obtains two integers a and b occasionally. He wants to calculate the sum of all nice integers. Positive integer x is called nice if <image> and <image>, where k is some integer number in range [1, a].\n\nBy <image> we denote the quotien...
[{"input": "10000000 10000000\n", "output": "425362313\n"}, {"input": "10000000 9999999\n", "output": "930564389\n"}, {"input": "3865975 13943620\n", "output": "633381536\n"}, {"input": "6407688 3000816\n", "output": "895399645\n"}, {"input": "1507925 5483803\n", "output": "727607740\n"}, {"input": "9900111 1082917\n",...
code_stdio
[ { "content": "### Background\nIn classical cryptography, the Hill cipher is a polygraphic substitution cipher based on linear algebra. It was invented by Lester S. Hill in 1929.\n\n\n\n### Task\n\n\nThis cipher involves a text key which has to be turned into a matrix and text which needs to be encoded. The text...
[{"input": "\"Five + Seven = Twelve\"\n\"math\"", "output": "[\"IVSLIGSLAQEECSWR\"]", "fn_name": "encrypt"}, {"input": "\"CODEWARS IS GREAT\"\n\"wxyz\"", "output": "[\"CICQQIIASSDXKSFP\"]", "fn_name": "encrypt"}, {"input": "\"This is a good day\"\n\"bbaa\"", "output": "[\"AAAAAAGACAGAYA\"]", "fn_name": "encrypt"}, {"in...
code_functional
[ { "content": "Alice and Brown loves games. Today, they will play the following game.\nIn this game, there are two piles initially consisting of X and Y stones, respectively.\nAlice and Bob alternately perform the following operation, starting from Alice:\n - Take 2i stones from one of the piles. Then, throw awa...
[{"input": "13 -1", "output": "Alice\n"}, {"input": "-1 10", "output": "Alice\n"}, {"input": "18 -1", "output": "Alice\n"}, {"input": "-1 14", "output": "Alice\n"}, {"input": "14 -1", "output": "Alice\n"}, {"input": "-1 12", "output": "Alice\n"}, {"input": "-1 21", "output": "Alice\n"}, {"input": "-1 20", "output": "Al...
code_stdio
[ { "content": "Twin adventurers Rin and Len are searching for treasure in the Mirror Cave. The cave has two pairs of rooms, the Hall of Mirrors, and an expensive treasure lies behind the door of the room.\n\nFor convenience, each of the two rooms is considered to have W × H cells arranged in a grid pattern. The ...
[{"input": "5 5\n%#... ...#%\n.#.#. .#.#.\n.#.#. .#.#.\n.#.#. .#.#.\n...#L R#...\n3 2\n.L. .R#\n%.. .&.\n4 1\nL.%. %..R\n0 0", "output": "Yes\nNo\nNo\n"}, {"input": "5 5\n%#... ...#%\n.#.#. .#.#.\n.#.#. .#.#.\n.#.#. .#.#.\n...#L R#...\n3 2\n.L. .R#\n%.. .&.\n4 1\nL.$. %..R\n0 0", "output": "Yes\nNo\nNo\n"}, {"input": "...
code_stdio
[ { "content": "Homer has two friends Alice and Bob. Both of them are string fans.\n\nOne day, Alice and Bob decide to play a game on a string $s = s_1 s_2 \\dots s_n$ of length $n$ consisting of lowercase English letters. They move in turns alternatively and Alice makes the first move.\n\nIn a move, a player mus...
[{"input": "5\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\nzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\nazazazazazazazazazazazazazazazazazazazazazazazazaz\nzazazazazazazazazazazazazazazazazazazazazazazazaza\nzzazzazzazzazzazzazzazzazzazzazzazzazzazzazza\n", "output": "bzbzbzbzbzbzbzbzbzbzbzbzbzbzbzbzbzbz...
code_stdio
[ { "content": "Given a name, turn that name into a perfect square matrix (nested array with the amount of arrays equivalent to the length of each array). \n\nYou will need to add periods (`.`) to the end of the name if necessary, to turn it into a matrix. \n\nIf the name has a length of 0, return `\"name must be...
[{"input": "\"Franklin\"", "output": "[[[\"F\", \"r\", \"a\"], [\"n\", \"k\", \"l\"], [\"i\", \"n\", \".\"]]]", "fn_name": "matrixfy"}, {"input": "\"Beyonce\"", "output": "[[[\"B\", \"e\", \"y\"], [\"o\", \"n\", \"c\"], [\"e\", \".\", \".\"]]]", "fn_name": "matrixfy"}, {"input": "\"Frank\"", "output": "[[[\"F\", \"r\",...
code_functional
[ { "content": "Vasya has got $n$ books, numbered from $1$ to $n$, arranged in a stack. The topmost book has number $a_1$, the next one — $a_2$, and so on. The book at the bottom of the stack has number $a_n$. All numbers are distinct.\n\nVasya wants to move all the books to his backpack in $n$ steps. During $i$-...
[{"input": "10\n4 7 10 2 1 8 3 5 9 6\n4 2 7 1 8 10 5 3 9 6\n", "output": "1 3 0 1 1 0 2 0 1 1 \n"}, {"input": "10\n4 7 10 2 1 8 3 5 9 6\n4 2 7 1 8 10 5 3 9 6\n", "output": "1 3 0 1 1 0 2 0 1 1 "}, {"input": "10\n4 7 10 2 1 8 3 5 9 6\n4 2 7 1 8 10 5 3 7 6\n", "output": "1 3 0 1 1 0 2 0 0 2\n"}, {"input": "10\n4 7 10 2 1...
code_stdio
[ { "content": "D: The Diversity of Prime Factorization\n\nProblem\n\nEbi-chan has the FACTORIZATION MACHINE, which can factorize natural numbers M (greater than 1) in O ($ \\ log $ M) time! But unfortunately, the machine could display only digits and white spaces.\n\nIn general, we consider the factorization of ...
[{"input": "3\n2 3 11", "output": "3\n"}, {"input": "3\n2 2 11", "output": "1\n"}, {"input": "3\n2 2 13", "output": "1\n"}, {"input": "3\n2 3 17", "output": "3\n"}, {"input": "3\n2 2 15", "output": "0\n"}, {"input": "3\n3 2 11", "output": "1\n"}, {"input": "3\n2 2 17", "output": "1\n"}, {"input": "3\n4 3 10", "output":...
code_stdio
[ { "content": "We start with a permutation $a_1, a_2, \\ldots, a_n$ and with an empty array $b$. We apply the following operation $k$ times.\n\nOn the $i$-th iteration, we select an index $t_i$ ($1 \\le t_i \\le n-i+1$), remove $a_{t_i}$ from the array, and append one of the numbers $a_{t_i-1}$ or $a_{t_i+1}$ (i...
[{"input": "6\n2 1\n2 1\n1\n3 2\n1 3 2\n1 3\n4 2\n4 1 3 2\n1 2\n5 3\n4 3 2 5 1\n1 4 5\n6 3\n2 4 5 6 1 3\n2 4 5\n7 3\n7 6 4 3 2 1 5\n1 2 6\n", "output": "1\n0\n2\n0\n0\n4\n"}, {"input": "6\n2 1\n2 1\n1\n3 2\n1 3 2\n1 3\n4 2\n4 1 3 2\n1 2\n5 3\n4 3 2 5 1\n1 4 5\n6 3\n2 4 5 6 1 3\n2 4 5\n7 3\n7 6 4 3 2 1 5\n1 2 6\n", "out...
code_stdio
[ { "content": "You are given a rooted tree with root in vertex 1. Each vertex is coloured in some colour.\n\nLet's call colour c dominating in the subtree of vertex v if there are no other colours that appear in the subtree of vertex v more times than colour c. So it's possible that two or more colours will be d...
[{"input": "15\n1 2 3 1 2 3 3 1 1 3 2 2 1 2 3\n1 2\n1 3\n1 4\n1 14\n1 15\n2 5\n2 6\n2 7\n3 8\n3 9\n3 10\n4 11\n4 12\n4 13\n", "output": "6 5 4 3 2 3 3 1 1 3 2 2 1 2 3 \n"}, {"input": "15\n1 2 3 1 2 3 3 1 1 3 2 2 1 2 3\n1 2\n1 3\n1 4\n1 14\n1 15\n2 5\n2 6\n2 7\n3 8\n3 9\n3 10\n4 11\n4 12\n4 13\n", "output": "6 5 4 3 2 3...
code_stdio
[ { "content": "A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.\n\nCatacombs consist of several rooms and bidirectional passages between some pairs of them. Some passages can connect a room to itself...
[{"input": "100\n0 0 0 0 0 0 1 4 4 0 2 2 4 1 7 1 11 0 8 4 12 12 3 0 3 2 2 4 3 9 1 5 4 6 9 14 6 2 4 18 7 7 19 11 20 13 17 16 0 34 2 6 12 27 9 4 29 22 4 20 20 17 17 20 37 53 17 3 3 15 1 46 11 24 31 6 12 6 11 18 13 1 5 0 19 10 24 41 16 41 18 52 46 39 16 30 18 23 53 13\n", "output": "66\n"}, {"input": "100\n0 0 0 0 0 0 1 4...
code_stdio
[ { "content": "Farmer John has just given the cows a program to play with! The program contains two integer variables, x and y, and performs the following operations on a sequence a_1, a_2, ..., a_{n} of positive integers: Initially, x = 1 and y = 0. If, after any step, x ≤ 0 or x > n, the program immediately t...
[{"input": "98\n94 24 17 92 275858941 58 91 57 13 468038892 42 195790073 494005784 8 468106970 518962936 33 27 61 72 42 206673418 10 82 23 34 29 77 90 39 9 67 34 71 29 95 49 48 60 69 86 64 94 77 48 74 19 96700186 5 67 881058074 663483223 64 64 78 23 8 60 7 17 96 71 70 20 5 63 35 34 63 30 86 76 32 86 11 6 96 10 4 378916...
code_stdio
[ { "content": "You are given an input string.\n\nFor each symbol in the string if it's the first character occurrence, replace it with a '1', else replace it with the amount of times you've already seen it...\n \nBut will your code be **performant enough**?\n\n___\n\n## Examples:\n\n```\ninput = \"Hello,...
[{"input": "\"In this string, I'll make sure the amounts of a character go over 9\"", "output": "[\"11111112221221132112411115312263237221234482193101343525441123124155131\"]", "fn_name": "numericals"}, {"input": "\"hope you 123456789 expected numbers in the string\"", "output": "[\"111111212111111111321231141412115115...
code_functional
[ { "content": "There are various parking lots such as three-dimensional type and tower type in the city to improve the utilization efficiency of the parking lot. In some parking lots, a \"two-stage parking device\" as shown in the figure is installed in one parking space to secure a parking space for two cars. T...
[{"input": "5 5\n136\n68\n82\n84\n114\n2 4\n14\n30\n118\n54\n0 0", "output": "2 3 4 1 5\n1 2 4 3\n"}, {"input": "2 5\n123\n52\n195\n87\n105\n2 4\n18\n30\n80\n24\n0 0", "output": "4 2 3 1 5\n1 2 4 3\n"}, {"input": "1 5\n123\n52\n105\n87\n105\n2 4\n18\n30\n80\n14\n0 0", "output": "2 3 1 5 4\n1 2 4 3\n"}, {"input": "1 5\n...
code_stdio
[ { "content": "Alexey is travelling on a train. Unfortunately, due to the bad weather, the train moves slower that it should!\n\nAlexey took the train at the railroad terminal. Let's say that the train starts from the terminal at the moment $0$. Also, let's say that the train will visit $n$ stations numbered fro...
[{"input": "2\n2\n2 4\n10 12\n0 2\n5\n1 4\n7 8\n9 10\n13 15\n19 20\n1 2 3 4 5\n", "output": "\n12\n32\n"}, {"input": "2\n2\n2 4\n10 12\n0 2\n5\n1 4\n7 8\n9 10\n13 15\n19 20\n1 2 3 4 5\n", "output": "12\n32\n"}, {"input": "2\n2\n2 3\n10 12\n0 2\n5\n1 4\n7 8\n9 10\n13 15\n19 20\n1 2 3 4 5\n", "output": "12\n32\n"}, {"inp...
code_stdio
[ { "content": "You are given an array $a$ of $n$ ($n \\geq 2$) positive integers and an integer $p$. Consider an undirected weighted graph of $n$ vertices numbered from $1$ to $n$ for which the edges between the vertices $i$ and $j$ ($i<j$) are added in the following manner:\n\nIf $gcd(a_i, a_{i+1}, a_{i+2}, \\d...
[{"input": "1\n10 195593331\n886547706 549473499 719535263 337021357 357872635 1071822623 699988186 10455 29750933 887846992\n", "output": "1760339979\n"}, {"input": "1\n10 121406599\n432485522 549473499 522487623 1009120577 698965406 845977171 252631181 1770 81120106 717095635\n", "output": "1092659391\n"}, {"input": ...
code_stdio
[ { "content": "The goal of this exercise is to convert a string to a new string where each character in the new string is `\"(\"` if that character appears only once in the original string, or `\")\"` if that character appears more than once in the original string. Ignore capitalization when determining if a cha...
[{"input": "\"Supralapsarian\"", "output": "[\")()))()))))()(\"]", "fn_name": "duplicate_encode"}, {"input": "\"CodeWarrior\"", "output": "[\"()(((())())\"]", "fn_name": "duplicate_encode"}, {"input": "\"Success\"", "output": "[\")())())\"]", "fn_name": "duplicate_encode"}, {"input": "\"recede\"", "output": "[\"()()()\...
code_functional
[ { "content": "You have to restore the wall. The wall consists of $N$ pillars of bricks, the height of the $i$-th pillar is initially equal to $h_{i}$, the height is measured in number of bricks. After the restoration all the $N$ pillars should have equal heights.\n\nYou are allowed the following operations: put...
[{"input": "100 20 149 72\n67 101 52 15 0 92 26 74 44 61 6 44 45 19 22 8 10 85 67 78 24 61 81 99 62 84 9 71 11 65 5 97 3 72 5 81 81 104 65 85 52 21 20 53 66 91 4 75 84 139 72 27 50 26 9 65 14 6 54 68 6 2 89 78 40 45 98 45 27 51 94 72 67 81 20 19 38 64 14 40 57 21 82 99 37 113 21 22 30 14 73 93 60 8 63 25 27 30 32 13\n"...
code_stdio
[ { "content": "Given is a rooted tree with N vertices numbered 1 to N.\nThe root is Vertex 1, and the i-th edge (1 \\leq i \\leq N - 1) connects Vertex a_i and b_i.\nEach of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0.\nNow, the following Q operations will b...
[{"input": "6 2\n1 2\n1 3\n2 4\n3 6\n2 5\n1 10\n1 10\n", "output": "20 20 20 20 20 20\n"}, {"input": "6 2\n1 2\n1 3\n2 4\n3 6\n2 5\n2 10\n1 10", "output": "10 20 10 20 20 10\n"}, {"input": "6 1\n1 2\n1 3\n2 4\n3 6\n2 5\n1 10\n1 10", "output": "10 10 10 10 10 10\n"}, {"input": "6 2\n1 2\n1 3\n2 4\n3 6\n2 5\n1 14\n1 10",...
code_stdio
[ { "content": "We have N camels numbered 1,2,\\ldots,N. Snuke has decided to make them line up in a row.\n\nThe happiness of Camel i will be L_i if it is among the K_i frontmost camels, and R_i otherwise.\n\nSnuke wants to maximize the total happiness of the camels. Find the maximum possible total happiness of t...
[{"input": "3\n2\n1 3 10\n2 15 10\n3\n2 93 78\n1 71 59\n3 57 129\n19\n19 22 16\n5 90 13\n12 85 70\n19 67 78\n18 16 16\n18 48 28\n5 4 24\n12 97 97\n4 57 87\n18 91 74\n18 100 76\n12 31 11\n9 100 57\n3 76 73\n6 84 93\n1 6 139\n11 75 120\n19 15 3\n12 11 34", "output": "25\n221\n1335\n"}, {"input": "3\n2\n1 3 10\n2 15 10\n3...
code_stdio
[ { "content": "When naming identifiers (variables and functions) in programming, compound words that concatenate words are used. However, if you concatenate them as they are, you will not be able to understand the word breaks, so in general, select and apply the one that is unified from the following naming conv...
[{"input": "get^user_name L\ngetTserNbme U\nemaNresUteG D\nEndOfInput X", "output": "get^userName\nGetTserNbme\nema_nres_ute_g\n"}, {"input": "get^user_name L\nembNresTteg U\nemaNresUteG D\nEndOfInput X", "output": "get^userName\nEmbNresTteg\nema_nres_ute_g\n"}, {"input": "get_user_nbme L\ngetUserOame U\nemaNresUteG D\...
code_stdio
[ { "content": "You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$). \n\nYou want to make the median of the array the largest possible us...
[{"input": "23 290352079\n162011045 845692742 774584765 103906675 222286673 251540072 1067675108 30856336 71306611 790640347 835976636 327687572 387722548 48938195 769656348 341889962 393959831 928029640 320443541 248114937 798473713 159552755 814528707\n", "output": "471308140\n"}, {"input": "23 290352079\n285170966 3...
code_stdio
[ { "content": "Nicholas, a painter is going to paint several new canvases. Nicholas is sure that the canvases will turn out so great that each one will need framing and being hung on the wall. Frames are what Nicholas decided to begin with. \n\nNicholas has n sticks whose lengths equal a1, a2, ... an. Nicholas d...
[{"input": "100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100...
code_stdio
[ { "content": "Polycarp's workday lasts exactly $n$ minutes. He loves chocolate bars and can eat one bar in one minute. Today Polycarp has $k$ bars at the beginning of the workday.\n\nIn some minutes of the workday Polycarp has important things to do and in such minutes he is not able to eat a chocolate bar. In ...
[{"input": "100 19\n0011011110011111111010111101101100101111111111011011111111110111101111101111111101111011111011101110\n", "output": "10\n"}, {"input": "100 19\n0011011110011111111010111101101100101111111111011011111111110111101111101111111101111011111011101110\n", "output": "10\n"}, {"input": "100 89\n00110111100111...
code_stdio
[ { "content": "The executive chef is trying to bring some competitive spirit into his kitchen. He wants to split the chefs into two teams based on their age - he'll form the young and the old team. To make it fair, he will split them evenly or give the young team one person advantage when there is an odd number ...
[{"input": "5\n6 2\n4 -1\n0 28\n3 1\n0 76", "output": "2\n3\n25\n28\n104\n"}, {"input": "5\n0 2\n0 -1\n12 11\n4 1\n5 25", "output": "2\n3\n10\n11\n34\n"}, {"input": "5\n0 2\n2 1\n12 20\n4 0\n13 11", "output": "2\n1\n17\n17\n28\n"}, {"input": "5\n6 1\n4 -1\n0 28\n0 1\n0 76", "output": "1\n2\n26\n29\n105\n"}, {"input": "...
code_stdio
[ { "content": "You helped Dima to have a great weekend, but it's time to work. Naturally, Dima, as all other men who have girlfriends, does everything wrong.\n\nInna and Dima are now in one room. Inna tells Dima off for everything he does in her presence. After Inna tells him off for something, she goes to anoth...
[{"input": "50 10\n1 2 3 4 5 6 7 8 9 10 10 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1\n", "output": "2\n"}, {"input": "50 10\n1 2 3 4 5 4 7 8 9 10 10 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1\n", "output": "2\n"}, {"input": "50 10\n1 2 3 4 5 1...
code_stdio
[ { "content": "**Principal Diagonal** -- The principal diagonal in a matrix identifies those elements of the matrix running from North-West to South-East.\n\n**Secondary Diagonal** -- the secondary diagonal of a matrix identifies those elements of the matrix running from North-East to South-West.\n\nFor example:...
[{"input": "[[88, 2, 2, 5, 1, 1, 2, 2, 5, 1], [4, 1, 6, 1, 1, 1, 2, 2, 7, 1], [1, 8, 1, 6, 2, 1, 2, 1, 5, 1], [1, 5, 2, 7, 2, 1, 1, 2, 5, 1], [1, 8, 2, 6, 1, 1, 2, 2, 5, 1], [1, 2, 2, 5, 1, 1, 2, 2, 5, 1], [1, 2, 2, 1, 1, 1, 1, 2, 5, 1], [1, 2, 1, 5, 1, 1, 2, 1, 5, 1], [1, 1, 2, 5, 1, 1, 2, 2, 1, 1], [88, 2, 2, 5, 1, 1...
code_functional
[ { "content": "The Fair Nut lives in $n$ story house. $a_i$ people live on the $i$-th floor of the house. Every person uses elevator twice a day: to get from the floor where he/she lives to the ground (first) floor and to get from the first floor to the floor where he/she lives, when he/she comes back home in th...
[{"input": "100\n95 81 40 82 80 78 4 86 37 94 1 46 85 6 41 87 100 69 100 87 12 61 55 81 81 32 40 54 22 32 24 73 61 68 76 16 83 76 73 77 41 37 88 46 72 63 2 37 14 49 45 81 75 56 10 101 73 85 41 17 5 2 16 75 28 53 35 77 66 53 69 82 50 95 2 12 35 62 84 46 29 95 91 49 78 14 88 75 58 52 49 31 56 43 55 39 10 72 23 60\n", "ou...
code_stdio
[ { "content": "Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. He cannot do any other calculation.\nGiven are two integers A and B.\nIf Takahashi can calculate A \\times B, print the result; if he cannot, print -1 instead.\n\n-----Constraints----...
[{"input": "20 20\n", "output": "-1\n"}, {"input": "33 106", "output": "-1\n"}, {"input": "5 10\n", "output": "-1\n"}, {"input": "1 11\n", "output": "-1\n"}, {"input": "20 1\n", "output": "-1\n"}, {"input": "11 3\n", "output": "-1\n"}, {"input": "3 14\n", "output": "-1\n"}, {"input": "16 4\n", "output": "-1\n"}, {"inpu...
code_stdio
[ { "content": "2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.\nTask:\nWrite\n```\nsmallest(n)\n```\nthat will find the smallest positive number that is evenly divisible by all of the numbers from 1 to n (n <= 40). \nE.g\n```python\nsmallest(5) == 60 # 1...
[{"input": "19", "output": "[232792560]", "fn_name": "smallest"}, {"input": "20", "output": "[232792560]", "fn_name": "smallest"}, {"input": "17", "output": "[12252240]", "fn_name": "smallest"}, {"input": "18", "output": "[12252240]", "fn_name": "smallest"}, {"input": "13", "output": "[360360]", "fn_name": "smallest"},...
code_functional
[ { "content": "Three years have passes and nothing changed. It is still raining in London, and Mr. Black has to close all the doors in his home in order to not be flooded. Once, however, Mr. Black became so nervous that he opened one door, then another, then one more and so on until he opened all the doors in hi...
[{"input": "250\n1 0 1 1 0 1 0 1 1 1 1 1 1 0 0 1 1 1 0 1 0 0 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 1 0 0 1 0 0 0 1 1 1 0 0 0 1 0 1 1 0 1 1 1 1 0 0 1 1 0 0 1 1 1 1 1 1 1 0 1 0 0 1 1 1 1 1 1 1 1 0 1 0 1 1 1 0 1 0 1 1 1 0 0 1 0 1 1 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 1 1 1 0 1 0 0 1 0 1...
code_stdio
[ { "content": "C: Prayer (Pray)\n\nSome twins are famous for praying before the contest.\n\nThere are four integers $ H, W, X, Y $, and it seems unlucky if $ H \\ times W $ and $ x + y $ are both odd numbers.\n\ninput\n\nFour integers $ H, W, X, Y $ are given, separated by spaces.\n\noutput\n\nOutput \"No\" if y...
[{"input": "-1 -1 -3 -1", "output": "Yes\n"}, {"input": "-2 -1 -3 -1", "output": "Yes\n"}, {"input": "-2 -1 -4 -1", "output": "Yes\n"}, {"input": "0 -1 -4 -1", "output": "Yes\n"}, {"input": "0 -1 -3 -1", "output": "Yes\n"}, {"input": "-1 -1 -2 0", "output": "Yes\n"}, {"input": "0 -1 -5 -1", "output": "Yes\n"}, {"input"...
code_stdio
[ { "content": "After seeing the \"ALL YOUR BASE ARE BELONG TO US\" meme for the first time, numbers X and Y realised that they have different bases, which complicated their relations.\n\nYou're given a number X represented in base b_{x} and a number Y represented in base b_{y}. Compare those two numbers.\n\n\n--...
[{"input": "10 40\n39 39 39 39 39 39 39 39 39 39\n10 39\n38 38 38 38 38 38 38 38 38 38\n", "output": ">\n"}, {"input": "10 40\n39 39 39 14 39 39 39 39 39 39\n10 39\n38 38 38 38 38 38 38 38 38 38\n", "output": ">\n"}, {"input": "10 38\n16 19 37 32 16 7 14 33 16 11\n10 39\n10 27 35 15 31 15 17 16 38 35\n", "output": ">\n...
code_stdio
[ { "content": "X and A are integers between 0 and 9 (inclusive).\nIf X is less than A, print 0; if X is not less than A, print 10.\n\n-----Constraints-----\n - 0 \\leq X, A \\leq 9\n - All values in input are integers.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nX A\n\n-----O...
[{"input": "11 -1", "output": "10\n"}, {"input": "10 -1", "output": "10\n"}, {"input": "19 -1", "output": "10\n"}, {"input": "-1 -1", "output": "10\n"}, {"input": "10 -2", "output": "10\n"}, {"input": "14 -2", "output": "10\n"}, {"input": "14 -1", "output": "10\n"}, {"input": "-2 -2", "output": "10\n"}, {"input": "7 5\...
code_stdio
[ { "content": "Little beaver is a beginner programmer, so informatics is his favorite subject. Soon his informatics teacher is going to have a birthday and the beaver has decided to prepare a present for her. He planted n flowers in a row on his windowsill and started waiting for them to grow. However, after som...
[{"input": "11 18 8\n4744 4993 1340 4982 4982 1437 2765 2200 6975 4989 10703\n", "output": "1358\n"}, {"input": "11 18 8\n4744 4993 7957 4982 4982 1437 2765 2200 6975 4989 10703\n", "output": "1455\n"}, {"input": "11 18 8\n4996 4993 4988 4982 4982 4982 4982 4982 4986 4989 4994\n", "output": "5000\n"}, {"input": "11 18 ...
code_stdio
[ { "content": "## Task\n\nGiven a positive integer, `n`, return the number of possible ways such that `k` positive integers multiply to `n`. Order matters.\n\n**Examples**\n```\nn = 24\nk = 2\n(1, 24), (2, 12), (3, 8), (4, 6), (6, 4), (8, 3), (12, 2), (24, 1) -> 8\n\nn = 100\nk = 1\n100 -> 1\n\nn = 20\nk = 3\n(1...
[{"input": "1000000\n3", "output": "[784]", "fn_name": "multiply"}, {"input": "36\n4", "output": "[100]", "fn_name": "multiply"}, {"input": "100\n1", "output": "[1]", "fn_name": "multiply"}, {"input": "20\n3", "output": "[18]", "fn_name": "multiply"}, {"input": "24\n2", "output": "[8]", "fn_name": "multiply"}, {"input"...
code_functional
[ { "content": "On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the toy.\n\nThe toy consists of n parts and m ropes. Each rope links two parts, but every pair of parts is linked by at most one rope. To split the toy, the child must r...
[{"input": "10 30\n3 6 17 15 13 25 9 12 12 1\n3 8\n1 10\n4 7\n1 7\n3 7\n2 9\n8 10\n3 1\n3 4\n8 6\n10 3\n6 9\n2 3\n10 4\n2 10\n5 8\n9 5\n6 1\n2 1\n7 2\n7 6\n7 10\n4 8\n5 6\n3 6\n4 1\n8 9\n7 9\n4 2\n5 10\n", "output": "211\n"}, {"input": "10 30\n3 6 25 15 13 25 9 12 12 1\n3 8\n1 10\n4 7\n1 7\n3 7\n2 9\n8 10\n3 1\n3 4\n8 ...
code_stdio
[ { "content": "Paul hates palindromes. He assumes that string s is tolerable if each its character is one of the first p letters of the English alphabet and s doesn't contain any palindrome contiguous substring of length 2 or more.\n\nPaul has found a tolerable string s of length n. Help him find the lexicograph...
[{"input": "302 4\nabdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdc...
code_stdio
[ { "content": "Edo has got a collection of n refrigerator magnets!\n\nHe decided to buy a refrigerator and hang the magnets on the door. The shop can make the refrigerator with any size of the door that meets the following restrictions: the refrigerator door must be rectangle, and both the length and the width o...
[{"input": "20 5\n1 12 21 22\n9 10 15 20\n10 12 12 20\n1 1 25 29\n5 10 21 22\n4 9 20 25\n12 10 14 24\n3 3 19 27\n3 4 23 28\n9 1 11 31\n9 14 17 18\n8 12 14 20\n8 11 18 19\n12 3 14 29\n7 8 13 22\n6 4 16 30\n11 3 13 27\n9 16 15 18\n6 13 14 21\n9 12 15 22\n", "output": "4\n"}, {"input": "20 5\n1 12 21 22\n9 10 15 20\n10 12...
code_stdio
[ { "content": "We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}.\n\nLet B be a sequence of K \\times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2.\n\nFind the inversion number of B, modulo 10^9 + 7.\n\nHere the inversion number of B ...
[{"input": "10 998244353\n10 10 10 9 5 12 0 4 7 0", "output": "559205848\n"}, {"input": "10 1051516890\n10 15 10 1 5 4 0 8 4 0", "output": "142815647\n"}, {"input": "10 918571889\n10 9 10 7 7 3 0 11 4 0", "output": "551061978\n"}, {"input": "10 1051516890\n10 9 10 7 5 5 0 4 4 0", "output": "818429624\n"}, {"input": "10...
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\nPetya wonders eagerly what minimum lucky number has the sum of digits equal ...
[{"input": "691900\n", "output": "4444477777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777...
code_stdio
[ { "content": "Problem G Rendezvous on a Tetrahedron\n\nOne day, you found two worms $P$ and $Q$ crawling on the surface of a regular tetrahedron with four vertices $A$, $B$, $C$ and $D$. Both worms started from the vertex $A$, went straight ahead, and stopped crawling after a while.\n\nWhen a worm reached one o...
[{"input": "CD 51 1\nDB 30 1", "output": "YES\n"}, {"input": "CD 51 1\nDB 55 1", "output": "YES\n"}, {"input": "CD 51 1\nDB 19 1", "output": "YES\n"}, {"input": "CD 30 1\nDB 30 2", "output": "YES\n"}, {"input": "CD 51 1\nDB 56 1", "output": "YES\n"}, {"input": "CD 20 1\nDB 103 0", "output": "NO\n"}, {"input": "CD 29 1\...
code_stdio
[ { "content": "Petya recieved a gift of a string s with length up to 10^5 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves: Extract the first character of s and append t with this character. Extract the last character of t and appe...
[{"input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"}, {"input": "bababaaababaabbbbbabbbbbbaaabbabaaaaabbbbbaaaabbbbabaabaabababbbabbabbabaaa...
code_stdio
[ { "content": "Zane the wizard is going to perform a magic show shuffling the cups.\n\nThere are n cups, numbered from 1 to n, placed along the x-axis on a table that has m holes on it. More precisely, cup i is on the table at the position x = i.\n\nThe problematic bone is initially at the position x = 1. Zane w...
[{"input": "203948 2 14\n203948 203947\n39 47\n4959 3030\n1 203947\n2929 12381\n203944 203948\n203947 203944\n203944 203922\n203922 203948\n2495 20495\n29419 5959\n12949 12\n49 29292\n1 94\n1 203\n", "output": "203947\n"}, {"input": "203948 2 14\n203948 203947\n39 38\n4959 3030\n1 203947\n2929 9292\n203944 203948\n2039...
code_stdio
[ { "content": "Ayoub had an array $a$ of integers of size $n$ and this array had two interesting properties: All the integers in the array were between $l$ and $r$ (inclusive). The sum of all the elements was divisible by $3$. \n\nUnfortunately, Ayoub has lost his array, but he remembers the size of the array...
[{"input": "101149 1300011130 1476544836\n", "output": "156648241\n"}, {"input": "101149 686320621 1476544836\n", "output": "113944181\n"}, {"input": "120881 536336525 585696606\n", "output": "915864703\n"}, {"input": "121382 445163929 988375913\n", "output": "594431176\n"}, {"input": "126028 622192701 881885560\n", "o...
code_stdio