messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.\n\nInput\n\nThe first line of input contains one integer number N (1 β€ N β€ 100 000) β the number of points. Each of the following N lines contain two integer numbers X an... | [{"input": "30\n-7 -23\n-2 5\n13 8\n12 17\n15 -18\n20 6\n21 8\n-13 12\n-4 -20\n-11 -16\n-6 16\n1 -1\n5 -12\n13 -17\n11 10\n8 -9\n-13 3\n19 -13\n-19 -8\n-14 10\n10 3\n-16 -8\n-17 16\n-14 -15\n5 1\n-13 -14\n13 17\n-12 -8\n2 1\n18 5\n", "output": "279169\n"}, {"input": "30\n-7 -23\n-2 5\n13 8\n12 17\n15 -18\n11 6\n21 8\n-... | code_stdio |
[
{
"content": "Implement `String#to_cents`, which should parse prices expressed as `$1.23` and return number of cents, or in case of bad format return `nil`.\n\nWrite Python code to solve this problem. Define a top-level function named `to_cents` that takes the input arguments described above and returns the ans... | [{"input": "\"$12345678.90\"", "output": "[1234567890]", "fn_name": "to_cents"}, {"input": "\"$9.69$4.3.7\"", "output": "[null]", "fn_name": "to_cents"}, {"input": "\"$1.23\\n\"", "output": "[null]", "fn_name": "to_cents"}, {"input": "\"\\n$1.23\"", "output": "[null]", "fn_name": "to_cents"}, {"input": "\"$99.99\"", "o... | code_functional |
[
{
"content": "Let's call a sequence $b_1, b_2, b_3 \\dots, b_{k - 1}, b_k$ almost increasing if $$\\min(b_1, b_2) \\le \\min(b_2, b_3) \\le \\dots \\le \\min(b_{k - 1}, b_k).$$ In particular, any sequence with no more than two elements is almost increasing.\n\nYou are given a sequence of integers $a_1, a_2, \\d... | [{"input": "3\n8\n1 2 7 3 2 1 2 3\n2\n2 1\n7\n4 1 5 2 6 3 7\n", "output": "\n6\n2\n7\n"}, {"input": "3\n8\n1 2 7 3 2 1 2 3\n2\n2 1\n7\n4 1 5 2 6 3 7\n", "output": "6\n2\n7\n"}, {"input": "3\n8\n1 2 7 3 2 1 2 5\n2\n2 1\n7\n4 1 5 2 6 3 7\n", "output": "6\n2\n7\n"}, {"input": "3\n8\n1 2 7 6 2 1 1 3\n2\n2 1\n7\n4 1 5 2 6 3... | code_stdio |
[
{
"content": "Many years ago Berland was a small country where only $n$ people lived. Each person had some savings: the $i$-th one had $a_i$ burles.\n\nThe government considered a person as wealthy if he had at least $x$ burles. To increase the number of wealthy people Berland decided to carry out several refor... | [{"input": "4\n4 3\n6 1 2 1\n4 10\n11 9 11 18\n2 5\n4 3\n3 7\n9 4 11\n", "output": "3\n4\n0\n3\n"}, {"input": "4\n4 3\n10 1 2 1\n4 10\n11 7 11 9\n2 5\n4 3\n3 7\n9 2 9\n", "output": "4\n3\n0\n2\n"}, {"input": "4\n4 3\n10 1 3 1\n4 10\n11 7 11 9\n2 5\n4 3\n3 6\n9 2 9\n", "output": "4\n3\n0\n3\n"}, {"input": "4\n4 3\n6 1 2... | code_stdio |
[
{
"content": "A subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is a string x = sk1sk2... sk|x| (1 β€ k1 < k2 < ... < k|x| β€ |s|).\n\nYou've got two strings β s and t. Let's consider all subsequences of string s, coinciding with string t. Is it true that each character ... | [{"input": "ctkhagrifaztmnxhmqztzibnmzzkojiztvrkfeoqegvwtbxlvvjhebshqaicsovtkcdovytimjggglyxlvglgunbohnkxargymbqvzgsnvjzgxivdgnaesgxqcruaopjuqsyyorrobnelehjnxcetveehlbmeskptivsuhuqupbieumycwczxyqjtwfofehfkpqmjngygwxkaviuyouiippgvlxjgtkxmhcwtzacbllsybgiujyryngapfwjkkyapfgxtcdpc\nctkhagrifaztmnxhmqztzibnmzzkojiztvrkfeoqe... | code_stdio |
[
{
"content": "Lord Omkar would like to have a tree with n nodes (3 β€ n β€ 10^5) and has asked his disciples to construct the tree. However, Lord Omkar has created m (1 β€ m < n) restrictions to ensure that the tree will be as heavenly as possible. \n\nA tree with n nodes is an connected undirected graph with n no... | [{"input": "2\n27 4\n1 3 3\n4 2 2\n5 7 10\n4 9 4\n6 0\n1 2 -1\n2 6 4\n4 1 8\n", "output": "1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10\n1 11\n1 12\n1 13\n1 14\n1 15\n1 16\n1 17\n1 18\n1 19\n1 20\n1 21\n1 22\n1 23\n1 24\n1 25\n1 26\n1 27\n1 2\n1 3\n1 4\n1 5\n1 6\n"}, {"input": "2\n26 4\n1 3 3\n4 4 7\n5 1 17\n4 9 4\n6 0... | code_stdio |
[
{
"content": "Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal integers by transforming some of them.\nHe may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (iβ j), he has to pay the cost separately for transform... | [{"input": "4\n-100 -45 -100 -100", "output": "2269\n"}, {"input": "4\n-100 -100 -100 -100\n", "output": "0\n"}, {"input": "4\n-100 -100 -100 -100", "output": "0"}, {"input": "3\n-3 -1 23", "output": "419\n"}, {"input": "3\n-3 -1 21", "output": "355\n"}, {"input": "3\n-4 -1 21", "output": "373\n"}, {"input": "3\n1 -1 3... | code_stdio |
[
{
"content": "You are given integers N and K. Find the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K.\nThe order of a,b,c does matter, and some of them can be the same.\n\n-----Constraints-----\n - 1 \\leq N,K \\leq 2\\times 10^5\n - N and K a... | [{"input": "200000 1\n", "output": "8000000000000000\n"}, {"input": "200000 2\n", "output": "2000000000000000\n"}, {"input": "200000 3\n", "output": "296287407496296\n"}, {"input": "100004 8\n", "output": "3906718787501\n"}, {"input": "100000 7\n", "output": "2915014599125\n"}, {"input": "10003 8\n", "output": "3906250... | code_stdio |
[
{
"content": "Vasily has a number a, which he wants to turn into a number b. For this purpose, he can do two types of operations: multiply the current number by 2 (that is, replace the number x by 2Β·x); append the digit 1 to the right of current number (that is, replace the number x by 10Β·x + 1). \n\nYou need... | [{"input": "1 536870912\n", "output": "YES\n30\n1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864 134217728 268435456 536870912 \n"}, {"input": "1 536870912\n", "output": "YES\n30\n1 2 4 8 16 32 64 128 256 512 1024 2048 409... | code_stdio |
[
{
"content": "<image>\n\nInput\n\nThe input contains two integers a, b (1 β€ a β€ 10, 0 β€ b β€ 22Β·a - 1) separated by a single space.\n\nOutput\n\nOutput two integers separated by a single space.\n\nExamples\n\nInput\n\n1 0\n\n\nOutput\n\n0 0\n\n\nInput\n\n2 15\n\n\nOutput\n\n3 0\n\n\nInput\n\n4 160\n\n\nOutput\n\... | [{"input": "10 165056\n", "output": "391 431\n"}, {"input": "10 595169\n", "output": "619 770\n"}, {"input": "10 156555\n", "output": "468 325\n"}, {"input": "10 140634\n", "output": "323 383"}, {"input": "10 1048575\n", "output": "1023 0"}, {"input": "10 921462\n", "output": "757 203"}, {"input": "10 850222\n", "outpu... | code_stdio |
[
{
"content": "The Little Elephant loves Ukraine very much. Most of all he loves town Rozdol (ukr. \"Rozdil\").\n\nHowever, Rozdil is dangerous to settle, so the Little Elephant wants to go to some other town. The Little Elephant doesn't like to spend much time on travelling, so for his journey he will choose a ... | [{"input": "100\n922 938 103 689 526 118 314 496 373 47 224 544 495 656 804 754 269 356 354 536 817 597 787 178 516 659 790 993 786 169 866 779 997 350 674 310 219 546 564 893 402 449 751 628 329 686 392 951 716 439 332 563 215 146 746 311 866 773 548 1100 731 183 890 802 488 944 473 25 662 559 732 534 777 144 502 593 ... | code_stdio |
[
{
"content": "You are given a string s consisting of `A`, `B` and `C`.\n\nSnuke wants to perform the following operation on s as many times as possible:\n\n* Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.\n\n\n\nFind the maximum possible number of operations.\n\nConstraints\n\n* ... | [{"input": "ABBACCBACCBCAABCB", "output": "2\n"}, {"input": "ACBAACBCCABCCBBBA", "output": "1\n"}, {"input": "ABCAACBCAABCCBBBC", "output": "3\n"}, {"input": "ACCAAABCAABCCBBBC", "output": "8\n"}, {"input": "ABBBCCBACCBCAABCB", "output": "2\n"}, {"input": "ABBBCCBACCBCAABCA", "output": "2\n"}, {"input": "ACBAACBCAABCCB... | code_stdio |
[
{
"content": "Polycarpus is the director of a large corporation. There are n secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that when two people call each other via Spyke, the Spyke network assigns a unique ID to this call, a positive i... | [{"input": "123\n0 6361 8903 10428 0 258 0 10422 0 0 2642 1958 0 0 0 0 0 8249 1958 0 0 2642 0 0 0 11566 4709 1847 3998 0 1331 0 0 10289 2739 6135 3450 0 0 10994 6069 4337 5854 1331 5854 0 630 630 11244 5928 2706 0 683 214 0 9080 0 0 0 10422 683 11566 10994 0 0 3450 11244 11542 3998 1847 2708 9871 2739 2001 0 12216 6069... | code_stdio |
[
{
"content": "While 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 computing $1 + 4$, he gets the correct answer, $5$. Puzzled by this myst... | [{"input": "3\n1 8\n378 590\n0 1001000\n", "output": "26\n3586\n3444149719\n"}, {"input": "3\n0 4\n378 590\n1 1000000\n", "output": "17\n3586\n3439863766\n"}, {"input": "3\n1 4\n323 590\n1 1000000\n", "output": "8\n4758\n3439863766\n"}, {"input": "3\n0 4\n217 323\n1 1000000\n", "output": "17\n562\n3439863766\n"}, {"inp... | code_stdio |
[
{
"content": "Lately, Mr. Chanek frequently plays the game Arena of Greed. As the name implies, the game's goal is to find the greediest of them all, who will then be crowned king of Compfestnesia.\n\nThe game is played by two people taking turns, where Mr. Chanek takes the first turn. Initially, there is a tre... | [{"input": "2\n18\n122\n", "output": "14\n114\n"}, {"input": "2\n20\n122\n", "output": "15\n114\n"}, {"input": "2\n12\n122\n", "output": "9\n114\n"}, {"input": "2\n10\n122\n", "output": "8\n114\n"}, {"input": "2\n3\n122\n", "output": "2\n114\n"}, {"input": "2\n6\n122\n", "output": "4\n114\n"}, {"input": "2\n4\n122\n", ... | code_stdio |
[
{
"content": "Nezzar has a binary string s of length n that he wants to share with his best friend, Nanako. Nanako will spend q days inspecting the binary string. At the same time, Nezzar wants to change the string s into string f during these q days, because it looks better.\n\nIt is known that Nanako loves co... | [{"input": "4\n5 2\n00000\n00111\n1 5\n1 3\n2 1\n00\n01\n1 2\n10 6\n1111111111\n0110001110\n1 10\n5 9\n7 10\n1 7\n3 5\n6 10\n5 2\n10000\n11000\n2 5\n1 3\n", "output": "\nYES\nNO\nYES\nNO\n"}, {"input": "4\n5 2\n00000\n00111\n1 5\n1 3\n2 1\n00\n01\n1 2\n10 6\n1111111111\n0110000110\n1 10\n5 9\n7 10\n1 7\n3 5\n6 10\n5 2\... | code_stdio |
[
{
"content": "You are given a sequence a_1, a_2, ..., a_n, consisting of integers.\n\nYou can apply the following operation to this sequence: choose some integer x and move all elements equal to x either to the beginning, or to the end of a. Note that you have to move all these elements in one direction in one ... | [{"input": "3\n7\n3 1 6 6 3 1 1\n8\n1 1 4 4 4 7 8 8\n7\n2 2 5 2 6 2 7\n", "output": "2\n0\n1\n"}, {"input": "3\n7\n3 1 6 6 3 1 1\n8\n1 1 4 4 4 7 8 2\n7\n2 2 5 2 6 2 7\n", "output": "2\n2\n1\n"}, {"input": "3\n7\n3 1 6 6 3 1 1\n8\n1 1 4 4 4 3 8 2\n7\n2 2 5 2 6 2 7\n", "output": "2\n3\n1\n"}, {"input": "3\n7\n3 1 6 6 3 1... | code_stdio |
[
{
"content": "For a positive integer n, let us define f(n) as the number of digits in base 10.\nYou are given an integer S.\nCount the number of the pairs of positive integers (l, r) (l \\leq r) such that f(l) + f(l + 1) + ... + f(r) = S, and find the count modulo 10^9 + 7.\n\n-----Constraints-----\n - 1 \\leq ... | [{"input": "100000000\n", "output": "914705724\n"}, {"input": "91304885\n", "output": "555850206\n"}, {"input": "89317875\n", "output": "494668252\n"}, {"input": "78876118\n", "output": "915018436\n"}, {"input": "18434582\n", "output": "752917978\n"}, {"input": "15764866\n", "output": "563424334\n"}, {"input": "7952872... | code_stdio |
[
{
"content": "You are given a chessboard consisting of $n$ rows and $n$ columns. Rows are numbered from bottom to top from $1$ to $n$. Columns are numbered from left to right from $1$ to $n$. The cell at the intersection of the $x$-th column and the $y$-th row is denoted as $(x, y)$. Furthermore, the $k$-th col... | [{"input": "5 3 5\n4 4\n3 5\n2 4\n3 4\n3 5\n", "output": "0\n1\n2\n2\n1\n"}, {"input": "5 5 5\n4 4\n3 5\n2 4\n3 4\n3 5\n", "output": "0\n2\n3\n3\n2\n"}, {"input": "5 5 5\n4 4\n3 5\n2 3\n3 3\n3 5\n", "output": "0\n2\n2\n3\n2\n"}, {"input": "5 5 5\n1 4\n3 5\n2 3\n3 3\n3 5\n", "output": "3\n3\n3\n3\n3\n"}, {"input": "5 3 ... | code_stdio |
[
{
"content": "Please notice the unusual memory limit of this problem.\n\nOrac likes games. Recently he came up with the new game, \"Game of Life\".\n\nYou should play this game on a black and white grid with $n$ rows and $m$ columns. Each cell is either black or white.\n\nFor each iteration of the game (the ini... | [{"input": "5 5 3\n01011\n10110\n01101\n11010\n10101\n1 1 4\n1 2 3\n5 5 3\n", "output": "1\n0\n1\n"}, {"input": "5 5 3\n01011\n10110\n01101\n11010\n10001\n1 1 4\n1 2 3\n5 5 3\n", "output": "1\n0\n1\n"}, {"input": "5 5 3\n01011\n10110\n01101\n11010\n10001\n1 1 4\n1 2 2\n5 5 3\n", "output": "1\n1\n1\n"}, {"input": "5 5 3... | code_stdio |
[
{
"content": "There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. \n\nYou are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exac... | [{"input": "5\n3 0 0 0\n3 3 0 0\n6 4 1 0\n6 6 0 0\n3 3 3 2\n", "output": "yes\nyes\nyes\nyes\nno\n"}, {"input": "5\n3 0 0 0\n3 3 0 0\n6 4 1 0\n6 3 3 -1\n3 3 3 2\n", "output": "yes\nyes\nyes\nno\nno\n"}, {"input": "5\n3 0 0 0\n3 3 0 0\n6 4 1 0\n6 3 3 -1\n3 3 4 2\n", "output": "yes\nyes\nyes\nno\nno\n"}, {"input": "5\n3 ... | code_stdio |
[
{
"content": "Amugae has a hotel consisting of $10$ rooms. The rooms are numbered from $0$ to $9$ from left to right.\n\nThe hotel has two entrances β one from the left end, and another from the right end. When a customer arrives to the hotel through the left entrance, they are assigned to an empty room closest... | [{"input": "100\nLLLLLLLLLL0L2L48LL6L7L7L0L3L0L63LL3L4L9L2L7L6L3L8L2L5L9L0L3L3L9L3L3L3L5L2L2L2L1L8L5L7L9L2L05L0LL6L2L\n", "output": "1111111111\n"}, {"input": "100\nRRLLLLLLRR1R7R3L2R0L52RR2R4L1L7L6R4R0R4L5L4L5R2R8L7R0R6R4R8L6L8L4R5R7R3L9R7L64RR8L0R6R4R9L0R9R7R7R0L\n", "output": "1111111111\n"}, {"input": "100\nL0L0R9R... | code_stdio |
[
{
"content": "The Menger Sponge is a three-dimensional fractal, first described by Karl Menger in 1926.\n\n\n###### _An illustration of the iterative construction of a Menger sponge_\n\nA method of constructing a Menger Sponge can be visualized as fol... | [{"input": "6", "output": "[64000000]", "fn_name": "calc_ms"}, {"input": "5", "output": "[3200000]", "fn_name": "calc_ms"}, {"input": "4", "output": "[160000]", "fn_name": "calc_ms"}, {"input": "3", "output": "[8000]", "fn_name": "calc_ms"}, {"input": "2", "output": "[400]", "fn_name": "calc_ms"}, {"input": "1", "outpu... | code_functional |
[
{
"content": "One day Squidward, Spongebob and Patrick decided to go to the beach. Unfortunately, the weather was bad, so the friends were unable to ride waves. However, they decided to spent their time building sand castles.\n\nAt the end of the day there were n castles built by friends. Castles are numbered f... | [{"input": "101\n1 50 170 269 214 153 132 234 181 188 180 225 226 200 197 122 181 168 160 220 223 160 235 94 257 145 199 235 102 146 119 60 109 134 209 260 210 191 180 271 236 195 155 169 166 143 106 102 208 137 278 269 156 251 198 165 111 198 151 213 256 121 276 163 179 285 104 99 139 122 188 184 215 242 244 115 304 2... | code_stdio |
[
{
"content": "Problem H: Squid Multiplication\n\nSquid Eiko loves mathematics. Especially she loves to think about integer. One day, Eiko found a math problem from a website.\n\n\"A sequence b ={ai + aj | i < j } is generated from a sequence a ={a0 , ... , an | ai is even if i is 0, otherwise ai is odd}. Given ... | [{"input": "3\n6 10 26 15 27 35\n2\n30 42 35\n0", "output": "2\n3 5 13\n6\n5 7\n"}, {"input": "3\n6 10 28 15 31 35\n2\n30 42 35\n0", "output": "2\n3 5 14\n6\n5 7\n"}, {"input": "3\n6 10 26 15 27 43\n2\n30 42 35\n0", "output": "2\n3 5 13\n6\n5 7\n"}, {"input": "3\n6 10 14 15 27 35\n2\n30 42 35\n0", "output": "2\n3 5 7\n... | code_stdio |
[
{
"content": "This is a story of a world somewhere far from the earth. In this world, the land is parted into a number of countries ruled by empires. This world is not very peaceful: they have been involved in army race.\n\nThey are competing in production of missiles in particular. Nevertheless, no countries h... | [{"input": "3 3\n3 4 1 1\n2 1 5\n2 3 3\n3 6\n3 2 5 1\n2 1 5\n2 3 3\n0 0", "output": "Yes\nYes\n"}, {"input": "3 6\n3 8 1 1\n2 2 6\n2 2 3\n3 3\n3 2 5 1\n2 1 11\n2 3 3\n0 0", "output": "Yes\nNo\n"}, {"input": "3 2\n3 11 1 1\n2 2 8\n2 2 3\n3 5\n3 4 5 1\n2 0 11\n2 3 3\n0 0", "output": "No\nNo\n"}, {"input": "3 3\n3 4 1 1\n... | code_stdio |
[
{
"content": "Because of budget cuts one IT company established new non-financial reward system instead of bonuses.\n\nTwo kinds of actions are rewarded: fixing critical bugs and suggesting new interesting features. A man who fixed a critical bug gets \"I fixed a critical bug\" pennant on his table. A man who s... | [{"input": "444\n", "output": "2159776046970635520\n"}, {"input": "498\n", "output": "5392730685240975000"}, {"input": "500\n", "output": "5567867859752100000"}, {"input": "500\n", "output": "5567867859752100000"}, {"input": "498\n", "output": "5392730685240975000"}, {"input": "308\n", "output": "117307091246785440\n"}... | code_stdio |
[
{
"content": "Roma is playing a new expansion for his favorite game World of Darkraft. He made a new character and is going for his first grind.\n\nRoma has a choice to buy exactly one of n different weapons and exactly one of m different armor sets. Weapon i has attack modifier a_i and is worth ca_i coins, and... | [{"input": "10 10 10\n51 87\n68 743\n82 1284\n73 936\n55 242\n89 1554\n58 357\n66 666\n62 512\n51 87\n92 1670\n56 280\n56 280\n91 1631\n77 1091\n89 1554\n61 473\n98 1901\n77 1091\n77 1091\n86 15 386\n43 58 386\n68 33 386\n39 62 386\n95 6 386\n74 27 386\n94 7 386\n17 84 386\n97 4 386\n45 56 386\n", "output": "212\n"}, {... | code_stdio |
[
{
"content": "We guessed some integer number $x$. You are given a list of almost all its divisors. Almost all means that there are all divisors except $1$ and $x$ in the list.\n\nYour task is to find the minimum possible integer $x$ that can be the guessed number, or say that the input data is contradictory and... | [{"input": "25\n2\n999389 999917\n2\n999307 999613\n2\n999529 999611\n2\n999221 999853\n2\n999683 999433\n2\n999907 999749\n2\n999653 999499\n2\n999769 999931\n2\n999809 999287\n2\n999233 999239\n2\n999553 999599\n2\n999371 999763\n2\n999491 999623\n2\n999961 999773\n2\n999671 999269\n2\n999883 999437\n2\n999953 999331... | code_stdio |
[
{
"content": "According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimete... | [{"input": "100 100\n51 93 101 960 2 477 213 129 663 925 254 78 1486 274 160 481 132 156 589 372 3 57 210 298 1771 7 359 468 254 406 202 929 221 366 552 97 555 29 634 118 539 140 992 854 7 163 134 103 940 30 409 1003 564 43 555 79 107 40 23 103 643 171 310 382 770 288 18 189 570 177 29 54 855 171 451 291 563 935 620 18... | code_stdio |
[
{
"content": "Given are a sequence of N integers A_1, A_2, \\ldots, A_N and a positive integer S.\n\nFor a pair of integers (L, R) such that 1\\leq L \\leq R \\leq N, let us define f(L, R) as follows:\n\n - f(L, R) is the number of sequences of integers (x_1, x_2, \\ldots , x_k) such that L \\leq x_1 < x_2 < \\... | [{"input": "2896 1518\n498 2010 1723 2089 76 1224 1972 612 465 880 283 143 1538 372 841 1998 292 2096 423 728 2199 807 2325 1185 1664 2349 531 40 1039 2006 2179 1842 2954 2847 2540 1045 2697 2112 1625 2062 631 2136 544 2420 1199 2592 2820 802 1157 383 1164 617 1513 2876 2625 947 1720 1640 1772 2137 282 754 1325 2663 27... | code_stdio |
[
{
"content": "Alyona's mother wants to present an array of n non-negative integers to Alyona. The array should be special. \n\nAlyona is a capricious girl so after she gets the array, she inspects m of its subarrays. Subarray is a set of some subsequent elements of the array. The i-th subarray is described with... | [{"input": "15 10\n1 9\n4 8\n4 8\n5 9\n1 9\n3 5\n1 6\n1 9\n2 6\n6 9\n", "output": "3\n0 1 2 0 1 2 0 1 2 0 1 2 0 1 2\n"}, {"input": "15 10\n1 9\n4 8\n4 8\n5 9\n1 9\n3 5\n1 6\n1 9\n4 6\n6 9\n", "output": "3\n0 1 2 0 1 2 0 1 2 0 1 2 0 1 2\n"}, {"input": "15 10\n1 9\n4 8\n4 8\n5 9\n1 9\n3 5\n1 6\n1 9\n1 6\n6 9\n", "output"... | code_stdio |
[
{
"content": "Polycarpus has postcards and photos hung in a row on the wall. He decided to put them away to the closet and hang on the wall a famous painter's picture. Polycarpus does it like that: he goes from the left to the right and removes the objects consecutively. As Polycarpus doesn't want any mix-ups t... | [{"input": "CPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCP\n", "output": "100\n"}, {"input": "PPPPPPPPPPPPPPPPPPPPPPPCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCPPPPPCCCPPPPCCCCCPCC\n", "output": "23\n"}, {"input": "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC... | code_stdio |
[
{
"content": "There is a square painted on a piece of paper, the square's side equals n meters. John Doe draws crosses on the square's perimeter. John paints the first cross in the lower left corner of the square. Then John moves along the square's perimeter in the clockwise direction (first upwards, then to th... | [{"input": "8\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 13\n", "output": "4000000001\n4000000001\n4000000001\n4000000001\n4000000001\n4000000001\n4000000001\n27\n"}, {"input": "8\n1000000000 1000000000 1000000000 1000000100 1000000000 1000000000 1000000000 13\n", "output": "400000000... | code_stdio |
[
{
"content": "[INSPION FullBand Master - INSPION](https://www.youtube.com/watch?v=kwsciXm_7sA)\n\n[INSPION - IOLITE-SUNSTONE](https://www.youtube.com/watch?v=kwsciXm_7sA)\n\nOn another floor of the A.R.C. Markland-N, the young man Simon \"Xenon\" Jackson, takes a break after finishing his project early (as alwa... | [{"input": "50\n21 10\n30 22\n3 37\n37 32\n4 27\n18 10\n2 30\n29 19\n6 37\n12 39\n47 25\n41 49\n45 9\n25 48\n16 14\n10 7\n33 28\n3 31\n34 16\n35 37\n27 40\n45 16\n29 44\n16 15\n26 3\n1 12\n2 13\n15 21\n43 14\n9 33\n44 15\n46 1\n38 5\n15 5\n1 32\n42 35\n20 27\n23 12\n1 16\n15 17\n36 50\n13 8\n49 45\n11 2\n24 4\n36 15\n1... | code_stdio |
[
{
"content": "You are given an array $a$ of $n$ integers and an integer $s$. It is guaranteed that $n$ is odd.\n\nIn one operation you can either increase or decrease any single element by one. Calculate the minimum number of operations required to make the median of the array being equal to $s$.\n\nThe median ... | [{"input": "7 33\n21 15 12 11 20 19 12\n", "output": "57\n"}, {"input": "7 20\n2 15 12 11 20 19 12\n", "output": "14\n"}, {"input": "7 20\n1 15 12 11 29 20 12\n", "output": "13\n"}, {"input": "7 20\n1 13 12 11 29 20 12\n", "output": "15\n"}, {"input": "7 20\n1 13 10 15 29 20 12\n", "output": "12\n"}, {"input": "7 20\n1... | code_stdio |
[
{
"content": "For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$.\n\nConstraints\n\n* $1 \\leq n \\leq 10,000$\n* $0 \\leq c_i \\leq 100,000$\n* $|E| < 500,000$\n* All vert... | [{"input": "5\n0 3 2 4 3 1 1 2\n1 2 3 3 3 4\n2 3 0 3 3 2 4 1\n3 4 0 1 0 -1 1 0 3 3\n4 2 0 1 3 3", "output": "0 0\n1 1\n2 4\n3 1\n4 5\n"}, {"input": "5\n0 3 2 4 3 1 1 2\n1 2 1 4 3 4\n2 3 0 10 3 0 4 1\n3 4 0 1 0 1 1 1 1 3\n4 2 2 1 3 3", "output": "0 0\n1 2\n2 4\n3 1\n4 5\n"}, {"input": "5\n0 3 2 3 3 2 1 0\n1 2 0 5 4 4\n2... | code_stdio |
[
{
"content": "Dima is a beginner programmer. During his working process, he regularly has to repeat the following operation again and again: to remove every second element from the array. One day he has been bored with easy solutions of this problem, and he has come up with the following extravagant algorithm.\... | [{"input": "15 12\n2\n10\n5\n2\n8\n2\n8\n6\n4\n10\n12\n1\n", "output": "12\n13\n3\n12\n10\n12\n10\n14\n9\n13\n11\n1\n"}, {"input": "15 12\n9\n10\n5\n2\n8\n2\n8\n6\n4\n10\n12\n1\n", "output": "5\n13\n3\n12\n10\n12\n10\n14\n9\n13\n11\n1\n"}, {"input": "15 12\n9\n10\n5\n2\n7\n2\n8\n6\n4\n10\n12\n1\n", "output": "5\n13\n3\... | code_stdio |
[
{
"content": "Given is a three-digit integer N. Does N contain the digit 7?\nIf so, print Yes; otherwise, print No.\n\n-----Constraints-----\n - 100 \\leq N \\leq 999\n\n-----Input-----\nInput is given from Standard Input in the following format:\nN\n\n-----Output-----\nIf N contains the digit 7, print Yes; oth... | [{"input": "117\n", "output": "Yes\n"}, {"input": "777\n", "output": "Yes\n"}, {"input": "974\n", "output": "Yes\n"}, {"input": "477\n", "output": "Yes\n"}, {"input": "758\n", "output": "Yes\n"}, {"input": "767\n", "output": "Yes\n"}, {"input": "779\n", "output": "Yes\n"}, {"input": "1760", "output": "Yes\n"}, {"input"... | code_stdio |
[
{
"content": "You are given two binary strings $x$ and $y$, which are binary representations of some two integers (let's denote these integers as $f(x)$ and $f(y)$). You can choose any integer $k \\ge 0$, calculate the expression $s_k = f(x) + f(y) \\cdot 2^k$ and write the binary representation of $s_k$ in rev... | [{"input": "4\n1010\n11\n10001\n110\n1\n1\n1010101010101\n11110000\n", "output": "1\n3\n0\n0\n"}, {"input": "4\n1010\n11\n10001\n110\n1\n1\n1010101010100\n11110000\n", "output": "1\n3\n0\n0\n"}, {"input": "4\n1010\n11\n10001\n110\n1\n1\n1010101010100\n11100000\n", "output": "1\n3\n0\n1\n"}, {"input": "4\n1010\n11\n1000... | code_stdio |
[
{
"content": "You are given an image, that can be represented with a 2-d n by m grid of pixels. Each pixel of the image is either on or off, denoted by the characters \"0\" or \"1\", respectively. You would like to compress this image. You want to choose an integer k > 1 and split the image into k by k blocks. ... | [{"input": "3 5\n00100\n10110\n11001\n", "output": "5\n"}, {"input": "3 5\n00100\n00110\n11001\n", "output": "4\n"}, {"input": "3 5\n00100\n00110\n11011\n", "output": "5\n"}, {"input": "3 5\n00100\n00110\n01001\n", "output": "3\n"}, {"input": "3 5\n00100\n00110\n11111\n", "output": "6\n"}, {"input": "3 5\n00110\n00110\... | code_stdio |
[
{
"content": "Let's assume that v(n) is the largest prime number, that does not exceed n;\n\n u(n) is the smallest prime number strictly greater than n. \n\nFind $\\sum_{i = 2}^{n} \\frac{1}{v(i) u(i)}$.\n\n\n-----Input-----\n\nThe first line contains integer tΒ (1 β€ t β€ 500) β the number of testscases. \n\nEa... | [{"input": "6\n885\n419\n821\n635\n63\n480\n", "output": "781453/1566442\n175559/352798\n674039/1351366\n403199/808942\n3959/8174\n232303/466546\n"}, {"input": "6\n885\n419\n821\n635\n63\n480\n", "output": "781453/1566442\n175559/352798\n674039/1351366\n403199/808942\n3959/8174\n232303/466546\n"}, {"input": "6\n1656\n4... | code_stdio |
[
{
"content": "There is little time left before the release of the first national operating system BerlOS. Some of its components are not finished yet β the memory manager is among them. According to the developers' plan, in the first release the memory manager will be very simple and rectilinear. It will suppor... | [{"input": "47 43\nerase 1\nalloc 95\nalloc 53\nerase 2\ndefragment\nalloc 100\nerase 4\nerase 2\nerase -849472053\ndefragment\nerase -638355221\nalloc 90\nerase 3\nerase 2\ndefragment\nalloc 17\nerase 5\ndefragment\nerase 6\ndefragment\nerase 3\ndefragment\ndefragment\nalloc 99\nalloc 69\nalloc 80\nerase 9\nerase 5\nd... | code_stdio |
[
{
"content": "A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward. Examples of numerical palindromes are: `2332, 110011, 54322345`\n\nFor a given number ```num```, write a function which returns an array of all the numerical palindromes contained with... | [{"input": "141221001", "output": "[[22, 141, 1001, 1221]]", "fn_name": "palindrome"}, {"input": "34322122", "output": "[[22, 212, 343, 22122]]", "fn_name": "palindrome"}, {"input": "13598", "output": "[\"No palindromes found\"]", "fn_name": "palindrome"}, {"input": "10015885", "output": "[[88, 1001, 5885]]", "fn_name"... | code_functional |
[
{
"content": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \n\nArrays have fallen out of Chef's good books, and he plans to destroy all arrays he possesses. He is left with the last array A, consisting of N positive integers. In order to destroy the array, he can perform the fo... | [{"input": "3\n2\n1 1\n2\n1 1\n3\n1 2 -1", "output": "2\n2\n2\n"}, {"input": "3\n2\n1 1\n2\n1 2\n3\n1 2 -1", "output": "2\n1\n2\n"}, {"input": "3\n2\n1 2\n2\n1 1\n3\n1 2 -1", "output": "1\n2\n2\n"}, {"input": "3\n2\n2 2\n2\n1 1\n3\n1 2 -1", "output": "2\n2\n2\n"}, {"input": "3\n2\n1 1\n2\n0 2\n3\n1 2 -1", "output": "2\... | code_stdio |
[
{
"content": "Thanos sort is a supervillain sorting algorithm, which works as follows: if the array is not sorted, snap your fingers* to remove the first or the second half of the items, and repeat the process.\n\nGiven an input array, what is the size of the longest sorted array you can obtain from it using Th... | [{"input": "16\n12 17 18 51 49 54 107 59 68 74 88 91 98 100 66 49\n", "output": "4\n"}, {"input": "16\n12 17 18 51 52 54 56 59 68 74 88 91 98 100 66 49\n", "output": "8\n"}, {"input": "16\n12 17 18 51 52 54 56 59 68 74 88 91 98 100 66 49\n", "output": "8\n"}, {"input": "16\n12 17 18 51 49 54 56 59 68 74 88 91 98 100 66... | code_stdio |
[
{
"content": "Write a program that takes in a letterclass ID of a ship and display the equivalent string class description of the given ID. Use the table below.\n\nClass ID Ship ClassB or bBattleShipC or cCruiserD or dDestroyerF or fFrigate\n\n-----Input-----\n\nThe first line contains an integer T, the total n... | [{"input": "3 \nB\nb\nB", "output": "BattleShip\nBattleShip\nBattleShip\n"}, {"input": "3 \nD\nb\nB", "output": "Destroyer\nBattleShip\nBattleShip\n"}, {"input": "3 \nB\nb\nD", "output": "BattleShip\nBattleShip\nDestroyer\n"}, {"input": "3 \nB\nd\nB", "output": "BattleShip\nDestroyer\nBattleShip\n"}, {"input": "3 \nB\n... | code_stdio |
[
{
"content": "You are given a text of single-space separated words, consisting of small and capital Latin letters.\n\nVolume of the word is number of capital letters in the word. Volume of the text is maximum volume of all words in the text.\n\nCalculate the volume of the given text.\n\n\n-----Input-----\n\nThe... | [{"input": "200\nLBmJKQLCKUgtTxMoDsEerwvLOXsxASSydOqWyULsRcjMYDWdDCgaDvBfATIWPVSXlbcCLHPYahhxMEYUiaxoCebghJqvmRnaNHYTKLeOiaLDnATPZAOgSNfBzaxLymTGjfzvTegbXsAthTxyDTcmBUkqyGlVGZhoazQzVSoKbTFcCRvYsgSCwjGMxBfWEwMHuagTBxkz\n", "output": "105\n"}, {"input": "200\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... | code_stdio |
[
{
"content": "# Task\n Changu and Mangu are great buddies. Once they found an infinite paper which had 1,2,3,4,5,6,7,8,......... till infinity, written on it.\n\n Both of them did not like the sequence and started deleting some numbers in the following way.\n ```\nFirst they deleted every 2nd number.\nSo remain... | [{"input": "134", "output": "[false]", "fn_name": "survivor"}, {"input": "15", "output": "[false]", "fn_name": "survivor"}, {"input": "289", "output": "[true]", "fn_name": "survivor"}, {"input": "5", "output": "[false]", "fn_name": "survivor"}, {"input": "8", "output": "[false]", "fn_name": "survivor"}, {"input": "9", ... | code_functional |
[
{
"content": "Dima loves Inna very much. He decided to write a song for her. Dima has a magic guitar with n strings and m frets. Dima makes the guitar produce sounds like that: to play a note, he needs to hold one of the strings on one of the frets and then pull the string. When Dima pulls the i-th string holdi... | [{"input": "11 11 9 11\n1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 2 2 1\n1 1 1 1 1 1 1 1 3 1 1\n1 1 1 1 1 1 1 3 1 1 1\n1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1\n1 1 1 2 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1\n3 3 3 3 3 3 3 3 3 2 2\n", "output": "14\n"}... | code_stdio |
[
{
"content": "# Kata Task\n\nGiven a list of random integers, return the Three Amigos.\n\nThese are 3 numbers that live next to each other in the list, and who have the **most** in common with each other by these rules:\n* lowest statistical range\n* same parity\n\n# Notes\n\n* The list will contain at least 3 ... | [{"input": "[2, 4, 6, 8, 10, 2, 2, 2, 1, 1, 1, 5, 3]", "output": "[[2, 2, 2]]", "fn_name": "three_amigos"}, {"input": "[1, 2, 34, 2, 1, 5, 3, 5, 7, 234, 2, 1]", "output": "[[5, 3, 5]]", "fn_name": "three_amigos"}, {"input": "[6, 9, -18, -19, -14, -10, -24]", "output": "[[-14, -10, -24]]", "fn_name": "three_amigos"}, {"... | code_functional |
[
{
"content": "Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.\nSnuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:\n - Operation:... | [{"input": "999999999999990\n", "output": "181818181818180\n"}, {"input": "999999999999991\n", "output": "181818181818181\n"}, {"input": "999999999999996\n", "output": "181818181818181\n"}, {"input": "999999999999997\n", "output": "181818181818182\n"}, {"input": "49247635594153\n", "output": "8954115562574\n"}, {"input... | code_stdio |
[
{
"content": "We have a 3 \\times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.\n\nAccording to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number writt... | [{"input": "19 -1 0\n2 3 6\n4 -4 -1", "output": "No\n"}, {"input": "12 -1 3\n2 2 3\n2 -4 2", "output": "No\n"}, {"input": "12 -1 0\n2 2 3\n2 -4 2", "output": "No\n"}, {"input": "12 -1 0\n2 2 3\n4 -4 2", "output": "No\n"}, {"input": "12 -1 0\n2 2 3\n4 -4 0", "output": "No\n"}, {"input": "12 -1 0\n2 2 3\n4 -4 1", "output... | code_stdio |
[
{
"content": "> In information theory and computer science, the Levenshtein distance is a string metric for measuring the difference between two sequences. Informally, the Levenshtein distance between two words is the minimum number of single-character edits (i.e. insertions, deletions or substitutions) require... | [{"input": "\"qlzcfayxiz\"\n\"vezkvgejzb\"", "output": "[9]", "fn_name": "levenshtein"}, {"input": "\"nayvyedosf\"\n\"sjxen\"", "output": "[9]", "fn_name": "levenshtein"}, {"input": "\"kitten\"\n\"sitting\"", "output": "[3]", "fn_name": "levenshtein"}, {"input": "\"sjxen\"\n\"sjxen\"", "output": "[0]", "fn_name": "leve... | code_functional |
[
{
"content": "Mr. Kitayuta has kindly given you a string s consisting of lowercase English letters. You are asked to insert exactly one lowercase English letter into s to make it a palindrome. A palindrome is a string that reads the same forward and backward. For example, \"noon\", \"testset\" and \"a\" are all... | [{"input": "lsdijfjisl\n", "output": "lsdijfjidsl\n"}, {"input": "lsdijfjisl\n", "output": "lsdijfjidsl\n"}, {"input": "lsdijfjisl\n", "output": "lsdijfjidsl\n"}, {"input": "lsdijgjisl\n", "output": "lsdijgjidsl\n"}, {"input": "nqwcvcwqn\n", "output": "nqwcvvcwqn\n"}, {"input": "jewiiwefj\n", "output": "jfewiiwefj\n"},... | code_stdio |
[
{
"content": "Prize\n\nSegtree entered a programming contest with a team of $ N $ and won a $ K $ yen prize! I'm trying to distribute this prize now.\n\nEach $ N $ team member, including Segtree, is numbered from $ 1 $ to $ N $ in order of ability. Segtree is $ 1 $.\n\nIf the prize amount of $ i $'s teammate $ ... | [{"input": "48 109", "output": "56\n"}, {"input": "12 100", "output": "51\n"}, {"input": "1 100", "output": "100\n"}, {"input": "8 203", "output": "103\n"}, {"input": "1 110", "output": "110\n"}, {"input": "11 152", "output": "78\n"}, {"input": "1 173", "output": "173\n"}, {"input": "8 253", "output": "127\n"}, {"input... | code_stdio |
[
{
"content": "There was a powerful school where powerful people gathered. At the athletic meet of the powerful school, powerful people march in a formation.\n\nWhile the powerhouses always want to show off their power, most of them don't want to walk on their own. So I thought that some of them would be at the ... | [{"input": "3\n156 120\n100 50\n80 100", "output": "1\n"}, {"input": "3\n156 120\n100 50\n80 000", "output": "1\n"}, {"input": "3\n156 159\n100 50\n80 000", "output": "1\n"}, {"input": "3\n156 22\n100 50\n152 000", "output": "1\n"}, {"input": "3\n156 11\n100 50\n80 000", "output": "1\n"}, {"input": "3\n156 22\n100 50\n... | code_stdio |
[
{
"content": "Petya is a big fan of mathematics, especially its part related to fractions. Recently he learned that a fraction $\\frac{a}{b}$ is called proper iff its numerator is smaller than its denominator (a < b) and that the fraction is called irreducible if its numerator and its denominator are coprime (t... | [{"input": "1000\n", "output": "499 501\n"}, {"input": "1000\n", "output": "499 501\n"}, {"input": "1120\n", "output": "559 561\n"}, {"input": "1010\n", "output": "503 507\n"}, {"input": "1200\n", "output": "599 601\n"}, {"input": "1764\n", "output": "881 883\n"}, {"input": "1729\n", "output": "864 865\n"}, {"input": "... | code_stdio |
[
{
"content": "Snuke, who loves animals, built a zoo.\nThere are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle.\nThe animal numbered i (2β€iβ€N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, ... | [{"input": "10\noxooxoxoox\n", "output": "SSWWSSSWWS\n"}, {"input": "10\nxooxoxooxo", "output": "SWWSSSWWSS\n"}, {"input": "10\nxxooxoxooo", "output": "SWSWWWSSSS\n"}, {"input": "10\noxooooxxox", "output": "SSWWSWWWWS\n"}, {"input": "10\nxoxxooooxo", "output": "SWWWWSWWSS\n"}, {"input": "10\noooxoxooxx", "output": "SSS... | code_stdio |
[
{
"content": "# Longest Palindromic Substring (Linear)\n\nA palindrome is a word, phrase, or sequence that reads the same backward as forward, e.g.,\n'madam' or 'racecar'. Even the letter 'x' is considered a palindrome. \n\nFor this Kata, you are given a string ```s```. Write a function that returns the longest... | [{"input": "\"ttaaftffftfaafatf\"", "output": "[\"aaftffftfaa\"]", "fn_name": "longest_palindrome"}, {"input": "\"abcdefghijklmnopqrstuvwxyz\"", "output": "[\"a\"]", "fn_name": "longest_palindrome"}, {"input": "\"abababa\"", "output": "[\"abababa\"]", "fn_name": "longest_palindrome"}, {"input": "\"ababbab\"", "output":... | code_functional |
[
{
"content": "To make a paper airplane, one has to use a rectangular piece of paper. From a sheet of standard size you can make $s$ airplanes.\n\nA group of $k$ people decided to make $n$ airplanes each. They are going to buy several packs of paper, each of them containing $p$ sheets, and then distribute the sh... | [{"input": "10000 10000 1 1\n", "output": "100000000\n"}, {"input": "10000 10000 1 1\n", "output": "100000000\n"}, {"input": "10000 10000 3 2\n", "output": "16670000\n"}, {"input": "10000 10000 3 2\n", "output": "16670000\n"}, {"input": "10000 10000 2 4\n", "output": "12500000\n"}, {"input": "10000 10000 1 4\n", "outpu... | code_stdio |
[
{
"content": "Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integers (positive, negative and zero). At the beginning she is standing at the cell 0.\n\nThere are also n cards, each card has 2 attributes: length l_{i} and cost c_{i}. If she pays c_{i} dollars then s... | [{"input": "35\n512 268435456 8 128 134217728 8192 33554432 33554432 536870912 512 65536 1048576 32768 512 524288 1024 536870912 536870912 16 32 33554432 134217728 2 16 16777216 8192 262144 65536 33554432 128 4096 2097152 33554432 2097152 2\n36157 67877 79710 63062 12683 36255 61053 83828 93590 74236 5281 28143 7350 45... | code_stdio |
[
{
"content": "<!--\n\nProblem B\n\n-->\n\nOn-Screen Keyboard\n\nYou are to input a string with an OSK (on-screen keyboard). A remote control with five buttons, four arrows and an OK (Fig. B-1), is used for the OSK. Find the minimum number of button presses required to input a given string with the given OSK.\n\... | [{"input": "3 9\nABCDEFGHI\nJKLMNOPQR\nSTUVWXYZ_\nICPC\n5 11\n___________\n____A______\n________M__\n___________\n_C_________\nACM\n4 21\n1_2_3_4_5_6_7_8_9_0_-\nQqWwEeRrTtYyUuIiOoPp@\nAaSsDdFfGgHhJjKkLl;^:\nZzXxCcVvBbNnMm,_._/__\nICPC2019,AsiaYokohamaRegional,QualificationRound\n0 0", "output": "28\n23\n493\n"}, {"inpu... | code_stdio |
[
{
"content": "# Task\nGiven a number `n`, return a string representing it as a sum of distinct powers of three, or return `\"Impossible\"` if that's not possible to achieve.\n\n\n# Input/Output\n\n\n`[input]` integer `n`\n\n\nA positive integer n. \n\n`1 β€ n β€ 10^16`.\n\n`[output]` a string\n\nA string represen... | [{"input": "87754", "output": "[\"3^10+3^9+3^8+3^7+3^5+3^3+3^1+3^0\"]", "fn_name": "sum_of_threes"}, {"input": "5559060566575209", "output": "[\"3^33+3^9+3^1\"]", "fn_name": "sum_of_threes"}, {"input": "8312964441463288", "output": "[\"Impossible\"]", "fn_name": "sum_of_threes"}, {"input": "1418194818", "output": "[\"I... | code_functional |
[
{
"content": "There is a house with $n$ flats situated on the main street of Berlatov. Vova is watching this house every night. The house can be represented as an array of $n$ integer numbers $a_1, a_2, \\dots, a_n$, where $a_i = 1$ if in the $i$-th flat the light is on and $a_i = 0$ otherwise.\n\nVova thinks t... | [{"input": "100\n0 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 -1 1 0\n", "output": "24\n"}, {"input": "100\n0 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": "10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th.\n\nThe score of a participant is the product of his/her ranks in the two contests.\n\nProcess the following Q queries:\n\n*... | [{"input": "8\n1 4\n10 5\n3 3\n4 11\n8 9\n22 11\n8 36\n314159265 358979323", "output": "1\n12\n4\n11\n14\n29\n31\n671644785\n"}, {"input": "8\n1 4\n10 5\n3 3\n4 20\n8 9\n22 40\n8 36\n314159265 358979323", "output": "1\n12\n4\n15\n14\n57\n31\n671644785\n"}, {"input": "8\n1 4\n10 5\n3 3\n4 11\n8 9\n22 11\n8 18\n314159265... | code_stdio |
[
{
"content": "Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexad... | [{"input": "2\n110111100000101101101011001110100111011001000000000000000000\n", "output": "1000000000000000000"}, {"input": "2\n110111100000101101101011001110100111011001000000000000000000\n", "output": "1000000000000000000"}, {"input": "2\n1110110101111000010001011110101001011001110000000010110010\n", "output": "26736... | code_stdio |
[
{
"content": "Little penguin Polo loves his home village. The village has n houses, indexed by integers from 1 to n. Each house has a plaque containing an integer, the i-th house has a plaque containing integer pi (1 β€ pi β€ n).\n\nLittle penguin Polo loves walking around this village. The walk looks like that. ... | [{"input": "1000 8\n", "output": "339760446\n"}, {"input": "1000 6\n", "output": "834332109\n"}, {"input": "1000 1\n", "output": "760074701\n"}, {"input": "1000 5\n", "output": "583047503\n"}, {"input": "1000 2\n", "output": "675678679\n"}, {"input": "1000 4\n", "output": "660270610\n"}, {"input": "1000 3\n", "output":... | code_stdio |
[
{
"content": "Some dwarves that are finishing the StUDY (State University for Dwarven Youngsters) Bachelor courses, have been told \"no genome, no degree\". That means that all dwarves should write a thesis on genome. Dwarven genome is far from simple. It is represented by a string that consists of lowercase La... | [{"input": "aaaabcccca\naaaadccccb\n", "output": "NO\n"}, {"input": "aaaabcccca\naaaadccdcb\n", "output": "NO\n"}, {"input": "accccbaaaa\naaaadccdcb\n", "output": "NO\n"}, {"input": "rtfabanpc\natfabrnpc\n", "output": "YES\n"}, {"input": "rtfabanpc\natfrbanpc\n", "output": "YES\n"}, {"input": "qxolmbkkt\naovlajmlf\n", ... | code_stdio |
[
{
"content": "Takahashi is hosting an sports meet. There are N people who will participate. These people are conveniently numbered 1 through N. Also, there are M options of sports for this event. These sports are numbered 1 through M. Among these options, Takahashi will select one or more sports (possibly all) ... | [{"input": "2 5\n5 1 3 4 2\n2 5 3 1 4\n2 3 1 10 10\n2 5 4 3 1", "output": "1\n"}, {"input": "2 5\n5 1 3 4 2\n2 5 3 1 4\n2 3 1 6 10\n2 5 4 3 1", "output": "1\n"}, {"input": "2 5\n5 1 3 4 2\n2 5 3 1 4\n2 3 1 6 10\n2 5 4 2 1", "output": "1\n"}, {"input": "2 5\n5 1 3 4 2\n2 5 3 1 4\n2 3 1 6 10\n2 5 3 3 1", "output": "1\n"}... | code_stdio |
[
{
"content": "In Russia, there is an army-purposed station named UVB-76 or \"Buzzer\" (see also https://en.wikipedia.org/wiki/UVB-76). Most of time specific \"buzz\" noise is being broadcasted, but on very rare occasions, the buzzer signal is interrupted and a voice transmission in Russian takes place. Transmit... | [{"input": "\"MDZHBMDZHB 855 56 KLASA 81 00 02 91\"", "output": "[false]", "fn_name": "validate"}, {"input": "\"MD2HB 60 1S0 AKKRETSIA 58 89 54 54\"", "output": "[false]", "fn_name": "validate"}, {"input": "\"MDZHB 12 733 EDIN ENIE 67 79 66 32\"", "output": "[false]", "fn_name": "validate"}, {"input": "\"MDZHB 12 733 6... | code_functional |
[
{
"content": "In this kata you need to build a function to return either `true/True` or `false/False` if a string can be seen as the repetition of a simpler/shorter subpattern or not.\n\nFor example:\n\n```cpp,java\nhasSubpattern(\"a\") == false; //no repeated pattern\nhasSubpattern(\"aaaa\") == true; //created... | [{"input": "\"123A123a123a\"", "output": "[false]", "fn_name": "has_subpattern"}, {"input": "\"123a123a123a\"", "output": "[true]", "fn_name": "has_subpattern"}, {"input": "\"abbaabbaabba\"", "output": "[true]", "fn_name": "has_subpattern"}, {"input": "\"abcdabcabcd\"", "output": "[false]", "fn_name": "has_subpattern"}... | code_functional |
[
{
"content": "The 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 to this problem:\n\nGiven a number $m$, how many polynomials $P$ with coeff... | [{"input": "100\n891 894 462 899 163 868 418 903 31 333 670 32 705 561 505 920 414 81 723 603 513 25 896 879 703 415 799 271 440 8 596 207 296 116 458 646 781 842 963 174 157 747 207 996 361 371 721 447 566 438 566 449 522 176 79 740 757 156 436 296 23 704 542 572 455 886 962 194 219 301 437 315 122 513 299 468 760 133... | code_stdio |
[
{
"content": "Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.\n\nThere are n trees located along the road at points with coordinate... | [{"input": "67\n1 1\n3 8\n4 10\n7 8\n9 2\n10 1\n11 5\n12 8\n13 4\n16 6\n18 3\n19 3\n22 5\n24 6\n27 5\n28 3\n29 3\n30 5\n32 5\n33 10\n34 7\n35 8\n36 5\n41 3\n42 2\n43 5\n46 4\n48 4\n49 9\n52 4\n53 9\n55 1\n56 4\n59 7\n68 7\n69 4\n71 9\n72 10\n74 5\n76 4\n77 9\n80 7\n81 9\n82 5\n83 5\n84 9\n85 7\n86 9\n87 4\n88 7\n89 10\... | code_stdio |
[
{
"content": "Kaavi, the mysterious fortune teller, deeply believes that one's fate is inevitable and unavoidable. Of course, she makes her living by predicting others' future. While doing divination, Kaavi believes that magic spells can provide great power for her to see the future. [Image]Β \n\nKaavi has a str... | [{"input": "babbaaababbbbabbaaaababbbaabababbaabbaababbaaabaabbabaabbaababababbaabaaabaaaaababbaabaaaaabaabbabaaababbbb\nbbaabbbbabbbbaaaaaababbbabaaabbbbabababbbaabbbbbabaababbaabaaabaabbababababaaaaabaabbabaaabaaaaaaaaaaaaabbb\n", "output": "284471294\n"}, {"input": "babbaaababbbbabbaaaababbbaabababbaabbaababbaaabaab... | code_stdio |
[
{
"content": "You have n dices each one having s sides numbered from 1 to s.\nHow many outcomes add up to a specified number k?\n\nFor example if we roll four normal six-sided dices we\nhave four outcomes that add up to 5. \n\n(1, 1, 1, 2)\n(1, 1, 2, 1)\n(1, 2, 1, 1)\n(2, 1, 1, 1)\n\nWrite Python code to solve ... | [{"input": "3\n100\n100", "output": "[4851]", "fn_name": "outcome"}, {"input": "6\n10\n27", "output": "[39662]", "fn_name": "outcome"}, {"input": "5\n10\n27", "output": "[6000]", "fn_name": "outcome"}, {"input": "4\n10\n27", "output": "[480]", "fn_name": "outcome"}, {"input": "10\n5\n13", "output": "[220]", "fn_name": ... | code_functional |
[
{
"content": "# Right in the Center\n\n_This is inspired by one of Nick Parlante's exercises on the [CodingBat](https://codingbat.com/java) online code practice tool._\n\nGiven a sequence of characters, does `\"abc\"` appear in the CENTER of the sequence?\n\nThe sequence of characters could contain more than on... | [{"input": "\"abcabcabcabc\"", "output": "[false]", "fn_name": "is_in_middle"}, {"input": "\"AAabcabcBB\"", "output": "[false]", "fn_name": "is_in_middle"}, {"input": "\"AAAAabcBB\"", "output": "[false]", "fn_name": "is_in_middle"}, {"input": "\"abcabcabc\"", "output": "[true]", "fn_name": "is_in_middle"}, {"input": "\... | code_functional |
[
{
"content": "Your task is to create a function called ```sum_arrays()``` in Python or ```addArrays``` in Javascript, which takes two arrays consisting of integers, and returns the sum of those two arrays.\n\nThe twist is that (for example) ```[3,2,9]``` does not equal ``` 3 + 2 + 9```, it would equal ```'3' + ... | [{"input": "[-4, 5, 7, 3, 6]\n[5, 3, 4, 5]", "output": "[[-4, 0, 3, 9, 1]]", "fn_name": "sum_arrays"}, {"input": "[3, 2, 6, 6]\n[-7, 2, 2, 8]", "output": "[[-3, 9, 6, 2]]", "fn_name": "sum_arrays"}, {"input": "[4, 7, 3]\n[1, 2, 3]", "output": "[[5, 9, 6]]", "fn_name": "sum_arrays"}, {"input": "[3, 2, 9]\n[1, 2]", "outp... | code_functional |
[
{
"content": "This winter is so cold in Nvodsk! A group of n friends decided to buy k bottles of a soft drink called \"Take-It-Light\" to warm up a bit. Each bottle has l milliliters of the drink. Also they bought c limes and cut each of them into d slices. After that they found p grams of salt.\n\nTo make a to... | [{"input": "115 1000 1000 1000 1000 1000 17 15\n", "output": "0\n"}, {"input": "1 1000 1000 1000 1000 1000 1 1\n", "output": "1000\n"}, {"input": "1 1000 1001 1000 1000 1000 1 1\n", "output": "1000\n"}, {"input": "82 1000 1000 1000 1000 1000 17 15\n", "output": "0\n"}, {"input": "82 1010 1000 1000 1000 1000 17 15\n", "... | code_stdio |
[
{
"content": "Two chess pieces, a rook and a knight, stand on a standard chessboard 8 Γ 8 in size. The positions in which they are situated are known. It is guaranteed that none of them beats the other one.\n\nYour task is to find the number of ways to place another knight on the board so that none of the three... | [{"input": "c1\nd2\n", "output": "42\n"}, {"input": "g1\ne6\n", "output": "39\n"}, {"input": "h8\ng2\n", "output": "43\n"}, {"input": "a8\nf1\n", "output": "42\n"}, {"input": "e4\nc1\n", "output": "37\n"}, {"input": "b6\ng7\n", "output": "39\n"}, {"input": "a4\nd1\n", "output": "42\n"}, {"input": "h6\na1\n", "output": ... | code_stdio |
[
{
"content": "Example\n\nInput\n\n1\n\n\nOutput\n\n)(\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your complete solution in a single ```python code block.",
"role": "user"
}
] | [{"input": "321", "output": ")))))))))))))))))))))())))((((((((((((((((((((((((\n"}, {"input": "222", "output": "))))))))))))()))))))))((((((((((((((((((((\n"}, {"input": "193", "output": ")))()))))))))))))))))(((((((((((((((((((\n"}, {"input": "180", "output": ")))))))))())))))))))((((((((((((((((((\n"}, {"input": "17... | code_stdio |
[
{
"content": "And where the are the phone numbers?\n\nYou are given a string s consisting of lowercase English letters and an integer k. Find the lexicographically smallest string t of length k, such that its set of letters is a subset of the set of letters of s and s is lexicographically smaller than t.\n\nIt'... | [{"input": "3 99948\nttt\n", "output": "tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt... | code_stdio |
[
{
"content": "You have given an array $a$ of length $n$ and an integer $x$ to a brand new robot. What the robot does is the following: it iterates over the elements of the array, let the current element be $q$. If $q$ is divisible by $x$, the robot adds $x$ copies of the integer $\\frac{q}{x}$ to the end of the... | [{"input": "1\n20 9\n288 279 252 279 288 207 261 270 297 288 276 265 209 217 214 300 227 221 215 271\n", "output": "7833\n"}, {"input": "1\n20 9\n288 279 252 279 288 207 261 270 297 288 276 265 209 217 214 300 227 221 215 271\n", "output": "7833\n"}, {"input": "1\n20 9\n288 279 252 279 288 207 261 270 297 288 276 265 2... | code_stdio |
[
{
"content": "Write a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II.\n\n* insert $k$: Insert a node containing $k$ as key into $T$.\n* find $k$: Report whether $T$ has a node containing $k$.\n* delete $k$: Delete a node contai... | [{"input": "18\ninsert 13\ninsert 2\ninsert 3\ninsert 7\ninsert 22\ninsert 1\nfind 1\nfind 2\nfind 3\nfind 13\nfind 5\nfind 6\nfind 4\nfind 7\nprint\ndelete 3\ndelete 7\nprint", "output": "yes\nyes\nyes\nyes\nno\nno\nno\nyes\n 1 2 3 7 13 22\n 13 2 1 3 7 22\n 1 2 13 22\n 13 2 1 22\n"}, {"input": "18\ninsert 16\ninsert 2... | code_stdio |
[
{
"content": "At the school where Vasya is studying, preparations are underway for the graduation ceremony. One of the planned performances is a ball, which will be attended by pairs of boys and girls.\n\nEach class must present two couples to the ball. In Vasya's class, $a$ boys and $b$ girls wish to participa... | [{"input": "3\n12 6 4\n2 1 2 4\n1 1 2 3\n2 1 1\n1\n1\n3 15 4\n1 1 2 2\n1 2 1 2\n", "output": "4\n0\n2\n"}, {"input": "3\n12 6 4\n2 1 2 4\n1 1 3 3\n2 1 1\n1\n1\n3 15 4\n1 1 2 2\n1 2 1 2\n", "output": "3\n0\n2\n"}, {"input": "3\n12 6 4\n2 1 2 7\n1 1 3 3\n2 1 1\n1\n1\n3 15 4\n1 1 2 2\n1 2 1 2\n", "output": "3\n0\n2\n"}, {... | code_stdio |
[
{
"content": "You are given an array $a$ consisting of $n$ integers.\n\nIn one move, you can choose two indices $1 \\le i, j \\le n$ such that $i \\ne j$ and set $a_i := a_j$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation... | [{"input": "5\n2\n0 3\n4\n2 0 13 1\n3\n3 3 3\n4\n5 10 5 4\n4\n2 1 1 2\n", "output": "YES\nYES\nYES\nYES\nYES\n"}, {"input": "5\n2\n0 3\n4\n2 0 25 1\n3\n3 3 3\n4\n5 10 5 4\n4\n2 1 1 2\n", "output": "YES\nYES\nYES\nYES\nYES\n"}, {"input": "5\n2\n0 3\n4\n2 0 25 1\n3\n3 3 3\n4\n5 10 1 4\n4\n2 1 1 2\n", "output": "YES\nYES\... | code_stdio |
[
{
"content": "Niwango-kun, an employee of Dwango Co., Ltd., likes Niconico TV-chan, so he collected a lot of soft toys of her and spread them on the floor.\n\nNiwango-kun has N black rare soft toys of Niconico TV-chan and they are spread together with ordinary ones. He wanted these black rare soft toys to be cl... | [{"input": "17 2\n0 5\n2 3\n1 0\n1 2\n3 1\n3 1\n3 5\n5 1\n5 4\n7 4\n8 4\n6 1\n1 2\n6 1\n8 1\n11 0\n11 0\n11 -1\n7 0", "output": "5\n"}, {"input": "17 3\n0 5\n2 3\n1 0\n1 2\n3 1\n3 1\n3 5\n5 1\n5 4\n7 4\n8 4\n6 1\n1 2\n6 1\n8 1\n11 1\n11 0\n11 -1\n7 1", "output": "6\n"}, {"input": "17 2\n1 5\n2 3\n1 0\n1 2\n3 1\n3 1\n3 ... | code_stdio |
[
{
"content": "Problem D: Mr. Rito Post Office\n\nYou are a programmer working at a post office on a remote island. The area you live in consists of multiple islands. There is one or more port towns on each island. There may be other towns and villages in addition to them. You have to use a boat to go from one i... | [{"input": "3 3\n1 2 10 L\n1 2 7 S\n2 3 11 S\n3\n1 2 1\n5 5\n1 2 15 L\n2 3 10 L\n4 5 7 L\n1 4 30 S\n3 5 100 S\n5\n1 3 5 4 1\n0 0", "output": "14\n124\n"}, {"input": "3 3\n1 2 5 L\n1 2 7 S\n2 3 11 S\n3\n1 2 3\n5 5\n1 2 15 L\n2 3 10 L\n4 5 12 L\n1 3 30 S\n3 5 100 S\n5\n1 3 5 4 1\n0 0", "output": "18\n279\n"}, {"input": "... | code_stdio |
[
{
"content": "The king of a country loves prime numbers and gambling. The unit of currency in this country is called prime. As of November 1, 2007, Prime's cross-yen rate was just prime at 9973, so the King is overjoyed. Subsidiary coins with 1/101 prime as one subprime are used in this country.\n\nThe governme... | [{"input": "4\n3 -1\n14 4\n3 24\n8 4\n1\n955049 29\n0", "output": "10\n4\n"}, {"input": "4\n0 -1\n13 1\n3 10\n8 3\n1\n964394 20\n0", "output": "6\n-1\n"}, {"input": "4\n0 -1\n18 2\n3 24\n8 4\n1\n190049 29\n0", "output": "10\n3\n"}, {"input": "4\n2 -1\n14 0\n3 24\n8 7\n1\n144232 29\n0", "output": "10\n5\n"}, {"input": "... | code_stdio |
[
{
"content": "The Chef's latest idea is that some cooks might work better in pairs. So, he is going to experiment by pairing up some of his employees to see if the quality of the food prepared in his kitchen increases. However, only some pairs of employees are compatible. Two employees that are not compatible c... | [{"input": "2\n4 5\n-1 0\n2 3\n0 1\n2 1\n1 0\n4 2\n0 1\n2 3\n2 0", "output": "1 4\n0 1\n"}, {"input": "2\n11 5\n0 2\n1 1\n1 3\n1 6\n3 0\n4 3\n0 -1\n0 -1\n2 0", "output": "3 4\n2\n"}, {"input": "2\n11 5\n0 4\n1 1\n1 3\n1 6\n3 0\n4 3\n0 -1\n0 -1\n2 0", "output": "3 4\n2\n"}, {"input": "2\n6 5\n0 1\n1 2\n2 3\n1 3\n3 0\n8 ... | code_stdio |
[
{
"content": "Let'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 from string t, if we can remove some characters from string t and obtain str... | [{"input": "10000000 1\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "10000000\n"}, {"input": "10000000 10000000\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... | code_stdio |
[
{
"content": "Petya has equal wooden bars of length n. He wants to make a frame for two equal doors. Each frame has two vertical (left and right) sides of length a and one top side of length b. A solid (i.e. continuous without breaks) piece of bar is needed for each side.\n\nDetermine a minimal number of wooden... | [{"input": "1000\n1000\n1000\n", "output": "6\n"}, {"input": "1000\n1000\n1000\n", "output": "6"}, {"input": "800\n401\n400\n", "output": "5\n"}, {"input": "828\n468\n726\n", "output": "6\n"}, {"input": "956\n153\n941\n", "output": "3\n"}, {"input": "676\n175\n514\n", "output": "4\n"}, {"input": "713\n150\n591\n", "out... | code_stdio |
[
{
"content": "DevuLand is a very strange place. There are n villages in it. Some of the villages are occupied by dinosaurs while the remaining ones by villagers.\n\tYou are given the information of DevuLand \n\tby an array D of size n. If D[i] is non-negative, it means that there are D[i] villagers in that vill... | [{"input": "3\n2\n5 -5\n2\n-5 5\n3\n-1 3 -2", "output": "5\n5\n3\n"}, {"input": "3\n1\n5 -5\n2\n-5 5\n3\n1 2 -3", "output": "5\n5\n4\n"}, {"input": "3\n2\n5 -5\n2\n-5 5\n3\n0 3 -3", "output": "5\n5\n3\n"}, {"input": "3\n1\n5 -5\n1\n-5 5\n2\n1 3 -4", "output": "5\n5\n5\n"}, {"input": "3\n1\n5 -5\n2\n-8 8\n2\n1 2 -3", "o... | code_stdio |
[
{
"content": "Let a and b be some non-negative integers. Let's define strange addition of a and b as following:\n\n 1. write down the numbers one under another and align them by their least significant digit; \n 2. add them up digit by digit and concatenate the respective sums together. \n\n\n\nAssume that bo... | [{"input": "2 3\n14\n2 4\n2 1\n1 1\n", "output": "15\n12\n12\n"}, {"input": "2 3\n14\n2 4\n2 1\n2 0\n", "output": "15\n12\n11\n"}, {"input": "2 3\n11\n2 8\n2 2\n2 0\n", "output": "19\n13\n11\n"}, {"input": "2 3\n11\n2 8\n2 2\n2 1\n", "output": "19\n13\n12\n"}, {"input": "2 3\n11\n2 8\n2 2\n2 2\n", "output": "19\n13\n13... | code_stdio |
[
{
"content": "Given are three integers A_1, A_2, and A_3.\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\n-----Constraints-----\n - 1 \\leq A_i \\leq 13 \\ \\ (i=1,2,3)\n - All values in input are integers.\n\n-----Input-----\nInput is given from Standard Input in the follow... | [{"input": "13 13 13\n", "output": "bust\n"}, {"input": "1 10 11\n", "output": "bust\n"}, {"input": "6 13 10\n", "output": "bust\n"}, {"input": "115 -5 1", "output": "bust\n"}, {"input": "-2 -10 -1", "output": "win\n"}, {"input": "-4 -10 -1", "output": "win\n"}, {"input": "-4 -13 -1", "output": "win\n"}, {"input": "-4 ... | code_stdio |
[
{
"content": "You are given N points in the xy-plane. You have a circle of radius one and move it on the xy-plane, so as to enclose as many of the points as possible. Find how many points can be simultaneously enclosed at the maximum. A point is considered enclosed by a circle when it is inside or on the circle... | [{"input": "3\n6.834942604239939 7.69628\n6.04723928846506 4.859878448884584\n7.439438773048666 6.914350092484497\n6\n7.260024632937995 4.220572316804344\n7.2301779956102665 2.69466\n5.977411451010016 4.7893139817742\n5.771323891387089 5.033018424848772\n7.097650770216692 5.940611762552271\n8.514204260774932 5.46523993... | code_stdio |
[
{
"content": "The process of mammoth's genome decoding in Berland comes to its end!\n\nOne of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a quest... | [{"input": "252\n???????GCG??T??TT?????T?C???C?CCG???GA???????AC??A???AAC?C?CC??CCC??A??TA?CCC??T???C??CA???CA??G????C?C?C????C??C??A???C?T????C??ACGC??CC?A?????A??CC?C??C?CCG?C??C??A??CG?A?????A?CT???CC????CCC?CATC?G??????????A???????????????TCCCC?C?CA??AC??GC????????\n", "output": "AAAAAAAGCGAATAATTAAAAATACAAACACCGAA... | code_stdio |
[
{
"content": "Compare two strings by comparing the sum of their values (ASCII character code).\n\n* For comparing treat all letters as UpperCase\n* `null/NULL/Nil/None` should be treated as empty strings\n* If the string contains other characters than letters, treat the whole string as it would be empty\n\nYour... | [{"input": "\"ZzZz\"\n\"ffPFF\"", "output": "[true]", "fn_name": "compare"}, {"input": "\"!!\"\n\"7476\"", "output": "[true]", "fn_name": "compare"}, {"input": "\"##\"\n\"1176\"", "output": "[true]", "fn_name": "compare"}, {"input": "\"AD\"\n\"DD\"", "output": "[false]", "fn_name": "compare"}, {"input": "\"Ad\"\n\"DD\"... | code_functional |
[
{
"content": "We consider a positive integer perfect, if and only if the sum of its digits is exactly $10$. Given a positive integer $k$, your task is to find the $k$-th smallest perfect positive integer.\n\n\n-----Input-----\n\nA single line with a positive integer $k$ ($1 \\leq k \\leq 10\\,000$).\n\n\n-----O... | [{"input": "10000\n", "output": "10800100\n"}, {"input": "9999\n", "output": "10800010\n"}, {"input": "9139\n", "output": "10134010\n"}, {"input": "9859\n", "output": "10422001\n"}, {"input": "8888\n", "output": "10110061\n"}, {"input": "9411\n", "output": "10214200\n"}, {"input": "8515\n", "output": "10030114\n"}, {"i... | code_stdio |
[
{
"content": "Convenience store Deven Eleven is planning to open its first store in Aizuwakamatsu City to expand its business. There are already many other convenience stores in Aizuwakamatsu, so the place to open a new store is likely to be the key to success. Under the premise that \"customers use the conveni... | [{"input": "10 12\n6\n2 1\n6 1\n6 2\n1 5\n0 6\n5 6\n2\n1 3\n5 3\n11 6\n6\n3 3\n3 4\n6 1\n1 1\n1 6\n5 6\n2\n0 3\n6 4\n0 0", "output": "6\n18\n"}, {"input": "10 12\n6\n1 1\n6 1\n6 2\n1 5\n0 6\n5 6\n2\n1 3\n5 3\n11 6\n6\n3 3\n3 4\n6 2\n1 1\n1 5\n1 6\n2\n0 3\n6 4\n0 0", "output": "8\n20\n"}, {"input": "6 6\n6\n1 1\n4 2\n3 ... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.