messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
1 value
[ { "content": "10^9 contestants, numbered 1 to 10^9, will compete in a competition. There will be two contests in this competition.\n\nThe organizer prepared N problems, numbered 1 to N, to use in these contests. When Problem i is presented in a contest, it will be solved by all contestants from Contestant L_i t...
[{"input": "10\n457835016 1871204067\n456475528 529149798\n455108441 512701454\n455817105 523506955\n457368248 814532746\n455073228 459494089\n888688315 774276744\n457667152 974637457\n457293701 800549465\n456580262 636471526", "output": "1413369052"}, {"input": "10\n457835016 1799005777\n456475528 140431139\n455108441...
code_stdio
[ { "content": "Xenia is a girl being born a noble. Due to the inflexibility and harshness of her family, Xenia has to find some ways to amuse herself.\n\n<image>\n\nRecently Xenia has bought n_r red gems, n_g green gems and n_b blue gems. Each of the gems has a weight.\n\nNow, she is going to pick three gems.\n\...
[{"input": "5\n2 2 3\n7 8\n6 3\n3 1 4\n1 1 1\n1\n1\n1000000000\n2 2 2\n0 2\n5 4\n6 7\n2 2 2\n1 2\n3 4\n6 7\n3 4 1\n3 2 1\n7 3 3 4\n12\n", "output": "14\n1999999996000000002\n24\n24\n122\n"}, {"input": "5\n2 2 3\n7 8\n6 3\n3 0 4\n1 1 1\n1\n1\n1000000000\n2 2 2\n0 2\n5 4\n6 7\n2 2 2\n1 2\n3 4\n6 7\n3 4 1\n3 2 1\n7 3 3 4\...
code_stdio
[ { "content": "N people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i.\n\nMr. Takahashi, the shop owner, has decided on the following scheme: He picks a product, sets a positive integer P indicating its price...
[{"input": "15\n4\n1\n4\n1\n3\n18\n4\n12\n5\n3\n6\n8\n15\n12\n9", "output": "43\n"}, {"input": "15\n4\n1\n4\n1\n3\n18\n4\n12\n5\n3\n3\n8\n15\n12\n9", "output": "42\n"}, {"input": "15\n4\n1\n4\n1\n3\n31\n4\n8\n5\n3\n6\n8\n15\n7\n9", "output": "46\n"}, {"input": "15\n3\n1\n1\n1\n5\n15\n2\n6\n5\n3\n5\n8\n9\n6\n12", "outpu...
code_stdio
[ { "content": "Your program fails again. This time it gets \"Wrong answer on test 233\"\n\n.\n\nThis is the easier version of the problem. In this version 1 ≤ n ≤ 2000. You can hack this problem only if you solve and lock both problems.\n\nThe problem is about a test containing n one-choice-questions. Each of th...
[{"input": "100 100\n82 51 81 14 37 17 78 123 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 75 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 16 3 55 37 85 46 22 159 52 98 41 21 84 63 17 62 91\n", ...
code_stdio
[ { "content": "Amugae has a sentence consisting of $n$ words. He want to compress this sentence into one word. Amugae doesn't like repetitions, so when he merges two words into one word, he removes the longest prefix of the second word that coincides with a suffix of the first word. For example, he merges \"samp...
[{"input": "9\nL M5 M5D M5DAYBl0r6gmttCTR M5DAYBl0r6gmttCTRoKdM9EFrX22qBZpAc M5DAYBl0r6gmttCTRoKdM9EFrX22qBZpAczv7fKrVgg0xe M5DAYBl0r6gmttCTRoKdM9EFrX22qBZpAczv7fKrVhg0xe09re M5DAYBl0r6gmttCTRoKdM9EFrX22qBZpAczv7fKrVhg0xe09re M5DAYBl0r6gmttCTRoKdM9EFrX22qBZpAczv7fKrVhg0xe09re\n", "output": "LM5DAYBl0r6gmttCTRoKdM9EFrX2...
code_stdio
[ { "content": "There are n incoming messages for Vasya. The i-th message is going to be received after t_{i} minutes. Each message has a cost, which equals to A initially. After being received, the cost of a message decreases by B each minute (it can become negative). Vasya can read any message after receiving i...
[{"input": "108 576 610 844 573\n242 134 45 515 430 354 405 179 174 366 155 4 300 176 96 36 508 70 75 316 118 563 55 340 128 214 138 511 507 437 454 478 341 443 421 573 270 362 208 107 256 471 436 378 336 507 383 352 450 411 297 34 179 551 119 524 141 288 387 9 283 241 304 214 503 559 416 447 495 61 169 228 479 568 368...
code_stdio
[ { "content": "There is a plan view consisting of 12 vertical and 12 horizontal squares showing the terrain. Each square is painted white or black. White represents the sea and black represents the land. When two black squares touch each other vertically or horizontally, they are said to be continuous. In this p...
[{"input": "111100001111\n111000001111\n110000001110\n100000001111\n000100010000\n010000111010\n000001111100\n100011111110\n010101111100\n111000111000\n111100010000\n000000100000\n\n110001111100\n110010001010\n010010000001\n010000000001\n010000000110\n010000111000\n010000000000\n010000010010\n010000000001\n010010000001...
code_stdio
[ { "content": "Flatland is inhabited by pixels of three colors: red, green and blue. We know that if two pixels of different colors meet in a violent fight, only one of them survives the fight (that is, the total number of pixels decreases by one). Besides, if pixels of colors x and y (x ≠ y) meet in a violent f...
[{"input": "2147483630 2147483642 2147483610\n", "output": " 2147483630\n"}, {"input": "1944219055 454183506 1369298327\n", "output": " 1944219055\n"}, {"input": "772486757 1747374885 377299255\n", "output": " ...
code_stdio
[ { "content": "Masa Kita, who entered the University of Tokyo, joined a circle called TSG (University of Tokyo Super Gamers).\n\nThis circle exhibits games at the Komaba Festival every year, and Masa Kita decided to create and display the games as well.\n\nThe game created by Kitamasa is a common falling block p...
[{"input": "3\n......\n......\n......\n......\n......\n......\n......\n......\n.RGB..\nRGOP..\nRGBPB.\nRGBPP.\nGBRGYP\nGBRRYP\nBGGRBB\nBPRGYY\nGGPRRY\nBYPPRB\nYGGGPB\nGYYYPR\nYRBRBR\nYBRBRB\nBRBRBR\nBRBRBR\n......\n......\n......\n......\n......\n......\n......\n......\n.....-\n......\n..OO..\n..OO..", "output": "3\n18...
code_stdio
[ { "content": "ICP city has an express company whose trucks run from the crossing S to the crossing T. The president of the company is feeling upset because all the roads in the city are one-way, and are severely congested. So, he planned to improve the maximum flow (edge disjoint paths) from the crossing S to t...
[{"input": "3 3\n3 2\n1 2\n3 1\n1 3", "output": "2\n2\n1\n3"}, {"input": "4 1\n1 2\n2 1", "output": "1\n1\n1\n"}, {"input": "3 1\n1 2\n2 1", "output": "1\n1\n1\n"}, {"input": "4 1\n1 4\n4 1", "output": "1\n1\n1\n"}, {"input": "5 -1\n1 4\n4 11", "output": "0\n0\n"}, {"input": "11 -1\n1 4\n3 3", "output": "0\n0\n"}, {"in...
code_stdio
[ { "content": "A-Aun's breathing\n\nProblem Statement\n\nMaeda-san and Goto-san, who will both turn 70 years old in 2060, are long-time friends and friends who fought together at the ACM-ICPC in college.\n\nThe two are still excited about competitive programming, drinking tea together.\n\nWhen the two of us dran...
[{"input": "4\nA\nUn\nB\nUn", "output": "NO\n"}, {"input": "4\n@\nUn\nB\nUn", "output": "NO\n"}, {"input": "4\n@\nUn\nB\nnU", "output": "NO\n"}, {"input": "4\n@\nUn\nB\noU", "output": "NO\n"}, {"input": "4\n@\nUn\nA\noU", "output": "NO\n"}, {"input": "4\n@\nUn\nA\nUo", "output": "NO\n"}, {"input": "4\n@\nTn\nA\nUo", "o...
code_stdio
[ { "content": "Calculate the minimum number of characters you need to change in the string s, so that it contains at least k different letters, or print that it is impossible.\n\nString s consists only of lowercase Latin letters, and it is allowed to change characters only to lowercase Latin letters too.\n\n\n--...
[{"input": "smaxpqplaqqbxuqxalqmbmmgubbpspxhawbxsuqhhegpmmpebqmqpbbeplwaepxmsahuepuhuhwxeqmmlgqubuaxehwuwasgxpqmugbmuawuhwqlswllssueglbxepbmwgs\n1\n", "output": "0\n"}, {"input": "smaxpqplaqqbxuqxalqmbmmgubbpspxhawbxsuqhhegpmmpebqmqpbbeplwaepxmsahuepuhuhwxeqmmlgqubuaxehwuwasgxpqmugbmuawuhwqlswllssueglbxepbmwgs\n1\n", "...
code_stdio
[ { "content": "Polycarp has a strict daily schedule. He has n alarms set for each day, and the i-th alarm rings each day at the same time during exactly one minute.\n\nDetermine the longest time segment when Polycarp can sleep, i. e. no alarm rings in that period. It is possible that Polycarp begins to sleep in ...
[{"input": "70\n03:33\n23:36\n03:16\n18:18\n06:36\n06:58\n17:27\n04:07\n14:39\n15:53\n17:09\n05:16\n20:28\n09:34\n02:41\n14:18\n20:00\n04:14\n00:25\n20:18\n16:34\n10:13\n21:45\n11:08\n16:19\n20:50\n03:08\n05:06\n02:08\n02:51\n15:16\n11:02\n18:13\n18:35\n00:04\n08:50\n06:12\n20:16\n12:05\n04:01\n08:38\n03:57\n22:44\n04:...
code_stdio
[ { "content": "You are given two integers $l$ and $r$, $l\\le r$. Find the largest possible value of $a mod b$ over all pairs $(a, b)$ of integers for which $r\\ge a \\ge b \\ge l$.\n\nAs a reminder, $a mod b$ is a remainder we get when dividing $a$ by $b$. For example, $26 mod 8 = 2$.\n\n\n-----Input-----\n\nEa...
[{"input": "4\n1 1\n117772020 1000000000\n13 102\n1 1716228987\n", "output": "0\n499999999\n50\n858114493\n"}, {"input": "4\n1 1\n117772020 1010000000\n16 102\n2 1716228987\n", "output": "0\n504999999\n50\n858114493\n"}, {"input": "4\n1 1\n117772020 1000000000\n13 139\n1 1137810732\n", "output": "0\n499999999\n69\n5689...
code_stdio
[ { "content": "Relative B man came to A child's house. He is 3 years old and loves singing. He is singing the song \"Kobutanuki Tsuneko\" (written and composed by Naozumi Yamamoto), which he learned from kindergarten. In this song, the four words \"kobuta,\" \"raccoon dog,\" \"fox,\" and \"cat\" are arranged in ...
[{"input": "5\napple\nyellow\ngeorgia\ngnik\nemail\n7\napple\nyellow\ngeorgia\nking\nemail\nwink\nlucky\n0", "output": "NG\nOK\n"}, {"input": "5\napple\nyellow\ngeorgia\ngnik\nemail\n7\napple\nzellow\ngeorgia\nking\nemail\nwink\nlucky\n0", "output": "NG\nNG\n"}, {"input": "5\napple\nyellow\ngeorgia\ngnik\nemail\n7\napp...
code_stdio
[ { "content": "You are given an array a of length 2n. Consider a partition of array a into two subsequences p and q of length n each (each element of array a should be in exactly one subsequence: either in p or in q).\n\nLet's sort p in non-decreasing order, and q in non-increasing order, we can denote the sorte...
[{"input": "16\n433598100 998244362 998244362 393272824 998244362 998244362 998244362 998244362 998244362 79531025 1605828054 998244362 998244362 998244362 998244362 998244362 998244363 998244363 998244363 998244363 998244363 998244363 998244363 260228230 1941226836 998244363 1240344627 998244363 998244363 998244363 99...
code_stdio
[ { "content": "There are n cups of different sizes and three trays (bon festivals) A, B, and C, and these cups are placed on top of each of the three trays in a pile. However, in any tray, the smallest cup in the tray is on the bottom, the second smallest cup is on top, and the third smallest cup is on top, in a...
[{"input": "3 10\n0\n1 1\n2 2 3\n4 13\n1 1 2\n1 3\n1 4\n1 5\n2 1 2\n0\n0\n3 6\n0\n1 1\n2 2 3\n0 0", "output": "9\n-1\n0\n-1\n"}, {"input": "3 10\n0\n1 1\n2 2 3\n4 20\n2 1 2\n1 3\n1 4\n1 5\n2 1 2\n0\n0\n3 3\n0\n1 1\n2 2 3\n0 0", "output": "9\n3\n0\n-1\n"}, {"input": "3 10\n0\n1 1\n2 2 3\n4 7\n2 1 2\n1 2\n1 4\n1 5\n2 1 2...
code_stdio
[ { "content": "Today you are going to lead a group of elven archers to defend the castle that is attacked by an army of angry orcs. Three sides of the castle are protected by impassable mountains and the remaining side is occupied by a long wall that is split into n sections. At this moment there are exactly ai ...
[{"input": "100 100 1000\n814 165 709 628 263 653 940 749 331 437 129 547 575 73 480 429 396 688 489 312 425 946 444 228 547 512 477 849 53 241 643 416 141 502 449 58 686 111 171 844 113 790 79 107 399 846 945 427 361 68 295 630 260 939 679 458 485 738 202 141 166 940 5 73 108 351 245 998 640 772 604 123 389 758 491 34...
code_stdio
[ { "content": "One of Arkady's friends works at a huge radio telescope. A few decades ago the telescope has sent a signal $s$ towards a faraway galaxy. Recently they've received a response $t$ which they believe to be a response from aliens! The scientists now want to check if the signal $t$ is similar to $s$.\n...
[{"input": "01\nzbrronwaofovklkopelo\n", "output": "19\n"}, {"input": "01\nzbrronwaofovklkopelo\n", "output": "19\n"}, {"input": "01\nzbrronwaofovklkopeln\n", "output": "19\n"}, {"input": "01\nzbrrnnwaofovklkopeln\n", "output": "19\n"}, {"input": "01\nzbrrnnwaofovklkopelo\n", "output": "19\n"}, {"input": "01\nzbrrnnwbo...
code_stdio
[ { "content": "Три брата договорились о встрече. Пронумеруем братьев следующим образом: пусть старший брат имеет номер 1, средний брат имеет номер 2, а младший брат — номер 3. \n\nКогда пришло время встречи, один из братьев опоздал. По заданным номерам двух братьев, которые пришли вовремя, вам предстоит определи...
[{"input": "3 1\n", "output": "2\n"}, {"input": "2 1\n", "output": "3\n"}, {"input": "2 3\n", "output": "1\n"}, {"input": "1 2\n", "output": "3\n"}, {"input": "1 3\n", "output": "2\n"}, {"input": "3 2\n", "output": "1\n"}]
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 group is p...
[{"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": "Amr loves Chemistry, and specially doing experiments. He is preparing for a new interesting experiment.\n\nAmr has n different types of chemicals. Each chemical i has an initial volume of a_{i} liters. For this experiment, Amr has to mix all the chemicals together, but all the chemicals volumes mu...
[{"input": "20\n1 2 3 4 6 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 100000\n", "output": "113\n"}, {"input": "20\n1 2 3 4 6 8 16 32 64 128 256 512 1024 2048 3647 8192 16384 32768 65536 100000\n", "output": "124\n"}, {"input": "20\n1 2 3 4 6 8 16 32 8 128 256 512 1024 2048 3647 13320 16384 32768 65536...
code_stdio
[ { "content": "Problem B Parallel Lines\n\nGiven an even number of distinct planar points, consider coupling all of the points into pairs. All the possible couplings are to be considered as long as all the given points are coupled to one and only one other point.\n\nWhen lines are drawn connecting the two points...
[{"input": "4\n-1 -1\n1 1\n-1 4\n0 5", "output": "1\n"}, {"input": "4\n-2 -1\n1 1\n-1 4\n0 5", "output": "0\n"}, {"input": "4\n-1 0\n1 1\n-1 2\n2 2", "output": "0\n"}, {"input": "4\n0 -1\n1 1\n-1 2\n2 3", "output": "0\n"}, {"input": "4\n-1 0\n1 1\n-1 2\n1 2", "output": "1\n"}, {"input": "4\n0 -1\n1 1\n-1 2\n2 5", "outp...
code_stdio
[ { "content": "We have N integers. The i-th number is A_i.\n\\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\\leq i < j \\leq N.\n\\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\\ldots,A_N)=1.\nDetermine if \\{A_i\\} ...
[{"input": "3\n6 10 15\n", "output": "setwise coprime\n"}, {"input": "3\n17 10 15", "output": "setwise coprime\n"}, {"input": "3\n26 10 15", "output": "setwise coprime\n"}, {"input": "3\n7 10 31", "output": "pairwise coprime\n"}, {"input": "3\n3 4 5\n", "output": "pairwise coprime\n"}, {"input": "3\n7 19 4", "output": ...
code_stdio
[ { "content": "Let's define the sum of two permutations p and q of numbers 0, 1, ..., (n - 1) as permutation [Image], where Perm(x) is the x-th lexicographically permutation of numbers 0, 1, ..., (n - 1) (counting from zero), and Ord(p) is the number of permutation p in the lexicographical order.\n\nFor example,...
[{"input": "84\n83 4 68 34 24 2 48 38 22 51 5 62 31 67 66 53 49 70 9 71 46 41 30 8 50 17 28 79 15 80 32 43 14 74 29 42 81 60 56 65 23 0 77 76 58 78 1 11 37 27 75 35 18 73 54 20 57 33 36 6 61 69 64 55 39 10 3 45 13 26 59 82 21 25 63 52 16 44 47 72 19 12 7 40\n63 41 80 52 36 45 17 69 22 66 37 21 46 44 64 9 48 74 58 81 10...
code_stdio
[ { "content": "Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.\n\nHe wants to know how many subsequences of length three can be selected from a, so that...
[{"input": "18 10\n10000000 100000000 1000000000 -10000000 -100000000 -1000000000 -10000000 -100000000 -1000000000 -10000000 -100000000 -1000000000 10000000 100000000 1000000000 10000000 100000000 1000000000\n", "output": "20\n"}, {"input": "18 10\n10000000 100000000 1000000000 -10000000 -100000000 -1000000000 -1000000...
code_stdio
[ { "content": "There are three sticks with integer lengths $l_1, l_2$ and $l_3$.\n\nYou are asked to break exactly one of them into two pieces in such a way that:\n\nboth pieces have positive (strictly greater than $0$) integer length;\n\nthe total length of the pieces is equal to the original length of the stic...
[{"input": "68\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1 2\n1 1...
code_stdio
[ { "content": "On the great island of Baltia, there live N people, numbered from 1 to N. There are exactly M pairs of people that are friends with each other. The people of Baltia want to organize a successful party, but they have very strict rules on what a party is and when the party is successful. On the isla...
[{"input": "20 57\n13 14\n12 20\n18 3\n17 20\n15 9\n18 13\n12 19\n2 4\n9 2\n12 11\n14 1\n16 11\n11 14\n16 4\n16 15\n11 19\n15 4\n10 15\n12 5\n9 3\n10 2\n10 4\n20 19\n14 7\n19 2\n5 8\n6 14\n4 17\n2 17\n17 9\n13 9\n19 9\n18 8\n12 16\n18 5\n7 1\n8 3\n11 20\n6 13\n20 5\n13 8\n17 19\n7 6\n9 11\n18 9\n13 1\n12 14\n7 3\n10 16...
code_stdio
[ { "content": "You might have heard about the next game in Lara Croft series coming out this year. You also might have watched its trailer. Though you definitely missed the main idea about its plot, so let me lift the veil of secrecy.\n\nLara is going to explore yet another dangerous dungeon. Game designers deci...
[{"input": "636553724 546535019 115079316355948443\n", "output": "425992073 546535018\n"}, {"input": "548492800 434105920 179638683192075937\n", "output": "134679777 434105920\n"}, {"input": "595261150 794915864 332353903994901365\n", "output": "177161677 794915848\n"}, {"input": "636553724 546535019 115079316355948443...
code_stdio
[ { "content": "Tyndex is again well ahead of the rivals! The reaction to the release of Zoozle Chrome browser was the release of a new browser Tyndex.Brome!\n\nThe popularity of the new browser is growing daily. And the secret is not even the Tyndex.Bar installed (the Tyndex.Bar automatically fills the glass wit...
[{"input": "20 10\niwbiucrjoj\nqvjewvdrgwgc\newwqyhtdzakryafqaacimthycyasyb\ncuoscayekvbsqokyfdmjnojkjennf\nhkuv\njtdgbespjdtbc\ngeulitsrlqihoujvwuobnfospq\nzphnlqxacchxhyeehnpfwdjnwvj\nxicsaoyfgtdbwqfrdgaiyn\natgshewfkuxaipizcdev\nvp\nyblkfmqsj\nyevxolvycyrrooosberqzrabefdckg\nrytykrlgttc\nafphunqbtydppxotf\nnkfoatpik...
code_stdio
[ { "content": "Let's play a game using a robot on a rectangular board covered with a square mesh (Figure D-1). The robot is initially set at the start square in the northwest corner facing the east direction. The goal of this game is to lead the robot to the goal square in the southeast corner.\n\n<image>\n\nFig...
[{"input": "8 3\n0 0 -1 1 0 0 0 1\n2 3 1 2 3 0 0 1\n3 3 0 0 0 1 -1 4\n11 9 2 9\n4 4\n3 3 4 0\n1 2 4 4\n0 1 1 0\n0 2 4 4\n16 7 2 1\n2 8\n2 1\n4 1\n0 4\n1 3\n1 0\n2 1\n0 6\n1 4\n1 9 3 1\n0 0", "output": "13\n11\n5\n"}, {"input": "8 3\n0 0 0 0 -1 0 0 1\n2 3 0 1 4 0 0 1\n3 3 0 0 0 -1 0 8\n9 9 1 9\n4 4\n3 3 4 0\n1 1 4 4\n1 ...
code_stdio
[ { "content": "Petya was late for the lesson too. The teacher gave him an additional task. For some array a Petya should find the number of different ways to select non-empty subset of elements from it in such a way that their product is equal to a square of some integer.\n\nTwo ways are considered different if ...
[{"input": "20\n20 34 51 40 70 64 14 30 24 20 6 1 70 28 38 43 9 60 31 69\n", "output": "2047\n"}, {"input": "20\n20 34 51 40 70 64 14 30 24 20 6 1 70 28 38 43 9 60 31 69\n", "output": "2047\n"}, {"input": "18\n22 41 40 8 36 48 23 5 58 12 26 44 53 49 3 56 58 57\n", "output": "127\n"}, {"input": "18\n22 41 40 8 36 48 23 ...
code_stdio
[ { "content": "Let's call a number k-good if it contains all digits not exceeding k (0, ..., k). You've got a number k and an array a containing n numbers. Find out how many k-good numbers are in a (count each number every time it occurs in array a).\n\n\n-----Input-----\n\nThe first line contains integers n and...
[{"input": "10 6\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n", "output": "10\n"}, {"input": "10 6\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n", "output": "10\n"}, {"input": "10 6\n2416023\n1234560\n1234560\n1234560\n1234560\...
code_stdio
[ { "content": "Zhinü was a child of the Emperor, but he was weaving the machine even if he opened it at the request of his father.\n\nIt was a pleasure of the Emperor to wear clothes made of a splendid cloth called Unnishiki woven by Zhinü. Unnishiki has a short lifespan and deteriorates quickly, but there was n...
[{"input": "5\n0 4 0 2 9 3 4 8 2 -1\n3 8 -1 0 0 3 1 2 17 54\n1 2 1 2 41 2 17 21 11 0\n-2 2 14 24 0 21 1 14 20 4\n7 6 30 0 10 1 22 -2 8 -1", "output": "NG\nNG\nNG\nOK\nNG\n"}, {"input": "5\n0 4 -1 2 7 3 4 8 2 -1\n3 5 -1 0 0 3 0 6 8 62\n1 4 1 0 76 4 17 2 11 0\n-2 2 14 24 -1 27 0 14 28 3\n7 -1 30 0 0 1 37 -2 0 -1", "outpu...
code_stdio
[ { "content": "Once N boys and M girls attended a party. You are given a matrix A of N rows and M columns where Aij is 1 if the i-th boy likes the j-th girl, otherwise it will be 0. Note that it is not necessary that if a boy x likes girl y, then girl y should like boy x.\nYou know that if there are two differen...
[{"input": "2\n4 3\n101\n111\n111\n011\n2 -1\n10\n01", "output": "12\n0\n"}, {"input": "2\n4 3\n101\n101\n111\n011\n2 0\n10\n01", "output": "10\n0\n"}, {"input": "2\n4 3\n101\n101\n110\n000\n-1 1\n10\n01", "output": "4\n0\n"}, {"input": "2\n4 3\n100\n101\n110\n000\n-1 1\n10\n01", "output": "3\n0\n"}, {"input": "2\n4 3\...
code_stdio
[ { "content": "Ataru Oafoot of Aizu Gakuen University High School decided to play with a slot machine.\n\nWhen you insert a medal on this machine, three reels will start spinning and each reel will stop automatically. In a normal game (normal game), 3 medals are inserted, and when the symbols are aligned, the fo...
[{"input": "3 2 30 3 41 226\n9 0 18 4 20 118\n5 5 12 0 15 203\n13 4 19 2 22 197\n7 4 24 4 17 209\n0 0 0 0 0 0", "output": "172\n795\n410\n1199\n617\n"}, {"input": "3 2 30 3 41 226\n9 0 36 4 20 118\n5 5 12 0 18 203\n13 4 19 2 22 197\n1 4 42 4 17 209\n0 0 0 0 0 0", "output": "172\n921\n419\n1199\n173\n"}, {"input": "3 2 ...
code_stdio
[ { "content": "Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.\n\nConstraints\n\n* $0 \\leq a, b \\leq 2^{32} - 1$\n\nInput\n\nThe input is given in the fol...
[{"input": "-136 -1", "output": "11111111111111111111111101111000\n11111111111111111111111111111111\n00000000000000000000000010000111\n"}, {"input": "-104 -3", "output": "11111111111111111111111110011000\n11111111111111111111111111111101\n00000000000000000000000001100101\n"}, {"input": "-104 -5", "output": "11111111111...
code_stdio
[ { "content": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\...
[{"input": "1000\n", "output": "44\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 54 \n"}, {"input": "990\n", "output": "44\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 4...
code_stdio
[ { "content": "You are going to the beach with the idea to build the greatest sand castle ever in your head! The beach is not as three-dimensional as you could have imagined, it can be decribed as a line of spots to pile up sand pillars. Spots are numbered 1 through infinity from left to right. \n\nObviously, th...
[{"input": "1000000000000000000 1000000000000000000\n", "output": "1414213562\n"}, {"input": "1000000000000000000 1000000000000000000\n", "output": "1414213562\n"}, {"input": "999999997351043581 1000000000000000000\n", "output": "1414213561\n"}, {"input": "999999997351043581 1000000000000000000\n", "output": "141421356...
code_stdio
[ { "content": "After battling Shikamaru, Tayuya decided that her flute is too predictable, and replaced it with a guitar. The guitar has $6$ strings and an infinite number of frets numbered from $1$. Fretting the fret number $j$ on the $i$-th string produces the note $a_{i} + j$.\n\nTayuya wants to play a melody...
[{"input": "58260522 32004256 2436426 24979445 61648772 23690081\n10\n582107247 906728404 411434947 673536177 411497300 488012525 1035611341 800305059 992325267 138720156\n", "output": "837678839\n"}, {"input": "58260522 32004256 2436426 24979445 12477970 11891566\n10\n582107247 906728404 411434947 673536177 411497300 ...
code_stdio
[ { "content": "Little Petya likes permutations a lot. Recently his mom has presented him permutation q_1, q_2, ..., q_{n} of length n.\n\nA permutation a of length n is a sequence of integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ n), all integers there are distinct. \n\nThere is only one thing Petya likes more than ...
[{"input": "55 28\n25 13 15 37 5 7 42 9 50 8 14 21 3 30 29 38 1 51 52 20 16 27 6 41 48 4 49 32 2 44 55 10 33 34 54 23 40 26 12 31 39 28 43 46 53 19 22 35 36 47 24 17 11 45 18\n17 29 13 26 5 23 6 10 8 32 53 39 2 11 3 21 52 55 46 20 12 47 36 51 1 38 22 42 15 14 40 28 33 34 48 49 4 16 41 37 24 7 43 30 54 44 50 25 27 9 18 ...
code_stdio
[ { "content": "You are given an array $a_1, a_2, \\dots , a_n$ and two integers $m$ and $k$.\n\nYou can choose some subarray $a_l, a_{l+1}, \\dots, a_{r-1}, a_r$. \n\nThe cost of subarray $a_l, a_{l+1}, \\dots, a_{r-1}, a_r$ is equal to $\\sum\\limits_{i=l}^{r} a_i - k \\lceil \\frac{r - l + 1}{m} \\rceil$, wher...
[{"input": "44 2 531595322\n926215961 -385821837 -278841122 -422772006 -509196878 -81824369 -101501043 -33095577 -520514931 402836017 48602657 881104200 -110528684 52550046 -208588735 -814534121 -548420443 410430115 -636402169 -848516069 -70639158 775203498 -679440929 -427359667 33598904 656872639 -225600926 57010433 -...
code_stdio
[ { "content": "You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.\n\nYou are really curious about prime numbers. ...
[{"input": "10 10\n20 53 6 97 74 12 92 48 13 97\n157 47 32 75 21 69 75 95 54 1\n97 36 1 41 87 1 23 39 44 27\n97 73 1 1 26 6 3 48 69 5\n70 93 42 35 5 12 22 33 29 13\n96 8 13 69 40 91 5 19 16 33\n61 92 54 82 60 24 63 64 59 65\n76 44 60 37 29 16 50 74 59 59\n77 58 95 30 52 25 34 2 49 92\n37 65 12 77 68 33 30 39 16 85\n", ...
code_stdio
[ { "content": "Vasya is developing his own programming language VPL (Vasya Programming Language). Right now he is busy making the system of exceptions. He thinks that the system of exceptions must function like that.\n\nThe exceptions are processed by try-catch-blocks. There are two operators that work with the ...
[{"input": "21\n try \n try \n try \n try \n try \n try \n try \n try \n try \n try \n throw( qtSMze) \ncatch(LY,\"x3 j\")\ncatch(hgSAFgbMGx,\"moByu\")\ncatch(LmydVQgv,\"hbZl\")\ncatch(oK,\"B6OZx qy\")\ncatch(rrtnRQB,\"7VFkQMv\")\ncatch(CASqQXaz,\"d9oci1Kx\")\ncatch(CTCzsdD,\"u\")\ncatch(xqqMxbE...
code_stdio
[ { "content": "Vasya has started watching football games. He has learned that for some fouls the players receive yellow cards, and for some fouls they receive red cards. A player who receives the second yellow card automatically receives a red card.\n\nVasya is watching a recorded football match now and makes no...
[{"input": "KASFLS\nASJBGGDLJFDDFHHTHJH\n42\n2 a 68 y\n4 h 64 r\n5 a 24 y\n6 h 20 r\n2 a 16 r\n9 a 96 y\n10 h 36 r\n12 a 44 y\n13 h 69 r\n16 a 62 r\n18 a 99 r\n20 h 12 r\n21 a 68 y\n25 h 40 y\n26 h 54 r\n28 h 91 r\n29 a 36 r\n33 a 91 y\n36 h 93 r\n37 h 60 r\n38 a 82 r\n41 a 85 y\n42 a 62 r\n46 a 22 r\n48 a 88 r\n49 a 8...
code_stdio
[ { "content": "Petya and Vasya are brothers. Today is a special day for them as their parents left them home alone and commissioned them to do n chores. Each chore is characterized by a single parameter — its complexity. The complexity of the i-th chore equals hi.\n\nAs Petya is older, he wants to take the chore...
[{"input": "150 10 140\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 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": "The Rebel fleet is on the run. It consists of m ships currently gathered around a single planet. Just a few seconds ago, the vastly more powerful Empire fleet has appeared in the same solar system, and the Rebels will need to escape into hyperspace. In order to spread the fleet, the captain of eac...
[{"input": "30\n(89+76)/87\n(81+78)/18\n(60+97)/32\n(41+14)/48\n(55+65)/27\n(29+15)/95\n(64+13)/96\n(78+30)/75\n(43+6)/60\n(69+34)/48\n(62+2)/97\n(85+42)/3\n(4+97)/42\n(1+18)/39\n(46+55)/76\n(22+59)/24\n(62+81)/98\n(64+8)/51\n(9+59)/48\n(47+2)/80\n(33+74)/76\n(61+83)/44\n(86+4)/51\n(65+41)/49\n(53+36)/45\n(6+19)/15\n(5...
code_stdio
[ { "content": "Taro is an elementary school student who has just learned multiplication. Somehow, he likes multiplication, so when he sees numbers, he wants to multiply. He seems to like to do the following for integers greater than or equal to 0. (Processing flow)\n\n* Procedure 1. If a certain integer n greate...
[{"input": "2\n999999\n1000100", "output": "12\n2\n"}, {"input": "2\n999999\n1010100", "output": "12\n3\n"}, {"input": "2\n999999\n1010110", "output": "12\n5\n"}, {"input": "2\n999999\n1101100", "output": "12\n4\n"}, {"input": "2\n114494\n1101001", "output": "11\n5\n"}, {"input": "2\n114494\n1111001", "output": "11\n7\...
code_stdio
[ { "content": "You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:\n\n* Append one of the following at the end of T: `dream`, `dreamer`, `erase` ...
[{"input": "resaremaerd", "output": "NO\n"}, {"input": "ersaremaerd", "output": "NO\n"}, {"input": "ersaremadrd", "output": "NO\n"}, {"input": "ersarfmadrd", "output": "NO\n"}, {"input": "errarfmadrd", "output": "NO\n"}, {"input": "errarfmadrc", "output": "NO\n"}, {"input": "arrerfmadrc", "output": "NO\n"}, {"input": "...
code_stdio
[ { "content": "One day Vasya was on a physics practical, performing the task on measuring the capacitance. He followed the teacher's advice and did as much as n measurements, and recorded the results in the notebook. After that he was about to show the results to the teacher, but he remembered that at the last l...
[{"input": "100\n4204 4719 4688 3104 4012 4927 4696 4614 4826 4792 3891 4672 4914 4740 4968 3879 4424 4755 3856 3837 4965 4939 4030 4941 4504 4668 4908 4608 3660 4822 4846 3945 4539 4819 4895 3746 4324 4233 4135 4956 4983 4546 4673 4617 3533 4851 4868 4838 4998 4769 4899 4578 3841 4974 4627 4990 4524 4939 4469 4233 443...
code_stdio
[ { "content": "Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearly see that there exists a unique shortes...
[{"input": "10\n2 37526406560905229 37526426361107171\n2 37526424114740747 18763396439955441\n2 300485276957081578 301492476099962199\n1 75035386466351570 441803674395985082 642312512\n2 300197522144700185 220954108245114486\n1 150105696341181576 559187296 100113944\n1 300197522135707767 150242638470761995 170574370\n2...
code_stdio
[ { "content": "There is a right triangle ABC with ∠ABC=90°.\nGiven the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.\nIt is guaranteed that the area of the triangle ABC is an integer.\n\n-----Constraints-----\n - 1 \\leq |AB|,|BC|,|CA| \\leq 100\n - All values in input ...
[{"input": "28 96 100\n", "output": "1344\n"}, {"input": "35 84 91\n", "output": "1470\n"}, {"input": "77 36 85\n", "output": "1386\n"}, {"input": "32 69 101", "output": "1104\n"}, {"input": "45 28 53\n", "output": "630\n"}, {"input": "24 10 26\n", "output": "120\n"}, {"input": "13 84 85\n", "output": "546\n"}, {"input...
code_stdio
[ { "content": "Tenten runs a weapon shop for ninjas. Today she is willing to sell n shurikens which cost 1, 2, ..., n ryo (local currency). During a day, Tenten will place the shurikens onto the showcase, which is empty at the beginning of the day. Her job is fairly simple: sometimes Tenten places another shurik...
[{"input": "10\n+\n- 3\n+\n+\n+\n+\n- 1\n- 7\n- 9\n- 10\n+\n+\n+\n- 4\n- 5\n- 8\n+\n- 6\n+\n- 2\n", "output": "YES\n3 10 9 7 1 8 5 4 6 2 "}, {"input": "10\n+\n- 1\n+\n+\n+\n+\n- 1\n- 7\n- 9\n- 10\n+\n+\n+\n- 7\n- 10\n- 8\n+\n+\n- 6\n- 2\n", "output": "NO\n"}, {"input": "10\n+\n- 3\n+\n+\n+\n+\n- 1\n- 7\n- 9\n- 10\n+\n+...
code_stdio
[ { "content": "You are given an array of positive integers. While there are at least two equal elements, we will perform the following operation. We choose the smallest value $x$ that occurs in the array $2$ or more times. Take the first two occurrences of $x$ in this array (the two leftmost occurrences). Remove...
[{"input": "34\n967614464 967614464 1000000000 1000000000 1000000000 1000000000 1000000000 1010000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100000000...
code_stdio
[ { "content": "There are N students and M checkpoints on the xy-plane.\n\nThe coordinates of the i-th student (1 \\leq i \\leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \\leq j \\leq M) is (c_j,d_j).\n\nWhen the teacher gives a signal, each student has to go to the nearest checkpoint m...
[{"input": "50 50\n-87868672 9773500\n38180447 36636308\n-93470873 38029088\n49678522 -87311634\n62792334 -82584220\n50941177 2445768\n-21746015 -16856077\n-69539173 -40150977\n-82915111 -60619217\n-42155179 93071641\n-3205477 16657057\n26789545 -1410866\n-32360553 -38239433\n-69707837 59109468\n-8767620 51549299\n-195...
code_stdio
[ { "content": "You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N.\nYou can perform the following operation any number of times (possibly zero):\nOperation: Swap two adjacent elements in the permutation.\nYou want to have p_i ≠ i for all 1≤i≤N.\nFind the minimum required number of operations to a...
[{"input": "9\n1 4 1 2 3 10 2 12 14", "output": "1\n"}, {"input": "9\n1 4 0 2 3 10 2 12 14", "output": "1\n"}, {"input": "9\n1 1 0 2 3 10 2 12 14", "output": "1\n"}, {"input": "9\n1 1 1 2 3 10 2 12 14", "output": "1\n"}, {"input": "9\n1 4 1 2 3 10 2 6 10", "output": "1\n"}, {"input": "9\n1 4 1 2 3 10 2 6 14", "output":...
code_stdio
[ { "content": "AtCoDeer the deer has found two positive integers, a and b.\nDetermine whether the concatenation of a and b in this order is a square number.\n\n-----Constraints-----\n - 1 ≤ a,b ≤ 100\n - a and b are integers.\n\n-----Input-----\nInput is given from Standard Input in the following format:\na b\n\...
[{"input": "100 100\n", "output": "No\n"}, {"input": "000 001", "output": "Yes\n"}, {"input": "010 000", "output": "Yes\n"}, {"input": "000 000", "output": "Yes\n"}, {"input": "000 100", "output": "Yes\n"}, {"input": "110 100", "output": "No\n"}, {"input": "101 100", "output": "No\n"}, {"input": "101 101", "output": "N...
code_stdio
[ { "content": "In a strategic computer game \"Settlers II\" one has to build defense structures to expand and protect the territory. Let's take one of these buildings. At the moment the defense structure accommodates exactly n soldiers. Within this task we can assume that the number of soldiers in the defense st...
[{"input": "100 100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100...
code_stdio
[ { "content": "We all know that GukiZ often plays with arrays. \n\nNow he is thinking about this problem: how many arrays a, of length n, with non-negative elements strictly less then 2l meet the following condition: <image>? Here operation <image> means bitwise AND (in Pascal it is equivalent to and, in C/C++/J...
[{"input": "1000000000000000000 1000000000000000000 64 1000000007\n", "output": "818137911\n"}, {"input": "1000000000000000000 1000000000000000100 64 1000000007\n", "output": "705677915\n"}, {"input": "85689952135646564 456465135103154 61 554556465\n", "output": "526174733\n"}, {"input": "94056881908542814 456465135103...
code_stdio
[ { "content": "Recently, Duff has been practicing weight lifting. As a hard practice, Malek gave her a task. He gave her a sequence of weights. Weight of i-th of them is 2wi pounds. In each step, Duff can lift some of the remaining weights and throw them away. She does this until there's no more weight left. Mal...
[{"input": "100\n196 1681 196 0 61 93 196 196 196 196 196 0 0 96 18 1576 0 93 666463 18 93 1 1278 8939 93 196 196 1278 3 0 67416 869956 10 56489 196 745 39 783 196 8939 196 81 69634 4552 39 3 14 20 25 8 10 4 7302 0 19579 20 1140 15990 7302 0 19579 4142 11 1354 75252 93 311 1278 0 79475 10 75252 93 7302 0 81 408441 1957...
code_stdio
[ { "content": "There was an electronic store heist last night.\n\nAll keyboards which were in the store yesterday were numbered in ascending order from some integer number $x$. For example, if $x = 4$ and there were $3$ keyboards in the store, then the devices had indices $4$, $5$ and $6$, and if $x = 10$ and th...
[{"input": "40\n194 121 110 134 172 142 195 135 186 187 128 161 185 132 117 175 178 131 143 151 170 181 188 140 133 145 119 129 179 149 109 123 124 106 100 199 197 155 141 183\n", "output": "60\n"}, {"input": "40\n194 121 110 134 172 142 195 135 186 187 128 161 185 132 117 175 178 131 143 151 170 181 188 140 133 145 11...
code_stdio
[ { "content": "Once Bob took a paper stripe of n squares (the height of the stripe is 1 square). In each square he wrote an integer number, possibly negative. He became interested in how many ways exist to cut this stripe into three pieces so that the sum of numbers from each piece is equal to the sum of numbers...
[{"input": "100\n3 0 -5 2 -3 -1 -1 0 -2 -5 -4 2 1 2 -2 -1 -1 -4 3 -1 -3 -1 5 0 -4 -4 -1 0 -2 -2 0 1 -1 -2 -1 -5 -4 -2 3 1 -3 0 -1 1 0 -1 2 0 -2 -1 -3 1 -2 2 3 2 -3 -5 2 2 -2 -2 1 2 -2 -1 3 0 -4 7 -2 2 1 4 -9 -1 -2 -1 0 -1 0 -2 -2 -1 1 1 -4 2 -3 -3 7 1 1 -3 -7 0 -2 0 5 -2\n", "output": "5\n"}, {"input": "100\n3 0 -5 2 -...
code_stdio
[ { "content": "Let x be an array of integers x = [x_1, x_2, ..., x_n]. Let's define B(x) as a minimal size of a partition of x into subsegments such that all elements in each subsegment are equal. For example, B([3, 3, 6, 1, 6, 6, 6]) = 4 using next partition: [3, 3\\ |\\ 6\\ |\\ 1\\ |\\ 6, 6, 6].\n\nNow you don...
[{"input": "5\n1 1 1 1 1\n1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "530612279\n"}, {"input": "10\n10 1 9 3 9 4 10 3 8 5\n10 1 10 14 12 4 10 4 10 7\n", "output": "875000103\n"}, {"input": "10\n10 1 9 3 9 4 10 3 8 5\n10 2 10 14 12 4 10 4 10 7\n", "output": "875000103\n"}, {"input": "10\n10 1 9...
code_stdio
[ { "content": "You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called health, and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below.\nFortunately, you are a skilled magician, c...
[{"input": "5 2 1\n900000000\n900000000\n1000000000\n1000000000\n1000000000\n", "output": "800000000\n"}, {"input": "5 2 1\n105611412\n1737860309\n1010000000\n1000000101\n1100000000", "output": "969572082\n"}, {"input": "5 3 1\n105611412\n1151487296\n1010000000\n1000000101\n1100000000", "output": "710247900\n"}, {"inpu...
code_stdio
[ { "content": "Ilya is an experienced player in tic-tac-toe on the 4 × 4 field. He always starts and plays with Xs. He played a lot of games today with his friend Arseny. The friends became tired and didn't finish the last game. It was Ilya's turn in the game when they left it. Determine whether Ilya could have ...
[{"input": "xx..\n.oo.\nx...\noox.\n", "output": "YES\n"}, {"input": "x..x\n..oo\no...\nx.xo\n", "output": "YES\n"}, {"input": ".xox\no.x.\nx.o.\n..o.\n", "output": "YES\n"}, {"input": "o.oo\n.x.o\nx.x.\n.x..\n", "output": "YES\n"}, {"input": ".xx.\n.xoo\n.oox\n....\n", "output": "YES\n"}, {"input": "xxox\no.x.\nx.oo\n...
code_stdio
[ { "content": "Sehr Sus is an infinite hexagonal grid as pictured below, controlled by MennaFadali, ZerooCool and Hosssam.\n\nThey love equilateral triangles and want to create $n$ equilateral triangles on the grid by adding some straight lines. The triangles must all be empty from the inside (in other words, no...
[{"input": "10\n45996\n1494\n17871\n87082\n59317\n76537\n37514\n56796\n60195\n80410\n", "output": "263\n48\n164\n362\n299\n339\n238\n292\n301\n348\n"}, {"input": "5\n66\n6666\n666666\n66666666\n666666666\n", "output": "10\n100\n1000\n10000\n31623\n"}, {"input": "3\n390\n398\n285\n", "output": "25\n25\n21\n"}, {"input":...
code_stdio
[ { "content": "Problem\n\nKND is a student programmer at the University of Aizu. His neighbor is known to be very annoying. Neighbors find out that he is a sweet tooth and plan to add more sweetness than necessary to make him fat. To that end, your neighbor, you, was introduced to a sweets shop by a friend.\n\nH...
[{"input": "3 3 100\n2\n5 20 3 10\n2\n13 50 16 60\n2\n8 30 22 100\n0 1 2\n\n1 1 30\n1\n13 16\n0", "output": "27 100\n13 16\n"}, {"input": "3 3 100\n2\n5 20 3 10\n2\n13 60 16 60\n2\n8 30 22 100\n0 1 2\n\n1 1 30\n1\n13 17\n0", "output": "27 100\n13 17\n"}, {"input": "3 3 100\n2\n5 20 3 10\n2\n13 60 16 41\n2\n8 30 22 100\...
code_stdio
[ { "content": "Given N integers A_1, ..., A_N, compute A_1 \\times ... \\times A_N.\nHowever, if the result exceeds 10^{18}, print -1 instead.\n\n-----Constraints-----\n - 2 \\leq N \\leq 10^5\n - 0 \\leq A_i \\leq 10^{18}\n - All values in input are integers.\n\n-----Input-----\nInput is given from Standard Inp...
[{"input": "31\n4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0\n", "output": "0\n"}, {"input": "31\n4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 0 2 7 9 5 0", "output": "0\n"}, {"input": "31\n4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0", "output": "0"}, {"input": "2\n1000000000 100...
code_stdio
[ { "content": "There are n workers in a company, each of them has a unique id from 1 to n. Exaclty one of them is a chief, his id is s. Each worker except the chief has exactly one immediate superior.\n\nThere was a request to each of the workers to tell how how many superiors (not only immediate). Worker's supe...
[{"input": "10 10\n3 0 0 0 0 0 1 1 1 0\n", "output": "5\n"}, {"input": "10 10\n3 0 0 0 0 0 1 0 1 0\n", "output": "6\n"}, {"input": "10 10\n3 0 0 0 0 1 1 0 1 0\n", "output": "5\n"}, {"input": "10 10\n3 0 0 0 1 1 1 0 1 0\n", "output": "4\n"}, {"input": "10 10\n3 0 0 0 0 2 1 0 1 0\n", "output": "5\n"}, {"input": "10 6\n3 ...
code_stdio
[ { "content": "Once upon a time, Oolimry saw a suffix array. He wondered how many strings can produce this suffix array.\n\nMore formally, given a suffix array of length $n$ and having an alphabet size $k$, count the number of strings that produce such a suffix array.\n\nLet $s$ be a string of length $n$. Then t...
[{"input": "73 95\n4 53 37 9 45 54 16 34 12 10 13 24 2 36 33 48 50 43 15 11 47 42 46 30 27 52 67 72 66 19 56 61 69 21 68 1 70 49 64 62 3 51 44 65 29 25 38 28 8 5 39 59 17 6 26 20 63 7 41 23 22 32 40 14 57 60 55 31 35 58 18 0 71\n", "output": "423380456"}, {"input": "73 95\n4 53 37 9 45 54 16 34 12 10 13 24 2 36 33 48 5...
code_stdio
[ { "content": "We have N squares assigned the numbers 1,2,3,\\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i.\n\nHow many squares i satisfy both of the following conditions?\n\n* The assigned number, i, is odd.\n* The written integer is odd.\n\nConstraints\n\n* All ...
[{"input": "15\n1 10 145 15 87 138 51 194 1 18 77 20 9 17 93", "output": "8\n"}, {"input": "15\n15 11 46 15 50 98 93 129 31 43 44 11 6 24 14", "output": "3\n"}, {"input": "15\n15 11 46 15 50 98 93 129 41 43 44 11 6 24 14", "output": "3\n"}, {"input": "15\n15 11 46 15 50 98 93 87 31 43 44 11 10 24 14", "output": "3\n"},...
code_stdio
[ { "content": "There are N integers, A_1, A_2, ..., A_N, written on the blackboard.\nYou will choose one of them and replace it with an integer of your choice between 1 and 10^9 (inclusive), possibly the same as the integer originally written.\nFind the maximum possible greatest common divisor of the N integers ...
[{"input": "3206\n2048 536870912 536870912 268435456 2097152 8192 128 16 16777216 4096 4096 16777216 32 131072 67108864 16777216 256 8388608 1048576 8 2048 8388608 4 16777216 33554432 8 512 16777216 8 33554432 65536 8192 64 64 4 16777216 524288 16 8192 16777216 67108864 536870912 268435456 536870912 4096 33554432 26214...
code_stdio
[ { "content": "Firecrackers scare Nian the monster, but they're wayyyyy too noisy! Maybe fireworks make a nice complement.\n\nLittle Tommy is watching a firework show. As circular shapes spread across the sky, a splendid view unfolds on the night of Lunar New Year's eve.\n\nA wonder strikes Tommy. How many regio...
[{"input": "3\n-10 4 10\n10 4 10\n0 -7 10\n", "output": "7\n"}, {"input": "3\n-10 4 10\n10 4 10\n0 -7 10\n", "output": "7\n"}, {"input": "3\n-3 -2 3\n-4 -12 3\n-6 -4 9\n", "output": "5\n"}, {"input": "3\n1 -7 10\n-7 9 10\n-2 -1 4\n", "output": "8\n"}, {"input": "3\n-3 -2 3\n-4 -6 3\n-6 -4 9\n", "output": "5\n"}, {"inpu...
code_stdio
[ { "content": "Dima the hamster enjoys nibbling different things: cages, sticks, bad problemsetters and even trees!\n\nRecently he found a binary search tree and instinctively nibbled all of its edges, hence messing up the vertices. Dima knows that if Andrew, who has been thoroughly assembling the tree for a lon...
[{"input": "36\n3 41 82 123 174 216 432 864 1080 1228 2149 4298 8596 11052 22104 33156 35919 71838 179595 359190 431028 862056 994680 1315440 1753920 3507840 7015680 10523520 21047040 26500200 53000400 106000800 132501000 176668000 353336000 530004000\n", "output": "Yes\n"}, {"input": "36\n3 41 82 123 174 216 432 864 1...
code_stdio
[ { "content": "-----Problem Statement-----\nWrite a program that accepts a number, n, and outputs the same.\n\n-----Input-----\nThe only line contains a single integer. \n\n-----Output-----\nOutput the answer in a single line.\n\n-----Constraints-----\n- 0 ≤ n ≤ 105\n\n-----Sample Input-----\n123\n\n-----Sample ...
[{"input": "1047", "output": "1047\n"}, {"input": "1652", "output": "1652\n"}, {"input": "3133", "output": "3133\n"}, {"input": "1313", "output": "1313\n"}, {"input": "1107", "output": "1107\n"}, {"input": "2085", "output": "2085\n"}, {"input": "2863", "output": "2863\n"}, {"input": "-160", "output": "-160\n"}, {"input...
code_stdio
[ { "content": "Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She d...
[{"input": "100 100\n", "output": "101\n"}, {"input": "100 100\n", "output": "101\n"}, {"input": "99 100\n", "output": "99\n"}, {"input": "100 3\n", "output": "149\n"}, {"input": "100 2\n", "output": "199\n"}, {"input": "99 10\n", "output": "109\n"}, {"input": "100 5\n", "output": "124\n"}, {"input": "95 16\n", "output...
code_stdio
[ { "content": "You are given two arrays $a$ and $b$, both of length $n$. All elements of both arrays are from $0$ to $n-1$.\n\nYou can reorder elements of the array $b$ (if you want, you may leave the order of elements as it is). After that, let array $c$ be the array of length $n$, the $i$-th element of this ar...
[{"input": "10\n6 3 0 5 4 5 5 5 8 5\n3 8 2 9 5 4 1 0 3 6\n", "output": "0 1 0 0 0 4 6 7 1 8 \n"}, {"input": "10\n6 3 0 5 4 5 5 5 8 5\n3 8 2 9 5 4 1 0 3 6\n", "output": "0 1 0 0 0 4 6 7 1 8 "}, {"input": "10\n6 3 0 5 4 5 5 4 8 5\n3 8 2 9 5 4 1 0 3 6\n", "output": "0 1 0 0 0 4 6 6 1 8\n"}, {"input": "10\n6 3 0 5 6 5 5 5 ...
code_stdio
[ { "content": "Initially Ildar has an empty array. He performs $n$ steps. On each step he takes a subset of integers already added to the array and appends the mex of this subset to the array. \n\nThe mex of an multiset of integers is the smallest non-negative integer not presented in the multiset. For example, ...
[{"input": "3\n0 1 1000000000\n", "output": "3\n"}, {"input": "3\n1 1 1000000000\n", "output": "1\n"}, {"input": "3\n1 0 1000000000\n", "output": "1\n"}, {"input": "3\n1 0 0000000000\n", "output": "1\n"}, {"input": "3\n1 0 0000001000\n", "output": "1\n"}, {"input": "3\n0 0 0000001000\n", "output": "3\n"}, {"input": "3\...
code_stdio
[ { "content": "Two countries, Country A and Country B, are at war. As a soldier in Country A, you will lead n soldiers to occupy the territory of Country B.\n\nThe territory of Country B is represented by a two-dimensional grid. The first place you occupy is a square on the 2D grid. Each of the soldiers you lead...
[{"input": "10\n10\n10\n14\n10\n10\n10\n10\n10\n10\n10", "output": "97\n"}, {"input": "10\n6\n10\n14\n10\n10\n10\n10\n10\n10\n20", "output": "103\n"}, {"input": "10\n6\n10\n14\n10\n10\n10\n10\n10\n18\n20", "output": "111\n"}, {"input": "10\n6\n10\n14\n10\n10\n10\n10\n10\n11\n20", "output": "104\n"}, {"input": "10\n6\n1...
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}... 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 s and r...
[{"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 2\n)())(()(\n10 5\n)))(()()((\n2 1\n)(\n2 1\n)(\n", "output": "4\n1 2\n3 5\n4 6\n5 8\n5\n1 4\n3 5\n5 7\n7 9\n9 10\n1\n1 2\n1\n1 2\n"}, {"input": "4\n8 2...
code_stdio
[ { "content": "Given are a positive integer N and a string S of length N consisting of lowercase English letters.\nDetermine whether the string is a concatenation of two copies of some string.\nThat is, determine whether there is a string T such that S = T + T.\n\n-----Constraints-----\n - 1 \\leq N \\leq 100\n ...
[{"input": "100\ntttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt\n", "output": "Yes\n"}, {"input": "100\nyyxyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\n", "output": "No\n"}, {"input": "99\nbbbbbbbbbbbbbbbbbbbbbbb...
code_stdio
[ { "content": "In this task you need to process a set of stock exchange orders and use them to create order book.\n\nAn order is an instruction of some participant to buy or sell stocks on stock exchange. The order number i has price p_{i}, direction d_{i} — buy or sell, and integer q_{i}. This means that the pa...
[{"input": "3 3\nB 16671 5044\nS 23924 4895\nS 76276 1905\n", "output": "S 76276 1905\nS 23924 4895\nB 16671 5044\n"}, {"input": "3 3\nB 16671 5006\nS 23924 4895\nS 76276 1905\n", "output": "S 76276 1905\nS 23924 4895\nB 16671 5006\n"}, {"input": "3 3\nB 16671 5006\nS 23924 4895\nS 76276 3800\n", "output": "S 76276 380...
code_stdio
[ { "content": "We have a grid with (2^N - 1) rows and (2^M-1) columns. You are asked to write 0 or 1 in each of these squares. Let a_{i,j} be the number written in the square at the i-th row from the top and the j-th column from the left.\n\nFor a quadruple of integers (i_1, i_2, j_1, j_2) such that 1\\leq i_1 \...
[{"input": "9 7", "output": "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\n111111111111111111111111111111111...
code_stdio
[ { "content": "Problem C Medical Checkup\n\nStudents of the university have to go for a medical checkup, consisting of lots of checkup items, numbered 1, 2, 3, and so on.\n\nStudents are now forming a long queue, waiting for the checkup to start. Students are also numbered 1, 2, 3, and so on, from the top of the...
[{"input": "3 102\n1\n3\n0", "output": "103\n34\n34\n"}, {"input": "3 35\n1\n3\n3", "output": "36\n12\n11\n"}, {"input": "3 55\n1\n3\n4", "output": "56\n19\n13\n"}, {"input": "3 55\n1\n3\n0", "output": "56\n19\n19\n"}, {"input": "3 55\n1\n4\n0", "output": "56\n14\n14\n"}, {"input": "3 55\n2\n4\n0", "output": "28\n14\n1...
code_stdio
[ { "content": "C: Divisor Game\n\nproblem\n\ntsutaj is trying to play about a few games.\n\nIn a divisor game, a natural number N of 2 or more is given first, and then the game progresses according to the following procedure.\n\n* Declare one integer from the divisors of N other than N. However, at this time, it...
[{"input": "1008", "output": "3 29\n"}, {"input": "3690", "output": "4 23\n"}, {"input": "5184", "output": "2 34\n"}, {"input": "120", "output": "3 15\n"}, {"input": "324", "output": "2 14\n"}, {"input": "330", "output": "4 15\n"}, {"input": "560", "output": "3 19\n"}, {"input": "180", "output": "3 17\n"}, {"input": "2...
code_stdio
[ { "content": "В самолёте есть n рядов мест. Если смотреть на ряды сверху, то в каждом ряду есть 3 места слева, затем проход между рядами, затем 4 центральных места, затем ещё один проход между рядами, а затем ещё 3 места справа.\n\nИзвестно, что некоторые места уже заняты пассажирами. Всего есть два вида пассаж...
[{"input": "30 1\nPPP-PPP.-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP-PPP\nPPP-PPPP...
code_stdio
[ { "content": "When Petya went to school, he got interested in large numbers and what they were called in ancient times. For instance, he learned that the Russian word \"tma\" (which now means \"too much to be counted\") used to stand for a thousand and \"tma tmyschaya\" (which literally means \"the tma of tmas\...
[{"input": "2147483647\n2147483647\n", "output": "YES\n0\n"}, {"input": "2147483646\n2147483647\n", "output": "NO\n"}, {"input": "1094841453\n1656354409\n", "output": "NO\n"}, {"input": "2147483647\n2147483646\n", "output": "NO\n"}, {"input": "1470193122\n1420950405\n", "output": "NO\n"}, {"input": "1470193122\n1180021...
code_stdio
[ { "content": "Andrewid the Android is a galaxy-famous detective. He is now chasing a criminal hiding on the planet Oxa-5, the planet almost fully covered with water.\n\nThe only dry land there is an archipelago of n narrow islands located in a row. For more comfort let's represent them as non-intersecting segme...
[{"input": "20 10\n4 9\n10 15\n17 18\n20 21\n11 27\n13 32\n35 40\n46 48\n49 51\n53 56\n59 60\n63 111\n130 68\n69 70\n74 50\n79 80\n89 82\n84 87\n88 91\n98 001\n4 7 6 1 5 4 3 1 8 2\n", "output": "No\n"}, {"input": "20 10\n4 9\n10 15\n17 18\n20 21\n25 27\n13 32\n35 40\n46 48\n49 51\n53 56\n59 60\n63 64\n130 68\n69 70\n74...
code_stdio
[ { "content": "Vasya is studying in the last class of school and soon he will take exams. He decided to study polynomials. Polynomial is a function P(x) = a_0 + a_1x^1 + ... + a_{n}x^{n}. Numbers a_{i} are called coefficients of a polynomial, non-negative integer n is called a degree of a polynomial.\n\nVasya ha...
[{"input": "1000000000000000000 1000000000000000000 1000000000000000000\n", "output": "2\n"}, {"input": "1000000000000000000 1000000000000000000 1000000000000000000\n", "output": "2\n"}, {"input": "1001000000000000000 1000000000000000000 1000000000000000000\n", "output": "1\n"}, {"input": "1001000000000000000 100000000...
code_stdio
[ { "content": "You are given an array $a_{1}, a_{2}, \\ldots, a_{n}$. You can remove at most one subsegment from it. The remaining elements should be pairwise distinct.\n\nIn other words, at most one time you can choose two integers $l$ and $r$ ($1 \\leq l \\leq r \\leq n$) and delete integers $a_l, a_{l+1}, \\l...
[{"input": "87\n65 97 97 99 57 78 92 55 68 89 63 94 71 54 74 63 94 60 97 75 96 82 87 90 62 72 83 100 76 67 95 69 61 53 55 79 73 99 77 85 79 84 51 58 66 96 97 89 69 84 87 72 53 67 90 63 92 65 73 57 82 69 96 77 73 53 85 96 84 86 61 54 84 52 52 68 100 94 80 60 61 83 89 91 74 92 55\n", "output": "72\n"}, {"input": "87\n65 ...
code_stdio
[ { "content": "Shaass has decided to hunt some birds. There are n horizontal electricity wires aligned parallel to each other. Wires are numbered 1 to n from top to bottom. On each wire there are some oskols sitting next to each other. Oskol is the name of a delicious kind of birds in Shaass's territory. Suppose...
[{"input": "100\n54 15 25 18 64 62 23 59 70 137 50 26 87 35 75 86 0 22 6 60 70 41 21 9 75 50 25 3 69 14 39 68 64 46 59 99 2 0 21 76 90 12 61 42 12 91 36 39 47 41 93 81 66 57 70 36 68 89 52 1 19 93 67 22 76 20 8 81 123 18 100 73 61 93 75 80 53 72 40 20 2 86 33 70 27 16 11 26 55 44 47 55 94 58 2 55 82 22 9 95\n0\n", "out...
code_stdio
[ { "content": "Given are strings S and T. Consider changing S to T by repeating the operation below. Find the minimum number of operations required to do so.\nOperation: Choose one character of S and replace it with a different character.\n\n-----Constraints-----\n - S and T have lengths between 1 and 2\\times 1...
[{"input": "sjpvbzildfxlaukqtfznjjyryrdawsycubdpieejlzsexyhuajiqqigetwdyjeignkuuedzguvqhyrubpdfsenayqahbaqnyhavlaptlqtrotfzvbqbtpkuddnopjzoteuubxgkthzdyepesqgozkdvkcakraxeulhhqtnpolbtcsgxgskjjzdimcyhclnnwfbxwmznpvjaqjqqogwgwmzzpcvhywpcocmsxxmgsodckxvipzobspvwjezxugjlivdhefgdfkzzidktxjcnayjubmsqmpuaaidduwpmhkewaqtkvsudo...
code_stdio
[ { "content": "Leha decided to move to a quiet town Vičkopolis, because he was tired by living in Bankopolis. Upon arrival he immediately began to expand his network of hacked computers. During the week Leha managed to get access to n computers throughout the town. Incidentally all the computers, which were hack...
[{"input": "10\n877105545 939360757 849826701 845946140 803128820 926787996 967305000 1743698496 717018470 971203310\n", "output": "181734622\n"}, {"input": "10\n877105545 939360757 849826701 845946140 803128820 926787996 967305000 904694971 921301848 971203310\n", "output": "861364152\n"}, {"input": "10\n877105545 939...
code_stdio
[ { "content": "Let's assume that \n\n * v(n) is the largest prime number, that does not exceed n;\n * u(n) is the smallest prime number strictly greater than n. \n\n\n\nFind <image>.\n\nInput\n\nThe first line contains integer t (1 ≤ t ≤ 500) — the number of testscases. \n\nEach of the following t lines of the...
[{"input": "6\n999\n1095\n821\n635\n63\n480\n", "output": "1003961/2011946\n1196833/2398042\n674039/1351366\n403199/808942\n3959/8174\n232303/466546\n"}, {"input": "6\n999\n588\n821\n635\n63\n480\n", "output": "1003961/2011946\n346909/696182\n674039/1351366\n403199/808942\n3959/8174\n232303/466546\n"}, {"input": "6\n88...
code_stdio
[ { "content": "There are N cities numbered 1 to N, connected by M railroads.\nYou are now at City 1, with 10^{100} gold coins and S silver coins in your pocket.\nThe i-th railroad connects City U_i and City V_i bidirectionally, and a one-way trip costs A_i silver coins and takes B_i minutes.\nYou cannot use gold...
[{"input": "50 98 49\n12 13 38 966876944\n35 47 5 419053521\n20 23 39 513566946\n43 45 31 973756616\n11 39 45 339701654\n8 12 34 119183522\n5 16 50 644322683\n37 44 42 476275226\n3 4 41 832102486\n29 45 1 974869661\n6 21 32 929876961\n23 33 18 660381903\n12 19 26 747314758\n9 45 22 109205766\n43 50 9 353453224\n18 23 3...
code_stdio
[ { "content": "Caracal is fighting with a monster.\nThe health of the monster is H.\nCaracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:\n - If the monster's health is 1, it drops to 0.\n - If the monster's health, X, is greater than ...
[{"input": "1000000000000\n", "output": "1099511627775\n"}, {"input": "999999999999\n", "output": "1099511627775\n"}, {"input": "549755813888\n", "output": "1099511627775\n"}, {"input": "707813884927\n", "output": "1099511627775\n"}, {"input": "913056879650\n", "output": "1099511627775\n"}, {"input": "1010000000000", "...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \n\nEugene loves sequences, especially arithmetic progressions. One day he was asked to solve a difficult problem.\n\nIf a sequence of numbers A_{1}, A_{2}, ... , A_{N} form an arithmetic progression A, he was asked to c...
[{"input": "2\n-3 3 -2 -2\n2 2 126 3", "output": "6\n-609\n"}, {"input": "2\n-3 3 -2 -2\n2 2 126 0", "output": "6\n-621\n"}, {"input": "2\n-1 6 -2 -2\n2 2 92 -1", "output": "8\n-461\n"}, {"input": "2\n-2 6 -2 -2\n2 2 92 -1", "output": "7\n-461\n"}, {"input": "2\n-2 6 0 -2\n2 2 92 -1", "output": "-4\n-461\n"}, {"input":...
code_stdio
[ { "content": "Polycarpus has a ribbon, its length is n. He wants to cut the ribbon in a way that fulfils the following two conditions: \n\n * After the cutting each ribbon piece should have length a, b or c. \n * After the cutting the number of ribbon pieces should be maximum. \n\n\n\nHelp Polycarpus and find...
[{"input": "3043 317 1141 2438\n", "output": "7\n"}, {"input": "3399 2035 2 3334\n", "output": "683\n"}, {"input": "4000 500 1000 2000\n", "output": "8\n"}, {"input": "4000 500 1000 1671\n", "output": "8\n"}, {"input": "918 102 1327 1733\n", "output": "9\n"}, {"input": "595 2263 3625 1\n", "output": "595\n"}, {"input":...
code_stdio
[ { "content": "You are given integers N,\\ A and B. Determine if there exists a permutation (P_0,\\ P_1,\\ ...\\ P_{2^N-1}) of (0,\\ 1,\\ ...\\ 2^N-1) that satisfies all of the following conditions, and create one such permutation if it exists.\n\n* P_0=A\n* P_{2^N-1}=B\n* For all 0 \\leq i < 2^N-1, the binary r...
[{"input": "2 1 0", "output": "YES\n1 3 2 0\n"}, {"input": "2 2 0", "output": "YES\n2 3 1 0\n"}, {"input": "2 3 2", "output": "YES\n3 1 0 2\n"}, {"input": "2 0 2", "output": "YES\n0 1 3 2\n"}, {"input": "2 2 3", "output": "YES\n2 0 1 3\n"}, {"input": "2 3 1", "output": "YES\n3 2 0 1\n"}, {"input": "2 0 1", "output": "Y...
code_stdio
[ { "content": "We have a board with a 2 \\times N grid.\nSnuke covered the board with N dominoes without overlaps.\nHere, a domino can cover a 1 \\times 2 or 2 \\times 1 square.\nThen, Snuke decided to paint these dominoes using three colors: red, cyan and green.\nTwo dominoes that are adjacent by side should be...
[{"input": "52\nRvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn\nRLLwwdWIxxNNQUUXXVVMMooBBaggDKqcimmeYrhAljOOTTJuuzzn\n", "output": "958681902\n"}, {"input": "52\nLLJngjjWwrKFFqcXNNYYaaGiimDtlsuuCTTyppVkkfobOOvxxAAU\nIIJnghhWwrKRRqcXZZQQddGMMmDtlsPPCeeyzzVSSfobHHvBBEEU\n", "output": "358954489\n"}, {"input": "52\n...
code_stdio