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\nThere are n piles of stones of sizes a1, a2, ..., an lying on the table in front of you.\n\nDuring one move you can take one pile and add it to the other. As you add pile i to pile j, the size of pile j increases by the c...
[{"type": "stdin_stdout", "input": "2\n2 9\n5\n4 10 7 3 4\n", "output": "2 2 2 2 2\n"}, {"type": "stdin_stdout", "input": "2\n2 9\n5\n4 10 7 3 4\n", "output": "2 2 2 2 2\n"}, {"type": "stdin_stdout", "input": "2\n2 1\n5\n4 10 7 3 4\n", "output": "1 1 1 1 1\n"}, {"type": "stdin_stdout", "input": "2\n2 9\n5\n4 13 7 3 4\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Petya likes permutations a lot. Recently his mom has presented him permutation q1, q2, ..., qn of length n.\n\nA permutation a of length n is a sequence of integers a1, a2, ..., an (1 ≀ ai ≀ n), all integers there ...
[{"type": "stdin_stdout", "input": "55 28\n34 11 18 6 16 43 12 25 48 27 35 17 19 14 33 30 7 53 52 2 15 10 44 1 37 28 22 49 46 8 45 39 21 47 40 20 41 51 13 24 42 55 23 4 36 38 50 31 3 9 54 32 5 29 26\n34 11 18 6 16 43 12 25 48 27 35 17 19 14 33 30 7 53 52 2 15 10 44 1 37 28 22 49 46 8 45 39 21 47 40 20 41 51 13 24 42 55...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe little girl loves the problems on array queries very much.\n\nOne day she came across a rather well-known problem: you've got an array of n elements (the elements of the array are indexed starting from 1); also, there...
[{"type": "stdin_stdout", "input": "31 48\n45 19 16 42 38 18 50 7 28 40 39 25 45 14 36 18 27 30 16 4 22 6 1 23 16 47 14 35 27 47 2\n6 16\n11 28\n4 30\n25 26\n11 30\n5 9\n4 17\n15 17\n10 25\n15 26\n1 3\n9 26\n8 29\n16 30\n3 24\n27 30\n9 10\n22 29\n2 6\n15 24\n6 21\n19 21\n4 28\n1 7\n18 21\n10 22\n6 15\n14 28\n4 19\n12 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou want to arrange n integers a1, a2, ..., an in some order in a row. Let's define the value of an arrangement as the sum of differences between all pairs of adjacent integers.\n\nMore formally, let's denote some arrange...
[{"type": "stdin_stdout", "input": "100\n-790 341 910 905 -779 279 696 -375 525 -21 -2 751 -887 764 520 -844 850 -537 -882 -183 139 -397 561 -420 -991 691 587 -93 -701 -957 -89 227 233 545 934 309 -26 454 -336 -994 -135 -840 -320 -387 -943 650 628 -583 701 -708 -881 287 -932 -265 -312 -757 695 985 -165 -329 -4 -462 -62...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLately, a national version of a bingo game has become very popular in Berland. There are n players playing the game, each player has a card with numbers. The numbers on each card are distinct, but distinct cards can have ...
[{"type": "stdin_stdout", "input": "40\n2 12 19\n4 10 7 1 3\n2 15 17\n1 6\n3 17 8 20\n4 8 16 11 18\n2 2 7\n4 12 13 8 7\n3 6 1 15\n3 19 11 13\n1 2\n2 16 14\n5 1 17 8 9 5\n1 2\n3 15 17 12\n4 20 4 19 18\n1 10\n4 12 1 17 16\n4 5 10 8 11\n1 10\n1 13\n1 17\n2 19 18\n1 3\n2 6 20\n1 8\n2 3 14\n3 17 3 1\n2 4 3\n1 12\n1 15\n1 2\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nValera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell tha...
[{"type": "stdin_stdout", "input": "89 159 3600\n", "output": "2 1 1 1 2\n2 1 3 1 4\n2 1 5 1 6\n2 1 7 1 8\n2 1 9 1 10\n2 1 11 1 12\n2 1 13 1 14\n2 1 15 1 16\n2 1 17 1 18\n2 1 19 1 20\n2 1 21 1 22\n2 1 23 1 24\n2 1 25 1 26\n2 1 27 1 28\n2 1 29 1 30\n2 1 31 1 32\n2 1 33 1 34\n2 1 35 1 36\n2 1 37 1 38\n2 1 39 1 40\n2 1 41...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGargari got bored to play with the bishops and now, after solving the problem about them, he is trying to do math homework. In a math book he have found k permutations. Each of them consists of numbers 1, 2, ..., n in som...
[{"type": "stdin_stdout", "input": "41 4\n24 15 17 35 13 41 4 14 23 5 8 16 21 18 30 36 6 22 11 29 26 1 40 31 7 3 32 10 28 38 12 20 39 37 34 19 33 27 2 25 9\n22 13 25 24 38 35 29 12 15 8 11 37 3 19 4 23 18 32 30 40 36 21 16 34 27 9 5 41 39 2 14 17 31 33 26 7 1 10 20 6 28\n31 27 39 16 22 12 13 32 6 10 19 29 37 7 18 33 24...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider a sequence [a1, a2, ... , an]. Define its prefix product sequence <image>.\n\nNow given n, find a permutation of [1, 2, ..., n], such that its prefix product sequence is a permutation of [0, 1, ..., n - 1].\n\nIn...
[{"type": "stdin_stdout", "input": "18047\n", "output": "YES\n1\n2\n9025\n6017\n4513\n7220\n3009\n15470\n2257\n8022\n12634\n4923\n1505\n5554\n16759\n8423\n1129\n5309\n13035\n12349\n15341\n11173\n2462\n2355\n753\n12273\n11801\n14706\n8380\n9958\n4212\n3494\n565\n13673\n2655\n13923\n6518\n16097\n6175\n1852\n7671\n15407\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFox Ciel is playing a mobile puzzle game called \"Two Dots\". The basic levels are played on a board of size n Γ— m cells, like this:\n\n<image>\n\nEach cell contains a dot that has some color. We will use different upperc...
[{"type": "stdin_stdout", "input": "50 2\nAA\nCD\nEE\nFC\nED\nAF\nFC\nAD\nBA\nAF\nBF\nDA\nAC\nFC\nFA\nBF\nAD\nBB\nDC\nAF\nAA\nAD\nEE\nED\nCD\nFC\nFB\nBB\nDD\nEB\nBE\nCF\nDE\nAE\nFD\nAB\nFB\nAE\nBE\nFA\nCF\nFB\nDE\nED\nAD\nFA\nBB\nBF\nDA\nEE\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "50 2\nAA\nCD\nEE\nFC\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKarafs is some kind of vegetable in shape of an 1 Γ— h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs.\n\n<image>\n\nEach Karafs has a positiv...
[{"type": "stdin_stdout", "input": "447 74474 4\n47 777474 1358\n74 744744 74477\n477 477447 777\n7 477777 444444\n", "output": "-1\n-1\n-1\n7\n"}, {"type": "stdin_stdout", "input": "447 74474 4\n47 777474 747\n74 744744 74477\n477 477447 777\n7 477777 444444\n", "output": "-1\n-1\n-1\n7\n"}, {"type": "stdin_stdout", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlena has successfully passed the entrance exams to the university and is now looking forward to start studying.\n\nOne two-hour lesson at the Russian university is traditionally called a pair, it lasts for two academic h...
[{"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": "100\n"}, {"type": "stdin_stdout", "input": "100\n1 1 1 1 1 1 1 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGenos needs your help. He was asked to solve the following programming problem by Saitama:\n\nThe length of some string s is denoted |s|. The Hamming distance between two strings s and t of equal length is defined as <ima...
[{"type": "stdin_stdout", "input": "1001101001101110101101000\n01111000010011111111110010001101000100011110101111\n", "output": "321\n"}, {"type": "stdin_stdout", "input": "1110010001000101001011111\n00011011000000100001010000010100110011010001111010\n", "output": "316\n"}, {"type": "stdin_stdout", "input": "1001101001...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nStatistics claims that students sleep no more than three hours a day. But even in the world of their dreams, while they are snoring peacefully, the sense of impending doom is still upon them.\n\nA poor student is dreaming...
[{"type": "stdin_stdout", "input": "100 100\n50 50\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "82 60\n100 38\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "100 100\n36 50\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "82 60\n100 64\n", "output": "YES\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given names of two days of the week.\n\nPlease, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day...
[{"type": "stdin_stdout", "input": "wednesday\nwednesday\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "wednesday\nsaturday\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "thursday\nsaturday\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "saturday\nsaturday\n", "output": "YES\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is the faculty of Computer Science in Berland. In the social net \"TheContact!\" for each course of this faculty there is the special group whose name equals the year of university entrance of corresponding course o...
[{"type": "stdin_stdout", "input": "5\n2099 2096 2095 2097 2098\n", "output": "2097\n"}, {"type": "stdin_stdout", "input": "5\n2097 2099 2100 2098 2096\n", "output": "2098\n"}, {"type": "stdin_stdout", "input": "5\n2011 2014 2013 2010 2012\n", "output": "2012\n"}, {"type": "stdin_stdout", "input": "5\n2021 2023 2024 20...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice is a beginner composer and now she is ready to create another masterpiece. And not even the single one but two at the same time! \n\nAlice has a sheet with n notes written on it. She wants to take two such non-empty...
[{"type": "stdin_stdout", "input": "10\n7776 32915 1030 71664 7542 72359 65387 75222 95899 40333\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "10\n7776 65664 1030 71664 7542 72359 65387 75222 95899 40333\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "10\n1 1 1 1 1 1 1 1 1 1\n", "output": "10\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n cities and n - 1 roads in the Seven Kingdoms, each road connects two cities and we can reach any city from any other by the roads.\n\nTheon and Yara Greyjoy are on a horse in the first city, they are starting ...
[{"type": "stdin_stdout", "input": "70\n1 25\n57 1\n18 1\n65 1\n38 1\n1 41\n1 5\n1 69\n1 3\n31 1\n1 8\n1 9\n53 1\n70 1\n45 1\n1 24\n1 42\n1 30\n1 12\n1 37\n64 1\n1 28\n1 58\n1 22\n11 1\n1 4\n1 27\n1 16\n1 21\n54 1\n1 51\n1 43\n29 1\n56 1\n1 39\n32 2\n1 15\n1 17\n1 19\n1 40\n36 1\n48 1\n63 1\n1 7\n1 47\n1 13\n1 46\n60 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet S(n) denote the number that represents the digits of n in sorted order. For example, S(1) = 1, S(5) = 5, S(50394) = 3459, S(353535) = 333555.\n\nGiven a number X, compute <image> modulo 109 + 7.\n\nInput\n\nThe first ...
[{"type": "stdin_stdout", "input": "44649014054971081213608137817466046254652492627741860478258558206397113198232823859870363821007188476405951611069347299689170240023979048198711745011542774268179055311013054073075176122755643483380248999657649211459997766221072399103579977409770898200358240970169892326442892826731631...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn Arcady's garden there grows a peculiar apple-tree that fruits one time per year. Its peculiarity can be explained in following way: there are n inflorescences, numbered from 1 to n. Inflorescence number 1 is situated n...
[{"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\nTwo players play a game.\n\nInitially there are n integers a_1, a_2, …, a_n written on the board. Each turn a player selects one number and erases it from the board. This continues until there is only one number left on t...
[{"type": "stdin_stdout", "input": "10\n58 26 65 15 13 81 111 48 22 50\n", "output": "48\n"}, {"type": "stdin_stdout", "input": "10\n58 26 65 15 13 81 111 48 22 55\n", "output": "48\n"}, {"type": "stdin_stdout", "input": "10\n58 26 77 15 53 81 68 48 22 65\n", "output": "53\n"}, {"type": "stdin_stdout", "input": "10\n58...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIndia is a cricket crazy nation. Chang also loves cricket and computations related to cricket. Chang has created a Cricket app.This app analyses the performance of a cricketer. If a cricketer under-performs, then a negati...
[{"type": "stdin_stdout", "input": "8\n-1 -5 4 -2 0 1 4 -10\n\nSEMPLA", "output": "7\n"}, {"type": "stdin_stdout", "input": "8\n-1 -5 4 -2 0 1 4 -10\n\nALPMES", "output": "7\n"}, {"type": "stdin_stdout", "input": "8\n-1 -5 4 -2 0 1 4 -17\n\nALPMES", "output": "7\n"}, {"type": "stdin_stdout", "input": "8\n-1 -5 4 -2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMilly loves chocolates very much. She is at the land of chocolates. This land has N rooms such that there are some chocolates of different brands in every room. It is possible that there can be multiple chocolates of same...
[{"type": "stdin_stdout", "input": "3\n10 40\n10 ggl fhklnkh addejhpo igkknigiq c egfhh egfhh edhdhholl fhklnkh ahg\n10 chj di bhfmgmj edgjhoo djkdgh chj heek djkdgh ggl ahg\n10 gjkegonh hbgjlk edhdhholl chj chj ecgielp c edhdhholl fjkghilnj ahg\n10 fieg eigkhh eigkhh h fjkghilnj ecgielp ggl di ggl ahg\n10 ecgielp j bh...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a kingdom, that has a long straight road of length L meters and width 0. Coordinate x on the road denotes point that is at x meters from the start of the road. That is coordinate 0 denotes beginning of the road a...
[{"type": "stdin_stdout", "input": "3\n18 6\n2 1 5\n8 4 0\n0 2 7\n1 15 2\n2 8 9\n5 27 4\n16 6\n7 12 4\n1 32 2\n6 5 12\n0 10 2\n-1 3 6\n1 16 2\n2 2\n-1 1 10\n0 0 15\n0 1 1\n11 0 1\n\nEMPMAS", "output": "13\n4\n-1\n"}, {"type": "stdin_stdout", "input": "3\n9 6\n2 1 5\n4 4 0\n1 1 8\n0 11 2\n5 5 2\n5 15 2\n16 6\n7 8 3\n1 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHackland is being attacked by Greyland, and you have been assigned the job to save it. Your enemies, known as Grey hats, are numbered starting from L to R, both inclusive. But, here is the fun part: Grey hats are known t...
[{"type": "stdin_stdout", "input": "200\n1 1001 1000\n5 511 10\t\n5 4747 10\n1 1000000 10\t\n10 10110 10\n1 1 10\t\n1000000 1000000 10\t\n491273 842398 10\t\n849859 958925 10\t\n67803 771363 10\t\n184892 391907 10\t\n75799 256150 10\n268944 342402 10\t\n228640 894352 10\t\n903885 908656 10\t\n292588 414271 10\t\n852057...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe dark lord wants to send armies of imps to assault Hogwarts in the first wave of offense. The imps are accustomed to fight in communities and will not fight separately. Communities are sent to battle such that the size...
[{"type": "stdin_stdout", "input": "10\n100\n5644 1134 9689 3313 8924 5073 6948 8330 4393 1486 440 9499 890 9913 6345 3036 206 8377 377 3492 1677 740 8766 3218 9196 1020 11250 8174 1041 766 8823 1199 1001 1303 3404 2095 1991 538 7069 1340 6013 4241 9102 463 1647 6592 6347 6690 10174 6528 5122 1934 6435 4202 9074 2067 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a binary array A=(A_1,A_2,\\cdots,A_N) of length N.\n\nProcess Q queries of the following types. The i-th query is represented by three integers T_i,L_i,R_i.\n\n* T_i=1: Replace the value of A_j with 1-A_j f...
[{"type": "stdin_stdout", "input": "5 9\n1 1 0 0 1\n2 1 4\n1 3 4\n2 2 5\n2 1 3\n2 1 2", "output": "4\n0\n0\n0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "5 8\n1 1 0 0 1\n2 1 4\n1 3 4\n2 3 5\n2 1 3\n2 1 2", "output": "4\n0\n0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "5 6\n1 1 0 0 0\n2 3 5\n2 3 4\n2 2 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi and Aoki will have a battle using their monsters.\n\nThe health and strength of Takahashi's monster are A and B, respectively, and those of Aoki's monster are C and D, respectively.\n\nThe two monsters will take...
[{"type": "stdin_stdout", "input": "139 11 4 17", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "366 15 4 17", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "117 8 1 10", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "117 8 1 17", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "139 8 1 17...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi is solving quizzes. He has easily solved all but the last one.\n\nThe last quiz has three choices: 1, 2, and 3.\n\nWith his supernatural power, Takahashi has found out that the choices A and B are both wrong.\n\...
[{"type": "stdin_stdout", "input": "3\n001", "output": "2\n"}, {"type": "stdin_stdout", "input": "3\n001", "output": "2\n"}, {"type": "stdin_stdout", "input": "3\n2", "output": "1\n"}, {"type": "stdin_stdout", "input": "1\n3", "output": "2\n"}, {"type": "stdin_stdout", "input": "3\n2", "output": "1\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are H rows and W columns of white square cells.\n\nYou will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns.\n\nHow many white cells will remain?\n\nIt can be...
[{"type": "stdin_stdout", "input": "21 -1\n-5 -5", "output": "104\n"}, {"type": "stdin_stdout", "input": "39 -1\n-5 -5", "output": "176\n"}, {"type": "stdin_stdout", "input": "22 -1\n1 4", "output": "-105\n"}, {"type": "stdin_stdout", "input": "38 -1\n1 4", "output": "-185\n"}, {"type": "stdin_stdout", "input": "38 -1\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence D_1, D_2, ..., D_N of length N. The values of D_i are all distinct. Does a tree with N vertices that satisfies the following conditions exist?\n\n* The vertices are numbered 1,2,..., N.\n* The edg...
[{"type": "stdin_stdout", "input": "15\n57\n62\n47\n45\n42\n74\n90\n75\n54\n50\n66\n63\n77\n87\n51", "output": "1 10\n1 11\n2 8\n2 15\n3 5\n3 9\n4 5\n4 10\n5 15\n6 12\n6 14\n7 13\n9 12\n11 13"}, {"type": "stdin_stdout", "input": "15\n81\n66\n114\n117\n83\n171\n74\n75\n48\n140\n263\n9\n227\n149\n9", "output": "-1\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSome number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \\leq i \\leq N) ate one chocolate piece on each of the following days in the c...
[{"type": "stdin_stdout", "input": "5\n30 44\n26\n18\n81\n18\n10", "output": "54\n"}, {"type": "stdin_stdout", "input": "5\n30 29\n26\n18\n81\n18\n10", "output": "39\n"}, {"type": "stdin_stdout", "input": "5\n30 29\n26\n18\n81\n18\n19", "output": "38\n"}, {"type": "stdin_stdout", "input": "5\n1 113\n25\n21\n13\n16\n7",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nE869120 found a chest which is likely to contain treasure.\nHowever, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters.\nHe also found a string S', which turns ...
[{"type": "stdin_stdout", "input": "?tc??@?\ncoder", "output": "UNRESTORABLE\n"}, {"type": "stdin_stdout", "input": "?tc??@?\ncnder", "output": "UNRESTORABLE\n"}, {"type": "stdin_stdout", "input": "?tc??@?\nendcr", "output": "UNRESTORABLE\n"}, {"type": "stdin_stdout", "input": "@tc??@?\nendcr", "output": "UNRESTORABLE\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N cities and M roads. The i-th road (1≀i≀M) connects two cities a_i and b_i (1≀a_i,b_i≀N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads...
[{"type": "stdin_stdout", "input": "17 1\n2 8\n3 4\n1 5\n2 8\n4 7\n8 2\n4 1\n0 14", "output": "0\n1\n0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "13 7\n2 4\n3 4\n1 5\n2 8\n3 7\n5 2\n4 1\n6 8", "output": "2\n3\n2\n3\n2\n0\n1\n1\n0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHaiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.\n\nIroha is looking for X,Y,Z-Haiku (defined below) in integer sequences.\n\nConsider all integer seque...
[{"type": "stdin_stdout", "input": "15 10 2 3", "output": "138603924\n"}, {"type": "stdin_stdout", "input": "37 4 3 3", "output": "180978943\n"}, {"type": "stdin_stdout", "input": "37 3 3 3", "output": "632821729\n"}, {"type": "stdin_stdout", "input": "15 5 2 3", "output": "179274801\n"}, {"type": "stdin_stdout", "inpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe University of Aizu has a park covered with grass, and there are no trees or buildings that block the sunlight. On sunny summer days, sprinklers installed in the park operate to sprinkle water on the lawn. The frog Pyo...
[{"type": "stdin_stdout", "input": "10 1\n10\n2 6 6 3 1 2 -1 2 4 0 1 8 5 9 7 9 8 9 6 3\n6 1\n10\n10 2 5 3 1 2 0 12 4 6 1 4 9 9 11 12 8 6 14 0\n0 0", "output": "NA\nNA\n"}, {"type": "stdin_stdout", "input": "10 1\n10\n2 6 6 3 1 2 -1 2 4 0 1 8 5 9 7 9 8 9 6 3\n6 1\n10\n10 2 5 3 1 2 0 12 4 6 1 4 9 9 17 12 8 6 14 0\n0 0", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nI am a pipe tie craftsman. As long as you get the joints and pipes that connect the pipes, you can connect any pipe. Every day, my master gives me pipes and joints, which I connect and give to my master. But if you have t...
[{"type": "stdin_stdout", "input": "3\n0 1 1\n3 3\n4\n4 1 2 3\n1 1 1\n5\n1 1 3 4 5\n3 12 2 2\n0", "output": "10\n40\n104\n"}, {"type": "stdin_stdout", "input": "3\n0 1 1\n3 3\n4\n3 1 5 3\n1 1 1\n5\n2 4 6 4 5\n0 3 2 1\n0", "output": "10\n48\n105\n"}, {"type": "stdin_stdout", "input": "3\n0 1 1\n3 3\n4\n3 1 5 3\n1 1 1\n5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nOnce upon a time there were settlements and many people lived there. People built buildings of various shapes and sizes. But those buildings have already been lost, only the literature and the pillars found in ...
[{"type": "stdin_stdout", "input": "10\n2 0\n1 1\n1 0\n1 -1\n2 5\n0 1\n2 1\n1 4\n1 14\n18 1\n10\n4 14\n4 0\n2 1\n0 2\n1 4\n0 5\n4 1\n1 1\n2 6\n5 -1\n0", "output": "1\n0\n"}, {"type": "stdin_stdout", "input": "10\n16 0\n0 1\n1 1\n1 0\n2 7\n0 3\n3 1\n1 3\n1 14\n18 2\n10\n2 7\n5 5\n2 1\n0 2\n1 4\n1 4\n4 1\n1 1\n1 6\n5 4\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe city is full of ghosts, something the average person doesn't know about. Most of them are harmless, but the trouble is that there are quite a few evil spirits that curse people.\n\nThere was a girl who fought against ...
[{"type": "stdin_stdout", "input": "4 7\nA#...#B\n...#.##\n.#.#.#.\n...#...\n5\n4 7\nA#...\"B\n.#.#.#.\n.#.#.#.\n...#...\n8\n4 7\nA#...#B\n.#.#.#.\n##...#.\n...#...\n6\n4 7\nB#...#A\n.#.#.#.\n...###.\n...#...\n442668\n1 10\nA#.......B\n55555554\n1 10\nB.......#A\n55555555\n0 0", "output": "impossible\n12 0 6\nimpossibl...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEncryption System\n\nA programmer developed a new encryption system. However, his system has an issue that two or more distinct strings are `encrypted' to the same string.\n\nWe have a string encrypted by his system. To d...
[{"type": "stdin_stdout", "input": "enw\nabc\nabcdefghijklmnopqrst\ny\n#", "output": "1\nfox\n5\nacc\nacd\nbbd\nbcc\nbcd\n17711\nacceeggiikkmmooqqssu\nacceeggiikkmmooqqstt\nacceeggiikkmmooqqstu\nacceeggiikkmmooqrrtt\nacceeggiikkmmooqrrtu\nbcdefghijklmnopqrrtt\nbcdefghijklmnopqrrtu\nbcdefghijklmnopqrssu\nbcdefghijklmnop...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProfessor Abacus has just built a new computing engine for making numerical tables. It was designed to calculate the values of a polynomial function in one variable at several points at a time. With the polynomial functio...
[{"type": "stdin_stdout", "input": "2\n1.0\n4.0\n14.21446074361601\n16.0\n25.0\n1\n-30.5893962764\n6.055835197262627\n39.3853798058\n74.3727663177\n0\n42.56611822314588\n79.5420238202\n28.0282396675\n-30.3627807522\n-49.34987576252381\n-25.34819013612247\n7.58575761381\n0\n-21.42163030108298\n-47.94509062430888\n-23.35...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTime Limit: 8 sec / Memory Limit: 64 MB\n\n\n\n\n\nExample\n\nInput\n\neggchickenegg\n\n\nOutput\n\negg\n\nThe input will be given via stdin and the output should be printed to stdout by your code.\n\nNow solve the proble...
[{"type": "stdin_stdout", "input": "egechmilfgcgg", "output": "chicken\n"}, {"type": "stdin_stdout", "input": "egichgckenegg", "output": "egg\n"}, {"type": "stdin_stdout", "input": "egichnckegegg", "output": "egg\n"}, {"type": "stdin_stdout", "input": "egechickgnegg", "output": "egg\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven a set of $N$ axis-aligned rectangular seals, find the number of overlapped seals on the region which has the maximum number of overlapped seals.\n\nConstraints\n\n* $ 1 \\leq N \\leq 100000 $\n* $ 0 \\leq x1_i < x2_...
[{"type": "stdin_stdout", "input": "3\n0 0 1 2\n0 0 2 2\n0 0 2 2", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\n0 0 2 4\n0 0 2 2\n0 0 2 2", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\n0 0 1 2\n0 0 2 3\n0 0 2 2", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\n0 1 2 4\n0 0 2 2\n0 0 2 2", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOur Chef is very happy that his son was selected for training in one of the finest culinary schools of the world.\nSo he and his wife decide to buy a gift for the kid as a token of appreciation.\nUnfortunately, the Chef h...
[{"type": "stdin_stdout", "input": "3 3\n13 1 11\n0 6 34\n5 10 11", "output": "GUESS\n"}, {"type": "stdin_stdout", "input": "3 3\n9 8 11\n0 6 34\n5 10 11", "output": "GUESS\n"}, {"type": "stdin_stdout", "input": "3 3\n9 1 11\n0 6 34\n5 10 11", "output": "GUESS\n"}, {"type": "stdin_stdout", "input": "3 3\n9 8 11\n0 8 34...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEverybody seems to think that the Martians are green, but it turns out they are metallic pink and fat. Ajs has two bags of distinct nonnegative integers. The bags are disjoint, and the union of the sets of numbers in the ...
[{"type": "stdin_stdout", "input": "36 81\n4 5 7 8 13 14 16 17 22 23 25 26 31 32 34 35 40 41 43 44 49 50 52 53 58 59 61 62 67 68 70 71 76 77 79 80\n", "output": "9\n3 12 21 30 39 48 57 66 75 \n"}, {"type": "stdin_stdout", "input": "36 81\n4 5 7 10 13 14 16 17 22 23 25 26 31 32 22 35 40 41 43 44 49 50 52 53 58 59 61 62 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIvan has number b. He is sorting through the numbers a from 1 to 10^{18}, and for every a writes ([a, b])/(a) on blackboard. Here [a, b] stands for least common multiple of a and b. Ivan is very lazy, that's why thi...
[{"type": "stdin_stdout", "input": "2793510720\n", "output": "1792\n"}, {"type": "stdin_stdout", "input": "1102701600\n", "output": "1440\n"}, {"type": "stdin_stdout", "input": "2327925600\n", "output": "1728\n"}, {"type": "stdin_stdout", "input": "2095133040\n", "output": "1600\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string s=s_1s_2... s_n of length n, which only contains digits 1, 2, ..., 9.\n\nA substring s[l ... r] of s is a string s_l s_{l + 1} s_{l + 2} … s_r. A substring s[l ... r] of s is called even if the numb...
[{"type": "stdin_stdout", "input": "39\n263254663359864483324578786753512345165\n", "output": "327\n"}, {"type": "stdin_stdout", "input": "10\n9572683145\n", "output": "24\n"}, {"type": "stdin_stdout", "input": "4\n2244\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "4\n2864\n", "output": "10\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a long decimal number a consisting of n digits from 1 to 9. You also have a function f that maps every digit from 1 to 9 to some (possibly the same) digit from 1 to 9.\n\nYou can perform the following operat...
[{"type": "stdin_stdout", "input": "20\n58832646452639258958\n9 2 2 1 1 4 8 6 6\n", "output": "58832646452639258958"}, {"type": "stdin_stdout", "input": "19\n2612437771227631192\n6 7 3 6 8 7 9 4 9\n", "output": "7767639996779736697\n"}, {"type": "stdin_stdout", "input": "19\n4752348644348366742\n2 7 9 7 5 7 9 9 5\n", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has n different matryoshkas. Any matryoshka is a figure of volume out_i ...
[{"type": "stdin_stdout", "input": "20\n51 47\n46 42\n25 22\n41 31\n11 2\n27 24\n18 13\n49 45\n16 11\n19 14\n10 1\n30 27\n10 1\n41 31\n16 11\n10 1\n41 31\n41 31\n31 28\n49 45\n", "output": "256"}, {"type": "stdin_stdout", "input": "20\n51 47\n46 42\n25 22\n41 31\n11 2\n28 24\n18 13\n49 45\n16 11\n19 14\n10 1\n30 27\n10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have two strings a and b of equal even length n consisting of characters 0 and 1.\n\nWe're in the endgame now. To finally make the universe perfectly balanced, you need to make strings a and b equal.\n\nIn one step, y...
[{"type": "stdin_stdout", "input": "4\n0100011011\n1101011000\n10101010\n10101010\n0011\n1001\n100011\n110010\n", "output": "11\n2 2 4 4 6 4 6 6 8 8 10 \n8\n8 2 2 4 4 6 6 8 \n-1\n6\n2 2 2 4 4 6 \n"}, {"type": "stdin_stdout", "input": "4\n0100011011\n1101011000\n10101010\n10101010\n0011\n1001\n100011\n110010\n", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMr. Scrooge, a very busy man, decided to count the time he wastes on all sorts of useless stuff to evaluate the lost profit. He has already counted the time he wastes sleeping and eating. And now Mr. Scrooge wants to coun...
[{"type": "stdin_stdout", "input": "61 764\n-9 15\n11 -8\n-6 -7\n-13 -19\n16 -16\n-5 -1\n20 -19\n-14 -1\n-11 4\n7 -2\n-3 2\n-14 -17\n15 18\n20 15\n-13 -2\n15 8\n3 13\n19 -10\n2 -6\n15 -3\n-12 11\n4 -16\n-14 20\n0 2\n11 -7\n-6 -11\n16 7\n8 -3\n16 -10\n-3 9\n9 5\n4 -1\n-17 9\n14 -4\n8 6\n-19 12\n10 -17\n-5 7\n7 -3\n5 3\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a of length n and array b of length m both consisting of only integers 0 and 1. Consider a matrix c of size n Γ— m formed by following rule: c_{i, j} = a_i β‹… b_j (i.e. a_i multiplied by b_j). It's ea...
[{"type": "stdin_stdout", "input": "50 50 6\n1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 0 1\n1 1 0 1 0 1 1 0 1 1 1 1 1 1 0 1 1 0 1 0 0 1 1 1 1 0 0 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0\n", "output": "2153\n"}, {"type": "stdin_stdout", "input": "50 50 6\n1 0 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two integers x and y. You can perform two types of operations: \n\n 1. Pay a dollars and increase or decrease any of these integers by 1. For example, if x = 0 and y = 7 there are four possible outcomes aft...
[{"type": "stdin_stdout", "input": "3\n1 3\n391 555\n129 8437\n9 4\n321 654\n3 4\n", "output": "1337\n75288\n2283\n"}, {"type": "stdin_stdout", "input": "3\n1 6\n391 555\n129 8437\n9 4\n321 654\n3 4\n", "output": "2510\n75288\n2283\n"}, {"type": "stdin_stdout", "input": "3\n1 6\n391 555\n129 9245\n9 4\n321 654\n3 4\n",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is on constraints. In this version constraints are higher. You can make hacks only if all versions of the problem are solved.\n\nKoa the Koala is at the beach!\n\nThe bea...
[{"type": "stdin_stdout", "input": "1\n100 5 4\n1 -2 -1 0 0 4 3 3 1 3 1 5 3 3 0 3 3 6 3 5 6 0 3 3 4 0 2 2 2 0 2 2 4 2 2 4 3 2 3 6 0 0 3 2 1 0 0 2 1 1 3 4 6 9 5 8 12 2 2 0 6 2 4 2 3 1 3 4 2 3 3 2 2 3 2 1 0 2 1 1 0 5 3 3 3 1 8 4 4 11 6 3 1 2 4 4 2 -1 -1 1\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "1\n100 5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a weighted undirected 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\nLet's define the weight of the path consisti...
[{"type": "stdin_stdout", "input": "13 37\n3 9 6\n8 7 1\n7 4 10\n10 2 8\n13 1 8\n9 8 1\n8 1 1\n5 1 8\n4 13 5\n5 12 1\n2 9 8\n3 8 5\n1 10 10\n11 12 3\n11 8 3\n11 4 10\n7 1 2\n3 1 3\n10 13 10\n6 8 6\n8 5 1\n6 12 7\n5 7 4\n10 12 1\n9 7 6\n2 1 9\n7 11 2\n8 13 2\n5 13 9\n3 11 6\n10 9 10\n3 7 5\n12 4 3\n11 10 4\n1 11 2\n2 5 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou like numbers, don't you? Nastia has a lot of numbers and she wants to share them with you! Isn't it amazing?\n\nLet a_i be how many numbers i (1 ≀ i ≀ k) you have.\n\nAn n Γ— n matrix is called beautiful if it contains...
[{"type": "stdin_stdout", "input": "2\n3 4\n3 0 0 1\n16 4\n4 3 16 1\n", "output": "3\n1 1 4 \n0 0 0 \n0 1 0 \n6\n3 3 3 3 3 3 \n1 0 1 0 2 0 \n3 3 3 3 3 3 \n2 0 2 0 4 0 \n3 3 1 3 1 3 \n0 0 0 0 0 0 \n"}, {"type": "stdin_stdout", "input": "2\n3 4\n2 0 0 1\n15 4\n2 4 16 1\n", "output": "2\n1 1 \n4 0 \n6\n3 3 3 3 3 3 \n2 0 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string s of length n. Each character is either one of the first k lowercase Latin letters or a question mark.\n\nYou are asked to replace every question mark with one of the first k lowercase Latin letters...
[{"type": "stdin_stdout", "input": "466 10\nhga??dfdgae??j?f???h?jdd?????dhgc???????bj?j????b?be?b?jedd??g?cg????bj?b?h?heg?cb?e??hgf???fcd?g??hf?a????ie???if?deibf?j?g??cea?????????f?i?geh??h??gb?c?a?a?iei???caa?cieehd?b????cf??ei????ebjb?gijcf??fg?eg?agjba?eb????hh????aa??d????gg?e?b?g?bba???d??ea??b??c????babc?d???j...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Smart Beaver from ABBYY decided to have a day off. But doing nothing the whole day turned out to be too boring, and he decided to play a game with pebbles. Initially, the Beaver has n pebbles. He arranges them in a eq...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "1998535156\n"}, {"type": "stdin_stdout", "input": "999161856\n", "output": "1998319610\n"}, {"type": "stdin_stdout", "input": "999936000\n", "output": "1999743134\n"}, {"type": "stdin_stdout", "input": "999999948\n", "output": "1833697140\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format:\n\n<protocol>://<domain>.ru[/<c...
[{"type": "stdin_stdout", "input": "ftpprutpfrutrutptpfrutpfrutfrutrfrutpfrutprutruruu\n", "output": "ftp://p.ru/tpfrutrutptpfrutpfrutfrutrfrutpfrutprutruruu\n"}, {"type": "stdin_stdout", "input": "ftpprutufrutrutptpfrutpfrutfrutrfrutpfrptprutruruu\n", "output": "ftp://p.ru/tufrutrutptpfrutpfrutfrutrfrutpfrptprutruruu"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given the following concurrent program. There are N processes and the i-th process has the following pseudocode: \n \n \n repeat ni times \n yi := y \n y := yi + 1 \n end repeat \n ...
[{"type": "stdin_stdout", "input": "100 338\n118 26 134 55 135 221 39 49 175 39 98 23 124 38 411 224 107 124 100 38 90 146 205 89 10 30 6 173 102 210 15 45 90 86 36 231 171 152 62 109 55 13 237 2 16 126 27 80 235 10 80 171 119 6 19 112 42 80 14 8 57 11 17 71 117 41 119 326 11 14 151 15 5 34 138 50 1 81 165 46 39 44 65 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permutations. Iahubina is angry that she is no more important for Iahub. When Iahub goes away, Iahubina comes t...
[{"type": "stdin_stdout", "input": "20\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1\n", "output": "927799753\n"}, {"type": "stdin_stdout", "input": "10\n4 10 -1 1 6 8 9 2 -1 -1\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "6\n-1 -1 -1 -1 -1 -1\n", "output": "265\n"}, {"type": "stdin_stdout", ...
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 3 7 4 3 5 8 11 3 9 15 4 11 15 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 1 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 69 74 10 91 93 31 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBertown is under siege! The attackers have blocked all the ways out and their cannon is bombarding the city. Fortunately, Berland intelligence managed to intercept the enemies' shooting plan. Let's introduce the Cartesian...
[{"type": "stdin_stdout", "input": "6 389\n0.0303\n0.7536\n0.7225\n0.2404\n0.2432\n0.57407891942809\n3\n979.9372 478.06119955606886\n469.9804 408.1158\n924.0113575468439 220.5522\n", "output": "469.98040000 7.08571971\n15409.70354778 0.00000000\n469.98040000 401.57781402\n469.98040000 107.62902712\n469.98040000 109.014...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled \"a\" to \"z\", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos bein...
[{"type": "stdin_stdout", "input": "gggggggggggggggggggg\n", "output": "526\n"}, {"type": "stdin_stdout", "input": "coccoooogogcgocccmcg\n", "output": "526\n"}, {"type": "stdin_stdout", "input": "takttttaakaaktakttkt\n", "output": "526\n"}, {"type": "stdin_stdout", "input": "cskgsxywlvfeicoueglr\n", "output": "526\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an alphabet consisting of n letters, your task is to make a string of the maximum possible length so that the following conditions are satisfied: \n\n * the i-th letter occurs in the string no more than ai ...
[{"type": "stdin_stdout", "input": "26\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 10000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor.\n\nThere are n citizens in Kekoland, each person has ci coins. Each ...
[{"type": "stdin_stdout", "input": "123 54564\n38 44 41 42 59 3 95 15 45 32 44 69 35 83 94 57 65 85 64 47 24 20 34 86 26 91 98 12 36 96 80 4 70 40 95 38 70 22 58 50 34 84 80 45 14 60 61 43 11 56 19 59 50 63 35 15 97 98 27 13 9 71 32 18 90 10 2 99 75 87 74 83 79 37 89 3 49 27 92 95 49 1 26 82 72 75 81 37 60 98 28 28 10 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles ca...
[{"type": "stdin_stdout", "input": "25\n76 0 85 9\n46 0 55 9\n6 0 13 9\n86 0 95 9\n56 0 65 9\n152 0 157 9\n146 0 151 9\n14 0 21 9\n0 0 1 9\n180 0 189 9\n120 0 125 9\n96 0 99 9\n126 0 133 9\n158 0 169 9\n22 0 27 9\n100 0 107 9\n170 0 179 9\n2 0 5 17\n134 0 141 9\n114 0 119 9\n108 0 113 9\n66 0 75 9\n36 0 45 9\n142 0 145...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMisha and Grisha are funny boys, so they like to use new underground. The underground has n stations connected with n - 1 routes so that each route connects two stations, and it is possible to reach every station from any...
[{"type": "stdin_stdout", "input": "5 20\n5 5 1 4\n1 4 3\n2 4 1\n1 5 5\n5 1 4\n5 1 5\n1 5 5\n5 4 4\n2 3 3\n4 4 1\n1 4 1\n4 5 4\n1 4 5\n4 1 5\n2 4 2\n4 3 3\n2 5 5\n1 5 4\n3 3 4\n5 5 1\n3 4 1\n", "output": "3\n3\n3\n2\n3\n3\n2\n3\n2\n2\n2\n2\n2\n3\n3\n2\n2\n3\n3\n3\n"}, {"type": "stdin_stdout", "input": "5 20\n4 1 1 4\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCountry of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process.\n\nThere ar...
[{"type": "stdin_stdout", "input": "2 6 5\n1 1 0 5000\n3 2 0 5500\n2 2 0 6000\n15 0 2 9000\n9 0 1 7000\n8 0 2 6500\n", "output": " 24500\n"}, {"type": "stdin_stdout", "input": "10 10 1\n351 0 3 7\n214 0 9 9\n606 0 7 8\n688 0 9 3\n188 3 0 9\n994 0 1 7\n372 5 0 8\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn Ann's favorite book shop are as many as n books on math and economics. Books are numbered from 1 to n. Each of them contains non-negative number of problems.\n\nToday there is a sale: any subsegment of a segment from l...
[{"type": "stdin_stdout", "input": "10 10\n2 1 1 1 1 1 1 1 1 2\n0 10 10 0 0 10 10 10 10 0\n10\n4 10\n3 7\n9 9\n2 9\n10 10\n5 5\n2 2\n6 8\n3 4\n1 3\n", "output": "7\n7\n1\n10\n0\n0\n1\n3\n2\n3\n"}, {"type": "stdin_stdout", "input": "10 10\n2 1 1 1 1 1 1 1 1 2\n0 10 10 0 0 10 10 10 10 0\n10\n4 10\n3 7\n9 9\n2 9\n10 10\n5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSuppose you have two polynomials <image> and <image>. Then polynomial <image> can be uniquely represented in the following way:\n\n<image>\n\nThis can be done using [long division](https://en.wikipedia.org/wiki/Polynomial...
[{"type": "stdin_stdout", "input": "150\n", "output": "150\n1 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 1 0 1 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 0 1 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n\n\nInput\n\nThe input contains a single integer a (10 ≀ a ≀ 999).\n\nOutput\n\nOutput 0 or 1.\n\nExamples\n\nInput\n\n13\n\n\nOutput\n\n1\n\n\nInput\n\n927\n\n\nOutput\n\n1\n\n\nInput\n\n48\n\n\nOutput\n\n0\n\nThe input ...
[{"type": "stdin_stdout", "input": "927\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "758\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "496\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "957\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "835\n", "output": "1\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKuro is living in a country called Uberland, consisting of n towns, numbered from 1 to n, and n - 1 bidirectional roads connecting these towns. It is possible to reach each town from any other. Each road connects two town...
[{"type": "stdin_stdout", "input": "70 42 32\n25 50\n51 7\n39 61\n1 33\n20 5\n1 70\n1 63\n42 35\n64 16\n1 11\n39 42\n20 54\n11 14\n57 44\n1 59\n55 40\n25 3\n31 18\n38 68\n57 23\n39 57\n28 10\n39 20\n42 26\n58 6\n20 56\n57 2\n13 21\n15 69\n39 64\n1 39\n62 53\n39 13\n1 41\n22 12\n13 30\n68 67\n20 31\n51 15\n57 32\n59 34\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBenny noticed a random property of numbers. The numbers which followed this property were called as interesting numbers by Benny. Let's dive into what Benny discovered about these numbers.\n\n1 is an interesting number.\n...
[{"type": "stdin_stdout", "input": "100\n206848\n967423\n947070\n996389\n442876\n1161917\n242906\n244787\n1822273\n414286\n872996\n566711\n1271076\n257947\n388443\n388046\n175914\n683712\n181942\n159735\n1068857\n190120\n31615\n158307\n136192\n2168824\n571168\n103301\n853080\n939489\n210311\n1413810\n1822092\n234251\n6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer K. Print the string obtained by repeating the string `ACL` K times and concatenating them.\n\nFor example, if K = 3, print `ACLACLACL`.\n\nConstraints\n\n* 1 \\leq K \\leq 5\n* All values in input...
[{"type": "stdin_stdout", "input": "451", "output": "ACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACL...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, a...
[{"type": "stdin_stdout", "input": "31 61 59", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "31 61 51", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "31 86 59", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "39 69 59", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "31 49 59", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nShichi-Go-San (literally \"Seven-Five-Three\") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.\n\nTakahashi is now X years old. Will his growth be celebrat...
[{"type": "stdin_stdout", "input": "-132", "output": "NO\n"}, {"type": "stdin_stdout", "input": "-154", "output": "NO\n"}, {"type": "stdin_stdout", "input": "-133", "output": "NO\n"}, {"type": "stdin_stdout", "input": "-108", "output": "NO\n"}, {"type": "stdin_stdout", "input": "1271", "output": "NO\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn AtCoder Kingdom, Gregorian calendar is used, and dates are written in the \"year-month-day\" order, or the \"month-day\" order without the year.\nFor example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year...
[{"type": "stdin_stdout", "input": "-13 438", "output": "-13\n"}, {"type": "stdin_stdout", "input": "-18 766", "output": "-18\n"}, {"type": "stdin_stdout", "input": "-143 0", "output": "-143\n"}, {"type": "stdin_stdout", "input": "-212 0", "output": "-212\n"}, {"type": "stdin_stdout", "input": "-106 5", "output": "-106...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRingo has an undirected graph G with N vertices numbered 1,2,...,N and M edges numbered 1,2,...,M. Edge i connects Vertex a_{i} and b_{i} and has a length of w_i.\n\nNow, he is in the middle of painting these N vertices i...
[{"type": "stdin_stdout", "input": "18 37 12\n5 0 4 10 8 7 2 10 6 0 9 12 12 11 11 11 0 1\n17 1 1\n11 16 7575\n11 15 9\n10 10 289938980\n5 10 17376\n18 4 1866625\n8 11 959154208\n18 13 200\n16 13 2\n2 7 982223\n12 12 9331\n13 12 8861390\n14 13 743\n2 10 162440\n2 4 981849\n7 9 1\n14 27 2800\n2 7 7225452\n3 7 85\n5 17 4\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi wants to gain muscle, and decides to work out at AtCoder Gym.\n\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i...
[{"type": "stdin_stdout", "input": "5\n3\n-1\n4\n3\n4", "output": "-1\n"}, {"type": "stdin_stdout", "input": "5\n1\n3\n5\n2\n4", "output": "-1\n"}, {"type": "stdin_stdout", "input": "5\n1\n3\n5\n4\n4", "output": "-1\n"}, {"type": "stdin_stdout", "input": "5\n1\n3\n5\n2\n5", "output": "-1\n"}, {"type": "stdin_stdout", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two integers K and S.\nThree variable X, Y and Z takes integer values satisfying 0≀X,Y,Z≀K.\nHow many different assignments of values to X, Y and Z are there such that X + Y + Z = S?\n\nConstraints\n\n* 2≀K≀...
[{"type": "stdin_stdout", "input": "100 58", "output": "1770\n"}, {"type": "stdin_stdout", "input": "100 50", "output": "1326\n"}, {"type": "stdin_stdout", "input": "101 60", "output": "1891\n"}, {"type": "stdin_stdout", "input": "111 72", "output": "2701\n"}, {"type": "stdin_stdout", "input": "111 79", "output": "3240...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a grid with H rows and W columns. At first, all cells were painted white.\n\nSnuke painted N of these cells. The i-th ( 1 \\leq i \\leq N ) cell he painted is the cell at the a_i-th row and b_i-th column.\n\nCompu...
[{"type": "stdin_stdout", "input": "10 28 20\n0 1\n2 4\n1 9\n2 5\n0 6\n4 1\n1 7\n5 9\n6 4\n6 6\n6 5\n2 2\n10 3\n7 8\n16 1\n3 5\n11 10\n10 5\n17 4\n4 7", "output": "152\n28\n18\n10\n0\n0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "10 28 20\n0 1\n2 4\n1 9\n2 5\n0 6\n4 1\n1 7\n5 9\n6 4\n6 6\n6 5\n2 2\n10 1\n7 8\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDr .: Peter, I've finally done it.\nPeter: What's wrong, Dr. David? Is it a silly invention again?\nDr .: This table, this table.\n\n\n| Character | Sign\n--- | ---\n(Blank) | 101\n'| 000000\n, | 000011\n-| 10010001\n. | ...
[{"type": "stdin_stdout", "input": "URQDE ERQSQN", "output": "TSE?DV E?GT'PA\n"}, {"type": "stdin_stdout", "input": "UEQDR ERQSQN", "output": "TTJ'GF E?GT'PA\n"}, {"type": "stdin_stdout", "input": "RDQEU ERQSQN", "output": "QGP-HF E?GT'PA\n"}, {"type": "stdin_stdout", "input": "QDQEU ERQSQN", "output": "T,M? OLUJ'NH,'\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n\"What are your shoe sizes?\"\n\nSuddenly, the doctor asked me when I met him for the first time.\n\n\"It's 23.5\"\n\"Oh, that's a really nice number. It's 2 to the 4th power plus 2 to the 2nd power, 2 to the 1st power, 2...
[{"type": "stdin_stdout", "input": "27.100228165013633\n158.95452966627283\n-0.21569613349567962", "output": "NA\nNA\n"}, {"type": "stdin_stdout", "input": "27.432484603703674\n158.95452966627283\n-0.21569613349567962", "output": "NA\nNA\n"}, {"type": "stdin_stdout", "input": "27.932276079901406\n158.95452966627283\n-0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPCK Taxi in Aizu city, owned by PCK company, has adopted a unique billing system: the user can decide the taxi fare. Today as usual, many people are waiting in a queue at the taxi stand in front of the station.\n\nIn fron...
[{"type": "stdin_stdout", "input": "3\n6 8 10 0\n4 7 -1 1 15\n3 21 8 70", "output": "106\n"}, {"type": "stdin_stdout", "input": "3\n6 14 10 0\n4 7 -1 1 15\n3 21 8 47", "output": "83\n"}, {"type": "stdin_stdout", "input": "3\n6 8 10 0\n4 7 -1 1 15\n3 21 8 98", "output": "134\n"}, {"type": "stdin_stdout", "input": "3\n3 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet A, B, C, D, E be sets of integers and let U is a universal set that includes all sets under consideration. All elements in any set are different (no repetitions).\n\nu - union of two sets, AuB = {x ∈ U : x ∈ A or x ∈ ...
[{"type": "stdin_stdout", "input": "A 3\n1 2 -1\nB 4\n4 0 0 11\nD 1\n5\nR 0\ncAiBdD\nC 3\n1 2 3\nA 4\n2 7 8 0\nB 3\n3 6 21\nR 0\n(As(AiB))uB", "output": "0 4 11\n0 2 3 6 7 8 21\n"}, {"type": "stdin_stdout", "input": "A 3\n2 3 -1\nB 4\n3 1 10 11\nD 1\n5\nR 0\ncAiBdD\nC 3\n1 2 3\nA 4\n2 10 8 3\nB 3\n2 4 7\nR 0\n(As(AiB))...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTaro and Hanako have numbers of cards in their hands. Each of the cards has a score on it. Taro and Hanako wish to make the total scores of their cards equal by exchanging one card in one's hand with one card in the other...
[{"type": "stdin_stdout", "input": "2 2\n1\n6\n3\n14\n6 5\n3\n4\n5\n2\n4\n7\n11\n2\n7\n4\n1\n4 5\n10\n-1\n3\n11\n1\n9\n6\n0\n1\n7 4\n1\n0\n4\n0\n2\n1\n4\n4\n2\n1\n-1\n2 3\n0\n1\n2\n4\n2\n0 0", "output": "-1\n2 2\n3 0\n2 -1\n-1\n"}, {"type": "stdin_stdout", "input": "2 2\n1\n6\n3\n14\n6 5\n3\n4\n5\n2\n4\n7\n11\n2\n7\n4\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nInternational Center for Picassonian Cubism is a Spanish national museum of cubist artworks, dedicated to Pablo Picasso. The center held a competition for an artwork that will be displayed in front of the facade of the mu...
[{"type": "stdin_stdout", "input": "5 5\n1 2 3 2 5\n1 2 1 4 5\n5 5\n2 3 3 1 3\n4 1 5 3 2\n5 5\n1 2 3 4 5\n3 3 1 4 5\n3 3\n7 7 7\n7 14 7\n3 3\n2 4 4\n4 3 4\n4 3\n4 0 2 5\n0 2 1\n4 4\n2 8 8 8\n2 3 8 3\n10 10\n9 9 9 9 17 9 9 17 9 9\n9 16 9 9 9 9 9 9 9 3\n10 9\n20 1 20 20 20 20 20 18 20 20\n20 20 20 20 7 17 20 20 4\n0 0", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSpace Coconut Crab\n\nSpace coconut crab\n\nEnglish text is not available in this practice contest.\n\nKen Marine Blue is a space hunter who travels through the entire galaxy in search of space coconut crabs. The space co...
[{"type": "stdin_stdout", "input": "1\n2\n4\n48\n266\n1236\n0", "output": "1\n2\n2\n12\n14\n36\n"}, {"type": "stdin_stdout", "input": "1\n2\n4\n48\n266\n1300\n0", "output": "1\n2\n2\n12\n14\n38\n"}, {"type": "stdin_stdout", "input": "1\n2\n4\n27\n557\n1250\n0", "output": "1\n2\n2\n3\n23\n44\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMr. A and Mr. B live in an N Γ— M rectangular grid area. Each square is either a road, a wall, or a house. Since this area is famous for the frequent occurrence of molestation damage due to the complicated and intricate ro...
[{"type": "stdin_stdout", "input": "4 4\n....\n.#.G\n...#\n..#^", "output": "-1\n"}, {"type": "stdin_stdout", "input": "4 4\n-...\nG.#.\n...#\n^#..", "output": "13\n"}, {"type": "stdin_stdout", "input": "4 4\n....\nG.#.\n...#\n..\"^", "output": "11\n"}, {"type": "stdin_stdout", "input": "4 4\n./..\n.#.G\n...#\n..#^", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFind the area of intersection between a circle $c$ and a polygon $g$. The center coordinate of the circle is ($0, 0$).\n\nThe polygon $g$ is represented by a sequence of points $p_1$, $p_2$,..., $p_n$ where line segments ...
[{"type": "stdin_stdout", "input": "4 5\n0 0\n-3 -6\n1 -3\n5 -4", "output": "11.787686807576"}, {"type": "stdin_stdout", "input": "4 16\n-1 0\n-1 -5\n1 -3\n10 -5", "output": "16.50000000\n"}, {"type": "stdin_stdout", "input": "4 8\n-1 0\n-3 -5\n1 -3\n10 -6", "output": "17.27422100\n"}, {"type": "stdin_stdout", "input":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a dictionary $M$ that stores elements formed by a pair of a string key and an integer value, perform a sequence of the following operations. Note that each key in $M$ must be unique.\n\n* insert($key$, $x$): Insert an...
[{"type": "stdin_stdout", "input": "8\n0 blue 4\n0 der 0\n0 white 10\n1 esd\n1 bmue\n1 der\n1 black\n1 qed", "output": "0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "8\n0 blue 4\n0 red 1\n0 white 10\n1 red\n1 bmue\n1 red\n1 kcalb\n1 rdd", "output": "1\n0\n1\n0\n0\n"}, {"type": "stdin_stdout", "input": "8\n0 blu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSince Sonya has just learned the basics of matrices, she decided to play with them a little bit.\n\nSonya imagined a new type of matrices that she called rhombic matrices. These matrices have exactly one zero, while all o...
[{"type": "stdin_stdout", "input": "20\n1 0 2 3 5 3 2 1 3 2 3 1 4 2 1 4 2 3 2 4\n", "output": "4 5\n2 2\n"}, {"type": "stdin_stdout", "input": "18\n2 2 3 2 4 3 3 3 0 2 4 2 1 3 2 1 1 1\n", "output": "3 6\n2 3\n"}, {"type": "stdin_stdout", "input": "20\n1 0 2 3 5 10 2 2 5 4 3 2 2 2 1 3 0 3 2 4\n", "output": "-1\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's consider a simplified version of order book of some stock. The order book is a list of orders (offers) from people that want to buy or sell one unit of the stock, each order is described by direction (BUY or SELL) a...
[{"type": "stdin_stdout", "input": "15\nADD 14944938\nADD 40032655\nACCEPT 14944938\nACCEPT 40032655\nADD 79373162\nACCEPT 79373162\nADD 55424250\nACCEPT 55424250\nADD 67468892\nACCEPT 67468892\nADD 51815959\nADD 18075798\nADD 2040654\nADD 74300637\nACCEPT 51815959\n", "output": "32\n"}, {"type": "stdin_stdout", "input...
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": "20\n10 1 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": "20\n16 1 2 3 5 7 7 9 4 9 9 4 9 7 7 5 3 2 5 10\n", "output": "NO\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base.\n\nLet we represent their base with an array, where each position can be occupied by many avengers, but one avenger ca...
[{"type": "stdin_stdout", "input": "5 3 10000 2737\n5 12 2\n", "output": "52844\n"}, {"type": "stdin_stdout", "input": "5 3 3521 10010\n5 12 2\n", "output": "58198\n"}, {"type": "stdin_stdout", "input": "5 3 3521 10000\n6 12 2\n", "output": "58168\n"}, {"type": "stdin_stdout", "input": "5 3 10000 3241\n10 6 2\n", "outp...
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 moves needed...
[{"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\nYou are given a binary string s (recall that a string is binary if each character is either 0 or 1).\n\nLet f(t) be the decimal representation of integer t written in binary form (possibly with leading zeroes). For exampl...
[{"type": "stdin_stdout", "input": "4\n0110\n0101\n00001000\n0001000\n", "output": "4\n3\n4\n3\n"}, {"type": "stdin_stdout", "input": "4\n0110\n1101\n00001000\n0001000\n", "output": "4\n4\n4\n3\n"}, {"type": "stdin_stdout", "input": "4\n0110\n1101\n00001000\n0101000\n", "output": "4\n4\n4\n5\n"}, {"type": "stdin_stdout...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSeveral days ago you bought a new house and now you are planning to start a renovation. Since winters in your region can be very cold you need to decide how to heat rooms in your house.\n\nYour house has n rooms. In the i...
[{"type": "stdin_stdout", "input": "69\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 15\n2 6\n2 6\n2 6\n2 6\n2 6\n2 11\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 7\n2 11\n2 6\n2 6\n2 6\n2 6\n4 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlicia has an array, a_1, a_2, …, a_n, of non-negative integers. For each 1 ≀ i ≀ n, she has found a non-negative integer x_i = max(0, a_1, …, a_{i-1}). Note that for i=1, x_i = 0.\n\nFor example, if Alicia had the array ...
[{"type": "stdin_stdout", "input": "35\n15 13 -25 -7 -18 -16 4 -15 2 -23 0 -3 -26 -27 -24 -27 -22 1 -52 -19 -16 -15 -29 -43 -18 -27 -11 -20 -2 -11 -20 -30 -1 -13 -46\n", "output": "15 28 3 21 10 12 32 17 34 11 34 31 8 7 10 7 12 35 -17 16 19 20 6 -8 17 8 24 15 33 24 15 5 34 22 -11 "}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a special jigsaw puzzle consisting of nβ‹… m identical pieces. Every piece has three tabs and one blank, as pictured below.\n\n<image>\n\nThe jigsaw puzzle is considered solved if the following conditions hold...
[{"type": "stdin_stdout", "input": "3\n1 10\n001000 100000\n10 2\n", "output": "YES\nNO\nNO\n"}, {"type": "stdin_stdout", "input": "3\n1 10\n001000 100000\n16 2\n", "output": "YES\nNO\nNO\n"}, {"type": "stdin_stdout", "input": "3\n1 12\n110000 101110\n1 2\n", "output": "YES\nNO\nYES\n"}, {"type": "stdin_stdout", "input...
code_stdio