messages listlengths 1 1 | ground_truth stringlengths 88 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMatryoshka\n\nMatryoshka is a famous Russian folk craft doll. Matryoshka can be divided into upper and lower parts, and when opened, there is another smaller doll inside. The nesting structure is such that when the small ... | [{"type": "stdin_stdout", "input": "2\n1 4 6\n4 2 3\n3\n2 5 2\n3 3 4\n5 5 10\n1\n1 1 2\n2 2 0\n3 3 1\n4 4 4\n5 10 14\n4\n2 1 0\n2 1 1\n3 1 1\n3 1 1\n5 1 1\n10\n3 1 4\n1 5 9\n3 6 7\n3 5 8\n9 7 9\n3 2 0\n8 2 5\n2 6 4\n3 2 8\n3 2 7\n0", "output": "48\n270\n2\n12\n312\n3\n5\n860\n"}, {"type": "stdin_stdout", "input": "2\n1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nCutlet Sandwich\n\nIn some worlds, there are $ X $ types of \"sandwiches\", $ Y $ types of \"cutlets\", and $ Z $ types of \"curry\" foods.\n\nThere is a $ N $ type of \"cutlet sandwich\" in this world, and the $ i $ type... | [{"type": "stdin_stdout", "input": "17 3 1 1 1 1 1\n2 -1\n1 1", "output": "-1\n"}, {"type": "stdin_stdout", "input": "29 3 1 1 1 1 1\n2 -1\n1 1", "output": "-1\n"}, {"type": "stdin_stdout", "input": "5 1 1 1 1 1 1\n2 -1\n2 1", "output": "-1\n"}, {"type": "stdin_stdout", "input": "5 3 1 1 1 1 1\n2 -1\n1 1", "output": "-... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nConstraints\n\n* 1 β€ |V| β€ 1000\n* 0 β€ |E| β€ 2000\n* -10000 β€ di β€ 10000\n* There are no parallel edges\n* There are no self-loops\n\nInput\n\nAn edge-weighted graph G (V, E) and the source r.\n\n\n|V| |E| r\ns0 t0 d0\ns1... | [{"type": "stdin_stdout", "input": "42 0 1\n2 -1 3\n0 5 55\n1 0 -2\n-2 0 1\n2 4 -1", "output": "INF\n0\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\nINF\n"}, {"type": "st... | 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 β€ l_i β€ r_i β€ n) was se... | [{"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\n199989 199989 199989 199989 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are n pillars aligned in a row and numbered from 1 to n.\n\nInitially each pillar contains exactly one disk. The i-th pillar contains a disk having radius a_i.\n\nYou can move these disks from one pillar to another.... | [{"type": "stdin_stdout", "input": "100\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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPetya's friends made him a birthday present β a bracket sequence. Petya was quite disappointed with his gift, because he dreamed of correct bracket sequence, yet he told his friends nothing about his dreams and decided to... | [{"type": "stdin_stdout", "input": "500\n()))))()()(()((((())))((((()()((()))))))((()())))()(()(()))()()()))())))()))))))(()()(()((()))()(((()(()(()())(((())()((()((()((())(()()()(()(()())(()(((((((((()))(()()()))))())((()()))))()(((()()()((((((()()()()()(())))))((((((())(()()())(((((((((((()(()))()(((()))())))))))((()... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRecall that a binary search tree is a rooted binary tree, whose nodes each store a key and each have at most two distinguished subtrees, left and right. The key in each node must be greater than any key stored in the left... | [{"type": "stdin_stdout", "input": "1000000\n", "output": "0"}, {"type": "stdin_stdout", "input": "908995\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "365825\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "123856\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "265206\n", "output": "0\n"}, ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSanta Claus has received letters from n different kids throughout this year. Of course, each kid wants to get some presents from Santa: in particular, the i-th kid asked Santa to give them one of k_i different items as a ... | [{"type": "stdin_stdout", "input": "10\n5 48258 84644 992412 548310 132019\n5 132019 556600 548310 94345 992412\n6 132019 771663 523582 548310 463969 556600\n7 556600 132019 992412 523582 548310 70239 84644\n4 504172 548310 523582 286042\n7 548310 84644 771663 556600 132019 463969 48258\n5 556600 771663 463969 523582 8... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAnna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each... | [{"type": "stdin_stdout", "input": "96 70\n30 37\n47 56\n19 79\n15 28\n2 43\n43 54\n59 75\n42 22\n38 18\n18 14\n47 41\n60 29\n35 11\n90 4\n14 41\n11 71\n41 24\n68 28\n45 92\n14 15\n34 63\n77 32\n67 38\n36 8\n37 4\n58 95\n68 84\n69 81\n35 23\n56 63\n78 91\n35 44\n66 63\n80 19\n87 88\n28 14\n62 35\n24 23\n83 37\n54 89\n1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDenis, after buying flowers and sweets (you will learn about this story in the next task), went to a date with Nastya to ask her to become a couple. Now, they are sitting in the cafe and finally... Denis asks her to be to... | [{"type": "stdin_stdout", "input": "10 10\n1101001\n0110000\n0111010\n0010000\n1010000\n0111000\n1011011\n1010010\n1101011\n1111110\n", "output": "9941743758\n"}, {"type": "stdin_stdout", "input": "10 10\n0101111\n0000000\n1111011\n1011011\n1011011\n1111011\n0010010\n1010010\n1101111\n0000000\n", "output": "8993391761\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA permutation of length n is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4... | [{"type": "stdin_stdout", "input": "3\n2\n1 2\n6\n0 0 3 10 4 3\n5\n3 6 3 1 10\n", "output": "2 1\n3 4 10 3 0 0\n10 1 3 6 3\n"}, {"type": "stdin_stdout", "input": "3\n2\n1 2\n6\n0 1 10 5 4 3\n5\n2 6 3 1 10\n", "output": "2 1\n3 4 5 10 1 0\n10 1 3 6 2\n"}, {"type": "stdin_stdout", "input": "3\n2\n1 2\n6\n0 1 10 5 4 3\n5\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nInitially, you have the array a consisting of one element 1 (a = [1]).\n\nIn one move, you can do one of the following things:\n\n * Increase some (single) element of a by 1 (choose some i from 1 to the current length of... | [{"type": "stdin_stdout", "input": "5\n1\n13\n42\n2538\n1000000000\n", "output": "0\n6\n11\n99\n63244\n"}, {"type": "stdin_stdout", "input": "5\n1\n10\n143\n255\n1000000000\n", "output": "0\n5\n22\n30\n63244\n"}, {"type": "stdin_stdout", "input": "5\n1\n13\n143\n751\n1000001000\n", "output": "0\n6\n22\n53\n63244\n"}, {... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe Super Duper Secret Meeting of the Super Duper Secret Military Squad takes place in a Super Duper Secret Place. The place is an infinite plane with introduced Cartesian coordinate system. The meeting table is represent... | [{"type": "stdin_stdout", "input": "-565 -444 -419 -421\n30\n363 -249 790\n704 57 999\n-316 -305 119\n-778 -543 373\n-589 466 190\n516 -174 893\n-742 -662 390\n-382 825 1000\n520 -732 909\n-220 -985 555\n-49 -697 396\n-701 -882 520\n-105 227 691\n-113 -470 231\n-503 98 1088\n236 69 759\n150 393 951\n414 381 1000\n1096 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet's define a multiplication operation between a string a and a positive integer x: a β
x is the string that is a result of writing x copies of a one after another. For example, \"abc\" β
~2~= \"abcabc\", \"a\" β
~5~= \"aa... | [{"type": "stdin_stdout", "input": "13\na\na\na\na\na\na\na\na\na\na\na\na\nb\na\na\na\na\na\na\na\na\na\na\na\nb\na\n", "output": "a\na\na\na\na\na\n-1\na\na\na\na\na\n-1\n"}, {"type": "stdin_stdout", "input": "13\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\nb\na\n", "output": "a\na\na\na\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a string s of length n consisting only of the characters 0 and 1.\n\nYou perform the following operation until the string becomes empty: choose some consecutive substring of equal characters, erase it from t... | [{"type": "stdin_stdout", "input": "3\n3 2 -1\n010\n5 -2 5\n01001\n6 -1 -12\n110111\n", "output": "4\n15\n-30\n"}, {"type": "stdin_stdout", "input": "3\n3 3 -1\n010\n5 -2 5\n01001\n6 -1 -12\n110111\n", "output": "7\n15\n-30\n"}, {"type": "stdin_stdout", "input": "3\n3 3 -2\n011\n5 -2 5\n01001\n6 -1 -12\n110111\n", "out... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given two polynomials:\n\n * P(x) = a0Β·xn + a1Β·xn - 1 + ... + an - 1Β·x + an and \n * Q(x) = b0Β·xm + b1Β·xm - 1 + ... + bm - 1Β·x + bm. \n\n\n\nCalculate limit <image>.\n\nInput\n\nThe first line contains two space... | [{"type": "stdin_stdout", "input": "69 69\n-7 38 -3 -22 65 -78 -65 -99 -76 63 0 -4 -78 -51 54 -61 -53 60 80 34 -96 162 -78 -96 21 -10 -86 33 -9 -81 -19 -2 -76 -3 -66 -80 -55 -21 -50 37 -86 -37 47 44 76 -39 54 -25 41 -86 -3 -25 -67 94 18 67 27 -5 -30 -69 2 -76 7 -97 -52 -35 -55 -20 92 2\n90 -94 37 41 -27 -54 96 -15 -60 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters Β«+Β» and Β«1Β» into this sequence. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, whil... | [{"type": "stdin_stdout", "input": "))())))))))())))))()()))()()))))())))))()))))))))))))(()))())(()))))(()))))())))((((()()))))()))()))\n", "output": "48\n"}, {"type": "stdin_stdout", "input": ")))()))()))))()((((())))()))))(()))))(())()))(()))))))))))))())))))()))))()()))()())))))())))))))())\n", "output": "48\n"}, {... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIahub has drawn a set of n points in the cartesian plane which he calls \"special points\". A quadrilateral is a simple polygon without self-intersections with four sides (also called edges) and four vertices (also called... | [{"type": "stdin_stdout", "input": "50\n-768 -243\n-741 -984\n-370 213\n-808 571\n-726 442\n234 452\n-105 -990\n-876 -278\n987 473\n-968 -531\n-274 -842\n259 -655\n-59 -555\n976 -396\n878 -85\n551 213\n675 599\n-990 -507\n1 48\n-147 919\n-218 798\n-191 928\n916 263\n-975 169\n567 -967\n394 16\n-224 915\n280 -613\n804 -... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA group of n schoolboys decided to ride bikes. As nobody of them has a bike, the boys need to rent them.\n\nThe renting site offered them m bikes. The renting price is different for different bikes, renting the j-th bike ... | [{"type": "stdin_stdout", "input": "40 40 61\n28 59 8 27 45 67 33 32 61 3 29 2 3 37 8 8 10 61 1 2 65 28 34 27 8 35 45 49 30 49 10 23 23 53 20 48 14 74 16 6\n69 56 34 66 42 73 45 49 29 70 26 77 73 26 78 11 50 69 64 72 78 66 66 29 80 40 50 75 58 47 78 113 41 70 52 52 69 22 69 66\n", "output": "23 960\n"}, {"type": "stdin... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGeorge is a cat, so he really likes to play. Most of all he likes to play with his array of positive integers b. During the game, George modifies the array by using special changes. Let's mark George's current array as b1... | [{"type": "stdin_stdout", "input": "69756649467079322827497669450385938193725265564551073376856848456377282337192553343102536673046067874193973249293390979688852602950724884726382282903675659200865787042684264196306648305545290076062924087939978017987667847105325657080274323400258982046115892228300171243907466293917094... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPasha has a positive integer a without leading zeroes. Today he decided that the number is too small and he should make it larger. Unfortunately, the only operation Pasha can do is to swap two adjacent decimal digits of t... | [{"type": "stdin_stdout", "input": "1541326723729813719 14\n", "output": "9541132672372813719\n"}, {"type": "stdin_stdout", "input": "191919191919119911 100\n", "output": "999999991111111111\n"}, {"type": "stdin_stdout", "input": "219810011901120912 100\n", "output": "999822211111110000\n"}, {"type": "stdin_stdout", "i... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOne day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be ... | [{"type": "stdin_stdout", "input": "A>B\nC<B\nA>C\n", "output": "Impossible\n"}, {"type": "stdin_stdout", "input": "A<B\nB>C\nC>A\n", "output": "Impossible\n"}, {"type": "stdin_stdout", "input": "A>B\nC<B\nC;tg&A\n", "output": "Impossible\n"}, {"type": "stdin_stdout", "input": "A<:B\nB>C\nC... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet's define the sum of two permutations p and q of numbers 0, 1, ..., (n - 1) as permutation <image>, where Perm(x) is the x-th lexicographically permutation of numbers 0, 1, ..., (n - 1) (counting from zero), and Ord(p)... | [{"type": "stdin_stdout", "input": "84\n83 4 68 34 24 2 48 38 22 51 5 62 31 67 66 53 49 70 9 71 46 41 30 8 50 17 28 79 15 80 32 43 14 74 29 42 81 60 56 65 23 0 77 76 58 78 1 11 37 27 75 35 18 73 54 20 57 33 36 6 61 69 64 55 39 10 3 45 13 26 59 82 21 25 63 52 16 44 47 72 19 12 7 40\n63 41 80 52 36 45 17 69 22 66 37 21 4... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are many anime that are about \"love triangles\": Alice loves Bob, and Charlie loves Bob as well, but Alice hates Charlie. You are thinking about an anime which has n characters. The characters are labeled from 1 to... | [{"type": "stdin_stdout", "input": "28567 13\n28079 24675 1\n18409 26720 1\n980 10815 1\n20794 16571 1\n7376 19861 1\n11146 706 1\n4255 16391 1\n27376 18263 1\n10019 28444 1\n6574 28053 1\n5036 16610 1\n3543 7122 1\n512 9554 1\n", "output": " 928433852\n"}, {"type":... | 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\n3 4\n3 4\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "4 6\n1 2\n1 1\n1 4\n2 3\n2 4\n3 4\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "4 6\n1 4\n1 1\n1 4\n2 3\n2 4\n3 4\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "4 6\n1 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA MIPT student named Misha has a birthday today, and he decided to celebrate it in his country house in suburban Moscow. n friends came by, and after a typical party they decided to play blind man's buff.\n\nThe birthday ... | [{"type": "stdin_stdout", "input": "100\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "51614.556434047350\n"}, {"type": "stdin_stdout", "input": "99\n1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn an attempt to escape the Mischievous Mess Makers' antics, Farmer John has abandoned his farm and is traveling to the other side of Bovinia. During the journey, he and his k cows have decided to stay at the luxurious Gr... | [{"type": "stdin_stdout", "input": "491 172\n01111101111111100000111010110001010001110111000010101111101000100010010111011101110110111101101010111000111000011100011010010010111111000011011010100110001000011100111000001011100010001111101111101000111001100110010100101000001110010100100100100101001100010101001000010000111... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nEvery year, hundreds of people come to summer camps, they learn new algorithms and solve hard problems.\n\nThis is your first year at summer camp, and you are asked to solve the following problem. All integers starting wi... | [{"type": "stdin_stdout", "input": "1000\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "942\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "952\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "191\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "289\n", "output": "1\n"}, {"type": "std... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nEfim just received his grade for the last test. He studies in a special school and his grade can be equal to any positive decimal fraction. First he got disappointed, as he expected a way more pleasant result. Then, he de... | [{"type": "stdin_stdout", "input": "320 142\n2704701300865535.432223312233434114130011113220102420131323010344144201124303144444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444447444444444444444444444444444444615444444482101673308979557675074444444444444446... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya plays The Elder Trolls IV: Oblivon. Oh, those creators of computer games! What they do not come up with! Absolutely unique monsters have been added to the The Elder Trolls IV: Oblivon. One of these monsters is Unkil... | [{"type": "stdin_stdout", "input": "1000000 1000000 1000000 1000000000\n", "output": "1000000000000000000\n"}, {"type": "stdin_stdout", "input": "1000000 1000000 1001000 1000000000\n", "output": "1001000000000000000\n"}, {"type": "stdin_stdout", "input": "1000000 1000000 1011000 1000000000\n", "output": "10110000000000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRick and Morty are playing their own version of Berzerk (which has nothing in common with the famous Berzerk game). This game needs a huge space, so they play it with a computer.\n\nIn this game there are n objects number... | [{"type": "stdin_stdout", "input": "7000\n7 419 1631 1925 3861 6940 379 493\n29 5389 5925 2923 4696 972 6125 3779 6044 5477 1305 6488 5059 5515 3238 3863 248 6947 4023 6168 1915 6607 2991 2220 2023 200 4457 6398 1017 447\n", "output": "Loop Loop Loop Loop Loop Loop Loop Loop Loop Loop Loop Loop Loop Loop Loop Loop Loop... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIt's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends.\n\nToday he invented one simple game to play with Lena, with w... | [{"type": "stdin_stdout", "input": "545668929424440387 508692735816921376\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "251656215122324104 164397544865601257\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "669038685745448997 501718093668307460\n", "output": "YES\n"}, {"type": "stdin_stdout", "in... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSlava plays his favorite game \"Peace Lightning\". Now he is flying a bomber on a very specific map.\n\nFormally, map is a checkered field of size 1 Γ n, the cells of which are numbered from 1 to n, in each cell there can... | [{"type": "stdin_stdout", "input": "11124\n", "output": "16686\n2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 122 124 126 128 130 132 134 136 138 140 142 144 146 148 150 152 154 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nCount the number of distinct sequences a1, a2, ..., an (1 β€ ai) consisting of positive integers such that gcd(a1, a2, ..., an) = x and <image>. As this number could be large, print the answer modulo 109 + 7.\n\ngcd here m... | [{"type": "stdin_stdout", "input": "495219 444706662\n", "output": "115165527\n"}, {"type": "stdin_stdout", "input": "34601 35742833\n", "output": "60054095\n"}, {"type": "stdin_stdout", "input": "524 991033864\n", "output": "172439543\n"}, {"type": "stdin_stdout", "input": "225 315096300\n", "output": "413133630\n"}, ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDima is a beginner programmer. During his working process, he regularly has to repeat the following operation again and again: to remove every second element from the array. One day he has been bored with easy solutions o... | [{"type": "stdin_stdout", "input": "15 12\n2\n10\n5\n2\n8\n2\n8\n6\n4\n10\n12\n1\n", "output": "12\n13\n3\n12\n10\n12\n10\n14\n9\n13\n11\n1\n"}, {"type": "stdin_stdout", "input": "15 12\n9\n10\n5\n2\n8\n2\n8\n6\n4\n10\n12\n1\n", "output": "5\n13\n3\n12\n10\n12\n10\n14\n9\n13\n11\n1\n"}, {"type": "stdin_stdout", "input"... | 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 values ... | [{"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\nMishka started participating in a programming contest. There are n problems in the contest. Mishka's problem-solving skill is equal to k.\n\nMishka arranges all problems from the contest into a list. Because of his weird ... | [{"type": "stdin_stdout", "input": "100 90\n90 90 90 90 90 90 55 21 90 90 90 90 90 90 90 90 90 90 69 83 90 90 90 90 90 90 90 90 93 95 92 98 92 97 91 92 92 91 91 95 94 95 100 100 96 97 94 93 90 90 95 95 97 99 90 95 98 91 94 96 99 99 94 95 95 97 99 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 12 9... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nNaruto is a fan of numbers, he likes to play with them. This time he decided to multiply numbers and produce output. After every k elements he decides to find x^m, where x is the multiplication till k elements and m is a ... | [{"type": "stdin_stdout", "input": "2\n3 2 6 4\n1 2 3 4 9\n7 1 2 5\n0 2 -1 -1 6\n\nSAMPLE", "output": "0\n0\n"}, {"type": "stdin_stdout", "input": "2\n5 2 3 5\n1 2 1 6 11\n5 2 0 5\n1 2 1 9 6\n\nSAMPLE", "output": "2\n1\n"}, {"type": "stdin_stdout", "input": "2\n10 2 2 5\n1 0 3 1 9\n5 2 1 5\n1 3 3 2 6\n\nSAMPME", "outpu... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAfter Joeffrey chocked to death, Cercei blamed Tyrian for his death. After seeing his love, Shae betrayed him, he demanded trial by combat. Now this combat is not with swords but with logic and problem solving. Tywin will... | [{"type": "stdin_stdout", "input": "293\n20 6005\n1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n56 1362\n1 0 0 1 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n2 4237\n1 1\n17 410\n0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n22 2366\n1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nShil is your new boss and he likes palindromes very much. Palindrome is a string that can be read the same way in either direction, from the left to the right and from the right to the left. (ex. madam , aabaa, racecar) ... | [{"type": "stdin_stdout", "input": "yvqszlrqoxkfaupflahrnwygzetlwynhxalauuzhaaeoxzkyroertpxdwxlngzfoxregqxqhgmoklururjaetlwwnsggpyarhrxwgfaqhoecwrwwaewfsnwuaeurualuytawoeuaowtulstcumwntegoxjjsuptrjvbaouygwahnzdbnxsexdwtlngcxaxtbnrfqgrblxqntqnmeqtqwaalzjgqgoellzxlylnjqoaydqgprvaezoremrlghjaoobeysywoouzjzhwhexezcakesevlv... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn this problem, we use the 24-hour clock.\n\nTakahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study for K consecutive... | [{"type": "stdin_stdout", "input": "17 -4 435 10 -1", "output": "25095\n"}, {"type": "stdin_stdout", "input": "17 -4 722 10 -1", "output": "42315\n"}, {"type": "stdin_stdout", "input": "-1 -3 436 11 -1", "output": "26235\n"}, {"type": "stdin_stdout", "input": "-1 -3 239 11 -1", "output": "14415\n"}, {"type": "stdin_std... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven is a positive integer N.\nFind the number of pairs (A, B) of positive integers not greater than N that satisfy the following condition:\n\n* When A and B are written in base ten without leading zeros, the last digit... | [{"type": "stdin_stdout", "input": "141750", "output": "200930633\n"}, {"type": "stdin_stdout", "input": "200000", "output": "400000008"}, {"type": "stdin_stdout", "input": "3437", "output": "118300\n"}, {"type": "stdin_stdout", "input": "3093", "output": "95976\n"}, {"type": "stdin_stdout", "input": "1020", "output": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}.\n\nLet B be a sequence of K \\times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2.\n\nFind t... | [{"type": "stdin_stdout", "input": "10 998244353\n10 10 10 9 5 12 0 4 7 0", "output": "559205848\n"}, {"type": "stdin_stdout", "input": "10 1051516890\n10 15 10 1 5 4 0 8 4 0", "output": "142815647\n"}, {"type": "stdin_stdout", "input": "10 918571889\n10 9 10 7 7 3 0 11 4 0", "output": "551061978\n"}, {"type": "stdin_s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn some other world, today is the day before Christmas Eve.\n\nMr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \\leq i \\leq N) is p_i yen (the currency of Japan).\n\nHe has a dis... | [{"type": "stdin_stdout", "input": "4\n4320\n7204\n4320\n4320", "output": "16562\n"}, {"type": "stdin_stdout", "input": "4\n7514\n7204\n4320\n4320", "output": "19601\n"}, {"type": "stdin_stdout", "input": "4\n4320\n3600\n4320\n4320", "output": "14400\n"}, {"type": "stdin_stdout", "input": "4\n7514\n7204\n4821\n4320", "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have a permutation of the integers from 1 through N, p_1, p_2, .., p_N. We also have M pairs of two integers between 1 and N (inclusive), represented as (x_1,y_1), (x_2,y_2), .., (x_M,y_M). AtCoDeer the deer is going t... | [{"type": "stdin_stdout", "input": "10 8\n10 3 6 8 7 10 9 1 2 4\n2 1\n4 1\n5 9\n4 2\n6 2\n3 5\n8 9\n7 9", "output": "2\n"}, {"type": "stdin_stdout", "input": "10 8\n10 3 6 8 7 10 9 1 2 4\n2 1\n3 1\n5 9\n4 2\n6 2\n3 5\n8 9\n7 9", "output": "7\n"}, {"type": "stdin_stdout", "input": "10 8\n10 3 6 8 7 10 9 1 2 4\n2 1\n4 1\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSnuke is buying a lamp. The light of the lamp can be adjusted to m levels of brightness, represented by integers from 1 through m, by the two buttons on the remote control.\n\nThe first button is a \"forward\" button. Whe... | [{"type": "stdin_stdout", "input": "4 32\n13 18 1 14 1 14 4 0 1 1", "output": "19\n"}, {"type": "stdin_stdout", "input": "7 19\n2 17 6 18 2 14 4 0 4 1", "output": "30\n"}, {"type": "stdin_stdout", "input": "4 19\n15 6 10 13 2 14 3 3 3 1", "output": "8\n"}, {"type": "stdin_stdout", "input": "4 19\n15 6 10 2 0 14 3 2 6 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\n<image>\n\n\nThere used to be a game called Joseph's potatoes. Let's say n people are participating. Participants form a circle facing the center and are numbered starting from 1. One hot potato is given to participant n ... | [{"type": "stdin_stdout", "input": "44 3\n45 10\n0 0", "output": "40\n33\n"}, {"type": "stdin_stdout", "input": "75 2\n16 14\n0 0", "output": "23\n10\n"}, {"type": "stdin_stdout", "input": "18 3\n45 10\n0 0", "output": "14\n33\n"}, {"type": "stdin_stdout", "input": "26 3\n45 10\n0 0", "output": "17\n33\n"}, {"type": "s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAt Aizu Riverside Hospital, inpatients walk twice a day for rehabilitation and health promotion. As the number of people trying to recover their physical strength by walking is increasing day by day in order to leave the ... | [{"type": "stdin_stdout", "input": "5\n263 1519 1817\n2 1240 1985\n11656 1896 4132\n10001 503 3107\n51 1421 2690\n3\n345 1628 2181\n7 3910 1590\n5982 2525 3616\n0", "output": "11656 6028\n5982 6141\n"}, {"type": "stdin_stdout", "input": "5\n263 1519 1817\n2 1240 1985\n11656 1896 4132\n10001 503 3107\n51 1421 2690\n3\n3... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPlease find the greatest common divisor of two natural numbers. A clue is: The Euclid's algorithm is a way to resolve this task.\n\n\n\nInput\n\nThe input file consists of several lines with pairs of two natural numbers i... | [{"type": "stdin_stdout", "input": "010 90\n11 496", "output": "10\n1\n"}, {"type": "stdin_stdout", "input": "102 24\n101 116", "output": "6\n1\n"}, {"type": "stdin_stdout", "input": "110 103\n30 10", "output": "1\n10\n"}, {"type": "stdin_stdout", "input": "98 224\n28 84", "output": "14\n28\n"}, {"type": "stdin_stdout"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAt 17:00, special agent Jack starts to escape from the enemy camp. There is a cliff in between the camp and the nearest safety zone. Jack has to climb the almost vertical cliff by stepping his feet on the blocks that cove... | [{"type": "stdin_stdout", "input": "6 6\n4 4 X X T T\n4 7 8 2 X 7\n1 X X X 1 8\n1 2 X X X 6\n1 1 2 4 4 7\nS S 2 3 X X\n2 10\nT 1\n1 X\n1 X\n1 X\n1 1\n1 X\n1 X\n1 1\n1 X\nS S\n2 10\nT X\n1 X\n1 X\n1 X\n1 1\n1 X\n1 X\n1 1\n1 X\nS S\n10 10\nT T T T T T T T T T\nX 2 X X X X X 3 4 X\n9 8 9 X X X 2 9 X 9\n7 7 X 7 3 X X 8 9 X... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMr. Yamada Springfield Tanaka was appointed as Deputy Deputy Director of the National Land Readjustment Business Bureau. Currently, his country is in the midst of a major land readjustment, and if this land readjustment c... | [{"type": "stdin_stdout", "input": "2\n-100 -20 100 20\n-20 -100 18 100\n2\n-100 -20 -20 -100\n20 100 100 20\n0", "output": "4\n3\n"}, {"type": "stdin_stdout", "input": "2\n-100 -20 100 20\n-20 -100 20 100\n2\n-100 -34 -20 -100\n20 100 100 20\n0", "output": "4\n3\n"}, {"type": "stdin_stdout", "input": "2\n-100 -20 100 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFor given two circles $c1$ and $c2$, print the coordinates of the cross points of them.\n\nConstraints\n\n* The given circle have at least one cross point and have different center coordinates.\n* $-10,000 \\leq c1x, c1y,... | [{"type": "stdin_stdout", "input": "-1 -2 2\n-1 0 1", "output": "-1.9682458366 -0.2500000000 -0.0317541634 -0.2500000000\n"}, {"type": "stdin_stdout", "input": "-1 -2 2\n-2 0 1", "output": "-2.6000000000 -0.8000000000 -1.0000000000 -0.0000000000\n"}, {"type": "stdin_stdout", "input": "-2 -2 2\n-2 0 1", "output": "-2.96... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFor a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.\n\n* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.\n* f... | [{"type": "stdin_stdout", "input": "9\n0 1\n0 2\n0 3\n3 2\n1 0\n1 2\n0 3\n0 4\n3 2 10", "output": "1\n2\n3\n3\n1\n2\n3\n2\n3\n2\n3\n"}, {"type": "stdin_stdout", "input": "9\n0 1\n0 4\n0 3\n3 2\n1 0\n1 2\n0 3\n0 4\n3 2 10", "output": "1\n2\n3\n3\n1\n3\n4\n3\n4\n3\n4\n"}, {"type": "stdin_stdout", "input": "9\n0 1\n0 2\n0... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:\n\nGiven two binary numbers a and b of length n. How many different ways of swapping two digits in a (only in a,... | [{"type": "stdin_stdout", "input": "30\n011110110100010000011001000100\n110111101001011001100001101101\n", "output": "146\n"}, {"type": "stdin_stdout", "input": "30\n011110110100010000011001000100\n110111101000011001100001101101\n", "output": "153\n"}, {"type": "stdin_stdout", "input": "30\n0111101101000100000110010001... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThis is an interactive problem.\n\nIn the Wonderful Metropolis of the Future, there is no need in subway train drivers. Due to the technological progress, they were replaced by the Artificial Intelligence (AI). Unfortunat... | [{"type": "stdin_stdout", "input": "1 2\n\nseY\n\nNo\n\nYes\n\nYds\n", "output": "1 1\n1 1\n1 1\n"}, {"type": "stdin_stdout", "input": "10 2\n\nYes\n\nNo\n\nYes\n\nYes\n", "output": "2 2\n"}, {"type": "stdin_stdout", "input": "1 2\n\nYes\n\nNo\n\nYer\n\nYes\n", "output": "1 1\n"}, {"type": "stdin_stdout", "input": "1 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe Squareland national forest is divided into equal 1 Γ 1 square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates (x, y) of its south-west corn... | [{"type": "stdin_stdout", "input": "0 1000\n1000 0\n1000 1000\n", "output": "2001\n0 1000\n1 1000\n2 1000\n3 1000\n4 1000\n5 1000\n6 1000\n7 1000\n8 1000\n9 1000\n10 1000\n11 1000\n12 1000\n13 1000\n14 1000\n15 1000\n16 1000\n17 1000\n18 1000\n19 1000\n20 1000\n21 1000\n22 1000\n23 1000\n24 1000\n25 1000\n26 1000\n27 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSalem gave you n sticks with integer positive lengths a_1, a_2, β¦, a_n.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the s... | [{"type": "stdin_stdout", "input": "113\n86 67 31 33 72 100 88 63 16 12 79 80 76 45 31 96 44 10 24 33 53 11 56 100 23 57 9 48 28 73 18 48 12 89 73 9 51 11 82 94 90 92 34 99 54 58 33 67 35 87 58 90 94 64 57 80 87 99 84 99 20 1 63 12 16 40 50 95 33 58 7 23 71 89 53 15 95 29 71 16 65 21 66 89 82 30 6 45 6 66 58 32 27 78 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBerland SU holds yet another training contest for its students today. n students came, each of them brought his laptop. However, it turned out that everyone has forgot their chargers!\n\nLet students be numbered from 1 to... | [{"type": "stdin_stdout", "input": "7 200000\n66 57 15 65 32 46 30\n66 31 64 9 63 57 65\n", "output": "-1"}, {"type": "stdin_stdout", "input": "7 200000\n66 57 15 65 32 46 30\n7 31 64 9 63 57 65\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "6 200000\n66 57 15 65 32 46 30\n7 31 64 9 63 57 65\n", "output": "-... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet's define a function f(p) on a permutation p as follows. Let g_i be the [greatest common divisor (GCD)](https://en.wikipedia.org/wiki/Greatest_common_divisor) of elements p_1, p_2, ..., p_i (in other words, it is the G... | [{"type": "stdin_stdout", "input": "1000000\n", "output": "943169120\n"}, {"type": "stdin_stdout", "input": "955654\n", "output": "416395816\n"}, {"type": "stdin_stdout", "input": "425221\n", "output": "973943578\n"}, {"type": "stdin_stdout", "input": "786432\n", "output": "755978297\n"}, {"type": "stdin_stdout", "inpu... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nKamil likes streaming the competitive programming videos. His MeTube channel has recently reached 100 million subscribers. In order to celebrate this, he posted a video with an interesting problem he couldn't solve yet. C... | [{"type": "stdin_stdout", "input": "32\n402528994560 0 0 0 0 0 0 932646223872 893192888700 0 813583026900 0 0 0 0 143521875000 0 177570054144 186624000000 0 517655600000 202145625000 341007975000 0 116252718750 0 148561875000 0 304819200000 248474688000 0 103125000000\n29 25\n20 24\n8 21\n23 3\n32 14\n29 30\n31 24\n28 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRecently, Norge found a string s = s_1 s_2 β¦ s_n consisting of n lowercase Latin letters. As an exercise to improve his typing speed, he decided to type all substrings of the string s. Yes, all (n (n + 1))/(2) of them!\n\... | [{"type": "stdin_stdout", "input": "200 13\nvgfjhgkgwkftaeqejmbgildembgxdbskxfndwmcckjfkbeekxkgakmcjhclqsecpnkaigcxxhfghgegfadjktckftdhtifriemfifakygoesjfginnddjjklwiwlbjsgftwhtjdxmcadpvhaeddxwnmguwhetwbmffbmvdvuhecgjckddrbikgwkrfwfhdhqolidgkfm\na b c d e f g h i j k l m\n", "output": "578\n"}, {"type": "stdin_stdout",... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given two integers a and m. Calculate the number of integers x such that 0 β€ x < m and \\gcd(a, m) = \\gcd(a + x, m).\n\nNote: \\gcd(a, b) is the greatest common divisor of a and b.\n\nInput\n\nThe first line cont... | [{"type": "stdin_stdout", "input": "10\n164 252\n94 226\n38 254\n196 255\n35 256\n174 257\n251 495\n246 527\n9 260\n149 261\n", "output": "36\n112\n126\n128\n128\n256\n240\n480\n96\n168\n"}, {"type": "stdin_stdout", "input": "10\n164 252\n94 253\n171 254\n196 255\n35 256\n174 257\n251 258\n239 259\n9 260\n98 261\n", "o... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nNash designed an interesting yet simple board game where a player is simply required to follow instructions written on the cell where the player currently stands. \n\nThis board game is played on the nΓ n board. Rows and ... | [{"type": "stdin_stdout", "input": "10\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1\n-1 -1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 -1 -1\n-1 -1 -1 -1 3 3 3 4 3 5 3 6 3 7 3 8 -1 -1 -1 -1\n-1 -1 4 2 4 3 4 4 4 5 4 6 4 7 4 8 -1 -1 -1 -1\n-1 -1 5 2 5 3 5 3 5 5 5 6 5 7 5 9 5 9 -1 -1\n-1 -1 6 2 6 3 6 5 6 5 6 6 6 7 6 8... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nHaving read half of the book called \"Storm and Calm\" on the IT lesson, Innocentius was absolutely determined to finish the book on the maths lessons. All was fine until the math teacher Ms. Watkins saw Innocentius readi... | [{"type": "stdin_stdout", "input": "DaABYAOivguEueXufuoUeoiLiuEuEIeZAdoPgaUIIrUtoodAALPESiUaEbqitAphOIIEAogrjUBZLnIALGbazIermGEiAAdDAOFaaizopuUuuEugOHsXTAelFxAyZXWQXiEEKkGiIVdUmwiThDOiEyiuOEaiIAAjEQyaEuOiUGOuuzvaIEUEAhXEuOliOeEkJuJaUaszUKePiQuwXSuoQYEeUOgOeuyvOwhUuitEEKDVOaUaoiaIyiAEkyXeuiEkUorUYCaOXEAiUYPnUMaURebouLUO... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOleg's favorite subjects are History and Math, and his favorite branch of mathematics is division.\n\nTo improve his division skills, Oleg came up with t pairs of integers p_i and q_i and for each pair decided to find the... | [{"type": "stdin_stdout", "input": "10\n238517256500070918 988176216\n363959778883784349 933416507\n631238591652944446 530795521\n557307185726829409 1481431174\n86402035814143715 513728064\n101626841876448103 26556040\n598448092106640578 746411314\n733629261048200000 361714100\n624561301519202735 38\n106258810456388771... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMonocarp had a sequence a consisting of n + m integers a_1, a_2, ..., a_{n + m}. He painted the elements into two colors, red and blue; n elements were painted red, all other m elements were painted blue.\n\nAfter paintin... | [{"type": "stdin_stdout", "input": "4\n4\n4 -5 11 -4\n3\n2 3 -4\n2\n1 1\n4\n10 -3 0 2\n5\n-1 -2 -3 -1 -5\n5\n-1 -2 -3 -4 -4\n1\n-1\n1\n0\n", "output": "15\n12\n0\n0\n"}, {"type": "stdin_stdout", "input": "4\n4\n4 -9 12 -6\n3\n2 3 -1\n2\n0 1\n4\n10 -3 0 3\n5\n-1 -2 -3 0 -10\n5\n-2 -2 -3 -4 -5\n1\n-1\n1\n0\n", "output": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nCirno gave AquaMoon a chessboard of size 1 Γ n. Its cells are numbered with integers from 1 to n from left to right. In the beginning, some of the cells are occupied with at most one pawn, and other cells are unoccupied.\... | [{"type": "stdin_stdout", "input": "6\n4\n0110\n6\n011011\n5\n01010\n20\n10001111110110111000\n20\n00110110100110111101\n20\n11001111011000100010\n", "output": "3\n6\n1\n1287\n1287\n1001\n"}, {"type": "stdin_stdout", "input": "6\n4\n0110\n6\n011011\n5\n01011\n20\n10001111110110111000\n20\n00110110100110111101\n20\n1110... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn Berland the opposition is going to arrange mass walking on the boulevard. The boulevard consists of n tiles that are lain in a row and are numbered from 1 to n from right to left. The opposition should start walking on... | [{"type": "stdin_stdout", "input": "250\n5 3 5 1 3 5 3 4 4 3 1 5 2 2 1 1 5 2 3 3 2 5 4 3 2 4 2 3 5 4 1 2 3 5 2 2 5 4 1 3 3 5 4 4 4 4 4 2 4 2 3 5 1 4 3 3 2 3 5 3 3 4 4 2 3 1 3 4 1 4 5 4 1 2 3 4 1 5 3 3 2 3 5 4 2 5 2 2 3 5 4 3 5 4 2 1 4 1 4 1 1 3 5 1 1 2 1 3 4 5 4 3 2 5 1 3 5 1 1 3 3 5 1 4 5 1 2 1 1 5 5 3 5 1 4 1 4 4 4 4... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOne day n students come to the stadium. They want to play football, and for that they need to split into teams, the teams must have an equal number of people.\n\nWe know that this group of people has archenemies. Each stu... | [{"type": "stdin_stdout", "input": "100 72\n2 88\n55 80\n22 20\n78 52\n66 74\n91 82\n59 77\n97 93\n46 44\n99 35\n73 62\n58 24\n6 16\n47 41\n98 86\n23 19\n39 68\n32 28\n85 29\n37 40\n16 62\n19 61\n84 72\n17 15\n76 96\n37 31\n67 35\n48 15\n80 85\n90 47\n79 36\n39 54\n57 87\n42 60\n34 56\n23 61\n92 2\n88 63\n20 42\n27 81\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nn people came to a party. Then those, who had no friends among people at the party, left. Then those, who had exactly 1 friend among those who stayed, left as well. Then those, who had exactly 2, 3, ..., n - 1 friends amo... | [{"type": "stdin_stdout", "input": "1\n108\n", "output": "106\n"}, {"type": "stdin_stdout", "input": "1\n157\n", "output": "155\n"}, {"type": "stdin_stdout", "input": "1\n168\n", "output": "166\n"}, {"type": "stdin_stdout", "input": "1\n299\n", "output": "297\n"}, {"type": "stdin_stdout", "input": "1\n111\n", "output":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOne beautiful day Vasily the bear painted 2m circles of the same radius R on a coordinate plane. Circles with numbers from 1 to m had centers at points (2R - R, 0), (4R - R, 0), ..., (2Rm - R, 0), respectively. Circles wi... | [{"type": "stdin_stdout", "input": "100000 4\n", "output": "266669.98044222436\n"}, {"type": "stdin_stdout", "input": "66666 8\n", "output": "355558.62761817535\n"}, {"type": "stdin_stdout", "input": "66666 11\n", "output": "488893.1129749911\n"}, {"type": "stdin_stdout", "input": "11905 7\n", "output": "55562.46664223... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSimon has a prime number x and an array of non-negative integers a1, a2, ..., an.\n\nSimon loves fractions very much. Today he wrote out number <image> on a piece of paper. After Simon led all fractions to a common denomi... | [{"type": "stdin_stdout", "input": "26 7\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2\n", "output": "49\n"}, {"type": "stdin_stdout", "input": "26 2\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "1 1139170813\n800000011\n", "output": "1\n"}, {"type"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nArthur and Alexander are number busters. Today they've got a competition. \n\nArthur took a group of four integers a, b, w, x (0 β€ b < w, 0 < x < w) and Alexander took integer Ρ. Arthur and Alexander use distinct approach... | [{"type": "stdin_stdout", "input": "200000000 794 1000 117 2000000000\n", "output": "2038505096\n"}, {"type": "stdin_stdout", "input": "20000000 280 1000 25 2000000000\n", "output": "2030769231\n"}, {"type": "stdin_stdout", "input": "13597422 280 1000 42 2000000000\n", "output": "2073489121\n"}, {"type": "stdin_stdout"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet's call an undirected graph of n vertices p-interesting, if the following conditions fulfill: \n\n * the graph contains exactly 2n + p edges; \n * the graph doesn't contain self-loops and multiple edges; \n * for an... | [{"type": "stdin_stdout", "input": "5\n24 228\n24 228\n24 228\n24 228\n24 228\n", "output": "1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10\n1 11\n1 12\n1 13\n1 14\n1 15\n1 16\n1 17\n1 18\n1 19\n1 20\n1 21\n1 22\n1 23\n1 24\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n2 11\n2 12\n2 13\n2 14\n2 15\n2 16\n2 17\n2 18\n2 19\n2 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIahub is training for the IOI. What is a better way to train than playing a Zuma-like game? \n\nThere are n balls put in a row. Each ball is colored in one of k colors. Initially the row doesn't contain three or more cont... | [{"type": "stdin_stdout", "input": "100 100 100\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 12 19 20 21 22 23 24 25 30 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 6 43 44 45 46 47 48 49 99 12 52 53 54 55 56 57 58 92 60 61 62 63 64 65 66 67 68 21 70 71 84 73 74 75 76 77 78 79 118 81 98 83 84 85 86 87 88 89 90 164 92 93 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given three strings (s1, s2, s3). For each integer l (1 β€ l β€ min(|s1|, |s2|, |s3|) you need to find how many triples (i1, i2, i3) exist such that three strings sk[ik... ik + l - 1] (k = 1, 2, 3) are pairwise equa... | [{"type": "stdin_stdout", "input": "aaababaaaaaaaaaaaaabaaaaaaaaaabaaaaaaaaaaaaa\nbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbabbbbbbbbabbbb\nccccccccbccccccccccccccccaccccccccccccccccbbccccccccccccccccaaacccccccccccccccc\n", "output": "1116 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given sequence a1, a2, ..., an and m queries lj, rj (1 β€ lj β€ rj β€ n). For each query you need to print the minimum distance between such pair of elements ax and ay (x β y), that:\n\n * both indexes of the elemen... | [{"type": "stdin_stdout", "input": "10 6\n4 2 1 5 12 7 9 8 10 4\n1 3\n1 10\n2 10\n2 9\n5 5\n2 8\n", "output": "-1\n9\n-1\n-1\n-1\n-1\n"}, {"type": "stdin_stdout", "input": "10 6\n4 2 1 5 6 7 9 8 10 4\n1 3\n1 10\n2 10\n2 9\n5 5\n2 8\n", "output": "-1\n9\n-1\n-1\n-1\n-1\n"}, {"type": "stdin_stdout", "input": "10 6\n4 2 1... | 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": "178481\n", "output": "845172388\n"}, {"type": "stdin_stdout", "inpu... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nShapur was an extremely gifted student. He was great at everything including Combinatorics, Algebra, Number Theory, Geometry, Calculus, etc. He was not only smart but extraordinarily fast! He could manage to sum 1018 numb... | [{"type": "stdin_stdout", "input": "1010000011010110011101001101110001110010000111011101110010110110111111001001110100101100010101010001\n0111101000111100101100000101111010100100001000011101010100110011100011010011010101000100101011100011\n", "output": "110110101110101011000100100000101101011000111100000010011000010101... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFirst-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge ... | [{"type": "stdin_stdout", "input": "prntaxhysjfcfmrjngdsitlguahtpnwgbaxptubgpwcfxqehrulbxfcjssgocqncscduvyvarvwxzvmjoatnqfsvsilubexmwugedtzavyamqjqtkxzuslielibjnvkpvyrbndehsqcaqzcrmomqqwskwcypgqoawxdutnxmeivnfpzwvxiyscbfnloqjhjacsfnkfmbhgzpujrqdbaemjsqphokkiplblbflvadcyykcqrdohfasstobwrobslaofbasylwiizrpozvhtwyxtzl\n",... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOne particularly well-known fact about zombies is that they move and think terribly slowly. While we still don't know why their movements are so sluggish, the problem of laggy thinking has been recently resolved. It turns... | [{"type": "stdin_stdout", "input": "10 9\n2 3\n6 8\n10 1\n1 8\n6 7\n8 7\n10 5\n7 10\n2 5\n", "output": "no\n"}, {"type": "stdin_stdout", "input": "10 9\n2 3\n6 8\n10 1\n1 8\n6 7\n8 7\n10 5\n7 10\n2 2\n", "output": "no\n"}, {"type": "stdin_stdout", "input": "10 9\n2 3\n6 8\n10 1\n1 8\n6 7\n8 7\n10 4\n7 10\n2 2\n", "outp... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAnton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next level he has to prepare n potions.\n\nAnton has a special kettle, that can prepare one potions in x seconds.... | [{"type": "stdin_stdout", "input": "256 22 22\n45 42\n21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42\n21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42\n21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42\n21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOn the Literature lesson Sergei noticed an awful injustice, it seems that some students are asked more often than others.\n\nSeating in the class looks like a rectangle, where n rows with m pupils in each. \n\nThe teacher... | [{"type": "stdin_stdout", "input": "1 1 1000000000000000000 1 1\n", "output": "1000000000000000000 1000000000000000000 1000000000000000000\n"}, {"type": "stdin_stdout", "input": "1 100 1000000000000000000 1 35\n", "output": "10000000000000000 10000000000000000 10000000000000000\n"}, {"type": "stdin_stdout", "input": "1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe year of 2012 is coming...\n\nAccording to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the hu... | [{"type": "stdin_stdout", "input": "22\nCleo likes Snowy\nCleo likes Troll\nChapay likes Dracul\nSnowy likes Troll\nDracul likes Chapay\nDracul likes Snowy\nChapay likes Cleo\nSnowy likes Chapay\nDracul likes Troll\nAnka likes Hexadecimal\nSnowy likes Anka\nHexadecimal likes Cleo\nHexadecimal likes Troll\nDracul likes ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWherever the destination is, whoever we meet, let's render this song together.\n\nOn a Cartesian coordinate plane lies a rectangular stage of size w Γ h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and ... | [{"type": "stdin_stdout", "input": "20 50000 50000\n2 45955 55488\n1 19804 29337\n2 3767 90811\n2 24025 33558\n1 46985 56518\n2 21094 30627\n2 5787 15320\n1 4262 91306\n2 37231 46764\n1 18125 27658\n1 36532 12317\n1 31330 40863\n1 18992 28525\n1 29387 38920\n1 44654 54187\n2 45485 55018\n2 36850 46383\n1 44649 54182\n1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given several queries. In the i-th query you are given a single positive integer ni. You are to represent ni as a sum of maximum possible number of composite summands and print this maximum number, or print -1, if... | [{"type": "stdin_stdout", "input": "100\n611\n513\n544\n463\n38\n778\n116\n317\n848\n664\n440\n108\n718\n54\n334\n876\n234\n22\n944\n305\n159\n245\n513\n691\n639\n65\n308\n324\n813\n459\n164\n116\n331\n993\n184\n224\n853\n769\n121\n687\n93\n930\n751\n308\n485\n1386\n400\n695\n95\n751\n175\n972\n121\n654\n242\n610\n1074... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya has a non-negative integer n. He wants to round it to nearest integer, which ends up with 0. If n already ends up with 0, Vasya considers it already rounded.\n\nFor example, if n = 4722 answer is 4720. If n = 5 Vasy... | [{"type": "stdin_stdout", "input": "1000000000\n", "output": "1000000000\n"}, {"type": "stdin_stdout", "input": "1031575393\n", "output": "1031575390\n"}, {"type": "stdin_stdout", "input": "1022742286\n", "output": "1022742290\n"}, {"type": "stdin_stdout", "input": "1259496606\n", "output": "1259496610\n"}, {"type": "s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe consider a positive integer perfect, if and only if the sum of its digits is exactly 10. Given a positive integer k, your task is to find the k-th smallest perfect positive integer.\n\nInput\n\nA single line with a pos... | [{"type": "stdin_stdout", "input": "10000\n", "output": "10800100"}, {"type": "stdin_stdout", "input": "8020\n", "output": "10000180\n"}, {"type": "stdin_stdout", "input": "9411\n", "output": "10214200"}, {"type": "stdin_stdout", "input": "8888\n", "output": "10110061"}, {"type": "stdin_stdout", "input": "9999\n", "out... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence a consisting of n integers. You may partition this sequence into two sequences b and c in such a way that every element belongs exactly to one of these sequences. \n\nLet B be the sum of elements ... | [{"type": "stdin_stdout", "input": "100\n-100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPetya loves volleyball very much. One day he was running late for a volleyball match. Petya hasn't bought his own car yet, that's why he had to take a taxi. The city has n junctions, some of which are connected by two-way... | [{"type": "stdin_stdout", "input": "15 29\n6 6\n7 12 7\n11 3 7\n4 5 18\n13 9 18\n3 8 12\n6 1 7\n4 1 4\n12 5 18\n10 8 15\n2 10 1\n9 7 11\n2 4 10\n2 14 3\n15 12 14\n1 13 8\n11 4 1\n15 11 2\n1 5 9\n5 2 5\n9 10 5\n15 2 17\n11 5 1\n14 15 14\n10 1 16\n15 9 2\n13 15 6\n13 5 1\n7 12 6\n12 5 13\n8 26\n35 17\n16 14\n12 13\n21 1\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTwo participants are each given a pair of distinct numbers from 1 to 9 such that there's exactly one number that is present in both pairs. They want to figure out the number that matches by using a communication channel y... | [{"type": "stdin_stdout", "input": "12 12\n6 7 5 4 7 8 2 9 12 5 3 5 1 6 7 3 7 9 5 7 1 8 6 8\n6 4 2 1 7 8 1 6 8 5 9 8 1 5 7 2 5 9 6 3 9 2 9 4\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "12 12\n1 6 2 6 8 3 6 4 4 8 7 2 7 5 9 4 2 4 9 5 8 5 3 2\n2 8 6 9 2 6 7 4 6 5 6 3 5 8 7 8 7 1 1 9 9 7 7 3\n", "output": "-1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nValentine week has started and Chotu wants to impress his crush. On this rose day Chotu plans to give his crush a bouquet of roses. Chotu visits a rose shop which has N number of roses and each rose has a certain love fac... | [{"type": "stdin_stdout", "input": "10\n1000\n4913 1000 405224 328509 512 592704 343 857375 39304 8000 614125 79507 287496 373248 39304 250047 10843 68921 1728 12167 493039 29791 614125 2744 287496 79507 2197 343 389017 704969 262144 287496 35937 373248 884736 753571 125000 148877 50653 12167 205379 226981 857375 31443... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nStatement: Security is the major factor, which is prohibiting hackers letting into bank accounts online. But still, we have breached 2nd level security of SBIS bank and a final level is kept for you. Your task is simple, ... | [{"type": "stdin_stdout", "input": "20\n77098906505852940\n23695632789598785\n83179477858357140\n38835312821902340\n20531402854248883\n79217919497750700\n97700573573820292\n61817719996906820\n76683795335702609\n12297584302723408\n37055948958732184\n94997957651503400\n99667860986664907\n28605950158089400\n87323704292066... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAlice and Bob text each other everyday. Bob, tired of writing long messages has come up with a way to reduce their size.\nAlice and Bob are both fluent in 2 languages, L1 and L2. A language consists of a collection of\ndi... | [{"type": "stdin_stdout", "input": "1 1\namit am\namit\n\nSAMPLE", "output": "am\n"}, {"type": "stdin_stdout", "input": "1 1\namit am\namit\n\nSAMQLE", "output": "am\n"}, {"type": "stdin_stdout", "input": "1 1\namit bm\namit\n\nSAMPLE", "output": "bm\n"}, {"type": "stdin_stdout", "input": "1 1\namit an\namit\n\nSALQLE"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven is a string S consisting of `0` and `1`. Find the number of strings, modulo 998244353, that can result from applying the following operation on S zero or more times:\n\n* Remove the two characters at the beginning o... | [{"type": "stdin_stdout", "input": "11101111011111000000000110000001111100011111000000001101111110000000111111111", "output": "323558395\n"}, {"type": "stdin_stdout", "input": "11101111011101000000000110000001111100011111000000001101111110000000111111111", "output": "979142942\n"}, {"type": "stdin_stdout", "input": "11... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are N people living on a number line.\n\nThe i-th person lives at coordinate X_i.\n\nYou are going to hold a meeting that all N people have to attend.\n\nThe meeting can be held at any integer coordinate. If you cho... | [{"type": "stdin_stdout", "input": "7\n14 14 3 13 56 2 37", "output": "2319\n"}, {"type": "stdin_stdout", "input": "7\n0 1 0 20 141 0 -1", "output": "16580\n"}, {"type": "stdin_stdout", "input": "7\n0 1 0 20 141 1 -1", "output": "16535\n"}, {"type": "stdin_stdout", "input": "7\n1 1 0 20 141 1 -1", "output": "16490\n"},... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have N ID cards, and there are M gates.\n\nWe can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.\n\nHow many of the ID cards allow us to pass all the gate... | [{"type": "stdin_stdout", "input": "101000 1\n1 100000", "output": "100000\n"}, {"type": "stdin_stdout", "input": "101000 1\n1 100100", "output": "100100\n"}, {"type": "stdin_stdout", "input": "101000 1\n1 100110", "output": "100110\n"}, {"type": "stdin_stdout", "input": "101000 1\n1 100010", "output": "100010\n"}, {"t... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFind the number of integers between 1 and K (inclusive) satisfying the following condition, modulo 10^9 + 7:\n\n* The sum of the digits in base ten is a multiple of D.\n\nConstraints\n\n* All values in input are integers.... | [{"type": "stdin_stdout", "input": "98765432109876543210\n66", "output": "678072802\n"}, {"type": "stdin_stdout", "input": "98765432109876543210\n18", "output": "852803440\n"}, {"type": "stdin_stdout", "input": "98765432109876543210\n11", "output": "501683936\n"}, {"type": "stdin_stdout", "input": "98765432109876543210... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a string S consisting of `0` and `1`. Find the maximum integer K not greater than |S| such that we can turn all the characters of S into `0` by repeating the following operation some number of times.\n\n* Ch... | [{"type": "stdin_stdout", "input": "100000010", "output": "7\n"}, {"type": "stdin_stdout", "input": "100000101", "output": "6\n"}, {"type": "stdin_stdout", "input": "000000000", "output": "9\n"}, {"type": "stdin_stdout", "input": "100000011", "output": "7\n"}, {"type": "stdin_stdout", "input": "100001011", "output": "5... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N.\n\nThere are M kinds of regular boat services between these islan... | [{"type": "stdin_stdout", "input": "7 3\n2 16\n4 2\n5 -1\n1 4\n-1 7", "output": "IMPOSSIBLE\n"}, {"type": "stdin_stdout", "input": "7 3\n2 16\n4 2\n5 -1\n1 1\n-1 7", "output": "IMPOSSIBLE\n"}, {"type": "stdin_stdout", "input": "7 3\n2 16\n4 2\n5 -1\n1 4\n0 7", "output": "IMPOSSIBLE\n"}, {"type": "stdin_stdout", "input"... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.