messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "Given some positive integers, I wish to print the integers such that all take up the same width by adding a minimum number of leading zeroes. No leading zeroes shall be added to the largest integer.\n\nFor example, given `1, 23, 2, 17, 102`, I wish to print out these numbers as follows:\n\n```pyth... | [{"input": "1\n12\n34", "output": "[\"01\\n12\\n34\"]", "fn_name": "print_nums"}, {"input": "1009\n2", "output": "[\"1009\\n0002\"]", "fn_name": "print_nums"}, {"input": "1\n1\n13", "output": "[\"01\\n01\\n13\"]", "fn_name": "print_nums"}, {"input": "1\n8\n27", "output": "[\"01\\n08\\n27\"]", "fn_name": "print_nums"}, ... | code_functional |
[
{
"content": "\"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score...\" β an excerpt from contest rules.\n\nA total of n participants took part in the contest (n β₯ k), and you already know their s... | [{"input": "50 44\n100 100 99 97 95 91 91 84 83 83 79 71 70 69 69 62 61 60 59 59 58 102 58 55 55 54 52 48 47 45 44 44 38 36 38 31 28 28 25 25 24 24 24 22 17 15 14 13 12 4\n", "output": "44\n"}, {"input": "50 44\n100 100 99 97 95 91 91 84 83 83 79 71 70 69 69 62 61 60 59 59 58 58 58 55 55 54 52 48 47 45 44 44 38 36 32 3... | code_stdio |
[
{
"content": "Everything got unclear to us in a far away constellation Tau Ceti. Specifically, the Taucetians choose names to their children in a very peculiar manner.\n\nTwo young parents abac and bbad think what name to give to their first-born child. They decided that the name will be the permutation of lett... | [{"input": "abbabaaabaaabbbbabbbbbababababaaaabbabbbbabbbbbabbbbababbaaaaabbbabbbbabbbbbbabaabababaabbbabababbaz\nabaaabaabbbbaabbbbaabababbaabaabababbbaabbbaaabbabbabbbbbbbbaabbbbbabababbbbaaabaaaabbbbbbbbabababba\n", "output": "abaaabaabbbbaabbbbaabababbaabaabababbbaabbbaaabbabbabbbbbbbbaabbbbbabababbbbaaabaaaabbbbbb... | code_stdio |
[
{
"content": "Increasing E869120 (Ninja E869120)\n\nE869120 You are good at alter ego.\n\nHere are $ N $ members of the PA Lab. But some of them may be E869120.\n\nSo you asked all the $ N $ members of the PA Lab for their names. As a result, the $ N $ members named themselves $ S_1, S_2, S_3, \\ dots, S_N $, r... | [{"input": "5\nE869120\nTMJN\nE869120\nASIAT\nYNYMXIAOLONGBAO", "output": "2\n"}, {"input": "5\nE869120\nTMJN\nE809126\nATIAT\nYNYMXIAOGONLBAO", "output": "1\n"}, {"input": "5\nE86912/\nTMJN\n621908E\nIATSA\nYNYMXIBOGONLBAO", "output": "0\n"}, {"input": "5\nE869120\nTMJN\nE869120\nASIAT\nYNYMXIAOGONLBAO", "output": "2\... | code_stdio |
[
{
"content": "You are given a tree (an undirected connected graph without cycles) and an integer s.\n\nVanya wants to put weights on all edges of the tree so that all weights are non-negative real numbers and their sum is s. At the same time, he wants to make the diameter of the tree as small as possible.\n\nLe... | [{"input": "3 1000000000\n3 2\n2 1\n", "output": "1000000000.0000000000\n"}, {"input": "2 1000000000\n2 1\n", "output": "1000000000.0000000000\n"}, {"input": "6 1\n2 1\n4 3\n2 5\n5 4\n5 6\n", "output": "0.6666666667\n"}, {"input": "6 1\n2 1\n2 3\n2 5\n2 4\n5 6\n", "output": "0.5000000000\n"}, {"input": "6 2\n2 1\n4 3\n... | code_stdio |
[
{
"content": "problem\n\nJOI City will hold a large-scale exposition.\n\nThere are two themes for this exposition, and each of the N exhibition facilities in JOI City will exhibit on one of the two themes.\n\nThe location of the facility is represented by plane coordinates (x, y). To move from the facility at p... | [{"input": "5\n-9 -11\n1 0\n2 -1\n-22 -1\n-37 -2", "output": "21\n"}, {"input": "5\n-1 -1\n23 2\n4 -11\n-25 -1\n-1 -1", "output": "32\n"}, {"input": "5\n-1 -1\n23 2\n7 -11\n-25 0\n-1 -1", "output": "29\n"}, {"input": "5\n-1 -1\n39 2\n7 -11\n-25 0\n-1 -1", "output": "43\n"}, {"input": "5\n-2 -1\n39 2\n19 -22\n-7 0\n-3 -... | code_stdio |
[
{
"content": "In mathematics, a [Diophantine equation](https://en.wikipedia.org/wiki/Diophantine_equation) is a polynomial equation, usually with two or more unknowns, such that only the integer solutions are sought or studied.\n\nIn this kata we want to find all integers `x, y` (`x >= 0, y >= 0`) solutions of ... | [{"input": "900000012", "output": "[[[225000004, 112500001], [75000004, 37499999], [3358276, 1679071], [1119604, 559601]]]", "fn_name": "sol_equa"}, {"input": "90000001", "output": "[[[45000001, 22500000], [6428575, 3214284], [3461545, 1730766], [494551, 247230]]]", "fn_name": "sol_equa"}, {"input": "90009", "output": ... | code_functional |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nToday is Chef's birthday. His mom gifted him a truly lovable gift, a permutation of first N positive integers.\n\nShe placed the permutation on a very long table in front of Chef and left it for him to play with it. But as there was a ... | [{"input": "2\n0 2\n1 3\n11 -1\n2", "output": "Chef\nChef\n"}, {"input": "2\n0 2\n0 3\n11 -1\n2", "output": "Chef\nChef\n"}, {"input": "2\n0 2\n0 3\n11 -2\n2", "output": "Chef\nChef\n"}, {"input": "2\n3 2\n1 4\n13 1\n1", "output": "Chef\nChef\n"}, {"input": "2\n3 2\n1 4\n25 1\n1", "output": "Chef\nChef\n"}, {"input": "... | code_stdio |
[
{
"content": "Find the largest square number not exceeding N. Here, a square number is an integer that can be represented as the square of an integer.\n\n-----Constraints-----\n - 1 \\leq N \\leq 10^9\n - N is an integer.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nN\n\n----... | [{"input": "1205711547", "output": "1205686729\n"}, {"input": "1258489257", "output": "1258475625\n"}, {"input": "1044195797", "output": "1044194596\n"}, {"input": "271828182\n", "output": "271821169\n"}, {"input": "115087508", "output": "115068529\n"}, {"input": "167542739", "output": "167521249\n"}, {"input": "317532... | code_stdio |
[
{
"content": "You are given a string $s$ of length $n$ consisting of characters a and/or b.\n\nLet $\\operatorname{AB}(s)$ be the number of occurrences of string ab in $s$ as a substring. Analogically, $\\operatorname{BA}(s)$ is the number of occurrences of ba in $s$ as a substring.\n\nIn one step, you can choo... | [{"input": "1\naaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbab\n", "output": "baaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbab\n"}, {"input": "1\nabbabababbabababbababbbabbbbabbbabaabaabba\n", "output": "abbabababbabababbababbbabbbbabbbabaabaabba\n"}, {"input": "1\nabbabababbabababbababbbabbbbabbbabaabaabba\n", "output": "abbabab... | code_stdio |
[
{
"content": "Patrick likes to play baseball, but sometimes he will spend so many hours hitting home runs that his mind starts to get foggy! Patrick is sure that his scores across $n$ sessions follow the identity permutation (ie. in the first game he scores $1$ point, in the second game he scores $2$ points and... | [{"input": "5\n5\n1 3 4 2 5\n4\n2 1 3 4\n5\n2 1 3 5 4\n7\n3 2 4 1 5 7 6\n6\n3 2 1 6 5 4\n", "output": "1\n1\n2\n2\n2\n"}, {"input": "5\n5\n1 3 4 2 5\n4\n2 1 3 4\n5\n2 1 3 5 4\n7\n3 2 4 1 5 7 6\n6\n3 2 1 6 5 1\n", "output": "1\n1\n2\n2\n2\n"}, {"input": "5\n5\n1 3 4 2 5\n4\n2 1 3 4\n5\n2 1 3 5 4\n7\n3 1 4 1 5 7 6\n6\n3 ... | code_stdio |
[
{
"content": "One day Sasha visited the farmer 2D and his famous magnetic farm. On this farm, the crop grows due to the influence of a special magnetic field. Maintaining of the magnetic field is provided by $n$ machines, and the power of the $i$-th machine is $a_i$. \n\nThis year 2D decided to cultivate a new ... | [{"input": "166\n61 19 19 67 11 11 73 89 73 11 47 2 59 43 61 31 19 83 71 19 29 97 89 97 2 11 5 73 19 2 19 7 41 53 5 23 11 89 2 23 47 47 83 71 17 71 67 67 43 3 29 97 17 83 11 19 67 17 97 7 19 29 29 41 13 71 29 19 19 43 47 17 71 3 13 71 41 19 47 7 29 43 29 97 31 11 43 17 23 83 37 61 79 31 17 5 59 13 67 29 29 11 43 67 89 ... | code_stdio |
[
{
"content": "It is raining heavily. But this is the first day for Serval, who just became 3 years old, to go to the kindergarten. Unfortunately, he lives far from kindergarten, and his father is too busy to drive him there. The only choice for this poor little boy is to wait for a bus on this rainy day. Under ... | [{"input": "37 99816\n19935 98486\n13473 97526\n12932 94864\n12400 98868\n13485 96232\n10902 93340\n10315 93206\n14926 98755\n13524 99060\n10391 94409\n14740 94040\n16968 94901\n18543 98563\n16376 96008\n16802 95903\n19742 97400\n10380 97416\n13674 91688\n16347 99505\n17541 91909\n19573 93640\n11353 96027\n10659 99302\... | 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\n"}, {"input": "10\n8 2 10 3 4 6 1 7 9 5\n8 2 10 3 4 6 1 7 9 5\n", "output": "0\n"}, {"input": "10\n2 1 10 3 7 8 5 6 9 4\n6 9 2 4 1 10 3 7 8 5\n", "output": "3\n"}, {"input": "10\n1 6... | code_stdio |
[
{
"content": "Itβs still hot every day, but September has already come. Itβs autumn according to the calendar. Looking around, I see two red dragonflies at rest on the wall in front of me. Itβs autumn indeed.\n\nWhen two red dragonfliesβ positional information as measured from the end of the wall is given, make... | [{"input": "-7 1028", "output": "1035\n"}, {"input": "-2 1028", "output": "1030\n"}, {"input": "-2 1094", "output": "1096\n"}, {"input": "-2 1349", "output": "1351\n"}, {"input": "-3 1349", "output": "1352\n"}, {"input": "-3 1765", "output": "1768\n"}, {"input": "-3 1569", "output": "1572\n"}, {"input": "-125 1", "outp... | code_stdio |
[
{
"content": "Summer holidays! Someone is going on trips, someone is visiting grandparents, but someone is trying to get a part-time job. This summer Noora decided that she wants to earn some money, and took a job in a shop as an assistant.\n\nShop, where Noora is working, has a plan on the following n days. Fo... | [{"input": "50 2\n74 90\n68 33\n49 88\n52 13\n73 21\n77 63\n27 62\n8 52\n60 57\n42 83\n98 15\n79 11\n77 46\n55 91\n72 100\n70 86\n50 51\n57 39\n20 54\n64 95\n66 22\n79 64\n31 28\n11 89\n1 36\n13 4\n75 62\n16 62\n100 35\n43 96\n97 54\n86 33\n62 63\n94 24\n19 6\n20 58\n38 38\n11 76\n70 40\n44 24\n32 96\n28 100\n62 45\n41... | code_stdio |
[
{
"content": "Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit... | [{"input": "100\n1 1 0 0 1 1 1 1 0 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 0 1 0 0 0 0 1 1 1 1 0 0 1 0 0 1 1 0 1 1 1 1 1 1 0 0 0 0 1 1 0 0 0 0 0 1 1 0 1 0 0 1 0 0 1 0 1 0 0 0 0 1 0 1 1 0 1 1 1 1 0 0 1 1 0 0 0 0 1 1 1 0 0 1 0 0\n", "output": "1446\n"}, {"input": "100\n1 1 0 0 1 1 1 1 0 1 1 1 0 1 1 1 0 0 0 0 0 0 1 1 0 1 0 0 0 0 1 ... | code_stdio |
[
{
"content": "Shichi-Go-San (literally \"Seven-Five-Three\") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.\nTakahashi is now X years old. Will his growth be celebrated in Shichi-Go-San this time?\n\n-----Constraints-----\n - 1 β€ X β€ 9\n - X is ... | [{"input": "-132", "output": "NO\n"}, {"input": "-154", "output": "NO\n"}, {"input": "-133", "output": "NO\n"}, {"input": "-108", "output": "NO\n"}, {"input": "1271", "output": "NO\n"}, {"input": "5\n", "output": "YES\n"}, {"input": "3\n", "output": "YES\n"}, {"input": "7\n", "output": "YES\n"}, {"input": "-12", "outpu... | code_stdio |
[
{
"content": "Two students of AtCoder Kindergarten are fighting over candy packs.\nThere are three candy packs, each of which contains a, b, and c candies, respectively.\nTeacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whethe... | [{"input": "10 30 20\n", "output": "Yes\n"}, {"input": "30 30 100\n", "output": "No\n"}, {"input": "56 25 31\n", "output": "Yes\n"}, {"input": "30 30 000", "output": "Yes\n"}, {"input": "106 25 31", "output": "No\n"}, {"input": "30 47 100", "output": "No\n"}, {"input": "30 26 100", "output": "No\n"}, {"input": "30 16 1... | code_stdio |
[
{
"content": "ΠΠ°ΡΡΠ° Π·Π²ΡΠ·Π΄Π½ΠΎΠ³ΠΎ Π½Π΅Π±Π° ΠΏΡΠ΅Π΄ΡΡΠ°Π²Π»ΡΠ΅Ρ ΡΠΎΠ±ΠΎΠΉ ΠΏΡΡΠΌΠΎΡΠ³ΠΎΠ»ΡΠ½ΠΎΠ΅ ΠΏΠΎΠ»Π΅, ΡΠΎΡΡΠΎΡΡΠ΅Π΅ ΠΈΠ· n ΡΡΡΠΎΠΊ ΠΏΠΎ m ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ² Π² ΠΊΠ°ΠΆΠ΄ΠΎΠΉ ΡΡΡΠΎΠΊΠ΅. ΠΠ°ΠΆΠ΄ΡΠΉ ΡΠΈΠΌΠ²ΠΎΠ»Β β ΡΡΠΎ Π»ΠΈΠ±ΠΎ Β«.Β» (ΠΎΠ·Π½Π°ΡΠ°Π΅Ρ ΠΏΡΡΡΠΎΠΉ ΡΡΠ°ΡΡΠΎΠΊ Π½Π΅Π±Π°), Π»ΠΈΠ±ΠΎ Β«*Β» (ΠΎΠ·Π½Π°ΡΠ°Π΅Ρ ΡΠΎ, ΡΡΠΎ Π² ΡΡΠΎΠΌ ΠΌΠ΅ΡΡΠ΅ Π½Π° Π½Π΅Π±Π΅ Π΅ΡΡΡ Π·Π²Π΅Π·Π΄Π°). \n\nΠΠΎΠ²ΠΎΠ΅ ΠΈΠ·Π΄Π°Π½ΠΈΠ΅ ΠΊΠ°ΡΡΡ Π·Π²ΡΠ·Π΄Π½ΠΎΠ³ΠΎ Π½Π΅Π±Π° Π±ΡΠ΄Π΅Ρ Π½Π°ΠΏΠ΅ΡΠ°ΡΠ°Π½ΠΎ Π½Π° ΠΊΠ²Π°Π΄... | [{"input": "7 10\n..........\n......*...\n....**..*.\n...**.....\n...*......\n..........\n..**.*....\n", "output": "7\n"}, {"input": "3 9\n.........\n......*..\n.........\n", "output": "1\n"}, {"input": "5 5\n....*\n....*\n....*\n..*..\n..*.*\n", "output": "5\n"}, {"input": "5 5\n.....\n..*..\n*....\n.....\n.....\n", "... | code_stdio |
[
{
"content": "Complete the function which returns the weekday according to the input number:\n\n* `1` returns `\"Sunday\"`\n* `2` returns `\"Monday\"`\n* `3` returns `\"Tuesday\"`\n* `4` returns `\"Wednesday\"`\n* `5` returns `\"Thursday\"`\n* `6` returns `\"Friday\"`\n* `7` returns `\"Saturday\"`\n* Otherwise ... | [{"input": "20", "output": "[\"Wrong, please enter a number between 1 and 7\"]", "fn_name": "whatday"}, {"input": "0", "output": "[\"Wrong, please enter a number between 1 and 7\"]", "fn_name": "whatday"}, {"input": "8", "output": "[\"Wrong, please enter a number between 1 and 7\"]", "fn_name": "whatday"}, {"input": "4... | code_functional |
[
{
"content": "You are a member of the space station engineering team, and are assigned a task in the construction process of the station. You are expected to write a computer program to complete the task.\n\nThe space station is made up with a number of units, called cells. All cells are sphere-shaped, but thei... | [{"input": "3\n10.428063836405636 10.000 50.41258054211165 10.000\n40.000 10.67607738240928 53.01420883969367 10.791354692497457\n40.998260752412115 40.51646067399203 50.343828752057796 10.89540561727416\n2\n30.571866538226903 30.21421585553614 30.992025805702255 20.557461946050214\n40.000 40.897526923182255 40.8505801... | code_stdio |
[
{
"content": "For a given two numbers your mission is to derive a function that evaluates whether two given numbers are **abundant**, **deficient** or **perfect** and whether together they are **amicable**.\n\n\n\n### Abundant Numbers\nAn abundant number or excessive number is a number for which the sum of its ... | [{"input": "220221\n282224", "output": "[\"deficient abundant not amicable\"]", "fn_name": "deficiently_abundant_amicable_numbers"}, {"input": "299920\n9284", "output": "[\"abundant deficient not amicable\"]", "fn_name": "deficiently_abundant_amicable_numbers"}, {"input": "999220\n2849", "output": "[\"abundant deficien... | code_functional |
[
{
"content": "To give credit where credit is due: This problem was taken from the ACMICPC-Northwest Regional Programming Contest. Thank you problem writers.\n\nYou are helping an archaeologist decipher some runes. He knows that this ancient society used a Base 10 system, and that they never start a number with ... | [{"input": "\"-7715?5--484?00=-28?9?5\"", "output": "[6]", "fn_name": "solve_runes"}, {"input": "\"50685?--1?5630=652?8?\"", "output": "[4]", "fn_name": "solve_runes"}, {"input": "\"-?56373--9216=-?47157\"", "output": "[8]", "fn_name": "solve_runes"}, {"input": "\"?8?170-1?6256=7?2?14\"", "output": "[9]", "fn_name": "s... | code_functional |
[
{
"content": "Obesity is cited as the cause of many adult diseases. In the past, with a few exceptions, it was unrelated to high school students. However, it is no longer unrealistic to suffer from lack of exercise due to excessive studying for entrance exams, or to become bulimia nervosa due to stress. It may ... | [{"input": "1011,50.0,1.60\n1002,60.1,0.70\n1003,60.0,0.80\n1004,80.0,1.71\n1005,90.0,1.60", "output": "1002\n1003\n1004\n1005\n"}, {"input": "1011,50.0,1.60\n1102,60.1,0.70\n1003,60.0,0.80\n1004,80.0,1.71\n1005,80.0,1.60", "output": "1102\n1003\n1004\n1005\n"}, {"input": "1011,50.0,1.61\n1072,60.0,1.00\n1003,70.8,1.00... | code_stdio |
[
{
"content": "On her way to programming school tiger Dasha faced her first test β a huge staircase! [Image] \n\nThe steps were numbered from one to infinity. As we know, tigers are very fond of all striped things, it is possible that it has something to do with their color. So on some interval of her way she ca... | [{"input": "100 100\n", "output": "YES\n"}, {"input": "100 100\n", "output": "YES\n"}, {"input": "100 101\n", "output": "YES\n"}, {"input": "110 111\n", "output": "YES\n"}, {"input": "111 111\n", "output": "YES\n"}, {"input": "100 99\n", "output": "YES\n"}, {"input": "99 100\n", "output": "YES\n"}, {"input": "100 99\n"... | code_stdio |
[
{
"content": "Given an integer `n`, find two integers `a` and `b` such that:\n```Pearl\nA) a >= 0 and b >= 0\nB) a + b = n\nC) DigitSum(a) + Digitsum(b) is maximum of all possibilities. \n```\nYou will return the digitSum(a) + digitsum(b). \n\n```\nFor example:\nsolve(29) = 11. If we take 15 + 14 = 29 and digi... | [{"input": "15569047737", "output": "[144]", "fn_name": "solve"}, {"input": "2452148459", "output": "[116]", "fn_name": "solve"}, {"input": "50000000", "output": "[68]", "fn_name": "solve"}, {"input": "1140", "output": "[33]", "fn_name": "solve"}, {"input": "7019", "output": "[35]", "fn_name": "solve"}, {"input": "18",... | code_functional |
[
{
"content": "Takahashi is going to set a 3-character password.\nHow many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)?\n\n-----Constraints-----\n - 1 \\leq N \\leq 9\n - N is an integer.\n\n-----Input-----\nInput is given from Standard Input in the followin... | [{"input": "-109", "output": "-1295029\n"}, {"input": "-61", "output": "-226981\n"}, {"input": "-57", "output": "-185193\n"}, {"input": "-68", "output": "-314432\n"}, {"input": "-95", "output": "-857375\n"}, {"input": "-52", "output": "-140608\n"}, {"input": "-59", "output": "-205379\n"}, {"input": "148", "output": "32... | code_stdio |
[
{
"content": "Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers.\n\nA common divisor for two positive numbers is a number which both numbers are divisible by.\n\nBut your teacher wants to give you a... | [{"input": "31607 999002449\n18\n31607 31607\n31606 31608\n31607 31608\n31606 31607\n31606 31606\n31608 31608\n1 31607\n1 31606\n1 31608\n1 1000000000\n31607 1000000000\n31606 1000000000\n31608 1000000000\n1000000000 1000000000\n1 1\n2 31606\n2 31607\n2 31608\n", "output": "31607\n31607\n31607\n31607\n-1\n-1\n31607\n1\... | code_stdio |
[
{
"content": "Given a sequence of numbers a1, a2, a3, ..., an, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a contiquous subsequence.\n\n\n\nInput\n\nThe input consists of multiple datasets. Each data set consists of:\n\n\nn\na1\na2\n.\n.\nan... | [{"input": "7\n-4\n-4\n6\n14\n15\n-8\n-14\n13\n1\n0\n3\n2\n-3\n-1\n1\n1\n5\n3\n0\n-6\n2\n3\n1100\n-200\n145\n0", "output": "35\n12\n1100\n"}, {"input": "7\n-5\n-4\n6\n8\n15\n-6\n-12\n13\n1\n2\n3\n2\n-2\n-1\n1\n1\n3\n2\n0\n-4\n2\n3\n1100\n-200\n145\n0", "output": "29\n12\n1100\n"}, {"input": "7\n-5\n-4\n6\n8\n15\n-6\n-1... | code_stdio |
[
{
"content": "This problem consists of three subproblems: for solving subproblem C1 you will receive 4 points, for solving subproblem C2 you will receive 4 points, and for solving subproblem C3 you will receive 8 points.\n\nManao decided to pursue a fighter's career. He decided to begin with an ongoing tourname... | [{"input": "40 3\n1 62395\n5 40319\n4 165445\n10 137479\n10 47829\n8 9741\n5 148106\n10 25494\n10 162856\n2 106581\n0 194523\n9 148086\n1 100862\n6 147600\n6 107486\n6 166873\n7 16721\n4 22192\n0 8827\n1 197146\n10 8949\n0 150443\n9 148348\n3 143935\n1 139371\n7 128821\n10 107760\n4 141821\n1 35852\n9 107522\n10 54717\... | code_stdio |
[
{
"content": "Bankopolis is an incredible city in which all the n crossroads are located on a straight line and numbered from 1 to n along it. On each crossroad there is a bank office.\n\nThe crossroads are connected with m oriented bicycle lanes (the i-th lane goes from crossroad ui to crossroad vi), the diffi... | [{"input": "10 7\n50\n4 7 655\n7 3 220\n3 5 15\n5 10 811\n10 1 490\n1 2 800\n7 10 200\n1 5 377\n1 4 656\n6 4 432\n3 7 563\n1 8 122\n2 9 777\n3 2 157\n5 8 912\n9 8 496\n9 2 740\n3 2 201\n6 7 653\n1 7 554\n6 9 660\n3 2 622\n6 10 227\n9 1 42\n2 6 346\n2 7 944\n3 10 654\n5 2 501\n1 6 786\n3 8 306\n6 1 998\n6 2 581\n10 1 84... | code_stdio |
[
{
"content": "Petya has an array $a$ consisting of $n$ integers. He wants to remove duplicate (equal) elements.\n\nPetya wants to leave only the rightmost entry (occurrence) for each element of the array. The relative order of the remaining unique elements should not be changed.\n\n\n-----Input-----\n\nThe firs... | [{"input": "48\n992 995 992 991 994 992 995 999 996 993 999 995 993 992 1000 992 568 996 991 993 992 998 998 998 999 995 992 992 993 992 992 995 996 995 997 991 997 991 999 994 994 997 1000 32 1000 992 1000 999\n", "output": "12\n568 998 993 996 995 991 994 997 32 992 1000 999\n"}, {"input": "49\n991 997 995 991 995 99... | code_stdio |
[
{
"content": "We have A balls with the string S written on each of them and B balls with the string T written on each of them.\n\nFrom these balls, Takahashi chooses one with the string U written on it and throws it away.\n\nFind the number of balls with the string S and balls with the string T that we have now... | [{"input": "abcdeabcde opqrsopqrs\n7 2\nabcdeabcde\n", "output": "6 2\n"}, {"input": "airport door\n5 5\nairport\n", "output": "4 5\n"}, {"input": "length depth\n3 1\nlength\n", "output": "2 1\n"}, {"input": "tea coffee\n4 4\ncoffee\n", "output": "4 3\n"}, {"input": "rice bread\n3 6\nbread\n", "output": "3 5\n"}, {"inp... | code_stdio |
[
{
"content": "Create a function that takes a positive integer and returns the next bigger number that can be formed by rearranging its digits. For example:\n\n```\n12 ==> 21\n513 ==> 531\n2017 ==> 2071\n```\n\nIf the digits can't be rearranged to form a bigger number, return `-1` (or `nil` in Swift):\n\n```\n9 ... | [{"input": "59884848459853", "output": "[59884848483559]", "fn_name": "next_bigger"}, {"input": "1234567890", "output": "[1234567908]", "fn_name": "next_bigger"}, {"input": "123456789", "output": "[123456798]", "fn_name": "next_bigger"}, {"input": "9876543210", "output": "[-1]", "fn_name": "next_bigger"}, {"input": "99... | code_functional |
[
{
"content": "Alice and Bob have participated to a Rock Off with their bands. A jury of true metalheads rates the two challenges, awarding points to the bands on a scale from 1 to 50 for three categories: Song Heaviness, Originality, and Members' outfits.\n\nFor each one of these 3 categories they are going to ... | [{"input": "[47, 7, 2]\n[47, 7, 2]", "output": "[\"0, 0: that looks like a \\\"draw\\\"! Rock on!\"]", "fn_name": "solve"}, {"input": "[5, 6, 7]\n[3, 6, 10]", "output": "[\"1, 1: that looks like a \\\"draw\\\"! Rock on!\"]", "fn_name": "solve"}, {"input": "[47, 50, 22]\n[26, 47, 12]", "output": "[\"3, 0: Alice made \\\... | code_functional |
[
{
"content": "Let \\mathrm{popcount}(n) be the number of `1`s in the binary representation of n. For example, \\mathrm{popcount}(3) = 2, \\mathrm{popcount}(7) = 3, and \\mathrm{popcount}(0) = 0.\n\nLet f(n) be the number of times the following operation will be done when we repeat it until n becomes 0: \"replac... | [{"input": "23\n00110111001011011001111", "output": "3\n3\n2\n2\n3\n3\n2\n3\n3\n3\n2\n2\n3\n2\n2\n2\n2\n3\n2\n3\n3\n3\n2\n"}, {"input": "23\n00110111001011011101111", "output": "4\n4\n3\n3\n4\n3\n3\n3\n4\n4\n3\n4\n3\n3\n4\n3\n3\n3\n4\n3\n3\n3\n2\n"}, {"input": "23\n00110111001011011101101", "output": "3\n3\n2\n2\n3\n3\... | code_stdio |
[
{
"content": "The developers of Looksery have to write an efficient algorithm that detects faces on a picture. Unfortunately, they are currently busy preparing a contest for you, so you will have to do it for them. \n\nIn this problem an image is a rectangular table that consists of lowercase Latin letters. A f... | [{"input": "9 46\nuuexbaacesjclggslacermcbkxlcxhdgqtacdwfryxzuxc\naclrsaefakndbnzlkefenuphgcgoedhkaxefjtnkgfeaca\nefuqunpmfxdyyffyhvracozzrxlpekhtsrfhlilfmyhefg\numyacfzffvicqtdpiulefnwcojuwtfbvlxkfsiapdnzpqo\nactefvuxqptremlqjhdbdwacjxdxitxjktecvefacamjcz\neflarseklqrkayhosverpfefzirqigzlxezabhzeferkwm\nztpypwxyohtacs... | code_stdio |
[
{
"content": "Read problems statements in Russian also. \nChef likes playing with strings. The most interesting game are named \"CHEF in string\". The move of the game consists of the following: Chef takes a subsequence of string's letters that form the word \"CHEF\" and then he removes that symbols. The goal o... | [{"input": "CHEFCHEFFFF\n", "output": "2"}, {"input": "CIEFCHEFFFF", "output": "1\n"}, {"input": "BHHHEEFFFCC", "output": "0\n"}, {"input": "CHEFCHEFGFF", "output": "2\n"}, {"input": "CHHHEEFFFCC", "output": "1\n"}, {"input": "FIEFCHECFFF", "output": "1\n"}, {"input": "FJEFCHECFFF", "output": "1\n"}, {"input": "BHIHEEF... | code_stdio |
[
{
"content": "F: Grid number\n\nproblem\n\nEbi-chan is trying to write exactly one integer from 1 to 2 \\ times n in a grid with n columns horizontally and 2 rows vertically.\n\nOnly one integer can be written to each cell in the grid.\n\nIt's not fun just to write normally, so I set the following rules.\n\n* T... | [{"input": "8 10 37", "output": "24\n"}, {"input": "5 4 11", "output": "10\n"}, {"input": "5 3 17", "output": "16\n"}, {"input": "5 4 18", "output": "14\n"}, {"input": "8 6 37", "output": "21\n"}, {"input": "8 6 42", "output": "34\n"}, {"input": "8 6 39", "output": "37\n"}, {"input": "8 6 77", "output": "13\n"}, {"inpu... | code_stdio |
[
{
"content": "There are two main kinds of events in the life of top-model: fashion shows and photo shoots. Participating in any of these events affects the rating of appropriate top-model. After each photo shoot model's rating increases by a and after each fashion show decreases by b (designers do too many expe... | [{"input": "10 1 1 1 2 0 10\n1 1\n2 1\n3 0\n4 0\n5 1\n6 1\n14 1\n8 1\n9 1\n10 1\n", "output": "5\n"}, {"input": "10 1 1 1 2 0 10\n1 1\n2 1\n3 0\n4 0\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n", "output": "5\n"}, {"input": "10 1 1 1 2 0 10\n1 1\n2 1\n3 0\n4 0\n5 1\n6 1\n7 1\n8 1\n5 1\n10 1\n", "output": "5\n"}, {"input": "5 1 1 -... | code_stdio |
[
{
"content": "The goddess of programming is reviewing a thick logbook, which is a yearly record of visitors to her holy altar of programming. The logbook also records her visits at the altar.\n\nThe altar attracts programmers from all over the world because one visitor is chosen every year and endowed with a gi... | [{"input": "14\n04/21 09:00 I 000\n04/21 09:00 I 001\n04/21 09:15 I 002\n04/21 90:30 O 001\n04/21 09:45 O 000\n12/40 10:00 O 002\n04/28 09:00 I 003\n04/28 09:15 I 000\n04/28 09:30 I 004\n04/28 09:45 P 004\n04/28 10:00 O 000\n04/28 10:15 O 003\n04/29 20:00 I 002\n04/29 21:30 O 002\n20\n06/01 09:00 I 001\n06/01 09:15 I 0... | code_stdio |
[
{
"content": "Little Vasya had n boxes with balls in the room. The boxes stood in a row and were numbered with numbers from 1 to n from left to right.\n\nOnce Vasya chose one of the boxes, let's assume that its number is i, took all balls out from it (it is guaranteed that this box originally had at least one b... | [{"input": "48 19\n227460648 746912227 51958075 682685526 1080381698 666833118 492590399 167395932 678377837 125106811 638633256 713194370 386921921 34175133 704550052 220688092 499436761 495071386 57379330 137372655 0 720974146 209203457 946682102 237312198 943872065 957150897 357568282 367006748 0 730509325 68523190 ... | code_stdio |
[
{
"content": "Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed.\n\nNumbers in this system are written as a sequence of one or more digits. We define the... | [{"input": "1000000000\n", "output": "48999999753\n"}, {"input": "1000000001\n", "output": "48999999802\n"}, {"input": "1897400395\n", "output": "92972619108\n"}, {"input": "1100000001\n", "output": "53899999802\n"}, {"input": "1533257378\n", "output": "75129611275\n"}, {"input": "1100000011\n", "output": "53900000292\... | code_stdio |
[
{
"content": "There is a puzzle to complete by combining 14 numbers from 1 to 9. Complete by adding another number to the given 13 numbers.\n\nThe conditions for completing the puzzle are\n\n* You must have one combination of the same numbers.\n* The remaining 12 numbers are 4 combinations of 3 numbers.\nThe co... | [{"input": "3649596966777\n4672433573317\n9118992346175\n9643871425498\n7755542764533\n1133557799246", "output": "2 3 5 8\n1 2 4 5 7\n1 2 3 4 5 6 7 8 9\n7 8 9\n1 2 3 4 6 7 8\n0\n"}, {"input": "3649596966777\n4672433573317\n9118992346175\n9643871425498\n7755542764533\n1079549632139", "output": "2 3 5 8\n1 2 4 5 7\n1 2 3... | code_stdio |
[
{
"content": "You are given a positive integer $m$ and two integer sequence: $a=[a_1, a_2, \\ldots, a_n]$ and $b=[b_1, b_2, \\ldots, b_n]$. Both of these sequence have a length $n$.\n\nPermutation is a sequence of $n$ different positive integers from $1$ to $n$. For example, these sequences are permutations: $[... | [{"input": "20 1000000000\n667066860 170421783 139902912 635488786 31946329 289281524 541340760 264115900 680775010 102068388 128171043 636359373 477042326 879154458 716982402 654668379 256334407 874949294 737194458 663371809\n688973261 813186249 677241392 581016678 216137209 424019643 428224807 184559135 203738728 185... | code_stdio |
[
{
"content": "Imagine you have an infinite 2D plane with Cartesian coordinate system. Some of the integral points are blocked, and others are not. Two integral points A and B on the plane are 4-connected if and only if:\n\n * the Euclidean distance between A and B is one unit and neither A nor B is blocked; \n... | [{"input": "18855321\n", "output": "106661800\n"}, {"input": "34609610\n", "output": "195781516\n"}, {"input": "40000000\n", "output": "226274168\n"}, {"input": "38450759\n", "output": "217510336\n"}, {"input": "39099999\n", "output": "221182992\n"}, {"input": "30426905\n", "output": "172120564\n"}, {"input": "39999996... | code_stdio |
[
{
"content": "Write a function that takes a positive integer n, sums all the cubed values from 1 to n, and returns that sum.\n\nAssume that the input n will always be a positive integer.\n\nExamples:\n\n```python\nsum_cubes(2)\n> 9 \n# sum of the cubes of 1 and 2 is 1 + 8\n```\n\nWrite Python code to solve this... | [{"input": "123", "output": "[58155876]", "fn_name": "sum_cubes"}, {"input": "10", "output": "[3025]", "fn_name": "sum_cubes"}, {"input": "4", "output": "[100]", "fn_name": "sum_cubes"}, {"input": "3", "output": "[36]", "fn_name": "sum_cubes"}, {"input": "1", "output": "[1]", "fn_name": "sum_cubes"}, {"input": "2", "ou... | code_functional |
[
{
"content": "Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won.\n\nHaving carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The p... | [{"input": "284254589153928171911281811000\n1009 1000\n", "output": "YES\n2842545891539\n28171911281811000\n"}, {"input": "284254589153928171911281811000\n1009 1100\n", "output": "YES\n2842545891539\n28171911281811000\n"}, {"input": "284254589153928171911281811000\n1009 1000\n", "output": "YES\n2842545891539\n281719112... | code_stdio |
[
{
"content": "AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.\n\nThe company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.\n\nHow many different PIN co... | [{"input": "19\n5546189040285140044", "output": "273\n"}, {"input": "19\n4753841743850076999", "output": "311\n"}, {"input": "19\n9039528710159876563", "output": "412\n"}, {"input": "19\n3616863455241776042", "output": "322\n"}, {"input": "19\n2785343766571511696", "output": "239\n"}, {"input": "19\n2922045480066417189... | code_stdio |
[
{
"content": "Bob is about to take a hot bath. \n\nThere are two taps to fill the bath: a hot water tap and a cold water tap. The cold water's temperature is t1, and the hot water's temperature is t2. The cold water tap can transmit any integer number of water units per second from 0 to x1, inclusive. Similarly... | [{"input": "1000000 1000000 1000000 1000000 1000000\n", "output": "1000000 1000000\n"}, {"input": "1000000 1000000 999999 999998 1000000\n", "output": "999999 999998\n"}, {"input": "176902 1481077 847541 412251 587604\n", "output": "616526 283398\n"}, {"input": "1000000 1001000 1000000 1000000 1000000\n", "output": "10... | code_stdio |
[
{
"content": "Arkady and his friends love playing checkers on an $n \\times n$ field. The rows and the columns of the field are enumerated from $1$ to $n$.\n\nThe friends have recently won a championship, so Arkady wants to please them with some candies. Remembering an old parable (but not its moral), Arkady wa... | [{"input": "1000000000 1\n", "output": "1000000000000000000\n"}, {"input": "1000000000 1000\n", "output": "3400000000000000\n"}, {"input": "1100000000 1000\n", "output": "4114000000000000\n"}, {"input": "1000010000 1\n", "output": "1000020000100000000\n"}, {"input": "1100010000 1000\n", "output": "4114074800340000\n"},... | code_stdio |
[
{
"content": "You are given a rectangular matrix of size $n \\times m$ consisting of integers from $1$ to $2 \\cdot 10^5$.\n\nIn one move, you can: choose any element of the matrix and change its value to any integer between $1$ and $n \\cdot m$, inclusive; take any column and shift it one cell up cyclically ... | [{"input": "7 8\n110137 66175 74657 124739 63011 153464 30956 8\n9 62369 169892 183765 84737 20941 35760 132079\n20802 67434 149925 53269 150062 35286 50218 112696\n153864 26 7405 121648 170439 115181 195278 127323\n136381 197880 57522 109132 104537 38 39 47930\n51739 77547 43 169711 18955 134957 7223 37489\n53153 1084... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nAditi recently discovered a new magic trick. First, she gives you an integer N and asks you to think an integer between 1 and N. Then she gives you a bundle of cards each having a sorted list (in ascending order) of some distinct integ... | [{"input": "2\n12\n191", "output": "5\n11\n"}, {"input": "2\n14\n108", "output": "6\n10\n"}, {"input": "2\n21\n114", "output": "7\n10\n"}, {"input": "2\n25\n193", "output": "7\n11\n"}, {"input": "2\n38\n107", "output": "8\n10\n"}, {"input": "2\n14\n204", "output": "6\n11\n"}, {"input": "2\n25\n333", "output": "7\n12\n"... | code_stdio |
[
{
"content": "You are given an undirected connected weighted graph consisting of $n$ vertices and $m$ edges. Let's denote the length of the shortest path from vertex $1$ to vertex $i$ as $d_i$. \n\nYou have to erase some edges of the graph so that at most $k$ edges remain. Let's call a vertex $i$ good if there ... | [{"input": "9 9 7\n1 2 1000000000\n7 9 1000000000\n9 4 1000000000\n2 6 1000000000\n2 3 1000000000\n3 7 1000000000\n6 8 1000000000\n8 4 1000000000\n4 5 1000000000\n", "output": "7\n1 5 4 6 7 8 2 \n"}, {"input": "9 9 7\n1 2 1000000000\n7 9 1000000000\n9 4 1000000000\n2 6 1000000000\n2 3 1000000000\n3 7 1000000000\n6 8 10... | code_stdio |
[
{
"content": "Peter likes to travel by train. He likes it so much that on the train he falls asleep. \n\nOnce in summer Peter was going by train from city A to city B, and as usual, was sleeping. Then he woke up, started to look through the window and noticed that every railway station has a flag of a particula... | [{"input": "aababaaababaabbaabababaaababaabababbaabbabaabababaabbabbbababbababababababaabababaababaaaabababaabab\nabaabababaa\nabaabbaa\n", "output": "backward\n"}, {"input": "aababaaababaabbaabababaaababaabababbaabbabaabababaabbabbbababbababababababaabababaababaaaabababaabab\nabaabababaa\naabbaaba\n", "output": "backw... | code_stdio |
[
{
"content": "A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), ... | [{"input": "1\n1\n10\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n", "output": "even\neven\neven\neven\neven\neven\neven\neven\neven\neven\n"}, {"input": "1\n1\n10\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n", "output": "even\neven\neven\neven\neven\neven\neven\neven\neven\neven\n"}, {"input": "7\n2 6 1 7... | code_stdio |
[
{
"content": "Dima is a beginner programmer. During his working process, he regularly has to repeat the following operation again and again: to remove every second element from the array. One day he has been bored with easy solutions of this problem, and he has come up with the following extravagant algorithm.\... | [{"input": "12 12\n10\n11\n5\n3\n11\n2\n8\n6\n4\n4\n12\n1\n", "output": "9\n6\n3\n2\n6\n7\n12\n8\n10\n10\n11\n1\n"}, {"input": "12 12\n9\n11\n5\n3\n11\n2\n8\n4\n4\n4\n12\n1\n", "output": "5\n6\n3\n2\n6\n7\n12\n10\n10\n10\n11\n1\n"}, {"input": "12 12\n9\n11\n5\n3\n11\n2\n8\n6\n4\n4\n12\n1\n", "output": "5\n6\n3\n2\n6\n7... | code_stdio |
[
{
"content": "A and B are preparing themselves for programming contests.\n\nThe University where A and B study is a set of rooms connected by corridors. Overall, the University has n rooms connected by n - 1 corridors so that you can get from any room to any other one by moving along the corridors. The rooms ar... | [{"input": "15\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n5 8\n6 9\n9 14\n14 15\n7 10\n4 13\n3 11\n3 12\n6\n10 15\n13 12\n2 15\n8 4\n15 12\n6 13\n", "output": "1\n10\n1\n7\n0\n4\n"}, {"input": "15\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n5 8\n6 9\n9 14\n14 15\n7 10\n4 13\n4 11\n3 12\n6\n10 15\n13 12\n2 15\n8 4\n15 12\n6 13\n", "output": "1\... | code_stdio |
[
{
"content": "# How much is the fish! (- Scooter )\nThe ocean is full of colorful fishes. We as programmers want to know the hexadecimal value of these fishes.\n\n## Task\nTake all hexadecimal valid characters (a,b,c,d,e,f) of the given name and XOR them. Return the result as an integer.\n\n## Input\nThe input ... | [{"input": "\"African glass catfish\"", "output": "[0]", "fn_name": "fisHex"}, {"input": "\"Airbreathing catfish\"", "output": "[12]", "fn_name": "fisHex"}, {"input": "\"Australasian salmon\"", "output": "[10]", "fn_name": "fisHex"}, {"input": "\"Atlantic silverside\"", "output": "[1]", "fn_name": "fisHex"}, {"input": ... | code_functional |
[
{
"content": "This is an easy version of the problem. The only difference between an easy and a hard version is in the number of queries.\n\nPolycarp grew a tree from $n$ vertices. We remind you that a tree of $n$ vertices is an undirected connected graph of $n$ vertices and $n-1$ edges that does not contain cy... | [{"input": "19\n15 19\n19 1\n12 19\n18 9\n13 19\n4 18\n19 11\n19 17\n5 9\n14 19\n8 19\n19 6\n16 9\n19 7\n3 19\n19 9\n19 10\n9 2\n5\n19\n11 12 18 14 2 3 16 15 4 17 8 9 19 1 10 13 7 6 5\n12\n1 2 4 5 7 8 9 12 13 14 15 16\n19\n5 17 2 19 1 18 7 12 15 14 4 9 16 10 11 3 13 8 6\n12\n2 3 4 5 6 7 9 10 12 14 16 18\n19\n8 10 18 1 ... | code_stdio |
[
{
"content": "Limak is a little polar bear. He loves connecting with other bears via social networks. He has n friends and his relation with the i-th of them is described by a unique integer t_{i}. The bigger this value is, the better the friendship is. No two friends have the same value t_{i}.\n\nSpring is sta... | [{"input": "20 2 15\n1744261 55128070 116962690 156763505 188535242 194018601 134662359 428710623 442819431 483000923 516768937 552903993 633087286 373594646 415184994 714291344 717660646 846508634 879748146 937368929\n2 20\n1 2\n2 2\n1 19\n1 12\n2 2\n2 18\n2 11\n1 16\n2 1\n2 3\n2 19\n1 17\n2 9\n2 6\n", "output": "NO\n... | code_stdio |
[
{
"content": "For a given sequence $A = \\\\{a_0, a_1, ... a_{n-1}\\\\}$, the number of pairs $(i, j)$ where $a_i > a_j$ and $i < j$, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following program:\n\n\nbubbleSort(A)\ncnt = 0 // the n... | [{"input": "5\n3 -13 7 -1 -4", "output": "6\n"}, {"input": "5\n3 -13 10 0 -4", "output": "6\n"}, {"input": "5\n3 -13 10 0 -5", "output": "6\n"}, {"input": "5\n2 -13 10 0 -5", "output": "6\n"}, {"input": "5\n2 -13 10 0 -1", "output": "6\n"}, {"input": "5\n0 -13 10 0 -1", "output": "5\n"}, {"input": "5\n0 -13 17 0 -1", "... | code_stdio |
[
{
"content": "There are $n$ detachments on the surface, numbered from $1$ to $n$, the $i$-th detachment is placed in a point with coordinates $(x_i, y_i)$. All detachments are placed in different points.\n\nBrimstone should visit each detachment at least once. You can choose the detachment where Brimstone start... | [{"input": "23\n-1000000000 -964752353\n-967012509 -1000000000\n34021744 1000000000\n-931956512 -34021744\n-1034253 967204159\n-1034253 -34021744\n-1034253 -1000000000\n-931956512 -1000000000\n-967012509 1000000000\n964944003 1225903\n1000000000 1225903\n-967012509 1225903\n-1034253 -964752353\n-931956512 1000000000\n3... | code_stdio |
[
{
"content": "You are given an array $a$ consisting of $n$ integers $a_1, a_2, \\dots, a_n$. You want to split it into exactly $k$ non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for each subsegment, the sum of all elements that belong to this subsegment is odd). It is imposs... | [{"input": "3\n5 3\n7 18 3 14 1\n5 4\n1 2 3 4 1\n6 3\n3 1 1 4 10 0\n", "output": "YES\n1 3 5\nNO\nYES\n1 2 6\n"}, {"input": "3\n5 3\n7 18 3 14 1\n5 4\n1 2 3 4 5\n6 2\n3 1 8 4 10 2\n", "output": "YES\n1 3 5\nNO\nYES\n1 6\n"}, {"input": "3\n5 3\n7 18 3 14 1\n5 4\n1 2 3 4 1\n6 2\n3 1 8 4 10 2\n", "output": "YES\n1 3 5\nNO... | code_stdio |
[
{
"content": "You've got an array a, consisting of n integers. The array elements are indexed from 1 to n. Let's determine a two step operation like that:\n\n 1. First we build by the array a an array s of partial sums, consisting of n elements. Element number i (1 β€ i β€ n) of array s equals <image>. The opera... | [{"input": "42 42\n42 42 42 42 74 42 42 42 3 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 59 42 42 42 42 42\n", "output": "42 1806 39732 595980 6853802 64426782 515432400 608248315 553670947 820980301 784579711 753219887 714714707 805611691 208784644 262712997 126286707 369857538 724... | code_stdio |
[
{
"content": "You've just entered a programming contest and have a chance to win a million dollars. This is the last question you have to solve, so your victory (and your vacation) depend on it. Can you guess the function just by looking at the test cases? There are two numerical inputs and one numerical output... | [{"input": "123\n456", "output": "[1419]", "fn_name": "code"}, {"input": "200\n100", "output": "[1698]", "fn_name": "code"}, {"input": "100\n200", "output": "[1698]", "fn_name": "code"}, {"input": "12\n8", "output": "[88]", "fn_name": "code"}, {"input": "3\n2", "output": "[13]", "fn_name": "code"}, {"input": "1\n1", "o... | code_functional |
[
{
"content": "You will be given an array of strings. The words in the array should mesh together where one or more letters at the end of one word will have the same letters (in the same order) as the next word in the array. But, there are times when all the words won't mesh. \n\nExamples of meshed words:\n\n \... | [{"input": "[\"peanutbutterandjellyontoast\", \"jellyontoastcanbepleasant\", \"bepleasantpleaseorleave\", \"ventyouranger\", \"rangersinthepark\"]", "output": "[\"jellyontoastbepleasantveranger\"]", "fn_name": "word_mesh"}, {"input": "[\"caughtinthemiddle\", \"thesunshinesinthemiddle\", \"themiddleearthwasarealplaceint... | code_functional |
[
{
"content": "A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R.\nTakahashi placed a mass of weight A and a mass of weight B on the left pan of a... | [{"input": "3 4 5 2\n", "output": "Balanced\n"}, {"input": "0 8 7 1", "output": "Balanced\n"}, {"input": "4 3 5 2", "output": "Balanced\n"}, {"input": "8 3 8 3", "output": "Balanced\n"}, {"input": "12 6 33 2", "output": "Right\n"}, {"input": "19 6 33 2", "output": "Right\n"}, {"input": "19 6 59 2", "output": "Right\n"}... | code_stdio |
[
{
"content": "Each evening Roma plays online poker on his favourite website. The rules of poker on this website are a bit strange: there are always two players in a hand, there are no bets, and the winner takes 1 virtual bourle from the loser.\n\nLast evening Roma started to play poker. He decided to spend no m... | [{"input": "20 7\n?LLLLLWWWWW?????????\n", "output": "WLLLLLWWWWWWWWWWDDDW\n"}, {"input": "20 6\n?LLLLLWWWWW?????????\n", "output": "WLLLLLWWWWWWWWWDDDDW\n"}, {"input": "20 5\n?LLLLLWWWWW?????????\n", "output": "WLLLLLWWWWWWWWDDDDDW"}, {"input": "10 3\nDWD?DL??LL\n", "output": "DWDWDLLLLL\n"}, {"input": "10 2\nD??W?WL?... | code_stdio |
[
{
"content": "Vasya plays a computer game with ninjas. At this stage Vasya's ninja should get out of a deep canyon.\n\nThe canyon consists of two vertical parallel walls, their height is n meters. Let's imagine that we split these walls into 1 meter-long areas and number them with positive integers from 1 to n ... | [{"input": "001 1\n----------------------------------------------------------------------------------------------------X\n----------------------------------------------------------------------------------------------------X\n", "output": "YES\n"}, {"input": "011 1\n------------------------------------------------------... | code_stdio |
[
{
"content": "Gru has not been in the limelight for a long time and is, therefore, planning something particularly nefarious. Frustrated by his minions' incapability which has kept him away from the limelight, he has built a transmogrifier β a machine which mutates minions.\n\nEach minion has an intrinsic chara... | [{"input": "1\n4 2\n-1 8 1 -1 -1", "output": "0\n"}, {"input": "1\n5 10\n2 4 1 62 1", "output": "1\n"}, {"input": "1\n5 20\n2 4 1 62 1", "output": "2\n"}, {"input": "1\n4 2\n0 14 1 -1 1", "output": "0\n"}, {"input": "1\n4 2\n0 15 1 -1 1", "output": "0\n"}, {"input": "1\n5 10\n2 6 1 35 1", "output": "0\n"}, {"input": "1... | code_stdio |
[
{
"content": "Mr. A loves sweets, but recently his wife has told him to go on a diet. One day, when Mr. A went out from his home to the city hall, his wife recommended that he go by bicycle. There, Mr. A reluctantly went out on a bicycle, but Mr. A, who likes sweets, came up with the idea of ββstopping by a cak... | [{"input": "1 1 2 5\n13\nH L1 18\nC1 D 6\nC1 H 12\nL1 D 10\nC1 L1 24\n2 2 4 6\n100 112\nH L1 10\nC1 L1 12\nC1 D 11\nC2 L1 7\nC2 D 12\nL1 D 8\n0 0 0 0", "output": "23\n-24\n"}, {"input": "1 1 2 5\n25\nH L1 18\nC1 D 6\nC1 H 12\nL1 D 10\nC1 L1 24\n2 2 4 6\n100 112\nH L1 10\nC1 L1 12\nC1 D 11\nC2 L1 2\nC2 D 7\nL1 D 8\n0 0 ... | code_stdio |
[
{
"content": "Given an array $a$ of length $n$, find another array, $b$, of length $n$ such that:\n\n for each $i$ $(1 \\le i \\le n)$ $MEX(\\{b_1$, $b_2$, $\\ldots$, $b_i\\})=a_i$. \n\nThe $MEX$ of a set of integers is the smallest non-negative integer that doesn't belong to this set.\n\nIf such array doesn't... | [{"input": "10\n1 2 3 4 4 4 7 7 7 10\n", "output": "0 1 2 3 5 6 4 8 9 7 "}, {"input": "10\n1 2 3 4 4 4 7 7 7 10\n", "output": "0 1 2 3 5 6 4 8 9 7\n"}, {"input": "7\n0 0 2 2 3 5 6\n", "output": "1 4 0 7 2 3 5 \n"}, {"input": "7\n0 0 2 2 3 5 7\n", "output": "1 4 0 6 2 3 5 \n"}, {"input": "7\n0 0 2 4 5 5 6\n", "output": ... | code_stdio |
[
{
"content": "Vlad has $n$ friends, for each of whom he wants to buy one gift for the New Year.\n\nThere are $m$ shops in the city, in each of which he can buy a gift for any of his friends. If the $j$-th friend ($1 \\le j \\le n$) receives a gift bought in the shop with the number $i$ ($1 \\le i \\le m$), then... | [{"input": "5\n\n2 2\n2 2\n3 3\n\n4 3\n1 5 1\n0 1 0\n2 2 2\n2 2 3\n\n2 3\n0 4 4\n3 2 1\n\n4 2\n14 15\n8 -1\n9 1\n2 23\n\n2 4\n6 6 2 1\n7 -1 9 0\n", "output": "3\n2\n3\n14\n1\n"}, {"input": "5\n\n2 2\n2 2\n3 7\n\n4 3\n1 3 1\n3 1 1\n1 2 2\n1 2 5\n\n2 3\n-1 3 4\n2 2 1\n\n4 2\n7 9\n8 1\n16 14\n4 13\n\n2 4\n6 8 0 2\n7 -1 7 ... | code_stdio |
[
{
"content": "An `non decreasing` number is one containing no two consecutive digits (left to right), whose the first is higer than the second. For example, 1235 is an non decreasing number, 1229 is too, but 123429 isn't.\n\nWrite a function that finds the number of non decreasing numbers up to `10**N` (exclusi... | [{"input": "50", "output": "[12565671261]", "fn_name": "increasing_numbers"}, {"input": "20", "output": "[10015005]", "fn_name": "increasing_numbers"}, {"input": "10", "output": "[92378]", "fn_name": "increasing_numbers"}, {"input": "5", "output": "[2002]", "fn_name": "increasing_numbers"}, {"input": "6", "output": "[5... | code_functional |
[
{
"content": "There is unrest in the Galactic Senate. Several thousand solar systems have declared their intentions to leave the Republic. Master Heidi needs to select the Jedi Knights who will go on peacekeeping missions throughout the galaxy. It is well-known that the success of any peacekeeping mission depen... | [{"input": "6 6\n1 1 3 2 2 2\n1 0 0 1 0 0\n", "output": "-1\n"}, {"input": "6 6\n4 3 5 4 5 2\n0 1 0 1 2 0\n", "output": "0\n"}, {"input": "6 6\n1 1 3 2 2 2\n1 0 0 0 0 0\n", "output": "0\n"}, {"input": "6 6\n4 3 5 6 5 5\n0 0 1 1 0 0\n", "output": "0\n"}, {"input": "6 6\n6 2 6 2 5 4\n0 1 0 0 0 1\n", "output": "0\n"}, {"i... | code_stdio |
[
{
"content": "You are given sequence a_1, a_2, ..., a_{n} of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.\n\nSubsequence is a sequence that can be derived fro... | [{"input": "59\n8593 5929 3016 -859 4366 -6842 8435 -3910 -2458 -8503 -3612 -9793 -5360 -9791 -362 -7180 727 -6245 -8869 -7316 8214 -7944 7098 3788 -5436 -6626 -1131 -2410 -5647 -7981 263 -5879 8786 709 6489 5316 -4039 4909 -4340 7979 -89 9844 -906 172 -7674 -3371 -6828 9505 3284 5895 3646 6680 -1255 3635 -9547 -5104 -... | code_stdio |
[
{
"content": "Fox Ciel is playing a game with numbers now. \n\nCiel has n positive integers: x_1, x_2, ..., x_{n}. She can do the following operation as many times as needed: select two different indexes i and j such that x_{i} > x_{j} hold, and then apply assignment x_{i} = x_{i} - x_{j}. The goal is to make t... | [{"input": "100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100... | code_stdio |
[
{
"content": "The magic sum of 3s is calculated on an array by summing up odd numbers which include the digit `3`. Write a function `magic_sum` which accepts an array of integers and returns the sum.\n\n*Example:* `[3, 12, 5, 8, 30, 13]` results in `16` (`3` + `13`)\n\nIf the sum cannot be calculated, `0` shoul... | [{"input": "[3, 12, 5, 8, 30, 13]", "output": "[16]", "fn_name": "magic_sum"}, {"input": "[30, 34, 330]", "output": "[0]", "fn_name": "magic_sum"}, {"input": "[3, 13]", "output": "[16]", "fn_name": "magic_sum"}, {"input": "null", "output": "[0]", "fn_name": "magic_sum"}, {"input": "[3]", "output": "[3]", "fn_name": "ma... | code_functional |
[
{
"content": "Limak is a little bear who loves to play. Today he is playing by destroying block towers. He built n towers in a row. The i-th tower is made of h_{i} identical blocks. For clarification see picture for the first sample.\n\nLimak will repeat the following operation till everything is destroyed.\n\n... | [{"input": "170\n1 2 1 2 1 1 1 1 2 3 2 1 1 2 2 1 2 1 2 1 1 2 3 3 2 1 1 1 1 1 1 1 1 2 1 2 3 3 2 1 2 2 1 2 3 2 1 1 2 3 2 1 2 1 1 1 2 3 3 2 1 2 1 2 1 1 1 2 1 2 1 1 2 2 1 1 2 1 2 2 1 2 1 2 2 1 2 1 2 3 2 1 1 2 3 4 4 3 2 1 2 1 2 1 2 3 3 2 1 2 1 1 1 1 1 1 1 2 2 1 1 2 1 1 1 1 2 1 1 2 3 2 1 2 2 1 2 1 1 1 2 2 1 2 1 2 3 2 1 2 1 1... | code_stdio |
[
{
"content": "You are given an integer sequence $1, 2, \\dots, n$. You have to divide it into two sets $A$ and $B$ in such a way that each element belongs to exactly one set and $|sum(A) - sum(B)|$ is minimum possible.\n\nThe value $|x|$ is the absolute value of $x$ and $sum(S)$ is the sum of elements of the se... | [{"input": "2000000000\n", "output": "0\n"}, {"input": "1999999999\n", "output": "0\n"}, {"input": "1999999997\n", "output": "1\n"}, {"input": "1999999998\n", "output": "1\n"}, {"input": "1000271094\n", "output": "1\n"}, {"input": "1825468885\n", "output": "1\n"}, {"input": "1000080110\n", "output": "1\n"}, {"input": "... | code_stdio |
[
{
"content": "Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special β it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initi... | [{"input": "100 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1... | code_stdio |
[
{
"content": "In the wake of the npm's `left-pad` debacle, you decide to write a new super padding method that superceds the functionality of `left-pad`. Your version will provide the same functionality, but will additionally add right, and justified padding of string -- the `super_pad`.\n\nYour function `super... | [{"input": "\"some other test\"\n10\n\"nope\"", "output": "[\"other test\"]", "fn_name": "super_pad"}, {"input": "\"some other test\"\n10\n\"> \"", "output": "[\"some other\"]", "fn_name": "super_pad"}, {"input": "\"test\"\n7\n\"^more complex\"", "output": "[\"motestm\"]", "fn_name": "super_pad"}, {"input": "\"test\"\n... | code_functional |
[
{
"content": "Drazil has many friends. Some of them are happy and some of them are unhappy. Drazil wants to make all his friends become happy. So he invented the following plan.\n\nThere are n boys and m girls among his friends. Let's number them from 0 to n - 1 and 0 to m - 1 separately. In i-th day, Drazil in... | [{"input": "91 98\n78 0 1 2 3 4 5 7 8 9 10 11 12 14 15 16 17 18 19 21 22 23 24 25 26 28 29 30 31 32 33 35 36 37 38 39 40 42 43 44 45 46 47 49 50 51 52 53 54 56 57 58 59 60 61 63 64 65 66 67 68 70 71 72 73 74 75 77 78 79 80 81 82 84 85 86 87 88 89\n84 0 1 2 3 4 5 7 8 9 10 11 12 14 15 16 17 18 19 21 22 23 24 25 26 28 29 ... | code_stdio |
[
{
"content": "n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winn... | [{"input": "100 2\n62 70 35 14 12 87 94 78 39 92 84 91 129 49 82 33 69 37 19 61 42 8 45 97 81 22 54 67 1 22 77 25 65 17 18 28 25 57 16 90 40 13 4 21 68 35 15 76 73 93 56 111 79 47 74 75 30 71 130 99 68 24 29 83 5 6 31 96 38 80 27 46 51 53 2 86 35 9 20 100 26 36 63 7 52 55 23 3 50 59 48 118 167 44 34 64 13 72 7 98\n", "... | code_stdio |
[
{
"content": "A long time ago (probably even in the first book), Nicholas Flamel, a great alchemist and the creator of the Philosopher's Stone, taught Harry Potter three useful spells. The first one allows you to convert a grams of sand into b grams of lead, the second one allows you to convert c grams of lead ... | [{"input": "911 728 910 407 833 594\n", "output": "Hermione\n"}, {"input": "632 446 352 317 522 451\n", "output": "Hermione\n"}, {"input": "542 11 820 850 1201 738\n", "output": "Hermione\n"}, {"input": "911 728 910 180 833 594\n", "output": "Hermione\n"}, {"input": "542 11 820 850 791 738\n", "output": "Hermione\n"}, ... | code_stdio |
[
{
"content": "You are given sequences A and B consisting of non-negative integers.\nThe lengths of both A and B are N, and the sums of the elements in A and B are equal.\nThe i-th element in A is A_i, and the i-th element in B is B_i.\nTozan and Gezan repeats the following sequence of operations:\n - If A and B... | [{"input": "3\n11 3\n-1 1\n2 8", "output": "9\n"}, {"input": "3\n8 3\n0 1\n4 8\n", "output": "9\n"}, {"input": "3\n8 3\n-1 1\n5 8", "output": "9\n"}, {"input": "3\n8 3\n-1 0\n4 8", "output": "8\n"}, {"input": "3\n8 3\n0 1\n4 8", "output": "9"}, {"input": "2\n-1 1\n1 -1", "output": "1\n"}, {"input": "2\n-1 -1\n1 1", "ou... | code_stdio |
[
{
"content": "Aoki is playing with a sequence of numbers a_{1}, a_{2}, ..., a_{N}. Every second, he performs the following operation :\n\n* Choose a positive integer k. For each element of the sequence v, Aoki may choose to replace v with its remainder when divided by k, or do nothing with v. The cost of this o... | [{"input": "3\n2 20 33\n2 2 13", "output": "1048584\n"}, {"input": "3\n23 10 26\n0 4 7", "output": "524354\n"}, {"input": "3\n7 23 26\n3 6 5", "output": "131216\n"}, {"input": "3\n23 10 31\n0 4 6", "output": "66114\n"}, {"input": "3\n7 23 23\n3 6 5", "output": "131152\n"}, {"input": "3\n23 10 31\n1 4 6", "output": "661... | code_stdio |
[
{
"content": "Two players A and B have a list of $n$ integers each. They both want to maximize the subtraction between their score and their opponent's score. \n\nIn one turn, a player can either add to his score any element from his list (assuming his list is not empty), the element is removed from the list af... | [{"input": "29\n254369 14511 114048 683934 553812 575014 620356 217938 286195 131704 268393 78202 296626 986697 175814 600746 146985 215868 740052 711417 11221 944700 940915 53378 698708 878644 704035 120164 437165\n3415 443979 327875 491782 974937 176118 37957 316844 12044 156497 462613 338831 796707 658031 906915 955... | code_stdio |
[
{
"content": "There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and therefore knows exactly that the animal number i in the queue ... | [{"input": "150 2476\n70 21 114 127 22 11 29 59 51 59 35 3 53 88 5 8 44 4 8 100 1 27 1 25 27 56 48 22 23 103 85 66 14 58 20 7 176 11 19 26 105 97 83 3 29 30 52 92 59 11 135 37 59 8 66 20 47 19 143 16 93 18 57 71 1 13 141 1 119 6 2 87 40 68 28 22 20 53 31 19 15 33 32 9 70 63 16 26 77 7 45 52 73 25 22 21 68 79 16 3 164 2... | 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 has two strings a and b of the same length n. The strings consist on... | [{"input": "44447774444474477747774774477777474774744744477444447777477477744747477774744444744777777777747777477447744774744444747477744744\n77777474477477747774777777474474477444474777477747747777477747747744474474747774747747444777474444744744444477477777747744747477\n", "output": "37\n"}, {"input": "774774747744474... | code_stdio |
[
{
"content": "Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \\leq k \\leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transform... | [{"input": "1\n440\ntcjbjlbtjfmvzdqutuwzvmgqrqtrvxwrdacxcowbmbwvwssihttgdsjntiawqavwspzmybakxmwpbcgaffpyhvjrulqsorkcuozvtdbkkmasxtemrrbhqnmkpgewwphdvcyhxmatrfjkesacujihmtyqtqcjfqhpsjhgzimegvkjylapylqprykvkjavlmipewlzqsfefjzecadsqmfutgnegngmwchqttcyklocfcyuhghvtygdbsxaoxkvtgdcnsqddzzakhgrribwxkuakxkjneasowsadprpcusmbevu... | code_stdio |
[
{
"content": "Complete the function that takes a string as an input, and return a list of all the unpaired characters (i.e. they show up an odd number of times in the string), in the order they were encountered as an array. \n\nIn case of multiple appearances to choose from, take the last occurence of the unpai... | [{"input": "\"\\u00bc x 4 = 1 and \\u00bd x 4 = 2\"", "output": "[[\"\\u00bc\", \"1\", \"a\", \"n\", \"d\", \"\\u00bd\", \"2\"]]", "fn_name": "odd_one_out"}, {"input": "\"Codewars\"", "output": "[[\"C\", \"o\", \"d\", \"e\", \"w\", \"a\", \"r\", \"s\"]]", "fn_name": "odd_one_out"}, {"input": "\"Hello World\"", "output"... | code_functional |
[
{
"content": "The concept of \"[smooth number](https://en.wikipedia.org/wiki/Smooth_number)\" is applied to all those numbers whose prime factors are lesser than or equal to `7`: `60` is a smooth number (`2 * 2 * 3 * 5`), `111` is not (`3 * 37`).\n\nMore specifically, smooth numbers are classified by their high... | [{"input": "3125", "output": "[\"Hamming number\"]", "fn_name": "is_smooth"}, {"input": "60", "output": "[\"Hamming number\"]", "fn_name": "is_smooth"}, {"input": "98", "output": "[\"humble number\"]", "fn_name": "is_smooth"}, {"input": "4096", "output": "[\"power of 2\"]", "fn_name": "is_smooth"}, {"input": "7", "outp... | code_functional |
[
{
"content": "We guessed a permutation $p$ consisting of $n$ integers. The permutation of length $n$ is the array of length $n$ where each element from $1$ to $n$ appears exactly once. This permutation is a secret for you.\n\nFor each position $r$ from $2$ to $n$ we chose some other index $l$ ($l < r$) and gave... | [{"input": "5\n6\n3 2 5 6\n2 4 6\n3 1 3 4\n2 1 3\n4 1 2 4 6\n5\n2 2 3\n2 1 2\n2 1 4\n2 4 5\n7\n3 1 2 6\n4 1 3 5 6\n2 1 2\n3 4 5 7\n6 1 2 3 4 5 6\n3 1 3 6\n2\n2 1 2\n5\n2 2 5\n3 2 3 5\n4 2 3 4 5\n5 1 2 3 4 5\n", "output": "3 1 4 6 2 5 \n3 2 1 4 5 \n2 1 6 3 5 4 7 \n1 2 \n2 5 3 4 1 \n"}, {"input": "5\n6\n3 2 5 6\n2 4 6\n3... | code_stdio |
[
{
"content": "You have to create a function named reverseIt.\n\nWrite your function so that in the case a string or a number is passed in as the data , you will return the data in reverse order. If the data is any other type, return it as it is.\n\n\nExamples of inputs and subsequent outputs:\n```\n\"Hello\" ->... | [{"input": "[1, 2, 3]", "output": "[[1, 2, 3]]", "fn_name": "reverse_it"}, {"input": "\"314159\"", "output": "[\"951413\"]", "fn_name": "reverse_it"}, {"input": "\"Hello\"", "output": "[\"olleH\"]", "fn_name": "reverse_it"}, {"input": "314159", "output": "[951413]", "fn_name": "reverse_it"}, {"input": "true", "output":... | code_functional |
[
{
"content": "You have a multiset containing several integers. Initially, it contains $a_1$ elements equal to $1$, $a_2$ elements equal to $2$, ..., $a_n$ elements equal to $n$.\n\nYou may apply two types of operations: choose two integers $l$ and $r$ ($l \\le r$), then remove one occurrence of $l$, one occurr... | [{"input": "20\n1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2\n", "output": "11\n"}, {"input": "20\n1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2\n", "output": "11\n"}, {"input": "20\n1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 3\n", "output": "11\n"}, {"input": "20\n1 2 1 2 1 2 0 2 1 2 1 2 1 2 1 2 1 2 1 3\n", "output": "12\n"}, {"input... | code_stdio |
[
{
"content": "You're given two arrays $a[1 \\dots n]$ and $b[1 \\dots n]$, both of the same length $n$.\n\nIn order to perform a push operation, you have to choose three integers $l, r, k$ satisfying $1 \\le l \\le r \\le n$ and $k > 0$. Then, you will add $k$ to elements $a_l, a_{l+1}, \\ldots, a_r$.\n\nFor ex... | [{"input": "4\n6\n3 7 1 4 1 2\n3 7 3 6 3 2\n5\n1 1 1 1 1\n1 2 1 3 1\n2\n42 42\n42 42\n1\n7\n6\n", "output": "YES\nNO\nYES\nNO\n"}, {"input": "4\n6\n3 7 1 4 1 2\n3 7 3 6 3 2\n5\n1 1 1 1 1\n1 2 1 3 1\n2\n42 42\n42 48\n1\n7\n6\n", "output": "YES\nNO\nYES\nNO\n"}, {"input": "4\n6\n3 7 1 4 1 2\n3 7 3 6 3 2\n5\n1 1 1 1 1\n1 ... | code_stdio |
[
{
"content": "You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\n* For each element x in b, the value x... | [{"input": "8\n12 13 1 15 2 2 1 12", "output": "5\n"}, {"input": "8\n4 13 1 15 2 8 1 12", "output": "7\n"}, {"input": "8\n4 13 1 15 2 2 1 12", "output": "5\n"}, {"input": "8\n6 13 1 15 2 2 1 12", "output": "5\n"}, {"input": "8\n12 13 1 0 2 2 1 12", "output": "5\n"}, {"input": "8\n12 13 1 1 2 2 1 12", "output": "5\n"}, ... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.