messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
1 value
[ { "content": "There are many anime that are about \"love triangles\": Alice loves Bob, and Charlie loves Bob as well, but Alice hates Charlie. You are thinking about an anime which has n characters. The characters are labeled from 1 to n. Every pair of two characters can either mutually love each other or mutua...
[{"input": "28567 13\n28079 24675 1\n18409 26720 1\n980 10815 1\n20794 16571 1\n7376 19861 1\n11146 706 1\n4255 16391 1\n27376 18263 1\n10019 28444 1\n6574 28053 1\n5036 16610 1\n3543 7122 1\n512 9554 1\n", "output": " 928433852\n"}, {"input": "28567 13\n28079 24675...
code_stdio
[ { "content": "You are given a sequence of integers $a_1, a_2, \\dots, a_n$. You need to paint elements in colors, so that: If we consider any color, all elements of this color must be divisible by the minimal element of this color. The number of used colors must be minimized. \n\nFor example, it's fine to pa...
[{"input": "100\n94 83 55 57 63 89 73 59 75 97 77 54 77 81 70 81 99 52 88 76 98 88 79 67 76 80 89 50 60 60 53 83 96 87 75 99 61 91 75 85 88 80 90 54 84 88 98 93 69 97 93 54 83 59 57 92 88 78 53 55 99 63 60 70 61 52 60 55 100 85 80 58 53 97 59 61 50 90 75 85 86 63 91 96 67 68 86 96 79 98 51 83 82 92 65 100 76 83 57 100\...
code_stdio
[ { "content": "International Abbreviation Olympiad takes place annually starting from 1989. Each year the competition receives an abbreviation of form IAO'y, where y stands for some number of consequent last digits of the current year. Organizers always pick an abbreviation with non-empty string y that has never...
[{"input": "9\nIAO'0\nIAO'00\nIAO'000\nIAO'0000\nIAO'00000\nIAO'000000\nIAO'0000000\nIAO'00000000\nIAO'000000000\n", "output": "1990\n2000\n3000\n10000\n100000\n1000000\n10000000\n100000000\n1000000000\n"}, {"input": "5\nIAO'15\nIAO'2015\nIAO'1\nIAO'9\nIAO'0\n", "output": "2015\n12015\n1991\n1989\n1990\n"}, {"input": "...
code_stdio
[ { "content": "You are given a garland consisting of $n$ lamps. States of the lamps are represented by the string $s$ of length $n$. The $i$-th character of the string $s_i$ equals '0' if the $i$-th lamp is turned off or '1' if the $i$-th lamp is turned on. You are also given a positive integer $k$.\n\nIn one mo...
[{"input": "6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0\n", "output": "1\n2\n5\n4\n0\n0\n"}, {"input": "6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n0\n1 1\n0\n", "output": "1\n2\n5\n4\n0\n0\n"}, {"input": "6\n9 2\n010001010\n9 5\n111100000\n7 4\n1111111\...
code_stdio
[ { "content": "Kolya loves putting gnomes at the circle table and giving them coins, and Tanya loves studying triplets of gnomes, sitting in the vertexes of an equilateral triangle.\n\nMore formally, there are 3n gnomes sitting in a circle. Each gnome can have from 1 to 3 coins. Let's number the places in the or...
[{"input": "100000\n", "output": "192156836"}, {"input": "100000\n", "output": "192156836"}, {"input": "100000\n", "output": "192156836"}, {"input": "10701\n", "output": "198227529\n"}, {"input": "10010\n", "output": "495680028\n"}, {"input": "62113\n", "output": "786955632\n"}, {"input": "48613\n", "output": "33515912...
code_stdio
[ { "content": "You are given a problemset consisting of $n$ problems. The difficulty of the $i$-th problem is $a_i$. It is guaranteed that all difficulties are distinct and are given in the increasing order.\n\nYou have to assemble the contest which consists of some problems of the given problemset. In other wor...
[{"input": "9\n4 6 9 12 100 150 200 400 800\n", "output": "5\n"}, {"input": "9\n4 6 9 12 100 150 200 400 800\n", "output": "5\n"}, {"input": "9\n4 6 9 12 100 150 200 400 612\n", "output": "5\n"}, {"input": "9\n4 2 9 12 100 150 200 400 612\n", "output": "5\n"}, {"input": "10\n1 2 5 11 12 24 25 26 27 28\n", "output": "7\...
code_stdio
[ { "content": "One company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hire new employees for it. After placing an advertisment the company received n resumes. Now the HR department has to evaluate each possible group composition and select one of them. Your ...
[{"input": "700\n", "output": "16017044425409540\n"}, {"input": "776\n", "output": "33019955679376860\n"}, {"input": "666\n", "output": "11292070960994226\n"}, {"input": "777\n", "output": "33319741730082870\n"}, {"input": "756\n", "output": "27490983258573432\n"}, {"input": "666\n", "output": "11292070960994226"}, {"i...
code_stdio
[ { "content": "You are given an integer $n$ and an integer $k$.\n\nIn one step you can do one of the following moves: decrease $n$ by $1$; divide $n$ by $k$ if $n$ is divisible by $k$. \n\nFor example, if $n = 27$ and $k = 3$ you can do the following steps: $27 \\rightarrow 26 \\rightarrow 25 \\rightarrow 24 ...
[{"input": "93\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\...
code_stdio
[ { "content": "Dr. Sato, a botanist, invented a number of special fertilizers for seedlings. When you give the fertilizer to the seedlings, the size of the seedlings changes in a blink of an eye. However, it was found that fertilizer has the following side effects.\n\n* The size of the seedlings does not change ...
[{"input": "3 3\n1.8036677694351575 3.7376015310643522 0.9359006248557373\n4.789021816134845 2.456993805979323 1.0\n3.0 1.470921439035275 1.5624820640788264\n2 7\n1.2643980385584639 1.3805003041132355\n2.3877376705228617 1.9499455465451372\n0 0", "output": "17.90\n67.31\n"}, {"input": "3 3\n1.8036677694351575 3.6908040...
code_stdio
[ { "content": "Ayush is a cashier at the shopping center. Recently his department has started a ''click and collect\" service which allows users to shop online. \n\nThe store contains k items. n customers have already used the above service. Each user paid for m items. Let a_{ij} denote the j-th item in the i-th...
[{"input": "10 1 100\n1 55 67 75 40 86 24 84 82 26 81 23 70 79 51 54 21 78 31 98 68 93 66 88 99 65 20 52 35 85 16 12 94 100 59 56 18 33 47 46 71 8 38 57 2 92 3 95 6 4 87 22 48 80 15 29 11 45 72 76 44 60 91 90 39 74 41 36 13 27 53 83 32 10 30 63 89 64 49 17 9 97 69 14 50 77 37 96 10 42 28 34 61 19 73 7 62 43 58 25\n33\n...
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 12 100 1 27 1 25 27 56 48 22 23 103 85 66 14 58 20 7 176 11 19 26 154 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 ...
code_stdio
[ { "content": "You are given n segments on the coordinate axis Ox and the number k. The point is satisfied if it belongs to at least k segments. Find the smallest (by the number of segments) set of segments on the coordinate axis Ox which contains all satisfied points and no others.\n\nInput\n\nThe first line co...
[{"input": "10 1\n-260424665 -168566709\n299109864 663179811\n769984405 942516913\n-998905510 -707148023\n-167958021 60599275\n658861231 718845364\n79407402 279078536\n13652788 79756488\n-676213666 -339118351\n-349156760 -258185154\n", "output": "5\n-998905510 -707148023\n-676213666 -168566709\n-167958021 279078536\n29...
code_stdio
[ { "content": "There are a number of ways to shuffle a deck of cards. Riffle shuffle is one such example. The following is how to perform riffle shuffle.\n\nThere is a deck of n cards. First, we divide it into two decks; deck A which consists of the top half of it and deck B of the bottom half. Deck A will have ...
[{"input": "17 1\n1\n28 4\n1 1 6 4", "output": "16\n19\n"}, {"input": "17 1\n1\n28 4\n1 2 6 4", "output": "16\n12\n"}, {"input": "6 1\n3\n18 4\n2 1 11 11", "output": "2\n13\n"}, {"input": "10 1\n3\n18 4\n2 2 12 4", "output": "4\n13\n"}, {"input": "16 1\n3\n11 4\n1 2 6 4", "output": "7\n10\n"}, {"input": "14 1\n2\n11 4\...
code_stdio
[ { "content": "Mr. Bender has a digital table of size n Γ— n, each cell can be switched on or off. He wants the field to have at least c switched on squares. When this condition is fulfilled, Mr Bender will be happy.\n\nWe'll consider the table rows numbered from top to bottom from 1 to n, and the columns β€” numbe...
[{"input": "1000000000 999999938 999999936 384381709\n", "output": "27600\n"}, {"input": "1000000000 999999946 999999941 715189365\n", "output": "37707\n"}, {"input": "1000000000 999999916 999999940 857945620\n", "output": "41279\n"}, {"input": "1000000000 504951981 646612086 602763371\n", "output": "17360\n"}, {"input...
code_stdio
[ { "content": "You are given an array $a$ consisting of $n$ integers. Let's denote monotonic renumeration of array $a$ as an array $b$ consisting of $n$ integers such that all of the following conditions are met:\n\n $b_1 = 0$; for every pair of indices $i$ and $j$ such that $1 \\le i, j \\le n$, if $a_i = a_j...
[{"input": "200\n1 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 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8...
code_stdio
[ { "content": "Luba has to do n chores today. i-th chore takes a_{i} units of time to complete. It is guaranteed that for every $i \\in [ 2 . . n ]$ the condition a_{i} β‰₯ a_{i} - 1 is met, so the sequence is sorted.\n\nAlso Luba can work really hard on some chores. She can choose not more than k any chores and d...
[{"input": "100 1 99\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 10...
code_stdio
[ { "content": "We have a string s consisting of lowercase English letters. Snuke can perform the following operation repeatedly:\n\n* Insert a letter `x` to any position in s of his choice, including the beginning and end of s.\n\n\n\nSnuke's objective is to turn s into a palindrome. Determine whether the object...
[{"input": "bxbax", "output": "-1\n"}, {"input": "xxabb", "output": "-1\n"}, {"input": "xyabb", "output": "-1\n"}, {"input": "bbayx", "output": "-1\n"}, {"input": "bb`yx", "output": "-1\n"}, {"input": "bb`xx", "output": "-1\n"}, {"input": "bc`xx", "output": "-1\n"}, {"input": "cc`xx", "output": "-1\n"}, {"input": "xx`c...
code_stdio
[ { "content": "Polycarp urgently needs a shovel! He comes to the shop and chooses an appropriate one. The shovel that Policarp chooses is sold for k burles. Assume that there is an unlimited number of such shovels in the shop.\n\nIn his pocket Polycarp has an unlimited number of \"10-burle coins\" and exactly on...
[{"input": "1000 12\n", "output": "1\n"}, {"input": "1000 18\n", "output": "1\n"}, {"input": "1000 19\n", "output": "1\n"}, {"input": "1100 19\n", "output": "1\n"}, {"input": "1010 13\n", "output": "1\n"}, {"input": "1100 22\n", "output": "1\n"}, {"input": "0010 13\n", "output": "1\n"}, {"input": "1000 3\n", "output": ...
code_stdio
[ { "content": "A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many applications in science and engineering. Vasya liked the idea of the method very much, and he decid...
[{"input": "168\n0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1...
code_stdio
[ { "content": "Chef has learned a new technique for comparing two recipes. A recipe contains a list of ingredients in increasing order of the times they will be processed. An ingredient is represented by a letter 'a'-'z'. The i-th letter in a recipe denotes the i-th ingredient. An ingredient can be used multiple...
[{"input": "3\nelax axle\nesidarap djapers\nalice bob", "output": "YES\nYES\nYES\n"}, {"input": "3\nelax ayle\nesidarap djapers\nalice bob", "output": "YES\nYES\nYES\n"}, {"input": "3\nelax ayle\nesidarap srepajd\nalice bob", "output": "YES\nYES\nYES\n"}, {"input": "3\nelax ayle\netidarap srepajd\nalice bob", "output":...
code_stdio
[ { "content": "You are given a keyboard that consists of $26$ keys. The keys are arranged sequentially in one row in a certain order. Each key corresponds to a unique lowercase Latin letter.\n\nYou have to type the word $s$ on this keyboard. It also consists only of lowercase Latin letters.\n\nTo type a word, yo...
[{"input": "5\nabcdefghijklmnopqrstuvwxyz\nnlleh\nabcxefghijklmnopqrstuvwdyz\ni\nabcdefghhjllmnzpqrstuvwxyo\ncodeforecs\nmnbvcxzlkjhefdsapoiuytrgwq\nqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\nqwertyuiopasdfghjklzxcvbnm\nabacaba\n", "output": "12\n0\n106\n18\n74\n"}, {"input": "5\nabcdefghijklmnopqrstuvwxyz\nhe...
code_stdio
[ { "content": "This is the hard version of the problem. The difference between versions is the constraints on $n$ and $a_i$. You can make hacks only if all versions of the problem are solved.\n\nFirst, Aoi came up with the following idea for the competitive programming problem:\n\nYuzu is a girl who collecting c...
[{"input": "87 83\n40 6 7 50 16 65 47 90 94 65 79 29 41 76 80 13 87 37 92 71 54 53 93 79 14 53 71 78 50 50 74 40 30 92 66 86 94 60 37 65 82 14 61 48 68 71 91 99 74 88 89 34 57 74 25 2 79 72 92 37 61 16 32 85 29 74 6 69 50 74 76 48 31 42 40 95 29 27 28 31 38 60 52 45 14 78 59\n", "output": "75\n17 18 19 20 21 22 23 24 2...
code_stdio
[ { "content": "Given is a string S consisting of lowercase English letters. Find the maximum positive integer K that satisfies the following condition:\n\n* There exists a partition of S into K non-empty strings S=S_1S_2...S_K such that S_i \\neq S_{i+1} (1 \\leq i \\leq K-1).\n\n\n\nHere S_1S_2...S_K represents...
[{"input": "aaaccacabaababb", "output": "11\n"}, {"input": "abbccacabaababa", "output": "13\n"}, {"input": "abbccaaabaababc", "output": "12\n"}, {"input": "`abab`cbbba`c`b", "output": "14\n"}, {"input": "`_b`ab`_babcdba", "output": "15\n"}, {"input": "aabccacabaababb", "output": "11\n"}, {"input": "bbabaabacaccbaa", "o...
code_stdio
[ { "content": "n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≀ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any...
[{"input": "1000000000 1000000000 1000000000\n", "output": "1\n"}, {"input": "100000000 999834114 93836827\n", "output": "29998\n"}, {"input": "1000000000 1000000000 1000000000\n", "output": "1\n"}, {"input": "100000000 999834114 93836827\n", "output": "29998\n"}, {"input": "1000000000 1000000010 1000000000\n", "output...
code_stdio
[ { "content": "problem\n\nJOI decided to make a signboard for the store.\n\nThere are N old signboards with letters written at equal intervals. JOI makes a sign by erasing some letters from the old sign. I want the remaining characters to be the name of the store, and the remaining characters to be evenly spaced...
[{"input": "4\nbar\nabracadabra\nbear\nbar\nbbraxbara", "output": "3\n"}, {"input": "4\nrab\nabracadabra\nbear\nbar\nbbraxbara", "output": "1\n"}, {"input": "4\nrab\nabracadabra\nbear\nbar\narabxarbb", "output": "2\n"}, {"input": "4\nqab\nabracadabra\nbear\nbar\narabxarbb", "output": "0\n"}, {"input": "4\nqab\nabracada...
code_stdio
[ { "content": "A wise king declared a new calendar. \"Tomorrow shall be the first day of the calendar, that is, the day 1 of the month 1 of the year 1. Each year consists of 10 months, from month 1 through month 10, and starts from a big month. A common year shall start with a big month, followed by small months...
[{"input": "8\n-1 1 1\n344 4 0\n738 4 2\n182 9 5\n992 5 6\n344 5 26\n696 6 19\n231 8 25", "output": "196865\n128957\n51469\n160715\n1492\n128912\n59672\n151076\n"}, {"input": "8\n-1 1 1\n344 3 0\n738 4 2\n182 9 5\n998 5 7\n344 5 26\n696 6 19\n231 10 25", "output": "196865\n128977\n51469\n160715\n311\n128912\n59672\n151...
code_stdio
[ { "content": "problem\n\nA city in Canada where JOI lives is divided into a grid pattern by w roads that extend straight in the north-south direction and h roads that extend straight in the east-west direction.\n\nThe w roads in the north-south direction are numbered 1, 2, ..., w in order from the west. In addi...
[{"input": "10 4\n13 70\n0 0", "output": "26\n55422\n"}, {"input": "10 4\n13 80\n0 0", "output": "26\n77629\n"}, {"input": "4 5\n13 34\n0 0", "output": "11\n61707\n"}, {"input": "8 4\n15 33\n0 0", "output": "20\n41241\n"}, {"input": "4 7\n12 40\n0 0", "output": "17\n43422\n"}, {"input": "6 5\n13 38\n0 0", "output": "26...
code_stdio
[ { "content": "Alexey, a merry Berland entrant, got sick of the gray reality and he zealously wants to go to university. There are a lot of universities nowadays, so Alexey is getting lost in the diversity β€” he has not yet decided what profession he wants to get. At school, he had bad grades in all subjects, and...
[{"input": "50\n69 6 6\n22 1 1\n23 3 3\n60 13 13\n13 3 3\n7 4 7\n6 1 1\n49 7 9\n68 8 8\n20 2 2\n34 1 1\n143 5 5\n22 1 1\n77 58 65\n10 3 3\n72 5 5\n47 1 1\n82 3 3\n92 8 8\n34 1 1\n42 9 10\n63 14 14\n10 3 3\n38 2 2\n80 6 6\n79 5 5\n53 5 5\n44 7 7\n85 2 2\n24 2 2\n57 3 3\n95 29 145\n77 6 6\n24 1 1\n33 4 4\n93 6 6\n55 22 2...
code_stdio
[ { "content": "problem\n\nAOR Ika is studying to pass the test.\n\nAOR Ika-chan solved the $ N $ question. After that, round the solved problem according to the following procedure.\n\n1. Check the correctness of the answer.\n2. If the answer is correct, write a circle mark, and if it is incorrect, write a cross...
[{"input": "3\nnxx", "output": "2\n"}, {"input": "3\nnwx", "output": "3\n"}, {"input": "3\nxxo", "output": "1\n"}, {"input": "3\nxwn", "output": "3\n"}, {"input": "3\nowx", "output": "3\n"}, {"input": "3\npxx", "output": "2\n"}, {"input": "3\npyx", "output": "3\n"}, {"input": "3\npzx", "output": "3\n"}, {"input": "3\np...
code_stdio
[ { "content": "A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters Β«+Β» and Β«1Β» into this sequence. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not.\n\nOne day Johnny got bracket sequence. H...
[{"input": "))())))))))())))))()()))()()))))())))))()))))))))))))(()))())(()))))(()))))())))((((()()))))()))()))\n", "output": "48\n"}, {"input": ")))()))()))))()((((())))()))))(()))))(())()))(()))))))))))))())))))()))))()()))()())))))())))))))())\n", "output": "48\n"}, {"input": ")))()))()))))()((((())))()))))(()))))(...
code_stdio
[ { "content": "Tomya is a girl. She loves Chef Ciel very much.\n\nTomya like a positive integer p, and now she wants to get a receipt of Ciel's restaurant whose total price is exactly p.\nThe current menus of Ciel's restaurant are shown the following table.\nName of Menupriceeel flavored water1deep-fried eel bon...
[{"input": "4\n10\n1012\n255\n4096", "output": "2\n7\n8\n2\n"}, {"input": "4\n12\n379\n297\n6095", "output": "2\n7\n4\n11\n"}, {"input": "4\n10\n376\n255\n4096", "output": "2\n5\n8\n2\n"}, {"input": "4\n10\n376\n255\n3088", "output": "2\n5\n8\n3\n"}, {"input": "4\n11\n376\n255\n3088", "output": "3\n5\n8\n3\n"}, {"input...
code_stdio
[ { "content": "Student Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange algorithm on a graph β€” something that will definitely never be useful in real life. He asked a girl sitting next to him to lend him some cheat papers for this questions and found the...
[{"input": "10 15\n900000007 1\n900000002 1\n900000004 0\n900000002 1\n900000006 1\n900000000 1\n900000006 1\n900000008 1\n900000002 0\n1419868175 0\n900000002 0\n900000005 0\n900000001 0\n900000000 1\n900000008 1\n", "output": "1 8\n1 4\n2 5\n1 5\n1 6\n1 2\n1 7\n1 9\n2 4\n4 5\n3 4\n3 5\n2 3\n1 3\n1 10\n"}, {"input": "...
code_stdio
[ { "content": "Fox Ciel is playing a card game with her friend Jiro.\n\nJiro has n cards, each one has two attributes: position (Attack or Defense) and strength. Fox Ciel has m cards, each one has these two attributes too. It's known that position of all Ciel's cards is Attack.\n\nNow is Ciel's battle phase, Cie...
[{"input": "36 30\nATK 116\nATK 120\nATK 122\nATK 120\nATK 116\nATK 118\nATK 123\nDEF 2564\nATK 123\nDEF 1810\nATK 124\nATK 120\nDEF 2598\nATK 119\nDEF 2103\nATK 123\nATK 118\nATK 118\nATK 123\nDEF 1988\nATK 122\nATK 120\nDEF 2494\nATK 122\nATK 124\nATK 117\nATK 121\nATK 118\nATK 117\nATK 122\nATK 119\nATK 122\nDEF 248...
code_stdio
[ { "content": "Mad scientist Mike is building a time machine in his spare time. To finish the work, he needs a resistor with a certain resistance value.\n\nHowever, all Mike has is lots of identical resistors with unit resistance R0 = 1. Elements with other resistance can be constructed from these resistors. In ...
[{"input": "999999999999999999 1000000000000000000\n", "output": "1000000000000000000\n"}, {"input": "999999999999999991 1000000000000000000\n", "output": "111111111111111120\n"}, {"input": "999999999999999993 999999999999999991\n", "output": "499999999999999998\n"}, {"input": "999999999999999999 1010000000000000000\n"...
code_stdio
[ { "content": "There is a frog staying to the left of the string $s = s_1 s_2 \\ldots s_n$ consisting of $n$ characters (to be more precise, the frog initially stays at the cell $0$). Each character of $s$ is either 'L' or 'R'. It means that if the frog is staying at the $i$-th cell and the $i$-th character is '...
[{"input": "6\nLRLRRLL\nL\nLLR\nRRRR\nLLLLLL\nR\n", "output": "3\n2\n3\n1\n7\n1\n"}, {"input": "6\nRRLRLLL\nL\nLLR\nRRRR\nLLLLLL\nR\n", "output": "4\n2\n3\n1\n7\n1\n"}, {"input": "6\nMRLRRLL\nL\nLLR\nRRRR\nLLLLLL\nR\n", "output": "3\n2\n3\n1\n7\n1\n"}, {"input": "6\nLLLRLRR\nL\nLRL\nRRRR\nLLLLLL\nR\n", "output": "4\n2\...
code_stdio
[ { "content": "Snuke is making sugar water in a beaker.\nInitially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.\n - Operation 1: Pour 100A grams of water into the beaker.\n - Operation 2: Pour 100B grams...
[{"input": "17 19 22 26 55 2802\n", "output": "2634 934\n"}, {"input": "28 29 22 26 55 4180", "output": "4180 1380\n"}, {"input": "41 29 22 26 55 4180", "output": "4180 1280\n"}, {"input": "17 19 22 26 55 3359", "output": "2944 1044\n"}, {"input": "26 19 22 26 55 2802", "output": "2802 902\n"}, {"input": "26 29 22 26 5...
code_stdio
[ { "content": "The most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term gave the name to the cellular phone) and every phone connects to the BTS with the strongest signal (in a little simplified view). Of course, BTSes need so...
[{"input": "6\n3\n175\n101\n1057\n17888\n11057064", "output": "0\n43\n24\n262\n4469\n2764261\n"}, {"input": "6\n3\n175\n111\n1057\n17888\n11057064", "output": "0\n43\n26\n262\n4469\n2764261\n"}, {"input": "6\n1\n60\n100\n1526\n23456\n17396335", "output": "0\n14\n24\n380\n5861\n4349078\n"}, {"input": "6\n3\n117\n111\n97...
code_stdio
[ { "content": "Как извСстно, Π² Ρ‚Π΅ΠΏΠ»ΡƒΡŽ ΠΏΠΎΠ³ΠΎΠ΄Ρƒ ΠΌΠ½ΠΎΠ³ΠΈΠ΅ ΠΆΠΈΡ‚Π΅Π»ΠΈ ΠΊΡ€ΡƒΠΏΠ½Ρ‹Ρ… Π³ΠΎΡ€ΠΎΠ΄ΠΎΠ² ΠΏΠΎΠ»ΡŒΠ·ΡƒΡŽΡ‚ΡΡ сСрвисами городского Π²Π΅Π»ΠΎΠΏΡ€ΠΎΠΊΠ°Ρ‚Π°. Π’ΠΎΡ‚ ΠΈ Аркадий сСгодня Π±ΡƒΠ΄Π΅Ρ‚ Π΄ΠΎΠ±ΠΈΡ€Π°Ρ‚ΡŒΡΡ ΠΎΡ‚ ΡˆΠΊΠΎΠ»Ρ‹ Π΄ΠΎ Π΄ΠΎΠΌΠ°, ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΡ городскиС вСлосипСды.\n\nΠ¨ΠΊΠΎΠ»Π° ΠΈ Π΄ΠΎΠΌ находятся Π½Π° ΠΎΠ΄Π½ΠΎΠΉ прямой ΡƒΠ»ΠΈΡ†Π΅, ΠΊΡ€ΠΎΠΌΠ΅ Ρ‚ΠΎΠ³ΠΎ, Π½Π° Ρ‚ΠΎΠΉ ΠΆΠ΅ ΡƒΠ»ΠΈΡ†Π΅ Π΅ΡΡ‚ΡŒ n Ρ‚ΠΎΡ‡Π΅ΠΊ, Π³Π΄Π΅ ΠΌΠΎΠΆΠ½ΠΎ взят...
[{"input": "50 15001\n1269 1580 5431 5916 6642 14145 15760 19922 20589 22062 24138 33454 33505 35916 37012 42577 43140 49457 54720 55188 56205 56639 56870 57997 58379 59088 59297 61805 61861 63005 64013 68848 71182 71497 72715 73008 75616 76042 76614 80690 83089 85033 86408 92392 92763 93833 95085 95815 97152 99379\n",...
code_stdio
[ { "content": "Given are strings s and t of length N each, both consisting of lowercase English letters.\nLet us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ...,...
[{"input": "100\naernvaoeiuraxmueiwovioxmuaioervuaionuxiaomuahlhakaqduwbuvpgrrgreiufwuiaubewobsjdhfbajkslfhjcaklyuwee aibfaeqpwidbcuoifnydukfbavysknxyualdyksayfkjdafqiryekucyuwepaasfdasdfiocaudmiovuandksfucnaldsfumioxa\n", "output": "aaeirbnfvaaeoqepiwuirdabxcmuuoeiifwnoyvdiuokxfmbuaaviyosekrnvxuyauiaolnduyxkisaaoymfuk...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian as well. \n\nGiven n words w[1..n], which originate from the same stem (e.g. grace, graceful, disgraceful, gracefully), we are interested in the original stem. To simplify the problem, we define the stem as the longest consecutive substring ...
[{"input": "1\n4\ngrace gracefuk disgraceful gracefully", "output": "grace\n"}, {"input": "1\n4\ngrace graceful disgraceful gracefully", "output": "grace\n"}, {"input": "1\n4\ngrace graceful disgraceful gracefully", "output": "grace"}, {"input": "1\n4\ngracd gracefuk disgraceful gracefully", "output": "grac\n"}, {"inpu...
code_stdio
[ { "content": "This is the hard version of the problem. The difference is the constraint on the sum of lengths of strings and the number of test cases. You can make hacks only if you solve all versions of this task.\n\nYou are given a string $s$, consisting of lowercase English letters. Find the longest string, ...
[{"input": "10\nu\nxqpczgnzazxyrvx\ncfjgfhxmzqmjgzzjthziuomldylspyfuxvjlgdc\nooydbldio\nyvaamavy\nrzjjebcgotjffuzr\nhtfkwvihzuwxczopzqujdnaorgxibjfcmlzntskawxhyoymwynitukttewfpajuph\nfactnjajntcaf\nywowyovhrgradhtrqkgurkjpudnrrqhmmwiaqicfxnoyejdsmmurusdzqgjjntocryhqsgr\nqq\n", "output": "u\nxqx\ncfc\nooo\nyvaaavy\nrzjj...
code_stdio
[ { "content": "For a dynamic array $A = \\\\{a_0, a_1, ...\\\\}$ of integers, perform a sequence of the following operations:\n\n* push($d$, $x$): Add element $x$ at the begining of $A$, if $d = 0$. Add element $x$ at the end of $A$, if $d = 1$.\n* randomAccess($p$): Print element $a_p$.\n* pop($d$): Delete the ...
[{"input": "11\n0 1 0\n0 0 2\n0 1 3\n1 1\n1 1\n1 0\n2 -1\n1 1\n0 1 4\n1 0\n1 0", "output": "0\n0\n2\n0\n2\n2\n"}, {"input": "11\n0 1 1\n0 0 2\n0 1 3\n1 1\n1 1\n1 0\n2 0\n1 1\n0 0 4\n1 0\n1 0", "output": "1\n1\n2\n3\n4\n4\n"}, {"input": "11\n0 0 1\n0 0 3\n0 1 3\n1 0\n1 1\n1 0\n2 0\n1 1\n0 0 4\n1 0\n1 1", "output": "3\n1...
code_stdio
[ { "content": "There is a sequence of length N: a = (a_1, a_2, ..., a_N). Here, each a_i is a non-negative integer.\n\nSnuke can repeatedly perform the following operation:\n\n* Let the XOR of all the elements in a be x. Select an integer i (1 ≀ i ≀ N) and replace a_i with x.\n\n\n\nSnuke's objective is to match...
[{"input": "4\n-1 0 3 -1\n2 -1 1 4", "output": "-1\n"}, {"input": "4\n-1 2 5 -1\n2 0 0 4", "output": "-1\n"}, {"input": "4\n-1 2 5 -1\n2 0 1 4", "output": "-1\n"}, {"input": "4\n-1 2 7 -1\n2 0 1 4", "output": "-1\n"}, {"input": "4\n-1 3 2 0\n2 -1 1 4", "output": "-1\n"}, {"input": "4\n-1 3 3 0\n2 -1 1 4", "output": "-1...
code_stdio
[ { "content": "There is a matrix A of size x Γ— y filled with integers. For every $i \\in [ 1 . . x ]$, $j \\in [ 1 . . y ]$ A_{i}, j = y(i - 1) + j. Obviously, every integer from [1..xy] occurs exactly once in this matrix. \n\nYou have traversed some path in this matrix. Your path can be described as a sequence ...
[{"input": "10\n999999999 999999998 999999997 999999996 999999995 999999994 999999993 999999992 999999991 62465930\n", "output": "YES\n1000000000 937534061"}, {"input": "10\n999999999 999999998 999999997 999999996 999999995 999999994 999999993 999999992 999999991 999999990\n", "output": "YES\n1000000000 1\n"}, {"input"...
code_stdio
[ { "content": "You are given N real values A_1, A_2, \\ldots, A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i \\cdot A_j is integer.\n\nConstraints\n\n* 2 \\leq N \\leq 200\\,000\n* 0 < A_i < 10^4\n* A_i is given with at most 9 digits after the decimal.\n\nInput\n\nInput is...
[{"input": "11\n0.9\n1\n1\n1.25\n2.7527267588296525\n5\n70\n0.000000001\n9999.999999999\n0.999999999\n1.7676771981771382", "output": "7\n"}, {"input": "11\n0.9\n1\n1\n1.25\n2.30000\n5\n70\n0.000000001\n9999.999999999\n0.999999999\n1.7676771981771382", "output": "8\n"}, {"input": "5\n14.596573229675469\n11.6891813242635...
code_stdio
[ { "content": "You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.\nAn example of a trapezoid\nFind the area of this trapezoid.\n\n-----Constraints-----\n - 1≦a≦100\n - 1≦b≦100\n - 1≦h≦100\n - All input values are integers.\n - h is even.\n\n-----Input-...
[{"input": "3\n1\n-135", "output": "-270\n"}, {"input": "3\n2\n-135", "output": "-338\n"}, {"input": "3\n10\n-65", "output": "-423\n"}, {"input": "3\n5\n-103", "output": "-412\n"}, {"input": "3\n5\n-107", "output": "-428\n"}, {"input": "3\n5\n-168", "output": "-672\n"}, {"input": "3\n1\n-168", "output": "-336\n"}, {"in...
code_stdio
[ { "content": "Counting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This information can be used to place element x directly...
[{"input": "7\n4 11 2 3 4 3 1", "output": "1 2 3 3 4 4 11\n"}, {"input": "7\n8 9 2 0 12 3 3", "output": "0 2 3 3 8 9 12\n"}, {"input": "7\n10 9 3 0 6 3 3", "output": "0 3 3 3 6 9 10\n"}, {"input": "7\n6 5 3 0 12 3 3", "output": "0 3 3 3 5 6 12\n"}, {"input": "7\n4 11 2 3 4 6 1", "output": "1 2 3 4 4 6 11\n"}, {"input":...
code_stdio
[ { "content": "You have a string S consisting of N uppercase English letters. You are allowed to perform at most one operation of following kind: Choose any position in the string, remove the character at that position and insert it back to any other place in the string.\n\nFind the lexicographically smallest ...
[{"input": "2\n4\nDCBA\n7\nXYZZYZY", "output": "ADCB\nXYYZZYZ\n"}, {"input": "2\n4\nDCBA\n7\nXZZZYZZ", "output": "ADCB\nXYZZZZZ\n"}, {"input": "2\n4\nABCD\n7\nXYZZYZY", "output": "ABCD\nXYYZZYZ\n"}, {"input": "2\n4\nCBAD\n7\nXYZZYZY", "output": "ACBD\nXYYZZYZ\n"}, {"input": "2\n4\nCBAD\n7\nYZYZZYX", "output": "ACBD\nXY...
code_stdio
[ { "content": "International Women's Day is coming soon! Polycarp is preparing for the holiday.\n\nThere are $n$ candy boxes in the shop for sale. The $i$-th box contains $d_i$ candies.\n\nPolycarp wants to prepare the maximum number of gifts for $k$ girls. Each gift will consist of exactly two boxes. The girls ...
[{"input": "8 2\n1 2 2 3 2 4 6 10\n", "output": "8\n"}, {"input": "8 2\n2 2 2 2 2 4 6 10\n", "output": "8\n"}, {"input": "8 2\n1 2 2 2 2 4 6 10\n", "output": "6\n"}, {"input": "8 2\n2 2 2 2 2 4 7 10\n", "output": "6\n"}, {"input": "8 2\n1 2 2 3 3 4 6 10\n", "output": "6\n"}, {"input": "8 2\n1 4 2 2 2 4 6 10\n", "output...
code_stdio
[ { "content": "Problem\n\nGiven the strings $ s $, $ t $.\nFirst, let the string set $ A = $ {$ s $}, $ B = \\ phi $.\nAt this time, I want to perform the following operations as much as possible.\n\noperation\n\nstep1\n\nPerform the following processing for all $ u ∊ A $.\n\n1. From all subsequences of $ u $ (n...
[{"input": "abaabbabaab`abbabbabaabbab\nab", "output": "2\n"}, {"input": "abaabbbbaab`abbabbabaabaab\nab", "output": "2\n"}, {"input": "abaabbbbaab`abbabbabaabaab\n`b", "output": "1\n"}, {"input": "abaabbbbaaa`abbabbabbabaab\n`b", "output": "1\n"}, {"input": "abaabbbaaab`abbabbabbabaab\n`b", "output": "1\n"}, {"input":...
code_stdio
[ { "content": "You've gotten an n Γ— m sheet of squared paper. Some of its squares are painted. Let's mark the set of all painted squares as A. Set A is connected. Your task is to find the minimum number of squares that we can delete from set A to make it not connected.\n\nA set of painted squares is called conne...
[{"input": "20 20\n.....######.........\n.....#....#.........\n.....#....#.........\n.....#....#.........\n.....############...\n.........##.....#...\n..........#.....#...\n..........#.....#...\n..........###...#...\n............#...#...\n............#...#...\n............#...#...\n............#...#...\n............###...
code_stdio
[ { "content": "There are $n$ persons who initially don't know each other. On each morning, two of them, who were not friends before, become friends.\n\nWe want to plan a trip for every evening of $m$ days. On each trip, you have to select a group of people that will go on the trip. For every person, one of the f...
[{"input": "16 20 2\n10 4\n5 3\n10 5\n12 7\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n16 3\n10 2\n14 4\n15 14\n4 13\n13 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n4\n4\n4\n4\n10\n10\n10\n10\n10\n14\n14\n14\n14\n15\n"}, {"input": "16 20 2\n10 4\n5 3\n10 5\n12 7\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n16 3\n10 3\n14 ...
code_stdio
[ { "content": "Two people are playing a game with a string $s$, consisting of lowercase latin letters. \n\nOn a player's turn, he should choose two consecutive equal letters in the string and delete them. \n\nFor example, if the string is equal to \"xaax\" than there is only one possible turn: delete \"aa\", so ...
[{"input": "pogfjssywv\n", "output": "Yes\n"}, {"input": "axxxxbbaaa\n", "output": "Yes\n"}, {"input": "axxxxbbaaa\n", "output": "Yes\n"}, {"input": "pogfjssywv\n", "output": "Yes\n"}, {"input": "aaabbxxxxa\n", "output": "Yes\n"}, {"input": "pogfjssywu\n", "output": "Yes\n"}, {"input": "axabbxaxxa\n", "output": "Yes\n"...
code_stdio
[ { "content": "When Valera has got some free time, he goes to the library to read some books. Today he's got t free minutes to read. That's why Valera took n books in the library and for each book he estimated the time he is going to need to read it. Let's number the books by integers from 1 to n. Valera needs a...
[{"input": "100 100\n75 92 18 7 81 67 7 92 100 65 57 32 50 131 85 31 80 91 84 63 39 52 92 81 1 98 24 12 84 48 17 86 51 72 48 95 81 50 12 66 19 79 49 89 34 1 193 75 20 33 96 27 42 23 133 71 93 1 85 19 66 14 13 13 20 39 36 33 42 61 56 64 23 91 37 99 40 74 13 18 98 85 74 39 62 84 46 74 50 23 38 11 83 14 9 25 66 100 25 52\...
code_stdio
[ { "content": "Om Nom is the main character of a game \"Cut the Rope\". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image] \n\nThe park consists of 2^{n} + 1 -...
[{"input": "6\n87 62 58 32 81 92 12 50 23 27 38 39 64 74 16 35 84 59 91 87 14 48 90 47 44 95 64 45 31 11 67 5 80 60 36 15 91 3 21 2 40 24 37 69 5 50 23 37 49 19 68 21 49 9 100 94 45 41 22 31 31 48 25 70 25 25 95 88 82 1 37 53 49 31 57 74 94 45 55 93 43 37 13 85 59 72 15 68 3 90 96 55 100 64 63 69 43 33 66 84 57 97 87 3...
code_stdio
[ { "content": "Vlad enjoys listening to music. He lives in Sam's Town. A few days ago he had a birthday, so his parents gave him a gift: MP3-player! Vlad was the happiest man in the world! Now he can listen his favorite songs whenever he wants!\nVlad built up his own playlist. The playlist consists of N songs, e...
[{"input": "3\n4\n-1 16 14 1\n2\n5\n1 4 0 17 8\n3\n5\n-1 1 -1 18 4 \n0", "output": "4\n1\n4\n"}, {"input": "3\n4\n0 4 5 2\n-1\n5\n1 1 5 11 4\n-1\n5\n1 2 3 9 -1 \n2", "output": "4\n5\n3\n"}, {"input": "3\n4\n1 3 11 2\n2\n5\n1 2 -1 6 4\n-1\n5\n1 2 0 9 4 \n2", "output": "3\n5\n3\n"}, {"input": "3\n4\n1 3 4 2\n-1\n5\n0 2 -...
code_stdio
[ { "content": "One day n cells of some array decided to play the following game. Initially each cell contains a number which is equal to it's ordinal number (starting from 1). Also each cell determined it's favourite number. On it's move i-th cell can exchange it's value with the value of some other j-th cell, i...
[{"input": "82\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 59 17 18 19 20 21 22 23 24 25 26 27 28 29 61 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 16 60 30 79 63 64 65 66 67 68 69 70 71 72 73 74 75 76 82 78 62 80 81 77\n8 79 66 53 45 15 70 17 53 28 30 70 14 49 51 43 45 14 27 30 37 51 2...
code_stdio
[ { "content": "You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed...
[{"input": "300000 300000 300000 300000\n", "output": "4500090000549998\n"}, {"input": "300000 300000 300000 300000\n", "output": "4500090000549998\n"}, {"input": "300000 300000 300000 300000\n", "output": "4500090000549998\n"}, {"input": "300000 300000 433625 300000\n", "output": "4400668305451891\n"}, {"input": "5355...
code_stdio
[ { "content": "You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between.\nPrint the acronym formed from the uppercased initial letters of the words.\n\n-----Constraints-----\n - s_1, s_2 and s_3 are composed of lowercase English letters.\n - 1 ≀ |s_i| ≀ 10 (1...
[{"input": "atcoder beginner contest\n", "output": "ABC\n"}, {"input": "resident register number\n", "output": "RRN\n"}, {"input": "resident retsiger number", "output": "RRN\n"}, {"input": "atcoder beginner contdst", "output": "ABC\n"}, {"input": "resident setsiger nuebmr", "output": "RSN\n"}, {"input": "resident setsi...
code_stdio
[ { "content": "The Smart Beaver from ABBYY came up with another splendid problem for the ABBYY Cup participants! This time the Beaver invites the contest participants to check out a problem on sorting documents by their subjects. Let's describe the problem:\n\nYou've got some training set of documents. For each ...
[{"input": "24000\nN.Y. BANK DISCOUNT BORROWINGS 169 MLN DLRS\nNEW YORK, April 9 - The eight major New York City banks had\ndaily average borrowings of 169 mln dlrs from the Federal\nReserve in the week ended April 8, a Fed spokesman said.\nA Fed spokesman said that all of the borrowings were made\nyesterday by fewer t...
code_stdio
[ { "content": "How to make a cake you'll never eat.\n\nIngredients. \n\n * 2 carrots\n * 0 calories\n * 100 g chocolate spread\n * 1 pack of flour\n * 1 egg\n\n\n\nMethod. \n\n 1. Put calories into the mixing bowl.\n 2. Take carrots from refrigerator.\n 3. Chop carrots.\n 4. Take chocolate spread from r...
[{"input": "100 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1010 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000...
code_stdio
[ { "content": "Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?\n\nYou are given a set of digits, your task is to find the maximum ...
[{"input": "12\n3 1 2 3 2 0 2 2 3 0 2 1\n", "output": "333222221100\n"}, {"input": "12\n3 1 2 3 2 0 2 2 2 0 2 3\n", "output": "33322222200\n"}, {"input": "12\n3 1 2 3 2 0 2 2 3 0 2 3\n", "output": "33332222100\n"}, {"input": "12\n0 1 4 4 2 1 7 7 1 2 5 1\n", "output": "77544211110\n"}, {"input": "12\n3 1 4 3 2 0 2 2 3 0...
code_stdio
[ { "content": "Sereja showed an interesting game to his friends. The game goes like that. Initially, there is a table with an empty cup and n water mugs on it. Then all players take turns to move. During a move, a player takes a non-empty mug of water and pours all water from it into the cup. If the cup overfill...
[{"input": "100 1000\n10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1...
code_stdio
[ { "content": "There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.\n\nIn the beginning, Snuke stands on S...
[{"input": "15 -1 6 15 13\n...#.#...#.#...", "output": "Yes\n"}, {"input": "15 -1 3 15 11\n...#.#...#...#.", "output": "Yes\n"}, {"input": "16 -1 3 15 11\n...#.#...#...#.", "output": "Yes\n"}, {"input": "16 -1 3 15 13\n...#.#...#...#.", "output": "Yes\n"}, {"input": "20 -1 3 15 11\n...#.#...#...#.", "output": "Yes\n"},...
code_stdio
[ { "content": "You are given a chessboard of size $n \\times n$. It is filled with numbers from $1$ to $n^2$ in the following way: the first $\\lceil \\frac{n^2}{2} \\rceil$ numbers from $1$ to $\\lceil \\frac{n^2}{2} \\rceil$ are written in the cells with even sum of coordinates from left to right from top to b...
[{"input": "4 5\n2 1\n1 4\n5 3\n3 2\n2 4\n", "output": "11\n10\n10\n13\n4\n"}, {"input": "4 5\n2 1\n1 4\n5 3\n6 2\n2 4\n", "output": "11\n10\n10\n11\n4\n"}, {"input": "8 5\n2 1\n4 4\n4 3\n3 2\n2 4\n", "output": "37\n14\n46\n41\n6\n"}, {"input": "4 5\n4 1\n1 4\n5 3\n3 2\n2 4\n", "output": "15\n10\n10\n13\n4\n"}, {"input...
code_stdio
[ { "content": "There is an integer sequence of length 2^N: A_0, A_1, ..., A_{2^N-1}. (Note that the sequence is 0-indexed.)\nFor every integer K satisfying 1 \\leq K \\leq 2^N-1, solve the following problem:\n - Let i and j be integers. Find the maximum value of A_i + A_j where 0 \\leq i < j \\leq 2^N-1 and (i o...
[{"input": "4\n75 26 45 72 81 47 97 97 2 2 25 82 84 17 56 32\n", "output": "101\n120\n147\n156\n156\n178\n194\n194\n194\n194\n194\n194\n194\n194\n194\n"}, {"input": "4\n75 26 45 112 81 47 97 97 2 2 25 95 84 17 56 32", "output": "101\n120\n187\n187\n187\n187\n209\n209\n209\n209\n209\n209\n209\n209\n209\n"}, {"input": "4...
code_stdio
[ { "content": "You are given $n$ segments on a coordinate axis $OX$. The $i$-th segment has borders $[l_i; r_i]$. All points $x$, for which $l_i \\le x \\le r_i$ holds, belong to the $i$-th segment.\n\nYour task is to choose the maximum by size (the number of segments) subset of the given set of segments such th...
[{"input": "4\n4\n1 5\n2 4\n2 3\n3 4\n5\n1 5\n2 3\n2 5\n3 5\n2 2\n3\n1 3\n2 4\n2 3\n7\n1 10\n2 8\n2 5\n3 4\n4 4\n6 8\n7 7\n", "output": "3\n4\n2\n7\n"}, {"input": "4\n4\n1 5\n2 4\n2 3\n3 4\n5\n1 5\n2 3\n2 5\n3 5\n2 2\n3\n1 3\n2 4\n2 3\n7\n1 10\n2 8\n0 5\n3 4\n4 4\n6 8\n7 7\n", "output": "3\n4\n2\n6\n"}, {"input": "4\n4...
code_stdio
[ { "content": "There is a string $s$ of length $3$, consisting of uppercase and lowercase English letters. Check if it is equal to \"YES\" (without quotes), where each letter can be in any case. For example, \"yES\", \"Yes\", \"yes\" are all allowable.\n\n\n-----Input-----\n\nThe first line of the input contains...
[{"input": "10\nYES\nyES\nyes\nYes\nYeS\nNoo\norZ\nyEz\nYas\nXES\n", "output": "YES\nYES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\n"}, {"input": "2\nyes\nlll\n", "output": "YES\nNO\n"}, {"input": "1\nvop\n", "output": "NO\n"}, {"input": "1\nhac\n", "output": "NO\n"}, {"input": "1\nNNy\n", "output": "NO\n"}, {"input": "1\nHAC...
code_stdio
[ { "content": "You have $n$ chains, the $i$-th chain consists of $c_i$ vertices. Vertices in each chain are numbered independently from $1$ to $c_i$ along the chain. In other words, the $i$-th chain is the undirected graph with $c_i$ vertices and $(c_i - 1)$ edges connecting the $j$-th and the $(j + 1)$-th verti...
[{"input": "3\n4\n3 4 3 6\n-1 1 2 2\n-2 2 2 3\n2\n5 10\n-2 5\n-1 1\n3\n10 5 2\n-1 1 2\n-1 10 5\n", "output": "10\n15\n15\n"}, {"input": "3\n4\n3 4 3 6\n-1 1 2 2\n-1 2 2 3\n2\n5 10\n-1 5\n-1 1\n3\n6 5 2\n-1 1 2\n-1 5 5\n", "output": "10\n15\n10\n"}, {"input": "3\n4\n1 4 3 6\n-1 1 2 2\n-1 2 2 3\n2\n5 13\n-1 5\n-1 1\n3\n6...
code_stdio
[ { "content": "As behooves any intelligent schoolboy, Kevin Sun is studying psycowlogy, cowculus, and cryptcowgraphy at the Bovinia State University (BGU) under Farmer Ivan. During his Mathematics of Olympiads (MoO) class, Kevin was confronted with a weird functional equation and needs your help. For two fixed i...
[{"input": "990037 453792\n", "output": "654009570\n"}, {"input": "498653 116674\n", "output": "625264514\n"}, {"input": "512287 359783\n", "output": "542484357\n"}, {"input": "337411 146419\n", "output": "532279245\n"}, {"input": "586189 189159\n", "output": "168174057\n"}, {"input": "613463 269592\n", "output": "3368...
code_stdio
[ { "content": "Once upon a time in the Kingdom of Far Far Away lived Sir Lancelot, the chief Royal General. He was very proud of his men and he liked to invite the King to come and watch drill exercises which demonstrated the fighting techniques and tactics of the squad he was in charge of. But time went by and ...
[{"input": "1000 1000\n", "output": "500000\n"}, {"input": "997 1000\n", "output": "498500\n"}, {"input": "999 1000\n", "output": "499500\n"}, {"input": "1000 999\n", "output": "499500\n"}, {"input": "1000 998\n", "output": "499000\n"}, {"input": "1000 997\n", "output": "498500\n"}, {"input": "998 1000\n", "output": "4...
code_stdio
[ { "content": "Paw the Spider is making a web. Web-making is a real art, Paw has been learning to do it his whole life. Let's consider the structure of the web.\n\n<image>\n\nThere are n main threads going from the center of the web. All main threads are located in one plane and divide it into n equal infinite s...
[{"input": "20\n5 15 40 35 68 22\n6 70 19 28 69 63 1\n4 37 154 41 90\n7 11 148 35 94 55 59 64\n7 46 28 22 90 97 37 13\n5 62 45 34 50 94\n6 85 83 37 72 27 53\n6 46 56 116 71 49 33\n7 17 35 91 24 50 30 38\n2 75 12\n2 46 38\n1 61\n11 15 79 14 89 20 96 84 26 93 132 18\n1 75\n6 4 100 55 59 62 83\n5 48 44 37 12 6\n6 68 53 28...
code_stdio
[ { "content": "A tree is a graph with n vertices and exactly n - 1 edges; this graph should meet the following condition: there exists exactly one shortest (by number of edges) path between any pair of its vertices.\n\nA subtree of a tree T is a tree with both vertices and edges as subsets of vertices and edges ...
[{"input": "12\n1 6\n10 1\n4 1\n7 1\n1 2\n5 1\n1 8\n1 11\n3 1\n12 1\n9 1\n580660007 861441526 -470133967 488291045 253254575 -974301934 709266786 926718320 87511873 514836444 -1167698791 848928657\n", "output": "2916057589\n"}, {"input": "12\n1 6\n10 1\n4 1\n7 1\n1 2\n4 1\n1 8\n1 11\n3 1\n12 1\n9 1\n580660007 861441526...
code_stdio
[ { "content": "The polar bears are going fishing. They plan to sail from (s_{x}, s_{y}) to (e_{x}, e_{y}). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, west or north. Assume the boat is currently at (x, y). If the wind blows to the east, the bo...
[{"input": "39 -1000000000 -1000000000 -999999997 -1000000000\nENEENWSWSSWESNSSEESNSESWSWNSWESNENWNWEE\n", "output": "4\n"}, {"input": "39 -1000000000 -1000000000 -999999997 -1000000000\nENEENWSWSSWESNSSEESNSESWSWNSWESNENWNWEE\n", "output": "4\n"}, {"input": "51 -1000000000 -1000000000 -999999997 -1000000000\nENEENWSWS...
code_stdio
[ { "content": "The time is 2020. There is data that saves the qualifying results of PC Koshien 2020. This data stores the reference number and the number of correct answers assigned to each team. Here, the ranking is determined by the number of correct answers, and the ranking is given in descending order of the...
[{"input": "1,20\n2,20\n3,30\n4,10\n5,10\n6,20\n0,0\n1\n2\n4\n1", "output": "2\n2\n3\n2\n"}, {"input": "1,20\n2,20\n3,30\n4,10\n5,10\n0,26\n0,0\n1\n2\n4\n1", "output": "3\n3\n4\n3\n"}, {"input": "1,20\n2,20\n3,30\n4,10\n5,10\n0,26\n0,0\n0\n2\n4\n1", "output": "2\n3\n4\n3\n"}, {"input": "1,20\n2,20\n3,30\n4,10\n5,10\n0,...
code_stdio
[ { "content": "Sonya decided that having her own hotel business is the best way of earning money because she can profit and rest wherever she wants.\n\nThe country where Sonya lives is an endless line. There is a city in each integer coordinate on this line. She has $n$ hotels, where the $i$-th hotel is located ...
[{"input": "100 10\n-489 -476 -445 -432 -430 -421 -420 -418 -412 -411 -404 -383 -356 -300 -295 -293 -287 -276 -265 -263 -258 -251 -249 -246 -220 -219 -205 -186 -166 -157 -143 -137 -136 -130 -103 -86 -80 -69 -67 -55 -43 -41 -40 -26 -19 -9 16 29 41 42 54 76 84 97 98 99 101 115 134 151 157 167 169 185 197 204 208 226 227 ...
code_stdio
[ { "content": "Let S be the concatenation of 10^{10} copies of the string 110. (For reference, the concatenation of 3 copies of 110 is 110110110.)\nWe have a string T of length N.\nFind the number of times T occurs in S as a contiguous substring.\n\n-----Constraints-----\n - 1 \\leq N \\leq 2 \\times 10^5\n - T ...
[{"input": "62089\n1101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101...
code_stdio
[ { "content": "\"Fukusekiken\" is a popular ramen shop where you can line up. But recently, I've heard some customers say, \"I can't afford to have vacant seats when I enter the store, even though I have a long waiting time.\" I'd like to find out why such dissatisfaction occurs, but I'm too busy to check the ac...
[{"input": "5\n41\n27\n26", "output": "0\n28\n18\n23\n"}, {"input": "5\n24\n18\n13", "output": "0\n11\n15\n2\n"}, {"input": "5\n24\n27\n13", "output": "0\n11\n18\n2\n"}, {"input": "5\n29\n27\n26", "output": "0\n8\n18\n23\n"}, {"input": "5\n24\n12\n13", "output": "0\n11\n3\n2\n"}, {"input": "5\n24\n34\n13", "output": "0...
code_stdio
[ { "content": "Recently, the Fair Nut has written $k$ strings of length $n$, consisting of letters \"a\" and \"b\". He calculated $c$Β β€” the number of strings that are prefixes of at least one of the written strings. Every string was counted only one time.\n\nThen, he lost his sheet with strings. He remembers tha...
[{"input": "100 1000000000\nbbabbaabbbaaaaabbabbbaaabbbbabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbaabbbbabaabbbabbaaaaabbbbaab\nbbabbaabbbaaaaabbabbbaaabbbbabbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaababbbabbbbaaaaabbaaaaaaaab\n", "output": "41073741883\n"}, {"input": "100 1000000000\nabbbbabababaabaabaabbababaabbb...
code_stdio
[ { "content": "It's a walking tour day in SIS.Winter, so $t$ groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another.\n\nInitially, some students are angry. Let's describe a group of students by a string of capital letters \"A\" and \"P\": \...
[{"input": "16\n4\nPPPP\n4\nAPPP\n4\nPAPP\n4\nAAPP\n4\nPPAP\n4\nAPAP\n4\nPAAP\n4\nAAAP\n4\nPPPA\n4\nAPPA\n4\nPAPA\n4\nAAPA\n4\nPPAA\n4\nAPAA\n4\nPAAA\n4\nAAAA\n", "output": "0\n3\n2\n2\n1\n1\n1\n1\n0\n2\n1\n1\n0\n1\n0\n0\n"}, {"input": "16\n4\nPPPP\n4\nAPPP\n4\nPAPP\n4\nAAPP\n4\nPPAP\n4\nAPAP\n4\nPAAP\n4\nAAAP\n4\nPPPA...
code_stdio
[ { "content": "On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January 23, 2018 should be written as 2018/01/23.\nAfter finishing the document, she noticed that she had mistakenly wrote 2017 at the beginning...
[{"input": "2017/01/07\n", "output": "2018/01/07\n"}, {"input": "2017/01/31\n", "output": "2018/01/31\n"}, {"input": "2017/01/06", "output": "2018/01/06\n"}, {"input": "2017/01/32", "output": "2018/01/32\n"}, {"input": "2017/01//7", "output": "2018/01//7\n"}, {"input": "2010/01/77", "output": "2018/01/77\n"}, {"input":...
code_stdio
[ { "content": "Elections in Berland are coming. There are only two candidates β€” Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four k...
[{"input": "54\n10 13\n10 45\n10 51\n01 44\n10 24\n10 26\n10 39\n10 38\n10 41\n10 33\n10 18\n10 12\n10 38\n10 30\n11 31\n10 46\n11 50\n00 26\n00 29\n00 50\n10 16\n10 40\n10 50\n00 43\n10 48\n10 32\n10 18\n10 8\n10 24\n10 32\n10 52\n00 41\n10 37\n10 38\n10 49\n00 35\n10 52\n00 44\n10 41\n10 36\n00 28\n00 43\n10 36\n00 2...
code_stdio
[ { "content": "You are given an n Γ— m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the table\n \n \n \n abcd ...
[{"input": "4 100\ngdgmmejiigzsmlarrnfsypvlbutvoxazcigpcospgztqkowfhhbnnbxxrbmwbxwkvxlxzabjjjdtbebedukdelooqlxnadjwjpnp\ndmtsnsbsfdzqvydxcdcnkkfcbseicxhvclsligbhqlkccwujpirymoshkqcosbtlxdypsdqkqaolrqtiibymavcwmbfryttdckhx\nqwujylxpxechsqxqwnxtanhpwenvbdgxighxkklpjtnowrcusxgezlnutcxrauuoqwmlsfzhcyqovfamqqvnzouuicpcjldpm...
code_stdio
[ { "content": "Assume that you have $k$ one-dimensional segments $s_1, s_2, \\dots s_k$ (each segment is denoted by two integers β€” its endpoints). Then you can build the following graph on these segments. The graph consists of $k$ vertexes, and there is an edge between the $i$-th and the $j$-th vertexes ($i \\ne...
[{"input": "1\n10\n1 2\n1 3\n2 4\n2 5\n2 6\n3 7\n3 8\n4 9\n4 10\n", "output": "10\n"}, {"input": "1\n10\n1 2\n2 3\n1 4\n2 5\n4 6\n6 7\n3 8\n4 9\n4 10\n", "output": "10\n"}, {"input": "1\n10\n1 2\n1 3\n1 4\n2 5\n2 6\n6 7\n1 8\n4 9\n4 10\n", "output": "10\n"}, {"input": "1\n10\n1 2\n1 3\n2 4\n2 5\n2 6\n3 7\n1 8\n4 9\n4 1...
code_stdio
[ { "content": "The only difference between easy and hard versions is on constraints. In this version constraints are lower. You can make hacks only if all versions of the problem are solved.\n\nKoa the Koala is at the beach!\n\nThe beach consists (from left to right) of a shore, $n+1$ meters of sea and an island...
[{"input": "32\n3 1 3\n2 2 1\n3 1 3\n2 2 2\n3 1 3\n2 2 3\n3 1 3\n2 3 1\n3 1 3\n2 3 2\n3 1 3\n2 3 3\n3 1 3\n3 1 1\n3 1 3\n3 1 2\n3 1 3\n3 1 3\n3 1 3\n3 2 1\n3 1 3\n3 2 2\n3 1 3\n3 2 3\n3 1 3\n3 3 1\n3 1 3\n3 3 2\n3 1 3\n3 3 3\n3 2 1\n1 1 1\n3 2 1\n1 1 2\n3 2 1\n1 1 3\n3 2 1\n1 2 1\n3 2 1\n1 2 2\n3 2 1\n1 2 3\n3 2 1\n1 3...
code_stdio
[ { "content": "After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $n$. Let's call them $a$ and $b$.\n\nNote that a permutation of $n$ elements is a sequence ...
[{"input": "20\n9 15 11 8 10 5 19 13 12 18 3 20 17 14 2 16 7 4 1 6\n12 6 7 5 4 20 15 14 1 18 10 17 9 19 16 3 13 11 2 8\n", "output": "2\n"}, {"input": "20\n9 15 11 8 10 5 19 13 12 18 3 20 17 14 2 16 7 4 1 6\n12 6 7 5 4 20 15 14 1 18 10 17 9 19 16 3 13 11 2 8\n", "output": "2"}, {"input": "18\n11 16 18 3 7 12 10 6 14 15...
code_stdio
[ { "content": "The Little Elephant likes permutations. This time he has a permutation A[1], A[2], ..., A[N] of numbers 1, 2, ..., N.\n\nHe calls a permutation A good, if the number of its inversions is equal to the number of its local inversions. The number of inversions is equal to the number of pairs of intege...
[{"input": "4\n0\n1\n2\n0 1\n3\n0 1 2\n4\n1 3 2 4", "output": "YES\nYES\nYES\nYES\n"}, {"input": "4\n0\n1\n2\n0 1\n3\n11 1 1\n4\n1 3 2 -1", "output": "YES\nYES\nNO\nNO\n"}, {"input": "4\n-1\n1\n1\n0 1\n3\n3 0 1\n4\n1 3 2 4", "output": "YES\nYES\nNO\nYES\n"}, {"input": "4\n0\n1\n2\n0 1\n3\n3 -1 0\n4\n1 3 2 4", "output":...
code_stdio
[ { "content": "Shinya watched a program on TV called \"Maya's Great Prophecy! Will the World End in 2012?\" After all, I wasn't sure if the world would end, but I was interested in Maya's \"long-term calendar,\" which was introduced in the program. The program explained as follows.\n\nThe Maya long-term calendar...
[{"input": "2012.12.31\n2.11.16.14.14\n7138.4.03\n10.5.5.1.2\n10000000.12.31\n#", "output": "0.0.0.0.10\n3034.11.28\n12.19.19.16.10\n6059.2.10\n8.19.3.13.2\n"}, {"input": "2312.02.12\n2.12.16.14.14\n7128.5.13\n5.1.5.2.01\n10020000.10.31\n#", "output": "0.15.3.8.19\n3054.8.15\n12.19.9.15.18\n4009.1.7\n7.13.14.14.11\n"},...
code_stdio
[ { "content": "Cirno_9baka has a tree with $n$ nodes. He is willing to share it with you, which means you can operate on it.\n\nInitially, there are two chess pieces on the node $1$ of the tree. In one step, you can choose any piece, and move it to the neighboring node. You are also given an integer $d$. You nee...
[{"input": "15 6\n11 8\n9 12\n7 12\n14 13\n12 4\n12 13\n1 7\n10 6\n12 8\n3 5\n3 2\n15 2\n6 8\n12 2\n4 14 11 10 2\n4 12 5 8 9\n", "output": "32"}, {"input": "15 2\n5 1\n15 8\n9 3\n2 10\n15 13\n12 1\n14 15\n2 1\n6 15\n13 7\n11 1\n1 15\n15 4\n1 9\n1 14\n7 5 15 1 7 11 2 13\n", "output": "16"}, {"input": "15 2\n4 13\n8 5\n1...
code_stdio
[ { "content": "It is a complicated version of problem F1. The difference between them is the constraints (F1: $k \\le 2$, F2: $k \\le 10$).\n\nYou are given an integer $n$. Find the minimum integer $x$ such that $x \\ge n$ and the number $x$ is $k$-beautiful.\n\nA number is called $k$-beautiful if its decimal re...
[{"input": "6\n2021 3\n177890 2\n34512 3\n724533 4\n998244353 1\n12345678 10\n", "output": "2021\n181111\n34533\n724542\n999999999\n12345678\n"}, {"input": "6\n2021 3\n177890 2\n34512 3\n724533 4\n998244353 1\n12345678 10\n", "output": "2021\n181111\n34533\n724542\n999999999\n12345678\n"}, {"input": "6\n2021 3\n177890 ...
code_stdio
[ { "content": "There is a toy building consisting of $n$ towers. Each tower consists of several cubes standing on each other. The $i$-th tower consists of $h_i$ cubes, so it has height $h_i$.\n\nLet's define operation slice on some height $H$ as following: for each tower $i$, if its height is greater than $H$, t...
[{"input": "10 10\n1 1 1 1 1 1 1 1 1 1\n", "output": "0\n"}, {"input": "10 10\n3 3 3 3 3 3 3 3 3 3\n", "output": "0\n"}, {"input": "10 10\n1 1 1 1 1 1 1 1 1 1\n", "output": "0\n"}, {"input": "10 10\n3 3 3 3 3 3 3 3 3 3\n", "output": "0\n"}, {"input": "10 10\n1 1 1 1 2 1 1 1 1 1\n", "output": "1\n"}, {"input": "10 10\n3...
code_stdio
[ { "content": "Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: \n\n Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal f...
[{"input": "28\nOctahedron\nDodecahedron\nOctahedron\nOctahedron\nDodecahedron\nIcosahedron\nIcosahedron\nDodecahedron\nDodecahedron\nDodecahedron\nCube\nDodecahedron\nCube\nTetrahedron\nCube\nCube\nTetrahedron\nDodecahedron\nDodecahedron\nDodecahedron\nIcosahedron\nIcosahedron\nDodecahedron\nIcosahedron\nDodecahedron\...
code_stdio
[ { "content": "The problem was inspired by Pied Piper story. After a challenge from Hooli's compression competitor Nucleus, Richard pulled an all-nighter to invent a new approach to compression: middle-out.\n\nYou are given two strings $s$ and $t$ of the same length $n$. Their characters are numbered from $1$ to...
[{"input": "6\n7\ncontest\nntecost\n7\ncontest\nnsttdco\n7\ncontest\ntnsteco\n7\ncontess\ncotestn\n7\ncontest\ncontest\n7\nontestc\ncontest\n", "output": "3\n-1\n4\n-1\n0\n1\n"}, {"input": "6\n7\ncontest\nntecost\n7\ncontest\nnstteco\n7\ncontest\ntnsteco\n7\ncontess\ncotestn\n7\ncontest\ncontest\n7\nontestc\ncontest\n"...
code_stdio
[ { "content": "The Beroil corporation structure is hierarchical, that is it can be represented as a tree. Let's examine the presentation of this structure as follows:\n\n * employee ::= name. | name:employee1,employee2, ... ,employeek.\n * name ::= name of an employee \n\n\n\nThat is, the description of each e...
[{"input": "ZLWSYH:WNMTNAI:FTCKPGZBJ.,UZSCFZVXXK.,LNGCU.,TCT.,LNGCU.,U.,NEHYSET..,FBLI:NEHYSET:IFY..,VN.,VN.,IFY.,FBLI.,YH.,FBLI.,DTXG.,NEHYSET.,WNMTNAI.,VN.,SVXN.,NEHYSET.,TCT.,DTXG..,UZSCFZVXXK:KZQRJFST.,FTCKPGZBJ.,WNMTNAI.,SVXN:DHONBXRZAL..,NEHYSET.,IFY..,MPOEEMVOP:DHONBXRZAL.,DTXG.,FTCKPGZBJ..,KZQRJFST:SVXN.,SVXN.....
code_stdio
[ { "content": "You were lucky enough to get a map just before entering the legendary magical mystery world. The map shows the whole area of your planned exploration, including several countries with complicated borders. The map is clearly drawn, but in sepia ink only; it is hard to recognize at a glance which re...
[{"input": "6\nBlizid\n0 0\n60 -1\n60 60\n0 60\n0 50\n50 50\n50 10\n0 10\n-1\nBlizid\n0 10\n10 10\n10 50\n0 50\n-1\nWindom\n10 10\n50 10\n40 20\n20 20\n20 40\n10 50\n-1\nAccent\n50 10\n50 50\n35 50\n35 25\n-1\nPilot\n35 25\n35 50\n19 50\n-1\nBlizid\n20 20\n40 20\n20 40\n-1\n4\nA1234567890123456789\n0 0\n0 100\n100 100\...
code_stdio
[ { "content": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in countercl...
[{"input": "50 100\n0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98\n1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99\n", "outp...
code_stdio
[ { "content": "coastline\n\nWaves rush to the beach every second. There is data that observes and records how many meters the wave rushed beyond the reference point P every second for only T seconds. The data consists of T integers x1, ..., xT, and for each i (1 ≀ i ≀ T), a wave from point P to the point exactly...
[{"input": "5 2 3\n3\n2\n1\n2\n6\n3 100 100\n5\n3\n4\n20 2 8\n3\n2\n10\n1\n14\n1\n1\n4\n2\n2\n16\n1\n8\n8\n2\n6\n3\n8\n3\n8\n7 2 2\n0\n2\n5\n2\n5\n2\n-1\n0 0 0", "output": "2\n0\n11\n5\n"}, {"input": "5 2 3\n3\n2\n1\n2\n6\n3 110 100\n5\n3\n4\n20 2 3\n3\n2\n10\n1\n14\n1\n1\n4\n2\n2\n16\n1\n8\n8\n2\n6\n3\n8\n3\n8\n7 2 2\...
code_stdio
[ { "content": "Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases: They are equal. If we split string a into two halves of the same size a_1 and a_2, and string b into two halves of the same ...
[{"input": "yhwepqwyhwepqwyhwepqweahnqtueahnqtueahnqtuyhwepqwyhwepqwyhwepqwyhwepqweahnqtueahnqtuyhwepqweahnqtueahnqtueahnqtueahnqtueahnqtueahnqtu\neahnqtueahnqtueahnqtuyhwepqweahnqtuyhwepqwyhwepqweahnqtuyhwepqweahnqtuyhwepqweahnqtueahnqtuyhwepqweahnqtueahnqtuyhwepqwyhwepqwyhwepqw\n", "output": "NO\n"}, {"input": "yhwep...
code_stdio
[ { "content": "[Image] \n\n\n-----Input-----\n\nThe input contains a single integer $a$ ($0 \\le a \\le 15$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n13\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the ou...
[{"input": "000\n", "output": "15\n"}, {"input": "3\n", "output": "13\n"}, {"input": "0\n", "output": "15\n"}, {"input": "1\n", "output": "14\n"}, {"input": "2\n", "output": "12\n"}, {"input": "6\n", "output": "10\n"}, {"input": "7\n", "output": "11\n"}, {"input": "10\n", "output": "2\n"}, {"input": "11\n", "output": "...
code_stdio
[ { "content": "Smart Beaver recently got interested in a new word game. The point is as follows: count the number of distinct good substrings of some string s. To determine if a string is good or not the game uses rules. Overall there are n rules. Each rule is described by a group of three (p, l, r), where p is ...
[{"input": "hrsszhjvrbsszvqesessiqbzeqijjerqirhhjsehiehezvzihzssivhvihrivrhizeqvvhejvibhqrbbqjrjsessvrhijzsrqirvsqqbibzhrzseijesszsrzhjjbqsrjrsrizivvhsjvqz\n3\nrzzevhiibziqiirhsebebrvrvvjihsjhvjjrejvqezireqevqeszrrseriijijijveqzbsbrezqhrrhbshqrhzshjervqjjzveeqsisrbevvjvjhbzvbjrrvizh 0 122\niqqqjirjjhrbrerhssszbqqizzhre...
code_stdio