messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
1 value
[ { "content": "In Japan, temperature is usually expressed using the Celsius (℃) scale. In America, they used the Fahrenheit (℉) scale instead. $20$ degrees Celsius is roughly equal to $68$ degrees Fahrenheit. A phrase such as \"Today’s temperature is $68$ degrees\" is commonly encountered while you are in Americ...
[{"input": "22485", "output": "11227\n"}, {"input": "37535", "output": "18752\n"}, {"input": "54760", "output": "27365\n"}, {"input": "10347", "output": "5158\n"}, {"input": "10699", "output": "5334\n"}, {"input": "19116", "output": "9543\n"}, {"input": "11734", "output": "5852\n"}, {"input": "14312", "output": "7141\n...
code_stdio
[ { "content": "You planned a trip using trains and buses.\nThe train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket.\nSimilarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ...
[{"input": "549\n817\n715\n603\n", "output": "1152\n"}, {"input": "600\n300\n220\n420\n", "output": "520\n"}, {"input": "555\n555\n400\n200\n", "output": "755\n"}, {"input": "549\n838\n715\n603", "output": "1152\n"}, {"input": "555\n312\n400\n200", "output": "512\n"}, {"input": "600\n548\n220\n420", "output": "768\n"},...
code_stdio
[ { "content": "You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friend...
[{"input": "500000000 500000000 29983 29989\n", "output": "1000000001\n"}, {"input": "500000000 500000000 29959 29983\n", "output": "1000000001\n"}, {"input": "500000000 500000000 29983 29989\n", "output": "1000000001\n"}, {"input": "500000000 500000000 29959 29983\n", "output": "1000000001\n"}, {"input": "500000000 33...
code_stdio
[ { "content": "Little penguin Polo likes permutations. But most of all he likes permutations of integers from 0 to n, inclusive.\n\nFor permutation p = p_0, p_1, ..., p_{n}, Polo has defined its beauty — number $(0 \\oplus p_{0}) +(1 \\oplus p_{1}) + \\cdots +(n \\oplus p_{n})$.\n\nExpression $x \\oplus y$ means...
[{"input": "15475\n", "output": "239491100\n3 2 1 0 11 10 9 8 7 6 5 4 115 114 113 112 111 110 109 108 107 106 105 104 103 102 101 100 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 ...
code_stdio
[ { "content": "Limak is a little polar bear. He doesn't have many toys and thus he often plays with polynomials.\n\nHe considers a polynomial valid if its degree is n and its coefficients are integers not exceeding k by the absolute value. More formally:\n\nLet a0, a1, ..., an denote the coefficients, so <image>...
[{"input": "100 1000\n-62 57 -27 -67 49 -10 66 -64 -36 -78 62 -75 -39 75 -47 -36 41 -88 62 -43 22 29 -20 58 40 16 71 -2 -87 12 86 -90 -92 67 -12 -48 -10 -26 78 68 22 -3 66 -95 -81 34 14 -76 -27 76 -60 87 -84 3 35 -60 46 -65 29 -29 2 -44 -55 18 -75 91 36 34 -86 53 59 -54 -29 33 -95 66 9 72 67 -44 37 44 32 -52 -34 -4 -99...
code_stdio
[ { "content": "It is winter now, and Max decided it's about time he watered the garden.\n\nThe garden can be represented as n consecutive garden beds, numbered from 1 to n. k beds contain water taps (i-th tap is located in the bed x_{i}), which, if turned on, start delivering water to neighbouring beds. If the t...
[{"input": "1\n177 99\n1 4 7 10 11 13 14 15 16 17 19 21 22 24 25 26 27 28 32 34 35 38 39 40 42 45 46 52 54 55 57 58 59 60 62 64 65 67 70 71 74 77 78 79 80 81 83 84 88 92 93 94 95 100 101 102 104 106 107 108 109 110 112 113 114 115 116 118 122 123 124 125 127 128 129 130 134 135 137 138 139 140 142 146 148 149 154 158 1...
code_stdio
[ { "content": "You are looking at the floor plan of the Summer Informatics School's new building. You were tasked with SIS logistics, so you really care about travel time between different locations: it is important to know how long it would take to get from the lecture room to the canteen, or from the gym to th...
[{"input": "100000000 100000000 100000000 100000000 1\n100000000 100000000 100001000 1\n", "output": "100000999\n"}, {"input": "100000000 100000000 100000000 100000000 1\n100000000 100000000 100000000 1\n", "output": "99999999\n"}, {"input": "100000000 100000000 100000000 100000000 1\n100000000 100000000 100000000 1\n"...
code_stdio
[ { "content": "We have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left. On this grid, there is a piece, which is initially placed at square (s_r,s_c).\n\nTakahashi and Aoki will play a game, wh...
[{"input": "2 6 11\n2 1\nRLDRRUDDLRL\nURRDRLLDLRD", "output": "NO\n"}, {"input": "5 6 11\n2 0\nRLDRRUDDLRL\nURRDRLLDLRD", "output": "NO\n"}, {"input": "4 6 11\n2 1\nRLDRRUDDLRL\nURRDRLLDLRD", "output": "NO\n"}, {"input": "5 1 11\n2 0\nRLDRRUDDLRL\nURRDRLLDLRD", "output": "NO\n"}, {"input": "5 6 11\n2 1\nRLDRRUDDLSL\nUR...
code_stdio
[ { "content": "For an array $b$ of length $m$ we define the function $f$ as $ f(b) = \\begin{cases} b[1] & \\quad \\text{if } m = 1 \\\\ f(b[1] \\oplus b[2],b[2] \\oplus b[3],\\dots,b[m-1] \\oplus b[m]) & \\quad \\text{otherwise,} \\end{cases} $ \n\nwhere $\\oplus$ is bitwise exclusive OR.\n\nFor example, $f(1,...
[{"input": "6\n0 1 6 12 51 68\n4\n1 6\n2 6\n3 3\n2 4\n", "output": "125\n125\n6\n13\n"}, {"input": "6\n1 2 4 12 16 32\n4\n1 6\n2 6\n3 4\n1 4\n", "output": "56\n56\n12\n14\n"}, {"input": "6\n1 2 4 12 32 32\n4\n1 6\n2 6\n3 4\n1 4\n", "output": "44\n44\n12\n14\n"}, {"input": "6\n1 2 4 12 16 31\n4\n1 6\n2 6\n3 4\n1 4\n", "...
code_stdio
[ { "content": "At Akabeko Elementary School, all the students participate in a slightly unusual jogging. Students run their own lap courses at their own pace. After going around each of your courses, you will be returned to elementary school. How many laps do they all meet at the same time in elementary school a...
[{"input": "2\n3 4\n13 4\n5\n789 289\n166 46\n9 4\n617 272\n972 303\n2\n11 5\n23 20\n0", "output": "13\n3\n1598397732\n1209243492\n1939462992\n1923746112\n1360317793\n23\n44\n"}, {"input": "2\n3 4\n13 4\n5\n789 289\n166 46\n9 4\n617 272\n972 303\n2\n11 5\n32 20\n0", "output": "13\n3\n1598397732\n1209243492\n1939462992\...
code_stdio
[ { "content": "Now I have a card with n numbers on it. Consider arranging some or all of these appropriately to make numbers. Find the number obtained by adding all the numbers created at this time.\n\nFor example, if you have 1 and 2, you will get 4 numbers 1, 2, 12, 21 so the total number is 36. Even if the sa...
[{"input": "4\n2\n8\n6\n10", "output": "1177916\n"}, {"input": "4\n4\n8\n6\n10", "output": "1315948\n"}, {"input": "4\n1\n5\n7\n17", "output": "1022430\n"}, {"input": "4\n4\n8\n3\n10", "output": "1108900\n"}, {"input": "4\n1\n7\n7\n17", "output": "1160462\n"}, {"input": "4\n2\n7\n7\n17", "output": "1229478\n"}, {"input...
code_stdio
[ { "content": "Vasya has got a robot which is situated on an infinite Cartesian plane, initially in the cell $(0, 0)$. Robot can perform the following four kinds of operations: U — move from $(x, y)$ to $(x, y + 1)$; D — move from $(x, y)$ to $(x, y - 1)$; L — move from $(x, y)$ to $(x - 1, y)$; R — move fr...
[{"input": "386\nRUDLURLUURDDLLLRLDURLRRDLDUUURLLRDLRRDLDRLDDURDURURDRLUULLDUULRULDLLLLDLUURRLRRRUDULRDDRDLDULRLDDRDDRLRLDLDULLULUDULLLDUUDURURDDLDRLUDDDDLDUDUURLUUDURRUDRLUDRLULLRLRRDLULDRRURUULLRDLDRLURDUDRLDLRLLUURLURDUUDRDURUDDLLDURURLLRRULURULRRLDLDRLLUUURURDRRRLRDRURULUDURRLRLDRUDLRRRRLLRURDUUDLLLLURDLRLRRDLDLLLD...
code_stdio
[ { "content": "In some country live wizards. They love playing with numbers. \n\nThe blackboard has two numbers written on it — a and b. The order of the numbers is not important. Let's consider a ≤ b for the sake of definiteness. The players can cast one of the two spells in turns:\n\n * Replace b with b - ak....
[{"input": "66\n7 0\n5 7\n1 3\n3 2\n3 5\n0 6\n1 2\n0 7\n4 5\n4 7\n5 1\n2 0\n4 0\n0 5\n3 6\n7 2\n6 0\n5 3\n6 6\n1 7\n5 6\n2 2\n3 4\n2 0\n5 3\n4 6\n6 1\n5 3\n100000000000 0000000000000000000\n0 1\n4 1\n2 6\n5 5\n4 5\n0 3\n3 7\n3 1\n1 0\n4 4\n1000000000000000000 100000000000\n12 6\n4 2\n7 5\n1 6\n6 1\n2 7\n7 7\n6 7\n2 4\n...
code_stdio
[ { "content": "As AtCoder Beginner Contest 100 is taking place, the office of AtCoder, Inc. is decorated with a sequence of length N, a = {a_1, a_2, a_3, ..., a_N}.\n\nSnuke, an employee, would like to play with this sequence.\nSpecifically, he would like to repeat the following operation as many times as possib...
[{"input": "10000\n126382592 432418816 117063168 213396480 379143680 515038208 324231168 266539520 602792960 314653184 650153984 883734016 33309696 9005056 46451200 158759424 33279488 319342080 499438080 853167616 310094336 919876608 882363392 132034048 288561664 745817600 28561408 9703936 792974336 310508544 125830656...
code_stdio
[ { "content": "Four players participate in the playoff tournament. The tournament is held according to the following scheme: the first player will play with the second, and the third player with the fourth, then the winners of the pairs will play in the finals of the tournament.\n\nIt is known that in a match be...
[{"input": "4\n3 7 9 5\n4 5 6 1\n5 3 8 1\n2 5 3 2\n", "output": "YES\nYES\nYES\nYES\n"}, {"input": "4\n3 7 2 5\n4 5 6 9\n5 3 15 1\n2 5 3 1\n", "output": "YES\nNO\nYES\nYES\n"}, {"input": "4\n3 7 9 5\n4 5 6 9\n5 3 8 1\n2 5 3 2\n", "output": "YES\nNO\nYES\nYES\n"}, {"input": "4\n3 7 9 5\n4 5 6 9\n5 3 8 1\n2 5 3 1\n", "ou...
code_stdio
[ { "content": "For a given positive integer n denote its k-rounding as the minimum positive integer x, such that x ends with k or more zeros in base 10 and is divisible by n.\n\nFor example, 4-rounding of 375 is 375·80 = 30000. 30000 is the minimum integer such that it ends with 4 or more zeros and is divisible ...
[{"input": "1005856822 8\n", "output": "50292841100000000\n"}, {"input": "1522186596 8\n", "output": "38054664900000000\n"}, {"input": "123456789 8\n", "output": "12345678900000000\n"}, {"input": "999999999 8\n", "output": "99999999900000000\n"}, {"input": "222222222 8\n", "output": "11111111100000000\n"}, {"input": "6...
code_stdio
[ { "content": "You are fed up with your messy room, so you decided to clean it up.\n\nYour room is a bracket sequence $s=s_{1}s_{2}\\dots s_{n}$ of length $n$. Each character of this string is either an opening bracket '(' or a closing bracket ')'.\n\nIn one operation you can choose any consecutive substring of ...
[{"input": "4\n8 3\n)())(()(\n10 3\n))()()()((\n2 1\n)(\n2 1\n)(\n", "output": "4\n1 2\n3 5\n5 6\n6 8\n5\n1 3\n3 5\n5 7\n6 9\n7 10\n1\n1 2\n1\n1 2\n"}, {"input": "4\n8 2\n)())(()(\n10 4\n))()()()((\n2 1\n)(\n2 1\n)(\n", "output": "4\n1 2\n3 5\n4 6\n5 8\n5\n1 3\n3 5\n5 7\n7 9\n8 10\n1\n1 2\n1\n1 2\n"}, {"input": "4\n8 1...
code_stdio
[ { "content": "You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q.\n\nFor example, the string \"Hello\" for p = 2, q = 3 can be split to the two strings \"Hel\" and \"lo\" or to the two strings \"He\" and \"llo\".\n\nNote it is allowed to split the string ...
[{"input": "100 1 1\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n", "output": "100\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\nb\nb\nb\nb\nb\nb\nb\nb\nb\nb...
code_stdio
[ { "content": "In this problem you have to solve a simple classification task: given an image, determine whether it depicts a Fourier doodle. \n\nYou are given a set of 50 images with ids 1 through 50. You are also given a text file labels.txt containing the labels for images with ids 1 through 20, which compris...
[{"input": "-116\n", "output": "0\n1\n1\n0\n1\n1\n0\n1\n1\n1\n1\n1\n0\n1\n0\n1\n1\n1\n0\n1\n1\n1\n1\n1\n0\n1\n0\n1\n1\n1\n"}, {"input": "-132\n", "output": "0\n1\n1\n0\n1\n1\n0\n1\n1\n1\n1\n1\n0\n1\n0\n1\n1\n1\n0\n1\n1\n1\n1\n1\n0\n1\n0\n1\n1\n1\n"}, {"input": "-119\n", "output": "0\n1\n1\n0\n1\n1\n0\n1\n1\n1\n1\n1\n0\...
code_stdio
[ { "content": "A substring of some string is called the most frequent, if the number of its occurrences is not less than number of occurrences of any other substring.\n\nYou are given a set of strings. A string (not necessarily from this set) is called good if all elements of the set are the most frequent substr...
[{"input": "76\namnctposz\nmnctpos\nos\nu\ne\nam\namnc\neamnctpo\nl\nx\nq\nposzq\neamnc\nctposzq\nctpos\nmnc\ntpos\namnctposzql\ntposzq\nmnctposz\nnctpos\nctposzql\namnctpos\nmnct\np\nux\nposzql\ntpo\nmnctposzql\nmnctp\neamnctpos\namnct\ntposzql\nposz\nz\nct\namnctpo\noszq\neamnct\ntposz\ns\nmn\nn\nc\noszql\npo\no\nmnc...
code_stdio
[ { "content": "You are given a permutation $p_1, p_2, \\ldots, p_n$.\n\nIn one move you can swap two adjacent values.\n\nYou want to perform a minimum number of moves, such that in the end there will exist a subsegment $1,2,\\ldots, k$, in other words in the end there should be an integer $i$, $1 \\leq i \\leq n...
[{"input": "100\n98 52 63 2 18 96 31 58 84 40 41 45 66 100 46 71 26 48 81 20 73 91 68 76 13 93 17 29 64 95 79 21 55 75 19 85 54 51 89 78 15 87 43 59 36 1 90 35 65 56 62 28 86 5 82 49 3 99 33 9 92 32 74 69 27 22 77 16 44 94 34 6 57 70 23 12 61 25 8 11 67 47 83 88 10 14 30 7 97 60 42 37 24 38 53 50 4 80 72 39\n", "output...
code_stdio
[ { "content": "Addition of Big Integers\n\nGiven two integers $A$ and $B$, compute the sum, $A + B$.\n\nInput\n\nTwo integers $A$ and $B$ separated by a space character are given in a line.\n\nOutput\n\nPrint the sum in a line.\n\nConstraints\n\n* $-1 \\times 10^{100000} \\leq A, B \\leq 10^{100000}$\n\n\n\nSamp...
[{"input": "109 30", "output": "139\n"}, {"input": "195 30", "output": "225\n"}, {"input": "302 30", "output": "332\n"}, {"input": "552 30", "output": "582\n"}, {"input": "139 37", "output": "176\n"}, {"input": "139 39", "output": "178\n"}, {"input": "107 39", "output": "146\n"}, {"input": "107 73", "output": "180\n"},...
code_stdio
[ { "content": "Celebrating the new year, many people post videos of falling dominoes; Here's a list of them: https://www.youtube.com/results?search_query=New+Years+Dominos\n\nUser ainta, who lives in a 2D world, is going to post a video as well.\n\nThere are n dominoes on a 2D Cartesian plane. i-th domino (1 ≤ i...
[{"input": "10\n142699629 183732682\n229190264 203769218\n582937498 331846994\n637776490 872587100\n646511567 582113351\n708368481 242093919\n785185417 665206490\n827596004 933089845\n905276008 416253629\n916536536 583835690\n5\n9 10\n4 9\n1 10\n6 10\n4 5\n", "output": "0\n0\n149978016\n0\n0\n"}, {"input": "10\n1426996...
code_stdio
[ { "content": "George has recently entered the BSUCP (Berland State University for Cool Programmers). George has a friend Alex who has also entered the university. Now they are moving into a dormitory. \n\nGeorge and Alex want to live in the same room. The dormitory has n rooms in total. At the moment the i-th r...
[{"input": "100\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0...
code_stdio
[ { "content": "Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his pr...
[{"input": "3\nAZAMON ALPPE\nAZOMAN ABABILAAAAAAAAAAA\nAPPLE ANAOAB\n", "output": "AAZMON\nAAOMZN\nAEPLP\n"}, {"input": "3\nAZANOM APPLE\nAAZMON ABABILAAAAAAAAAAA\nAPPLF ANANAB\n", "output": "AAZNOM\nAAMZON\nAFPLP\n"}, {"input": "3\nZAAMON APPLE\nAZAMON ABABHLAAAA@AAAAAA\nAPPLF ANANAB\n", "output": "AAZMON\nAAZMON\nAFP...
code_stdio
[ { "content": "Kate has a set $S$ of $n$ integers $\\{1, \\dots, n\\} $. \n\nShe thinks that imperfection of a subset $M \\subseteq S$ is equal to the maximum of $gcd(a, b)$ over all pairs $(a, b)$ such that both $a$ and $b$ are in $M$ and $a \\neq b$. \n\nKate is a very neat girl and for each $k \\in \\{2, \\do...
[{"input": "21031\n", "output": "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
code_stdio
[ { "content": "Chef is fan of pairs and he likes all things that come in pairs. He even has a doll collection in which the dolls come in pairs. One day while going through his collection he found that there are odd number of dolls. Someone had stolen a doll!!! \nHelp chef find which type of doll is missing..\n\...
[{"input": "1\n1\n100 \n3\n1", "output": "100\n"}, {"input": "1\n5\n1\n1\n3\n3\n3", "output": "3\n"}, {"input": "1\n5\n1\n1\n3\n6\n3", "output": "6\n"}, {"input": "1\n5\n1\n1\n2\n2\n5", "output": "5\n"}, {"input": "1\n5\n1\n1\n3\n3\n9", "output": "9\n"}, {"input": "1\n1\n48 \n9\n-1", "output": "48\n"}, {"input": "1\n1\...
code_stdio
[ { "content": "A string is called palindrome if it reads the same from left to right and from right to left. For example \"kazak\", \"oo\", \"r\" and \"mikhailrubinchikkihcniburliahkim\" are palindroms, but strings \"abb\" and \"ij\" are not.\n\nYou are given string s consisting of lowercase Latin letters. At on...
[{"input": "wrwrwfrrfrffrrwwwffffwrfrrwfrrfrwwfwfrwfwfwffwrrwfrrrwwwfrrrwfrrfwrwwrwrrrffffwrrrwrwfffwrffrwwwrwww\n", "output": "fffffffffffffffrrrrrrrrrrrrrrrrrrwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrrrrrrrrrrrrrrrrrrfffffffffffffff\n"}, {"input": "wrwrwfrrfrffrrwwwffffwrfrrwfrrfrwwfwfrwfwfwffwrrwfrrrwwwfrrrwfrrfwrwwrwrrrf...
code_stdio
[ { "content": "You might have heard about our new goodie distribution program aka the \"Laddu Accrual System\". This problem is designed to give you a glimpse of its rules. You can read the page once before attempting the problem if you wish, nonetheless we will be providing all the information needed here itsel...
[{"input": "2\n4 INDIAN\nCONTEST_WON 0\nTOP_CONTRIBUTOR\nBUG_FOUND 110\nCONTEST_HOSTED\n2 NON_INDIAN\nCONTEST_WON -1\nTOP_CONTRIBUTOR\nBUH_FOUND 100\nCONTEST_HOSTED", "output": "3\n1\n"}, {"input": "2\n4 INDIAN\nCONTEST_WON 0\nTOP_CONTRIBUTOR\nBUG_FOUND 110\nCONTEST_HOSTED\n2 NON_INDIAN\nCONTEST_WON -1\nTOP_CONTRIBUTOR...
code_stdio
[ { "content": "The only difference between easy and hard versions are constraints on $n$ and $k$.\n\nYou are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most $k$ most recent conversations with your friends. Initially, the screen is empty (i.e. the number of di...
[{"input": "10 4\n2 3 3 1 1 2 1 4 3 3\n", "output": "4\n4 1 3 2\n"}, {"input": "10 4\n2 3 5 1 1 2 1 4 3 3\n", "output": "4\n4 1 5 3\n"}, {"input": "10 4\n2 3 5 2 1 2 1 4 2 3\n", "output": "4\n3 2 4 1\n"}, {"input": "10 4\n2 3 3 1 1 2 1 2 4 3\n", "output": "4\n4 1 3 2\n"}, {"input": "10 4\n2 3 5 2 1 2 1 4 3 3\n", "outpu...
code_stdio
[ { "content": "According to Berland laws it is only allowed to sell alcohol to people not younger than 18 years. Vasya's job is to monitor the law's enforcement. Tonight he entered a bar and saw n people sitting there. For every one of them Vasya happened to determine either the age or the drink the person is ha...
[{"input": "4\n1475\nKXJURNYJHVLVKULJBPRBCZSOTKNTOGKGFKIQDQEMEAFTPNXQTIQWROI\nKTR\nRHVRWGODYWWTYZFLFYKCVUFFRTQDINKNWPKFHZBFWBHWINWJW\n", "output": "0\n"}, {"input": "4\n1475\nKXJURNYJHVLVKULJBPRBCZSOTKNTOGKGFKIQDQEMEAFTPNXQTIQWROI\nRTK\nRHVRWGODYWWTYZFLFYKCVUFFRTQDINKNWPKFHZBFWBHWINWJW\n", "output": "0\n"}, {"input": "...
code_stdio
[ { "content": "You are given a sequence $a_1, a_2, \\dots, a_n$ consisting of $n$ integers.\n\nYou may perform the following operation on this sequence: choose any element and either increase or decrease it by one.\n\nCalculate the minimum possible difference between the maximum element and the minimum element i...
[{"input": "100 1186\n619 240 80 547 446 128 43 285 725 220 56 690 770 431 777 5 41 549 405 203 2 477 919 481 453 787 680 326 318 241 942 497 504 324 598 925 346 628 851 38 355 493 748 685 901 63 698 676 154 162 313 964 455 617 381 41 479 746 83 253 164 907 950 918 264 307 980 743 257 322 845 419 559 496 434 759 584 95...
code_stdio
[ { "content": "In this problem is used an extremely simplified version of HTML table markup. Please use the statement as a formal document and read it carefully.\n\nA string is a bHTML table, if it satisfies the grammar: \n \n \n \n TABLE ::= <table>ROWS</table> \n ROWS ::= ROW | ROW ROWS \n ...
[{"input": "<table><tr><td><table><tr><td><table><tr><td><table><tr><td><table><tr><td><table><tr><td><table><tr><td><table><tr><td><table><tr><td><table><tr><td><table><tr><td><table><tr><td><table><tr><td><table><tr><td></td></tr></table></td></tr></table></td></tr></table></td></tr></table></td></tr></table></td></t...
code_stdio
[ { "content": "Snuke stands on a number line. He has L ears, and he will walk along the line continuously under the following conditions:\n\n* He never visits a point with coordinate less than 0, or a point with coordinate greater than L.\n* He starts walking at a point with integer coordinate, and also finishes...
[{"input": "7\n180356616\n666988621\n1507983937\n574614921\n254436000\n1351749818\n0", "output": "0\n"}, {"input": "7\n314159265\n429733551\n846264338\n327950288\n419716939\n937510582\n-1", "output": "0\n"}, {"input": "7\n314159265\n274050664\n846264338\n327950288\n419716939\n937510582\n-1", "output": "0\n"}, {"input":...
code_stdio
[ { "content": "In one of the games Arkady is fond of the game process happens on a rectangular field. In the game process Arkady can buy extensions for his field, each extension enlarges one of the field sizes in a particular number of times. Formally, there are n extensions, the i-th of them multiplies the widt...
[{"input": "82424 40643 9 2 200\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 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 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 2 2 2 2 2 2 2 2...
code_stdio
[ { "content": "One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps:\n\n 1. Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; \n 2. Delete the firs...
[{"input": "20 20\n20 1 19 2 18 3 17 4 16 5 15 6 14 7 13 8 12 9 11 10\n", "output": "19\n"}, {"input": "20 10\n1 2 3 4 8 6 7 10 9 10 1 1 1 1 1 1 1 1 1 1\n", "output": "-1\n"}, {"input": "20 10\n1 2 3 4 8 6 7 10 9 10 1 1 1 1 0 1 1 1 1 1\n", "output": "-1\n"}, {"input": "20 10\n1 1 3 4 8 6 7 10 9 10 1 1 1 1 0 1 1 1 1 1\n...
code_stdio
[ { "content": "Mr. A, who will graduate next spring, decided to move when he got a job. The company that finds a job has offices in several towns, and the offices that go to work differ depending on the day. So Mr. A decided to live in a town where he had a short time to go to any office.\n\nSo you decided to fi...
[{"input": "6\n0 1 80\n1 3 20\n0 2 60\n2 4 50\n3 2 66\n0 4 165\n2\n0 1 1\n1 2 1\n0", "output": "2 262\n1 2\n"}, {"input": "6\n0 1 80\n1 3 20\n0 2 60\n2 4 50\n3 2 66\n0 4 165\n2\n0 1 1\n0 2 1\n0", "output": "2 262\n0 2\n"}, {"input": "6\n0 1 113\n1 4 20\n0 2 60\n2 2 47\n3 4 66\n1 4 90\n2\n0 1 1\n1 2 1\n0", "output": "1 ...
code_stdio
[ { "content": "Let's define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of n vertices. For each vertex v from 0 to n - 1 he wrote down two integers, degreev and sv, were the first integer is the number of vertices adjacent to v...
[{"input": "19\n1 13\n0 0\n1 9\n1 11\n1 11\n2 3\n2 30\n0 0\n1 5\n1 2\n0 0\n5 29\n1 6\n2 11\n0 0\n0 0\n0 0\n0 0\n2 13\n", "output": "10\n0 13\n2 9\n3 11\n4 11\n8 5\n12 6\n13 11\n5 11\n6 18\n11 18\n"}, {"input": "18\n0 0\n0 0\n2 19\n1 2\n2 29\n0 0\n1 7\n1 6\n1 12\n1 13\n0 0\n1 12\n4 23\n1 9\n0 0\n0 0\n2 14\n1 4\n", "outp...
code_stdio
[ { "content": "B: Dansunau www --Dance Now!-\n\nstory\n\nLast lab life! Daigakuin! !! Dosanko Snow has won 9th place in the event \"Master Idol World\", which can be said to be the outpost of the biggest competition \"Lab Life\" where master idols compete. The sharp dance is ridiculed as \"9th place dance\", and...
[{"input": "9\n9 8 7 6 9 5 3 2 1\n1 1 1\n3 4 2\n4 3 3\n4 0 4\n5 10 5\n12 9 7\n7 7 7\n8 11 8\n9 11 9", "output": "3\n"}, {"input": "9\n9 8 7 6 9 5 3 2 1\n1 1 1\n3 4 2\n4 3 3\n4 0 4\n5 10 5\n12 9 7\n7 7 7\n8 8 8\n9 11 9", "output": "3\n"}, {"input": "9\n9 8 7 6 9 5 3 2 1\n1 1 1\n3 4 2\n8 3 3\n4 0 4\n5 10 5\n12 9 7\n7 7 7...
code_stdio
[ { "content": "problem\n\nFive students, Taro, Jiro, Saburo, Shiro, and Hanako, participated in the JOI High School class.\n\nIn this class, a final exam was conducted. All five people took the final exam. For students with a final exam score of 40 or higher, the final exam score was used as is. All students wit...
[{"input": "10\n130\n100\n37\n101", "output": "82\n"}, {"input": "10\n130\n100\n65\n101", "output": "87\n"}, {"input": "10\n130\n100\n98\n101", "output": "93\n"}, {"input": "10\n130\n110\n98\n100", "output": "95\n"}, {"input": "10\n130\n111\n98\n000", "output": "83\n"}, {"input": "10\n100\n111\n225\n4", "output": "103\...
code_stdio
[ { "content": "Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b.\n\nConstraints\n\n* 0 < a, b ≤ 2,000,000,000\n* LCM(a, b) ≤ 2,000,000,000\n* The number of data sets ≤ 50\n\nInput\n\nInput consists of several data sets. Each data set contains a...
[{"input": "34 12\n234598000 42842091", "output": "2 204\n1 10050668864418000\n"}, {"input": "34 12\n234598000 60832539", "output": "2 204\n1 14271191984322000\n"}, {"input": "34 9\n234598000 42842091", "output": "1 306\n1 10050668864418000\n"}, {"input": "13 24\n38128567 122348608", "output": "1 312\n1 466497709748473...
code_stdio
[ { "content": "You have a string s = s_1s_2...s_{|}s|, where |s| is the length of string s, and s_{i} its i-th character. \n\nLet's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string s_{i}s_{i} + 1...s_{j}. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1.....
[{"input": "AAAAAAAAAAAAAAAAXAAAAAAAAAAAAAAAAAAAAAAA\n", "output": "17\n1 39\n2 37\n3 35\n4 33\n5 31\n6 29\n7 27\n8 25\n9 23\n10 21\n11 19\n12 17\n13 15\n14 13\n15 11\n16 9\n40 1\n"}, {"input": "AAAAAAAAAAAAAAAAXAAAAAAAAAAAAAAAAAAAAAAA\n", "output": "17\n1 39\n2 37\n3 35\n4 33\n5 31\n6 29\n7 27\n8 25\n9 23\n10 21\n11 1...
code_stdio
[ { "content": "You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room.\n\nFor each notice, you are given four integers b, f, r and v which represent that v persons ent...
[{"input": "3\n-1 1 10 18\n3 3 6 20\n4 3 8 -1", "output": " 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n####################\n 0 0 0 0 0 0 0 0 0 18\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 20 0 0 0 0\n#################...
code_stdio
[ { "content": "Takahashi has a lot of peculiar devices. These cylindrical devices receive balls from left and right. Each device is in one of the two states A and B, and for each state, the device operates as follows:\n\n* When a device in state A receives a ball from either side (left or right), the device thro...
[{"input": "4 123456789\nAABA", "output": "BABA\n"}, {"input": "4 110986646\nAABB", "output": "BABA\n"}, {"input": "4 123456789\nAAAA", "output": "BABA\n"}, {"input": "4 110986646\nBABA", "output": "BABA\n"}, {"input": "4 164919271\nBAAA", "output": "BABA\n"}, {"input": "4 219940491\nBAAA", "output": "BABA\n"}, {"input...
code_stdio
[ { "content": "You are given a string S of length 2N, containing N occurrences of `a` and N occurrences of `b`.\n\nYou will choose some of the characters in S. Here, for each i = 1,2,...,N, it is not allowed to choose exactly one of the following two: the i-th occurrence of `a` and the i-th occurrence of `b`. (T...
[{"input": "9\nbbbbbaaaababbaabaa", "output": "bbbbbaaaababbaabaa\n"}, {"input": "9\nbbbbbabaabbaaabaaa", "output": "bbbbbabaabbaaabaaa\n"}, {"input": "9\nabbbbabaababaabbaa", "output": "bbbabaababaabbaa\n"}, {"input": "9\nabbbbabaaabbabaaba", "output": "bbbabaaabbabaaba\n"}, {"input": "9\nabbbbabaabababaaab", "output"...
code_stdio
[ { "content": "10^{10^{10}} participants, including Takahashi, competed in two programming contests.\nIn each contest, all participants had distinct ranks from first through 10^{10^{10}}-th.\nThe score of a participant is the product of his/her ranks in the two contests.\nProcess the following Q queries:\n - In ...
[{"input": "99\n207579013 207579013\n376140463 376140463\n186969586 186969586\n326402540 326402540\n158176573 158176573\n127860890 127860890\n570870045 570870045\n178509023 178509023\n61263305 61263305\n558212775 558212775\n26389630 26389630\n496148000 496148000\n837151741 837151741\n656585276 656585276\n902071051 9020...
code_stdio
[ { "content": "After you had helped Fedor to find friends in the «Call of Soldiers 3» game, he stopped studying completely. Today, the English teacher told him to prepare an essay. Fedor didn't want to prepare the essay, so he asked Alex for help. Alex came to help and wrote the essay for Fedor. But Fedor didn't...
[{"input": "2\nABBABAABBAABABBABAABABBAABBABAABBAABABBAABBABAABABBABAABBAABABBA ABBABAABBAABABBABAABABBAABBABAABBAABABBAABBABAABABBABAABBAABABA\n2\nABBABAABBAABABBABAABABBAABBABAAABAABABBAABBABAABABBABAABBAABABA neuzaiheshi\nABBABAABBAABABBABAABABBAABBABAABBAABABBAABBABAABABBABAABBAABABBA ABBABAABBAABABBABAABABBAABBABA...
code_stdio
[ { "content": "Gerald has been selling state secrets at leisure. All the secrets cost the same: n marks. The state which secrets Gerald is selling, has no paper money, only coins. But there are coins of all positive integer denominations that are powers of three: 1 mark, 3 marks, 9 marks, 27 marks and so on. The...
[{"input": "243\n", "output": " 1\n"}, {"input": "108\n", "output": " 2\n"}, {"input": "81\n", "output": " 1\n"}, {"input": "10\n", "o...
code_stdio
[ { "content": "N of us are going on a trip, by train or taxi.\nThe train will cost each of us A yen (the currency of Japan).\nThe taxi will cost us a total of B yen.\nHow much is our minimum total travel expense?\n\n-----Constraints-----\n - All values in input are integers.\n - 1 \\leq N \\leq 20\n - 1 \\leq A ...
[{"input": "12 -13 -107", "output": "-156\n"}, {"input": "-1719 1 -2", "output": "-1719\n"}, {"input": "10 -2 -141", "output": "-141\n"}, {"input": "10 -2 -162", "output": "-162\n"}, {"input": "10 -7 -107", "output": "-107\n"}, {"input": "19 -7 -107", "output": "-133\n"}, {"input": "13 -13 -48", "output": "-169\n"}, {"...
code_stdio
[ { "content": "Pari wants to buy an expensive chocolate from Arya. She has n coins, the value of the i-th coin is c_{i}. The price of the chocolate is k, so Pari will take a subset of her coins with sum equal to k and give it to Arya.\n\nLooking at her coins, a question came to her mind: after giving the coins t...
[{"input": "9 436\n1 2 4 8 14 32 27 128 256\n", "output": "160\n0 1 2 3 4 6 8 9 10 11 14 15 16 17 18 20 22 23 24 25 27 28 29 30 32 34 35 36 37 38 41 42 43 44 46 48 49 50 51 52 128 129 130 131 132 134 136 137 138 139 142 143 144 145 146 148 150 151 152 153 155 156 157 158 160 162 163 164 165 166 169 170 171 172 174 176 ...
code_stdio
[ { "content": "Write a program which reads three integers a, b and c, and prints \"Yes\" if a < b < c, otherwise \"No\".\n\nConstraints\n\n* 0 ≤ a, b, c ≤ 100\n\nInput\n\nThree integers a, b and c separated by a single space are given in a line.\n\nOutput\n\nPrint \"Yes\" or \"No\" in a line.\n\nExamples\n\nInpu...
[{"input": "-1 -1 -1", "output": "No\n"}, {"input": "-1 -1 -2", "output": "No\n"}, {"input": "18 10 10", "output": "No\n"}, {"input": "-1 0 2", "output": "Yes\n"}, {"input": "-1 -1 2", "output": "No\n"}, {"input": "-1 -1 1", "output": "No\n"}, {"input": "-1 -1 0", "output": "No\n"}, {"input": "18 16 5", "output": "No\n...
code_stdio
[ { "content": "You're given an array $a$. You should repeat the following operation $k$ times: find the minimum non-zero element in the array, print it, and then subtract it from all the non-zero elements of the array. If all the elements are 0s, just print 0.\n\n\n-----Input-----\n\nThe first line contains inte...
[{"input": "50 48\n26 87 99 27 2 2 94 10 21 9 6 7 85 10 66 56 16 55 101 51 16 151 100 28 93 70 33 84 50 87 55 36 93 84 63 94 119 2 42 84 37 54 34 76 38 78 14 21 6 4\n", "output": "2\n2\n2\n1\n2\n1\n4\n2\n5\n5\n1\n1\n5\n1\n2\n1\n1\n4\n8\n1\n3\n1\n1\n7\n3\n4\n6\n2\n6\n1\n2\n6\n1\n5\n1\n1\n18\n32\n0\n0\n0\n0\n0\n0\n0\n0\n...
code_stdio
[ { "content": "Recently Vladik discovered a new entertainment — coding bots for social networks. He would like to use machine learning in his bots so now he want to prepare some learning data for them.\n\nAt first, he need to download t chats. Vladik coded a script which should have downloaded the chats, however...
[{"input": "2\n3\nnetman vladik Fedosik\n2\n?: users are netman, vladik, kisodeF\nvladik: something wrong with shis chat\n4\nnetman tigerrrrr banany2001 klinchuh\n4\n?: tigerrrrr, banany2001, klinchuh- my favourite team evdr, are you ready?\nklinchuh: xes, coach!\n?: yes, netman\nbanany2001: yes of .esruoc\n", "output"...
code_stdio
[ { "content": "Arithmetic Progressions\n\nAn arithmetic progression is a sequence of numbers $a_1, a_2, ..., a_k$ where the difference of consecutive members $a_{i+1} - a_i$ is a constant ($1 \\leq i \\leq k-1$). For example, the sequence 5, 8, 11, 14, 17 is an arithmetic progression of length 5 with the common ...
[{"input": "6\n-2 11 12 30 3 0", "output": "2\n"}, {"input": "6\n-4 1 6 2 13 -1", "output": "3\n"}, {"input": "6\n-2 1 -1 8 13 9", "output": "2\n"}, {"input": "6\n-2 11 5 20 8 0", "output": "3\n"}, {"input": "6\n-2 11 6 20 8 0", "output": "2\n"}, {"input": "6\n-2 11 6 20 3 0", "output": "3\n"}, {"input": "6\n-2 11 6 30...
code_stdio
[ { "content": "A triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.\nYou will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No.\n\n-----Constraints-----\n - A, B, and C are all integers betw...
[{"input": "1 -2 -2", "output": "Yes\n"}, {"input": "0 -2 -2", "output": "Yes\n"}, {"input": "5 7 5\n", "output": "Yes\n"}, {"input": "3 3 4\n", "output": "Yes\n"}, {"input": "6 1 6\n", "output": "Yes\n"}, {"input": "8 8 2\n", "output": "Yes\n"}, {"input": "9 1 1\n", "output": "Yes\n"}, {"input": "7 8 8\n", "output": "...
code_stdio
[ { "content": "Takahashi and Aoki are going to together construct a sequence of integers.\nFirst, Takahashi will provide a sequence of integers a, satisfying all of the following conditions:\n - The length of a is N.\n - Each element in a is an integer between 1 and K, inclusive.\n - a is a palindrome, that is, ...
[{"input": "1000000000 1000000000\n", "output": "875699961\n"}, {"input": "1000000000 146388030\n", "output": "329875629\n"}, {"input": "1000000000 121963892\n", "output": "419967204\n"}, {"input": "1000000000 153662193\n", "output": "749048454\n"}, {"input": "1000001000 1000000000", "output": "212353005\n"}, {"input":...
code_stdio
[ { "content": "We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.\nWe will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).\n\n-----Constraints-----\n - 1 \\leq N \\leq 2\\times 10^5\n - 1 \\leq K \\leq N+1\n - All values in input...
[{"input": "123333 101429\n", "output": "175623902\n"}, {"input": "141421 35623\n", "output": "220280457\n"}, {"input": "154242 56347\n", "output": "520400358\n"}, {"input": "105711 80705\n", "output": "801552417\n"}, {"input": "223214 200001", "output": "534704743\n"}, {"input": "402106 200001", "output": "533363909\n...
code_stdio
[ { "content": "Ivan unexpectedly saw a present from one of his previous birthdays. It is array of $n$ numbers from $1$ to $200$. Array is old and some numbers are hard to read. Ivan remembers that for all elements at least one of its neighbours ls not less than it, more formally:\n\n$a_{1} \\le a_{2}$,\n\n$a_{n}...
[{"input": "37\n52 52 66 149 149 130 47 47 26 110 185 -1 73 73 65 -1 -1 130 -1 -1 -1 94 97 190 -1 -1 49 49 54 -1 92 92 5 25 48 79 79\n", "output": "903952722\n"}, {"input": "37\n52 52 66 149 149 130 47 47 26 110 185 -1 73 73 65 -1 -1 130 -1 -1 -1 94 97 190 -1 -1 49 49 54 -1 92 92 5 25 48 79 79\n", "output": "903952722\...
code_stdio
[ { "content": "Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. [Image] \n\nEach Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The heigh...
[{"input": "447 74474 4\n47 777474 1358\n74 744744 74477\n477 477447 777\n7 477777 444444\n", "output": "-1\n-1\n-1\n7\n"}, {"input": "447 74474 4\n47 777474 747\n74 744744 74477\n477 477447 777\n7 477777 444444\n", "output": "-1\n-1\n-1\n7\n"}, {"input": "447 74474 4\n47 777474 747\n74 744744 74477\n477 477447 777\n7 ...
code_stdio
[ { "content": "One day, Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He is interested in properties of the sequence a.\n\nFor a nonempty contiguous subsequence a_l, ..., a_r (1 \\leq l \\leq r \\leq N) of the sequence a, its beauty is defined as a_l + ... +...
[{"input": "8 2\n13 0 11 2 14 4 11 8", "output": "55\n"}, {"input": "8 4\n10 2 18 7 21 1 10 1", "output": "58\n"}, {"input": "8 4\n10 2 28 7 23 0 10 3", "output": "70\n"}, {"input": "8 2\n18 0 28 5 17 1 16 1", "output": "84\n"}, {"input": "8 2\n13 0 11 2 14 5 6 4", "output": "51\n"}, {"input": "8 2\n13 0 11 2 14 5 6 7"...
code_stdio
[ { "content": "King of Berland Berl IV has recently died. Hail Berl V! As a sign of the highest achievements of the deceased king the new king decided to build a mausoleum with Berl IV's body on the main square of the capital.\n\nThe mausoleum will be constructed from 2n blocks, each of them has the shape of a c...
[{"input": "30 50\n17 >= 29\n19 <= 18\n3 > 50\n54 >= 56\n47 < 15\n50 <= 33\n49 < 8\n57 <= 16\n30 > 35\n49 < 21\n3 >= 37\n56 <= 51\n46 > 51\n35 >= 48\n32 < 15\n12 <= 4\n38 > 57\n55 < 9\n49 <= 1\n9 >= 38\n60 = 60\n1 > 12\n40 >= 43\n13 > 38\n24 >= 39\n9 < 2\n12 > 58\n15 >= 30\n13 > 50\n42 <= 16\n23 >= 54\n16 < 10\n1 > 43\...
code_stdio
[ { "content": "Professor Matsuzaki is a scientist studying the truth of the universe. Life, the universe, all the answers are said to be 42, but Professor Matsuzaki thinks that this alone is not enough to elucidate the truth of the universe. Professor Matsuzaki believes that the truth of the universe is represen...
[{"input": "0 55\n0 1\n0 2\n0 3\n10 1\n10 2\n10 3\n10 4\n10 5\n10 6\n11 1\n11 2\n11 3\n100001 100\n-1 -1", "output": "42\n4\n5\n6\n22\n24\n26\n28\n30\n30\n26\n30\n32\n200274\n"}, {"input": "0 55\n0 1\n0 2\n0 3\n10 1\n10 2\n10 3\n10 4\n10 5\n10 1\n11 1\n11 2\n11 3\n100001 100\n-1 -1", "output": "42\n4\n5\n6\n22\n24\n26\...
code_stdio
[ { "content": "A robot is put at the origin in a two-dimensional plane.\nInitially, the robot is facing in the positive x-axis direction.\nThis robot will be given an instruction sequence s.\ns consists of the following two kinds of letters, and will be executed in order from front to back.\n - F : Move in the c...
[{"input": "FTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFT...
code_stdio
[ { "content": "You are given a string $s$ of length $n$ consisting only of lowercase Latin letters.\n\nA substring of a string is a contiguous subsequence of that string. So, string \"forces\" is substring of string \"codeforces\", but string \"coder\" is not.\n\nYour task is to calculate the number of ways to r...
[{"input": "420\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "In the Bus of Characters there are $n$ rows of seat, each having $2$ seats. The width of both seats in the $i$-th row is $w_i$ centimeters. All integers $w_i$ are distinct.\n\nInitially the bus is empty. On each of $2n$ stops one passenger enters the bus. There are two types of passengers: an in...
[{"input": "10\n24 53 10 128 141 9 15 62 32 47\n00100000000111111111\n", "output": "6 3 3 7 1 9 10 2 8 4 5 5 4 8 2 10 9 1 7 6\n"}, {"input": "10\n24 53 10 128 141 9 15 97 32 47\n00100000000111111111\n", "output": "6 3 3 7 1 9 10 2 8 4 5 5 4 8 2 10 9 1 7 6\n"}, {"input": "10\n24 53 10 99 83 9 15 62 33 47\n00100000000111...
code_stdio
[ { "content": "We have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i.\nVertex i has an integer a_i written on it.\nFor every integer k from 1 through N, solve the following problem:\n - We will make a sequence by lining up the integers written on the vertices along the shortest path ...
[{"input": "10\n1 2 4 2 11 1 7 11 0 4\n1 3\n2 3\n3 4\n7 5\n2 6\n6 7\n1 8\n2 9\n2 10", "output": "1\n2\n2\n2\n4\n2\n3\n2\n2\n3\n"}, {"input": "10\n1 2 4 0 12 1 7 11 0 4\n1 5\n2 3\n3 4\n7 5\n2 6\n6 7\n1 8\n2 9\n2 10", "output": "1\n2\n3\n3\n2\n2\n2\n2\n2\n3\n"}, {"input": "10\n1 2 6 2 7 1 2 10 0 4\n1 3\n2 3\n3 4\n10 5\n2...
code_stdio
[ { "content": "We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of substrings \"ab\" in the string and replace it with the string \"bba\". If we have no \"ab\" as a substring, our job is done. Print the minimum number of steps we should perform to make...
[{"input": "abaaaaaabaaaabbabbaaabbbbabababaaaaabbaabbaaaaabbbaababaaaaaaabbbbbaaaaabaababbabababbabbbbabbbaabbabbbabaabbaabbaaaaaab\n", "output": "502032780\n"}, {"input": "abaaaaaabaaaabbabbaaabbababababaaaaabbaabbaaaaabbbaababaaaaaaabbbbbaaaaabbababbabababbabbbbabbbaabbabbbabaabbaabbaaaaaab\n", "output": "366132879\...
code_stdio
[ { "content": "Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L.\nShe will concatenate all of the strings in some order, to produce a long string.\nAmong all strings that she can produce in this way, find the lexicographically smallest one.\nHere, a string s=s_1s_2s_3...s_n is...
[{"input": "3 3\ndxx\naxx\ncxx\n", "output": "axxcxxdxx\n"}, {"input": "3 3\ndxx\naxx\ndxx", "output": "axxdxxdxx\n"}, {"input": "3 3\ndxx\naxx\nxxd", "output": "axxdxxxxd\n"}, {"input": "3 3\ndxx\nxxa\nxxd", "output": "dxxxxaxxd\n"}, {"input": "3 3\ncxx\nxxa\nxxd", "output": "cxxxxaxxd\n"}, {"input": "3 3\ndxx\n`xx\nc...
code_stdio
[ { "content": "Suppose there is a $h \\times w$ grid consisting of empty or full cells. Let's make some definitions:\n\n $r_{i}$ is the number of consecutive full cells connected to the left side in the $i$-th row ($1 \\le i \\le h$). In particular, $r_i=0$ if the leftmost cell of the $i$-th row is empty. $c_{...
[{"input": "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 12 16 10 11 15 4\n", "output": "974740338\n"}, {"input": "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4\n", "output": "797922655\n"}, {"input": "19 16\n16 16 16 16 15 15 0 5 0 4 ...
code_stdio
[ { "content": "In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets.\n\nWrite a program which reads an integer x and print it as is. Note that mu...
[{"input": "3\n14\n11\n14\n2\n58\n0", "output": "Case 1: 3\nCase 2: 14\nCase 3: 11\nCase 4: 14\nCase 5: 2\nCase 6: 58\n"}, {"input": "3\n5\n11\n14\n26\n34\n0", "output": "Case 1: 3\nCase 2: 5\nCase 3: 11\nCase 4: 14\nCase 5: 26\nCase 6: 34\n"}, {"input": "3\n14\n15\n14\n2\n58\n0", "output": "Case 1: 3\nCase 2: 14\nCase...
code_stdio
[ { "content": "You have a statistic of price changes for one product represented as an array of $n$ positive integers $p_0, p_1, \\dots, p_{n - 1}$, where $p_0$ is the initial price of the product and $p_i$ is how the price was increased during the $i$-th month.\n\nUsing these price changes you are asked to calc...
[{"input": "2\n4 1\n20100 1 202 525\n3 101\n1 0 1\n", "output": "32197\n0\n"}, {"input": "2\n4 1\n20100 1 182 525\n3 101\n1 0 1\n", "output": "32217\n0\n"}, {"input": "2\n4 1\n33029 1 202 525\n3 101\n1 0 1\n", "output": "19268\n0\n"}, {"input": "2\n4 1\n20100 1 182 649\n3 101\n1 0 1\n", "output": "44617\n0\n"}, {"input...
code_stdio
[ { "content": "<image> <image>\n\n*The two images are equivalent, feel free to use either one.\n\nInput\n\nThe input contains a single integer a (-100 ≤ a ≤ 100).\n\nOutput\n\nOutput the result – an integer number.\n\nExample\n\nInput\n\n\n1\n\n\nOutput\n\n\n1\n\nWrite Python code to solve this problem. Your pro...
[{"input": "-1079\n", "output": "-1164239\n"}, {"input": "-340\n", "output": "-115598\n"}, {"input": "-449\n", "output": "-201599\n"}, {"input": "-685\n", "output": "-469223\n"}, {"input": "-432\n", "output": "-186622\n"}, {"input": "-346\n", "output": "-119714\n"}, {"input": "-410\n", "output": "-168098\n"}, {"input":...
code_stdio
[ { "content": "There are S sheep and W wolves.\nIf the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep.\nIf the wolves will attack the sheep, print unsafe; otherwise, print safe.\n\n-----Constraints-----\n - 1 \\leq S \\leq 100\n - 1 \\leq W \\leq 100\n\n-----Input---...
[{"input": "100 100\n", "output": "unsafe\n"}, {"input": "10 10\n", "output": "unsafe\n"}, {"input": "99 99\n", "output": "unsafe\n"}, {"input": "74 74\n", "output": "unsafe\n"}, {"input": "63 64\n", "output": "unsafe\n"}, {"input": "1 100\n", "output": "unsafe\n"}, {"input": "-1 -1", "output": "unsafe\n"}, {"input": "...
code_stdio
[ { "content": "In a very ancient country the following game was popular. Two people play the game. Initially first player writes a string s1, consisting of exactly nine digits and representing a number that does not exceed a. After that second player looks at s1 and writes a string s2, consisting of exactly nine...
[{"input": "1000000000 100050 1000001\n", "output": "1 000000101\n"}, {"input": "702034015 6007275 9777625\n", "output": "1 000000001\n"}, {"input": "123456789 1234561 1234567\n", "output": "1 000549636\n"}, {"input": "972037745 4602117 5090186\n", "output": "1 000000011\n"}, {"input": "585173560 4799128 5611727\n", "o...
code_stdio
[ { "content": "Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had.\n\nConstraints\n\n* 1 \\leq N \\leq 10^5\n* 0 \\leq K \\leq N-1\n*...
[{"input": "38823 9265", "output": "550080294\n"}, {"input": "11695 7143", "output": "10362628\n"}, {"input": "31415 9265", "output": "287927211"}, {"input": "11695 9265", "output": "2953665\n"}, {"input": "11695 8033", "output": "6706953\n"}, {"input": "3903 337", "output": "10168461\n"}, {"input": "4275 337", "output...
code_stdio
[ { "content": "Food contains three nutrients called \"protein\", \"fat\" and \"carbohydrate\", which are called three major nutrients. It is calculated that protein and carbohydrate are 4 kcal (kilocalories) and fat is 9 kcal per 1 g (gram). For example, according to the table below, the number 1 cake contains 7...
[{"input": "4\n1 7 14 47\n2 5 35 55\n3 6 3 59\n4 6 5 15\n10 15 50 110\n2\n1 8 10 116\n-1 4 18 33\n10 10 50 300\n0", "output": "NA\nNA\n"}, {"input": "4\n1 7 14 47\n2 5 35 55\n3 6 3 59\n4 6 5 15\n10 15 50 110\n2\n1 8 10 116\n0 4 18 33\n10 10 50 300\n0", "output": "NA\nNA\n"}, {"input": "4\n1 7 14 47\n2 5 35 55\n3 6 3 59...
code_stdio
[ { "content": "Andrew, Fedor and Alex are inventive guys. Now they invent the game with strings for two players.\n\nGiven a group of n non-empty strings. During the game two players build the word together, initially the word is empty. The players move in turns. On his step player must add a single letter in the...
[{"input": "5 6\nabas\ndsfdf\nabacaba\ndartsidius\nkolobok\n", "output": "Second\n"}, {"input": "5 6\nabas\ndsfdf\nabacaba\ndartsidius\nkolobok\n", "output": "Second\n"}, {"input": "5 6\nabas\ndsfdf\nabacaba\ndartsidius\nkobolok\n", "output": "Second\n"}, {"input": "5 6\nabas\ndsfdf\nabacaba\ndadtsirius\nkolobok\n", "o...
code_stdio
[ { "content": "I'm traveling to a country with a rabbit. There are n cities in this country numbered from 1 to n, and the rabbit is now in city 1. City i is a point on the coordinate plane (xi, yi) ).\n\nRabbits travel to meet the following conditions.\n\n* The travel path is a polygonal line, each part of which...
[{"input": "5\n101.13623414746552 91.04161232454778\n1 -1\n1 10\n0 3\n19 -1\n20 7", "output": "9\n"}, {"input": "5\n100.60853142327974 90.65666260699702\n1 0\n1 10\n8 3\n10 -1\n12 10", "output": "2\n"}, {"input": "5\n100.60853142327974 90.65666260699702\n1 0\n1 10\n8 3\n19 -1\n12 10", "output": "3\n"}, {"input": "5\n10...
code_stdio
[ { "content": "Numbers of black and white points are placed on a plane. Let's imagine that a straight line of infinite length is drawn on the plane. When the line does not meet any of the points, the line divides these points into two groups. If the division by such a line results in one group consisting only of...
[{"input": "3 3\n100 700\n200 200\n600 600\n500 100\n605 300\n800 578\n3 3\n100 300\n400 600\n400 100\n600 400\n500 900\n300 300\n3 4\n300 300\n935 300\n400 600\n100 100\n200 900\n500 900\n158 110\n1 2\n300 300\n100 100\n500 500\n1 1\n100 100\n200 100\n2 2\n0 0\n500 700\n1000 1400\n1500 2100\n2 2\n0 0\n1000 1000\n1010 ...
code_stdio
[ { "content": "Consider a tic-tac-toe on a 3x3 board. Tic-tac-toe is a two-player battle game. Decide the first attack and the second attack, one hits Kuroishi and one hits Shiraishi. The winner is the person who puts stones one by one on the board alternately and arranges three of his own stones first in either...
[{"input": "bbw\nbww\n+b+\nbwb\nwbx\nwbw\n0", "output": "NA\nNA\n"}, {"input": "caw\nwbw\n+b+\nbwb\nwxb\nwbw\n0", "output": "NA\nNA\n"}, {"input": "bbw\nbww\n+b+\nbwb\nwbx\nwbv\n0", "output": "NA\nNA\n"}, {"input": "cbw\nbww\n+b+\nbwb\nwbx\nwbw\n0", "output": "NA\nNA\n"}, {"input": "caw\nwbw\n+b+\nbwb\nwxb\nwbv\n0", "o...
code_stdio
[ { "content": "Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes.\n\nThe exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the...
[{"input": "10\n3 5 1 3\n0 0 1\n2 1 4\n2 5 2 3\n1 0\n3 2\n1 20 2 4\n0\n16\n6 20 2 5\n1 1 0 1 0 0\n0 8 2 9 11 6\n4 12 3 6\n1 0 1 1\n8 3 5 6\n6 20 3 12\n0 1 0 0 1 0\n20 11 3 20 16 17\n7 17 1 6\n1 1 0 1 0 0 0\n1 8 0 11 15 15 10\n6 17 2 6\n0 0 1 0 0 1\n7 11 2 7 10 12\n5 17 2 5\n1 1 1 1 0\n17 11 10 6 4\n1 1 1 2\n0\n1\n", "o...
code_stdio
[ { "content": "\"Hey, it's homework time\" — thought Polycarpus and of course he started with his favourite subject, IT. Polycarpus managed to solve all tasks but for the last one in 20 minutes. However, as he failed to solve the last task after some considerable time, the boy asked you to help him.\n\nThe seque...
[{"input": "100\n340 14 3275 2283 2673 1107 817 2243 1226 32 2382 3638 4652 418 68 4962 387 764 4647 159 1846 225 2760 4904 3150 403 3 2439 91 4428 92 4705 75 348 1566 1465 69 6 49 4 62 4643 564 1090 3447 1871 2255 139 24 99 2669 969 86 61 4550 158 4537 3993 1589 872 2907 1888 401 80 1825 1483 63 1 2264 4068 4113 2548 ...
code_stdio
[ { "content": "Vasya is reading a e-book. The file of the book consists of $n$ pages, numbered from $1$ to $n$. The screen is currently displaying the contents of page $x$, and Vasya wants to read the page $y$. There are two buttons on the book which allow Vasya to scroll $d$ pages forwards or backwards (but he ...
[{"input": "5\n20 10 2 9\n1000000000 2 89 4\n1000000000 2 89 8\n1000000000 142 1 1000000000\n1000000000 1000000000 4 3\n", "output": "4\n23\n12\n1\n333333332\n"}, {"input": "5\n20 10 2 9\n1000000000 2 89 4\n1000000000 2 89 5\n1000000000 142 1 1000000000\n1000000000 1000000000 4 3\n", "output": "4\n23\n-1\n1\n333333332\...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian. \n\nChef loves to prepare delicious dishes. This time, Chef has decided to prepare a special dish for you, and needs to gather several apples to do so.\n\nChef has N apple trees in his home garden. Each tree has a certain (non-zero) number...
[{"input": "2\n3\n3 14 3\n4\n1 2 3 3", "output": "2\n3\n"}, {"input": "2\n3\n1 14 3\n4\n1 2 3 3", "output": "3\n3\n"}, {"input": "2\n2\n3 3 1\n4\n1 12 3 3", "output": "2\n3\n"}, {"input": "2\n3\n6 14 3\n4\n1 2 3 3", "output": "3\n3\n"}, {"input": "2\n3\n1 14 3\n4\n1 2 3 2", "output": "3\n3\n"}, {"input": "2\n3\n3 3 3\n...
code_stdio
[ { "content": "Leha plays a computer game, where is on each level is given a connected graph with n vertices and m edges. Graph can contain multiple edges, but can not contain self loops. Each vertex has an integer d_{i}, which can be equal to 0, 1 or - 1. To pass the level, he needs to find a «good» subset of ...
[{"input": "10 10\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1\n6 7\n8 3\n6 4\n4 2\n9 1\n5 10\n9 8\n10 7\n5 1\n6 2\n", "output": "0\n\n"}, {"input": "10 10\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1\n6 7\n8 3\n4 4\n4 2\n9 1\n5 10\n9 8\n10 7\n5 1\n6 2\n", "output": "0\n\n"}, {"input": "10 10\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1\n6 7\n8 3\n6 4\n4 2\n9 ...
code_stdio
[ { "content": "We define $x \\bmod y$ as the remainder of division of $x$ by $y$ ($\\%$ operator in C++ or Java, mod operator in Pascal).\n\nLet's call an array of positive integers $[a_1, a_2, \\dots, a_k]$ stable if for every permutation $p$ of integers from $1$ to $k$, and for every non-negative integer $x$, ...
[{"input": "500000 250000\n", "output": "803991687\n"}, {"input": "500000 250000\n", "output": "803991687\n"}, {"input": "500000 471528\n", "output": "588862109\n"}, {"input": "500000 121854\n", "output": "377057930\n"}, {"input": "123456 78901\n", "output": "963821949\n"}, {"input": "123456 78901\n", "output": "963821...
code_stdio
[ { "content": "Some programming contest problems are really tricky: not only do they\nrequire a different output format from what you might have expected, but\nalso the sample output does not show the difference. For an example,\nlet us look at permutations.\n\nA permutation of the integers 1 to n is an\norderin...
[{"input": "4\n-2 1 2 4\n5\n-1 3 0 3 0\n1\n1\n0", "output": "not ambiguous\nnot ambiguous\nambiguous\n"}, {"input": "4\n-1 4 2 4\n5\n0 3 4 3 0\n1\n1\n0", "output": "not ambiguous\nnot ambiguous\nambiguous\n"}, {"input": "4\n-1 4 2 1\n5\n0 3 4 3 0\n1\n1\n0", "output": "not ambiguous\nnot ambiguous\nambiguous\n"}, {"inpu...
code_stdio
[ { "content": "There are n boys and m girls attending a theatre club. To set a play \"The Big Bang Theory\", they need to choose a group containing exactly t actors containing no less than 4 boys and no less than one girl. How many ways are there to choose a group? Of course, the variants that only differ in the...
[{"input": "30 30 30\n", "output": "118264581548187697"}, {"input": "30 29 19\n", "output": "1396982287132530\n"}, {"input": "30 30 19\n", "output": "2044156982307300\n"}, {"input": "30 29 42\n", "output": "277508869722315\n"}, {"input": "21 30 30\n", "output": "114456652814979\n"}, {"input": "30 30 44\n", "output": "1...
code_stdio
[ { "content": "There is a special offer in Vasya's favourite supermarket: if the customer buys $a$ chocolate bars, he or she may take $b$ additional bars for free. This special offer can be used any number of times.\n\nVasya currently has $s$ roubles, and he wants to get as many chocolate bars for free. Each cho...
[{"input": "16\n1 1 1 1\n1 1 1 1000000000\n1 1 1000000000 1\n1 1 1000000000 1000000000\n1 1000000000 1 1\n1 1000000000 1 1000000000\n1 1000000000 1000000000 1\n1 1000000000 1000000000 1000000000\n1000000000 1 1 1\n1000000000 1 1 1000000000\n1000000000 1 1000000000 1\n1000000000 1 1000000000 1000000000\n1000000000 10000...
code_stdio
[ { "content": "There is a bar of chocolate with a height of H blocks and a width of W blocks.\nSnuke is dividing this bar into exactly three pieces.\nHe can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle.\nSnuke is trying to divide the bar as evenly as possible.\nMore s...
[{"input": "100000 100000\n", "output": "50000\n"}, {"input": "100100 100000", "output": "50000\n"}, {"input": "100100 110000", "output": "50050\n"}, {"input": "100111 100001", "output": "83371\n"}, {"input": "100100 100010", "output": "50005\n"}, {"input": "110111 100001", "output": "86704\n"}, {"input": "101111 01000...
code_stdio
[ { "content": "Tattah is asleep if and only if Tattah is attending a lecture. This is a well-known formula among Tattah's colleagues.\n\nOn a Wednesday afternoon, Tattah was attending Professor HH's lecture. At 12:21, right before falling asleep, he was staring at the digital watch around Saher's wrist. He notic...
[{"input": "04:50\n", "output": "05:50\n"}, {"input": "02:17\n", "output": "02:20\n"}, {"input": "12:14\n", "output": "12:21\n"}, {"input": "03:44\n", "output": "04:40\n"}, {"input": "00:17\n", "output": "01:10\n"}, {"input": "15:51\n", "output": "20:02\n"}, {"input": "23:31\n", "output": "23:32\n"}, {"input": "07:56\n...
code_stdio
[ { "content": "J: City\n\nSanta decides to deliver a present to a city.\n\nThe city has a rectangular shape divided into north-south $ H $ parcels x east-west $ W $ parcels, with one house delivering gifts to each parcel.\n\nThe $ X $ th section from the north and the $ Y $ th section from the west are represent...
[{"input": "2 -2 11 0", "output": "Yes\n"}, {"input": "0 -1 12 1", "output": "Yes\n"}, {"input": "-1 2 0 14", "output": "Yes\n"}, {"input": "0 -1 1 11", "output": "Yes\n"}, {"input": "1 -2 11 0", "output": "Yes\n"}, {"input": "3 1 2 12", "output": "Yes\n"}, {"input": "2 2 0 14", "output": "Yes\n"}, {"input": "0 2 0 14"...
code_stdio
[ { "content": "Vasya plays the LionAge II. He was bored of playing with a stupid computer, so he installed this popular MMORPG, to fight with his friends. Vasya came up with the name of his character — non-empty string s, consisting of a lowercase Latin letters. However, in order not to put up a front of friends...
[{"input": "emrvvhupytoxzhqxmuop 1\n49\ng g -558\nd g 845\nd k -745\nb g -773\nf f -733\nb s -491\na s -894\ng d -565\ns k -756\nb a 373\nb d 398\nk f 250\na b 531\nf g -27\nf b 125\na g -555\ns f 540\ng b 194\nk s -636\ns b -955\nd a -520\ng f -97\nf s -204\ns a 171\nb k -304\ns g -160\na a -567\na f -455\nd d -571\nd...
code_stdio
[ { "content": "Find the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\n-----Constraints-----\n - 2 \\leq K \\leq 10^5\n - K is an integer.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nK\n\n-----Output-----\nPrint the smallest possib...
[{"input": "79992\n", "output": "36\n"}, {"input": "10989", "output": "27\n"}, {"input": "37450", "output": "3\n"}, {"input": "70620", "output": "6\n"}, {"input": "11849", "output": "5\n"}, {"input": "48730", "output": "4\n"}, {"input": "45794", "output": "3\n"}, {"input": "34375", "output": "2\n"}, {"input": "31041", ...
code_stdio
[ { "content": "Problem Statement\n\nThe Animal School is a primary school for animal children. You are a fox attending this school.\n\nOne day, you are given a problem called \"Arithmetical Restorations\" from the rabbit teacher, Hanako. Arithmetical Restorations are the problems like the following:\n\n* You are...
[{"input": "3?4\n?21\n5?5\n14??\n?7?5\n3?9?\n?????\n?????\n?????\n0", "output": "10\n100\n200039979\n"}, {"input": "3?5\n1?1\n5?6\n41??\n5?7?\n9??2\n?????\n?????\n?????\n0", "output": "45\n823\n200039979\n"}, {"input": "3?5\n1?1\n5?6\n41??\n5?6?\n9??2\n?????\n?????\n?????\n0", "output": "45\n833\n200039979\n"}, {"input...
code_stdio
[ { "content": "There are N positive integers written on a blackboard: A_1, ..., A_N.\nSnuke can perform the following operation when all integers on the blackboard are even:\n - Replace each integer X on the blackboard by X divided by 2.\nFind the maximum possible number of operations that Snuke can perform.\n\n...
[{"input": "6\n382253568 723152896 37802240 379425024 404894720 471526144\n", "output": "8\n"}, {"input": "6\n348324507 1154626501 32183854 379425024 590201381 471526144", "output": "0\n"}, {"input": "6\n586050932 1154626501 32183854 379425024 590201381 471526144", "output": "0\n"}, {"input": "6\n586050932 1154626501 3...
code_stdio
[ { "content": "There are n integers b_1, b_2, ..., b_{n} written in a row. For all i from 1 to n, values a_{i} are defined by the crows performing the following procedure:\n\n The crow sets a_{i} initially 0. The crow then adds b_{i} to a_{i}, subtracts b_{i} + 1, adds the b_{i} + 2 number, and so on until the...
[{"input": "10\n-38980 0001000000 -1000000000 1000000000 -1000000000 1000010010 -1000000000 1010000010 -1556535198 1000000000\n", "output": "961020 -999000000 0 0 10010 10010 10000010 -546535188 -556535198 1000000000\n"}, {"input": "10\n-38980 0001000000 -1000000000 1000000000 -1000000000 1000010011 -1000000000 1010000...
code_stdio
[ { "content": "Let's call (yet again) a string good if its length is even, and every character in odd position of this string is different from the next character (the first character is different from the second, the third is different from the fourth, and so on). For example, the strings good, string and xyyx ...
[{"input": "100\nababbaaabaaabaabbabbaaabbabaaabbbabbbbbbbbababbbbbabbaaaabbbabbaababaabaababbbabababbbababbbbaabbbba\n", "output": "34\nababbaabababbabaabbabaabbababababaabbabaabababababbabababababaabba\n"}, {"input": "100\nabbbbaabbbbababbbabababbbabaabaababaabbabbbaaaabbabbbbbababbbbbbbbabbbaaababbaaabbabbaabaaabaaa...
code_stdio
[ { "content": "You are given two polynomials:\n\n * P(x) = a0·xn + a1·xn - 1 + ... + an - 1·x + an and \n * Q(x) = b0·xm + b1·xm - 1 + ... + bm - 1·x + bm. \n\n\n\nCalculate limit <image>.\n\nInput\n\nThe first line contains two space-separated integers n and m (0 ≤ n, m ≤ 100) — degrees of polynomials P(x) an...
[{"input": "69 69\n-7 38 -3 -22 65 -78 -65 -99 -76 63 0 -4 -78 -51 54 -61 -53 60 80 34 -96 162 -78 -96 21 -10 -86 33 -9 -81 -19 -2 -76 -3 -66 -80 -55 -21 -50 37 -86 -37 47 44 76 -39 54 -25 41 -86 -3 -25 -67 94 18 67 27 -5 -30 -69 2 -76 7 -97 -52 -35 -55 -20 92 2\n90 -94 37 41 -27 -54 96 -15 -60 -29 -75 -93 -57 62 7 -88...
code_stdio
[ { "content": "You have a fence consisting of $n$ vertical boards. The width of each board is $1$. The height of the $i$-th board is $a_i$. You think that the fence is great if there is no pair of adjacent boards having the same height. More formally, the fence is great if and only if for all indices from $2$ to...
[{"input": "3\n3\n3 4\n2 1\n3 7\n3\n2 3\n2 2\n2 0\n4\n1 7\n12 2\n2 15\n1000000000 8\n", "output": "0\n2\n0\n"}, {"input": "3\n3\n3 4\n2 1\n3 4\n3\n2 3\n2 2\n2 0\n4\n1 7\n12 2\n2 15\n1000000000 8\n", "output": "0\n2\n0\n"}, {"input": "3\n3\n3 4\n2 1\n3 7\n3\n2 3\n2 2\n2 0\n4\n1 7\n12 2\n3 15\n1000000000 8\n", "output": ...
code_stdio