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\nLeha is planning his journey from Moscow to Saratov. He hates trains, so he has decided to get from one city to another by car.\n\nThe path from Moscow to Saratov can be represented as a straight line (well, it's not that... | [{"type": "stdin_stdout", "input": "100\n3 3 3 4 7 8 8 8 9 9 10 12 12 13 14 14 15 15 16 17 17 20 21 21 22 22 23 25 29 31 36 37 37 38 39 10 41 41 41 42 43 44 45 46 46 47 47 49 49 49 51 52 52 53 54 55 59 59 59 60 62 63 63 64 66 69 70 71 71 72 74 76 76 77 77 78 78 79 80 81 81 82 82 84 85 86 87 87 87 89 91 92 92 92 92 97 9... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAt many competitions that have a word Β«cupΒ» in its official name the winner is presented with an actual cup. This time the organizers of one unusual programming competition have decided to please the winner even more and ... | [{"type": "stdin_stdout", "input": "QDpiNBmCRFWxpdbfGOzvvOcemjructoAdEwegTvbVbfWWRPGyEAxGdDRWVlqNyGWMWHMrHAIZpyxvgaflrsVZhhZRouvpxrKXFZa\n", "output": "5 20\nQDpiNBmCRFWxpdbfGOzv\nvOcemjructoAdEwegTvb\nVbfWWRPGyEAxGdDRWVlq\nNyGWMWHMrHAIZpyxvgaf\nlrsVZhhZRouvpxrKXFZa\n"}, {"type": "stdin_stdout", "input": "QDpiNBmCRFWxp... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIlya lives in a beautiful city of Chordalsk.\n\nThere are n houses on the street Ilya lives, they are numerated from 1 to n from left to right; the distance between every two neighboring houses is equal to 1 unit. The nei... | [{"type": "stdin_stdout", "input": "41\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1\n", "output": "39\n"}, {"type": "stdin_stdout", "input": "41\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 16 19 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1\n", "outpu... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn this problem you have to solve a simple classification task: given an image, determine whether it depicts a Fourier doodle. \n\nYou are given a set of 50 images with ids 1 through 50. You are also given a text file lab... | [{"type": "stdin_stdout", "input": "-116\n", "output": "0\n1\n1\n0\n1\n1\n0\n1\n1\n1\n1\n1\n0\n1\n0\n1\n1\n1\n0\n1\n1\n1\n1\n1\n0\n1\n0\n1\n1\n1\n"}, {"type": "stdin_stdout", "input": "-132\n", "output": "0\n1\n1\n0\n1\n1\n0\n1\n1\n1\n1\n1\n0\n1\n0\n1\n1\n1\n0\n1\n1\n1\n1\n1\n0\n1\n0\n1\n1\n1\n"}, {"type": "stdin_stdou... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven a positive integer m, we say that a sequence x_1, x_2, ..., x_n of positive integers is m-cute if for every index i such that 2 β€ i β€ n it holds that x_i = x_{i - 1} + x_{i - 2} + ... + x_1 + r_i for some positive i... | [{"type": "stdin_stdout", "input": "20\n55 41281776055438 9\n16 67246008464266 18\n69 91089644324882 2\n39 87960930222080 1\n36 88548139500148 9\n18 26775940243079 14\n10 82202722513992 12\n26 89451917375946 20\n69 77900225490904 18\n28 70399749705714 15\n95 177066709280014 8\n54 66641166632298 18\n83 54867502014847 19... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMethodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keybo... | [{"type": "stdin_stdout", "input": "10\naaaa\naaaab\naaaa\nbaaaa\na\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\na\nb\naaaaa\naaaa\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaba\naaaaaaaaaaaaaaaaaaa... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version.\n\nPolycarp is a very famous freelancer. His current rating is r u... | [{"type": "stdin_stdout", "input": "50 15000\n142 -300\n20 -298\n560 -300\n1815 -292\n282 -297\n92 -293\n34 -284\n555 -299\n408 -293\n504 -284\n278 -284\n139 -291\n64 -298\n311 -293\n130 -293\n89 -298\n129 -294\n385 -295\n136 -288\n41 -293\n112 -290\n416 -295\n178 -294\n154 -300\n110 -300\n346 -299\n209 -294\n1394 -295... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBoy Dima gave Julian a birthday present β set B consisting of positive integers. However, he didn't know, that Julian hates sets, but enjoys bipartite graphs more than anything else!\n\nJulian was almost upset, but her fr... | [{"type": "stdin_stdout", "input": "10\n15 44 84 89 18 86 23 20 62 81\n", "output": "6\n 44 84 18 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWhile doing some spring cleaning, Daniel found an old calculator that he loves so much. However, it seems like it is broken. When he tries to compute 1 + 3 using the calculator, he gets 2 instead of 4. But when he tries c... | [{"type": "stdin_stdout", "input": "3\n1 8\n378 590\n0 1001000\n", "output": "26\n3586\n3444149719\n"}, {"type": "stdin_stdout", "input": "3\n0 4\n378 590\n1 1000000\n", "output": "17\n3586\n3439863766\n"}, {"type": "stdin_stdout", "input": "3\n1 4\n323 590\n1 1000000\n", "output": "8\n4758\n3439863766\n"}, {"type": "s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAn integer sequence is called beautiful if the difference between any two consecutive numbers is equal to 1. More formally, a sequence s_1, s_2, β¦, s_{n} is beautiful if |s_i - s_{i+1}| = 1 for all 1 β€ i β€ n - 1.\n\nTrans... | [{"type": "stdin_stdout", "input": "139 140 2362 2360\n", "output": "YES\n0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAshishgup and FastestFinger play a game. \n\nThey start with a number n and play in turns. In each turn, a player can make any one of the following moves:\n\n * Divide n by any of its odd divisors greater than 1. \n * S... | [{"type": "stdin_stdout", "input": "100\n101\n102\n103\n104\n105\n106\n107\n108\n109\n110\n111\n112\n113\n114\n15\n116\n117\n118\n119\n120\n121\n122\n123\n124\n125\n126\n127\n128\n100\n130\n131\n132\n133\n134\n135\n136\n137\n120\n139\n140\n141\n142\n143\n144\n145\n146\n147\n148\n149\n150\n151\n152\n153\n154\n155\n156\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nzscoder has a deck of n+m custom-made cards, which consists of n cards labelled from 1 to n and m jokers. Since zscoder is lonely, he wants to play a game with himself using those cards. \n\nInitially, the deck is shuffle... | [{"type": "stdin_stdout", "input": "1999992 1999927\n", "output": "334593851\n"}, {"type": "stdin_stdout", "input": "1999968 1999941\n", "output": "499830706\n"}, {"type": "stdin_stdout", "input": "1999913 1999918\n", "output": "667185390\n"}, {"type": "stdin_stdout", "input": "2000000 2000000\n", "output": "507914970\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTenten runs a weapon shop for ninjas. Today she is willing to sell n shurikens which cost 1, 2, ..., n ryo (local currency). During a day, Tenten will place the shurikens onto the showcase, which is empty at the beginning... | [{"type": "stdin_stdout", "input": "10\n+\n- 3\n+\n+\n+\n+\n- 1\n- 7\n- 9\n- 10\n+\n+\n+\n- 4\n- 5\n- 8\n+\n- 6\n+\n- 2\n", "output": "YES\n3 10 9 7 1 8 5 4 6 2 "}, {"type": "stdin_stdout", "input": "10\n+\n- 1\n+\n+\n+\n+\n- 1\n- 7\n- 9\n- 10\n+\n+\n+\n- 7\n- 10\n- 8\n+\n+\n- 6\n- 2\n", "output": "NO\n"}, {"type": "st... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA robot is standing at the origin of the infinite two-dimensional plane. Each second the robot moves exactly 1 meter in one of the four cardinal directions: north, south, west, and east. For the first step the robot can c... | [{"type": "stdin_stdout", "input": "1000\n", "output": "251001\n"}, {"type": "stdin_stdout", "input": "777\n", "output": "303420\n"}, {"type": "stdin_stdout", "input": "999\n", "output": "501000\n"}, {"type": "stdin_stdout", "input": "998\n", "output": "250000\n"}, {"type": "stdin_stdout", "input": "795\n", "output": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven a positive integer k, two arrays are called k-similar if:\n\n * they are strictly increasing; \n * they have the same length; \n * all their elements are positive integers between 1 and k (inclusive); \n * they ... | [{"type": "stdin_stdout", "input": "6 5 15\n2 5 6 7 8 15\n1 2\n1 1\n5 5\n5 6\n4 5\n", "output": "15\n14\n14\n19\n13\n"}, {"type": "stdin_stdout", "input": "6 5 15\n2 5 6 4 8 15\n1 2\n1 1\n5 5\n5 6\n4 5\n", "output": "15\n14\n14\n19\n16\n"}, {"type": "stdin_stdout", "input": "6 5 13\n2 4 6 7 8 12\n1 4\n1 3\n3 5\n2 2\n5 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe student council is preparing for the relay race at the sports festival.\n\nThe council consists of n members. They will run one after the other in the race, the speed of member i is s_i. The discrepancy d_i of the i-t... | [{"type": "stdin_stdout", "input": "100\n9135 4978 1897 347 1835 10266 9413 1712 1496 347 8724 4978 7037 7498 9022 720 6342 927 6927 1712 1897 9022 6046 8549 726 6598 10764 9227 4319 4016 11900 4782 1785 4118 3120 568 9160 3015 195 3317 2463 4186 7037 2373 4025 2677 4118 4025 4168 9808 5235 9160 4308 9570 5607 9227 227... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\n2^k teams participate in a playoff tournament. The tournament consists of 2^k - 1 games. They are held as follows: first of all, the teams are split into pairs: team 1 plays against team 2, team 3 plays against team 4 (ex... | [{"type": "stdin_stdout", "input": "3\n0110?11\n6\n5 1\n6 ?\n7 ?\n1 ?\n5 ?\n1 1\n", "output": "\n1\n2\n3\n3\n5\n4\n"}, {"type": "stdin_stdout", "input": "3\n0110?11\n6\n5 1\n6 ?\n7 ?\n2 ?\n5 ?\n1 1\n", "output": "1\n2\n3\n4\n5\n5\n"}, {"type": "stdin_stdout", "input": "3\n0110?11\n6\n5 1\n6 ?\n6 ?\n1 ?\n5 ?\n1 1\n", "o... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given n segments on the Ox-axis. You can drive a nail in any integer point on the Ox-axis line nail so, that all segments containing this point, are considered nailed down. If the nail passes through endpoint of s... | [{"type": "stdin_stdout", "input": "35\n-47 61\n-73 -15\n9 43\n43 -4\n13 -6\n48 -65\n49 -84\n-6 76\n40 6\n-41 11\n-63 -42\n-7 -7\n47 -98\n-17 61\n79 99\n47 -98\n61 31\n85 72\n-50 -17\n-67 45\n14 -50\n-45 61\n-6 -96\n-47 -83\n56 -58\n-24 -15\n14 20\n-95 -82\n47 93\n-4 -7\n70 9\n91 -18\n-71 31\n55 -20\n81 -8\n", "output"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGena loves sequences of numbers. Recently, he has discovered a new type of sequences which he called an almost arithmetical progression. A sequence is an almost arithmetical progression, if its elements can be represented... | [{"type": "stdin_stdout", "input": "73\n531 626 701 57 708 511 54 441 297 697 411 253 397 652 21 59 851 561 539 461 629 894 275 417 127 505 433 243 963 247 5 368 969 541 408 485 319 117 441 131 265 357 1 659 267 983 643 285 913 782 813 569 99 781 297 636 645 341 6 17 601 129 509 197 226 105 241 737 86 128 762 647 849\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou've got an array, consisting of n integers a1, a2, ..., an. Also, you've got m queries, the i-th query is described by two integers li, ri. Numbers li, ri define a subsegment of the original array, that is, the sequenc... | [{"type": "stdin_stdout", "input": "100 10\n53 72 2 58 6 48 65 13 43 9 77 1 58 28 49 95 12 11 7 36 51 25 78 20 6 2 69 76 1 47 17 6 91 54 50 66 69 122 74 31 19 96 35 84 163 15 65 73 66 73 29 53 17 47 3 19 4 16 85 6 49 6 57 70 96 19 66 92 86 61 10 21 11 82 13 98 59 96 85 1 13 65 28 34 143 16 88 32 60 50 33 37 36 57 97 28... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYaroslav is playing a game called \"Time\". The game has a timer showing the lifespan he's got left. As soon as the timer shows 0, Yaroslav's character dies and the game ends. Also, the game has n clock stations, station ... | [{"type": "stdin_stdout", "input": "22 1000\n22 609 173 244 930 515 169 56 192 974 923 749 652 987 145 447 1116 518 630 917\n13 93\n99 6\n41 -54\n67 -85\n24 38\n23 -65\n9 -60\n-29 -78\n-29 -32\n53 -70\n-83 -50\n31 1\n-85 16\n74 95\n-30 10\n114 -67\n70 -74\n-78 -73\n19 17\n97 4\n97 -27\n-4 -48\n", "output": "158000\n"},... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nn soldiers stand in a circle. For each soldier his height ai is known. A reconnaissance unit can be made of such two neighbouring soldiers, whose heights difference is minimal, i.e. |ai - aj| is minimal. So each of them w... | [{"type": "stdin_stdout", "input": "88\n1000 1000 1000 1000 1000 998 998 1000 1000 1000 1000 999 999 1000 1000 1000 999 1000 997 999 997 1000 999 998 1000 999 1000 1000 1000 999 1000 999 999 1000 1000 999 1000 999 1000 1000 998 1000 1000 1000 998 998 1000 1000 999 1000 1000 1000 1000 1000 1000 1000 998 1000 1000 1000 9... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.\n\nYou want to make a consecutive integer sequence starting from number m (m, ... | [{"type": "stdin_stdout", "input": "10000000000000000 10000000000000000 1000000000\n", "output": "588235\n"}, {"type": "stdin_stdout", "input": "10000000000000000 10000000000000000 1\n", "output": "588235294117647\n"}, {"type": "stdin_stdout", "input": "10000000010000000 10000000000000000 1\n", "output": "5882352947058... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe Physical education teacher at SESC is a sort of mathematician too. His most favorite topic in mathematics is progressions. That is why the teacher wants the students lined up in non-decreasing height form an arithmeti... | [{"type": "stdin_stdout", "input": "100\n246 485 -940 -186 -841 -98 711 429 -154 164 -244 -111 886 -447 22 480 224 -132 927 812 -243 -152 -843 403 -320 -346 -407 827 645 -903 -172 540 -359 498 270 18 374 -52 -983 -164 -707 -242 -159 -825 -889 661 -629 212 849 -891 -622 810 957 897 -110 -293 -257 822 690 369 -914 212 -3... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPeter has a sequence of integers a1, a2, ..., an. Peter wants all numbers in the sequence to equal h. He can perform the operation of \"adding one on the segment [l, r]\": add one to all elements of the sequence with indi... | [{"type": "stdin_stdout", "input": "99 1999\n1999 1998 1997 1996 1995 1994 1993 1992 1991 1990 1989 1988 1987 1986 1985 1984 1983 1982 1981 1980 1979 1978 1977 1976 1975 1974 1973 1972 1971 1970 1969 1968 1967 1966 1965 1964 1963 1962 1961 1960 1959 1958 1957 1956 1955 1954 1953 1952 1951 1950 1951 1952 1953 1954 1955 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya has a beautiful garden where wonderful fruit trees grow and yield fantastic harvest every year. But lately thieves started to sneak into the garden at nights and steal the fruit too often. Vasya canβt spend the nigh... | [{"type": "stdin_stdout", "input": "10 10\n1 0 1 1 1 1 1 1 1 1\n1 1 1 0 1 1 0 1 1 1\n1 0 1 0 1 1 1 1 0 1\n1 1 0 1 1 1 0 0 0 1\n0 1 0 1 1 1 0 1 1 1\n1 0 1 0 1 0 1 1 1 1\n1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 0 1 1\n1 1 1 1 0 1 1 1 1 1\n0 1 1 1 1 0 1 1 0 1\n10 10\n", "output": "79\n"}, {"type": "stdin_stdout", "input": "10 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBerland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room.\n\nToday was the pilot la... | [{"type": "stdin_stdout", "input": "50\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPasha has a wooden stick of some positive integer length n. He wants to perform exactly three cuts to get four parts of the stick. Each part must have some positive integer length and the sum of these lengths will obvious... | [{"type": "stdin_stdout", "input": "1757577394\n", "output": "439394348\n"}, {"type": "stdin_stdout", "input": "1925088820\n", "output": "481272204\n"}, {"type": "stdin_stdout", "input": "1967345604\n", "output": "491836400\n"}, {"type": "stdin_stdout", "input": "1976637136\n", "output": "494159283\n"}, {"type": "stdin... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIT City company developing computer games decided to upgrade its way to reward its employees. Now it looks the following way. After a new game release users start buying it actively, and the company tracks the number of s... | [{"type": "stdin_stdout", "input": "1000000000000000000\n", "output": "228571428571428571\n"}, {"type": "stdin_stdout", "input": "1000000010000000000\n", "output": "228571430857142858\n"}, {"type": "stdin_stdout", "input": "1334196189585702396\n", "output": "304959129048160547\n"}, {"type": "stdin_stdout", "input": "13... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.\n\nTania has ... | [{"type": "stdin_stdout", "input": "5 100000000\n100000000 999999999 1 2 3\n", "output": "14138\n4 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 8... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasily exited from a store and now he wants to recheck the total price of all purchases in his bill. The bill is a string in which the names of the purchases and their prices are printed in a row without any spaces. Check... | [{"type": "stdin_stdout", "input": "amhppqxei543.370.32o544.196nocwgxticn776.562nm212.195dcftrrg635.773n646.814.94vrfmjjsgoi405.114k821.983.12rb749.955.62jifmdlgs615.101hg42.083.41gdqififg908.729qrrgopyn684.451avcjul727.150s864.068bcd196.732.37jd349.984.25ghn379.763.11dw881.650.19eysthrm790.534.68gilg546.048qs648.876pd... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSanta Claus has Robot which lives on the infinite grid and can move along its lines. He can also, having a sequence of m points p1, p2, ..., pm with integer coordinates, do the following: denote its initial location by p0... | [{"type": "stdin_stdout", "input": "26\nRURULRRURUDLULDLDLDURLRDDL\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "26\nRURULRRLRUDUULLLDLDURDRDLD\n", "output": "11\n"}, {"type": "stdin_stdout", "input": "26\nLDDRLRUDLDLDLULDURURRLURUR\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "26\nLDDRLRLDLDLDL... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if they got an order that Bob ... | [{"type": "stdin_stdout", "input": "50 2\nYES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES\n", "output": "Aa Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av A... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nZane the wizard is going to perform a magic show shuffling the cups.\n\nThere are n cups, numbered from 1 to n, placed along the x-axis on a table that has m holes on it. More precisely, cup i is on the table at the posit... | [{"type": "stdin_stdout", "input": "203948 2 14\n203948 203947\n39 47\n4959 3030\n1 203947\n2929 12381\n203944 203948\n203947 203944\n203944 203922\n203922 203948\n2495 20495\n29419 5959\n12949 12\n49 29292\n1 94\n1 203\n", "output": "203947\n"}, {"type": "stdin_stdout", "input": "203948 2 14\n203948 203947\n39 38\n495... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOn the way to school, Karen became fixated on the puzzle game on her phone!\n\n<image>\n\nThe game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0... | [{"type": "stdin_stdout", "input": "1 100\n396 314 350 362 287 349 266 289 297 305 235 226 256 385 302 304 253 192 298 238 360 366 163 340 247 395 318 260 252 281 178 188 252 379 212 187 354 232 225 159 290 335 387 234 383 215 356 182 323 280 195 209 263 215 322 262 334 157 189 214 195 386 220 209 177 193 368 174 270 3... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLeha like all kinds of strange things. Recently he liked the function F(n, k). Consider all possible k-element subsets of the set [1, 2, ..., n]. For subset find minimal element in it. F(n, k) β mathematical expectation o... | [{"type": "stdin_stdout", "input": "7\n4 12 5 15 8 2 5\n2 1 2 0 1 1 1\n", "output": "4 12 2 15 8 5 5\n"}, {"type": "stdin_stdout", "input": "7\n4 12 5 8 10 2 3\n2 1 2 1 1 1 2\n", "output": "4 12 3 10 8 5 2\n"}, {"type": "stdin_stdout", "input": "7\n4 12 5 8 10 2 3\n2 2 2 1 1 1 2\n", "output": "5 4 3 12 10 8 2\n"}, {"ty... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPetya has n positive integers a1, a2, ..., an. \n\nHis friend Vasya decided to joke and replaced all digits in Petya's numbers with a letters. He used the lowercase letters of the Latin alphabet from 'a' to 'j' and replac... | [{"type": "stdin_stdout", "input": "50\ng\nha\nhd\ndi\nac\nfdhhb\ng\nhgeag\nafafb\nb\nb\najjj\ncaiadi\nhciifa\nhb\ncaih\ncdbbi\ngjff\nbfe\neddci\ndijfie\nacjj\nef\ng\njdc\nahg\ne\nhbbh\ncdc\njifdc\ne\nffaehj\nhjhi\ng\neag\nfbbc\nchg\njhahfg\nbb\njd\njchh\nbefifj\nejac\ne\nh\njfhb\nedhe\nf\nag\nca\n", "output": "2673136... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou have a team of N people. For a particular task, you can pick any non-empty subset of people. The cost of having x people for the task is xk. \n\nOutput the sum of costs over all non-empty subsets of people.\n\nInput\n... | [{"type": "stdin_stdout", "input": "1000000000 5000\n", "output": "642932262\n"}, {"type": "stdin_stdout", "input": "880895728 3537\n", "output": "266659411\n"}, {"type": "stdin_stdout", "input": "602436426 4445\n", "output": "582490088\n"}, {"type": "stdin_stdout", "input": "971407775 4325\n", "output": "905271522\n"}... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBrio got his house constructed near the National Highway. The Construction and Planning Committee has planned to construct a road near his house. Brio is worried about the Committee's plan as he fears that his house might... | [{"type": "stdin_stdout", "input": "2\n4 7 -2 -1 \n1\n-1 13 -1 -1\n1\n\nDLOMCS", "output": "JUST MISSED\nJUST MISSED\n"}, {"type": "stdin_stdout", "input": "2\n10 1 -1 0 \n1\n2 1 0 0\n0\n\nEAMPMR", "output": "REPLANNING\nJUST MISSED\n"}, {"type": "stdin_stdout", "input": "2\n5 3 -5 5 \n4\n1 2 3 4\n5\n\nSAMPLE", "output... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDarshak (Dark) completed with his studies and became a engineer, now to earn his bread he decided to start a company, being a son of rich men he need not to think about investors. \n\nHe came up with a idea of bringing ... | [{"type": "stdin_stdout", "input": "5000\n1\n931733\n694459\n638630\n749751\n238760\n886106\n762142\n517246\n642611\n203388\n491378\n369474\n521162\n899808\n515894\n181906\n384967\n89477\n457040\n5247\n595890\n702862\n958156\n466119\n22392\n723141\n665357\n176213\n703604\n515031\n981604\n635338\n723694\n134439\n899293\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are two kind of bots in the game BOT A and BOT B. Both are designed so as to move only in one direction in a 1-D array. Bot A can move towards left whereas bot B is constrained to move rightwards. Both are constrain... | [{"type": "stdin_stdout", "input": "2\n#A#B#B# A###B#B\n#A#B# #B#A#\n\nSAMPLE", "output": "Yes\nNo\n"}, {"type": "stdin_stdout", "input": "2\n#A#B#B# A###B#B\n#A#B# #B#A#\n\nS@MPLE", "output": "Yes\nNo\n"}, {"type": "stdin_stdout", "input": "2\n#A#B#A# A###B#B\n#A#B# #B#A#\n\nSAMPLE", "output": "No\nNo\n"}, {"type": "s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMike lost in a coding contest just because he was not aware with the concept of palindrome properly.\nSo finally he learnt about it and decided to mess up with the Winners name of the contest as he will now meddle with le... | [{"type": "stdin_stdout", "input": "10\nwtqhatpvjsdgtbmathmxekisqvvgraxntnuuilrugwazxmatumqawysowoxnoucjjyfrkxlqtlrryrkufcuebmuzcroslqcuqhoagzsalktlddflhzpknjjsbzkopolgyzieadelpxyscdfkeuuuggmjfyzxnkfllprmswxhvycydhkiegekosvuqutffyqqpkeigepbctbfbnpfwtrknmgegzlnzegpokzuooxqibylonsmjjxwxdcffotesbvglucalbsvcsgtgyfrjepgisln... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nEvery one is now a days playing games on their smartphones for passing free time. Because of which there are number of game developing companies growing in the market. Not only that, each company is now flooding the marke... | [{"type": "stdin_stdout", "input": "2 3 3\n10 20 31\n7 24 100\n11 13\n35 13\n010 1002\n\nSAMPLE", "output": "1\n1\n1\n"}, {"type": "stdin_stdout", "input": "2 3 3\n10 20 30\n3 14 100\n11 10\n19 13\n100 1002\n\nSAMPLE", "output": "1\n1\n3\n"}, {"type": "stdin_stdout", "input": "2 3 3\n10 20 30\n3 14 100\n11 10\n16 13\n1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or... | [{"type": "stdin_stdout", "input": "1000000000000000 1000100000000000 1000000000000000", "output": "1000000000000000\n"}, {"type": "stdin_stdout", "input": "1101110100000001 1010101001100000 1110001000000000", "output": "1101110100000001\n"}, {"type": "stdin_stdout", "input": "1101010100000001 1010101000100000 11100010... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nConsider sequences \\\\{A_1,...,A_N\\\\} of length N consisting of integers between 1 and K (inclusive).\n\nThere are K^N such sequences. Find the sum of \\gcd(A_1, ..., A_N) over all of them.\n\nSince this sum can be eno... | [{"type": "stdin_stdout", "input": "101000 100000", "output": "817082185\n"}, {"type": "stdin_stdout", "input": "101010 100000", "output": "781111243\n"}, {"type": "stdin_stdout", "input": "100000 100000", "output": "742202979"}, {"type": "stdin_stdout", "input": "10 280", "output": "563548517\n"}, {"type": "stdin_stdo... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.\n\nThe company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits... | [{"type": "stdin_stdout", "input": "19\n5546189040285140044", "output": "273\n"}, {"type": "stdin_stdout", "input": "19\n4753841743850076999", "output": "311\n"}, {"type": "stdin_stdout", "input": "19\n9039528710159876563", "output": "412\n"}, {"type": "stdin_stdout", "input": "19\n3616863455241776042", "output": "322\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nN of us are going on a trip, by train or taxi.\n\nThe train will cost each of us A yen (the currency of Japan).\n\nThe taxi will cost us a total of B yen.\n\nHow much is our minimum total travel expense?\n\nConstraints\n\... | [{"type": "stdin_stdout", "input": "12 -13 -107", "output": "-156\n"}, {"type": "stdin_stdout", "input": "-1719 1 -2", "output": "-1719\n"}, {"type": "stdin_stdout", "input": "10 -2 -141", "output": "-141\n"}, {"type": "stdin_stdout", "input": "10 -2 -162", "output": "-162\n"}, {"type": "stdin_stdout", "input": "10 -7 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFind the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive). The order does not matter.\n\nConstraints\n\n* 2\\leq K\\leq 100\n* K is an integer.\n\n... | [{"type": "stdin_stdout", "input": "-2373", "output": "1407782\n"}, {"type": "stdin_stdout", "input": "-1265", "output": "400056\n"}, {"type": "stdin_stdout", "input": "-1867", "output": "871422\n"}, {"type": "stdin_stdout", "input": "-1056", "output": "278784\n"}, {"type": "stdin_stdout", "input": "-1235", "output": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTakahashi and Aoki are playing a stone-taking game. Initially, there are N piles of stones, and the i-th pile contains A_i stones and has an associated integer K_i.\n\nStarting from Takahashi, Takahashi and Aoki take alte... | [{"type": "stdin_stdout", "input": "4\n3141 59\n26535 897\n93 23\n10502 64", "output": "Takahashi\n"}, {"type": "stdin_stdout", "input": "4\n3141 59\n51840 1663\n73 23\n8462 64", "output": "Takahashi\n"}, {"type": "stdin_stdout", "input": "4\n3141 59\n26535 508\n93 23\n10502 64", "output": "Takahashi\n"}, {"type": "std... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nN cells are arranged in a row. Some of them may contain tokens. You are given a string s that consists of `0`s and `1`s. If the i-th character of s is `1`, the i-th cell (from left) contains a token. Otherwise, it doesn't... | [{"type": "stdin_stdout", "input": "50\n10101000010011011110001001111110001101010111100110", "output": "11\n"}, {"type": "stdin_stdout", "input": "50\n10101000010011011010001001111110001101010111100100", "output": "10\n"}, {"type": "stdin_stdout", "input": "50\n10101110010101010110001001011111001001110111000000", "outp... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.\n\nConstraints\n\n* s_1, s_2 and s... | [{"type": "stdin_stdout", "input": "resident retsiger number", "output": "RRN\n"}, {"type": "stdin_stdout", "input": "atcoder beginner contdst", "output": "ABC\n"}, {"type": "stdin_stdout", "input": "resident setsiger nuebmr", "output": "RSN\n"}, {"type": "stdin_stdout", "input": "resident setsiger rmbeun", "output": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are N panels arranged in a row in Takahashi's house, numbered 1 through N. The i-th panel has a number A_i written on it. Takahashi is playing by throwing balls at these panels.\n\nTakahashi threw a ball K times. Le... | [{"type": "stdin_stdout", "input": "10 3 10\n3 7 2 6 8 4 7 5 1 1000000000", "output": "10000000209\n"}, {"type": "stdin_stdout", "input": "10 3 10\n3 7 2 6 8 4 5 5 1 1000000000", "output": "10000000195\n"}, {"type": "stdin_stdout", "input": "10 3 5\n1 7 2 6 9 4 13 5 1 1000000100", "output": "5000000598\n"}, {"type": "s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWrite a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b.\n\nConstraints\n\n* 0 < a, b β€ 2,000,000,000\n* LCM(a, b) β€ 2,000,000,000\n* The number of data sets β€... | [{"type": "stdin_stdout", "input": "34 12\n234598000 42842091", "output": "2 204\n1 10050668864418000\n"}, {"type": "stdin_stdout", "input": "34 12\n234598000 60832539", "output": "2 204\n1 14271191984322000\n"}, {"type": "stdin_stdout", "input": "34 9\n234598000 42842091", "output": "1 306\n1 10050668864418000\n"}, {"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nCreate a program of the square picking method, which is one of the classical random number generation methods. The square harvesting method was proposed by von Neumann in the mid-1940s.\n\nIn the square picking method, wh... | [{"type": "stdin_stdout", "input": "2\n387\n615", "output": "Case 1:\n1497\n2410\n8081\n3025\n1506\n2680\n1824\n3269\n6863\n1007\nCase 2:\n3782\n3035\n2112\n4605\n2060\n2436\n9340\n2356\n5507\n3270\n"}, {"type": "stdin_stdout", "input": "2\n210\n567", "output": "Case 1:\n441\n1944\n7791\n6996\n9440\n1136\n2904\n4332\n7... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have decided to introduce an automatic ticket gate to the railway network of a certain country. One of the difficult issues to implement is determining whether a given ticket can move between designated stations. Each ... | [{"type": "stdin_stdout", "input": "6 7\n1 2 3\n1 4 1\n2 3 5\n4 3 1\n3 6 2\n4 5 2\n5 6 1\n1 6 6\n1 6\n4 3\n4 6\n5 6\n2 6\n2 5", "output": "Yes\nYes\nYes\nYes\nNo\nNo"}, {"type": "stdin_stdout", "input": "6 0\n1 2 5\n1 4 2\n2 3 5\n4 3 1\n3 0 2\n1 5 2\n5 2 1\n1 4 6\n1 2\n4 3\n4 0\n5 6\n1 11\n2 5", "output": "No\nYes\nNo\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAnimation is one of methods for making movies and in Japan, it is popular to broadcast as a television program or perform as a movie. Many people, especially the young, love one. And here is an anime lover called Jack. We... | [{"type": "stdin_stdout", "input": "1\ngalaxy_angel 0 1197\n1\ngalaxy_angel\n11\nA 0 600\nB 0 610\nC 0 610\nD 0 931\nE 0 640\nEE 0 700\nF 0 788\nG 0 710\nH 0 710\nI 0 740\nJ 0 750\n2\nB\nH\n42\nnchj 6 2620\nanhnnnmewbktthsrn 4 2515\ngntmdsh 1 1800\nachnnl 4 2540\nhnskirh 0 2200\naonexrcst 0 1700\ndgdys 6 2330\nhdnnara ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nE: Taiyaki-Master and Eater\n\nstory\n\nTsuta is very good at making Taiyaki. Ebi-chan loves Taiyaki made by Tsuta-san. The two are happy to make and eat Taiyaki every week, but Tsuta-san's recent worries are that Ebi-cha... | [{"type": "stdin_stdout", "input": "3 3 0 19\n1 0 1 1\n2 2 1 2 1 2\n3 1 1 2\n4 0 4 1\n5 2 3 1 2 2\n6 2 0 1 3 0", "output": "0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n"}, {"type": "stdin_stdout", "input": "3 3 4 16\n1 0 1 2\n2 2 2 1 2 2\n3 1 0 1\n4 0 2 1\n5 2 2 1 2 2\n6 2 2 1 3 1", ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWrite a program which manipulates a weighted rooted tree $T$ with the following operations:\n\n* $add(v,w)$: add $w$ to all edges from the root to node $u$\n\n* $getSum(u)$: report the sum of weights of all edges from the... | [{"type": "stdin_stdout", "input": "6\n2 1 2\n2 3 5\n0\n0\n0\n1 4\n7\n1 1\n0 3 12\n1 2\n0 4 20\n1 3\n0 3 40\n1 4", "output": "0\n0\n44\n112\n"}, {"type": "stdin_stdout", "input": "6\n2 1 2\n2 3 5\n0\n0\n0\n1 4\n7\n1 1\n0 3 10\n1 2\n0 4 20\n1 3\n0 5 40\n1 4", "output": "0\n0\n40\n150"}, {"type": "stdin_stdout", "input":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBerland shop sells n kinds of juices. Each juice has its price c_i. Each juice includes some set of vitamins in it. There are three types of vitamins: vitamin \"A\", vitamin \"B\" and vitamin \"C\". Each juice can contain... | [{"type": "stdin_stdout", "input": "25\n8 CA\n4 AB\n8 CA\n4 CA\n2 CB\n4 CB\n4 CB\n2 AC\n2 CA\n3 BC\n4 AC\n7 AB\n3 CA\n5 BC\n7 CB\n9 CA\n7 AB\n7 CA\n9 BA\n8 AC\n6 BA\n2 AC\n1 CB\n5 AB\n3 AB\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "25\n8 CA\n4 AB\n8 CA\n4 CA\n7 CB\n4 CB\n4 CB\n2 AC\n2 CA\n3 BC\n4 AC\n7 AB... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a special offer in Vasya's favourite supermarket: if the customer buys a chocolate bars, he or she may take b additional bars for free. This special offer can be used any number of times.\n\nVasya currently has s... | [{"type": "stdin_stdout", "input": "16\n1 1 1 1\n1 1 1 1000000000\n1 1 1000000000 1\n1 1 1000000000 1000000000\n1 1000000000 1 1\n1 1000000000 1 1000000000\n1 1000000000 1000000000 1\n1 1000000000 1000000000 1000000000\n1000000000 1 1 1\n1000000000 1 1 1000000000\n1000000000 1 1000000000 1\n1000000000 1 1000000000 1000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer n.\n\nYou can perform any of the following operations with this number an arbitrary (possibly, zero) number of times: \n\n 1. Replace n with n/2 if n is divisible by 2; \n 2. Replace n with 2n/3... | [{"type": "stdin_stdout", "input": "7\n1\n14\n73\n30\n14\n39\n1000000000000000000\n", "output": "0\n-1\n-1\n6\n-1\n-1\n72\n"}, {"type": "stdin_stdout", "input": "7\n1\n7\n73\n52\n14\n39\n1000000000000000000\n", "output": "0\n-1\n-1\n-1\n-1\n-1\n72\n"}, {"type": "stdin_stdout", "input": "7\n1\n14\n73\n30\n14\n27\n100000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions are constraints on n and k.\n\nYou are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most k most recent conversations w... | [{"type": "stdin_stdout", "input": "10 4\n2 3 3 1 1 4 1 2 3 3\n", "output": "4\n4 1 3 2\n"}, {"type": "stdin_stdout", "input": "10 4\n2 3 3 1 1 2 1 2 5 3\n", "output": "4\n5 1 3 2\n"}, {"type": "stdin_stdout", "input": "10 4\n2 3 3 2 1 4 1 2 3 3\n", "output": "4\n4 1 3 2\n"}, {"type": "stdin_stdout", "input": "10 4\n2 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou're given two arrays a[1 ... n] and b[1 ... n], both of the same length n.\n\nIn order to perform a push operation, you have to choose three integers l, r, k satisfying 1 β€ l β€ r β€ n and k > 0. Then, you will add k to ... | [{"type": "stdin_stdout", "input": "4\n6\n3 7 1 4 1 2\n3 7 3 6 3 2\n5\n1 1 1 1 1\n1 2 1 3 1\n2\n42 42\n42 42\n1\n7\n6\n", "output": "YES\nNO\nYES\nNO\n"}, {"type": "stdin_stdout", "input": "4\n6\n3 7 1 4 1 2\n3 7 3 6 3 2\n5\n1 1 1 1 1\n1 2 1 3 1\n2\n42 42\n42 48\n1\n7\n6\n", "output": "YES\nNO\nYES\nNO\n"}, {"type": "s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are n railway stations in Berland. They are connected to each other by n-1 railway sections. The railway network is connected, i.e. can be represented as an undirected tree.\n\nYou have a map of that network, so for... | [{"type": "stdin_stdout", "input": "10\n9 4\n5 7\n2 1\n3 4\n2 10\n6 3\n2 5\n1 3\n4 8\n8\n6 8 3\n10 5 3\n2 10 3\n3 5 2\n8 4 3\n1 9 3\n9 5 2\n3 10 2\n", "output": "3 1 2 3 3 3 3 3 3 \n"}, {"type": "stdin_stdout", "input": "10\n3 6\n3 2\n4 1\n1 10\n3 8\n5 2\n6 7\n2 1\n6 9\n7\n9 10 3\n5 7 1\n9 10 3\n7 4 1\n3 10 4\n3 6 4\n5... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTanya wants to go on a journey across the cities of Berland. There are n cities situated along the main railroad line of Berland, and these cities are numbered from 1 to n. \n\nTanya plans her journey as follows. First of... | [{"type": "stdin_stdout", "input": "10\n10 60 12 13 14 15 16 66 18 130\n", "output": "130\n"}, {"type": "stdin_stdout", "input": "10\n8 60 12 13 14 15 16 66 18 130\n", "output": "130\n"}, {"type": "stdin_stdout", "input": "9\n18 11 24 7 18 10 1 20 17\n", "output": "24\n"}, {"type": "stdin_stdout", "input": "9\n4 10 21 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nConsider all binary strings of length m (1 β€ m β€ 60). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly 2^m suc... | [{"type": "stdin_stdout", "input": "5\n3 3\n010\n001\n111\n4 3\n000\n111\n100\n011\n1 1\n1\n1 1\n0\n3 2\n00\n01\n10\n", "output": "100\n010\n0\n1\n11\n"}, {"type": "stdin_stdout", "input": "5\n3 3\n010\n001\n110\n4 3\n000\n111\n100\n011\n1 1\n1\n1 1\n0\n3 2\n00\n01\n10\n", "output": "100\n010\n0\n1\n11\n"}, {"type": "s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThis is the hard version of the problem. The difference between the versions is the constraint on n and the required number of operations. You can make hacks only if all versions of the problem are solved.\n\nThere are tw... | [{"type": "stdin_stdout", "input": "5\n2\n01\n10\n5\n01011\n01101\n2\n01\n01\n10\n0111011011\n1000110100\n1\n0\n1\n", "output": "3 1 2 1\n6 1 4 3 1 2 1\n0\n11 1 10 8 7 6 1 5 4 1 3 1\n1 1\n"}, {"type": "stdin_stdout", "input": "5\n2\n01\n10\n5\n00011\n11100\n2\n01\n01\n10\n0110011001\n1000000100\n1\n0\n1\n", "output": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given two sequences a_1, a_2, ..., a_n and b_1, b_2, ..., b_n. Each element of both sequences is either 0, 1 or 2. The number of elements 0, 1, 2 in the sequence a is x_1, y_1, z_1 respectively, and the number of ... | [{"type": "stdin_stdout", "input": "1\n45094381 58629867 47778466\n33028864 48902149 69571701\n", "output": "46602292\n"}, {"type": "stdin_stdout", "input": "3\n2 3 2\n3 3 1\n4 0 1\n2 3 0\n0 0 1\n0 0 1\n", "output": "4\n2\n0\n"}, {"type": "stdin_stdout", "input": "3\n2 3 2\n3 3 1\n4 0 1\n3 3 0\n0 0 1\n0 0 1\n", "output... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe Bubble Cup hypothesis stood unsolved for 130 years. Who ever proves the hypothesis will be regarded as one of the greatest mathematicians of our time! A famous mathematician Jerry Mao managed to reduce the hypothesis ... | [{"type": "stdin_stdout", "input": "100\n751 557 779 329 39 213 844 289 137 50 951 284 671 474 829 906 736 395 366 22 133 418 552 649 636 109 974 775 852 971 384 945 335 961 472 651 335 543 560 135 85 952 558 838 147 644 688 727 940 978 309 705 409 27 774 951 92 277 835 804 589 103 529 11 304 171 655 378 792 876 1161 3... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPetya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\... | [{"type": "stdin_stdout", "input": "3 2\n1 47 47\n", "output": " 2\n"}, {"type": "stdin_stdout", "input": "20 7\n1 4 5 8 47 777777777 1 5 4 8 5 9 5 4 7 4 5 7 7 44474\n", "output": "29172\n"}, {"type": "stdin_stdout", "input": "20 7\n1 4 5 8 47 777777777 1 5 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nKawashiro Nitori is a girl who loves competitive programming.\n\nOne day she found a string and an integer. As an advanced problem setter, she quickly thought of a problem.\n\nGiven a string s and a parameter k, you need ... | [{"type": "stdin_stdout", "input": "7\n5 2\nrwrwq\n2 0\nac\n3 1\nioi\n4 0\nibdp\n22 0\ndokidoktliteraiureclub\n19 0\necilbiahgaahsmnetmi\n6 2\naaaaaa\n", "output": "NO\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "7\n5 1\nqwqwq\n2 0\nab\n3 1\nioi\n4 2\nipcc\n22 0\ncokidokiliteratureclub\n19 11\n... | 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\n01010\n20\n10001111110110110000\n20\n00110110100110111101\n20\n1100... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLittle Bolek has found a picture with n mountain peaks painted on it. The n painted peaks are represented by a non-closed polyline, consisting of 2n segments. The segments go through 2n + 1 points with coordinates (1, y1)... | [{"type": "stdin_stdout", "input": "100 20\n2 3 0 4 0 1 0 6 3 4 3 6 4 6 0 9 0 6 2 7 3 8 7 10 2 9 3 9 5 6 5 10 3 7 1 5 2 8 3 7 2 3 1 6 0 8 3 8 0 4 1 8 3 7 1 9 5 9 5 8 7 8 5 6 5 8 1 9 8 9 8 10 7 10 5 8 6 10 2 6 3 9 2 6 3 10 5 9 3 10 1 3 2 11 8 9 8 10 1 8 7 11 0 9 5 8 4 5 0 7 3 7 5 9 5 10 1 7 1 9 1 6 3 8 2 4 1 4 2 6 0 4 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLiLand is a country, consisting of n cities. The cities are numbered from 1 to n. The country is well known because it has a very strange transportation system. There are many one-way flights that make it possible to trav... | [{"type": "stdin_stdout", "input": "5 6\n1 2\n2 3\n3 5\n1 4\n4 5\n1 3\n", "output": "Yes\n1\n1\n2\n2\n2\n2\n"}, {"type": "stdin_stdout", "input": "4 4\n1 2\n2 3\n3 4\n1 3\n", "output": "Yes\n1\n1\n2\n2\n"}, {"type": "stdin_stdout", "input": "4 3\n1 2\n2 3\n3 4\n-1 -2\n", "output": "Yes\n2\n2\n2\n"}, {"type": "stdin_std... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA motorcade of n trucks, driving from city Β«ZΒ» to city Β«ΠΒ», has approached a tunnel, known as Tunnel of Horror. Among truck drivers there were rumours about monster DravDe, who hunts for drivers in that tunnel. Some drive... | [{"type": "stdin_stdout", "input": "20\n7892 2 0 24\n4201 1 2 23\n3667 1 3 22\n6388 1 4 21\n2406 1 5 20\n1148 1 6 19\n3958 1 7 18\n7363 1 8 17\n9025 2 9 15\n1909 1 11 14\n73 1 12 13\n5477 2 13 11\n1869 1 15 10\n107 1 16 9\n523 1 17 8\n6589 2 18 6\n6277 2 20 4\n3881 1 22 3\n5771 1 23 2\n622 2 24 0\n", "output": "20\n1 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet's introduce the designation <image>, where x is a string, n is a positive integer and operation \" + \" is the string concatenation operation. For example, [abc, 2] = abcabc.\n\nWe'll say that string s can be obtained... | [{"type": "stdin_stdout", "input": "10000000 1\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "10000000\n"}, {"type": "stdin_stdout", "input": "10000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to ... | [{"type": "stdin_stdout", "input": "155\n", "output": "12013\nC.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C\n.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe Saratov State University Olympiad Programmers Training Center (SSU OPTC) has n students. For each student you know the number of times he/she has participated in the ACM ICPC world programming championship. According ... | [{"type": "stdin_stdout", "input": "20 1\n5 0 4 2 2 3 2 1 2 4 1 3 5 5 5 4 4 1 3 0\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "20 2\n1 4 5 1 3 4 0 5 0 3 3 0 4 0 0 1 4 2 0 4\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "20 1\n5 0 8 2 2 3 2 1 2 4 1 3 5 5 5 4 4 1 3 0\n", "output": "5\n"}, {"type": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTwilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept losing. Having returned to the castle, Twilight Sparkle became interested in the dice that were used in the game.\n... | [{"type": "stdin_stdout", "input": "100001 100000\n", "output": "100000.41802404786\n"}, {"type": "stdin_stdout", "input": "50000 100000\n", "output": "49999.843487110797\n"}, {"type": "stdin_stdout", "input": "99999 100000\n", "output": "99998.418042461126\n"}, {"type": "stdin_stdout", "input": "100000 100000\n", "out... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDreamoon loves summing up something for no reason. One day he obtains two integers a and b occasionally. He wants to calculate the sum of all nice integers. Positive integer x is called nice if <image> and <image>, where ... | [{"type": "stdin_stdout", "input": "10000000 10000000\n", "output": "425362313\n"}, {"type": "stdin_stdout", "input": "10000000 9999999\n", "output": "930564389\n"}, {"type": "stdin_stdout", "input": "3865975 13943620\n", "output": "633381536\n"}, {"type": "stdin_stdout", "input": "6407688 3000816\n", "output": "895399... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTomorrow Peter has a Biology exam. He does not like this subject much, but d days ago he learnt that he would have to take this exam. Peter's strict parents made him prepare for the exam immediately, for this purpose he h... | [{"type": "stdin_stdout", "input": "30 71\n1 3\n0 9\n3 5\n3 6\n2 4\n2 9\n2 3\n0 8\n2 5\n2 4\n2 3\n3 11\n0 0\n5 7\n0 2\n5 10\n-1 12\n4 7\n0 3\n3 7\n2 3\n4 5\n7 8\n7 7\n2 2\n1 3\n-1 1\n1 5\n3 7\n5 8\n", "output": "YES\n3 0 3 3 2 2 2 0 2 2 2 3 0 5 0 5 -1 4 0 3 2 4 7 7 2 1 -1 1 3 5 "}, {"type": "stdin_stdout", "input": "30... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAfter a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from lef... | [{"type": "stdin_stdout", "input": "100\nqDpInBmCrFwXpDbFgOzVvOcEmJrUcToAdEwEgTvBvBfWwRpGyEaXgDdRwVlQnYgWmWhMrHaIzPyXvGaFlRsVzHhZrOuVpXrKxFzAmWwPlFtNfPtJxVmLuHjKfYyArHrEnSwSzOvDpQhCgCqLlAcNpGhXrEeFuCmAqIkXyYtSsQwIxJzNiIuTgEbVuWrMwPrAlLyKaZ\n", "output": "42\n"}, {"type": "stdin_stdout", "input": "100\nqDpInBmCrFwXpDbFg... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou have n problems. You have estimated the difficulty of the i-th one as integer ci. Now you want to prepare a problemset for a contest, using some of the problems you've made.\n\nA problemset for the contest must consis... | [{"type": "stdin_stdout", "input": "15 4789415 23152928 140536\n502422 273992 449428 1752566 753047 681985 857134 243310 478052 77769 936151 642380 464695 281772 964693\n", "output": "15447\n"}, {"type": "stdin_stdout", "input": "15 4789415 22705612 140536\n502422 273992 449428 1752566 753047 681985 857134 243310 47805... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLittle Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 Γ n in size, when viewed from above. This rectangle is divided into n equal s... | [{"type": "stdin_stdout", "input": "100\n1 2 3 7 5 6 10 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 30 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 1 82 83 84 85 86 87 88 89 90 91 92 93 94 100 5 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nZS the Coder loves mazes. Your job is to create one so that he can play with it. A maze consists of n Γ m rooms, and the rooms are arranged in n rows (numbered from the top to the bottom starting from 1) and m columns (nu... | [{"type": "stdin_stdout", "input": "789730223053602816\n", "output": "41 41 214\n1 3 1 4\n1 4 2 4\n1 5 1 6\n2 4 2 5\n2 5 3 5\n2 6 2 7\n3 1 4 1\n3 5 3 6\n3 6 4 6\n3 7 3 8\n4 1 4 2\n4 2 5 2\n4 6 4 7\n4 7 5 7\n4 8 4 9\n5 1 6 1\n5 2 5 3\n5 3 6 3\n5 7 5 8\n5 8 6 8\n5 9 5 10\n6 2 7 2\n6 3 6 4\n6 4 7 4\n6 8 6 9\n6 9 7 9\n6 10... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPetr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to weeks (a week is seven consequent days from Monday to Sunday), rows correspond to weekdays, and cells conta... | [{"type": "stdin_stdout", "input": "11 6\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "11 3\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "10 6\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "12 1\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "12 2\n", "output": "5\n"}, {"type": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of substrings \"ab\" in the string and replace it with the string \"bba\". If we have no \"ab\" as a substring,... | [{"type": "stdin_stdout", "input": "abaaaaaabaaaabbabbaaabbbbabababaaaaabbaabbaaaaabbbaababaaaaaaabbbbbaaaaabaababbabababbabbbbaabbaabbabbbabaabbaabbaaaaaab\n", "output": "235606597\n"}, {"type": "stdin_stdout", "input": "baaaaaabbaabbaababababbaabbaabbbbabbabababbabaabaaaaabbbbbaaaaaaababaabbbaaaaabbaabbaaaaababababbb... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are n shovels in Polycarp's shop. The i-th shovel costs i burles, that is, the first shovel costs 1 burle, the second shovel costs 2 burles, the third shovel costs 3 burles, and so on. Polycarps wants to sell shovel... | [{"type": "stdin_stdout", "input": "499999999\n", "output": "1249999995\n"}, {"type": "stdin_stdout", "input": "452405440\n", "output": "1012027201\n"}, {"type": "stdin_stdout", "input": "1000000000\n", "output": "500000000\n"}, {"type": "stdin_stdout", "input": "499999998\n", "output": "1249999991\n"}, {"type": "stdin... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAllen has a LOT of money. He has n dollars in the bank. For security reasons, he wants to withdraw it in cash (we will not disclose the reasons here). The denominations for dollar bills are 1, 5, 10, 20, 100. What is the ... | [{"type": "stdin_stdout", "input": "1000000000\n", "output": "10000000\n"}, {"type": "stdin_stdout", "input": "1230910855\n", "output": "12309112\n"}, {"type": "stdin_stdout", "input": "1199225057\n", "output": "11992256\n"}, {"type": "stdin_stdout", "input": "1100000000\n", "output": "11000000\n"}, {"type": "stdin_std... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nToday RK has to transport his N items of different weights(in calories) to a near city but before that he wants to make sure that the weights of all items are balanced. In order to check this he puts all items on the weig... | [{"type": "stdin_stdout", "input": "10\n100\n125 70 77 47 113 84 56 91 44 21 7 70 77 106 56 63 14 84 56 14 77 77 63 70 14 7 28 91 63 16 21 105 21 56 62 98 96 84 98 14 7 56 49 28 91 98 7 56 5 162 14 98 49 28 72 8 98 98 26 70 35 44 63 16 7 63 63 56 91 98 35 42 42 35 64 35 42 14 63 21 77 105 42 77 35 34 56 20 28 84 56 60 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nProblem:\n\nBlack and White are playing a game of chess on a chess board of n X n dimensions. The game is nearing its end. White has his King and a Pawn left. Black has only his King left. So, definitely Black cannot win ... | [{"type": "stdin_stdout", "input": "96\n4978293 57077654 13779632 39203998 50091653 1\n330056655 133054953 8102946 39409316 45198702 -1\n31241018 58779281 7437322 75012605 16258100 2\n24093030 11941249 14270682 13824288 33816735 0\n930018290 6186719 81620229 939478848 66720282 -1\n35385960 35246971 19141396 3174023 182... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOz is in love with number theory, so he expects you to love it too and solve his problems. The current problem which has been given by Oz to you is in the form of an array. So, he has given you N integers i.e a1,a2,..,aN ... | [{"type": "stdin_stdout", "input": "1000\n204 188 114 382 862 941 149 900 1435 129 10 845 454 531 993 444 917 639 190 917 462 585 504 946 637 121 275 1337 737 815 753 598 632 871 995 565 920 998 760 659 841 708 769 110 92 926 645 491 931 474 45 62 431 524 65 519 963 128 842 297 800 832 111 1473 1162 284 210 496 445 231... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTakahashi has decided to hold fastest-finger-fast quiz games. Kizahashi, who is in charge of making the scoreboard, is struggling to write the program that manages the players' scores in a game, which proceeds as follows.... | [{"type": "stdin_stdout", "input": "130 -2 -1\n-2\n22\n0\n4", "output": "No\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSnuke has N integers: 1,2,\\ldots,N. He will choose K of them and give those to Takahashi.\n\nHow many ways are there to choose K consecutive integers?\n\nConstraints\n\n* All values in input are integers.\n* 1 \\leq K \\... | [{"type": "stdin_stdout", "input": "1 -159", "output": "161\n"}, {"type": "stdin_stdout", "input": "119 -1", "output": "121\n"}, {"type": "stdin_stdout", "input": "2 -107", "output": "110\n"}, {"type": "stdin_stdout", "input": "0 -159", "output": "160\n"}, {"type": "stdin_stdout", "input": "112 -1", "output": "114\n"},... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFor an n \\times n grid, let (r, c) denote the square at the (r+1)-th row from the top and the (c+1)-th column from the left. A good coloring of this grid using K colors is a coloring that satisfies the following:\n\n* Ea... | [{"type": "stdin_stdout", "input": "240", "output": "120\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 9... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSnuke has an integer sequence, a, of length N. The i-th element of a (1-indexed) is a_{i}.\n\nHe can perform the following operation any number of times:\n\n* Operation: Choose integers x and y between 1 and N (inclusive)... | [{"type": "stdin_stdout", "input": "3\n-3 5 -1", "output": "3\n2 1\n2 3\n2 3\n"}, {"type": "stdin_stdout", "input": "3\n-2 5 -1", "output": "2\n2 3\n3 3"}, {"type": "stdin_stdout", "input": "3\n-2 5 0", "output": "2\n2 1\n2 3\n"}, {"type": "stdin_stdout", "input": "2\n1 -11", "output": "2\n2 1\n2 1\n"}, {"type": "stdin... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a tree with N vertices, numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i.\n\nCurrently, there are A_i stones placed on vertex i. Takahashi and Aoki will play a game using this tree.\n... | [{"type": "stdin_stdout", "input": "5\n0 12 -4 11 -1\n0 2\n1 3\n2 14\n3 5", "output": "1 2 5 \n"}, {"type": "stdin_stdout", "input": "5\n2 12 -2 4 3\n1 2\n1 3\n2 8\n4 5", "output": "1 2 4 \n"}, {"type": "stdin_stdout", "input": "5\n2 1 1 2 5\n1 2\n1 3\n2 4\n2 5", "output": "1 4 5 \n"}, {"type": "stdin_stdout", "input":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are n vertical lines in the Amidakuji. This Amidakuji meets the following conditions.\n\n* Draw a horizontal line right next to it. Do not pull diagonally.\n* Horizontal lines always connect adjacent vertical lines.... | [{"type": "stdin_stdout", "input": "5\n2\n3\n9\n1010\n1001\n0100\n1001\n0010\n1000\n0000\n0101\n1010\n0", "output": "6 4\n"}, {"type": "stdin_stdout", "input": "5\n2\n3\n9\n1010\n1001\n1000\n1001\n0010\n1000\n0000\n0101\n1001\n0", "output": "5 1\n"}, {"type": "stdin_stdout", "input": "5\n2\n3\n9\n1010\n0001\n0000\n1001... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou finally got a magic pot, an alchemy pot. You can create a new item by putting multiple items in the alchemy pot. Newly created items can also be placed in alchemy pots to make other items. A list of items needed to ma... | [{"type": "stdin_stdout", "input": "8\nwood 5003\nstring 1120\nrice 32\nwater -1\nracket 5000\nmicrophone 4961\nonigiri 140\nguitar 98000\n3\nracket 2 wood string\nonigiri 2 rice water\nguitar 3 tekcar microphone onigiri\nguitar\n1\ncomputer 112750\n-1\ncomputer\n0", "output": "4992\n112750\n"}, {"type": "stdin_stdout"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nI am a craftsman specialized in interior works. A customer asked me to perform wiring work on a wall whose entire rectangular surface is tightly pasted with pieces of panels. The panels are all of the same size (2 m in wi... | [{"type": "stdin_stdout", "input": "1 -11", "output": "-10\n"}, {"type": "stdin_stdout", "input": "171 2", "output": "173\n"}, {"type": "stdin_stdout", "input": "120 3", "output": "121\n"}, {"type": "stdin_stdout", "input": "109 1", "output": "110\n"}, {"type": "stdin_stdout", "input": "119 1", "output": "120\n"}, {"ty... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.