messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "You have N cards. On the i-th card, an integer A_i is written.\nFor each j = 1, 2, ..., M in this order, you will perform the following operation once:\nOperation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card with C_j.\nFind the maximum possible sum of ...
[{"input": "11 3\n1 1 1 1 1 1 1 1 1 1 1\n3 1000000000\n4 1000000000\n3 1000000000\n", "output": "10000000001\n"}, {"input": "11 3\n1 1 1 1 1 1 1 1 1 1 1\n3 1000000000\n4 1000000000\n3 1000000001", "output": "10000000004\n"}, {"input": "11 3\n1 1 1 1 1 1 1 1 1 1 1\n3 1000000000\n4 1000000000\n3 1100000000", "output": "1...
code_stdio
[ { "content": "Let A, B, C, D, E be sets of integers and let U is a universal set that includes all sets under consideration. All elements in any set are different (no repetitions).\n\nu - union of two sets, AuB = {x ∈ U : x ∈ A or x ∈ B} is the set of all elements which belong to A or B.\n\ni - intersection of ...
[{"input": "A 3\n1 2 -1\nB 4\n4 0 0 11\nD 1\n5\nR 0\ncAiBdD\nC 3\n1 2 3\nA 4\n2 7 8 0\nB 3\n3 6 21\nR 0\n(As(AiB))uB", "output": "0 4 11\n0 2 3 6 7 8 21\n"}, {"input": "A 3\n2 3 -1\nB 4\n3 1 10 11\nD 1\n5\nR 0\ncAiBdD\nC 3\n1 2 3\nA 4\n2 10 8 3\nB 3\n2 4 7\nR 0\n(As(AiB))uC", "output": "1 10 11\n1 2 3 8 10\n"}, {"input...
code_stdio
[ { "content": "Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will \"hang up\" as the size of data to watch per second ...
[{"input": "1000 1 1000\n", "output": "999000\n"}, {"input": "1286 123 1043\n", "output": "9862\n"}, {"input": "1286 187 1043\n", "output": "6130\n"}, {"input": "1705 812 917\n", "output": "1009\n"}, {"input": "1286 123 899\n", "output": "8501\n"}, {"input": "1705 1125 917\n", "output": "473\n"}, {"input": "1329 1125 9...
code_stdio
[ { "content": "As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below:\n\n* A consists of integers between X and Y (inclusive).\n* For each 1\\leq i \\leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i.\n\...
[{"input": "15043200 358979323846264338", "output": "35\n"}, {"input": "12899738 158337027091717102", "output": "34\n"}, {"input": "12899738 686618920047839292", "output": "36\n"}, {"input": "1565492 1138463356571161467", "output": "40\n"}, {"input": "12899738 272946151952874087", "output": "35\n"}, {"input": "12899738...
code_stdio
[ { "content": "A monster is chasing after Rick and Morty on another planet. They're so frightened that sometimes they scream. More accurately, Rick screams at times b, b + a, b + 2a, b + 3a, ... and Morty screams at times d, d + c, d + 2c, d + 3c, .... [Image] \n\nThe Monster will catch them if at any point the...
[{"input": "100 100\n100 100\n", "output": "100\n"}, {"input": "100 100\n100 100\n", "output": "100\n"}, {"input": "100 110\n100 100\n", "output": "-1\n"}, {"input": "87 22\n119 64\n", "output": "1849\n"}, {"input": "31 74\n88 152\n", "output": "2616\n"}, {"input": "39 52\n88 78\n", "output": "1222\n"}, {"input": "59 9...
code_stdio
[ { "content": "It all started with a black-and-white picture, that can be represented as an $n \\times m$ matrix such that all its elements are either $0$ or $1$. The rows are numbered from $1$ to $n$, the columns are numbered from $1$ to $m$.\n\nSeveral operations were performed on the picture (possibly, zero),...
[{"input": "6 4 7\n\n1010\n0001\n0001\n1000\n0111\n0101\n\n1010\n0001\n0001\n1000\n0111\n0101\n\n1010\n0001\n0001\n1000\n0111\n0101\n\n1010\n0001\n0001\n1000\n0111\n0101\n\n1010\n0001\n0001\n1000\n0111\n0101\n\n1010\n0001\n0001\n1000\n0111\n0101\n\n1010\n0001\n0001\n1000\n0111\n0101\n\n1010\n0001\n0001\n1000\n0111\n010...
code_stdio
[ { "content": "Create a function that returns an array containing the first `l` digits from the `n`th diagonal of [Pascal's triangle](https://en.wikipedia.org/wiki/Pascal's_triangle).\n\n`n = 0` should generate the first diagonal of the triangle (the 'ones'). The first number in each diagonal should be 1.\n\nIf ...
[{"input": "4\n10", "output": "[[1, 5, 15, 35, 70, 126, 210, 330, 495, 715]]", "fn_name": "generate_diagonal"}, {"input": "100\n6", "output": "[[1, 101, 5151, 176851, 4598126, 96560646]]", "fn_name": "generate_diagonal"}, {"input": "3\n10", "output": "[[1, 4, 10, 20, 35, 56, 84, 120, 165, 220]]", "fn_name": "generate_d...
code_functional
[ { "content": "Polycarp is wondering about buying a new computer, which costs $c$ tugriks. To do this, he wants to get a job as a programmer in a big company.\n\nThere are $n$ positions in Polycarp's company, numbered starting from one. An employee in position $i$ earns $a[i]$ tugriks every day. The higher the p...
[{"input": "3\n4 15\n1 3 20 11\n1 2 13\n4 100\n2 5 10 50\n3 26 12\n2 1000000000\n1 1\n1\n", "output": "5\n14\n1000000000\n"}, {"input": "3\n4 15\n1 6 20 11\n1 2 13\n4 100\n2 7 10 50\n3 26 12\n2 1000000000\n1 1\n1\n", "output": "5\n12\n1000000000\n"}, {"input": "3\n4 15\n1 3 10 11\n0 2 23\n4 100\n2 5 10 50\n3 14 12\n2 1...
code_stdio
[ { "content": "There is a binary string $a$ of length $n$. In one operation, you can select any prefix of $a$ with an equal number of $0$ and $1$ symbols. Then all symbols in the prefix are inverted: each $0$ becomes $1$ and each $1$ becomes $0$.\n\nFor example, suppose $a=0111010000$.\n\nIn the first operation,...
[{"input": "5\n10\n0111010000\n0100101100\n4\n0000\n0000\n3\n000\n000\n12\n010101010101\n100110011010\n6\n000111\n110100\n", "output": "YES\nYES\nYES\nYES\nNO\n"}, {"input": "5\n10\n0101011000\n1001101000\n4\n0000\n0000\n3\n010\n100\n12\n010101010101\n100110011010\n6\n000011\n110100\n", "output": "YES\nYES\nYES\nYES\nN...
code_stdio
[ { "content": "You are given an array $a$ of $n$ positive integers.\n\nYou can use the following operation as many times as you like: select any integer $1 \\le k \\le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array. ...
[{"input": "4\n3\n1 2 -1\n5\n40 9 13 6 13\n5\n1 1 0 1 1\n4\n7 2 1 10\n", "output": "NO\nYES\nYES\nYES\n"}, {"input": "4\n3\n1 2 2\n5\n20 9 15 6 9\n5\n1 1 0 1 1\n4\n5 2 1 10\n", "output": "YES\nYES\nYES\nYES\n"}, {"input": "4\n3\n1 2 1\n5\n20 9 15 6 9\n5\n1 1 0 1 1\n4\n5 2 1 10\n", "output": "YES\nYES\nYES\nYES\n"}, {"i...
code_stdio
[ { "content": "Write a function that receives two strings and returns n, where n is equal to the number of characters we should shift the first string forward to match the second.\n\nFor instance, take the strings \"fatigue\" and \"tiguefa\". In this case, the first string has been rotated 5 characters forward t...
[{"input": "\"123456789!@#$%^&*( )qwerty\"\n\"9!@#$%^&*( )qwerty12345678\"", "output": "[18]", "fn_name": "shifted_diff"}, {"input": "\"doomhouse\"\n\"hoodmouse\"", "output": "[-1]", "fn_name": "shifted_diff"}, {"input": "\"fatigue\"\n\"tiguefa\"", "output": "[5]", "fn_name": "shifted_diff"}, {"input": "\"eecoff\"\n\"c...
code_functional
[ { "content": "In the capital city of Berland, Bertown, demonstrations are against the recent election of the King of Berland. Berland opposition, led by Mr. Ovalny, believes that the elections were not fair enough and wants to organize a demonstration at one of the squares.\n\nBertown has n squares, numbered fr...
[{"input": "100 10\n9199\n89 409 428 408 309 400 259 393 212 273 472 654 533 774 663 484 695 801 587 518 521 578 767 644 532 785 500 944 582 680 899 882 589 601 614 633 877 543 770 614 852 715 932 627 639 658 765 957 898 545 977 751 740 869 885 831 834 702 934 954 500 626 605 921 755 661 707 952 842 978 979 879 837 581...
code_stdio
[ { "content": "A browser-based puzzle game called \"Bubble Puzzle\" is now popular on the Internet.\n\nThe puzzle is played on a 4 Γ— 4 grid, and initially there are several bubbles in the grid squares. Each bubble has a state expressed by a positive integer, and the state changes when the bubble gets stimulated....
[{"input": "2 4 3 4\n2 1 2 4\n3 3 2 2\n0 3 3 3", "output": "-1\n"}, {"input": "2 4 3 4\n2 1 2 0\n3 3 2 2\n0 3 3 3", "output": "-1\n"}, {"input": "2 1 4 1\n2 2 4 2\n2 4 4 1\n0 4 4 1", "output": "-1\n"}, {"input": "2 4 3 3\n2 1 4 1\n3 3 2 2\n0 3 1 3", "output": "-1\n"}, {"input": "2 4 4 0\n2 2 4 1\n2 4 1 1\n2 3 4 0", "ou...
code_stdio
[ { "content": "When provided with a number between 0-9, return it in words.\n\nInput :: 1\n\nOutput :: \"One\".\n\nIf your language supports it, try using a switch statement.\n\nWrite Python code to solve this problem. Define a top-level function named `switch_it_up` that takes the input arguments described abov...
[{"input": "3", "output": "[\"Three\"]", "fn_name": "switch_it_up"}, {"input": "7", "output": "[\"Seven\"]", "fn_name": "switch_it_up"}, {"input": "8", "output": "[\"Eight\"]", "fn_name": "switch_it_up"}, {"input": "0", "output": "[\"Zero\"]", "fn_name": "switch_it_up"}, {"input": "4", "output": "[\"Four\"]", "fn_name"...
code_functional
[ { "content": "# Task\n let F(N) be the sum square of digits of N. So:\n \n `F(1) = 1, F(3) = 9, F(123) = 14`\n\n Choose a number A, the sequence {A0, A1, ...} is defined as followed:\n ```\n A0 = A\n A1 = F(A0)\n A2 = F(A1) ...\n ```\n \n if A = 123, we have:\n ```\n 123 β†’ 14(1 x 1 + 2 x 2 + 3 x 3)\n ...
[{"input": "810", "output": "[8]", "fn_name": "repeat_sequence_len"}, {"input": "812", "output": "[8]", "fn_name": "repeat_sequence_len"}, {"input": "818", "output": "[1]", "fn_name": "repeat_sequence_len"}, {"input": "833", "output": "[1]", "fn_name": "repeat_sequence_len"}, {"input": "85", "output": "[8]", "fn_name":...
code_functional
[ { "content": "There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.\nSnuke plotted N points into the rectangle. The coordinate of t...
[{"input": "18 1 -1\n2 -1 1\n5 2 1\n1 1 4\n5 2 0\n2 0 12", "output": "18\n"}, {"input": "10 10 5\n1 6 1\n4 1 3\n6 9 4\n9 4 2\n3 1 3\n", "output": "64\n"}, {"input": "10 10 5\n1 14 1\n4 1 1\n6 4 4\n9 0 2\n3 2 4", "output": "10\n"}, {"input": "10 10 0\n1 6 1\n4 1 1\n6 4 4\n9 4 0\n3 2 4", "output": "100\n"}, {"input": "10...
code_stdio
[ { "content": "Emuskald considers himself a master of flow algorithms. Now he has completed his most ingenious program yet β€” it calculates the maximum flow in an undirected graph. The graph consists of n vertices and m edges. Vertices are numbered from 1 to n. Vertices 1 and n being the source and the sink respe...
[{"input": "10 23\n10 5 94\n6 9 20\n10 2 79\n3 9 63\n1 6 80\n7 8 21\n3 5 6\n3 1 94\n2 5 21\n1 2 100\n1 7 79\n6 10 59\n8 1 60\n10 3 37\n9 1 37\n4 8 40\n7 10 100\n6 4 41\n5 1 79\n8 10 79\n9 10 80\n10 4 60\n4 1 59\n", "output": "1\n1\n1\n0\n0\n1\n1\n1\n0\n0\n0\n0\n1\n1\n1\n0\n0\n0\n1\n0\n0\n1\n1\n"}, {"input": "10 20\n3 8...
code_stdio
[ { "content": "Kuriyama Mirai has killed many monsters and got many (namely n) stones. She numbers the stones from 1 to n. The cost of the i-th stone is v_{i}. Kuriyama Mirai wants to know something about these stones so she will ask you two kinds of questions: She will tell you two numbers, l and rΒ (1 ≀ l ≀ r ...
[{"input": "56\n43 100 44 66 65 11 26 75 96 77 5 15 75 96 11 44 11 97 75 53 33 26 32 33 90 26 68 72 5 44 53 26 33 88 68 25 84 21 25 92 1 84 21 66 94 35 76 51 11 95 67 4 61 3 34 18\n27\n1 20 38\n1 11 46\n2 42 53\n1 8 11\n2 11 42\n2 35 39\n2 37 41\n1 48 51\n1 32 51\n1 36 40\n1 31 56\n1 18 38\n2 9 51\n1 7 48\n1 15 52\n1 2...
code_stdio
[ { "content": "In a public bath, there is a shower which emits water for T seconds when the switch is pushed.\n\nIf the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional sec...
[{"input": "4 1000000000\n0 1100 1000000 1000000000", "output": "2000000000\n"}, {"input": "4 1000000000\n0 1100 1000000 1010000000", "output": "2001000000\n"}, {"input": "4 1000010000\n0 1000 1000000 1000000000", "output": "2000010000\n"}, {"input": "4 1000000000\n0 1100 1100000 1010000000", "output": "2001100000\n"},...
code_stdio
[ { "content": "This kata requires you to convert minutes (`int`) to hours and minutes in the format `hh:mm` (`string`).\n\nIf the input is `0` or negative value, then you should return `\"00:00\"`\n\n**Hint:** use the modulo operation to solve this challenge. The modulo operation simply returns the remainder aft...
[{"input": "565757", "output": "[\"9429:17\"]", "fn_name": "time_convert"}, {"input": "134", "output": "[\"02:14\"]", "fn_name": "time_convert"}, {"input": "180", "output": "[\"03:00\"]", "fn_name": "time_convert"}, {"input": "970", "output": "[\"16:10\"]", "fn_name": "time_convert"}, {"input": "-6", "output": "[\"00:0...
code_functional
[ { "content": "There is an undirected tree of $n$ vertices, connected by $n-1$ bidirectional edges. There is also a snake stuck inside of this tree. Its head is at vertex $a$ and its tail is at vertex $b$. The snake's body occupies all vertices on the unique simple path between $a$ and $b$.\n\nThe snake wants to...
[{"input": "4\n8 4 7\n1 2\n2 3\n1 4\n4 5\n4 6\n1 7\n7 8\n4 3 2\n4 3\n1 2\n2 3\n9 3 5\n1 2\n2 3\n3 4\n1 5\n5 6\n6 7\n1 8\n8 9\n16 15 12\n1 2\n2 3\n1 4\n4 5\n5 6\n6 7\n4 8\n10 9\n8 13\n10 11\n11 12\n11 13\n13 14\n10 15\n15 16\n", "output": "YES\nNO\nNO\nYES\n"}, {"input": "4\n8 4 7\n1 2\n2 3\n1 4\n4 5\n4 6\n1 7\n7 8\n4 3...
code_stdio
[ { "content": "Chef is good at making pancakes. Generally he gets requests to serve N pancakes at once.\nHe serves them in the form of a stack.\nA pancake can be treated as a circular disk with some radius.\n\nChef needs to take care that when he places a pancake on the top of the stack the radius of the pancake...
[{"input": "2\n-1\n162", "output": "0\n688663125\n"}, {"input": "2\n-1\n199", "output": "0\n347692428\n"}, {"input": "2\n-1\n52", "output": "0\n756600466\n"}, {"input": "2\n-1\n87", "output": "0\n884560880\n"}, {"input": "2\n-1\n14", "output": "0\n190899322\n"}, {"input": "2\n1\n108", "output": "1\n842145354\n"}, {"inp...
code_stdio
[ { "content": "To become the king of Codeforces, Kuroni has to solve the following problem.\n\nHe is given $n$ numbers $a_1, a_2, \\dots, a_n$. Help Kuroni to calculate $\\prod_{1\\le i<j\\le n} |a_i - a_j|$. As result can be very big, output it modulo $m$.\n\nIf you are not familiar with short notation, $\\prod...
[{"input": "140 149\n124 109 136 123 83 121 53 37 111 105 75 224 99 87 51 45 131 83 18 76 99 29 115 96 16 89 88 69 81 100 120 90 141 48 83 97 26 27 51 94 53 25 32 27 4 139 81 140 137 95 94 89 116 32 85 155 68 12 107 10 124 96 110 32 135 126 2 146 79 14 132 136 110 16 130 98 109 191 2 18 52 27 134 74 101 84 13 133 12 38...
code_stdio
[ { "content": "Your friend Mishka and you attend a calculus lecture. Lecture lasts n minutes. Lecturer tells a_{i} theorems during the i-th minute.\n\nMishka is really interested in calculus, though it is so hard to stay awake for all the time of lecture. You are given an array t of Mishka's behavior. If Mishka ...
[{"input": "10 5\n1 1 1 1 1 1 1 1 10000 1\n1 1 1 1 1 1 1 1 0 1\n", "output": "10009\n"}, {"input": "10 5\n1 1 1 1 1 1 1 1 10000 1\n1 1 1 1 1 1 1 1 0 1\n", "output": "10009\n"}, {"input": "10 5\n1 1 1 1 1 1 1 1 10000 1\n1 1 1 0 1 1 1 1 0 1\n", "output": "10008\n"}, {"input": "10 5\n1 2 1 1 1 1 1 1 10000 1\n1 1 1 0 1 1 1...
code_stdio
[ { "content": "The History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asleep during history lessons, and his magical quill writes the lectures for him. Professor Binns, the history of magic teacher, lectures in such a boring and monotono...
[{"input": "50\n1230\n6040\n1035\n1973\n9096\n5133\n1146\n1164\n9195\n5211\n6212\n1313\n1953\n1560\n1382\n2324\n1343\n1481\n1555\n1363\n1487\n1414\n1525\n1564\n1561\n9585\n7590\n1663\n5625\n1630\n1630\n3644\n1164\n1665\n7678\n1282\n1626\n1798\n9755\n7801\n8809\n1762\n1867\n1861\n1826\n1809\n8902\n1033\n1774\n9978\n", "...
code_stdio
[ { "content": "Toad Zitz has an array of integers, each integer is between $0$ and $m-1$ inclusive. The integers are $a_1, a_2, \\ldots, a_n$.\n\nIn one operation Zitz can choose an integer $k$ and $k$ indices $i_1, i_2, \\ldots, i_k$ such that $1 \\leq i_1 < i_2 < \\ldots < i_k \\leq n$. He should then change $...
[{"input": "100 1000\n980 755 745 448 424 691 210 545 942 979 555 783 425 942 495 741 487 514 752 434 187 874 372 617 414 505 659 445 81 397 243 986 441 587 31 350 831 801 194 103 723 166 108 182 252 846 328 905 639 690 738 638 986 340 559 626 572 808 442 410 179 549 880 153 449 99 434 945 163 687 173 797 999 274 975 6...
code_stdio
[ { "content": "You are given a multiset S. Over all pairs of subsets A and B, such that:\n\n * B βŠ‚ A; \n * |B| = |A| - 1; \n * greatest common divisor of all elements in A is equal to one; \n\n\n\nfind the sum of βˆ‘_{x ∈ A}{x} β‹… βˆ‘_{x ∈ B}{x}, modulo 998 244 353.\n\nInput\n\nThe first line contains one integer ...
[{"input": "30\n50791 243945320\n48702 457583014\n41675 229737141\n51903 823204069\n62672 982333456\n13022 6181002\n21220 952812271\n49208 751131975\n73341 457778516\n17236 855209229\n34474 293240200\n4702 655177190\n39507 367063302\n94513 894252033\n62219 507962042\n88877 952246542\n74469 527469163\n54023 724142796\n9...
code_stdio
[ { "content": "The Cybernetics Failures (CF) organisation made a prototype of a bomb technician robot. To find the possible problems it was decided to carry out a series of tests. At the beginning of each test the robot prototype will be placed in cell (x_0, y_0) of a rectangular squared field of size x Γ— y, aft...
[{"input": "15 17 8 9\nURRDLUULLDDDRRURR\n", "output": "1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 0 241\n"}, {"input": "15 17 8 9\nURRDLUULLDDDRRURR\n", "output": "1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 0 241 "}, {"input": "15 17 7 9\nURRDLUULLDDDRRURR\n", "output": "1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 0 241\n"}, {"input": "15 17 1 9\nURRD...
code_stdio
[ { "content": "Daisy, being a good hacker as we all know, recently came across a file of the evil organization-Hydra which requires a password to open, and you have been assigned the task to help her in it.\n\nShe knows that the password of Hydra files are usually made from a list of words that Daisy already has...
[{"input": "206\nHa HaHaHaHa\nTheHandleCanBeVeryLong TheHandleCanBeVeryLong\nLong LongLong\nhFVvzbvASpRyHNXXoGHe NxjozJgpEPXrDJaBJmtjessBysMuMZzawDHEFqAQ\nUxuJUtGhPW yCqiAekNxXkzlPBTpBOy\nLDybFtrIbfBFfKBfxM LDybFtrIbfBFfKBfxMLDybFtrIbfBFfKBfxM\nwSoinsWghfObLqESjxBOJCW xwzBtBWANgrWaqdFjkRthQHdbblnTmELOqiFOPjAWRJSWu\nJAl...
code_stdio
[ { "content": "Your favorite music streaming platform has formed a perfectly balanced playlist exclusively for you. The playlist consists of $n$ tracks numbered from $1$ to $n$. The playlist is automatic and cyclic: whenever track $i$ finishes playing, track $i+1$ starts playing automatically; after track $n$ go...
[{"input": "100\n7585 5510 1017 4329 2840 8171 5089 1873 7308 9656 6833 7578 4914 6658 4408 7122 5265 1204 9800 3150 2151 6906 6041 3973 931 7239 4421 4211 156 8655 4266 3543 9752 3117 2731 6052 8950 9391 6367 996 9973 629 9489 4912 9226 9301 5166 4889 3710 6794 618 9155 2462 1120 5499 5861 3177 9274 3036 666 8054 5789...
code_stdio
[ { "content": "You have to rebuild a string from an enumerated list.\nFor this task, you have to check if input is correct beforehand.\n\n* Input must be a list of tuples\n* Each tuple has two elements.\n* Second element is an alphanumeric character.\n* First element is the index of this character into the recon...
[{"input": "[[\"a\", 0]]", "output": "[false]", "fn_name": "denumerate"}, {"input": "[[1, \"a\"]]", "output": "[false]", "fn_name": "denumerate"}, {"input": "[[0, \"\"]]", "output": "[false]", "fn_name": "denumerate"}, {"input": "\"a\"", "output": "[false]", "fn_name": "denumerate"}, {"input": "[0]", "output": "[false]...
code_functional
[ { "content": "According to an old legeng, a long time ago Ankh-Morpork residents did something wrong to miss Fortune, and she cursed them. She said that at some time n snacks of distinct sizes will fall on the city, and the residents should build a Snacktower of them by placing snacks one on another. Of course,...
[{"input": "100\n98 52 63 2 18 96 31 58 84 40 41 45 66 100 46 71 26 48 81 20 73 91 68 76 13 93 17 29 64 95 79 21 55 75 19 85 54 51 89 78 15 87 43 59 36 1 90 35 65 56 62 28 86 5 82 49 3 99 33 9 92 32 74 69 27 22 77 16 44 94 34 6 57 70 23 12 61 25 8 11 67 47 83 88 10 14 30 7 97 60 42 37 24 38 53 50 4 80 72 39\n", "output...
code_stdio
[ { "content": "problem\n\nYou love pasta, and you make and eat pasta for dinner every day. You can make three types of pasta: tomato sauce, cream sauce, and basil sauce.\n\nI decided to plan a dinner for N days. Choose one of the three types of pasta each day. However, if the same pasta continues, you will get b...
[{"input": "12 0\n1 3\n-1 1\n1 1", "output": "4576\n"}, {"input": "21 1\n2 2\n1 4\n10 2", "output": "2256\n"}, {"input": "18 2\n12 3\n1 1\n4 5", "output": "2568\n"}, {"input": "17 0\n1 3\n-2 1\n1 2", "output": "8560\n"}, {"input": "10 1\n3 2\n1 2\n4 3", "output": "9136\n"}, {"input": "13 3\n3 2\n1 2\n4 3", "output": "8...
code_stdio
[ { "content": "The life goes up and down, just like nice sequences. Sequence t_1, t_2, ..., t_{n} is called nice if the following two conditions are satisfied: t_{i} < t_{i} + 1 for each odd i < n; t_{i} > t_{i} + 1 for each even i < n. \n\nFor example, sequences (2, 8), (1, 5, 1) and (2, 5, 1, 100, 99, 120) ...
[{"input": "50\n11836 28308 72527 92281 139289 93797 134555 148444 40866 111317 21564 87813 65466 20541 99238 2287 74647 128071 18163 61672 39766 55589 138385 147443 138100 142683 60703 15444 52566 72976 147412 116006 115986 110545 79993 100440 9876 71470 75209 62443 64906 88987 72232 2246 63160 45041 729 148611 103397...
code_stdio
[ { "content": "There are N towns on a line running east-west. The towns are numbered 1 through N, in order from west to east. Each point on the line has a one-dimensional coordinate, and a point that is farther east has a greater coordinate value. The coordinate of town i is X_i.\n\nYou are now at town 1, and yo...
[{"input": "7 4 101\n20 172 33 4 146 156 146", "output": "-470\n"}, {"input": "7 2 100\n40 43 45 105 108 115 124", "output": "148\n"}, {"input": "7 2 101\n40 105 30 4 146 147 37", "output": "-218\n"}, {"input": "7 2 101\n20 174 30 4 146 147 37", "output": "-356\n"}, {"input": "7 2 101\n20 172 33 4 146 156 37", "output"...
code_stdio
[ { "content": "You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made.\n\nA problemset for the contest must consist of at least two problems. You think that the total difficulty of the pro...
[{"input": "15 4789415 23152928 140536\n502422 273992 449428 1752566 753047 681985 857134 243310 478052 77769 936151 642380 464695 281772 964693\n", "output": "15447\n"}, {"input": "15 4789415 22705612 140536\n502422 273992 449428 1752566 753047 681985 857134 243310 478052 77769 936151 642380 464695 281772 964693\n", "...
code_stdio
[ { "content": "Description\n\nF, who likes to dance, decided to practice a hardcore dance called JUMP STYLE at a certain dance hall.\n\nThe floor is tiled in an N Γ— N grid. To support the dance practice, each tile has the coordinates of the tile to jump to the next step. F has strong motor nerves through daily p...
[{"input": "1\n0 0\n2\n1 0 0 1\n0 0 0 0\n2\n1 1 0 1\n1 1 1 0\n3\n0 1 2 2 2 0\n0 2 1 2 2 1\n0 0 0 1 1 0\n4\n3 2 2 -1 3 2 0 1\n1 1 0 3 1 2 3 0\n1 3 1 3 3 0 2 2\n1 1 1 1 3 2 1 3\n0", "output": "1\n1\n1\n4\n1\n"}, {"input": "1\n0 0\n2\n1 0 0 1\n0 0 0 0\n2\n1 1 0 1\n1 1 1 0\n3\n0 1 2 2 2 2\n0 2 1 2 2 0\n0 0 0 1 1 0\n4\n3 2 ...
code_stdio
[ { "content": "Iahub likes trees very much. Recently he discovered an interesting tree named propagating tree. The tree consists of n nodes numbered from 1 to n, each node i having an initial value a_{i}. The root of the tree is node 1.\n\nThis tree has a special property: when a value val is added to a value of...
[{"input": "10 10\n418 45 865 869 745 901 177 773 854 462\n4 8\n1 4\n3 6\n1 5\n1 10\n5 9\n1 2\n4 7\n1 3\n2 2\n1 6 246\n1 4 296\n1 2 378\n1 8 648\n2 6\n1 5 288\n1 6 981\n1 2 868\n2 7\n", "output": "45\n1147\n-119\n"}, {"input": "10 10\n418 45 865 869 745 901 177 773 854 462\n4 8\n1 4\n3 6\n1 5\n1 10\n5 9\n1 2\n4 7\n1 3\...
code_stdio
[ { "content": "In the capital city of Berland, Bertown, demonstrations are against the recent election of the King of Berland. Berland opposition, led by Mr. Ovalny, believes that the elections were not fair enough and wants to organize a demonstration at one of the squares.\n\nBertown has n squares, numbered fr...
[{"input": "100 10\n9199\n89 409 428 408 309 400 259 393 212 273 472 654 533 774 663 484 695 801 587 518 521 578 767 644 532 785 500 944 582 680 899 882 589 601 614 633 877 543 770 614 852 715 932 627 639 658 765 957 898 545 977 751 740 869 885 831 834 702 934 954 500 626 605 921 755 661 707 952 842 978 979 879 837 581...
code_stdio
[ { "content": "This contest is `CODE FESTIVAL`. However, Mr. Takahashi always writes it `CODEFESTIVAL`, omitting the single space between `CODE` and `FESTIVAL`.\n\nSo he has decided to make a program that puts the single space he omitted.\n\nYou are given a string s with 12 letters. Output the string putting a s...
[{"input": "ETAUDARGTSOP", "output": "ETAU DARGTSOP\n"}, {"input": "AACDEFGHIJKL", "output": "AACD EFGHIJKL\n"}, {"input": "COCEFESTIVAL", "output": "COCE FESTIVAL\n"}, {"input": "POSTGRADUATF", "output": "POST GRADUATF\n"}, {"input": "ALCDEFGHIJKA", "output": "ALCD EFGHIJKA\n"}, {"input": "COCEFESTIV@L", "output": "CO...
code_stdio
[ { "content": "You have N coins each of which has a value ai. Find the number of combinations that result when you choose K different coins in such a way that the total value of the coins is greater than or equal to L and less than or equal to R.\n\nConstraints\n\n* 1 ≀ K ≀ N ≀ 40\n* 1 ≀ ai ≀ 1016\n* 1 ≀ L ≀ R ≀...
[{"input": "5 4 7 19\n1 10 2 2 -1", "output": "4\n"}, {"input": "5 6 7 19\n1 10 2 2 -1", "output": "0\n"}, {"input": "5 4 13 19\n1 5 1 2 -1", "output": "0\n"}, {"input": "5 6 10 7\n1 10 2 2 -1", "output": "0\n"}, {"input": "5 3 13 19\n1 5 1 2 -1", "output": "0\n"}, {"input": "5 6 10 7\n0 10 2 2 -1", "output": "0\n"}, {...
code_stdio
[ { "content": "Have you ever tried to explain to the coordinator, why it is eight hours to the contest and not a single problem has been prepared yet? Misha had. And this time he has a really strong excuse: he faced a space-time paradox! Space and time replaced each other.\n\nThe entire universe turned into an e...
[{"input": "11 59 59 11 12\n", "output": "YES\n"}, {"input": "12 12 12 11 12\n", "output": "YES\n"}, {"input": "11 59 59 12 11\n", "output": "YES\n"}, {"input": "12 12 12 11 12\n", "output": "YES\n"}, {"input": "11 59 59 11 12\n", "output": "YES\n"}, {"input": "11 59 59 12 11\n", "output": "YES\n"}, {"input": "10 22 59...
code_stdio
[ { "content": "We have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.\nWe will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.\nThe i-th and j-th sardines (i \\neq j) ar...
[{"input": "10\n2 0\n2 -1\n-1 -1\n1 20\n0 -1\n-18 -1\n1 -1\n1 1\n-5 -1\n4 0", "output": "399\n"}, {"input": "10\n2 0\n0 0\n-1 2\n-1 13\n-2 -26\n-11 -1\n2 -1\n0 1\n0 0\n0 4", "output": "161\n"}, {"input": "10\n2 -1\n0 0\n-1 2\n-1 13\n0 -26\n-16 -1\n4 -1\n0 1\n0 0\n0 4", "output": "257\n"}, {"input": "10\n1 -1\n0 0\n0 3\...
code_stdio
[ { "content": "The protection of a popular program developed by one of IT City companies is organized the following way. After installation it outputs a random five digit number which should be sent in SMS to a particular phone number. In response an SMS activation code arrives.\n\nA young hacker Vasya disassemb...
[{"input": "91537\n", "output": "27651\n"}, {"input": "13542\n", "output": "84443\n"}, {"input": "32036\n", "output": "82432\n"}, {"input": "71232\n", "output": "10151\n"}, {"input": "10000\n", "output": "00000\n"}, {"input": "70809\n", "output": "00000\n"}, {"input": "41675\n", "output": "61851\n"}, {"input": "99999\n...
code_stdio
[ { "content": "Snuke found N strange creatures. Each creature has a fixed color and size. The color and size of the i-th creature are represented by i and A_i, respectively.\n\nEvery creature can absorb another creature whose size is at most twice the size of itself. When a creature of size A and color B absorbs...
[{"input": "6\n65 3 38 -1 1 43", "output": "3\n"}, {"input": "6\n65 2 38 -1 1 43", "output": "3\n"}, {"input": "6\n65 3 38 -2 1 43", "output": "3\n"}, {"input": "6\n65 4 38 -1 1 43", "output": "3\n"}, {"input": "6\n40 1 26 2 7 20", "output": "4\n"}, {"input": "6\n40 1 26 2 9 20", "output": "4\n"}, {"input": "6\n40 1 21...
code_stdio
[ { "content": "This time the Berland Team Olympiad in Informatics is held in a remote city that can only be reached by one small bus. Bus has n passenger seats, seat i can be occupied only by a participant from the city ai.\n\nToday the bus has completed m trips, each time bringing n participants. The participan...
[{"input": "10 5 1000000000\n1 1 1 2 2 1 2 2 2 2\n", "output": "10000000000\n"}, {"input": "10 5 1000000000\n1 1 1 2 2 1 2 2 3 2\n", "output": "10000000000\n"}, {"input": "10 5 1000000000\n1 1 1 2 0 1 2 2 3 2\n", "output": "10000000000\n"}, {"input": "1 1000000000 1000000000\n100000\n", "output": "0\n"}, {"input": "1 1...
code_stdio
[ { "content": "In the Kingdom of AtCoder, people use a language called Taknese, which uses lowercase English letters.\nIn Taknese, the plural form of a noun is spelled based on the following rules:\n - If a noun's singular form does not end with s, append s to the end of the singular form.\n - If a noun's singul...
[{"input": "upruskhsmeicaqqesyyvopepmvdosibrvqoghdeikbpqbfgrufxdsqchjkuxpxngebxrmqdgqjsosencrbwknllvucvubyozfmttxtlsrrnrqavshaszrenhlbzpnpjgqftvwgukjwsekfcgllbzlnvmosmvqubtwsgltvmmzmslqdxqiifzkaqhsxzguseuexlycgubhdnwhrssyiybitcoowlhmmrdpgtrdwalvffknwibhwhacqfjcmwupoxonavvxwsvprpymskznabsquwssucxrmywerfpziqdziycnynthgmd...
code_stdio
[ { "content": "There are n stones on the table in a row, each of them can be red, green or blue. Count the minimum number of stones to take from the table so that any two neighboring stones had different colors. Stones in a row are considered neighboring if there are no other stones between them.\n\n\n-----Input...
[{"input": "50\nGRBGGRBRGRBGGBBBBBGGGBBBBRBRGBRRBRGBBBRBBRRGBGGGRB\n", "output": "18\n"}, {"input": "50\nRBGGBGGRBGRBBBGBBGRBBBGGGRBBBGBBBGRGGBGGBRBGBGRRGG\n", "output": "17\n"}, {"input": "50\nGGGBBRGGGGGRRGGRBGGRGBBRBRRBGRGBBBGBRBGRGBBGRGGBRB\n", "output": "16\n"}, {"input": "50\nGBGRGRRBRRRRRGGBBGBRRRBBBRBBBRRGRBBRG...
code_stdio
[ { "content": "A boy Valera registered on site Codeforces as Valera, and wrote his first Codeforces Round #300. He boasted to a friend Arkady about winning as much as x points for his first contest. But Arkady did not believe his friend's words and decided to check whether Valera could have shown such a result.\...
[{"input": "230 125 175 124 1 1\n", "output": "YES\n"}, {"input": "230 125 221 124 1 1\n", "output": "YES\n"}, {"input": "230 195 221 124 1 1\n", "output": "YES\n"}, {"input": "375 6 133 267 19 36\n", "output": "NO\n"}, {"input": "363 2 280 239 5 231\n", "output": "NO\n"}, {"input": "223 92 123 118 1 1\n", "output": "Y...
code_stdio
[ { "content": "In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 Γ— 8): Anna is in the upper right corner, and Maria is in the lower left one. Apart from them, the board has several statues. Each statue occupies exactly one square. ...
[{"input": "S......A\n.SS..S..\nS....S..\nSSS...S.\n.SS.STS.\n.S.SS...\n..S..S..\nM.SS....\n", "output": "LOSE\n"}, {"input": "SSSSSSSA\n......S.\n/.....S.\n.....SS.\n....SS..\n...SS...\n..SS....\nMSS.....\n", "output": "LOSE\n"}, {"input": "S..SSSSA\n.S..S...\nS.S....S\n.S.S..SS\nSSSS.S..\n.SS..SS.\n....SS..\nMS..S......
code_stdio
[ { "content": "Bob has a string $s$ consisting of lowercase English letters. He defines $s'$ to be the string after removing all \"a\" characters from $s$ (keeping all other characters in the same order). He then generates a new string $t$ by concatenating $s$ and $s'$. In other words, $t=s+s'$ (look at notes fo...
[{"input": "keumiataaaaaznatbaawaaahebaaftaakaammcaeaihadapagaaaabaaacaxaaauaahwlydqnacamhpitahaamamaazaiohaaaaakeumitzntbwhebftkmmceihdpgbcxuhwlydqncmhpithmmzioh\n", "output": "keumiataaaaaznatbaawaaahebaaftaakaammcaeaihadapagaaaabaaacaxaaauaahwlydqnacamhpitahaamamaazaiohaaaaa\n"}, {"input": "aeaaaaravazyzaadwaarzajaa...
code_stdio
[ { "content": "Given a sequence of items and a specific item in that sequence, return the item immediately following the item specified. If the item occurs more than once in a sequence, return the item after the first occurence. This should work for a sequence of any type.\n\nWhen the item isn't present or nothi...
[{"input": "[1, 2, 3, 4, 5, 6, 7, 8]\n3", "output": "[4]", "fn_name": "next_item"}, {"input": "[\"a\", \"b\", \"c\"]\n\"d\"", "output": "[null]", "fn_name": "next_item"}, {"input": "[\"a\", \"b\", \"c\"]\n\"c\"", "output": "[null]", "fn_name": "next_item"}, {"input": "\"testing\"\n\"t\"", "output": "[\"e\"]", "fn_name"...
code_functional
[ { "content": "We will play a one-player game using a number line and N pieces.\nFirst, we place each of these pieces at some integer coordinate.\nHere, multiple pieces can be placed at the same coordinate.\nOur objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the...
[{"input": "2060 10101\n-28299 -22999 -45034 -52144 -38874 -24054 -31154 -41529 -19634 -44464 -39214 -24864 -14084 -47669 -34229 -25844 -19579 -10739 -54349 -12634 -55214 -37604 -45514 -52584 -41274 -55634 -23024 -42104 -54549 -44704 -11454 -28559 -9914 -50144 -41269 -30224 -39509 -14994 -33229 -35339 -49969 -12744 -39...
code_stdio
[ { "content": "The Berland Armed Forces System consists of n ranks that are numbered using natural numbers from 1 to n, where 1 is the lowest rank and n is the highest rank.\n\nOne needs exactly di years to rise from rank i to rank i + 1. Reaching a certain rank i having not reached all the previous i - 1 ranks ...
[{"input": "100\n63 65 21 41 95 23 3 4 12 23 95 50 75 63 58 34 71 27 75 31 23 94 96 74 69 34 43 25 25 55 44 19 43 86 68 17 52 65 36 29 72 96 84 25 84 23 71 54 6 7 71 7 21 100 99 58 93 35 62 47 36 70 68 9 75 13 35 70 76 36 62 22 52 51 2 87 66 41 54 35 78 62 30 35 65 44 74 93 78 37 96 70 26 32 71 27 85 85 63\n43 92\n", "...
code_stdio
[ { "content": "You will have a list of rationals in the form\n\n```\nlst = [ [numer_1, denom_1] , ... , [numer_n, denom_n] ]\n```\nor\n```\nlst = [ (numer_1, denom_1) , ... , (numer_n, denom_n) ]\n```\n\nwhere all numbers are positive integers. You have to produce their sum `N / D` in an irreducible form: this m...
[{"input": "[[81345, 15786], [87546, 11111111], [43216, 255689]]", "output": "[[79677895891146625, 14949283383840498]]", "fn_name": "sum_fracts"}, {"input": "[[6, 13], [187, 1310], [31, 41]]", "output": "[[949861, 698230]]", "fn_name": "sum_fracts"}, {"input": "[[77, 130], [84, 131], [60, 80]]", "output": "[[67559, 340...
code_functional
[ { "content": "Bear Limak has n colored balls, arranged in one long row. Balls are numbered 1 through n, from left to right. There are n possible colors, also numbered 1 through n. The i-th ball has color ti.\n\nFor a fixed interval (set of consecutive elements) of balls we can define a dominant color. It's a co...
[{"input": "150\n28 124 138 71 71 18 78 136 138 93 145 93 18 15 71 47 47 64 18 72 138 72 18 150 7 71 109 149 18 115 149 149 15 78 124 27 72 124 28 108 138 109 108 111 148 138 78 27 28 150 138 65 15 145 109 47 102 62 28 7 115 108 102 149 150 27 111 64 149 124 13 21 108 64 7 15 72 72 124 47 102 28 109 18 124 28 111 138 7...
code_stdio
[ { "content": "Little Paul wants to learn how to play piano. He already has a melody he wants to start with. For simplicity he represented this melody as a sequence a_1, a_2, …, a_n of key numbers: the more a number is, the closer it is to the right end of the piano keyboard.\n\nPaul is very clever and knows tha...
[{"input": "100\n5 5 2 4 5 4 4 4 4 2 5 3 4 2 4 4 1 1 5 3 2 2 1 3 3 2 5 3 4 5 1 3 5 4 4 4 3 1 4 4 3 4 5 2 5 4 2 1 2 2 3 5 5 5 1 4 5 3 1 4 2 2 5 1 5 3 4 1 5 1 2 2 3 5 1 3 2 4 2 4 2 2 4 1 3 5 2 2 2 3 3 4 3 2 2 5 5 4 2 5\n", "output": "1 2 1 2 3 1 2 1 2 1 2 1 2 1 2 3 2 1 3 2 1 2 1 3 2 1 2 1 2 3 1 2 3 2 1 3 2 1 3 2 1 2 3 1 ...
code_stdio
[ { "content": "A sequence of non-negative integers a_1, a_2, ..., a_{n} of length n is called a wool sequence if and only if there exists two integers l and r (1 ≀ l ≀ r ≀ n) such that $a_{l} \\oplus a_{l + 1} \\oplus \\cdots \\oplus a_{r} = 0$. In other words each wool sequence contains a subsequence of consecu...
[{"input": "100000 100000\n", "output": "738698541\n"}, {"input": "100000 100000\n", "output": "738698541\n"}, {"input": "100010 100000\n", "output": "917914137\n"}, {"input": "50000 100000\n", "output": "821709120\n"}, {"input": "50000 100000\n", "output": "821709120\n"}, {"input": "60282 92611\n", "output": "81490807...
code_stdio
[ { "content": "Emuskald needs a fence around his farm, but he is too lazy to build it himself. So he purchased a fence-building robot.\n\nHe wants the fence to be a regular polygon. The robot builds the fence along a single path, but it can only make fence corners at a single angle a.\n\nWill the robot be able t...
[{"input": "6\n1\n2\n3\n170\n179\n25\n", "output": "NO\nNO\nNO\nYES\nYES\nNO\n"}, {"input": "6\n1\n2\n3\n170\n179\n25\n", "output": "NO\nNO\nNO\nYES\nYES\nNO\n"}, {"input": "6\n1\n2\n3\n107\n179\n25\n", "output": "NO\nNO\nNO\nNO\nYES\nNO\n"}, {"input": "6\n2\n2\n3\n107\n179\n25\n", "output": "NO\nNO\nNO\nNO\nYES\nNO\n"...
code_stdio
[ { "content": "The final match of the Berland Football Cup has been held recently. The referee has shown $n$ yellow cards throughout the match. At the beginning of the match there were $a_1$ players in the first team and $a_2$ players in the second team.\n\nThe rules of sending players off the game are a bit dif...
[{"input": "1000\n1000\n1000\n1000\n1999999\n", "output": "1999 1999\n"}, {"input": "1000\n1000\n1000\n1000\n2000000\n", "output": "2000 2000\n"}, {"input": "1000\n1000\n1000\n1000\n2000000\n", "output": "2000 2000\n"}, {"input": "1000\n1000\n1000\n1000\n1999999\n", "output": "1999 1999\n"}, {"input": "1000\n1000\n1000...
code_stdio
[ { "content": "Areas on the Cross-Section Diagram\n\nYour task is to simulate a flood damage.\n\nFor a given cross-section diagram, reports areas of flooded sections.\n\n<image>\n\n\n\nAssume that rain is falling endlessly in the region and the water overflowing from the region is falling in the sea at the both ...
[{"input": "\\/_/\\_/\\\\_/\\\\__///\\\\/_/\\\\\\\\/\\/_\\/\\/\\\\", "output": "32\n8 1 2 20 5 1 1 1 1\n"}, {"input": "\\/_/\\_/\\\\_/\\\\__///\\\\/_/\\[\\\\0\\/_\\/\\/\\\\", "output": "31\n7 1 2 20 5 1 1 1\n"}, {"input": "\\/_/\\_/\\\\_/\\\\__///\\\\/_0\\[\\\\0\\/_\\/\\/\\\\", "output": "27\n7 1 2 20 1 1 1 1\n"}, {"in...
code_stdio
[ { "content": "You will be given a string and you task is to check if it is possible to convert that string into a palindrome by removing a single character. If the string is already a palindrome, return `\"OK\"`. If it is not, and we can convert it to a palindrome by removing one character, then return `\"remov...
[{"input": "\"abbcdedba\"", "output": "[\"not possible\"]", "fn_name": "solve"}, {"input": "\"raydarm\"", "output": "[\"not possible\"]", "fn_name": "solve"}, {"input": "\"abbaab\"", "output": "[\"not possible\"]", "fn_name": "solve"}, {"input": "\"abededba\"", "output": "[\"remove one\"]", "fn_name": "solve"}, {"input...
code_functional
[ { "content": "N players will participate in a tennis tournament. We will call them Player 1, Player 2, \\ldots, Player N.\nThe tournament is round-robin format, and there will be N(N-1)/2 matches in total.\nIs it possible to schedule these matches so that all of the following conditions are satisfied? If the an...
[{"input": "171\n158 2 11 40 53 51 26 89 135 78 167 25 123 157 100 152 72 35 39 126 124 119 68 105 162 150 84 82 59 109 28 70 34 110 85 136 57 145 134 47 99 20 83 95 154 98 73 138 48 29 120 116 66 58 96 18 102 24 153 127 125 61 32 129 16 131 50 46 10 113 91 75 13 86 65 45 146 133 122 103 128 93 77 5 63 3 118 164 147 16...
code_stdio
[ { "content": "This problem's actual name, \"Lexicographically Largest Palindromic Subsequence\" is too long to fit into the page headline.\n\nYou are given string s consisting of lowercase English letters only. Find its lexicographically largest palindromic subsequence.\n\nWe'll call a non-empty string s[p1p2.....
[{"input": "zzzzzzzzzz\n", "output": "zzzzzzzzzz\n"}, {"input": "aaaaaaaaaa\n", "output": "aaaaaaaaaa\n"}, {"input": "zzzzzzzazz\n", "output": "zzzzzzzzz\n"}, {"input": "abbbbbbbbb\n", "output": "bbbbbbbbb\n"}, {"input": "zzzzzzzzzy\n", "output": "zzzzzzzzz\n"}, {"input": "zzazzzzzzz\n", "output": "zzzzzzzzz\n"}, {"inp...
code_stdio
[ { "content": "Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.\n\nYui loves sweets, but she can eat at most $m$ sweets each day for health reasons.\n\nDays are $1$-indexed (numbered $1...
[{"input": "37 13\n164823 8992 21818 77521 130870 83201 174985 168799 9565 84443 105083 54131 130813 42829 98759 60103 198520 125068 59611 45609 124003 106143 54167 179002 103755 152802 146640 74767 91309 11941 131534 32533 67324 27272 49166 129157 41630\n", "output": "8992 18557 30498 52316 79588 112121 153751 196580 ...
code_stdio
[ { "content": "AtCoDeer the deer and his friend TopCoDeer is playing a game.\nThe game consists of N turns.\nIn each turn, each player plays one of the two gestures, Rock and Paper, as in Rock-paper-scissors, under the following condition:\n(β€») After each turn, (the number of times the player has played Paper)≦(...
[{"input": "ggppgggpgg\n", "output": "2\n"}, {"input": "ggpgggppgg", "output": "2\n"}, {"input": "ggggggpppg", "output": "2\n"}, {"input": "ggppgpgggg", "output": "2\n"}, {"input": "ggppggpggg", "output": "2\n"}, {"input": "gggpggppgg", "output": "2\n"}, {"input": "gggggpppgg", "output": "2\n"}, {"input": "pggpggpggg",...
code_stdio
[ { "content": "### Unfinished Loop - Bug Fixing #1\n\nOh no, Timmy's created an infinite loop! Help Timmy find and fix the bug in his unfinished for loop!\n\nWrite Python code to solve this problem. Define a top-level function named `create_array` that takes the input arguments described above and returns the an...
[{"input": "10", "output": "[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]", "fn_name": "create_array"}, {"input": "9", "output": "[[1, 2, 3, 4, 5, 6, 7, 8, 9]]", "fn_name": "create_array"}, {"input": "8", "output": "[[1, 2, 3, 4, 5, 6, 7, 8]]", "fn_name": "create_array"}, {"input": "7", "output": "[[1, 2, 3, 4, 5, 6, 7]]", "fn_nam...
code_functional
[ { "content": "Haiku is a genre of Japanese traditional poetry.\n\nA haiku poem consists of 17 syllables split into three phrases, containing 5, 7 and 5 syllables correspondingly (the first phrase should contain exactly 5 syllables, the second phrase should contain exactly 7 syllables, and the third phrase shoul...
[{"input": "aaaaaccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\naaaaaaaccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\naaaaaccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\n",...
code_stdio
[ { "content": "Two bored soldiers are playing card war. Their card deck consists of exactly n cards, numbered from 1 to n, all values are different. They divide cards between them in some manner, it's possible that they have different number of cards. Then they play a \"war\"-like card game. \n\nThe rules are fo...
[{"input": "10\n9 8 7 6 2 3 5 4 10 1\n1 9\n", "output": "103 1\n"}, {"input": "10\n1 10\n9 5 7 6 1 2 3 9 8 4\n", "output": "105 1\n"}, {"input": "10\n9 8 7 6 2 3 5 4 9 1\n1 10\n", "output": "105 2\n"}, {"input": "10\n9 8 7 6 2 3 5 4 9 1\n1 10\n", "output": "105 2"}, {"input": "10\n1 10\n9 5 7 6 1 2 3 9 8 4\n", "output"...
code_stdio
[ { "content": "n soldiers stand in a circle. For each soldier his height ai is known. A reconnaissance unit can be made of such two neighbouring soldiers, whose heights difference is minimal, i.e. |ai - aj| is minimal. So each of them will be less noticeable with the other. Output any pair of soldiers that can f...
[{"input": "88\n1000 1000 1000 1000 1000 998 998 1000 1000 1000 1000 999 999 1000 1000 1000 999 1000 997 999 997 1000 999 998 1000 999 1000 1000 1000 999 1000 999 999 1000 1000 999 1000 999 1000 1000 998 1000 1000 1000 998 998 1000 1000 999 1000 1000 1000 1000 1000 1000 1000 998 1000 1000 1000 999 1000 1000 999 1000 10...
code_stdio
[ { "content": "β€” Thanks a lot for today.\n\nβ€” I experienced so many great things.\n\nβ€” You gave me memories like dreams... But I have to leave now...\n\nβ€” One last request, can you...\n\nβ€” Help me solve a Codeforces problem?\n\nβ€” ......\n\nβ€” What?\n\nChtholly has been thinking about a problem for days:\n\nIf a n...
[{"input": "100000 1000000000\n", "output": "495495496\n"}, {"input": "100000 1000000000\n", "output": "495495496\n"}, {"input": "91454 1017443433\n", "output": "794092041\n"}, {"input": "42147 412393322\n", "output": "251637727\n"}, {"input": "77809 868097296\n", "output": "440411873\n"}, {"input": "75615 376679484\n"...
code_stdio
[ { "content": "You are given a string S consisting of uppercase English letters. Find the length of the longest ACGT string that is a substring (see Notes) of S.\nHere, a ACGT string is a string that contains no characters other than A, C, G and T.\n\n-----Notes-----\nA substring of a string T is a string obtain...
[{"input": "TTTTTTTTTT\n", "output": "10\n"}, {"input": "BBBBBBBBBB\n", "output": "0\n"}, {"input": "GACGCTCCAV\n", "output": "9\n"}, {"input": "CTTAHTGACT\n", "output": "5\n"}, {"input": "TGMJCTTDAA\n", "output": "3\n"}, {"input": "ABTTGTTTC\n", "output": "7\n"}, {"input": "HATAGAYA\n", "output": "5\n"}, {"input": "SH...
code_stdio
[ { "content": "Yaroslav has an array that consists of n integers. In one second Yaroslav can swap two neighboring array elements. Now Yaroslav is wondering if he can obtain an array where any two neighboring elements would be distinct in a finite time.\n\nHelp Yaroslav.\n\n\n-----Input-----\n\nThe first line con...
[{"input": "100\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 100...
code_stdio
[ { "content": "You are given a three-digit positive integer N.\n\nDetermine whether N is a palindromic number.\n\nHere, a palindromic number is an integer that reads the same backward as forward in decimal notation.\n\n-----Constraints-----\n - 100≀N≀999\n - N is an integer.\n\n-----Input-----\nInput is given fr...
[{"input": "575\n", "output": "Yes\n"}, {"input": "999\n", "output": "Yes\n"}, {"input": "171\n", "output": "Yes\n"}, {"input": "123\n", "output": "No\n"}, {"input": "812\n", "output": "No\n"}, {"input": "100\n", "output": "No\n"}, {"input": "521\n", "output": "No\n"}, {"input": "974\n", "output": "No\n"}, {"input": "2...
code_stdio
[ { "content": "Pasha loves his phone and also putting his hair up... But the hair is now irrelevant.\n\nPasha has installed a new game to his phone. The goal of the game is following. There is a rectangular field consisting of n row with m pixels in each row. Initially, all the pixels are colored white. In one m...
[{"input": "928 467 10\n37 45\n47 278\n17 467\n158 66\n483 198\n83 123\n285 219\n513 187\n380 107\n304 352\n", "output": "0\n"}, {"input": "518 518 10\n37 97\n47 278\n17 467\n158 66\n483 351\n83 123\n285 219\n513 187\n380 75\n304 352\n", "output": "0\n"}, {"input": "518 518 10\n37 97\n38 278\n17 467\n158 66\n483 351\n8...
code_stdio
[ { "content": "You are given a string $s$, consisting only of characters '0' or '1'. Let $|s|$ be the length of $s$.\n\nYou are asked to choose some integer $k$ ($k > 0$) and find a sequence $a$ of length $k$ such that:\n\n$1 \\le a_1 < a_2 < \\dots < a_k \\le |s|$;\n\n$a_{i-1} + 1 < a_i$ for all $i$ from $2$ to...
[{"input": "1\n0000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100\n", "output": "NO\n"}, {"input": "1\n0000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100\n", "output": "NO\n"}, {"input": "1\n00000111111111111111111111111...
code_stdio
[ { "content": "A taxi driver, Nakamura, was so delighted because he got a passenger who wanted to go to a city thousands of kilometers away. However, he had a problem. As you may know, most taxis in Japan run on liquefied petroleum gas (LPG) because it is cheaper than gasoline. There are more than 50,000 gas sta...
[{"input": "6 3 41\nTokyo Kyoto\nTokyo Niigata 335\nTokyo Shizuoka 174\nShizuoka Nagoya 176\nNagoya Kyoto 195\nToyama Niigata 215\nToyama Kyoto 296\nNagoya\nNiigata\nToyama\n6 3 30\nTokyo Kyoto\nTokyo Niigata 335\nTokyo Shizuoka 174\nShizuoka Nagoya 176\nNagoya Kyoto 195\nToyama Niigata 215\nToyama Kyoto 296\nNagoya\nN...
code_stdio
[ { "content": "Mr. Simpson got up with a slight feeling of tiredness. It was the start of another day of hard work. A bunch of papers were waiting for his inspection on his desk in his office. The papers contained his students' answers to questions in his Math class, but the answers looked as if they were just s...
[{"input": "a+b+c\n(a+b)+c\na- (b-c)+2\n.\n4ab\n(a - b) (0-b+a) - 1a ^ 2 - b ^ 3\n2 b 2 a\n.\n108 a\n2 2 3 3 3 a\n4 a^1 27\n.\n.", "output": "yes\nno\n.\nno\nyes\n.\nyes\nyes\n.\n"}, {"input": "a+b+c\n(a+b)+c\na- (b-c)+2\n.\n4ab\n(a - b) (0-b+a) - 1a ^ 4 - b ^ 3\n2 b 2 a\n.\n108 a\n2 2 3 3 3 a\n4 a^1 27\n.\n.", "output...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian as well. \n\nThere are 100 houses located on a straight line. The first house is numbered 1 and the last one is numbered 100. Some M houses out of these 100 are occupied by cops.\nThief Devu has just stolen PeePee's bag and is looking for a ...
[{"input": "3\n4 7 8\n12 52 56 8\n2 10 2\n21 75\n2 5 8\n10 49", "output": "0\n18\n11\n"}, {"input": "3\n4 7 3\n3 52 56 8\n2 10 2\n21 75\n2 5 8\n10 49", "output": "24\n18\n11\n"}, {"input": "3\n4 7 8\n19 52 56 8\n2 20 2\n21 34\n2 5 8\n10 29", "output": "0\n26\n31\n"}, {"input": "3\n4 7 8\n7 87 96 8\n2 11 2\n66 75\n2 10 ...
code_stdio
[ { "content": "The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.\n\n-----Input-----\nThe in...
[{"input": "7 2\n1\n106\n966369\n10\n12\n40177\n11", "output": "3\n"}, {"input": "7 4\n1\n106\n966369\n10\n12\n40177\n11", "output": "1\n"}, {"input": "7 4\n1\n106\n966369\n10\n18\n40177\n11", "output": "0\n"}, {"input": "7 2\n1\n62\n334284\n16\n12\n40177\n12", "output": "5\n"}, {"input": "7 2\n1\n62\n966369\n10\n12\n4...
code_stdio
[ { "content": "There are N points in a D-dimensional space.\nThe coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).\nThe distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \\sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.\nHow many pairs (i, j) ...
[{"input": "10 10\n8 -14 -14 -20 18 -1 -3 18 -1 10\n-9 2 4 -13 13 5 14 -9 20 -18\n-19 -19 -19 20 -3 20 -2 -18 -7 -11\n5 7 3 -11 12 -9 -10 10 20 -19\n-12 -8 -20 -13 12 13 17 17 -6 0\n-4 -14 -15 -15 18 19 -8 -1 -20 -2\n-7 11 -10 -16 3 -5 -12 15 6 -2\n12 18 -3 -15 -20 17 9 9 10 -10\n10 -2 9 -16 2 17 15 -16 -2 -12\n16 -7 -...
code_stdio
[ { "content": "A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward. Examples of numerical palindromes are: \n\n2332\n110011\n54322345\n\nFor this kata, single digit numbers will not be considered numerical palindromes. \n\nFor a given number ```num```,...
[{"input": "\"ACCDDCCA\"", "output": "[\"Not valid\"]", "fn_name": "palindrome"}, {"input": "\"1551\"", "output": "[\"Not valid\"]", "fn_name": "palindrome"}, {"input": "-4505", "output": "[\"Not valid\"]", "fn_name": "palindrome"}, {"input": "22.22", "output": "[\"Not valid\"]", "fn_name": "palindrome"}, {"input": "12...
code_functional
[ { "content": "Luntik has decided to try singing. He has $a$ one-minute songs, $b$ two-minute songs and $c$ three-minute songs. He wants to distribute all songs into two concerts such that every song should be included to exactly one concert.\n\nHe wants to make the absolute difference of durations of the concer...
[{"input": "4\n2 4 1\n4 2 0\n10 4 5\n1 1 2\n", "output": "1\n0\n1\n1\n"}, {"input": "4\n2 2 0\n4 2 0\n10 4 5\n1 1 2\n", "output": "0\n0\n1\n1\n"}, {"input": "4\n2 4 0\n4 2 0\n10 4 5\n1 1 2\n", "output": "0\n0\n1\n1\n"}, {"input": "4\n2 4 1\n4 2 0\n10 4 3\n1 1 2\n", "output": "1\n0\n1\n1\n"}, {"input": "4\n2 4 1\n7 2 0\...
code_stdio
[ { "content": "###Instructions\n\nA time period starting from ```'hh:mm'``` lasting until ```'hh:mm'``` is stored in an array:\n```\n['08:14', '11:34']\n```\nA set of different time periods is then stored in a 2D Array like so, each in its own sub-array:\n```\n[['08:14','11:34'], ['08:16','08:18'], ['22:18','01:...
[{"input": "[[\"12:00\", \"10:01\"], [\"06:31\", \"14:23\"], [\"03:02\", \"07:58\"], [\"08:13\", \"10:05\"], [\"18:37\", \"04:22\"], [\"12:58\", \"14:28\"], [\"01:51\", \"14:40\"], [\"04:27\", \"01:00\"], [\"22:56\", \"23:33\"], [\"19:23\", \"07:00\"], [\"02:13\", \"16:14\"], [\"10:40\", \"02:36\"], [\"11:49\", \"00:10...
code_functional
[ { "content": "Alicia has an array, $a_1, a_2, \\ldots, a_n$, of non-negative integers. For each $1 \\leq i \\leq n$, she has found a non-negative integer $x_i = max(0, a_1, \\ldots, a_{i-1})$. Note that for $i=1$, $x_i = 0$.\n\nFor example, if Alicia had the array $a = \\{0, 1, 2, 0, 3\\}$, then $x = \\{0, 0, 1...
[{"input": "35\n15 13 -25 -7 -18 -16 4 -15 2 -23 0 -3 -26 -27 -24 -27 -22 1 -52 -19 -16 -15 -29 -43 -18 -27 -11 -20 -2 -11 -20 -30 -1 -13 -46\n", "output": "15 28 3 21 10 12 32 17 34 11 34 31 8 7 10 7 12 35 -17 16 19 20 6 -8 17 8 24 15 33 24 15 5 34 22 -11 "}, {"input": "35\n15 13 -25 -7 -18 -16 4 -15 2 -23 0 -3 -26 -2...
code_stdio
[ { "content": "Let p (i) be the i-th prime number from the smallest. For example, 7 is the fourth prime number from the smallest, 2, 3, 5, 7, so p (4) = 7.\n\nGiven n, the sum of p (i) from i = 1 to n s\n\ns = p (1) + p (2) + .... + p (n)\n\nCreate a program that outputs. For example, when n = 9, s = 2 + 3 + 5 +...
[{"input": "2\n219\n0", "output": "5\n136114\n"}, {"input": "2\n279\n0", "output": "5\n231208\n"}, {"input": "2\n195\n0", "output": "5\n105540\n"}, {"input": "2\n199\n0", "output": "5\n110364\n"}, {"input": "2\n233\n0", "output": "5\n156108\n"}, {"input": "2\n264\n0", "output": "5\n204989\n"}, {"input": "2\n361\n0", "o...
code_stdio
[ { "content": "Little Petya loves counting. He wants to count the number of ways to paint a rectangular checkered board of size n Γ— m (n rows, m columns) in k colors. Besides, the coloring should have the following property: for any vertical line that passes along the grid lines and divides the board in two non-...
[{"input": "1000 1000 1000000\n", "output": " 396597934\n"}, {"input": "182 314 814124\n", "output": " 753768028\n"}, {"input": "892 996 619800\n", "output": " ...
code_stdio
[ { "content": "There are 32 letters in the Polish alphabet: 9 vowels and 23 consonants. \n \nYour task is to change the letters with diacritics:\n\n```\ną -> a,\nć -> c,\nę -> e,\nł -> l,\nń -> n,\nó -> o,\nś -> s,\nź -> z,\nż -> z\n```\nand print out the string without the use of the Polish letters.\n\n\nFor ex...
[{"input": "\"W\\u00f3\\u0142 go pyta: 'Panie chrz\\u0105szczu,Po co pan tak brz\\u0119czy w g\\u0105szczu?'\"", "output": "[\"Wol go pyta: 'Panie chrzaszczu,Po co pan tak brzeczy w gaszczu?'\"]", "fn_name": "correct_polish_letters"}, {"input": "\"Za\\u017c\\u00f3\\u0142\\u0107 g\\u0119\\u015bl\\u0105 ja\\u017a\\u0144\...
code_functional
[ { "content": "A bracketed sequence is called correct (regular) if by inserting \"+\" and \"1\" you can get a well-formed mathematical expression from it. For example, sequences \"(())()\", \"()\" and \"(()(()))\" are correct, while \")(\", \"(()\" and \"(()))(\" are not.\n\nThe teacher gave Dmitry's class a ver...
[{"input": "101\n(())))))()))()())(()))((())))((())(()()()(()()((()()((()((())))((()))()(())(()(())((()))(()))()(((()(\n", "output": "-1\n"}, {"input": "100\n)()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()(\n", "output": "100\n"}, {"input": "101\n(())))))()))()())(())...
code_stdio
[ { "content": "Daniel has a string s, consisting of lowercase English letters and period signs (characters '.'). Let's define the operation of replacement as the following sequence of steps: find a substring \"..\" (two consecutive periods) in string s, of all occurrences of the substring let's choose the first ...
[{"input": "2 7\nab\n1 w\n2 w\n1 c\n2 .\n2 .\n1 .\n2 b\n", "output": "0\n0\n0\n0\n0\n1\n0\n"}, {"input": "2 7\nab\n1 w\n2 w\n1 c\n2 .\n2 .\n1 .\n2 b\n", "output": "0\n0\n0\n0\n0\n1\n0\n"}, {"input": "2 7\nab\n2 w\n2 w\n1 c\n2 .\n2 .\n1 .\n2 b\n", "output": "0\n0\n0\n0\n0\n1\n0\n"}, {"input": "2 7\nab\n2 w\n2 w\n1 c\n2 ...
code_stdio
[ { "content": "Yakko, Wakko and Dot, world-famous animaniacs, decided to rest from acting in cartoons, and take a leave to travel a bit. Yakko dreamt to go to Pennsylvania, his Motherland and the Motherland of his ancestors. Wakko thought about Tasmania, its beaches, sun and sea. Dot chose Transylvania as the mo...
[{"input": "-16 2\n", "output": "5/6\n"}, {"input": "-16 3\n", "output": "2/3\n"}, {"input": "-12 2\n", "output": "5/6\n"}, {"input": "3 -12\n", "output": "2/3\n"}, {"input": "-12 3\n", "output": "2/3\n"}, {"input": "-17 5\n", "output": "1/3\n"}, {"input": "-1 3\n", "output": "2/3\n"}, {"input": "2 -1\n", "output": "5/...
code_stdio
[ { "content": "Greg has an array a = a_1, a_2, ..., a_{n} and m operations. Each operation looks as: l_{i}, r_{i}, d_{i}, (1 ≀ l_{i} ≀ r_{i} ≀ n). To apply operation i to the array means to increase all array elements with numbers l_{i}, l_{i} + 1, ..., r_{i} by value d_{i}.\n\nGreg wrote down k queries on a pie...
[{"input": "4 3 6\n2 2 3 4\n1 2 2\n2 3 2\n3 4 4\n1 2\n1 3\n2 3\n1 2\n1 3\n2 3\n", "output": "10 22 31 20\n"}, {"input": "4 3 6\n2 2 3 4\n1 2 2\n3 3 2\n3 4 4\n1 2\n1 3\n2 3\n1 2\n1 3\n2 3\n", "output": "10 10 31 20\n"}, {"input": "4 3 6\n2 2 3 4\n1 2 2\n2 3 4\n3 4 4\n1 2\n1 3\n2 3\n1 2\n1 3\n2 3\n", "output": "10 34 43 ...
code_stdio
[ { "content": "You are given a string $s$ consisting of $n$ lowercase Latin letters. Polycarp wants to remove exactly $k$ characters ($k \\le n$) from the string $s$. Polycarp uses the following algorithm $k$ times:\n\n if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, ...
[{"input": "26 1\nabcdefghijklmnopqrstuvwxyz\n", "output": "bcdefghijklmnopqrstuvwxyz\n"}, {"input": "26 1\nabcdefghijklmnopqrsuuvwxyz\n", "output": "bcdefghijklmnopqrsuuvwxyz\n"}, {"input": "26 2\nabcdefghijklmnopqrstuvwxyz\n", "output": "cdefghijklmnopqrstuvwxyz\n"}, {"input": "26 3\nabcdefghijklmnopqrstuvwxyz\n", "o...
code_stdio
[ { "content": "You are given an array of positive integers a1, a2, ..., an Γ— T of length n Γ— T. We know that for any i > n it is true that ai = ai - n. Find the length of the longest non-decreasing sequence of the given array.\n\nInput\n\nThe first line contains two space-separated integers: n, T (1 ≀ n ≀ 100, 1...
[{"input": "100 10000000\n300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 30...
code_stdio
[ { "content": "After finding and moving to the new planet that supports human life, discussions started on which currency should be used. After long negotiations, Bitcoin was ultimately chosen as the universal currency.\n\nThese were the great news for Alice, whose grandfather got into Bitcoin mining in 2013, an...
[{"input": "10\n1 10 100 1000 10000 100000 1000000 10000000 100000000 1000000001\n1000000000 999999999\n", "output": "999999999\n"}, {"input": "10\n1 10 100 1000 10000 100000 1000000 11000000 100000000 1000000001\n1000000000 999999999\n", "output": "999999999\n"}, {"input": "10\n1 5 100 1000 10000 100000 1000000 100000...
code_stdio
[ { "content": "You and your n - 1 friends have found an array of integers a_1, a_2, ..., a_n. You have decided to share it in the following way: All n of you stand in a line in a particular order. Each minute, the person at the front of the line chooses either the first or the last element of the array, removes ...
[{"input": "4\n6 4 2\n3 9 2 3 8 4\n4 3 1\n1 13 60 4\n4 1 3\n1 0 2 1\n2 2 2\n1 2\n", "output": "8\n60\n1\n2\n"}, {"input": "4\n6 4 2\n2 7 4 5 8 7\n4 4 1\n8 13 111 4\n4 1 2\n1 2 2 1\n2 2 1\n2 3\n", "output": "7\n8\n1\n3\n"}, {"input": "4\n6 4 2\n2 7 4 5 1 7\n4 4 1\n8 13 111 4\n4 1 2\n1 2 2 1\n2 2 1\n2 3\n", "output": "4\...
code_stdio
[ { "content": "The only difference between the easy and the hard version is the constraint on $n$.\n\nYou are given an undirected complete graph on $n$ vertices. A complete graph is a graph where each pair of vertices is connected by an edge. You have to paint the edges of the graph into two colors, red and blue...
[{"input": "1337\n", "output": "520628749\n"}, {"input": "1000\n", "output": "756980810\n"}, {"input": "3000\n", "output": "596853783\n"}, {"input": "4500\n", "output": "299551211\n"}, {"input": "100\n", "output": "878752271\n"}, {"input": "5000\n", "output": "37327598\n"}, {"input": "500\n", "output": "39656147\n"}, {...
code_stdio
[ { "content": "The winter in Berland lasts n days. For each day we know the forecast for the average air temperature that day. \n\nVasya has a new set of winter tires which allows him to drive safely no more than k days at any average air temperature. After k days of using it (regardless of the temperature of th...
[{"input": "100 50\n-7 -3 9 2 16 -19 0 -10 3 -11 17 7 -7 -10 -14 -14 -7 -15 -15 -8 8 -18 -17 -5 -19 -15 -14 0 8 -3 -19 -13 -3 11 -3 -16 16 -16 -12 -2 -17 7 -16 -14 -10 0 -10 -18 -16 -11 -2 -12 -15 -8 -1 -11 -3 -17 -14 -6 -9 -15 -14 -11 -20 -20 -4 -20 -14 -2 0 -2 -20 17 -17 2 0 1 2 6 -5 -13 -16 -5 -11 0 16 -16 -4 -18 -1...
code_stdio
[ { "content": "The number `1035` is the smallest integer that exhibits a non frequent property: one its multiples, `3105 = 1035 * 3`, has its same digits but in different order, in other words, `3105`, is one of the permutations of `1035`.\n\nThe number `125874` is the first integer that has this property when t...
[{"input": "10000\n7", "output": "[1]", "fn_name": "search_permMult"}, {"input": "10000\n4", "output": "[2]", "fn_name": "search_permMult"}, {"input": "10000\n3", "output": "[2]", "fn_name": "search_permMult"}, {"input": "5000\n7", "output": "[0]", "fn_name": "search_permMult"}, {"input": "8000\n4", "output": "[1]", "f...
code_functional
[ { "content": "Takahashi went to an all-you-can-eat buffet with N kinds of dishes and ate all of them (Dish 1, Dish 2, \\ldots, Dish N) once.\nThe i-th dish (1 \\leq i \\leq N) he ate was Dish A_i.\nWhen he eats Dish i (1 \\leq i \\leq N), he gains B_i satisfaction points.\nAdditionally, when he eats Dish i+1 ju...
[{"input": "20\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20\n50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50\n50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50\n", "output": "1950\n"}, {"input": "20\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20\n22 9 21 42 22 12 39 41 37 11 35 19 43 38 3...
code_stdio