messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
1 value
[ { "content": "Petya and Vasya decided to play a little. They found n red cubes and m blue cubes. The game goes like that: the players take turns to choose a cube of some color (red or blue) and put it in a line from left to right (overall the line will have n + m cubes). Petya moves first. Petya's task is to ge...
[{"input": "100000 100000\n", "output": "99999 100000\n"}, {"input": "100000 100000\n", "output": "99999 100000\n"}, {"input": "10000 100010\n", "output": "100009 10000\n"}, {"input": "10000 110010\n", "output": "110009 10000\n"}, {"input": "110881 42754\n", "output": "110880 42754\n"}, {"input": "25938 152750\n", "out...
code_stdio
[ { "content": "Let's denote that some array $b$ is bad if it contains a subarray $b_l, b_{l+1}, \\dots, b_{r}$ of odd length more than $1$ ($l < r$ and $r - l + 1$ is odd) such that $\\forall i \\in \\{0, 1, \\dots, r - l\\}$ $b_{l + i} = b_{r - i}$.\n\nIf an array is not bad, it is good.\n\nNow you are given an...
[{"input": "10 11\n-1 11 -1 -1 -1 -1 10 -1 -1 -1\n", "output": "100000000\n"}, {"input": "10 11\n-1 11 -1 -1 -1 -1 10 -1 -1 -1\n", "output": "100000000\n"}, {"input": "10 17\n-1 11 -1 -1 -1 -1 10 -1 -1 -1\n", "output": "301989884\n"}, {"input": "10 11\n-1 1 -1 -1 -1 -1 10 -1 -1 -1\n", "output": "100000000\n"}, {"input"...
code_stdio
[ { "content": "In the 17th century, Fermat wrote that he proved for any integer $n \\geq 3$, there exist no positive integers $x$, $y$, $z$ such that $x^n + y^n = z^n$. However he never disclosed the proof. Later, this claim was named Fermat's Last Theorem or Fermat's Conjecture.\n\nIf Fermat's Last Theorem hold...
[{"input": "6\n3\n13\n0", "output": "27\n11\n126\n"}, {"input": "6\n25\n12\n0", "output": "27\n64\n54\n"}, {"input": "6\n6\n15\n0", "output": "27\n27\n119\n"}, {"input": "6\n15\n2\n0", "output": "27\n119\n6\n"}, {"input": "6\n14\n4\n0", "output": "27\n16\n10\n"}, {"input": "6\n25\n4\n0", "output": "27\n64\n10\n"}, {"in...
code_stdio
[ { "content": "You are solving the crossword problem K from IPSC 2014. You solved all the clues except for one: who does Eevee evolve into? You are not very into pokemons, but quick googling helped you find out, that Eevee can evolve into eight different pokemons: Vaporeon, Jolteon, Flareon, Espeon, Umbreon, Lea...
[{"input": "8\n.a.o.e.n\n", "output": "vaporeon\n"}, {"input": "8\n........\n", "output": "vaporeon\n"}, {"input": "8\n..p.....\n", "output": "vaporeon\n"}, {"input": "8\n..p.....\n", "output": "vaporeon\n"}, {"input": "8\n.a.o.e.n\n", "output": "vaporeon\n"}, {"input": "8\n........\n", "output": "vaporeon\n"}, {"input...
code_stdio
[ { "content": "Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the 0 key, the 1 key and the backspace key.\nTo begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is l...
[{"input": "01B0\n", "output": "00\n"}, {"input": "B010", "output": "010\n"}, {"input": "B110", "output": "110\n"}, {"input": "B011", "output": "011\n"}, {"input": "B101", "output": "101\n"}, {"input": "B111", "output": "111\n"}, {"input": "B100", "output": "100\n"}, {"input": "B001", "output": "001\n"}, {"input": "B00...
code_stdio
[ { "content": "Kolya Gerasimov loves kefir very much. He lives in year 1984 and knows all the details of buying this delicious drink. One day, as you probably know, he found himself in year 2084, and buying kefir there is much more complicated.\n\nKolya is hungry, so he went to the nearest milk shop. In 2084 you...
[{"input": "1000000000000000000\n999999998000000000\n999999999000000000\n999999998000000000\n", "output": " 3\n"}, {"input": "1\n1000000000000000000\n1000000000\n999999999\n", "output": " 0\n"}, {...
code_stdio
[ { "content": "You are given strings S and T consisting of lowercase English letters.\nYou can perform the following operation on S any number of times:\nOperation: Choose two distinct lowercase English letters c_1 and c_2, then replace every occurrence of c_1 with c_2, and every occurrence of c_2 with c_1.\nDet...
[{"input": "yiizlygglzgpypipzllbzpwgblzziigpgpgywpggbpylpylzlzplwypgwizgpgbywiwwzpygzpgillgbzyiwpwzgppwlbpwzilwilbbbybgzlppgwgyypybbpgbwplzbbzpzbzzzzzzppbwipyzzylyyyibwipyzbyzpygppggibzzlgpzwyglglbywwiglyggbzyzwgpzillgybypbywygzpwzligpwlzwizbpwbzzybzyyglbplpzlgzzipplizbgpgpggylgzybplwyyggyiybppzzibzlpgwplilwigbypzzipgy...
code_stdio
[ { "content": "As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices.\n\nOne day, a group of three good friends living in the Matsunaga housin...
[{"input": "4 2\n50 40 100 80\n7 3\n400 139 100 700 200 600 500\n0 0", "output": "150\n2000\n"}, {"input": "4 2\n50 40 100 80\n7 3\n400 300 100 700 116 600 500\n0 0", "output": "150\n2100\n"}, {"input": "4 3\n50 40 100 80\n7 3\n400 290 000 1162 352 600 57\n0 0", "output": "220\n2404\n"}, {"input": "4 3\n97 59 100 113\n...
code_stdio
[ { "content": "A piece of paper contains an array of n integers a1, a2, ..., an. Your task is to find a number that occurs the maximum number of times in this array.\n\nHowever, before looking for such number, you are allowed to perform not more than k following operations — choose an arbitrary element from the ...
[{"input": "100 1000\n-281 191 -27 -286 -497 462 0 889 0 -350 -720 -507 916 0 -648 -942 -140 0 0 -877 66 576 -278 410 -792 -607 713 712 296 -828 -488 -129 508 -106 470 -263 -865 -506 -604 334 591 -40 220 0 0 198 -435 374 -34 254 970 0 549 100 555 326 91 0 -361 -835 472 823 -663 -456 0 91 295 126 383 141 476 609 518 545...
code_stdio
[ { "content": "Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay one silver coin.\n\nThe world can be represented by the first quadrant of a plane and the wall is built a...
[{"input": "100\nRUURUURRUURUUUUURRUUURRRRUURRURRURRRRUUUUUURRUURRRRURUUURUURURRRRRURUURRUURUURRUUURUUUUUURRUUUURUUUR\n", "output": "3\n"}, {"input": "100\nRUURUURRUURUUUUURRUUURRRRUURRURRURRRRUUUUUURRUURRRRURUUURUURURRRRRURUURRUURUURRUUURUUUUUURRUUUURUUUR\n", "output": "3\n"}, {"input": "100\nRUUURUUUURRUUUUUURUUURRUU...
code_stdio
[ { "content": "Little boy Gerald studies at school which is quite far from his house. That's why he has to go there by bus every day. The way from home to school is represented by a segment of a straight line; the segment contains exactly n + 1 bus stops. All of them are numbered with integers from 0 to n in the...
[{"input": "68 74\n51 54\n3 22\n12 24\n3 27\n32 42\n36 55\n60 64\n1 4\n4 23\n11 64\n54 62\n50 56\n21 34\n27 63\n15 54\n28 61\n13 57\n39 53\n12 32\n32 40\n33 67\n55 61\n33 67\n30 37\n15 49\n27 45\n21 41\n8 42\n24 63\n40 48\n28 41\n30 67\n0 4\n7 15\n27 59\n60 62\n25 65\n30 31\n38 67\n24 43\n14 64\n26 46\n8 12\n34 41\n32 ...
code_stdio
[ { "content": "Cyael is a teacher at a very famous school in Byteland and she is known by her students for being very polite to them and also to encourage them to get good marks on their tests.\nThen, if they get good marks she will reward them with candies :) However, she knows they are all very good at Mathema...
[{"input": "2\n17 0\n100 1", "output": "0 17\n100 0\n"}, {"input": "2\n17 0\n101 0", "output": "0 17\n0 101\n"}, {"input": "2\n17 0\n101 1", "output": "0 17\n101 0\n"}, {"input": "2\n10 0\n101 3", "output": "0 10\n33 2\n"}, {"input": "2\n18 0\n101 3", "output": "0 18\n33 2\n"}, {"input": "2\n18 0\n111 3", "output": "0 ...
code_stdio
[ { "content": "Let's define a good tree:It is a tree with k * n nodes labeled from 0 to k * n - 1\nNode i and node j are not adjacent, for all 0 ≤ i, j < k * n such that i div k = j div k (here div means integer division. E.g. 7 div 2 = 3)\n\nGiven n and k, how many different good trees are there?\n\n------ Inp...
[{"input": "11 11", "output": "459104785\n"}, {"input": "11 14", "output": "737454094\n"}, {"input": "11 28", "output": "685943622\n"}, {"input": "4 10", "output": "994788518\n"}, {"input": "6 10", "output": "835647629\n"}, {"input": "6 13", "output": "865042129\n"}, {"input": "2 13", "output": "748239339\n"}, {"input"...
code_stdio
[ { "content": "At the first holiday in spring, the town Shortriver traditionally conducts a flower festival. Townsfolk wear traditional wreaths during these festivals. Each wreath contains exactly $k$ flowers.\n\nThe work material for the wreaths for all $n$ citizens of Shortriver is cut from the longest flowere...
[{"input": "100 15 6 10\n6 9 1 7 6 4 1 9 3 2 4 6 2 5 3 10 9 2 9 1 6 5 6 2 3 10 7 10 7 4 5 4 4 4 4 7 1 10 8 4 8 3 10 10 7 4 4 10 6 1 8 5 4 6 2 3 10 3 2 5 7 5 6 10 10 3 4 5 4 3 3 1 7 8 10 10 10 10 8 3 7 4 2 1 8 6 5 6 5 8 7 9 2 1 5 2 4 6 10 8\n6 9 7 8 7 1 4 3 5 8\n", "output": "2\n76 77 \n"}, {"input": "100 15 6 10\n3 2 3...
code_stdio
[ { "content": "Snuke has decided to construct a string that starts with A and ends with Z, by taking out a substring of a string s (that is, a consecutive part of s).\nFind the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts w...
[{"input": "HASFJGHOGAKZZFEGA\n", "output": "12\n"}, {"input": "HASFJGHOGAK[ZFEGA", "output": "12\n"}, {"input": "IBAG[IHNGFKKZSFGB", "output": "11\n"}, {"input": "AIEFZGKAFOFGJZSAH", "output": "14\n"}, {"input": "ICAF[IHNGFKZKSFGB", "output": "10\n"}, {"input": "AGEFZJG@GNHHZFSAK", "output": "13\n"}, {"input": "HASFEH...
code_stdio
[ { "content": "There are two cameras which observe the up line and the down line respectively on the double lane (please see the following figure). These cameras are located on a line perpendicular to the lane, and we call the line 'monitoring line.' (the red line in the figure)\n\n\n<image>\n\n\nMonitoring syst...
[{"input": "4 5\n20 35 110 70\n15 30 40 84 113\n3 2\n10 20 30\n81 60\n0 1\n100\n1 1\n10\n83\n0 0", "output": "30\n30\n100\n73\n"}, {"input": "4 5\n20 60 110 70\n15 30 40 84 113\n3 2\n10 20 30\n42 60\n0 1\n100\n1 1\n10\n83\n0 0", "output": "26\n18\n100\n73\n"}, {"input": "4 5\n4 35 110 134\n15 30 40 84 113\n3 2\n10 20 3...
code_stdio
[ { "content": "Given is a positive even number N.\n\nFind the number of strings s of length N consisting of `A`, `B`, and `C` that satisfy the following condition:\n\n* s can be converted to the empty string by repeating the following operation:\n* Choose two consecutive characters in s and erase them. However, ...
[{"input": "1100000", "output": "298228697\n"}, {"input": "0110000", "output": "784164463\n"}, {"input": "0110010", "output": "189920713\n"}, {"input": "1100010", "output": "865187132\n"}, {"input": "0100100", "output": "545699273\n"}, {"input": "1110010", "output": "816062167\n"}, {"input": "0110110", "output": "97385...
code_stdio
[ { "content": "Alice, the president of club FCB, wants to build a team for the new volleyball tournament. The team should consist of p players playing in p different positions. She also recognizes the importance of audience support, so she wants to select k people as part of the audience.\n\nThere are n people i...
[{"input": "6 2 3\n78 93 9 17 13 78\n80 97\n30 52\n49 17\n56 68\n60 36\n84 55\n", "output": "377\n"}, {"input": "6 2 3\n78 93 9 17 13 78\n80 12\n30 52\n49 17\n56 68\n60 36\n84 55\n", "output": "377\n"}, {"input": "6 2 3\n78 93 9 17 13 78\n80 97\n30 52\n26 17\n56 68\n60 36\n84 55\n", "output": "377"}, {"input": "3 2 1\n...
code_stdio
[ { "content": "This version of the problem differs from the next one only in the constraint on n.\n\nNote that the memory limit in this problem is lower than in others.\n\nYou have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom.\n\nYou also have a token that is initially pla...
[{"input": "162685 187160003\n", "output": "175888140\n"}, {"input": "200000 316925344\n", "output": "253547906\n"}, {"input": "140750 887458748\n", "output": "669831877\n"}, {"input": "197426 364348492\n", "output": "289708472\n"}, {"input": "199862 999999937\n", "output": "750469605"}, {"input": "124953 922406879\n",...
code_stdio
[ { "content": "Limak and Radewoosh are going to compete against each other in the upcoming algorithmic contest. They are equally skilled but they won't solve problems in the same order.\n\nThere will be n problems. The i-th problem has initial score p_{i} and it takes exactly t_{i} minutes to solve it. Problems ...
[{"input": "50 1\n6 17 44 82 94 127 134 156 187 211 212 252 256 292 294 303 352 355 379 380 398 409 424 434 480 524 584 594 631 714 745 756 777 778 789 793 799 821 841 849 859 878 879 895 925 932 944 952 958 990\n15 16 40 42 45 71 143 100 117 120 174 181 186 318 221 268 289 332 376 394 403 409 411 444 471 487 499 539 5...
code_stdio
[ { "content": "There is an N-car train.\nYou are given an integer i. Find the value of j such that the following statement is true: \"the i-th car from the front of the train is the j-th car from the back.\"\n\n-----Constraints-----\n - 1 \\leq N \\leq 100\n - 1 \\leq i \\leq N\n\n-----Input-----\nInput is given...
[{"input": "-108 -1", "output": "-106\n"}, {"input": "-108 71", "output": "-178\n"}, {"input": "-159 71", "output": "-229\n"}, {"input": "-116 71", "output": "-186\n"}, {"input": "-74 36", "output": "-109\n"}, {"input": "-74 71", "output": "-144\n"}, {"input": "-93 71", "output": "-163\n"}, {"input": "-97 71", "output"...
code_stdio
[ { "content": "As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon.\n\nElections are coming. You know the number of voters and the number of parties — $n$ and $m$...
[{"input": "10 10\n7 29\n10 31\n9 40\n5 17\n5 30\n6 85\n2 53\n7 23\n4 57\n10 9\n", "output": "49\n"}, {"input": "10 10\n5 81\n7 68\n7 48\n1 10\n5 37\n7 97\n8 54\n7 41\n7 56\n5 21\n", "output": "110\n"}, {"input": "10 10\n5 81\n7 68\n7 48\n1 10\n5 37\n7 97\n8 54\n7 41\n7 56\n5 21\n", "output": "110\n"}, {"input": "10 10...
code_stdio
[ { "content": "A triangular number is the number of dots in an equilateral triangle uniformly filled with dots. For example, three dots can be arranged in a triangle; thus three is a triangular number. The n-th triangular number is the number of dots in a triangle with n dots on a side. <image>. You can learn mo...
[{"input": "300\n", "output": "YES\n"}, {"input": "406\n", "output": "YES\n"}, {"input": "253\n", "output": "YES\n"}, {"input": "276\n", "output": "YES\n"}, {"input": "496\n", "output": "YES\n"}, {"input": "351\n", "output": "YES\n"}, {"input": "378\n", "output": "YES\n"}, {"input": "153\n", "output": "YES\n"}, {"input...
code_stdio
[ { "content": "Takahashi has come to an integer shop to buy an integer.\nThe shop sells the integers from 1 through 10^9. The integer N is sold for A \\times N + B \\times d(N) yen (the currency of Japan), where d(N) is the number of digits in the decimal notation of N.\nFind the largest integer that Takahashi c...
[{"input": "1000000000 1000000000 1000000000000000000\n", "output": "999999991\n"}, {"input": "773361868 125660016 773361869833880887\n", "output": "1000000000\n"}, {"input": "839296263 462224593 839296268591205063\n", "output": "1000000000\n"}, {"input": "450968417 430302156 443135970740411047\n", "output": "982631931...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian as well. \n\nPetr, Nikita G. and Nikita are the most influential music critics in Saint-Petersburg. They have recently downloaded their favorite band's new album and going to listen to it. Nikita claims that the songs of entire album should ...
[{"input": "3\n6\n6\n6", "output": "14.7\n14.7\n14.7\n"}, {"input": "3\n1\n6\n6", "output": "1.0\n14.7\n14.7\n"}, {"input": "3\n2\n6\n6", "output": "3.0\n14.7\n14.7\n"}, {"input": "3\n6\n1\n6", "output": "14.7\n1.0\n14.7\n"}, {"input": "3\n6\n2\n6", "output": "14.7\n3.0\n14.7\n"}, {"input": "3\n3\n6\n6", "output": "5.5...
code_stdio
[ { "content": "Devu and his brother love each other a lot. As they are super geeks, they only like to play with arrays. They are given two arrays a and b by their father. The array a is given to Devu and b to his brother. \n\nAs Devu is really a naughty kid, he wants the minimum value of his array a should be at...
[{"input": "10 10\n23 101 38 38 73 54 59 69 44 150\n100 100 100 100 100 100 100 100 100 100\n", "output": "402\n"}, {"input": "10 10\n23 101 38 38 73 54 59 69 44 150\n100 100 100 100 100 100 100 101 100 100\n", "output": "403\n"}, {"input": "10 10\n23 100 38 74 73 54 59 69 44 139\n100 100 100 100 110 100 100 100 100 10...
code_stdio
[ { "content": "VK news recommendation system daily selects interesting publications of one of $n$ disjoint categories for each user. Each publication belongs to exactly one category. For each category $i$ batch algorithm selects $a_i$ publications.\n\nThe latest A/B test suggests that users are reading recommend...
[{"input": "40\n19 20 8 13 13 17 1 14 15 20 14 17 2 9 9 10 19 16 6 12 9 7 20 5 12 2 4 4 12 5 4 11 8 1 2 8 11 19 18 4\n52258 5648 46847 9200 63940 79328 118413 54479 1788 60107 8234 64215 15419 84411 50307 78075 92548 17867 43456 7970 1390 99373 97297 90662 82950 678 79356 51351 2794 82477 16508 19254 81295 9711 72350 1...
code_stdio
[ { "content": "We have a permutation p = {p_1,\\ p_2,\\ ...,\\ p_n} of {1,\\ 2,\\ ...,\\ n}.\nPrint the number of elements p_i (1 < i < n) that satisfy the following condition:\n - p_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.\n\n-----Constraints-----\n - All values in ...
[{"input": "20\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20\n", "output": "18\n"}, {"input": "20\n20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1\n", "output": "18\n"}, {"input": "20\n1 20 2 19 3 18 4 17 5 16 6 15 7 14 8 13 9 12 10 11\n", "output": "0\n"}, {"input": "20\n20 1 2 19 3 18 4 17 5 16 6 15 7 14 8 1...
code_stdio
[ { "content": "Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from $1$ to $9$). In this problem, we use one digit and one lowercase le...
[{"input": "1s 2s 3s\n", "output": "0\n"}, {"input": "9m 9m 9m\n", "output": "0\n"}, {"input": "3p 9m 2p\n", "output": "1\n"}, {"input": "8p 2s 9m\n", "output": "2\n"}, {"input": "5s 8m 5s\n", "output": "1\n"}, {"input": "9s 4s 3m\n", "output": "2\n"}, {"input": "4p 8m 9s\n", "output": "2\n"}, {"input": "8s 5s 7p\n", "...
code_stdio
[ { "content": "Fox Ciel is developing an artificial intelligence (AI) for a game. This game is described as a game tree T with n vertices. Each node in the game has an evaluation value which shows how good a situation is. This value is the same as maximum value of child nodes’ values multiplied by -1. Values on ...
[{"input": "3\n-1 2 -1\n2 2 3\n0\n1", "output": "2 2\n"}, {"input": "3\n-2 4 -1\n2 2 3\n0\n0", "output": "2 2\n"}, {"input": "3\n-2 4 -2\n2 2 3\n0\n0", "output": "2 2\n"}, {"input": "3\n-2 2 -1\n2 2 3\n0\n1", "output": "2 2\n"}, {"input": "3\n-4 4 -1\n2 2 3\n0\n0", "output": "2 2\n"}, {"input": "3\n-1 -1 0\n2 2 3\n0\n1...
code_stdio
[ { "content": "We have N locked treasure boxes, numbered 1 to N.\nA shop sells M keys. The i-th key is sold for a_i yen (the currency of Japan), and it can unlock b_i of the boxes: Box c_{i1}, c_{i2}, ..., c_{i{b_i}}. Each key purchased can be used any number of times.\nFind the minimum cost required to unlock a...
[{"input": "12 1000\n100000 12\n1 2 3 4 5 6 7 8 9 10 11 12\n100000 12\n1 2 3 4 5 6 7 8 9 10 11 12\n100000 12\n1 2 3 4 5 6 7 8 9 10 11 12\n100000 12\n1 2 3 4 5 6 7 8 9 10 11 12\n100000 12\n1 2 3 4 5 6 7 8 9 10 11 12\n100000 12\n1 2 3 4 5 6 7 8 9 10 11 12\n100000 12\n1 2 3 4 5 6 7 8 9 10 11 12\n100000 12\n1 2 3 4 5 6 7 8...
code_stdio
[ { "content": "You're given an array $a$ of length $n$. You can perform the following operation on it as many times as you want: Pick two integers $i$ and $j$ $(1 \\le i,j \\le n)$ such that $a_i+a_j$ is odd, then swap $a_i$ and $a_j$. \n\nWhat is lexicographically the smallest array you can obtain?\n\nAn array...
[{"input": "36\n398353608 662365068 456456182 594572278 958026500 524977116 903404403 382220192 142092809 137516115 522872496 527845939 116437661 423289717 907151540 961740613 981968938 143206666 773454188 691188206 95402302 602570397 986508327 617421132 46091276 866348540 485487643 843511039 768135914 68050875 2627811...
code_stdio
[ { "content": "There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the children from 1 to n. The i-th child wants to get at least a_{i} candies.\n\nJzzhu asks children to line up. Initially, the i-th child stands at the i-th place of the line. Then Jzzhu start di...
[{"input": "100 20\n21 19 61 70 54 97 98 14 61 72 25 94 24 56 55 25 12 80 76 11 35 17 80 26 11 94 52 47 84 61 10 2 74 25 10 21 2 79 55 50 30 75 10 64 44 5 60 96 52 16 74 41 20 77 20 44 8 86 74 36 49 61 99 13 54 64 19 99 50 43 12 73 48 48 83 55 72 73 63 81 30 27 95 9 97 82 24 3 89 90 33 14 47 88 22 78 12 75 58 67\n", "o...
code_stdio
[ { "content": "Vasya follows a basketball game and marks the distances from which each team makes a throw. He knows that each successful throw has value of either 2 or 3 points. A throw is worth 2 points if the distance it was made from doesn't exceed some value of d meters, and a throw is worth 3 points if the ...
[{"input": "18\n450 3726 12063 42865 29689 35320 33937 4067 45951 80313 53004 59541 75551 75836 151186 81297 93876 96211\n47\n3393 11375 6494 7645 9549 8499 11145 13121 14801 15578 24104 24125 25871 31280 35036 38969 29966 41342 42708 46033 47491 25404 49152 51905 55002 9827 56565 57901 104645 37176 66075 87521 68397 1...
code_stdio
[ { "content": "Adilbek was assigned to a special project. For Adilbek it means that he has $n$ days to run a special program and provide its results. But there is a problem: the program needs to run for $d$ days to calculate the results.\n\nFortunately, Adilbek can optimize the program. If he spends $x$ ($x$ is ...
[{"input": "50\n1000000000 1000000000\n999999999 1000000000\n999999998 1000000000\n999999997 1000000000\n999999996 1000000000\n999999995 1000000000\n999999994 1000000000\n999999900 1000000000\n1 11\n2 11\n3 11\n4 11\n5 11\n6 11\n7 11\n8 11\n9 11\n10 11\n11 11\n4 18\n4 20\n3 19\n3 18\n3 167\n3 15\n3 14\n3 13\n3 12\n3 11...
code_stdio
[ { "content": "You are given a string S of length n with each character being one of the first m lowercase English letters. \n\nCalculate how many different strings T of length n composed from the first m lowercase English letters exist such that the length of LCS (longest common subsequence) between S and T is ...
[{"input": "100 26\njysrixyptvsesnapfljeqkytlpeepjopspmkviqdqbdkylvfiawhdjjdvqqvcjmmsgfdmpjwahuwhgsyfcgnefzmqlvtvqqfbfsf\n", "output": "237400\n"}, {"input": "100 26\njysrixyptvsesnapfljeqkytlpeepjopspmkviqdqbdkylvfiawhdjjdvqqvcjmmsgfdmpjwahuwhgsyfcgnefzmqlvtvqqfbfsf\n", "output": "237400\n"}, {"input": "100 26\njysrix...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian as well. \n\nEuler's phi function for a positive integer N is usually denoted as φ(N) and defined as the number of positive integers less than or equal to N that are coprime with N. Let's call a positive integer N a super number if N can b...
[{"input": "3\n2 1\n229 975\n12 34", "output": "0\n12\n5\n"}, {"input": "3\n2 1\n229 975\n6 62", "output": "0\n12\n10\n"}, {"input": "3\n3 10\n48 237\n18 32", "output": "3\n11\n3\n"}, {"input": "3\n1 10\n48 237\n18 32", "output": "5\n11\n3\n"}, {"input": "3\n2 1\n396 1220\n3 12", "output": "0\n10\n4\n"}, {"input": "3\n...
code_stdio
[ { "content": "In cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, 'a' would be repl...
[{"input": "xlmw mw xli tmgxyvi xlex m xsso mr ilx xvmt.", "output": "this is the picture that i took in eht trip.\n"}, {"input": "xlmw mw xli tmgxyvi xlex m ossx mr ilx xvmt.", "output": "this is the picture that i koot in eht trip.\n"}, {"input": "xlmw mw xli tmgxyvi xlex m ossx mr ilx xwmt.", "output": "this is the ...
code_stdio
[ { "content": "One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles.\n\nThe store may run out of some flavors, so you'll decide which one to buy after arriving there. But there ar...
[{"input": "4\n1\n1337\n3\n31 7 1\n5\n0 2 2 6 10\n3\n9 143 1515\n", "output": "446\n11\n4\n506\n"}, {"input": "4\n1\n1337\n3\n10 2 1\n5\n2 2 3 4 5\n3\n10 115 1546\n", "output": "446\n5\n3\n516\n"}, {"input": "4\n1\n1337\n3\n31 7 1\n5\n0 2 2 6 10\n3\n9 105 940\n", "output": "446\n11\n4\n314\n"}, {"input": "4\n1\n1337\n3...
code_stdio
[ { "content": "You are given a string $s$ consisting of exactly $n$ characters, and each character is either '0', '1' or '2'. Such strings are called ternary strings.\n\nYour task is to replace minimum number of characters in this string with other characters to obtain a balanced ternary string (balanced ternary...
[{"input": "69\n000000000000000000000000000000000000000000000000000000000000000000000\n", "output": "000000000000000000000001111111111111111111111122222222222222222222222\n"}, {"input": "69\n000000000000000000000000000000000000000000000000000000000000000000000\n", "output": "00000000000000000000000111111111111111111111...
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, w...
[{"input": "16\n998244362 998244362 1545401713 998244362 998244362 998244362 998244362 998244362 1483557929 998244362 998244362 356870606 998244362 998244362 998244362 998244362 998244363 998244363 998244363 998244363 998244363 998244363 998244363 998244363 998244363 998244363 998244363 998244363 1290068308 998244363 9...
code_stdio
[ { "content": "Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. \n\nInspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and whi...
[{"input": "wwwbbwbbbwbwbwwbwwbbbwbwbwwbbbwbwwwbwwbwbbbbwwbwwwwwbwwwwwwwwbbwwwwbbbbbwbwbbwwbbbbbwbwbbwbwwwbbwwbbbwwwbbwwbwwbbbbwwbwbbwbwwbbwbwbwbbwwbwwwbwbwbbbwwwwwwbwwbbbwwbwwbwbwwwbbwwwwwwwwwbwwbwbbbwbwwwwbwwbbwbbwbwwbwwbwwbbwbbwwwwbwwwbwwwbwbwwwbbwwbbwwbwbwwwwwwbwbwwwwbbwwwbwbwwwbbwwwwwbwwbwbbbbbwbwwbbbbbbbwbbwbbwww...
code_stdio
[ { "content": "Alice and Bob are controlling a robot. They each have one switch that controls the robot.\n\nAlice started holding down her button A second after the start-up of the robot, and released her button B second after the start-up.\n\nBob started holding down his button C second after the start-up, and ...
[{"input": "56 100 33 100\n", "output": "44\n"}, {"input": "0 100 0 100\n", "output": "100\n"}, {"input": "0 75 25 100\n", "output": "50\n"}, {"input": "10 90 20 80\n", "output": "60\n"}, {"input": "77 88 34 96\n", "output": "11\n"}, {"input": "0 100 99 100\n", "output": "1\n"}, {"input": "0 148 36 100", "output": "64\...
code_stdio
[ { "content": "You a captain of a ship. Initially you are standing in a point $(x_1, y_1)$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $(x_2, y_2)$. \n\nYou know the weather forecast — the string $s$ of length $n$, consisting only of letters U, D, L...
[{"input": "0 0\n1000000000 1000000000\n2\nDR\n", "output": "2000000000\n"}, {"input": "0 0\n1000000000 1000000000\n2\nDR\n", "output": "2000000000\n"}, {"input": "0 0\n1000000010 1000000000\n2\nDR\n", "output": "2000000010\n"}, {"input": "1 0\n1010000000 1000000000\n2\nDR\n", "output": "2010000000\n"}, {"input": "0 0\...
code_stdio
[ { "content": "You are policeman and you are playing a game with Slavik. The game is turn-based and each turn consists of two phases. During the first phase you make your move and during the second phase Slavik makes his move.\n\nThere are $n$ doors, the $i$-th door initially has durability equal to $a_i$.\n\nDu...
[{"input": "100 2 2\n1 73456 13268 11914 2 1 2 1 1 2 1 1 87480 65464 2 40468 7016 70750 28675 92808 74100 22702 47484 22345 61255 1 104206 62017 89058 61094 76626 1 171051 98876 97451 18228 2 2 1 38979 1 144831 1 43289 73591 2 1 91061 89577 13598 1 2 2 57020 2 82044 24974 1 1 958 8399 1 98709 10870 1 66150 2 79527 2 2 ...
code_stdio
[ { "content": "Gennady is one of the best child dentists in Berland. Today n children got an appointment with him, they lined up in front of his office.\n\nAll children love to cry loudly at the reception at the dentist. We enumerate the children with integers from 1 to n in the order they go in the line. Every ...
[{"input": "10\n9 8 8\n2 9 33\n10 7 42\n7 2 18\n3 5 82\n9 9 25\n3 2 86\n1 5 49\n5 3 72\n4 4 71\n", "output": "10\n1 2 3 4 5 6 7 8 9 10 "}, {"input": "10\n9 8 8\n2 9 33\n10 7 42\n7 2 18\n3 4 82\n9 9 25\n3 2 86\n1 5 49\n5 3 72\n4 4 71\n", "output": "10\n1 2 3 4 5 6 7 8 9 10 "}, {"input": "10\n9 8 8\n2 9 33\n10 7 42\n8 2 ...
code_stdio
[ { "content": "Tree is a connected graph without cycles. A leaf of a tree is any vertex connected with exactly one other vertex.\n\nYou are given a tree with n vertices and a root in the vertex 1. There is an ant in each leaf of the tree. In one second some ants can simultaneously go to the parent vertex from th...
[{"input": "12\n1 2\n1 3\n1 4\n2 5\n2 6\n3 7\n3 12\n3 9\n8 10\n8 11\n8 12\n", "output": "5\n"}, {"input": "12\n1 2\n1 3\n1 4\n2 5\n2 6\n5 7\n3 8\n3 9\n8 10\n8 11\n8 12\n", "output": "5\n"}, {"input": "12\n1 2\n2 3\n1 4\n2 5\n2 6\n5 7\n3 8\n3 9\n8 10\n8 11\n8 12\n", "output": "7\n"}, {"input": "12\n1 2\n1 3\n1 4\n2 5\n3...
code_stdio
[ { "content": "Luke Skywalker gave Chewbacca an integer number x. Chewbacca isn't good at numbers but he loves inverting digits in them. Inverting digit t means replacing it with digit 9 - t. \n\nHelp Chewbacca to transform the initial number x to the minimum possible positive number by inverting some (possibly,...
[{"input": "1000000000000000000\n", "output": "1000000000000000000\n"}, {"input": "1000000000000000000\n", "output": "1000000000000000000\n"}, {"input": "1000001000000000000\n", "output": "1000001000000000000\n"}, {"input": "1000001000000000010\n", "output": "1000001000000000010\n"}, {"input": "1010001000000000010\n", ...
code_stdio
[ { "content": "Let f(A, B), where A and B are positive integers, be the string satisfying the following conditions:\n\n* f(A, B) has length A + B;\n* f(A, B) contains exactly A letters `A` and exactly B letters `B`;\n* The length of the longest substring of f(A, B) consisting of equal letters (ex., `AAAAA` or `B...
[{"input": "5\n2 3 1 5\n6 7 1 10\n2 3 1 4\n6 12 2 10\n8 10 10 14", "output": "BABAB\nBABABABABA\nBABA\nBBABBABBA\nABBAB\n"}, {"input": "5\n2 3 1 5\n6 7 1 10\n2 3 1 4\n6 12 3 10\n8 10 10 14", "output": "BABAB\nBABABABABA\nBABA\nBABBABBA\nABBAB\n"}, {"input": "5\n2 3 1 5\n6 7 1 10\n2 3 1 4\n6 12 3 7\n8 10 6 14", "output"...
code_stdio
[ { "content": "The cities of Byteland and Berland are located on the axis $Ox$. In addition, on this axis there are also disputed cities, which belong to each of the countries in their opinion. Thus, on the line $Ox$ there are three types of cities: the cities of Byteland, the cities of Berland, disputed citi...
[{"input": "15\n-9518 R\n-6858 P\n-6726 B\n-6486 R\n-4496 P\n-4191 P\n-772 B\n-258 R\n-194 P\n1035 R\n2297 P\n4816 B\n5779 R\n9342 B\n9713 B\n", "output": "25088\n"}, {"input": "15\n-9518 R\n-6858 P\n-6726 B\n-6486 R\n-4496 P\n-4191 P\n-772 B\n-258 R\n-194 P\n1035 R\n2297 P\n4816 B\n5779 R\n9342 B\n9713 B\n", "output":...
code_stdio
[ { "content": "Blake is a CEO of a large company called \"Blake Technologies\". He loves his company very much and he thinks that his company should be the best. That is why every candidate needs to pass through the interview that consists of the following problem.\n\nWe define function f(x, l, r) as a bitwise O...
[{"input": "25\n12 30 47 109 81 124 80 33 38 48 29 78 96 48 96 27 80 77 102 65 80 113 31 194 35\n25 64 177 13 12 6 111 80 85 16 61 119 23 65 73 65 20 95 124 18 28 79 125 106 116\n", "output": "510\n"}, {"input": "25\n12 30 47 109 81 124 80 33 38 48 29 78 96 48 96 27 80 77 102 65 80 113 31 194 35\n25 64 177 13 12 6 111 ...
code_stdio
[ { "content": "Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nPetya calls a number almost lucky if it could be evenly divided by some luck...
[{"input": "1000\n", "output": "YES\n"}, {"input": "477\n", "output": "YES\n"}, {"input": "124\n", "output": "YES\n"}, {"input": "480\n", "output": "YES\n"}, {"input": "141\n", "output": "YES\n"}, {"input": "882\n", "output": "YES\n"}, {"input": "799\n", "output": "YES\n"}, {"input": "444\n", "output": "YES\n"}, {"inpu...
code_stdio
[ { "content": "Let's introduce the designation <image>, where x is a string, n is a positive integer and operation \" + \" is the string concatenation operation. For example, [abc, 2] = abcabc.\n\nWe'll say that string s can be obtained from string t, if we can remove some characters from string t and obtain str...
[{"input": "10000000 10000000\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "1\n"}, {"input": "10000000 1\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "Anadi has a set of dominoes. Every domino has two parts, and each part contains some dots. For every $a$ and $b$ such that $1 \\leq a \\leq b \\leq 6$, there is exactly one domino with $a$ dots on one half and $b$ dots on the other half. The set contains exactly $21$ dominoes. Here is an exact ill...
[{"input": "7 21\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n2 3\n2 4\n2 5\n2 6\n2 7\n3 4\n3 5\n3 6\n3 7\n4 5\n4 6\n4 7\n5 6\n5 7\n6 7\n", "output": "16\n"}, {"input": "7 21\n3 5\n7 2\n2 3\n6 5\n5 2\n4 7\n2 6\n2 4\n6 7\n5 1\n1 4\n4 5\n5 7\n4 6\n3 1\n1 2\n3 4\n7 1\n3 7\n6 1\n3 6\n", "output": "16\n"}, {"input": "7 21\n3 5\n7 2\n2 3\...
code_stdio
[ { "content": "How many integer sequences A_1,A_2,\\ldots,A_N of length N satisfy all of the following conditions?\n - 0 \\leq A_i \\leq 9\n - There exists some i such that A_i=0 holds.\n - There exists some i such that A_i=9 holds.\nThe answer can be very large, so output it modulo 10^9 + 7.\n\n-----Constraints...
[{"input": "1000000\n", "output": "787616419\n"}, {"input": "260522\n", "output": "765255076\n"}, {"input": "914575\n", "output": "875983450\n"}, {"input": "436426\n", "output": "851976198\n"}, {"input": "979445\n", "output": "664003445\n"}, {"input": "648772\n", "output": "256544986\n"}, {"input": "690081\n", "output"...
code_stdio
[ { "content": "We have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\n-----Constraints-----\n - 1 \\leq N \\leq 2 \\times 10^5\n - S_i (1 \\leq i \\leq N) are strings consisting of ...
[{"input": "8\nfubfalo\nbuefalo\nbuffamo\nolaffub\nouafflb\nomaffub\nbuffalo\nbuofalf", "output": "buefalo\nbuffalo\nbuffamo\nbuofalf\nfubfalo\nolaffub\nomaffub\nouafflb\n"}, {"input": "8\nfubfalo\nbuefola\nbuffamo\nolaffub\nouafflb\nomaffub\nbuffalo\nbuofalf", "output": "buefola\nbuffalo\nbuffamo\nbuofalf\nfubfalo\nol...
code_stdio
[ { "content": "After reaching your destination, you want to build a new colony on the new planet. Since this planet has many mountains and the colony must be built on a flat surface you decided to flatten the mountains using boulders (you are still dreaming so this makes sense to you).\n\nYou are given an array ...
[{"input": "20\n5 166\n11 21 31 41 51\n5 37\n11 21 31 41 51\n5 231\n11 21 31 41 51\n5 58\n11 21 31 41 51\n5 157\n11 21 31 41 51\n5 179\n11 21 31 41 51\n5 150\n11 21 31 41 51\n5 122\n11 20 27 37 47\n5 204\n11 21 31 41 51\n5 62\n3 13 23 8 43\n5 136\n43 58 51 86 34\n5 42\n31 25 62 45 100\n5 36\n20 26 37 5 69\n5 169\n41 99...
code_stdio
[ { "content": "For a given array $a_1, a_2, a_3, ... , a_N$ of $N$ elements and an integer $S$, find the smallest sub-array size (smallest window length) where the sum of the sub-array is greater than or equal to $S$. If there is not such sub-array, report 0.\n\nConstraints\n\n* $1 \\leq N \\leq 10^5$\n* $1 \\le...
[{"input": "12 5\n0 2 0 3 10 7", "output": "1\n"}, {"input": "12 5\n1 2 0 3 10 7", "output": "1\n"}, {"input": "13 5\n1 2 0 3 10 7", "output": "1\n"}, {"input": "24 5\n1 2 0 3 10 7", "output": "1\n"}, {"input": "24 5\n1 2 1 3 10 7", "output": "1\n"}, {"input": "41 5\n1 2 1 3 10 7", "output": "1\n"}, {"input": "53 5\n1 ...
code_stdio
[ { "content": "B: Periodic Sequence-\n\nproblem\n\nDr. Period, a professor at H University, is studying a property called the cycle that is supposed to be hidden in all things. As a generally known basic cycle, a cycle hidden in a sequence may be considered. That is, if the sequence S = S_1, S_2, ..., S_N of len...
[{"input": "6\n-1 -14 10 -3 2 -1", "output": "1\n"}, {"input": "6\n-1 -14 18 -3 2 -1", "output": "1\n"}, {"input": "6\n-1 -14 18 -1 2 -1", "output": "1\n"}, {"input": "6\n-1 -10 18 -1 2 -1", "output": "1\n"}, {"input": "6\n0 -10 18 -2 -1 -2", "output": "1\n"}, {"input": "6\n-1 -10 8 -3 2 -1", "output": "1\n"}, {"input"...
code_stdio
[ { "content": "Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes. \n\nThey took n prizes for the contestants and wrote on each of the...
[{"input": "10\n-1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000\n7 8\n5 10\n8 6\n1 5\n7 9\n3 9\n2 10\n2 6\n4 3\n", "output": "Impossible"}, {"input": "10\n-1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -10000000...
code_stdio
[ { "content": "Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them.\n\nBeroffice works only with small English letters (i.e. with 26 letters from a to z). Beroffice thinks that a word is typed with...
[{"input": "bababcdfabbcabcdfacbbabcdfacacabcdfacbcabcdfaccbabcdfacaaabcdfabacabcdfabcbabcdfacbaabcdfabaaabcdfabbaabcdfacababcdfabbbabcdfabcaabcdfaaababcdfabccabcdfacccabcdfaacbabcdfaabaabcdfaabcabcdfaaacabcdfaccaabcdfaabbabcdfaaaaabcdfaacaabcdfaacc\n", "output": "bababc dfabb cabc dfacb babc dfacacabc dfacb cabc dfacc...
code_stdio
[ { "content": "The translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little: it is spelled (and pronounced) reversely. For example, a Berlandish word code corresponds to a...
[{"input": "vxpqullmcbegsdskddortcvxyqlbvxmmkhevovnezubvpvnrcajpxraeaxizgaowtfkzywvhnbgzsxbhkaipcmoumtikkiyyaivg\ngviayyikkitmuomcpiakhbxszgbnhvwyzkftwoagzixaearxpjacrnvpvbuzenvovehkmmxvblqyxvctroddksdsgebcmlluqpxv\n", "output": "YES\n"}, {"input": "dgxmzbqofstzcdgthbaewbwocowvhqpinehpjatnnbrijcolvsatbblsrxabzrpszoiecp...
code_stdio
[ { "content": "Alice and Bob decided to eat some fruit. In the kitchen they found a large bag of oranges and apples. Alice immediately took an orange for herself, Bob took an apple. To make the process of sharing the remaining fruit more fun, the friends decided to play a game. They put multiple cards and on eac...
[{"input": "420196140727489673 679891637638612258\n", "output": "1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B\n"}, {"input": "420196140727489673 679891637638612258\n", "output": "1B1A1B1A1B1A1B1...
code_stdio
[ { "content": "In a Berland's zoo there is an enclosure with camels. It is known that camels like to spit. Bob watched these interesting animals for the whole day and registered in his notepad where each animal spitted. Now he wants to know if in the zoo there are two camels, which spitted at each other. Help hi...
[{"input": "30\n-398 -1774\n313 -6974\n2346 -4657\n8552 -9647\n-5265 1538\n8195 4864\n-5641 -5219\n-1394 8563\n-1190 1992\n-4669 -1156\n7574 256\n9206 -2414\n4140 -549\n-294 2169\n7029 -2871\n3808 -9799\n3141 5690\n4648 -2680\n-5990 9800\n-2299 1697\n6077 -7177\n-400 -9724\n-4644 -2392\n-2198 -9531\n-2105 9386\n-8165 -...
code_stdio
[ { "content": "Mrs. Smith is trying to contact her husband, John Smith, but she forgot the secret phone number!\n\nThe only thing Mrs. Smith remembered was that any permutation of $n$ can be a secret phone number. Only those permutations that minimize secret value might be the phone of her husband.\n\nThe sequen...
[{"input": "11110\n", "output": "11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053...
code_stdio
[ { "content": "You are given two lists of segments $[al_1, ar_1], [al_2, ar_2], \\dots, [al_n, ar_n]$ and $[bl_1, br_1], [bl_2, br_2], \\dots, [bl_n, br_n]$.\n\nInitially, all segments $[al_i, ar_i]$ are equal to $[l_1, r_1]$ and all segments $[bl_i, br_i]$ are equal to $[l_2, r_2]$.\n\nIn one step, you can choo...
[{"input": "3\n3 5\n1 2\n3 4\n2 1000000000\n1 1\n999999999 999999999\n10 3\n5 10\n7 8\n", "output": "7\n2000000000\n0\n"}, {"input": "3\n3 5\n1 2\n3 4\n1 1000000000\n1 1\n999999999 999999999\n10 3\n5 10\n7 8\n", "output": "7\n2000000000\n0\n"}, {"input": "3\n3 2\n1 2\n3 4\n1 1000000000\n1 1\n999999999 999999999\n10 3\n...
code_stdio
[ { "content": "Vanya decided to walk in the field of size n × n cells. The field contains m apple trees, the i-th apple tree is at the cell with coordinates (xi, yi). Vanya moves towards vector (dx, dy). That means that if Vanya is now at the cell (x, y), then in a second he will be at cell <image>. The followin...
[{"input": "2 15 1 1\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 -1\n0 0\n0 0\n0 0\n", "output": "0 0\n"}, {"input": "2 15 1 1\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 -1\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n", "output": "0 0\n"}, {"input": "2 15 1 1\n0 0\n0 1\n0 0\n0 1\n0 0\n0 1\n0 0\n0 1\n0 0\n0 1\n0 0\n0 1...
code_stdio
[ { "content": "Nastya received a gift on New Year — a magic wardrobe. It is magic because in the end of each month the number of dresses in it doubles (i.e. the number of dresses becomes twice as large as it is in the beginning of the month).\n\nUnfortunately, right after the doubling the wardrobe eats one of th...
[{"input": "314647997243943415 107188213956410843\n", "output": "109575135\n"}, {"input": "314647997243943415 107188213956410843\n", "output": "109575135\n"}, {"input": "316313018463929883 108989792589951708\n", "output": "398397727\n"}, {"input": "1497482167524343307 29585639347346605\n", "output": "228961297\n"}, {"i...
code_stdio
[ { "content": "You are given a connected undirected graph consisting of $n$ vertices and $m$ edges. There are no self-loops or multiple edges in the given graph.\n\nYou have to direct its edges in such a way that the obtained directed graph does not contain any paths of length two or greater (where the length of...
[{"input": "10 10\n9 2\n6 4\n2 10\n7 8\n8 6\n9 3\n2 6\n7 1\n7 4\n5 4\n", "output": "YES\n0010101000\n"}, {"input": "10 10\n1 3\n9 6\n4 5\n1 9\n8 6\n1 7\n3 2\n5 7\n5 3\n10 5\n", "output": "YES\n1001010110\n"}, {"input": "10 10\n4 3\n6 8\n5 3\n8 1\n2 9\n9 8\n3 6\n10 2\n9 3\n6 3\n", "output": "YES\n1110010111\n"}, {"input...
code_stdio
[ { "content": "It is a balmy spring afternoon, and Farmer John's n cows are ruminating about link-cut cacti in their stalls. The cows, labeled 1 through n, are arranged so that the i-th cow occupies the i-th stall from the left. However, Elsie, after realizing that she will forever live in the shadows beyond Bes...
[{"input": "100000 100000\n", "output": "4999950000\n"}, {"input": "100000 100000\n", "output": "4999950000\n"}, {"input": "100000 40000\n", "output": "4799960000\n"}, {"input": "100000 50000\n", "output": "4999950000\n"}, {"input": "100000 50001\n", "output": "4999950000\n"}, {"input": "100000 50002\n", "output": "499...
code_stdio
[ { "content": "Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.\n\nA little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the p...
[{"input": "btbdpnzdenxueteteytvkwnegodyhmdwhmrmbftrifytzudumzlacwytsuzefqfpjesdblxhpcsidgksisjdmhyxmmugrjmtfcgxmcgpmvbxbyszdugvmoyjeeqsywcvuqskcjotyhvdijyslgfvyujxthngnonasgnbzzygyikheelirdfsvuicbiazfdeqecbtbdpnzdenxueteteytvkwnegodyhmdwhmrmbftrifytzudumzlacwytsuzefqfpjesdblxhpcsidgksisjdmhyxmmugrjmtfcgxmcgpccdtdteoht...
code_stdio
[ { "content": "ZS the Coder loves to read the dictionary. He thinks that a word is nice if there exists a substring (contiguous segment of letters) of it of length 26 where each letter of English alphabet appears exactly once. In particular, if the string has length strictly less than 26, no such substring exist...
[{"input": "LLVYUOXHBHUZSAPUMQEKWSQAFRKSMEENXDQYOPQFXNNFXSRBGXFUIRBFJDSDKQIDMCPPTWRJOZCRHZYZPBVUJPQXHNALAOCJDTTBDZWYDBVPMNSQNVMLHHUJAOIWFSEJEJSRBYREOZKHEXTBAXPTISPGIPOYBFFEJNAKKXAEPNGKWYGEJTNEZIXAWRSCEIRTKNEWSKSGKNIKDEOVXGYVEVFRGTNDFNWIFDRZQEJQZYIWNZXCONVZAKKKETPTPPXZMIVDWPGXOFODRNJZBATKGXAPXYHTUUFFASCHOLSMVSWBIJBAENEG...
code_stdio
[ { "content": "A permutation is a sequence of integers from 1 to n of length n containing each number exactly once. For example, (1), (4, 3, 5, 1, 2), (3, 2, 1) are permutations, and (1, 1), (4, 3, 1), (2, 3, 4) are not. \n\nThere are many tasks on permutations. Today you are going to solve one of them. Let’s im...
[{"input": "100\n9 6 3 28 10 2 2 11 2 1 25 3 13 5 14 13 4 14 2 16 12 27 8 1 7 9 8 19 33 23 4 1 15 6 7 12 2 8 30 4 1 31 6 1 15 5 18 3 2 24 7 3 1 20 10 8 26 22 3 3 9 6 1 10 1 5 1 3 7 6 11 10 1 16 19 5 9 4 4 4 2 18 12 21 11 5 2 32 17 29 2 4 8 1 7 5 3 2 17 1\n", "output": "12\n1 1 1 1 1 1 2 1 3 1 1 2 1 1 1 2 1 2 4 1 1 1 1 ...
code_stdio
[ { "content": "You are given a sequence with N integers: A = \\{ A_1, A_2, \\cdots, A_N \\}.\nFor each of these N integers, we will choose a color and paint the integer with that color. Here the following condition must be satisfied:\n - If A_i and A_j (i < j) are painted with the same color, A_i < A_j.\nFind th...
[{"input": "5\n10\n-1\n1\n13\n3", "output": "2\n"}, {"input": "5\n10\n-1\n6\n13\n3", "output": "3\n"}, {"input": "5\n10\n-1\n1\n13\n2", "output": "2\n"}, {"input": "5\n10\n-1\n6\n13\n5", "output": "3\n"}, {"input": "5\n10\n-1\n1\n13\n5", "output": "2\n"}, {"input": "5\n10\n-1\n6\n13\n6", "output": "3\n"}, {"input": "5\...
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": "Vasya got really tired of these credits (from problem F) and now wants to earn the money himself! He decided to make a contest to gain a profit.\n\nVasya has $n$ problems to choose from. They are numbered from $1$ to $n$. The difficulty of the $i$-th problem is $d_i$. Moreover, the problems are gi...
[{"input": "22 936\n20 743\n55 46\n83 282\n157 3\n168 979\n241 338\n293 113\n312 292\n333 509\n339 632\n345 149\n347 109\n384 846\n420 151\n619 923\n647 336\n706 935\n726 600\n760 45\n804 126\n810 739\n906 341\n", "output": " 3371\n"}, {"input": "22 936\n20 743...
code_stdio
[ { "content": "You are given a permutation p consisting of n integers 1, 2, ..., n (a permutation is an array where each element from 1 to n occurs exactly once).\n\nLet's call an array a bipartite if the following undirected graph is bipartite:\n\n * the graph consists of n vertices; \n * two vertices i and j...
[{"input": "4\n3\n1 2 1\n6\n1 3 2 6 2 4\n4\n4 1 3 2\n8\n3 2 1 6 7 8 2 4\n", "output": "YES\n-1 -2 1\nYES\n-1 -3 2 6 2 4\nYES\n-4 -1 -3 2\nYES\n-3 -2 1 6 7 -8 2 4\n"}, {"input": "4\n3\n1 2 3\n6\n1 0 2 6 5 4\n4\n4 1 3 2\n8\n3 2 1 6 7 8 5 4\n", "output": "YES\n1 2 3\nYES\n-1 0 2 -6 -5 4\nYES\n-4 -1 -3 2\nYES\n-3 -2 1 6 7 ...
code_stdio
[ { "content": "We have N cards numbered 1, 2, ..., N. Card i (1 \\leq i \\leq N) has an integer A_i written in red ink on one side and an integer B_i written in blue ink on the other side. Initially, these cards are arranged from left to right in the order from Card 1 to Card N, with the red numbers facing up.\n...
[{"input": "5\n28 15 22 43 30\n20 22 43 33 32", "output": "-1"}, {"input": "5\n28 15 22 43 31\n20 22 43 33 32", "output": "-1"}, {"input": "5\n11 15 22 43 30\n20 22 43 33 32", "output": "1"}, {"input": "5\n4 46 6 31 43\n33 15 18 27 37", "output": "3"}, {"input": "5\n4 26 6 31 43\n33 15 18 27 37", "output": "3"}, {"inpu...
code_stdio
[ { "content": "Given is a sequence of integers A_1, A_2, ..., A_N.\nIf its elements are pairwise distinct, print YES; otherwise, print NO.\n\n-----Constraints-----\n - 2 ≤ N ≤ 200000\n - 1 ≤ A_i ≤ 10^9\n - All values in input are integers.\n\n-----Input-----\nInput is given from Standard Input in the following f...
[{"input": "2\n10000000 10000000\n", "output": "NO\n"}, {"input": "2\n10000100 10000000", "output": "YES\n"}, {"input": "2\n10000100 10001000", "output": "YES\n"}, {"input": "2\n10000100 10101000", "output": "YES\n"}, {"input": "2\n10010100 10101000", "output": "YES\n"}, {"input": "2\n10010100 10101001", "output": "YES...
code_stdio
[ { "content": "Tokitsukaze has two colorful tapes. There are $n$ distinct colors, numbered $1$ through $n$, and each color appears exactly once on each of the two tapes. Denote the color of the $i$-th position of the first tape as $ca_i$, and the color of the $i$-th position of the second tape as $cb_i$.\n\nNow ...
[{"input": "1\n50\n4 50 11 27 15 29 2 9 12 39 31 1 6 17 32 28 7 24 36 3 18 49 37 35 33 21 48 19 26 5 20 45 14 13 34 40 42 16 44 43 41 25 38 23 30 10 22 8 47 46\n10 43 29 5 47 12 39 26 31 15 33 18 13 21 11 22 44 4 38 30 41 25 1 24 14 8 27 36 20 45 23 48 2 42 46 19 32 17 7 50 40 49 37 9 3 35 28 6 16 34\n", "output": "125...
code_stdio
[ { "content": "Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store — \"PriceFixed\". Here are some rules of that store:\n\nThe store has an infinite number of items of every product.\n\nAll products have the same price: $2$...
[{"input": "15\n1 18646259228611\n1 76062756486449\n1 5817259716888\n1 22110867828535\n1 100627485465221\n1 40799537235509\n1 56529154503793\n1 56148198559428\n1 77940886559829\n1 74079407528201\n1 6574734766207\n1 79264199999788\n1 19171266033881\n1 38437872037474\n1 34320923862986\n", "output": "30\n"}, {"input": "15...
code_stdio
[ { "content": "In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi.\n\nTakahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For ...
[{"input": "3\n7 12 11", "output": "1\n"}, {"input": "3\n8 12 11", "output": "1\n"}, {"input": "3\n10 12 8", "output": "2\n"}, {"input": "3\n9 12 8", "output": "3\n"}, {"input": "3\n8 12 0", "output": "0\n"}, {"input": "3\n4 12 8", "output": "4\n"}, {"input": "2\n12 12", "output": "0\n"}, {"input": "3\n7 12 8", "output...
code_stdio
[ { "content": "Snuke got positive integers s_1,...,s_N from his mother, as a birthday present. There may be duplicate elements.\n\nHe will circle some of these N integers. Since he dislikes cubic numbers, he wants to ensure that if both s_i and s_j (i ≠ j) are circled, the product s_is_j is not cubic. For exampl...
[{"input": "10\n1\n11\n100\n1000000007\n10000000100\n1000000009\n999999999\n1416\n999\n999", "output": "10"}, {"input": "10\n1\n11\n100\n1000000007\n10000000100\n1000000009\n999999999\n1416\n922\n999", "output": "10"}, {"input": "10\n1\n11\n100\n1000000007\n10000000100\n1000000009\n999999999\n1416\n922\n613", "output":...
code_stdio
[ { "content": "You are given a positive integer X.\nFind the largest perfect power that is at most X.\nHere, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.\n\n-----Constraints-----\n - 1 ≤ X ≤ 1000\n - X is an integer.\n\n-...
[{"input": "1074", "output": "1024\n"}, {"input": "1023", "output": "1000\n"}, {"input": "1298", "output": "1296\n"}, {"input": "1357", "output": "1331\n"}, {"input": "1746", "output": "1728\n"}, {"input": "999\n", "output": "961\n"}, {"input": "610", "output": "576\n"}, {"input": "159", "output": "144\n"}, {"input": "...
code_stdio
[ { "content": "Having read half of the book called \"Storm and Calm\" on the IT lesson, Innocentius was absolutely determined to finish the book on the maths lessons. All was fine until the math teacher Ms. Watkins saw Innocentius reading fiction books instead of solving equations of the fifth degree. As during ...
[{"input": "DaABYAOivguEueXufuoUeoiLiuEuEIeZAdoPgaUIIrUtoodAALPESiUaEbqitAphOIIEAogrjUBZLnIALGbazIermGEiAAdDAOFaaizopuUuuEugOHsXTAelFxAyZXWQXiEEKkGiIVdUmwiThDOiEyiuOEaiIAAjEQyaEuOiUGOuuzvaIEUEAhXEuOliOeEkJuJaUaszUKePiQuwXSuoQYEeUOgOeuyvOwhUuitEEKDVOaUaoiaIyiAEkyXeuiEkUorUYCaOXEAiUYPnUMaURebouLUOiOojcOeODaaIeEeuukDvpiIk...
code_stdio
[ { "content": "Bob and Alice are often participating in various programming competitions. Like many competitive programmers, Alice and Bob have good and bad days. They noticed, that their lucky and unlucky days are repeating with some period. For example, for Alice days $[l_a; r_a]$ are lucky, then there are som...
[{"input": "372839920 992839201 1000000000\n100293021 1262614379 999999993\n", "output": "619999282\n"}, {"input": "372839920 992839201 1000000000\n100293021 773829394 999999993\n", "output": "619999282\n"}, {"input": "372839920 992839201 1000000000\n100293021 773829394 999999993\n", "output": "619999282\n"}, {"input":...
code_stdio
[ { "content": "Dice Stamp\n\nDice stamp\n\nAt a local fair, you found a game store you've never seen before. This is a game in which N 6-sided dice are dropped and rolled on the board. More precisely, N buttons are tied to N dice on a one-to-one basis, and pressing the button causes the corresponding dice to fal...
[{"input": "1\n0 0\n1 2 3 4 5 6\nRRRRBBBBLLLLFFFF\n2\n0 0\n1 1 1 1 1 1\nRRR\n2 2\n100 100 100 100 100 101\nFFF\n1\n1010 -1000\n1 2 3 4 5 6\nLFRB\n4\n-3 -4\n1 2 3 4 5 6\nBBBBBBBB\n4 -3\n11 12 13 14 15 16\nLLLLLLLL\n3 4\n21 22 23 24 25 26\nFFFFFFFF\n-4 3\n31 32 33 34 35 36\nRRRRRRRR\n3\n-2 -2\n9 3 1 1 1 1\nRRRRBLLLBRRBLB...
code_stdio
[ { "content": "For a given sequence A = {a0, a1, ... , an-1}, find the length of the longest increasing subsequnece (LIS) in A.\n\nAn increasing subsequence of A is defined by a subsequence {ai0, ai1, ... , aik} where 0 ≤ i0 < i1 < ... < ik < n and ai0 < ai1 < ... < aik.\n\nConstraints\n\n* 1 ≤ n ≤ 100000\n* 0 ≤...
[{"input": "5\n5\n1\n2\n-1\n10", "output": "3\n"}, {"input": "5\n5\n1\n0\n-1\n10", "output": "2\n"}, {"input": "5\n5\n1\n0\n-1\n11", "output": "2\n"}, {"input": "5\n8\n1\n0\n-1\n11", "output": "2\n"}, {"input": "5\n8\n2\n0\n-1\n11", "output": "2\n"}, {"input": "5\n11\n1\n1\n0\n11", "output": "2\n"}, {"input": "5\n14\n1...
code_stdio
[ { "content": "problem\n\nHanako is playing with n (4 ≤ n ≤ 10) cards side by side. Each card has one integer between 1 and 99. Hanako chose k cards (2 ≤ k ≤ 4) from these cards and arranged them in a horizontal row to make an integer. How many kinds of integers can Hanako make in total?\n\nFor example, consider...
[{"input": "4\n2\n-1\n3\n10\n1\n6\n2\n133\n1\n15\n6\n0\n-1\n0\n0", "output": "12\n30\n"}, {"input": "4\n2\n1\n3\n22\n2\n6\n4\n11\n3\n12\n10\n2\n1\n0\n0", "output": "11\n308\n"}, {"input": "4\n4\n1\n7\n42\n0\n6\n3\n126\n3\n43\n7\n1\n2\n0\n0", "output": "24\n120\n"}, {"input": "4\n2\n-1\n10\n12\n2\n6\n3\n72\n2\n12\n7\n2\...
code_stdio
[ { "content": "Petya is a beginner programmer. He has already mastered the basics of the C++ language and moved on to learning algorithms. The first algorithm he encountered was insertion sort. Petya has already written the code that implements this algorithm and sorts the given integer zero-indexed array a of s...
[{"input": "150\n48 115 13 9 105 117 41 136 123 32 84 95 62 50 140 106 145 91 57 141 139 35 45 27 129 63 137 10 37 60 44 30 101 119 138 78 22 103 39 134 49 36 25 12 28 67 69 99 148 26 16 87 146 65 8 74 14 38 47 89 81 19 40 11 64 43 110 66 102 3 122 124 100 2 125 42 97 73 121 7 52 23 29 109 1 70 34 108 59 55 127 90 88 1...
code_stdio
[ { "content": "On a certain meeting of a ruling party \"A\" minister Pavel suggested to improve the sewer system and to create a new pipe in the city.\n\nThe city is an n × m rectangular squared field. Each square of the field is either empty (then the pipe can go in it), or occupied (the pipe cannot go in such ...
[{"input": "9 37\n.......#................#.##...#.....\n..#......................##..........\n..#......#.........#.................\n..........#..#..#..#...........#.....\n...#............#..##.#.....##.......\n......................#..............\n......#........##....#......#........\n........#.......................
code_stdio
[ { "content": "Vasya decided to learn to play chess. Classic chess doesn't seem interesting to him, so he plays his own sort of chess.\n\nThe queen is the piece that captures all squares on its vertical, horizontal and diagonal lines. If the cell is located on the same vertical, horizontal or diagonal line with ...
[{"input": "1000000000\n", "output": "white\n1 2\n"}, {"input": "1000000000\n", "output": "white\n1 2\n"}, {"input": "1000000010\n", "output": "white\n1 2\n"}, {"input": "1823733270\n", "output": "white\n1 2\n"}, {"input": "1381061568\n", "output": "white\n1 2\n"}, {"input": "1091549244\n", "output": "white\n1 2\n"}, {...
code_stdio
[ { "content": "You are given an array $a[0 \\ldots n - 1] = [a_0, a_1, \\ldots, a_{n - 1}]$ of zeroes and ones only. Note that in this problem, unlike the others, the array indexes are numbered from zero, not from one.\n\nIn one step, the array $a$ is replaced by another array of length $n$ according to the foll...
[{"input": "5\n2 2\n0 1\n3 2\n1 1 1\n5 2\n1 1 0 0 0\n4 1\n0 0 0 0\n1 1\n1\n", "output": "-1\n-1\n1\n0\n-1\n"}, {"input": "5\n2 1\n1 1\n3 1\n0 1 0\n5 3\n1 1 0 0 0\n4 4\n1 1 0 0\n1 1\n1\n", "output": "-1\n1\n1\n-1\n-1\n"}, {"input": "5\n2 1\n0 1\n3 3\n0 1 0\n5 3\n1 1 1 1 0\n4 4\n0 1 0 0\n1 1\n1\n", "output": "1\n-1\n4\n-...
code_stdio
[ { "content": "Polycarpus is sure that his life fits the description: \"first there is a white stripe, then a black one, then a white one again\". So, Polycarpus is sure that this rule is going to fulfill during the next n days. Polycarpus knows that he is in for w good events and b not-so-good events. At least ...
[{"input": "4000 2000 2219\n", "output": " 865711019"}, {"input": "4000 1244 4000\n", "output": " 344837886"}, {"input": "4000 1244 2881\n", "output": " 8905...
code_stdio
[ { "content": "A and B are preparing themselves for programming contests.\n\nAfter several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.\n\nA likes lowercase letters of the Latin alphabet. He has ...
[{"input": "-2 -2 2 1 4 0 -2 4 5 4 -5 -5 2 1 1 -1 0 -5 -2 3 -2 4 5 2 3 -5\nqgzhbkitmqwttdyoyvcbxincwjryzknubpacsngorexaldfurondbednowemnnlphhboycfavsovisrmfaefusoobingjhsmrukx\n", "output": "7\n"}, {"input": "-2 -2 2 1 4 0 -2 4 5 4 -5 -5 2 1 1 -1 0 -5 -2 3 -2 4 5 2 3 -5\nqgzhbkitmqwttdyoyvcbxincwjryzknubpacsngorexaldfu...
code_stdio
[ { "content": "Arkady wants to water his only flower. Unfortunately, he has a very poor watering system that was designed for $n$ flowers and so it looks like a pipe with $n$ holes. Arkady can only use the water that flows from the first hole.\n\nArkady can block some of the holes, and then pour $A$ liters of wa...
[{"input": "10 300 100\n35 25 110 40 60 7 44 145 23 96\n", "output": "6\n"}, {"input": "10 300 100\n35 42 110 40 60 7 44 145 23 96\n", "output": "6\n"}, {"input": "10 300 100\n35 42 110 40 60 7 26 145 23 96\n", "output": "6\n"}, {"input": "10 300 100\n35 42 110 40 60 7 26 158 23 96\n", "output": "6\n"}, {"input": "10 2...
code_stdio
[ { "content": "Berland year consists of $m$ months with $d$ days each. Months are numbered from $1$ to $m$. Berland week consists of $w$ days. The first day of the year is also the first day of the week. Note that the last week of the year might be shorter than $w$ days.\n\nA pair $(x, y)$ such that $x < y$ is a...
[{"input": "5\n6 7 1\n10 12 11\n12 30 6\n1 1 1\n3247834 10298779 625324\n", "output": "15\n45\n6\n0\n116461800\n"}, {"input": "5\n6 7 4\n10 9 16\n12 17 4\n0 1 1\n7341628 25065973 296620\n", "output": "6\n16\n66\n0\n359753922\n"}, {"input": "5\n6 10 1\n10 7 12\n12 30 6\n1 1 1\n3247834 3741802 625324\n", "output": "15\n9...
code_stdio
[ { "content": "Arkady's morning seemed to be straight of his nightmare. He overslept through the whole morning and, still half-asleep, got into the tram that arrived the first. Some time after, leaving the tram, he realized that he was not sure about the line number of the tram he was in.\n\nDuring his ride, Ark...
[{"input": "2\n64 23 81 66 95 91 56 12 48 24 78 36 67 57 75 88 82 98 83 46 100 58 62 80 8 4 28 74 70 50 42 11 68 18 19 6 94 59 13 72 37 31 90 41 60 34 86 55 76 69 32 21 73 84 3 52 92 79 61 63 38 87 17 14 29\n65 89 14 93 58 60 80 64 28 91 70 48 19 55 75 21 100 98 88 69 7 42 41 81 8 76 54 87 16 56 53 29 71 9 37 62 61 73 ...
code_stdio
[ { "content": "We have a two-dimensional grid with H \\times W squares. There are M targets to destroy in this grid - the position of the i-th target is \\left(h_i, w_i \\right).\nTakahashi will choose one square in this grid, place a bomb there, and ignite it. The bomb will destroy all targets that are in the r...
[{"input": "5 5 10\n2 5\n4 3\n2 3\n5 5\n2 2\n5 4\n5 3\n5 1\n3 5\n1 4\n", "output": "6\n"}, {"input": "5 10 10\n2 5\n4 5\n2 3\n5 5\n2 4\n5 4\n5 1\n1 1\n4 5\n1 4", "output": "6\n"}, {"input": "5 10 10\n2 5\n4 5\n2 3\n5 5\n2 4\n5 4\n5 1\n1 1\n4 1\n1 4", "output": "6\n"}, {"input": "5 10 10\n2 5\n4 5\n2 1\n3 5\n2 2\n5 4\n5...
code_stdio
[ { "content": "There are b blocks of digits. Each one consisting of the same n digits, which are given to you in the input. Wet Shark must choose exactly one digit from each block and concatenate all of those digits together to form one large integer. For example, if he chooses digit 1 from the first block and d...
[{"input": "100 1000000000 42 97\n2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2\n", "output": "590949100\n"}, {"input": "100 1000000000 42 97\n2 5 1 8 8 1 5 2 1 2 5 1...
code_stdio