messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
1 value
[ { "content": "Each evening Roma plays online poker on his favourite website. The rules of poker on this website are a bit strange: there are always two players in a hand, there are no bets, and the winner takes 1 virtual bourle from the loser.\n\nLast evening Roma started to play poker. He decided to spend no m...
[{"input": "20 7\n?LLLLLWWWWW?????????\n", "output": "WLLLLLWWWWWWWWWWDDDW\n"}, {"input": "20 6\n?LLLLLWWWWW?????????\n", "output": "WLLLLLWWWWWWWWWDDDDW\n"}, {"input": "20 5\n?LLLLLWWWWW?????????\n", "output": "WLLLLLWWWWWWWWDDDDDW"}, {"input": "10 3\nDWD?DL??LL\n", "output": "DWDWDLLLLL\n"}, {"input": "10 2\nD??W?WL?...
code_stdio
[ { "content": "Vasya plays a computer game with ninjas. At this stage Vasya's ninja should get out of a deep canyon.\n\nThe canyon consists of two vertical parallel walls, their height is n meters. Let's imagine that we split these walls into 1 meter-long areas and number them with positive integers from 1 to n ...
[{"input": "001 1\n----------------------------------------------------------------------------------------------------X\n----------------------------------------------------------------------------------------------------X\n", "output": "YES\n"}, {"input": "011 1\n------------------------------------------------------...
code_stdio
[ { "content": "Gru has not been in the limelight for a long time and is, therefore, planning something particularly nefarious. Frustrated by his minions' incapability which has kept him away from the limelight, he has built a transmogrifier — a machine which mutates minions.\n\nEach minion has an intrinsic chara...
[{"input": "1\n4 2\n-1 8 1 -1 -1", "output": "0\n"}, {"input": "1\n5 10\n2 4 1 62 1", "output": "1\n"}, {"input": "1\n5 20\n2 4 1 62 1", "output": "2\n"}, {"input": "1\n4 2\n0 14 1 -1 1", "output": "0\n"}, {"input": "1\n4 2\n0 15 1 -1 1", "output": "0\n"}, {"input": "1\n5 10\n2 6 1 35 1", "output": "0\n"}, {"input": "1...
code_stdio
[ { "content": "Mr. A loves sweets, but recently his wife has told him to go on a diet. One day, when Mr. A went out from his home to the city hall, his wife recommended that he go by bicycle. There, Mr. A reluctantly went out on a bicycle, but Mr. A, who likes sweets, came up with the idea of ​​stopping by a cak...
[{"input": "1 1 2 5\n13\nH L1 18\nC1 D 6\nC1 H 12\nL1 D 10\nC1 L1 24\n2 2 4 6\n100 112\nH L1 10\nC1 L1 12\nC1 D 11\nC2 L1 7\nC2 D 12\nL1 D 8\n0 0 0 0", "output": "23\n-24\n"}, {"input": "1 1 2 5\n25\nH L1 18\nC1 D 6\nC1 H 12\nL1 D 10\nC1 L1 24\n2 2 4 6\n100 112\nH L1 10\nC1 L1 12\nC1 D 11\nC2 L1 2\nC2 D 7\nL1 D 8\n0 0 ...
code_stdio
[ { "content": "Given an array $a$ of length $n$, find another array, $b$, of length $n$ such that:\n\n for each $i$ $(1 \\le i \\le n)$ $MEX(\\{b_1$, $b_2$, $\\ldots$, $b_i\\})=a_i$. \n\nThe $MEX$ of a set of integers is the smallest non-negative integer that doesn't belong to this set.\n\nIf such array doesn't...
[{"input": "10\n1 2 3 4 4 4 7 7 7 10\n", "output": "0 1 2 3 5 6 4 8 9 7 "}, {"input": "10\n1 2 3 4 4 4 7 7 7 10\n", "output": "0 1 2 3 5 6 4 8 9 7\n"}, {"input": "7\n0 0 2 2 3 5 6\n", "output": "1 4 0 7 2 3 5 \n"}, {"input": "7\n0 0 2 2 3 5 7\n", "output": "1 4 0 6 2 3 5 \n"}, {"input": "7\n0 0 2 4 5 5 6\n", "output": ...
code_stdio
[ { "content": "Vlad has $n$ friends, for each of whom he wants to buy one gift for the New Year.\n\nThere are $m$ shops in the city, in each of which he can buy a gift for any of his friends. If the $j$-th friend ($1 \\le j \\le n$) receives a gift bought in the shop with the number $i$ ($1 \\le i \\le m$), then...
[{"input": "5\n\n2 2\n2 2\n3 3\n\n4 3\n1 5 1\n0 1 0\n2 2 2\n2 2 3\n\n2 3\n0 4 4\n3 2 1\n\n4 2\n14 15\n8 -1\n9 1\n2 23\n\n2 4\n6 6 2 1\n7 -1 9 0\n", "output": "3\n2\n3\n14\n1\n"}, {"input": "5\n\n2 2\n2 2\n3 7\n\n4 3\n1 3 1\n3 1 1\n1 2 2\n1 2 5\n\n2 3\n-1 3 4\n2 2 1\n\n4 2\n7 9\n8 1\n16 14\n4 13\n\n2 4\n6 8 0 2\n7 -1 7 ...
code_stdio
[ { "content": "There is unrest in the Galactic Senate. Several thousand solar systems have declared their intentions to leave the Republic. Master Heidi needs to select the Jedi Knights who will go on peacekeeping missions throughout the galaxy. It is well-known that the success of any peacekeeping mission depen...
[{"input": "6 6\n1 1 3 2 2 2\n1 0 0 1 0 0\n", "output": "-1\n"}, {"input": "6 6\n4 3 5 4 5 2\n0 1 0 1 2 0\n", "output": "0\n"}, {"input": "6 6\n1 1 3 2 2 2\n1 0 0 0 0 0\n", "output": "0\n"}, {"input": "6 6\n4 3 5 6 5 5\n0 0 1 1 0 0\n", "output": "0\n"}, {"input": "6 6\n6 2 6 2 5 4\n0 1 0 0 0 1\n", "output": "0\n"}, {"i...
code_stdio
[ { "content": "You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.\n\nSubsequence is a sequence that can be derived fro...
[{"input": "59\n8593 5929 3016 -859 4366 -6842 8435 -3910 -2458 -8503 -3612 -9793 -5360 -9791 -362 -7180 727 -6245 -8869 -7316 8214 -7944 7098 3788 -5436 -6626 -1131 -2410 -5647 -7981 263 -5879 8786 709 6489 5316 -4039 4909 -4340 7979 -89 9844 -906 172 -7674 -3371 -6828 9505 3284 5895 3646 6680 -1255 3635 -9547 -5104 -...
code_stdio
[ { "content": "Fox Ciel is playing a game with numbers now. \n\nCiel has n positive integers: x_1, x_2, ..., x_{n}. She can do the following operation as many times as needed: select two different indexes i and j such that x_{i} > x_{j} hold, and then apply assignment x_{i} = x_{i} - x_{j}. The goal is to make t...
[{"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": "Limak is a little bear who loves to play. Today he is playing by destroying block towers. He built n towers in a row. The i-th tower is made of h_{i} identical blocks. For clarification see picture for the first sample.\n\nLimak will repeat the following operation till everything is destroyed.\n\n...
[{"input": "170\n1 2 1 2 1 1 1 1 2 3 2 1 1 2 2 1 2 1 2 1 1 2 3 3 2 1 1 1 1 1 1 1 1 2 1 2 3 3 2 1 2 2 1 2 3 2 1 1 2 3 2 1 2 1 1 1 2 3 3 2 1 2 1 2 1 1 1 2 1 2 1 1 2 2 1 1 2 1 2 2 1 2 1 2 2 1 2 1 2 3 2 1 1 2 3 4 4 3 2 1 2 1 2 1 2 3 3 2 1 2 1 1 1 1 1 1 1 2 2 1 1 2 1 1 1 1 2 1 1 2 3 2 1 2 2 1 2 1 1 1 2 2 1 2 1 2 3 2 1 2 1 1...
code_stdio
[ { "content": "You are given an integer sequence $1, 2, \\dots, n$. You have to divide it into two sets $A$ and $B$ in such a way that each element belongs to exactly one set and $|sum(A) - sum(B)|$ is minimum possible.\n\nThe value $|x|$ is the absolute value of $x$ and $sum(S)$ is the sum of elements of the se...
[{"input": "2000000000\n", "output": "0\n"}, {"input": "1999999999\n", "output": "0\n"}, {"input": "1999999997\n", "output": "1\n"}, {"input": "1999999998\n", "output": "1\n"}, {"input": "1000271094\n", "output": "1\n"}, {"input": "1825468885\n", "output": "1\n"}, {"input": "1000080110\n", "output": "1\n"}, {"input": "...
code_stdio
[ { "content": "Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initi...
[{"input": "100 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1...
code_stdio
[ { "content": "Drazil has many friends. Some of them are happy and some of them are unhappy. Drazil wants to make all his friends become happy. So he invented the following plan.\n\nThere are n boys and m girls among his friends. Let's number them from 0 to n - 1 and 0 to m - 1 separately. In i-th day, Drazil in...
[{"input": "91 98\n78 0 1 2 3 4 5 7 8 9 10 11 12 14 15 16 17 18 19 21 22 23 24 25 26 28 29 30 31 32 33 35 36 37 38 39 40 42 43 44 45 46 47 49 50 51 52 53 54 56 57 58 59 60 61 63 64 65 66 67 68 70 71 72 73 74 75 77 78 79 80 81 82 84 85 86 87 88 89\n84 0 1 2 3 4 5 7 8 9 10 11 12 14 15 16 17 18 19 21 22 23 24 25 26 28 29 ...
code_stdio
[ { "content": "n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winn...
[{"input": "100 2\n62 70 35 14 12 87 94 78 39 92 84 91 129 49 82 33 69 37 19 61 42 8 45 97 81 22 54 67 1 22 77 25 65 17 18 28 25 57 16 90 40 13 4 21 68 35 15 76 73 93 56 111 79 47 74 75 30 71 130 99 68 24 29 83 5 6 31 96 38 80 27 46 51 53 2 86 35 9 20 100 26 36 63 7 52 55 23 3 50 59 48 118 167 44 34 64 13 72 7 98\n", "...
code_stdio
[ { "content": "A long time ago (probably even in the first book), Nicholas Flamel, a great alchemist and the creator of the Philosopher's Stone, taught Harry Potter three useful spells. The first one allows you to convert a grams of sand into b grams of lead, the second one allows you to convert c grams of lead ...
[{"input": "911 728 910 407 833 594\n", "output": "Hermione\n"}, {"input": "632 446 352 317 522 451\n", "output": "Hermione\n"}, {"input": "542 11 820 850 1201 738\n", "output": "Hermione\n"}, {"input": "911 728 910 180 833 594\n", "output": "Hermione\n"}, {"input": "542 11 820 850 791 738\n", "output": "Hermione\n"}, ...
code_stdio
[ { "content": "You are given sequences A and B consisting of non-negative integers.\nThe lengths of both A and B are N, and the sums of the elements in A and B are equal.\nThe i-th element in A is A_i, and the i-th element in B is B_i.\nTozan and Gezan repeats the following sequence of operations:\n - If A and B...
[{"input": "3\n11 3\n-1 1\n2 8", "output": "9\n"}, {"input": "3\n8 3\n0 1\n4 8\n", "output": "9\n"}, {"input": "3\n8 3\n-1 1\n5 8", "output": "9\n"}, {"input": "3\n8 3\n-1 0\n4 8", "output": "8\n"}, {"input": "3\n8 3\n0 1\n4 8", "output": "9"}, {"input": "2\n-1 1\n1 -1", "output": "1\n"}, {"input": "2\n-1 -1\n1 1", "ou...
code_stdio
[ { "content": "Aoki is playing with a sequence of numbers a_{1}, a_{2}, ..., a_{N}. Every second, he performs the following operation :\n\n* Choose a positive integer k. For each element of the sequence v, Aoki may choose to replace v with its remainder when divided by k, or do nothing with v. The cost of this o...
[{"input": "3\n2 20 33\n2 2 13", "output": "1048584\n"}, {"input": "3\n23 10 26\n0 4 7", "output": "524354\n"}, {"input": "3\n7 23 26\n3 6 5", "output": "131216\n"}, {"input": "3\n23 10 31\n0 4 6", "output": "66114\n"}, {"input": "3\n7 23 23\n3 6 5", "output": "131152\n"}, {"input": "3\n23 10 31\n1 4 6", "output": "661...
code_stdio
[ { "content": "Two players A and B have a list of $n$ integers each. They both want to maximize the subtraction between their score and their opponent's score. \n\nIn one turn, a player can either add to his score any element from his list (assuming his list is not empty), the element is removed from the list af...
[{"input": "29\n254369 14511 114048 683934 553812 575014 620356 217938 286195 131704 268393 78202 296626 986697 175814 600746 146985 215868 740052 711417 11221 944700 940915 53378 698708 878644 704035 120164 437165\n3415 443979 327875 491782 974937 176118 37957 316844 12044 156497 462613 338831 796707 658031 906915 955...
code_stdio
[ { "content": "There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and therefore knows exactly that the animal number i in the queue ...
[{"input": "150 2476\n70 21 114 127 22 11 29 59 51 59 35 3 53 88 5 8 44 4 8 100 1 27 1 25 27 56 48 22 23 103 85 66 14 58 20 7 176 11 19 26 105 97 83 3 29 30 52 92 59 11 135 37 59 8 66 20 47 19 143 16 93 18 57 71 1 13 141 1 119 6 2 87 40 68 28 22 20 53 31 19 15 33 32 9 70 63 16 26 77 7 45 52 73 25 22 21 68 79 16 3 164 2...
code_stdio
[ { "content": "Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nPetya has two strings a and b of the same length n. The strings consist on...
[{"input": "44447774444474477747774774477777474774744744477444447777477477744747477774744444744777777777747777477447744774744444747477744744\n77777474477477747774777777474474477444474777477747747777477747747744474474747774747747444777474444744744444477477777747744747477\n", "output": "37\n"}, {"input": "774774747744474...
code_stdio
[ { "content": "Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \\leq k \\leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transform...
[{"input": "1\n440\ntcjbjlbtjfmvzdqutuwzvmgqrqtrvxwrdacxcowbmbwvwssihttgdsjntiawqavwspzmybakxmwpbcgaffpyhvjrulqsorkcuozvtdbkkmasxtemrrbhqnmkpgewwphdvcyhxmatrfjkesacujihmtyqtqcjfqhpsjhgzimegvkjylapylqprykvkjavlmipewlzqsfefjzecadsqmfutgnegngmwchqttcyklocfcyuhghvtygdbsxaoxkvtgdcnsqddzzakhgrribwxkuakxkjneasowsadprpcusmbevu...
code_stdio
[ { "content": "We guessed a permutation $p$ consisting of $n$ integers. The permutation of length $n$ is the array of length $n$ where each element from $1$ to $n$ appears exactly once. This permutation is a secret for you.\n\nFor each position $r$ from $2$ to $n$ we chose some other index $l$ ($l < r$) and gave...
[{"input": "5\n6\n3 2 5 6\n2 4 6\n3 1 3 4\n2 1 3\n4 1 2 4 6\n5\n2 2 3\n2 1 2\n2 1 4\n2 4 5\n7\n3 1 2 6\n4 1 3 5 6\n2 1 2\n3 4 5 7\n6 1 2 3 4 5 6\n3 1 3 6\n2\n2 1 2\n5\n2 2 5\n3 2 3 5\n4 2 3 4 5\n5 1 2 3 4 5\n", "output": "3 1 4 6 2 5 \n3 2 1 4 5 \n2 1 6 3 5 4 7 \n1 2 \n2 5 3 4 1 \n"}, {"input": "5\n6\n3 2 5 6\n2 4 6\n3...
code_stdio
[ { "content": "You have a multiset containing several integers. Initially, it contains $a_1$ elements equal to $1$, $a_2$ elements equal to $2$, ..., $a_n$ elements equal to $n$.\n\nYou may apply two types of operations: choose two integers $l$ and $r$ ($l \\le r$), then remove one occurrence of $l$, one occurr...
[{"input": "20\n1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2\n", "output": "11\n"}, {"input": "20\n1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2\n", "output": "11\n"}, {"input": "20\n1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 3\n", "output": "11\n"}, {"input": "20\n1 2 1 2 1 2 0 2 1 2 1 2 1 2 1 2 1 2 1 3\n", "output": "12\n"}, {"input...
code_stdio
[ { "content": "You're given two arrays $a[1 \\dots n]$ and $b[1 \\dots n]$, both of the same length $n$.\n\nIn order to perform a push operation, you have to choose three integers $l, r, k$ satisfying $1 \\le l \\le r \\le n$ and $k > 0$. Then, you will add $k$ to elements $a_l, a_{l+1}, \\ldots, a_r$.\n\nFor ex...
[{"input": "4\n6\n3 7 1 4 1 2\n3 7 3 6 3 2\n5\n1 1 1 1 1\n1 2 1 3 1\n2\n42 42\n42 42\n1\n7\n6\n", "output": "YES\nNO\nYES\nNO\n"}, {"input": "4\n6\n3 7 1 4 1 2\n3 7 3 6 3 2\n5\n1 1 1 1 1\n1 2 1 3 1\n2\n42 42\n42 48\n1\n7\n6\n", "output": "YES\nNO\nYES\nNO\n"}, {"input": "4\n6\n3 7 1 4 1 2\n3 7 3 6 3 2\n5\n1 1 1 1 1\n1 ...
code_stdio
[ { "content": "You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\n* For each element x in b, the value x...
[{"input": "8\n12 13 1 15 2 2 1 12", "output": "5\n"}, {"input": "8\n4 13 1 15 2 8 1 12", "output": "7\n"}, {"input": "8\n4 13 1 15 2 2 1 12", "output": "5\n"}, {"input": "8\n6 13 1 15 2 2 1 12", "output": "5\n"}, {"input": "8\n12 13 1 0 2 2 1 12", "output": "5\n"}, {"input": "8\n12 13 1 1 2 2 1 12", "output": "5\n"}, ...
code_stdio
[ { "content": "Long ago, Vasily built a good fence at his country house. Vasily calls a fence good, if it is a series of n consecutively fastened vertical boards of centimeter width, the height of each in centimeters is a positive integer. The house owner remembers that the height of the i-th board to the left i...
[{"input": "50\n1 3083990 976356336 922018335 1 170272482 1 547248035 1 1 1 1 1 928379588 1 1 1 270052499 315045369 1 1 556091215 1 655608230 424079072 1 1 185387009 77360256 1 1 942696777 228860271 1 487787709 1 437229749 167886535 1 1 904578415 319694007 1 313704390 1 1 957736320 771147030 458205965 497342117\n", "ou...
code_stdio
[ { "content": "You are given a string $s$, consisting of $n$ lowercase Latin letters.\n\nA substring of string $s$ is a continuous segment of letters from $s$. For example, \"defor\" is a substring of \"codeforces\" and \"fors\" is not. \n\nThe length of the substring is the number of letters in it.\n\nLet's cal...
[{"input": "25\nbbaaaaabaaaabbabaaaababaa\n", "output": "YES\nba\n"}, {"input": "25\nbbaaaaabaaaabbabaaaababaa\n", "output": "YES\nba\n"}, {"input": "25\nbbaaaaabaaaabbabaaaabab`a\n", "output": "YES\nba\n"}, {"input": "25\nbbaaaaabaaaabbabaaaacab`a\n", "output": "YES\nba\n"}, {"input": "25\na`bacaaaababbaaaabaaaaabb\n"...
code_stdio
[ { "content": "Not so long ago as a result of combat operations the main Berland place of interest — the magic clock — was damaged. The cannon's balls made several holes in the clock, that's why the residents are concerned about the repair. The magic clock can be represented as an infinite Cartesian plane, where...
[{"input": "1000 -1000\n", "output": "white\n"}, {"input": "0000 -1000\n", "output": "black\n"}, {"input": "-1059 -929\n", "output": "black\n"}, {"input": "-215 -996\n", "output": "black\n"}, {"input": "-496 -644\n", "output": "black\n"}, {"input": "-196 -484\n", "output": "black\n"}, {"input": "-796 -365\n", "output":...
code_stdio
[ { "content": "There are N slimes lining up in a row. Initially, the i-th slime from the left has a size of a_i.\n\nTaro is trying to combine all the slimes into a larger slime. He will perform the following operation repeatedly until there is only one slime:\n\n* Choose two adjacent slimes, and combine them int...
[{"input": "3\n1001000000 1000000000 1000000000", "output": "5001000000\n"}, {"input": "3\n1001000000 1000000001 1000000000", "output": "5001000002\n"}, {"input": "3\n1001000000 1010000001 1000000000", "output": "5021000002\n"}, {"input": "3\n1001000000 1010000011 1000000000", "output": "5021000022\n"}, {"input": "3\n1...
code_stdio
[ { "content": "Seryozha has a very changeable character. This time he refused to leave the room to Dima and his girlfriend (her hame is Inna, by the way). However, the two lovebirds can always find a way to communicate. Today they are writing text messages to each other.\n\nDima and Inna are using a secret code ...
[{"input": "7\ni\nam\nont\nmain\nin\nthe\nfamily\n&lt;3i&lt;&gt;3am&lt;3the&lt;3&lt;main&lt;3in&lt;3the&lt;3&gt;&lt;3family&lt;3\n", "output": "no\n"}, {"input": "7\ni\nam\nont\nmbin\nin\nthe\nfamily\n&lt;3i&lt;&gt;3am&lt;3the&lt;3&lt;main&lt;3in&lt;3the&lt;3&gt;&lt;3family&lt;3\n", "output": "no\n"}, {"input": "7\ni\n...
code_stdio
[ { "content": "Everybody knows that the Berland citizens are keen on health, especially students. Berland students are so tough that all they drink is orange juice!\n\nYesterday one student, Vasya and his mates made some barbecue and they drank this healthy drink only. After they ran out of the first barrel of j...
[{"input": "2000\naabaaabaabababbbbbbabbbbb\n", "output": "0\n"}, {"input": "2000\naabaaabaabababbbbbbabbbbb\n", "output": "0\n"}, {"input": "2000\naaaaaabaabababbbbbbabbbbb\n", "output": "0\n"}, {"input": "2000\naaaaaabaababaabbbbbabbbbb\n", "output": "0\n"}, {"input": "2000\nbbbbbabbbbbaababaabaaaaaa\n", "output": "0...
code_stdio
[ { "content": "You are given two arrays A and B, each of size n. The error, E, between these two arrays is defined $E = \\sum_{i = 1}^{n}(a_{i} - b_{i})^{2}$. You have to perform exactly k_1 operations on array A and exactly k_2 operations on array B. In one operation, you have to choose one element of the array...
[{"input": "22 334 246\n-462653 -618002 4973 -348485 366658 192390 274752 200590 138367 779540 -661269 642587 113645 -110388 -604418 -491231 -933401 -219332 -603140 836439 167007 210226\n357638 -646669 -558432 -434313 -285851 -119233 323088 -512237 -729293 215256 39316 -984201 -209814 715016 -271932 796550 988227 -8957...
code_stdio
[ { "content": "A binary tree of n nodes is given. Nodes of the tree are numbered from 1 to n and the root is the node 1. Each node can have no child, only one left child, only one right child, or both children. For convenience, let's denote l_u and r_u as the left and the right child of the node u respectively, ...
[{"input": "50 50\navzqjbotzkdbrhpknuxxcndqnnkfpthvjriridgnocygczqeyy\n3 50\n0 0\n24 47\n0 0\n0 0\n0 36\n0 0\n42 0\n0 0\n0 0\n0 0\n2 9\n40 0\n0 0\n0 0\n0 0\n20 0\n5 0\n11 32\n0 0\n8 30\n0 34\n0 0\n17 21\n0 0\n0 0\n23 38\n15 39\n0 13\n19 0\n0 7\n10 14\n0 0\n4 41\n48 44\n33 27\n29 0\n0 0\n0 37\n0 0\n45 0\n31 25\n0 0\n12 ...
code_stdio
[ { "content": "Iahub recently has learned Bubble Sort, an algorithm that is used to sort a permutation with n elements a1, a2, ..., an in ascending order. He is bored of this so simple algorithm, so he invents his own graph. The graph (let's call it G) initially has n vertices and 0 edges. During Bubble Sort exe...
[{"input": "100\n36 48 92 87 28 85 42 10 44 41 39 3 79 9 14 56 1 16 46 35 93 8 82 26 100 59 60 2 96 52 13 98 70 81 71 94 54 91 17 88 33 30 19 50 18 73 65 29 78 21 61 7 99 97 45 89 57 27 76 11 49 72 84 69 43 62 4 22 75 6 66 83 38 34 86 15 40 51 37 74 67 31 20 63 77 80 12 53 5 25 58 90 68 24 64 23 95 32 55 47\n", "output...
code_stdio
[ { "content": "There is an infinitely large pond, which we consider as a number line.\nIn this pond, there are N lotuses floating at coordinates 0, 1, 2, ..., N-2 and N-1.\nOn the lotus at coordinate i, an integer s_i is written.\nYou are standing on the lotus at coordinate 0. You will play a game that proceeds ...
[{"input": "11\n0 -4 0 -99 107 13 -43 -39 207 37 0", "output": "271\n"}, {"input": "11\n0 -4 0 -99 31 14 -26 -39 115 29 0", "output": "140\n"}, {"input": "11\n0 -4 0 -99 31 14 -26 -39 115 27 0", "output": "138\n"}, {"input": "11\n0 -4 0 -99 31 14 -26 -39 116 27 0", "output": "139\n"}, {"input": "11\n0 -4 0 -99 59 14 -2...
code_stdio
[ { "content": "Vasya has n burles. One bottle of Ber-Cola costs a burles and one Bars bar costs b burles. He can buy any non-negative integer number of bottles of Ber-Cola and any non-negative integer number of Bars bars.\n\nFind out if it's possible to buy some amount of bottles of Ber-Cola and Bars bars and sp...
[{"input": "10000000\n10000000\n10000000\n", "output": "YES\n0 1\n"}, {"input": "10000000\n10000000\n10000000\n", "output": "YES\n0 1\n"}, {"input": "10000000\n10000100\n10000000\n", "output": "YES\n0 1\n"}, {"input": "10000000\n9999999\n1\n", "output": "YES\n0 10000000\n"}, {"input": "10000000\n1234523\n1\n", "output"...
code_stdio
[ { "content": "I decided to do bowling as a recreation of the class. Create a program that inputs the pitching information for each participant and outputs the grade information in descending order of score. If there is a tie, output in ascending order of student ID number. However, it is assumed that the number...
[{"input": "3\n1010 6 3 10 10 1 0 7 9 1 10 6 2 4 3 9 1 9 0\n1200 5 3 9 1 12 1 0 0 12 1 10 10 4 3 9 1 8 2 9\n1101 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3\n4\n3321 8 2 10 9 1 7 0 10 10 10 0 8 10 10 10 10\n3332 5 0 10 13 1 4 1 9 0 10 10 7 1 5 2 8 1\n3335 10 10 10 10 10 10 10 10 10 10 10 10\n3340 8 2 7 3 0 4 8 2 8 2 14 1 7...
code_stdio
[ { "content": "You are given positive integers N and M.\nHow many sequences a of length N consisting of positive integers satisfy a_1 \\times a_2 \\times ... \\times a_N = M? Find the count modulo 10^9+7.\nHere, two sequences a' and a'' are considered different when there exists some i such that a_i' \\neq a_i''...
[{"input": "100000 1000000000\n", "output": "957870001\n"}, {"input": "100000 450968417\n", "output": "993000007\n"}, {"input": "100000 654885000\n", "output": "888903730\n"}, {"input": "100000 497668710\n", "output": "999983200\n"}, {"input": "100000 588153930\n", "output": "999983200\n"}, {"input": "100000 380570190\...
code_stdio
[ { "content": "You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \\cdot 10^5$, inclusive). It may contain leading zeros.\n\nYou can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when d...
[{"input": "3\n0709\n1337\n246432\n", "output": "0079\n1337\n234642\n"}, {"input": "3\n0709\n1337\n246432\n", "output": "0079\n1337\n234642\n"}, {"input": "3\n477\n1337\n246432\n", "output": "477\n1337\n234642\n"}, {"input": "3\n477\n1216\n246432\n", "output": "477\n1126\n234642\n"}, {"input": "3\n716\n1216\n246432\n",...
code_stdio
[ { "content": "В Берляндском государственном университете локальная сеть между серверами не всегда работает без ошибок. При передаче двух одинаковых сообщений подряд возможна ошибка, в результате которой эти два сообщения сливаются в одно. При таком слиянии конец первого сообщения совмещается с началом второго. ...
[{"input": "wajaubjjlsvvatkrwphykszmkwajaubjjlsvvatkrwphykszmkwajaubjjlsvvatkrwphykszmkwajaubjjlsvvatkrwphykszmk\n", "output": "YES\nwajaubjjlsvvatkrwphykszmkwajaubjjlsvvatkrwphykszmkwajaubjjlsvvatkrwphykszmk\n"}, {"input": "twfflboprkkjobbgoubmybfkbmmconrjhsktwfflboprkkjobbgoubmybfkbmmconrjhsktwfflboprkkjobbgoubmybfkb...
code_stdio
[ { "content": "T is playing a game with his friend, HL.\n\nThere are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones. \n\nT and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a...
[{"input": "4\n5\n1 3 1 3 4\n1\n4\n1\n5\n2\n3 3\n", "output": "HL\nT\nT\nHL\n"}, {"input": "4\n5\n1 3 1 3 4\n1\n4\n1\n5\n2\n3 3\n", "output": "HL\nT\nT\nHL\n"}, {"input": "4\n5\n1 3 1 3 4\n1\n4\n1\n4\n2\n3 3\n", "output": "HL\nT\nT\nHL\n"}, {"input": "4\n5\n1 3 1 3 4\n1\n5\n1\n4\n2\n3 3\n", "output": "HL\nT\nT\nHL\n"},...
code_stdio
[ { "content": "You have written N problems to hold programming contests. The i-th problem will have a score of P_i points if used in a contest.\n\nWith these problems, you would like to hold as many contests as possible under the following condition:\n\n* A contest has three problems. The first problem has a sco...
[{"input": "8\n3 14\n2 5 10 2 13 12 15 20", "output": "2\n"}, {"input": "8\n3 14\n2 5 10 2 13 12 15 22", "output": "2\n"}, {"input": "8\n3 14\n2 5 5 2 13 12 15 20", "output": "2\n"}, {"input": "8\n3 14\n2 5 6 2 13 12 15 22", "output": "2\n"}, {"input": "8\n3 14\n2 5 3 2 13 12 15 22", "output": "2\n"}, {"input": "7\n8 2...
code_stdio
[ { "content": "There is a famous olympiad, which has more than a hundred participants. The Olympiad consists of two stages: the elimination stage, and the final stage. At least a hundred participants will advance to the final stage. The elimination stage in turn consists of two contests.\n\nA result of the elimi...
[{"input": "2\n1 2 2 1\n4 8 12 4\n", "output": "3\n16\n"}, {"input": "2\n1 2 3 1\n4 8 12 4\n", "output": "4\n16\n"}, {"input": "2\n1 2 2 1\n4 8 9 2\n", "output": "3\n12\n"}, {"input": "2\n1 2 2 1\n4 8 9 4\n", "output": "3\n13\n"}, {"input": "2\n1 0 2 1\n4 8 9 4\n", "output": "3\n13\n"}, {"input": "2\n1 2 2 1\n4 8 9 2\n...
code_stdio
[ { "content": "You are given a string s consisting of |s| small english letters.\n\nIn one move you can replace any character of this string to the next character in alphabetical order (a will be replaced with b, s will be replaced with t, etc.). You cannot replace letter z with any other letter.\n\nYour target ...
[{"input": "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzabcdefghijklmnopqrstuvwxyzaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"}, {"input": "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz...
code_stdio
[ { "content": "Recently Ivan the Fool decided to become smarter and study the probability theory. He thinks that he understands the subject fairly well, and so he began to behave like he already got PhD in that area.\n\nTo prove his skills, Ivan decided to demonstrate his friends a concept of random picture. A p...
[{"input": "100000 100000\n", "output": "870472905\n"}, {"input": "100000 100000\n", "output": "870472905\n"}, {"input": "86821 24538\n", "output": "1000000005\n"}, {"input": "99999 100000\n", "output": "758107445\n"}, {"input": "100000 99999\n", "output": "758107445\n"}, {"input": "52702 64157\n", "output": "100000000...
code_stdio
[ { "content": "Write a program which performs the following operations to a binary search tree $T$ by adding the find operation to A: Binary Search Tree I.\n\n* insert $k$: Insert a node containing $k$ as key into $T$.\n* find $k$: Report whether $T$ has a node containing $k$.\n* print: Print the keys of the bi...
[{"input": "10\ninsert 30\ninsert 100\ninsert 19\ninsert 1\ninsert 16\nfind 13\ninsert 17\ninsert 25\nfind 16\nprint", "output": "no\nyes\n 1 16 17 19 25 30 100\n 30 19 1 16 17 25 100\n"}, {"input": "10\ninsert 30\ninsert 100\ninsert 19\ninsert 1\ninsert 12\nfind 13\ninsert 17\ninsert 25\nfind 16\nprint", "output": "no...
code_stdio
[ { "content": "While Patrick was gone shopping, Spongebob decided to play a little trick on his friend. The naughty Sponge browsed through Patrick's personal stuff and found a sequence a_1, a_2, ..., a_{m} of length m, consisting of integers from 1 to n, not necessarily distinct. Then he picked some sequence f_1...
[{"input": "2 100\n2 1\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 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n", "output": "Possible\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...
code_stdio
[ { "content": "A chess tournament will be held soon, where $n$ chess players will take part. Every participant will play one game against every other participant. Each game ends in either a win for one player and a loss for another player, or a draw for both players.\n\nEach of the players has their own expectat...
[{"input": "3\n3\n111\n2\n11\n4\n2122\n", "output": "YES\nX==\n=X=\n==X\nYES\nX=\n=X\nYES\nX=+-\n=X==\n-=X+\n+=-X\n"}, {"input": "3\n3\n111\n1\n1\n4\n2122\n", "output": "YES\nX==\n=X=\n==X\nYES\nX\nYES\nX=+-\n=X==\n-=X+\n+=-X\n"}, {"input": "3\n3\n111\n2\n21\n4\n2122\n", "output": "YES\nX==\n=X=\n==X\nNO\nYES\nX=+-\n=X...
code_stdio
[ { "content": "— Hey folks, how do you like this problem?\n\n— That'll do it. \n\nBThero is a powerful magician. He has got $n$ piles of candies, the $i$-th pile initially contains $a_i$ candies. BThero can cast a copy-paste spell as follows: He chooses two piles $(i, j)$ such that $1 \\le i, j \\le n$ and $i ...
[{"input": "3\n2 2\n2 1\n3 5\n1 3 3\n3 12\n1 2 2\n", "output": "0\n4\n20\n"}, {"input": "3\n2 2\n1 1\n3 10\n1 2 4\n3 7\n3 2 2\n", "output": "1\n14\n4\n"}, {"input": "3\n2 2\n2 1\n3 5\n1 3 3\n3 24\n1 2 2\n", "output": "0\n4\n44\n"}, {"input": "3\n2 2\n1 1\n3 10\n1 3 4\n3 7\n3 2 2\n", "output": "1\n13\n4\n"}, {"input": "...
code_stdio
[ { "content": "Calendars in widespread use today include the Gregorian calendar, which is the de facto international standard, and is used almost everywhere in the world for civil purposes. The Gregorian reform modified the Julian calendar's scheme of leap years as follows:\n\n Every year that is exactly divisib...
[{"input": "1900:01:01\n2038:12:31\n", "output": "50768\n"}, {"input": "1903:09:27\n1988:06:15\n", "output": "30943\n"}, {"input": "1915:01:01\n2007:07:01\n", "output": "33784\n"}, {"input": "1925:07:15\n2010:06:22\n", "output": "31023\n"}, {"input": "1986:08:24\n1926:04:13\n", "output": "22048\n"}, {"input": "1932:11:...
code_stdio
[ { "content": "As many of you know, we have two major calendar systems used in Japan today. One of them is Gregorian calendar which is widely used across the world. It is also known as “Western calendar” in Japan.\n\nThe other calendar system is era-based calendar, or so-called “Japanese calendar.” This system c...
[{"input": "4 3\nmeiji 10 1877\ntaisho 6 1917\nrhowa 62 1987\nheisei 22 2010\n2046\n1917\n1988\n1 1\nuniversalbentury 218 2168\n2010\n0 0", "output": "Unknown\ntaisho 6\nUnknown\nuniversalbentury 60\n"}, {"input": "4 3\nmeiji 10 1877\nasisho 6 3102\nsiowa 62 1987\nieisei 25 2010\n526\n2891\n1988\n1 1\nuniversalcentury ...
code_stdio
[ { "content": "There is a white sheet of paper lying on a rectangle table. The sheet is a rectangle with its sides parallel to the sides of the table. If you will take a look from above and assume that the bottom left corner of the table has coordinates $(0, 0)$, and coordinate axes are left and bottom sides of ...
[{"input": "676584 172869 696986 939949\n217531 247380 771662 973703\n630670 592931 1018961 967883\n", "output": "YES\n"}, {"input": "347722 718484 584813 736820\n280059 317406 1617512 588815\n388486 281361 399827 854715\n", "output": "YES\n"}, {"input": "347722 718484 584813 736820\n280059 317406 997137 588815\n388486...
code_stdio
[ { "content": "Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $s$ of length $n$ and $t$ of length $m$.\n\nA sequence $p_1, p_2, \\ldots, p_m$, where $1 \\leq p_1 < p_2 < \\ldots < p_m \\leq n$, is called beautiful, if $s_{p_i} = t_i$ for all $i...
[{"input": "99 54\nfdabegacbffbgcacafcegfaegcacaegdbcabfgaecgbgfgefddggcdgebaaaccbcafdgcceabddfcacgdccfcgebccfffdaccac\nfdabegabffbgcaafcegfgcacaegdbcabfaecgbgfcgbccfffdaccac\n", "output": "40\n"}, {"input": "99 54\nfdabegacbffbgcacafcegfaegcacaegdbcabfgaecgbgfgefddggcdgebaaaccbcafdgcceabddfcacgdccfcgebccfffdaccac\nfda...
code_stdio
[ { "content": "You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $r$ candies in it, the second pile contains only green candies and there are $g$ candies in it, the third pile contains only blue candies and there are $b$ candies in it. \n\nEac...
[{"input": "6\n2 1 1\n1 1 1\n4 1 2\n7 7 18\n12 1 4\n14 0 13\n", "output": "2\n1\n3\n14\n5\n13\n"}, {"input": "6\n1 1 1\n1 2 1\n4 1 1\n7 7 25\n8 1 4\n14 2 15\n", "output": "1\n2\n2\n14\n5\n15\n"}, {"input": "6\n1 1 1\n1 2 1\n4 1 1\n7 7 25\n8 1 4\n14 2 29\n", "output": "1\n2\n2\n14\n5\n16\n"}, {"input": "6\n1 1 1\n1 2 1\...
code_stdio
[ { "content": "Problem\n\nGiven a natural number N less than or equal to 12, find the smallest natural number such that the number of divisors is exactly N.\n\nConstraints\n\n* 1 ≤ N ≤ 12\n\nInput\n\nOne natural number N is given in one line.\n\nOutput\n\nOutput the smallest natural number on a line so that the ...
[{"input": "011", "output": "1024\n"}, {"input": "011", "output": "1024\n"}, {"input": "11", "output": "1024\n"}, {"input": "11", "output": "1024\n"}, {"input": "010", "output": "48\n"}, {"input": "010", "output": "48\n"}, {"input": "10", "output": "48\n"}, {"input": "12", "output": "60\n"}, {"input": "001", "output": ...
code_stdio
[ { "content": "Winnie-the-Pooh likes honey very much! That is why he decided to visit his friends. Winnie has got three best friends: Rabbit, Owl and Eeyore, each of them lives in his own house. There are winding paths between each pair of houses. The length of a path between Rabbit's and Owl's houses is a meter...
[{"input": "100\n100\n100\n100\n", "output": "9900\n"}, {"input": "100\n100\n100\n100\n", "output": "9900\n"}, {"input": "100\n100\n110\n100\n", "output": "9900\n"}, {"input": "100\n100\n111\n100\n", "output": "9900\n"}, {"input": "100\n100\n010\n100\n", "output": "990\n"}, {"input": "73\n136\n69\n66\n", "output": "475...
code_stdio
[ { "content": "A rabbit is playing a role-playing game. Just before entering the castle, he was ambushed by an enemy!\n\nIt was a battle between one hero operated by a rabbit and n enemies. Each character has four stats, health hi, attack power ai, defense power di, and agility si. I = 0 is the information of th...
[{"input": "1\n-2 11 -1 -2\n11011 11101 11000 00111", "output": "-1\n"}, {"input": "1\n-2 17 -1 -2\n11011 11101 11000 00111", "output": "-1\n"}, {"input": "1\n-2 17 -1 -2\n11011 11101 11000 00011", "output": "-1\n"}, {"input": "1\n-1 2 -1 -1\n00101 00011 01000 10101", "output": "-1\n"}, {"input": "1\n-1 2 -1 -1\n00101 ...
code_stdio
[ { "content": "Breaking Good is a new video game which a lot of gamers want to have. There is a certain level in the game that is really difficult even for experienced gamers.\n\nWalter William, the main character of the game, wants to join a gang called Los Hermanos (The Brothers). The gang controls the whole c...
[{"input": "13 58\n9 12 0\n8 11 0\n4 8 1\n2 12 1\n9 1 1\n10 6 1\n5 2 1\n3 9 0\n8 3 0\n9 10 0\n8 5 1\n11 3 0\n11 1 0\n2 6 1\n12 3 1\n11 6 0\n1 12 0\n2 1 1\n11 13 0\n6 8 1\n11 5 1\n8 9 0\n1 4 0\n12 7 1\n5 12 0\n11 7 0\n11 2 0\n5 11 1\n9 4 1\n7 5 1\n2 11 0\n13 12 1\n10 3 1\n1 13 0\n7 1 0\n6 3 0\n7 13 0\n4 10 0\n7 10 1\n12...
code_stdio
[ { "content": "A young boy John is playing with eight triangular panels. These panels are all regular triangles of the same size, each painted in a single color; John is forming various octahedra with them.\n\nWhile he enjoys his playing, his father is wondering how many octahedra can be made of these panels sin...
[{"input": "lbeu blue eulb lbud bluf cleu bule bleu\nder fmub blue bleu beul blse blve eulb\nqdd red eulb bleu eula bkue cmue bltd", "output": "1680\n1680\n1680\n"}, {"input": "lbeu blue eulb lbud bluf cleu bule bleu\nder fmub blue uelb beul blse blve eulb\nqdd red eulb bleu eula bkue cmue bltd", "output": "1680\n1680\...
code_stdio
[ { "content": "Takahashi has come to a party as a special guest.\nThere are N ordinary guests at the party. The i-th ordinary guest has a power of A_i.\nTakahashi has decided to perform M handshakes to increase the happiness of the party (let the current happiness be 0).\nA handshake will be performed as follows...
[{"input": "9 73\n67597 102019 5828 66249 138664 64141 11513 192153 16076", "output": "11787970\n"}, {"input": "9 73\n67597 52981 5828 66249 138664 64141 11513 192153 16076", "output": "10905286\n"}, {"input": "9 73\n67597 52981 5828 66249 138664 64141 11513 132567 16076", "output": "9832738\n"}, {"input": "9 73\n67597...
code_stdio
[ { "content": "There are N persons called Person 1 through Person N.\nYou are given M facts that \"Person A_i and Person B_i are friends.\" The same fact may be given multiple times.\nIf X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived fro...
[{"input": "4 10\n1 2\n2 1\n1 2\n2 1\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n", "output": "4\n"}, {"input": "1 0\n1 1\n1 2\n0 6\n-1 1\n1 4\n0 12\n2 1\n4 3\n2 4\n4 0", "output": "1\n"}, {"input": "1 0\n1 1\n1 2\n0 6\n-1 1\n1 4\n0 12\n2 1\n4 3\n2 4\n7 0", "output": "1\n"}, {"input": "1 0\n1 1\n1 2\n0 6\n-1 1\n1 4\n0 12\n2 1\n4 5\...
code_stdio
[ { "content": "Nian is a monster which lives deep in the oceans. Once a year, it shows up on the land, devouring livestock and even people. In order to keep the monster away, people fill their villages with red colour, light, and cracking noise, all of which frighten the monster out of coming.\n\nLittle Tommy ha...
[{"input": "24 24\n299931317 581208095 975349898 832722683 817690798 482251493 336949323 145902930 573001018 802990442 898055771 253410043 150981561 225791789 53290960 405421751 723296526 565432511 256399554 374970926 22699716 104391316 121063780 149329252\n-295118728 -830122321 -294539299 -905916790 -596056305 -120216...
code_stdio
[ { "content": "Soma is a fashionable girl. She absolutely loves shiny stones that she can put on as jewellery accessories. She has been collecting stones since her childhood - now she has become really good with identifying which ones are fake and which ones are not. Her King requested for her help in mining pr...
[{"input": "4\nacb\nabcdef\naA\nabAZ\naaa\na\nwhat\nnone", "output": "3\n2\n1\n0\n"}, {"input": "4\nacb\nabcdef\nAa\nabZA\naaa\n`\nwhat\nnone", "output": "3\n2\n0\n0\n"}, {"input": "4\naca\nebcdaf\naA\nAbZa\n`aa\n`\nswha\nnomf", "output": "2\n2\n1\n0\n"}, {"input": "4\nac`\nebcdae\naA\nAbZa\n`aa\n_\nsvha\nnome", "outpu...
code_stdio
[ { "content": "Профиль горного хребта схематично задан в виде прямоугольной таблицы из символов «.» (пустое пространство) и «*» (часть горы). Каждый столбец таблицы содержит хотя бы одну «звёздочку». Гарантируется, что любой из символов «*» либо находится в нижней строке матрицы, либо непосредственно под ним нах...
[{"input": "20 20\n........*...........\n........*........*..\n........*........*..\n.**.....*.......**..\n.**.....*.......**..\n.**.....*.....*.**..\n.**.....*.....*.**..\n.**.....*.....*.**..\n.**.....*.....*.**..\n.**.*...*.....*.**..\n.**.*...*.....*.**..\n.**.*...*....**.**..\n.**.*...*..*.**.**..\n.**.*...*..*.**...
code_stdio
[ { "content": "Caisa solved the problem with the sugar and now he is on the way back to home. \n\nCaisa is playing a mobile game during his path. There are (n + 1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (i > 0) has height h_{i}. The goal of the ...
[{"input": "99\n1401 2019 1748 3785 3236 3177 3443 3772 2138 1049 353 1195 310 2388 1322 88 2160 2783 435 2248 1471 706 2468 2319 3156 3506 2794 1999 1983 2519 2597 3735 537 344 3519 3772 3872 2961 3895 2010 10 247 3269 671 2986 942 758 1146 77 1545 3745 1547 2250 2565 217 1406 2070 3010 3404 404 1528 2352 138 2065 304...
code_stdio
[ { "content": "Let's define the following recurrence: $$a_{n+1} = a_{n} + minDigit(a_{n}) \\cdot maxDigit(a_{n}).$$\n\nHere $minDigit(x)$ and $maxDigit(x)$ are the minimal and maximal digits in the decimal representation of $x$ without leading zeroes. For examples refer to notes.\n\nYour task is calculate $a_{K}...
[{"input": "8\n1 4\n487 1\n487 2\n487 3\n487 4\n487 5\n937 6\n487 1\n", "output": "42\n487\n519\n528\n544\n564\n1000\n487\n"}, {"input": "8\n1 4\n487 1\n487 2\n487 3\n487 4\n487 5\n487 6\n487 10\n", "output": "42\n487\n519\n528\n544\n564\n588\n716\n"}, {"input": "8\n1 4\n487 1\n487 2\n487 3\n487 4\n487 5\n487 6\n487 7\...
code_stdio
[ { "content": "Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.\n\nThe girl noticed that some of the tree's vertices are sad, so she decided to play w...
[{"input": "39\n100 110 92 26 10 63 56 85 14 64 25 50 75 51 11 41 78 53 52 96 63 12 48 88 57 57 25 52 69 45 4 97 5 87 58 15 72 59 100\n35 -60\n33 -39\n1 65\n11 -65\n34 -63\n38 84\n4 76\n22 -9\n4 -91\n23 -65\n18 7\n2 -17\n29 -15\n19 26\n29 23\n14 -12\n30 -72\n9 14\n12 -1\n27 -21\n32 -67\n7 -3\n26 -18\n12 -45\n33 75\n14 ...
code_stdio
[ { "content": "You are given a boolean function of three variables which is defined by its truth table. You need to find an expression of minimum length that equals to this function. The expression may consist of: Operation AND ('&', ASCII code 38) Operation OR ('|', ASCII code 124) Operation NOT ('!', ASCII...
[{"input": "5\n01111000\n00110110\n00011000\n01110111\n01010010\n", "output": "!x&(y|z)|!y&!z&x\n!(x&z)&y|!y&x&z\n!x&y&z|!y&!z&x\ny|z\n!x&z|!z&x&y\n"}, {"input": "5\n01111000\n00110110\n00011100\n01110111\n01010010\n", "output": "!x&(y|z)|!y&!z&x\n!(x&z)&y|!y&x&z\n!x&y&z|!y&x\ny|z\n!x&z|!z&x&y\n"}, {"input": "5\n011110...
code_stdio
[ { "content": "Polycarpus is an amateur businessman. Recently he was surprised to find out that the market for paper scissors is completely free! Without further ado, Polycarpus decided to start producing and selling such scissors.\n\nPolycaprus calculated that the optimal celling price for such scissors would b...
[{"input": "1000000000000000000 999999999999999999\n", "output": "999999999999999999\n"}, {"input": "1000010000000000000 999999999999999999\n", "output": "999999999999999999\n"}, {"input": "999999999999999998 999999999999999997\n", "output": "899999999999999999\n"}, {"input": "1365906875851574593 354162450334047\n", "o...
code_stdio
[ { "content": "Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of Mysterious Light.\n\nThree mirrors of length N are set so that they form an equilateral triangle. Let the vertices of the triangle be a, b and c.\n\nInside the triangle, the rifle is placed at the point p o...
[{"input": "1435 1", "output": "4302\n"}, {"input": "1556 2", "output": "4662\n"}, {"input": "457 3", "output": "1368\n"}, {"input": "371 4", "output": "1110\n"}, {"input": "702 4", "output": "2100\n"}, {"input": "590 4", "output": "1764\n"}, {"input": "590 1", "output": "1767\n"}, {"input": "843 1", "output": "2526\n"...
code_stdio
[ { "content": "Let us define the oddness of a permutation p = {p_1,\\ p_2,\\ ...,\\ p_n} of {1,\\ 2,\\ ...,\\ n} as \\sum_{i = 1}^n |i - p_i|.\nFind the number of permutations of {1,\\ 2,\\ ...,\\ n} of oddness k, modulo 10^9+7.\n\n-----Constraints-----\n - All values in input are integers.\n - 1 \\leq n \\leq 5...
[{"input": "49 1200\n", "output": "366641438\n"}, {"input": "50 1250\n", "output": "472467292\n"}, {"input": "38 716\n", "output": "810790165\n"}, {"input": "31 344\n", "output": "996412950\n"}, {"input": "43 668\n", "output": "484721091\n"}, {"input": "44 350\n", "output": "15060087\n"}, {"input": "17 56\n", "output":...
code_stdio
[ { "content": "Let w be a string consisting of lowercase letters.\nWe will call w beautiful if the following condition is satisfied:\n - Each lowercase letter of the English alphabet occurs even number of times in w.\nYou are given the string w. Determine if w is beautiful.\n\n-----Constraints-----\n - 1 \\leq |...
[{"input": "abaccaba\n", "output": "Yes\n"}, {"input": "ab`cc`ba", "output": "Yes\n"}, {"input": "ab`ccaba", "output": "No\n"}, {"input": "`b`cc`ba", "output": "No\n"}, {"input": "ab`cc`b`", "output": "No\n"}, {"input": "`b`cc`ca", "output": "No\n"}, {"input": "`b_cc`ca", "output": "No\n"}, {"input": "`b_dc`ca", "outpu...
code_stdio
[ { "content": "DLS and JLS are bored with a Math lesson. In order to entertain themselves, DLS took a sheet of paper and drew $n$ distinct lines, given by equations $y = x + p_i$ for some distinct $p_1, p_2, \\ldots, p_n$.\n\nThen JLS drew on the same paper sheet $m$ distinct lines given by equations $y = -x + q...
[{"input": "7\n2\n1000000000 0\n2\n1000000000 0\n2\n1 0\n2\n1000000000 0\n2\n1 0\n2\n1 0\n2\n1000000000 0\n2\n1 0\n1\n999999999\n1\n99999999\n1\n1000000000\n1\n999999999\n3\n1000000000 999999999 999999998\n7\n2 3 5 7 10 11 12\n", "output": "4\n2\n2\n2\n1\n0\n10\n"}, {"input": "7\n2\n1000000000 0\n2\n1000000000 0\n2\n1 ...
code_stdio
[ { "content": "Dreamoon wants to climb up a stair of n steps. He can climb 1 or 2 steps at each move. Dreamoon wants the number of moves to be a multiple of an integer m. \n\nWhat is the minimal number of moves making him climb to the top of the stairs that satisfies his condition?\n\n\n-----Input-----\n\nThe si...
[{"input": "10000 10\n", "output": "5000\n"}, {"input": "10000 10\n", "output": "5000\n"}, {"input": "24634 6\n", "output": "12318\n"}, {"input": "48898 6\n", "output": "24450\n"}, {"input": "26032 9\n", "output": "13023\n"}, {"input": "20108 9\n", "output": "10062\n"}, {"input": "10000 2\n", "output": "5000\n"}, {"inp...
code_stdio
[ { "content": "You are going to eat X red apples and Y green apples.\n\nYou have A red apples of deliciousness p_1,p_2, \\dots, p_A, B green apples of deliciousness q_1,q_2, \\dots, q_B, and C colorless apples of deliciousness r_1,r_2, \\dots, r_C.\n\nBefore eating a colorless apple, you can paint it red or gree...
[{"input": "2 2 4 4 4\n11 12 13 14\n21 22 23 24\n1 2 3 4\n", "output": "74\n"}, {"input": "2 4 4 4 4\n11 15 13 14\n21 22 23 22\n1 2 3 4", "output": "117\n"}, {"input": "0 2 4 -1 4\n14 22 13 1\n18 15 31 74\n1 0 2 1", "output": "105\n"}, {"input": "2 2 4 4 4\n11 12 13 14\n21 22 23 22\n1 2 3 4", "output": "72\n"}, {"input...
code_stdio
[ { "content": "Once when Gerald studied in the first year at school, his teacher gave the class the following homework. She offered the students a string consisting of n small Latin letters; the task was to learn the way the letters that the string contains are written. However, as Gerald is too lazy, he has no ...
[{"input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n99\n", "output": "1\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"input": "geovcaxzjyhxbpnbkbsxfpkyofopxquzzxeigdflfumisevzsjdywehxconimkkbvjyxbq...
code_stdio
[ { "content": "Polycarp has a string $s[1 \\dots n]$ of length $n$ consisting of decimal digits. Polycarp performs the following operation with the string $s$ no more than once (i.e. he can perform operation $0$ or $1$ time):\n\nPolycarp selects two numbers $i$ and $j$ ($1 \\leq i \\leq j \\leq n$) and removes c...
[{"input": "6\n8\n20192020\n8\n22019020\n4\n2020\n5\n20002\n6\n729040\n6\n200200\n", "output": "\nYES\nYES\nYES\nNO\nNO\nNO\n"}, {"input": "6\n8\n20192020\n8\n22019020\n4\n2020\n5\n20002\n6\n729040\n6\n200200\n", "output": "YES\nYES\nYES\nNO\nNO\nNO\n"}, {"input": "1\n8\n00202000\n", "output": "NO\n"}, {"input": "1\n8\...
code_stdio
[ { "content": "Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nPetya has sequence a consisting of n integers.\n\nThe subsequence of the s...
[{"input": "20 7\n1 4 5 8 47 777777777 1 5 4 8 5 9 5 4 7 4 5 7 7 44474\n", "output": "29172\n"}, {"input": "20 7\n1 2 5 8 47 777777777 1 5 4 8 5 9 5 4 7 4 5 7 7 44474\n", "output": "39468\n"}, {"input": "13 5\n44 44 49 44 44 44 44 44 77 102 66 99 55\n", "output": "111\n"}, {"input": "13 5\n44 44 44 44 44 44 44 44 77 10...
code_stdio
[ { "content": "There are $n$ startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup.\n\nT...
[{"input": "50\n36 36 45 44 -1 -1 13 -1 36 -1 44 36 -1 -1 -1 35 -1 36 36 35 -1 -1 -1 14 36 36 22 36 13 -1 35 -1 35 36 -1 -1 13 13 45 36 14 -1 36 -1 -1 -1 22 36 -1 13\n", "output": "949472419\n"}, {"input": "50\n36 36 45 44 -1 -1 13 -1 36 -1 44 36 -1 -1 -1 35 -1 36 36 35 -1 -1 -1 14 36 36 22 36 13 -1 35 -1 35 36 -1 -1 1...
code_stdio
[ { "content": "Little Johnny has recently learned about set theory. Now he is studying binary relations. You've probably heard the term \"equivalence relation\". These relations are very important in many areas of mathematics. For example, the equality of the two numbers is an equivalence relation.\n\nA set ρ of...
[{"input": "4000\n", "output": "341934157\n"}, {"input": "3000\n", "output": "949793998\n"}, {"input": "3555\n", "output": "810675957\n"}, {"input": "2999\n", "output": "634360769\n"}, {"input": "3789\n", "output": "397160465\n"}, {"input": "2000\n", "output": "323848720\n"}, {"input": "3333\n", "output": "938772236\n"...
code_stdio
[ { "content": "Today is Wednesday, the third day of the week. What's more interesting is that tomorrow is the last day of the year 2015.\n\nLimak is a little polar bear. He enjoyed this year a lot. Now, he is so eager to the coming year 2016.\n\nLimak wants to prove how responsible a bear he is. He is going to r...
[{"input": "30 of month\n", "output": "11\n"}, {"input": "17 of month\n", "output": "12\n"}, {"input": "10 of month\n", "output": "12\n"}, {"input": "11 of month\n", "output": "12\n"}, {"input": "12 of month\n", "output": "12\n"}, {"input": "13 of month\n", "output": "12\n"}, {"input": "14 of month\n", "output": "12\n"...
code_stdio
[ { "content": "There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis.\n\nYou planned a trip along the axis. In this pla...
[{"input": "6\n-168 -101 -3258 1873 -20088 -2101", "output": "50438\n50438\n44258\n40310\n14598\n50572\n"}, {"input": "6\n-168 -101 -3258 1873 -20088 -1768", "output": "50438\n50438\n44258\n40310\n13932\n50572\n"}, {"input": "6\n-679 -3431 -3258 3095 -3291 -4462", "output": "21976\n21630\n21976\n9270\n21976\n19634\n"},...
code_stdio
[ { "content": "Andrewid the Android is a galaxy-famous detective. He is now investigating a case of frauds who make fake copies of the famous Stolp's gears, puzzles that are as famous as the Rubik's cube once was.\n\nIts most important components are a button and a line of n similar gears. Each gear has n teeth ...
[{"input": "100\n15 86 17 88 19 90 21 92 23 94 25 96 27 98 29 0 31 2 33 4 35 6 37 8 39 10 41 12 43 14 45 16 47 18 49 20 51 22 53 24 55 26 57 28 59 30 61 32 63 34 65 36 67 38 69 40 71 42 73 44 75 46 77 48 79 50 81 52 83 54 85 56 87 58 89 60 91 62 93 64 95 66 97 68 99 70 1 72 3 74 5 76 7 78 9 80 11 82 13 84\n", "output":...
code_stdio
[ { "content": "Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, t...
[{"input": "1000000 1000000\n1000000 999999\n1000000 999998\n999999 1000000\n999999 999998\n999998 1000000\n999998 999999\n999998 999998\n", "output": "respectable\n"}, {"input": "1000000 1000000\n1000000 999999\n1000000 999998\n999999 1000000\n999999 999998\n999998 1000000\n999998 999999\n999998 999998\n", "output": "...
code_stdio
[ { "content": "There are $n$ lamps on a line, numbered from $1$ to $n$. Each one has an initial state off ($0$) or on ($1$).\n\nYou're given $k$ subsets $A_1, \\ldots, A_k$ of $\\{1, 2, \\dots, n\\}$, such that the intersection of any three subsets is empty. In other words, for all $1 \\le i_1 < i_2 < i_3 \\le k...
[{"input": "19 5\n1001001001100000110\n2\n2 3\n2\n5 6\n2\n8 9\n5\n12 13 14 15 16\n1\n19\n", "output": "0\n1\n1\n1\n2\n2\n2\n3\n3\n3\n3\n4\n4\n4\n4\n4\n4\n4\n5\n"}, {"input": "19 5\n1001001001100000110\n2\n2 3\n2\n5 6\n2\n8 9\n5\n12 13 14 15 16\n1\n19\n", "output": "0\n1\n1\n1\n2\n2\n2\n3\n3\n3\n3\n4\n4\n4\n4\n4\n4\n4\n...
code_stdio
[ { "content": "Consider some square matrix A with side n consisting of zeros and ones. There are n rows numbered from 1 to n from top to bottom and n columns numbered from 1 to n from left to right in this matrix. We'll denote the element of the matrix which is located at the intersection of the i-row and the j-...
[{"input": "100\n", "output": "15"}, {"input": "010\n", "output": "5\n"}, {"input": "001\n", "output": "1\n"}, {"input": "011\n", "output": "5\n"}, {"input": "61\n", "output": "11"}, {"input": "98\n", "output": "15"}, {"input": "84\n", "output": "13"}, {"input": "43\n", "output": "11"}, {"input": "60\n", "output": "11"...
code_stdio
[ { "content": "You are given a binary matrix $A$ of size $n \\times n$. Let's denote an $x$-compression of the given matrix as a matrix $B$ of size $\\frac{n}{x} \\times \\frac{n}{x}$ such that for every $i \\in [1, n], j \\in [1, n]$ the condition $A[i][j] = B[\\lceil \\frac{i}{x} \\rceil][\\lceil \\frac{j}{x} ...
[{"input": "16\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\n", "output": "2\n"}, {"input": "16\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFD0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\n", "output": "1\n"}, {"input": "16\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFD0\nFFC0...
code_stdio
[ { "content": "Masha works in an advertising agency. In order to promote the new brand, she wants to conclude contracts with some bloggers. In total, Masha has connections of $n$ different bloggers. Blogger numbered $i$ has $a_i$ followers.\n\nSince Masha has a limited budget, she can only sign a contract with $...
[{"input": "3\n4 3\n1 3 1 2\n4 2\n1 1 1 1\n2 1\n1 2\n", "output": "\n2\n6\n1\n"}, {"input": "3\n4 3\n1 3 1 2\n4 2\n1 1 1 1\n2 1\n1 2\n", "output": "2\n6\n1\n"}, {"input": "3\n4 3\n1 3 1 2\n4 2\n1 2 1 1\n2 1\n1 2\n", "output": "2\n3\n1\n"}, {"input": "3\n4 3\n1 3 1 2\n4 2\n1 1 1 1\n2 1\n2 2\n", "output": "2\n6\n2\n"}, {...
code_stdio
[ { "content": "Vasya and Petya are playing a simple game. Vasya thought of number x between 1 and n, and Petya tries to guess the number.\n\nPetya can ask questions like: \"Is the unknown number divisible by number y?\".\n\nThe game is played by the following rules: first Petya asks all the questions that intere...
[{"input": "1000\n", "output": "193\n2 4 8 16 32 64 128 256 512 3 9 27 81 243 729 5 25 125 625 7 49 343 11 121 13 169 17 289 19 361 23 529 29 841 31 961 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 2...
code_stdio
[ { "content": "The blinds are known to consist of opaque horizontal stripes that can be rotated thus regulating the amount of light flowing in the room. There are n blind stripes with the width of 1 in the factory warehouse for blind production. The problem is that all of them are spare details from different or...
[{"input": "100 17\n20 61 7 74 87 84 87 35 64 7 36 5 72 20 62 29 29 58 67 51 50 45 82 20 76 79 39 21 5 39 94 13 65 11 3 21 26 2 15 56 20 75 49 27 64 48 51 96 32 80 57 10 57 48 36 83 51 25 45 65 24 22 3 92 45 52 52 58 15 90 23 43 56 88 46 50 72 70 60 47 91 68 40 24 16 44 82 90 17 17 51 71 25 94 13 42 26 25 53 95\n", "ou...
code_stdio
[ { "content": "Solve the mystery. \nInput:\nString which consists of words(all the characters of any word are lower case letters) and punctuation marks(consists of {'.' , ',' , '?' , '!'}). Also every input string consists of one '*' in it.\nIt is guaranteed that strings doesn't start or end with space(' ') and...
[{"input": "890\n*a\na*\n*abbax\nhello *lleh\nhe.llo!ol?*eh.\namy, must i jujitsu *y ma?\nbbmqbhc*bqmbb\nrzowkkyhhykkwoz*\ndqscdxr*dcsqd\now*o\nxsjybldbefsarcbynecdyggxxpklorelerolkpxxggydcenybcrasfebdlbyj*x\nmpp*\nqfwkhopkmcoqhnwnkuewhsqmgbbuqcljjjl*qubbgmqshweuknwnhqocmkpohkwfq\nswmdkqtbxixmvtrrbljptnsnfw*fnsntpjlbrr...
code_stdio
[ { "content": "Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.\n\n\nCircle ...
[{"input": "-2 -1 0 10 -18", "output": "Yes\n"}, {"input": "-2 -1 0 11 -18", "output": "Yes\n"}, {"input": "-2 1 3 10 -18", "output": "Yes\n"}, {"input": "-2 0 3 10 -18", "output": "Yes\n"}, {"input": "-2 0 0 10 -18", "output": "Yes\n"}, {"input": "-2 -1 0 6 -18", "output": "Yes\n"}, {"input": "-3 -1 0 6 -18", "output"...
code_stdio
[ { "content": "Let's consider one interesting word game. In this game you should transform one word into another through special operations. \n\nLet's say we have word w, let's split this word into two non-empty parts x and y so, that w = xy. A split operation is transforming word w = xy into word u = yx. For ex...
[{"input": "dkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjij\ndddkikjjidkkidijjjjkkjjikjdikiidijjikikjijjiijdikkjjjiddjjijkkkjkiijijkijdjjikikdjjjijdddjkjjdij...
code_stdio
[ { "content": "In the computer network of the Berland State University there are n routers numbered from 1 to n. Some pairs of routers are connected by patch cords. Information can be transmitted over patch cords in both direction. The network is arranged in such a way that communication between any two routers ...
[{"input": "10\n2:7,4-2:5,8-1:3-1:6-1:2-2:10,9\n9:6,7,3,4,10,8,9,5,1\n9:2,1,7,6,9,4,8,10,5\n8:5,2,1,3,6,9,10,8-1:7\n1:8-8:9,10,2,6,3,1,7,4\n9:8,4,1,2,10,9,7,3,5\n9:1,3,6,2,9,10,5,8,4\n9:5,2,7,3,6,4,10,1,9\n9:3,7,6,8,10,5,1,2,4\n1:9-8:2,7,3,6,8,5,1,4\n", "output": "9\n1 2\n1 3\n1 4\n1 5\n1 6\n1 10\n4 7\n5 8\n9 10\n"}, {...
code_stdio
[ { "content": "ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be naughty and color the trees in the park. The trees are numbered with integers from 1 to n from left to right.\n\nInitially, tree i has color c_{i}. ZS the Coder and Chris the B...
[{"input": "8 6 6\n0 0 0 0 0 0 0 0\n709812879 751993522 552838834 932579085 381597201 889756688\n77223016 35398130 932703875 852137134 124534767 472656085\n828677108 158247840 540181954 573979204 389860841 490718346\n666733838 404533406 50010075 311518758 460372535 69832342\n591244215 400838850 867732307 113910196 4459...
code_stdio
[ { "content": "Mashmokh works in a factory. At the end of each day he must turn off all of the lights. \n\nThe lights on the factory are indexed from 1 to n. There are n buttons in Mashmokh's room indexed from 1 to n as well. If Mashmokh pushes button with index i, then each light with index not less than i that...
[{"input": "100 100\n100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1\n", "ou...
code_stdio
[ { "content": "Vasily exited from a store and now he wants to recheck the total price of all purchases in his bill. The bill is a string in which the names of the purchases and their prices are printed in a row without any spaces. Check has the format \"name_1price_1name_2price_2...name_{n}price_{n}\", where nam...
[{"input": "amhppqxei543.370.32o544.196nocwgxticn776.562nm212.195dcftrrg635.773n646.814.94vrfmjjsgoi405.114k821.983.12rb749.955.62jifmdlgs615.101hg42.083.41gdqififg908.729qrrgopyn684.451avcjul727.150s864.068bcd196.732.37jd349.984.25ghn379.763.11dw881.650.19eysthrm790.534.68gilg546.048qs648.876pdudevipn986.325jcwqq376.6...
code_stdio
[ { "content": "Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.\n\nShe starts with 0 money on her account.\n\nIn the evening of i-th day a transaction a_{i} occurs. If a_{i} > 0, then a_{i} bourles are deposited to Luba's account. If a_{i} < 0, then a_{...
[{"input": "20 23036\n-1 1 -1 -1 -1 -1 1 -1 -1 0 0 1 1 0 -1 1 0 1 -1 -1\n", "output": "1\n"}, {"input": "20 23036\n-1 1 -1 -1 -1 -1 1 -1 -2 0 0 1 1 0 -1 1 0 1 -1 -1\n", "output": "1\n"}, {"input": "20 23036\n-1 1 -1 -1 -1 -1 1 -1 -2 0 0 1 1 0 -1 1 1 1 -1 -1\n", "output": "1\n"}, {"input": "20 23036\n-1 1 -1 -1 -1 -1 1 ...
code_stdio
[ { "content": "This is the easy version of the problem. The difference between the versions is the constraints on a_i. You can make hacks only if all versions of the problem are solved.\n\nLittle Dormi has recently received a puzzle from his friend and needs your help to solve it. \n\nThe puzzle consists of an u...
[{"input": "5 7\n#....#.\n.#.#...\n#....#.\n#....##\n#.#....\n4 1 1 1 0 3 1\n", "output": "\n3\n"}, {"input": "3 10\n#..###..##\n...#..###.\n.###..##..\n1 1 1 3 1 1 2 2 2 1\n", "output": "1\n"}, {"input": "3 6\n..#..#\n......\n#####.\n1 1 2 1 1 1\n", "output": "2\n"}, {"input": "3 3\n#.#\n#..\n##.\n3 1 1\n", "output": ...
code_stdio
[ { "content": "Vasya has a sequence $a$ consisting of $n$ integers $a_1, a_2, \\dots, a_n$. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform number $6$ $(\\dots 00000000110_2)$ into $3$ $(\\dots...
[{"input": "5\n1000000000000000000 352839520853234088 175235832528365792 753467583475385837 895062156280564685\n", "output": "3\n"}, {"input": "5\n1000000000000000000 352839520853234088 175235832528365792 753467583475385837 895062156280564685\n", "output": "3\n"}, {"input": "4\n1 2 1 16\n", "output": "4\n"}, {"input": ...
code_stdio