messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "Awruk is taking part in elections in his school. It is the final round. He has only one opponent — Elodreip. The are $n$ students in the school. Each student has exactly $k$ votes and is obligated to use all of them. So Awruk knows that if a person gives $a_i$ votes for Elodreip, than he will get ...
[{"input": "100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100...
code_stdio
[ { "content": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES\n\nWrite Python code to solve this ...
[{"input": "46\n", "output": "YES\n"}, {"input": "12\n", "output": "YES\n"}, {"input": "30\n", "output": "YES\n"}, {"input": "35\n", "output": "YES\n"}, {"input": "43\n", "output": "YES\n"}, {"input": "52\n", "output": "YES\n"}, {"input": "64\n", "output": "YES\n"}, {"input": "86\n", "output": "YES\n"}, {"input": "011\...
code_stdio
[ { "content": "Given a string of length n s = s1, s2,…, sn and m queries. Each query qk (1 ≤ k ≤ m) is one of four types, \"L ++\", \"L-\", \"R ++\", \"R-\", and l [for the kth query qk. k] and r [k] are defined below.\n\n* L ++: l [k] = l [k-1] + 1, r [k] = r [k-1]\n\n* L-: l [k] = l [k-1] -1, r [k] = r [k-1]\n...
[{"input": "10 13\naacacbabac\nR++\nR++\nL++\nR++\nR++\nL++\nL++\nR++\nR++\nL--\nL--\nR--\nR--", "output": "11"}, {"input": "4 6\nbaba\nR++\nL++\nR++\nL++\nR++\nL++", "output": "4\n"}, {"input": "4 6\nbaab\nR++\nL++\nR++\nL++\nR++\nL++", "output": "5\n"}, {"input": "8 6\nbacb\nR++\nL++\nR++\nL++\nR++\nL++", "output": "...
code_stdio
[ { "content": "Nantendo Co., Ltd. has released a game software called Packet Monster. This game was intended to catch, raise, and fight monsters, and was a very popular game all over the world.\n\nThis game had features not found in traditional games. There are two versions of this game, Red and Green, and the m...
[{"input": "CBA\ncba\ncCa\nX\nYZ\nZ\n-", "output": "BbA\nYX\n"}, {"input": "CBA\ncba\ncCa\nY\nYZ\nZ\n-", "output": "BbA\nYY\n"}, {"input": "CBA\ncca\ncCa\nX\nZY\nZ\n-", "output": "BcA\nXY\n"}, {"input": "CAB\ncba\ncCa\nX\nYZ\nZ\n-", "output": "AbB\nYX\n"}, {"input": "CAB\ncca\ncCa\nX\nYZ\nZ\n-", "output": "AcB\nYX\n"},...
code_stdio
[ { "content": "There are several days left before the fiftieth birthday of a famous Berland's writer Berlbury. In this connection the local library decided to make an exposition of the works of this famous science-fiction writer. It was decided as well that it is necessary to include into the exposition only tho...
[{"input": "55 1000\n2612 1306 4300 1790 3173 9493 7209 7763 8563 4534 7466 1281 4483 6863 3787 7292 3957 8775 7221 4016 5743 6556 2070 2119 4795 9094 1913 2077 8786 4520 1865 2357 7871 3288 8231 5808 9383 9820 9974 3056 5343 2169 5177 6299 5805 8132 9315 6747 5226 3531 1206 4073 8290 1423 6720\n", "output": "3 1\n37 3...
code_stdio
[ { "content": "To stay woke and attentive during classes, Karen needs some coffee! [Image] \n\nKaren, a coffee aficionado, wants to know the optimal temperature for brewing the perfect cup of coffee. Indeed, she has spent some time reading several recipe books, including the universally acclaimed \"The Art of th...
[{"input": "3 2 4\n91 288\n92 97\n116 271\n92 192\n93 97\n95 138\n90 100\n", "output": "83\n5\n26\n6\n"}, {"input": "3 2 4\n91 510\n92 97\n66 271\n51 94\n93 97\n95 316\n100 111\n", "output": "4\n5\n177\n12\n"}, {"input": "3 2 4\n91 288\n92 97\n116 271\n86 192\n93 97\n95 138\n90 100\n", "output": "83\n5\n26\n6\n"}, {"in...
code_stdio
[ { "content": "There are some beautiful girls in Arpa’s land as mentioned before.\n\nOnce Arpa came up with an obvious problem:\n\nGiven an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \\oplus a_{j} = x$, where $\\oplus$ is bitwise xor operation (see notes for ...
[{"input": "64 118\n361 547 410 294 448 377 482 490 13 116 346 50 251 330 443 128 543 580 370 489 337 509 414 291 228 71 245 308 319 314 154 39 317 288 145 248 547 152 262 278 89 108 522 238 128 575 112 469 86 230 310 492 127 270 475 25 179 72 345 444 17 332 544 338\n", "output": "3\n"}, {"input": "64 118\n361 547 410 ...
code_stdio
[ { "content": "Valentin participates in a show called \"Shockers\". The rules are quite easy: jury selects one letter which Valentin doesn't know. He should make a small speech, but every time he pronounces a word that contains the selected letter, he receives an electric shock. He can make guesses which letter ...
[{"input": "15\n. r\n? e\n. s\n. rw\n? y\n. fj\n. zftyd\n? r\n! wq\n? w\n? p\n. ours\n. dto\n. lbyfru\n? q\n", "output": "2\n"}, {"input": "8\n! hello\n! codeforces\n? c\n. o\n? d\n? h\n. l\n? e\n", "output": "2\n"}, {"input": "7\n! ababahalamaha\n? a\n? b\n? a\n? b\n? a\n? h\n", "output": "0\n"}, {"input": "3\n. abcde...
code_stdio
[ { "content": "Problem statement\n\nA programming contest will be held in the Russian Federation. The contest has N questions and has M participants. Question i has a score a_i, and it is known that participant j's ability is b_j. For problem i and participant j, participant j can always solve problem i if a_i ≤...
[{"input": "6\n1 2 0 15 0 2\n7\n2 5 4 2 6 1 0\n1 28 1 3 5 1 0", "output": "Yes\nNo\nYes\nYes\nYes\nYes\nYes\n"}, {"input": "6\n1 1 0 15 0 3\n7\n2 5 4 2 10 1 0\n1 28 1 3 0 1 0", "output": "Yes\nNo\nYes\nNo\nYes\nYes\nYes\n"}, {"input": "6\n1 2 0 15 1 4\n7\n0 5 8 2 11 1 0\n1 11 1 5 0 0 -1", "output": "No\nNo\nYes\nNo\nYe...
code_stdio
[ { "content": "You are given a string s.\nAmong the different substrings of s, print the K-th lexicographically smallest one.\nA substring of s is a string obtained by taking out a non-empty contiguous part in s.\nFor example, if s = ababc, a, bab and ababc are substrings of s, while ac, z and an empty string ar...
[{"input": "atcoderandatcodeer\n5\n", "output": "andat\n"}, {"input": "atcoderamdatcodeer\n5", "output": "amdat\n"}, {"input": "roddadtadmaoefectr\n5", "output": "admao\n"}, {"input": "atcoderamdascodeer\n5", "output": "amdas\n"}, {"input": "atcoderandatcodeer\n4", "output": "anda\n"}, {"input": "roddadtadmboefectr\n4"...
code_stdio
[ { "content": "Kate likes to count words in text blocks. By words she means continuous sequences of English alphabetic characters (from a to z ). Here are examples:\n\n`Hello there, little user5453 374 ())$. I’d been using my sphere as a stool. Slow-moving target 839342 was hit by OMGd-63 or K4mp.` contains \"wo...
[{"input": "\"Really2374239847 long ^&#$&(*@# sequence\"", "output": "[3]", "fn_name": "word_count"}, {"input": "\"Hello there, little user5453 374 ())$.\"", "output": "[4]", "fn_name": "word_count"}, {"input": "\"Slow-moving user6463 has been here\"", "output": "[6]", "fn_name": "word_count"}, {"input": "\"I'd like to...
code_functional
[ { "content": "Fox Ciel has a robot on a 2D plane. Initially it is located in (0, 0). Fox Ciel code a command to it. The command was represented by string s. Each character of s is one move operation. There are four move operations at all: 'U': go up, (x, y) → (x, y+1); 'D': go down, (x, y) → (x, y-1); 'L...
[{"input": "-1000000000 -1000000000\nDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDL\n", "output": "Yes\n"}, {"input": "-1000000000 -1000000000\nDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDL\n", "output": "Yes\n"...
code_stdio
[ { "content": "You are given an infinite checkered field. You should get from a square (x1; y1) to a square (x2; y2). Using the shortest path is not necessary. You can move on the field squares in four directions. That is, when you are positioned in any square, you can move to any other side-neighboring one. \n\...
[{"input": "999999999 1000000000 1000000000 -999999999 -1000000000 999999999\n", "output": "1"}, {"input": "101304499 148554333 -590787464 -890180401 -117457421 997140710\n", "output": "12"}, {"input": "1000000000 1000000000 871940474 991768763 -914352281 -886310260\n", "output": "1"}, {"input": "781751245 1100000000 -...
code_stdio
[ { "content": "The only difference between easy and hard versions is constraints.\n\nYou are given a sequence $a$ consisting of $n$ positive integers.\n\nLet's define a three blocks palindrome as the sequence, consisting of at most two distinct elements (let these elements are $a$ and $b$, $a$ can be equal $b$) ...
[{"input": "6\n8\n1 1 4 2 1 2 1 1\n3\n1 3 12\n4\n1 10 10 1\n1\n26\n2\n2 4\n3\n2 1 1\n", "output": "6\n1\n4\n1\n1\n2\n"}, {"input": "6\n8\n1 1 2 2 3 2 1 1\n3\n1 3 3\n4\n1 10 10 1\n1\n26\n2\n2 1\n3\n1 1 1\n", "output": "7\n2\n4\n1\n1\n3\n"}, {"input": "6\n8\n1 1 2 2 3 2 1 1\n3\n1 3 3\n4\n1 10 10 1\n1\n26\n2\n2 2\n3\n1 1 ...
code_stdio
[ { "content": "Ramesses knows a lot about problems involving trees (undirected connected graphs without cycles)!\n\nHe created a new useful tree decomposition, but he does not know how to construct it, so he asked you for help!\n\nThe decomposition is the splitting the edges of the tree in some simple paths in s...
[{"input": "9\n1 2\n1 3\n1 4\n1 5\n1 6\n6 7\n7 8\n8 9\n", "output": "Yes\n5\n1 2\n1 3\n1 4\n1 5\n1 9\n"}, {"input": "9\n1 2\n2 3\n1 4\n1 5\n1 6\n6 7\n5 8\n7 9\n", "output": "Yes\n4\n1 3\n1 4\n1 8\n1 9\n"}, {"input": "9\n1 2\n2 3\n1 4\n1 8\n1 6\n6 7\n5 8\n7 9\n", "output": "Yes\n4\n1 3\n1 4\n1 5\n1 9\n"}, {"input": "5\n...
code_stdio
[ { "content": "A permutation is a sequence of integers from $1$ to $n$ of length $n$ containing each number exactly once. For example, $[1]$, $[4, 3, 5, 1, 2]$, $[3, 2, 1]$ — are permutations, and $[1, 1]$, $[4, 3, 1]$, $[2, 3, 4]$ — no.\n\nPermutation $a$ is lexicographically smaller than permutation $b$ (they ...
[{"input": "5 4\n1 2 5\n2 3\n1 1 3\n1 3 4\n", "output": "14\n7\n9\n"}, {"input": "4 4\n1 2 4\n2 3\n1 1 2\n1 1 4\n", "output": "9\n4\n10\n"}, {"input": "5 4\n1 1 4\n2 5\n1 1 2\n1 3 4\n", "output": "10\n3\n9\n"}, {"input": "5 4\n1 1 4\n2 5\n1 1 1\n1 3 4\n", "output": "10\n1\n9\n"}, {"input": "4 4\n1 1 4\n2 3\n1 1 2\n1 3 ...
code_stdio
[ { "content": "Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coord...
[{"input": "25\n-611859852 0\n-611859842 0\n-611859837 0\n-611859843 0\n-611859863 0\n-611859851 0\n-611859857 0\n-611859858 0\n-611859845 0\n-611859865 0\n-611859836 0\n-611859839 0\n-611859850 0\n-611859854 0\n-611859838 0\n-611859840 0\n-611859860 0\n-611859853 0\n-611859848 0\n-611859844 0\n-611859861 0\n-611859856...
code_stdio
[ { "content": "Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside.\n\nThe text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ w...
[{"input": "abcdefghijklyyyyyyymnopqrstuvwxabcdefghijklyyyyyyymnopqrstuvwxabcdefghijklyyyyyyymnopqrstuvwxabcdefghijklyyyyyyymnopqrstuvwxabcdefghijklyyyyyyymnopqrstuvwxabcdefghijklzzzzzzzmnopqrstuvwxabcdefghijklzzzzzzzmnopqrstuvwxabcdefghijklzzzzzzzmnopqrstuvwxabcdefghijklzzzzzzzmnopqrstuvwxabcdefghijklzzzzzzzmnopqrstuv...
code_stdio
[ { "content": "As you probably know, Fibonacci sequence are the numbers in the following integer sequence:\n1, 1, 2, 3, 5, 8, 13...\nWrite a method that takes the index as an argument and returns last digit from fibonacci number. Example:\n getLastDigit(15) - 610. Your method must return 0 because the last digi...
[{"input": "193150", "output": "[5]", "fn_name": "get_last_digit"}, {"input": "193241", "output": "[1]", "fn_name": "get_last_digit"}, {"input": "20001", "output": "[6]", "fn_name": "get_last_digit"}, {"input": "99999", "output": "[6]", "fn_name": "get_last_digit"}, {"input": "1001", "output": "[1]", "fn_name": "get_la...
code_functional
[ { "content": "Koa the Koala has a binary string $s$ of length $n$. Koa can perform no more than $n-1$ (possibly zero) operations of the following form:\n\nIn one operation Koa selects positions $i$ and $i+1$ for some $i$ with $1 \\le i < |s|$ and sets $s_i$ to $max(s_i, s_{i+1})$. Then Koa deletes position $i+1...
[{"input": "0100111100100101001101111001011101011001111100110111101110001001010111100010011100011011101111010111111010010101000001110110111110010001100010101110111111000011101110000000001101010011000111111100000000000000001010011111010111\n", "output": "975171002\n"}, {"input": "0100111100100101001101111001011101011001...
code_stdio
[ { "content": "A new task for you!\n\nYou have to create a method, that corrects a given time string.\nThere was a problem in addition, so many of the time strings are broken.\nTime-Format is european. So from \"00:00:00\" to \"23:59:59\".\n\n\nSome examples:\n\n\"09:10:01\" -> \"09:10:01\"\n\"11:70:10\" -> \"12...
[{"input": "\"09:10:01\"", "output": "[\"09:10:01\"]", "fn_name": "time_correct"}, {"input": "\"11:70:10\"", "output": "[\"12:10:10\"]", "fn_name": "time_correct"}, {"input": "\"19:99:99\"", "output": "[\"20:40:39\"]", "fn_name": "time_correct"}, {"input": "\"24:01:01\"", "output": "[\"00:01:01\"]", "fn_name": "time_co...
code_functional
[ { "content": "JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \\le a_1 < a_2 < \\ldots < a_n \\le 10^3$, and then went to the bathroom.\n\nJATC decided to prank his friend by erasing some...
[{"input": "100\n901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976...
code_stdio
[ { "content": "You have a string of decimal digits s. Let's define b_{ij} = s_{i}·s_{j}. Find in matrix b the number of such rectangles that the sum b_{ij} for all cells (i, j) that are the elements of the rectangle equals a in each rectangle.\n\nA rectangle in a matrix is a group of four integers (x, y, z, t) (...
[{"input": "700\n100101011011001100111101100101000100000000011001111000111110001011011100010110000000000100100000001100000011110011101110011101101110111011011100001001101011000100000000000110001000101001100011111110011010101011010100010100001011011111001011000101001101000111010100110000100100110011111100010111100010000...
code_stdio
[ { "content": "We often have to copy large volumes of information. Such operation can take up many computer resources. Therefore, in this problem you are advised to come up with a way to copy some part of a number array into another one, quickly.\n\nMore formally, you've got two arrays of integers a_1, a_2, ...,...
[{"input": "20 30\n5 6 -6 10 10 -6 10 7 0 -20 3 1 -7 -13 1 -7 5 1 -1 1\n2 10 -10 -1 -9 3 9 -9 6 5 10 -2 -5 -14 1 5 -4 -1 -8 -7\n2 14\n1 8 11 1\n2 7\n1 6 11 1\n1 9 2 7\n1 12 1 7\n2 20\n2 5\n1 14 8 3\n1 8 17 4\n2 4\n1 11 12 9\n2 8\n2 3\n2 2\n1 17 13 2\n1 3 18 1\n2 11\n1 5 12 6\n1 12 13 1\n2 16\n2 11\n2 10\n2 19\n2 20\n2 ...
code_stdio
[ { "content": "You are given $n$ segments on a Cartesian plane. Each segment's endpoints have integer coordinates. Segments can intersect with each other. No two segments lie on the same line.\n\nCount the number of distinct points with integer coordinates, which are covered by at least one segment.\n\n\n-----In...
[{"input": "10\n841746 527518 -841746 -527518\n595261 331297 -595261 -331297\n-946901 129987 946901 -129987\n670374 -140388 -670374 140388\n-684770 309555 684770 -309555\n-302589 415564 302589 -415564\n-387435 613331 387435 -613331\n-624940 -95922 624940 95922\n945847 -199224 -945847 199224\n24636 -565799 -24636 565799...
code_stdio
[ { "content": "Vasya has a string $s$ of length $n$ consisting only of digits 0 and 1. Also he has an array $a$ of length $n$. \n\nVasya performs the following operation until the string becomes empty: choose some consecutive substring of equal characters, erase it from the string and glue together the remaining...
[{"input": "99\n101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1000000000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
code_stdio
[ { "content": "In Japan, people make offerings called hina arare, colorful crackers, on March 3.\nWe have a bag that contains N hina arare. (From here, we call them arare.)\nIt is known that the bag either contains arare in three colors: pink, white and green, or contains arare in four colors: pink, white, green...
[{"input": "100\nP P P G G P P P G G P P G G P G W G W G G G P G P P G P P P G G G P P G P G P P G P P G G G W G G G P P P W G P G G P G G G G G P P W P G G G G G P P G G P G P G G G G P G G G G W P G P P P G G P G P\n", "output": "Three\n"}, {"input": "100\nG G G G G W W W W W W G W G G G W G P W W W W G G W G W G W W...
code_stdio
[ { "content": "Takahashi is going to buy N items one by one.\nThe price of the i-th item he buys is A_i yen (the currency of Japan).\nHe has M discount tickets, and he can use any number of them when buying an item.\nIf Y tickets are used when buying an item priced X yen, he can get the item for \\frac{X}{2^Y} (...
[{"input": "7955 99805\n280223699 243184364 149210358 462114945 880243783 898930650 89064311 63969626 29578760 282083932 336425831 645450084 410674240 438196631 429198606 786790252 782175216 882975396 529275843 756821367 312076396 771188495 855523957 734650681 911233499 357477721 909515813 72334495 882955704 862214008 ...
code_stdio
[ { "content": "The educational program (AHK Education) of the Aiz Broadcasting Corporation broadcasts a program called \"Play with Tsukuro\" for children. Today is the time to make a box with drawing paper, but I would like to see if the rectangular drawing paper I prepared can make a rectangular parallelepiped....
[{"input": "2 -1\n2 9\n-1 1\n0 -1\n-1 6\n-1 5", "output": "no\n"}, {"input": "2 -1\n2 6\n-1 1\n0 -1\n-1 6\n-1 5", "output": "no\n"}, {"input": "2 -1\n2 6\n-1 1\n0 -1\n-1 6\n-2 5", "output": "no\n"}, {"input": "2 -1\n2 7\n-1 1\n0 -1\n-1 6\n-2 5", "output": "no\n"}, {"input": "2 -1\n2 7\n-2 1\n0 -1\n-1 6\n-2 5", "output"...
code_stdio
[ { "content": "Given are integers a,b,c and d.\nIf x and y are integers and a \\leq x \\leq b and c\\leq y \\leq d hold, what is the maximum possible value of x \\times y?\n\n-----Constraints-----\n - -10^9 \\leq a \\leq b \\leq 10^9\n - -10^9 \\leq c \\leq d \\leq 10^9\n - All values in input are integers.\n\n-...
[{"input": "-1000000000 1000000000 -1000000000 1000000000\n", "output": "1000000000000000000\n"}, {"input": "418379342 802780784 -790013317 -445130206\n", "output": "-186233282690604452\n"}, {"input": "-477104372 -381646699 -939378260 508013173\n", "output": "448181474807752720\n"}, {"input": "-683353808 -213997410 -57...
code_stdio
[ { "content": "Some time ago Leonid have known about idempotent functions. Idempotent function defined on a set {1, 2, ..., n} is such function <image>, that for any <image> the formula g(g(x)) = g(x) holds.\n\nLet's denote as f(k)(x) the function f applied k times to the value x. More formally, f(1)(x) = f(x), ...
[{"input": "142\n34 88 88 88 88 88 131 53 88 130 131 88 88 130 88 131 53 130 130 34 88 88 131 130 53 88 88 34 131 130 88 131 130 34 130 53 53 34 53 34 130 34 88 88 130 88 131 130 34 53 88 34 53 88 130 53 34 53 88 131 130 34 88 88 130 88 130 130 131 131 130 53 131 130 131 130 53 34 131 34 88 53 88 53 34 130 88 88 130 53...
code_stdio
[ { "content": "You have N cups and 1 ball.\n\nThe cups are arranged in a row, from left to right.\n\nYou turned down all the cups, then inserted the ball into the leftmost cup.\n\nThen, you will perform the following Q operations:\n\n* The i-th operation: swap the positions of the A_i-th and B_i-th cups from the...
[{"input": "20 3\n1 4\n10 17\n1 19", "output": "4\n"}, {"input": "20 3\n1 4\n10 17\n1 14", "output": "4\n"}, {"input": "20 3\n1 4\n10 17\n1 13", "output": "4\n"}, {"input": "20 3\n1 1\n10 17\n1 13", "output": "4\n"}, {"input": "24 1\n2 1\n11 18\n1 35", "output": "3\n"}, {"input": "20 3\n1 4\n10 17\n2 14", "output": "4\...
code_stdio
[ { "content": "Chef loves arrays. But he really loves a specific kind of them - Rainbow Arrays. \nThe array is a Rainbow Array if it has such a structure:\n- The first a1 elements equal to 1. \n- The next a2 elements equal to 2. \n- The next a3 elements equal to 3. \n- The next a4 elements equal to 4. \n- The...
[{"input": "1018", "output": "857373624\n"}, {"input": "200", "output": "120529249\n"}, {"input": "140", "output": "119877472\n"}, {"input": "320", "output": "398506989\n"}, {"input": "147", "output": "170230452\n"}, {"input": "269", "output": "177979760\n"}, {"input": "229", "output": "666926094\n"}, {"input": "303", ...
code_stdio
[ { "content": "You are given a string $s$, consisting only of characters '0' and '1'.\n\nYou have to choose a contiguous substring of $s$ and remove all occurrences of the character, which is a strict minority in it, from the substring.\n\nThat is, if the amount of '0's in the substring is strictly smaller than ...
[{"input": "1\n101010101010101010101010101010010101010101010101010101010101010101010100000\n", "output": "35\n"}, {"input": "1\n10101010101010101010101010101001010101010101010101010101010101010101010000\n", "output": "35\n"}, {"input": "1\n1101010101111010110101010101001010111010\n", "output": "17\n"}, {"input": "1\n00...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese here \nRead problems statements in Russian here \n\n------ Problem Statement ------ \n\nOne day Chef is waiting his girlfriend on the bus station. The girlfriend said that she will be at time_{1}. Chef went to the bus station at time_{2}. When Chef has ...
[{"input": "3\n10:00\n09:00\n14\n10:00\n08:00\n151\n10:00\n09:00\n167", "output": "74.0 60.0\n271.0 211.0\n227.0 197.0\n"}, {"input": "3\n10:00\n09:00\n20\n10:00\n08:00\n151\n10:00\n09:00\n167", "output": "80.0 60.0\n271.0 211.0\n227.0 197.0\n"}, {"input": "3\n10:00\n09:00\n15\n10:00\n08:00\n151\n10:00\n09:00\n167", "o...
code_stdio
[ { "content": "Fibonacci number f(i) appear in a variety of puzzles in nature and math, including packing problems, family trees or Pythagorean triangles. They obey the rule f(i) = f(i - 1) + f(i - 2), where we set f(0) = 1 = f(-1).\n\nLet V and d be two certain positive integers and be N ≡ 1001 a constant. Cons...
[{"input": "10 1\n118 1\n22 23", "output": "10\n109\n12\n"}, {"input": "10 7\n118 1\n22 23", "output": "6\n109\n12\n"}, {"input": "10 3\n118 1\n22 23", "output": "8\n109\n12\n"}, {"input": "21 2\n104 7\n52 12", "output": "20\n59\n30\n"}, {"input": "16 2\n50 2\n22 20", "output": "15\n47\n13\n"}, {"input": "16 2\n75 2\n2...
code_stdio
[ { "content": "Goldbach's Conjecture: For any even number n greater than or equal to 4, there exists at least one pair of prime numbers p1 and p2 such that n = p1 + p2.\n\nThis conjecture has not been proved nor refused yet. No one is sure whether this conjecture actually holds. However, one can find such a pair...
[{"input": "6\n10\n14\n0", "output": "1\n2\n2\n"}, {"input": "6\n1\n12\n0", "output": "1\n0\n1\n"}, {"input": "6\n10\n8\n0", "output": "1\n2\n1\n"}, {"input": "6\n4\n12\n0", "output": "1\n1\n1\n"}, {"input": "6\n2\n14\n0", "output": "1\n0\n2\n"}, {"input": "6\n16\n1\n0", "output": "1\n2\n0\n"}, {"input": "6\n6\n14\n0",...
code_stdio
[ { "content": "At Akabe High School, which is a programmer training school, the roles of competition programmers in team battles are divided into the following three types.\nC: | Coder | I am familiar with the language and code.\n--- | --- | ---\nA: | Algorithm | I am good at logical thinking and think about alg...
[{"input": "4\n2 1 2\n2 1 2\n13 15 2\n0 1 3", "output": "1\n1\n7\n0\n"}, {"input": "4\n2 1 2\n2 2 2\n13 15 2\n0 1 3", "output": "1\n2\n7\n0\n"}, {"input": "4\n11 0 1\n0 3 3\n2 10 4\n1 2 3", "output": "3\n0\n2\n1\n"}, {"input": "4\n0 1 2\n3 0 2\n13 19 2\n0 1 3", "output": "0\n1\n7\n0\n"}, {"input": "4\n2 1 2\n2 4 2\n13 ...
code_stdio
[ { "content": "Given are N positive integers A_1,...,A_N.\nConsider positive integers B_1, ..., B_N that satisfy the following condition.\nCondition: For any i, j such that 1 \\leq i < j \\leq N, A_i B_i = A_j B_j holds.\nFind the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N.\nSince the answer ...
[{"input": "10000\n996426 991040 991394 993249 993789 994392 991787 998270 994534 999447 995337 997096 996535 997215 994454 999779 998240 991404 991682 999870 990794 994313 993602 993869 997730 991987 994764 993847 993506 990653 996555 994126 992060 995401 997275 995702 995833 993070 990511 991728 996911 991730 991236 ...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian. \n\nChef is on a vacation these days, so his friend Chefza is trying to solve Chef's everyday tasks.\nToday's task is to make a sweet roll. Rolls are made by a newly invented cooking machine. The machine is pretty universal - it can make l...
[{"input": "6\n1 1\n2 4\n3 16\n4 16\n4 1\n1 4", "output": "0\n1\n5\n2\n2\n2\n"}, {"input": "6\n2 1\n2 1\n3 8\n14 16\n1 1\n2 4", "output": "1\n1\n4\n7\n0\n1\n"}, {"input": "6\n1 2\n2 4\n5 4\n16 32\n3 2\n1 8", "output": "1\n1\n2\n1\n2\n3\n"}, {"input": "6\n1 2\n4 4\n5 4\n16 32\n3 2\n1 8", "output": "1\n0\n2\n1\n2\n3\n"},...
code_stdio
[ { "content": "You have two variables a and b. Consider the following sequence of actions performed with these variables: If a = 0 or b = 0, end the process. Otherwise, go to step 2; If a ≥ 2·b, then set the value of a to a - 2·b, and repeat step 1. Otherwise, go to step 3; If b ≥ 2·a, then set the value of b to...
[{"input": "1000000000000000000 1000000000000000000\n", "output": "1000000000000000000 1000000000000000000\n"}, {"input": "1100000000000000000 1000000000000000000\n", "output": "1100000000000000000 1000000000000000000\n"}, {"input": "1100000000000000000 1000000000000010000\n", "output": "1100000000000000000 10000000000...
code_stdio
[ { "content": "<image>\n\nTo monitor cryptocurrency exchange rates trader William invented a wonderful device consisting of n lights arranged in a row. The device functions in the following way:\n\nInitially, all lights on William's device are turned off. At the beginning of a new iteration the device randomly, ...
[{"input": "10\n100000 99990\n100000 99997\n100000 99995\n100000 99993\n100000 99990\n100000 99992\n100000 99999\n100000 99992\n100000 99994\n100000 99992\n", "output": "969821134\n814889585\n537223949\n802818035\n969821134\n889337472\n635814936\n889337472\n352113525\n889337472\n"}, {"input": "10\n100000 99991\n100000 ...
code_stdio
[ { "content": "The problem uses a simplified TCP/IP address model, please make sure you've read the statement attentively.\n\nPolycarpus has found a job, he is a system administrator. One day he came across n IP addresses. Each IP address is a 32 bit number, represented as a group of four 8-bit numbers (without ...
[{"input": "15 8\n244.1.125.160\n39.50.68.162\n142.253.101.137\n52.239.241.147\n194.4.189.143\n200.238.160.30\n245.78.177.243\n89.249.140.19\n169.51.142.22\n123.246.20.99\n133.44.192.119\n226.240.179.30\n76.209.211.184\n98.15.6.117\n227.219.117.153\n", "output": "-1\n"}, {"input": "15 8\n244.1.125.160\n39.50.68.162\n14...
code_stdio
[ { "content": "# RoboScript #3 - Implement the RS2 Specification\n\n## Disclaimer\n\nThe story presented in this Kata Series is purely fictional; any resemblance to actual programming languages, products, organisations or people should be treated as purely coincidental.\n\n## About this Kata Series\n\nThis Kata ...
[{"input": "\"((F3)10(F2)11)10\"", "output": "[\"*******************************************************************************************************************************************************************************************************************************************************************************...
code_functional
[ { "content": "Pari wants to buy an expensive chocolate from Arya. She has n coins, the value of the i-th coin is ci. The price of the chocolate is k, so Pari will take a subset of her coins with sum equal to k and give it to Arya.\n\nLooking at her coins, a question came to her mind: after giving the coins to A...
[{"input": "15 388\n33 232 106 369 266 135 22 169 367 37 14 181 232 25 257\n", "output": "89\n0 14 22 25 33 36 37 39 47 51 55 58 59 61 62 69 70 72 73 76 80 84 92 94 95 98 106 109 117 131 135 149 157 160 168 169 172 174 181 182 183 186 191 193 194 195 197 202 205 206 207 214 216 219 220 228 231 239 253 257 271 279 282 2...
code_stdio
[ { "content": "Given are N integers A_1,\\ldots,A_N.\nFind the sum of A_i \\times A_j over all pairs (i,j) such that 1\\leq i < j \\leq N, modulo (10^9+7).\n\n-----Constraints-----\n - 2 \\leq N \\leq 2\\times 10^5\n - 0 \\leq A_i \\leq 10^9\n - All values in input are integers.\n\n-----Input-----\nInput is give...
[{"input": "4\n141421356 17320508 22360679 244949\n", "output": "437235829\n"}, {"input": "4\n141421356 17320508 22360679 176612", "output": "432841470\n"}, {"input": "4\n141421356 17320508 44188846 176612", "output": "442072669\n"}, {"input": "4\n141421356 15438004 10545868 176612", "output": "309796111\n"}, {"input":...
code_stdio
[ { "content": "Joisino is planning to open a shop in a shopping street.\nEach of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during ...
[{"input": "3\n1 1 1 1 1 1 0 0 1 1\n0 1 0 1 1 0 1 0 1 0\n1 0 1 1 0 0 0 1 0 1\n-8 6 -2 -11 -12 4 14 9 -6 2 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 9 -9 12 -5 8 0 -9 -7 -7", "output": "33\n"}, {"input": "3\n1 1 1 1 1 1 0 0 0 0\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -16 -15 0 11 7 -6 0 2\n-9 2 0 1 7 -5 0 -2 -7 5 5\...
code_stdio
[ { "content": "You are given an array $a$ consisting of $n$ integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the array [10, -5, 10, -4, 1] is 15, and the beauty of the array [-3, -5, -1] is 0.\n\nYou may choose at mos...
[{"input": "42 0\n286046708 405034560 -729242288 -594215986 -417878652 197367358 -252467864 -633931002 396498018 -511564535 -989028451 133570042 -189524845 -823874429 -29495943 609283144 349227466 -228464789 -326269641 -837429605 310547279 27725681 -167613209 -86658444 900798243 607258117 280296177 -521198948 862072118...
code_stdio
[ { "content": "A rectangle with sides $A$ and $B$ is cut into rectangles with cuts parallel to its sides. For example, if $p$ horizontal and $q$ vertical cuts were made, $(p + 1) \\cdot (q + 1)$ rectangles were left after the cutting. After the cutting, rectangles were of $n$ different types. Two rectangles are ...
[{"input": "2\n2 2 20\n2 10 40\n", "output": "6\n"}, {"input": "2\n2 2 20\n1 10 11\n", "output": "0\n"}, {"input": "2\n2 2 35\n1 10 11\n", "output": "0\n"}, {"input": "2\n2 3 20\n2 4 40\n", "output": "6\n"}, {"input": "2\n2 2 20\n2 4 40\n", "output": "6\n"}, {"input": "2\n2 2 20\n2 7 16\n", "output": "3\n"}, {"input": ...
code_stdio
[ { "content": "Consider a tunnel on a one-way road. During a particular day, $n$ cars numbered from $1$ to $n$ entered and exited the tunnel exactly once. All the cars passed through the tunnel at constant speeds.\n\nA traffic enforcement camera is mounted at the tunnel entrance. Another traffic enforcement came...
[{"input": "7\n5 2 3 6 7 1 4\n2 3 6 7 1 4 5\n", "output": "6\n"}, {"input": "7\n5 2 3 6 7 1 4\n2 3 6 7 1 4 5\n", "output": "6\n"}, {"input": "5\n3 5 2 1 4\n4 3 2 5 1\n", "output": "2\n"}, {"input": "5\n3 5 2 1 4\n4 3 2 5 1\n", "output": "2\n"}, {"input": "2\n1 2\n1 2\n", "output": "0\n"}, {"input": "2\n1 2\n2 1\n", "ou...
code_stdio
[ { "content": "There are n banks in the city where Vasya lives, they are located in a circle, such that any two banks are neighbouring if their indices differ by no more than 1. Also, bank 1 and bank n are neighbours if n > 1. No bank is a neighbour of itself.\n\nVasya has an account in each bank. Its balance ma...
[{"input": "50\n108431864 128274949 -554057370 -384620666 -202862975 -803855410 -482167063 -55139054 -215901009 0 0 0 0 0 94325701 730397219 358214459 -673647271 -131397668 -377892440 0 0 0 0 0 -487994257 -360271553 639988328 489338210 -281060728 250208758 0 993242346 -213071841 -59752620 -864351041 -114363541 50627995...
code_stdio
[ { "content": "There are n servers in a laboratory, each of them can perform tasks. Each server has a unique id — integer from 1 to n.\n\nIt is known that during the day q tasks will come, the i-th of them is characterized with three integers: t_{i} — the moment in seconds in which the task will come, k_{i} — th...
[{"input": "1 10\n4 1 1\n9 1 1\n10 1 1\n12 1 1\n13 1 1\n15 1 1\n16 1 1\n18 1 1\n19 1 1\n20 1 1\n", "output": "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n"}, {"input": "1 10\n4 1 1\n9 1 1\n10 1 1\n12 1 1\n13 1 1\n15 1 1\n16 1 1\n18 1 1\n19 1 1\n20 1 1\n", "output": "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n"}, {"input": "4 10\n1 1 1\n3 1 2\n4 ...
code_stdio
[ { "content": "Cengiz recently learned Fibonacci numbers and now he is studying different algorithms to find them. After getting bored of reading them, he came with his own new type of numbers that he named XORinacci numbers. He defined them as follows: $f(0) = a$; $f(1) = b$; $f(n) = f(n-1) \\oplus f(n-2)$ ...
[{"input": "10\n669924290 408119795 804030560\n663737793 250734602 29671646\n431160679 146708815 289491233\n189259304 606497663 379372476\n707829111 49504411 81710658\n54555019 65618101 626948607\n578351356 288589794 974275296\n400531973 205638174 323247740\n219131617 178762989 799964854\n825160173 502080627 608216046\...
code_stdio
[ { "content": "Bike loves looking for the second maximum element in the sequence. The second maximum element in the sequence of distinct numbers x_1, x_2, ..., x_{k} (k > 1) is such maximum element x_{j}, that the following inequality holds: $x_{j} \\neq \\operatorname{max}_{i = 1}^{k} x_{i}$.\n\nThe lucky numbe...
[{"input": "10\n29272229 8752316 10025994 52398694 16706314 49609605 28150935 102254532 44865054 87041483\n", "output": "129354579\n"}, {"input": "10\n4547989 39261040 185956581 38131456 26174500 1101740 71295827 77784626 155701452 61318416\n", "output": "263691991\n"}, {"input": "10\n4547989 39261040 185956581 3813145...
code_stdio
[ { "content": "Holidays are coming up really soon. Rick realized that it's time to think about buying a traditional spruce tree. But Rick doesn't want real trees to get hurt so he decided to find some in an $n \\times m$ matrix consisting of \"*\" and \".\".\n\nTo find every spruce first let's define what a spru...
[{"input": "6\n4 7\n...*...\n..***..\n.****..\n*******\n6 10\n....*.*...\n...*****..\n..*******.\n.********.\n********.*\n**********\n5 5\n*...*\n**.**\n*****\n**.**\n*...*\n5 6\n.*....\n.**...\n.***..\n.****.\n.*****\n3 3\n*.*\n...\n*.*\n2 4\n.**.\n****\n", "output": "24\n89\n19\n22\n4\n8\n"}, {"input": "6\n4 7\n...*....
code_stdio
[ { "content": "I, Fischl, Prinzessin der Verurteilung, descend upon this land by the call of fate an — Oh, you are also a traveler from another world? Very well, I grant you permission to travel with me.\n\nIt is no surprise Fischl speaks with a strange choice of words. However, this time, not even Oz, her raven...
[{"input": "3\n28\nqaabzwsxedcrfvtgbyhnujmiklop\n13\ncleanairactbd\n10\naannttoonn\n", "output": "\nac\nf\nb\n"}, {"input": "4\n5\noisha\n10\niloveoisha\n16\nshahromloveoisha\n16\noishaloveshahrom\n", "output": "b\nb\nb\nb\n"}, {"input": "4\n5\naisho\n10\niloveoisha\n16\nshahromloveoisha\n16\noishaloveshahrom\n", "outp...
code_stdio
[ { "content": "Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: \n\n 1. The house consists of some non-zero numbe...
[{"input": "1000000000000\n", "output": "272165"}, {"input": "225849940487\n", "output": "129343\n"}, {"input": "542905489591\n", "output": "200537\n"}, {"input": "376593918338\n", "output": "167021\n"}, {"input": "249436457427\n", "output": "135929\n"}, {"input": "468135010961\n", "output": "186217\n"}, {"input": "235...
code_stdio
[ { "content": "You have an initially empty cauldron, and you want to brew a potion in it. The potion consists of two ingredients: magic essence and water. The potion you want to brew should contain exactly $k\\ \\%$ magic essence and $(100 - k)\\ \\%$ water.\n\nIn one step, you can pour either one liter of magic...
[{"input": "100\n2\n36\n43\n19\n99\n100\n98\n9\n79\n57\n1\n78\n56\n14\n66\n93\n62\n50\n76\n33\n25\n41\n15\n61\n97\n33\n51\n97\n95\n96\n83\n53\n12\n77\n87\n85\n37\n72\n82\n70\n44\n69\n58\n52\n48\n73\n21\n24\n20\n8\n31\n32\n45\n55\n29\n13\n28\n49\n60\n54\n90\n86\n94\n10\n71\n47\n40\n74\n80\n23\n26\n84\n38\n89\n4\n39\n6\n...
code_stdio
[ { "content": "Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1.\n\nYour task is to write a program which sorts a given set of cards in ascending order by thei...
[{"input": "5\nH4 B9 S4 D2 C3", "output": "D2 C3 H4 S4 B9\nStable\nD2 C3 S4 H4 B9\nNot stable\n"}, {"input": "5\nH4 C9 S4 D2 C2", "output": "D2 C2 H4 S4 C9\nStable\nD2 C2 S4 H4 C9\nNot stable\n"}, {"input": "5\nH4 B9 S4 E2 C3", "output": "E2 C3 H4 S4 B9\nStable\nE2 C3 S4 H4 B9\nNot stable\n"}, {"input": "5\nI4 C9 S4 D2...
code_stdio
[ { "content": "Aiz, which is located in cyberspace, trades information with Wakamatsu. The two countries are developing their economies by exchanging useful data with each other. The two countries, whose national policy is philanthropy and equality, and above all, the old word of the Aizu region, \"what must be ...
[{"input": "5\n18\n102\n-181\n53\n9", "output": "0\n"}, {"input": "5\n18\n102\n-155\n53\n9", "output": "3\n"}, {"input": "5\n18\n146\n-181\n53\n9", "output": "0\n"}, {"input": "5\n33\n146\n-181\n53\n9", "output": "0\n"}, {"input": "5\n55\n146\n-181\n53\n9", "output": "0\n"}, {"input": "5\n18\n102\n-155\n53\n32", "outpu...
code_stdio
[ { "content": "Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\\ldots,s_N are all distinct.\n\nNiwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they ...
[{"input": "15\nypnxn 279\njgjfwx 926\nqpuhuwq 327\nrxing 1136\npmuduhznoaqu 912\ndagktgdarveusju 764\nwocppgafnui 200\ndhavrncwfw 725\njpcmigg 658\nwrczqxycivdqn 1232\nmcmkkbnifeod 1503\nhtqvkgkbhtytsz 130\ntwflegsjz 1089\npkhfxzuxrxzwsd 989\nszfwtzfpnscgue 958\npmuduhznoaqu", "output": "8248\n"}, {"input": "15\nypnxn...
code_stdio
[ { "content": "The first algorithm for detecting a face on the image working in realtime was developed by Paul Viola and Michael Jones in 2001. A part of the algorithm is a procedure that computes Haar features. As part of this task, we consider a simplified model of this concept.\n\nLet's consider a rectangular...
[{"input": "100 1\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\n"...
code_stdio
[ { "content": "Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers).\n\nThe key in football is to divide into ...
[{"input": "100\n2382 7572 9578 1364 2325 2929 7670 5574 2836 2440 6553 1751 929 8785 6894 9373 9308 7338 6380 9541 9951 6785 13181 9942 5087 7544 6582 7139 8458 7424 9759 8199 9464 8817 7625 6200 4955 9373 9500 3062 849 4210 9337 5466 2190 8150 4971 3145 869 5675 1975 161 1998 378 5229 9000 8958 761 358 434 7636 8295 ...
code_stdio
[ { "content": "You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions:\n\n* The graph is simple and connected.\n* There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is...
[{"input": "4", "output": "4\n1 2\n1 3\n2 4\n3 4\n"}, {"input": "4", "output": "4\n1 2\n1 3\n2 4\n3 4\n"}, {"input": "3", "output": "2\n1 3\n2 3"}, {"input": "000", "output": "0\n"}, {"input": "001", "output": "0\n"}, {"input": "001", "output": "0\n"}, {"input": "000", "output": "0\n"}, {"input": "0", "output": "0\n"},...
code_stdio
[ { "content": "There are $n$ students numerated from $1$ to $n$. The level of the $i$-th student is $a_i$. You need to split the students into stable groups. A group of students is called stable, if in the sorted array of their levels no two neighboring elements differ by more than $x$.\n\nFor example, if $x = 4...
[{"input": "96 15 21\n76 26 108 220 384 4 170 198 568 571 2 193 244 359 78 133 107 340 110 135 565 341 109 572 243 138 357 52 293 344 595 105 569 362 639 134 82 356 27 137 194 291 499 104 28 290 197 477 339 50 288 289 160 54 358 640 343 542 566 79 136 385 3 641 195 355 361 169 196 429 242 162 338 80 77 161 81 337 132 5...
code_stdio
[ { "content": "You have a tree of $n$ vertices. You are going to convert this tree into $n$ rubber bands on infinitely large plane. Conversion rule follows:\n\nFor every pair of vertices $a$ and $b$, rubber bands $a$ and $b$ should intersect if and only if there is an edge exists between $a$ and $b$ in the tree....
[{"input": "28\n2 24\n2 4\n2 3\n1 2\n1 17\n1 21\n1 22\n10 22\n22 23\n22 26\n25 26\n16 25\n7 26\n5 7\n5 8\n5 15\n5 14\n5 12\n10 20\n11 4\n9 25\n6 9\n12 19\n9 28\n13 14\n18 28\n27 28\n", "output": "13\n"}, {"input": "28\n2 24\n2 4\n2 3\n1 2\n1 17\n1 21\n1 22\n10 22\n22 23\n22 26\n25 26\n16 25\n7 26\n5 7\n5 8\n5 15\n5 14\...
code_stdio
[ { "content": "A + B is often used as an example of the easiest problem possible to show some contest platform. However, some scientists have observed that sometimes this problem is not so easy to get accepted. Want to try?\n\n\n-----Input-----\n\nThe input contains two integers a and b (0 ≤ a, b ≤ 10^3), separa...
[{"input": "1094 350\n", "output": "1444\n"}, {"input": "1132 485\n", "output": "1617\n"}, {"input": "1062 519\n", "output": "1581\n"}, {"input": "260 1041\n", "output": "1301\n"}, {"input": "1132 306\n", "output": "1438\n"}, {"input": "1267 243\n", "output": "1510\n"}, {"input": "1062 931\n", "output": "1993\n"}, {"in...
code_stdio
[ { "content": "_A mad sociopath scientist just came out with a brilliant invention! He extracted his own memories to forget all the people he hates! Now there's a lot of information in there, so he needs your talent as a developer to automatize that task for him._\n\n> You are given the memories as a string cont...
[{"input": "\"Albert Einstein, !Sarah Connor, Marilyn Monroe, Abraham Lincoln, Sarah Connor, Sean Connery, Marilyn Monroe, Bjarne Stroustrup, Manson Marilyn, Monroe Mary\"", "output": "[\"Albert Einstein, Abraham Lincoln, Sean Connery, Bjarne Stroustrup, Manson Marilyn, Monroe Mary\"]", "fn_name": "select"}, {"input": ...
code_functional
[ { "content": "You play a computer game. Your character stands on some level of a multilevel ice cave. In order to move on forward, you need to descend one level lower and the only way to do this is to fall through the ice.\n\nThe level of the cave where you are is a rectangular square grid of n rows and m colum...
[{"input": "21 21\n.....X...X.........X.\n...X...XX......X.....\n..X........X.X...XX..\n.........X....X...X..\nX...X...........XX...\n...X...X....XX...XXX.\n.X............X......\n......X.X............\n.X...X.........X.X...\n......XX......X.X....\n....X.......X.XXX....\n.X.......X..XXX.X..X.\n..X........X....X...X\n.....
code_stdio
[ { "content": "Lucy loves to travel. Luckily she is a renowned computer scientist and gets to travel to international conferences using her department's budget.\n\nEach year, Society for Exciting Computer Science Research (SECSR) organizes several conferences around the world. Lucy always picks one conference fr...
[{"input": "[\"Mexico City\", \"Dubai\", \"Philadelphia\", \"Madrid\", \"Houston\", \"Chicago\", \"Delhi\", \"Seoul\", \"Mumbai\", \"Lisbon\", \"Hong Kong\", \"Brisbane\", \"Stockholm\", \"Tokyo\", \"San Francisco\", \"Rio De Janeiro\"]\n[\"Lisbon\", \"Mexico City\"]", "output": "[\"No worthwhile conferences this year!...
code_functional
[ { "content": "Read problems statements in Mandarin Chinese and Russian. \n\nN one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line.\nA kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L \n≤ x ≤ R.\n\nYour tas...
[{"input": "1\n3\n1 4\n-1 14\n12 12", "output": "2\n"}, {"input": "1\n3\n0 4\n-1 14\n12 12", "output": "2\n"}, {"input": "1\n3\n0 3\n-2 12\n12 19", "output": "2\n"}, {"input": "1\n3\n0 4\n-1 14\n12 22", "output": "2\n"}, {"input": "1\n3\n1 3\n-1 10\n23 13", "output": "2\n"}, {"input": "1\n3\n0 4\n-1 14\n12 16", "output...
code_stdio
[ { "content": "You are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a mirror string.\n\nHere, a mirror string is a string S such that the following sequence of operations on S results in the same string S:\n\n1. Reverse the order of the characters in S.\n\n2. Replace each ...
[{"input": "qbdp", "output": "Yes\n"}, {"input": "dqpb", "output": "Yes\n"}, {"input": "dpqb", "output": "Yes\n"}, {"input": "bpqd", "output": "Yes\n"}, {"input": "bqpd", "output": "Yes\n"}, {"input": "pbdq", "output": "Yes\n"}, {"input": "qdbp", "output": "Yes\n"}, {"input": "dbqp", "output": "No\n"}, {"input": "bdqp"...
code_stdio
[ { "content": "The USA Construction Operation (USACO) recently ordered Farmer John to arrange a row of $n$ haybale piles on the farm. The $i$-th pile contains $a_i$ haybales. \n\nHowever, Farmer John has just left for vacation, leaving Bessie all on her own. Every day, Bessie the naughty cow can choose to move o...
[{"input": "3\n4 4\n0 0 2 2\n2 1\n100 2\n1 14\n0\n", "output": "2\n101\n0\n"}, {"input": "3\n4 5\n0 0 0 2\n2 2\n110 2\n1 14\n0\n", "output": "1\n112\n0\n"}, {"input": "3\n4 4\n0 0 2 2\n2 1\n100 4\n1 23\n1\n", "output": "2\n101\n1\n"}, {"input": "3\n4 5\n1 0 0 4\n2 1\n110 2\n1 14\n1\n", "output": "2\n111\n1\n"}, {"input...
code_stdio
[ { "content": "Amr bought a new video game \"Guess Your Way Out! II\". The goal of the game is to find an exit from the maze that looks like a perfect binary tree of height h. The player is initially standing at the root of the tree and the exit from the tree is located at some leaf node.\n\nLet's index all the ...
[{"input": "4 3\n4 10 14 1\n3 7 6 0\n2 3 3 1\n", "output": "Data not sufficient!\n"}, {"input": "4 3\n4 10 26 1\n3 7 6 0\n2 3 3 1\n", "output": "Data not sufficient!\n"}, {"input": "4 3\n4 10 23 1\n3 7 6 0\n2 3 3 1\n", "output": "Data not sufficient!\n"}, {"input": "8 3\n4 10 14 1\n3 7 6 0\n2 3 3 1\n", "output": "Data ...
code_stdio
[ { "content": "There are N positive integers A_1, A_2, ..., A_N. Takahashi can perform the following operation on these integers any number of times:\n\n* Choose 1 \\leq i \\leq N and multiply the value of A_i by -2.\n\n\n\nNotice that he multiplies it by minus two.\n\nHe would like to make A_1 \\leq A_2 \\leq ....
[{"input": "8\n657312726 129662684 181537270 131300599 468214806 916875077 825989291 319670097", "output": "11\n"}, {"input": "8\n67210447 129662684 189766490 160785725 468214806 1492516422 483353884 319670097", "output": "15\n"}, {"input": "8\n347554626 129662684 181537270 324043958 468214806 916875077 825989291 31967...
code_stdio
[ { "content": "Snuke has an integer sequence A of length N.\n\nHe will make three cuts in A and divide it into four (non-empty) contiguous subsequences B, C, D and E. The positions of the cuts can be freely chosen.\n\nLet P,Q,R,S be the sums of the elements in B,C,D,E, respectively. Snuke is happier when the abs...
[{"input": "10\n10 102 113 60 6 47 23 25 52 118", "output": "58\n"}, {"input": "10\n10 102 113 60 6 90 16 25 52 118", "output": "61\n"}, {"input": "10\n10 102 113 72 6 90 16 25 52 118", "output": "73\n"}, {"input": "10\n10 102 113 72 6 90 16 25 89 118", "output": "95\n"}, {"input": "10\n19 183 113 60 6 194 16 6 52 118"...
code_stdio
[ { "content": "Vasya has an array a_1, a_2, ..., a_n.\n\nYou don't know this array, but he told you m facts about this array. The i-th fact is a triple of numbers t_i, l_i and r_i (0 ≤ t_i ≤ 1, 1 ≤ l_i < r_i ≤ n) and it means:\n\n * if t_i=1 then subbarray a_{l_i}, a_{l_i + 1}, ..., a_{r_i} is sorted in non-dec...
[{"input": "1001 2\n1 999 1000\n0 230 581\n", "output": "YES\n1001 1000 999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 ...
code_stdio
[ { "content": "In April 2008, Aizuwakamatsu City succeeded in making yakitori with a length of 20 m 85 cm. The chicken used at this time is Aizu local chicken, which is a specialty of Aizu. Aizu local chicken is very delicious, but it is difficult to breed, so the production volume is small and the price is high...
[{"input": "17 5128 240 126 32\n20 4907 303 151 7\n60 73980 2086 337 15\n3 3216 562 010 6\n40 8478 221 53 307\n23 27966 5 92 13\n50 107893 4497 65 20\n199 88677 2825 226 8\n0", "output": "21 0\n7 18\n15 126\n5 40\n37 5\n13 303\n20 276\n8 292\n"}, {"input": "49 5128 240 252 32\n20 4907 303 151 7\n60 73980 2086 337 15\n3...
code_stdio
[ { "content": "This problem is same as the previous one, but has larger constraints.\n\nShiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.\n\nFor each of the $n$ days sin...
[{"input": "10\n30518 30518 30518 30518 30518 30518 30518 30518 30518 30518\n", "output": "10\n"}, {"input": "10\n30518 30518 30518 30518 30518 30518 30518 30518 30518 30518\n", "output": "10"}, {"input": "10\n30518 96518 74071 59971 50121 4862 43967 73607 19138 90754\n", "output": "10\n"}, {"input": "10\n30518 96518 7...
code_stdio
[ { "content": "Your task is to create function```isDivideBy``` (or ```is_divide_by```) to check if an integer number is divisible by each out of two arguments.\n\nA few cases:\n\n```\n\n(-12, 2, -6) -> true\n(-12, 2, -5) -> false\n\n(45, 1, 6) -> false\n(45, 5, 15) -> true\n\n(4, 1, 4) -> true\n(...
[{"input": "-100\n-25\n10", "output": "[true]", "fn_name": "is_divide_by"}, {"input": "10000\n5\n-3", "output": "[false]", "fn_name": "is_divide_by"}, {"input": "-96\n25\n17", "output": "[false]", "fn_name": "is_divide_by"}, {"input": "48\n2\n-5", "output": "[false]", "fn_name": "is_divide_by"}, {"input": "12\n-3\n4", ...
code_functional
[ { "content": "Vova is playing a computer game. There are in total $n$ turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of the game) is $k$.\n\nDuring each turn Vova can choose what to do: If the current charge of his laptop...
[{"input": "20\n1000000001 510000100 2 1\n1000000000 500000000 2 1\n1000000000 500000000 2 1\n1000000000 500000000 2 1\n1000000000 500000000 2 1\n1000000000 684100035 2 1\n1000000100 500000000 2 1\n1000000000 690764083 2 1\n1000000000 500000000 2 1\n1000000000 167868648 2 1\n1000000001 999999995 2 1\n1000000000 2618165...
code_stdio
[ { "content": "AtCoDeer the deer is seeing a quick report of election results on TV.\nTwo candidates are standing for the election: Takahashi and Aoki.\nThe report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes.\nAtCoDeer has checked the repo...
[{"input": "5\n3 10\n48 17\n31 199\n231 23\n3 2\n", "output": "6930\n"}, {"input": "5\n3 10\n48 28\n31 199\n300 23\n3 4", "output": "12600\n"}, {"input": "5\n3 11\n87 28\n31 199\n300 23\n3 2", "output": "13000\n"}, {"input": "5\n3 11\n33 28\n31 269\n300 23\n3 2", "output": "12000\n"}, {"input": "5\n1 10\n48 28\n31 199\...
code_stdio
[ { "content": "Welcome to Codeforces Stock Exchange! We're pretty limited now as we currently allow trading on one stock, Codeforces Ltd. We hope you'll still be able to make profit from the market!\n\nIn the morning, there are $n$ opportunities to buy shares. The $i$-th of them allows to buy as many shares as y...
[{"input": "29 30 989\n450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 450 434\n451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451\n", "output": "1023\n"}, {"input": "29 30 989\n450 450 450 4...
code_stdio
[ { "content": "Arya has n opponents in the school. Each day he will fight with all opponents who are present this day. His opponents have some fighting plan that guarantees they will win, but implementing this plan requires presence of them all. That means if one day at least one of Arya's opponents is absent at...
[{"input": "1 100\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n"...
code_stdio
[ { "content": "You are given a sequence of positive integers a_1, a_2, ..., a_{n}. \n\nWhile possible, you perform the following operation: find a pair of equal consecutive elements. If there are more than one such pair, find the leftmost (with the smallest indices of elements). If the two integers are equal to ...
[{"input": "4\n1101111010 1000000000 1000010000 1001001010\n", "output": "4\n1101111010 1000000000 1000010000 1001001010\n"}, {"input": "4\n1101111010 1000000000 1100010000 1001001010\n", "output": "4\n1101111010 1000000000 1100010000 1001001010\n"}, {"input": "4\n1101111010 1000000000 1100000000 1001001010\n", "output...
code_stdio
[ { "content": "Let us define the FizzBuzz sequence a_1,a_2,... as follows:\n - If both 3 and 5 divides i, a_i=\\mbox{FizzBuzz}.\n - If the above does not hold but 3 divides i, a_i=\\mbox{Fizz}.\n - If none of the above holds but 5 divides i, a_i=\\mbox{Buzz}.\n - If none of the above holds, a_i=i.\nFind the sum ...
[{"input": "1000000\n", "output": "266666333332\n"}, {"input": "999997\n", "output": "266665333334\n"}, {"input": "870108\n", "output": "201890463153\n"}, {"input": "1100000", "output": "322667033332\n"}, {"input": "1110000", "output": "328560000000\n"}, {"input": "1110010", "output": "328565550022\n"}, {"input": "1111...
code_stdio
[ { "content": "Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Petya didn't like it at once. He decided to choose exactly one element from the array and replace it with an...
[{"input": "25\n1 1 1 2 2 2 1 2 1 2 2 2 2 2 1 2 2 2 1 2 2 2 2 1 2\n", "output": "1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n"}, {"input": "25\n1 1 1 2 2 2 1 2 1 2 4 2 2 2 1 2 2 2 1 2 2 2 2 1 2\n", "output": "1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n"}, {"input": "25\n2 1 1 2 2 2 1 2 1 2 2 2 2 2 1 2 2 ...
code_stdio
[ { "content": "One of the first algorithm used for approximating the integer square root of a positive integer `n` is known as \"Hero's method\", \nnamed after the first-century Greek mathematician Hero of Alexandria who gave the first description\nof the method. Hero's method can be obtained from Newton's metho...
[{"input": "9094947017729282379150390625\n1", "output": "[52]", "fn_name": "int_rac"}, {"input": "125348981764\n356243", "output": "[3]", "fn_name": "int_rac"}, {"input": "835871232077058\n1", "output": "[30]", "fn_name": "int_rac"}, {"input": "246391990316004\n1", "output": "[29]", "fn_name": "int_rac"}, {"input": "40...
code_functional
[ { "content": "A positive integer X is said to be a lunlun number if and only if the following condition is satisfied:\n - In the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1.\nFor example, 1234, 1, and 334 are l...
[{"input": "100000\n", "output": "3234566667\n"}, {"input": "94598\n", "output": "2345654334\n"}, {"input": "91278\n", "output": "2332345676\n"}, {"input": "97979\n", "output": "3223456555\n"}, {"input": "94981\n", "output": "3210111111\n"}, {"input": "96910\n", "output": "3222212323\n"}, {"input": "32454\n", "output":...
code_stdio
[ { "content": "Write a program which reads a $n \\times m$ matrix $A$ and a $m \\times l$ matrix $B$, and prints their product, a $n \\times l$ matrix $C$. An element of matrix $C$ is obtained by the following formula:\n\n\\\\[ c_{ij} = \\sum_{k=1}^m a_{ik}b_{kj} \\\\]\n\nwhere $a_{ij}$, $b_{ij}$ and $c_{ij}$ ar...
[{"input": "4 0 13\n1 1\n2 4\n4 15\n-1 0 2\n1 5 2", "output": "0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0\n"}, {"input": "4 0 12\n1 1\n-1 2\n4 1\n1 0 -1\n1 12 5", "output": "0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0...
code_stdio
[ { "content": "There is a set of cards with positive integers written on them. Stack the cards to make several piles and arrange them side by side. Select two adjacent piles of cards from them, and stack the left pile on top of the right pile. Repeat this operation until there is only one pile of cards.\n\nWhen ...
[{"input": "3\n2 21\n0 48\n-1 12", "output": "-1152\n"}, {"input": "3\n4 21\n0 48\n-1 12", "output": "-2304\n"}, {"input": "3\n4 21\n0 28\n-1 12", "output": "-1344\n"}, {"input": "3\n6 93\n1 -14\n1 -1", "output": "-7728\n"}, {"input": "3\n2 4\n-1 -12\n27 2", "output": "-1200\n"}, {"input": "3\n2 4\n-1 -12\n27 4", "outp...
code_stdio
[ { "content": "There are N islands lining up from west to east, connected by N-1 bridges.\nThe i-th bridge connects the i-th island from the west and the (i+1)-th island from the west.\nOne day, disputes took place between some islands, and there were M requests from the inhabitants of the islands:\nRequest i: A...
[{"input": "21189 4345\n10171 15645\n10849 16732\n6014 18169\n3995 20232\n1557 8296\n2238 15717\n10071 12875\n2148 13213\n14696 19948\n2063 14524\n7571 10285\n2102 14395\n12673 13427\n15751 16347\n317 13928\n9825 17447\n7990 9393\n8479 14766\n6185 6858\n2781 11064\n14909 16382\n8468 9916\n7189 12428\n16941 18034\n8365 ...
code_stdio
[ { "content": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6\n\nWrite Python code to solve this problem. Your prog...
[{"input": "64\n", "output": "267\n"}, {"input": "16\n", "output": "14\n"}, {"input": "24\n", "output": "15\n"}, {"input": "32\n", "output": "51\n"}, {"input": "36\n", "output": "14\n"}, {"input": "40\n", "output": "14\n"}, {"input": "48\n", "output": "52\n"}, {"input": "54\n", "output": "15\n"}, {"input": "56\n", "out...
code_stdio
[ { "content": "Well, those numbers were right and we're going to feed their ego.\n\nWrite a function, isNarcissistic, that takes in any amount of numbers and returns true if all the numbers are narcissistic. Return false for invalid arguments (numbers passed in as strings are ok).\n\nFor more information about n...
[{"input": "0\n1\n2\n3\n4\n5\n6\n7\n22\n9", "output": "[false]", "fn_name": "is_narcissistic"}, {"input": "0\n1\n2\n3\n4\n5\n6\n7\n8\n9", "output": "[true]", "fn_name": "is_narcissistic"}, {"input": "\"4\"\n7\n\"9\"", "output": "[true]", "fn_name": "is_narcissistic"}, {"input": "5\n\"\"\n407", "output": "[false]", "fn_...
code_functional
[ { "content": "Grandma Capa has decided to knit a scarf and asked Grandpa Sher to make a pattern for it, a pattern is a string consisting of lowercase English letters. Grandpa Sher wrote a string $s$ of length $n$.\n\nGrandma Capa wants to knit a beautiful scarf, and in her opinion, a beautiful scarf can only be...
[{"input": "5\n8\nabbaacab\n6\nxyzwyz\n4\nabba\n8\nspaqrlap\n10\nykhyhhyyhl\n", "output": "-1\n-1\n0\n-1\n-1\n"}, {"input": "5\n8\nabcaacbb\n6\nxyzxyz\n4\nabca\n8\nrpqarlap\n10\nykhxhhyyhk\n", "output": "-1\n-1\n1\n-1\n-1\n"}, {"input": "5\n8\nabbaacab\n6\nxyzwyz\n4\nbcaa\n8\nrpqarlap\n10\nykhyhhyyhk\n", "output": "-1\...
code_stdio
[ { "content": "Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nOne day Petya dreamt of a lexicographically k-th permutation of integers fro...
[{"input": "1000000000 1000000000\n", "output": "1022\n"}, {"input": "1000010000 1000000000\n", "output": "1022\n"}, {"input": "77777779 1000000000\n", "output": "508\n"}, {"input": "444747744 1000000000\n", "output": "554"}, {"input": "77777779 1000000001\n", "output": "508\n"}, {"input": "854459 95554455\n", "output"...
code_stdio
[ { "content": "Late last night in the Tanner household, ALF was repairing his spaceship so he might get back to Melmac. Unfortunately for him, he forgot to put on the parking brake, and the spaceship took off during repair. Now it's hovering in space.\n\nALF has the technology to bring the spaceship home if he c...
[{"input": "\"..........\\n..........\\n.......X..\\n..........\\n..........\"", "output": "[[7, 2]]", "fn_name": "find_spaceship"}, {"input": "\"..........\\n..........\\n..........\\n........X.\\n..........\"", "output": "[[8, 1]]", "fn_name": "find_spaceship"}, {"input": "\"........................\"", "output": "[\...
code_functional
[ { "content": "# Task\n\nChristmas is coming. In the [previous kata](https://www.codewars.com/kata/5a405ba4e1ce0e1d7800012e), we build a custom Christmas tree with the specified characters and the specified height.\n\nNow, we are interested in the center of the Christmas tree. \n\nPlease imagine that we build a ...
[{"input": "\"dbdbebedbddbedededeeddbbdeddbeddeebdeddeebbbb\"", "output": "[\"deededebddeebeddeddeddbddeddeddebeeddbededeed\"]", "fn_name": "center_of"}, {"input": "\"vttussvutvuvvtustsvsvtvu\"", "output": "[\"vsvvtvvtvvsv\"]", "fn_name": "center_of"}, {"input": "\"aaaaaaaaaaaaaa\"", "output": "[\"a\"]", "fn_name": "ce...
code_functional
[ { "content": "A burglar got into a matches warehouse and wants to steal as many matches as possible. In the warehouse there are m containers, in the i-th container there are ai matchboxes, and each matchbox contains bi matches. All the matchboxes are of the same size. The burglar's rucksack can hold n matchboxe...
[{"input": "200000000 20\n983125 2\n7453215 9\n9193588 2\n11558049 7\n28666199 1\n34362244 1\n5241493 5\n15451270 4\n19945845 8\n6208681 3\n38300385 7\n6441209 8\n21046742 7\n577198 10\n3826434 8\n9764276 8\n6264675 7\n8567063 3\n3610303 4\n2908232 3\n", "output": "1131379312\n"}, {"input": "200000000 20\n983125 2\n745...
code_stdio
[ { "content": "Vasya became interested in bioinformatics. He's going to write an article about similar cyclic DNA sequences, so he invented a new method for determining the similarity of cyclic sequences.\n\nLet's assume that strings s and t have the same length n, then the function h(s, t) is defined as the num...
[{"input": "318\nTATCAATCGGTACGTGCGCATCATTGTCAATCGGGCTTCATGGCTTGCGGGCGCTACCCGAGGGGAAGCTGCGGACAGGTAGGTAAGATACACACGAACCAAACGGAGTTATGTTGGATAAATTGGCTGGAAGGGCGTAGGTATATCGAGTCGCGGACCTGGCATAGACTATCAGGGGCAGCGGTACAAGGCAACCGTGAGCGGGGTCTGCCCACCATTAGACCGATGCGCCGGCTCGTATATGTGATTCTGGTGAAAAGTATCATGCCGGGACGCGTAATGACCCGGCTGGCTAATCCACCG...
code_stdio