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\nÆsir - CHAOS Æsir - V.\n\n\"Everything has been planned out. No more hidden concerns. The condition of Cytus is also perfect.\n\nThe time right now...... 00:01:12......\n\nIt's time.\"\n\nThe emotion samples are now suffi...
[{"type": "stdin_stdout", "input": "87\n1120 1120 1120 872 1120 731 3583 2815 4019 1291 4568 973 1120 1705 1120 822 203 1120 1120 1120 1120 4196 3166 4589 3030 1120 1120 1120 711 1120 500 1120 1120 3551 1120 1120 1120 1700 1120 1120 2319 4554 1120 1312 1120 1120 4176 1120 1120 3661 1120 1120 1120 1120 142 63 4125 1120 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIahub and Sorin are the best competitive programmers in their town. However, they can't both qualify to an important contest. The selection will be made with the help of a single problem. Blatnatalag, a friend of Iahub, m...
[{"type": "stdin_stdout", "input": "100\n-57 -64 83 76 80 27 60 76 -80 -56 52 72 -17 92 -96 87 41 -88 94 89 12 42 36 34 -100 -43 -42 62 3 87 -69 -6 -27 -59 -7 5 -90 -23 63 -87 -60 -92 -40 54 -16 -47 67 -64 10 33 -19 53 -7 -62 16 -74 -36 4 -75 -55 92 3 -22 43 -30 48 -27 88 -58 41 36 8 -40 -30 -18 16 22 -66 -91 -46 48 -6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a string S of length N consisting of characters 0 and 1. You will perform the following operation for each i = 1, 2, ..., m:\n - Arbitrarily permute the characters within the substring of S starting at the l_i-th...
[{"type": "stdin_stdout", "input": "3000 3000\n010100001010100010010011011011000111111011101010000011000111010111001001010101011101000010100101101110111010011111001010000100000010011000011000101110110010010111001111001111011001101010100010010100100101011011101000100010011001100101010000010011011100001110110111000100001...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to $120^{\\circ}$. Then he measured the length of its sides, and found that each of them is equal to an in...
[{"type": "stdin_stdout", "input": "1000 1000 1000 1000 1000 1000\n", "output": "6000000\n"}, {"type": "stdin_stdout", "input": "718 466 729 470 714 481\n", "output": "2102808\n"}, {"type": "stdin_stdout", "input": "677 303 685 288 692 296\n", "output": "1365807\n"}, {"type": "stdin_stdout", "input": "1000 1000 1 1000 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSquirrel Liss is interested in sequences. She also has preferences of integers. She thinks n integers a_1, a_2, ..., a_{n} are good.\n\nNow she is interested in good sequences. A sequence x_1, x_2, ..., x_{k} is called go...
[{"type": "stdin_stdout", "input": "49\n10 34 58 72 126 166 176 180 198 200 208 228 238 248 302 332 340 344 350 354 380 406 418 428 438 442 482 532 536 544 546 554 596 626 642 682 684 704 714 792 804 820 862 880 906 946 954 966 970\n", "output": "49\n"}, {"type": "stdin_stdout", "input": "44\n1 5 37 97 107 147 185 187 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are an intergalactic surgeon and you have an alien patient. For the purposes of this problem, we can and we will model this patient's body using a $2 \\times (2k + 1)$ rectangular grid. The alien has $4k + 1$ distinct...
[{"type": "stdin_stdout", "input": "4\n14\nE 1 2 3 4 5 22 7 44 25 10 11 12 13 14 15 16 17 18 19 20 21 6 23 24 9 26 27 28\n57 56 55 54 53 52 51 50 49 48 47 46 45 8 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29\n2\nE 1 2 3 4\n6 7 8 9 5\n2\nE 1 2 3 4\n9 8 7 6 5\n2\nE 1 2 3 4\n9 8 7 6 5\n", "output": "SURGERY FAILED\nSURGER...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a permutation P[1... N] of integers from 1 to N, function f is defined as follows:\n\n $f(i, j) = \\left\\{\\begin{array}{ll}{P [ i ]} & {\\text{if} j = 1} \\\\{f(P [ i ], j - 1)} & {\\text{otherwise}} \\end{array} \\...
[{"type": "stdin_stdout", "input": "10 7 5\n", "output": "2 3 4 5 1 7 8 9 10 6 "}, {"type": "stdin_stdout", "input": "9 2 5\n", "output": "2 1 4 3 6 7 8 9 5 "}, {"type": "stdin_stdout", "input": "9 7 9\n", "output": "2 3 4 5 6 7 8 9 1 "}, {"type": "stdin_stdout", "input": "390612 20831 55790\n", "output": "-1"}, {"type...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEnough is enough. Too many times it happened that Vasya forgot to dispose of garbage and his apartment stank afterwards. Now he wants to create a garbage disposal plan and stick to it.\n\nFor each of next $n$ days Vasya k...
[{"type": "stdin_stdout", "input": "185 2\n0 14 2 11 5 17 9 11 8 12 8 17 17 0 4 15 4 17 8 1 2 10 8 0 8 16 1 7 10 4 0 18 2 15 2 1 4 1 10 11 6 10 19 5 5 18 2 1 15 17 0 4 12 19 12 8 11 4 7 15 13 0 9 6 2 6 5 2 17 4 7 9 11 17 1 13 4 6 4 10 1 14 0 13 17 16 10 5 7 19 19 9 2 2 17 17 11 6 11 15 4 17 18 18 14 9 15 10 10 10 14 18...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIs there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. \n\nInspired by this adventure and an a...
[{"type": "stdin_stdout", "input": "wwwbbwbbbwbwbwwbwwbbbwbwbwwbbbwbwwwbwwbwbbbbwwbwwwwwbwwwwwwwwbbwwwwbbbbbwbwbbwwbbbbbwbwbbwbwwwbbwwbbbwwwbbwwbwwbbbbwwbwbbwbwwbbwbwbwbbwwbwwwbwbwbbbwwwwwwbwwbbbwwbwwbwbwwwbbwwwwwwwwwbwwbwbbbwbwwwwbwwbbwbbwbwwbwwbwwbbwbbwwwwbwwwbwwwbwbwwwbbwwbbwwbwbwwwwwwbwbwwwwbbwwwbwbwwwbbwwwwwbwwbwb...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a set of $n$ weights. You know that their masses are $a_1$, $a_2$, ..., $a_n$ grams, but you don't know which of them has which mass. You can't distinguish the weights.\n\nHowever, your friend does know the mass ...
[{"type": "stdin_stdout", "input": "100\n50 50 51 50 51 51 51 51 51 50 50 50 50 50 50 51 50 51 50 51 51 50 50 51 51 51 51 51 51 50 50 51 51 51 50 50 50 51 50 51 51 51 50 51 51 50 50 50 50 50 50 51 50 50 51 51 51 50 50 50 51 50 51 50 51 51 50 51 50 51 51 51 50 51 50 50 51 50 51 51 51 51 50 51 51 51 51 50 51 51 51 51 51 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSuppose you are given a string $s$ of length $n$ consisting of lowercase English letters. You need to compress it using the smallest possible number of coins.\n\nTo compress the string, you have to represent $s$ as a conc...
[{"type": "stdin_stdout", "input": "255 3880 4590\nwgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwewgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwkwgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwewgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwawgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwewgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwkwgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwewgwzwgwuwgwzwgwxwgwzwgwuwgwzwgw\n", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMolly Hooper has n different kinds of chemicals arranged in a line. Each of the chemicals has an affection value, The i-th of them has affection value a_{i}.\n\nMolly wants Sherlock to fall in love with her. She intends t...
[{"type": "stdin_stdout", "input": "89 -7\n5972 4011 3914 670 3727 2913 6935 6927 2118 6645 7141 3585 9811 2859 459 8870 6578 8667 468 5152 3241 7455 7323 8817 4866 1040 5102 9146 621 5002 396 4967 9822 4200 3899 4416 5225 9415 9606 4802 5589 1798 9094 5453 7163 264 1026 6187 3918 4237 -17 4306 8960 3321 2927 9205 6248...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the evening Polycarp decided to analyze his today's travel expenses on public transport.\n\nThe bus system in the capital of Berland is arranged in such a way that each bus runs along the route between two stops. Each ...
[{"type": "stdin_stdout", "input": "27 8 1 0 1\nBcd A\nA b\nb BcDc\ndc dbaC\ndbaC dcCB\nB d\nd BbAc\nCBC b\nDBDca d\ncAbb AA\nAA Ba\ncAccb DBDca\ncb DdaB\nAAcBc Ba\nBa dc\ndc DDCd\nbcBDA da\nbDD ADD\nAA b\nb cb\ncb CCBbd\nCCBbd bcDdb\nbcDdb ddc\nddc C\nC Adc\nAdc BbAc\nBbAc DD\n", "output": "111\n"}, {"type": "stdin_st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last n days. Assume that the average air temperature for each day is integral.\n\nVasya bel...
[{"type": "stdin_stdout", "input": "100\n-85 -80 -76 -72 -68 -64 -60 -56 -52 -48 -44 -40 -36 -32 -28 -24 -20 -16 -12 -8 -4 0 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120 124 128 132 136 140 144 148 152 156 160 164 168 172 176 180 184 188 192 196 200 204 208 212 216 220 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNote that this is the first problem of the two similar problems. You can hack this problem only if you solve both problems.\n\nYou are given a tree with $n$ nodes. In the beginning, $0$ is written on all edges. In one ope...
[{"type": "stdin_stdout", "input": "60\n26 6\n59 30\n31 12\n31 3\n38 23\n59 29\n53 9\n38 56\n53 54\n29 21\n17 55\n59 38\n26 16\n24 59\n24 25\n17 35\n24 41\n30 15\n31 27\n8 44\n26 5\n26 48\n8 32\n53 17\n3 34\n3 51\n30 28\n47 10\n53 60\n36 42\n24 53\n59 22\n53 40\n26 52\n36 4\n59 8\n29 37\n36 20\n17 47\n53 18\n3 50\n30 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBoy Dima gave Julian a birthday present — set $B$ consisting of positive integers. However, he didn't know, that Julian hates sets, but enjoys bipartite graphs more than anything else!\n\nJulian was almost upset, but her ...
[{"type": "stdin_stdout", "input": "10\n221998069488770316 954736809508793543 598658276983441394 74222410330038206 823279423814526176 807704234927978303 752441720796406299 872983354198335776 826110873403601011 45690579225458516\n", "output": "6\n598658276983441394 74222410330038206 221998069488770316 45690579225458516 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider a table G of size n × m such that G(i, j) = GCD(i, j) for all 1 ≤ i ≤ n, 1 ≤ j ≤ m. GCD(a, b) is the greatest common divisor of numbers a and b.\n\nYou have a sequence of positive integer numbers a_1, a_2, ..., a...
[{"type": "stdin_stdout", "input": "1000000000000 1000000000000 116\n1587924000 7 2 3 4 5 6 1 56 9 10 1 12 13 2 105 16 1 18 1 620 3 14 1 24 25 26 27 4 203 30 1 32 3 2 5 252 1 2 39 40 1 6 7 4 45 2 1 48 1 350 93 52 1 54 5 8 21 58 1 60 1 2 9 224 65 6 1 4 3 10 7 72 1 2 75 4 1 546 1 80 81 62 1 12 35 2 87 8 1 90 13 28 3 2 5 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a square grid of size $n \\times n$. Some cells are colored in black, all others are colored in white. In one operation you can select some rectangle and color all its cells in white. It costs $\\min(h, w)$ to co...
[{"type": "stdin_stdout", "input": "1000 24\n190 39 552 958\n539 146 763 587\n31 526 423 673\n208 432 953 442\n263 69 719 635\n162 428 623 797\n49 126 94 963\n749 623 979 919\n190 461 367 855\n211 240 939 914\n169 80 336 203\n684 546 829 582\n80 218 324 327\n560 452 656 637\n316 534 982 642\n521 634 758 686\n514 324 75...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSlime has a sequence of positive integers $a_1, a_2, \\ldots, a_n$.\n\nIn one operation Orac can choose an arbitrary subsegment $[l \\ldots r]$ of this sequence and replace all values $a_l, a_{l + 1}, \\ldots, a_r$ to the...
[{"type": "stdin_stdout", "input": "5\n5 3\n1 5 2 6 1\n1 6\n6\n3 2\n1 2 3\n4 3\n3 1 2 3\n10 3\n1 2 3 4 5 6 7 8 9 10\n", "output": "no\nyes\nyes\nno\nyes\n"}, {"type": "stdin_stdout", "input": "2\n1 1\n1000000000\n3 1000000000\n1000000000 996 251\n", "output": "no\nno\n"}, {"type": "stdin_stdout", "input": "1\n17 15\n3 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlyona's mother wants to present an array of n non-negative integers to Alyona. The array should be special. \n\nAlyona is a capricious girl so after she gets the array, she inspects m of its subarrays. Subarray is a set ...
[{"type": "stdin_stdout", "input": "10 10\n1 5\n7 10\n2 10\n2 5\n2 9\n5 9\n3 10\n4 9\n6 9\n2 7\n", "output": "4\n0 1 2 3 0 1 2 3 0 1\n"}, {"type": "stdin_stdout", "input": "10 10\n1 9\n4 8\n4 8\n5 9\n1 9\n3 8\n1 6\n1 9\n1 6\n6 9\n", "output": "4\n0 1 2 3 0 1 2 3 0 1\n"}, {"type": "stdin_stdout", "input": "9 9\n4 5\n5 8...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMoriarty has trapped n people in n distinct rooms in a hotel. Some rooms are locked, others are unlocked. But, there is a condition that the people in the hotel can only escape when all the doors are unlocked at the same ...
[{"type": "stdin_stdout", "input": "13 11\n0 1 1 0 1 0 0 0 1 0 0 1 1\n6 2 8 9 11 12 13\n3 1 3 11\n1 12\n1 7\n3 6 10 13\n3 1 3 8\n2 7 9\n1 4\n1 2\n2 5 10\n3 4 5 6\n", "output": "NO"}, {"type": "stdin_stdout", "input": "11 10\n0 0 1 0 0 0 0 1 1 0 1\n3 2 3 11\n1 3\n2 6 7\n1 5\n1 11\n1 10\n5 4 6 8 9 10\n2 1 5\n1 7\n5 1 2 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nUser ainta loves to play with cards. He has a cards containing letter \"o\" and b cards containing letter \"x\". He arranges the cards in a row, and calculates the score of the deck by the formula below. At first, the sc...
[{"type": "stdin_stdout", "input": "206 209\n", "output": "34847\nxxxxxxxxxxxxxxxxxxxoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooxxxxxxxxxxxxxxxxxxxoxxxxxxxxxxxxxxxxxx...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice, Bob and Charlie are playing Card Game for Three, as below:\n - At first, each of the three players has a deck consisting of some number of cards. Alice's deck has N cards, Bob's deck has M cards, and Charlie's deck...
[{"type": "stdin_stdout", "input": "300000 300000 300000\n", "output": "415274335\n"}, {"type": "stdin_stdout", "input": "123321 287789 256654\n", "output": "507348047\n"}, {"type": "stdin_stdout", "input": "298865 299673 299514\n", "output": "652837961\n"}, {"type": "stdin_stdout", "input": "299983 299972 299996\n", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDora loves adventures quite a lot. During some journey she encountered an amazing city, which is formed by $n$ streets along the Eastern direction and $m$ streets across the Southern direction. Naturally, this city has $n...
[{"type": "stdin_stdout", "input": "1 100\n855 693 601 329 311 798 783 920 504 868 521 358 367 467 623 767 481 635 855 608 157 95 273 261 110 713 948 897 546 476 855 337 93 321 648 441 215 979 505 69 858 99 877 337 237 116 824 98 955 192 773 99 485 385 861 849 772 993 470 215 792 635 986 515 84 7 476 831 903 74 79 545 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is constraints.\n\nNauuo is a girl who loves random picture websites.\n\nOne day she made a random picture website by herself which includes $n$ pictures.\n\nWhen Nauuo v...
[{"type": "stdin_stdout", "input": "20 30\n0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0\n34095514 37349809 60555988 40280455 19504485 77297461 41415742 66290058 20631093 185280391 7151718 64927972 15611855 4317891 24600598 24588269 60808977 9108470 13217752 191209824\n", "output": "313283482\n21804622\n682197550\n361027027\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nArtem has an array of n positive integers. Artem decided to play with it. The game consists of n moves. Each move goes like this. Artem chooses some element of the array and removes it. For that, he gets min(a, b) points,...
[{"type": "stdin_stdout", "input": "10\n96 66 8 18 30 48 34 11 37 42\n", "output": "299\n"}, {"type": "stdin_stdout", "input": "9\n72 49 39 50 68 35 75 94 56\n", "output": "435\n"}, {"type": "stdin_stdout", "input": "8\n77 84 26 34 17 56 76 3\n", "output": "279\n"}, {"type": "stdin_stdout", "input": "10\n4 2 2 4 1 2 2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSomeone give a strange birthday present to Ivan. It is hedgehog — connected undirected graph in which one vertex has degree at least $3$ (we will call it center) and all other vertices has degree 1. Ivan thought that hedg...
[{"type": "stdin_stdout", "input": "33 2\n3 13\n17 3\n2 6\n5 33\n4 18\n1 2\n31 5\n4 19\n3 16\n1 3\n9 2\n10 3\n5 1\n5 28\n21 4\n7 2\n1 4\n5 24\n30 5\n14 3\n3 11\n27 5\n8 2\n22 4\n12 3\n20 4\n26 5\n4 23\n32 5\n25 5\n15 3\n29 5\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "25 2\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA monopole magnet is a magnet that only has one pole, either north or south. They don't actually exist since real magnets have two poles, but this is a programming contest problem, so we don't care.\n\nThere is an $n\\tim...
[{"type": "stdin_stdout", "input": "18 22\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\nInitially there was an array $a$ consisting of $n$ integers. Positions in it are numbered from $1$ to $n$.\n\nExactly $q$ queries were performed on the array. During the $i$-th query some segment $(l_i, r_i)$ $(1 \\le l_i...
[{"type": "stdin_stdout", "input": "50 200000\n0 199989 0 0 0 0 200000 200000 0 200000 0 200000 200000 0 0 200000 0 0 0 0 200000 200000 200000 200000 0 0 0 200000 0 0 0 0 200000 200000 0 200000 0 200000 0 200000 200000 0 200000 0 199999 199980 199978 199978 199964 199952\n", "output": "YES\n1 199989 1 1 1 1 200000 2000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe GCD table G of size n × n for an array of positive integers a of length n is defined by formula $g_{ij} = \\operatorname{gcd}(a_{i}, a_{j})$ \n\nLet us remind you that the greatest common divisor (GCD) of two positiv...
[{"type": "stdin_stdout", "input": "5\n537163 537163 537163 537163 537163 537163 1074326 537163 537163 537163 515139317 1074326 537163 537163 537163 539311652 321760637 170817834 537163 537163 537163 537163 537163 537163 392666153\n", "output": "170817834 321760637 392666153 515139317 539311652 "}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ points on the plane, the $i$-th of which is at $(x_i, y_i)$. Tokitsukaze wants to draw a strange rectangular area and pick all the points in the area.\n\nThe strange area is enclosed by three lines, $x = l$,...
[{"type": "stdin_stdout", "input": "35\n8 1\n6 8\n4 1\n1 2\n1 4\n5 10\n10 8\n9 1\n9 9\n10 2\n6 5\n8 8\n7 6\n10 6\n9 4\n4 9\n3 2\n1 8\n3 9\n7 3\n3 7\n2 7\n3 8\n3 1\n2 2\n5 5\n7 2\n4 10\n6 3\n5 1\n8 10\n4 3\n9 8\n9 7\n3 10\n", "output": "316\n"}, {"type": "stdin_stdout", "input": "35\n4 2\n9 6\n3 10\n2 5\n7 9\n6 9\n10 7\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are an adventurer currently journeying inside an evil temple. After defeating a couple of weak zombies, you arrived at a square room consisting of tiles forming an n × n grid. The rows are numbered 1 through n from to...
[{"type": "stdin_stdout", "input": "17\n.EEEEE...EEEE..EE\nEEE..E...EEEEE..E\n.E..E..EEE.EE...E\n.EEE.EE..EE...E..\nE..EEEEEE.EE.....\nE.EE...EEEEEEE.E.\nEEEE....EE..E.EEE\n...EEEEE.E..EE...\nEEE.E..EEEE.EEE..\n..E.E....EEE.....\nEE..E..E.E..EEEEE\nEEE..E.EEEEE.E...\n..EEEEE.E..EE.EE.\nEE.E...E..E..E.EE\n..E.EEE.EE..EE...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation:\n\n$f(a, l, r) = \\sum_{i = l}^{r} a [ i ] ; m(a) = \\operatorname{max}_{1 \\leq l \\leq r \\leq n} f(a, l, r)$\n\n...
[{"type": "stdin_stdout", "input": "116 10\n477 -765 -756 376 -48 -75 768 -658 263 -207 362 -535 96 -960 630 -686 609 -830 889 57 -239 346 -298 -18 -107 853 -607 -443 -517 371 657 105 479 498 -47 432 503 -917 -656 610 -466 216 -747 -587 -163 -174 493 -882 853 -582 -774 -477 -386 610 -58 557 968 196 69 610 -38 366 -79 5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise ...
[{"type": "stdin_stdout", "input": "5 10 8\n1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "1073741825000000000\n"}, {"type": "stdin_stdout", "input": "3 2 6\n724148075 828984987 810015532\n", "output": "29996605423\n"}, {"type": "stdin_stdout", "input": "1 2 3\n612635770\n", "output": "5513721930...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi throws N dice, each having K sides with all integers from 1 to K. The dice are NOT pairwise distinguishable.\nFor each i=2,3,...,2K, find the following value modulo 998244353:\n - The number of combinations of N...
[{"type": "stdin_stdout", "input": "2000 3\n", "output": "337087647\n337087647\n337085647\n337085647\n337083647\n337083647\n337081647\n337081647\n337079647\n337079647\n337077647\n337077647\n337075647\n337075647\n337073647\n337073647\n337071647\n337071647\n337069647\n337069647\n337067647\n337067647\n337065647\n337065647...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTreeland is a country in which there are n towns connected by n - 1 two-way road such that it's possible to get from any town to any other town. \n\nIn Treeland there are 2k universities which are located in different tow...
[{"type": "stdin_stdout", "input": "35 15\n6 12 32 18 11 10 29 9 30 27 31 14 8 24 28 25 19 15 21 3 4 1 33 22 23 17 16 13 7 2\n1 2\n20 3\n1 4\n20 5\n20 6\n1 7\n13 8\n4 9\n1 10\n1 11\n1 12\n1 13\n18 14\n10 15\n1 16\n16 17\n1 18\n1 19\n1 20\n20 21\n1 22\n27 23\n25 24\n1 25\n20 26\n20 27\n18 28\n4 29\n13 30\n4 31\n1 32\n20...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days ar...
[{"type": "stdin_stdout", "input": "0000000000011001100011110101000101000010010111000100110110000011010011110110001100100001001001010010\n", "output": "22\n1 1\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n7 9 24 25 26 27 28 29\n7 10 13 14 17 18 23 30\n11 11 12 15 16 19 22 31 32 33 34 35\n3 20 21 36\n3 37 46 47\n9 38 39 40 45 48...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has g_{i} Pokemon in it. There are m distinct Pok...
[{"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\nSomething happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found tha...
[{"type": "stdin_stdout", "input": "100\n23 64 60 -45 -36 -64 -59 15 -75 69 -30 -7 -20 17 -77 58 93 -76 -98 -22 -31 16 -50 6 -20 -85 1 64 -88 -8 -15 -6 -57 25 91 10 2 -90 74 -66 -42 73 28 49 -85 59 96 79 -25 49 -59 -89 -75 12 -96 -33 -65 -8 -100 -81 17 99 -91 -5 7 -21 1 85 63 86 -26 85 -31 11 -75 35 -82 15 98 93 -55 66...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day, little Vasya found himself in a maze consisting of (n + 1) rooms, numbered from 1 to (n + 1). Initially, Vasya is at the first room and to get out of the maze, he needs to get to the (n + 1)-th one.\n\nThe maze i...
[{"type": "stdin_stdout", "input": "129\n1 1 3 3 1 4 7 4 3 5 8 11 3 9 15 4 11 17 1 6 18 9 11 13 17 22 8 18 26 13 16 20 3 16 35 26 23 28 27 30 39 29 43 8 14 6 17 32 26 31 2 18 3 47 52 21 57 1 35 35 53 47 16 26 30 65 48 2 32 11 10 5 4 1 4 53 71 21 53 8 58 49 17 6 19 80 1 49 43 60 12 60 35 25 86 45 47 97 52 74 10 91 93 31...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n types of coins in Byteland. Conveniently, the denomination of the coin type k divides the denomination of the coin type k + 1, the denomination of the coin type 1 equals 1 tugrick. The ratio of the denominatio...
[{"type": "stdin_stdout", "input": "100\n4 1 5 3 2 1 1 1 4 1 1 2 1 1 1 4 1 1 3 1 3 1 1 1 1 4 5 1 5 2 5 3 1 1 1 1 1 1 1 3 2 1 1 3 1 1 3 4 3 2 4 1 1 4 1 1 2 2 4 1 4 1 2 5 1 2 2 1 5 3 1 5 4 2 1 1 2 5 5 1 4 4 2 3 1 4 1 3 2 1 1 1 4 1 3 1 1 5 1\n0 18 10 2 1 9 9 0 9 5 6 8 11 6 28 11 29 50 25 15 9 4 3 51 13 4 68 31 4 6 2 5 26 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProgrammers working on a large project have just received a task to write exactly m lines of code. There are n programmers working on a project, the i-th of them makes exactly a_{i} bugs in every line of code that he writ...
[{"type": "stdin_stdout", "input": "123 432 342 1000000007\n72 20 34 115 65 29 114 41 18 16 122 104 88 37 119 11 108 91 13 110 47 73 80 35 62 12 9 116 55 66 54 113 50 57 8 25 98 105 0 120 93 78 61 17 84 48 42 106 63 103 7 59 90 89 28 49 53 71 51 83 75 67 64 95 107 3 32 85 69 99 33 79 109 56 10 23 87 19 121 94 44 82 102...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a text consisting of n lines. Each line contains some space-separated words, consisting of lowercase English letters.\n\nWe define a syllable as a string that contains exactly one vowel and any arbitrary num...
[{"type": "stdin_stdout", "input": "4\n13 11 15 15\nto be or not to be that is the question\nwhether tis nobler in the mind to suffer\nthe slings and arrows of outrageous fortune\nor to take arms against a sea of troubles\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "2\n26 35\ngouojxaoobw iu bkaadyo degnjk...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEmuskald is an avid horticulturist and owns the world's longest greenhouse — it is effectively infinite in length.\n\nOver the years Emuskald has cultivated n plants in his greenhouse, of m different plant species numbere...
[{"type": "stdin_stdout", "input": "20 15\n6 8719.787178\n10 13066.663722\n15 58623.690996\n9 184321.819759\n3 227999.294560\n2 279836.330518\n9 282806.308675\n8 311056.507765\n1 312315.562927\n5 459200.373445\n14 563454.265947\n7 647364.984868\n13 679761.613732\n4 684192.647497\n1 733119.607626\n7 748637.778398\n12 82...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.\n\nGiven a sequence a consisting of n integers. The player can m...
[{"type": "stdin_stdout", "input": "100\n4 8 10 1 8 8 8 1 10 3 1 8 6 8 6 1 10 3 3 3 3 7 2 1 1 6 10 1 7 9 8 10 3 8 6 2 1 6 5 6 10 8 9 7 4 3 10 5 3 9 10 5 10 8 8 5 7 8 9 5 3 9 9 2 7 8 1 10 4 9 2 8 10 10 5 8 5 1 7 3 4 5 2 5 9 3 2 5 6 2 3 10 1 5 9 6 10 4 10 8\n", "output": "380\n"}, {"type": "stdin_stdout", "input": "100\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarpus just has been out of luck lately! As soon as he found a job in the \"Binary Cat\" cafe, the club got burgled. All ice-cream was stolen.\n\nOn the burglary night Polycarpus kept a careful record of all club visi...
[{"type": "stdin_stdout", "input": "-+++---+++++++++++++-++-++++++-++-+-+++-\n", "output": "22\n"}, {"type": "stdin_stdout", "input": "++-++--+++++-+++++---+++-++-++-\n", "output": "12\n"}, {"type": "stdin_stdout", "input": "----+-+--++---++---++-+-----+--\n", "output": "11\n"}, {"type": "stdin_stdout", "input": "-+++-...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNatasha travels around Mars in the Mars rover. But suddenly it broke down, namely — the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the vertex $1$, in which every le...
[{"type": "stdin_stdout", "input": "60\nAND 20 4\nNOT 42\nAND 48 59\nOR 17 7\nIN 0\nAND 36 37\nIN 1\nIN 0\nIN 1\nNOT 47\nAND 52 49\nOR 44 35\nIN 0\nIN 1\nAND 33 56\nIN 0\nIN 0\nIN 0\nAND 31 41\nOR 15 3\nOR 43 46\nIN 1\nXOR 22 28\nIN 1\nIN 1\nIN 1\nAND 34 21\nIN 1\nIN 1\nIN 0\nXOR 51 23\nXOR 10 54\nOR 57 40\nIN 0\nNOT 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSereja has two sequences a and b and number p. Sequence a consists of n integers a_1, a_2, ..., a_{n}. Similarly, sequence b consists of m integers b_1, b_2, ..., b_{m}. As usual, Sereja studies the sequences he has. Toda...
[{"type": "stdin_stdout", "input": "82 50 1\n4 2 2 4 4 3 2 2 3 3 4 3 4 1 4 1 4 3 5 3 4 2 4 4 5 2 5 4 2 4 2 5 3 2 3 4 2 5 4 3 3 4 3 4 1 1 5 2 4 1 3 3 2 4 1 2 2 5 4 4 5 3 3 1 2 3 4 5 3 1 2 3 3 5 5 2 4 1 4 2 3 1\n4 3 3 3 4 1 4 4 5 5 5 2 5 4 1 2 2 1 3 3 3 3 2 5 3 2 4 3 2 2 4 4 4 3 4 2 1 2 3 2 1 1 5 2 3 5 4 5 3 4\n", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHongcow is ruler of the world. As ruler of the world, he wants to make it easier for people to travel by road within their own countries.\n\nThe world can be modeled as an undirected graph with n nodes and m edges. k of t...
[{"type": "stdin_stdout", "input": "24 38 2\n4 13\n7 1\n24 1\n2 8\n17 2\n2 18\n22 2\n23 3\n5 9\n21 5\n6 7\n6 19\n6 20\n11 7\n7 20\n13 8\n16 8\n9 10\n14 9\n21 9\n12 10\n10 22\n23 10\n17 11\n11 24\n20 12\n13 16\n13 23\n15 14\n17 14\n14 20\n19 16\n17 20\n17 23\n18 22\n18 23\n22 19\n21 20\n23 24\n", "output": "215\n"}, {"t...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou all know that the Library of Bookland is the largest library in the world. There are dozens of thousands of books in the library.\n\nSome long and uninteresting story was removed...\n\nThe alphabet of Bookland is so l...
[{"type": "stdin_stdout", "input": "10 10\n8 1 1 6 10 2 2 9 7\n6 2 7 1 9 5 10\n1 5\n7 3 6 9 6 3 7 6\n10 3 9 10 3 6 7 10 6 9 6\n10 4 4 9 8 2 10 3 6 2 9\n8 4 8 6 4 6 4 8 6\n2 7 5\n6 8 6 2 1 9 8\n3 10 2 10\n", "output": "Yes\n3\n1 2 5 "}, {"type": "stdin_stdout", "input": "10 10\n8 2 1 3 2 10 5 4 1\n6 2 1 7 5 7 1\n9 2 1 7...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter the war, the supersonic rocket became the most common public transportation.\n\nEach supersonic rocket consists of two \"engines\". Each engine is a set of \"power sources\". The first engine has $n$ power sources, ...
[{"type": "stdin_stdout", "input": "8 8\n53212775 61830464\n32047271 31958754\n46845363 47341547\n46097536 79640734\n25559819 90360169\n5442822 40309249\n57656501 31139219\n1191345 7784770\n61052639 71686018\n53542361 10165576\n61963163 25946318\n15498921 83261369\n97981085 40697107\n35269685 20583089\n50275077 3751318...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn Morse code, an letter of English alphabet is represented as a string of some length from $1$ to $4$. Moreover, each Morse code representation of an English letter contains only dots and dashes. In this task, we will re...
[{"type": "stdin_stdout", "input": "50\n1\n1\n0\n1\n0\n0\n0\n0\n0\n1\n1\n0\n1\n1\n1\n0\n0\n1\n1\n0\n1\n1\n1\n1\n0\n1\n0\n0\n1\n1\n1\n0\n1\n0\n1\n1\n1\n1\n0\n1\n0\n0\n0\n0\n1\n0\n1\n0\n0\n1\n", "output": "1\n3\n10\n24\n51\n109\n221\n437\n853\n1682\n3168\n6140\n11860\n22892\n44135\n82151\n158191\n304543\n564961\n1085797\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMike and Ann are sitting in the classroom. The lesson is boring, so they decided to play an interesting game. Fortunately, all they need to play this game is a string $s$ and a number $k$ ($0 \\le k < |s|$).\n\nAt the beg...
[{"type": "stdin_stdout", "input": "dequudpveoozswafkmdadrxtnmagtpcdqzhxkitrbqytichoswltzzasfoeqktomxlypvhjyjnjymvlrvglvyursfm\n", "output": "Mike\nAnn\nAnn\nAnn\nAnn\nMike\nAnn\nAnn\nAnn\nAnn\nAnn\nAnn\nAnn\nAnn\nMike\nAnn\nAnn\nAnn\nAnn\nMike\nAnn\nAnn\nAnn\nAnn\nAnn\nAnn\nMike\nAnn\nAnn\nAnn\nAnn\nAnn\nAnn\nAnn\nAnn...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle penguin Polo adores strings. But most of all he adores strings of length n.\n\nOne day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, t...
[{"type": "stdin_stdout", "input": "128 26\n", "output": "ababababababababababababababababababababababababababababababababababababababababababababababababababababcdefghijklmnopqrstuvwxyz\n"}, {"type": "stdin_stdout", "input": "123 21\n", "output": "abababababababababababababababababababababababababababababababababababa...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA dragon symbolizes wisdom, power and wealth. On Lunar New Year's Day, people model a dragon with bamboo strips and clothes, raise them with rods, and hold the rods high and low to resemble a flying dragon.\n\nA performer...
[{"type": "stdin_stdout", "input": "200\n2 1 1 2 1 2 2 2 2 2 1 2 2 1 1 2 2 1 1 1 2 1 1 2 2 2 2 2 1 1 2 1 2 1 1 2 1 1 1 1 2 1 2 2 1 2 1 1 1 2 1 1 1 2 2 2 1 1 1 1 2 2 2 1 2 2 2 1 2 2 2 1 2 1 2 1 2 1 1 1 1 2 2 2 1 1 2 1 2 1 2 1 2 2 1 1 1 2 2 2 2 1 2 2 2 1 1 1 1 2 1 1 1 2 2 1 2 1 2 2 2 1 2 1 2 1 2 1 2 2 2 1 2 2 2 1 1 1 1 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has a graph containing both directed (oriented) and undirected (non-oriented) edges. There can be multiple edges between a pair of vertices.\n\nVasya has picked a vertex s from the graph. Now Vasya wants to create t...
[{"type": "stdin_stdout", "input": "14 19 14\n2 5 7\n1 4 1\n2 9 8\n1 7 3\n2 14 2\n2 2 8\n2 6 7\n2 14 7\n1 7 8\n2 10 8\n2 11 10\n1 11 7\n2 3 13\n1 5 4\n1 14 8\n2 3 1\n2 6 1\n2 6 10\n2 8 1\n", "output": "13\n--+--+--+---+\n2\n++-++-++++++-\n"}, {"type": "stdin_stdout", "input": "10 20 10\n2 7 3\n1 7 9\n1 3 6\n2 8 3\n2 9 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.\n\nNumber a doesn't contain...
[{"type": "stdin_stdout", "input": "2717172350336955863014903670481525170997949309274087058935108848979319747543008692128164875210350026\n", "output": "2771723503355630149036704815251709979493092740870589351088489793197475430086921281648752103500261986\n"}, {"type": "stdin_stdout", "input": "982599565604028679312800604...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn Absurdistan, there are n towns (numbered 1 through n) and m bidirectional railways. There is also an absurdly simple road network — for each pair of different towns x and y, there is a bidirectional road between towns ...
[{"type": "stdin_stdout", "input": "4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "5 5\n4 2\n3 5\n4 5\n5 1\n1 2\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "4 5\n1 3\n2 1\n3 4\n4 2\n2 3\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "5 5\n2 5\n1 2\n1 4\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently, Tokitsukaze found an interesting game. Tokitsukaze had $n$ items at the beginning of this game. However, she thought there were too many items, so now she wants to discard $m$ ($1 \\le m \\le n$) special items o...
[{"type": "stdin_stdout", "input": "1000000000000000000 20 365\n31881893160049984 103938857870698567 103962228223609431 140762820261865064 175962215264653912 239086305245565642 354522451098745823 383839975876242372 443471287955807705 478923027151493682 511195154588214957 619570919279066139 677571312513476877 7058647976...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt is a holiday season, and Koala is decorating his house with cool lights! He owns $n$ lights, all of which flash periodically.\n\nAfter taking a quick glance at them, Koala realizes that each of his lights can be descri...
[{"type": "stdin_stdout", "input": "70\n0010011111011101101111000111101011010101000011000000010100010101010001\n3 1\n1 5\n3 1\n4 1\n3 3\n2 4\n2 1\n5 1\n2 4\n5 2\n5 2\n4 1\n2 5\n2 2\n4 2\n5 1\n1 2\n2 4\n3 1\n1 1\n5 3\n5 2\n3 5\n4 4\n2 1\n3 2\n1 3\n5 1\n3 4\n2 3\n1 5\n4 1\n2 2\n5 1\n3 3\n4 2\n1 4\n5 2\n1 2\n4 1\n1 4\n5 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet $s$ be some string consisting of symbols \"0\" or \"1\". Let's call a string $t$ a substring of string $s$, if there exists such number $1 \\leq l \\leq |s| - |t| + 1$ that $t = s_l s_{l+1} \\ldots s_{l + |t| - 1}$. L...
[{"type": "stdin_stdout", "input": "100 80\n", "output": "0000000000100000000001000000000010000000000100000000001000000000010000000000100000000001000000000010"}, {"type": "stdin_stdout", "input": "101 3\n", "output": "00000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000010"...
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\nAlyona has a tree with n vertices. The root of the tree is the vertex 1. In each vertex Alyona wrote an positive integer, in the vertex i she wrote a_{i}. Moreover, the girl wrote a positive integer to every edge of the t...
[{"type": "stdin_stdout", "input": "10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n1 1000000000\n2 1000000000\n3 1000000000\n4 1000000000\n5 1000000000\n6 1000000000\n7 1000000000\n8 1000000000\n9 1000000000\n", "output": "1 1 1 1 1 1 1 1 1 0\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA group of n friends enjoys playing popular video game Toda 2. There is a rating system describing skill level of each player, initially the rating of the i-th friend is r_{i}.\n\nThe friends decided to take part in the c...
[{"type": "stdin_stdout", "input": "2\n71 70\n", "output": "0\n71\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n11\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAtCoDeer the deer has N square tiles. The tiles are numbered 1 through N, and the number given to each tile is written on one side of the tile. Also, each corner of each tile is painted in one of the 1000 colors, which ar...
[{"type": "stdin_stdout", "input": "400\n196 345 527 695\n685 207 136 831\n303 497 409 762\n464 670 120 403\n867 799 702 490\n986 9 287 852\n519 89 617 973\n291 551 957 275\n329 210 75 744\n685 560 225 510\n568 429 313 112\n94 659 30 204\n51 891 791 326\n890 977 807 600\n203 468 753 791\n738 279 376 58\n377 694 954 955...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an unweighted tree with $n$ vertices. Recall that a tree is a connected undirected graph without cycles.\n\nYour task is to choose three distinct vertices $a, b, c$ on this tree such that the number of edges...
[{"type": "stdin_stdout", "input": "9\n9 2\n6 8\n4 1\n2 5\n1 9\n8 7\n3 6\n5 7\n", "output": "8 \n4 1 3\n"}, {"type": "stdin_stdout", "input": "9\n3 1\n7 4\n1 4\n1 8\n2 1\n2 6\n9 1\n1 5\n", "output": "5\n6 9 7\n"}, {"type": "stdin_stdout", "input": "9\n8 9\n6 2\n1 6\n1 4\n3 1\n9 1\n1 5\n1 7\n", "output": "5\n2 7 8\n"}, ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently you have received two positive integer numbers $x$ and $y$. You forgot them, but you remembered a shuffled list containing all divisors of $x$ (including $1$ and $x$) and all divisors of $y$ (including $1$ and $y...
[{"type": "stdin_stdout", "input": "128\n540 90 378 3780 270 35 180 15 6 14 20 3780 2520 140 1080 54 540 120 1890 15 420 840 20 756 10 126 42 54 36 14 216 8 168 210 60 7 63 2 216 21 30 189 28 135 2 630 21 30 60 1512 7560 70 5 12 40 7560 252 378 3 108 5 72 10 3 28 24 1 27 9 45 180 56 1260 945 1080 420 168 2520 18 70 1 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between problems C1 and C2 is that all values in input of problem C1 are distinct (this condition may be false for problem C2).\n\nYou are given a sequence $a$ consisting of $n$ integers.\n\nYou are ma...
[{"type": "stdin_stdout", "input": "93\n6 6 10 10 8 4 7 10 2 3 4 10 7 2 8 8 4 2 4 4 7 7 3 2 3 1 5 3 7 2 4 9 10 8 10 5 1 6 2 1 10 3 5 6 6 9 3 10 1 10 1 6 2 3 8 7 1 5 4 10 4 3 5 8 8 1 3 8 2 3 10 7 2 4 5 2 6 4 10 4 4 8 5 1 6 3 1 9 5 4 9 4 3\n", "output": "4\nRRLR\n"}, {"type": "stdin_stdout", "input": "89\n4 5 4 8 3 3 6 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence $a_1, a_2, \\dots, a_n$ consisting of $n$ integers.\n\nYou can choose any non-negative integer $D$ (i.e. $D \\ge 0$), and for each $a_i$ you can:\n\n add $D$ (only once), i. e. perform $a_i := a_...
[{"type": "stdin_stdout", "input": "100\n49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a white sheet of paper lying on a rectangle table. The sheet is a rectangle with its sides parallel to the sides of the table. If you will take a look from above and assume that the bottom left corner of the tabl...
[{"type": "stdin_stdout", "input": "347722 718484 584813 736820\n280059 317406 997137 588815\n388486 281361 399827 854715\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "623181 608349 717362 757936\n654173 174442 707580 812338\n649542 255816 917899 810891\n", "output": "YES\n"}, {"type": "stdin_stdout", "inp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's denote a function $f(x)$ in such a way: we add $1$ to $x$, then, while there is at least one trailing zero in the resulting number, we remove that zero. For example, $f(599) = 6$: $599 + 1 = 600 \\rightarrow 60 \\...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "91\n"}, {"type": "stdin_stdout", "input": "932415950\n", "output": "53\n"}, {"type": "stdin_stdout", "input": "987654321\n", "output": "46\n"}, {"type": "stdin_stdout", "input": "916073472\n", "output": "52\n"}, {"type": "stdin_stdout", "input": "999999999\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ friends who want to give gifts for the New Year to each other. Each friend should give exactly one gift and receive exactly one gift. The friend cannot give the gift to himself.\n\nFor each friend the value ...
[{"type": "stdin_stdout", "input": "148\n0 110 76 0 0 106 56 107 0 115 0 0 8 0 0 0 0 74 15 58 108 78 0 0 0 29 28 0 103 25 0 0 0 13 0 0 0 126 0 0 0 0 124 12 0 10 0 0 141 19 135 0 84 30 0 100 86 118 95 0 0 134 0 0 0 0 101 0 128 7 5 0 91 0 138 57 112 43 9 0 52 0 0 0 16 0 11 0 0 63 109 0 0 142 53 99 0 0 129 148 21 0 1 0 0 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a huge decimal number consisting of $n$ digits. It is guaranteed that this number has no leading zeros. Each digit of this number is either 0 or 1.\n\nYou may perform several (possibly zero) operations with ...
[{"type": "stdin_stdout", "input": "213 5 3\n111001111110111001101011111100010010011001000001111010110110011000100000101010111110010001111110001010011001101000000011111110101001101100100100110100000111111100010100011010010001011100111011000001110000111000101\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "107 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given three integers $a \\le b \\le c$.\n\nIn one move, you can add $+1$ or $-1$ to any of these integers (i.e. increase or decrease any number by one). You can perform such operation any (possibly, zero) number o...
[{"type": "stdin_stdout", "input": "10\n3351 6383 6479\n7051 9793 9929\n1 1061 9572\n5401 5401 5865\n9777 9987 9987\n3393 7229 9665\n8014 8533 8665\n9549 9917 9998\n3336 6686 9962\n5351 8201 9241\n", "output": "208\n3239 6478 6478\n2223\n4964 9928 9928\n7\n1 1063 9567\n464\n5401 5401 5401\n210\n9987 9987 9987\n2608\n32...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $a$ consisting of $n$ integer numbers.\n\nLet instability of the array be the following value: $\\max\\limits_{i = 1}^{n} a_i - \\min\\limits_{i = 1}^{n} a_i$.\n\nYou have to remove exactly one elem...
[{"type": "stdin_stdout", "input": "82\n53931 67166 20637 68570 4855 63080 53128 28375 54407 70564 46622 46903 32659 68966 20614 11381 51217 94774 90448 13368 51098 46518 15907 1090 44331 39269 17316 22813 66082 78034 58245 36364 45200 78881 4933 66406 58312 74413 94780 12718 61328 57754 75973 93986 26719 12938 21718 9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$.\n\nThere are three...
[{"type": "stdin_stdout", "input": "100 43\n76 77 1\n24 25 1\n2 3 1\n85 86 1\n49 50 1\n15 16 1\n30 31 1\n78 79 1\n54 55 1\n58 59 1\n17 18 1\n67 68 1\n21 22 1\n80 81 1\n35 36 1\n8 9 1\n83 84 1\n44 45 1\n62 63 1\n64 65 1\n72 73 1\n27 28 1\n56 57 1\n12 13 1\n40 41 1\n32 33 1\n52 53 1\n70 71 1\n97 98 1\n37 38 1\n87 88 1\n4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp plays \"Game 23\". Initially he has a number $n$ and his goal is to transform it to $m$. In one move, he can multiply $n$ by $2$ or multiply $n$ by $3$. He can perform any number of moves.\n\nPrint the number of ...
[{"type": "stdin_stdout", "input": "289777775 341477104\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "100000000 100000001\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "139999978 419999934\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "300000007 300000007\n", "output": "0\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's call an array good if there is an element in the array that equals to the sum of all other elements. For example, the array $a=[1, 3, 3, 7]$ is good because there is the element $a_4=7$ which equals to the sum $1 + ...
[{"type": "stdin_stdout", "input": "4\n500000 500000 1000000 1000000\n", "output": "2\n3 4 \n"}, {"type": "stdin_stdout", "input": "6\n4 7 1 1 1 1\n", "output": "5\n2 3 4 5 6 \n"}, {"type": "stdin_stdout", "input": "4\n2 1000000 1000000 14\n", "output": "0\n\n"}, {"type": "stdin_stdout", "input": "6\n16 4 4 4 4 16\n", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between the easy and the hard versions is constraints.\n\nA subsequence is a string that can be derived from another string by deleting some or no symbols without changing the order of the remaining sy...
[{"type": "stdin_stdout", "input": "100 1000000000000\ndjgykfqaywhkhpocyxcpvbiiouyielmighclnuopadzuvrirbecucwnzwahahagvfstbxxaednajfauscxwttiglbbxtomnnalcl\n", "output": "8854753825335\n"}, {"type": "stdin_stdout", "input": "100 1000000000\ngaoxttalzmmhfhjphaftcwnnhjotuyxcnzlhqoynmcfhhmpzumichrghshdmbtjxmkwegnajkbtfhgl...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an undirected unweighted connected graph consisting of $n$ vertices and $m$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.\n\nYour task is to find any spanning tre...
[{"type": "stdin_stdout", "input": "13 18 4\n12 10\n4 12\n13 12\n5 4\n13 8\n5 10\n1 8\n7 8\n10 3\n5 2\n9 8\n6 11\n12 1\n9 2\n11 1\n7 1\n5 1\n10 1\n", "output": "YES\n9 2\n10 5\n1 11\n1 8\n13 8\n4 12\n10 3\n5 4\n11 6\n7 1\n12 1\n8 9\n"}, {"type": "stdin_stdout", "input": "13 18 2\n4 5\n11 8\n10 8\n5 8\n2 12\n9 2\n3 9\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp is going to participate in the contest. It starts at $h_1:m_1$ and ends at $h_2:m_2$. It is guaranteed that the contest lasts an even number of minutes (i.e. $m_1 \\% 2 = m_2 \\% 2$, where $x \\% y$ is $x$ modulo...
[{"type": "stdin_stdout", "input": "10:00\n11:00\n", "output": "10:30\n"}, {"type": "stdin_stdout", "input": "11:10\n11:12\n", "output": "11:11\n"}, {"type": "stdin_stdout", "input": "01:02\n03:02\n", "output": "02:02\n"}, {"type": "stdin_stdout", "input": "00:00\n23:58\n", "output": "11:59\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\...
[{"type": "stdin_stdout", "input": "64\n", "output": "267\n"}, {"type": "stdin_stdout", "input": "16\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "24\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "32\n", "output": "51\n"}, {"type": "stdin_stdout", "input": "36\n", "output": "14\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given $n$ segments on a number line; each endpoint of every segment has integer coordinates. Some segments can degenerate to points. Segments can intersect with each other, be nested in each other or even coincide...
[{"type": "stdin_stdout", "input": "6\n2 4\n3 5\n2 5\n1 6\n2 4\n3 6\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "6\n6 6\n3 4\n3 5\n4 5\n1 2\n5 6\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "6\n2 4\n3 6\n2 6\n2 5\n1 4\n1 4\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "6\n1 5\n1 4\n1 6\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. Now it's totally up to Vova to put the finishing touches.\n\nThe current state of ...
[{"type": "stdin_stdout", "input": "20\n10 5 2 3 5 7 7 9 4 9 9 4 9 7 7 5 3 2 5 10\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "14\n7 7 7 4 3 3 4 5 4 4 5 7 7 7\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "13\n5 2 2 1 1 2 5 2 1 1 2 2 5\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between the easy and the hard versions is constraints.\n\nA subsequence is a string that can be derived from another string by deleting some or no symbols without changing the order of the remaining sy...
[{"type": "stdin_stdout", "input": "100 100\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "4950\n"}, {"type": "stdin_stdout", "input": "100 100\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\n", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMasha has $n$ types of tiles of size $2 \\times 2$. Each cell of the tile contains one integer. Masha has an infinite number of tiles of each type.\n\nMasha decides to construct the square of size $m \\times m$ consisting...
[{"type": "stdin_stdout", "input": "6\n3 4\n1 2\n5 6\n5 7\n7 4\n8 9\n9 8\n2 5\n1 1\n1 1\n2 2\n2 2\n1 100\n10 10\n10 10\n1 2\n4 5\n8 4\n2 2\n1 1\n1 1\n1 2\n3 4\n1 2\n1 1\n1 1\n", "output": "YES\nNO\nYES\nNO\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "1\n8 2\n3 5\n10 7\n3 3\n7 9\n5 9\n7 4\n6 8\n3 8\n7 6\n1 6\n5 7\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer sequence $1, 2, \\dots, n$. You have to divide it into two sets $A$ and $B$ in such a way that each element belongs to exactly one set and $|sum(A) - sum(B)|$ is minimum possible.\n\nThe value $|x...
[{"type": "stdin_stdout", "input": "2000000000\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1999999999\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1999999997\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1999999998\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1000271094\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a bracket sequence $s$ (not necessarily a regular one). A bracket sequence is a string containing only characters '(' and ')'.\n\nA regular bracket sequence is a bracket sequence that can be transformed into...
[{"type": "stdin_stdout", "input": "100\n()()))(()()))))((()()))))(()()(()())()))))()())()()((((()(()()((())))((()()())())(())((()((()))(((()(()))))))())))((((()())))(()(()(())))(()))()()())((())()((())(()(((()((())))())))()()()((()))()()())\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "100\n(()(()()()((()((...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given $n$ strings. Each string consists of lowercase English letters. Rearrange (reorder) the given strings in such a way that for every string, all strings that are placed before it are its substrings.\n\nString ...
[{"type": "stdin_stdout", "input": "5\na\naba\nabacaba\nba\naba\n", "output": "YES\na\nba\naba\naba\nabacaba\n"}, {"type": "stdin_stdout", "input": "3\nqwerty\nqwerty\nqwerty\n", "output": "YES\nqwerty\nqwerty\nqwerty\n"}, {"type": "stdin_stdout", "input": "3\nababc\nabababc\nab\n", "output": "YES\nab\nababc\nabababc\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is an infinite board of square tiles. Initially all tiles are white.\n\nVova has a red marker and a blue marker. Red marker can color $a$ tiles. Blue marker can color $b$ tiles. If some tile isn't white then you can...
[{"type": "stdin_stdout", "input": "99999999999973 99999999999971\n", "output": "199999999999948\n"}, {"type": "stdin_stdout", "input": "99999999999962 99999999999973\n", "output": "133333333333296\n"}, {"type": "stdin_stdout", "input": "99999999999973 99999999999930\n", "output": "399999999999808\n"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFind the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.)\nHe...
[{"type": "stdin_stdout", "input": "80 100\n", "output": "1000\n"}, {"type": "stdin_stdout", "input": "68 85\n", "output": "850\n"}, {"type": "stdin_stdout", "input": "24 30\n", "output": "300\n"}, {"type": "stdin_stdout", "input": "25 32\n", "output": "320\n"}, {"type": "stdin_stdout", "input": "27 34\n", "output": "3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp has to solve exactly $n$ problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in $k$ days. It means tha...
[{"type": "stdin_stdout", "input": "849600011 46\n", "output": "YES\n18469542 18469543 18469545 18469546 18469547 18469548 18469549 18469550 18469551 18469552 18469553 18469554 18469555 18469556 18469557 18469558 18469559 18469560 18469561 18469562 18469563 18469564 18469565 18469566 18469567 18469568 18469569 18469570...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version.\n\nPolycarp is a very famous freelancer. His current rating is $r$...
[{"type": "stdin_stdout", "input": "50 15000\n142 -300\n20 -298\n560 -300\n1815 -292\n282 -297\n92 -293\n34 -284\n555 -299\n408 -293\n504 -284\n278 -284\n139 -291\n64 -298\n311 -293\n130 -293\n89 -298\n129 -294\n385 -295\n136 -288\n41 -293\n112 -290\n416 -295\n178 -294\n154 -300\n110 -300\n346 -299\n209 -294\n1394 -295...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.\n\nFor example, the followi...
[{"type": "stdin_stdout", "input": "13\n1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5 6 6 6 6 7 7 7 7 8 8 8 8 9 9 9 9 10 10 10 10 11 11 11 11 12 12 12 12 13 13 13 13 14 14 14 14 15 15 15 15 16 16 16 16 17 17 17 17 18 18 18 18 19 19 19 19 20 20 20 20 21 21 21 21 22 22 22 22 23 23 23 23 24 24 24 24 25 25 25 25 26 26 26 26 27 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version.\n\nPolycarp is a very famous freelancer. His current rating is $r$...
[{"type": "stdin_stdout", "input": "58 168\n25 -3\n70 -3\n169 2\n182 -4\n183 2\n178 4\n14 2\n18 0\n167 3\n8 4\n215 -4\n146 -3\n229 1\n27 3\n88 3\n202 4\n208 3\n33 2\n161 -4\n87 -1\n115 0\n175 2\n220 -4\n119 3\n188 -4\n50 1\n71 -2\n118 4\n55 1\n55 -4\n144 0\n66 -3\n90 -2\n147 3\n83 0\n111 -2\n10 1\n106 4\n117 -1\n43 3\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a river of width $n$. The left bank of the river is cell $0$ and the right bank is cell $n + 1$ (more formally, the river can be represented as a sequence of $n + 2$ cells numbered from $0$ to $n + 1$). There are...
[{"type": "stdin_stdout", "input": "93 66 2\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 3 21\n", "output": "YES\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is the length of the string.\n\nYou are given a string $s$ and a string $t$, both consisting only of lowercase Latin letters. It is guaranteed that $t$ can be obtained fr...
[{"type": "stdin_stdout", "input": "izoiweukqszkkhwapzxyotbaarpqxbybsjxilhylbbjbvoedrezyluaabsfzvtxxvncdwxrlfdtfvbfoqwlzqwneimwzpoygfdcldmxdhoxzensxlspituzocvzzrfomhggrwurdccgfoorvhyzsdkpjhwakuoxwdjhzaalanyzwuuqwlrtmvmdraleyusjqdyxuztvc\nizoiweukqszkkhwapzxyotbaarpqxbybsjxilhylbbjbvoedrezyluaabsfzvtxxvncdwxrlfdtfvbfoqw...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n$\\text{A}$ \n\n\n-----Input-----\n\nThe input contains a single floating-point number x with exactly 6 decimal places (0 < x < 5).\n\n\n-----Output-----\n\nOutput two integers separated by a single space. Each integer sh...
[{"type": "stdin_stdout", "input": "4.472136\n", "output": "10 10\n"}, {"type": "stdin_stdout", "input": "2.572479\n", "output": "10 3\n"}, {"type": "stdin_stdout", "input": "0.499376\n", "output": "1 10\n"}, {"type": "stdin_stdout", "input": "1.483405\n", "output": "3 10\n"}, {"type": "stdin_stdout", "input": "3.12347...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given three integers $n$, $d$ and $k$.\n\nYour task is to construct an undirected tree on $n$ vertices with diameter $d$ and degree of each vertex at most $k$, or say that it is impossible.\n\nAn undirected tree i...
[{"type": "stdin_stdout", "input": "26 5 4\n", "output": "YES\n2 13\n2 10\n25 10\n1 25\n1 12\n26 10\n10 22\n5 25\n25 16\n19 2\n2 6\n15 1\n14 1\n24 26\n26 17\n7 26\n4 22\n22 21\n18 22\n9 5\n5 20\n23 5\n11 16\n3 16\n16 8\n"}, {"type": "stdin_stdout", "input": "22 6 3\n", "output": "YES\n2 13\n10 2\n10 3\n1 3\n12 1\n12 8\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two strings $s$ and $t$ both of length $2$ and both consisting only of characters 'a', 'b' and 'c'.\n\nPossible examples of strings $s$ and $t$: \"ab\", \"ca\", \"bb\".\n\nYou have to find a string $res$ con...
[{"type": "stdin_stdout", "input": "100\nab\nac\n", "output": "YES\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
code_stdio