messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$.\n\nYou can move only in two directions:\n\nto the right, i. e. horizontally and in the direction that increase your $x$ coordinate,\n\nor up, i. e. vertically and in the direction that increase you...
[{"input": "3\n2\n13 100\n3\n4 3 1\n5\n13 4 1 1 5\n", "output": "226\n15\n25\n"}, {"input": "3\n2\n13 100\n3\n2 3 0\n5\n4 3 2 1 5\n", "output": "226\n11\n19\n"}, {"input": "3\n2\n13 100\n3\n2 3 0\n5\n4 3 1 1 5\n", "output": "226\n11\n15\n"}, {"input": "3\n2\n13 100\n3\n2 3 0\n5\n4 3 0 1 5\n", "output": "226\n11\n11\n"}...
code_stdio
[ { "content": "There are N balls in a row. Initially, the i-th ball from the left has the integer A_i written on it.\n\nWhen Snuke cast a spell, the following happens:\n\n* Let the current number of balls be k. All the balls with k written on them disappear at the same time.\n\n\n\nSnuke's objective is to vanish...
[{"input": "10 10\n8 7 2 9 10 6 6 5 5 4\n8 1\n6 3\n6 2\n7 10\n9 7\n9 9\n2 4\n10 1\n1 8\n7 7", "output": "1\n0\n1\n2\n2\n3\n3\n4\n4\n3\n"}, {"input": "10 10\n8 7 2 9 10 6 6 5 5 4\n8 1\n6 3\n6 2\n7 10\n9 7\n9 4\n2 4\n10 1\n1 8\n7 7", "output": "1\n0\n1\n2\n2\n2\n3\n3\n3\n2\n"}, {"input": "10 10\n8 7 2 9 10 6 6 5 5 4\n8 1...
code_stdio
[ { "content": "You are given a string s, consisting of small Latin letters. Let's denote the length of the string as |s|. The characters in the string are numbered starting from 1. \n\nYour task is to find out if it is possible to rearrange characters in string s so that for any prime number p ≀ |s| and for any ...
[{"input": "xxxxxxxxxxfxxxxxxxxxxxxxxxxxxxxxxxxxxxrxtxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxexxxxmxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxoxxxxxxxxxxexxxxxxxxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxoxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxtxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxuxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
code_stdio
[ { "content": "You've got a rectangular parallelepiped with integer edge lengths. You know the areas of its three faces that have a common vertex. Your task is to find the sum of lengths of all 12 edges of this parallelepiped.\n\nInput\n\nThe first and the single line contains three space-separated integers β€” th...
[{"input": "10000 10000 10000\n", "output": "1200"}, {"input": "10000 1 10000\n", "output": "40008"}, {"input": "9801 9801 9801\n", "output": "1188"}, {"input": "1 10000 10000\n", "output": "40008"}, {"input": "9801 9702 9702\n", "output": "1184"}, {"input": "1656 6900 1350\n", "output": "740"}, {"input": "3623 3623 1\...
code_stdio
[ { "content": "Alice and Bob are playing a game on a line with n cells. There are n cells labeled from 1 through n. For each i from 1 to n-1, cells i and i+1 are adjacent.\n\nAlice initially has a token on some cell on the line, and Bob tries to guess where it is. \n\nBob guesses a sequence of line cell numbers ...
[{"input": "50 75\n2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50\n", "output": "0\n"}, {"input": "50 75\n2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36...
code_stdio
[ { "content": "You are given two positive integer numbers x and y. An array F is called an y-factorization of x iff the following conditions are met: There are y elements in F, and all of them are integer numbers; $\\prod_{i = 1}^{y} F_{i} = x$. \n\nYou have to count the number of pairwise distinct arrays that...
[{"input": "1\n524288 1000000\n", "output": "645043186\n"}, {"input": "1\n524288 1000000\n", "output": "645043186\n"}, {"input": "1\n983675 1000000\n", "output": "661876874\n"}, {"input": "1\n65536 1000000\n", "output": "928522471\n"}, {"input": "1\n65536 1000000\n", "output": "928522471\n"}, {"input": "1\n36157 100000...
code_stdio
[ { "content": "She loves e-mail so much! She sends e-mails by her cellular phone to her friends when she has breakfast, she talks with other friends, and even when she works in the library! Her cellular phone has somewhat simple layout (Figure 1). Pushing button 1 once displays a character (’), pushing\n\n<image...
[{"input": "666660666\n134424306396481246895756\n12784174432754272468162", "output": "No\n'dhagdmdwmgt'agmtwjpjm\n'aptg'phdapjgapagmt'ma\n"}, {"input": "666660666\n113124756735251440964347\n33891614279093528467517", "output": "No\n,d'agpjmpdjaj'hwmgdgp\netw'm'gapwwdjatgmpj'p\n"}, {"input": "666660666\n11850618639893972...
code_stdio
[ { "content": "Character recognition software is widely used to digitise printed texts. Thus the texts can be edited, searched and stored on a computer.\n\nWhen documents (especially pretty old ones written with a typewriter), are digitised character recognition softwares often make mistakes.\n\nYour task is cor...
[{"input": "\"J. K. R0WL1NG - HARRY P0TTER AND THE PH1L050PHER'5 5T0NE\"", "output": "[\"J. K. ROWLING - HARRY POTTER AND THE PHILOSOPHER'S STONE\"]", "fn_name": "correct"}, {"input": "\"J. K. R0WL1NG - HARRY P0TTER AND THE PR150NER 0F Azkaban\"", "output": "[\"J. K. ROWLING - HARRY POTTER AND THE PRISONER OF Azkaban\"...
code_functional
[ { "content": "Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to (x - 1, y) or (x, y - 1). Vasiliy can move his pawn from (x...
[{"input": "100000 100000 100000 123228\n", "output": "Polycarp\n"}, {"input": "100000 99999 100000 100000\n", "output": "Polycarp\n"}, {"input": "100000 99999 100010 100000\n", "output": "Polycarp\n"}, {"input": "100000 100000 100000 99999\n", "output": "Vasiliy\n"}, {"input": "53208 42123 134209 85846\n", "output": "...
code_stdio
[ { "content": "Your job is to write a function which increments a string, to create a new string.\n\n- If the string already ends with a number, the number should be incremented by 1.\n- If the string does not end with a number. the number 1 should be appended to the new string.\n\nExamples:\n\n`foo -> foo1`\n\n...
[{"input": "\"foobar00999\"", "output": "[\"foobar01000\"]", "fn_name": "increment_string"}, {"input": "\"foobar999\"", "output": "[\"foobar1000\"]", "fn_name": "increment_string"}, {"input": "\"foobar001\"", "output": "[\"foobar002\"]", "fn_name": "increment_string"}, {"input": "\"foobar000\"", "output": "[\"foobar001...
code_functional
[ { "content": "Alice and Bob begin their day with a quick game. They first choose a starting number X_0 β‰₯ 3 and try to reach one million by the process described below. \n\nAlice goes first and then they take alternating turns. In the i-th turn, the player whose turn it is selects a prime number smaller than the...
[{"input": "1000000\n", "output": "998677\n"}, {"input": "959806\n", "output": "239958\n"}, {"input": "166320\n", "output": "110879\n"}, {"input": "221760\n", "output": "110880\n"}, {"input": "277200\n", "output": "138600\n"}, {"input": "332640\n", "output": "166320\n"}, {"input": "498960\n", "output": "332639\n"}, {"i...
code_stdio
[ { "content": "Little Petya has a birthday soon. Due this wonderful event, Petya's friends decided to give him sweets. The total number of Petya's friends equals to n.\n\nLet us remind you the definition of the greatest common divisor: GCD(a1, ..., ak) = d, where d represents such a maximal positive number that ...
[{"input": "50\n", "output": "9539133444790097506800945910496378878609919834178506027953758452154850007466954507364870095\n6359422296526731671200630606997585919073279889452337351969172301436566671644636338243246730\n3815653377916039002720378364198551551443967933671402411181503380861940002986781802945948038\n27254666985...
code_stdio
[ { "content": "Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nPetya loves long lucky numbers very much. He is interested in the minimum ...
[{"input": "86451 754 85 84\n", "output": "4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444...
code_stdio
[ { "content": "What joy! Petya's parents went on a business trip for the whole year and the playful kid is left all by himself. Petya got absolutely happy. He jumped on the bed and threw pillows all day long, until... \n\nToday Petya opened the cupboard and found a scary note there. His parents had left him with...
[{"input": "100\n100 100 100 100 100 100 100 100 100 100 100 100\n", "output": "1\n"}, {"input": "100\n100 100 100 100 110 100 100 100 100 100 100 100\n", "output": "1\n"}, {"input": "100\n100 100 100 100 110 100 100 100 100 100 101 100\n", "output": "1\n"}, {"input": "100\n100 100 100 100 110 100 100 100 100 100 101 1...
code_stdio
[ { "content": "Valerian was captured by Shapur. The victory was such a great one that Shapur decided to carve a scene of Valerian's defeat on a mountain. So he had to find the best place to make his victory eternal!\n\nHe decided to visit all n cities of Persia to find the best available mountain, but after the ...
[{"input": "15\n12 1 52\n6 2 10\n4 1 55\n11 7 20\n10 3 54\n13 9 44\n15 2 6\n14 5 55\n9 3 32\n2 1 32\n8 4 14\n6 5 24\n5 3 74\n7 6 157\n", "output": "1039\n"}, {"input": "15\n12 1 52\n3 2 10\n4 1 45\n11 7 20\n10 3 54\n13 9 44\n15 2 6\n14 5 55\n9 3 32\n2 1 32\n8 4 14\n6 5 24\n5 3 74\n7 6 157\n", "output": "921\n"}, {"inpu...
code_stdio
[ { "content": "A cricket team consists of 11 players and some are good at batting, others are good at bowling and some of them are good at both batting and bowling. The batting coach wants to select exactly K players having maximum possible sum of scores. Given the batting score of each of the 11 players, find t...
[{"input": "2\n1 2 3 4 5 11 14 11 11 6 11\n3\n0 5 1 2 4 1 4 5 1 2 1\n11", "output": "6\n1\n"}, {"input": "2\n2 1 3 4 5 11 14 11 12 6 12\n3\n0 5 1 2 4 1 4 5 1 2 1\n11", "output": "1\n1\n"}, {"input": "2\n2 1 3 4 5 11 14 11 9 6 11\n3\n-1 5 1 2 4 1 4 5 1 2 1\n11", "output": "3\n1\n"}, {"input": "2\n2 1 3 4 5 11 14 11 9 6 ...
code_stdio
[ { "content": "Alice and Bob are playing a game on a line with $n$ cells. There are $n$ cells labeled from $1$ through $n$. For each $i$ from $1$ to $n-1$, cells $i$ and $i+1$ are adjacent.\n\nAlice initially has a token on some cell on the line, and Bob tries to guess where it is. \n\nBob guesses a sequence of ...
[{"input": "50 75\n2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50\n", "output": "0\n"}, {"input": "50 75\n2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36...
code_stdio
[ { "content": "Given are a prime number p and a sequence of p integers a_0, \\ldots, a_{p-1} consisting of zeros and ones.\nFind a polynomial of degree at most p-1, f(x) = b_{p-1} x^{p-1} + b_{p-2} x^{p-2} + \\ldots + b_0, satisfying the following conditions:\n - For each i (0 \\leq i \\leq p-1), b_i is an integ...
[{"input": "2999\n0 0 0 0 0 0 1 0 1 1 0 1 0 1 1 1 1 0 0 1 0 0 1 1 0 0 0 1 0 0 1 1 0 0 0 0 1 1 0 1 1 1 1 0 1 0 0 1 0 0 1 1 0 0 0 1 0 1 1 1 0 1 1 0 1 0 1 0 1 1 0 1 1 1 1 1 1 1 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 0 1 1 0 0 1 1 1 0 0 0 0 1 0 1 1 1 0 1 1 1 1 1 0 0 1 0 1 1 1 1 0 1 0 1 1 1 0 0 ...
code_stdio
[ { "content": "Вася ΠΊΡƒΠΏΠΈΠ» стол, Ρƒ ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠ³ΠΎ n Π½ΠΎΠΆΠ΅ΠΊ. КаТдая Π½ΠΎΠΆΠΊΠ° состоит ΠΈΠ· Π΄Π²ΡƒΡ… частСй, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ ΡΠΎΠ΅Π΄ΠΈΠ½ΡΡŽΡ‚ΡΡ Π΄Ρ€ΡƒΠ³ с Π΄Ρ€ΡƒΠ³ΠΎΠΌ. КаТдая Ρ‡Π°ΡΡ‚ΡŒ ΠΌΠΎΠΆΠ΅Ρ‚ Π±Ρ‹Ρ‚ΡŒ ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ»ΡŒΠ½ΠΎΠΉ ΠΏΠΎΠ»ΠΎΠΆΠΈΡ‚Π΅Π»ΡŒΠ½ΠΎΠΉ Π΄Π»ΠΈΠ½Ρ‹, Π½ΠΎ гарантируСтся, Ρ‡Ρ‚ΠΎ ΠΈΠ· всСх 2n частСй Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ ΡΠΎΡΡ‚Π°Π²ΠΈΡ‚ΡŒ n Π½ΠΎΠΆΠ΅ΠΊ ΠΎΠ΄ΠΈΠ½Π°ΠΊΠΎΠ²ΠΎΠΉ Π΄Π»ΠΈΠ½Ρ‹. ΠŸΡ€ΠΈ составлСнии Π½ΠΎΠΆΠΊΠΈ Π»ΡŽΠ±Ρ‹Π΅ Π΄Π²Π΅ части ΠΌΠΎΠ³ΡƒΡ‚ Π±Ρ‹...
[{"input": "100\n8 7 7 5 2 7 7 5 1 8 6 3 6 7 2 4 4 2 6 8 5 6 5 2 6 1 3 9 5 8 7 6 5 4 8 6 5 5 3 2 6 5 4 9 7 1 5 7 9 5 7 4 1 6 5 8 2 6 6 1 4 2 3 2 3 9 3 8 7 1 2 4 5 7 3 5 5 6 3 8 3 6 1 5 5 3 3 3 8 8 1 4 3 6 7 1 1 2 4 4 7 3 7 7 8 9 5 8 6 6 4 7 4 9 3 4 7 5 2 8 4 1 9 7 9 7 9 6 7 7 9 6 1 1 1 9 9 4 4 1 5 6 6 3 9 3 3 7 4 2 4 9...
code_stdio
[ { "content": "Soroush and Keshi each have a labeled and rooted tree on n vertices. Both of their trees are rooted from vertex 1.\n\nSoroush and Keshi used to be at war. After endless decades of fighting, they finally became allies to prepare a Codeforces round. To celebrate this fortunate event, they decided to...
[{"input": "4\n4\n1 2 3\n1 2 3\n5\n1 2 3 4\n1 1 1 1\n6\n1 1 1 1 2\n1 2 1 2 2\n7\n1 1 3 4 4 5\n1 2 1 4 2 5\n", "output": "\n1\n4\n1\n3\n"}, {"input": "4\n4\n1 2 3\n1 2 3\n5\n1 2 3 4\n1 1 1 1\n6\n1 2 1 1 2\n1 2 1 2 2\n7\n1 1 3 4 4 5\n1 2 1 4 2 5\n", "output": "1\n4\n1\n3\n"}, {"input": "4\n4\n1 2 3\n1 2 3\n5\n1 2 3 4\n1 ...
code_stdio
[ { "content": "Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $1$ to $n$. For every edge $e$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the ed...
[{"input": "15\n10 15\n12 15\n6 15\n8 15\n2 15\n3 15\n10 15\n13 15\n5 15\n7 15\n11 15\n4 14\n1 15\n14 15\n", "output": "NO\n"}, {"input": "15\n10 15\n12 15\n6 15\n8 15\n2 15\n3 15\n10 15\n13 15\n5 15\n7 15\n11 15\n4 14\n1 15\n14 15\n", "output": "NO\n"}, {"input": "15\n9 15\n6 15\n12 15\n3 14\n14 15\n11 15\n6 15\n7 15\...
code_stdio
[ { "content": "Takahashi's house has only one socket.\nTakahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.\nOne power strip with A sockets can extend one empty socket into A empty sockets.\nFind the minimum number of power strips required.\n\n-----Con...
[{"input": "13 17\n", "output": "2\n"}, {"input": "10 19\n", "output": "2\n"}, {"input": "20 19\n", "output": "1\n"}, {"input": "2 20\n", "output": "19\n"}, {"input": "4 10\n", "output": "3\n"}, {"input": "4 12\n", "output": "4\n"}, {"input": "9 12\n", "output": "2\n"}, {"input": "3 17\n", "output": "8\n"}, {"input": "...
code_stdio
[ { "content": "Takayuki and Kazuyuki are good twins, but their behavior is exactly the opposite. For example, if Takayuki goes west, Kazuyuki goes east, and if Kazuyuki goes north, Takayuki goes south. Currently the two are in a department store and are in different locations. How can two people who move in the ...
[{"input": "6 6\n2 4\n6 2\n0 0 0 0 1 0\n0 1 1 0 0 0\n0 1 0 0 0 0\n0 0 0 1 0 0\n0 0 0 0 0 1\n0 0 0 0 0 0\n3 3\n1 1\n3 3\n0 0 0\n0 1 0\n0 0 0\n0 0", "output": "3\nNA\n"}, {"input": "6 6\n2 4\n6 2\n0 0 0 0 1 0\n0 1 0 0 1 0\n0 1 0 0 0 0\n0 1 0 1 1 0\n0 0 0 0 0 1\n0 0 0 0 0 0\n3 3\n1 1\n3 3\n0 0 0\n0 1 0\n0 0 0\n0 0", "outp...
code_stdio
[ { "content": "Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a...
[{"input": "1707 1117\n", "output": "237674323"}, {"input": "1766 1038\n", "output": "435768250"}, {"input": "1229 1315\n", "output": "100240813"}, {"input": "1903 1612\n", "output": "620810276"}, {"input": "1887 1729\n", "output": "730033374"}, {"input": "1153 1823\n", "output": "791493066"}, {"input": "1544 1794\n", ...
code_stdio
[ { "content": "And again a misfortune fell on Poor Student. He is being late for an exam.\n\nHaving rushed to a bus stop that is in point (0, 0), he got on a minibus and they drove along a straight line, parallel to axis OX, in the direction of increasing x.\n\nPoor Student knows the following: \n\n * during on...
[{"input": "94 2 1\n0 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 506...
code_stdio
[ { "content": "Uh oh! Ray lost his array yet again! However, Omkar might be able to help because he thinks he has found the OmkArray of Ray's array. The OmkArray of an array a with elements a_1, a_2, …, a_{2k-1}, is the array b with elements b_1, b_2, …, b_{k} such that b_i is equal to the median of a_1, a_2, …,...
[{"input": "5\n8\n-8 2 -6 -5 -4 3 2 2\n7\n1 1 3 1 0 -2 -1\n7\n6 12 8 6 2 6 10\n6\n5 1 2 2 12 7\n5\n1 3 4 3 -1\n", "output": "NO\nYES\nNO\nNO\nNO\n"}, {"input": "5\n8\n-8 3 -6 -5 -4 3 3 2\n7\n1 1 4 1 0 -2 -1\n7\n6 12 8 6 2 6 10\n6\n5 1 2 2 12 7\n5\n1 3 4 3 0\n", "output": "YES\nYES\nNO\nNO\nNO\n"}, {"input": "5\n8\n-8 3...
code_stdio
[ { "content": "You are given a sequence a_1, a_2, ..., a_{n} of one-dimensional segments numbered 1 through n. Your task is to find two distinct indices i and j such that segment a_{i} lies within segment a_{j}.\n\nSegment [l_1, r_1] lies within segment [l_2, r_2] iff l_1 β‰₯ l_2 and r_1 ≀ r_2.\n\nPrint indices i ...
[{"input": "11\n22226 28285\n9095 23314\n19162 25530\n255 13298\n4904 25801\n17914 23501\n13874 28117\n11880 29994\n11123 19874\n21505 27971\n7658 14109\n", "output": "11 5\n"}, {"input": "11\n22226 28285\n9095 23314\n19162 25530\n255 13298\n4904 25801\n17914 23501\n8441 28117\n11880 29994\n11123 19874\n21505 27971\n76...
code_stdio
[ { "content": "Zeke loves to spend time with Penny and likes her. Penny is having an issue to solve a mathematics problem and is confused. She seeks Zeke's help as she feels he could help her with the problem. He finds this problem very simple. The problem is to count the number of unique triplets of different n...
[{"input": "1000\n1804289384 846930887 1681692778\n1714636916 1957747794 424238336\n719885387 1649760493 596516650\n1189641422 1025202363 1350490028\n783368691 1102520060 2044897764\n1967513927 1365180541 1540383427\n304089173 1303455737 35005212\n521595369 294702568 1726956430\n336465783 861021531 278722863\n233665124...
code_stdio
[ { "content": "Happy PMP is freshman and he is learning about algorithmic problems. He enjoys playing algorithmic games a lot.\n\nOne of the seniors gave Happy PMP a nice game. He is given two permutations of numbers 1 through n and is asked to convert the first one to the second. In one move he can remove the l...
[{"input": "20\n1 12 9 6 11 13 2 8 20 7 16 19 4 18 3 15 10 17 14 5\n5 14 17 10 15 3 18 4 19 16 7 20 8 2 13 11 6 9 12 1\n", "output": "19"}, {"input": "10\n1 6 10 3 4 9 2 5 8 7\n7 5 2 6 10 3 4 8 9 1\n", "output": "9\n"}, {"input": "10\n5 8 1 10 3 6 2 9 7 4\n4 2 6 3 1 9 10 5 8 7\n", "output": "8"}, {"input": "10\n1 6 10 ...
code_stdio
[ { "content": "Taro and Hanako decided to play hit-and-blow. The hit-and-blow rules are as follows.\n\n* Separated into questioners and respondents.\n* The questioner decides a 4-digit number (correct answer) that does not include duplicate numbers.\n* Respondents guess the 4-digit number (answer).\n* For the an...
[{"input": "1234 10660\n1234 1354\n1234 1234\n1230 1023\n0123 1234\n0 0", "output": "1 0\n2 1\n4 0\n1 3\n0 3\n"}, {"input": "1234 10660\n1964 1354\n1234 1234\n1230 1023\n0123 1234\n0 0", "output": "1 0\n2 0\n4 0\n1 3\n0 3\n"}, {"input": "1234 10660\n2242 1354\n1234 1234\n1230 1023\n0123 1234\n0 0", "output": "1 0\n0 1\...
code_stdio
[ { "content": "Anton likes to play chess, and so does his friend Danik.\n\nOnce they have played n games in a row. For each game it's known who was the winnerΒ β€” Anton or Danik. None of the games ended with a tie.\n\nNow Anton wonders, who won more games, he or Danik? Help him determine this.\n\n\n-----Input-----...
[{"input": "379\nAADAAAAAADDAAAAAADAADADADDAAAAADADDAADAAAADDDADAAAAAAADAADAAAAAAADAAAAAAAAADAAAAAAADAAAAAAAAAAADDDADAAAAAAAADAADADAAAADAAAAAAAAAAAAAAAAADAAAADDDAADAAAAAAADAAADAAADAADDDADDAAADAAAAAADDDADDDAAADAAAADAAAAAAAAADAAADAAAAAAAAADAAAAAAAAAAAAAAAAAADADAAAAAAAAAAADAAAAADAAAADAAAAAAAAAAAAADADAADAAAAAAAADAADAAAAAAA...
code_stdio
[ { "content": "A string is called beautiful if no two consecutive characters are equal. For example, \"ababcb\", \"a\" and \"abab\" are beautiful strings, while \"aaaaaa\", \"abaa\" and \"bb\" are not.\n\nAhcl wants to construct a beautiful string. He has a string $s$, consisting of only characters 'a', 'b', 'c'...
[{"input": "23\n?\n??\n???\n????\n????\n?a\n?b\n?c\na?\nb?\nc?\n?a?\n?b?\n?c?\na?a\na?b\na?c\nb?a\nb?b\nb?c\nc?a\nc?b\nc?c\n", "output": "a\nab\naba\nabab\nabab\nba\nab\nac\nab\nba\nca\nbab\naba\naca\naba\nacb\nabc\nbca\nbab\nbac\ncba\ncab\ncac\n"}, {"input": "23\n?\n??\n???\n????\n????\n?a\n?b\n?c\na?\nb?\nc?\n?a?\n?b...
code_stdio
[ { "content": "Let us consider a grid of squares with 10^9 rows and N columns. Let (i, j) be the square at the i-th column (1 \\leq i \\leq N) from the left and j-th row (1 \\leq j \\leq 10^9) from the bottom.\n\nSnuke has cut out some part of the grid so that, for each i = 1, 2, ..., N, the bottom-most h_i squa...
[{"input": "9\n17 18 51 18 28 45 112 45 23", "output": "917046249"}, {"input": "9\n17 18 51 18 34 45 112 45 23", "output": "938229436"}, {"input": "9\n17 18 51 18 34 45 190 45 23", "output": "353713429"}, {"input": "9\n17 18 51 18 34 45 190 56 23", "output": "814466445"}, {"input": "9\n17 18 81 18 34 45 190 56 23", "ou...
code_stdio
[ { "content": "You are given a digital clock with $n$ digits. Each digit shows an integer from $0$ to $9$, so the whole clock shows an integer from $0$ to $10^n-1$. The clock will show leading zeroes if the number is smaller than $10^{n-1}$.\n\nYou want the clock to show $0$ with as few operations as possible. I...
[{"input": "7\n3\n007\n4\n1000\n5\n00000\n3\n153\n4\n1247\n9\n123456789\n30\n001678294039710047203946100020\n", "output": "7\n2\n0\n11\n17\n53\n115\n"}, {"input": "7\n3\n007\n4\n1000\n5\n00000\n3\n153\n4\n1293\n9\n123456789\n30\n001678294039710047203946100020\n", "output": "7\n2\n0\n11\n18\n53\n115\n"}, {"input": "7\n3...
code_stdio
[ { "content": "Valera had two bags of potatoes, the first of these bags contains x (x β‰₯ 1) potatoes, and the second β€” y (y β‰₯ 1) potatoes. Valera β€” very scattered boy, so the first bag of potatoes (it contains x potatoes) Valera lost. Valera remembers that the total amount of potatoes (x + y) in the two bags, fir...
[{"input": "1 2 27764\n", "output": "1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 16...
code_stdio
[ { "content": "We have a string X, which has an even number of characters. Half the characters are `S`, and the other half are `T`.\n\nTakahashi, who hates the string `ST`, will perform the following operation 10^{10000} times:\n\n* Among the occurrences of `ST` in X as (contiguous) substrings, remove the leftmo...
[{"input": "SSTTTSST", "output": "2\n"}, {"input": "TTTTSSSS", "output": "8\n"}, {"input": "TSSTTSST", "output": "2\n"}, {"input": "TTSTSSST", "output": "4\n"}, {"input": "SSTTSTST", "output": "0\n"}, {"input": "TSSSTSTT", "output": "2\n"}, {"input": "TSTSTTSS", "output": "4\n"}, {"input": "SSSTTTST", "output": "0\n"},...
code_stdio
[ { "content": "Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation a_{i}x + b_{i}y + c_{i} = 0, where a_{i} and b_{i} are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block...
[{"input": "841746 527518\n595261 331297\n10\n-946901 129987 670374\n-140388 -684770 309555\n-302589 415564 -387435\n-565799 -72069 -395358\n-523453 -511446 854898\n-846967 -749453 -341866\n-622388 434663 264157\n-638453 625357 344195\n-255265 -676356 -772398\n-824723 -319141 33585\n", "output": "0\n"}, {"input": "8417...
code_stdio
[ { "content": "You are given an array of n integers a1... an. The cost of a subsegment is the number of unordered pairs of distinct indices within the subsegment that contain equal elements. Split the given array into k non-intersecting non-empty subsegments so that the sum of their costs is minimum possible. Ea...
[{"input": "128 5\n116 8 116 116 119 39 116 116 119 116 8 119 119 119 39 116 39 119 39 119 119 39 8 39 14 119 8 116 116 116 119 119 8 39 39 8 116 119 119 119 119 8 11 8 119 39 119 116 119 119 39 39 119 8 116 116 116 116 116 119 116 116 119 116 39 39 119 8 8 119 39 116 39 39 119 119 116 116 119 119 119 119 8 8 116 116 1...
code_stdio
[ { "content": "There is a building with n rooms, numbered 1 to n.\nWe can move from any room to any other room in the building.\nLet us call the following event a move: a person in some room i goes to another room j~ (i \\neq j).\nInitially, there was one person in each room in the building.\nAfter that, we know...
[{"input": "200000 1000000000\n", "output": "607923868\n"}, {"input": "200000 0000001000", "output": "525127456\n"}, {"input": "200000 0000001001", "output": "578341203\n"}, {"input": "200000 0001001001", "output": "607923868\n"}, {"input": "140753 0011001000", "output": "810481869\n"}, {"input": "135689 0011001000", "...
code_stdio
[ { "content": "# Task\n Yesterday you found some shoes in your room. Each shoe is described by two values:\n```\ntype indicates if it's a left or a right shoe;\nsize is the size of the shoe.\n```\n Your task is to check whether it is possible to pair the shoes you found in such a way that each pair consists of a...
[{"input": "[[0, 23], [1, 23], [1, 23], [0, 23], [0, 23], [0, 23]]", "output": "[false]", "fn_name": "pair_of_shoes"}, {"input": "[[0, 23], [1, 21], [1, 23], [0, 21], [1, 22], [0, 22]]", "output": "[true]", "fn_name": "pair_of_shoes"}, {"input": "[[0, 21], [1, 23], [1, 21], [1, 23]]", "output": "[false]", "fn_name": "p...
code_functional
[ { "content": "Hofstadter sequences are a family of related integer sequences, among which the first ones were described by an American professor Douglas Hofstadter in his book GΓΆdel, Escher, Bach. \n\n### Task\nToday we will be implementing the rather chaotic recursive sequence of integers called Hofstadter Q.\...
[{"input": "1000", "output": "[502]", "fn_name": "hofstadter_Q"}, {"input": "100", "output": "[56]", "fn_name": "hofstadter_Q"}, {"input": "10", "output": "[6]", "fn_name": "hofstadter_Q"}, {"input": "1", "output": "[1]", "fn_name": "hofstadter_Q"}, {"input": "3", "output": "[2]", "fn_name": "hofstadter_Q"}, {"input": ...
code_functional
[ { "content": "We have N cards. A number a_i is written on the i-th card.\n\nAlice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.\n\nThe game ends when all the cards are taken by the two players, and the score of each player is the sum of the ...
[{"input": "4\n20 18 2 18\n", "output": "18\n"}, {"input": "4\n20 18 2 12", "output": "12\n"}, {"input": "4\n139 4 2 5", "output": "136\n"}, {"input": "4\n139 1 2 5", "output": "135\n"}, {"input": "4\n139 0 2 4", "output": "137\n"}, {"input": "4\n20 1 4 12", "output": "11\n"}, {"input": "4\n20 2 0 12", "output": "10\n"...
code_stdio
[ { "content": "Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of spor...
[{"input": "50 77\n24 119\n43 119\n102 22\n117 30\n127 54\n93 19\n120 9\n118 27\n98 16\n17 105\n22 127\n109 52\n115 40\n11 121\n12 120\n113 30\n13 108\n33 124\n31 116\n112 39\n37 108\n127 28\n127 39\n120 29\n19 114\n103 18\n106 16\n24 121\n93 10\n36 112\n104 40\n39 100\n36 97\n83 9\n14 114\n126 12\n85 47\n25 84\n105 29...
code_stdio
[ { "content": "After bracket sequences Arthur took up number theory. He has got a new favorite sequence of length n (a1, a2, ..., an), consisting of integers and integer k, not exceeding n.\n\nThis sequence had the following property: if you write out the sums of all its segments consisting of k consecutive elem...
[{"input": "39 3\n-5 1 -13 ? 2 -12 ? 3 -11 -2 4 -10 ? 5 -9 0 6 -8 ? 7 -7 ? 8 -6 5 9 -5 ? 10 -4 ? 11 -3 ? 12 -2 10 13 -1\n", "output": "-5 1 -13 -4 2 -12 -3 3 -11 -2 4 -10 -1 5 -9 0 6 -8 1 7 -7 2 8 -6 5 9 -5 6 10 -4 7 11 -3 8 12 -2 10 13 -1\n"}, {"input": "39 3\n-5 1 -13 ? 2 -12 ? 3 -11 -3 4 -10 ? 5 -9 0 6 -8 ? 7 -7 ? 8...
code_stdio
[ { "content": "In this Kata, you will be given two integers `n` and `k` and your task is to remove `k-digits` from `n` and return the lowest number possible, without changing the order of the digits in `n`. Return the result as a string.\n\nLet's take an example of `solve(123056,4)`. We need to remove `4` digits...
[{"input": "1284569\n1", "output": "[\"124569\"]", "fn_name": "solve"}, {"input": "1284569\n2", "output": "[\"12456\"]", "fn_name": "solve"}, {"input": "123056\n1", "output": "[\"12056\"]", "fn_name": "solve"}, {"input": "1284569\n3", "output": "[\"1245\"]", "fn_name": "solve"}, {"input": "123056\n2", "output": "[\"105...
code_functional
[ { "content": "Maxim always goes to the supermarket on Sundays. Today the supermarket has a special offer of discount systems.\n\nThere are m types of discounts. We assume that the discounts are indexed from 1 to m. To use the discount number i, the customer takes a special basket, where he puts exactly qi items...
[{"input": "48\n14 2 5 3 10 10 5 6 14 8 19 13 4 4 3 13 18 19 9 16 3 1 14 9 13 10 13 4 12 11 8 2 18 20 14 11 3 11 18 11 4 2 7 2 18 19 2 8\n70\n9497 5103 1001 2399 5701 4053 3557 8481 1736 4139 5829 1107 6461 4089 5936 7961 6017 1416 1191 4635 4288 5605 8857 1822 71 1435 2837 5523 6993 2404 2840 8251 765 5678 7834 8595 3...
code_stdio
[ { "content": "You have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.\n\nYou can choose any two indices i and j such that 1 \\leq i \\leq j \\leq n and reverse substring A_i A_{i+1} ... A_j.\n\nYou can perform this operation at most once.\n\nHow many different strings can you obtain?\n\nC...
[{"input": "abracbdabra", "output": "46\n"}, {"input": "aaracbdaarb", "output": "44\n"}, {"input": "aarqabdaacb", "output": "45\n"}, {"input": "abrqabdaacb", "output": "47\n"}, {"input": "arbadbcbrca", "output": "48\n"}, {"input": "arbadbcbsca", "output": "49\n"}, {"input": "aqbadacaraa", "output": "41\n"}, {"input": "...
code_stdio
[ { "content": "Each employee of the \"Blake Techologies\" company uses a special messaging app \"Blake Messenger\". All the stuff likes this app and uses it constantly. However, some important futures are missing. For example, many users want to be able to search through the message history. It was already annou...
[{"input": "28 7\n1-a 1-b 1-c 1-d 1-e 1-f 1-t 1-a 1-b 1-c 1-d 1-e 1-f 1-j 1-a 1-b 1-c 1-d 1-e 1-f 1-g 1-a 1-b 1-c 1-d 1-e 1-f 2-g\n1-a 1-b 1-c 1-d 1-e 1-f 1-g\n", "output": "2\n"}, {"input": "28 7\n1-a 1-b 1-c 1-d 1-e 1-f 1-t 1-a 1-b 1-c 1-d 1-e 1-f 1-j 1-a 1-b 1-c 1-d 1-e 1-f 1-g 1-a 1-b 1-c 1-d 1-e 1-f 2-g\n1-a 1-b 1...
code_stdio
[ { "content": "You will be given a fruit which a farmer has harvested, your job is to see if you should buy or sell.\n\nYou will be given 3 pairs of fruit. Your task is to trade your harvested fruit back into your harvested fruit via the intermediate pair, you should return a string of 3 actions.\n\nif you have ...
[{"input": "[[\"orange\", \"apple\"], [\"pear\", \"orange\"], [\"apple\", \"pear\"]]\n\"apple\"", "output": "[[\"sell\", \"sell\", \"sell\"]]", "fn_name": "buy_or_sell"}, {"input": "[[\"apple\", \"orange\"], [\"pear\", \"orange\"], [\"apple\", \"pear\"]]\n\"apple\"", "output": "[[\"buy\", \"sell\", \"sell\"]]", "fn_nam...
code_functional
[ { "content": "Alice and Bob play a game. The game consists of several sets, and each set consists of several rounds. Each round is won either by Alice or by Bob, and the set ends when one of the players has won $x$ rounds in a row. For example, if Bob won five rounds in a row and $x = 2$, then two sets ends.\n\...
[{"input": "12\n???1??????1?\n", "output": "12 6 4 3 2 2 1 1 1 1 1 1 \n"}, {"input": "12\n?1?1????????\n", "output": "12 6 4 3 2 2 1 1 1 1 1 1\n"}, {"input": "12\n?1??????1???\n", "output": "12 6 4 3 2 2 1 1 1 1 1 1\n"}, {"input": "12\n????????1?1?\n", "output": "12 6 4 3 2 2 1 1 1 1 1 1\n"}, {"input": "12\n???1??????1...
code_stdio
[ { "content": "Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consisting of lowercase Latin letters without spaces or punctuation marks.\n\nSerg...
[{"input": "ttspivgoupgupvgpusvppogsseueusuglpiugssviuutlvgvugtpovuvspvpipggooplgvgugpogvesppulovugsvuougveiivgvslllviogpvtolepglguuellotpvgevspvoiiggiiplppgosuguvtstttpielteuglspgeoeeuivtptggltoltpgliviotsospvitupiopisoetupvvspooilsopslpoloptigstspoiuutiuvvuvlpplvioitsuvlpvtleveslslovolloogsgpvpepgueesslgtosttuupiepps...
code_stdio
[ { "content": "There is a string s of length 3 or greater. No two neighboring characters in s are equal.\n\nTakahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first:\n\n* Remove one of the characters in s, excluding both ends. How...
[{"input": "bceab", "output": "Second\n"}, {"input": "bacba", "output": "First\n"}, {"input": "badba", "output": "First\n"}, {"input": "cadba", "output": "First\n"}, {"input": "dadba", "output": "First\n"}, {"input": "ddaba", "output": "First\n"}, {"input": "dd`ba", "output": "First\n"}, {"input": "dd`b`", "output": "F...
code_stdio
[ { "content": "Petya and Vasya are competing with each other in a new interesting game as they always do.\n\nAt the beginning of the game Petya has to come up with an array of N positive integers. Sum of all elements in his array should be equal to S. Then Petya has to select an integer K such that 0 ≀ K ≀ S.\n\...
[{"input": "10 20\n", "output": "YES\n2 2 2 2 2 2 2 2 2 2\n1\n"}, {"input": "10 24\n", "output": "YES\n2 2 2 2 2 2 2 2 2 6\n1\n"}, {"input": "8 36\n", "output": "YES\n2 2 2 2 2 2 2 22\n1\n"}, {"input": "8 17\n", "output": "YES\n2 2 2 2 2 2 2 3\n1\n"}, {"input": "8 18\n", "output": "YES\n2 2 2 2 2 2 2 4\n1\n"}, {"input"...
code_stdio
[ { "content": "Snuke received a positive integer N from Takahashi. A positive integer m is called a favorite number when the following condition is satisfied:\n\n* The quotient and remainder of N divided by m are equal, that is, \\lfloor \\frac{N}{m} \\rfloor = N \\bmod m holds.\n\n\n\nFind all favorite numbers ...
[{"input": "1000010000000", "output": "2716922731275\n"}, {"input": "1000011000000", "output": "3307289212967\n"}, {"input": "1100011000000", "output": "2999416055122\n"}, {"input": "1110011000000", "output": "3146654438234\n"}, {"input": "1110011100000", "output": "4080876601631\n"}, {"input": "1110011100100", "output...
code_stdio
[ { "content": "A shop sells N kinds of fruits, Fruit 1, \\ldots, N, at prices of p_1, \\ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)\nHere, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.\n\n-----Constraints-----\n...
[{"input": "1000 1000\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 10...
code_stdio
[ { "content": "There is a queue for the self-checkout tills at the supermarket. Your task is write a function to calculate the total time required for all the customers to check out!\n\n### input\n```if-not:c\n* customers: an array of positive integers representing the queue. Each integer represents a customer, ...
[{"input": "[2, 2, 3, 3, 4, 4]\n2", "output": "[9]", "fn_name": "queue_time"}, {"input": "[1, 2, 3, 4, 5]\n100", "output": "[5]", "fn_name": "queue_time"}, {"input": "[1, 2, 3, 4, 5]\n1", "output": "[15]", "fn_name": "queue_time"}, {"input": "[5]\n1", "output": "[5]", "fn_name": "queue_time"}, {"input": "[2]\n5", "outp...
code_functional
[ { "content": "Chef likes cooking. But more than that, he likes to give gifts. And now he wants to give his girlfriend an unforgettable gift. But unfortunately he forgot the password to the safe where the money he saved for the gift is kept.\n\nBut he knows how to hack the safe. To do this, you need to correctly...
[{"input": "2\n3\n3 -2 3\n-1\n10", "output": "-18\n10\n"}, {"input": "2\n3\n3 -4 3\n-2\n10", "output": "-36\n10\n"}, {"input": "2\n3\n3 -4 0\n-2\n10", "output": "-12\n10\n"}, {"input": "2\n3\n3 -5 0\n-2\n10", "output": "-15\n10\n"}, {"input": "2\n3\n3 -5 1\n-2\n10", "output": "-16\n10\n"}, {"input": "2\n3\n5 -4 5\n1\n3...
code_stdio
[ { "content": "Given few numbers, you need to print out the digits that are not being used.\n\nExample:\n\n```python\nunused_digits(12, 34, 56, 78) # \"09\"\nunused_digits(2015, 8, 26) # \"3479\"\n```\n\nNote:\n\n- Result string should be sorted\n- The test case won't pass Integer with leading zero\n\nWrite Pyth...
[{"input": "1\n11\n111\n1111\n11111", "output": "[\"023456789\"]", "fn_name": "unused_digits"}, {"input": "364\n500\n715\n730", "output": "[\"289\"]", "fn_name": "unused_digits"}, {"input": "864\n896\n744", "output": "[\"01235\"]", "fn_name": "unused_digits"}, {"input": "93\n10\n11\n40", "output": "[\"25678\"]", "fn_na...
code_functional
[ { "content": "Each year in the castle of Dwarven King there is a competition in growing mushrooms among the dwarves. The competition is one of the most prestigious ones, and the winner gets a wooden salad bowl. This year's event brought together the best mushroom growers from around the world, so we had to slig...
[{"input": "10 6 1 48\n239 632\n976 315\n797 112\n1 835\n938 862\n531 884\n422 607\n152 331\n413 677\n622 978\n", "output": "5 3788.56\n10 3673.36\n2 3360.12\n6 3289.08\n4 2606.20\n3 2598.64\n9 2525.24\n7 2315.84\n1 2210.84\n8 1184.72\n"}, {"input": "10 6 1 41\n239 632\n976 315\n797 112\n1 835\n938 862\n531 884\n422 60...
code_stdio
[ { "content": "Imagine that you have a twin brother or sister. Having another person that looks exactly like you seems very unusual. It's hard to say if having something of an alter ego is good or bad. And if you do have a twin, then you very well know what it's like.\n\nNow let's imagine a typical morning in yo...
[{"input": "100\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100\n", "output...
code_stdio
[ { "content": "This kata is blatantly copied from inspired by This Kata\nWelcome\n\nthis is the second in the series of the string iterations kata!\n\nHere we go!\n\n---------------------------------------------------------------------------------\n\nWe have a string s\n\nLet's say you start with this: \"Strin...
[{"input": "\"String for test: incommensurability\"\n1", "output": "[\"ySttirliinbga rfuosrn etmemsotc:n i\"]", "fn_name": "string_func"}, {"input": "\"This is a string exemplification!\"\n0", "output": "[\"This is a string exemplification!\"]", "fn_name": "string_func"}, {"input": "\"this_test_will_hurt_you\"\n1234567...
code_functional
[ { "content": "One quite ordinary day Valera went to school (there's nowhere else he should go on a week day). In a maths lesson his favorite teacher Ms. Evans told students about divisors. Despite the fact that Valera loved math, he didn't find this particular topic interesting. Even more, it seemed so boring t...
[{"input": "1000000000 2000000000 2\n", "output": "500000001\n"}, {"input": "200000000 2000000000 1800000011\n", "output": "1\n"}, {"input": "1500000000 2000000000 11\n", "output": "10389612\n"}, {"input": "1100000000 2000000000 2\n", "output": "450000001\n"}, {"input": "316274526 2000000000 1800000011\n", "output": "1...
code_stdio
[ { "content": "Serval is fighting with a monster.\nThe health of the monster is H.\nIn one attack, Serval can decrease the monster's health by A.\nThere is no other way to decrease the monster's health.\nServal wins when the monster's health becomes 0 or below.\nFind the number of attacks Serval needs to make be...
[{"input": "10000 1\n", "output": "10000\n"}, {"input": "10000 10000\n", "output": "1\n"}, {"input": "11000 1", "output": "11000\n"}, {"input": "10010 1", "output": "10010\n"}, {"input": "10001 1", "output": "10001\n"}, {"input": "11010 1", "output": "11010\n"}, {"input": "10101 1", "output": "10101\n"}, {"input": "100...
code_stdio
[ { "content": "Monocarp has arranged $n$ colored marbles in a row. The color of the $i$-th marble is $a_i$. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color). \n\nIn other w...
[{"input": "100\n11 16 16 11 16 11 16 16 11 16 16 16 16 16 16 16 16 16 11 16 16 16 16 16 16 11 16 11 16 11 16 16 16 11 5 16 16 11 16 16 16 16 16 11 16 11 5 16 16 16 16 5 16 16 11 11 16 16 5 16 11 11 16 16 16 11 11 16 11 16 16 16 16 16 16 11 11 16 16 5 16 5 20 5 16 16 16 11 16 16 16 16 16 16 11 16 20 11 16 5\n", "output...
code_stdio
[ { "content": "You are given an array of n integer numbers a_0, a_1, ..., a_{n} - 1. Find the distance between two closest (nearest) minimums in it. It is guaranteed that in the array a minimum occurs at least two times.\n\n\n-----Input-----\n\nThe first line contains positive integer n (2 ≀ n ≀ 10^5) β€” size of ...
[{"input": "85\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 72 67 68 69 70 71 72 73 74 119 76 77 78 79 80 81 82 83 84 1\n", "output": "84\n"}, {"input": "85\n1 2 3 4 5 6 7 8 9 10...
code_stdio
[ { "content": "Alice and Bob play ping-pong with simplified rules.\n\nDuring the game, the player serving the ball commences a play. The server strikes the ball then the receiver makes a return by hitting the ball back. Thereafter, the server and receiver must alternately make a return until one of them doesn't ...
[{"input": "12\n1 1\n2 1\n1 7\n1 1\n2 1\n1 7\n1 1\n2 1\n1 7\n1 1\n2 1\n1 7\n", "output": "0 1\n1 1\n0 7\n0 1\n1 1\n0 7\n0 1\n1 1\n0 7\n0 1\n1 1\n0 7\n"}, {"input": "12\n1 1\n2 1\n1 7\n1 1\n2 1\n1 7\n1 1\n2 1\n1 7\n1 1\n2 1\n1 7\n", "output": "0 1\n1 1\n0 7\n0 1\n1 1\n0 7\n0 1\n1 1\n0 7\n0 1\n1 1\n0 7\n"}, {"input": "2\...
code_stdio
[ { "content": "Anton likes to play chess. Also, he likes to do programming. That is why he decided to write the program that plays chess. However, he finds the game on 8 to 8 board to too simple, he uses an infinite one instead.\n\nThe first task he faced is to check whether the king is in check. Anton doesn't k...
[{"input": "20\n-321 454\nQ 1369 -89\nR -811 454\nQ -404 454\nR -734 454\nQ -804 454\nQ -316 77\nQ -802 468\nB -499 602\nQ 401 -663\nQ -601 454\nQ -974 454\nB 710 298\nB -917 454\nB -555 -924\nQ -337 950\nR 501 40\nR 355 310\nB 1163 -374\nR -860 454\nR 839 -10\n", "output": "YES\n"}, {"input": "20\n-321 454\nQ 1369 -89...
code_stdio
[ { "content": "There are N stores called Store 1, Store 2, \\cdots, Store N. Takahashi, who is at his house at time 0, is planning to visit some of these stores.\n\nIt takes Takahashi one unit of time to travel from his house to one of the stores, or between any two stores.\n\nIf Takahashi reaches Store i at tim...
[{"input": "7 149\n0 25\n3 10\n2 4\n2 20\n3 22\n2 23\n1 2", "output": "4\n"}, {"input": "7 85\n0 25\n3 10\n2 4\n5 20\n3 22\n2 23\n1 18", "output": "3\n"}, {"input": "7 99\n0 25\n3 10\n2 4\n5 20\n3 22\n2 23\n1 18", "output": "3\n"}, {"input": "7 99\n0 25\n3 10\n2 4\n2 20\n3 22\n2 23\n1 18", "output": "3\n"}, {"input": "...
code_stdio
[ { "content": "Programmer Vasya is studying a new programming language &K*. The &K* language resembles the languages of the C family in its syntax. However, it is more powerful, which is why the rules of the actual C-like languages are unapplicable to it. To fully understand the statement, please read the langua...
[{"input": "10\ntypedef &void**** youdyfpinzk\ntypeof &youdyfpinzk***\ntypedef &&&&youdyfpinzk****** nfbsgpjzhxzskmxc\ntypeof nfbsgpjzhxzskmxc***\ntypedef &&&void*** puerqioirikxej\ntypeof &puerqioirikxej********\ntypedef &puerqioirikxej******** xzgzsamjdufuyxz\ntypeof &xzgzsamjdufuyxz******\ntypedef &&&&xzgzsamjdufuyx...
code_stdio
[ { "content": "There are N cats. We number them from 1 through N.\n\nEach of the cats wears a hat. Cat i says: \"there are exactly a_i different colors among the N - 1 hats worn by the cats except me.\"\n\nDetermine whether there exists a sequence of colors of the hats that is consistent with the remarks of the ...
[{"input": "5\n3 4 3 4 3", "output": "Yes\n"}, {"input": "5\n3 4 3 3 3", "output": "No\n"}, {"input": "4\n1 0 -1 2", "output": "No\n"}, {"input": "4\n1 0 -1 3", "output": "No\n"}, {"input": "4\n1 1 -1 3", "output": "No\n"}, {"input": "4\n1 2 -1 3", "output": "No\n"}, {"input": "4\n2 2 -1 3", "output": "No\n"}, {"input"...
code_stdio
[ { "content": "# Task\n Consider a `bishop`, a `knight` and a `rook` on an `n Γ— m` chessboard. They are said to form a `triangle` if each piece attacks exactly one other piece and is attacked by exactly one piece. \n \n Calculate the number of ways to choose positions of the pieces to form a triangle.\n\n Note t...
[{"input": "40\n40", "output": "[92400]", "fn_name": "chess_triangle"}, {"input": "1\n30", "output": "[0]", "fn_name": "chess_triangle"}, {"input": "3\n3", "output": "[48]", "fn_name": "chess_triangle"}, {"input": "5\n2", "output": "[40]", "fn_name": "chess_triangle"}, {"input": "2\n3", "output": "[8]", "fn_name": "che...
code_functional
[ { "content": "This is the easy version of the problem. The difference between the versions is in the constraints on the array elements. You can make hacks only if all versions of the problem are solved.\n\nYou are given an array [a_1, a_2, ..., a_n]. \n\nYour goal is to find the length of the longest subarray o...
[{"input": "100\n92 42 58 62 24 59 62 100 92 62 54 100 62 82 91 62 100 100 62 100 100 62 92 92 92 62 92 92 62 92 62 92 88 100 100 36 62 92 16 92 62 100 62 92 35 62 100 92 92 62 93 100 100 62 76 100 62 62 92 62 92 50 100 8 7 62 100 18 92 62 92 92 100 62 32 92 92 62 37 76 100 39 62 92 62 41 62 62 19 57 100 37 92 99 100 4...
code_stdio
[ { "content": "You are given a string s consisting of lowercase English letters and a number k. Let's call a string consisting of lowercase English letters beautiful if the number of occurrences of each letter in that string is divisible by k. You are asked to find the lexicographically smallest beautiful string...
[{"input": "12\n12 3\nzazasqzqsasq\n1 2\ny\n1 1\na\n15 5\nabccbaabccbazaa\n16 8\ncadjfdsljfdkljds\n6 2\nbaazaa\n6 3\nbosszb\n6 1\nqwerty\n7 7\ndaaaaaa\n14 2\nacabcbdeffewzc\n18 6\nzzzzzzzzzzzzyyyyyz\n9 4\naabaabbbc\n", "output": "zazasqzqsasq\n-1\na\nabccbaabccbbaac\ncbbbbbbbbccccccc\nbaazbz\nbpbbpp\nqwerty\nddddddd\na...
code_stdio
[ { "content": "This is the easy version of the problem. The only difference is that in this version q = 1. You can make hacks only if both versions of the problem are solved.\n\nThere is a process that takes place on arrays a and b of length n and length n-1 respectively. \n\nThe process is an infinite sequence ...
[{"input": "100\n45 21 34 56 15 0 46 59 40 39 78 83 29 77 19 30 60 39 90 64 11 47 10 47 35 79 30 13 21 31 26 68 0 67 52 43 29 94 100 76 16 61 74 34 62 63 4 41 78 31 77 21 90 2 43 70 53 15 53 29 47 87 33 20 23 30 55 57 13 25 19 89 10 17 92 24 47 6 4 91 52 9 11 25 81 14 82 75 46 49 66 62 28 84 88 101 0 19 34 94\n0 0 0 0 ...
code_stdio
[ { "content": "Polycarp must pay exactly $n$ burles at the checkout. He has coins of two nominal values: $1$ burle and $2$ burles. Polycarp likes both kinds of coins equally. So he doesn't want to pay with more coins of one type than with the other.\n\nThus, Polycarp wants to minimize the difference between the ...
[{"input": "6\n1001\n42\n0\n131\n1000101010\n12\n", "output": "333 334\n14 14\n0 0\n43 44\n333367004 333367003\n4 4\n"}, {"input": "6\n1001\n42\n0\n131\n1000101010\n0\n", "output": "333 334\n14 14\n0 0\n43 44\n333367004 333367003\n0 0\n"}, {"input": "6\n1000\n30\n1\n32\n1000000000\n5\n", "output": "334 333\n10 10\n1 0\...
code_stdio
[ { "content": "Gaius Julius Caesar, a famous general, loved to line up his soldiers. Overall the army had n1 footmen and n2 horsemen. Caesar thought that an arrangement is not beautiful if somewhere in the line there are strictly more that k1 footmen standing successively one after another, or there are strictly...
[{"input": "100 99 10 10\n", "output": "65210983\n"}, {"input": "100 100 9 10\n", "output": "67740290\n"}, {"input": "99 100 10 10\n", "output": "65210983\n"}, {"input": "100 100 10 10\n", "output": "950492\n"}, {"input": "100 99 10 4\n", "output": "41571840\n"}, {"input": "78 21 10 1\n", "output": "96098560\n"}, {"inp...
code_stdio
[ { "content": "Consider integer coordinates x, y in the Cartesian plan and three functions f, g, h\ndefined by:\n```\nf: 1 <= x <= n, 1 <= y <= n --> f(x, y) = min(x, y)\ng: 1 <= x <= n, 1 <= y <= n --> g(x, y) = max(x, y)\nh: 1 <= x <= n, 1 <= y <= n --> h(x, y) = x + y\n``` \nwhere n is a given integer (n >= 1...
[{"input": "4000", "output": "[21341334000]", "fn_name": "sumin"}, {"input": "730", "output": "[129938905]", "fn_name": "sumin"}, {"input": "365", "output": "[16275715]", "fn_name": "sumin"}, {"input": "100", "output": "[338350]", "fn_name": "sumin"}, {"input": "15", "output": "[1240]", "fn_name": "sumin"}, {"input": "...
code_functional
[ { "content": "You have been blessed as a child of Omkar. To express your gratitude, please solve this problem for Omkar!\n\nAn array a of length n is called complete if all elements are positive and don't exceed 1000, and for all indices x,y,z (1 ≀ x,y,z ≀ n), a_{x}+a_{y} β‰  a_{z} (not necessarily distinct).\n\n...
[{"input": "2\n1412\n721\n", "output": "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 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 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": "Vova decided to clean his room. The room can be represented as the coordinate axis $OX$. There are $n$ piles of trash in the room, coordinate of the $i$-th pile is the integer $p_i$. All piles have different coordinates.\n\nLet's define a total cleanup as the following process. The goal of this pr...
[{"input": "5 8\n5 1 2 4 3\n0 1\n0 2\n0 3\n0 4\n0 5\n1 1000000000\n1 1\n1 500000000\n", "output": "3\n2\n1\n0\n0\n0\n0\n0\n499999999\n"}, {"input": "5 8\n5 1 2 4 3\n0 1\n0 2\n0 3\n0 4\n0 5\n1 1000000000\n1 1\n1 500000000\n", "output": "3\n2\n1\n0\n0\n0\n0\n0\n499999999\n"}, {"input": "5 4\n5 1 2 4 3\n0 1\n0 2\n0 3\n0 4...
code_stdio
[ { "content": "You are a coach of a group consisting of $n$ students. The $i$-th student has programming skill $a_i$. All students have distinct programming skills. You want to divide them into teams in such a way that: No two students $i$ and $j$ such that $|a_i - a_j| = 1$ belong to the same team (i.e. skills...
[{"input": "10\n5\n3 4 1 5 2\n2\n2 1\n4\n4 1 3 2\n5\n2 3 1 5 4\n2\n1 2\n4\n1 2 3 4\n2\n1 2\n4\n3 4 2 1\n3\n3 2 1\n1\n1\n", "output": "2\n2\n2\n2\n2\n2\n2\n2\n2\n1\n"}, {"input": "10\n5\n3 4 1 5 2\n2\n2 1\n4\n4 1 3 2\n5\n2 3 1 5 4\n2\n1 2\n4\n1 2 3 4\n2\n1 2\n4\n3 4 2 1\n3\n3 2 1\n1\n1\n", "output": "2\n2\n2\n2\n2\n2\n2...
code_stdio
[ { "content": "This is an easier version of the next problem. In this version, $q = 0$.\n\nA sequence of integers is called nice if its elements are arranged in blocks like in $[3, 3, 3, 4, 1, 1]$. Formally, if two elements are equal, everything in between must also be equal.\n\nLet's define difficulty of a sequ...
[{"input": "100 0\n6 7 100 8 5 61 5 75 59 65 51 47 83 37 34 54 87 46 4 26 21 87 12 97 86 68 60 11 62 76 14 83 29 31 91 62 57 80 47 75 85 97 62 77 91 86 14 25 48 77 83 65 39 61 78 77 45 46 90 74 100 91 86 98 55 5 84 42 91 69 100 4 74 98 60 37 75 44 41 12 15 34 36 1 99 16 7 87 36 26 79 42 41 84 17 98 72 16 38 55\n", "out...
code_stdio
[ { "content": "Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab.\n\nThere are $n$ solutions, the $i$-th of them should be tested on $a_i$ tests, testing one solution on one test takes $1$ second. The solutions are judged in the order fr...
[{"input": "100 10\n3 114 77 78 105 87 6 122 141 100 75 118 64 18 88 37 109 72 31 101 36 10 62 18 52 17 149 115 22 150 138 48 46 42 104 8 63 21 117 58 87 80 7 131 125 118 67 13 144 43 59 67 74 13 124 77 86 148 107 11 51 9 87 52 147 22 7 22 143 12 121 123 17 35 33 87 91 140 92 38 106 10 66 26 40 100 121 42 134 127 116 1...
code_stdio
[ { "content": "The game of Berland poker is played with a deck of $n$ cards, $m$ of which are jokers. $k$ players play this game ($n$ is divisible by $k$).\n\nAt the beginning of the game, each player takes $\\frac{n}{k}$ cards from the deck (so each card is taken by exactly one player). The player who has the m...
[{"input": "4\n8 3 2\n4 2 4\n12 6 3\n42 0 7\n", "output": "3\n0\n3\n0\n"}, {"input": "4\n12 3 2\n4 2 4\n9 6 3\n42 0 7\n", "output": "3\n0\n1\n0\n"}, {"input": "4\n8 1 2\n4 2 4\n12 6 3\n66 0 7\n", "output": "1\n0\n3\n0\n"}, {"input": "4\n8 5 2\n4 2 4\n12 11 3\n7 0 9\n", "output": "3\n0\n0\n0\n"}, {"input": "4\n8 3 2\n4 ...
code_stdio
[ { "content": "Jou and Yae are a good couple. Jou is collecting prizes for capsule toy vending machines (Gachapon), and even when they go out together, when they find Gachapon, they seem to get so hot that they try it several times. Yae was just looking at Jou, who looked happy, but decided to give him a Gachapo...
[{"input": "2\n1 0\n3\n1 1 0\n1\n0000\n0", "output": "NA\nNA\nNA\n"}, {"input": "2\n3 2\n3\n0 1 1\n1\n0000\n0", "output": "3\nNA\nNA\n"}, {"input": "2\n1 0\n3\n0 1 1\n1\n1000\n0", "output": "NA\nNA\n2\n"}, {"input": "2\n1 0\n3\n0 4 0\n1\n0000\n0", "output": "NA\n2\nNA\n"}, {"input": "2\n1 0\n3\n2 1 0\n1\n0000\n0", "out...
code_stdio
[ { "content": "There is a long plate s containing n digits. Iahub wants to delete some digits (possibly none, but he is not allowed to delete all the digits) to form his \"magic number\" on the plate, a number that is divisible by 5. Note that, the resulting number may contain leading zeros.\n\nNow Iahub wants t...
[{"input": "27755776656210607832788619414635535178188775623838313967013958143619017005079991285469853503718562504927535176713879737569375166451462839457844835806559098448980069427607\n151\n", "output": "319271478\n"}, {"input": "2775577665621060783278861941463553517818877562383831396701395814361901700507999128546985350...
code_stdio
[ { "content": "One day, Chef prepared D brand new dishes. He named the i-th dish by a string Si. After the cooking, he decided to categorize each of these D dishes as special or not.\n\nA dish Si is called special if it's name (i.e. the string Si) can be represented in the form of a double string by removing at ...
[{"input": "3\ncdd\n_a_a\n_ed[", "output": "YES\nYES\nNO\n"}, {"input": "3\naba\nabac\naacd", "output": "YES\nNO\nNO\n"}, {"input": "3\nfda\n`a`a\nb`Ze", "output": "NO\nYES\nNO\n"}, {"input": "3\naba\nabac\ndaca", "output": "YES\nNO\nNO\n"}, {"input": "3\naba\nabac\ndaac", "output": "YES\nNO\nNO\n"}, {"input": "3\naba\...
code_stdio
[ { "content": "A sequence of square brackets is regular if by inserting symbols \"+\" and \"1\" into it, you can get a regular mathematical expression from it. For example, sequences \"[[]][]\", \"[]\" and \"[[][[]]]\" β€” are regular, at the same time \"][\", \"[[]\" and \"[[]]][\" β€” are irregular. \n\nDraw the g...
[{"input": "100\n[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\n", "output": "+- -+\n|+- ...
code_stdio
[ { "content": "Given is a string S consisting of L and R.\nLet N be the length of S. There are N squares arranged from left to right, and the i-th character of S from the left is written on the i-th square from the left.\nThe character written on the leftmost square is always R, and the character written on the ...
[{"input": "RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...
code_stdio
[ { "content": "In a building where Polycarp lives there are equal number of flats on each floor. Unfortunately, Polycarp don't remember how many flats are on each floor, but he remembers that the flats are numbered from 1 from lower to upper floors. That is, the first several flats are on the first floor, the ne...
[{"input": "50 70\n3 3\n80 80\n23 23\n11 11\n87 87\n7 7\n63 63\n61 61\n67 67\n53 53\n9 9\n43 43\n55 55\n27 27\n5 5\n1 1\n99 99\n65 65\n37 37\n60 60\n32 32\n38 38\n81 81\n2 2\n34 34\n17 17\n82 82\n26 26\n71 71\n4 4\n16 16\n19 19\n39 39\n51 51\n6 6\n49 49\n64 64\n83 83\n10 10\n56 56\n30 30\n76 76\n90 90\n42 42\n47 47\n91...
code_stdio
[ { "content": "**This Kata is intended as a small challenge for my students**\n\nCreate a function, called ``removeVowels`` (or ``remove_vowels``), that takes a string argument and returns that same string with all vowels removed (vowels are \"a\", \"e\", \"i\", \"o\", \"u\").\n\nWrite Python code to solve this ...
[{"input": "\"scholarstem\"", "output": "[\"schlrstm\"]", "fn_name": "remove_vowels"}, {"input": "\"high fives!\"", "output": "[\"hgh fvs!\"]", "fn_name": "remove_vowels"}, {"input": "\"codewars\"", "output": "[\"cdwrs\"]", "fn_name": "remove_vowels"}, {"input": "\"drake\"", "output": "[\"drk\"]", "fn_name": "remove_vo...
code_functional
[ { "content": "An isogram is a word that has no repeating letters, consecutive or non-consecutive. Implement a function that determines whether a string that contains only letters is an isogram. Assume the empty string is an isogram. Ignore letter case.\n\n```python\nis_isogram(\"Dermatoglyphics\" ) == true\nis_...
[{"input": "\"abcdefghijklmnopqrstuwwxyz\"", "output": "[false]", "fn_name": "is_isogram"}, {"input": "\"abcdefghijklmnopqrstuvwxyz\"", "output": "[true]", "fn_name": "is_isogram"}, {"input": "\"thumbscrewjapingly\"", "output": "[true]", "fn_name": "is_isogram"}, {"input": "\"Dermatoglyphics\"", "output": "[true]", "fn...
code_functional
[ { "content": "Read problems statements in Mandarin Chinese and Russian. \n\nYesterday Chef had a great party and doesn't remember the way he celebreated it. But he found a strange paper in his kitchen containing n digits (lets give them indices from 1 to n and name them a_{1}, a_{2} ... a_{N}). \nChef remember...
[{"input": "10 3\n0324152397\n2\n3\n10", "output": "3\n3\n38\n"}, {"input": "10 3\n0324152397\n4\n3\n10", "output": "7\n3\n38\n"}, {"input": "10 3\n0324152397\n1\n3\n10", "output": "0\n3\n38\n"}, {"input": "10 3\n0324152397\n1\n4\n10", "output": "0\n7\n38\n"}, {"input": "10 3\n0324152397\n7\n3\n10", "output": "9\n3\n38...
code_stdio
[ { "content": "There are n cities situated along the main road of Berland. Cities are represented by their coordinates β€” integer numbers a_1, a_2, ..., a_{n}. All coordinates are pairwise distinct.\n\nIt is possible to get from one city to another only by bus. But all buses and roads are very old, so the Ministe...
[{"input": "20\n105619866 106083760 106090730 105809555 106115212 105155938 105979518 106075627 106145216 105637844 105925719 105498536 105927000 106155938 106134226 106125969 106130588 105464813 106145509 106114971\n", "output": "241 1\n"}, {"input": "20\n105619866 106083760 106090730 105809555 106115212 105155938 105...
code_stdio
[ { "content": "A correct expression of the form a+b=c was written; a, b and c are non-negative integers without leading zeros. In this expression, the plus and equally signs were lost. The task is to restore the expression. In other words, one character '+' and one character '=' should be inserted into given seq...
[{"input": "100277221476489181970323375139380435110027722147648918197032337513938043511002772214764891819703233751393804351100277221476489181970323375139380435120055444295297836394064675027876087022005544429529783639406467502787608702\n", "output": "1002772214764891819703233751393804351100277221476489181970323375139380...
code_stdio
[ { "content": "Polycarp lives on a coordinate line at the point $x = 0$. He goes to his friend that lives at the point $x = a$. Polycarp can move only from left to right, he can pass one unit of length each second.\n\nNow it's raining, so some segments of his way are in the rain. Formally, it's raining on $n$ no...
[{"input": "100 50 1\n1 2\n3 4\n5 6\n7 8\n9 10\n11 12\n13 14\n15 16\n17 18\n19 20\n21 22\n23 24\n25 26\n27 28\n29 30\n31 32\n33 34\n35 36\n37 38\n39 40\n41 42\n43 44\n45 46\n47 48\n49 50\n51 52\n53 54\n55 56\n57 58\n59 60\n61 62\n63 64\n65 66\n67 68\n69 70\n71 72\n73 74\n75 76\n77 78\n79 80\n81 82\n83 84\n85 86\n87 88\...
code_stdio
[ { "content": "Daruma Otoshi\n\nYou are playing a variant of a game called \"Daruma Otoshi (Dharma Block Striking)\".\n\nAt the start of a game, several wooden blocks of the same size but with varying weights are stacked on top of each other, forming a tower. Another block symbolizing Dharma is placed atop. You ...
[{"input": "4\n1 2 3 4\n4\n1 2 3 1\n5\n5 0 3 3 6\n14\n11 7 1 4 3 5 0 1 6 13 10 4 11 5\n5\n1 3 5 2 3\n0", "output": "4\n4\n2\n6\n2\n"}, {"input": "4\n1 2 3 4\n4\n1 2 3 1\n5\n5 0 3 3 6\n14\n11 7 1 4 3 5 4 1 6 13 10 4 6 5\n5\n1 3 5 2 3\n0", "output": "4\n4\n2\n10\n2\n"}, {"input": "4\n1 2 3 4\n4\n1 2 3 1\n5\n5 0 3 3 6\n14...
code_stdio
[ { "content": "Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).\n\nFor example, as a result of typing the...
[{"input": "10\naaaa\naaaab\naaaa\nbaaaa\na\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\na\nb\naaaaa\naaaa\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaba\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\...
code_stdio
[ { "content": "Sunuke received a d-dimensional hypercube with a side length of l1 Γ— ... Γ— ld as a birthday present. Sunuke placed this rectangular parallelepiped so that the range of the i-th coordinate was 0 or more and li or less, and ate the part that satisfied x1 + ... + xd ≀ s. However, xi represents the i-...
[{"input": "5\n12\n27\n15\n17\n149\n123", "output": "867510000\n"}, {"input": "5\n12\n34\n15\n17\n149\n119", "output": "998784000\n"}, {"input": "5\n12\n34\n15\n23\n149\n119", "output": "300622393\n"}, {"input": "5\n12\n27\n15\n22\n149\n151", "output": "449835161\n"}, {"input": "5\n12\n34\n56\n17\n90\n123", "output": "...
code_stdio
[ { "content": "As you have noticed, there are lovely girls in Arpa’s land.\n\nPeople in Arpa's land are numbered from 1 to n. Everyone has exactly one crush, i-th person's crush is person with the number crush_{i}. [Image] \n\nSomeday Arpa shouted Owf loudly from the top of the palace and a funny game started in...
[{"input": "100\n84 94 72 32 61 90 61 2 76 42 35 82 90 29 51 27 65 99 38 41 44 73 100 58 56 64 54 31 14 58 57 64 90 49 73 80 74 19 31 86 73 44 39 43 28 95 23 5 85 5 74 81 34 44 86 30 50 57 94 56 53 42 53 87 92 78 53 49 78 60 37 63 41 19 15 68 25 77 87 48 23 100 54 27 68 84 43 92 76 55 2 94 100 20 92 18 76 83 100 99\n",...
code_stdio
[ { "content": "Yuki made a sugoroku so that everyone can play at the children's association event. In this sugoroku, squares are lined up in a ring, and each square has an integer of 1 or more written on it.\n\nThe player chooses a square as a starting point and places his piece. Advance the pieces clockwise by ...
[{"input": "8\n2 -1 3 -1 1 4 -1 0", "output": "5\n"}, {"input": "8\n3 -1 3 -1 1 4 -1 0", "output": "6\n"}, {"input": "8\n3 -1 3 -1 2 4 -1 0", "output": "6\n"}, {"input": "8\n3 -1 3 -1 0 4 -1 0", "output": "7\n"}, {"input": "8\n3 -1 3 -1 0 4 -1 1", "output": "6\n"}, {"input": "8\n1 1 1 2 11 1 -2 1", "output": "8\n"}, {"...
code_stdio