messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
1 value
[ { "content": "Andryusha goes through a park each day. The squares and paths between them look boring to Andryusha, so he decided to decorate them.\n\nThe park consists of n squares connected with (n - 1) bidirectional paths in such a way that any square is reachable from any other using these paths. Andryusha d...
[{"input": "50\n8 37\n40 8\n38 40\n10 38\n29 10\n33 29\n17 33\n25 17\n19 25\n3 19\n13 3\n24 13\n12 24\n5 12\n41 5\n11 41\n27 11\n45 27\n6 45\n35 6\n9 35\n50 9\n32 50\n21 32\n22 21\n1 22\n31 1\n28 31\n4 28\n30 4\n7 30\n48 7\n46 48\n16 46\n49 16\n39 49\n18 39\n14 18\n34 14\n23 34\n20 23\n15 20\n44 15\n42 44\n2 42\n36 2\n...
code_stdio
[ { "content": "A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal.\n\nGiven a string S, determine whether it is coffee-like.\n\n-----Constraints-----\n - S is a string of leng...
[{"input": "sippuu\n", "output": "Yes\n"}, {"input": "coffee\n", "output": "Yes\n"}, {"input": "dceett\n", "output": "Yes\n"}, {"input": "otjjmm\n", "output": "Yes\n"}, {"input": "zkrrcc\n", "output": "Yes\n"}, {"input": "abcccc\n", "output": "Yes\n"}, {"input": "iphone\n", "output": "No\n"}, {"input": "mdihxy\n", "out...
code_stdio
[ { "content": "Takahashi has decided to work on K days of his choice from the N days starting with tomorrow.\nYou are given an integer C and a string S. Takahashi will choose his workdays as follows:\n - After working for a day, he will refrain from working on the subsequent C days.\n - If the i-th character of ...
[{"input": "16 4 3\noxxoxoxxxxxooxoo", "output": "1\n6\n12\n16\n"}, {"input": "16 4 3\nooxxoxnyxxoxoxwo", "output": "1\n5\n11\n16\n"}, {"input": "16 4 3\npoxxoxoxxyoxoxxo", "output": "2\n7\n11\n16\n"}, {"input": "16 4 3\nooxxnxoxxyoxxxop", "output": "7\n11\n15\n"}, {"input": "16 4 3\nooxxoxoxxxoxoxxo\n", "output": "11\...
code_stdio
[ { "content": "The Floral Clock has been standing by the side of Mirror Lake for years. Though unable to keep time, it reminds people of the passage of time and the good old days.\n\nOn the rim of the Floral Clock are 2n flowers, numbered from 1 to 2n clockwise, each of which has a colour among all n possible on...
[{"input": "23333\n", "output": "259575428\n"}, {"input": "49997\n", "output": "645043850\n"}, {"input": "10492\n", "output": "914991759\n"}, {"input": "30000\n", "output": "583465411\n"}, {"input": "10001\n", "output": "552705744\n"}, {"input": "49999\n", "output": "791828238\n"}, {"input": "10000\n", "output": "93853...
code_stdio
[ { "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 5\n", "output": "INFINITE\n"}, {"input": "10\n>>>>>>>>><\n1 1 1 1 1 1 1 1 1 1\n", "output": "INFINITE\n"}, {"input": "10\n>>>>>>>>>>\n1 1 1 1 1 1 1 1 1 100\n", "output": "FINITE\n"}, {"input": "10\n>>>>>>>>>>\n1 1 1 1 1 1 1 1 1 100\n", "output": "FINITE\n"}, {"input": "10\n...
code_stdio
[ { "content": "problem\n\nAOR Ika made a set $ S = \\\\ {a_1, ..., a_N \\\\} $ and a map $ f: S → S $. $ f (a_i) = b_i $. For any element $ x $ in the set $ S $, all maps $ g, h: S → S $ satisfying $ g (f (x)) = h (f (x)) $ are $ g (x). ) = Determine if h (x) $ is satisfied, and if not, configure one counterexam...
[{"input": "5\n2 1 3 4 5\n3 4 2 5 1", "output": "Yes\n"}, {"input": "5\n1 2 3 4 5\n2 4 3 5 1", "output": "Yes\n"}, {"input": "5\n1 3 2 4 5\n3 4 2 5 1", "output": "Yes\n"}, {"input": "5\n2 1 3 4 5\n2 4 3 5 1", "output": "Yes\n"}, {"input": "5\n1 4 3 2 5\n3 4 2 5 1", "output": "Yes\n"}, {"input": "5\n2 1 3 4 5\n3 4 2 5 1...
code_stdio
[ { "content": "You are given a sequence of $n$ integers $a_1$, $a_2$, ..., $a_n$. Let us call an index $j$ ($2 \\le j \\le {{n-1}}$) a hill if $a_j > a_{{j+1}}$ and $a_j > a_{{j-1}}$; and let us call it a valley if $a_j < a_{{j+1}}$ and $a_j < a_{{j-1}}$.\n\nLet us define the intimidation value of a sequence as ...
[{"input": "4\n3\n3 14 1\n5\n3 3 2 2 4\n6\n1 6 2 2 2 10\n5\n1 12 1 4 2\n", "output": "0\n0\n0\n0\n"}, {"input": "4\n3\n3 14 1\n5\n3 3 2 1 4\n6\n1 6 2 2 2 10\n5\n1 12 1 4 2\n", "output": "0\n0\n0\n0\n"}, {"input": "4\n3\n1 5 0\n5\n5 4 2 2 -1\n6\n0 8 2 5 4 10\n5\n2 6 1 4 -1\n", "output": "0\n0\n1\n0\n"}, {"input": "4\n3\...
code_stdio
[ { "content": "Bandits appeared in the city! One of them is trying to catch as many citizens as he can.\n\nThe city consists of $n$ squares connected by $n-1$ roads in such a way that it is possible to reach any square from any other square. The square number $1$ is the main square.\n\nAfter Sunday walk all the ...
[{"input": "100\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n0 0 63 70 92 75 4 96 52 33 86 57 53 85 91 62 23 0 28 37 41 69 26 64 7 100 41 19 70 60 1 50 12 98 62 45 7...
code_stdio
[ { "content": "There are n student groups at the university. During the study day, each group can take no more than 7 classes. Seven time slots numbered from 1 to 7 are allocated for the classes.\n\nThe schedule on Monday is known for each group, i. e. time slots when group will have classes are known.\n\nYour t...
[{"input": "20\n1111111\n1101011\n1111011\n0111111\n1111111\n1110111\n1111111\n1111111\n1111111\n1111111\n1110111\n1111111\n0111111\n1011111\n1111111\n1111111\n1101110\n1111111\n1111111\n1111111\n", "output": "20\n"}, {"input": "20\n1111111\n1101011\n1111011\n0111111\n1111111\n1110111\n1111111\n1111111\n1111111\n111111...
code_stdio
[ { "content": "Student Andrey has been skipping physical education lessons for the whole term, and now he must somehow get a passing grade on this subject. Obviously, it is impossible to do this by legal means, but Andrey doesn't give up. Having obtained an empty certificate from a local hospital, he is going to...
[{"input": "8 8\n.#.#.#.#\n#.#.#.#.\n.#.#.#.#\n#.#.#.#.\n.#.#.#.#\n#.#.#.#.\n.#.#.#.#\n#.#.#.#.\n", "output": "NO\n"}, {"input": "8 8\n.#.#.#.#\n.#.#.#.#\n.#.#.#.#\n#.#.#.#.\n.#.#.#.#\n#.#.#.#.\n.#.#.#.#\n#.#.#.#.\n", "output": "NO\n"}, {"input": "8 8\n.#.#.#.#\n.##..#.#\n.#.#.#.#\n#.#.#.#.\n.#.#.#.#\n#.#.#.#.\n.#.#.#....
code_stdio
[ { "content": "In Omkar's last class of math, he learned about the least common multiple, or $LCM$. $LCM(a, b)$ is the smallest positive integer $x$ which is divisible by both $a$ and $b$.\n\nOmkar, having a laudably curious mind, immediately thought of a problem involving the $LCM$ operation: given an integer $...
[{"input": "10\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n", "output": "500000000 500000000\n500000000 500000000\n500000000 500000000\n500000000 500000000\n500000000 500000000\n500000000 500000000\n500000000 500000000\n500000000 500000000\n50...
code_stdio
[ { "content": "Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem!\n\nYou are given $n$ nonnegative integers $a_1, a_2, \\dots, a_n$ arranged in a circle, where $n$ must be odd (ie. $n-1$ is divisible by $2$). Formally, for all $i$ such that $...
[{"input": "41\n67695023 47580738 52676259 26530025 83455112 2392302 23011073 86422683 148437329 42852564 97383338 95729385 6219705 42027049 79082264 1205076 1191075 18025596 75651485 93690196 63851880 23817841 79285846 9296266 60979868 62770176 40911517 96687661 35967137 55930828 78662969 51939718 99402988 89044881 66...
code_stdio
[ { "content": "Recently, Tokitsukaze found an interesting game. Tokitsukaze had $n$ items at the beginning of this game. However, she thought there were too many items, so now she wants to discard $m$ ($1 \\le m \\le n$) special items of them.\n\nThese $n$ items are marked with indices from $1$ to $n$. In the be...
[{"input": "1000000000000000000 20 365\n31881893160049984 103938857870698567 103962228223609431 140762820261865064 175962215264653912 239086305245565642 354522451098745823 383839975876242372 443471287955807705 478923027151493682 511195154588214957 619570919279066139 677571312513476877 705864797651447277 789633853044745...
code_stdio
[ { "content": "You are a secret agent from the Intelligence Center of Peacemaking Committee. You've just sneaked into a secret laboratory of an evil company, Automated Crime Machines.\n\nYour mission is to get a confidential document kept in the laboratory. To reach the document, you need to unlock the door to t...
[{"input": "10 1\n3\n1", "output": "Yes\n"}, {"input": "7 1\n6\n-1", "output": "Yes\n"}, {"input": "11 1\n3\n1", "output": "Yes\n"}, {"input": "6 2\n10\n3", "output": "Yes\n"}, {"input": "7 1\n6\n-2", "output": "Yes\n"}, {"input": "11 1\n2\n1", "output": "Yes\n"}, {"input": "17 1\n4\n0", "output": "Yes\n"}, {"input": "...
code_stdio
[ { "content": "User ainta loves to play with cards. He has a cards containing letter \"o\" and b cards containing letter \"x\". He arranges the cards in a row, and calculates the score of the deck by the formula below.\n\n 1. At first, the score is 0. \n 2. For each block of contiguous \"o\"s with length x the...
[{"input": "29 89946\n", "output": "-269676073\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
code_stdio
[ { "content": "Valera loves his garden, where n fruit trees grow.\n\nThis year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that ...
[{"input": "24 1524\n16 934\n23 1940\n21 1447\n20 417\n24 1340\n22 1932\n13 775\n19 2918\n12 2355\n9 593\n11 2676\n3 1857\n16 868\n13 426\n18 1679\n22 991\n9 2728\n10 2497\n16 1221\n9 772\n23 2522\n24 982\n12 1431\n18 757\n", "output": "25893\n"}, {"input": "24 1524\n16 934\n23 1940\n21 1447\n20 417\n24 1340\n22 1932\n...
code_stdio
[ { "content": "The recent All-Berland Olympiad in Informatics featured n participants with each scoring a certain amount of points.\n\nAs the head of the programming committee, you are to determine the set of participants to be awarded with diplomas with respect to the following criteria: At least one particip...
[{"input": "100\n600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600...
code_stdio
[ { "content": "You are given a complete undirected graph. For each pair of vertices you are given the length of the edge that connects them. Find the shortest paths between each pair of vertices in the graph and return the length of the longest of them.\n\n\n-----Input-----\n\nThe first line of the input contain...
[{"input": "10\n0 1 100 100 100 100 100 100 100 100\n1 0 1 100 100 100 100 100 100 100\n100 1 0 1 100 100 100 100 100 100\n100 100 1 0 1 100 100 100 100 100\n100 100 100 1 0 1 100 100 100 100\n100 100 100 100 1 0 1 100 100 100\n100 100 100 100 100 1 0 1 100 100\n100 100 100 100 100 100 1 0 1 100\n100 100 100 100 100 10...
code_stdio
[ { "content": "Hooray! Polycarp turned n years old! The Technocup Team sincerely congratulates Polycarp!\n\nPolycarp celebrated all of his n birthdays: from the 1-th to the n-th. At the moment, he is wondering: how many times he turned beautiful number of years?\n\nAccording to Polycarp, a positive integer is be...
[{"input": "6\n14\n2\n11\n100500\n23\n1000000000\n", "output": "10\n2\n10\n45\n11\n81\n"}, {"input": "6\n20\n1\n11\n100500\n57\n1000000000\n", "output": "10\n1\n10\n45\n14\n81\n"}, {"input": "6\n18\n1\n9\n100500\n65\n1000000000\n", "output": "10\n1\n9\n45\n14\n81\n"}, {"input": "6\n18\n2\n9\n100500\n33\n1000000000\n", ...
code_stdio
[ { "content": "On a clear night, a boy, Campanella looked up at the sky, there were many stars which have different colors such as red, yellow, green, blue, purple, etc. He was watching the stars and just lost track of time. Presently, he wondered,\n\n| <image>\n---|---\n\n\"There are many stars in the space. W...
[{"input": "8\n1 0 3 3 0 1 14 5\n7\n1 2 -1 8 12 1 5\n0", "output": "NO COLOR\nNO COLOR\n"}, {"input": "8\n1 0 3 3 0 1 14 5\n7\n1 2 -1 8 22 1 5\n0", "output": "NO COLOR\nNO COLOR\n"}, {"input": "8\n1 0 3 3 0 1 14 5\n7\n1 2 -1 8 13 1 5\n0", "output": "NO COLOR\nNO COLOR\n"}, {"input": "8\n3 1 3 3 2 1 16 10\n7\n2 2 1 3 4 ...
code_stdio
[ { "content": "Valera's finally decided to go on holiday! He packed up and headed for a ski resort.\n\nValera's fancied a ski trip but he soon realized that he could get lost in this new place. Somebody gave him a useful hint: the resort has n objects (we will consider the objects indexed in some way by integers...
[{"input": "100\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 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 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n38 2 49 55 6 42 12 100 25 69 85 76 13 22 78 73 37 64 5 21 0 23 61 87 4 16 44 3 98 54 1 91 18 26 82 24 ...
code_stdio
[ { "content": "Santa has to send presents to the kids. He has a large stack of $n$ presents, numbered from $1$ to $n$; the topmost present has number $a_1$, the next present is $a_2$, and so on; the bottom present has number $a_n$. All numbers are distinct.\n\nSanta has a list of $m$ distinct presents he has to ...
[{"input": "2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n6 1\n", "output": "5\n14\n"}, {"input": "2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n4 1\n", "output": "5\n10\n"}, {"input": "2\n3 3\n3 1 2\n3 2 1\n7 2\n4 1 7 3 2 5 4\n5 1\n", "output": "5\n12\n"}, {"input": "2\n3 3\n3 1 2\n3 2 1\n7 2\n5 1 7 3 2 5 6\n3 2\n", "output":...
code_stdio
[ { "content": "Today is the ticket release date for Aizu Entertainment's recommended idol group \"Akabeko & Koboushi\". There are four types of tickets:\n\nS seat 6000 yen\nA seat 4000 yen\nB seat 3000 yen\nC seat 2000 yen\n\nYou, the sales manager, are excitedly waiting for the launch. Finally on sale. It's sel...
[{"input": "3 57\n1 4\n1 -2\n1 2", "output": "171000\n24000\n-12000\n12000\n"}, {"input": "3 57\n1 3\n1 -2\n1 2", "output": "171000\n18000\n-12000\n12000\n"}, {"input": "3 16\n1 4\n1 -2\n1 5", "output": "48000\n24000\n-12000\n30000\n"}, {"input": "3 16\n1 4\n1 -2\n1 2", "output": "48000\n24000\n-12000\n12000\n"}, {"inp...
code_stdio
[ { "content": "In the speed skating badge test, grades are awarded when the time specified for two distances is exceeded. For example, to reach Class A, 500 M requires less than 40.0 seconds and 1000 M requires less than 1 minute and 23 seconds.\n\nCreate a program that takes the time recorded in the speed skati...
[{"input": "70.02963720383003 94.72312922368101\n103.91489947609344 168.84078141503855", "output": "NA\nNA\n"}, {"input": "50.825010742906116 75.69989732783311\n82.26479437960049 146.33206365267094", "output": "D\nNA\n"}, {"input": "40.991466890252646 70.71729331330802\n73.89035215619808 141.43642793972484", "output": ...
code_stdio
[ { "content": "Imp is in a magic forest, where xorangles grow (wut?)\n\n [Image] \n\nA xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equal to zero. Imp has to count the number of distinct xorangles of order n to ge...
[{"input": "2500\n", "output": "700393\n"}, {"input": "1216\n", "output": "160822\n"}, {"input": "2140\n", "output": "614785\n"}, {"input": "1488\n", "output": "239580\n"}, {"input": "1040\n", "output": "145820\n"}, {"input": "1965\n", "output": "545494\n"}, {"input": "1703\n", "output": "352045\n"}, {"input": "1051\n"...
code_stdio
[ { "content": "Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters.\n\nTakahashi wanted to choose a notch and cut the bar at that point into two parts with the same length. How...
[{"input": "12\n101 104 102 187 103 176 110 117 104 102 104 111", "output": "125\n"}, {"input": "12\n001 104 102 187 191 176 110 117 104 102 104 011", "output": "139\n"}, {"input": "12\n001 104 102 187 191 176 110 117 104 102 132 011", "output": "167\n"}, {"input": "12\n100 104 102 105 103 103 100 117 104 102 104 101",...
code_stdio
[ { "content": "The only difference between the easy and the hard versions is the maximum value of $k$.\n\nYou are given an infinite sequence of form \"112123123412345$\\dots$\" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$...
[{"input": "19\n1\n10\n100\n1000\n10000\n100000\n1000000\n10000000\n100000000\n1000000000\n10000000000\n100000000000\n1000000000000\n10000000000000\n100000000000000\n1000000000000000\n10000000000000000\n100000000000000000\n1000000000000000000\n", "output": "1\n4\n1\n4\n9\n2\n6\n2\n6\n8\n1\n1\n9\n8\n3\n7\n6\n1\n1\n"}, {...
code_stdio
[ { "content": "Create a program of the square picking method, which is one of the classical random number generation methods. The square harvesting method was proposed by von Neumann in the mid-1940s.\n\nIn the square picking method, when the number of digits of the generated random number is n, the square of th...
[{"input": "2\n387\n615", "output": "Case 1:\n1497\n2410\n8081\n3025\n1506\n2680\n1824\n3269\n6863\n1007\nCase 2:\n3782\n3035\n2112\n4605\n2060\n2436\n9340\n2356\n5507\n3270\n"}, {"input": "2\n210\n567", "output": "Case 1:\n441\n1944\n7791\n6996\n9440\n1136\n2904\n4332\n7662\n7062\nCase 2:\n3214\n3297\n8702\n7248\n5335...
code_stdio
[ { "content": "Inaka has a disc, the circumference of which is n units. The circumference is equally divided by n points numbered clockwise from 1 to n, such that points i and i + 1 (1 ≤ i < n) are adjacent, and so are points n and 1.\n\nThere are m straight segments on the disc, the endpoints of which are all a...
[{"input": "30000 28\n10601 1119\n11119 20601\n9493 25771\n14351 4869\n13101 3619\n23101 13619\n29869 9351\n6119 15601\n3101 23619\n1851 22369\n11851 2369\n8619 18101\n19579 12933\n18619 28101\n16851 7369\n8101 28619\n24869 4351\n24351 14869\n2690 6851\n9869 19351\n5601 26119\n3976 21301\n21851 12369\n25601 16119\n2449...
code_stdio
[ { "content": "You need to execute several tasks, each associated with number of processors it needs, and the compute power it will consume.\n\nYou have sufficient number of analog computers, each with enough processors for any task. Each computer can execute up to one task at a time, and no more than two tasks ...
[{"input": "50\n83 43 73 75 11 53 10 43 67 38 83 12 70 27 60 13 9 79 61 30 29 71 10 11 95 87 26 26 19 99 13 47 66 93 91 47 90 75 68 3 22 29 59 12 44 41 64 3 99 100\n13 36 69 25 18 33 15 70 12 91 41 44 1 96 80 74 12 80 16 82 88 25 87 17 53 63 3 42 81 6 50 78 34 68 65 78 94 14 53 14 41 97 63 44 21 62 95 37 36 31\n", "out...
code_stdio
[ { "content": "Vova has taken his summer practice this year and now he should write a report on how it went.\n\nVova has already drawn all the tables and wrote down all the formulas. Moreover, he has already decided that the report will consist of exactly $n$ pages and the $i$-th page will include $x_i$ tables a...
[{"input": "94 3\n4 2 1 6 1 1 1 5 1 3 3 3 6 1 6 6 3 5 3 1 4 1 3 6 4 5 3 4 6 5 5 2 1 5 4 5 6 5 2 2 6 5 4 6 1 3 5 1 2 5 5 2 1 3 4 5 6 4 3 1 4 4 1 5 4 4 2 2 2 4 4 3 6 2 6 1 5 6 1 3 5 5 1 3 5 3 5 2 6 1 3 6 1 5\n5 6 3 5 4 1 4 6 3 1 4 4 3 3 6 2 1 1 4 6 4 2 4 1 3 1 5 3 6 2 5 6 1 6 6 2 2 2 2 5 2 6 1 4 1 5 1 3 6 6 5 3 2 6 6 2 5...
code_stdio
[ { "content": "It seems that Borya is seriously sick. He is going visit n doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed order (i.e. Borya should first visit doctor 1, then doctor 2, then doctor 3 and so o...
[{"input": "42\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n", "output": "83\n"}, {"input": "42\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 ...
code_stdio
[ { "content": "Duff is addicted to meat! Malek wants to keep her happy for n days. In order to be happy in i-th day, she needs to eat exactly a_{i} kilograms of meat. [Image] \n\nThere is a big shop uptown and Malek wants to buy meat for her from there. In i-th day, they sell meat for p_{i} dollars per kilogram....
[{"input": "12\n70 11\n18 27\n32 11\n26 158\n91 18\n97 12\n75 43\n75 21\n84 29\n16 3\n133 124\n21 124\n", "output": "6758\n"}, {"input": "12\n70 11\n21 27\n32 11\n26 158\n91 18\n97 12\n75 43\n75 21\n84 29\n16 3\n133 124\n21 124\n", "output": "6791\n"}, {"input": "12\n70 11\n21 27\n32 11\n26 158\n91 18\n97 12\n75 30\n75...
code_stdio
[ { "content": "\"Night gathers, and now my watch begins. It shall not end until my death. I shall take no wife, hold no lands, father no children. I shall wear no crowns and win no glory. I shall live and die at my post. I am the sword in the darkness. I am the watcher on the walls. I am the shield that guards t...
[{"input": "205\n5 5 3 3 6 2 9 3 8 9 6 6 10 8 1 5 3 3 1 2 9 9 9 3 9 10 3 9 8 3 5 6 6 4 6 9 2 9 10 9 5 6 6 7 4 2 6 3 4 1 10 1 7 2 7 7 3 2 6 5 5 2 9 3 8 8 7 6 6 4 2 2 6 2 3 5 7 2 2 10 1 4 6 9 2 3 7 2 2 7 4 4 9 10 7 5 8 6 5 3 6 10 2 7 5 6 6 8 3 3 9 4 3 5 7 9 3 2 1 1 3 2 1 9 3 1 4 4 10 2 5 5 8 1 4 8 5 3 1 10 8 6 5 8 3 5 4 ...
code_stdio
[ { "content": "You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.\n\nWrite a program which reads values of a currency $R_t$ at a certain...
[{"input": "6\n-10\n38\n2\n4\n-2\n8", "output": "48\n"}, {"input": "6\n-17\n38\n2\n4\n-2\n8", "output": "55\n"}, {"input": "6\n-17\n33\n2\n1\n-3\n8", "output": "50\n"}, {"input": "6\n-17\n61\n2\n1\n-3\n8", "output": "78\n"}, {"input": "6\n-17\n45\n2\n1\n-3\n8", "output": "62\n"}, {"input": "6\n-20\n17\n1\n0\n-2\n0", "o...
code_stdio
[ { "content": "In this problem, we only consider strings consisting of lowercase English letters.\n\nStrings s and t are said to be isomorphic when the following conditions are satisfied:\n\n* |s| = |t| holds.\n* For every pair i, j, one of the following holds:\n* s_i = s_j and t_i = t_j.\n* s_i \\neq s_j and t_...
[{"input": "8", "output": "aaaaaaaa\naaaaaaab\naaaaaaba\naaaaaabb\naaaaaabc\naaaaabaa\naaaaabab\naaaaabac\naaaaabba\naaaaabbb\naaaaabbc\naaaaabca\naaaaabcb\naaaaabcc\naaaaabcd\naaaabaaa\naaaabaab\naaaabaac\naaaababa\naaaababb\naaaababc\naaaabaca\naaaabacb\naaaabacc\naaaabacd\naaaabbaa\naaaabbab\naaaabbac\naaaabbba\naaa...
code_stdio
[ { "content": "Sonya was unable to think of a story for this problem, so here comes the formal description.\n\nYou are given the array containing n positive integers. At one turn you can pick any element and increase or decrease it by 1. The goal is the make the array strictly increasing by making the minimum po...
[{"input": "75\n392 593 98 1017 515 448 220 310 475 79 539 294 208 828 75 534 875 493 94 205 656 105 546 493 60 188 222 108 788 504 809 621 934 455 307 236 630 298 938 62 850 421 839 134 950 256 934 817 209 559 866 67 990 835 534 672 733 768 757 516 959 893 275 315 692 927 321 554 801 805 885 12 67 245 495\n", "output"...
code_stdio
[ { "content": "Consider the following arithmetic progression with n terms:\n\n* x, x + d, x + 2d, \\ldots, x + (n-1)d\n\n\n\nWhat is the product of all terms in this sequence? Compute the answer modulo 1\\ 000\\ 003.\n\nYou are given Q queries of this form. In the i-th query, compute the answer in case x = x_i, ...
[{"input": "2\n12 1 5\n42764 449743 2019", "output": "524160\n165266\n"}, {"input": "2\n12 1 5\n42764 376063 2019", "output": "524160\n455865\n"}, {"input": "2\n12 1 5\n23772 376063 2019", "output": "524160\n755257\n"}, {"input": "2\n23 1 5\n23772 376063 2019", "output": "687573\n755257\n"}, {"input": "2\n23 0 5\n23772...
code_stdio
[ { "content": "Rabbits and cats are competing. The rules are as follows.\n\nFirst, each of the two animals wrote n2 integers on a piece of paper in a square with n rows and n columns, and drew one card at a time. Shuffle two cards and draw them one by one alternately. Each time a card is drawn, the two will mark...
[{"input": "3 0 6 11\n2 0 4\n3 0 16\n0 8 5\n1 2 3\n21 5 4\n7 4 7\n20\n11\n6\n9\n10\n18\n6\n2\n3\n8", "output": "USAGI\n"}, {"input": "3 0 6 11\n2 0 4\n3 0 16\n0 8 5\n1 2 3\n21 5 4\n7 4 7\n20\n11\n1\n9\n10\n18\n6\n2\n3\n8", "output": "USAGI\n"}, {"input": "3 0 6 11\n2 0 4\n3 0 16\n0 8 5\n1 2 3\n21 5 4\n7 4 7\n20\n11\n1\...
code_stdio
[ { "content": "Vova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. Now it's totally up to Vova to put the finishing touches.\n\nThe current state of the wall can be respresented by a sequence $a$ of $n$ integers, with $a_i$ be...
[{"input": "20\n10 5 2 3 5 7 7 9 4 9 9 4 9 7 7 5 3 2 5 10\n", "output": "YES\n"}, {"input": "14\n7 7 7 4 3 3 4 5 4 4 5 7 7 7\n", "output": "YES\n"}, {"input": "14\n7 7 7 4 3 3 4 5 4 8 5 7 7 7\n", "output": "YES\n"}, {"input": "13\n5 2 2 1 1 2 5 2 1 1 2 2 5\n", "output": "NO\n"}, {"input": "13\n5 2 2 1 1 2 5 2 1 2 2 2 5...
code_stdio
[ { "content": "Denis, after buying flowers and sweets (you will learn about this story in the next task), went to a date with Nastya to ask her to become a couple. Now, they are sitting in the cafe and finally... Denis asks her to be together, but ... Nastya doesn't give any answer. \n\nThe poor boy was very ups...
[{"input": "10 10\n1101001\n0110000\n0111010\n0010000\n1010000\n0111000\n1011011\n1010010\n1101011\n1111110\n", "output": "9941743758\n"}, {"input": "10 10\n0101111\n0000000\n1111011\n1011011\n1011011\n1111011\n0010010\n1010010\n1101111\n0000000\n", "output": "8993391761\n"}, {"input": "10 10\n1101001\n0110000\n0111010...
code_stdio
[ { "content": "There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.\n\nEvery contestant ...
[{"input": "3\n1000000\n999999 999998\n999997 999996 999995\n999994 999993 999992 999991\n999990 999989 999988 999987 999986\n", "output": "2 1 4 3 6 5\n"}, {"input": "3\n1000000\n999999 999998\n999997 999996 999995\n999994 999993 999992 999991\n999990 999989 999988 999987 999986\n", "output": "2 1 4 3 6 5\n"}, {"input...
code_stdio
[ { "content": "You are given two integers K and S.\n\nThree variable X, Y and Z takes integer values satisfying 0≤X,Y,Z≤K.\n\nHow many different assignments of values to X, Y and Z are there such that X + Y + Z = S? \n\n-----Constraints-----\n - 2≤K≤2500 \n - 0≤S≤3K \n - K and S are integers. \n\n-----Input---...
[{"input": "2500 3750\n", "output": "4691251\n"}, {"input": "2048 2806\n", "output": "3078045\n"}, {"input": "446 491\n", "output": "118173\n"}, {"input": "602 293\n", "output": "43365\n"}, {"input": "2500 7500\n", "output": "1\n"}, {"input": "1198 3594\n", "output": "1\n"}, {"input": "148 35\n", "output": "666\n"}, {"...
code_stdio
[ { "content": "Alex, Bob and Carl will soon participate in a team chess tournament. Since they are all in the same team, they have decided to practise really hard before the tournament. But it's a bit difficult for them because chess is a game for two players, not three.\n\nSo they play with each other according...
[{"input": "100\n2\n3\n1\n2\n3\n3\n3\n1\n1\n1\n1\n3\n3\n3\n3\n1\n2\n3\n3\n3\n3\n3\n3\n3\n1\n2\n2\n2\n3\n1\n1\n3\n3\n3\n3\n3\n3\n3\n3\n1\n2\n3\n3\n3\n1\n1\n1\n1\n3\n3\n3\n3\n1\n2\n3\n1\n2\n2\n2\n3\n3\n2\n1\n3\n3\n1\n2\n3\n1\n1\n1\n2\n2\n2\n3\n1\n1\n1\n1\n1\n1\n3\n2\n2\n2\n2\n2\n2\n3\n1\n2\n2\n2\n2\n2\n3\n3\n2\n1\n1\n", ...
code_stdio
[ { "content": "Given an integer $x$. Your task is to find out how many positive integers $n$ ($1 \\leq n \\leq x$) satisfy $$n \\cdot a^n \\equiv b \\quad (\\textrm{mod}\\;p),$$ where $a, b, p$ are all known constants.\n\n\n-----Input-----\n\nThe only line contains four integers $a,b,p,x$ ($2 \\leq p \\leq 10^6+...
[{"input": "1000002 1000002 1000003 1000000000000\n", "output": "999998\n"}, {"input": "1000002 1000002 1000003 1000000000000\n", "output": "999998\n"}, {"input": "693528 398514 1000003 1000000000000\n", "output": "999995\n"}, {"input": "693528 398514 1000003 1000000000000\n", "output": "999995\n"}, {"input": "812415 8...
code_stdio
[ { "content": "Student Dima from Kremland has a matrix $a$ of size $n \\times m$ filled with non-negative integers.\n\nHe wants to select exactly one integer from each row of the matrix so that the bitwise exclusive OR of the selected integers is strictly greater than zero. Help him!\n\nFormally, he wants to cho...
[{"input": "1 249\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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 67 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": "As a token of his gratitude, Takahashi has decided to give his mother an integer sequence.\nThe sequence A needs to satisfy the conditions below:\n - A consists of integers between X and Y (inclusive).\n - For each 1\\leq i \\leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i.\n...
[{"input": "1000000000000000000 1000000000000000000\n", "output": "1\n"}, {"input": "314159265 358979323846264338\n", "output": "31\n"}, {"input": "275278675 992237867823568722\n", "output": "32\n"}, {"input": "10000 10995116277760000\n", "output": "41\n"}, {"input": "1 1000000000000000000\n", "output": "60\n"}, {"inpu...
code_stdio
[ { "content": "Mr. Frugal bought a new house. He feels deeply in love with his new house because it has a comfortable living room in which he can put himself completely at ease. He thinks his new house is a really good buy.\n\nBut, to his disappointment, the floor of its living room has some scratches on it.\n\n...
[{"input": "4 3\n0 1 1 1\n1 1 1 1\n1 1 1 1\n8 5\n0 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1\n1 0 1 1 1 1 1 1\n1 1 0 0 1 1 1 1\n0 1 1 1 0 1 1 1\n8 8\n0 1 1 0 0 1 1 0\n1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1\n0 1 1 0 0 1 1 0\n0 1 1 0 0 1 1 0\n1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1\n0 1 1 0 0 1 1 0\n10 10\n1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1...
code_stdio
[ { "content": "Dima and his friends have been playing hide and seek at Dima's place all night. As a result, Dima's place got messy. In the morning they decided that they need to clean the place.\n\nTo decide who exactly would clean the apartment, the friends want to play a counting-out game. First, all the guys ...
[{"input": "100\n3 3 1 4 2 4 4 3 1 5 1 1 4 4 3 4 4 3 5 4 5 2 4 3 4 1 2 4 5 4 2 1 5 4 1 1 4 3 2 4 1 2 1 4 4 5 5 4 4 5 3 2 5 1 4 2 2 1 1 2 5 2 5 1 5 3 1 4 3 2 4 3 2 2 4 5 5 1 2 3 1 4 1 2 2 2 5 5 2 3 2 4 3 1 1 2 1 2 1 2\n", "output": "5\n"}, {"input": "100\n2 1 1 3 5 4 4 2 3 4 3 4 5 4 5 4 2 4 5 3 4 5 4 1 1 4 4 1 1 2 5 4 2...
code_stdio
[ { "content": "There is a tree with N vertices numbered 1 through N.\nThe i-th edge connects Vertex x_i and y_i.\nEach vertex is painted white or black.\nThe initial color of Vertex i is represented by a letter c_i.\nc_i = W represents the vertex is white; c_i = B represents the vertex is black.\nA cat will walk...
[{"input": "20\n2 19\n5 13\n6 4\n15 6\n12 19\n13 19\n3 11\n12 3\n3 20\n16 13\n7 14\n3 17\n7 13\n10 20\n20 9\n12 18\n8 3\n10 1\n6 13\nWBWBWBBWWWBBWWBBBBBW", "output": "21\n"}, {"input": "20\n2 19\n5 13\n6 4\n15 6\n12 19\n13 19\n3 11\n12 3\n3 20\n16 13\n7 14\n3 17\n7 13\n10 20\n11 9\n8 18\n8 2\n10 1\n6 13\nWBWBWBBWWWBBWW...
code_stdio
[ { "content": "Vasya has a multiset s consisting of n integer numbers. Vasya calls some number x nice if it appears in the multiset exactly once. For example, multiset \\{1, 1, 2, 3, 3, 3, 4\\} contains nice numbers 2 and 4.\n\nVasya wants to split multiset s into two multisets a and b (one of which may be empty...
[{"input": "100\n92 90 95 93 93 96 93 94 96 97 96 100 93 93 90 95 94 99 100 93 100 98 91 90 90 96 97 94 93 98 90 97 96 100 100 95 99 99 92 96 98 90 92 97 91 94 100 100 99 91 91 97 93 92 97 94 91 91 100 100 94 95 100 100 100 92 92 90 97 93 96 92 91 97 100 96 94 96 97 95 96 90 100 95 95 94 93 99 97 91 93 93 93 99 94 93 9...
code_stdio
[ { "content": "Just in case somebody missed it: this winter is totally cold in Nvodsk! It is so cold that one gets funny thoughts. For example, let's say there are strings with the length exactly n, based on the alphabet of size m. Any its substring with length equal to k is a palindrome. How many such strings e...
[{"input": "1000 1000 1000\n", "output": "850431726\n"}, {"input": "1984 1847 1992\n", "output": "345702953\n"}, {"input": "2000 2000 2000\n", "output": "321179016\n"}, {"input": "1999 2000 2000\n", "output": "675798323\n"}, {"input": "1000 1000 1010\n", "output": "524700271\n"}, {"input": "2000 2000 2872\n", "output":...
code_stdio
[ { "content": "We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor.\n\nThere are n citizens in Kekoland, each person has ci coins. Each day, Robin Hood will take exactly 1 coin from the richest person in the city ...
[{"input": "123 54564\n38 44 41 42 59 3 95 15 45 32 44 69 35 83 94 57 65 85 64 47 24 20 34 86 26 91 98 12 36 96 80 4 70 40 95 38 70 22 58 50 34 84 80 45 14 60 61 43 11 56 19 59 50 63 35 15 97 98 27 13 9 71 32 18 90 10 2 99 75 87 74 83 79 37 89 3 49 27 92 95 49 1 26 82 72 75 81 37 60 98 28 28 10 93 99 63 14 26 69 51 47 ...
code_stdio
[ { "content": "In Berland each high school student is characterized by academic performance — integer value between 1 and 5.\n\nIn high school 0xFF there are two groups of pupils: the group A and the group B. Each group consists of exactly n students. An academic performance of each student is known — integer va...
[{"input": "100\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\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
code_stdio
[ { "content": "A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a positive number (i.e. rays of length $0$ are not a...
[{"input": "100 3\n.*.\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n*...
code_stdio
[ { "content": "Do you know the story about the three musketeers? Anyway, you must help them now.\n\nRichelimakieu is a cardinal in the city of Bearis. He found three brave warriors and called them the three musketeers. Athos has strength a, Borthos strength b, and Caramis has strength c.\n\nThe year 2015 is almo...
[{"input": "30\n34938093 71279712 25853338\n29827587 21741565 52179990 30235076 83272806 10815432 98887688 94542207 99870240 97586453 21739186 30460781 75347784 50711354 12162179 74306503 97398492 88466481 52489587 67579359 53177356 75077523 86044366 14405531 73916272 78242091 49321886 41937821 89258359 51438752\n", "o...
code_stdio
[ { "content": "In this problem at each moment you have a set of intervals. You can move from interval (a, b) from our set to interval (c, d) from our set if and only if c < a < d or c < b < d. Also there is a path from interval I1 from our set to interval I2 from our set if there is a sequence of successive move...
[{"input": "20\n1 1208 1583\n1 -258 729\n1 -409 1201\n1 194 1938\n1 -958 1575\n1 -1466 1752\n2 1 2\n2 1 2\n2 6 5\n1 -1870 1881\n1 -2002 2749\n1 -2002 2984\n1 -2002 3293\n2 2 4\n2 8 10\n2 9 6\n1 -2002 3572\n1 -2002 4175\n1 -2002 4452\n1 -2002 4605\n", "output": "YES\nYES\nYES\nYES\nYES\nNO\n"}, {"input": "20\n1 1208 158...
code_stdio
[ { "content": "Kostya likes Codeforces contests very much. However, he is very disappointed that his solutions are frequently hacked. That's why he decided to obfuscate (intentionally make less readable) his code before upcoming contest.\n\nTo obfuscate the code, Kostya first looks at the first variable name use...
[{"input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\nHe wants to make K moves so that the absolute value of the coordinate ...
[{"input": "-1000000000000000 1000000000000000 1000000000000000\n", "output": "1000000000000000\n"}, {"input": "1000000000000000 1000000000000000 1000000000000000\n", "output": "1000000000000000\n"}, {"input": "1000000000000000 1000100000000000 1000000000000000", "output": "1000000000000000\n"}, {"input": "110111010000...
code_stdio
[ { "content": "Polycarpus got an internship in one well-known social network. His test task is to count the number of unique users who have visited a social network during the day. Polycarpus was provided with information on all user requests for this time period. For each query, we know its time... and nothing ...
[{"input": "10 3 30000\n00:06:54\n00:42:06\n03:49:45\n04:38:35\n05:33:30\n05:51:46\n10:46:34\n14:34:59\n14:40:06\n14:53:13\n", "output": "6\n1\n2\n3\n3\n3\n3\n4\n5\n6\n6\n"}, {"input": "10 3 30000\n00:06:54\n00:42:06\n03:49:45\n04:38:35\n05:33:30\n05:51:46\n10:46:34\n14:34:59\n14:40:06\n14:53:13\n", "output": "6\n1\n2\...
code_stdio
[ { "content": "You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits \"1974\".\n\nConstraints\n\n* 0 \\leq N_1, N_2, N_3, N_4 \\leq 9\n* N_1, N_2, N_3 and N_4 are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\n\nN_1 N...
[{"input": "-1 3 13 -1", "output": "NO\n"}, {"input": "-1 2 13 -1", "output": "NO\n"}, {"input": "-1 2 17 -1", "output": "NO\n"}, {"input": "-1 2 -1 24", "output": "NO\n"}, {"input": "-1 2 17 -2", "output": "NO\n"}, {"input": "-1 1 -1 24", "output": "NO\n"}, {"input": "-1 4 17 -2", "output": "NO\n"}, {"input": "-1 1 -1...
code_stdio
[ { "content": "You are given two strings $s$ and $t$, both consisting only of lowercase Latin letters.\n\nThe substring $s[l..r]$ is the string which is obtained by taking characters $s_l, s_{l + 1}, \\dots, s_r$ without changing the order.\n\nEach of the occurrences of string $a$ in a string $b$ is a position $...
[{"input": "11 3 66\nssszzzzsssz\nsss\n1 1\n1 2\n2 2\n1 3\n2 3\n3 3\n1 4\n2 4\n3 4\n4 4\n1 5\n2 5\n3 5\n4 5\n5 5\n1 6\n2 6\n3 6\n4 6\n5 10\n6 6\n1 7\n2 7\n3 7\n4 7\n5 7\n6 7\n7 7\n1 8\n2 8\n3 8\n4 8\n5 8\n6 8\n7 8\n8 8\n1 9\n2 9\n3 9\n4 9\n5 9\n6 9\n7 9\n8 9\n9 9\n1 10\n2 10\n3 10\n4 10\n5 10\n6 10\n7 10\n8 10\n9 10\n1...
code_stdio
[ { "content": "While Vasya finished eating his piece of pizza, the lesson has already started. For being late for the lesson, the teacher suggested Vasya to solve one interesting problem. Vasya has an array a and integer x. He should find the number of different ordered pairs of indexes (i, j) such that a_{i} ≤ ...
[{"input": "100 2 1\n1 2 2 2 1 2 1 2 2 2 2 1 2 1 1 2 1 2 2 1 1 2 1 1 2 2 1 1 2 1 2 2 2 2 2 1 1 1 2 1 2 1 2 1 2 1 2 2 1 2 2 2 1 1 1 2 2 1 1 2 2 1 1 1 1 1 1 2 2 1 1 2 2 1 2 2 1 2 1 2 2 1 2 1 1 1 2 2 1 1 2 1 2 2 1 1 2 2 2 1\n", "output": "5200\n"}, {"input": "100 2 1\n1 2 2 2 1 2 1 2 2 2 2 1 2 1 1 2 1 2 2 1 1 2 1 1 2 2 1 ...
code_stdio
[ { "content": "Little Petya very much likes gifts. Recently he has received a new laptop as a New Year gift from his mother. He immediately decided to give it to somebody else as what can be more pleasant than giving somebody gifts. And on this occasion he organized a New Year party at his place and invited n hi...
[{"input": "100\n42 23 48 88 36 6 18 70 96 1 34 40 46 22 39 55 85 93 45 67 71 75 59 9 21 3 86 63 65 68 20 38 73 31 84 90 50 51 56 95 72 33 49 19 83 76 54 74 100 30 17 98 15 94 4 97 5 99 81 27 92 32 89 12 13 91 87 29 60 11 52 43 35 58 10 25 16 80 28 2 44 61 8 82 66 69 41 24 57 62 78 37 79 77 53 7 14 47 26 64\n", "output...
code_stdio
[ { "content": "E869120 found a chest which is likely to contain treasure.\n\nHowever, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters.\n\nHe also found a string S', which turns out to be the string S with some of its letters (possibly all or none) re...
[{"input": "??p??d??\nabc\n", "output": "UNRESTORABLE\n"}, {"input": "?tc??@?\ncoder", "output": "UNRESTORABLE\n"}, {"input": "?tc??@?\ncnder", "output": "UNRESTORABLE\n"}, {"input": "?tc??@?\nendcr", "output": "UNRESTORABLE\n"}, {"input": "@tc??@?\nendcr", "output": "UNRESTORABLE\n"}, {"input": "@tc??@?\nendcq", "outp...
code_stdio
[ { "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 12 17 15 13 15 6 12 9 1\n3 8\n1 10\n4 7\n1 7\n3 7\n2 9\n8 10\n3 1\n3 4\n8 6\n10 3\n3 9\n2 3\n10 4\n2 10\n5 8\n9 5\n6 1\n2 1\n5 2\n7 6\n7 10\n4 8\n5 6\n3 6\n4 1\n8 9\n7 9\n4 2\n5 10\n", "output": "209\n"}, {"input": "10 30\n3 6 17 15 13 15 6 12 9 1\n3 8\n1 10\n4 7\n1 7\n3 7\n2 9\n8 10\n3 1\n3 4\n8 6...
code_stdio
[ { "content": "Today we will be playing a red and white colouring game (no, this is not the Russian Civil War; these are just the colours of the Canadian flag).\n\nYou are given an $n \\times m$ grid of \"R\", \"W\", and \".\" characters. \"R\" is red, \"W\" is white and \".\" is blank. The neighbours of a cell ...
[{"input": "3\n4 6\n.R....\n......\n......\n.W....\n4 4\nR..W\n....\n....\n....\n5 1\nR\nW\nR\nW\nR\n", "output": "YES\nWRWRWR\nRWRWRW\nWRWRWR\nRWRWRW\nYES\nRWRW\nWRWR\nRWRW\nWRWR\nYES\nR\nW\nR\nW\nR\n"}, {"input": "3\n4 6\n.R....\n......\n......\n.W....\n4 4\n.R.W\n....\n....\n....\n5 1\nR\nW\nR\nW\nR\n", "output": "\...
code_stdio
[ { "content": "Good evening, contestants.\n\nIf a and d are relatively prime positive integers, the arithmetic sequence beginning with a and increasing by d, i.e., a, a + d, a + 2d, a + 3d, a + 4d, ..., contains infinitely many prime numbers. This fact is known as Dirichlet's Theorem on Arithmetic Progressions, ...
[{"input": "367 186 151\n179 10 203\n271 37 39\n103 230 1\n27 104 285\n253 50 85\n1 1 1\n9075 337 210\n307 40 79\n331 221 177\n259 170 40\n269 75 102\n0 0 0", "output": "92809\n6709\n12037\n103\n153739\n14503\n2\n899429\n10667\n412717\n22699\n38669\n"}, {"input": "367 186 104\n179 10 203\n271 37 39\n73 230 2\n19 104 18...
code_stdio
[ { "content": "Tattah's youngest brother, Tuftuf, is new to programming.\n\nSince his older brother is such a good programmer, his biggest dream is to outshine him. Tuftuf is a student at the German University in Cairo (GUC) where he learns to write programs in Gava.\n\nToday, Tuftuf was introduced to Gava's uns...
[{"input": "220\n10 6 6 2 8 6 6 5 6 2 10 3 9 10 10 2 3 5 2 2 4 7 6 6 7 5 6 2 10 10 1 1 2 2 3 2 4 4 8 1 1 2 1 10 9 2 1 4 2 1 7 4 8 4 2 9 7 7 6 6 8 3 1 9 10 6 3 5 9 5 1 1 8 3 10 8 10 3 7 9 2 4 8 2 8 4 10 5 7 10 6 8 3 5 7 9 4 2 6 2 2 7 7 2 10 1 1 8 7 4 8 8 9 1 1 9 5 5 5 3 5 5 3 2 6 4 7 9 10 9 3 1 10 1 7 8 8 7 6 5 1 5 6 2 ...
code_stdio
[ { "content": "Problem statement\n\nN first-year students of the Faculty of Information Science and Technology of R University take the final exam of the lecture called Programming Exercise 1. The test is a perfect score of m. In other words, the score that one student can get is an integer between 0 and m.\n\nS...
[{"input": "89 111", "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 0 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111\n"}, {"input": "85 110...
code_stdio
[ { "content": "A palindrome is a string $t$ which reads the same backward as forward (formally, $t[i] = t[|t| + 1 - i]$ for all $i \\in [1, |t|]$). Here $|t|$ denotes the length of a string $t$. For example, the strings 010, 1001 and 0 are palindromes.\n\nYou have $n$ binary strings $s_1, s_2, \\dots, s_n$ (each...
[{"input": "11\n4\n0\n1\n1\n0\n2\n0001000\n0000000000000\n2\n1\n0\n1\n1\n1\n0\n2\n11\n00\n2\n111\n000\n2\n111\n00\n2\n00\n111\n2\n11111\n00\n2\n00000100000\n000\n", "output": "4\n2\n2\n1\n1\n2\n2\n2\n2\n2\n2\n"}, {"input": "11\n4\n0\n1\n1\n0\n2\n0001000\n0000000000000\n2\n1\n0\n1\n1\n1\n0\n2\n11\n00\n2\n111\n000\n2\n11...
code_stdio
[ { "content": "Search trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue.\n\nBinary search tree is one of fundamental search trees. The keys in a binary search tree are always stored...
[{"input": "8\ninsert 30\ninsert 113\ninsert 18\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint", "output": " 1 17 18 20 25 30 113\n 30 18 1 17 20 25 113\n"}, {"input": "8\ninsert 30\ninsert 166\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 19\nprint", "output": " 1 12 17 19 20 30 166\n 30 12 1 20 17 19 166\n"},...
code_stdio
[ { "content": "Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).\n\nThe 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.\n\nNote\n\n解説\n\n\n\nInput\n\nIn the first line, the number of cards n (n ≤ 52) ...
[{"input": "47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 7\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13", "output": "S 1\nH 3\nH 5\nC 12\nD 8\n"}, {"input": "4...
code_stdio
[ { "content": "Just in case somebody missed it: this winter is totally cold in Nvodsk! It is so cold that one gets funny thoughts. For example, let's say there are strings with the length exactly n, based on the alphabet of size m. Any its substring with length equal to k is a palindrome. How many such strings e...
[{"input": "1984 1110 1992\n", "output": "102579360\n"}, {"input": "1984 1847 1992\n", "output": "345702953"}, {"input": "1000 1000 1000\n", "output": "850431726"}, {"input": "1999 2000 2000\n", "output": "675798323"}, {"input": "2000 2000 2000\n", "output": "321179016"}, {"input": "331 1999 1234\n", "output": "9203825...
code_stdio
[ { "content": "The sequence is called ordered if it is non-decreasing or non-increasing. For example, sequnces [3, 1, 1, 0] and [1, 2, 3, 100] are ordered, but the sequence [1, 3, 3, 1] is not. You are given a sequence of numbers. You are to find it's shortest subsequence which is not ordered.\n\nA subsequence i...
[{"input": "5\n834472 -373089 441294 -633071 -957672\n", "output": "3\n1 2 3\n"}, {"input": "5\n834472 -373089 441294 -633071 -1240121\n", "output": "3\n1 2 3"}, {"input": "5\n834472 -373089 441294 -401384 -1240121\n", "output": "3\n1 2 3"}, {"input": "5\n834472 -373089 28898 -401384 -1240121\n", "output": "3\n1 2 3"},...
code_stdio
[ { "content": "It can be shown that any positive integer x can be uniquely represented as x = 1 + 2 + 4 + ... + 2^{k} - 1 + r, where k and r are integers, k ≥ 0, 0 < r ≤ 2^{k}. Let's call that representation prairie partition of x.\n\nFor example, the prairie partitions of 12, 17, 7 and 1 are: 12 = 1 + 2 + 4 + ...
[{"input": "100\n1 1 1 1 1 1 1 2 2 2 2 2 2 2 4 4 4 4 4 4 4 6 8 8 8 8 8 8 8 10 16 16 16 16 16 16 16 17 22 24 24 30 32 32 32 32 32 32 48 62 64 64 65 65 67 70 74 88 89 98 99 101 101 109 121 127 128 128 137 143 152 153 155 156 160 161 170 183 186 196 196 214 220 226 228 230 238 240 241 245 249 249 250 253 254 256 256 512 1...
code_stdio
[ { "content": "School holidays come in Berland. The holidays are going to continue for n days. The students of school №N are having the time of their lives and the IT teacher Marina Sergeyevna, who has spent all the summer busy checking the BSE (Berland State Examination) results, has finally taken a vacation br...
[{"input": "100 50\n1 8\n9 12\n13 19\n20 22\n23 27\n28 31\n32 36\n36 40\n40 43\n47 47\n48 51\n51 55\n62 63\n69 77\n77 84\n85 90\n98 99\n100 100\n100 100\n100 100\n100 100\n100 100\n100 100\n100 100\n100 100\n100 100\n100 100\n100 100\n100 100\n100 100\n100 100\n100 100\n100 100\n100 100\n100 100\n100 100\n100 100\n100 ...
code_stdio
[ { "content": "Two players play a game. The game is played on a rectangular board with n × m squares. At the beginning of the game two different squares of the board have two chips. The first player's goal is to shift the chips to the same square. The second player aims to stop the first one with a tube of super...
[{"input": "100 100 1 1 100 100\n", "output": "Second\n"}, {"input": "100 100 10 10 13 14\n", "output": "Second\n"}, {"input": "000 100 1 1 100 100\n", "output": "Second\n"}, {"input": "100 32 71 12 71 22\n", "output": "Second\n"}, {"input": "37 100 33 13 32 30\n", "output": "Second\n"}, {"input": "60 100 28 80 26 85\n...
code_stdio
[ { "content": "Dima has a hamsters farm. Soon N hamsters will grow up on it and Dima will sell them in a city nearby.\n\nHamsters should be transported in boxes. If some box is not completely full, the hamsters in it are bored, that's why each box should be completely full with hamsters.\n\nDima can buy boxes at...
[{"input": "1998451655 50\n977141206 956777871 186433588 538218068 28363231 327484438 88827268 266300062 670616672 756092978 414181331 913675814 898008516 343057716 99416265 255545168 76528140 550467703 684435578 844649988 1024428164 550467703 493542638 33869647 414181331 198095018 913675814 99416265 550467703 67955390...
code_stdio
[ { "content": "You are given a string S of length N consisting of lowercase English letters.\nProcess Q queries of the following two types:\n - Type 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.)\n - Type 2: answer the number of different characters occurring in ...
[{"input": "7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n", "output": "3\n1\n5\n"}, {"input": "7\nabcdbbd\n6\n2 6 6\n1 4 z\n2 1 -1\n1 4 a\n1 7 d\n2 1 7", "output": "1\n0\n4\n"}, {"input": "7\nabcdbbd\n6\n2 6 6\n1 4 z\n2 1 -1\n1 4 a\n1 7 d\n2 1 6", "output": "1\n0\n3\n"}, {"input": "7\nabcdbbd\n6\n2 6 6\n1 5...
code_stdio
[ { "content": "Given the integer $n$ — the number of available blocks. You must use all blocks to build a pedestal.\n\nThe pedestal consists of $3$ platforms for $2$-nd, $1$-st and $3$-rd places respectively. The platform for the $1$-st place must be strictly higher than for the $2$-nd place, and the platform fo...
[{"input": "17\n58512\n46568\n77983\n60262\n48767\n75002\n79520\n52911\n42089\n38692\n71175\n51960\n33754\n36367\n67108\n79100\n78009\n", "output": "19504 19505 19503\n15523 15524 15521\n25995 25996 25992\n20088 20089 20085\n16256 16257 16254\n25001 25002 24999\n26507 26508 26505\n17637 17638 17636\n14030 14031 14028\n...
code_stdio
[ { "content": "During one of the space missions, humans have found an evidence of previous life at one of the planets. They were lucky enough to find a book with birth and death years of each individual that had been living at this planet. What's interesting is that these years are in the range $(1, 10^9)$! Ther...
[{"input": "4\n3 13\n5 8\n8 9\n8 10\n", "output": "8 3\n"}, {"input": "4\n3 13\n5 8\n6 9\n8 10\n", "output": "6 3\n"}, {"input": "4\n3 4\n4 5\n4 6\n8 10\n", "output": "4 2\n"}, {"input": "4\n3 4\n4 8\n4 6\n8 10\n", "output": "4 2\n"}, {"input": "4\n3 8\n4 8\n4 9\n8 10\n", "output": "4 3\n"}, {"input": "4\n3 9\n4 8\n6 9...
code_stdio
[ { "content": "Petya has got an interesting flower. Petya is a busy person, so he sometimes forgets to water it. You are given n days from Petya's live and you have to determine what happened with his flower in the end.\n\nThe flower grows as follows: \n\n * If the flower isn't watered for two days in a row, it...
[{"input": "4\n3\n1 0 0\n3\n0 0 1\n4\n1 0 0 1\n1\n1\n", "output": "-1\n-1\n-1\n2\n"}, {"input": "4\n3\n0 0 1\n3\n0 0 1\n4\n1 0 0 1\n1\n0\n", "output": "-1\n-1\n-1\n1\n"}, {"input": "4\n3\n0 0 1\n3\n0 0 1\n4\n0 1 1 1\n1\n0\n", "output": "-1\n-1\n12\n1\n"}, {"input": "4\n3\n1 1 1\n3\n0 0 0\n4\n1 1 1 0\n1\n0\n", "output":...
code_stdio
[ { "content": "In Conway's Game of Life, cells in a grid are used to simulate biological cells.\nEach cell is considered to be either alive or dead.\nAt each step of the simulation\neach cell's current status and number of living neighbors is used to determine the status\nof the cell during the following step of...
[{"input": "4\n00000101\n000\n010101\n11100", "output": "11011000\nMultiple solutions\nMultiple solutions\n01000\n"}, {"input": "4\n00000101\n000\n011011\n10010", "output": "11011000\nMultiple solutions\nMultiple solutions\n01100\n"}, {"input": "4\n00010101\n000\n100011\n00010", "output": "00001110\nMultiple solutions\...
code_stdio
[ { "content": "AND gates and OR gates are basic components used in building digital circuits. Both gates have two input lines and one output line. The output of an AND gate is 1 if both inputs are 1, otherwise the output is 0. The output of an OR gate is 1 if at least one input is 1, otherwise the output is 0.\n...
[{"input": "4\n\n1\n0\n\n3\n0\n0\n2 1 2\n\n3\n0\n0\n1 2 1\n\n1\n0\n0\n-1\n2 1 3\n1 4 3", "output": "0.50000\n0.70711\n0.29289\n0.50000\n"}, {"input": "4\n\n1\n0\n\n3\n0\n0\n2 1 2\n\n3\n0\n0\n2 2 2\n\n1\n0\n-1\n0\n2 0 2\n1 3 3", "output": "0.50000\n0.70711\n0.70711\n0.50000\n"}, {"input": "4\n\n1\n0\n\n3\n0\n0\n1 1 2\n\...
code_stdio
[ { "content": "Lucy had recently learned the game, called Natural Numbers.\nThe rules of the game are really simple. There are N players. At the same time, every player says one natural number. Let's call the number said by the i-th player Ai. The person with the smallest unique number (that is, the smallest num...
[{"input": "2\n5\nKouta 0\nYuka 1\nMayu 3\nLucy 2\nNana 5\n2\nLucy 2\nOana 2", "output": "Kouta\nNobody wins.\n"}, {"input": "2\n5\natuoK 0\nYukb 1\nM`yu 2\nuLcy 4\nNana 5\n2\nLucy 1\nOana 1", "output": "atuoK\nNobody wins.\n"}, {"input": "2\n5\nKauto 0\nYuka 1\nuayL 3\nyucK 2\nNana 5\n2\nLucy 2\nNana 2", "output": "Ka...
code_stdio
[ { "content": "An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its...
[{"input": "50\n10 37 3 46 45 29 36 13 21 25 35 5 18 33 12 19 50 16 30 47 20 42 39 28 2 6 38 8 7 31 22 27 26 9 15 14 34 48 4 32 40 43 44 24 11 1 23 17 49 41\n", "output": "46"}, {"input": "50\n1 2 3 4 5 6 7 8 43 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 50 33 34 35 36 37 38 39 40 41 42 9 44 45 4...
code_stdio
[ { "content": "Родители Васи хотят, чтобы он как можно лучше учился. Поэтому если он получает подряд три положительные оценки («четвёрки» или «пятёрки»), они дарят ему подарок. Соответственно, оценки «единица», «двойка» и «тройка» родители Васи считают плохими. Когда Вася получает подряд три хорошие оценки, ему ...
[{"input": "250\n4 4 2 5 1 5 5 4 5 4 4 4 4 4 4 5 5 4 4 5 4 5 1 5 5 4 1 5 5 4 5 5 4 4 4 4 5 4 4 5 5 5 5 5 4 5 4 5 5 4 5 4 4 4 4 4 4 5 5 4 5 5 1 4 4 4 5 1 5 3 4 5 4 4 4 4 4 5 5 4 4 4 4 4 5 4 5 5 5 4 4 5 4 4 4 5 5 5 5 4 5 4 5 4 5 5 5 5 4 4 4 4 5 5 5 5 5 5 4 4 3 4 4 5 5 3 5 4 4 4 4 4 4 5 5 5 4 5 4 4 4 2 4 5 5 5 5 5 5 5 4 5...
code_stdio
[ { "content": "You are given a positive integer $n$ greater or equal to $2$. For every pair of integers $a$ and $b$ ($2 \\le |a|, |b| \\le n$), you can transform $a$ into $b$ if and only if there exists an integer $x$ such that $1 < |x|$ and ($a \\cdot x = b$ or $b \\cdot x = a$), where $|x|$ denotes the absolut...
[{"input": "100000\n", "output": "12898363344"}, {"input": "100000\n", "output": "12898363344"}, {"input": "88077\n", "output": "10005839736\n"}, {"input": "88853\n", "output": "10182812524\n"}, {"input": "93365\n", "output": "11243148040\n"}, {"input": "92775\n", "output": "11101694484"}, {"input": "90783\n", "output"...
code_stdio
[ { "content": "You are given string S and T consisting of lowercase English letters.\nDetermine if S equals T after rotation.\nThat is, determine if S equals T after the following operation is performed some number of times:\nOperation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}.\nHer...
[{"input": "pgykichjtpukfnlxfcevkjezqsmeycanjlbessrfazdprcomdpjimsfbuslksyveergcgmonctcsvypolplcgsqyfkilrixodiwq\nfnlxfcevkjezqsmeycanjlbessrfazdprcomdpjimsfbuslksyveergcgmonctcsvypolplcgsqyfkilrixodiwqpgykichjtpuk\n", "output": "Yes\n"}, {"input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "Vasya goes to visit his classmate Petya. Vasya knows that Petya's apartment number is $n$. \n\nThere is only one entrance in Petya's house and the distribution of apartments is the following: the first floor contains $2$ apartments, every other floor contains $x$ apartments each. Apartments are nu...
[{"input": "7\n7 3\n1 3\n18 6\n1865 4\n12 2\n2 10\n22 5\n", "output": "3\n1\n4\n467\n6\n1\n5\n"}, {"input": "7\n7 3\n1 3\n18 6\n987 4\n12 2\n2 10\n22 12\n", "output": "3\n1\n4\n248\n6\n1\n3\n"}, {"input": "7\n7 3\n1 3\n18 6\n1865 4\n12 2\n4 10\n22 5\n", "output": "3\n1\n4\n467\n6\n2\n5\n"}, {"input": "7\n2 3\n1 3\n18 6...
code_stdio
[ { "content": "A Little Elephant and his friends from the Zoo of Lviv like candies very much.\n\nThere are N elephants in the Zoo. The elephant with number K (1 ≤ K ≤ N) will be happy if he receives at least A_{K} candies. There are C candies in all in the Zoo.\n\nThe Zoo staff is interested in knowing whether i...
[{"input": "2\n2 1\n2 2\n3 13\n-1 2 2", "output": "No\nYes\n"}, {"input": "2\n2 1\n4 2\n3 13\n-1 2 2", "output": "No\nYes\n"}, {"input": "2\n2 1\n4 2\n3 13\n-1 2 1", "output": "No\nYes\n"}, {"input": "2\n2 0\n4 2\n3 13\n-1 2 1", "output": "No\nYes\n"}, {"input": "2\n2 1\n2 0\n3 13\n-1 2 2", "output": "No\nYes\n"}, {"in...
code_stdio
[ { "content": "While walking down the street Vanya saw a label \"Hide&Seek\". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of...
[{"input": "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnop...
code_stdio
[ { "content": "Lately, a national version of a bingo game has become very popular in Berland. There are n players playing the game, each player has a card with numbers. The numbers on each card are distinct, but distinct cards can have equal numbers. The card of the i-th player contains m_{i} numbers.\n\nDuring ...
[{"input": "40\n2 12 19\n4 10 7 1 3\n2 15 17\n1 6\n3 17 8 20\n4 8 16 11 18\n2 2 7\n4 12 13 8 7\n3 6 1 15\n3 19 11 13\n1 2\n2 16 14\n5 1 17 8 9 5\n1 2\n3 15 17 12\n4 20 4 19 18\n1 10\n4 12 1 17 16\n4 5 10 8 11\n1 10\n1 13\n1 17\n2 19 18\n1 3\n2 6 20\n1 8\n2 3 14\n3 17 3 1\n2 4 3\n1 12\n1 15\n1 2\n2 13 9\n2 1 14\n1 1\n5 ...
code_stdio
[ { "content": "Initially, you have the array $a$ consisting of one element $1$ ($a = [1]$).\n\nIn one move, you can do one of the following things:\n\n Increase some (single) element of $a$ by $1$ (choose some $i$ from $1$ to the current length of $a$ and increase $a_i$ by one); Append the copy of some (single...
[{"input": "5\n1\n13\n42\n2538\n1000000000\n", "output": "0\n6\n11\n99\n63244\n"}, {"input": "5\n1\n10\n143\n255\n1000000000\n", "output": "0\n5\n22\n30\n63244\n"}, {"input": "5\n1\n13\n143\n751\n1000001000\n", "output": "0\n6\n22\n53\n63244\n"}, {"input": "5\n1\n5\n42\n1337\n1000000000\n", "output": "0\n3\n11\n72\n632...
code_stdio
[ { "content": "Lolek and Bolek are about to travel abroad by plane. The local airport has a special \"Choose Your Plane\" offer. The offer's conditions are as follows:\n\n * it is up to a passenger to choose a plane to fly on; \n * if the chosen plane has x (x > 0) empty seats at the given moment, then the tic...
[{"input": "510 132\n50 76 77 69 94 30 47 65 14 62 18 121 26 35 49 17 105 93 47 16 78 3 7 74 7 37 30 36 30 83 121 113 7 58 86 10 65 57 34 102 55 44 43 47 106 44 115 75 109 70 47 45 16 57 62 55 20 88 74 40 45 84 41 1 9 53 65 25 67 31 115 2 63 51 123 70 65 65 18 14 75 14 103 26 117 105 36 104 81 37 35 62 44 90 71 70 88 8...
code_stdio
[ { "content": "Amugae is in a very large round corridor. The corridor consists of two areas. The inner area is equally divided by $n$ sectors, and the outer area is equally divided by $m$ sectors. A wall exists between each pair of sectors of same area (inner or outer), but there is no wall between the inner are...
[{"input": "1 1 10\n1 1 1 1\n1 1 1 1\n1 1 2 1\n1 1 1 1\n2 1 2 1\n2 1 1 1\n1 1 2 1\n1 1 2 1\n2 1 1 1\n2 1 1 1\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "1 1 10\n1 1 1 1\n1 1 1 1\n1 1 2 1\n1 1 1 1\n2 1 2 1\n2 1 1 1\n1 1 2 1\n1 1 2 1\n2 1 1 1\n2 1 1 1\n", "output": "YES\nYES\nYES\nYES\...
code_stdio
[ { "content": "Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). \n\nSince all the boxes have the same size, Ciel cannot put more than one box directly on the top...
[{"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": "Ivan has number $b$. He is sorting through the numbers $a$ from $1$ to $10^{18}$, and for every $a$ writes $\\frac{[a, \\,\\, b]}{a}$ on blackboard. Here $[a, \\,\\, b]$ stands for least common multiple of $a$ and $b$. Ivan is very lazy, that's why this task bored him soon. But he is interested in...
[{"input": "2793510720\n", "output": "1792\n"}, {"input": "1102701600\n", "output": "1440\n"}, {"input": "2327925600\n", "output": "1728\n"}, {"input": "2095133040\n", "output": "1600\n"}, {"input": "9133684560\n", "output": "1920\n"}, {"input": "6983776800\n", "output": "2304\n"}, {"input": "3491888400\n", "output": "...
code_stdio
[ { "content": "Jack is working on his jumping skills recently. Currently he's located at point zero of the number line. He would like to get to the point x. In order to train, he has decided that he'll first jump by only one unit, and each subsequent jump will be exactly one longer than the previous one. He can ...
[{"input": "-1000000000\n", "output": "44723\n"}, {"input": "-1028109475\n", "output": "45346\n"}, {"input": "-1050321888\n", "output": "45835\n"}, {"input": "-245245154\n", "output": "22147\n"}, {"input": "-779406751\n", "output": "39482\n"}, {"input": "-904422532\n", "output": "42531\n"}, {"input": "-517744582\n", "o...
code_stdio