messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "Sereja showed an interesting game to his friends. The game goes like that. Initially, there is a table with an empty cup and n water mugs on it. Then all players take turns to move. During a move, a player takes a non-empty mug of water and pours all water from it into the cup. If the cup overfill...
[{"input": "100 1000\n10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1...
code_stdio
[ { "content": "There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.\n\nIn the beginning, Snuke stands on S...
[{"input": "15 -1 6 15 13\n...#.#...#.#...", "output": "Yes\n"}, {"input": "15 -1 3 15 11\n...#.#...#...#.", "output": "Yes\n"}, {"input": "16 -1 3 15 11\n...#.#...#...#.", "output": "Yes\n"}, {"input": "16 -1 3 15 13\n...#.#...#...#.", "output": "Yes\n"}, {"input": "20 -1 3 15 11\n...#.#...#...#.", "output": "Yes\n"},...
code_stdio
[ { "content": "You are given a chessboard of size $n \\times n$. It is filled with numbers from $1$ to $n^2$ in the following way: the first $\\lceil \\frac{n^2}{2} \\rceil$ numbers from $1$ to $\\lceil \\frac{n^2}{2} \\rceil$ are written in the cells with even sum of coordinates from left to right from top to b...
[{"input": "4 5\n2 1\n1 4\n5 3\n3 2\n2 4\n", "output": "11\n10\n10\n13\n4\n"}, {"input": "4 5\n2 1\n1 4\n5 3\n6 2\n2 4\n", "output": "11\n10\n10\n11\n4\n"}, {"input": "8 5\n2 1\n4 4\n4 3\n3 2\n2 4\n", "output": "37\n14\n46\n41\n6\n"}, {"input": "4 5\n4 1\n1 4\n5 3\n3 2\n2 4\n", "output": "15\n10\n10\n13\n4\n"}, {"input...
code_stdio
[ { "content": "There is an integer sequence of length 2^N: A_0, A_1, ..., A_{2^N-1}. (Note that the sequence is 0-indexed.)\nFor every integer K satisfying 1 \\leq K \\leq 2^N-1, solve the following problem:\n - Let i and j be integers. Find the maximum value of A_i + A_j where 0 \\leq i < j \\leq 2^N-1 and (i o...
[{"input": "4\n75 26 45 72 81 47 97 97 2 2 25 82 84 17 56 32\n", "output": "101\n120\n147\n156\n156\n178\n194\n194\n194\n194\n194\n194\n194\n194\n194\n"}, {"input": "4\n75 26 45 112 81 47 97 97 2 2 25 95 84 17 56 32", "output": "101\n120\n187\n187\n187\n187\n209\n209\n209\n209\n209\n209\n209\n209\n209\n"}, {"input": "4...
code_stdio
[ { "content": "You are given $n$ segments on a coordinate axis $OX$. The $i$-th segment has borders $[l_i; r_i]$. All points $x$, for which $l_i \\le x \\le r_i$ holds, belong to the $i$-th segment.\n\nYour task is to choose the maximum by size (the number of segments) subset of the given set of segments such th...
[{"input": "4\n4\n1 5\n2 4\n2 3\n3 4\n5\n1 5\n2 3\n2 5\n3 5\n2 2\n3\n1 3\n2 4\n2 3\n7\n1 10\n2 8\n2 5\n3 4\n4 4\n6 8\n7 7\n", "output": "3\n4\n2\n7\n"}, {"input": "4\n4\n1 5\n2 4\n2 3\n3 4\n5\n1 5\n2 3\n2 5\n3 5\n2 2\n3\n1 3\n2 4\n2 3\n7\n1 10\n2 8\n0 5\n3 4\n4 4\n6 8\n7 7\n", "output": "3\n4\n2\n6\n"}, {"input": "4\n4...
code_stdio
[ { "content": "There is a string $s$ of length $3$, consisting of uppercase and lowercase English letters. Check if it is equal to \"YES\" (without quotes), where each letter can be in any case. For example, \"yES\", \"Yes\", \"yes\" are all allowable.\n\n\n-----Input-----\n\nThe first line of the input contains...
[{"input": "10\nYES\nyES\nyes\nYes\nYeS\nNoo\norZ\nyEz\nYas\nXES\n", "output": "YES\nYES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\n"}, {"input": "2\nyes\nlll\n", "output": "YES\nNO\n"}, {"input": "1\nvop\n", "output": "NO\n"}, {"input": "1\nhac\n", "output": "NO\n"}, {"input": "1\nNNy\n", "output": "NO\n"}, {"input": "1\nHAC...
code_stdio
[ { "content": "You have $n$ chains, the $i$-th chain consists of $c_i$ vertices. Vertices in each chain are numbered independently from $1$ to $c_i$ along the chain. In other words, the $i$-th chain is the undirected graph with $c_i$ vertices and $(c_i - 1)$ edges connecting the $j$-th and the $(j + 1)$-th verti...
[{"input": "3\n4\n3 4 3 6\n-1 1 2 2\n-2 2 2 3\n2\n5 10\n-2 5\n-1 1\n3\n10 5 2\n-1 1 2\n-1 10 5\n", "output": "10\n15\n15\n"}, {"input": "3\n4\n3 4 3 6\n-1 1 2 2\n-1 2 2 3\n2\n5 10\n-1 5\n-1 1\n3\n6 5 2\n-1 1 2\n-1 5 5\n", "output": "10\n15\n10\n"}, {"input": "3\n4\n1 4 3 6\n-1 1 2 2\n-1 2 2 3\n2\n5 13\n-1 5\n-1 1\n3\n6...
code_stdio
[ { "content": "As behooves any intelligent schoolboy, Kevin Sun is studying psycowlogy, cowculus, and cryptcowgraphy at the Bovinia State University (BGU) under Farmer Ivan. During his Mathematics of Olympiads (MoO) class, Kevin was confronted with a weird functional equation and needs your help. For two fixed i...
[{"input": "990037 453792\n", "output": "654009570\n"}, {"input": "498653 116674\n", "output": "625264514\n"}, {"input": "512287 359783\n", "output": "542484357\n"}, {"input": "337411 146419\n", "output": "532279245\n"}, {"input": "586189 189159\n", "output": "168174057\n"}, {"input": "613463 269592\n", "output": "3368...
code_stdio
[ { "content": "Once upon a time in the Kingdom of Far Far Away lived Sir Lancelot, the chief Royal General. He was very proud of his men and he liked to invite the King to come and watch drill exercises which demonstrated the fighting techniques and tactics of the squad he was in charge of. But time went by and ...
[{"input": "1000 1000\n", "output": "500000\n"}, {"input": "997 1000\n", "output": "498500\n"}, {"input": "999 1000\n", "output": "499500\n"}, {"input": "1000 999\n", "output": "499500\n"}, {"input": "1000 998\n", "output": "499000\n"}, {"input": "1000 997\n", "output": "498500\n"}, {"input": "998 1000\n", "output": "4...
code_stdio
[ { "content": "Paw the Spider is making a web. Web-making is a real art, Paw has been learning to do it his whole life. Let's consider the structure of the web.\n\n<image>\n\nThere are n main threads going from the center of the web. All main threads are located in one plane and divide it into n equal infinite s...
[{"input": "20\n5 15 40 35 68 22\n6 70 19 28 69 63 1\n4 37 154 41 90\n7 11 148 35 94 55 59 64\n7 46 28 22 90 97 37 13\n5 62 45 34 50 94\n6 85 83 37 72 27 53\n6 46 56 116 71 49 33\n7 17 35 91 24 50 30 38\n2 75 12\n2 46 38\n1 61\n11 15 79 14 89 20 96 84 26 93 132 18\n1 75\n6 4 100 55 59 62 83\n5 48 44 37 12 6\n6 68 53 28...
code_stdio
[ { "content": "A tree is a graph with n vertices and exactly n - 1 edges; this graph should meet the following condition: there exists exactly one shortest (by number of edges) path between any pair of its vertices.\n\nA subtree of a tree T is a tree with both vertices and edges as subsets of vertices and edges ...
[{"input": "12\n1 6\n10 1\n4 1\n7 1\n1 2\n5 1\n1 8\n1 11\n3 1\n12 1\n9 1\n580660007 861441526 -470133967 488291045 253254575 -974301934 709266786 926718320 87511873 514836444 -1167698791 848928657\n", "output": "2916057589\n"}, {"input": "12\n1 6\n10 1\n4 1\n7 1\n1 2\n4 1\n1 8\n1 11\n3 1\n12 1\n9 1\n580660007 861441526...
code_stdio
[ { "content": "The polar bears are going fishing. They plan to sail from (s_{x}, s_{y}) to (e_{x}, e_{y}). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, west or north. Assume the boat is currently at (x, y). If the wind blows to the east, the bo...
[{"input": "39 -1000000000 -1000000000 -999999997 -1000000000\nENEENWSWSSWESNSSEESNSESWSWNSWESNENWNWEE\n", "output": "4\n"}, {"input": "39 -1000000000 -1000000000 -999999997 -1000000000\nENEENWSWSSWESNSSEESNSESWSWNSWESNENWNWEE\n", "output": "4\n"}, {"input": "51 -1000000000 -1000000000 -999999997 -1000000000\nENEENWSWS...
code_stdio
[ { "content": "The time is 2020. There is data that saves the qualifying results of PC Koshien 2020. This data stores the reference number and the number of correct answers assigned to each team. Here, the ranking is determined by the number of correct answers, and the ranking is given in descending order of the...
[{"input": "1,20\n2,20\n3,30\n4,10\n5,10\n6,20\n0,0\n1\n2\n4\n1", "output": "2\n2\n3\n2\n"}, {"input": "1,20\n2,20\n3,30\n4,10\n5,10\n0,26\n0,0\n1\n2\n4\n1", "output": "3\n3\n4\n3\n"}, {"input": "1,20\n2,20\n3,30\n4,10\n5,10\n0,26\n0,0\n0\n2\n4\n1", "output": "2\n3\n4\n3\n"}, {"input": "1,20\n2,20\n3,30\n4,10\n5,10\n0,...
code_stdio
[ { "content": "Sonya decided that having her own hotel business is the best way of earning money because she can profit and rest wherever she wants.\n\nThe country where Sonya lives is an endless line. There is a city in each integer coordinate on this line. She has $n$ hotels, where the $i$-th hotel is located ...
[{"input": "100 10\n-489 -476 -445 -432 -430 -421 -420 -418 -412 -411 -404 -383 -356 -300 -295 -293 -287 -276 -265 -263 -258 -251 -249 -246 -220 -219 -205 -186 -166 -157 -143 -137 -136 -130 -103 -86 -80 -69 -67 -55 -43 -41 -40 -26 -19 -9 16 29 41 42 54 76 84 97 98 99 101 115 134 151 157 167 169 185 197 204 208 226 227 ...
code_stdio
[ { "content": "Let S be the concatenation of 10^{10} copies of the string 110. (For reference, the concatenation of 3 copies of 110 is 110110110.)\nWe have a string T of length N.\nFind the number of times T occurs in S as a contiguous substring.\n\n-----Constraints-----\n - 1 \\leq N \\leq 2 \\times 10^5\n - T ...
[{"input": "62089\n1101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101...
code_stdio
[ { "content": "\"Fukusekiken\" is a popular ramen shop where you can line up. But recently, I've heard some customers say, \"I can't afford to have vacant seats when I enter the store, even though I have a long waiting time.\" I'd like to find out why such dissatisfaction occurs, but I'm too busy to check the ac...
[{"input": "5\n41\n27\n26", "output": "0\n28\n18\n23\n"}, {"input": "5\n24\n18\n13", "output": "0\n11\n15\n2\n"}, {"input": "5\n24\n27\n13", "output": "0\n11\n18\n2\n"}, {"input": "5\n29\n27\n26", "output": "0\n8\n18\n23\n"}, {"input": "5\n24\n12\n13", "output": "0\n11\n3\n2\n"}, {"input": "5\n24\n34\n13", "output": "0...
code_stdio
[ { "content": "Recently, the Fair Nut has written $k$ strings of length $n$, consisting of letters \"a\" and \"b\". He calculated $c$ — the number of strings that are prefixes of at least one of the written strings. Every string was counted only one time.\n\nThen, he lost his sheet with strings. He remembers tha...
[{"input": "100 1000000000\nbbabbaabbbaaaaabbabbbaaabbbbabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbaabbbbabaabbbabbaaaaabbbbaab\nbbabbaabbbaaaaabbabbbaaabbbbabbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaababbbabbbbaaaaabbaaaaaaaab\n", "output": "41073741883\n"}, {"input": "100 1000000000\nabbbbabababaabaabaabbababaabbb...
code_stdio
[ { "content": "It's a walking tour day in SIS.Winter, so $t$ groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another.\n\nInitially, some students are angry. Let's describe a group of students by a string of capital letters \"A\" and \"P\": \...
[{"input": "16\n4\nPPPP\n4\nAPPP\n4\nPAPP\n4\nAAPP\n4\nPPAP\n4\nAPAP\n4\nPAAP\n4\nAAAP\n4\nPPPA\n4\nAPPA\n4\nPAPA\n4\nAAPA\n4\nPPAA\n4\nAPAA\n4\nPAAA\n4\nAAAA\n", "output": "0\n3\n2\n2\n1\n1\n1\n1\n0\n2\n1\n1\n0\n1\n0\n0\n"}, {"input": "16\n4\nPPPP\n4\nAPPP\n4\nPAPP\n4\nAAPP\n4\nPPAP\n4\nAPAP\n4\nPAAP\n4\nAAAP\n4\nPPPA...
code_stdio
[ { "content": "On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January 23, 2018 should be written as 2018/01/23.\nAfter finishing the document, she noticed that she had mistakenly wrote 2017 at the beginning...
[{"input": "2017/01/07\n", "output": "2018/01/07\n"}, {"input": "2017/01/31\n", "output": "2018/01/31\n"}, {"input": "2017/01/06", "output": "2018/01/06\n"}, {"input": "2017/01/32", "output": "2018/01/32\n"}, {"input": "2017/01//7", "output": "2018/01//7\n"}, {"input": "2010/01/77", "output": "2018/01/77\n"}, {"input":...
code_stdio
[ { "content": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four k...
[{"input": "54\n10 13\n10 45\n10 51\n01 44\n10 24\n10 26\n10 39\n10 38\n10 41\n10 33\n10 18\n10 12\n10 38\n10 30\n11 31\n10 46\n11 50\n00 26\n00 29\n00 50\n10 16\n10 40\n10 50\n00 43\n10 48\n10 32\n10 18\n10 8\n10 24\n10 32\n10 52\n00 41\n10 37\n10 38\n10 49\n00 35\n10 52\n00 44\n10 41\n10 36\n00 28\n00 43\n10 36\n00 2...
code_stdio
[ { "content": "## The Riddle\n\nThe King of a small country invites 1000 senators to his annual party. As a tradition, each senator brings the King a bottle of wine. Soon after, the Queen discovers that one of the senators is trying to assassinate the King by giving him a bottle of poisoned wine. Unfortunately, ...
[{"input": "[3, 5, 6, 7, 8, 9]", "output": "[1000]", "fn_name": "find"}, {"input": "[0, 3, 5, 4, 9, 8]", "output": "[825]", "fn_name": "find"}, {"input": "[0, 1, 2, 3, 4, 6]", "output": "[95]", "fn_name": "find"}, {"input": "[0, 1, 9, 3, 5]", "output": "[555]", "fn_name": "find"}, {"input": "[0, 1, 3, 4]", "output": "[...
code_functional
[ { "content": "You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the table\n \n \n \n abcd ...
[{"input": "4 100\ngdgmmejiigzsmlarrnfsypvlbutvoxazcigpcospgztqkowfhhbnnbxxrbmwbxwkvxlxzabjjjdtbebedukdelooqlxnadjwjpnp\ndmtsnsbsfdzqvydxcdcnkkfcbseicxhvclsligbhqlkccwujpirymoshkqcosbtlxdypsdqkqaolrqtiibymavcwmbfryttdckhx\nqwujylxpxechsqxqwnxtanhpwenvbdgxighxkklpjtnowrcusxgezlnutcxrauuoqwmlsfzhcyqovfamqqvnzouuicpcjldpm...
code_stdio
[ { "content": "Assume that you have $k$ one-dimensional segments $s_1, s_2, \\dots s_k$ (each segment is denoted by two integers — its endpoints). Then you can build the following graph on these segments. The graph consists of $k$ vertexes, and there is an edge between the $i$-th and the $j$-th vertexes ($i \\ne...
[{"input": "1\n10\n1 2\n1 3\n2 4\n2 5\n2 6\n3 7\n3 8\n4 9\n4 10\n", "output": "10\n"}, {"input": "1\n10\n1 2\n2 3\n1 4\n2 5\n4 6\n6 7\n3 8\n4 9\n4 10\n", "output": "10\n"}, {"input": "1\n10\n1 2\n1 3\n1 4\n2 5\n2 6\n6 7\n1 8\n4 9\n4 10\n", "output": "10\n"}, {"input": "1\n10\n1 2\n1 3\n2 4\n2 5\n2 6\n3 7\n1 8\n4 9\n4 1...
code_stdio
[ { "content": "The only difference between easy and hard versions is on constraints. In this version constraints are lower. You can make hacks only if all versions of the problem are solved.\n\nKoa the Koala is at the beach!\n\nThe beach consists (from left to right) of a shore, $n+1$ meters of sea and an island...
[{"input": "32\n3 1 3\n2 2 1\n3 1 3\n2 2 2\n3 1 3\n2 2 3\n3 1 3\n2 3 1\n3 1 3\n2 3 2\n3 1 3\n2 3 3\n3 1 3\n3 1 1\n3 1 3\n3 1 2\n3 1 3\n3 1 3\n3 1 3\n3 2 1\n3 1 3\n3 2 2\n3 1 3\n3 2 3\n3 1 3\n3 3 1\n3 1 3\n3 3 2\n3 1 3\n3 3 3\n3 2 1\n1 1 1\n3 2 1\n1 1 2\n3 2 1\n1 1 3\n3 2 1\n1 2 1\n3 2 1\n1 2 2\n3 2 1\n1 2 3\n3 2 1\n1 3...
code_stdio
[ { "content": "After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $n$. Let's call them $a$ and $b$.\n\nNote that a permutation of $n$ elements is a sequence ...
[{"input": "20\n9 15 11 8 10 5 19 13 12 18 3 20 17 14 2 16 7 4 1 6\n12 6 7 5 4 20 15 14 1 18 10 17 9 19 16 3 13 11 2 8\n", "output": "2\n"}, {"input": "20\n9 15 11 8 10 5 19 13 12 18 3 20 17 14 2 16 7 4 1 6\n12 6 7 5 4 20 15 14 1 18 10 17 9 19 16 3 13 11 2 8\n", "output": "2"}, {"input": "18\n11 16 18 3 7 12 10 6 14 15...
code_stdio
[ { "content": "The Little Elephant likes permutations. This time he has a permutation A[1], A[2], ..., A[N] of numbers 1, 2, ..., N.\n\nHe calls a permutation A good, if the number of its inversions is equal to the number of its local inversions. The number of inversions is equal to the number of pairs of intege...
[{"input": "4\n0\n1\n2\n0 1\n3\n0 1 2\n4\n1 3 2 4", "output": "YES\nYES\nYES\nYES\n"}, {"input": "4\n0\n1\n2\n0 1\n3\n11 1 1\n4\n1 3 2 -1", "output": "YES\nYES\nNO\nNO\n"}, {"input": "4\n-1\n1\n1\n0 1\n3\n3 0 1\n4\n1 3 2 4", "output": "YES\nYES\nNO\nYES\n"}, {"input": "4\n0\n1\n2\n0 1\n3\n3 -1 0\n4\n1 3 2 4", "output":...
code_stdio
[ { "content": "Shinya watched a program on TV called \"Maya's Great Prophecy! Will the World End in 2012?\" After all, I wasn't sure if the world would end, but I was interested in Maya's \"long-term calendar,\" which was introduced in the program. The program explained as follows.\n\nThe Maya long-term calendar...
[{"input": "2012.12.31\n2.11.16.14.14\n7138.4.03\n10.5.5.1.2\n10000000.12.31\n#", "output": "0.0.0.0.10\n3034.11.28\n12.19.19.16.10\n6059.2.10\n8.19.3.13.2\n"}, {"input": "2312.02.12\n2.12.16.14.14\n7128.5.13\n5.1.5.2.01\n10020000.10.31\n#", "output": "0.15.3.8.19\n3054.8.15\n12.19.9.15.18\n4009.1.7\n7.13.14.14.11\n"},...
code_stdio
[ { "content": "Cirno_9baka has a tree with $n$ nodes. He is willing to share it with you, which means you can operate on it.\n\nInitially, there are two chess pieces on the node $1$ of the tree. In one step, you can choose any piece, and move it to the neighboring node. You are also given an integer $d$. You nee...
[{"input": "15 6\n11 8\n9 12\n7 12\n14 13\n12 4\n12 13\n1 7\n10 6\n12 8\n3 5\n3 2\n15 2\n6 8\n12 2\n4 14 11 10 2\n4 12 5 8 9\n", "output": "32"}, {"input": "15 2\n5 1\n15 8\n9 3\n2 10\n15 13\n12 1\n14 15\n2 1\n6 15\n13 7\n11 1\n1 15\n15 4\n1 9\n1 14\n7 5 15 1 7 11 2 13\n", "output": "16"}, {"input": "15 2\n4 13\n8 5\n1...
code_stdio
[ { "content": "It is a complicated version of problem F1. The difference between them is the constraints (F1: $k \\le 2$, F2: $k \\le 10$).\n\nYou are given an integer $n$. Find the minimum integer $x$ such that $x \\ge n$ and the number $x$ is $k$-beautiful.\n\nA number is called $k$-beautiful if its decimal re...
[{"input": "6\n2021 3\n177890 2\n34512 3\n724533 4\n998244353 1\n12345678 10\n", "output": "2021\n181111\n34533\n724542\n999999999\n12345678\n"}, {"input": "6\n2021 3\n177890 2\n34512 3\n724533 4\n998244353 1\n12345678 10\n", "output": "2021\n181111\n34533\n724542\n999999999\n12345678\n"}, {"input": "6\n2021 3\n177890 ...
code_stdio
[ { "content": "There is a toy building consisting of $n$ towers. Each tower consists of several cubes standing on each other. The $i$-th tower consists of $h_i$ cubes, so it has height $h_i$.\n\nLet's define operation slice on some height $H$ as following: for each tower $i$, if its height is greater than $H$, t...
[{"input": "10 10\n1 1 1 1 1 1 1 1 1 1\n", "output": "0\n"}, {"input": "10 10\n3 3 3 3 3 3 3 3 3 3\n", "output": "0\n"}, {"input": "10 10\n1 1 1 1 1 1 1 1 1 1\n", "output": "0\n"}, {"input": "10 10\n3 3 3 3 3 3 3 3 3 3\n", "output": "0\n"}, {"input": "10 10\n1 1 1 1 2 1 1 1 1 1\n", "output": "1\n"}, {"input": "10 10\n3...
code_stdio
[ { "content": "Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: \n\n Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal f...
[{"input": "28\nOctahedron\nDodecahedron\nOctahedron\nOctahedron\nDodecahedron\nIcosahedron\nIcosahedron\nDodecahedron\nDodecahedron\nDodecahedron\nCube\nDodecahedron\nCube\nTetrahedron\nCube\nCube\nTetrahedron\nDodecahedron\nDodecahedron\nDodecahedron\nIcosahedron\nIcosahedron\nDodecahedron\nIcosahedron\nDodecahedron\...
code_stdio
[ { "content": "The problem was inspired by Pied Piper story. After a challenge from Hooli's compression competitor Nucleus, Richard pulled an all-nighter to invent a new approach to compression: middle-out.\n\nYou are given two strings $s$ and $t$ of the same length $n$. Their characters are numbered from $1$ to...
[{"input": "6\n7\ncontest\nntecost\n7\ncontest\nnsttdco\n7\ncontest\ntnsteco\n7\ncontess\ncotestn\n7\ncontest\ncontest\n7\nontestc\ncontest\n", "output": "3\n-1\n4\n-1\n0\n1\n"}, {"input": "6\n7\ncontest\nntecost\n7\ncontest\nnstteco\n7\ncontest\ntnsteco\n7\ncontess\ncotestn\n7\ncontest\ncontest\n7\nontestc\ncontest\n"...
code_stdio
[ { "content": "The Beroil corporation structure is hierarchical, that is it can be represented as a tree. Let's examine the presentation of this structure as follows:\n\n * employee ::= name. | name:employee1,employee2, ... ,employeek.\n * name ::= name of an employee \n\n\n\nThat is, the description of each e...
[{"input": "ZLWSYH:WNMTNAI:FTCKPGZBJ.,UZSCFZVXXK.,LNGCU.,TCT.,LNGCU.,U.,NEHYSET..,FBLI:NEHYSET:IFY..,VN.,VN.,IFY.,FBLI.,YH.,FBLI.,DTXG.,NEHYSET.,WNMTNAI.,VN.,SVXN.,NEHYSET.,TCT.,DTXG..,UZSCFZVXXK:KZQRJFST.,FTCKPGZBJ.,WNMTNAI.,SVXN:DHONBXRZAL..,NEHYSET.,IFY..,MPOEEMVOP:DHONBXRZAL.,DTXG.,FTCKPGZBJ..,KZQRJFST:SVXN.,SVXN.....
code_stdio
[ { "content": "You were lucky enough to get a map just before entering the legendary magical mystery world. The map shows the whole area of your planned exploration, including several countries with complicated borders. The map is clearly drawn, but in sepia ink only; it is hard to recognize at a glance which re...
[{"input": "6\nBlizid\n0 0\n60 -1\n60 60\n0 60\n0 50\n50 50\n50 10\n0 10\n-1\nBlizid\n0 10\n10 10\n10 50\n0 50\n-1\nWindom\n10 10\n50 10\n40 20\n20 20\n20 40\n10 50\n-1\nAccent\n50 10\n50 50\n35 50\n35 25\n-1\nPilot\n35 25\n35 50\n19 50\n-1\nBlizid\n20 20\n40 20\n20 40\n-1\n4\nA1234567890123456789\n0 0\n0 100\n100 100\...
code_stdio
[ { "content": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in countercl...
[{"input": "50 100\n0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98\n1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99\n", "outp...
code_stdio
[ { "content": "coastline\n\nWaves rush to the beach every second. There is data that observes and records how many meters the wave rushed beyond the reference point P every second for only T seconds. The data consists of T integers x1, ..., xT, and for each i (1 ≤ i ≤ T), a wave from point P to the point exactly...
[{"input": "5 2 3\n3\n2\n1\n2\n6\n3 100 100\n5\n3\n4\n20 2 8\n3\n2\n10\n1\n14\n1\n1\n4\n2\n2\n16\n1\n8\n8\n2\n6\n3\n8\n3\n8\n7 2 2\n0\n2\n5\n2\n5\n2\n-1\n0 0 0", "output": "2\n0\n11\n5\n"}, {"input": "5 2 3\n3\n2\n1\n2\n6\n3 110 100\n5\n3\n4\n20 2 3\n3\n2\n10\n1\n14\n1\n1\n4\n2\n2\n16\n1\n8\n8\n2\n6\n3\n8\n3\n8\n7 2 2\...
code_stdio
[ { "content": "Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases: They are equal. If we split string a into two halves of the same size a_1 and a_2, and string b into two halves of the same ...
[{"input": "yhwepqwyhwepqwyhwepqweahnqtueahnqtueahnqtuyhwepqwyhwepqwyhwepqwyhwepqweahnqtueahnqtuyhwepqweahnqtueahnqtueahnqtueahnqtueahnqtueahnqtu\neahnqtueahnqtueahnqtuyhwepqweahnqtuyhwepqwyhwepqweahnqtuyhwepqweahnqtuyhwepqweahnqtueahnqtuyhwepqweahnqtueahnqtuyhwepqwyhwepqwyhwepqw\n", "output": "NO\n"}, {"input": "yhwep...
code_stdio
[ { "content": "[Image] \n\n\n-----Input-----\n\nThe input contains a single integer $a$ ($0 \\le a \\le 15$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n13\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the ou...
[{"input": "000\n", "output": "15\n"}, {"input": "3\n", "output": "13\n"}, {"input": "0\n", "output": "15\n"}, {"input": "1\n", "output": "14\n"}, {"input": "2\n", "output": "12\n"}, {"input": "6\n", "output": "10\n"}, {"input": "7\n", "output": "11\n"}, {"input": "10\n", "output": "2\n"}, {"input": "11\n", "output": "...
code_stdio
[ { "content": "###Lucky number\n\nWrite a function to find if a number is lucky or not. If the sum of all digits is 0 or multiple of 9 then the number is lucky.\n\n`1892376 => 1+8+9+2+3+7+6 = 36`. 36 is divisble by 9, hence number is lucky.\n\n\nFunction will return `true` for lucky numbers and `false` for other...
[{"input": "1892231413243242344321432142343423437", "output": "[true]", "fn_name": "is_lucky"}, {"input": "18922314324324234423437", "output": "[false]", "fn_name": "is_lucky"}, {"input": "189223141324324234423437", "output": "[true]", "fn_name": "is_lucky"}, {"input": "1892376", "output": "[true]", "fn_name": "is_luck...
code_functional
[ { "content": "Create a function finalGrade, which calculates the final grade of a student depending on two parameters: a grade for the exam and a number of completed projects.\n\nThis function should take two arguments:\nexam - grade for exam (from 0 to 100);\nprojects - number of completed projects (from 0 and...
[{"input": "100\n12", "output": "[100]", "fn_name": "final_grade"}, {"input": "10\n15", "output": "[100]", "fn_name": "final_grade"}, {"input": "99\n0", "output": "[100]", "fn_name": "final_grade"}, {"input": "85\n5", "output": "[90]", "fn_name": "final_grade"}, {"input": "55\n3", "output": "[75]", "fn_name": "final_gr...
code_functional
[ { "content": "Smart Beaver recently got interested in a new word game. The point is as follows: count the number of distinct good substrings of some string s. To determine if a string is good or not the game uses rules. Overall there are n rules. Each rule is described by a group of three (p, l, r), where p is ...
[{"input": "hrsszhjvrbsszvqesessiqbzeqijjerqirhhjsehiehezvzihzssivhvihrivrhizeqvvhejvibhqrbbqjrjsessvrhijzsrqirvsqqbibzhrzseijesszsrzhjjbqsrjrsrizivvhsjvqz\n3\nrzzevhiibziqiirhsebebrvrvvjihsjhvjjrejvqezireqevqeszrrseriijijijveqzbsbrezqhrrhbshqrhzshjervqjjzveeqsisrbevvjvjhbzvbjrrvizh 0 122\niqqqjirjjhrbrerhssszbqqizzhre...
code_stdio
[ { "content": "Skier rides on a snowy field. Its movements can be described by a string of characters 'S', 'N', 'W', 'E' (which correspond to $1$ meter movement in the south, north, west or east direction respectively).\n\nIt is known that if he moves along a previously unvisited segment of a path (i.e. this seg...
[{"input": "1\nENNNNNNNNNNNSSSSSSSSSSSEEEEEEEEEEN\n", "output": "126\n"}, {"input": "1\nNEEEEEEEEEEEWWWWWWWWWWWNNNNNNNNNNE\n", "output": "126\n"}, {"input": "1\nENNNNNNNNNNNSSSSSSSNSSSEEEEEEEEEES\n", "output": "126\n"}, {"input": "1\nNNNNNNNNNNNESSSSSSSNSSSEEEEEEEEEES\n", "output": "162\n"}, {"input": "1\nNNNNSNNNNNNES...
code_stdio
[ { "content": "Balph is learning to play a game called Buma. In this game, he is given a row of colored balls. He has to choose the color of one new ball and the place to insert it (between two balls, or to the left of all the balls, or to the right of all the balls).\n\nWhen the ball is inserted the following h...
[{"input": "WWWOONOOOWWW\n", "output": "0\n"}, {"input": "WWWOONOOOVWW\n", "output": "0\n"}, {"input": "WVWOONOOOVWW\n", "output": "0\n"}, {"input": "WOWOONVOOVWW\n", "output": "0\n"}, {"input": "WOWONOVOOVWW\n", "output": "0\n"}, {"input": "WWVOOVONOWOW\n", "output": "0\n"}, {"input": "WWVPOVONOWOW\n", "output": "0\n"...
code_stdio
[ { "content": "Every day, N passengers arrive at Takahashi Airport. The i-th passenger arrives at time T_i.\n\nEvery passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers. Naturally, a passenger cannot take a bus that departs earlier than the airplane arri...
[{"input": "6 4 3\n11\n6\n2\n13\n17\n5", "output": "4\n"}, {"input": "6 4 3\n11\n9\n2\n13\n17\n5", "output": "4\n"}, {"input": "6 3 3\n7\n6\n2\n13\n17\n5", "output": "4\n"}, {"input": "6 3 3\n7\n6\n2\n13\n10\n6", "output": "3\n"}, {"input": "6 3 6\n7\n6\n2\n13\n10\n6", "output": "2\n"}, {"input": "6 3 6\n7\n6\n2\n22\n1...
code_stdio
[ { "content": "One day, at the \"Russian Code Cup\" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.\n\nThe appointed Judge was the most experienced member — Pave...
[{"input": "263 51\n", "output": "13413\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10\n1 11\n1 12\n1 13\n1 14\n1 15\n1 16\n1 17\n1 18\n1 19\n1 20\n1 21\n1 22\n1 23\n1 24\n1 25\n1 26\n1 27\n1 28\n1 29\n1 30\n1 31\n1 32\n1 33\n1 34\n1 35\n1 36\n1 37\n1 38\n1 39\n1 40\n1 41\n1 42\n1 43\n1 44\n1 45\n1 46\n1 47\n1 48\n1 49\...
code_stdio
[ { "content": "$n$ robots have escaped from your laboratory! You have to find them as soon as possible, because these robots are experimental, and their behavior is not tested yet, so they may be really dangerous!\n\nFortunately, even though your robots have escaped, you still have some control over them. First ...
[{"input": "4\n2\n-1 -2 0 0 0 0\n-1 -2 0 0 0 0\n3\n1 5 1 1 1 1\n2 5 0 0 0 1\n4 5 1 0 0 1\n2\n754 1337 0 1 1 1\n1336 1337 1 1 0 1\n1\n3 5 1 1 1 1\n", "output": "1 -1 -2\n1 2 -100000\n1 754 -100000\n1 -100000 -100000\n"}, {"input": "4\n2\n-1 -2 0 0 0 0\n-1 -2 0 0 0 0\n3\n1 5 1 1 1 1\n2 5 0 0 0 1\n4 5 1 0 0 1\n2\n754 1337...
code_stdio
[ { "content": "Given a square table sized NxN (3 ≤ N ≤ 5,000; rows and columns are indexed from 1) with a robot on it. The robot has a mission of moving from cell (1, 1) to cell (N, N) using only the directions \"right\" or \"down\". You are requested to find the number of different ways for the robot using exac...
[{"input": "2 4\n0 3\n3 9\n0 0", "output": "712406685\n49980002\n436378119\n"}, {"input": "2 2\n0 3\n3 9\n0 0", "output": "774058230\n49980002\n436378119\n"}, {"input": "2 2\n4 33\n6 3\n0 0", "output": "774058230\n361127130\n32\n"}, {"input": "2 2\n4 33\n5 3\n0 0", "output": "774058230\n361127130\n18\n"}, {"input": "2 ...
code_stdio
[ { "content": "Vasya is interested in arranging dominoes. He is fed up with common dominoes and he uses the dominoes of different heights. He put n dominoes on the table along one axis, going from left to right. Every domino stands perpendicular to that axis so that the axis passes through the center of its base...
[{"input": "10\n34 9\n-41 26\n-101 32\n1 10\n105 14\n92 7\n-45 35\n75 19\n-23 2\n-46 8\n", "output": "1 2 1 1 1 1 3 2 1 4\n"}, {"input": "10\n34 9\n-41 26\n-101 17\n1 10\n105 14\n92 7\n-45 35\n75 19\n-23 2\n-46 8\n", "output": "1 2 1 1 1 1 3 2 1 4\n"}, {"input": "10\n64 9\n-41 26\n-101 17\n1 10\n105 14\n92 7\n-45 35\n7...
code_stdio
[ { "content": "William really likes the cellular automaton called \"Game of Life\" so he decided to make his own version. For simplicity, William decided to define his cellular automaton on an array containing $n$ cells, with each cell either being alive or dead.\n\nEvolution of the array in William's cellular a...
[{"input": "4\n10 1\n1111111111\n9 4\n000000000\n9 4\n000000000\n9 4\n000000000\n", "output": "1111111111\n000000000\n000000000\n000000000\n"}, {"input": "4\n10 1\n1111111111\n9 4\n000000000\n9 4\n000000000\n9 4\n000000000\n", "output": "1111111111\n000000000\n000000000\n000000000\n"}, {"input": "4\n10 1\n1111111111\n9...
code_stdio
[ { "content": "In the Jambo Amusement Garden (JAG), you sell colorful drinks consisting of multiple color layers. This colorful drink can be made by pouring multiple colored liquids of different density from the bottom in order.\n\nYou have already prepared several colored liquids with various colors and densiti...
[{"input": "4\nred 3444\nred 3018\nred 3098\nred 3319\n4\nred\nred\nrec\nred", "output": "No\n"}, {"input": "4\nred 3444\nder 3018\nred 3098\nred 3319\n4\nred\nred\nrec\nred", "output": "No\n"}, {"input": "4\nred 2133\nder 3018\nred 3098\nred 3319\n4\nred\nred\nrec\nred", "output": "No\n"}, {"input": "4\nred 2133\nder ...
code_stdio
[ { "content": "Quantum mechanics tells us that a molecule is only allowed to have specific, discrete amounts of internal energy. The 'rigid rotor model', a model for describing rotations, tells us that the amount of rotational energy a molecule can have is given by: \n\n`E = B * J * (J + 1)`, \n\nwhere J is th...
[{"input": "423\n100\n150", "output": "[[4272300, 4357746, 4444038, 4531176, 4619160, 4707990, 4797666, 4888188, 4979556, 5071770, 5164830, 5258736, 5353488, 5449086, 5545530, 5642820, 5740956, 5839938, 5939766, 6040440, 6141960, 6244326, 6347538, 6451596, 6556500, 6662250, 6768846, 6876288, 6984576, 7093710, 7203690, ...
code_functional
[ { "content": "There are N squares numbered 1 to N from left to right. Each square has a character written on it, and Square i has a letter s_i. Besides, there is initially one golem on each square.\n\nSnuke cast Q spells to move the golems.\n\nThe i-th spell consisted of two characters t_i and d_i, where d_i is...
[{"input": "10 15\nSNCZWRCEWB\nB R\nR R\nE R\nW R\nZ L\nS R\nQ L\nW L\nB R\nC L\nA L\nN L\nE R\nZ L\nR L", "output": "7\n"}, {"input": "10 15\nBWECRWZCNS\nB R\nR R\nE R\nW R\nZ L\nS R\nQ L\nW L\nB R\nC L\nA L\nN L\nE R\nZ L\nR L", "output": "9\n"}, {"input": "10 0\nSNCZWRCEWB\nB R\nR R\nE R\nX R\nZ L\nS R\nQ L\nW L\nB ...
code_stdio
[ { "content": "Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number b_{i}. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. She wants to have those pairs of flowers that ...
[{"input": "10\n1000000000 1100000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000010000 1000000000\n", "output": "100000000 8\n"}, {"input": "10\n1000000000 1100000000 1000000100 1000000000 1000000000 1000000000 1000000000 1000000000 1000010000 1000000000\n", "output": "100000000 7\n"}, {"inp...
code_stdio
[ { "content": "As Sherlock Holmes was investigating another crime, he found a certain number of clues. Also, he has already found direct links between some of those clues. The direct links between the clues are mutual. That is, the direct link between clues A and B and the direct link between clues B and A is th...
[{"input": "30 70 288262020\n27 18\n5 19\n23 17\n16 17\n29 17\n1 22\n23 5\n10 13\n22 26\n14 3\n8 3\n29 9\n9 1\n3 9\n16 4\n9 22\n10 22\n20 1\n3 7\n23 19\n26 8\n24 1\n5 7\n28 29\n20 11\n16 12\n6 9\n24 29\n30 4\n5 26\n18 21\n5 21\n30 6\n12 13\n16 23\n28 14\n30 1\n7 27\n7 19\n27 17\n5 30\n30 27\n28 30\n12 28\n27 9\n30 26\n...
code_stdio
[ { "content": "You are given the current time in 24-hour format hh:mm. Find and print the time after a minutes.\n\nNote that you should find only the time after a minutes, see the examples to clarify the problem statement.\n\nYou can read more about 24-hour format here https://en.wikipedia.org/wiki/24-hour_clock...
[{"input": "12:34\n10000\n", "output": "11:14\n"}, {"input": "00:00\n10000\n", "output": "22:40\n"}, {"input": "00:00\n10000\n", "output": "22:40\n"}, {"input": "12:34\n10000\n", "output": "11:14\n"}, {"input": "00:00\n00000\n", "output": "00:00\n"}, {"input": "14:32\n10000\n", "output": "13:12\n"}, {"input": "00:00\n0...
code_stdio
[ { "content": "Nickname Generator\n\nWrite a function, `nicknameGenerator` that takes a string name as an argument and returns the first 3 or 4 letters as a nickname.\n\nIf the 3rd letter is a consonant, return the first 3 letters.\n\nIf the 3rd letter is a vowel, return the first 4 letters. \n\nIf the string is...
[{"input": "\"Sam\"", "output": "[\"Error: Name too short\"]", "fn_name": "nickname_generator"}, {"input": "\"Jam\"", "output": "[\"Error: Name too short\"]", "fn_name": "nickname_generator"}, {"input": "\"Suv\"", "output": "[\"Error: Name too short\"]", "fn_name": "nickname_generator"}, {"input": "\"Ni\"", "output": "...
code_functional
[ { "content": "Problem statement\n\nThere is a positive integer sequence $ a_1, a_2, \\ ldots, a_N $ of length $ N $.\n\nConsider the following game, which uses this sequence and is played by $ 2 $ players on the play and the play.\n\n* Alternately select one of the following operations for the first move and th...
[{"input": "2\n10 -2", "output": "Second\n"}, {"input": "2\n-1 10", "output": "First\n"}, {"input": "2\n-2 2", "output": "Second\n"}, {"input": "2\n-2 4", "output": "Second\n"}, {"input": "2\n-2 8", "output": "Second\n"}, {"input": "2\n0 -2", "output": "Second\n"}, {"input": "2\n0 10", "output": "Second\n"}, {"input": ...
code_stdio
[ { "content": "Given a positive integer $k$, two arrays are called $k$-similar if:\n\nthey are strictly increasing;\n\nthey have the same length;\n\nall their elements are positive integers between $1$ and $k$ (inclusive);\n\nthey differ in exactly one position.\n\nYou are given an integer $k$, a strictly increa...
[{"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"}, {"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"}, {"input": "6 5 13\n2 4 6 7 8 12\n1 4\n1 3\n3 5\n2 2\n5 5\n", "output": "11\n12\n10\n12\n12\n"}, {"input": "6 5 20\n2 5 6 7 8 9\...
code_stdio
[ { "content": "Stepan has a very big positive integer.\n\nLet's consider all cyclic shifts of Stepan's integer (if we look at his integer like at a string) which are also integers (i.e. they do not have leading zeros). Let's call such shifts as good shifts. For example, for the integer 10203 the good shifts are ...
[{"input": "8460711003592660299377170851036141857177105821455679225940496548902563144980707248030407967017317182\n13315371\n", "output": "16290\n"}, {"input": "8460711003592660299377170851036141857177105821455679225940496548902563144980707248030407967017317182\n6886527\n", "output": "136104\n"}, {"input": "846071100359...
code_stdio
[ { "content": "Mike and some bears are playing a game just for fun. Mike is the judge. All bears except Mike are standing in an n × m grid, there's exactly one bear in each cell. We denote the bear standing in column number j of row number i by (i, j). Mike's hands are on his ears (since he's the judge) and each...
[{"input": "5 5 30\n0 1 1 1 0\n1 1 0 1 1\n0 1 1 1 1\n0 0 1 1 0\n0 0 0 0 0\n3 2\n2 2\n2 2\n4 3\n1 4\n3 2\n4 1\n2 4\n1 4\n2 1\n5 2\n4 1\n4 1\n5 1\n2 4\n2 4\n4 4\n1 2\n3 1\n4 5\n1 2\n2 3\n1 1\n5 1\n3 4\n1 1\n5 4\n1 5\n5 4\n2 2\n", "output": "3\n3\n3\n3\n3\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n5\n5\n5\n5\n5\n5\n4\n3\n3\n...
code_stdio
[ { "content": "Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it either only consisted of lowercase letters or, vice versa, only of...
[{"input": "XHRPXZEGHSOCJPICUIXSKFrZUPYTSGJSDIYBCMNMNBPNDBXLXBzhbfnqvwcffvUdhtickyqhupmcehlsyvncqmfhautvxudqdhgg\n", "output": "xhrpxzeghsocjpicuixskfrzupytsgjsdiybcmnmnbpndbxlxbzhbfnqvwcffvudhtickyqhupmcehlsyvncqmfhautvxudqdhgg\n"}, {"input": "RJIQZMJzIMSNDBOHBRAWIENODSALETAKGKPYUFGVEFGCBRENZGAdkcetqjljtmttlonpekcovdz...
code_stdio
[ { "content": "Takahashi has K 500-yen coins. (Yen is the currency of Japan.)\nIf these coins add up to X yen or more, print Yes; otherwise, print No.\n\n-----Constraints-----\n - 1 \\leq K \\leq 100\n - 1 \\leq X \\leq 10^5\n\n-----Input-----\nInput is given from Standard Input in the following format:\nK X\n\n...
[{"input": "100 100000\n", "output": "No\n"}, {"input": "84 42001\n", "output": "No\n"}, {"input": "13 6498\n", "output": "Yes\n"}, {"input": "4 2000\n", "output": "Yes\n"}, {"input": "13 1282", "output": "Yes\n"}, {"input": "10 1282", "output": "Yes\n"}, {"input": "2 900\n", "output": "Yes\n"}, {"input": "1 500\n", "o...
code_stdio
[ { "content": "Pupils Alice and Ibragim are best friends. It's Ibragim's birthday soon, so Alice decided to gift him a new puzzle. The puzzle can be represented as a matrix with $2$ rows and $n$ columns, every element of which is either $0$ or $1$. In one move you can swap two values in neighboring cells.\n\nMor...
[{"input": "50\n0 1 1 1 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 0\n0 0 0 1 0 1 0 0 0 1 0 1 1 1 0 0 0 0 0 1 0 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 1\n0 0 0 0 1 1 0 0 1 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 0 0 1 0 1 1 0 0 1 0 0 0\n1...
code_stdio
[ { "content": "Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is not less than s. To prove that these numbers ma...
[{"input": "1000000000000000000 100000000000000000\n", "output": "899999999999999991\n"}, {"input": "1000000000000000000 200000000000000000\n", "output": "799999999999999991\n"}, {"input": "1000000000000000000 100000000000000000\n", "output": "899999999999999991\n"}, {"input": "1000000000000000000 200000000000000000\n"...
code_stdio
[ { "content": "Integral numbers can be even or odd.\n\nEven numbers satisfy `n = 2m` ( with `m` also integral ) and we will ( completely arbitrarily ) think of odd numbers as `n = 2m + 1`. \nNow, some odd numbers can be more odd than others: when for some `n`, `m` is more odd than for another's. Recursively. :]...
[{"input": "[1, 3, 5, 7]", "output": "[7]", "fn_name": "oddest"}, {"input": "[-1, -1]", "output": "[null]", "fn_name": "oddest"}, {"input": "[-1, 0, 1]", "output": "[-1]", "fn_name": "oddest"}, {"input": "[-5, 3]", "output": "[null]", "fn_name": "oddest"}, {"input": "[1, 5]", "output": "[null]", "fn_name": "oddest"}, {...
code_functional
[ { "content": "Quite recently, a very smart student named Jury decided that lectures are boring, so he downloaded a game called \"Black Square\" on his super cool touchscreen phone.\n\nIn this game, the phone's screen is divided into four vertical strips. Each second, a black square appears on some of the strips...
[{"input": "1809 1302 7164 6122\n3144121413113111223311232232114144321414421243443243422322144324121433444342231344234443332241322442\n", "output": "420780\n"}, {"input": "1809 1302 7164 6122\n3144121413113111223311232232114144321414421243443243422322144324121433444342231344234443332241322442\n", "output": "420780\n"},...
code_stdio
[ { "content": "Little Petya likes numbers a lot. He found that number 123 in base 16 consists of two digits: the first is 7 and the second is 11. So the sum of digits of 123 in base 16 is equal to 18.\n\nNow he wonders what is an average value of sum of digits of the number A written in all bases from 2 to A - 1...
[{"input": "1209\n", "output": "263450/1207\n"}, {"input": "1869\n", "output": "627063/1867\n"}, {"input": "1865\n", "output": "623876/1863\n"}, {"input": "1343\n", "output": "325366/1341\n"}, {"input": "1440\n", "output": "371753/1438\n"}, {"input": "1109\n", "output": "222215/1107\n"}, {"input": "1030\n", "output": "...
code_stdio
[ { "content": "This is the hard version of the problem. The only difference is that in this version 1 ≤ q ≤ 10^5. You can make hacks only if both versions of the problem are solved.\n\nThere is a process that takes place on arrays a and b of length n and length n-1 respectively. \n\nThe process is an infinite se...
[{"input": "3\n2 3 9\n0 1\n5\n-1 0 0 -100000 000000\n", "output": "120\n119\n119\n120\n119\n"}, {"input": "3\n2 3 9\n0 1\n5\n0 0 0 -100000 000000\n", "output": "119\n119\n119\n120\n119\n"}, {"input": "3\n4 5 4\n2 1\n5\n-1 0 1 -100000 100100\n", "output": "146\n113\n51\n150\n0\n"}, {"input": "3\n5 4 4\n2 1\n5\n-1 0 1 -1...
code_stdio
[ { "content": "# Task\n\nJohn is a programmer. He treasures his time very much. He lives on the `n` floor of a building. Every morning he will go downstairs as quickly as possible to begin his great work today.\n\nThere are two ways he goes downstairs: walking or taking the elevator.\n\nWhen John uses the elevat...
[{"input": "5\n6\n[1, 2, 3, 10]", "output": "[12]", "fn_name": "shortest_time"}, {"input": "5\n5\n[1, 2, 3, 10]", "output": "[11]", "fn_name": "shortest_time"}, {"input": "2\n2\n[2, 3, 4, 10]", "output": "[10]", "fn_name": "shortest_time"}, {"input": "5\n4\n[1, 2, 3, 10]", "output": "[12]", "fn_name": "shortest_time"},...
code_functional
[ { "content": "Ania has a large integer $S$. Its decimal representation has length $n$ and doesn't contain any leading zeroes. Ania is allowed to change at most $k$ digits of $S$. She wants to do it in such a way that $S$ still won't contain any leading zeroes and it'll be minimal possible. What integer will Ani...
[{"input": "400 224\n34034718296316650556302576767095880542740697596682657060609028712014739414658241556774411582749368771597248873201583574900424227251655547840887764275893533353440635216728376201808545879398359535670372855472971530695051695650262058940466340529417646357776899296790403916961389072619545914097176242329...
code_stdio
[ { "content": "The Robot is in a rectangular maze of size n × m. Each cell of the maze is either empty or occupied by an obstacle. The Robot can move between neighboring cells on the side left (the symbol \"L\"), right (the symbol \"R\"), up (the symbol \"U\") or down (the symbol \"D\"). The Robot can move to th...
[{"input": "20 20 118\n..............*.....\n........*.........*.\n............*.......\n*...................\n....*......*..*.....\n................*...\n....................\n...............*....\n.......*..........*.\n.*..........*.......\n.*..............*..X\n....................\n...............*....\n..............
code_stdio
[ { "content": "Difference of Big Integers\n\nGiven two integers $A$ and $B$, compute the difference, $A - B$.\n\nInput\n\nTwo integers $A$ and $B$ separated by a space character are given in a line.\n\nOutput\n\nPrint the difference in a line.\n\nConstraints\n\n* $-1 \\times 10^{100000} \\leq A, B \\leq 10^{1000...
[{"input": "-2 -1280", "output": "1278\n"}, {"input": "-2 -1243", "output": "1241\n"}, {"input": "-2 -2265", "output": "2263\n"}, {"input": "-1 -2265", "output": "2264\n"}, {"input": "-1 -2368", "output": "2367\n"}, {"input": "-1 -2335", "output": "2334\n"}, {"input": "-2 -2335", "output": "2333\n"}, {"input": "0 -2335...
code_stdio
[ { "content": "The weight of a sequence is defined as the number of unordered pairs of indexes $(i,j)$ (here $i \\lt j$) with same value ($a_{i} = a_{j}$). For example, the weight of sequence $a = [1, 1, 2, 2, 1]$ is $4$. The set of unordered pairs of indexes with same value are $(1, 2)$, $(1, 5)$, $(2, 5)$, and...
[{"input": "2\n4\n2 2 2 2\n4\n1 3 3 4\n", "output": "15\n4\n"}, {"input": "2\n4\n2 2 2 2\n4\n1 4 3 4\n", "output": "15\n2\n"}, {"input": "2\n4\n2 2 2 2\n4\n1 2 3 4\n", "output": "15\n0\n"}, {"input": "2\n4\n1 2 3 1\n4\n1 4 11 4\n", "output": "1\n2\n"}, {"input": "2\n4\n1 6 4 2\n4\n1 10 1 4\n", "output": "0\n2\n"}, {"in...
code_stdio
[ { "content": "For a permutation P[1... N] of integers from 1 to N, function f is defined as follows:\n\n $f(i, j) = \\left\\{\\begin{array}{ll}{P [ i ]} & {\\text{if} j = 1} \\\\{f(P [ i ], j - 1)} & {\\text{otherwise}} \\end{array} \\right.$ \n\nLet g(i) be the minimum positive integer j such that f(i, j) = i....
[{"input": "10 7 5\n", "output": "2 3 4 5 1 7 8 9 10 6 "}, {"input": "10 7 5\n", "output": "2 3 4 5 1 7 8 9 10 6 "}, {"input": "9 2 5\n", "output": "2 1 4 3 6 7 8 9 5 "}, {"input": "9 7 9\n", "output": "2 3 4 5 6 7 8 9 1 "}, {"input": "9 2 5\n", "output": "2 1 4 3 6 7 8 9 5 "}, {"input": "9 7 9\n", "output": "2 3 4 5 6...
code_stdio
[ { "content": "You'll be given a string, and have to return the total of all the unicode characters as an int. Should be able to handle any characters sent at it. \n\nexamples:\n\nuniTotal(\"a\") == 97\nuniTotal(\"aaa\") == 291\n\nWrite Python code to solve this problem. Define a top-level function named `uni_to...
[{"input": "\"Mary Had A Little Lamb\"", "output": "[1873]", "fn_name": "uni_total"}, {"input": "\"Mary had a little lamb\"", "output": "[2001]", "fn_name": "uni_total"}, {"input": "\"And so does Strive\"", "output": "[1661]", "fn_name": "uni_total"}, {"input": "\"CodeWars rocks\"", "output": "[1370]", "fn_name": "uni_...
code_functional
[ { "content": "Given three numbers $n, a, b$. You need to find an adjacency matrix of such an undirected graph that the number of components in it is equal to $a$, and the number of components in its complement is $b$. The matrix must be symmetric, and all digits on the main diagonal must be zeroes.\n\nIn an und...
[{"input": "191 1 1\n", "output": "YES\n01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n101000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
code_stdio
[ { "content": "##Task:\n\nYou have to write a function **pattern** which creates the following pattern upto n number of rows. \n\n* If the Argument is 0 or a Negative Integer then it should return \"\" i.e. empty string.\n\n* If any odd number is passed as argument then the pattern should last upto the largest e...
[{"input": "6", "output": "[\"22\\n4444\\n666666\"]", "fn_name": "pattern"}, {"input": "5", "output": "[\"22\\n4444\"]", "fn_name": "pattern"}, {"input": "2", "output": "[\"22\"]", "fn_name": "pattern"}, {"input": "-25", "output": "[\"\"]", "fn_name": "pattern"}, {"input": "1", "output": "[\"\"]", "fn_name": "pattern"}...
code_functional
[ { "content": "One day, Taro received a strange email with only the number \"519345213244\" in the text. The email was from my cousin, who was 10 years older than me, so when I called and asked, \"Oh, I sent it with a pocket bell because I was in a hurry. It's convenient. Nice to meet you!\" I got it. You know t...
[{"input": "341143514535\n158\n143565553551655311343411652235654535651124615163\n551544654451431564\n4\n3411\n6363636363\n153414", "output": "naruto\nNA\ndo you wanna go to aizu?\nyes sure!\nNA\nna\n?????\nend\n"}, {"input": "341143514535\n158\n143565553551655311343411652235654535651124615163\n551544654451431564\n4\n29...
code_stdio
[ { "content": "The 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$ units.\n\nSome very rich customers asked him to complete some projects for t...
[{"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\n209 -299\n16 -297\n592...
code_stdio
[ { "content": "[3R2 as DJ Mashiro - Happiness Breeze](https://open.spotify.com/track/2qGqK8GRS65Wlf20qUBEak)\n\n[Ice - DJ Mashiro is dead or alive](https://soundcloud.com/iceloki/dj-mashiro-is-dead-or-alive)\n\nNEKO#ΦωΦ has just got a new maze game on her PC!\n\nThe game's main puzzle is a maze, in the forms of ...
[{"input": "10 83\n1 3\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n1 4\n2 2\n2 3\n2 3\n2 3\n2 3\n2 3\n2 3\n1 4\n1 5\n1 7\n2 2\n2 2\n1 5\n2 2\n1 3\n2 1\n2 6\n1 5\n2 6\n2 9\n1 2\n2 5\n1 2\n2 5\n2 4\n2 4\n1 2\n1 2\n1 4\n2 6\n2 6\n2 4\n2 4\n1 2\n1 2\n2 4\n2 4\n2 3\n2 3\n1 2\n2 9\n1 2\n1 2\n1 2\n2 6\n2 6\n2 4\n2 4\n2 3\n2 5\n2 5\n2...
code_stdio
[ { "content": "Complete the function that takes 3 numbers `x, y and k` (where `x ≤ y`), and returns the number of integers within the range `[x..y]` (both ends included) that are divisible by `k`.\n\nMore scientifically: `{ i : x ≤ i ≤ y, i mod k = 0 }`\n\n\n## Example\n\nGiven ```x = 6, y = 11, k = 2``` the fu...
[{"input": "1005\n9999999999999999999999999999999999999999999\n109", "output": "[91743119266055045871559633027522935779807]", "fn_name": "divisible_count"}, {"input": "101\n9999999999999999999999999999999999999999999\n11", "output": "[909090909090909090909090909090909090909081]", "fn_name": "divisible_count"}, {"input"...
code_functional
[ { "content": "Here, we want to solve path planning for a mobile robot cleaning a rectangular room floor with furniture.\n\nConsider the room floor paved with square tiles whose size fits the cleaning robot (1 × 1). There are 'clean tiles' and 'dirty tiles', and the robot can change a 'dirty tile' to a 'clean ti...
[{"input": "7 5\n.......\n.o...*.\n.......\n.*...*.\n.......\n15 13\n.......x.......\n...o...x....*..\n.......x.......\n.......x.......\n.......x.......\n.-.............\nxxxxx.....xxxxx\n...............\n.......x.......\n.......x.......\n.......x.......\n..*....x....*..\n.......x.......\n10 10\n..........\n..o.......\...
code_stdio
[ { "content": "A newspaper is published in Walrusland. Its heading is s1, it consists of lowercase Latin letters. Fangy the little walrus wants to buy several such newspapers, cut out their headings, glue them one to another in order to get one big string. After that walrus erase several letters from this string...
[{"input": "ehfjaabjfedhddejjfcfijagefhkeahjcddhchahjbagi\nfbfdjbjhibjgjgaaajgdbcfdbhjcajcbbieijhcjgajhgaa\n", "output": "10\n"}, {"input": "ehfjaabjfedhddejjfcfijagefhkeahjcddhchahjbagi\naaghjagjchjieibbcjacjhbdfcbdgjaaagjgjbihjbjdfbf\n", "output": "10\n"}, {"input": "ehfjabbjfedhddejjfcfijagefhkeahjcddhchahjbagi\nfbf...
code_stdio
[ { "content": "An array $a$ is good if for all pairs of adjacent elements, $a_i$ and $a_{i+1}$ ($1\\le i \\lt n$) are of different parity. Note that an array of size $1$ is trivially good.\n\nYou are given an array of size $n$.\n\nIn one operation you can select any pair of adjacent elements in which both elemen...
[{"input": "30\n1\n1\n1\n2\n2\n1 1\n2\n1 2\n2\n2 1\n2\n2 2\n3\n1 1 1\n3\n1 1 2\n3\n1 2 1\n3\n1 2 2\n3\n2 1 1\n3\n2 1 2\n3\n2 2 1\n3\n2 2 2\n4\n1 1 1 1\n4\n1 1 1 2\n4\n1 1 2 1\n4\n1 1 2 2\n4\n1 2 1 1\n4\n1 2 1 2\n4\n1 2 2 1\n4\n1 2 2 2\n4\n2 1 1 1\n4\n2 1 1 2\n4\n2 1 2 1\n4\n2 1 2 2\n4\n2 2 1 1\n4\n2 2 1 2\n4\n2 2 2 1\n...
code_stdio
[ { "content": "Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. [Image] \n\nInitially, each hole has $a_i$ stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes the...
[{"input": "297857621 238127103 749085829 139033277 597985489 202617713 1366784327 117968155 278551059 297781685 330124279 338959601 682874531 259895291\n", "output": "5305874892\n"}, {"input": "404418821 993626161 346204297 122439813 461187221 628048227 625919459 628611733 938993057 701270099 398043779 684205961 63097...
code_stdio
[ { "content": "We have N weights indexed 1 to N. The mass of the weight indexed i is W_i.\nWe will divide these weights into two groups: the weights with indices not greater than T, and those with indices greater than T, for some integer 1 \\leq T < N. Let S_1 be the sum of the masses of the weights in the forme...
[{"input": "100\n15 62 67 2 22 89 88 68 100 14 35 3 81 6 26 81 13 90 17 53 60 82 6 84 31 76 26 64 74 41 33 93 29 99 89 85 34 56 62 64 100 85 65 67 95 28 49 100 9 53 18 31 37 3 37 37 24 71 91 47 73 86 42 71 90 63 98 50 75 82 67 61 48 30 35 29 41 37 1 58 85 91 19 40 85 68 36 48 52 73 6 8 100 47 82 3 17 88 28 94\n", "outp...
code_stdio
[ { "content": "Roman and Denis are on the trip to the programming competition. Since the trip was long, they soon got bored, and hence decided to came up with something. Roman invented a pizza's recipe, while Denis invented a string multiplication. According to Denis, the result of multiplication (product) of st...
[{"input": "4\nqe\nnd\niqryhukieskfvaeettersinksrmazelxtgvartuz\nvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv...
code_stdio
[ { "content": "Several ages ago Berland was a kingdom. The King of Berland adored math. That's why, when he first visited one of his many palaces, he first of all paid attention to the floor in one hall. The floor was tiled with hexagonal tiles.\n\nThe hall also turned out hexagonal in its shape. The King walked...
[{"input": "1000 1100 1000\n", "output": "3196901\n"}, {"input": "1000 0100 1000\n", "output": "1197901\n"}, {"input": "1000 1000 1000\n", "output": "2997001"}, {"input": "998 999 1001\n", "output": "2993002\n"}, {"input": "1143 998 467\n", "output": "2137954\n"}, {"input": "998 137 1000\n", "output": "1269592\n"}, {"i...
code_stdio
[ { "content": "Phoenix is picking berries in his backyard. There are $n$ shrubs, and each shrub has $a_i$ red berries and $b_i$ blue berries.\n\nEach basket can contain $k$ berries. But, Phoenix has decided that each basket may only contain berries from the same shrub or berries of the same color (red or blue). ...
[{"input": "20 4\n0 1\n0 2\n0 0\n1 2\n3 2\n1 3\n1 3\n2 0\n3 1\n0 2\n3 3\n2 3\n2 0\n3 2\n1 2\n1 1\n1 1\n1 2\n0 0\n1 3\n", "output": "14\n"}, {"input": "20 4\n0 1\n0 2\n0 0\n1 2\n3 2\n1 3\n1 3\n2 0\n3 1\n0 2\n3 3\n2 3\n2 0\n3 2\n1 2\n1 1\n1 1\n1 2\n0 0\n1 3\n", "output": "14\n"}, {"input": "20 4\n0 1\n0 2\n0 0\n1 2\n3 2\...
code_stdio
[ { "content": "The BFS algorithm is defined as follows. Consider an undirected graph with vertices numbered from $1$ to $n$. Initialize $q$ as a new queue containing only vertex $1$, mark the vertex $1$ as used. Extract a vertex $v$ from the head of the queue $q$. Print the index of vertex $v$. Iterate in ar...
[{"input": "11\n1 2\n2 8\n3 7\n4 9\n5 10\n5 11\n6 4\n6 5\n7 1\n1 6\n1 6 7 2 5 4 3 8 11 10 9\n", "output": "Yes\n"}, {"input": "11\n1 2\n2 8\n3 7\n4 9\n5 10\n5 11\n11 4\n6 5\n7 1\n1 6\n1 6 7 2 5 4 3 8 11 10 9\n", "output": "No\n"}, {"input": "11\n1 2\n2 8\n3 7\n4 9\n5 10\n5 11\n11 4\n8 5\n7 1\n1 6\n1 6 7 2 5 4 3 8 11 10...
code_stdio
[ { "content": "We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.\n\nInitially, the hand of every clock stands still, pointing directly upward.\n\nNow, Dolphin starts all the clocks simultaneously.\n\nIn how many seconds will the hand of every clock point directly u...
[{"input": "100\n999999999999999967\n999999999999999967\n999999999999999967\n999999999999999967\n999999999999999967\n999999999999999967\n999999999999999967\n999999999999999967\n999999999999999967\n999999999999999967\n999999999999999967\n999999999999999967\n999999999999999967\n999999999999999967\n999999999999999967\n999...
code_stdio
[ { "content": "$n$ people gathered to hold a jury meeting of the upcoming competition, the $i$-th member of the jury came up with $a_i$ tasks, which they want to share with each other.\n\nFirst, the jury decides on the order which they will follow while describing the tasks. Let that be a permutation $p$ of numb...
[{"input": "1\n74\n15 4 1 8 1 4 -1 5 9 1 6 3 1 16 2 1 3 6 7 4 1 6 8 9 21 4 0 6 6 4 22 1 8 7 0 1 6 6 4 1 8 9 16 4 10 5 9 2 20 10 0 5 3 8 1 7 7 0 2 10 2 4 8 4 6 9 2 4 9 8 1 11 3 0\n", "output": "210389544\n"}, {"input": "1\n74\n15 4 1 8 1 4 0 5 9 1 6 3 1 16 2 1 3 6 7 4 1 6 8 9 21 4 0 6 6 4 22 1 8 7 0 1 6 6 4 1 8 9 16 4 1...
code_stdio
[ { "content": "Given an array A1,A2...AN, you have to print the size of the largest contiguous subarray such that \nGCD of all integers in that subarray is 1.\n\nFormally,\nFor a subarray Ai,Ai+1...Aj where 1 ≤ i < j ≤ N to be valid: GCD(Ai,Ai+1...Aj) should be 1. You have to print the size of the largest valid ...
[{"input": "2\n1\n16 2\n3\n2 4 16", "output": "-1\n-1\n"}, {"input": "2\n1\n12 2\n3\n2 4 4", "output": "-1\n-1\n"}, {"input": "2\n1\n6 4\n2\n2 12 2", "output": "-1\n-1\n"}, {"input": "2\n1\n12 2\n3\n2 4 8", "output": "-1\n-1\n"}, {"input": "2\n1\n6 4\n2\n2 10 2", "output": "-1\n-1\n"}, {"input": "2\n1\n6 4\n2\n2 12 4",...
code_stdio
[ { "content": "You are a paparazzi working in Manhattan.\n\nManhattan has r south-to-north streets, denoted by numbers 1, 2,…, r in order from west to east, and r west-to-east streets, denoted by numbers 1,2,…,r in order from south to north. Each of the r south-to-north streets intersects each of the r west-to-e...
[{"input": "500 10\n69 477 122\n73 186 235\n341 101 145\n372 77 497\n404 117 440\n494 471 37\n522 300 498\n682 149 379\n821 486 359\n855 157 386\n", "output": "3\n"}, {"input": "500 10\n69 477 111\n73 186 235\n341 101 145\n372 77 497\n404 117 440\n494 471 37\n522 300 498\n682 149 379\n821 486 359\n855 157 386\n", "outp...
code_stdio
[ { "content": "We have N sticks with negligible thickness.\nThe length of the i-th stick is A_i.\nSnuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides.\nFind the maximum possible area of the rectangle.\n\n-----Constraints-----\n - ...
[{"input": "10\n1 1 2 -3 2 8 1 218 -1 8", "output": "16\n"}, {"input": "10\n0 1 0 -2 4 34 1 34 0 4", "output": "136\n"}, {"input": "10\n-1 2 12 15 3 1 0 18 1 1", "output": "0\n"}, {"input": "10\n-2 2 12 1 4 2 1 41 -1 1", "output": "2\n"}, {"input": "10\n0 2 12 13 3 1 0 18 3 1", "output": "3\n"}, {"input": "10\n-1 2 12 ...
code_stdio
[ { "content": "Consider the following series:\n\n`1, 2, 4, 8, 16, 22, 26, 38, 62, 74, 102, 104, 108, 116, 122`\n\nIt is generated as follows:\n\n* For single digit integers, add the number to itself to get the next element.\n* For other integers, multiply all the non-zero digits and add the result to the origina...
[{"input": "5000", "output": "[283]", "fn_name": "convergence"}, {"input": "500", "output": "[29]", "fn_name": "convergence"}, {"input": "10", "output": "[5]", "fn_name": "convergence"}, {"input": "15", "output": "[2]", "fn_name": "convergence"}, {"input": "3", "output": "[5]", "fn_name": "convergence"}, {"input": "5",...
code_functional
[ { "content": "Galois is one of the strongest chess players of Byteforces. He has even invented a new variant of chess, which he named «PawnChess».\n\nThis new game is played on a board consisting of 8 rows and 8 columns. At the beginning of every game some black and white pawns are placed on the board. The numb...
[{"input": "........\n........\n.B....B.\n....W...\n........\n..W.....\n........\n........\n", "output": "A\n"}, {"input": "..B.....\n..W.....\n......B.\n........\n.....W..\n......B.\n........\n........\n", "output": "B\n"}, {"input": ".BB.B.B.\nB..B..B.\n.B.BB...\nBB.....B\nBBB....B\nB..BB...\nBB.B...B\n....WWW.\n", "...
code_stdio
[ { "content": "Goldbach's conjecture is one of the oldest and best-known unsolved problems in number theory and all of mathematics. It states:\n\nEvery even integer greater than 2 can be expressed as the sum of two primes.\nFor example: \n\n`6 = 3 + 3`\n`8 = 3 + 5`\n`10 = 3 + 7 = 5 + 5`\n`12 = 5 + 7`\n\nSome rul...
[{"input": "5000", "output": "[[[7, 4993], [13, 4987], [31, 4969], [43, 4957], [67, 4933], [97, 4903], [139, 4861], [199, 4801], [211, 4789], [241, 4759], [271, 4729], [277, 4723], [337, 4663], [349, 4651], [379, 4621], [397, 4603], [409, 4591], [433, 4567], [439, 4561], [487, 4513], [577, 4423], [643, 4357], [661, 433...
code_functional
[ { "content": "Write a program which finds a pattern $p$ in a ring shaped text $s$.\n\n\n<image>\n\nConstraints\n\n* $1 \\leq $ length of $p \\leq $ length of $s \\leq 100$\n* $s$ and $p$ consists of lower-case letters\n\nInput\n\nIn the first line, the text $s$ is given.\nIn the second line, the pattern $p$ is ...
[{"input": "vanceknowledgetoad\nbdvanced", "output": "No\n"}, {"input": "vanceknowledgetoad\ncdvanced", "output": "No\n"}, {"input": "vanceknowmedgetoad\ncdvanced", "output": "No\n"}, {"input": "vbnceknowmedgetoad\ncdvanced", "output": "No\n"}, {"input": "vbnceknowledgetoad\ncdvanced", "output": "No\n"}, {"input": "vbn...
code_stdio
[ { "content": "Let $f(i)$ denote the minimum positive integer $x$ such that $x$ is not a divisor of $i$.\n\nCompute $\\sum_{i=1}^n f(i)$ modulo $10^9+7$. In other words, compute $f(1)+f(2)+\\dots+f(n)$ modulo $10^9+7$.\n\n\n-----Input-----\n\nThe first line contains a single integer $t$ ($1\\leq t\\leq 10^4$), t...
[{"input": "6\n1\n4\n3\n4\n10\n10000000000000000\n", "output": "2\n10\n7\n10\n26\n366580019\n"}, {"input": "6\n1\n2\n3\n4\n10\n10000000000000000\n", "output": "2\n5\n7\n10\n26\n366580019\n"}, {"input": "6\n1\n2\n3\n4\n10\n10000000000000000\n", "output": "2\n5\n7\n10\n26\n366580019\n"}, {"input": "1\n5897090464090076\n"...
code_stdio