messages
listlengths
1
1
ground_truth
stringlengths
88
726k
dataset
stringclasses
2 values
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is an integer N.\nDetermine whether there is a pair of positive integers (A, B) such that 3^A + 5^B = N, and find one such pair if it exists.\n\n-----Constraints-----\n - 1 \\leq N \\leq 10^{18}\n - All values in in...
[{"type": "stdin_stdout", "input": "748307129767950488\n", "output": "37 25\n"}, {"type": "stdin_stdout", "input": "450283905890997368\n", "output": "37 1\n"}, {"type": "stdin_stdout", "input": "298023223876953128\n", "output": "1 25\n"}, {"type": "stdin_stdout", "input": "150094635296999246\n", "output": "36 3\n"}, {"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCaracal is fighting with a monster.\nThe health of the monster is H.\nCaracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:\n - If the monster's...
[{"type": "stdin_stdout", "input": "1000000000000\n", "output": "1099511627775\n"}, {"type": "stdin_stdout", "input": "999999999999\n", "output": "1099511627775\n"}, {"type": "stdin_stdout", "input": "549755813888\n", "output": "1099511627775\n"}, {"type": "stdin_stdout", "input": "707813884927\n", "output": "109951162...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFind the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.\n\n-----Constraints-----\n - 1 \\leq N < 10^{100}\n - 1 \\leq K \\leq 3\n\n-----Input-----\nInput i...
[{"type": "stdin_stdout", "input": "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n3\n", "output": "117879300\n"}, {"type": "stdin_stdout", "input": "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n2\n", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTokitsukaze is one of the characters in the game \"Kantai Collection\". In this game, every character has a common attribute — health points, shortened to HP.\n\nIn general, different values of HP are grouped into $4$ cat...
[{"type": "stdin_stdout", "input": "100\n", "output": "1 A\n"}, {"type": "stdin_stdout", "input": "33\n", "output": "0 A\n"}, {"type": "stdin_stdout", "input": "98\n", "output": "1 B\n"}, {"type": "stdin_stdout", "input": "30\n", "output": "1 B\n"}, {"type": "stdin_stdout", "input": "43\n", "output": "2 A\n"}, {"type":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBob is an active user of the social network Faithbug. On this network, people are able to engage in a mutual friendship. That is, if $a$ is a friend of $b$, then $b$ is also a friend of $a$. Each user thus has a non-negat...
[{"type": "stdin_stdout", "input": "35\n21 26 18 4 28 2 15 13 16 25 6 32 11 5 31 17 9 3 24 33 14 27 29 1 20 4 12 7 10 30 34 8 19 23 22\n", "output": "13 15 17 19 21 \n"}, {"type": "stdin_stdout", "input": "19\n2 3 2 2 2 2 2 2 2 2 19 3 2 2 2 2 2 2 19\n", "output": "2 4 \n"}, {"type": "stdin_stdout", "input": "19\n2 2 2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOn her way to programming school tiger Dasha faced her first test — a huge staircase! [Image] \n\nThe steps were numbered from one to infinity. As we know, tigers are very fond of all striped things, it is possible that i...
[{"type": "stdin_stdout", "input": "100 100\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "100 99\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "99 100\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "74 73\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "57 57\n", "output": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two arrays A and B consisting of integers, sorted in non-decreasing order. Check whether it is possible to choose k numbers in array A and choose m numbers in array B so that any number chosen in the first a...
[{"type": "stdin_stdout", "input": "20 30\n19 29\n1 1 2 2 2 3 4 4 7 7 7 8 8 8 8 8 9 9 9 9\n6 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 10 10 10 10\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "20 30\n2 8\n6 7 7 7 7 7 7 8 8 8 8 9 9 9 9 10 10 10 10 10\n1 1 2 2 2 2 2 2 2 3 3 4 5 5 5 5 6 6 6 6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya 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 im...
[{"type": "stdin_stdout", "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 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAn array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\\ldots$, $a_r$ for some $l, r$.\n\nSuppose $m$ is some known constant. For any a...
[{"type": "stdin_stdout", "input": "94 2 17\n9576 -3108 -5821 4770 -2229 -8216 2947 -6820 5061 979 5595 3594 345 416 -3096 1595 -6589 -8121 9803 -2239 8316 -4841 -9490 -9915 7229 -9579 1383 -6737 3077 -8014 9061 -6238 190 240 3703 3316 4763 -2966 -8645 6458 -2526 6161 2250 -6623 7926 267 -6612 7748 3818 -3645 -6669 -92...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $A$, consisting of $n$ positive integers $a_1, a_2, \\dots, a_n$, and an array $B$, consisting of $m$ positive integers $b_1, b_2, \\dots, b_m$. \n\nChoose some element $a$ of $A$ and some element $...
[{"type": "stdin_stdout", "input": "52\n197 90 23 11 63 198 24 132 68 58 195 100 101 120 96 77 132 155 62 197 170 117 189 160 194 106 172 124 180 75 124 51 51 93 186 93 79 111 161 67 84 183 150 125 25 46 106 29 170 175 4 122\n18\n95 28 20 190 75 89 193 152 53 79 100 3 154 42 67 5 137 60\n", "output": "198 193"}, {"type...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n cities in Westeros. The i-th city is inhabited by a_{i} people. Daenerys and Stannis play the following game: in one single move, a player chooses a certain town and burns it to the ground. Thus all its reside...
[{"type": "stdin_stdout", "input": "4 4\n194368 948570 852413 562719\n", "output": "Daenerys\n"}, {"type": "stdin_stdout", "input": "4 4\n391529 690539 830662 546622\n", "output": "Daenerys\n"}, {"type": "stdin_stdout", "input": "6 3\n346 118 330 1403 5244 480\n", "output": "Daenerys\n"}, {"type": "stdin_stdout", "inpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSaitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, ...
[{"type": "stdin_stdout", "input": "100 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere was an electronic store heist last night.\n\nAll keyboards which were in the store yesterday were numbered in ascending order from some integer number $x$. For example, if $x = 4$ and there were $3$ keyboards in the...
[{"type": "stdin_stdout", "input": "40\n194 121 110 134 172 142 195 135 186 187 128 161 185 132 117 175 178 131 143 151 170 181 188 140 133 145 119 129 179 149 109 123 124 106 100 199 197 155 141 183\n", "output": "60\n"}, {"type": "stdin_stdout", "input": "30\n793 656 534 608 971 970 670 786 978 665 92 391 328 228 340...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVery soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they...
[{"type": "stdin_stdout", "input": "10\n18 18\n71 471\n121 362\n467 107\n138 254\n13 337\n499 373\n337 387\n147 417\n76 417\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "7\n2 1\n2 1\n2 1\n2 1\n1 200\n1 200\n1 200\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "6\n5 9\n1 3\n4 8\n4 5\n23 54\n12 32\n",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a with n elements. Each element of a is either 0 or 1.\n\nLet's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no m...
[{"type": "stdin_stdout", "input": "10 2\n1 0 0 1 0 1 0 1 0 1\n", "output": "5\n1 0 0 1 1 1 1 1 0 1\n"}, {"type": "stdin_stdout", "input": "10 3\n0 0 1 0 0 1 0 0 1 1\n", "output": "6\n0 0 1 0 1 1 1 1 1 1\n"}, {"type": "stdin_stdout", "input": "7 1\n1 0 0 1 1 0 1\n", "output": "4\n1 0 0 1 1 1 1\n"}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIA has so many colorful magnets on her fridge! Exactly one letter is written on each magnet, 'a' or 'b'. She loves to play with them, placing all magnets in a row. However, the girl is quickly bored and usually thinks how...
[{"type": "stdin_stdout", "input": "abaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaab\n", "output": "0 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya has k matches, placed in n matchboxes lying in a line from left to right. We know that k is divisible by n. Petya wants all boxes to have the same number of matches inside. For that, he can move a match from its box...
[{"type": "stdin_stdout", "input": "100\n6 3 4 5 3 4 2 4 1 2 4 1 8 5 2 2 4 4 6 8 4 10 4 4 6 8 6 5 5 4 8 4 3 3 6 5 7 2 9 7 6 5 6 3 2 6 8 10 3 6 8 7 2 3 5 4 8 6 5 6 6 8 4 1 5 6 1 8 12 5 3 3 8 2 4 2 4 5 6 6 9 5 1 2 8 8 3 7 5 3 4 5 7 6 3 9 4 6 3 6\n", "output": "867\n"}, {"type": "stdin_stdout", "input": "20\n1000000000 10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYaroslav 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 i...
[{"type": "stdin_stdout", "input": "56\n516 76 516 197 516 427 174 516 706 813 94 37 516 815 516 516 937 483 16 516 842 516 638 691 516 635 516 516 453 263 516 516 635 257 125 214 29 81 516 51 362 516 677 516 903 516 949 654 221 924 516 879 516 516 972 516\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "48\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNotice that the memory limit is non-standard.\n\nRecently Arthur and Sasha have studied correct bracket sequences. Arthur understood this topic perfectly and become so amazed about correct bracket sequences, so he even go...
[{"type": "stdin_stdout", "input": "50\n97 97\n61 61\n59 59\n29 29\n13 13\n7 7\n5 5\n3 3\n1 1\n3 3\n1 1\n13 13\n11 11\n9 9\n3 3\n1 1\n1 1\n1 1\n27 27\n25 25\n1 1\n21 21\n19 19\n17 17\n15 15\n5 5\n1 1\n1 1\n7 7\n1 1\n3 3\n1 1\n15 15\n13 13\n1 1\n9 9\n7 7\n5 5\n3 3\n1 1\n15 15\n5 5\n1 1\n1 1\n3 3\n1 1\n1 1\n1 1\n1 1\n1 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya has recently learned data structure named \"Binary heap\".\n\nThe heap he is now operating with allows the following operations: put the given number into the heap; get the value of the minimum element in the hea...
[{"type": "stdin_stdout", "input": "8\ninsert 219147240\nremoveMin\ngetMin 923854124\nremoveMin\ngetMin -876779400\nremoveMin\ninsert 387686853\ngetMin 749998368\n", "output": "12\ninsert 219147240\nremoveMin\ninsert 923854124\ngetMin 923854124\nremoveMin\ninsert -876779400\ngetMin -876779400\nremoveMin\ninsert 3876868...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAt 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 t...
[{"type": "stdin_stdout", "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"}, {"typ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a_1, a_2, ..., a_{n} in t...
[{"type": "stdin_stdout", "input": "50\n", "output": "50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 "}, {"type": "stdin_stdout", "input": "50\n", "output": "50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBizon the Champion isn't just attentive, he also is very hardworking.\n\nBizon the Champion decided to paint his old fence his favorite color, orange. The fence is represented as n vertical planks, put in a row. Adjacent ...
[{"type": "stdin_stdout", "input": "30\n1 4 5 3 9 7 8 4 5 9 2 3 4 2 3 4 5 5 6 8 1 2 9 4 3 7 2 6 5 4\n", "output": "26\n"}, {"type": "stdin_stdout", "input": "8\n5000 5000 5 5000 5000 5000 5000 5000\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "14\n1 1 3 1 1 4 4 4 4 4 4 4 4 4\n", "output": "5\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently Irina arrived to one of the most famous cities of Berland — the Berlatov city. There are n showplaces in the city, numbered from 1 to n, and some of them are connected by one-directional roads. The roads in Berla...
[{"type": "stdin_stdout", "input": "10 45 8\n1 2 1\n1 3 1\n1 4 1\n1 5 1\n1 6 1\n1 7 1\n1 8 1\n1 9 1\n1 10 1\n2 3 1\n2 4 1\n2 5 1\n2 6 1\n2 7 1\n2 8 1\n2 9 1\n2 10 1\n3 4 1\n3 5 1\n3 6 1\n3 7 1\n3 8 1\n3 9 1\n3 10 1\n4 5 1\n4 6 1\n4 7 1\n4 8 1\n4 9 1\n4 10 1\n5 6 1\n5 7 1\n5 8 1\n5 9 1\n5 10 1\n6 7 1\n6 8 1\n6 9 1\n6 10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRoma works in a company that sells TVs. Now he has to prepare a report for the last year.\n\nRoma has got a list of the company's incomes. The list is a sequence that consists of n integers. The total income of the compan...
[{"type": "stdin_stdout", "input": "17 27\n257 320 676 1136 2068 2505 2639 4225 4951 5786 7677 7697 7851 8337 8429 8469 9343\n", "output": "81852\n"}, {"type": "stdin_stdout", "input": "12 28\n-6652 -6621 -6471 -5559 -5326 -4551 -4401 -4326 -3294 -1175 -1069 -43\n", "output": "49488\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA multi-subject competition is coming! The competition has $m$ different subjects participants can choose from. That's why Alex (the coach) should form a competition delegation among his students. \n\nHe has $n$ candidate...
[{"type": "stdin_stdout", "input": "19 2\n1 2\n1 -3\n1 -1\n1 -2\n2 0\n1 -2\n1 -3\n2 -2\n2 -4\n2 -3\n2 0\n1 2\n1 -1\n1 -2\n1 -3\n1 -4\n2 2\n1 1\n1 -4\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "18 6\n5 2\n3 1\n3 -4\n2 -1\n5 3\n4 -3\n5 4\n3 4\n4 -2\n1 4\n5 -4\n5 -1\n1 -2\n1 4\n6 -3\n4 -1\n5 4\n5 -1\n", "outp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nXenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation.\n\nThe teacher has written down the sum of multiple numbers. Pupils should calculate the sum. To m...
[{"type": "stdin_stdout", "input": "2+3+3+1+2+2+2+1+1+2+1+3+2+2+3+3+2+2+3+3+3+1+1+1+3+3+3+2+1+3+2+3+2+1+1+3+3+3+1+2+2+1+2+2+1+2+1+3+1+1\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n"}, {"type": "stdin_stdout", "input": "2+1+2+2+1+3+2+3+1+1+2+1+2+2+3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPeople do many crazy things to stand out in a crowd. Some of them dance, some learn by heart rules of Russian language, some try to become an outstanding competitive programmers, while others collect funny math objects.\n...
[{"type": "stdin_stdout", "input": "6 2\n", "output": "117\n1 7 8 9 10 11\n2 12 13 14 15 16\n3 17 18 19 20 21\n4 22 23 24 25 26\n5 27 28 29 30 31\n6 32 33 34 35 36\n"}, {"type": "stdin_stdout", "input": "6 3\n", "output": "138\n1 2 13 14 15 16\n3 4 17 18 19 20\n5 6 21 22 23 24\n7 8 25 26 27 28\n9 10 29 30 31 32\n11 12 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBob is an avid fan of the video game \"League of Leesins\", and today he celebrates as the League of Leesins World Championship comes to an end! \n\nThe tournament consisted of $n$ ($n \\ge 5$) teams around the world. Bef...
[{"type": "stdin_stdout", "input": "9\n7 5 3\n8 9 4\n8 1 7\n8 9 1\n1 5 7\n2 3 5\n6 3 2\n", "output": "4 9 8 1 7 5 3 2 6 \n"}, {"type": "stdin_stdout", "input": "9\n1 8 9\n9 6 4\n2 1 3\n1 2 8\n3 5 2\n6 7 4\n8 9 4\n", "output": "5 3 2 1 8 9 4 6 7 \n"}, {"type": "stdin_stdout", "input": "9\n6 9 8\n2 3 4\n2 3 1\n5 6 8\n4 6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt's the year 5555. You have a graph, and you want to find a long cycle and a huge independent set, just because you can. But for now, let's just stick with finding either.\n\nGiven a connected graph with $n$ vertices, yo...
[{"type": "stdin_stdout", "input": "26 59\n9 23\n16 21\n20 14\n20 17\n24 20\n12 8\n18 21\n3 14\n3 18\n3 1\n2 8\n26 5\n12 2\n10 8\n23 22\n16 18\n24 25\n19 21\n3 4\n16 6\n2 4\n12 10\n3 26\n3 2\n7 13\n10 2\n16 19\n7 5\n20 25\n15 23\n1 22\n3 10\n6 19\n15 22\n5 13\n11 7\n14 25\n9 22\n26 13\n14 17\n11 13\n1 9\n3 12\n1 15\n11...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $a$ consisting of $n$ integers. You can perform the following operations with it: Choose some positions $i$ and $j$ ($1 \\le i, j \\le n, i \\ne j$), write the value of $a_i \\cdot a_j$ into the $...
[{"type": "stdin_stdout", "input": "3\n754191320 -760574499 -416425254\n", "output": "1 1 2\n1 2 3\n"}, {"type": "stdin_stdout", "input": "3\n-282808876 -671988567 -110199577\n", "output": "2 3\n1 1 2\n"}, {"type": "stdin_stdout", "input": "3\n901757671 602032179 648227272\n", "output": "1 1 2\n1 2 3\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's call the following process a transformation of a sequence of length $n$.\n\nIf the sequence is empty, the process ends. Otherwise, append the greatest common divisor (GCD) of all the elements of the sequence to the ...
[{"type": "stdin_stdout", "input": "21\n", "output": "1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 4 4 4 8 16 "}, {"type": "stdin_stdout", "input": "20\n", "output": "1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 4 4 4 8 16 "}, {"type": "stdin_stdout", "input": "19\n", "output": "1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 4 4 8 16 "}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nShichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:\n\nThere are $n$ new cities located in Prefecture X. Cities are numbered from $1$ to $n$. City $i$ is located $x_i$ km Nor...
[{"type": "stdin_stdout", "input": "6\n734304 42385\n464187 237466\n222360 313647\n364202 733043\n89833 694920\n398339 845862\n877584430 903224720 864319998 168282570 210185542 507819772\n660835099 966875896 281317003 56653645 396685040 815735737\n", "output": "3531417032\n6\n1 2 3 4 5 6 \n0\n"}, {"type": "stdin_stdout...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDima, Inna and Seryozha have gathered in a room. That's right, someone's got to go. To cheer Seryozha up and inspire him to have a walk, Inna decided to cook something. \n\nDima and Seryozha have n fruits in the fridge. E...
[{"type": "stdin_stdout", "input": "88 10\n6 64 43 1 1 1 8 15 39 1 95 2 1 80 36 40 25 2 52 24 29 26 16 45 96 99 1 91 16 97 67 1 39 91 1 41 72 67 93 84 1 12 67 53 26 1 14 39 94 92 28 75 10 16 81 97 77 22 1 1 41 90 51 49 90 74 5 61 1 45 88 1 40 7 4 59 16 33 6 4 92 1 38 20 4 53 10 80\n70 45 1 73 52 1 20 78 68 98 1 95 2 61...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string.\n\nA Bitlandish string is a string made only of characters \"0\" and...
[{"type": "stdin_stdout", "input": "1000000000000000000000000000000000000011111111000000000000\n0111111111100000000000111111111000000000000000111111110001\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "0000000000000000000000000000000000000000\n00000000000000000000000000000000000000000\n", "output": "NO\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJafar has n cans of cola. Each can is described by two integers: remaining volume of cola a_{i} and can's capacity b_{i} (a_{i} ≤ b_{i}).\n\nJafar has decided to pour all remaining cola into just 2 cans, determine if he...
[{"type": "stdin_stdout", "input": "10\n15 26 15 14 14 39 40 4 25 39\n27 72 16 44 69 48 53 17 63 42\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "10\n9 10 24 11 1 7 8 3 28 14\n86 20 34 11 22 94 8 16 73 85\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "6\n18 25 3 10 13 37\n38 73 19 35 24 37\n", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is the first subtask of problem F. The only differences between this and the second subtask are the constraints on the value of $m$ and the time limit. You need to solve both subtasks in order to hack this one.\n\nTh...
[{"type": "stdin_stdout", "input": "144 144\n5 62 104 123 137 128 79 17 12 93 122 34 116 25 42 109 114 105 83 21 10 95 94 126 33 68 75 24 131 67 11 134 124 39 97 7 61 90 117 46 142 92 81 118 85 35 89 86 111 43 53 63 27 44 135 59 52 49 6 20 91 26 16 45 102 69 141 98 66 38 84 87 18 57 71 41 47 129 28 125 119 107 15 14 11...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBachgold problem is very easy to formulate. Given a positive integer n represent it as a sum of maximum possible number of prime numbers. One can prove that such representation exists for any integer greater than 1.\n\nRe...
[{"type": "stdin_stdout", "input": "202\n", "output": "101\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n"}, {"type": "stdin_stdout", "input": "93\n", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ candy boxes in front of Tania. The boxes are arranged in a row from left to right, numbered from $1$ to $n$. The $i$-th box contains $r_i$ candies, candies have the color $c_i$ (the color can take one of thr...
[{"type": "stdin_stdout", "input": "50 49 1000\n30 37 34 31 26 44 32 12 36 15 5 5 31 24 17 24 43 19 17 23 45 2 24 17 23 48 20 44 46 44 13 4 29 49 33 41 14 25 46 43 7 47 28 25 2 30 37 37 19 32\nGBBBRBGRBRBRGRGRBBGBGRRBGGRBGRBRRRRRRRBRGRGGGGBRGG\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "50 37 500\n25 43 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N islands and M bridges.\nThe i-th bridge connects the A_i-th and B_i-th islands bidirectionally.\nInitially, we can travel between any two islands using some of these bridges.\nHowever, the results of a survey ...
[{"type": "stdin_stdout", "input": "29 45\n1 3\n2 3\n2 14\n2 19\n2 29\n3 26\n4 5\n4 6\n4 13\n4 17\n5 10\n5 19\n5 24\n6 18\n6 19\n6 24\n6 25\n6 28\n6 29\n8 9\n9 18\n9 25\n10 29\n11 16\n11 22\n12 14\n12 15\n12 26\n12 29\n13 14\n14 20\n14 27\n14 29\n15 16\n15 22\n15 25\n15 29\n16 29\n17 27\n19 26\n20 29\n24 26\n15 23\n1 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is a tree G with N vertices.\nThe vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i.\nConsider painting the edges in G with some number of colors.\nWe want to paint them so that...
[{"type": "stdin_stdout", "input": "672\n275 321\n185 433\n215 344\n22 130\n494 568\n440 636\n80 228\n179 409\n240 296\n273 576\n388 462\n19 69\n38 212\n76 622\n13 341\n532 558\n70 165\n121 615\n337 632\n92 293\n270 436\n91 125\n51 84\n295 326\n4 12\n440 494\n216 221\n273 284\n244 311\n221 268\n102 204\n146 233\n198 26...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a string S of length N consisting of R, G, and B.\nFind the number of triples (i,~j,~k)~(1 \\leq i < j < k \\leq N) that satisfy both of the following conditions:\n - S_i \\neq S_j, S_i \\neq S_k, and S_j \\neq S_...
[{"type": "stdin_stdout", "input": "4000\nGBRBRGGRRBRGBBGGRRGBRGGBRGGGBBGRGBRBRGGBGGGGRRGGBGGRGGGGRRGGRRGBBBGGRBGRRBBGGBRRBGGGGGBGGBGGRBBBGBGRGGRBGGRGRRRBRGBBBGGGRRBGRBBGGRGGRGRBGRRBGGRBRGGBBRGBRGRRGGRBGBRGBRGRRBGBRRBGRGBBGBRBGBBRBBGBBGBGGRBBRGRRGGRRBBBBRBBGBBGGRGRBBGGGBGGGGRRBBRGBBBBBRGGGBGGBBBRGRGRBGGGGBGBRGGBRGBRRRB...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor years, the Day of city N was held in the most rainy day of summer. New mayor decided to break this tradition and select a not-so-rainy day for the celebration. The mayor knows the weather forecast for the $n$ days of ...
[{"type": "stdin_stdout", "input": "100 7 7\n958 322 975 921 115 647 61 232 127 277 839 797 261 632 788 381 191 117 663 959 475 166 471 984 17 473 57 809 65 881 580 725 587 933 466 537 627 706 927 173 573 372 644 492 835 893 792 494 808 977 479 109 949 21 625 104 626 569 524 504 16 257 274 285 404 629 247 609 303 602 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOn a random day, Neko found $n$ treasure chests and $m$ keys. The $i$-th chest has an integer $a_i$ written on it and the $j$-th key has an integer $b_j$ on it. Neko knows those chests contain the powerful mysterious gree...
[{"type": "stdin_stdout", "input": "10 10\n522312461 931001459 598654597 488228616 544064902 21923894 329635457 980089248 988262691 654502493\n967529230 543358150 835120075 128123793 809901567 613170206 152157661 479980560 859252956 318029856\n", "output": "10"}, {"type": "stdin_stdout", "input": "27 9\n72 105 100 105 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAt a break Vanya came to the class and saw an array of $n$ $k$-bit integers $a_1, a_2, \\ldots, a_n$ on the board. An integer $x$ is called a $k$-bit integer if $0 \\leq x \\leq 2^k - 1$. \n\nOf course, Vanya was not able...
[{"type": "stdin_stdout", "input": "20 30\n30095551 1073741823 319405832 582219539 834291739 1073741823 834291739 491522284 582219539 812740772 261001051 553222931 796331080 759003208 759003208 0 1043646272 1073741823 834291739 1073741823\n", "output": "193"}, {"type": "stdin_stdout", "input": "20 30\n12966621 60525880...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.\n\nEach second all boys that stand right in front of...
[{"type": "stdin_stdout", "input": "MFFFMMFMFMFMFFFMMMFFMMMMMMFMMFFMMMFMMFMFFFMMFMMMFFMMFFFFFMFMFFFMMMFFFMFMFMFMFFFMMMMFMMFMMFFMMMMMMFFM\n", "output": "54\n"}, {"type": "stdin_stdout", "input": "MMMMMFFMFMFMFMMFMMFFMMFMFFFFFFFMFFFMMMMMMFFMMMFMFMMFMFFMMFMMMFFFFFMMMMMFMMMMFMMMFFMFFMFFFMFFMFFMMFFM\n", "output": "58\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nArkady is playing Battleship. The rules of this game aren't really important.\n\nThere is a field of $n \\times n$ cells. There should be exactly one $k$-decker on the field, i. e. a ship that is $k$ cells long oriented e...
[{"type": "stdin_stdout", "input": "19 6\n##..............###\n#......#####.....##\n.....#########.....\n....###########....\n...#############...\n..###############..\n.#################.\n.#################.\n.#################.\n.#################.\n#####....##....####\n####............###\n####............###\n#####...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDanny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem!\n\nYou are given $n$ nonnegative integers $a_1, a_2, \\dots, a_n$ arranged in a circle, where $n$ m...
[{"type": "stdin_stdout", "input": "41\n67695023 47580738 52676259 26530025 83455112 9118634 23011073 86422683 89065733 42852564 97383338 95729385 6219705 42027049 79082264 1205076 1191075 18025596 75651485 93690196 63851880 23817841 79285846 9296266 60979868 62770176 40911517 96687661 35967137 55930828 78662969 519397...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a binary matrix $A$ of size $n \\times n$. Let's denote an $x$-compression of the given matrix as a matrix $B$ of size $\\frac{n}{x} \\times \\frac{n}{x}$ such that for every $i \\in [1, n], j \\in [1, n]$ t...
[{"type": "stdin_stdout", "input": "16\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "12\nFC0\nFC0\nFC0\nFC0\nFC0\nFC0\nFC0\nFC0\nFC0\nFC0\nFC0\nFC0\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "12\n100\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs we all know Barney's job is \"PLEASE\" and he has not much to do at work. That's why he started playing \"cups and key\". In this game there are three identical cups arranged in a line from left to right. Initially key...
[{"type": "stdin_stdout", "input": "12\n254904759290707697 475737283258450340 533306428548398547 442127134828578937 779740159015946254 272877594683860919 93000149670491971 349640818793278778 498293278222136720 551099726729989816 149940343283925029 989425634209891686\n", "output": "674872752/24618241\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe rules of Sith Tournament are well known to everyone. n Sith take part in the Tournament. The Tournament starts with the random choice of two Sith who will fight in the first battle. As one of them loses, his place is ...
[{"type": "stdin_stdout", "input": "7\n0.000000 0.311935 0.623164 0.667542 0.225988 0.921559 0.575083\n0.688065 0.000000 0.889215 0.651525 0.119843 0.635314 0.564710\n0.376836 0.110785 0.000000 0.583317 0.175043 0.795995 0.836790\n0.332458 0.348475 0.416683 0.000000 0.263615 0.469602 0.883191\n0.774012 0.880157 0.82495...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAshish has an array $a$ of size $n$.\n\nA subsequence of $a$ is defined as a sequence that can be obtained from $a$ by deleting some elements (possibly none), without changing the order of the remaining elements.\n\nConsi...
[{"type": "stdin_stdout", "input": "10 4\n91239 51189 50977 96098 56330 55725 6448 7351 60071 93359\n", "output": "50977"}, {"type": "stdin_stdout", "input": "9 6\n61893 41300 6953 17157 3356 96839 77399 31252 37704\n", "output": "31252"}, {"type": "stdin_stdout", "input": "8 2\n53334 11332 30400 32538 96555 59257 5306...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn Berland a bus travels along the main street of the capital. The street begins from the main square and looks like a very long segment. There are n bus stops located along the street, the i-th of them is located at the ...
[{"type": "stdin_stdout", "input": "6\n2 3 5 7 9 11\n11\n1 2 2 3 3 4 4 5 5 5 6\n", "output": "18\n"}, {"type": "stdin_stdout", "input": "6\n2 3 5 7 11 13\n9\n1 2 2 3 3 4 5 5 6\n", "output": "16\n"}, {"type": "stdin_stdout", "input": "2\n1 1000000000\n4\n1 1 2 2\n", "output": "2999999997\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBerlanders like to eat cones after a hard day. Misha Square and Sasha Circle are local authorities of Berland. Each of them controls its points of cone trade. Misha has n points, Sasha — m. Since their subordinates consta...
[{"type": "stdin_stdout", "input": "10 10\n971 -2437\n-3336 3332\n-7503 -8713\n-9337 -9607\n-927 -9162\n-4375 -3790\n-913 -257\n-5916 5783\n5131 -7304\n9993 -9999\n-2774 8057\n8670 -7936\n8388 3302\n8718 -4865\n3329 -3334\n5088 -1539\n5050 8130\n4710 -2803\n8124 -4062\n-10000 9997\n", "output": "YES\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKilani is playing a game with his friends. This game can be represented as a grid of size $n \\times m$, where each cell is either empty or blocked, and every player has one or more castles in some cells (there are no two...
[{"type": "stdin_stdout", "input": "4 7 2\n13 1\n....###\n.#..1..\n.#.###.\n2#.....\n", "output": "18 1 \n"}, {"type": "stdin_stdout", "input": "4 7 2\n13 1\n###....\n..1..#.\n.###.#.\n.....#2\n", "output": "18 1 \n"}, {"type": "stdin_stdout", "input": "3 8 3\n1 1 1\n.222.321\n2.##3.31\n2#1.2131\n", "output": "7 10 4 \...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWilbur the pig is tinkering with arrays again. He has the array a_1, a_2, ..., a_{n} initially consisting of n zeros. At one step, he can choose any index i and either add 1 to all elements a_{i}, a_{i} + 1, ... , a_{n} o...
[{"type": "stdin_stdout", "input": "22\n1000000000 -1000000000 1000000000 -1000000000 1000000000 -1000000000 1000000000 -1000000000 1000000000 -1000000000 1000000000 -1000000000 1000000000 -1000000000 1000000000 -1000000000 1000000000 -1000000000 1000000000 -1000000000 1000000000 -1000000000\n", "output": "43000000000"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently Polycarp noticed that some of the buttons of his keyboard are malfunctioning. For simplicity, we assume that Polycarp's keyboard contains $26$ buttons (one for each letter of the Latin alphabet). Each button is e...
[{"type": "stdin_stdout", "input": "1\nammsdsdadasdsadssadassadsadasdsadsadr\n", "output": "adrs\n"}, {"type": "stdin_stdout", "input": "1\nammsdsdadasdsadsadassadsadasdsadsadr\n", "output": "adrs\n"}, {"type": "stdin_stdout", "input": "1\nlksjnksjfksjfksjfksjnfksjfsksjdf\n", "output": "dfjklns\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given n points on the straight line — the positions (x-coordinates) of the cities and m points on the same line — the positions (x-coordinates) of the cellular towers. All towers work in the same way — they provid...
[{"type": "stdin_stdout", "input": "10 10\n2 52 280 401 416 499 721 791 841 943\n246 348 447 486 507 566 568 633 953 986\n", "output": "244\n"}, {"type": "stdin_stdout", "input": "1 21\n3\n3 10 23 32 34 40 42 49 49 50 50 58 70 71 71 74 76 79 79 80 83\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "10 10\n1 1 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOn his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has...
[{"type": "stdin_stdout", "input": "90 61394040\n2480 6212 4506 829 8191 797 5336 6722 3178 1007 5849 3061 3588 6684 5983 5452 7654 5321 660 2569 2809 2179 679 4858 6887 2580 6880 6120 4159 5542 4999 8703 2386 8221 7046 1229 1662 4542 7089 3548 4298 1973 1854 2473 5507 241 359 5248 7907 5201 9624 4596 1723 2622 4800 47...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou will receive 3 points for solving this problem.\n\nManao is designing the genetic code for a new type of algae to efficiently produce fuel. Specifically, Manao is focusing on a stretch of DNA that encodes one protein....
[{"type": "stdin_stdout", "input": "CCCTTCACCCGGATCCAAATCCCTTAGAAATAATCCCCGACGGCGTTGTATCACCTCTGCACTTGTTAGTAAGGTCAGGCGTCCATTACGGAAGAACGTA\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "GCATTACATGGGGGGGTCCTACGAGCCCGGCATCCCGGAAACTAGCCGGTTAATTTGGTTTAAACCCTCCCACCCCGGATTGTAACCCCCCTCATTGGTT\n", "output": "17\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAndrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.\n\nOnce he thought about a string of length n consisting of zeroes and ones. Consider the foll...
[{"type": "stdin_stdout", "input": "9\n011111101\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "8\n11101111\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "8\n01011100\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "7\n0000011\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "7\n11100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nReforms continue entering Berland. For example, during yesterday sitting the Berland Parliament approved as much as n laws (each law has been assigned a unique number from 1 to n). Today all these laws were put on the tab...
[{"type": "stdin_stdout", "input": "98 24\n91 20 12 75 44 22 22 67 28 100 8 41 31 47 95 87 5 54 7 49 32 46 42 37 45 22 29 15 54 98 46 94 69 47 60 1 15 76 17 82 46 22 32 34 91 37 30 26 92 77 69 11 59 78 24 66 88 15 32 49 46 14 57 20 5 69 53 99 81 70 67 22 54 31 49 52 46 51 46 2 53 59 8 66 28 53 54 5 85 75 15 55 87 16 68...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given array $a$ of length $n$. You can choose one segment $[l, r]$ ($1 \\le l \\le r \\le n$) and integer value $k$ (positive, negative or even zero) and change $a_l, a_{l + 1}, \\dots, a_r$ by $k$ each (i.e. $a_i...
[{"type": "stdin_stdout", "input": "39 1\n4 2 1 1 3 5 1 5 1 1 3 3 4 3 1 1 4 5 1 5 2 3 3 1 5 1 2 1 1 4 1 1 5 2 2 1 1 2 4\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "29 3\n1 4 3 4 3 3 4 1 1 3 4 1 3 3 4 1 3 1 2 3 1 4 2 2 3 4 2 4 2\n", "output": "12\n"}, {"type": "stdin_stdout", "input": "18 1\n1 1 1 1 1 1 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLevko loves permutations very much. A permutation of length n is a sequence of distinct positive integers, each is at most n.\n\nLet’s assume that value gcd(a, b) shows the greatest common divisor of numbers a and b. Levk...
[{"type": "stdin_stdout", "input": "47 46\n", "output": "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 \n"}, {"type": "stdin_stdout", "input": "10 9\n", "output": "1 2 3 4 5 6 7 8 9 10 \n"}, {"type": "stdin_stdout", "input": "7 4\n", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle X and Little Z are good friends. They always chat online. But both of them have schedules.\n\nLittle Z has fixed schedule. He always online at any moment of time between a_1 and b_1, between a_2 and b_2, ..., betwe...
[{"type": "stdin_stdout", "input": "13 42 292 733\n304 308\n362 365\n396 397\n686 688\n719 722\n815 816\n901 902\n904 905\n921 924\n929 933\n953 954\n977 980\n982 985\n28 30\n36 37\n108 112\n123 127\n134 135\n151 153\n160 162\n203 205\n208 212\n240 243\n261 264\n271 274\n294 297\n356 358\n383 385\n408 412\n415 418\n435...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo bears are playing tic-tac-toe via mail. It's boring for them to play usual tic-tac-toe game, so they are a playing modified version of this game. Here are its rules.\n\nThe game is played on the following field. [Imag...
[{"type": "stdin_stdout", "input": "... ... ...\n... ... ...\n... ... ...\n\n... ... ...\n... ... ...\n... x.. ...\n\n... ... ...\n... ... ...\n... ... ...\n6 4\n", "output": "... ... ... \n... ... ... \n... ... ... \n\n... ... ... \n... ... ... \n... x.. ... \n\n!!! ... ... \n!!! ... ... \n!!! ... ... \n\n"}, {"type":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe new \"Die Hard\" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A \"Die Hard\" ticket costs 25 rubles. Can the bo...
[{"type": "stdin_stdout", "input": "14\n25 25 25 25 25 25 25 50 50 50 100 100 100 100\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "10\n100 100 100 100 100 100 100 100 100 100\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "10\n25 25 25 25 25 25 25 25 25 25\n", "output": "YES\n"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string s of length n consisting of lowercase English letters.\n\nFor two given strings s and t, say S is the set of distinct characters of s and T is the set of distinct characters of t. The strings s and ...
[{"type": "stdin_stdout", "input": "10 30\naccbaaccac\n6 8 3\n2 9 1\n6 8 3\n10 5 1\n6 2 2\n1 4 7\n3 10 1\n6 9 1\n7 7 3\n7 3 2\n8 4 1\n4 9 1\n7 6 4\n6 8 2\n10 2 1\n1 3 5\n5 10 1\n7 10 1\n4 1 2\n8 5 3\n9 8 1\n8 6 2\n6 9 2\n10 3 1\n3 9 1\n5 5 5\n1 5 6\n4 2 6\n10 7 1\n9 8 2\n", "output": "NO\nYES\nNO\nYES\nNO\nNO\nYES\nYES...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.\n\nNow the party is ready to start its journey, but firstly t...
[{"type": "stdin_stdout", "input": "50\n297 787 34 268 439 629 600 398 425 833 721 908 830 636 64 509 420 647 499 675 427 599 396 119 798 742 577 355 22 847 389 574 766 453 196 772 808 261 106 844 726 975 173 992 874 89 775 616 678 52 69 591 181 573 258 381 665 301 589 379 362 146 790 842 765 100 229 916 938 97 340 793...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Petya likes arrays that consist of non-negative integers a lot. Recently his mom has presented him one such array consisting of n elements. Petya immediately decided to find there a segment of consecutive elements,...
[{"type": "stdin_stdout", "input": "99\n3511 2076 9314 3598 7737 271 4110 4454 5830 8661 8584 8227 2236 2626 1025 3806 3162 2837 6071 9627 1836 7729 6629 4054 9377 3261 1325 8859 3610 7616 5052 9736 1249 6224 7031 6074 4196 8075 4005 5419 5664 8214 4391 731 8714 8622 6122 6976 4057 1770 8025 3778 2792 994 5204 1826 608...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset of vertices C of the maximu...
[{"type": "stdin_stdout", "input": "12\n66 4\n12 4\n60 4\n24 4\n48 4\n0 4\n36 4\n30 4\n6 4\n54 4\n42 4\n18 4\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "11\n0 4\n54 4\n48 4\n18 4\n24 4\n42 4\n6 4\n36 4\n12 4\n30 4\n60 4\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "10\n0 3\n30 3\n54 3\n6 3\n36 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarpus has got n candies and m friends (n ≥ m). He wants to make a New Year present with candies to each friend. Polycarpus is planning to present all candies and he wants to do this in the fairest (that is, most equa...
[{"type": "stdin_stdout", "input": "100 100\n", "output": "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 "}, {"type": "stdin_stdout", "input": "100 99\n", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point $T$, which coordinates to be found out.\n\nBob travelled around the world and collected clues of the treasure...
[{"type": "stdin_stdout", "input": "25\n2 2\n1 -2\n1 1\n0 1\n2 1\n-2 2\n-1 -2\n-1 2\n0 -2\n-1 1\n-2 -1\n-1 -1\n1 -1\n2 -1\n1 2\n-2 -2\n2 0\n-2 0\n-2 1\n2 -2\n-1 0\n1 0\n0 -1\n0 2\n0 0\n1 3\n-3 -1\n-2 0\n-3 1\n1 1\n0 0\n-2 2\n-1 -1\n1 -1\n-3 3\n0 3\n-2 1\n0 1\n-3 2\n-1 3\n-2 3\n-2 -1\n1 2\n1 0\n-3 0\n0 -1\n-1 2\n-1 1\n-...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDo you like summer? Residents of Berland do. They especially love eating ice cream in the hot summer. So this summer day a large queue of n Berland residents lined up in front of the ice cream stall. We know that each of ...
[{"type": "stdin_stdout", "input": "10\n536259132 536259132 536259132 536259132 536259132 536259132 536259132 536259132 536259132 536259132\n", "output": "536259132 536259132 536259132 536259132 536259132 536259132 536259132 536259132 536259132 536259132 "}, {"type": "stdin_stdout", "input": "10\n876584065 876584063 87...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven a string $s$ of length $n$ and integer $k$ ($1 \\le k \\le n$). The string $s$ has a level $x$, if $x$ is largest non-negative integer, such that it's possible to find in $s$: $x$ non-intersecting (non-overlapping)...
[{"type": "stdin_stdout", "input": "92 5\nwwwwwwwwwwwwwwwwwgggggggggggggggbbbbyyyyyyyyyyyyyyjjjjjjjjjjjuuuuuuuuaaaaaaaaaaaafooooooooig\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "83 2\njjjjjjjjjjjjjjjjjmmmmmmmmwwwwwwwwwwwcccccjjjjjjjppppppppppppccccccccqqqqqqqqqqktjkn\n", "output": "11\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nInnovation technologies are on a victorious march around the planet. They integrate into all spheres of human activity!\n\nA restaurant called \"Dijkstra's Place\" has started thinking about optimizing the booking system....
[{"type": "stdin_stdout", "input": "10\n739 307\n523 658\n700 143\n373 577\n120 433\n353 833\n665 516\n988 101\n817 604\n800 551\n10\n431 425 227 147 153 170 954 757 222 759\n", "output": "6 3621\n6 2\n2 8\n9 7\n4 1\n7 10\n5 4\n"}, {"type": "stdin_stdout", "input": "9\n216 860\n299 720\n688 831\n555 733\n863 873\n594 9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAyrat has number n, represented as it's prime factorization p_{i} of size m, i.e. n = p_1·p_2·...·p_{m}. Ayrat got secret information that that the product of all divisors of n taken modulo 10^9 + 7 is the password to the...
[{"type": "stdin_stdout", "input": "67\n98929 19079 160079 181891 17599 91807 19079 98929 182233 92647 77477 98929 98639 182233 181891 182233 160079 98929 19079 98639 114941 98929 161341 91807 160079 22777 132361 92647 98929 77477 182233 103913 160079 77477 55711 77477 77477 182233 114941 91807 98929 19079 104393 18223...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDoor's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!\n\nThe cake is a n × n square consisting of equal squares with side length 1. Each ...
[{"type": "stdin_stdout", "input": "21\n...CCC.....CC..C..C.C\n..CCC...CC...CC.CCC.C\n....C.C.C..CCC..C.C.C\n....CCC..C..C.CC.CCC.\n...CCC.C..C.C.....CCC\n.CCC.....CCC..C...C.C\nCCCC.C...CCC.C...C.CC\nC..C...C.CCC..CC..C..\nC...CC..C.C.CC..C.CC.\nCC..CCCCCCCCC..C....C\n.C..CCCC.CCCC.CCC...C\nCCC...CCC...CCC.C..C.\n.CCC...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together. \n\nSimply speaking, the process of taking photos can be described as follows. On the photo...
[{"type": "stdin_stdout", "input": "10\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n", "output": "90000 90000 90000 90000 90000 90000 90000 90000 90000 90000 "}, {"type": "stdin_stdout", "input": "10\n6 386\n9 816\n9 268\n9 481\n8 284\n10 715\n9 351\n7 580\n4 327\n7 392\n",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSasha and Ira are two best friends. But they aren’t just friends, they are software engineers and experts in artificial intelligence. They are developing an algorithm for two bots playing a two-player game. The game is co...
[{"type": "stdin_stdout", "input": "1000000\n", "output": "627314155\n"}, {"type": "stdin_stdout", "input": "999999\n", "output": "192151599\n"}, {"type": "stdin_stdout", "input": "524287\n", "output": "295397547\n"}, {"type": "stdin_stdout", "input": "131071\n", "output": "920253602\n"}, {"type": "stdin_stdout", "inpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nQuite recently, a very smart student named Jury decided that lectures are boring, so he downloaded a game called \"Black Square\" on his super cool touchscreen phone.\n\nIn this game, the phone's screen is divided into fo...
[{"type": "stdin_stdout", "input": "1809 1302 7164 6122\n3144121413113111223311232232114144321414421243443243422322144324121433444342231344234443332241322442\n", "output": "420780\n"}, {"type": "stdin_stdout", "input": "50 50 50 50\n11111111111111111111111111111111111111111111111111111\n", "output": "2650\n"}, {"type":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow ke...
[{"type": "stdin_stdout", "input": "198 3\ntuxqalctjyegbvouezfiqoeoazizhmjhpcmvyvjkyrgxkeupwcmvzcosdrrfgtdmxwfttxjxsbaspjwftgpnvsfyfqsrmyjmypdwonbzwsftepwtjlgbilhcsqyfzfzrfvrvfqiwoemthwvqptqnflqqspvqrnmvucnspexpijnivqpavqxjyucufcullevaedlvut\n", "output": "692\n"}, {"type": "stdin_stdout", "input": "167 152\nvqgjxbuxev...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a positive integer X, let f(X) be the number of positive divisors of X.\nGiven a positive integer N, find \\sum_{K=1}^N K\\times f(K).\n\n-----Constraints-----\n - 1 \\leq N \\leq 10^7\n\n-----Input-----\nInput is giv...
[{"type": "stdin_stdout", "input": "10000000\n", "output": "838627288460105\n"}, {"type": "stdin_stdout", "input": "9999991\n", "output": "838625848460453\n"}, {"type": "stdin_stdout", "input": "7914575\n", "output": "517994416125999\n"}, {"type": "stdin_stdout", "input": "9999985\n", "output": "838622848463579\n"}, {"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDolphin is planning to generate a small amount of a certain chemical substance C.\n\nIn order to generate the substance C, he must prepare a solution which is a mixture of two substances A and B in the ratio of M_a:M_b.\n...
[{"type": "stdin_stdout", "input": "40 3 8\n9 1 80\n7 8 13\n1 4 64\n5 2 60\n10 10 84\n5 6 64\n2 10 43\n9 2 73\n8 3 43\n8 2 53\n10 10 26\n4 4 20\n4 10 82\n9 7 96\n4 6 15\n1 3 45\n6 7 53\n3 3 92\n7 7 74\n4 2 62\n8 4 68\n3 7 7\n5 4 73\n5 10 22\n3 5 37\n2 10 88\n3 9 74\n1 7 80\n3 6 20\n7 9 5\n6 2 79\n9 9 20\n1 10 100\n9 7 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer N. Among the divisors of N! (= 1 \\times 2 \\times ... \\times N), how many Shichi-Go numbers (literally \"Seven-Five numbers\") are there?\nHere, a Shichi-Go number is a positive integer that has...
[{"type": "stdin_stdout", "input": "100\n", "output": "543\n"}, {"type": "stdin_stdout", "input": "52\n", "output": "123\n"}, {"type": "stdin_stdout", "input": "54\n", "output": "131\n"}, {"type": "stdin_stdout", "input": "77\n", "output": "323\n"}, {"type": "stdin_stdout", "input": "78\n", "output": "324\n"}, {"type":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ students and $m$ clubs in a college. The clubs are numbered from $1$ to $m$. Each student has a potential $p_i$ and is a member of the club with index $c_i$. Initially, each student is a member of exactly on...
[{"type": "stdin_stdout", "input": "20 20\n0 0 3 2 1 2 2 3 2 2 1 1 0 3 0 0 1 1 1 3\n15 1 20 13 6 12 16 8 3 14 10 5 18 17 4 9 2 11 7 19\n20\n2\n10\n7\n4\n6\n5\n14\n8\n9\n18\n13\n11\n19\n1\n16\n20\n17\n12\n15\n3\n", "output": "4\n4\n4\n4\n4\n4\n4\n4\n2\n2\n2\n2\n2\n2\n2\n2\n2\n1\n0\n0\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEvery evening Vitalya sets n alarm clocks to wake up tomorrow. Every alarm clock rings during exactly one minute and is characterized by one integer a_{i} — number of minute after midnight in which it rings. Every alarm c...
[{"type": "stdin_stdout", "input": "100 40 20\n148 120 37 65 188 182 199 131 97 174 157 113 62 63 193 8 72 152 138 5 90 48 133 83 197 118 123 2 181 151 53 115 78 177 144 33 196 19 85 104 77 34 173 198 136 44 3 22 86 200 23 129 68 176 29 58 121 56 79 15 159 183 171 60 141 54 158 106 30 17 116 105 190 59 36 46 169 142 16...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnd where the are the phone numbers?\n\nYou are given a string s consisting of lowercase English letters and an integer k. Find the lexicographically smallest string t of length k, such that its set of letters is a subset...
[{"type": "stdin_stdout", "input": "10 10\nmrfkcsxcuj\n", "output": "mrfkcsxcuk\n"}, {"type": "stdin_stdout", "input": "10 9\nbcegikmyyy\n", "output": "bcegikybb\n"}, {"type": "stdin_stdout", "input": "10 7\nffffffffyf\n", "output": "ffffffy\n"}, {"type": "stdin_stdout", "input": "8 9\npppppppp\n", "output": "ppppppppp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab.\n\nThere are $n$ solutions, the $i$-th of them should be tested on $a_i$ tests, testing one so...
[{"type": "stdin_stdout", "input": "100 10\n3 114 77 78 105 87 6 122 141 100 75 118 64 18 88 37 109 72 31 101 36 10 62 18 52 17 149 115 22 150 138 48 46 42 104 8 63 21 117 58 87 80 7 131 125 118 67 13 144 43 59 67 74 13 124 77 86 148 107 11 51 9 87 52 147 22 7 22 143 12 121 123 17 35 33 87 91 140 92 38 106 10 66 26 40 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMoscow is hosting a major international conference, which is attended by n scientists from different countries. Each of the scientists knows exactly one language. For convenience, we enumerate all languages of the world w...
[{"type": "stdin_stdout", "input": "20\n2 2 1 6 6 5 10 2 5 5 4 8 6 8 8 10 2 1 5 6\n20\n1 9 1 1 5 1 9 10 1 10 9 9 8 7 5 1 1 10 2 7\n3 5 9 10 10 8 2 9 6 7 8 8 6 5 3 4 6 3 7 4\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "10\n7 6 1 2 7 3 9 7 7 9\n10\n2 9 6 5 9 3 10 3 1 6\n4 6 7 9 7 4 1 9 2 5\n", "output": "5\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a permutation p of numbers 1, 2, ..., n. Let's define f(p) as the following sum:$f(p) = \\sum_{i = 1}^{n} \\sum_{j = i}^{n} \\operatorname{min}(p_{i}, p_{i + 1}, \\ldots p_{j})$\n\nFind the lexicographically...
[{"type": "stdin_stdout", "input": "8 127\n", "output": "7 8 6 5 4 3 2 1 \n"}, {"type": "stdin_stdout", "input": "8 128\n", "output": "8 7 6 5 4 3 2 1 \n"}, {"type": "stdin_stdout", "input": "8 1\n", "output": "1 2 3 4 5 6 7 8 \n"}, {"type": "stdin_stdout", "input": "7 44\n", "output": "2 4 7 6 5 3 1 \n"}, {"type": "st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMonocarp has arranged $n$ colored marbles in a row. The color of the $i$-th marble is $a_i$. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguo...
[{"type": "stdin_stdout", "input": "100\n11 16 16 11 16 11 16 16 11 16 16 16 16 16 16 16 16 16 11 16 16 16 16 16 16 11 16 11 16 11 16 16 16 11 5 16 16 11 16 16 16 16 16 11 16 11 5 16 16 16 16 5 16 16 11 11 16 16 5 16 11 11 16 16 16 11 11 16 11 16 16 16 16 16 16 11 11 16 16 5 16 5 20 5 16 16 16 11 16 16 16 16 16 16 11 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMasha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities.\n\nTo bake muffins in her bakery, Masha needs t...
[{"type": "stdin_stdout", "input": "8 57 3\n1 3 15\n2 3 1\n1 7 21\n1 2 8\n2 5 16\n1 6 4\n1 3 2\n3 7 17\n5 8 3\n1 3 18\n1 4 3\n1 2 1\n2 8 14\n1 4 17\n4 5 21\n2 3 6\n3 5 11\n2 8 11\n3 4 1\n1 3 9\n1 4 3\n2 3 12\n1 5 9\n2 3 15\n1 2 14\n1 2 10\n1 4 19\n5 7 7\n5 8 20\n5 8 1\n1 4 3\n4 5 8\n5 7 2\n1 2 14\n4 5 9\n6 7 2\n2 6 9\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given array consisting of n integers. Your task is to find the maximum length of an increasing subarray of the given array.\n\nA subarray is the sequence of consecutive elements of the array. Subarray is called in...
[{"type": "stdin_stdout", "input": "10\n802030518 598196518 640274071 983359971 71550121 96204862 799843967 446173607 796619138 402690754\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "6\n100 100 100 100 100 100\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "11\n1 2 3 1 2 3 2 1 2 3 4\n", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any posit...
[{"type": "stdin_stdout", "input": "48\n4 7 12 16 23 43 61 112 134 141 243 267 484 890 1427 1558 1653 2263 2889 3313 3730 5991 10176 18243 18685 36555 40006 62099 70557 106602 122641 125854 213236 309698 379653 713328 999577 1021356 2007207 2886237 4994645 5812125 11576387 14215887 26060277 35989707 36964781 57933366\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt is Professor R's last class of his teaching career. Every time Professor R taught a class, he gave a special problem for the students to solve. You being his favourite student, put your heart into solving it one last t...
[{"type": "stdin_stdout", "input": "70 11 17929\n17929 427 268935 211 197219 83 357 179290 97 358580 475 343 175 221 286864 429 304793 179290 189 363 221 340651 376509 453 251006 141 304793 358580 235 107574 141 358580 167 181 304793 335 286864 171 107574 105 449 358580 286864 161 286864 349 89645 197219 395 358580 233...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter you had helped Fedor to find friends in the «Call of Soldiers 3» game, he stopped studying completely. Today, the English teacher told him to prepare an essay. Fedor didn't want to prepare the essay, so he asked Ale...
[{"type": "stdin_stdout", "input": "2\nABBABAABBAABABBABAABABBAABBABAABBAABABBAABBABAABABBABAABBAABABBA ABBABAABBAABABBABAABABBAABBABAABBAABABBAABBABAABABBABAABBAABABA\n2\nABBABAABBAABABBABAABABBAABBABAABBAABABBAABBABAABABBABAABBAABABA neuzaiheshi\nABBABAABBAABABBABAABABBAABBABAABBAABABBAABBABAABABBABAABBAABABBA ABBABA...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nValera had an undirected connected graph without self-loops and multiple edges consisting of n vertices. The graph had an interesting property: there were at most k edges adjacent to each of its vertices. For convenience,...
[{"type": "stdin_stdout", "input": "9 4\n2 1 1 3 1 2 2 1 0\n", "output": "8\n1 8\n2 9\n3 9\n4 7\n5 9\n6 8\n7 8\n8 9\n"}, {"type": "stdin_stdout", "input": "7 3\n2 2 0 1 3 2 1\n", "output": "6\n1 7\n2 7\n3 4\n3 7\n4 6\n5 6\n"}, {"type": "stdin_stdout", "input": "5 3\n0 2 1 2 1\n", "output": "4\n1 3\n1 5\n2 5\n4 5\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt is winter now, and Max decided it's about time he watered the garden.\n\nThe garden can be represented as n consecutive garden beds, numbered from 1 to n. k beds contain water taps (i-th tap is located in the bed x_{i}...
[{"type": "stdin_stdout", "input": "1\n177 99\n1 4 7 10 11 13 14 15 16 17 19 21 22 24 25 26 27 28 32 34 35 38 39 40 42 45 46 52 54 55 57 58 59 60 62 64 65 67 70 71 74 77 78 79 80 81 83 84 88 92 93 94 95 100 101 102 104 106 107 108 109 110 112 113 114 115 116 118 122 123 124 125 127 128 129 130 134 135 137 138 139 140 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string $s$ of length $n$, which consists only of the first $k$ letters of the Latin alphabet. All letters in string $s$ are uppercase.\n\nA subsequence of string $s$ is a string that can be derived from $s...
[{"type": "stdin_stdout", "input": "76 26\nABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYABCDEFGHIJKLMNOPQRSTUVWXY\n", "output": "26"}, {"type": "stdin_stdout", "input": "22 1\nAAAAAAAAAAAAAAAAAAAAAA\n", "output": "22"}, {"type": "stdin_stdout", "input": "15 26\nWEYYDIADTLCOUEG\n", "output": "0"}, {"type": "stdin_...
code_stdio