messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "The prime number sequence starts with: `2,3,5,7,11,13,17,19...`. Notice that `2` is in position `one`. \n\n`3` occupies position `two`, which is a prime-numbered position. Similarly, `5`, `11` and `17` also occupy prime-numbered positions. We shall call primes such as `3,5,11,17` dominant primes b...
[{"input": "2000\n200000", "output": "[183035206]", "fn_name": "solve"}, {"input": "3000\n400000", "output": "[650120994]", "fn_name": "solve"}, {"input": "4000\n500000", "output": "[972664400]", "fn_name": "solve"}, {"input": "1000\n100000", "output": "[52114889]", "fn_name": "solve"}, {"input": "500\n10000", "output"...
code_functional
[ { "content": "There is a game called \"I Wanna Be the Guy\", consisting of n levels. Little X and his friend Little Y are addicted to the game. Each of them wants to pass the whole game.\n\nLittle X can pass only p levels of the game. And Little Y can pass only q levels of the game. You are given the indices of...
[{"input": "100\n75 83 69 73 30 76 37 48 14 41 42 21 35 15 50 61 86 85 46 3 31 13 78 10 2 44 80 95 56 82 38 75 77 4 99 9 84 53 12 11 36 74 39 72 43 89 57 28 54 1 51 66 27 22 93 59 68 88 91 29 7 20 63 8 52 23 64 58 100 79 65 49 96 71 33 45\n83 50 89 73 34 28 99 67 77 44 19 60 68 42 8 27 94 85 14 39 17 78 24 21 29 63 92 ...
code_stdio
[ { "content": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-han...
[{"input": "1000000000\n", "output": "231564544\n"}, {"input": "1000000000\n", "output": "231564544\n"}, {"input": "1000000100\n", "output": "231564594\n"}, {"input": "1000010100\n", "output": "231569594\n"}, {"input": "1038818275\n", "output": "519409137\n"}, {"input": "536870910\n", "output": "134217727\n"}, {"input"...
code_stdio
[ { "content": "After years of hard work scientists invented an absolutely new e-reader display. The new display has a larger resolution, consumes less energy and its production is cheaper. And besides, one can bend it. The only inconvenience is highly unusual management. For that very reason the developers decid...
[{"input": "10\n1101010101\n1110101010\n0111010101\n1011101010\n0101110101\n1010111010\n0101011101\n1010101110\n0101010111\n1010101011\n", "output": "100\n"}, {"input": "10\n1111100000\n0010100000\n0110111000\n0000001000\n1011001010\n0010100001\n0010111000\n0011001010\n0000110010\n0000001100\n", "output": "20\n"}, {"in...
code_stdio
[ { "content": "In this Kata, you will be given a string and your task will be to return a list of ints detailing the count of uppercase letters, lowercase, numbers and special characters, as follows.\n\n```Haskell\nSolve(\"*'&ABCDabcde12345\") = [4,5,5,3]. \n--the order is: uppercase letters, lowercase, numbers ...
[{"input": "\"RYT'>s&gO-.CM9AKeH?,5317tWGpS<*x2ukXZD\"", "output": "[[15, 8, 6, 9]]", "fn_name": "solve"}, {"input": "\"@mw>0=QD-iAx!rp9TaG?o&M%l$34L.nbft\"", "output": "[[7, 13, 4, 10]]", "fn_name": "solve"}, {"input": "\"P*K4%>mQUDaG$h=cx2?.Czt7!Zn16p@5H\"", "output": "[[9, 9, 6, 9]]", "fn_name": "solve"}, {"input": ...
code_functional
[ { "content": "Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). \n\nHe has a set that consists of n integer segments: [l_1; r_1], [l_2; r_2], ..., [l_{n}; r_{n}]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 ...
[{"input": "47 21\n3 5\n-422 -417\n60 60\n-348 -348\n-3 -3\n-364 -361\n-49 -41\n-436 -430\n-250 -244\n-33 -26\n-162 -158\n-90 -88\n-357 -352\n-339 -337\n-25 -19\n-69 -67\n-261 -260\n-292 -283\n12 18\n44 44\n-277 -275\n-301 -293\n-108 -98\n-180 -172\n-327 -318\n-314 -309\n-12 -7\n-134 -130\n33 35\n-190 -184\n-65 -55\n-2...
code_stdio
[ { "content": "You are given a tree consisting of n nodes. You generate an array from the tree by marking nodes one by one.\n\nInitially, when no nodes are marked, a node is equiprobably chosen and marked from the entire tree. \n\nAfter that, until all nodes are marked, a node is equiprobably chosen and marked f...
[{"input": "6\n2 1\n2 3\n6 1\n1 4\n1 5\n", "output": "750000011\n"}, {"input": "6\n2 1\n1 3\n6 1\n1 4\n2 5\n", "output": "416666675\n"}, {"input": "6\n2 1\n2 3\n6 1\n1 4\n4 5\n", "output": "666666677\n"}, {"input": "6\n2 1\n1 3\n6 1\n2 4\n4 5\n", "output": "500000009\n"}, {"input": "6\n2 1\n2 3\n6 1\n2 4\n4 5\n", "outp...
code_stdio
[ { "content": "In Berland, $n$ different types of banknotes are used. Banknotes of the $i$-th type have denomination $10^{a_i}$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $1$.\n\nLet's denote $f(s)$ as the minimum number of banknotes required to r...
[{"input": "4\n3 27\n0 1 2\n2 777\n0 2\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9\n", "output": "1099\n67999\n148999\n999999920999999999\n"}, {"input": "4\n3 22\n0 1 4\n2 1121\n0 2\n3 192\n0 1 2\n10 1000000000\n0 1 2 3 4 5 6 7 8 9\n", "output": "149\n102399\n17599\n999999920999999999\n"}, {"input": "4\n3 27\n0 1...
code_stdio
[ { "content": "Snuke has a calculator. It has a display and two buttons.\n\nInitially, the display shows an integer x. Snuke wants to change this value into another integer y, by pressing the following two buttons some number of times in arbitrary order:\n\n* Button A: When pressed, the value on the display is i...
[{"input": "-10 -23", "output": "15\n"}, {"input": "110 -1", "output": "110\n"}, {"input": "-10 -63", "output": "55\n"}, {"input": "273 -1", "output": "273\n"}, {"input": "141 -1", "output": "141\n"}, {"input": "174 -1", "output": "174\n"}, {"input": "141 -2", "output": "140\n"}, {"input": "264 -2", "output": "263\n"},...
code_stdio
[ { "content": "The marketing team is spending way too much time typing in hashtags. \nLet's help them with our own Hashtag Generator!\n\nHere's the deal:\n\n- It must start with a hashtag (`#`).\n- All words must have their first letter capitalized.\n- If the final result is longer than 140 chars it must retur...
[{"input": "\"Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong Cat\"", "output": "[false]", "fn_name": "generate_hashtag"}, {"input": "\"codewars is nice\"", "output": "[\"#CodewarsIsNice\"]", "fn_name": "gen...
code_functional
[ { "content": "Entrance Examination\n\nThe International Competitive Programming College (ICPC) is famous for its research on competitive programming. Applicants to the college are required to take its entrance examination.\n\nThe successful applicants of the examination are chosen as follows.\n\n* The score of ...
[{"input": "5 2 4\n100\n90\n82\n70\n65\n5 2 4\n100\n170\n80\n75\n65\n3 1 2\n5000\n6502\n3000\n4 2 3\n10000\n10100\n8000\n8000\n4 2 3\n10000\n10000\n10000\n8000\n5 2 3\n100\n80\n136\n60\n111\n0 0 0", "output": "3\n2\n2\n2\n3\n3\n"}, {"input": "5 2 3\n100\n161\n82\n70\n65\n5 2 4\n100\n90\n25\n144\n65\n3 1 2\n5000\n6502\n...
code_stdio
[ { "content": "Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.\n\nNow it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following ...
[{"input": "10\n5 7\n4 5\n10 2\n4 6\n1 2\n3 4\n8 5\n4 9\n2 3\n15 15 15 15 5 15 26 18 15 15\n", "output": "YES\n5\n"}, {"input": "10\n5 7\n4 5\n10 2\n4 6\n1 2\n3 4\n8 5\n4 9\n2 3\n15 15 15 15 5 15 42 18 15 15\n", "output": "YES\n5\n"}, {"input": "10\n5 7\n4 5\n10 2\n3 6\n1 2\n3 4\n8 5\n4 9\n2 3\n15 15 15 15 5 15 26 18 1...
code_stdio
[ { "content": "Gift Exchange Party\n\nA gift exchange party will be held at a school in TKB City.\n\nFor every pair of students who are close friends, one gift must be given from one to the other at this party, but not the other way around. It is decided in advance the gift directions, that is, which student of ...
[{"input": "4 3\n1 2\n2 3\n1 3\n4 3\n1 2\n1 3\n1 4\n15 6\n1 7\n1 3\n1 4\n2 3\n3 4\n3 4\n0 0", "output": "0 1\n0 1\n0 2\n"}, {"input": "3 3\n1 2\n2 3\n1 3\n4 3\n1 2\n1 3\n1 4\n4 6\n1 2\n1 3\n1 2\n2 3\n3 4\n2 4\n0 0", "output": "1 1\n0 1\n1 2\n"}, {"input": "3 3\n2 2\n2 3\n2 3\n4 3\n1 2\n1 3\n1 4\n4 6\n1 4\n1 3\n1 4\n2 3...
code_stdio
[ { "content": "You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c.\n\nYou have to find minimum k such that there exists at least one k-dominant character.\n\n\n-----Input-----\n\nThe first line ...
[{"input": "gfliflgfhhdkceacdljgkegmdlhcgkcmlelmbbbmdddgdeeljjhgbbffmemmmkhebgkhadkdajabcjkcgbkgbaeacdedlkklfech\n", "output": "17\n"}, {"input": "gfliflgfhhdkceacdljgkegmdlhcgkcmlelmbbbmdddgdeeljjhgbbffmemmmjhebgkhadkdajabcjkcgbkgbaeacdedlkklfech\n", "output": "17\n"}, {"input": "hceflkkldedcaeabgkbgckjcbajadkdahkgbeh...
code_stdio
[ { "content": "J - Tree Reconstruction\n\nProblem Statement\n\nYou have a directed graph. Some non-negative value is assigned on each edge of the graph. You know that the value of the graph satisfies the flow conservation law That is, for every node v, the sum of values on edges incoming to v equals to the sum o...
[{"input": "18 2\n1 1\n1 3\n1 13\n2 4\n3 0\n5 6\n0 9\n5 12\n0 10\n6 3\n7 9\n5 10\n9 1", "output": "1\n"}, {"input": "18 2\n1 1\n1 3\n1 9\n2 4\n3 0\n5 6\n0 9\n5 12\n0 10\n6 3\n7 9\n5 10\n9 1", "output": "1\n"}, {"input": "9 2\n1 1\n1 3\n1 11\n2 4\n3 0\n5 6\n4 9\n5 10\n6 20\n6 8\n7 9\n5 10\n9 1", "output": "1\n"}, {"inpu...
code_stdio
[ { "content": "A prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6, 4 are not.\n\nThe next prime number after x is the smallest prime number greater than x. For example, the next prime number after 2 is 3, and the next prime number ...
[{"input": "13 17\n", "output": "YES\n"}, {"input": "23 29\n", "output": "YES\n"}, {"input": "43 47\n", "output": "YES\n"}, {"input": "17 19\n", "output": "YES\n"}, {"input": "11 13\n", "output": "YES\n"}, {"input": "19 23\n", "output": "YES\n"}, {"input": "37 41\n", "output": "YES\n"}, {"input": "31 37\n", "output": "...
code_stdio
[ { "content": "4 different points on the plane Read the coordinates of $ A (x_a, y_a) $, $ B (x_b, y_b) $, $ C (x_c, y_c) $, $ D (x_d, y_d) $ and read those 4 points Create a program that outputs YES if there is no dent in the quadrangle $ ABCD $ with the coordinates as the vertices, and NO if there is a dent.\n...
[{"input": "1.0,0.0,0.1,0.1,0.0,0.1,0.0,0.0\n0.3,0.1,0.1,1.1,0.0,0.3,0.0,0.0", "output": "YES\nYES\n"}, {"input": "0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.1\n0.3,0.1,0.1,1.1,0.0,0.3,0.0,0.0", "output": "YES\nYES\n"}, {"input": "0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.1\n0.3,0.1,0.1,1.1,0.0,0.4,0.0,0.0", "output": "YES\nYES\n"}, {"input": ...
code_stdio
[ { "content": "You are given two strings of equal length $s$ and $t$ consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.\n\nDuring each operation you choose two adjacent characters in any string and assign the value of the first character to the value o...
[{"input": "3\nxabb\naabx\ntechnocup\ntechnocup\na\nz\n", "output": "YES\nYES\nNO\n"}, {"input": "3\nxabb\naabx\nteohnccup\ntechnocup\na\nz\n", "output": "YES\nYES\nNO\n"}, {"input": "3\nxabb\naabx\ntdohnccup\ntechnocup\na\nz\n", "output": "YES\nYES\nNO\n"}, {"input": "3\nxabb\nxbaa\ntdohnccup\ntechnocup\na\nz\n", "out...
code_stdio
[ { "content": "A group of university students wants to get to the top of a mountain to have a picnic there. For that they decided to use a cableway.\n\nA cableway is represented by some cablecars, hanged onto some cable stations by a cable. A cable is scrolled cyclically between the first and the last cable stat...
[{"input": "100 100 100\n", "output": "179"}, {"input": "100 0 100\n", "output": "179"}, {"input": "100 100 0\n", "output": "178"}, {"input": "0 100 100\n", "output": "179"}, {"input": "45 52 14\n", "output": "106\n"}, {"input": "50 28 30\n", "output": "102\n"}, {"input": "99 97 42\n", "output": "177\n"}, {"input": "90...
code_stdio
[ { "content": "Create a function that takes a list of one or more non-negative integers, and arranges them such that they form the largest possible number.\n\nExamples:\n\n`largestArrangement([4, 50, 8, 145])` returns 8504145 (8-50-4-145)\n\n`largestArrangement([4, 40, 7])` returns 7440 (7-4-40)\n\n`largestArran...
[{"input": "[422, 995, 500, 202, 772, 230, 258, 144, 752]", "output": "[995772752500422258230202144]", "fn_name": "largest_arrangement"}, {"input": "[451, 850, 85, 283, 4, 734, 605, 499, 249]", "output": "[858507346054994514283249]", "fn_name": "largest_arrangement"}, {"input": "[70, 7, 81, 28, 336, 246, 817, 77, 4, 55...
code_functional
[ { "content": "After passing a test, Vasya got himself a box of $n$ candies. He decided to eat an equal amount of candies each morning until there are no more candies. However, Petya also noticed the box and decided to get some candies for himself.\n\nThis means the process of eating candies is the following: in...
[{"input": "3345775397705614178\n", "output": "131353216887383264\n"}, {"input": "2750054323692292581\n", "output": "107965550311522536\n"}, {"input": "1000000000000000000\n", "output": "39259424579862572\n"}, {"input": "1000000000000000000\n", "output": "39259424579862572\n"}, {"input": "1288212249779732665\n", "outpu...
code_stdio
[ { "content": "Did you ever hear about 'Dragon Food' ? Its used to refer to the chocolates bought for your loved ones :). Po offers dragon food to master Shifu, who is a famous cook in the valley of food. In return, Shifu hands over the dragon scroll to Po, which is said to hold the ingredients of the secret rec...
[{"input": "3\n21 1 7\n2 1 1\n6 16 1", "output": "1966080\n3\n48\n"}, {"input": "3\n21 1 7\n2 0 1\n6 16 1", "output": "1966080\n2\n48\n"}, {"input": "3\n21 1 1\n2 0 1\n6 16 1", "output": "1572864\n2\n48\n"}, {"input": "3\n21 1 1\n2 0 1\n6 16 0", "output": "1572864\n2\n32\n"}, {"input": "3\n11 1 7\n2 1 1\n6 16 7", "outp...
code_stdio
[ { "content": "Kurt reaches nirvana when he finds the product of all the digits of some positive integer. Greater value of the product makes the nirvana deeper.\n\nHelp Kurt find the maximum possible product of digits among all integers from $1$ to $n$.\n\n\n-----Input-----\n\nThe only input line contains the in...
[{"input": "1000000000\n", "output": "387420489\n"}, {"input": "2000000000\n", "output": "387420489\n"}, {"input": "1382011913\n", "output": "387420489\n"}, {"input": "1999999999\n", "output": "387420489\n"}, {"input": "1999999998\n", "output": "387420489\n"}, {"input": "1616324002\n", "output": "387420489\n"}, {"input...
code_stdio
[ { "content": "A widely known among some people Belarusian sport programmer Lesha decided to make some money to buy a one square meter larger flat. To do this, he wants to make and carry out a Super Rated Match (SRM) on the site Torcoder.com. But there's a problem — a severe torcoder coordinator Ivan does not ac...
[{"input": "4\ntfggs qnehos igekv rnmr\n10\n8 ccj ccj qnehos igekv rnmr ccj igekv qnehos\n8 rnmr igekv gydhj tfggs ccj tfggs rnmr rnmr\n8 gydhj qnehos igekv ccj tfggs gydhj qnehos ccj\n8 tfggs igekv rnmr rnmr rnmr tfggs rnmr ccj\n8 jjwek gydhj gydhj tfggs igekv igekv rnmr ccj\n8 rnmr tfggs rnmr tfggs rnmr gydhj ccj qne...
code_stdio
[ { "content": "We will define Ginkgo numbers and multiplication on Ginkgo numbers.\n\nA Ginkgo number is a pair <m, n> where m and n are integers. For example, <1, 1>, <-2, 1> and <-3,-1> are Ginkgo numbers.\n\nThe multiplication on Ginkgo numbers is defined by <m, n> * <x, y> = <mx − ny, my + nx>. For example, ...
[{"input": "8\n10 -1\n-2 12\n1 3\n6 -1\n1 -40\n-8 0\n-4 1\n2 -1", "output": "P\nC\nC\nP\nP\nC\nP\nP\n"}, {"input": "8\n10 -1\n0 2\n-1 2\n4 0\n0 -25\n-4 0\n-2 -1\n2 -1", "output": "P\nC\nP\nC\nC\nC\nP\nP\n"}, {"input": "8\n10 -1\n-1 4\n0 3\n6 -1\n2 -23\n-13 0\n-2 1\n2 0", "output": "P\nP\nP\nP\nC\nC\nP\nC\n"}, {"input":...
code_stdio
[ { "content": "You are given an array $a$ consisting of $n$ positive integers. Find a non-empty subset of its elements such that their sum is even (i.e. divisible by $2$) or determine that there is no such subset.\n\nBoth the given array and required subset may contain equal values.\n\n\n-----Input-----\n\nThe f...
[{"input": "14\n1\n2\n1\n1\n2\n2 2\n2\n2 1\n2\n1 2\n2\n1 1\n3\n2 2 2\n3\n2 2 1\n3\n2 1 2\n3\n2 1 1\n3\n1 2 2\n3\n1 2 1\n3\n1 1 2\n3\n1 1 1\n", "output": "1\n1\n-1\n1\n1\n1\n1\n1\n2\n2\n1 2\n1\n1\n1\n1\n1\n1\n1\n1\n1\n2\n1\n2\n2\n1 2\n2\n1 2\n"}, {"input": "14\n1\n2\n1\n1\n2\n2 2\n2\n2 1\n2\n1 2\n2\n1 1\n3\n2 2 2\n3\n2 ...
code_stdio
[ { "content": "Jump is a simple one-player game:\n\nYou are initially at the first cell of an array of cells containing non-negative integers;\n\nAt each step you can jump ahead in the array as far as the integer at the current cell, or any smaller number of cells.\nYou win if there is a path that allows you to ...
[{"input": "[11, 6, 11, 0, 2, 1, 14, 3, 7, 6, 2, 1, 10, 6, 0, 0, 8, 10, 2, 12, 13, 11, 14, 6, 1, 4, 14, 3, 10, 4, 14, 2, 3, 10, 8, 13, 14, 8, 2, 13, 11, 14, 0, 1, 6, 2, 1, 6, 8, 2, 0, 12, 4, 9, 2, 6, 8, 14, 4, 14, 4, 10, 8, 7, 12, 11, 0, 3, 8, 0, 13, 9, 9, 11, 10, 13, 12, 1, 0, 10, 14, 6, 1, 11, 7, 8, 6, 2, 1, 3, 1, 1,...
code_functional
[ { "content": "You are given a sequence of positive integers a1, a2, ..., an. Find all such indices i, that the i-th element equals the arithmetic mean of all other elements (that is all elements except for this one).\n\nInput\n\nThe first line contains the integer n (2 ≤ n ≤ 2·105). The second line contains ele...
[{"input": "15\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "15\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n"}, {"input": "10\n3 3 3 3 3 4 3 3 3 2\n", "output": "8\n1 2 3 4 5 7 8 9\n"}, {"input": "10\n15 7 10 7 7 7 4 4 7 2\n", "output": "5\n2 4 5 6 9\n"}, {"input": "15\n1 1 1 1 1 1 1 1 1 1 1 2 1 1 1\n", "output": "0\n\n"}, {...
code_stdio
[ { "content": "Snark and Philip are preparing the problemset for the upcoming pre-qualification round for semi-quarter-finals. They have a bank of n problems, and they want to select any non-empty subset of it as a problemset.\n\nk experienced teams are participating in the contest. Some of these teams already k...
[{"input": "10 4\n1 0 1 0\n1 0 0 1\n1 1 0 1\n1 0 1 1\n1 1 0 1\n1 0 1 0\n0 0 0 0\n0 0 1 0\n1 0 1 0\n0 0 1 1\n", "output": "YES\n"}, {"input": "10 4\n1 0 1 0\n1 0 1 0\n0 1 1 1\n1 0 1 1\n1 1 0 1\n1 0 0 1\n0 1 1 1\n0 0 0 1\n1 1 1 1\n1 0 1 0\n", "output": "YES\n"}, {"input": "10 4\n0 0 1 1\n0 0 1 1\n0 0 1 1\n0 0 1 1\n0 0 1 ...
code_stdio
[ { "content": "Write a program which reads a sequence A of n elements and an integer M, and outputs \"yes\" if you can make M by adding elements in A, otherwise \"no\". You can use an element only once.\n\nYou are given the sequence A and q questions where each question contains Mi.\n\nNotes\n\nYou can solve thi...
[{"input": "5\n-1 5 10 1 21\n8\n1 8 31 11 16 14 001 40", "output": "yes\nno\nyes\nyes\nyes\nyes\nyes\nno\n"}, {"input": "5\n1 5 13 3 21\n8\n0 4 17 11 22 21 010 42", "output": "yes\nyes\nyes\nno\nyes\nyes\nno\nyes\n"}, {"input": "5\n1 5 7 3 21\n8\n0 4 17 11 22 21 010 42", "output": "yes\nyes\nno\nyes\nyes\nyes\nyes\nno\...
code_stdio
[ { "content": "Casimir has a rectangular piece of paper with a checkered field of size $n \\times m$. Initially, all cells of the field are white.\n\nLet us denote the cell with coordinates $i$ vertically and $j$ horizontally by $(i, j)$. The upper left cell will be referred to as $(1, 1)$ and the lower right ce...
[{"input": "8\n2 3 1\n*.*\n...\n4 9 2\n*.*.*...*\n.*.*...*.\n..*.*.*..\n.....*...\n4 4 1\n*.*.\n****\n.**.\n....\n5 5 1\n.....\n*...*\n.*.*.\n..*.*\n...*.\n5 5 2\n.....\n*...*\n.*.*.\n..*.*\n...*.\n4 7 1\n*.....*\n.....*.\n..*.*..\n...*...\n3 3 1\n***\n***\n***\n3 5 1\n*...*\n.***.\n.**..\n", "output": "NO\nYES\nYES\nY...
code_stdio
[ { "content": "Gildong is playing with his dog, Badugi. They're at a park that has $n$ intersections and $n-1$ bidirectional roads, each $1$ meter in length and connecting two intersections with each other. The intersections are numbered from $1$ to $n$, and for every $a$ and $b$ ($1 \\le a, b \\le n$), it is po...
[{"input": "3\n3\n1 2\n2 3\n4\n1 2\n2 3\n3 4\n5\n1 2\n2 3\n3 4\n4 5\n3 6\n6 7\n5 13\n", "output": "2\n3\n4\n"}, {"input": "3\n3\n1 2\n2 3\n4\n1 2\n2 3\n3 4\n4\n1 2\n1 3\n3 4\n1 5\n3 8\n6 13\n5 8\n", "output": "2\n3\n2\n"}, {"input": "3\n3\n1 2\n2 3\n4\n1 2\n2 3\n3 4\n4\n1 2\n1 3\n3 4\n1 5\n3 8\n5 13\n5 8\n", "output": ...
code_stdio
[ { "content": "We have a directed weighted graph with N vertices. Each vertex has two integers written on it, and the integers written on Vertex i are A_i and B_i.\n\nIn this graph, there is an edge from Vertex x to Vertex y for all pairs 1 \\leq x,y \\leq N, and its weight is {\\rm min}(A_x,B_y).\n\nWe will con...
[{"input": "6\n43 35\n97 26\n77 48\n133 16\n110 5\n154 15", "output": "140\n"}, {"input": "6\n43 35\n97 26\n77 48\n133 31\n110 5\n154 15", "output": "155\n"}, {"input": "6\n43 35\n97 26\n77 48\n133 36\n110 5\n154 15", "output": "160\n"}, {"input": "6\n43 35\n97 26\n46 48\n133 40\n010 5\n55 20", "output": "136\n"}, {"in...
code_stdio
[ { "content": "A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters + and 1 into this sequence. For example, sequences (())(), () and (()(())) are regular, while )(, (() and (()))( are not. Let's call a regular bracket sequence \"RBS\".\n\nYou are...
[{"input": "12\n(??)\n(??)\n(??)\n(??)\n(??)\n(??)\n(??)\n(??)\n(??)\n(??)\n(??)\n(??)\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "12\n(??)\n(??)\n(??)\n(??)\n(??)\n(??)\n(??)\n(??)\n(??)\n(??)\n(??)\n(??)\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES...
code_stdio
[ { "content": "# Task\n You are given a `moment` in time and space. What you must do is break it down into time and space, to determine if that moment is from the past, present or future.\n\n `Time` is the sum of characters that increase time (i.e. numbers in range ['1'..'9'].\n \n `Space` in the number of chara...
[{"input": "\"12:30 am\"", "output": "[[false, false, true]]", "fn_name": "moment_of_time_in_space"}, {"input": "\"12:02 pm\"", "output": "[[false, true, false]]", "fn_name": "moment_of_time_in_space"}, {"input": "\"01:00 pm\"", "output": "[[true, false, false]]", "fn_name": "moment_of_time_in_space"}, {"input": "\"11:...
code_functional
[ { "content": "A witch named Marie lived deep in a remote forest. Since she is a witch, she magically covers everything she needs to live, such as food, water, and fuel.\n\nHer magic is activated by drawing a magic circle using some magical stones and strings. This magic circle is drawn by placing stones and tyi...
[{"input": "5 4\n1 2\n2 3\n3 4\n4 5\n4 6\n1 2\n1 3\n1 4\n2 4\n2 4\n3 4\n5 0\n0 0", "output": "yes\nno\nyes\n"}, {"input": "5 4\n1 2\n2 3\n3 4\n4 5\n7 6\n1 2\n1 3\n1 4\n2 4\n2 4\n3 4\n5 0\n0 0", "output": "yes\nno\nyes\n"}, {"input": "5 4\n1 2\n2 3\n3 4\n4 5\n4 6\n1 2\n1 3\n1 4\n2 4\n2 1\n3 4\n5 0\n0 0", "output": "yes\...
code_stdio
[ { "content": "You are given the strings $a$ and $b$, consisting of lowercase Latin letters. You can do any number of the following operations in any order:\n\nif $|a| > 0$ (the length of the string $a$ is greater than zero), delete the first character of the string $a$, that is, replace $a$ with $a_2 a_3 \\ldot...
[{"input": "5\na\na\nabcd\nbc\nhello\ncodeforces\nhello\nhelo\ndhjakjsnasjhfksafasd\nadjsnasjhfksvdafdser\n", "output": "\n0\n2\n13\n3\n20\n"}, {"input": "5\na\na\nabcd\nbc\nhello\ncodeforces\nhello\nhelo\ndhjakjsnasjhfksafasd\nadjsnasjhfksvdafdser\n", "output": "0\n2\n13\n3\n20\n"}, {"input": "5\na\na\nabcc\nbc\nhello...
code_stdio
[ { "content": "A flower shop has got n bouquets, and the i-th bouquet consists of a_{i} flowers. Vasya, the manager of the shop, decided to make large bouquets from these bouquets. \n\nVasya thinks that a bouquet is large if it is made of two or more initial bouquets, and there is a constraint: the total number ...
[{"input": "25\n742168 377547 485672 437223 96307 902863 759104 747933 512899 410317 588598 666688 823202 257684 520631 910066 168864 71499 899972 565350 764848 754913 929040 864132 289976\n", "output": "10\n"}, {"input": "25\n742168 377547 485672 437223 96307 902863 759104 747933 512899 410317 588598 666688 823202 257...
code_stdio
[ { "content": "Heidi's friend Jenny is asking Heidi to deliver an important letter to one of their common friends. Since Jenny is Irish, Heidi thinks that this might be a prank. More precisely, she suspects that the message she is asked to deliver states: \"Send the fool further!\", and upon reading it the recip...
[{"input": "11\n1 0 6646\n2 0 8816\n3 2 9375\n4 2 5950\n5 1 8702\n6 2 2657\n7 2 885\n8 7 2660\n9 2 5369\n10 6 3798\n", "output": "18191\n"}, {"input": "11\n1 0 6646\n2 0 8816\n3 2 9375\n4 2 5950\n5 1 8702\n6 2 2657\n7 2 885\n8 7 2660\n9 2 5369\n10 6 3798\n", "output": "18191\n"}, {"input": "11\n1 0 6646\n2 0 8816\n3 2 ...
code_stdio
[ { "content": "You are given an array $a$ consisting of $n$ integers.\n\nYour task is to determine if $a$ has some subsequence of length at least $3$ that is a palindrome.\n\nRecall that an array $b$ is called a subsequence of the array $a$ if $b$ can be obtained by removing some (possibly, zero) elements from $...
[{"input": "15\n16\n1 1 1 1 1 1 1 1 1 1 1 1 5 12 12 14\n18\n12 14 12 15 17 16 11 5 15 15 7 15 15 14 16 16 11 11\n13\n4 9 11 7 13 9 10 1 3 7 12 5 9\n3\n3 2 2\n6\n6 3 2 2 3 1\n20\n2 2 4 4 5 5 5 5 5 5 5 5 5 5 6 8 10 12 12 17\n25\n1 1 6 10 8 8 9 10 14 16 16 16 16 16 16 16 16 16 16 16 16 18 21 21 23\n15\n6 1 5 3 15 10 14 15...
code_stdio
[ { "content": "Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some amount of snow every day. On day i he will make a pile of snow of volume V_{i} and put it in her garden...
[{"input": "13\n1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "1 1 1 1 1 1 1 1 1 1 1 1 1\n"}, {"input": "13\n1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "1 1 1 1 1 1 1 1 1 1 1 1 1 "}, {"input": "13\n1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 2 1 1 1 1 1 1\n", "output": "1 1 1 1 1...
code_stdio
[ { "content": "### Tongues\n\nGandalf's writings have long been available for study, but no one has yet figured out what language they are written in. Recently, due to programming work by a hacker known only by the code name ROT13, it has been discovered that Gandalf used nothing but a simple letter substitution...
[{"input": "\"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\"", "output": "[\"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\"]", "fn_name": "tongues"}, {"input": "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
code_functional
[ { "content": "Luntik came out for a morning stroll and found an array $a$ of length $n$. He calculated the sum $s$ of the elements of the array ($s= \\sum_{i=1}^{n} a_i$). Luntik calls a subsequence of the array $a$ nearly full if the sum of the numbers in that subsequence is equal to $s-1$.\n\nLuntik really wa...
[{"input": "5\n5\n1 2 3 4 1\n2\n1010 1000\n2\n1 0\n5\n3 -1 2 -1 1\n5\n2 1 0 3 0\n", "output": "2\n0\n2\n1\n4\n"}, {"input": "5\n5\n1 2 3 4 1\n2\n1001 1000\n2\n1 0\n5\n3 -1 2 -1 1\n5\n2 2 0 3 0\n", "output": "2\n0\n2\n1\n0\n"}, {"input": "5\n5\n1 2 3 4 1\n2\n1001 1000\n2\n1 0\n5\n3 -1 2 -1 2\n5\n2 2 0 3 0\n", "output": ...
code_stdio
[ { "content": "Snuke has N strings. The i-th string is s_i.\n\nLet us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.\n\nConstraints\n\n* 1 \\leq N \\leq 10^{4}\n* 2 \\leq |s_i| \\leq 10\n* s_i consists...
[{"input": "9\nBEWPVCRWH\nZQNZYIJX\nBAVREA\nPA\nHJMYITEOX\nBCJHMRMNK\nBP\nQVFABZ\nPRGKSPUNA", "output": "4\n"}, {"input": "9\nBEWPVCRWH\nZQNZYIJX\nAERVAB\nPA\nHJMYITEOX\nBCJHMRMNK\nBP\nQVFABZ\nPRGKSPUNA", "output": "4\n"}, {"input": "9\nBEWPVCRWH\nZQNZYIJX\nAERVAB\nPA\nHJMYITEOX\nBCJHMRMNK\nPB\nQVFABZ\nPRGKSPUNA", "out...
code_stdio
[ { "content": "There are N stones, numbered 1, 2, \\ldots, N. For each i (1 \\leq i \\leq N), the height of Stone i is h_i.\n\nThere is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N:\n\n* If the frog is currently on Stone i, jump to one of the follo...
[{"input": "10 1\n65 19 34 219 208 10 13 13 39 118", "output": "563\n"}, {"input": "5 1\n40 19 34 219 155 10 13 11 80 118", "output": "285\n"}, {"input": "5 1\n40 19 34 219 208 10 13 11 20 118", "output": "232\n"}, {"input": "6 1\n40 10 34 219 155 10 20 11 80 118", "output": "448\n"}, {"input": "5 1\n40 18 34 219 155 1...
code_stdio
[ { "content": "Write a function called calculate that takes 3 values. The first and third values are numbers. The second value is a character. If the character is \"+\" , \"-\", \"*\", or \"/\", the function will return the result of the corresponding mathematical function on the two numbers. If the string is no...
[{"input": "3.2\n\"+\"\n8", "output": "[11.2]", "fn_name": "calculate"}, {"input": "3.2\n\"-\"\n8", "output": "[-4.8]", "fn_name": "calculate"}, {"input": "3.2\n\"*\"\n8", "output": "[25.6]", "fn_name": "calculate"}, {"input": "3.2\n\"/\"\n8", "output": "[0.4]", "fn_name": "calculate"}, {"input": "-3\n\"/\"\n0", "outpu...
code_functional
[ { "content": "Every evening Vitalya sets n alarm clocks to wake up tomorrow. Every alarm clock rings during exactly one minute and is characterized by one integer a_{i} — number of minute after midnight in which it rings. Every alarm clock begins ringing at the beginning of the minute and rings during whole min...
[{"input": "100 40 20\n148 120 37 65 188 182 199 131 97 174 157 113 62 63 193 8 72 152 138 5 90 48 133 83 197 118 123 2 181 151 53 115 78 177 144 33 196 19 85 104 77 34 173 198 136 44 3 22 86 200 23 129 68 176 29 58 121 56 79 15 159 183 171 60 141 54 158 106 30 17 116 105 190 59 36 46 169 142 165 112 155 126 101 125 38...
code_stdio
[ { "content": "Ujan decided to make a new wooden roof for the house. He has $n$ rectangular planks numbered from $1$ to $n$. The $i$-th plank has size $a_i \\times 1$ (that is, the width is $1$ and the height is $a_i$).\n\nNow, Ujan wants to make a square roof. He will first choose some of the planks and place t...
[{"input": "10\n1\n1\n2\n2 1\n3\n3 1 2\n3\n2 2 2\n4\n4 1 4 2\n5\n5 4 3 4 1\n5\n1 2 3 4 5\n6\n3 2 1 6 2 2\n10\n4 5 2 9 6 10 3 7 1 8\n10\n1 3 2 2 2 9 10 10 9 10\n", "output": "1\n1\n2\n2\n2\n3\n3\n2\n5\n5\n"}, {"input": "10\n1\n1\n2\n2 1\n3\n3 1 2\n3\n2 2 2\n4\n4 1 4 1\n5\n5 4 3 2 1\n5\n1 2 3 4 5\n6\n3 2 1 6 2 2\n10\n4 5...
code_stdio
[ { "content": "\"Duel!\"\n\nBetting on the lovely princess Claris, the duel between Tokitsukaze and Quailty has started.\n\nThere are $n$ cards in a row. Each card has two sides, one of which has color. At first, some of these cards are with color sides facing up and others are with color sides facing down. Then...
[{"input": "30 27\n000000000010110000101111111111\n", "output": "tokitsukaze\n"}, {"input": "30 27\n100000000010110000101111111111\n", "output": "tokitsukaze\n"}, {"input": "30 16\n100000000010110000101111111111\n", "output": "once again\n"}, {"input": "30 7\n000000000010110000101111111111\n", "output": "once again\n"}...
code_stdio
[ { "content": "This time Baby Ehab will only cut and not stick. He starts with a piece of paper with an array a of length n written on it, and then he does the following:\n\n * he picks a range (l, r) and cuts the subsegment a_l, a_{l + 1}, …, a_r out, removing the rest of the array. \n * he then cuts this ran...
[{"input": "6 3\n2 3 10 12 5 14\n1 6\n2 4\n3 5\n", "output": "4\n2\n2\n"}, {"input": "6 3\n1 3 10 6 10 14\n1 6\n2 4\n3 5\n", "output": "4\n2\n3\n"}, {"input": "6 3\n1 5 10 6 10 14\n1 6\n2 4\n3 5\n", "output": "5\n3\n3\n"}, {"input": "6 3\n1 5 10 6 10 14\n1 6\n3 4\n3 5\n", "output": "5\n2\n3\n"}, {"input": "6 3\n1 5 10 ...
code_stdio
[ { "content": "Your friend has n cards.\n\nYou know that each card has a lowercase English letter on one side and a digit on the other.\n\nCurrently, your friend has laid out the cards on a table so only one side of each card is visible.\n\nYou would like to know if the following statement is true for cards that...
[{"input": "01234567890123456789012345678901234567890123456789\n", "output": "25\n"}, {"input": "qwertyuioplkjhgfdsazxcvbnmqwertyuioplkjhgfdsazxcvb\n", "output": "10\n"}, {"input": "kaq7jyialrfp4ilkni90eq8v3amcbygon7py0hb8z26fbl8ss1\n", "output": "13\n"}, {"input": "l3rw91a4m25l8iytxyeuixsegzcbm4h41ornf3pixkrmwznrzc\n"...
code_stdio
[ { "content": "You received a whatsup message from an unknown number. Could it be from that girl/boy with a foreign accent you met yesterday evening?\n\nWrite a simple regex to check if the string contains the word hallo in different languages.\n\nThese are the languages of the possible people you met the night ...
[{"input": "\"Hallo, wie geht's dir?\"", "output": "[true]", "fn_name": "validate_hello"}, {"input": "\"hombre! Hola!\"", "output": "[true]", "fn_name": "validate_hello"}, {"input": "\"hallo, salut\"", "output": "[true]", "fn_name": "validate_hello"}, {"input": "\"ciao bella!\"", "output": "[true]", "fn_name": "validat...
code_functional
[ { "content": "As we all know, Chef is cooking string for long days, his new discovery on string is the longest common pattern length. The longest common pattern length between two strings is the maximum number of characters that both strings have in common. Characters are case sensitive, that is, lower case and...
[{"input": "4\nabcd\nxyz\nabcd\nbcda\nacba\nacaa\nCodechef\nelfedcc", "output": "0\n4\n3\n5\n"}, {"input": "4\nbdca\nxyz\nabcd\nbcda\nabca\nacaa\nCodechff\nelfedcc", "output": "0\n4\n3\n4\n"}, {"input": "4\nbdca\nyyz\nabdd\nbcda\nabca\nacaa\nCodechff\nelfedcc", "output": "0\n3\n3\n4\n"}, {"input": "4\nabcd\nxyz\nabcd\n...
code_stdio
[ { "content": "A few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and good friends.\n\nThere are n schools numerated from 1 to n. One can travel between each pair of them, to do so, he needs to buy a ticket. The ticker be...
[{"input": "120494\n", "output": "60246\n"}, {"input": "116591\n", "output": "58295\n"}, {"input": "110052\n", "output": "55025\n"}, {"input": "101000\n", "output": "50499\n"}, {"input": "150380\n", "output": "75189\n"}, {"input": "159531\n", "output": "79765\n"}, {"input": "175733\n", "output": "87866\n"}, {"input": "...
code_stdio
[ { "content": "This is a harder version of the problem. In this version $n \\le 500\\,000$\n\nThe outskirts of the capital are being actively built up in Berland. The company \"Kernel Panic\" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the hig...
[{"input": "100\n82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 13 49 41 36 41 79 16 87 87 69 3 76 80 60 100 49 70 59 72 8 38 71 45 97 71 14 76 54 81 4 59 46 39 29 92 3 49 22 53 99 59 52 74 31 92 43 42 23 44 9 82 47 7 40 12 9 3 55 37 85 46 22 84 52 98 41 21 77 63 17 62 91\n", "output...
code_stdio
[ { "content": "This problem differs from one which was on the online contest.\n\nThe sequence a1, a2, ..., an is called increasing, if ai < ai + 1 for i < n.\n\nThe sequence s1, s2, ..., sk is called the subsequence of the sequence a1, a2, ..., an, if there exist such a set of indexes 1 ≤ i1 < i2 < ... < ik ≤ n ...
[{"input": "83\n95 164 123 111 177 71 38 225 103 59 210 209 117 139 115 140 66 21 39 84 14 227 0 43 90 233 96 98 232 237 108 139 55 220 14 225 134 39 68 167 193 125 86 216 87 14 94 75 255 24 165 98 177 191 239 123 98 90 29 52 155 231 187 90 180 1 31 237 167 145 242 115 61 190 47 41 61 206 191 248 126 196 26\n49\n234 13...
code_stdio
[ { "content": "Eleven wants to choose a new name for herself. As a bunch of geeks, her friends suggested an algorithm to choose a name for her. Eleven wants her name to have exactly n characters. [Image] \n\nHer friend suggested that her name should only consist of uppercase and lowercase letters 'O'. More prec...
[{"input": "1000\n", "output": "OOOoOooOooooOoooooooOooooooooooooOooooooooooooooooooooOoooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooo...
code_stdio
[ { "content": "You found a mysterious function f. The function takes two strings s1 and s2. These strings must consist only of lowercase English letters, and must be the same length.\n\nThe output of the function f is another string of the same length. The i-th character of the output is equal to the minimum of ...
[{"input": "tgharsjyihroiiahwgbjezlxvlterxivdhtzjcqegzmtigqmrehvhiyjeywegxaseoyoacouijudbiruoghgxvxadwzgdxtnxlds\ntghaksjsdhkoiiahegbjexlfrctercipdhmvjbgegxdtggqdpbhvhiseehhegnaseoooacnsijubbirjnghgsvpadhaadrtimfdp\n", "output": "tghaksjsdhkoiiahegbjexlfrctercipdhmvjbgegxdtggqdpbhvhiseehhegnaseoooacnsijubbirjnghgsvpadh...
code_stdio
[ { "content": "Santa has $n$ candies and he wants to gift them to $k$ kids. He wants to divide as many candies as possible between all $k$ kids. Santa can't divide one candy into parts but he is allowed to not use some candies at all.\n\nSuppose the kid who recieves the minimum number of candies has $a$ candies ...
[{"input": "5\n5 3\n19 4\n12 7\n10 2\n100001 44619\n", "output": "4\n18\n10\n10\n100001\n"}, {"input": "5\n5 3\n12 4\n12 7\n10 2\n100001 44619\n", "output": "4\n12\n10\n10\n100001\n"}, {"input": "5\n10 2\n1 11\n5 11\n11 1\n110001 90586\n", "output": "10\n1\n5\n11\n110001\n"}, {"input": "5\n10 2\n2 11\n5 11\n11 1\n11000...
code_stdio
[ { "content": "Takahashi and Aoki will play a game with a number line and some segments. Takahashi is standing on the number line and he is initially at coordinate 0. Aoki has N segments. The i-th segment is [L_i,R_i], that is, a segment consisting of points with coordinates between L_i and R_i (inclusive).\n\nT...
[{"input": "5\n-3 0\n-1 -1\n7 6\n18 11\n-2 -1", "output": "54\n"}, {"input": "5\n-3 0\n-1 -1\n7 8\n3 11\n-1 -1", "output": "24\n"}, {"input": "5\n-3 1\n-2 0\n7 8\n16 11\n-1 -1", "output": "48\n"}, {"input": "5\n-3 0\n-1 -1\n7 8\n9 11\n-1 -1", "output": "36\n"}, {"input": "5\n-3 0\n-1 -1\n7 6\n3 11\n-1 -1", "output": "2...
code_stdio
[ { "content": "This is the hard version of the problem. The difference between the versions is that the hard version does require you to output the numbers of the rods to be removed. You can make hacks only if all versions of the problem are solved.\n\nStitch likes experimenting with different machines with his ...
[{"input": "3\n14 1\n+--++---++-++-\n1 14\n14 3\n+--++---+++---\n1 14\n6 12\n1 10\n4 10\n+-+-\n1 2\n1 2\n1 2\n1 4\n2 2\n2 3\n2 4\n3 3\n3 4\n4 4\n", "output": "2\n1 2\n2\n1 9\n1\n9\n2\n1 2\n2\n1 2\n2\n1 2\n2\n1 2\n2\n1 3\n1\n2\n2\n2 3\n1\n3\n1\n3\n2\n3 4\n1\n4\n"}, {"input": "3\n14 1\n+--++---++-++-\n1 14\n14 3\n+--++--...
code_stdio
[ { "content": "Taro and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively puts out a card. The name of the animal consisting of alphabetical letters is written on each card, and the bigger one in lexicographical order becomes the winner of ...
[{"input": "3\nact dog\nfish fish\nlion tiger", "output": "1 7\n"}, {"input": "3\nact god\nfish fith\nlion tiger", "output": "0 9\n"}, {"input": "3\nuea goe\ndirh giuh\nnojk tiger", "output": "3 6\n"}, {"input": "3\nvea hpg\njrie giug\nnpjk rhget", "output": "6 3\n"}, {"input": "3\nv`f ggn\njrhd jgug\njnok ehrug", "out...
code_stdio
[ { "content": "A Ministry for Defense sent a general to inspect the Super Secret Military Squad under the command of the Colonel SuperDuper. Having learned the news, the colonel ordered to all n squad soldiers to line up on the parade ground.\n\nBy the military charter the soldiers should stand in the order of n...
[{"input": "100\n66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 55 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 153 95 95 95\n"...
code_stdio
[ { "content": "At first, let's define function $f(x)$ as follows: $$ \\begin{matrix} f(x) & = & \\left\\{ \\begin{matrix} \\frac{x}{2} & \\mbox{if } x \\text{ is even} \\\\ x - 1 & \\mbox{otherwise } \\end{matrix} \\right. \\end{matrix} $$\n\nWe can see that if we choose some value $v$ and will apply function $f...
[{"input": "1000000000000000000 1\n", "output": "1000000000000000000\n"}, {"input": "1000000000000000000 100\n", "output": "31249999999999998\n"}, {"input": "1000000000000000000 10000\n", "output": "244140624999998\n"}, {"input": "1000000000000000000 100000000\n", "output": "29802322386\n"}, {"input": "1000000000000000...
code_stdio
[ { "content": "Arthur has bought a beautiful big table into his new flat. When he came home, Arthur noticed that the new table is unstable.\n\nIn total the table Arthur bought has n legs, the length of the i-th leg is l_{i}.\n\nArthur decided to make the table stable and remove some legs. For each of them Arthur...
[{"input": "30\n20 27 26 17 29 9 25 13 6 21 15 1 14 22 26 2 15 18 20 23 27 9 15 29 11 2 19 23 14 12\n133 199 22 151 9 134 196 119 197 189 117 84 156 6 61 195 98 197 145 75 142 85 187 24 159 3 60 138 156 161\n", "output": "2804\n"}, {"input": "30\n20 27 26 17 29 9 25 13 6 21 15 1 14 22 26 2 15 18 20 23 27 9 15 29 11 2 1...
code_stdio
[ { "content": "One player came to a casino and found a slot machine where everything depends only on how he plays. The rules follow.\n\nA positive integer a is initially on the screen. The player can put a coin into the machine and then add 1 to or subtract 1 from any two adjacent digits. All digits must remain ...
[{"input": "66\n909090909090909090909090909090909909090909090909090909090909090909\n190909090909090909090909090909090090909090909090909090909090909091\n", "output": "9736\n33 -1\n32 1\n31 -1\n30 1\n29 -1\n28 1\n27 -1\n26 1\n25 -1\n24 1\n23 -1\n22 1\n21 -1\n20 1\n19 -1\n18 1\n17 -1\n16 1\n15 -1\n14 1\n13 -1\n12 1\n11 -1...
code_stdio
[ { "content": "-----Input-----\n\nThe input consists of a single string of uppercase letters A-Z. The length of the string is between 1 and 10 characters, inclusive.\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\nNEAT\n\nOutput\nYES\n\nInput\nWORD\n\nOutput\nNO\n\nInput\nCODER...
[{"input": "ALKALINITY\n", "output": "YES\n"}, {"input": "ALLALINITY\n", "output": "YES\n"}, {"input": "YTINILALLA\n", "output": "YES\n"}, {"input": "UNSCRAMBLE\n", "output": "NO\n"}, {"input": "ALKALINITY\n", "output": "YES"}, {"input": "TNSCRAMBLE\n", "output": "NO\n"}, {"input": "TNSARCMBLE\n", "output": "NO\n"}, {"...
code_stdio
[ { "content": "There is one apple tree in Arkady's garden. It can be represented as a set of junctions connected with branches so that there is only one way to reach any junctions from any other one using branches. The junctions are enumerated from $1$ to $n$, the junction $1$ is called the root.\n\nA subtree of...
[{"input": "10\n1 1 2 4 2 4 1 8 8\n", "output": "1 1 1 1 1 1 2 2 3 6 \n"}, {"input": "10\n1 2 2 3 3 4 4 5 5\n", "output": "1 1 1 1 1 2 2 3 5 5 \n"}, {"input": "10\n1 1 1 1 1 1 1 1 1\n", "output": "1 1 1 1 1 1 1 1 1 9 \n"}, {"input": "10\n1 2 2 3 3 4 4 5 5\n", "output": "1 1 1 1 1 2 2 3 5 5 \n"}, {"input": "10\n1 1 1 1 ...
code_stdio
[ { "content": "When provided with a String, capitalize all vowels\n\nFor example:\n\nInput : \"Hello World!\"\n\nOutput : \"HEllO WOrld!\"\n\nNote: Y is not a vowel in this kata.\n\nWrite Python code to solve this problem. Define a top-level function named `swap` that takes the input arguments described above an...
[{"input": "\"HelloWorld!\"", "output": "[\"HEllOWOrld!\"]", "fn_name": "swap"}, {"input": "\"abracadabra\"", "output": "[\"AbrAcAdAbrA\"]", "fn_name": "swap"}, {"input": "\"Codewars\"", "output": "[\"COdEwArs\"]", "fn_name": "swap"}, {"input": "\"Sunday\"", "output": "[\"SUndAy\"]", "fn_name": "swap"}, {"input": "\"Mo...
code_functional
[ { "content": "Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (https://en.wikipedia.org/wiki/Seven-segment_display). [Image] \n\nMax starts to type all the values from a to b. After typing each number Max resets ...
[{"input": "222145 353252\n", "output": "3860750\n"}, {"input": "222145 353252\n", "output": "3860750\n"}, {"input": "188883 353252\n", "output": "4803878\n"}, {"input": "188883 240204\n", "output": "1479377\n"}, {"input": "443 390308\n", "output": "10631342\n"}, {"input": "426 390308\n", "output": "10631576\n"}, {"inp...
code_stdio
[ { "content": "Gray code is a form of binary encoding where transitions between consecutive numbers differ by only one bit. This is a useful encoding for reducing hardware data hazards with values that change rapidly and/or connect to slower hardware as inputs. It is also useful for generating inputs for Karnaug...
[{"input": "[1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0]", "output": "[[1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1...
code_functional
[ { "content": "You've got another problem dealing with arrays. Let's consider an arbitrary sequence containing n (not necessarily different) integers a1, a2, ..., an. We are interested in all possible pairs of numbers (ai, aj), (1 ≤ i, j ≤ n). In other words, let's consider all n2 pairs of numbers, picked from t...
[{"input": "100 4755\n5 4 3 5 1 2 5 1 1 3 5 4 4 1 1 1 1 5 4 4 5 1 5 5 1 2 1 3 1 5 1 3 3 3 2 2 2 1 1 5 1 3 4 1 1 3 2 5 2 2 5 5 4 4 1 3 4 3 3 4 5 3 3 3 1 2 1 4 2 4 4 1 5 1 3 5 5 5 5 3 4 4 3 1 2 5 2 3 5 4 2 4 5 3 2 4 2 4 3 1\n", "output": "3 3\n"}, {"input": "100 9043\n4 1 4 2 1 4 2 2 1 1 4 2 4 2 4 1 4 2 2 1 2 2 2 2 1 1 2...
code_stdio
[ { "content": "Takahashi wants to gain muscle, and decides to work out at AtCoder Gym.\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.\nThese buttons are numbered 1 through N.\nWhen Button i is lighten up and you press it, the light is turned off, and then Button a_i...
[{"input": "5\n3\n-1\n4\n3\n4", "output": "-1\n"}, {"input": "5\n3\n3\n4\n2\n4\n", "output": "3\n"}, {"input": "5\n1\n3\n5\n2\n4", "output": "-1\n"}, {"input": "5\n1\n3\n5\n4\n4", "output": "-1\n"}, {"input": "5\n1\n3\n5\n2\n5", "output": "-1\n"}, {"input": "5\n3\n-1\n4\n2\n4", "output": "3\n"}, {"input": "5\n1\n3\n5\n...
code_stdio
[ { "content": "There is a pond with a rectangular shape.\nThe pond is divided into a grid with H rows and W columns of squares.\nWe will denote the square at the i-th row from the top and j-th column from the left by (i,\\ j).\nSome of the squares in the pond contains a lotus leaf floating on the water.\nOn one ...
[{"input": "100 100\noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo\noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo\nooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo...
code_stdio
[ { "content": "Hamed has recently found a string t and suddenly became quite fond of it. He spent several days trying to find all occurrences of t in other strings he had. Finally he became tired and started thinking about the following problem. Given a string s how many ways are there to extract k ≥ 1 non-overl...
[{"input": "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\nvvvvvvvv\n", "output": "2728075\n"}, {"input": "vnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssn\nnssnssns\n", "output": "943392\n"}, {"input": "kpjmawawawawawawawawawawawawawawawawawawawawawawaw\nwawawawa\n", "output": "834052\n"}, {"input": "vvvvvvvvvv...
code_stdio
[ { "content": "Polycarpus plays with red and blue marbles. He put n marbles from the left to the right in a row. As it turned out, the marbles form a zebroid.\n\nA non-empty sequence of red and blue marbles is a zebroid, if the colors of the marbles in this sequence alternate. For example, sequences (red; blue; ...
[{"input": "1000000\n", "output": "986892583"}, {"input": "491526\n", "output": "913830480\n"}, {"input": "470705\n", "output": "732073783\n"}, {"input": "201682\n", "output": "291520502\n"}, {"input": "117284\n", "output": "184689149\n"}, {"input": "728546\n", "output": "731715891\n"}, {"input": "721975\n", "output": ...
code_stdio
[ { "content": "Nuske has a grid with N rows and M columns of squares. The rows are numbered 1 through N from top to bottom, and the columns are numbered 1 through M from left to right. Each square in the grid is painted in either blue or white. If S_{i,j} is 1, the square at the i-th row and j-th column is blue;...
[{"input": "5 5 6\n11010\n01110\n10111\n11111\n01010\n1 1 5 5\n1 2 4 5\n2 3 3 5\n3 3 3 2\n3 1 3 5\n1 1 3 4", "output": "-2\n-2\n0\n0\n2\n1\n"}, {"input": "5 5 6\n11010\n01110\n10111\n11111\n01010\n1 1 5 5\n1 2 4 5\n3 3 3 5\n3 3 3 2\n3 1 3 5\n1 1 3 4", "output": "-2\n-2\n1\n0\n2\n1\n"}, {"input": "5 5 6\n11010\n01110\n1...
code_stdio
[ { "content": "You are given a grid with n rows and m columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number k > 0 written on it, then exactly k of its neighboring cells have a number greater than 0 written on ...
[{"input": "5\n3 4\n0 0 0 0\n0 1 0 0\n-1 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n-1 0 0\n0 0 0\n4 4\n0 0 0 -1\n0 2 0 2\n0 1 -1 0\n0 0 0 0\n", "output": "YES\n2 3 3 2\n3 4 4 3\n2 3 3 2\nNO\nYES\n2 2\n2 2\nYES\n2 3 2\n2 3 2\nYES\n2 3 3 2\n3 4 4 3\n3 4 4 3\n2 3 3 2\n"}, {"input": "5\n3 4\n0 0 0 0\n0 1 0 0\n-1 0 0 0\n2 2...
code_stdio
[ { "content": "For a positive integer X, let f(X) be the number of positive divisors of X.\nGiven a positive integer N, find \\sum_{K=1}^N K\\times f(K).\n\n-----Constraints-----\n - 1 \\leq N \\leq 10^7\n\n-----Input-----\nInput is given from Standard Input in the following format:\nN\n\n-----Output-----\nPrint...
[{"input": "10000000\n", "output": "838627288460105\n"}, {"input": "11001000", "output": "1020696029789074\n"}, {"input": "11000000", "output": "1020504841032058\n"}, {"input": "11001001", "output": "1020696117797082\n"}, {"input": "11001101", "output": "1020713851493884\n"}, {"input": "11001110", "output": "1020715369...
code_stdio
[ { "content": "Vasya wrote down two strings s of length n and t of length m consisting of small English letters 'a' and 'b'. What is more, he knows that string t has a form \"abab...\", namely there are letters 'a' on odd positions and letters 'b' on even positions.\n\nSuddenly in the morning, Vasya found that s...
[{"input": "340\nbaa?b?abab??ab??aaabaa???bbbb??abaaaba?a?b?bb?ab?bbaa??aaaa???aaa?b???ba?a??b?bb?bbbabb?bb?a?a?bbbabbba?b?ababbb?b?a??bbb??bb?ababb?abbbbba??aabbaab?aaa??a???bbaa?bb?bb?babaa?bb?a???b?abbb???bb?a?a??b?b?abbba?b??a?bab??baa?aabaabb?abbbab?aa???bbaab?bbab?ba?aab?b?baabb???aaa??bb?ab?aa?aaa????babbbb???ba...
code_stdio
[ { "content": "For a string S, let f(S) be the lexicographically smallest cyclic shift of S. For example, if S = `babca`, f(S) = `ababc` because this is the smallest among all cyclic shifts (`babca`, `abcab`, `bcaba`, `cabab`, `ababc`).\n\nYou are given three integers X, Y, and Z. You want to construct a string ...
[{"input": "7 32 3", "output": "abbbbbbbbabbbbbbbbacabbbbbbbbacabbbbbbbbac\n"}, {"input": "7 23 3", "output": "abbbbbacacacabbbbbbabbbbbbabbbbbb\n"}, {"input": "17 7 3", "output": "aabaacaacaacaababaababaabab\n"}, {"input": "13 7 3", "output": "aacababaacababaacababab\n"}, {"input": "7 12 3", "output": "abbbabbbacabbba...
code_stdio
[ { "content": "Three numbers A, B and C are the inputs. Write a program to find second largest among them.\n\n-----Input-----\n\nThe first line contains an integer T, the total number of testcases. Then T lines follow, each line contains three integers A, B and C. \n\n-----Output-----\nFor each test case, displa...
[{"input": "3 \n120 14 400\n10213 312 10\n10 3 450", "output": "120\n312\n10\n"}, {"input": "3 \n117 14 384\n10213 312 10\n10 3 450", "output": "117\n312\n10\n"}, {"input": "3 \n178 14 384\n10213 312 10\n10 3 450", "output": "178\n312\n10\n"}, {"input": "3 \n303 14 384\n10213 312 10\n10 0 450", "output": "303\n312\n10\...
code_stdio
[ { "content": "A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the larges...
[{"input": "100 99 98 97\n", "output": "196\n195\n98\n"}, {"input": "100 50 19 10\n", "output": "100\n50\n19\n"}, {"input": "100 50 19 25\n", "output": "100\n51\n25\n"}, {"input": "100 50 19 30\n", "output": "100\n61\n30\n"}, {"input": "99 98 50 97\n", "output": "196\n195\n97\n"}, {"input": "99 50 25 49\n", "output": "...
code_stdio
[ { "content": "Efim just received his grade for the last test. He studies in a special school and his grade can be equal to any positive decimal fraction. First he got disappointed, as he expected a way more pleasant result. Then, he developed a tricky plan. Each second, he can ask his teacher to round the grade...
[{"input": "320 142\n2704701300865535.432223312233434114130011113220102420131323010344144201124303144444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444447444444444444444444444444444444615444444482101673308979557675074444444444444446867245414595534444693160...
code_stdio
[ { "content": "Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need...
[{"input": "119 12 653\n877 938 872 962 590 500 422 249 141 163 609 452 594 768 316 530 838 945 658 636 997 938 941 272 102 8 713 862 572 809 301 462 282 478 12 544 157 204 367 789 136 251 754 43 349 355 560 325 463 659 666 644 992 603 799 597 364 234 903 377 896 92 971 308 617 712 480 772 170 68 318 947 741 568 63 483...
code_stdio
[ { "content": "You are given an integer $N$ and a string consisting of '+' and digits. You are asked to transform the string into a valid formula whose calculation result is smaller than or equal to $N$ by modifying some characters. Here, you replace one character with another character any number of times, and ...
[{"input": "2000\n0234++7890", "output": "3\n"}, {"input": "2000\n0987++4320", "output": "3\n"}, {"input": "2000\n0947++8320", "output": "3\n"}, {"input": "2000\n0947++3820", "output": "3\n"}, {"input": "2000\n0947++3028", "output": "3\n"}, {"input": "2000\n0947++3128", "output": "3\n"}, {"input": "2000\n09+74+3128", "...
code_stdio
[ { "content": "Princess'Marriage\n\nMarriage of a princess\n\nEnglish text is not available in this practice contest.\n\nA brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a r...
[{"input": "2 8\n7 6\n4 10\n3 2\n5 10\n3 10\n5 10\n0 0", "output": "18\n110\n"}, {"input": "2 8\n7 6\n4 10\n3 3\n5 10\n3 10\n5 10\n0 0", "output": "18\n100\n"}, {"input": "2 8\n5 6\n5 5\n3 3\n4 10\n13 10\n5 10\n0 0", "output": "10\n190\n"}, {"input": "2 8\n5 6\n5 5\n3 3\n3 10\n13 10\n5 10\n0 0", "output": "10\n180\n"},...
code_stdio
[ { "content": "Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken.\n\nCFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one — 7 chunks. Ivan wants to eat exactly x chunks. Now he wonders wheth...
[{"input": "100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100...
code_stdio
[ { "content": "Alice has learnt factorization recently. Bob doesn't think she has learnt it properly and hence he has decided to quiz her. Bob gives Alice a very large number and asks her to find out the number of factors of that number. To make it a little easier for her, he represents the number as a product o...
[{"input": "3\n3\n3 7 13\n3\n2 4 13\n2\n40 10", "output": "8\n8\n15\n"}, {"input": "3\n3\n3 7 13\n3\n2 4 13\n2\n40 12", "output": "8\n8\n24\n"}, {"input": "3\n3\n3 9 6\n3\n3 4 13\n2\n28 5", "output": "10\n12\n12\n"}, {"input": "3\n3\n6 5 14\n3\n2 12 6\n2\n8 6", "output": "24\n15\n10\n"}, {"input": "3\n3\n3 4 14\n3\n2 5...
code_stdio
[ { "content": "You are a *khm*mad*khm* scientist and you decided to play with electron distribution among atom's shells.\nYou know that basic idea of electron distribution is that electrons should fill a shell untill it's holding the maximum number of electrons.\n\n\n ---\nRules: \n - Maximum number of electr...
[{"input": "61", "output": "[[2, 8, 18, 32, 1]]", "fn_name": "atomic_number"}, {"input": "47", "output": "[[2, 8, 18, 19]]", "fn_name": "atomic_number"}, {"input": "50", "output": "[[2, 8, 18, 22]]", "fn_name": "atomic_number"}, {"input": "52", "output": "[[2, 8, 18, 24]]", "fn_name": "atomic_number"}, {"input": "60", ...
code_functional
[ { "content": "Stylish is a programming language whose syntax comprises names, that are sequences of Latin alphabet letters, three types of grouping symbols, periods ('.'), and newlines. Grouping symbols, namely round brackets ('(' and ')'), curly brackets ('{' and '}'), and square brackets ('[' and ']'), must m...
[{"input": "5 4\n(Folmow.my.style\n.........starting.from.round.brackets)\n{then.curly.brackets\n.....[.and.finally\n.......square.brackets.]}\n(Thank.you\n{for.showing.me\n[all\nthe.secrets]})\n4 2\n(This.time.I.will.show.you\n.........(how.to.use.round.brackets)\n.........[but.not.about.square.bsackets]\n.........{no...
code_stdio
[ { "content": "During the hypnosis session, Nicholas suddenly remembered a positive integer $n$, which doesn't contain zeros in decimal notation.\n\nSoon, when he returned home, he got curious: what is the maximum number of digits that can be removed from the number so that the number becomes not prime, that is,...
[{"input": "7\n3\n237\n5\n44444\n3\n337\n2\n35\n3\n773\n1\n4\n30\n626221626221626221626221626221\n", "output": "2\n27\n1\n4\n2\n33\n2\n35\n2\n77\n1\n4\n1\n6\n"}, {"input": "7\n3\n237\n5\n44444\n3\n337\n2\n35\n3\n773\n1\n8\n30\n626221626221626221626221626221\n", "output": "2\n27\n1\n4\n2\n33\n2\n35\n2\n77\n1\n8\n1\n6\n"...
code_stdio
[ { "content": "IT City company developing computer games invented a new way to reward its employees. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each transaction. Every time when the next number of sales is divisible by all numbers from 2 ...
[{"input": "2558402827158016680\n", "output": "1015239217126197\n"}, {"input": "1000000000000000000\n", "output": "396825396825396\n"}, {"input": "1209365011581446835\n", "output": "479906750627558\n"}, {"input": "1155798879255295086\n", "output": "458650348910831\n"}, {"input": "1000000000000001000\n", "output": "3968...
code_stdio
[ { "content": "Let {\\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order.\nFrom n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\\rm comb}(a_i,a_j) is maximized.\nIf there are multiple pairs that maximize the value, any of them is ac...
[{"input": "5\n20 13 1 4 20", "output": "20 13\n"}, {"input": "5\n36 13 1 8 10", "output": "36 13\n"}, {"input": "5\n36 13 1 8 17", "output": "36 17\n"}, {"input": "5\n1 10 -1 2 16", "output": "16 10\n"}, {"input": "5\n2 11 1 12 15", "output": "15 11\n"}, {"input": "5\n1 10 -1 2 24", "output": "24 10\n"}, {"input": "5\...
code_stdio
[ { "content": "Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the string so that the resulting one is a palindrome. \n\nA palindrome is a string that reads the same backward as forward, for example strings \"z\", \"aaa\", \"aba\", \"abccba\" are pa...
[{"input": "scfwrjevejrwfcs\n", "output": "YES\n"}, {"input": "thdaonpepdoadht\n", "output": "YES\n"}, {"input": "scfwrievejrwfcs\n", "output": "YES\n"}, {"input": "thdaodpepnoadht\n", "output": "YES\n"}, {"input": "jsfzcbnhsccuqsj\n", "output": "NO\n"}, {"input": "mhifbmmmmbmihm\n", "output": "YES\n"}, {"input": "cojh...
code_stdio
[ { "content": "When you play the game of thrones, you win, or you die. There is no middle ground.\n\nCersei Lannister, A Game of Thrones by George R. R. Martin\n\nThere are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ \"friendships\". A friendship between nobles $a$ and ...
[{"input": "20 53\n1 2\n1 4\n1 5\n1 6\n1 7\n1 8\n1 20\n2 3\n2 6\n2 16\n2 17\n3 6\n3 18\n3 20\n4 6\n4 7\n4 8\n4 9\n4 14\n4 18\n5 11\n5 13\n5 17\n5 18\n5 19\n6 8\n6 13\n7 8\n7 10\n7 15\n7 17\n7 18\n8 15\n8 16\n9 10\n9 15\n10 11\n10 17\n10 20\n11 15\n11 16\n12 14\n12 15\n12 16\n12 19\n14 16\n14 19\n16 17\n16 19\n16 20\n17...
code_stdio
[ { "content": "You are given a sequence $a_1, a_2, \\dots, a_n$ consisting of $n$ integers.\n\nYou can choose any non-negative integer $D$ (i.e. $D \\ge 0$), and for each $a_i$ you can:\n\n add $D$ (only once), i. e. perform $a_i := a_i + D$, or subtract $D$ (only once), i. e. perform $a_i := a_i - D$, or lea...
[{"input": "100\n49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49...
code_stdio
[ { "content": "Polycarp takes part in a quadcopter competition. According to the rules a flying robot should:\n\n start the race from some point of a field, go around the flag, close cycle returning back to the starting point. \n\nPolycarp knows the coordinates of the starting point (x_1, y_1) and the coordin...
[{"input": "-100 -100\n-100 100\n", "output": "406\n"}, {"input": "-100 -100\n100 -100\n", "output": "406\n"}, {"input": "100 -100\n-100 -100\n", "output": "406\n"}, {"input": "-100 100\n-100 -100\n", "output": "406\n"}, {"input": "-100 100\n-100 -192\n", "output": "590\n"}, {"input": "101 -100\n-100 -100\n", "output":...
code_stdio
[ { "content": "Given a string ``string`` that contains only letters, you have to find out the number of **unique** strings (including ``string`` itself) that can be produced by re-arranging the letters of the ``string``. Strings are case **insensitive**.\n\nHINT: Generating all the unique strings and calling le...
[{"input": "\"ABcDEFgHIJbaslidbailsbdilasbdkanmsdklhkbHSJKHVDASHVVYQVWKDVDWQUV\"", "output": "[176478346352319876826993574633158714419916931040323433922560000000]", "fn_name": "uniq_count"}, {"input": "\"ABcDEFgHIJbaslidbailsbdilasbdkanmsdklhkbHSJKHVDASH\"", "output": "[34111429518116758488933545882757275627520000000]"...
code_functional
[ { "content": "Woken up by the alarm clock Igor the financial analyst hurried up to the work. He ate his breakfast and sat in his car. Sadly, when he opened his GPS navigator, he found that some of the roads in Bankopolis, the city where he lives, are closed due to road works. Moreover, Igor has some problems wi...
[{"input": "7 7\n.S.****\n...*.*.\n.****..\n.*.**.*\n..T*...\n***..*.\n**+****\n", "output": "YES\n"}, {"input": "7 7\n.S.****\n...*.*.\n.****..\n.*.**.*\n..T*...\n***..*.\n****+**\n", "output": "YES\n"}, {"input": "7 7\n.S.****\n...*.*.\n.****..\n.****..\n..T*...\n***..*.\n**+****\n", "output": "YES\n"}, {"input": "7 ...
code_stdio