messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
1 value
[ { "content": "There are $n$ candy boxes in front of Tania. The boxes are arranged in a row from left to right, numbered from $1$ to $n$. The $i$-th box contains $r_i$ candies, candies have the color $c_i$ (the color can take one of three values ​​— red, green, or blue). All candies inside a single box have the ...
[{"input": "50 49 1000\n30 37 34 31 26 44 32 12 36 15 5 5 31 24 17 24 43 19 17 23 45 2 24 17 23 48 20 44 46 44 13 4 29 49 33 41 14 25 46 43 7 47 28 25 2 30 37 37 19 32\nGBBBRBGRBRBRGRGRBBGBGRRBGGRBGRBRRRRRRRBRGRGGGGBRGG\n", "output": "-1\n"}, {"input": "50 37 500\n25 43 15 16 29 23 46 18 15 21 33 26 38 25 2 17 48 50 33...
code_stdio
[ { "content": "If you visit Aizu Akabeko shrine, you will find a unique paper fortune on which a number with more than one digit is written.\n\nEach digit ranges from 1 to 9 (zero is avoided because it is considered a bad omen in this shrine). Using this string of numeric values, you can predict how many years i...
[{"input": "167918384", "output": "8\n"}, {"input": "177127860", "output": "8\n"}, {"input": "16612328", "output": "7\n"}, {"input": "23422731", "output": "6\n"}, {"input": "32523857", "output": "6\n"}, {"input": "14513597", "output": "8\n"}, {"input": "15282598", "output": "8\n"}, {"input": "12659326", "output": "8\n"...
code_stdio
[ { "content": "Arkady decides to observe a river for n consecutive days. The river's water level on each day is equal to some real value.\n\nArkady goes to the riverside each day and makes a mark on the side of the channel at the height of the water level, but if it coincides with a mark made before, no new mark...
[{"input": "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 14 5 8 28 29 30 31 31 31 0 3 15 31 8 33 6 35 35 35 36 71 37 37 38 39 28 0 2 23 41 9 9 0 6 25 41 41 12 42 43 43 36 44 51 11 43 4\n", "output": "2658\n"}, {"input": "100\n0 1...
code_stdio
[ { "content": "You are given an array $a_1, a_2, \\dots, a_n$. You can perform the following operation any number of times: Choose a pair of two neighboring equal elements $a_i = a_{i + 1}$ (if there is at least one such pair). Replace them by one element with value $a_i + 1$. \n\nAfter each such operation, th...
[{"input": "50\n1 1 1 1 1 2 1 1 2 1 2 1 1 1 2 1 1 1 2 2 2 1 1 2 2 1 2 1 1 2 2 1 1 2 2 1 1 1 1 1 2 2 2 2 2 1 2 2 2 1\n", "output": "19\n"}, {"input": "50\n1 1 1 1 1 2 1 1 2 1 2 1 1 1 2 1 1 1 2 2 2 1 1 2 2 1 2 1 1 2 2 1 1 2 2 1 1 1 1 1 2 2 2 2 2 1 2 2 2 1\n", "output": "19\n"}, {"input": "50\n1 1 1 1 1 2 1 1 2 1 4 1 1 1 ...
code_stdio
[ { "content": "There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins.\n\nSnuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get t...
[{"input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n"...
code_stdio
[ { "content": "When little Petya grew up and entered the university, he started to take part in АБМ contests. Later he realized that he doesn't like how the АБМ contests are organised: the team could only have three members (and he couldn't take all his friends to the competitions and distribute the tasks betwee...
[{"input": "16 25\nbBZ\nEr\nZ\nrYJmfZLgmx\nPaJNrF\naHtRqSxOO\nD\nhsagsG\nMDuBOXrmWH\nSgjMQZ\nYXgWq\nxDwpppG\nSDY\nJwZWx\ncOzrgrBaE\nFJYX\nYXgWq SgjMQZ\nSDY PaJNrF\nFJYX rYJmfZLgmx\nhsagsG Er\nxDwpppG rYJmfZLgmx\naHtRqSxOO rYJmfZLgmx\nhsagsG bBZ\nJwZWx hsagsG\nFJYX cOzrgrBaE\nSDY YXgWq\nFJYX Z\nJwZWx rYJmfZLgmx\nD rYJmf...
code_stdio
[ { "content": "Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive).\nThere are K^N such sequences. Find the sum of \\gcd(A_1, ..., A_N) over all of them.\nSince this sum can be enormous, print the value modulo (10^9+7).\nHere \\gcd(A_1, ..., A_N) denotes the greate...
[{"input": "100000 100000\n", "output": "742202979\n"}, {"input": "101000 100000", "output": "817082185\n"}, {"input": "101010 100000", "output": "781111243\n"}, {"input": "99991 99989\n", "output": "215961669\n"}, {"input": "23857 50338\n", "output": "123598436\n"}, {"input": "86918 71567\n", "output": "531753154\n"},...
code_stdio
[ { "content": "We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i.\nFor each k=1, ..., N, solve the problem below:\n - Consider writing a number on each vertex in the tree in the following manner:\n - First, write 1 on Vertex k.\n - Then, for each of the number...
[{"input": "8\n1 3\n2 3\n3 4\n3 5\n3 6\n6 7\n6 8", "output": "240\n240\n1680\n240\n240\n1008\n144\n144\n"}, {"input": "8\n1 3\n2 3\n5 4\n3 5\n3 6\n3 7\n3 8", "output": "360\n360\n2520\n120\n840\n360\n360\n360\n"}, {"input": "8\n1 2\n2 3\n2 4\n3 5\n2 6\n6 7\n2 8", "output": "180\n1260\n420\n180\n60\n420\n60\n180\n"}, {"...
code_stdio
[ { "content": "Every summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge wart. Every grandma knows that one should treat warts when the moon goes down. Thus, Vitya has to catch the moment when the moon is down.\n\nMoon cycle lasts 30 days. The size of the visible part of th...
[{"input": "92\n13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12\n", "output": "DOWN\n"}, {"input": "92\n14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 ...
code_stdio
[ { "content": "Two polar bears Menshykov and Uslada from the St.Petersburg zoo and elephant Horace from the Kiev zoo got six sticks to play with and assess the animals' creativity. Menshykov, Uslada and Horace decided to make either an elephant or a bear from those sticks. They can make an animal from sticks in ...
[{"input": "5 5 5 5 5 5\n", "output": "Elephant\n"}, {"input": "4 4 4 4 2 2\n", "output": "Elephant\n"}, {"input": "4 4 2 2 2 2\n", "output": "Elephant\n"}, {"input": "1 1 2 2 2 2\n", "output": "Elephant\n"}, {"input": "1 1 1 1 1 1\n", "output": "Elephant\n"}, {"input": "2 2 4 4 4 4\n", "output": "Elephant\n"}, {"input...
code_stdio
[ { "content": "The Cybermen and the Daleks have long been the Doctor's main enemies. Everyone knows that both these species enjoy destroying everything they encounter. However, a little-known fact about them is that they both also love taking Turing tests!\n\nHeidi designed a series of increasingly difficult tas...
[{"input": "10\n11 11\n11 12\n11 15\n11 17\n11 18\n11 19\n11 28\n11 33\n11 38\n11 40\n12 11\n15 46\n17 11\n17 46\n18 46\n19 11\n19 46\n20 11\n20 46\n24 46\n25 46\n26 11\n32 11\n32 46\n33 11\n34 46\n36 11\n39 11\n40 46\n43 11\n44 0\n46 14\n46 15\n46 17\n46 22\n46 26\n46 28\n46 32\n46 43\n46 45\n46 46\n", "output": "44 0...
code_stdio
[ { "content": "Jerry is a little mouse. He is trying to survive from the cat Tom. Jerry is carrying a parallelepiped-like piece of cheese of size A Γ— B Γ— C. It is necessary to trail this cheese to the Jerry's house. There are several entrances in the Jerry's house. Each entrance is a rounded hole having its own ...
[{"input": "10 7 12\n5\n1\n-1\n19\n2\n10\n0 0 0", "output": "NA\nNA\nOK\nNA\nOK\n"}, {"input": "10 7 12\n5\n1\n-1\n11\n2\n5\n0 0 0", "output": "NA\nNA\nOK\nNA\nNA\n"}, {"input": "10 6 8\n5\n1\n-1\n-1\n-1\n6\n0 0 0", "output": "NA\nNA\nNA\nNA\nOK\n"}, {"input": "10 7 12\n5\n1\n-1\n19\n2\n5\n0 0 0", "output": "NA\nNA\nOK...
code_stdio
[ { "content": "Casimir has a string $s$ which consists of capital Latin letters 'A', 'B', and 'C' only. Each turn he can choose to do one of the two following actions:\n\nhe can either erase exactly one letter 'A' and exactly one letter 'B' from arbitrary places of the string (these letters don't have to be adja...
[{"input": "6\nABABAB\nABBA\nBC\nABC\nCABBCB\nBBCBCBCBCBCCCBCB\n", "output": "YES\nYES\nYES\nNO\nYES\nYES\n"}, {"input": "6\nBBAACB\nABBA\nBC\nABA\nACBCBB\nCBCBCBCBCBCBCBCB\n", "output": "YES\nYES\nYES\nNO\nYES\nYES\n"}, {"input": "6\nABACAB\nABBA\nBC\nABB\nCABCBB\nCBCBCBCBCBCBCBCB\n", "output": "NO\nYES\nYES\nNO\nYES\...
code_stdio
[ { "content": "Snuke found a random number generator. It generates an integer between 0 and 2^N-1 (inclusive). An integer sequence A_0, A_1, \\cdots, A_{2^N-1} represents the probability that each of these integers is generated. The integer i (0 \\leq i \\leq 2^N-1) is generated with probability A_i / S, where S...
[{"input": "4\n337 780 799 18 796 875 331 223 1804 67 268 483 390 565 116 355", "output": "0\n870892872\n738673049\n866136893\n809360917\n134965576\n496873404\n200938352\n392063026\n225113281\n769068776\n945265000\n612087551\n845908556\n726467732\n606029955\n"}, {"input": "4\n337 780 799 10 796 875 331 223 1804 67 268 ...
code_stdio
[ { "content": "Mole is hungry again. He found one ant colony, consisting of n ants, ordered in a row. Each ant i (1 ≀ i ≀ n) has a strength si.\n\nIn order to make his dinner more interesting, Mole organizes a version of Β«Hunger GamesΒ» for the ants. He chooses two numbers l and r (1 ≀ l ≀ r ≀ n) and each pair of...
[{"input": "5\n1 5 2 4 2\n4\n1 5\n2 5\n3 5\n4 5\n", "output": "4\n4\n1\n1\n"}, {"input": "5\n1 3 4 4 2\n4\n1 5\n2 5\n3 5\n4 5\n", "output": "4\n4\n2\n1\n"}, {"input": "5\n1 3 4 4 2\n4\n1 5\n2 5\n3 5\n2 5\n", "output": "4\n4\n2\n4\n"}, {"input": "5\n1 3 4 4 2\n4\n1 5\n2 5\n1 5\n4 5\n", "output": "4\n4\n4\n1\n"}, {"input...
code_stdio
[ { "content": "Little Elephant is playing a game with arrays. He is given an array A0, A1, ..., ANβˆ’1 of N integers. And then Q queries are given, each containing an integer K. He has to tell how many subarrays satisfy the condition: the function foo returns K when it is applied to the subarray.\n\nIn this proble...
[{"input": "5\n4 1 1 6 4\n4\n1\n0\n1\n-1", "output": "11\n0\n11\n0\n"}, {"input": "5\n4 1 1 6 4\n4\n0\n5\n1\n-1", "output": "0\n0\n11\n0\n"}, {"input": "5\n4 -1 -1 0 0\n4\n6\n4\n2\n0", "output": "0\n1\n0\n3\n"}, {"input": "5\n3 0 3 0 10\n4\n0\n4\n6\n1", "output": "12\n0\n0\n0\n"}, {"input": "5\n4 -1 -1 0 0\n4\n6\n4\n4\...
code_stdio
[ { "content": "Silver Fox is fighting with N monsters.\nThe monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the health of H_i.\nSilver Fox can use bombs to attack the monsters.\nUsing a bomb at the coordinate x decrease...
[{"input": "3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n", "output": "3000000000\n"}, {"input": "3 -1 2\n156828556 1001000000\n100000000 1000101000\n114627287 1001010011", "output": "1501055506\n"}, {"input": "3 -1 2\n156828556 1001000000\n100000000 1000101000\n114627287 0001010011", "outpu...
code_stdio
[ { "content": "Nauuo is a girl who loves drawing circles.\n\nOne day she has drawn a circle and wanted to draw a tree on it.\n\nThe tree is a connected undirected graph consisting of n nodes and n-1 edges. The nodes are numbered from 1 to n.\n\nNauuo wants to draw a tree on the circle, the nodes of the tree shou...
[{"input": "10\n5 4\n5 2\n3 7\n9 3\n3 2\n3 1\n3 8\n9 10\n1 6\n", "output": "19200\n"}, {"input": "10\n5 4\n5 2\n3 7\n9 3\n3 2\n4 1\n3 8\n9 10\n1 6\n", "output": "7680\n"}, {"input": "10\n7 4\n5 2\n3 7\n9 3\n3 2\n4 1\n3 8\n9 10\n1 6\n", "output": "7680\n"}, {"input": "9\n5 6\n1 3\n2 3\n7 6\n4 1\n3 6\n8 1\n1 9\n", "outpu...
code_stdio
[ { "content": "Vasya’s elder brother Petya loves playing computer games. In one of his favourite computer games Petya reached the final level where a fight with the boss take place.\n\nWhile playing the game Petya found spell scrolls and now he is about to use them. Let’s describe the way fighting goes on this l...
[{"input": "70 1000 1\n91 2\n43 1\n100 1\n79 2\n26 1\n68 2\n4 2\n64 1\n100 1\n80 2\n20 2\n70 1\n25 1\n99 1\n64 1\n35 2\n60 1\n63 2\n93 1\n40 2\n100 1\n54 1\n100 1\n15 2\n72 1\n28 1\n5 1\n93 1\n100 2\n39 2\n54 2\n100 1\n55 1\n43 1\n20 1\n28 2\n21 1\n100 2\n98 1\n35 1\n12 2\n50 2\n7 2\n7 2\n12 2\n100 2\n44 1\n40 2\n56 2\...
code_stdio
[ { "content": "$n$ students attended the first meeting of the Berland SU programming course ($n$ is even). All students will be divided into two groups. Each group will be attending exactly one lesson each week during one of the five working days (Monday, Tuesday, Wednesday, Thursday and Friday), and the days ch...
[{"input": "2\n4\n1 0 0 1 0\n0 1 0 1 1\n0 0 0 1 0\n0 1 0 0 0\n2\n-1 0 0 1 0\n0 0 1 1 0\n", "output": "YES\nYES\n"}, {"input": "2\n4\n1 0 1 1 0\n1 1 0 0 1\n0 0 0 1 0\n0 1 0 1 0\n2\n-1 0 0 0 1\n0 0 0 1 0\n", "output": "YES\nYES\n"}, {"input": "2\n4\n1 0 0 1 0\n1 1 0 0 1\n0 1 0 1 0\n0 1 0 0 0\n2\n-1 1 0 0 0\n0 0 1 1 1\n",...
code_stdio
[ { "content": "Let s(x) be sum of digits in decimal representation of positive integer x. Given two integers n and m, find some positive integers a and b such that \n\n * s(a) β‰₯ n, \n * s(b) β‰₯ n, \n * s(a + b) ≀ m. \n\nInput\n\nThe only line of input contain two integers n and m (1 ≀ n, m ≀ 1129).\n\nOutput\n...
[{"input": "3963 619\n", "output": "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
code_stdio
[ { "content": "The greatest common divisor is an indispensable element in mathematics handled on a computer. Using the greatest common divisor can make a big difference in the efficiency of the calculation. One of the algorithms to find the greatest common divisor is \"Euclidean algorithm\". The flow of the proc...
[{"input": "1251 5715\n10 10\n0 0", "output": "9 6\n10 1\n"}, {"input": "1251 3144\n10 10\n0 0", "output": "3 6\n10 1\n"}, {"input": "1893 2905\n10 6\n0 0", "output": "1 11\n2 3\n"}, {"input": "1893 2905\n11 6\n0 0", "output": "1 11\n1 3\n"}, {"input": "1810 3998\n10 4\n0 0", "output": "2 10\n2 2\n"}, {"input": "1810 3...
code_stdio
[ { "content": "You are on the island which can be represented as a $n \\times m$ table. The rows are numbered from $1$ to $n$ and the columns are numbered from $1$ to $m$. There are $k$ treasures on the island, the $i$-th of them is located at the position $(r_i, c_i)$.\n\nInitially you stand at the lower left c...
[{"input": "21 3 61 3\n18 3\n21 3\n11 3\n13 2\n5 2\n14 2\n10 3\n9 3\n12 1\n1 2\n7 2\n20 1\n16 3\n18 2\n9 1\n20 3\n17 3\n6 1\n4 2\n1 1\n3 1\n4 1\n6 3\n6 2\n2 1\n13 3\n5 3\n3 2\n13 1\n10 1\n11 1\n18 1\n11 2\n5 1\n19 2\n20 2\n16 1\n12 3\n2 2\n3 3\n19 3\n8 2\n15 3\n8 1\n14 1\n17 1\n21 1\n19 1\n21 2\n12 2\n2 3\n8 3\n1 3\n16...
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": "9\nIAO'0\nIAO'00\nIAO'000\nIAO'0000\nIAO'00000\nIAO'010000\nIAO'0000000\nIAO'00000000\nIAO'000000000\n...
code_stdio
[ { "content": "Let's write all the positive integer numbers one after another from $1$ without any delimiters (i.e. as a single string). It will be the infinite sequence starting with 123456789101112131415161718192021222324252627282930313233343536...\n\nYour task is to print the $k$-th digit of this sequence.\n\...
[{"input": "1000000000000\n", "output": "1\n"}, {"input": "1009684841618\n", "output": "7\n"}, {"input": "999999999999\n", "output": "9\n"}, {"input": "134613461346\n", "output": "3\n"}, {"input": "100000000000\n", "output": "0\n"}, {"input": "100000000004\n", "output": "0\n"}, {"input": "523452345325\n", "output": "8\...
code_stdio
[ { "content": "You got a job as a marketer in a pet shop, and your current task is to boost sales of cat food. One of the strategies is to sell cans of food in packs with discounts. \n\nSuppose you decided to sell packs with $a$ cans in a pack with a discount and some customer wants to buy $x$ cans of cat food. ...
[{"input": "10\n335544320 671088640\n335544322 671088639\n335544321 671088639\n335544325 671088637\n335544319 671088640\n335544319 671088641\n335544319 671088639\n335544318 671088639\n352759476 671088637\n335544319 671088643\n", "output": "NO\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nYES\nNO\n"}, {"input": "10\n335544320 6710886...
code_stdio
[ { "content": "You are given an array $a$ consisting of $n$ non-negative integers. It is guaranteed that $a$ is sorted from small to large.\n\nFor each operation, we generate a new array $b_i=a_{i+1}-a_{i}$ for $1 \\le i < n$. Then we sort $b$ from small to large, replace $a$ with $b$, and decrease $n$ by $1$.\n...
[{"input": "1\n147\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 145 10443 49...
code_stdio
[ { "content": "Turtle Shi-ta and turtle Be-ko decided to divide a chocolate. The shape of the chocolate is rectangle. The corners of the chocolate are put on (0,0), (w,0), (w,h) and (0,h). The chocolate has lines for cutting. They cut the chocolate only along some of these lines.\n\nThe lines are expressed as fo...
[{"input": "2 3 7 10 50\n3 3\n6 6\n10 10\n4.0000000000 4.380940502722975\n7.0000000000 7.0000000000\n2 3 10 10 48\n2 3\n7 6\n10 10\n4.1530399119933294 4.124627510166318\n7.679827074828504 8.063298606739774\n2 3 10 10 30\n3 3\n6 6\n10 10\n4.0000000000 4.920930737803775\n7.0000000000 7.0000000000\n2 3 10 10 40\n3 3\n6 6\...
code_stdio
[ { "content": "On the planet Mars a year lasts exactly n days (there are no leap years on Mars). But Martians have the same weeks as earthlingsΒ β€” 5 work days and then 2 days off. Your task is to determine the minimum possible and the maximum possible number of days off per year on Mars.\n\n\n-----Input-----\n\nT...
[{"input": "1000000\n", "output": "285714 285715\n"}, {"input": "999999\n", "output": "285714 285714\n"}, {"input": "999998\n", "output": "285713 285714\n"}, {"input": "999997\n", "output": "285712 285714\n"}, {"input": "999996\n", "output": "285712 285714\n"}, {"input": "999995\n", "output": "285712 285714\n"}, {"inpu...
code_stdio
[ { "content": "Edogawa Conan got tired of solving cases, and invited his friend, Professor Agasa, over. They decided to play a game of cards. Conan has n cards, and the i-th card has a number a_{i} written on it.\n\nThey take turns playing, starting with Conan. In each turn, the player chooses a card and removes...
[{"input": "10\n38282 53699 38282 38282 38282 38282 38282 38282 38282 38282\n", "output": "Conan\n"}, {"input": "10\n50165 50165 50165 50165 50165 50165 50165 50165 50165 50165\n", "output": "Agasa\n"}, {"input": "10\n32093 36846 32093 32093 36846 36846 36846 36846 36846 36846\n", "output": "Conan\n"}, {"input": "10\n3...
code_stdio
[ { "content": "International Center for Picassonian Cubism is a Spanish national museum of cubist artworks, dedicated to Pablo Picasso. The center held a competition for an artwork that will be displayed in front of the facade of the museum building. The artwork is a collection of cubes that are piled up on the ...
[{"input": "5 5\n1 2 3 2 5\n1 2 1 4 5\n5 5\n2 3 3 1 3\n4 1 5 3 2\n5 5\n1 2 3 4 5\n3 3 1 4 5\n3 3\n7 7 7\n7 14 7\n3 3\n2 4 4\n4 3 4\n4 3\n4 0 2 5\n0 2 1\n4 4\n2 8 8 8\n2 3 8 3\n10 10\n9 9 9 9 17 9 9 17 9 9\n9 16 9 9 9 9 9 9 9 3\n10 9\n20 1 20 20 20 20 20 18 20 20\n20 20 20 20 7 17 20 20 4\n0 0", "output": "18\n21\n18\n3...
code_stdio
[ { "content": "Monocarp and Bicarp live in Berland, where every bus ticket consists of $n$ digits ($n$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even.\n\nMonocarp and Bicarp have decided ...
[{"input": "396\n???7?2675?2??52554870???512418???29?6270?638470?154?339014?59??5?3?51577??8?2???1441?86???90?7?6?472??3675?4??1920?9??6258??16362?979??707?0?05682730650?08???04005?54?355??4???530?5?1?9?84416??5???80??8102??2??8??3??868?18?304????68?91225?047175??4??8?14593???58?05661?9?0??4?8??1?47?1881???9751??68????...
code_stdio
[ { "content": "Problem\n\nYamano Mifune Gakuen's 1st grade G group is a class where female students carrying misfortune gather. They face various challenges every day with the goal of being happy.\n\nIn their class, they can take practical happiness courses as part of the test of happiness.\nFrom Monday to Frida...
[{"input": "5 10 5\n0 1 1 2\n0 2 1 2\n0 1 2 3\n1 2 0 2\n1 4 2 3\n2 1 1 1\n2 1 1 2\n3 3 2 3\n4 1 1 2\n4 2 1 2", "output": "13\n"}, {"input": "5 10 5\n0 1 1 2\n0 2 1 2\n0 1 2 3\n1 2 0 2\n1 4 2 3\n2 1 1 1\n2 1 1 2\n3 3 2 4\n4 1 1 2\n4 2 0 2", "output": "14\n"}, {"input": "5 10 5\n0 1 1 2\n0 2 1 2\n0 1 2 3\n1 2 1 2\n1 4 2 ...
code_stdio
[ { "content": "Recently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment $0$ and turn power off at moment $M$. Moreover, the lamp allows you to set a program of switching its state (states are \"lights on\" and \"...
[{"input": "7 1000000000\n1 10001 10011 20011 20021 40021 40031\n", "output": "999999969\n"}, {"input": "7 1000000000\n3 10001 10011 20011 20021 40021 40031\n", "output": "999999969\n"}, {"input": "7 1000000000\n1 10001 10011 20011 20021 40021 40031\n", "output": "999999969\n"}, {"input": "7 1000000000\n3 10001 10011 2...
code_stdio
[ { "content": "This is the easy version of the problem. The difference between the versions is that the easy version does not require you to output the numbers of the rods to be removed. You can make hacks only if all versions of the problem are solved.\n\nStitch likes experimenting with different machines with ...
[{"input": "3\n14 1\n+--++---++-++-\n1 14\n14 3\n+--++---+++---\n1 14\n6 12\n3 10\n4 10\n+-+-\n1 1\n1 2\n1 3\n1 4\n2 2\n2 3\n2 4\n3 3\n3 4\n4 4\n", "output": "2\n2\n1\n0\n1\n2\n1\n2\n1\n2\n1\n1\n2\n1\n"}, {"input": "3\n14 1\n+--++---++-++-\n1 14\n14 3\n+--++---+++---\n1 14\n7 12\n3 10\n4 10\n+-+-\n1 1\n1 2\n1 3\n1 4\n2...
code_stdio
[ { "content": "Alice and Bob play a game. There is a paper strip which is divided into n + 1 cells numbered from left to right starting from 0. There is a chip placed in the n-th cell (the last one).\n\nPlayers take turns, Alice is first. Each player during his or her turn has to move the chip 1, 2 or k cells to...
[{"input": "24\n26 13\n8 9\n2 9\n22 9\n29 5\n47 18\n9 15\n14 9\n27 9\n28 9\n35 8\n34 9\n23 6\n52 2\n1011010000 999999999\n232709804 999999999\n1011611339 999999999\n1000000100 5\n1000000000 3\n1000010010 9\n1737891047 6\n1058606099 5\n999999992 16\n974657870 9\n", "output": "Alice\nAlice\nAlice\nAlice\nAlice\nBob\nBob\...
code_stdio
[ { "content": "You went to the store, selling $n$ types of chocolates. There are $a_i$ chocolates of type $i$ in stock.\n\nYou have unlimited amount of cash (so you are not restricted by any prices) and want to buy as many chocolates as possible. However if you buy $x_i$ chocolates of type $i$ (clearly, $0 \\le ...
[{"input": "19\n11 10 2 12 1 1 9 13 8 40 16 27 18 22 33 1 14 32 12\n", "output": "34\n"}, {"input": "19\n11 10 2 12 1 1 9 13 8 40 8 27 18 22 33 1 14 32 12\n", "output": "34\n"}, {"input": "19\n11 10 6 11 2 1 6 13 8 38 8 27 9 22 18 7 14 20 12\n", "output": "61\n"}, {"input": "19\n11 10 6 12 2 1 6 13 8 38 8 27 9 22 18 1 ...
code_stdio
[ { "content": "This is the easier version of the problem. In this version $1 \\le n, m \\le 100$. You can hack this problem only if you solve and lock both problems.\n\nYou are given a sequence of integers $a=[a_1,a_2,\\dots,a_n]$ of length $n$. Its subsequence is obtained by removing zero or more elements from ...
[{"input": "5\n3 1 4 1 2\n15\n5 5\n5 4\n5 3\n5 2\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n", "output": "2\n1\n4\n1\n3\n2\n4\n1\n3\n2\n4\n3\n4\n3\n4\n"}, {"input": "5\n3 1 4 1 2\n15\n5 5\n5 4\n5 3\n5 2\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n", "output": "2\n1\n4\n1\n3\n2\n4\n1\n3\n2\n4\n3...
code_stdio
[ { "content": "One day you wanted to read something, so you went to your bookshelf to grab some book. But when you saw how messy the bookshelf was you decided to clean it up first.\n\nThere are $n$ books standing in a row on the shelf, the $i$-th book has color $a_i$.\n\nYou'd like to rearrange the books to make...
[{"input": "100\n82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 13 49 41 36 41 79 16 87 87 69 3 76 80 60 100 49 70 59 72 8 38 71 45 97 71 14 76 54 81 4 59 46 39 29 92 3 49 22 53 99 59 52 74 31 92 43 42 23 44 9 82 47 7 40 12 9 3 55 37 85 46 22 84 52 98 41 21 77 63 17 62 91\n", "output...
code_stdio
[ { "content": "Efim just received his grade for the last test. He studies in a special school and his grade can be equal to any positive decimal fraction. First he got disappointed, as he expected a way more pleasant result. Then, he developed a tricky plan. Each second, he can ask his teacher to round the grade...
[{"input": "320 142\n2704701300865535.432223312233434114130011113220102420131323010344144201124303144444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444447444444444444444444444444444444615444444482101673308979557675074444444444444446867245414595534444693160...
code_stdio
[ { "content": "You are given $a$ uppercase Latin letters 'A' and $b$ letters 'B'.\n\nThe period of the string is the smallest such positive integer $k$ that $s_i = s_{i~mod~k}$ ($0$-indexed) for each $i$. Note that this implies that $k$ won't always divide $a+b = |s|$.\n\nFor example, the period of string \"ABAA...
[{"input": "1000000000 1000000000\n", "output": "1999936805\n"}, {"input": "1000000000 1000000000\n", "output": "1999936805\n"}, {"input": "1000000000 956817411\n", "output": "1956733985\n"}, {"input": "1000000000 839933539\n", "output": "1839852485\n"}, {"input": "956817411 1000000000\n", "output": "1956733985\n"}, {"...
code_stdio
[ { "content": "You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i.\n\nYou will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W.\n\nYour objective is to maximize the total value of the selected items.\...
[{"input": "4 1\n10 100\n10 100\n10 101\n10 100", "output": "0\n"}, {"input": "4 2\n10 100\n10 100\n10 100\n10 100", "output": "0\n"}, {"input": "4 1\n10 100\n10 000\n10 101\n10 100", "output": "0\n"}, {"input": "4 2\n10 110\n10 100\n10 100\n10 100", "output": "0\n"}, {"input": "4 1\n10 100\n10 000\n10 001\n10 100", "o...
code_stdio
[ { "content": "Johnny has recently found an ancient, broken computer. The machine has only one register, which allows one to put in there one variable. Then in one operation, you can shift its bits left or right by at most three positions. The right shift is forbidden if it cuts off some ones. So, in fact, in on...
[{"input": "10\n10 5\n11 73\n17 21\n1 1\n96 3\n2 128\n0001 1100611139403776\n1000000000000000000 1000000001000000000\n7 1\n10 8\n", "output": "1\n-1\n-1\n0\n2\n2\n-1\n-1\n-1\n-1\n"}, {"input": "10\n10 5\n11 73\n17 18\n1 1\n96 3\n2 128\n0001 1100611139403776\n1000000000000000000 1000000001000000000\n7 1\n10 8\n", "outpu...
code_stdio
[ { "content": "Kirito is stuck on a level of the MMORPG he is playing now. To move on in the game, he's got to defeat all n dragons that live on this level. Kirito and the dragons have strength, which is represented by an integer. In the duel between two opponents the duel's outcome is determined by their streng...
[{"input": "9983 34\n6626 5976\n4448 3568\n2794 2309\n3741 8806\n4754 129\n2780 9275\n5785 9243\n3915 6159\n2609 4331\n238 6756\n6987 3887\n3384 5711\n4349 5563\n1135 4483\n9151 1584\n1500 766\n1608 4440\n7768 5005\n7205 2360\n9088 2933\n3923 7814\n7538 9372\n7504 165\n5277 1636\n2061 4384\n7668 1422\n9582 2121\n5483 7...
code_stdio
[ { "content": "You are given an array $a_1, a_2, \\dots, a_n$ consisting of $n$ distinct integers. Count the number of pairs of indices $(i, j)$ such that $i < j$ and $a_i \\cdot a_j = i + j$.\n\n\n-----Input-----\n\nThe first line contains one integer $t$ ($1 \\leq t \\leq 10^4$) β€” the number of test cases. The...
[{"input": "3\n2\n3 1\n3\n3 1 5\n5\n3 1 4 10 2\n", "output": "1\n2\n3\n"}, {"input": "3\n2\n2 1\n3\n4 2 5\n5\n3 1 4 10 2\n", "output": "0\n0\n3\n"}, {"input": "3\n2\n3 2\n3\n3 1 5\n5\n3 1 4 10 2\n", "output": "0\n2\n3\n"}, {"input": "3\n2\n3 1\n3\n4 1 5\n5\n3 1 4 10 2\n", "output": "1\n1\n3\n"}, {"input": "3\n2\n3 1\n3...
code_stdio
[ { "content": "Our bear's forest has a checkered field. The checkered field is an n Γ— n table, the rows are numbered from 1 to n from top to bottom, the columns are numbered from 1 to n from left to right. Let's denote a cell of the field on the intersection of row x and column y by record (x, y). Each cell of t...
[{"input": "1000000000 1000000000 1000000000 100 -100 1000000000000000000\n", "output": "969796608 969796608\n"}, {"input": "1000000000 1000000000 1000000001 100 -100 1000000000000000000\n", "output": "599261184 599261185\n"}, {"input": "1000000000 1000000000 1000000000 100 -100 1000000000000000000\n", "output": "96979...
code_stdio
[ { "content": "Little Dormi received a histogram with $n$ bars of height $a_1, a_2, \\ldots, a_n$ for Christmas. However, the more he played with his new histogram, the more he realized its imperfections, so today he wanted to modify it to his liking.\n\nTo modify the histogram, Little Dormi is able to perform t...
[{"input": "2\n4\n0 16 14 1\n6\n2 1 14 4 0 0\n", "output": "30\n19\n"}, {"input": "2\n4\n0 16 17 1\n6\n2 1 14 4 0 0\n", "output": "33\n19\n"}, {"input": "2\n4\n13 8 15 13\n6\n2 1 7 8 1 0\n", "output": "33\n16\n"}, {"input": "2\n4\n13 8 15 13\n6\n2 1 7 3 1 0\n", "output": "33\n11\n"}, {"input": "2\n4\n13 8 15 13\n6\n4 1...
code_stdio
[ { "content": "A way to make a new task is to make it nondeterministic or probabilistic. For example, the hard task of Topcoder SRM 595, Constellation, is the probabilistic version of a convex hull.\n\nLet's try to make a new task. Firstly we will use the following task. There are n people, sort them by their na...
[{"input": "6\nzfnkpxaavrcvqhhkclcuiswawpghlqrlq wnvbzhvsjozlkwxowcvyclmehjkkvkxin\nzkxkvlnovnloxjdydujkjydaegzjypsgrzq dmiilhmkspokltabpvwalijhlitbfp\nldfbfggqsdqethdgkmbcwloluguxiluqjyr fewoondewvndcxticvpiqnvvdhsnzfd\nepokfmixjnawdfgkmqlcyirxuprrvudh xvijbdzqdyjwsyhjucytuxrxuiynxf\nxntrjusjwbfemnysqrloflcmuiiqxdwvia...
code_stdio
[ { "content": "Given are N pairwise distinct non-negative integers A_1,A_2,\\ldots,A_N. Find the number of ways to choose a set of between 1 and K numbers (inclusive) from the given numbers so that the following two conditions are satisfied:\n\n* The bitwise AND of the chosen numbers is S.\n* The bitwise OR of t...
[{"input": "5 4 1 15\n3 11 1 0 5", "output": "4"}, {"input": "5 4 1 15\n3 11 1 1 5", "output": "7"}, {"input": "5 4 1 15\n3 11 1 0 2", "output": "0"}, {"input": "5 5 1 11\n3 4 11 1 5", "output": "2"}, {"input": "5 4 0 15\n3 11 1 1 5", "output": "0"}, {"input": "5 4 1 15\n1 11 1 0 5", "output": "4"}, {"input": "5 4 0 15...
code_stdio
[ { "content": "Kenkoooo found a simple connected graph. The vertices are numbered 1 through n. The i-th edge connects Vertex u_i and v_i, and has a fixed integer s_i.\n\nKenkoooo is trying to write a positive integer in each vertex so that the following condition is satisfied:\n\n* For every edge i, the sum of t...
[{"input": "8 7\n1 2 1000000000\n2 3 2\n3 4 1000000000\n4 5 2\n5 6 1000000000\n6 7 2\n2 8 1000000000", "output": "0\n"}, {"input": "8 7\n1 2 1000000000\n2 3 2\n2 4 1000000000\n4 5 2\n5 6 1000000000\n6 7 2\n2 8 1000000000", "output": "0\n"}, {"input": "8 7\n1 2 1000000000\n2 3 2\n3 6 1000000000\n4 5 2\n5 6 1000000000\n6...
code_stdio
[ { "content": "Problem\n\nI chose creature observation as the theme of my free study during the summer vacation and purchased a creature observation kit.\n\nThis creature prefers to live in a three-dimensional grid-like space. Only one animal can be placed in each cell. It repeats birth and death every day accor...
[{"input": "5\n00000\n01010\n00000\n00100\n00000\n\n00000\n01010\n00000\n01010\n00000\n\n00000\n00100\n00000\n01010\n00000\n\n00000\n01110\n00000\n00100\n00000\n\n00000\n00000\n00100\n00000\n00000\n\n1 2\n2 3 4\n4\n01110\n00100\n00100\n00100\n01110\n\n01110\n10001\n10000\n10001\n01110\n\n11111\n10001\n11111\n10000\n100...
code_stdio
[ { "content": "wHAT DO WE NEED cAPS LOCK FOR?\n\nCaps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. \n\nLet's consider that a word has been typed with the...
[{"input": "cTKDZNWVYRTFPQLDAUUNSPKTDJTUPPFPRXRSINTVFVNNQNKXWUZUDHZBUSOKTABUEDQKUIVRTTVUREEOBJTSDKJKVEGFXVHXEYPE\n", "output": "Ctkdznwvyrtfpqldauunspktdjtuppfprxrsintvfvnnqnkxwuzudhzbusoktabuedqkuivrttvureeobjtsdkjkvegfxvhxeype\n"}, {"input": "KETAXTSWAAOBKUOKUQREHIOMVMMRSAEWKGXZKRASwTVNSSFSNIWYNPSTMRADOADEEBURRHPOOBI...
code_stdio
[ { "content": "There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer $y$-coordinates, and their $x$-coordinate is equal to $-100$, while the second grou...
[{"input": "50 60\n445 303 -861 -583 436 -125 312 -700 -829 -865 -276 -25 -725 -286 528 -221 757 720 -572 514 -514 359 294 -992 -838 103 611 776 830 143 -247 182 -241 -627 299 -824 635 -571 -660 924 511 -876 160 569 -570 827 75 558 708 46\n899 974 750 -138 -439 -904 -113 -761 -150 -92 -279 489 323 -649 -759 667 -600 -7...
code_stdio
[ { "content": "Takahashi and Aoki will have a battle using their monsters.\nThe health and strength of Takahashi's monster are A and B, respectively, and those of Aoki's monster are C and D, respectively.\nThe two monsters will take turns attacking, in the order Takahashi's, Aoki's, Takahashi's, Aoki's, ...\nHer...
[{"input": "100 1 100 1\n", "output": "Yes\n"}, {"input": "85 7 30 19\n", "output": "Yes\n"}, {"input": "85 7 23 19\n", "output": "Yes\n"}, {"input": "38 11 7 79\n", "output": "Yes\n"}, {"input": "45 13 80 90\n", "output": "No\n"}, {"input": "52 62 6 48\n", "output": "Yes\n"}, {"input": "59 11 32 59\n", "output": "No\n...
code_stdio
[ { "content": "A stowaway and a controller play the following game. \n\nThe train is represented by n wagons which are numbered with positive integers from 1 to n from the head to the tail. The stowaway and the controller are initially in some two different wagons. Every minute the train can be in one of two con...
[{"input": "50 42 13\nto head\n00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\n", "output": "Controller 61\n"}, {"input": "49 44 14\nto head\n000000000000000000000000...
code_stdio
[ { "content": "Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.\n\nVolodya calls a string powerful if it starts with \"heavy\" and ends with \"metal\". Finding all powerful substrings (by substring Volodya...
[{"input": "trueheavymetalissotruewellitisalsosoheavythatyoucanalmosteeeltheweightofmetalonyou\n", "output": "3\n"}, {"input": "trueheavymetalissotrufwellitisalsosoheavythatyoucanalmosteeeltheweightofmetalonyou\n", "output": "3\n"}, {"input": "uoynolatemfothgiewehtleeetsomlanacuoytahtyvaehososlasitillewfurtossilatemyva...
code_stdio
[ { "content": "In recent years John has very successfully settled at his new job at the office. But John doesn't like to idly sit around while his code is compiling, so he immediately found himself an interesting distraction. The point of his distraction was to maintain a water level in the water cooler used by ...
[{"input": "1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000 1000000000000000000\n", "output": "No\n"}, {"input": "1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000 1000000000000000000\n", "output": "No\n"}, {"input": "1000000000000000000 1000...
code_stdio
[ { "content": "Now Serval is a junior high school student in Japari Middle School, and he is still thrilled on math as before. \n\nAs a talented boy in mathematics, he likes to play with numbers. This time, he wants to play with numbers on a rooted tree.\n\nA tree is a connected graph without cycles. A rooted tr...
[{"input": "100\n0 1 0 0 1 0 1 0 0 0 0 0 1 0 0 1 1 1 1 0 0 1 0 1 1 0 1 0 0 0 0 1 0 1 1 1 1 0 0 1 0 1 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 1 1 1 1 0 0 0 0 1 1 1 0 1 0 0 1 1 0 0 1 0 0 1 1 0 0 0 1 1 1 0 0 0 1\n1 2 3 4 2 6 5 5 4 8 10 8 1 14 5 16 3 11 13 11 12 8 11 22 8 17 19 5 15 27 14 13 12 4 6 2 10 25 36 14 16...
code_stdio
[ { "content": "Takahashi is about to assemble a character figure, consisting of N parts called Part 1, Part 2, ..., Part N and N-1 connecting components. Parts are distinguishable, but connecting components are not.\nPart i has d_i holes, called Hole 1, Hole 2, ..., Hole d_i, into which a connecting component ca...
[{"input": "44242\n1 2 1 1 3 2 2 1 1 2 1 1 3 3 2 1 3 3 1 1 2 4 2 1 3 3 1 2 1 4 2 1 4 1 1 3 1 1 1 2 3 1 3 1 1 3 2 2 2 1 2 2 2 2 3 1 3 2 2 2 2 2 2 1 4 3 1 2 1 2 2 1 2 5 1 1 3 5 2 2 1 3 6 2 1 2 1 1 3 1 1 1 1 4 1 2 2 1 1 1 2 1 2 3 1 4 1 1 1 2 2 3 1 1 1 2 3 1 1 4 1 1 2 2 2 4 2 3 1 1 2 3 2 2 2 2 2 2 1 2 2 3 2 2 1 1 1 3 4 2 2...
code_stdio
[ { "content": "Find \\displaystyle{\\sum_{a=1}^{K}\\sum_{b=1}^{K}\\sum_{c=1}^{K} \\gcd(a,b,c)}.\nHere \\gcd(a,b,c) denotes the greatest common divisor of a, b, and c.\n\n-----Constraints-----\n - 1 \\leq K \\leq 200\n - K is an integer.\n\n-----Input-----\nInput is given from Standard Input in the following form...
[{"input": "200\n", "output": "10813692\n"}, {"input": "199\n", "output": "10611772\n"}, {"input": "198\n", "output": "10493367\n"}, {"input": "197\n", "output": "10290813\n"}, {"input": "196\n", "output": "10174780\n"}, {"input": "195\n", "output": "9997134\n"}, {"input": "157\n", "output": "5205481\n"}, {"input": "12...
code_stdio
[ { "content": "In a small restaurant there are a tables for one person and b tables for two persons. \n\nIt it known that n groups of people come today, each consisting of one or two people. \n\nIf a group consist of one person, it is seated at a vacant one-seater table. If there are none of them, it is seated a...
[{"input": "30 10 10\n1 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\n", "output": "20\n"}, {"input": "30 10 10\n1 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\n", "output": "20\n"}, {"input": "20 4 3\n2 2 2 2 2 2 2 2 1 2 1 1 2 2 1 2 2 2 1 2\n", "output": "25\n"}, {"input": "20 4 3\n2 2 2 2 2 ...
code_stdio
[ { "content": "Sometimes it is hard to prepare tests for programming problems. Now Bob is preparing tests to new problem about strings β€” input data to his problem is one string. Bob has 3 wrong solutions to this problem. The first gives the wrong answer if the input data contains the substring s1, the second ent...
[{"input": "rdtevvmiqmfgvafkdypxjthzhfsbavmhgkavkfonscaokdxoscenpxrc\nijbvueenzsmgkmkrskjspvfchwkqdglkxnrdtevvmiqmfgvafkdypxjthz\nkqdglkxnrdtevvmiqmfgvafkdypxjthzhfsbavmhgkavkfonscaokdxoscenpxrcivydtkrxjy\n", "output": "100\n"}, {"input": "iefouqzxoyuieqdzalfktehtvdbvjmeubju\nocotspetkkhvwfgaqynhovjwjhciefouqzxoyuieqdz...
code_stdio
[ { "content": "Vasya has found a piece of paper with a coordinate system written on it. There are n distinct squares drawn in this coordinate system. Let's number the squares with integers from 1 to n. It turned out that points with coordinates (0, 0) and (ai, ai) are the opposite corners of the i-th square.\n\n...
[{"input": "50 2\n611819205 916034844 226292837 817298502 176794540 727900268 460009451 154197232 1083758894 641633528 316549457 84943963 320598147 360295861 299532522 279193498 61088105 776327911 952977833 796036148 193827182 248414821 822409059 451009120 316494610 702170585 194014479 567762248 201775925 186588924 630...
code_stdio
[ { "content": "Nauuo is a girl who loves playing cards.\n\nOne day she was playing cards but found that the cards were mixed with some empty ones.\n\nThere are $n$ cards numbered from $1$ to $n$, and they were mixed with another $n$ empty cards. She piled up the $2n$ cards and drew $n$ of them. The $n$ cards in ...
[{"input": "20\n0 0 0 0 5 6 7 8 0 0 11 12 13 14 15 16 17 18 0 0\n20 9 19 0 0 0 0 0 0 10 0 0 0 0 0 0 1 2 3 4\n", "output": "37\n"}, {"input": "20\n15 10 6 0 0 11 19 17 0 0 0 0 0 1 14 0 3 4 0 12\n20 7 0 0 0 0 0 0 5 8 2 16 18 0 0 13 9 0 0 0\n", "output": "30\n"}, {"input": "20\n15 10 6 0 0 11 19 17 0 0 0 0 0 1 14 0 3 4 0 ...
code_stdio
[ { "content": "Ancient Egyptians are known to have understood difficult concepts in mathematics. The ancient Egyptian mathematician Ahmes liked to write a kind of arithmetic expressions on papyrus paper which he called as Ahmes arithmetic expression.\n\nAn Ahmes arithmetic expression can be defined as: \"d\" i...
[{"input": "((((4?6)?9)?((5?(7?1))?(6?(4?(((((((7?3)?7)?(((((8?(6?7))?((1?2)?(5?8)))?8)?7)?4))?6)?7)?1)?((7?(2?((1?(((8?(((((2?7)?(((((3?6)?3)?(((((9?5)?7)?(1?(5?5)))?(8?((3?(1?2))?((8?5)?(7?((9?((9?8)?7))?1))))))?1))?1)?(9?2)))?((7?5)?((9?(4?(9?6)))?(8?(((5?7)?2)?(6?(3?8)))))))?(((4?(2?2))?(7?9))?((7?((((4?(3?(7?3)))?...
code_stdio
[ { "content": "Ito joined the Kyudo club after entering high school. At first, I had a hard time because the arrow didn't reach the target, but in the fall of my first year of high school, I managed to improve to the point where the arrow reached the target.\n\nOne day, my senior Kato suggested, \"Why don't you ...
[{"input": "20\n1\n11\n1\n-1\n0\n8\n-2\n1\n0", "output": "12\n-1\n"}, {"input": "20\n1\n10\n1\n-1\n0\n8\n-2\n1\n0", "output": "11\n-1\n"}, {"input": "20\n3\n2\n0\n1\n12\n8\n-1\n-1\n0", "output": "18\n-2\n"}, {"input": "20\n5\n10\n3\n1\n-2\n8\n0\n-2\n0", "output": "17\n-2\n"}, {"input": "20\n-1\n-2\n1\n-1\n0\n8\n0\n1\n0...
code_stdio
[ { "content": "You are given n Γ— m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n All cells in a set have the same color. Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m ...
[{"input": "5 50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\...
code_stdio
[ { "content": "We have a cord whose length is a positive integer. We will perform the following condition until the length of the cord becomes at most 2:\n\n* Operation: Cut the rope at two positions to obtain three cords, each with a length of a positive integer. Among these, discard one with the longest length...
[{"input": "52", "output": "18014398509481982\n"}, {"input": "51", "output": "9007199254740990\n"}, {"input": "49", "output": "2251799813685246\n"}, {"input": "50", "output": "4503599627370494\n"}, {"input": "48", "output": "1125899906842622\n"}, {"input": "47", "output": "562949953421310\n"}, {"input": "45", "output":...
code_stdio
[ { "content": "One day in the IT lesson Anna and Maria learned about the lexicographic order.\n\nString x is lexicographically less than string y, if either x is a prefix of y (and x β‰  y), or there exists such i (1 ≀ i ≀ min(|x|, |y|)), that xi < yi, and for any j (1 ≀ j < i) xj = yj. Here |a| denotes the length...
[{"input": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhihhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh...
code_stdio
[ { "content": "The only difference between easy and hard versions is the length of the string.\n\nYou are given a string $s$ and a string $t$, both consisting only of lowercase Latin letters. It is guaranteed that $t$ can be obtained from $s$ by removing some (possibly, zero) number of characters (not necessary ...
[{"input": "izoiweukqszkkhwapzxyotbaarpqxbybsjxilhylbbjbvoedrezyluaabsfzvtxxvncdwxrlfdtfvbfoqwlzqwneimwzpoygfdcldmxdhoxzensxlspituzocvzzrfomhggrwurdccgfoorvhyzsdkpjhwakuoxwdjhzaalanyzwuuqwlrtmvmdraleyusjqdyxuztvc\nizoiweukqszkkhwapzxyotbaarpqxbybsjxilhylbbjbvoedrezyluaabsfzvtxxvncdwxrlfdtfvbfoqwlzqwneimwzpoygfdcldmxdho...
code_stdio
[ { "content": "A girl named Xenia has a cupboard that looks like an arc from ahead. The arc is made of a semicircle with radius r (the cupboard's top) and two walls of height h (the cupboard's sides). The cupboard's depth is r, that is, it looks like a rectangle with base r and height h + r from the sides. The f...
[{"input": "1 10000000\n", "output": "20000001\n"}, {"input": "2 10000000\n", "output": "10000001\n"}, {"input": "1 10010000\n", "output": "20020001\n"}, {"input": "3 15787624\n", "output": "10525083\n"}, {"input": "2 10001000\n", "output": "10001001\n"}, {"input": "1 10010001\n", "output": "20020003\n"}, {"input": "2 ...
code_stdio
[ { "content": "Nathan O. Davis is challenging a kind of shooter game. In this game, enemies emit laser beams from outside of the screen. A laser beam is a straight line with a certain thickness. Nathan moves a circular-shaped machine within the screen, in such a way it does not overlap a laser beam. As in many s...
[{"input": "100 100 1 1\n78 1 50 100 21\n640 295 1 2\n1 -1 640 480 100\n0 0 0 0", "output": "Yes\nYes\n"}, {"input": "100 100 1 0\n78 1 50 100 21\n640 295 1 2\n1 -1 640 480 100\n0 0 0 0", "output": "Yes\nYes\n"}, {"input": "100 100 1 0\n78 1 50 100 21\n640 292 1 2\n1 -1 640 480 100\n0 0 0 0", "output": "Yes\nYes\n"}, {...
code_stdio
[ { "content": "Today on Informatics class Nastya learned about GCD and LCM (see links below). Nastya is very intelligent, so she solved all the tasks momentarily and now suggests you to solve one of them as well.\n\nWe define a pair of integers (a, b) good, if GCD(a, b) = x and LCM(a, b) = y, where GCD(a, b) den...
[{"input": "1000000000 1000000000 1000000000 1000000000\n", "output": "1\n"}, {"input": "1000000000 1000000000 1000000000 1000000000\n", "output": "1\n"}, {"input": "1000000000 1000000000 1000100000 1000000000\n", "output": "0\n"}, {"input": "11678540 172842392 2335708 864211960\n", "output": "4\n"}, {"input": "1167854...
code_stdio
[ { "content": "Polycarp has just invented a new binary protocol for data transmission. He is encoding positive integer decimal number to binary string using following algorithm:\n\n Each digit is represented with number of '1' characters equal to the value of that digit (for 0 it is zero ones). Digits are writ...
[{"input": "89\n11111111101111111110111111111011111111101111111110111111111011111111101111111110111111111\n", "output": "999999999\n"}, {"input": "89\n11111111101111111110111111111011111111101111111110111111111011111111101111111110111111111\n", "output": "999999999\n"}, {"input": "53\n1011011101111011111011111101111111...
code_stdio
[ { "content": "There are n stones arranged on an axis. Initially the i-th stone is located at the coordinate s_i. There may be more than one stone in a single place.\n\nYou can perform zero or more operations of the following type: \n\n * take two stones with indices i and j so that s_i ≀ s_j, choose an integer...
[{"input": "20\n53 86 76 100 16 12 13 97 79 23 28 64 42 10 23 56 59 76 48 12\n48 49 49 49 48 49 48 49 49 49 48 48 48 49 49 49 49 49 49 48\n", "output": "YES\n19\n14 1 4\n14 16 7\n14 17 10\n14 12 15\n14 3 2\n6 3 25\n6 18 11\n20 18 16\n20 9 20\n7 9 10\n7 2 25\n5 2 12\n5 8 20\n10 8 25\n15 8 3\n15 4 22\n11 4 21\n13 4 7\n19...
code_stdio
[ { "content": "Let's call the set of positive integers $S$ correct if the following two conditions are met:\n\n$S \\subseteq \\{1, 2, \\dots, n\\}$;\n\nif $a \\in S$ and $b \\in S$, then $|a-b| \\neq x$ and $|a-b| \\neq y$.\n\nFor the given values $n$, $x$, and $y$, you have to find the maximum size of the corre...
[{"input": "1000000000 22 22\n", "output": "500000006\n"}, {"input": "1000000000 21 22\n", "output": "488372094\n"}, {"input": "1000000000 20 22\n", "output": "476190480\n"}, {"input": "455678451 22 17\n", "output": "221997195\n"}, {"input": "708087026 21 16\n", "output": "344474771\n"}, {"input": "706836718 14 15\n", ...
code_stdio
[ { "content": "Vasya trains to compose crossword puzzles. He can only compose crosswords of a very simplΠ΅ type so far. All of them consist of exactly six words; the words can be read only from top to bottom vertically and from the left to the right horizontally. The words are arranged in the form of a rectangula...
[{"input": "ABBAAAABBBB\nBBABAAAABAABAB\nBAABABBBABBBBBAAA\nBABABAAABBAAABBAAAAB\nABAAAABBBBBABAABABBAAAAABBBBBB\nBBBBAABBAABBBBABAAABAABBAABBAA\n", "output": "BAABABBBABBBBBAAA.............\nA...............B.............\nB...............A.............\nA...............A.............\nB...............A.............\n...
code_stdio
[ { "content": "There is unrest in the Galactic Senate. Several thousand solar systems have declared their intentions to leave the Republic. Master Heidi needs to select the Jedi Knights who will go on peacekeeping missions throughout the galaxy. It is well-known that the success of any peacekeeping mission depen...
[{"input": "100 100\n52 93 36 69 49 37 48 42 63 27 16 60 16 63 80 37 69 24 86 38 73 15 43 65 49 35 39 98 91 24 20 35 12 40 75 32 54 4 76 22 23 7 50 86 41 9 9 91 23 18 41 61 47 66 1 79 49 21 99 29 87 94 42 55 87 21 60 67 36 89 40 71 6 63 65 88 17 12 89 32 79 99 34 30 63 33 53 56 10 11 66 80 73 50 47 12 91 42 28 56\n1 0 ...
code_stdio
[ { "content": "Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a_1, a_2, ..., a_{n} of length n, that the following condition fulfills: a_2 - a_1 = a_3 - a_2 = a_4 - a_3 = ... = a_{i} + 1 - a_{i} = ... = a_{n} - a_{n} - ...
[{"input": "40\n100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 1000...
code_stdio
[ { "content": "There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age equal to ai.\n\nThe i-th walrus becomes displeased if there...
[{"input": "15\n18 6 33 21 14 20 13 9 18 20 28 13 19 25 21\n", "output": "10 -1 11 8 6 6 0 -1 2 2 3 -1 -1 0 -1 "}, {"input": "15\n18 6 33 21 14 20 20 9 18 20 28 13 19 25 21\n", "output": "10 -1 11 8 6 6 5 -1 2 2 3 -1 -1 0 -1 "}, {"input": "15\n18 6 33 21 14 17 20 9 18 20 28 13 19 25 21\n", "output": "10 -1 11 8 6 5 5 -...
code_stdio
[ { "content": "Training is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well.\n\nToday's training is to perform a very large number of calculations to improve the calculation power and raise awareness. Exponentiation is an operation that easily...
[{"input": "3\n0\n0\n1000000010", "output": "1000000010\n0\n0\n"}, {"input": "3\n0\n0\n1000000000", "output": "1000000000\n0\n0"}, {"input": "4\n11\n5\n10\n10", "output": "5\n10\n10\n11\n"}, {"input": "4\n11\n5\n19\n10", "output": "5\n10\n11\n19\n"}, {"input": "4\n18\n5\n19\n10", "output": "5\n10\n18\n19\n"}, {"input":...
code_stdio
[ { "content": "Given are integer sequences A and B of length 3N. Each of these two sequences contains three copies of each of 1, 2, \\dots, N. In other words, A and B are both arrangements of (1, 1, 1, 2, 2, 2, \\dots, N, N, N).\n\nTak can perform the following operation to the sequence A arbitrarily many times:...
[{"input": "8\n3 6 7 5 4 8 4 1 1 3 8 7 3 8 2 4 7 5 2 2 6 5 6 1\n7 5 8 1 3 6 7 5 4 8 1 3 3 8 2 4 2 6 5 6 1 4 7 2", "output": "7"}, {"input": "3\n2 3 3 1 2 1 2 1 3\n3 2 2 1 1 1 3 3 2", "output": "-1\n"}, {"input": "3\n2 3 3 1 1 1 3 2 2\n3 2 2 1 1 1 3 3 2", "output": "-1\n"}, {"input": "3\n1 1 2 2 1 2 3 3 3\n1 1 1 2 3 2 3...
code_stdio
[ { "content": "There are $n$ districts in the town, the $i$-th district belongs to the $a_i$-th bandit gang. Initially, no districts are connected to each other.\n\nYou are the mayor of the city and want to build $n-1$ two-way roads to connect all districts (two districts can be connected directly or through oth...
[{"input": "4\n5\n1 3 2 1 5\n3\n2 1 0\n4\n-1 1000 101 1000\n4\n1 2 3 4\n", "output": "YES\n1 2\n1 3\n1 5\n5 4\nYES\n1 2\n1 3\nYES\n1 2\n1 3\n1 4\nYES\n1 2\n1 3\n1 4\n"}, {"input": "4\n5\n1 3 2 1 5\n3\n1 1 0\n4\n-1 1000 101 1000\n4\n1 2 3 4\n", "output": "YES\n1 2\n1 3\n1 5\n5 4\nYES\n1 3\n3 2\nYES\n1 2\n1 3\n1 4\nYES\n...
code_stdio
[ { "content": "For a non-negative integer N, define S(N) as the sum of the odd digits of N\nplus twice the sum of the even digits of N.\nFor example, S(5)=5, S(456)=2*4+5+2*6=25, and S(314159)=3+1+2*4+1+5+9=27.\nDefine D(N) as the last digit of S(N).\nSo D(5)=5, D(456)=5, and D(314159)=7.\nGiven 2 non-negative i...
[{"input": "3\n0 10\n34 453\n517800 1591348", "output": "46\n1890\n4830969\n"}, {"input": "3\n0 10\n16 252\n314159 1591348", "output": "46\n1065\n5747356\n"}, {"input": "3\n1 10\n28 297\n314159 559966", "output": "46\n1207\n1106130\n"}, {"input": "3\n1 10\n28 297\n206640 516069", "output": "46\n1207\n1392435\n"}, {"inp...
code_stdio
[ { "content": "It is a holiday season, and Koala is decorating his house with cool lights! He owns $n$ lights, all of which flash periodically.\n\nAfter taking a quick glance at them, Koala realizes that each of his lights can be described with two parameters $a_i$ and $b_i$. Light with parameters $a_i$ and $b_i...
[{"input": "70\n0010011111011101101111000111101011010101000011000000010100010101010001\n3 1\n1 5\n3 1\n4 1\n3 3\n2 4\n2 1\n5 1\n2 4\n5 2\n5 2\n4 1\n2 5\n2 2\n4 2\n5 1\n1 2\n2 4\n3 1\n1 1\n5 3\n5 2\n3 5\n4 4\n2 1\n3 2\n1 3\n5 1\n3 4\n2 3\n1 5\n4 1\n2 2\n5 1\n3 3\n4 2\n1 4\n5 2\n1 2\n4 1\n1 4\n5 3\n3 3\n2 5\n3 5\n3 4\n3 ...
code_stdio
[ { "content": "Takahashi has many red balls and blue balls. Now, he will place them in a row.\nInitially, there is no ball placed.\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n - Place A blue balls at the end of the row of balls already placed. Then, place B red balls at the ...
[{"input": "984159202374430527 552558592232591693 265756112319848958\n", "output": "718403090054581569\n"}, {"input": "994914121424164663 818665214162491101 129546857230076861\n", "output": "865367264194087802\n"}, {"input": "501719768609305159 370614275896614890 131105492712690269\n", "output": "370614275896614890\n"}...
code_stdio
[ { "content": "A ski base is planned to be built in Walrusland. Recently, however, the project is still in the constructing phase. A large land lot was chosen for the construction. It contains n ski junctions, numbered from 1 to n. Initially the junctions aren't connected in any way.\n\nIn the constructing proce...
[{"input": "2 40\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n", "output": "0\n1\n3\n7\n15\n31\n63\n127\n255\n511\n1023\n2047\n4095\n8191\n16383\n32767\n65535\n1310...
code_stdio
[ { "content": "Ibis is fighting with a monster.\nThe health of the monster is H.\nIbis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points.\nThe same spell can be cast multiple times. There is no way other than spells to decrease the monster's...
[{"input": "1832 947\n4182 1443\n3979 4739\n5500 1039\n9994 9474\n7064 5254\n3587 2902\n6074 3873\n3865 9760\n8970 4251\n6222 8535\n9192 643\n5820 6677\n9711 4431\n9112 6134\n8614 2404\n9041 3356\n7574 5999\n9710 6045\n2463 3743\n7637 6723\n7802 9816\n5829 2411\n8800 3617\n9653 7\n6034 1399\n5178 9084\n7630 9624\n2005 ...
code_stdio
[ { "content": "Write a program which reverses a given string str.\n\n\n\nInput\n\nstr (the size of str ≀ 20) is given in a line.\n\nOutput\n\nPrint the reversed str in a line.\n\nExample\n\nInput\n\nw32nimda\n\n\nOutput\n\nadmin23w\n\nWrite Python code to solve this problem. Your program should read the input fr...
[{"input": "w32njmda", "output": "admjn23w\n"}, {"input": "admjn23w", "output": "w32njmda\n"}, {"input": "acmjn23w", "output": "w32njmca\n"}, {"input": "3cmjn2aw", "output": "wa2njmc3\n"}, {"input": "3dmjn2aw", "output": "wa2njmd3\n"}, {"input": "wa2njmd3", "output": "3dmjn2aw\n"}, {"input": "xa2njmd3", "output": "3dmj...
code_stdio
[ { "content": "Joe has been hurt on the Internet. Now he is storming around the house, destroying everything in his path.\n\nJoe's house has n floors, each floor is a segment of m cells. Each cell either contains nothing (it is an empty cell), or has a brick or a concrete wall (always something one of three). It...
[{"input": "20 20\n..+#+.+++.+++#+..#++\n..####+++#..++#+.+.+\n+.+..+++..#.++++++++\n+##++..+.##..#+++.++\n++.+.+.+.++++.+++.++\n.+++++.+#+++++...+#+\n.++.#+++++++++.++.++\n...+.++++++.++#...++\n+++.+++.+....#....+.\n.++++++.+.+..++.++##\n.+..+..++#.+..++++++\n+..#+++++..+##+#++.+\n+.+#+#....+.#+++#+.+\n++.+.+++.++.+.#...
code_stdio
[ { "content": "There are $n + 2$ towns located on a coordinate line, numbered from $0$ to $n + 1$. The $i$-th town is located at the point $i$.\n\nYou build a radio tower in each of the towns $1, 2, \\dots, n$ with probability $\\frac{1}{2}$ (these events are independent). After that, you want to set the signal ...
[{"input": "200000\n", "output": "\n202370013\n"}, {"input": "200000\n", "output": "202370013\n"}, {"input": "199999\n", "output": "503231359\n"}, {"input": "199998\n", "output": "801261687\n"}, {"input": "199998\n", "output": "801261687\n"}, {"input": "199999\n", "output": "503231359\n"}, {"input": "103835\n", "output...
code_stdio
[ { "content": "A sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n - The first term s is given as input.\n - Let f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n - a_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\nFind the minimum integer m that satisfies ...
[{"input": "54\n", "output": "114\n"}, {"input": "100\n", "output": "27\n"}, {"input": "97\n", "output": "120\n"}, {"input": "95\n", "output": "107\n"}, {"input": "27\n", "output": "113\n"}, {"input": "108", "output": "115\n"}, {"input": "107", "output": "102\n"}, {"input": "161", "output": "100\n"}, {"input": "220", "...
code_stdio
[ { "content": "At the beginning of the new semester there is new schedule in the Berland State University. According to this schedule, n groups have lessons at the room 31. For each group the starting time of the lesson and the finishing time of the lesson are known. It has turned out that it is impossible to ho...
[{"input": "16\n203671 381501\n58867 59732\n817520 962123\n125391 163027\n601766 617692\n381501 444610\n761937 817520\n16 10551\n21096 38291\n718073 761937\n583868 601766\n554859 731755\n678098 718073\n962123 992003\n163027 203671\n87917 96397\n", "output": "1\n12 "}, {"input": "11\n717170 795210\n866429 970764\n163324...
code_stdio
[ { "content": "You are given two strings x and y, both consist only of lowercase Latin letters. Let |s| be the length of string s.\n\nLet's call a sequence a a merging sequence if it consists of exactly |x| zeros and exactly |y| ones in some order.\n\nA merge z is produced from a sequence a by the following rule...
[{"input": "justamassivetesttocheck\nhowwellyouhandlemodulooperations\n", "output": "\n667387032\n"}, {"input": "justamassivetestsocheck\nhowwellyouhandlemodulooperations\n", "output": "732028571\n"}, {"input": "kcehcostsetevissamatsuj\nhowwellyouhandlemodulooperations\n", "output": "957292014\n"}, {"input": "kcehcosts...
code_stdio
[ { "content": "The educational program (AHK Education) of the Aiz Broadcasting Association broadcasts a handicraft program for children, \"Play with Tsukuro\". This time I will make a box with sticks, but I would like to see if I can make a rectangular parallelepiped using the 12 sticks I prepared. However, the ...
[{"input": "0 1 1 4 11 16 3 2 0 0 5 13", "output": "no\n"}, {"input": "0 1 1 4 11 16 6 2 0 0 5 13", "output": "no\n"}, {"input": "0 1 1 4 11 16 6 2 1 0 5 13", "output": "no\n"}, {"input": "0 1 1 4 2 20 6 2 2 0 13 13", "output": "no\n"}, {"input": "0 1 1 4 2 20 6 2 3 0 13 13", "output": "no\n"}, {"input": "0 1 1 4 2 20 ...
code_stdio
[ { "content": "There is a n Γ— n grid D where each cell contains either 1 or 0.\n\nYour task is to create a program that takes the gird data as input and computes the greatest number of consecutive 1s in either vertical, horizontal, or diagonal direction.\n\nFor example, the consecutive 1s with greatest number in...
[{"input": "5\n00011\n00101\n01000\n10101\n00010\n8\n11000001\n10110111\n01100111\n01111010\n11111111\n01001010\n10100010\n10000001\n2\n01\n00\n3\n000\n000\n000\n0", "output": "4\n8\n1\n0\n"}, {"input": "5\n00011\n00101\n01000\n10101\n00010\n8\n11000001\n10110111\n01100111\n01111010\n11111111\n01001010\n10100010\n10000...
code_stdio
[ { "content": "You are given an array $a$ consisting of $n$ positive integers.\n\nInitially, you have an integer $x = 0$. During one move, you can do one of the following two operations: Choose exactly one $i$ from $1$ to $n$ and increase $a_i$ by $x$ ($a_i := a_i + x$), then increase $x$ by $1$ ($x := x + 1$)....
[{"input": "5\n4 3\n1 2 1 3\n10 6\n8 7 1 8 3 7 1 10 8 9\n5 13\n20 100 74 20 100500\n10 25\n24 39 19 24 24 87 24 24 24 10\n8 8\n1 2 3 4 5 7 7 12\n", "output": "6\n24\n20\n127\n13\n"}, {"input": "5\n4 3\n1 2 1 3\n10 6\n8 7 1 8 3 7 0 10 8 9\n5 13\n20 100 50 20 100500\n10 25\n24 24 19 24 24 40 24 24 24 10\n8 8\n1 2 3 4 5 7...
code_stdio
[ { "content": "A queen is the strongest chess piece. In modern chess the queen can move any number of squares in any horizontal, vertical or diagonal direction (considering that there're no other pieces on its way). The queen combines the options given to the rook and the bishop.\n\nThere are m queens on a squar...
[{"input": "10 20\n6 10\n3 10\n10 4\n5 3\n9 4\n10 1\n10 3\n10 7\n8 5\n7 2\n4 7\n5 1\n2 9\n5 5\n6 6\n9 8\n2 10\n9 10\n1 4\n7 4\n", "output": "0 0 4 9 4 1 2 0 0\n"}, {"input": "100 10\n97 5\n53 35\n92 86\n54 95\n98 13\n36 23\n55 56\n96 94\n25 96\n49 31\n", "output": "6 4 0 0 0 0 0 0 0\n"}, {"input": "100 10\n97 5\n53 35\...
code_stdio
[ { "content": "When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us arithmetics from the start. And what is the best way...
[{"input": "|||||||||||||||||||||||||||||||||||||||||||||||||||+|||||||||||||||||||||||||||||||||||||||||||||||||||=||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n", "output": "||||||||||||||||||||||||||||||||||||||||||||||||||+|||||||||||||||||||||||||||||||||||||...
code_stdio
[ { "content": "Print all the integers that satisfies the following in ascending order:\n - Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.\n\n-----Constraints-----\n - 1 \\leq A \\leq B \\leq 10^9\n - 1 \\leq K \\leq 100\n - All values...
[{"input": "0 32 110", "output": "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n"}, {"input": "8 35 011", "output": "8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n"}, {"input": "8 39 011", "output": "8\n9...
code_stdio