messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "Gildong has bought a famous painting software cfpaint. The working screen of cfpaint is square-shaped consisting of $n$ rows and $n$ columns of square cells. The rows are numbered from $1$ to $n$, from top to bottom, and the columns are numbered from $1$ to $n$, from left to right. The position of...
[{"input": "9 9\nBWBBWWWXW\nBWAWWWWWW\nWBWBBBBBB\nWWBBBWWWB\nWWBWBXBWW\nWBWWBBWWB\nWWWBWBWBW\nBBWBBBWWW\nWBWBBWWWW\n", "output": "18\n"}, {"input": "9 9\nBWBBWWWXW\nBWAWWWWWW\nWBWBBBBBB\nWWBBBWWWB\nWWBWBXBWW\nWBWWBBWWB\nWWWBWBWBW\nWWWBBBWBB\nWBWBBWWWW\n", "output": "18\n"}, {"input": "9 4\nBWBBWWWWW\nWWBWBWWWW\nWBWBBBB...
code_stdio
[ { "content": "You are given a positive integer N.\nFind the minimum positive integer divisible by both 2 and N.\n\n-----Constraints-----\n - 1 \\leq N \\leq 10^9\n - All values in input are integers.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nN\n\n-----Output-----\nPrint th...
[{"input": "15607691432", "output": "15607691432\n"}, {"input": "1000000000\n", "output": "1000000000\n"}, {"input": "8325199727", "output": "16650399454\n"}, {"input": "999999999\n", "output": "1999999998\n"}, {"input": "1604548808", "output": "1604548808\n"}, {"input": "1558666763", "output": "3117333526\n"}, {"input...
code_stdio
[ { "content": "You are given a string $s$. You can build new string $p$ from $s$ using the following operation no more than two times: choose any subsequence $s_{i_1}, s_{i_2}, \\dots, s_{i_k}$ where $1 \\le i_1 < i_2 < \\dots < i_k \\le |s|$; erase the chosen subsequence from $s$ ($s$ can become empty); con...
[{"input": "1\nbbbaaaaabbabaabbbbaabbbbabbaabbaababbbbbbababbababbbaaaaaaabaababbbaababbbbababbbabbbbbabaabbaaaabaa\nbbbababbaabbbbbaabaaabaababaaaabaabbbabbababaaabba\n", "output": "YES\n"}, {"input": "1\nbbbaaaaabbabaabbbbaabbbbabbaabbaababbbbbbababbababbbaaaaaaabaababbbaababbbbababbbabbbbbabaabbaaaabaa\nbbbababbaabb...
code_stdio
[ { "content": "Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.\n\nNow the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim...
[{"input": "50\n297 787 34 268 439 629 600 398 425 833 721 908 830 636 64 509 420 647 499 675 427 599 396 119 798 742 577 355 22 847 389 574 766 453 196 772 225 261 106 844 726 975 173 992 874 89 775 616 678 52 69 591 181 573 258 381 665 301 589 379 362 146 790 842 765 100 229 916 938 97 340 793 758 177 736 396 247 562...
code_stdio
[ { "content": "We have a deck consisting of N cards. Each card has an integer written on it. The integer on the i-th card from the top is a_i.\n\nTwo people X and Y will play a game using this deck. Initially, X has a card with Z written on it in his hand, and Y has a card with W written on it in his hand. Then,...
[{"input": "1 1 1\n1010000000", "output": "1009999999\n"}, {"input": "1 1 1\n1010100000", "output": "1010099999\n"}, {"input": "3 100 100\n10 1001 000", "output": "1001\n"}, {"input": "3 100 1001\n10 100 100", "output": "901\n"}, {"input": "3 100 100\n10 0001 000", "output": "100\n"}, {"input": "3 011 100\n6 1000 000",...
code_stdio
[ { "content": "Skyscraper \"MinatoHarukas\"\n\nMr. Port plans to start a new business renting one or more floors of the new skyscraper with one giga floors, MinatoHarukas. He wants to rent as many vertically adjacent floors as possible, because he wants to show advertisement on as many vertically adjacent window...
[{"input": "15\n27\n3\n5\n14453855\n142729211\n251672118\n560550970\n979553853\n999999999\n0", "output": "1 5\n2 6\n1 2\n2 2\n111119 130\n801761 178\n11923 13484\n4003866 140\n7523 37374\n163837 5994\n"}, {"input": "15\n16\n3\n3\n9699690\n237086004\n847288609\n900660121\n987698769\n999999999\n0", "output": "1 5\n16 1\n...
code_stdio
[ { "content": "This is the simple version of Fastest Code series. If you need some challenges, please try the [Performance version](http://www.codewars.com/kata/5714594d2817ff681c000783)\n\n## Task: \n \nGive you a number array ```numbers``` and a number ```c```.\n\nFind out a pair of numbers(we called them n...
[{"input": "[-3, -2, -2, -1, 0, 1, 2, 3, 4]\n4", "output": "[[-2, -2]]", "fn_name": "find_a_b"}, {"input": "[-3, -2, -2, -1, 0, 1, 2, 3, 4]\n0", "output": "[[-3, 0]]", "fn_name": "find_a_b"}, {"input": "[-3, -2, -1, 0, 1, 2, 3, 4]\n4", "output": "[[1, 4]]", "fn_name": "find_a_b"}, {"input": "[1, 2, 3, 4, 5, 6]\n15", "o...
code_functional
[ { "content": "Write a function called `LCS` that accepts two sequences and returns the longest subsequence common to the passed in sequences.\n\n### Subsequence\nA subsequence is different from a substring. The terms of a subsequence need not be consecutive terms of the original sequence.\n\n### Example subsequ...
[{"input": "\"finaltest\"\n\"zzzfinallyzzz\"", "output": "[\"final\"]", "fn_name": "lcs"}, {"input": "\"anothertest\"\n\"notatest\"", "output": "[\"nottest\"]", "fn_name": "lcs"}, {"input": "\"132535365\"\n\"123456789\"", "output": "[\"12356\"]", "fn_name": "lcs"}, {"input": "\"abcdef\"\n\"abc\"", "output": "[\"abc\"]"...
code_functional
[ { "content": "Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker...
[{"input": "10 1 100000000\n999999999 1634812359 999999999 999999999 129546129 999999999 999999999 999999999 1815265208 999999999\n", "output": "99999999 34812359 99999999 99999999 29546129 99999999 99999999 99999999 15265208 99999999\n"}, {"input": "10 1 100000000\n999999999 999999999 999999999 1957501121 999999999 99...
code_stdio
[ { "content": "A map of some object is a rectangular field consisting of n rows and n columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly k islands appear on the map. We will call a set of sand cells to be island if it is possible to get from...
[{"input": "100 5000\n", "output": "YES\nLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLS\nSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSL\nLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSL...
code_stdio
[ { "content": "Stellar history 2005.11.5. You are about to engage an enemy spacecraft as the captain of the UAZ Advance spacecraft. Fortunately, the enemy spaceship is still unnoticed. In addition, the space coordinates of the enemy are already known, and the \"feather cannon\" that emits a powerful straight bea...
[{"input": "-10 6 6\n20 2 5\n1 10 0\n-1 10 10\n0 0 10", "output": "MISS\n"}, {"input": "-10 6 6\n20 2 5\n0 10 0\n-1 10 10\n0 0 10", "output": "MISS\n"}, {"input": "-10 6 6\n20 2 5\n0 10 0\n-1 10 14\n0 0 10", "output": "MISS\n"}, {"input": "-10 6 6\n10 2 6\n0 10 0\n0 10 10\n0 0 10", "output": "MISS\n"}, {"input": "-10 6...
code_stdio
[ { "content": "Arcady is a copywriter. His today's task is to type up an already well-designed story using his favorite text editor.\n\nArcady types words, punctuation signs and spaces one after another. Each letter and each sign (including line feed) requires one keyboard click in order to be printed. Moreover,...
[{"input": "thun-thun-thunder, thunder, thunder\nthunder, thun-, thunder\nthun-thun-thunder, thunder\nthunder, feel the thunder\nlightning then the thunder\nthunder, feel the thunder\nlightning then the thunder\nthunder, thunder\n", "output": "183\n"}, {"input": "thun-thun-thunder, thunder, thunder\nthunder, thun-, thu...
code_stdio
[ { "content": "Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.\nIroha is looking for X,Y,Z-Haiku (defined below) in integer sequences.\nConsider all integer sequences of length N whose elements are between 1 and 10, inclusive. Out of those 10^...
[{"input": "37 4 2 3\n", "output": "863912418\n"}, {"input": "40 5 7 5\n", "output": "562805100\n"}, {"input": "15 10 2 3", "output": "138603924\n"}, {"input": "37 4 3 3", "output": "180978943\n"}, {"input": "37 3 3 3", "output": "632821729\n"}, {"input": "15 5 2 3", "output": "179274801\n"}, {"input": "37 7 2 3", "out...
code_stdio
[ { "content": "We have held a popularity poll for N items on sale. Item i received A_i votes.\nFrom these N items, we will select M as popular items. However, we cannot select an item with less than \\dfrac{1}{4M} of the total number of votes.\nIf M popular items can be selected, print Yes; otherwise, print No.\...
[{"input": "100 100\n1000 999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 92...
code_stdio
[ { "content": "Write a method that takes a string as an argument and groups the number of time each character appears in the string as a hash sorted by the highest number of occurrences.\n\nThe characters should be sorted alphabetically e.g:\n\n```python\nget_char_count(\"cba\") == {1: [\"a\", \"b\", \"c\"]}\n``...
[{"input": "\"France is also bacon\"", "output": "[{\"3\": [\"a\"], \"2\": [\"c\", \"n\", \"o\", \"s\"], \"1\": [\"b\", \"e\", \"f\", \"i\", \"l\", \"r\"]}]", "fn_name": "get_char_count"}, {"input": "\"Get me the bacon!\"", "output": "[{\"3\": [\"e\"], \"2\": [\"t\"], \"1\": [\"a\", \"b\", \"c\", \"g\", \"h\", \"m\", \...
code_functional
[ { "content": "There are N integers a_1, a_2, ..., a_N not less than 1. The values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \\times a_2 \\times ... \\times a_N = P.\n\nFind the maximum possible greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\n* 1 \\leq N \\leq 10^{12}\n* 1 \\...
[{"input": "1 1431379180228", "output": "1431379180228\n"}, {"input": "1 1472895801034", "output": "1472895801034\n"}, {"input": "1 1365467213485", "output": "1365467213485\n"}, {"input": "1 2203800626104", "output": "2203800626104\n"}, {"input": "1 972439611840", "output": "972439611840\n"}, {"input": "1 534720932937"...
code_stdio
[ { "content": "You are given a bracket sequence $s$ of length $n$, where $n$ is even (divisible by two). The string $s$ consists of $\\frac{n}{2}$ opening brackets '(' and $\\frac{n}{2}$ closing brackets ')'.\n\nIn one move, you can choose exactly one bracket and move it to the beginning of the string or to the ...
[{"input": "4\n2\n)(\n4\n()()\n8\n())()()(\n10\n)))((((())\n", "output": "1\n0\n1\n3\n"}, {"input": "4\n2\n)(\n4\n)()(\n8\n())()()(\n10\n)))((((())\n", "output": "1\n1\n1\n3\n"}, {"input": "4\n2\n)(\n4\n()()\n8\n())()()(\n10\n())((()())\n", "output": "1\n0\n1\n1\n"}, {"input": "4\n2\n)(\n4\n()()\n8\n()()())(\n10\n)))((...
code_stdio
[ { "content": "There are N items, numbered 1, 2, \\ldots, N. For each i (1 \\leq i \\leq N), Item i has a weight of w_i and a value of v_i.\n\nTaro has decided to choose some of the N items and carry them home in a knapsack. The capacity of the knapsack is W, which means that the sum of the weights of items take...
[{"input": "6 15\n6 5\n14 6\n6 12\n4 20\n3 16\n1 4", "output": "52\n"}, {"input": "5 31\n4 0\n0 33\n9 6\n16 20\n4 9\n-1 4", "output": "68\n"}, {"input": "6 16\n7 0\n0 11\n9 6\n8 20\n3 10\n1 4", "output": "45\n"}, {"input": "5 31\n4 0\n0 11\n9 6\n16 20\n4 9\n0 4", "output": "46\n"}, {"input": "5 31\n4 0\n0 22\n9 6\n16 2...
code_stdio
[ { "content": "Arthur and Alexander are number busters. Today they've got a competition. \n\nArthur took a group of four integers a, b, w, x (0 ≤ b < w, 0 < x < w) and Alexander took integer с. Arthur and Alexander use distinct approaches to number bustings. Alexander is just a regular guy. Each second, he subtr...
[{"input": "200000000 794 1000 117 2000000000\n", "output": "2038505096\n"}, {"input": "200000000 794 1000 117 2000000000\n", "output": "2038505096\n"}, {"input": "20000000 280 1000 25 2000000000\n", "output": "2030769231\n"}, {"input": "20000000 280 1000 25 2000000000\n", "output": "2030769231\n"}, {"input": "13597422...
code_stdio
[ { "content": "Duff is in love with lovely numbers! A positive integer x is called lovely if and only if there is no such positive integer a > 1 such that a^2 is a divisor of x. [Image] \n\nMalek has a number store! In his store, he has only divisors of positive integer n (and he has all of them). As a birthday ...
[{"input": "817634153013\n", "output": "817634153013\n"}, {"input": "734337660466\n", "output": "734337660466\n"}, {"input": "808453785117\n", "output": "808453785117\n"}, {"input": "294809951965\n", "output": "294809951965\n"}, {"input": "822722434952\n", "output": "205680608738\n"}, {"input": "699511759613\n", "outpu...
code_stdio
[ { "content": "Ashish has an array a of consisting of 2n positive integers. He wants to compress a into an array b of size n-1. To do this, he first discards exactly 2 (any two) elements from a. He then performs the following operation until there are no elements left in a: \n\n * Remove any two elements from a...
[{"input": "10\n9\n8 8 2 6 2 7 4 1 6 5 2 4 8 3 2 3 6 8\n6\n1 8 8 2 2 7 6 7 8 9 1 7\n5\n4 2 9 6 8 7 7 5 7 4\n9\n4 10 7 7 8 5 4 9 6 5 1 1 7 6 3 3 1 10\n4\n8 8 2 2 9 7 4 8\n3\n5 2 8 2 4 2\n9\n5 8 8 10 7 3 10 8 7 9 4 2 5 9 10 4 6 1\n5\n8 1 4 1 6 6 2 2 5 10\n10\n6 5 5 3 9 10 4 8 5 1 4 7 10 4 2 2 7 8 7 3\n8\n3 8 5 5 9 3 10 7...
code_stdio
[ { "content": "# Story\n\nWell, here I am stuck in another traffic jam.\n\n\n*Damn all those courteous people!*\n\nCars are trying to enter the main road from side-streets somewhere ahead of me and people keep letting them cut in.\n\nEach time somebody is let in the effect ripples back down the road, so pretty s...
[{"input": "\"abcdefghijklmnopqrstuvwX\"\n[\"AAA\", \"BBB\", \"CCC\", \"DDD\", \"EEE\", \"FFF\", \"GGG\", \"HHH\", \"III\", \"JJJ\", \"KKK\", \"LLL\", \"MMM\", \"NNN\", \"OOO\", \"PPP\", \"QQQ\", \"RRR\", \"SSS\", \"TTT\", \"UUU\", \"VVV\", \"WWW\"]", "output": "[\"aAbABAcBCBdCDCeDEDfEFEgFGFhGHGiHIHjIJIkJKJlKLKmLMLnMNM...
code_functional
[ { "content": "You are given an array $a$ of length $n$, which initially is a permutation of numbers from $1$ to $n$. In one operation, you can choose an index $i$ ($1 \\leq i < n$) such that $a_i < a_{i + 1}$, and remove either $a_i$ or $a_{i + 1}$ from the array (after the removal, the remaining parts are conc...
[{"input": "4\n3\n1 2 3\n4\n3 1 2 4\n3\n2 3 1\n6\n2 4 12 1 3 10\n", "output": "YES\nYES\nNO\nYES\n"}, {"input": "4\n3\n1 2 3\n4\n3 1 2 4\n3\n2 3 1\n6\n2 4 19 1 3 10\n", "output": "YES\nYES\nNO\nYES\n"}, {"input": "4\n3\n1 2 3\n4\n3 1 2 4\n3\n2 3 1\n6\n2 4 12 1 3 5\n", "output": "YES\nYES\nNO\nYES\n"}, {"input": "4\n3\n...
code_stdio
[ { "content": "A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward. Examples of numerical palindromes are: \n\n2332\n110011\n54322345\n\nFor a given number ```num```, write a function which returns the number of numerical palindromes within each number...
[{"input": "\"ACCDDCCA\"", "output": "[\"Not valid\"]", "fn_name": "palindrome"}, {"input": "\"1551\"", "output": "[\"Not valid\"]", "fn_name": "palindrome"}, {"input": "-4505", "output": "[\"Not valid\"]", "fn_name": "palindrome"}, {"input": "141221001", "output": "[5]", "fn_name": "palindrome"}, {"input": "13598", "o...
code_functional
[ { "content": "Two circles A, B are given on a two-dimensional plane. The coordinate of the center and radius of circle A is (x_A, y_A) and r_A respectively. The coordinate of the center and radius of circle B is (x_B, y_B) and r_B respectively. These two circles have no intersection inside. Here, we consider a ...
[{"input": "4\n2 -3 3 -1 3 1\n0 0 9 3 13 2\n-1 -1 10 10 10 5\n-1 0 707 1000 1100 479", "output": "3\n4\n11\n4\n"}, {"input": "4\n0 -3 3 -2 3 2\n0 1 8 3 13 4\n-1 0 9 10 10 5\n-1 0 707 1000 1110 329", "output": "4\n12\n8\n3\n"}, {"input": "4\n2 -3 3 -1 3 2\n0 0 9 3 13 2\n-1 -1 9 10 10 5\n-1 0 707 1000 1100 479", "output"...
code_stdio
[ { "content": "Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Petya didn't like it at once. He decided to choose exactly one element from the array and replace it with an...
[{"input": "25\n1 1 1 2 2 2 1 2 1 2 2 2 2 2 1 2 2 2 1 2 2 2 2 1 2\n", "output": "1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 "}, {"input": "4\n1011110011 158379 10597860 181988389\n", "output": "1 158379 10597860 181988389\n"}, {"input": "4\n1011110011 158379 10597860 218725134\n", "output": "1 158379 10597860 21...
code_stdio
[ { "content": "There is the word heuristics. It's a relatively simple approach that usually works, although there is no guarantee that it will work. The world is full of heuristics because it is simple and powerful.\n\nSome examples of heuristics include: In an anime program, the popularity of a character is pro...
[{"input": "4 1 3 4\nyskwcnt 16\nakzakr 7\ntsnukk 12\nfnmyi 13\nakzakr\n4 1 3 8\nakzakr 7\ntsnukk 4\nfnmyi 13\nyskwcnt 16\nakzakr\n4 2 2 1\nakzakr 4\ntsnukk 6\nyskwcnt 12\nfnmyi 12\nakzakr\nfnmyi\n5 2 3 28\nknmmdk 6\nskrkyk 14\ntmemm 14\nakmhmr 15\nmksyk 25\nknmmdk\nskrkyk\n5 2 3 11\ntmemm 12\nskrkyk 18\nknmmdk 21\nmks...
code_stdio
[ { "content": "It's 3AM and you get the dreaded call from a customer: the program your company sold them is hanging. You eventually trace the problem down to a call to a function named `mystery`. Usually, `mystery` works fine and produces an integer result for an integer input. However, on certain inputs, the `m...
[{"input": "111", "output": "[103]", "fn_name": "wrap_mystery"}, {"input": "122", "output": "[122]", "fn_name": "wrap_mystery"}, {"input": "125", "output": "[132]", "fn_name": "wrap_mystery"}, {"input": "135", "output": "[129]", "fn_name": "wrap_mystery"}, {"input": "139", "output": "[100]", "fn_name": "wrap_mystery"},...
code_functional
[ { "content": "You finally woke up after this crazy dream and decided to walk around to clear your head. Outside you saw your house's fence — so plain and boring, that you'd like to repaint it.\n\nYou have a fence consisting of $n$ planks, where the $i$-th plank has the color $a_i$. You want to repaint the fence...
[{"input": "6\n1 1\n1\n1\n1\n5 2\n1 2 2 1 1\n1 2 2 1 1\n1 2\n3 3\n2 2 2\n2 2 2\n2 3 2\n10 5\n7 3 2 1 7 9 4 2 7 9\n9 9 2 1 4 9 4 2 3 9\n9 9 7 4 3\n5 2\n1 2 2 1 1\n1 2 2 1 1\n3 3\n6 4\n3 4 2 4 1 2\n2 3 1 3 1 1\n2 2 3 4\n", "output": "\nYES\n1\nYES\n2 2\nYES\n1 1 1\nYES\n2 1 9 5 9\nNO\nNO\n"}, {"input": "6\n1 1\n1\n1\n1\n...
code_stdio
[ { "content": "Sugoroku\n\nproblem\n\nJOI is playing sugoroku alone. There are N squares in a straight line in this sugoroku, and each has a movement instruction written on it. The starting point is the 1st square and the goal is the Nth square. JOI repeats the following until he reaches the goal.\n\nRoll the di...
[{"input": "10 5\n-1\n1\n10\n6\n-2\n9\n1\n8\n-3\n0\n0\n0\n10\n1\n5\n10 10\n0\n-1\n-1\n10\n4\n-3\n-2\n1\n0\n0\n3\n6\n0\n0\n6\n3\n5\n4\n1\n6\n0 0", "output": "3\n1\n"}, {"input": "10 5\n-1\n1\n10\n9\n-2\n7\n1\n8\n-3\n0\n2\n1\n6\n1\n5\n10 10\n0\n-1\n-1\n3\n4\n-5\n1\n1\n-10\n0\n2\n5\n2\n5\n2\n5\n3\n2\n6\n6\n0 0", "output":...
code_stdio
[ { "content": "Define a function that takes in two non-negative integers `$a$` and `$b$` and returns the last decimal digit of `$a^b$`. Note that `$a$` and `$b$` may be very large!\n\nFor example, the last decimal digit of `$9^7$` is `$9$`, since `$9^7 = 4782969$`. The last decimal digit of `$({2^{200}})^{2^{30...
[{"input": "3715290469715693021198967285016729344580685479654510946723\n68819615221552997273737174557165657483427362207517952651", "output": "[7]", "fn_name": "last_digit"}, {"input": "38710248912497124917933333333284108412048102948908149081409204712406\n226628148126342643123641923461846128214626", "output": "[6]", "fn...
code_functional
[ { "content": "Polycarp calls an array dense if the greater of any two adjacent elements is not more than twice bigger than the smaller. More formally, for any $i$ ($1 \\le i \\le n-1$), this condition must be satisfied: $$\\frac{\\max(a[i], a[i+1])}{\\min(a[i], a[i+1])} \\le 2$$\n\nFor example, the arrays $[1, ...
[{"input": "6\n4\n4 2 10 1\n2\n1 3\n2\n12 1\n3\n1 4 2\n5\n1 2 3 4 3\n12\n4 27 25 50 30 20 34 46 42 16 15 21\n", "output": "5\n1\n3\n1\n0\n3\n"}, {"input": "6\n4\n4 2 10 1\n2\n1 6\n2\n6 1\n3\n1 7 2\n5\n1 1 2 6 1\n12\n3 58 25 17 43 21 20 46 42 11 30 16\n", "output": "5\n2\n2\n3\n3\n10\n"}, {"input": "6\n4\n4 2 10 1\n2\n1...
code_stdio
[ { "content": "Snuke loves flags.\n\nSnuke is placing N flags on a line.\n\nThe i-th flag can be placed at either coordinate x_i or coordinate y_i.\n\nSnuke thinks that the flags look nicer when the smallest distance between two of them, d, is larger. Find the maximum possible value of d.\n\nConstraints\n\n* 2 ≤...
[{"input": "22\n93 6440\n78 6647\n1028 11\n8306 9689\n798 99\n801 521\n188 206\n6079 971\n4559 209\n50 94\n92 6270\n5403 560\n803 83\n1855 99\n42 504\n75 484\n629 11\n92 122\n3359 37\n28 16\n648 14\n11 269", "output": "17\n"}, {"input": "22\n93 6440\n78 6647\n889 11\n8306 9689\n1104 135\n801 521\n188 257\n6079 971\n455...
code_stdio
[ { "content": "Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nPetya has a number consisting of n digits without leading zeroes. He represe...
[{"input": "485 9554485\n7759121368632736852539182753173468028218114958118158732302477551670775608015153610483175626465946144780731573954182900412248382710280376491925985206156109890139333293746203940442347501294009600230166311978044218247083102712257326301109220002496805123344816427514286225153139924306380089284878322...
code_stdio
[ { "content": "Malek has recently found a treasure map. While he was looking for a treasure he found a locked door. There was a string s written on the door consisting of characters '(', ')' and '#'. Below there was a manual on how to open the door. After spending a long time Malek managed to decode the manual a...
[{"input": "(#))(#(#)((((#(##((#(#((((#(##((((((#((()(()(())((()#((((#((()((((#(((((#(##)(##()((((()())(((((#(((\n", "output": "-1\n"}, {"input": "#(#(#((##((()))(((#)(#()#(((()()(()#(##(((()(((()))#(((((()(((((((()#((#((()(#(((()(()##(()(((()((#(\n", "output": "-1\n"}, {"input": "()#(#())()()#)(#)()##)#((()#)((#)()#()...
code_stdio
[ { "content": "The Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below.\n\nThe playing field is a sequence of n non-negative integers ai numbered from 1 to n. The goal of the game is to make numbers a1, a2, ..., ak (i.e. so...
[{"input": "120\n242 524 420 973 816 432 247 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 223 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 5...
code_stdio
[ { "content": "You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.\n\nConstraints\n\n* 1 \\leq K \\leq N\\leq 10\n* S is a string of length N consisting of ...
[{"input": "9\nedtbiuaon\n-2", "output": "******a**\n"}, {"input": "9\neducation\n4", "output": "***c*****\n"}, {"input": "9\nedubation\n4", "output": "***b*****\n"}, {"input": "9\nedubation\n6", "output": "*****t***\n"}, {"input": "9\nedubation\n8", "output": "*******o*\n"}, {"input": "9\nedubatinn\n8", "output": "***...
code_stdio
[ { "content": "Snuke is having another barbeque party.\n\nThis time, he will make one serving of Skewer Meal.\n\nHe has a stock of N Skewer Meal Packs. The i-th Skewer Meal Pack contains one skewer, A_i pieces of beef and B_i pieces of green pepper. All skewers in these packs are different and distinguishable, w...
[{"input": "3\n11 3\n2 2\n0 2", "output": "12951\n"}, {"input": "3\n12 2\n2 3\n2 0", "output": "11783\n"}, {"input": "3\n12 2\n2 3\n1 0", "output": "11753\n"}, {"input": "3\n3 1\n0 4\n7 9", "output": "262332\n"}, {"input": "3\n11 3\n2 1\n0 2", "output": "6758\n"}, {"input": "3\n12 2\n2 1\n2 1", "output": "1375\n"}, {"i...
code_stdio
[ { "content": "Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a_1, a_2, ..., a_{n} in the non-decreasing order. The pseudocode of the program, written by Valera, is...
[{"input": "50\n", "output": "50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 "}, {"input": "50\n", "output": "50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12...
code_stdio
[ { "content": "Sasha is a very happy guy, that's why he is always on the move. There are $n$ cities in the country where Sasha lives. They are all located on one straight line, and for convenience, they are numbered from $1$ to $n$ in increasing order. The distance between any two adjacent cities is equal to $1$...
[{"input": "84 15\n", "output": "2429 \n"}, {"input": "100 100\n", "output": "99 \n"}, {"input": "100 98\n", "output": "100 \n"}, {"input": "100 97\n", "output": "102 \n"}, {"input": "100 3\n", "output": "4755 \n"}, {"input": "100 1\n", "output": "4950 \n"}, {"input": "91 14\n", "output": "3016 \n"}, {"input": "100 43\...
code_stdio
[ { "content": "The string $t_1t_2 \\dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.\n\nA palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA ...
[{"input": "7\nAAABABB\n", "output": "15\n"}, {"input": "7\nBBABAAA\n", "output": "15\n"}, {"input": "7\nBAAAABB\n", "output": "12\n"}, {"input": "7\nABABAAB\n", "output": "14\n"}, {"input": "7\nBBAAABA\n", "output": "13\n"}, {"input": "7\nBAAAAAB\n", "output": "11\n"}, {"input": "7\nAAAAAAA\n", "output": "21\n"}, {"in...
code_stdio
[ { "content": "For given two lines s1 and s2, print \"2\" if they are parallel, \"1\" if they are orthogonal, or \"0\" otherwise.\n\ns1 crosses points p0 and p1, and s2 crosses points p2 and p3.\n\nConstraints\n\n* 1 ≤ q ≤ 1000\n* -10000 ≤ xpi, ypi ≤ 10000\n* p0 ≠ p1 and p2 ≠ p3.\n\nInput\n\nThe entire input loo...
[{"input": "3\n-1 -1 10 1 2 0 2 2\n0 5 6 -1 0 -1 0 22\n-2 -1 1 1 0 -1 2 2", "output": "0\n0\n0\n"}, {"input": "3\n-1 -1 10 1 2 0 2 2\n0 5 6 -1 0 -1 0 22\n-2 -1 1 1 1 -1 2 2", "output": "0\n0\n0\n"}, {"input": "3\n-1 -1 10 1 2 0 2 4\n0 5 6 -1 0 -1 0 22\n-2 -1 1 1 1 -1 2 2", "output": "0\n0\n0\n"}, {"input": "3\n-1 -1 10...
code_stdio
[ { "content": "You are given some text $t$ and a set of $n$ strings $s_1, s_2, \\dots, s_n$.\n\nIn one step, you can choose any occurrence of any string $s_i$ in the text $t$ and color the corresponding characters of the text in red. For example, if $t={bababa}$ and $s_1={ba}$, $s_2={aba}$, you can get $t={{ba}}...
[{"input": "5\naaaaa\n3\naaa\naaa\na\nabbaa\n4\nab\nbaa\nabb\na\nabcdefg\n10\na\nb\nc\nd\ne\nf\ng\nh\ni\nj\nabcdefghijklmnop\n4\nabcdefg\nefghijklmo\nijklmnop\nhijklmnop\nababababbababba\n5\na\nabba\nb\nbb\naa\n", "output": "2\n1 1\n1 3\n2\n3 1\n2 3\n7\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n7 7\n2\n1 1\n4 8\n9\n1 1\n3 2\n1 3\n...
code_stdio
[ { "content": "Two players, A and B, play the game using cards with numbers from 0 to 9. First, the two arrange the given n cards face down in a horizontal row. After that, the two players turn their cards face up one by one from the left, and the owner of the card with the larger number takes the two cards. At ...
[{"input": "3\n13 1\n1 4\n1 4\n3\n20 1\n6 7\n1 1\n3\n15 1\n5 5\n1 8\n0", "output": "14 10\n22 14\n21 14\n"}, {"input": "3\n13 1\n1 4\n1 4\n3\n20 1\n6 8\n1 1\n3\n15 1\n5 5\n1 8\n0", "output": "14 10\n22 15\n21 14\n"}, {"input": "3\n13 1\n1 4\n0 4\n3\n20 1\n6 15\n1 1\n3\n15 1\n5 5\n1 8\n0", "output": "14 9\n22 22\n21 14\...
code_stdio
[ { "content": "At the end of a busy day, The Chef and his assistants play a game together. The game is not just for fun but also used to decide who will have to clean the kitchen. The Chef is a Game Master, so his concern is how to manage the game but not how to win the game like his assistants do.\n\nThe game r...
[{"input": "1\n9 3 3\n-1 23\n1 1\n-1 -1", "output": "19\n"}, {"input": "1\n0 2 3\n5 37\n6 -1\n-1 49", "output": "46\n"}, {"input": "1\n9 3 3\n0 16\n1 1\n-1 -1", "output": "13\n"}, {"input": "1\n4 4 3\n2 0\n0 14\n-1 10", "output": "-1\n"}, {"input": "1\n0 1 3\n0 24\n1 0\n-1 -1", "output": "23\n"}, {"input": "1\n0 1 3\n1...
code_stdio
[ { "content": "Recently, Chef got obsessed with piano. He is a just a rookie in this stuff and can not move his fingers from one key to other fast enough. He discovered that the best way to train finger speed is to play scales.\n\nThere are different kinds of scales which are divided on the basis of their interv...
[{"input": "2 \nTSTT\n35\nRTTSSTT\n-4", "output": "12390\n0\n"}, {"input": "2 \nTSTT\n33\nRTTSSTT\n-6", "output": "11004\n0\n"}, {"input": "2 \nTSTT\n43\nSTSTTUR\n-1", "output": "18761\n0\n"}, {"input": "2 \nTSSS\n10\nSSTTRTT\n-14", "output": "1380\n0\n"}, {"input": "2 \nTTTS\n41\nTTSSTTR\n-6", "output": "17045\n0\n"},...
code_stdio
[ { "content": "Karan's company makes software that provides different features based on the version of operating system of the user.\n\nFor finding which version is more recent, Karan uses the following method:\n\nWhile this function worked for OS versions 10.6, 10.7, 10.8 and 10.9, the Operating system company ...
[{"input": "\"4.3.3\"\n\"4.3.3.1\"", "output": "[false]", "fn_name": "compare_versions"}, {"input": "\"10.4.9\"\n\"104.9\"", "output": "[false]", "fn_name": "compare_versions"}, {"input": "\"10.4\"\n\"10.4.8\"", "output": "[false]", "fn_name": "compare_versions"}, {"input": "\"10.4.9\"\n\"10.5\"", "output": "[false]", ...
code_functional
[ { "content": "I am a pipe tie craftsman. As long as you get the joints and pipes that connect the pipes, you can connect any pipe. Every day, my master gives me pipes and joints, which I connect and give to my master. But if you have too many pipes, you can't connect them all in one day. Even in such a case, th...
[{"input": "3\n0 1 1\n3 3\n4\n4 1 2 3\n1 1 1\n5\n1 1 3 4 5\n3 12 2 2\n0", "output": "10\n40\n104\n"}, {"input": "3\n0 1 1\n3 3\n4\n3 1 5 3\n1 1 1\n5\n2 4 6 4 5\n0 3 2 1\n0", "output": "10\n48\n105\n"}, {"input": "3\n0 1 1\n3 3\n4\n3 1 5 3\n1 1 1\n5\n4 4 3 4 5\n0 3 2 1\n0", "output": "10\n48\n100\n"}, {"input": "3\n-1 1...
code_stdio
[ { "content": "The Smart Beaver from ABBYY came up with another splendid problem for the ABBYY Cup participants! This time the Beaver invites the contest participants to check out a problem on sorting documents by their subjects. Let's describe the problem:\n\nYou've got some training set of documents. For each ...
[{"input": "21000\nSWISS OT LAHNCU NEW SERIES OF MONEY MARKET PEPAR\nZURICH, April 9 - The Svirs Federal tndmnrevoG lliw launch\na ndw series fo three mhnto mondx market setatificrec totallhng\nauornd 150 mln iwSss fraocs, dht National Bank said.\nSubscriptions close lirpA 14 and paynent date hs April 16.84368194671728...
code_stdio
[ { "content": "The main server of Gomble company received a log of one top-secret process, the name of which can't be revealed. The log was written in the following format: «[date:time]: message», where for each «[date:time]» value existed not more than 10 lines. All the files were encoded in a very complicated ...
[{"input": "14\n[12:07 p.m.]: mamaa\n[12:36 a.m.]: amaamppa\n[01:31 a.m.]: pmpp\n[05:47 a.m.]: paapappapaaampm\n[12:07 a.m.]: ppamammm\n[01:03 a.m.]: aapapmpampamamaaa\n[07:55 a.m.]: mpappmmapmpa\n[02:49 a.m.]: papmppppmpamppa\n[03:12 a.m.]: aaaaaaamam\n[04:40 a.m.]: paap\n[01:13 a.m.]: ap\n[03:22 a.m.]: mpmppmmapmmpp\...
code_stdio
[ { "content": "Magic The Gathering is a collectible card game that features wizards battling against each other with spells and creature summons. The game itself can be quite complicated to learn. In this series of katas, we'll be solving some of the situations that arise during gameplay. You won't need any prio...
[{"input": "[[1, 3], [3, 5], [4, 6], [5, 2]]\n[[2, 4], [6, 1], [4, 4], [3, 7], [3, 1]]", "output": "[{\"player1\": [[1, 3], [4, 6]], \"player2\": [[2, 4], [3, 7], [3, 1]]}]", "fn_name": "battle"}, {"input": "[[2, 3], [1, 4]]\n[[3, 3], [4, 1]]", "output": "[{\"player1\": [], \"player2\": [[3, 3]]}]", "fn_name": "battle"...
code_functional
[ { "content": "A median in an array with the length of n is an element which occupies position number <image> after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2, 6, 1, 2, 3) is the number 2, and a median of array (0, 96, 17, 23) — the...
[{"input": "100 813\n285 143 378 188 972 950 222 557 170 755 470 164 1433 553 146 820 842 62 496 1893 746 944 677 828 465 577 791 277 303 218 561 653 925 692 871 424 626 795 813 343 418 280 123 364 496 447 435 452 645 36 311 315 830 289 450 675 23 212 421 661 7 217 468 877 172 141 475 409 178 71 936 1584 761 889 417 31...
code_stdio
[ { "content": "The kingdom of Lazyland is the home to $n$ idlers. These idlers are incredibly lazy and create many problems to their ruler, the mighty King of Lazyland. \n\nToday $k$ important jobs for the kingdom ($k \\le n$) should be performed. Every job should be done by one person and every person can do at...
[{"input": "18 12\n6 3 6 6 6 6 6 6 6 12 1 3 6 6 10 6 6 6\n47 4 41 56 75 24 29 10 100 112 53 48 79 30 87 135 60 87\n", "output": "185\n"}, {"input": "18 12\n6 3 6 6 6 6 6 6 6 12 1 3 6 6 10 6 6 6\n47 4 41 56 75 24 29 10 100 112 53 48 79 30 87 135 10 87\n", "output": "148\n"}, {"input": "18 12\n6 6 6 6 6 6 6 6 6 12 1 6 6 ...
code_stdio
[ { "content": "Many years ago, Roman numbers were defined by only `4` digits: `I, V, X, L`, which represented `1, 5, 10, 50`. These were the only digits used. The value of a sequence was simply the sum of digits in it. For instance:\n```\nIV = VI = 6\nIX = XI = 11\nXXL = LXX = XLX = 70\n```\nIt is easy to see th...
[{"input": "10000000", "output": "[489999753]", "fn_name": "solve"}, {"input": "10", "output": "[244]", "fn_name": "solve"}, {"input": "2", "output": "[10]", "fn_name": "solve"}, {"input": "3", "output": "[20]", "fn_name": "solve"}, {"input": "4", "output": "[35]", "fn_name": "solve"}, {"input": "5", "output": "[56]", ...
code_functional
[ { "content": "Snuke signed up for a new website which holds programming competitions.\nHe worried that he might forget his password, and he took notes of it.\nSince directly recording his password would cause him trouble if stolen,\nhe took two notes: one contains the characters at the odd-numbered positions, a...
[{"input": "atcoderbeginnercontest\natcoderregularcontest\n", "output": "aattccooddeerrbreeggiunlnaerrccoonntteesstt\n"}, {"input": "atcoderbeeinnercontgst\natcoderregularcontest", "output": "aattccooddeerrbreeegiunlnaerrccoonnttegsstt\n"}, {"input": "atcoderbeeinnercontgst\natcoaerreguldrcontest", "output": "aattccood...
code_stdio
[ { "content": "Given is a tree with N vertices numbered 1 to N, and N-1 edges numbered 1 to N-1.\nEdge i connects Vertex a_i and b_i bidirectionally and has a length of 1.\nSnuke will paint each vertex white or black.\nThe niceness of a way of painting the graph is \\max(X, Y), where X is the maximum among the d...
[{"input": "10104\n5741 6080\n3408 7811\n5930 5446\n2841 6030\n7143 6678\n5930 3686\n3091 5609\n9185 6802\n8673 6440\n593 5930\n4271 5808\n3292 3568\n2712 5673\n10008 5082\n421 4874\n5930 7228\n5005 6587\n2254 9793\n8397 7976\n8682 4699\n8396 5930\n7253 1069\n1980 6577\n8066 4032\n2303 3724\n3700 6900\n2973 8487\n5004 ...
code_stdio
[ { "content": "The __Hamming weight__ of a string is the number of symbols that are different from the zero-symbol of the alphabet used. There are several algorithms for efficient computing of the Hamming weight for numbers. In this Kata, speaking technically, you have to find out the number of '1' bits in a bin...
[{"input": "2048", "output": "[1]", "fn_name": "hamming_weight"}, {"input": "10", "output": "[2]", "fn_name": "hamming_weight"}, {"input": "21", "output": "[3]", "fn_name": "hamming_weight"}, {"input": "0", "output": "[0]", "fn_name": "hamming_weight"}, {"input": "1", "output": "[1]", "fn_name": "hamming_weight"}, {"in...
code_functional
[ { "content": "# Task\nLet's define a `parameter` of number `n` as the least common multiple (LCM) of the sum of its digits and their product.\n\nCalculate the parameter of the given number `n`.\n\n# Input/Output\n\n`[input]` integer `n`\n\n A positive integer. It is guaranteed that no zero appears in `n`.\n\n`[...
[{"input": "999999999", "output": "[387420489]", "fn_name": "parameter"}, {"input": "123456789", "output": "[362880]", "fn_name": "parameter"}, {"input": "1234", "output": "[120]", "fn_name": "parameter"}, {"input": "239", "output": "[378]", "fn_name": "parameter"}, {"input": "344", "output": "[528]", "fn_name": "param...
code_functional
[ { "content": "Naming multiple files can be a pain sometimes.\n\n#### Task:\n\nYour job here is to create a function that will take three parameters, `fmt`, `nbr` and `start`, and create an array of `nbr` elements formatted according to `frm` with the starting index `start`. `fmt` will have `` inserted at variou...
[{"input": "\"<file> number <index_no>\"\n5\n0", "output": "[[\"<file> number 0\", \"<file> number 1\", \"<file> number 2\", \"<file> number 3\", \"<file> number 4\"]]", "fn_name": "name_file"}, {"input": "\"<file_no> number <index_no>\"\n2\n-1", "output": "[[\"<file_no> number -1\", \"<file_no> number 0\"]]", "fn_name...
code_functional
[ { "content": "Training is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well.\n\nToday's training is to gain dexterity that never mistypes by carefully stacking blocks. Since there are many building blocks, let's build a tall tower.\n\nThere ar...
[{"input": "3\n10 40\n15 40\n20 30", "output": "110\n"}, {"input": "3\n10 40\n15 40\n40 30", "output": "120\n"}, {"input": "3\n10 40\n15 40\n20 32", "output": "112\n"}, {"input": "3\n10 36\n15 40\n20 32", "output": "108\n"}, {"input": "3\n10 40\n15 62\n40 30", "output": "142\n"}, {"input": "3\n10 36\n15 40\n20 50", "ou...
code_stdio
[ { "content": "Bessie has way too many friends because she is everyone's favorite cow! Her new friend Rabbit is trying to hop over so they can play! \n\nMore specifically, he wants to get from $(0,0)$ to $(x,0)$ by making multiple hops. He is only willing to hop from one point to another point on the 2D plane if...
[{"input": "1\n19 1000000000\n15 8 22 12 10 16 2 17 14 7 20 23 9 18 3 19 21 11 1\n", "output": "43478261\n"}, {"input": "1\n19 1000000000\n15 8 22 12 10 16 2 17 14 7 20 23 9 18 3 19 21 11 1\n", "output": "43478261\n"}, {"input": "1\n19 1000000000\n15 8 22 12 10 16 2 17 14 7 20 23 9 14 3 19 21 11 1\n", "output": "434782...
code_stdio
[ { "content": "\"What are your shoe sizes?\"\n\nSuddenly, the doctor asked me when I met him for the first time.\n\n\"It's 23.5\"\n\"Oh, that's a really nice number. It's 2 to the 4th power plus 2 to the 2nd power, 2 to the 1st power, 2 to the 0th power, and 2 to the 1st power.\"\n\nThen the doctor asked.\n\n\"Y...
[{"input": "27.100228165013633\n158.95452966627283\n-0.21569613349567962", "output": "NA\nNA\n"}, {"input": "27.432484603703674\n158.95452966627283\n-0.21569613349567962", "output": "NA\nNA\n"}, {"input": "27.932276079901406\n158.95452966627283\n-0.21569613349567962", "output": "NA\nNA\n"}, {"input": "27.93227607990140...
code_stdio
[ { "content": "# Task\n Consider the following algorithm for constructing 26 strings S(1) .. S(26):\n```\nS(1) = \"a\";\nFor i in [2, 3, ..., 26]:\nS(i) = S(i - 1) + character(i) + S(i - 1).```\n\n For example:\n```\nS(1) = \"a\"\nS(2) = S(1) + \"b\" + S(1) = \"a\" + \"b\" + \"a\" = \"aba\"\nS(3) = S(2) + \"c\" ...
[{"input": "12", "output": "[\"c\"]", "fn_name": "abacaba"}, {"input": "16", "output": "[\"e\"]", "fn_name": "abacaba"}, {"input": "1", "output": "[\"a\"]", "fn_name": "abacaba"}, {"input": "2", "output": "[\"b\"]", "fn_name": "abacaba"}, {"input": "3", "output": "[\"a\"]", "fn_name": "abacaba"}, {"input": "4", "output...
code_functional
[ { "content": "Slime and his $n$ friends are at a party. Slime has designed a game for his friends to play.\n\nAt the beginning of the game, the $i$-th player has $a_i$ biscuits. At each second, Slime will choose a biscuit randomly uniformly among all $a_1 + a_2 + \\ldots + a_n$ biscuits, and the owner of this b...
[{"input": "100\n4364 698 1003 1128 1513 39 4339 969 7452 3415 1154 1635 6649 136 1442 50 834 1680 107 978 983 3176 4017 1692 1113 1504 1118 396 1975 2053 2366 3022 3007 167 610 4649 14659 2331 4565 318 7232 204 7131 6122 2885 5748 1998 3833 6799 4219 8454 8698 4964 1736 1554 1665 2425 4227 1967 534 2719 80 2865 652 19...
code_stdio
[ { "content": "Given are an integer K and integers a_1,\\dots, a_K. Determine whether a sequence P satisfying below exists. If it exists, find the lexicographically smallest such sequence.\n\n* Every term in P is an integer between 1 and K (inclusive).\n* For each i=1,\\dots, K, P contains a_i occurrences of i.\...
[{"input": "3\n2 4 4", "output": "2 3 1 2 3 2 3 1 2 3 \n"}, {"input": "4\n3 2 3 2", "output": "1 2 3 4 1 3 1 2 4 3"}, {"input": "3\n2 2 4", "output": "3 1 2 3 3 1 2 3 \n"}, {"input": "5\n1 1 1 1 2", "output": "5 1 2 3 4 5 \n"}, {"input": "3\n2 4 3", "output": "2 1 3 2 2 3 1 2 3"}, {"input": "5\n1 1 1 1 1", "output": "1...
code_stdio
[ { "content": "Поликарп мечтает стать программистом и фанатеет от степеней двойки. Среди двух чисел ему больше нравится то, которое делится на большую степень числа 2. \n\nПо заданной последовательности целых положительных чисел a_1, a_2, ..., a_{n} требуется найти r — максимальную степень числа 2, на которую де...
[{"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": "You certainly can tell which is the larger number between 2^(10) and 2^(15).\n\nBut what about, say, 2^(10) and 3^(10)? You know this one too.\n\nThings tend to get a bit more complicated with **both** different bases and exponents: which is larger between 3^(9) and 5^(6)?\n\nWell, by now you have...
[{"input": "[1024, 97]\n[1024, 81]", "output": "[-1]", "fn_name": "compare_powers"}, {"input": "[34, 98]\n[51, 67]", "output": "[-1]", "fn_name": "compare_powers"}, {"input": "[2, 100]\n[2, 150]", "output": "[1]", "fn_name": "compare_powers"}, {"input": "[2, 100]\n[3, 100]", "output": "[1]", "fn_name": "compare_powers"...
code_functional
[ { "content": "ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1.\n\nWhen ZS the Coder is at le...
[{"input": "7816\n", "output": "2\n17\n46\n97\n176\n289\n442\n641\n892\n1201\n1574\n2017\n2536\n3137\n3826\n4609\n5492\n6481\n7582\n8801\n10144\n11617\n13226\n14977\n16876\n18929\n21142\n23521\n26072\n28801\n31714\n34817\n38116\n41617\n45326\n49249\n53392\n57761\n62362\n67201\n72284\n77617\n83206\n89057\n95176\n101569\...
code_stdio
[ { "content": "<image>\n\nFor given three points p0, p1, p2, print\n\n\nCOUNTER_CLOCKWISE\n\n\nif p0, p1, p2 make a counterclockwise turn (1),\n\n\nCLOCKWISE\n\n\nif p0, p1, p2 make a clockwise turn (2),\n\n\nONLINE_BACK\n\n\nif p2 is on a line p2, p0, p1 in this order (3),\n\n\nONLINE_FRONT\n\n\nif p2 is on a l...
[{"input": "0 -1 1 -1\n3\n0 0\n0 1\n3 0", "output": "COUNTER_CLOCKWISE\nCOUNTER_CLOCKWISE\nCOUNTER_CLOCKWISE\n"}, {"input": "-1 -1 2 -3\n3\n-2 0\n-1 -1\n0 1", "output": "COUNTER_CLOCKWISE\nON_SEGMENT\nCOUNTER_CLOCKWISE\n"}, {"input": "0 -1 2 -1\n3\n-1 -1\n0 1\n3 1", "output": "ONLINE_BACK\nCOUNTER_CLOCKWISE\nCOUNTER_CL...
code_stdio
[ { "content": "Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nPetya wonders eagerly what minimum lucky number has the sum of digits equal ...
[{"input": "544958\n", "output": "4477777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777...
code_stdio
[ { "content": "There are N children, numbered 1, 2, \\ldots, N.\n\nThey have decided to share K candies among themselves. Here, for each i (1 \\leq i \\leq N), Child i must receive between 0 and a_i candies (inclusive). Also, no candies should be left over.\n\nFind the number of ways for them to share candies, m...
[{"input": "4 100000\n101000 100000 100000 100000", "output": "665683269\n"}, {"input": "4 101000\n101000 100000 100100 101000", "output": "744244119\n"}, {"input": "4 110000\n101000 100000 100000 100000", "output": "741473440\n"}, {"input": "4 100100\n101000 100000 100100 101000", "output": "185684912\n"}, {"input": "...
code_stdio
[ { "content": "Dr. A of the Aizu Institute of Biological Research discovered a mysterious insect on a certain southern island. The shape is elongated like a hornworm, but since one segment is shaped like a ball, it looks like a beaded ball connected by a thread. What was strange was that there were many variatio...
[{"input": "rbgrg\nbbbrbgr\nrbg\nrgbbrgrb\nrrgbgrggb\nggrgbrbggr\nrrrrr\nbgbr\n0", "output": "5\n7\n1\n6\nNA\n11\n0\n4\n"}, {"input": "grgbr\nrbbgbbr\nbgr\nbgbrrgbr\nbggrgbgrr\ngggbrggrbr\nrrrrr\nbgbr\n0", "output": "5\n7\n1\n9\nNA\n11\n0\n4\n"}, {"input": "grgbr\nrbbgbbr\nbrg\nrbggrbbr\nrrgbgrggb\ngbgrgrbggr\nrrrrr\nb...
code_stdio
[ { "content": "There are N camels numbered 1 through N.\nThe weight of Camel i is w_i.\nYou will arrange the camels in a line and make them cross a bridge consisting of M parts.\nBefore they cross the bridge, you can choose their order in the line - it does not have to be Camel 1, 2, \\ldots, N from front to bac...
[{"input": "8 5522\n35082527 79227267 44206285 89187090 61610002 29064205 89153995 36160269\n45347010 90255563\n70343288 95278607\n12732707 94045934\n45923577 89378293\n93771951 94507897\n93868604 89747889\n91718882 93526246\n64458862 90336799\n91324861 90667826\n62335106 95645278\n84387911 93916051\n47178161 99301170\...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian as well. \n\nAfter IOI Ilya decided to make a business. He found a social network called \"TheScorpyBook.com\". It currently has N registered users. As in any social network two users can be friends. Ilya wants the world to be as connected ...
[{"input": "4\n1111\n1000\n1000\n1000", "output": "6\n"}, {"input": "4\n0111\n1100\n0000\n1001", "output": "2\n"}, {"input": "4\n1111\n1010\n1000\n1010", "output": "4\n"}, {"input": "4\n0011\n0000\n0000\n1001", "output": "0\n"}, {"input": "4\n1111\n1100\n0000\n1001", "output": "2\n"}, {"input": "4\n0110\n1000\n0000\n10...
code_stdio
[ { "content": "Petr stands in line of n people, but he doesn't know exactly which position he occupies. He can say that there are no less than a people standing in front of him and no more than b people standing behind him. Find the number of different positions Petr can occupy.\n\nInput\n\nThe only line contain...
[{"input": "100 81 58\n", "output": "19\n"}, {"input": "100 81 54\n", "output": "19\n"}, {"input": "100 81 91\n", "output": "19"}, {"input": "100 11 88\n", "output": "89"}, {"input": "59 12 33\n", "output": "34\n"}, {"input": "49 19 37\n", "output": "30\n"}, {"input": "90 76 37\n", "output": "14\n"}, {"input": "58 23 2...
code_stdio
[ { "content": "We have a sequence of N \\times K integers: X=(X_0,X_1,\\cdots,X_{N \\times K-1}). Its elements are represented by another sequence of N integers: A=(A_0,A_1,\\cdots,A_{N-1}). For each pair i, j (0 \\leq i \\leq K-1,\\ 0 \\leq j \\leq N-1), X_{i \\times N + j}=A_j holds.\n\nSnuke has an integer se...
[{"input": "11 97\n0 1 8 2 5 4 2 6 2 3 5", "output": "0 1 8 6 2 3 5\n"}, {"input": "11 47\n0 1 0 3 10 5 1 36 2 2 0", "output": "10 5 1 36 0\n"}, {"input": "11 101\n0 2 4 1 5 4 4 6 0 3 5", "output": "2 4 6 0 3 5\n"}, {"input": "11 77\n0 1 0 3 10 3 1 20 4 2 0", "output": "1 20 4 2 0\n"}, {"input": "11 97\n0 0 0 3 5 8 5 1...
code_stdio
[ { "content": "Takahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The consumption coefficient of Member i is A_i.\nIn the contest, N foods numbered 1 through N will be presented, ...
[{"input": "11 14\n3 1 4 1 0 9 0 20 1 2 10\n15 6 7 26 3 2 3 8 4 8 2", "output": "20\n"}, {"input": "11 14\n3 1 4 1 0 9 0 20 1 2 10\n15 6 7 26 3 4 3 8 4 8 2", "output": "22\n"}, {"input": "11 14\n3 1 4 1 2 9 2 11 1 3 10\n15 9 7 26 3 2 3 8 4 8 2", "output": "16\n"}, {"input": "11 14\n3 1 4 1 2 9 2 11 5 3 10\n8 9 7 26 10 ...
code_stdio
[ { "content": "You are given two integers $n$ and $m$ ($m < n$). Consider a convex regular polygon of $n$ vertices. Recall that a regular polygon is a polygon that is equiangular (all angles are equal in measure) and equilateral (all sides have the same length). [Image] Examples of convex regular polygons \n\nYo...
[{"input": "2\n69 120\n11 9\n", "output": "NO\nNO\n"}, {"input": "2\n34 230\n4 15\n", "output": "NO\nNO\n"}, {"input": "2\n34 230\n4 27\n", "output": "NO\nNO\n"}, {"input": "2\n11 101\n13 4\n", "output": "NO\nNO\n"}, {"input": "2\n55 230\n4 27\n", "output": "NO\nNO\n"}, {"input": "2\n11 101\n13 6\n", "output": "NO\nNO\...
code_stdio
[ { "content": "Arkady decided to buy roses for his girlfriend.\n\nA flower shop has white, orange and red roses, and the total amount of them is n. Arkady thinks that red roses are not good together with white roses, so he won't buy a bouquet containing both red and white roses. Also, Arkady won't buy a bouquet ...
[{"input": "30 15\n7926 577 5009 7237 4395 3239 8994 4429 8126 2925 139 320 4442 3397 1292 2800 9505 6043 5946 8058 4031 6871 4689 1977 73 440 5320 5290 4707 387\nOOWOWWORRWOWORWRRRRWORROOWWROW\n", "output": "91633\n"}, {"input": "30 15\n7926 577 5009 7237 4395 3239 8994 4429 8126 2925 139 320 4442 3397 1292 2800 9505 ...
code_stdio
[ { "content": "You are given two integers $a$ and $b$. Moreover, you are given a sequence $s_0, s_1, \\dots, s_{n}$. All values in $s$ are integers $1$ or $-1$. It's known that sequence is $k$-periodic and $k$ divides $n+1$. In other words, for each $k \\leq i \\leq n$ it's satisfied that $s_{i} = s_{i - k}$.\n\...
[{"input": "904132655 827386249 118827660 334\n+++-+++++--+++----+-+-+-+-+--+-+---++--++--++--+-+-+++-+++--+-+-+----+-+-++++-----+--++++------+++-+-+-++-++++++++-+-++-+++--+--++------+--+-+++--++--+---++-++-+-+-++---++-++--+-+-++-+------+-+----+++-+++--+-+-+--+--+--+------+--+---+--+-++--+++---+-+-++--------+-++--++-+-...
code_stdio
[ { "content": "A one-dimensional Japanese crossword can be represented as a binary string of length x. An encoding of this crossword is an array a of size n, where n is the number of segments formed completely of 1's, and a_{i} is the length of i-th segment. No two segments touch or intersect.\n\nFor example: ...
[{"input": "10 1\n5 78 3 87 4 9 5 8 9 1235\n", "output": "NO\n"}, {"input": "10 1\n5 78 3 87 4 9 5 8 9 1235\n", "output": "NO\n"}, {"input": "10 1\n5 24 3 87 4 9 5 8 9 1235\n", "output": "NO\n"}, {"input": "10 1\n5 24 3 0 4 9 5 8 9 1235\n", "output": "NO\n"}, {"input": "10 0\n5 24 3 0 4 9 5 8 9 1235\n", "output": "NO\n...
code_stdio
[ { "content": "You are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges.\n\nHere, a self-loop is an edge where a_i = b_i (1≤i≤M), and double edges are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M).\n\nHow many different path...
[{"input": "8 28\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n3 4\n3 5\n3 6\n3 7\n3 8\n4 5\n4 6\n4 7\n4 8\n5 6\n5 7\n5 8\n6 7\n6 8\n7 8\n", "output": "5040\n"}, {"input": "8 27\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n2 3\n2 4\n2 5\n2 6\n2 7\n3 4\n3 5\n3 6\n3 7\n3 8\n4 5\n4 6\n4 7\n4 8\n5 6\n5 7\n5 8\n6...
code_stdio
[ { "content": "Example\n\nInput\n\nmmemewwemeww\n\n\nOutput\n\nCat\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your complete solution in a single ```python code block.", "role": "user" } ]
[{"input": "mmemwweemeww", "output": "Rabbit\n"}, {"input": "wwemeewwmemm", "output": "Rabbit\n"}, {"input": "mmemwweeneww", "output": "Rabbit\n"}, {"input": "mnemwweeneww", "output": "Rabbit\n"}, {"input": "wweneewwmenm", "output": "Rabbit\n"}, {"input": "wwmneewwmene", "output": "Rabbit\n"}, {"input": "xwmneewwmene",...
code_stdio
[ { "content": "There are n coins labeled from 1 to n. Initially, coin c_i is on position i and is facing upwards ((c_1, c_2, ..., c_n) is a permutation of numbers from 1 to n). You can do some operations on these coins. \n\nIn one operation, you can do the following:\n\n * Choose 2 distinct indices i and j.\n\n...
[{"input": "4\n2 3 4 1\n", "output": "5\n1 2\n2 3\n2 4\n1 3\n1 2\n"}, {"input": "4\n2 1 4 3\n", "output": "4\n1 3\n1 4\n3 2\n3 1\n"}, {"input": "3\n2 3 1\n", "output": "4\n1 2\n2 3\n1 3\n1 2\n"}, {"input": "3\n3 1 2\n", "output": "4\n1 3\n3 2\n1 2\n1 3\n"}, {"input": "3\n2 1 3\n", "output": "\n3\n1 3\n3 2\n3 1\n"}, {"i...
code_stdio
[ { "content": "Devu has an array A consisting of N positive integers. He would like to perform following operation on array.\n\n- Pick some two elements a, b in the array (a could be same as b, but their corresponding indices in the array should not be same).\nRemove both the elements a and b and instead add a n...
[{"input": "2 4\n1 18\n1\n2\n5\n4", "output": "Yes\nYes\nYes\nYes\n"}, {"input": "2 4\n1 3\n1\n2\n3\n3", "output": "Yes\nYes\nYes\nYes\n"}, {"input": "2 4\n2 18\n1\n2\n5\n4", "output": "No\nYes\nYes\nYes\n"}, {"input": "2 4\n8 0\n0\n2\n18\n0", "output": "Yes\nYes\nNo\nYes\n"}, {"input": "2 4\n1 3\n1\n2\n3\n10", "output...
code_stdio
[ { "content": "problem\n\nJOI, who has been suffering from his winter vacation homework every time, decided to do his homework systematically this time. Homework is a national language and math drill, with a national language drill on page A and a math drill on page B.\n\nJOI can advance the Japanese drill up to...
[{"input": "20\n10\n346\n6\n2", "output": "-153\n"}, {"input": "20\n10\n346\n4\n8", "output": "-24\n"}, {"input": "20\n25\n47\n6\n1", "output": "-27\n"}, {"input": "20\n4\n125\n1\n3", "output": "-22\n"}, {"input": "20\n28\n84\n1\n1", "output": "-64\n"}, {"input": "20\n13\n86\n8\n1", "output": "-66\n"}, {"input": "20\n1...
code_stdio
[ { "content": "You've come to your favorite store Infinitesco to buy some ice tea.\n\nThe store sells ice tea in bottles of different volumes at different costs. Specifically, a 0.25-liter bottle costs Q yen, a 0.5-liter bottle costs H yen, a 1-liter bottle costs S yen, and a 2-liter bottle costs D yen. The stor...
[{"input": "12345678 87654321 12345678 87654321\n226515686", "output": "2796489721305108\n"}, {"input": "12345678 87654321 12873114 87654321\n226515686", "output": "2915962248666204\n"}, {"input": "12345678 87654321 12345678 87654321\n123456789", "output": "1524157763907942"}, {"input": "1103255 87654321 12873114 87654...
code_stdio
[ { "content": "The Physical education teacher at SESC is a sort of mathematician too. His most favorite topic in mathematics is progressions. That is why the teacher wants the students lined up in non-decreasing height form an arithmetic progression.\n\nTo achieve the goal, the gym teacher ordered a lot of magic...
[{"input": "100\n246 485 -940 -186 -841 -98 711 429 -154 164 -244 -111 886 -447 22 480 224 -132 927 812 -243 -152 -843 403 -320 -346 -407 827 645 -903 -172 540 -359 498 270 18 374 -52 -983 -164 -707 -242 -159 -825 -889 661 -629 212 849 -891 -622 810 957 897 -110 -293 -257 822 690 369 -914 212 -338 -928 -862 525 -179 46...
code_stdio
[ { "content": "Peter can see a clock in the mirror from the place he sits in the office.\nWhen he saw the clock shows 12:22\n\n\n\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n\n\n\n\nHe knows that the time is 11:38\n\n\n\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n\n\n\n\nin the same manner:\n\n05:25 --> 06:35\n\n01:50 -...
[{"input": "\"06:35\"", "output": "[\"05:25\"]", "fn_name": "what_is_the_time"}, {"input": "\"11:59\"", "output": "[\"12:01\"]", "fn_name": "what_is_the_time"}, {"input": "\"12:02\"", "output": "[\"11:58\"]", "fn_name": "what_is_the_time"}, {"input": "\"04:00\"", "output": "[\"08:00\"]", "fn_name": "what_is_the_time"},...
code_functional
[ { "content": "Olga came to visit the twins Anna and Maria and saw that they have many cookies. The cookies are distributed into bags. As there are many cookies, Olga decided that it's no big deal if she steals a bag. However, she doesn't want the sisters to quarrel because of nothing when they divide the cookie...
[{"input": "99\n99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 100 99 ...
code_stdio
[ { "content": "Given an integer N, find the base -2 representation of N.\nHere, S is the base -2 representation of N when the following are all satisfied:\n - S is a string consisting of 0 and 1.\n - Unless S = 0, the initial character of S is 1.\n - Let S = S_k S_{k-1} ... S_0, then S_0 \\times (-2)^0 + S_1 \\t...
[{"input": "-1000000000\n", "output": "11000101101001010100101000000000\n"}, {"input": "-790013317\n", "output": "11010001001111101010111110001111\n"}, {"input": "1000000000\n", "output": "1001100111011111101111000000000\n"}, {"input": "586260100\n", "output": "1100111001101101110001110000100\n"}, {"input": "-192321079...
code_stdio
[ { "content": "Little Vasya has received a young builder’s kit. The kit consists of several wooden bars, the lengths of all of them are known. The bars can be put one on the top of the other if their lengths are the same.\n\nVasya wants to construct the minimal number of towers from the bars. Help Vasya to use t...
[{"input": "123\n112 277 170 247 252 115 157 293 256 143 196 90 12 164 164 42 8 223 167 109 175 232 239 111 148 51 9 254 93 32 268 162 231 91 47 162 161 191 195 145 247 292 129 199 230 94 144 217 18 205 176 20 143 198 121 243 211 262 230 277 195 255 108 290 220 275 158 2 286 200 60 267 278 207 123 150 123 116 131 13 12...
code_stdio
[ { "content": "Treeland is a country in which there are n towns connected by n - 1 two-way road such that it's possible to get from any town to any other town. \n\nIn Treeland there are 2k universities which are located in different towns. \n\nRecently, the president signed the decree to connect universities by ...
[{"input": "35 15\n6 12 32 18 11 10 29 9 30 27 31 14 8 24 28 25 19 15 21 3 4 1 33 22 23 17 16 13 7 2\n1 2\n20 3\n1 4\n20 5\n20 6\n1 7\n13 8\n4 9\n1 10\n1 11\n1 12\n1 13\n18 14\n10 15\n1 16\n16 17\n1 18\n1 19\n1 20\n20 21\n1 22\n27 23\n25 24\n1 25\n20 26\n20 27\n18 28\n4 29\n13 30\n4 31\n1 32\n20 33\n1 34\n4 35\n", "out...
code_stdio
[ { "content": "Pushok the dog has been chasing Imp for a few hours already. $48$ \n\nFortunately, Imp knows that Pushok is afraid of a robot vacuum cleaner. \n\nWhile moving, the robot generates a string t consisting of letters 's' and 'h', that produces a lot of noise. We define noise of string t as the number ...
[{"input": "100\nh\nshh\nh\nhs\nshh\nhh\nh\nssh\nhss\nh\nhh\nh\nh\nh\nh\nh\nh\nh\nh\nh\nhh\nh\nh\nh\nh\nhhh\nh\nh\nhhh\nsh\nhh\nhs\nh\nh\nshs\nh\nh\nh\nshh\nhs\nhs\nh\nh\nh\nhhh\nh\nhhs\nhh\nh\nssh\nh\nh\nhh\nsh\nh\nhss\nh\nhh\nsh\nhh\nhh\nhhh\nhs\nh\nh\nh\nshs\nhs\nshs\nsh\nh\nh\nhs\nh\nh\nh\nh\nsh\nssh\nh\nh\nhh\nhhh...
code_stdio
[ { "content": "Monocarp is playing a computer game. He's going to kill $n$ monsters, the $i$-th of them has $h_i$ health.\n\nMonocarp's character has two spells, either of which he can cast an arbitrary number of times (possibly, zero) and in an arbitrary order:\n\nchoose exactly two alive monsters and decrease ...
[{"input": "1\n43\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "22\n"}, {"input": "1\n30\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "15\n"}, {"input": "3\n4\n1 2 1 2\n3\n2 4 2\n5\n1 2 3 4 5\n", "output": "3\n3\n5\n"}, {"input": "1\n...
code_stdio
[ { "content": "In another Kata I came across a weird `sort` function to implement. We had to sort characters as usual ( 'A' before 'Z' and 'Z' before 'a' ) except that the `numbers` had to be sorted **after** the `letters` ( '0' after 'z') !!!\n\n(After a couple of hours trying to solve this unusual-sorting-kata...
[{"input": "[\"0\", \"9\", \"8\", \"1\", \"7\", \"2\", \"6\", \"3\", \"5\", \"4\"]", "output": "[[\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"]]", "fn_name": "unusual_sort"}, {"input": "[\"c\", \"b\", \"a\", \"9\", \"5\", \"0\", \"X\", \"Y\", \"Z\"]", "output": "[[\"X\", \"Y\", \"Z\", \"a\", \"b...
code_functional
[ { "content": "Nick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda a_{i} and bottle volume b_{i} (a_{i} ≤ b_{i}).\n\nNick has decided to pour all remaining soda into minimal number of bottles, moreover he has to do it as soon as possible. Nick spen...
[{"input": "90\n4 2 21 69 53 39 2 2 8 58 7 5 2 82 7 9 13 10 2 44 1 7 2 1 50 42 36 17 14 46 19 1 50 20 51 46 9 59 73 61 76 4 19 22 1 43 53 2 5 5 32 7 5 42 30 14 32 6 6 15 20 24 13 8 5 19 9 9 7 20 7 2 55 36 5 33 64 20 22 22 9 30 67 38 68 2 13 19 2 9\n48 4 39 85 69 70 11 42 65 77 61 6 60 84 67 15 99 12 2 84 51 17 10 3 50 ...
code_stdio
[ { "content": "Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly a_{i} feet high. \n\n [Image] \n\nA group of bears is a non-empty contiguous se...
[{"input": "20\n452405440 586588704 509061481 392584366 16115810 148658854 66743034 290624691 677780684 519361360 208050516 401554301 954478790 989443769 387546138 832279893 1081316002 80960260 846049648 588066499\n", "output": "1081316002 954478790 452405440 392584366 387546138 387546138 208050516 208050516 208050516 ...
code_stdio
[ { "content": "Vasya has gotten interested in programming contests in TCMCF+++ rules. On the contest n problems were suggested and every problem had a cost — a certain integral number of points (perhaps, negative or even equal to zero). According to TCMCF+++ rules, only accepted problems can earn points and the ...
[{"input": "100\n-93 -100 -99 -100 -99 -100 -99 -99 -99 -100 -99 -99 -100 -98 -98 -100 -99 -100 -95 -100 -100 -99 -98 -100 -96 -99 -99 -100 -97 -98 -100 -98 -98 -93 -100 -100 -99 -100 -100 -98 -100 -98 -100 -98 -97 -99 -98 -99 -99 -99 -100 -100 -100 -100 -98 -93 -100 -100 -97 -100 -100 -100 -98 -126 -100 -95 -98 -99 -1...
code_stdio
[ { "content": "Adilbek's house is located on a street which can be represented as the OX axis. This street is really dark, so Adilbek wants to install some post lamps to illuminate it. Street has $n$ positions to install lamps, they correspond to the integer numbers from $0$ to $n - 1$ on the OX axis. However, s...
[{"input": "20 16 16\n1 2 3 4 5 6 8 9 10 11 13 14 15 16 18 19\n2 1 1 1 1 1 3 3 2 2 1 3 3 3 3 2\n", "output": "3\n"}, {"input": "20 16 16\n1 2 3 4 5 6 8 9 10 11 13 14 15 16 18 19\n2 1 1 1 1 1 3 3 2 2 1 3 3 3 3 2\n", "output": "3\n"}, {"input": "20 16 16\n1 2 3 4 5 6 8 9 10 11 13 14 15 16 18 19\n2 1 1 1 1 1 3 1 2 2 1 3 3...
code_stdio