messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "# Task\nJohn was in math class and got bored, so he decided to fold some origami from a rectangular `a × b` sheet of paper (`a > b`). His first step is to make a square piece of paper from the initial rectangular piece of paper by folding the sheet along the bisector of the right angle and cutting... | [{"input": "1000\n999", "output": "[1000]", "fn_name": "folding"}, {"input": "1000\n700", "output": "[6]", "fn_name": "folding"}, {"input": "10\n7", "output": "[6]", "fn_name": "folding"}, {"input": "2\n1", "output": "[2]", "fn_name": "folding"}, {"input": "3\n1", "output": "[3]", "fn_name": "folding"}, {"input": "4\n1... | code_functional |
[
{
"content": "You are given a string S consisting of a,b and c. Find the number of strings that can be possibly obtained by repeatedly performing the following operation zero or more times, modulo 998244353:\n - Choose an integer i such that 1\\leq i\\leq |S|-1 and the i-th and (i+1)-th characters in S are diff... | [{"input": "ababacbcacbacacbcbbcbbacbaccacbacbacba\n", "output": "148010497\n"}, {"input": "ababacbcacbacacbcbbcbbbcbaccacbacbacba", "output": "148010497\n"}, {"input": "abcabcabcaccabcbbbcbbcbcacabcacbcababa", "output": "148010497\n"}, {"input": "abcabcabcaccabcbbacbbcbcacabcacbcababa", "output": "148010497\n"}, {"inp... | code_stdio |
[
{
"content": "problem\n\nGiven the sequence $ A $ of length $ N $. The $ i $ item in $ A $ is $ A_i $. You can do the following for this sequence:\n\n* $ 1 \\ leq i \\ leq N --Choose the integer i that is 1 $. Swap the value of $ A_i $ with the value of $ A_ {i + 1} $.\n\n\n\nFind the minimum number of operatio... | [{"input": "5\n2 10 5 22 4", "output": "0\n"}, {"input": "5\n1 6 7 31 10", "output": "1\n"}, {"input": "5\n1 8 7 31 12", "output": "0\n"}, {"input": "5\n2 10 5 22 8", "output": "0\n"}, {"input": "5\n2 6 12 86 3", "output": "1\n"}, {"input": "5\n2 3 7 105 7", "output": "1\n"}, {"input": "5\n0 4 3 13 4", "output": "0\n"}... | code_stdio |
[
{
"content": "Given a string of integers, return the number of odd-numbered substrings that can be formed. \n\nFor example, in the case of `\"1341\"`, they are `1, 1, 3, 13, 41, 341, 1341`, a total of `7` numbers. \n\n`solve(\"1341\") = 7`. See test cases for more examples.\n\nGood luck!\n\nIf you like substri... | [{"input": "\"13472315\"", "output": "[28]", "fn_name": "solve"}, {"input": "\"1347231\"", "output": "[20]", "fn_name": "solve"}, {"input": "\"134721\"", "output": "[13]", "fn_name": "solve"}, {"input": "\"13471\"", "output": "[12]", "fn_name": "solve"}, {"input": "\"1357\"", "output": "[10]", "fn_name": "solve"}, {"in... | code_functional |
[
{
"content": "Amr doesn't like Maths as he finds it really boring, so he usually sleeps in Maths lectures. But one day the teacher suspected that Amr is sleeping and asked him a question to make sure he wasn't.\n\nFirst he gave Amr two positive integers n and k. Then he asked Amr, how many integer numbers x > 0... | [{"input": "1000 100 777767777\n", "output": "577920877\n"}, {"input": "1000 100 777767777\n", "output": "577920877"}, {"input": "886 10 902171654\n", "output": "134375492\n"}, {"input": "712 53 592302770\n", "output": "147693148\n"}, {"input": "393 71 933802677\n", "output": "366541352\n"}, {"input": "312 41 915197716... | code_stdio |
[
{
"content": "There is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are N ants. These ants are numbered 1 through N in order of increasing coordinate... | [{"input": "4 20 18\n7 2\n9 1\n12 1\n18 1", "output": "10\n16\n7\n9\n"}, {"input": "4 20 18\n3 2\n9 1\n12 1\n18 1", "output": "10\n16\n5\n7\n"}, {"input": "4 20 18\n3 2\n9 1\n12 1\n18 2", "output": "5\n7\n10\n0\n"}, {"input": "4 20 0\n3 2\n9 1\n12 1\n18 2", "output": "3\n9\n12\n18\n"}, {"input": "4 20 9\n7 2\n9 1\n12 1... | code_stdio |
[
{
"content": "There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the following process is repeated: the boy and girl who stand ne... | [{"input": "10\nBGGBBGBGBG\n5445902 3514007 10377301 5241945 14514470 2911201 2983644 2891569 1596021 8471969\n", "output": "5\n6 7\n8 9\n1 2\n3 4\n5 10\n"}, {"input": "10\nBGGBBGBGBG\n5445902 3514007 10377301 5241945 14514470 1220159 2983644 2891569 1596021 8471969\n", "output": "5\n7 8\n6 9\n1 2\n3 4\n5 10\n"}, {"inp... | code_stdio |
[
{
"content": "You are given an undirected graph consisting of $n$ vertices. A number is written on each vertex; the number on vertex $i$ is $a_i$. Initially there are no edges in the graph.\n\nYou may add some edges to this graph, but you have to pay for them. The cost of adding an edge between vertices $x$ and... | [{"input": "10 10\n3 4 5 10 10 9 5 4 7 8\n1 5 5\n10 3 18\n1 7 20\n7 8 20\n10 4 8\n10 2 17\n9 4 2\n7 5 16\n1 8 17\n7 10 18\n", "output": "67\n"}, {"input": "10 10\n3 4 5 10 10 9 5 4 7 8\n1 5 5\n10 3 18\n1 7 20\n7 8 20\n10 4 8\n10 2 17\n9 4 2\n7 5 16\n1 8 17\n7 10 18\n", "output": "67\n"}, {"input": "2 1\n100000000000 10... | code_stdio |
[
{
"content": "Nathan O. Davis has been running an electronic bulletin board system named JAG-channel. He is now having hard time to add a new feature there --- threaded view.\n\nLike many other bulletin board systems, JAG-channel is thread-based. Here a thread (also called a topic) refers to a single conversati... | [{"input": "1\n0\nccpi", "output": "ccpi\n"}, {"input": "1\n0\nipcc", "output": "ipcc\n"}, {"input": "1\n0\njpcc", "output": "jpcc\n"}, {"input": "1\n0\ncbpi", "output": "cbpi\n"}, {"input": "1\n0\niocc", "output": "iocc\n"}, {"input": "1\n0\ncboi", "output": "cboi\n"}, {"input": "1\n0\ncdpi", "output": "cdpi\n"}, {"in... | code_stdio |
[
{
"content": "# Task\n A ciphertext alphabet is obtained from the plaintext alphabet by means of rearranging some characters. For example \"bacdef...xyz\" will be a simple ciphertext alphabet where a and b are rearranged.\n\n A substitution cipher is a method of encoding where each letter of the plaintext alpha... | [{"input": "\"jpeuizmi\"\n\"mxxcwriq\"", "output": "[false]", "fn_name": "is_substitution_cipher"}, {"input": "\"aaxxaaz\"\n\"aazzaay\"", "output": "[true]", "fn_name": "is_substitution_cipher"}, {"input": "\"aaxyaa\"\n\"aazzaa\"", "output": "[false]", "fn_name": "is_substitution_cipher"}, {"input": "\"aazzaa\"\n\"aaxy... | code_functional |
[
{
"content": "Let's call a sequence of integers $x_1, x_2, \\dots, x_k$ MEX-correct if for all $i$ ($1 \\le i \\le k$) $|x_i - \\operatorname{MEX}(x_1, x_2, \\dots, x_i)| \\le 1$ holds. Where $\\operatorname{MEX}(x_1, \\dots, x_k)$ is the minimum non-negative integer that doesn't belong to the set $x_1, \\dots,... | [{"input": "1\n30\n0 0 0 2 0 0 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n", "output": "998244352\n"}, {"input": "1\n30\n0 0 0 2 0 0 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n", "output": "998244352\n"}, {"input": "1\n30\n0 0 0 1 0 0 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n", "output": "587202561\... | code_stdio |
[
{
"content": "Given the string S and m queries. The i-th query is given by the two strings xi and yi.\n\nFor each query, answer the longest substring of the string S, starting with xi and ending with yi.\n\nFor the string S, | S | represents the length of S. Also, the fact that the character string T is a subst... | [{"input": "icpcsummertraining\n9\nmm n\nicpc summer\ntrain ing\nsummer mm\ni c\ni i\nh f\ntrain i\nsummer er", "output": "11\n10\n8\n0\n4\n16\n0\n6\n6\n"}, {"input": "icpcsummertraining\n9\nmm n\nicpc summer\nniart ing\nsummer mm\ni c\ni i\nh f\ntrain i\nsummer er", "output": "11\n10\n0\n0\n4\n16\n0\n6\n6\n"}, {"input... | code_stdio |
[
{
"content": "You are given a chess board with $n$ rows and $n$ columns. Initially all cells of the board are empty, and you have to put a white or a black knight into each cell of the board.\n\nA knight is a chess piece that can attack a piece in cell ($x_2$, $y_2$) from the cell ($x_1$, $y_1$) if one of the f... | [{"input": "104\n", "output": "WBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWB\nBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBW\nWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBW... | code_stdio |
[
{
"content": "Problem\n\nThere are N villages. Each village is numbered from 1 to N. Due to the recent merger boom, several villages have been merged. Two or more merged villages will become one new city, and villages that are not merged with any village will remain villages.\n\nYou will be given multiple piece... | [{"input": "20 5\n3 4\n1 2\n9 6\n2 6\n2 9", "output": "12\n"}, {"input": "27 5\n3 4\n1 2\n9 6\n2 6\n2 9", "output": "19\n"}, {"input": "10 5\n3 4\n1 2\n9 6\n3 6\n2 9", "output": "3\n"}, {"input": "10 5\n3 5\n1 2\n9 6\n2 6\n2 9", "output": "2\n"}, {"input": "10 5\n3 4\n1 4\n9 6\n3 6\n2 9", "output": "3\n"}, {"input": "1... | code_stdio |
[
{
"content": "Round any given number to the closest 0.5 step\n\nI.E.\n```\nsolution(4.2) = 4\nsolution(4.3) = 4.5\nsolution(4.6) = 4.5\nsolution(4.8) = 5\n```\n\nRound **up** if number is as close to previous and next 0.5 steps.\n\n```\nsolution(4.75) == 5\n```\n\nWrite Python code to solve this problem. Define... | [{"input": "4.74999999999", "output": "[4.5]", "fn_name": "solution"}, {"input": "4.74999999991", "output": "[4.5]", "fn_name": "solution"}, {"input": "4.25", "output": "[4.5]", "fn_name": "solution"}, {"input": "4.55", "output": "[4.5]", "fn_name": "solution"}, {"input": "4.74", "output": "[4.5]", "fn_name": "solution... | code_functional |
[
{
"content": "You are given an integer m.\n\nLet M = 2^{m} - 1.\n\nYou are also given a set of n integers denoted as the set T. The integers will be provided in base 2 as n binary strings of length m.\n\nA set of integers S is called \"good\" if the following hold. If $a \\in S$, then [Image]. If $a, b \\in ... | [{"input": "30 10\n001000000011000111000010010000\n000001100001010000000000000100\n000110100010100000000000101000\n110000010000000001000000000000\n100001000000000010010101000101\n001001000000000100000000110000\n000000010000100000001000000000\n001000010001000000001000000010\n000000110000000001001010000000\n0000110010000... | code_stdio |
[
{
"content": "This is a simplified version of the problem B2. Perhaps you should read the problem B2 before you start solving B1.\n\nPaul and Mary have a favorite string $s$ which consists of lowercase letters of the Latin alphabet. They want to paint it using pieces of chalk of two colors: red and green. Let's... | [{"input": "61\nkzaaa\ncodeforces\narchive\ny\nxxxxxx\nkzaaa\ncodeforces\narchive\ny\nxxxxxx\nkzaaa\ncodeforces\narchive\ny\nxxxxxx\nkzaaa\ncodeforces\narchive\ny\nxxxxxx\nkzaaa\ncodeforces\narchive\ny\nxxxxxx\nkzaaa\ncodeforces\narchive\ny\nxxxxxx\nkzaaa\ncodeforces\narchive\ny\nxxxxxx\nkzaaa\ncodeforces\narchive\ny\n... | code_stdio |
[
{
"content": "You are playing the following game with Joisino.\n - Initially, you have a blank sheet of paper.\n - Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.\n - Then, you are asked... | [{"input": "6\n12\n22\n16\n22\n18\n12\n", "output": "2\n"}, {"input": "6\n12\n22\n18\n22\n18\n12", "output": "0\n"}, {"input": "6\n12\n22\n18\n35\n18\n12", "output": "2\n"}, {"input": "6\n12\n22\n28\n35\n18\n12", "output": "4\n"}, {"input": "6\n12\n35\n28\n35\n18\n12", "output": "2\n"}, {"input": "6\n10\n34\n63\n35\n19... | code_stdio |
[
{
"content": "You will be given a string. \n\nYou need to return an array of three strings by gradually pulling apart the string.\n\nYou should repeat the following steps until the string length is 1:\n\na) remove the final character from the original string, add to solution string 1.\nb) remove the first chara... | [{"input": "\"reusetestcasesbitcointakeovertheworldmaybewhoknowsperhaps\"", "output": "[[\"spahrepswonkohwebyamdlroweht\", \"reusetestcasesbitcointakeove\", \"r\"]]", "fn_name": "pop_shift"}, {"input": "\"turnsoutrandomtestcasesareeasierthanwritingoutbasicones\"", "output": "[[\"senocisabtuognitirwnahtreis\", \"turnsou... | code_functional |
[
{
"content": "Let us consider sets of positive integers less than or equal to n. Note that all elements of a set are different. Also note that the order of elements doesn't matter, that is, both {3, 5, 9} and {5, 9, 3} mean the same set.\n\nSpecifying the number of set elements and their sum to be k and s, resp... | [{"input": "9 3 23\n10 3 22\n10 3 28\n16 10 107\n26 8 102\n20 10 105\n24 10 155\n3 4 3\n4 2 11\n0 0 0", "output": "1\n5\n0\n20\n32200\n5448\n10222\n0\n0\n"}, {"input": "9 3 23\n9 3 22\n10 3 28\n16 10 107\n26 8 102\n20 10 105\n24 10 155\n3 4 3\n4 2 11\n0 0 0", "output": "1\n2\n0\n20\n32200\n5448\n10222\n0\n0\n"}, {"inpu... | code_stdio |
[
{
"content": "Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-n... | [{"input": "1000000000 -1000\n", "output": "14\n"}, {"input": "1000000000 -1000\n", "output": "14\n"}, {"input": "1000000010 -1000\n", "output": "15\n"}, {"input": "1010000000 -1000\n", "output": "15\n"}, {"input": "1000000000 1000\n", "output": "16\n"}, {"input": "1000000000 1000\n", "output": "16\n"}, {"input": "3326... | code_stdio |
[
{
"content": "Ivan is playing a strange game.\n\nHe has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:\n\n... | [{"input": "3 57 3\n1 0 0 1 1 0 1 1 0 0 0 0 1 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 1 0 1 1 1 1 0 1 1 1 0 0 0 1 1 0 0 1 0 0 0 1 1 0 0 1 0\n1 1 0 0 0 1 1 1 0 1 1 0 0 0 0 1 1 0 0 1 0 0 1 1 1 0 1 0 0 0 0 1 1 1 0 0 0 1 0 1 0 0 0 1 1 0 0 0 1 1 0 0 1 1 0 0 0\n1 0 1 0 0 1 1 0 1 0 0 0 1 0 1 0 1 0 1 1 1 1 0 1 0 0 0 1 1 1 1 0 1 1 1 ... | code_stdio |
[
{
"content": "There are N towns located in a line, conveniently numbered 1 through N. Takahashi the merchant is going on a travel from town 1 to town N, buying and selling apples.\nTakahashi will begin the travel at town 1, with no apple in his possession. The actions that can be performed during the travel are... | [{"input": "10 100\n7 10 4 5 9 3 6 8 2 1\n", "output": "2\n"}, {"input": "10 100\n7 10 4 5 9 3 6 8 1 1", "output": "2\n"}, {"input": "10 100\n7 10 4 5 9 3 6 8 2 1", "output": "2"}, {"input": "5 8\n50 30 40 10 20\n", "output": "2\n"}, {"input": "5 10\n21 30 40 10 20", "output": "1\n"}, {"input": "5 10\n21 30 40 10 31", ... | code_stdio |
[
{
"content": "Haruna is a high school student. She must remember the seating arrangements in her class because she is a class president. It is too difficult task to remember if there are so many students.\n\nThat is the reason why seating rearrangement is depress task for her. But students have a complaint if s... | [{"input": "1 2\n11 0\n0 0", "output": "yes\nyes\n"}, {"input": "2 1\n10 0\n0 0", "output": "yes\nyes\n"}, {"input": "1 4\n11 0\n0 0", "output": "yes\nyes\n"}, {"input": "2 -1\n8 0\n0 0", "output": "yes\nyes\n"}, {"input": "3 0\n4 -1\n0 0", "output": "yes\nyes\n"}, {"input": "2 2\n4 -1\n0 0", "output": "yes\nyes\n"}, {... | code_stdio |
[
{
"content": "Not long ago Billy came across such a problem, where there were given three natural numbers A, B and C from the range [1, N], and it was asked to check whether the equation AB = C is correct. Recently Billy studied the concept of a digital root of a number. We should remind you that a digital root... | [{"input": "1000000\n", "output": "111111074060178115\n"}, {"input": "987572\n", "output": "107019643962508968\n"}, {"input": "983242\n", "output": "105618162572849728\n"}, {"input": "600000\n", "output": "23999973325791164\n"}, {"input": "783472\n", "output": "53435215015075583\n"}, {"input": "729761\n", "output": "43... | code_stdio |
[
{
"content": "Fox Ciel starts to learn programming. The first task is drawing a fox! However, that turns out to be too hard for a beginner, so she decides to draw a snake instead.\n\nA snake is a pattern on a n by m table. Denote c-th cell of r-th row as (r, c). The tail of the snake is located at (1, 1), then ... | [{"input": "49 50\n", "output": "##################################################\n.................................................#\n##################################################\n#.................................................\n##################################################\n.............................. | code_stdio |
[
{
"content": "You can perfectly predict the price of a certain stock for the next N days. You would like to profit on this knowledge, but only want to transact one share of stock per day. That is, each day you will either buy one share, sell one share, or do nothing. Initially you own zero shares, and you canno... | [{"input": "100\n411 642 560 340 276 440 515 519 182 314 35 227 390 136 97 5 502 584 567 79 543 444 413 463 455 316 545 329 437 443 9 435 291 384 328 501 603 234 285 297 453 587 550 72 130 163 282 298 605 349 270 198 24 179 243 92 115 56 83 26 3 456 622 325 366 360 299 153 140 552 216 117 61 307 278 189 496 562 38 527 ... | code_stdio |
[
{
"content": "A monster is attacking the Cyberland!\n\nMaster Yang, a braver, is going to beat the monster. Yang and the monster each have 3 attributes: hitpoints (HP), offensive power (ATK) and defensive power (DEF).\n\nDuring the battle, every second the monster's HP decrease by max(0, ATK_{Y} - DEF_{M}), whi... | [{"input": "100 100 100\n100 100 100\n100 100 100\n", "output": "100\n"}, {"input": "100 100 100\n100 100 100\n100 100 100\n", "output": "100\n"}, {"input": "50 100 51\n100 100 100\n1 100 100\n", "output": "1384\n"}, {"input": "100 100 1\n100 100 100\n1 100 100\n", "output": "1891\n"}, {"input": "100 100 1\n100 100 100... | code_stdio |
[
{
"content": "Petya's friends made him a birthday present — a bracket sequence. Petya was quite disappointed with his gift, because he dreamed of correct bracket sequence, yet he told his friends nothing about his dreams and decided to fix present himself. \n\nTo make everything right, Petya is going to move at... | [{"input": "500\n())()())((()(()((())())(())())()((()(()()))())())))()())())())()())))(()))))((((())(((()(())))()()(()))())(((((()()(((())()((()((())()))()())()))))()))()(((()(())((()()((()())()))((((())(())))()(()(())((((((()()()())))((()())(((((()()(((()))((()((()))())(((())((((()))))))))()()()))(())(())()())((((((((... | code_stdio |
[
{
"content": "We will define the median of a sequence b of length M, as follows:\n - Let b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down.\nFor example, the median of (10, 30, 20) ... | [{"input": "10\n15 -1 6 0 -1 7 -1 19 1 3", "output": "3\n"}, {"input": "10\n15 -1 6 0 -1 7 -1 11 1 3", "output": "3\n"}, {"input": "10\n15 -1 6 1 -1 7 -1 11 1 3", "output": "3\n"}, {"input": "10\n15 -1 6 2 -1 7 -1 11 1 3", "output": "3\n"}, {"input": "10\n15 -1 6 4 -1 7 -1 11 1 3", "output": "4\n"}, {"input": "10\n15 -... | code_stdio |
[
{
"content": "Dawid has four bags of candies. The $i$-th of them contains $a_i$ candies. Also, Dawid has two friends. He wants to give each bag to one of his two friends. Is it possible to distribute the bags in such a way that each friend receives the same amount of candies in total?\n\nNote, that you can't ke... | [{"input": "100 100 100 100\n", "output": "YES\n"}, {"input": "100 100 100 100\n", "output": "YES\n"}, {"input": "100 100 000 100\n", "output": "NO\n"}, {"input": "100 100 99 100\n", "output": "NO\n"}, {"input": "100 100 99 100\n", "output": "NO\n"}, {"input": "100 000 99 100\n", "output": "NO\n"}, {"input": "100 98 99... | code_stdio |
[
{
"content": "An array of integers $p_1, p_2, \\dots, p_n$ is called a permutation if it contains each number from $1$ to $n$ exactly once. For example, the following arrays are permutations: $[3, 1, 2]$, $[1]$, $[1, 2, 3, 4, 5]$ and $[4, 3, 1, 2]$. The following arrays are not permutations: $[2]$, $[1, 1]$, $[... | [{"input": "5\n-1 2 -3 -1\n", "output": "4 3 5 2 1 "}, {"input": "5\n-1 2 -3 -1\n", "output": "4 3 5 2 1 "}, {"input": "5\n3 -2 1 -3\n", "output": "2 5 3 4 1 "}, {"input": "5\n-4 1 2 -1\n", "output": "5 1 2 4 3 "}, {"input": "5\n-4 1 2 -1\n", "output": "5 1 2 4 3 "}, {"input": "5\n3 -2 1 -3\n", "output": "2 5 3 4 1 "},... | code_stdio |
[
{
"content": "You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if th... | [{"input": "21 7\n3 6\n5 2\n......*\n.****.*\n.****.*\n....*.*\n**.**.*\n**.**.*\n**.**.*\n**.**.*\n**.**.*\n**.**.*\n**.**.*\n**.**.*\n**.**.*\n**.**.*\n**.**.*\n**.**.*\n**.**.*\n**.**.*\n**....*\n**....*\n*******\n", "output": "51\n"}, {"input": "21 7\n3 6\n5 2\n......*\n.****.*\n.****.*\n....*.*\n**.**.*\n**.**.*\n... | code_stdio |
[
{
"content": "User ainta has a permutation p_1, p_2, ..., p_{n}. As the New Year is coming, he wants to make his permutation as pretty as possible.\n\nPermutation a_1, a_2, ..., a_{n} is prettier than permutation b_1, b_2, ..., b_{n}, if and only if there exists an integer k (1 ≤ k ≤ n) where a_1 = b_1, a_2 = b... | [{"input": "15\n6 1 2 7 9 13 14 8 4 5 3 12 10 15 11\n000100100100100\n000010010010010\n000001001001001\n100000100100100\n010000010010010\n001000001001001\n100100000100100\n010010000010010\n001001000001001\n100100100000100\n010010010000010\n001001001000001\n100100100100000\n010010010010000\n001001001001000\n", "output":... | code_stdio |
[
{
"content": "You are given a string $s$ consisting of $n$ lowercase Latin letters. $n$ is even.\n\nFor each position $i$ ($1 \\le i \\le n$) in string $s$ you are required to change the letter on this position either to the previous letter in alphabetic order or to the next one (letters 'a' and 'z' have only o... | [{"input": "50\n6\nbxyxcz\n4\nzzcy\n2\nzb\n2\nyb\n6\nzzbxyx\n4\nbxzb\n4\naaca\n4\nbzyx\n4\nxaac\n2\nbb\n2\nzb\n6\ncabcbb\n6\nyxzbbb\n2\nxz\n2\ncc\n6\nazcaza\n4\nyyaa\n2\nxb\n2\nyb\n6\nzaxxxz\n4\nbyab\n4\naxxz\n2\nay\n2\nyb\n2\ncx\n4\nzyab\n6\nybcyya\n6\nxayzaz\n4\nzacx\n6\nzzyxbz\n2\ncc\n4\nbycx\n2\nza\n4\naaxz\n6\nczy... | code_stdio |
[
{
"content": "For the multiset of positive integers s=\\\\{s_1,s_2,...,s_k\\}, define the Greatest Common Divisor (GCD) and Least Common Multiple (LCM) of s as follow:\n\n * \\gcd(s) is the maximum positive integer x, such that all integers in s are divisible on x.\n * lcm(s) is the minimum positive integer x... | [{"input": "10\n972 972 324 972 324 648 1944 243 324 474\n", "output": "162\n"}, {"input": "10\n61 1677 535 769 324 1309 1589 243 324 184\n", "output": "1\n"}, {"input": "10\n61 1677 535 769 627 1309 1589 243 324 184\n", "output": "1\n"}, {"input": "10\n54 972 224 392 324 809 1589 243 324 1357\n", "output": "1\n"}, {"i... | code_stdio |
[
{
"content": "Natasha is going to fly to Mars. She needs to build a rocket, which consists of several stages in some order. Each of the stages is defined by a lowercase Latin letter. This way, the rocket can be described by the string — concatenation of letters, which correspond to the stages.\n\nThere are $n$ ... | [{"input": "50 13\nqwertyuiopasdfghjklzxcvbnmaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "169\n"}, {"input": "50 13\nqwertyuiopasdfghjklzxcvbnmaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "169"}, {"input": "50 31\nahbyyoxltryqdmvenemaqnbakglgqolxnaifnqtoclnnqiabpz\n", "output": "-1\n"}, {"input": "50 14\nqwertyuiopasdfghjklzxcvbn... | code_stdio |
[
{
"content": "We have a tree with N vertices and N-1 edges, respectively numbered 1, 2,\\cdots, N and 1, 2, \\cdots, N-1. Edge i connects Vertex u_i and v_i.\nFor integers L, R (1 \\leq L \\leq R \\leq N), let us define a function f(L, R) as follows:\n - Let S be the set of the vertices numbered L through R. f(... | [{"input": "10\n5 4\n5 7\n-1 13\n0 9\n12 10\n4 11\n7 4\n11 10\n7 4", "output": "152\n"}, {"input": "10\n5 16\n5 6\n-1 24\n1 10\n13 10\n4 6\n13 4\n6 3\n7 3", "output": "187\n"}, {"input": "10\n5 16\n5 6\n-1 24\n1 10\n13 10\n4 6\n13 4\n6 5\n7 3", "output": "177\n"}, {"input": "10\n1 16\n5 6\n-1 24\n1 10\n13 10\n4 6\n13 4... | code_stdio |
[
{
"content": "You've probably heard about the twelve labors of Heracles, but do you have any idea about the thirteenth? It is commonly assumed it took him a dozen years to complete the twelve feats, so on average, a year to accomplish every one of them. As time flows faster these days, you have minutes rather t... | [{"input": "4\n4\n3 5 4 5\n2 1\n3 1\n4 3\n2\n21 32\n2 1\n6\n13 13 17 13 13 22\n2 1\n3 1\n4 2\n5 1\n6 1\n4\n10 11 3 11\n1 2\n2 3\n4 1\n", "output": "17 21 24\n53\n91 104 117 130 143\n35 46 56\n"}, {"input": "4\n4\n3 5 4 12\n2 1\n3 1\n4 3\n2\n21 32\n2 1\n6\n13 13 17 13 13 22\n2 1\n3 1\n4 1\n5 1\n6 1\n4\n10 6 3 11\n1 2\n2... | code_stdio |
[
{
"content": "Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n - a < b + c\n - b <... | [{"input": "2000\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 10... | code_stdio |
[
{
"content": "A country decides to build a palace.\nIn this country, the average temperature of a point at an elevation of x meters is T-x \\times 0.006 degrees Celsius.\nThere are N places proposed for the place. The elevation of Place i is H_i meters.\nAmong them, Princess Joisino orders you to select the pla... | [{"input": "1000\n20 -20\n51765 34765 54644 24887 70030 45034 46376 88410 33772 52941 79750 44783 70874 36236 36651 16147 23251 11281 36605 69084 74679 18310 88655 92253 0 76064 82769 20419 60361 61197 51619 35110 6063 82815 99426 22379 61759 34008 31814 22642 80907 10203 11864 18291 34343 35250 99120 14402 54252 92425... | code_stdio |
[
{
"content": "One day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together. \n\nSimply speaking, the process of taking photos can be described as follows. On the photo, each photographed friend occupies a rectangle of pixels: the i-th of them o... | [{"input": "10\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n", "output": "90000 90000 90000 90000 90000 90000 90000 90000 90000 90000 "}, {"input": "10\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n10 1000\n", "output": "90000 90000 90000... | code_stdio |
[
{
"content": "Kattapa, as you all know was one of the greatest warriors of his time. The kingdom of Maahishmati had never lost a battle under him (as army-chief), and the reason for that was their really powerful army, also called as Mahasena.\n\nKattapa was known to be a very superstitious person. He believed ... | [{"input": "5\n12 -1 -2 -2 -2", "output": "READY FOR BATTLE\n"}, {"input": "5\n2 -1 -2 -2 -2", "output": "READY FOR BATTLE\n"}, {"input": "5\n2 -1 -1 -2 -2", "output": "READY FOR BATTLE\n"}, {"input": "5\n4 -1 -1 -2 -2", "output": "READY FOR BATTLE\n"}, {"input": "5\n4 -1 -2 -2 -2", "output": "READY FOR BATTLE\n"}, {"i... | code_stdio |
[
{
"content": "You have r red, g green and b blue balloons. To decorate a single table for the banquet you need exactly three balloons. Three balloons attached to some table shouldn't have the same color. What maximum number t of tables can be decorated if we know number of balloons of each color?\n\nYour task i... | [{"input": "1000000000 1000000000 1000000000\n", "output": "1000000000\n"}, {"input": "1000000000 2000000000 1000000000\n", "output": "1333333333\n"}, {"input": "2000000000 2000000000 2000000000\n", "output": "2000000000\n"}, {"input": "1585222789 1889821127 2000000000\n", "output": "1825014638\n"}, {"input": "20000000... | code_stdio |
[
{
"content": "There is a board with a grid consisting of n rows and m columns, the rows are numbered from 1 from top to bottom and the columns are numbered from 1 from left to right. In this grid we will denote the cell that lies on row number i and column number j as (i, j).\n\nA group of six numbers (a, b, c,... | [{"input": "500 500 249995\n", "output": " 0\n"}, {"input": "500 500 249999\n", "output": " 0\n"}, {"input": "500 500 249993\n", "output": " ... | code_stdio |
[
{
"content": "You are given two strings A and B representing essays of two students who are suspected cheaters. For any two strings C, D we define their similarity score S(C,D) as 4⋅ LCS(C,D) - |C| - |D|, where LCS(C,D) denotes the length of the Longest Common Subsequence of strings C and D. \n\nYou believe tha... | [{"input": "175 190\nqnnnnnnnnnnrnnnnrnrnnnnnrnnnnrqnnnnnnannnnnnnrnrrnrnnnnnrnnrnnnnnnrnrnnnnnrnnnannnrrnnnnrnnnnnnnnnnnrnannnnnrnnnnrnnnnrnnnnnnrnarnnnnnnnnanrnnnnnnnrnnrrnrnrrnnnnnrnnnnnrnnnnnn\nnnnnnrnnnnrnnnnnrnnnnnnrnnqnnnnnnrnnnnnnnrnnrnnnnrnqnannnnnnnannnnnnnrnrnnnrnnnnrnnnnnnnrrnqnnnnnnnnnnnrnrnnrannnnrnnnnrnr... | code_stdio |
[
{
"content": "In a long narrow forest stretching east-west, there are N beasts. Below, we will call the point that is p meters from the west end Point p. The i-th beast from the west (1 ≤ i ≤ N) is at Point x_i, and can be sold for s_i yen (the currency of Japan) if captured.\n\nYou will choose two integers L a... | [{"input": "4\n1 101\n10 152\n812494145527274 53\n1000000000110000 151", "output": "244\n"}, {"input": "4\n2 101\n10 152\n812494145527274 53\n1000000010110000 151", "output": "245\n"}, {"input": "4\n0 101\n10 152\n812494145527274 53\n1000000010110000 151", "output": "243\n"}, {"input": "4\n0 101\n10 242\n48251700863794... | code_stdio |
[
{
"content": "Neko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire bag of catnip into the toys...\n\nIt took Neko an entire day to turn back to normal. Neko reported to Ak... | [{"input": "1000\n", "output": "143886430\n"}, {"input": "450\n", "output": "690479399\n"}, {"input": "999\n", "output": "742390865\n"}, {"input": "900\n", "output": "454329300\n"}, {"input": "500\n", "output": "660474384\n"}, {"input": "996\n", "output": "666557857\n"}, {"input": "998\n", "output": "311781222\n"}, {"i... | code_stdio |
[
{
"content": "You need count how many valleys you will pass.\n\nStart is always from zero level.\n\nEvery time you go down below 0 level counts as an entry of a valley, and as you go up to 0 level from valley counts as an exit of a valley.\n\nOne passed valley is equal one entry and one exit of a valley.\n```\n... | [{"input": "\"UFFDDFDUDFUFUUFFDDFDUDFUFUUFFDDFDUDFUFUUFFDDFDUDFUFUUFFDDFDUDFUFUUFFDDFDUDFUFU\"", "output": "[6]", "fn_name": "counting_valleys"}, {"input": "\"UFFDDFDUDFUFUUFFDDFDUDFUFUUFFDDFDUDFUFUUFFDDFDUDFUFU\"", "output": "[4]", "fn_name": "counting_valleys"}, {"input": "\"UFFDDFDUDFUFUUFFDDUFFDDUFFDDUDUDUDUDUDUUUU... | code_functional |
[
{
"content": "In this kata, you will be given a string of text and valid parentheses, such as `\"h(el)lo\"`. You must return the string, with only the text inside parentheses reversed, so `\"h(el)lo\"` becomes `\"h(le)lo\"`. However, if said parenthesized text contains parenthesized text itself, then that too m... | [{"input": "\"one (ruof ((rht)ee) owt)\"", "output": "[\"one (two ((thr)ee) four)\"]", "fn_name": "reverse_in_parentheses"}, {"input": "\"one (two (three) four)\"", "output": "[\"one (ruof (three) owt)\"]", "fn_name": "reverse_in_parentheses"}, {"input": "\"many (parens) on (top)\"", "output": "[\"many (snerap) on (pot... | code_functional |
[
{
"content": "Simon has a prime number x and an array of non-negative integers a_1, a_2, ..., a_{n}.\n\nSimon loves fractions very much. Today he wrote out number $\\frac{1}{x^{a} 1} + \\frac{1}{x^{a_{2}}} + \\ldots + \\frac{1}{x^{a_{n}}}$ on a piece of paper. After Simon led all fractions to a common denominat... | [{"input": "26 7\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2\n", "output": "49\n"}, {"input": "26 7\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2\n", "output": "49\n"}, {"input": "26 2\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2\n", "output": "8\n"}, {"input": "26 2\n0 0 0 0 0 0 0 0 0 0 0 0 0 0... | code_stdio |
[
{
"content": "Like any unknown mathematician, Yuri has favourite numbers: $A$, $B$, $C$, and $D$, where $A \\leq B \\leq C \\leq D$. Yuri also likes triangles and once he thought: how many non-degenerate triangles with integer sides $x$, $y$, and $z$ exist, such that $A \\leq x \\leq B \\leq y \\leq C \\leq z \... | [{"input": "86565 229134 356183 486713\n", "output": "1559833368660730\n"}, {"input": "90528 225462 336895 417903\n", "output": "1043176084391535\n"}, {"input": "178561 294901 405737 476436\n", "output": "911664147520700\n"}, {"input": "145490 215252 362118 413147\n", "output": "498858571439550\n"}, {"input": "108250 2... | code_stdio |
[
{
"content": "You are playing a variation of game 2048. Initially you have a multiset $s$ of $n$ integers. Every integer in this multiset is a power of two. \n\nYou may perform any number (possibly, zero) operations with this multiset.\n\nDuring each operation you choose two equal integers from $s$, remove them... | [{"input": "6\n4\n1024 512 64 512\n1\n2048\n3\n128 512 2\n2\n4096 8\n1\n2048 2 2048 2048 2048 2048 2048\n2\n2048 4898\n", "output": "YES\nYES\nNO\nNO\nYES\nYES\n"}, {"input": "6\n4\n1024 512 64 512\n1\n2048\n3\n64 512 2\n2\n4096 4\n7\n2048 2 2048 2048 2048 2048 2048\n2\n2048 4096\n", "output": "YES\nYES\nNO\nNO\nYES\nY... | code_stdio |
[
{
"content": "Create a function that checks if a number `n` is divisible by two numbers `x` **AND** `y`. All inputs are positive, non-zero digits.\n\n```JS\nExamples:\n1) n = 3, x = 1, y = 3 => true because 3 is divisible by 1 and 3\n2) n = 12, x = 2, y = 6 => true because 12 is divisible by 2 and 6\n3)... | [{"input": "100\n5\n10", "output": "[true]", "fn_name": "is_divisible"}, {"input": "100\n5\n3", "output": "[false]", "fn_name": "is_divisible"}, {"input": "17\n17\n17", "output": "[true]", "fn_name": "is_divisible"}, {"input": "17\n1\n17", "output": "[true]", "fn_name": "is_divisible"}, {"input": "3\n2\n2", "output": "... | code_functional |
[
{
"content": "Write a program which calculates the area and perimeter of a given rectangle.\n\nConstraints\n\n* 1 ≤ a, b ≤ 100\n\nInput\n\nThe length a and breadth b of the rectangle are given in a line separated by a single space.\n\nOutput\n\nPrint the area and perimeter of the rectangle in a line. The two in... | [{"input": "-10 2", "output": "-20 -16\n"}, {"input": "-16 -2", "output": "32 -36\n"}, {"input": "-16 -1", "output": "16 -34\n"}, {"input": "-16 1", "output": "-16 -30\n"}, {"input": "4 122", "output": "488 252\n"}, {"input": "1 122", "output": "122 246\n"}, {"input": "1 -10", "output": "-10 -18\n"}, {"input": "-8 2", ... | code_stdio |
[
{
"content": "My friend John and I are members of the \"Fat to Fit Club (FFC)\". John is worried because\neach month a list with the weights of members is published and each month he is the last on the list\nwhich means he is the heaviest. \n\nI am the one who establishes the list so I told him:\n\"Don't worry ... | [{"input": "\"387087 176 351832 100 430372 8 58052 54 175432 120 269974 147 309754 91 404858 67 271476 164 295747 111 40\"", "output": "[\"100 111 120 40 8 54 91 164 147 67 176 430372 58052 175432 351832 271476 309754 404858 387087 295747 269974\"]", "fn_name": "order_weight"}, {"input": "\"71899703 200 6 91 425 4 6740... | code_functional |
[
{
"content": "You are given two positive integers $a$ and $b$.\n\nIn one move, you can change $a$ in the following way:\n\n Choose any positive odd integer $x$ ($x > 0$) and replace $a$ with $a+x$; choose any positive even integer $y$ ($y > 0$) and replace $a$ with $a-y$. \n\nYou can perform as many such oper... | [{"input": "5\n2 3\n10 10\n2 4\n7 4\n9 3\n", "output": "1\n0\n2\n2\n1\n"}, {"input": "5\n2 3\n10 10\n2 4\n4 4\n9 3\n", "output": "1\n0\n2\n0\n1\n"}, {"input": "5\n2 3\n10 10\n2 7\n4 4\n9 3\n", "output": "1\n0\n1\n0\n1\n"}, {"input": "5\n2 3\n10 10\n2 2\n4 4\n9 3\n", "output": "1\n0\n0\n0\n1\n"}, {"input": "5\n2 2\n10 1... | code_stdio |
[
{
"content": "Vlad went into his appartment house entrance, now he is on the $1$-th floor. He was going to call the elevator to go up to his apartment.\n\nThere are only two elevators in his house. Vlad knows for sure that:\n\nthe first elevator is currently on the floor $a$ (it is currently motionless),\n\nthe... | [{"input": "69\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1 2\n3 2 1\n1 2 3\n3 1... | code_stdio |
[
{
"content": "We have a grid with 3 rows and N columns. The cell at the i-th row and j-th column is denoted (i, j). Initially, each cell (i, j) contains the integer i+3j-3.\n\n<image>\n\nA grid with N=5 columns\n\nSnuke can perform the following operation any number of times:\n\n* Choose a 3×3 subrectangle of t... | [{"input": "7\n21 12 1 16 14 6 10\n20 11 0 27 14 7 8\n19 10 3 18 7 4 12", "output": "No\n"}, {"input": "7\n21 12 1 16 14 6 10\n20 12 0 27 14 7 8\n19 10 3 18 7 4 12", "output": "No\n"}, {"input": "7\n21 12 1 16 12 6 10\n20 12 0 27 14 7 8\n19 10 3 18 7 4 12", "output": "No\n"}, {"input": "7\n21 12 1 16 13 6 7\n20 11 2 20... | code_stdio |
[
{
"content": "Every Friday and Saturday night, farmer counts amount of sheep returned back to his farm (sheep returned on Friday stay and don't leave for a weekend).\n\nSheep return in groups each of the days -> you will be given two arrays with these numbers (one for Friday and one for Saturday night). Entries... | [{"input": "[2, 5, 8]\n[11, 23, 3, 4, 15, 112, 12, 4]\n355", "output": "[156]", "fn_name": "lostSheep"}, {"input": "[2, 7, 13, 17]\n[23, 56, 44, 12, 1, 2, 1]\n255", "output": "[77]", "fn_name": "lostSheep"}, {"input": "[11, 23, 3, 4, 15]\n[7, 14, 9, 21, 15]\n300", "output": "[178]", "fn_name": "lostSheep"}, {"input": "... | code_functional |
[
{
"content": "The letters shop showcase is a string s, consisting of n lowercase Latin letters. As the name tells, letters are sold in the shop.\n\nLetters are sold one by one from the leftmost to the rightmost. Any customer can only buy some prefix of letters from the string s.\n\nThere are m friends, the i-th... | [{"input": "100\nwjtwxtttttxjjwxtjtttwxjwjjwjxtwwxxwwwtwttwxjxxjxwxwjtjjwxxxxwwtwtxjxwtwtjjjxwjxjtwwwwtjtttjjtxtwtxjw\n10\nxwjxjwxtwwj\nwxjxxjxjx\nwtjxxxjxjxtwt\njwwxj\njtwjtxjxttxwtw\nwtwxjjjttjx\nwwwjtxw\ntjxjwtjwtw\ntjwtjjxtxjwt\nwxwtxtjw\n", "output": "21\n29\n29\n12\n15\n17\n21\n14\n17\n14\n"}, {"input": "100\nwjt... | code_stdio |
[
{
"content": "Let a_1, …, a_n be an array of n positive integers. In one operation, you can choose an index i such that a_i = i, and remove a_i from the array (after the removal, the remaining parts are concatenated).\n\nThe weight of a is defined as the maximum number of elements you can remove.\n\nYou must an... | [{"input": "30 10\n1 1 3 3 5 2 1 8 2 6 11 5 2 6 12 11 8 5 11 3 14 8 16 13 14 25 16 2 8 17\n6 3\n0 15\n1 0\n9 2\n12 16\n1 0\n17 3\n14 13\n0 22\n3 10\n", "output": "3\n15\n16\n2\n0\n16\n0\n0\n8\n4\n"}, {"input": "30 10\n1 1 3 3 5 2 1 8 2 6 11 5 2 6 12 11 8 5 11 3 14 3 16 13 14 25 16 2 8 17\n6 3\n0 15\n1 0\n9 2\n12 16\n1 ... | code_stdio |
[
{
"content": "Iahub and Iahubina went to a picnic in a forest full of trees. Less than 5 minutes passed before Iahub remembered of trees from programming. Moreover, he invented a new problem and Iahubina has to solve it, otherwise Iahub won't give her the food. \n\nIahub asks Iahubina: can you build a rooted tr... | [{"input": "24\n1 2 3 4 5 10 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24\n", "output": "NO\n"}, {"input": "24\n5 3 3 4 2 6 7 14 9 10 11 12 13 14 29 16 17 18 19 25 31 22 23 24\n", "output": "NO\n"}, {"input": "24\n5 3 3 4 2 6 7 14 9 10 11 12 13 14 29 16 17 18 19 25 31 22 23 37\n", "output": "NO\n"}, {"input": "24... | code_stdio |
[
{
"content": "## Grade book\n\nComplete the function so that it finds the mean of the three scores passed to it and returns the letter value associated with that grade.\n\nNumerical Score | Letter Grade\n--- | ---\n90 <= score <= 100 | 'A'\n80 <= score < 90 | 'B'\n70 <= score < 80 | 'C'\n6... | [{"input": "100\n100\n100", "output": "[\"A\"]", "fn_name": "get_grade"}, {"input": "100\n85\n96", "output": "[\"A\"]", "fn_name": "get_grade"}, {"input": "70\n70\n100", "output": "[\"B\"]", "fn_name": "get_grade"}, {"input": "95\n90\n93", "output": "[\"A\"]", "fn_name": "get_grade"}, {"input": "92\n93\n94", "output": ... | code_functional |
[
{
"content": "Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.\n\nLet's denote a flip operation of an integer as follo... | [{"input": "1000000000000000000000001\n", "output": "1000000000000000000000000\n"}, {"input": "2442173122931392213712431\n", "output": "1776586566965695556855660"}, {"input": "9009900990099009900990098\n", "output": "4555455545554454445444544"}, {"input": "1000000177157517600000001\n", "output": "1000000088578758800000... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \n\nChef is playing a game with his friend Misha. They have a pile containg N coins. Players take alternate turns, removing some coins from the pile. On each turn, a player can remove either one coin or coins equal to so... | [{"input": "2\n-12\n-6", "output": "Misha\nMisha\n"}, {"input": "2\n-12\n-1", "output": "Misha\nChef\n"}, {"input": "2\n-11\n-6", "output": "Chef\nMisha\n"}, {"input": "2\n-15\n-6", "output": "Chef\nMisha\n"}, {"input": "2\n-6\n-10", "output": "Misha\nChef\n"}, {"input": "2\n-6\n-11", "output": "Misha\nChef\n"}, {"inpu... | code_stdio |
[
{
"content": "Polycarp is reading a book consisting of $n$ pages numbered from $1$ to $n$. Every time he finishes the page with the number divisible by $m$, he writes down the last digit of this page number. For example, if $n=15$ and $m=5$, pages divisible by $m$ are $5, 10, 15$. Their last digits are $5, 0, 5... | [{"input": "7\n1 1\n10 1\n100 3\n1024 14\n998244353 1337\n123 144\n1234312817382646 13\n", "output": "1\n45\n153\n294\n3359835\n0\n427262129093995\n"}, {"input": "7\n1 1\n10 2\n100 3\n1024 14\n998244353 1337\n123 144\n1234312817382646 13\n", "output": "1\n20\n153\n294\n3359835\n0\n427262129093995\n"}, {"input": "7\n1 1... | code_stdio |
[
{
"content": "Two semifinals have just been in the running tournament. Each semifinal had n participants. There are n participants advancing to the finals, they are chosen as follows: from each semifinal, we choose k people (0 ≤ 2k ≤ n) who showed the best result in their semifinals and all other places in the ... | [{"input": "8\n100 101\n200 201\n300 301\n310 400\n320 500\n330 600\n340 700\n350 800\n", "output": "11111000\n11110000\n"}, {"input": "8\n100 101\n200 201\n300 301\n310 400\n320 500\n330 600\n340 700\n350 800\n", "output": "11111000\n11110000\n"}, {"input": "8\n100 101\n200 201\n300 157\n310 400\n320 500\n330 600\n340... | code_stdio |
[
{
"content": "Bob has a rectangular chocolate bar of the size W × H. He introduced a cartesian coordinate system so that the point (0, 0) corresponds to the lower-left corner of the bar, and the point (W, H) corresponds to the upper-right corner. Bob decided to split the bar into pieces by breaking it. Each bre... | [{"input": "9 8 5\n4 3 4 4\n0 4 9 4\n5 4 5 8\n0 3 9 3\n1 4 1 8\n", "output": "4 4 5 16 16 27 \n"}, {"input": "10 10 4\n9 0 9 10\n4 0 4 10\n1 0 1 10\n1 4 4 4\n", "output": "10 10 12 18 50 \n"}, {"input": "14 10 4\n9 0 9 10\n4 0 4 10\n1 0 1 10\n1 4 4 4\n", "output": "10 12 18 50 50\n"}, {"input": "16 10 4\n9 0 9 10\n4 0 ... | code_stdio |
[
{
"content": "If the girl doesn't go to Denis, then Denis will go to the girl. Using this rule, the young man left home, bought flowers and went to Nastya. \n\nOn the way from Denis's house to the girl's house is a road of n lines. This road can't be always crossed in one green light. Foreseeing this, the good ... | [{"input": "30 8\n0 1 13 12 23 24 26 30\n40 7\n", "output": "30\n"}, {"input": "30 8\n0 1 9 12 23 24 26 30\n40 7\n", "output": "30\n"}, {"input": "30 8\n0 1 9 12 23 24 26 30\n27 7\n", "output": "41\n"}, {"input": "30 8\n0 1 9 10 23 24 26 30\n71 7\n", "output": "30\n"}, {"input": "30 8\n0 1 9 10 23 24 26 30\n71 2\n", "o... | code_stdio |
[
{
"content": "Bob is an active user of the social network Faithbug. On this network, people are able to engage in a mutual friendship. That is, if $a$ is a friend of $b$, then $b$ is also a friend of $a$. Each user thus has a non-negative amount of friends.\n\nThis morning, somebody anonymously sent Bob the fol... | [{"input": "35\n21 26 18 7 28 2 16 13 16 25 6 32 11 5 31 17 18 3 24 33 14 27 29 1 20 4 12 9 10 30 34 8 19 23 22\n", "output": "0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 \n"}, {"input": "35\n21 26 18 4 28 3 15 13 16 25 6 25 11 5 31 17 9 3 24 33 14 27 29 1 20 4 12 7 10 30 34 8 19 23 22\n", "output": "5 7 9 11 13 1... | code_stdio |
[
{
"content": "You are given a rectangle grid. That grid's size is n × m. Let's denote the coordinate system on the grid. So, each point on the grid will have coordinates — a pair of integers (x, y) (0 ≤ x ≤ n, 0 ≤ y ≤ m).\n\nYour task is to find a maximum sub-rectangle on the grid (x_1, y_1, x_2, y_2) so that i... | [{"input": "1000000000 1000000000 286536427 579261823 230782719 575570138\n", "output": "171145067 291476754 401927786 867046892\n"}, {"input": "1000000000 1000000000 623214043 753726318 970868535 929707704\n", "output": "29131465 70292296 1000000000 1000000000\n"}, {"input": "1000000000 1000000000 500000000 500000000 ... | code_stdio |
[
{
"content": "Write a function that checks if all the letters in the second string are present in the first one at least once, regardless of how many times they appear:\n\n```\n[\"ab\", \"aaa\"] => true\n[\"trances\", \"nectar\"] => true\n[\"compadres\", \"DRAPES\"] => true\n[\"parses\", \"parsecs\"] ... | [{"input": "[\"mastering\", \"streaming\"]", "output": "[true]", "fn_name": "letter_check"}, {"input": "[\"THE EYES\", \"they see\"]", "output": "[true]", "fn_name": "letter_check"}, {"input": "[\"drapes\", \"compadres\"]", "output": "[false]", "fn_name": "letter_check"}, {"input": "[\"assert\", \"staring\"]", "output"... | code_functional |
[
{
"content": "[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu)\n\n[KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives)\n\nWith a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space.\n\nThe space c... | [{"input": "10000000000000000 10000000000000000 100 100 10000000000000000 10000000000000000\n10000000000000000 10000000000000000 10000000000000000\n", "output": "1\n"}, {"input": "10000000000000000 10000000000000000 100 100 10000000000000000 10000000000000000\n10000000000000000 10000000000000000 10000000100000000\n", "... | code_stdio |
[
{
"content": "La Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each.\nDetermine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes.\n\n-----Constraints-----\... | [{"input": "100\n", "output": "Yes\n"}, {"input": "11\n", "output": "Yes\n"}, {"input": "40\n", "output": "Yes\n"}, {"input": "12\n", "output": "Yes\n"}, {"input": "15\n", "output": "Yes\n"}, {"input": "16\n", "output": "Yes\n"}, {"input": "19\n", "output": "Yes\n"}, {"input": "20\n", "output": "Yes\n"}, {"input": "56\... | code_stdio |
[
{
"content": "Innovation technologies are on a victorious march around the planet. They integrate into all spheres of human activity!\n\nA restaurant called \"Dijkstra's Place\" has started thinking about optimizing the booking system. \n\nThere are n booking requests received by now. Each request is characteri... | [{"input": "10\n739 307\n523 658\n700 143\n373 577\n120 433\n353 833\n665 516\n988 101\n817 604\n800 551\n10\n431 425 227 147 153 170 954 757 222 759\n", "output": "6 3621\n6 2\n2 8\n9 7\n4 1\n7 10\n5 4\n"}, {"input": "10\n739 307\n523 658\n700 143\n373 577\n120 433\n353 833\n665 516\n988 101\n817 604\n800 551\n10\n431... | code_stdio |
[
{
"content": "You are given a tree with $n$ vertices. You are allowed to modify the structure of the tree through the following multi-step operation: Choose three vertices $a$, $b$, and $c$ such that $b$ is adjacent to both $a$ and $c$. For every vertex $d$ other than $b$ that is adjacent to $a$, remove the e... | [{"input": "15\n4 6\n8 4\n12 11\n7 6\n9 8\n5 1\n14 13\n6 13\n1 4\n1 2\n6 11\n10 8\n15 14\n3 1\n", "output": "4\n"}, {"input": "15\n4 6\n8 4\n12 11\n7 6\n9 8\n5 1\n14 13\n6 13\n1 4\n1 2\n6 11\n10 8\n15 14\n3 1\n", "output": "4\n"}, {"input": "15\n9 11\n8 15\n6 5\n12 10\n1 2\n5 11\n10 7\n3 2\n6 7\n4 8\n3 5\n9 13\n13 14\n... | code_stdio |
[
{
"content": "Chef is playing a game on a sequence of N positive integers, say A_{1}, A_{2}, ... A_{N}. The game is played as follows.\nIf all the numbers are equal, the game ends.\nOtherwise\nSelect two numbers which are unequal\nSubtract the smaller number from the larger number\nReplace the larger number wit... | [{"input": "3\n2\n10 30\n2\n7 14\n3\n12 10 24", "output": "10\n7\n2\n"}, {"input": "3\n2\n10 21\n2\n20 10\n3\n11 10 9", "output": "1\n10\n1\n"}, {"input": "3\n2\n10 10\n2\n10 14\n3\n8 14 22", "output": "10\n2\n2\n"}, {"input": "3\n2\n19 19\n2\n10 14\n3\n8 10 24", "output": "19\n2\n2\n"}, {"input": "3\n2\n16 19\n2\n10 2... | code_stdio |
[
{
"content": "One day n friends gathered together to play \"Mafia\". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play a_{i} rounds. ... | [{"input": "100\n1 555 876 444 262 234 231 598 416 261 206 165 181 988 469 123 602 592 533 97 864 716 831 156 962 341 207 377 892 51 866 96 757 317 832 476 549 472 770 1000 887 145 956 515 992 653 972 677 973 527 984 559 280 346 580 30 372 547 209 929 492 520 446 726 47 170 699 560 814 206 688 955 308 287 26 102 77 430... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian \n\nChef is going to participate in a new quiz show: \"Who dares to be a millionaire?\"\nAccording to the rules of the game, contestants must answer N questions. The quiz being famous for its difficulty, each question has 26 candidate answ... | [{"input": "3\n5\nABCDE\nEBCDA\n1 10 34 18 78 225\n4\nCHEE\nQUIZ\n15 3 3 1 0\n8\nABBABAAB\nABABABAB\n100 100 100 100 001 001 000 000 000", "output": "34\n15\n100\n"}, {"input": "3\n5\nABCDE\nEBCDA\n1 10 34 18 63 225\n4\nCHEE\nQUIZ\n15 3 3 1 0\n8\nABBABAAB\nABABABAB\n100 101 100 100 001 001 000 000 001", "output": "34\n... | code_stdio |
[
{
"content": "Unary is a minimalistic Brainfuck dialect in which programs are written using only one token. \n\nBrainfuck programs use 8 commands: \"+\", \"-\", \"[\", \"]\", \"<\", \">\", \".\" and \",\" (their meaning is not important for the purposes of this problem). Unary programs are created from Brainfuc... | [{"input": ",]+>.],,+->+>-[]][><,-]><]++<.,-[.>.<+.[.<,[-,,[<]+>]->>]>]-+-+<][].,.]+][[<,-.+][+<<-+.],,,<,.]-].-\n", "output": "859903\n"}, {"input": ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n", "output": "208877\n"}, {"input": "[][][][][][][][][][][][][][][]... | code_stdio |
[
{
"content": "ZS the Coder and Chris the Baboon has explored Udayland for quite some time. They realize that it consists of n towns numbered from 1 to n. \n\nThere are n directed roads in the Udayland. i-th of them goes from town i to some other town a_{i} (a_{i} ≠ i). ZS the Coder can flip the direction of any... | [{"input": "84\n2 50 67 79 71 45 43 40 57 20 25 8 60 47 52 10 37 23 1 28 22 26 3 42 11 63 61 68 49 32 55 18 5 24 31 70 66 27 38 41 54 12 65 51 15 34 30 35 77 74 21 62 33 16 81 14 19 48 80 73 69 78 39 6 76 46 75 72 84 29 58 59 13 17 82 9 83 4 36 56 53 7 64 44\n", "output": "428380105\n"}, {"input": "84\n2 50 67 79 71 45... | code_stdio |
[
{
"content": "Bizon the Champion isn't just attentive, he also is very hardworking.\n\nBizon the Champion decided to paint his old fence his favorite color, orange. The fence is represented as n vertical planks, put in a row. Adjacent planks have no gap between them. The planks are numbered from the left to the... | [{"input": "30\n1 4 5 3 9 7 8 4 5 9 2 3 4 2 3 4 5 5 6 8 1 2 9 4 3 7 2 6 5 4\n", "output": "26\n"}, {"input": "30\n1 4 5 3 9 7 8 4 5 9 2 3 4 2 3 4 5 5 6 8 1 2 9 4 3 7 2 6 5 4\n", "output": "26\n"}, {"input": "30\n1 4 5 3 9 7 8 4 5 1 2 3 4 2 3 4 5 5 6 8 1 2 9 4 3 7 2 6 5 4\n", "output": "25\n"}, {"input": "30\n1 4 5 3 9 ... | code_stdio |
[
{
"content": "The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.\n\nThe Chef invest... | [{"input": "3\n2\n0 -1\n-1 -1\n1 0\n2\n0 0\n0 -1\n1 -1\n2\n1 0\n1 2\n1 1", "output": "yes\nyes\nyes\n"}, {"input": "3\n2\n0 -1\n-1 -1\n1 0\n2\n1 0\n0 -1\n1 -1\n2\n1 0\n1 2\n1 1", "output": "yes\nyes\nyes\n"}, {"input": "3\n2\n0 -1\n-1 -1\n1 0\n2\n0 1\n0 -1\n1 -1\n2\n1 0\n1 2\n1 1", "output": "yes\nyes\nyes\n"}, {"input... | code_stdio |
[
{
"content": "A [Word Square](https://en.wikipedia.org/wiki/Word_square) is a set of words written out in a square grid, such that the same words can be read both horizontally and vertically. The number of words, equal to the number of letters in each word, is known as the *order* of the square.\n\nFor example,... | [{"input": "\"DESCENDANTECHENEIDAESHORTCOATSCERBERULUSENTEROMERENECROLATERDIOUMABANAADALETABATNATURENAMETESSERATED\"", "output": "[true]", "fn_name": "word_square"}, {"input": "\"GLASSESRELAPSEIMITATESMEAREDTANNERY\"", "output": "[false]", "fn_name": "word_square"}, {"input": "\"FRACTUREOUTLINEDBLOOMINGSEPTETTE\"", "ou... | code_functional |
[
{
"content": "Write a function that will check whether the permutation of an input string is a palindrome. Bonus points for a solution that is efficient and/or that uses _only_ built-in language functions. Deem yourself **brilliant** if you can come up with a version that does not use _any_ function whatsoever.... | [{"input": "\"abcdefghba\"", "output": "[false]", "fn_name": "permute_a_palindrome"}, {"input": "\"racecars\"", "output": "[false]", "fn_name": "permute_a_palindrome"}, {"input": "\"baabcd\"", "output": "[false]", "fn_name": "permute_a_palindrome"}, {"input": "\"baa\"", "output": "[true]", "fn_name": "permute_a_palindr... | code_functional |
[
{
"content": "Example\n\nInput\n\n3\n1 3 3\n2\n1 2\n1 3\n\n\nOutput\n\n5\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": "3\n0 2 0\n-1\n1 2\n0 2", "output": "3\n"}, {"input": "3\n0 2 0\n-1\n1 2\n0 1", "output": "3\n"}, {"input": "3\n1 1 0\n0\n1 2\n-1 1", "output": "3\n"}, {"input": "3\n0 1 1\n0\n2 1\n-1 1", "output": "3\n"}, {"input": "3\n0 0 0\n0\n0 1\n-1 1", "output": "3\n"}, {"input": "3\n1 0 0\n0\n1 2\n-1 1", "output": "3\... | code_stdio |
[
{
"content": "**Debug** a function called calculate that takes 3 values. The first and third values are numbers. The second value is a character. If the character is \"+\" , \"-\", \"\\*\", or \"/\", the function will return the result of the corresponding mathematical function on the two numbers. If the string... | [{"input": "-2\n\"codewars\"\n-2", "output": "[null]", "fn_name": "calculate"}, {"input": "3.2\n\"+\"\n8", "output": "[11.2]", "fn_name": "calculate"}, {"input": "3.2\n\"-\"\n8", "output": "[-4.8]", "fn_name": "calculate"}, {"input": "3.2\n\"*\"\n8", "output": "[25.6]", "fn_name": "calculate"}, {"input": "6\n\"-\"\n1.5... | code_functional |
[
{
"content": "Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her ... | [{"input": "16 14\n15 15\n17 13\n", "output": "9 7\n6 8\n"}, {"input": "12 14\n11 15\n9 17\n", "output": "3 9\n8 6\n"}, {"input": "12 12\n14 10\n16 8\n", "output": "9 3\n5 7\n"}, {"input": "11 11\n17 5\n12 10\n", "output": "9 2\n8 3\n"}, {"input": "14 11\n16 9\n13 12\n", "output": "9 5\n7 4\n"}, {"input": "15 11\n16 10... | code_stdio |
[
{
"content": "You have to organize a wedding party. The program of the party will include a concentration game played by the bride and groom. The arrangement of the concentration game should be easy since this game will be played to make the party fun.\n\nWe have a 4x4 board and 8 pairs of cards (denoted by `A'... | [{"input": "-2 1 -3 1 1 0 0 1\n1 -1 2 1 2 2 -1 3\n8", "output": "145\n0\n"}, {"input": "-2 1 0 1 1 0 1 3\n2 0 2 0 3 2 0 4\n10", "output": "173\n256\n"}, {"input": "-2 1 -2 1 1 0 1 2\n1 0 2 1 2 2 0 3\n5", "output": "145\n29\n"}, {"input": "-2 1 -2 1 1 0 1 3\n1 0 2 1 2 2 0 3\n5", "output": "125\n29\n"}, {"input": "-2 1 -... | code_stdio |
[
{
"content": "Dima's got a staircase that consists of n stairs. The first stair is at height a1, the second one is at a2, the last one is at an (1 ≤ a1 ≤ a2 ≤ ... ≤ an). \n\nDima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width wi and he... | [{"input": "5\n1 2 3 6 6\n25\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 10000000... | code_stdio |
[
{
"content": "A sequence $a = [a_1, a_2, \\ldots, a_l]$ of length $l$ has an ascent if there exists a pair of indices $(i, j)$ such that $1 \\le i < j \\le l$ and $a_i < a_j$. For example, the sequence $[0, 2, 0, 2, 0]$ has an ascent because of the pair $(1, 4)$, but the sequence $[4, 3, 3, 3, 1]$ doesn't have ... | [{"input": "10\n3 62 24 39\n1 17\n1 99\n1 60\n1 64\n1 30\n2 79 29\n2 20 73\n2 85 37\n1 100\n", "output": "72\n"}, {"input": "10\n3 62 24 39\n1 17\n1 99\n1 60\n1 64\n1 30\n2 79 29\n2 20 73\n2 85 37\n1 100\n", "output": "72\n"}, {"input": "5\n5 1 2 2 4 5\n4 -1 2 3 6\n3 3 2 1\n2 3 1\n1 0\n", "output": "22\n"}, {"input": "... | code_stdio |
[
{
"content": "DropCaps means that the first letter of the starting word of the paragraph should be in caps and the remaining lowercase, just like you see in the newspaper. \n\nBut for a change, let's do that for each and every word of the given String. Your task is to capitalize every word that has length great... | [{"input": "\"Revelation of the contents outraged American public opinion, and helped generate\"", "output": "[\"Revelation of The Contents Outraged American Public Opinion, And Helped Generate\"]", "fn_name": "drop_cap"}, {"input": "\"more than one space between words\"", "output": "[\"More Than One Space Betw... | code_functional |
[
{
"content": "Student Valera is an undergraduate student at the University. His end of term exams are approaching and he is to pass exactly n exams. Valera is a smart guy, so he will be able to pass any exam he takes on his first try. Besides, he can take several exams on one day, and in any order.\n\nAccording... | [{"input": "1\n1000000000 999999999\n", "output": "999999999\n"}, {"input": "1\n1000000000 999999999\n", "output": "999999999\n"}, {"input": "1\n1010000000 999999999\n", "output": "999999999\n"}, {"input": "1\n1010000000 498441652\n", "output": "498441652\n"}, {"input": "1\n1000000000 115308630\n", "output": "115308630... | code_stdio |
[
{
"content": "Alice and Johnny are playing a simple guessing game. Johnny picks an arbitrary positive integer n (1<=n<=109) and gives Alice exactly k hints about the value of n. It is Alice's task to guess n, based on the received hints. \n\nAlice often has a serious problem guessing the value of n, and she's b... | [{"input": "3\n2\n< 100 No\n> 100 No\n3\n< 2 Yes\n> 4 Yes\n= 3 No\n6\n< 2 Yes\n> 1 Yes\n= 1 Yes\n= 1 Yes\n= 1 Yes\n= 1 Yes", "output": "0\n1\n1\n"}, {"input": "3\n2\n< 100 No\n? 100 No\n3\n< 2 Yes\n> 4 Yes\n= 3 No\n6\n< 2 Yes\n> 1 Yes\n= 1 Yes\n= 1 Yes\n> 1 Yes\n= 1 Yes", "output": "0\n1\n2\n"}, {"input": "3\n2\n< 100 ... | code_stdio |
[
{
"content": "Lavrenty, a baker, is going to make several buns with stuffings and sell them.\n\nLavrenty has n grams of dough as well as m different stuffing types. The stuffing types are numerated from 1 to m. Lavrenty knows that he has ai grams left of the i-th stuffing. It takes exactly bi grams of stuffing ... | [{"input": "1000 10 100 75\n100 97 100 95\n100 64 100 78\n110 82 100 35\n100 51 100 64\n100 67 100 25\n100 79 100 33\n100 65 100 85\n100 99 100 78\n100 53 100 74\n100 87 100 73\n", "output": "786\n"}, {"input": "1000 10 100 75\n100 97 100 95\n100 64 100 78\n100 82 100 35\n100 51 100 64\n100 67 100 25\n100 79 100 33\n10... | code_stdio |
[
{
"content": "Sereja owns a restaurant for n people. The restaurant hall has a coat rack with n hooks. Each restaurant visitor can use a hook to hang his clothes on it. Using the i-th hook costs a_{i} rubles. Only one person can hang clothes on one hook.\n\nTonight Sereja expects m guests in the restaurant. Nat... | [{"input": "100 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... | code_stdio |
[
{
"content": "Polycarpus has n friends in Tarasov city. Polycarpus knows phone numbers of all his friends: they are strings s1, s2, ..., sn. All these strings consist only of digits and have the same length. \n\nOnce Polycarpus needed to figure out Tarasov city phone code. He assumed that the phone code of the ... | [{"input": "10\n17254072509168593435\n17254072509168593433\n17254072509168593430\n17254072509168593432\n17254072509168593439\n17254072509168593436\n17254072509168593438\n17254072509168593437\n17254072509168593431\n17254072509168593434\n", "output": "19\n"}, {"input": "10\n17254072509168593435\n17475068102414404607\n172... | code_stdio |
[
{
"content": "Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:\n\n $1 \\le u < v \\le n$. $a_u > a_v$. \n\nMadeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decide... | [{"input": "100\n32 85 33 27 35 48 64 40 45 120 68 58 108 115 99 71 47 82 42 34 63 49 102 30 88 70 73 52 51 95 104 41 38 59 91 21 43 107 44 113 109 25 55 118 112 90 37 106 103 100 114 78 31 26 92 79 89 105 62 54 72 69 101 36 98 77 93 97 75 96 22 76 86 57 46 110 65 61 23 50 83 87 39 74 111 67 29 84 24 28 56 116 80 117 1... | code_stdio |
[
{
"content": "There is a frequency operation in the conversion operation of a finite number sequence. The conversion result of the sequence $ S = \\\\ {s_1, s_2, ... s_n \\\\} $ is a sequence of the same length. If the result is $ C = \\\\ {c_1, c_2, ..., c_n \\\\} $, then $ c_i $ represents the number of $ s_i... | [{"input": "10\n2 5 1 -1 3 4 27 0 -2 6\n0", "output": "2\n10 10 10 10 10 10 10 10 10 10\n"}, {"input": "10\n2 1 0 0 3 5 0 0 0 12\n0", "output": "3\n10 10 10 10 10 10 10 10 10 10\n"}, {"input": "10\n2 5 1 0 3 4 27 0 -2 10\n0", "output": "2\n8 8 8 2 8 8 8 2 8 8\n"}, {"input": "10\n2 5 1 -1 3 4 27 0 -2 5\n0", "output": "2... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.