messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "Santa puts all the presents into the huge sack. In order to let his reindeers rest a bit, he only takes as many reindeers with him as he is required to do. The others may take a nap.\n\nTwo reindeers are always required for the sleigh and Santa himself. Additionally he needs 1 reindeer per 30 pres... | [{"input": "120", "output": "[6]", "fn_name": "reindeer"}, {"input": "121", "output": "[7]", "fn_name": "reindeer"}, {"input": "150", "output": "[7]", "fn_name": "reindeer"}, {"input": "151", "output": "[8]", "fn_name": "reindeer"}, {"input": "180", "output": "[8]", "fn_name": "reindeer"}, {"input": "30", "output": "[3... | code_functional |
[
{
"content": "We have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).\n\nAmong them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?\n\nWe remind you that the distance between the origin and the point (p, ... | [{"input": "20 101000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n191679 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-178807 114185\n98784 -6820\n94111 -86268\n-30401 61477\n-55056 7872\n10994 -163796\n138819 -185986\n-69848 -96669", "... | code_stdio |
[
{
"content": "You are given a set of n elements indexed from 1 to n. The weight of i-th element is w_{i}. The weight of some subset of a given set is denoted as $W(S) =|S|\\cdot \\sum_{i \\in S} w_{i}$. The weight of some partition R of a given set into k subsets is $W(R) = \\sum_{S \\in R} W(S)$ (recall that a... | [{"input": "6 2\n2578 6301 8624 6020 8513 9486\n", "output": "4401332\n"}, {"input": "6 3\n4759 5555 7401 8003 2501 6345\n", "output": "7431260\n"}, {"input": "6 2\n2578 6301 8624 6020 8513 9486\n", "output": "4401332\n"}, {"input": "6 3\n4759 5555 7401 8003 2501 6345\n", "output": "7431260\n"}, {"input": "6 2\n2578 63... | code_stdio |
[
{
"content": "There are two bus stops denoted A and B, and there n buses that go from A to B every day. The shortest path from A to B takes t units of time but some buses might take longer paths. Moreover, buses are allowed to overtake each other during the route.\n\nAt each station one can find a sorted list o... | [{"input": "2 1000000000\n999999999 1000000000\n1 2\n", "output": "Yes\n1999999999 2000000000\n"}, {"input": "2 1000000000\n1 1000000000\n2 2\n", "output": "Yes\n2000000000 2000000001\n"}, {"input": "2 1000010000\n1 1000000000\n2 2\n", "output": "Yes\n2000010000 2000010001\n"}, {"input": "2 1000000000\n130296385 100000... | code_stdio |
[
{
"content": "Rng is preparing a problem set for a qualification round of CODEFESTIVAL.\n\nHe has N candidates of problems. The difficulty of the i-th candidate is D_i.\n\nThere must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be ... | [{"input": "7\n100 200 500 700 238 1600 2000\n6\n100 200 500 700 1600 1600", "output": "NO\n"}, {"input": "7\n100 200 500 700 238 1600 2000\n6\n100 200 500 337 1600 1600", "output": "NO\n"}, {"input": "7\n100 200 500 700 1200 1600 2000\n6\n100 200 500 700 1600 1600", "output": "NO"}, {"input": "7\n100 200 500 700 238 1... | code_stdio |
[
{
"content": "Misha and Vasya participated in a Codeforces contest. Unfortunately, each of them solved only one problem, though successfully submitted it at the first attempt. Misha solved the problem that costs a points and Vasya solved the problem that costs b points. Besides, Misha submitted the problem c mi... | [{"input": "1500 1000 176 177\n", "output": "Misha\n"}, {"input": "2750 1750 134 147\n", "output": "Misha\n"}, {"input": "3250 1000 160 138\n", "output": "Misha\n"}, {"input": "1250 2000 101 180\n", "output": "Misha\n"}, {"input": "2250 2250 163 145\n", "output": "Vasya\n"}, {"input": "1750 1250 179 180\n", "output": "... | code_stdio |
[
{
"content": "Manao has a monitor. The screen of the monitor has horizontal to vertical length ratio a:b. Now he is going to watch a movie. The movie's frame has horizontal to vertical length ratio c:d. Manao adjusts the view in such a way that the movie preserves the original frame ratio, but also occupies as ... | [{"input": "999 1000 1365 999\n", "output": "122333/455000\n"}, {"input": "999 1010 1365 999\n", "output": "126883/459550\n"}, {"input": "999 1000 1000 999\n", "output": "1999/1000000\n"}, {"input": "999 1000 1000 999\n", "output": "1999/1000000\n"}, {"input": "999 1000 1206 999\n", "output": "23111/134000\n"}, {"input... | code_stdio |
[
{
"content": "The objective is to return all pairs of integers from a given array of integers that have a difference of 2.\n\nThe result array should be sorted in ascending order of values.\n\nAssume there are no duplicate integers in the array. The order of the integers in the input array should not matter.\n\... | [{"input": "[1, 3, 5, 6, 8, 10, 15, 32, 12, 14, 56]", "output": "[[[1, 3], [3, 5], [6, 8], [8, 10], [10, 12], [12, 14]]]", "fn_name": "twos_difference"}, {"input": "[6, 3, 4, 1, 5]", "output": "[[[1, 3], [3, 5], [4, 6]]]", "fn_name": "twos_difference"}, {"input": "[1, 2, 3, 4]", "output": "[[[1, 3], [2, 4]]]", "fn_name... | code_functional |
[
{
"content": "The biggest event of the year – Cota 2 world championship \"The Innernational\" is right around the corner. $2^n$ teams will compete in a double-elimination format (please, carefully read problem statement even if you know what is it) to identify the champion. \n\nTeams are numbered from $1$ to $2... | [{"input": "16 50\n57794 44224 38309 41637 11732 44974 655 27143 11324 49584 3371 17159 26557 38800 33033 18231 26264 14765 33584 30879 46988 60703 52973 47349 22720 51251 54716 29642 7041 54896 12197 38530 51481 43063 55463 2057 48064 41953 16250 21272 34003 51464 50389 30417 45901 38895 25949 798 29404 55166\n", "out... | code_stdio |
[
{
"content": "On March 14, the day of the number $\\pi$ is celebrated all over the world. This is a very important mathematical constant equal to the ratio of the circumference of a circle to its diameter.\n\nPolycarp was told at school that the number $\\pi$ is irrational, therefore it has an infinite number o... | [{"input": "9\n000\n3\n4141592653\n141592653589793238462643383279\n31420\n31415\n314159265358\n27182\n314159265358979323846264338327\n", "output": "0\n1\n0\n0\n3\n5\n12\n0\n30\n"}, {"input": "3\n314\n315\n314\n", "output": "3\n2\n3\n"}, {"input": "2\n0314\n0003000\n", "output": "0\n0\n"}, {"input": "1\n31415653588880\n... | code_stdio |
[
{
"content": "This problem consists of three subproblems: for solving subproblem C1 you will receive 4 points, for solving subproblem C2 you will receive 4 points, and for solving subproblem C3 you will receive 8 points.\n\nManao decided to pursue a fighter's career. He decided to begin with an ongoing tourname... | [{"input": "40 3\n1 62395\n5 40319\n4 165445\n10 137479\n10 47829\n8 9741\n5 148106\n10 25494\n10 162856\n2 106581\n0 194523\n9 148086\n1 100862\n6 147600\n6 107486\n6 166873\n7 16721\n4 22192\n0 8827\n1 197146\n10 8949\n0 150443\n9 148348\n3 143935\n1 139371\n7 128821\n10 107760\n4 141821\n1 35852\n9 107522\n10 54717\... | code_stdio |
[
{
"content": "Vasya has got three integers n, m and k. He'd like to find three integer points (x_1, y_1), (x_2, y_2), (x_3, y_3), such that 0 ≤ x_1, x_2, x_3 ≤ n, 0 ≤ y_1, y_2, y_3 ≤ m and the area of the triangle formed by these points is equal to nm/k.\n\nHelp Vasya! Find such points (if it's possible). If th... | [{"input": "1000000000 1000000000 2\n", "output": "YES\n0 0\n1000000000 0\n0 1000000000\n"}, {"input": "1000000000 1000000001 2\n", "output": "YES\n0 0\n1000000000 0\n0 1000000001\n"}, {"input": "1000000010 1000000001 2\n", "output": "YES\n0 0\n1000000010 0\n0 1000000001\n"}, {"input": "236887699 1000000000 2\n", "outp... | code_stdio |
[
{
"content": "Robbers, who attacked the Gerda's cab, are very successful in covering from the kingdom police. To make the goal of catching them even harder, they use their own watches.\n\nFirst, as they know that kingdom police is bad at math, robbers use the positional numeral system with base 7. Second, they ... | [{"input": "1000000000 1000000000\n", "output": "0\n"}, {"input": "1010000000 1000000000\n", "output": "0\n"}, {"input": "1000000000 1000000100\n", "output": "0\n"}, {"input": "282475250 282475250\n", "output": "0\n"}, {"input": "421414245 4768815\n", "output": "0\n"}, {"input": "421414245 5452708\n", "output": "0\n"},... | code_stdio |
[
{
"content": "With the motto \"Creating your own path,\" a shrine created a fortune-telling fortune with its own hands. Ask the person who draws the lottery to throw six stones first, then the line segment connecting the first and second of the thrown stones, the line segment connecting the third and fourth, th... | [{"input": "-1 -2 9 6\n3 -2 7 6\n-1 0 9 0\n2 2 0 -1\n1 2 2 0\n-3 -1 3 1\n0 0 0 0", "output": "syo-kichi\nsyo-kichi\n"}, {"input": "-1 -2 22 6\n3 -2 7 10\n-1 0 9 0\n3 2 0 -1\n1 1 2 1\n-3 -1 3 1\n0 0 0 0", "output": "syo-kichi\nkyo\n"}, {"input": "-1 -1 22 6\n3 -2 7 10\n-1 0 9 0\n3 2 0 -1\n1 1 2 1\n-3 -1 3 1\n0 0 0 0", "... | code_stdio |
[
{
"content": "It is important to use strong passwords to make the Internet more secure. At the same time, it is very important not to reuse the same password. No matter how strong your password is, if the plaintext is leaked in one place, it will be very easy to break. Of course, if all applications hash passwo... | [{"input": "passxord", "output": "INVALID\n"}, {"input": "parsxosd", "output": "INVALID\n"}, {"input": "parsxpsd", "output": "INVALID\n"}, {"input": "qarsxpsd", "output": "INVALID\n"}, {"input": "qarxspsd", "output": "INVALID\n"}, {"input": "dspsxraq", "output": "INVALID\n"}, {"input": "qarxspsc", "output": "INVALID\n"... | code_stdio |
[
{
"content": "The door of Snuke's laboratory is locked with a security code.\nThe security code is a 4-digit number. We say the security code is hard to enter when it contains two consecutive digits that are the same.\nYou are given the current security code S. If S is hard to enter, print Bad; otherwise, print... | [{"input": "8080\n", "output": "Good\n"}, {"input": "0930\n", "output": "Good\n"}, {"input": "8901\n", "output": "Good\n"}, {"input": "3695\n", "output": "Good\n"}, {"input": "4649\n", "output": "Good\n"}, {"input": "12101", "output": "Good\n"}, {"input": "12904", "output": "Good\n"}, {"input": "24106", "output": "Good... | code_stdio |
[
{
"content": "You are given a 4-character string S consisting of uppercase English letters.\nDetermine if S consists of exactly two kinds of characters which both appear twice in S.\n\n-----Constraints-----\n - The length of S is 4.\n - S consists of uppercase English letters.\n\n-----Input-----\nInput is given... | [{"input": "ASSA\n", "output": "Yes\n"}, {"input": "FFEE\n", "output": "Yes\n"}, {"input": "AVVA\n", "output": "Yes\n"}, {"input": "HHTT\n", "output": "Yes\n"}, {"input": "ILIL\n", "output": "Yes\n"}, {"input": "STOP\n", "output": "No\n"}, {"input": "FREE\n", "output": "No\n"}, {"input": "ZZZZ\n", "output": "No\n"}, {"... | code_stdio |
[
{
"content": "This is a problem that involves adding numbers to items in a list.\nIn a list you will have to add the item's remainder when divided by a given divisor to each item.\n\nFor example if the item is 40 and the divisor is 3 you would have to add 1 since 40 minus the closest multiple of 3 which is 39 i... | [{"input": "[2, 7, 5, 9, 100, 34, 32, 0]\n3", "output": "[[4, 8, 7, 9, 101, 35, 34, 0]]", "fn_name": "solve"}, {"input": "[1000, 999, 998, 997]\n5", "output": "[[1000, 1003, 1001, 999]]", "fn_name": "solve"}, {"input": "[33, 23, 45, 78, 65]\n10", "output": "[[36, 26, 50, 86, 70]]", "fn_name": "solve"}, {"input": "[0, 0... | code_functional |
[
{
"content": "## Task\n\nYour challenge is to write a function named `getSlope`/`get_slope`/`GetSlope` that calculates the slope of the line through two points.\n\n## Input\n\n```if:javascript,python\nEach point that the function takes in is an array 2 elements long. The first number is the x coordinate and the... | [{"input": "[8, 3]\n[-4, 5]", "output": "[-0.16666666666666666]", "fn_name": "getSlope"}, {"input": "[-5, 9]\n[-5, 12]", "output": "[null]", "fn_name": "getSlope"}, {"input": "[-5, 9]\n[-5, 9]", "output": "[null]", "fn_name": "getSlope"}, {"input": "[11, 1]\n[1, 11]", "output": "[-1]", "fn_name": "getSlope"}, {"input":... | code_functional |
[
{
"content": "Robbers, who attacked the Gerda's cab, are very successful in covering from the kingdom police. To make the goal of catching them even harder, they use their own watches.\n\nFirst, as they know that kingdom police is bad at math, robbers use the positional numeral system with base 7. Second, they ... | [{"input": "1000000000 1000000000\n", "output": "0\n"}, {"input": "1000000000 1000000000\n", "output": "0\n"}, {"input": "1000000000 1000000001\n", "output": "0\n"}, {"input": "1000000000 1000000011\n", "output": "0\n"}, {"input": "1100000000 1000000011\n", "output": "0\n"}, {"input": "282475250 282475250\n", "output":... | code_stdio |
[
{
"content": "Unlike Knights of a Round Table, Knights of a Polygonal Table deprived of nobility and happy to kill each other. But each knight has some power and a knight can kill another knight if and only if his power is greater than the power of victim. However, even such a knight will torment his conscience... | [{"input": "11 10\n1 2 3 4 5 6 7 8 9 10 11\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "1000000000 2000000000 3000000000 4000000000 5000000000 6000000000 7000000000 8000000000 9000000000 10000000000 11000000000 "}, {"input": "11... | code_stdio |
[
{
"content": "Let's define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of n vertices. For each vertex v from 0 to n - 1 he wrote down two integers, degree_{v} and s_{v}, were the first integer is the number of vertices adjacen... | [{"input": "19\n1 13\n0 0\n1 9\n1 11\n1 11\n2 3\n2 30\n0 -1\n1 5\n1 2\n0 0\n5 29\n1 6\n2 11\n0 0\n0 0\n0 0\n0 -1\n2 13\n", "output": "10\n0 13\n2 9\n3 11\n4 11\n8 5\n12 6\n13 11\n5 11\n6 18\n11 18\n\n"}, {"input": "19\n1 13\n0 0\n1 9\n1 11\n1 11\n2 3\n2 30\n0 -1\n1 5\n1 2\n0 0\n5 29\n1 6\n2 11\n0 0\n0 0\n0 0\n0 0\n2 13... | code_stdio |
[
{
"content": "There is a tree T with N vertices, numbered 1 through N. For each 1 ≤ i ≤ N - 1, the i-th edge connects vertices a_i and b_i.\n\nSnuke is constructing a directed graph T' by arbitrarily assigning direction to each edge in T. (There are 2^{N - 1} different ways to construct T'.)\n\nFor a fixed T', ... | [{"input": "10\n2 4\n2 5\n8 3\n10 7\n1 7\n2 8\n9 10\n8 6\n10 8", "output": "220\n"}, {"input": "10\n1 4\n2 5\n1 3\n10 1\n1 6\n4 8\n9 8\n7 10\n10 2", "output": "122\n"}, {"input": "10\n2 4\n2 5\n2 3\n10 7\n1 6\n2 10\n9 5\n8 7\n10 6", "output": "194\n"}, {"input": "10\n1 4\n2 5\n1 3\n10 1\n1 6\n4 8\n9 3\n7 10\n10 2", "ou... | code_stdio |
[
{
"content": "Rational numbers are numbers represented by ratios of two integers. For a prime number p, one of the elementary theorems in the number theory is that there is no rational number equal to √p. Such numbers are called irrational numbers. It is also known that there are rational numbers arbitrarily cl... | [{"input": "2 10\n5 10\n19 111\n0 0", "output": "10/7 7/5\n9/4 2/1\n109/25 61/14\n"}, {"input": "11 5\n10 10\n5 100\n0 0", "output": "4/1 3/1\n10/3 3/1\n85/38 38/17\n"}, {"input": "2 5\n3 14\n26 111\n0 0", "output": "3/2 4/3\n7/4 12/7\n51/10 107/21\n"}, {"input": "8 24\n3 10\n5 110\n0 0", "output": "17/6 14/5\n7/4 5/3\... | code_stdio |
[
{
"content": "Chef's new hobby is painting, but he learned the fact that it's not easy to paint 2D pictures in a hard way, after wasting a lot of canvas paper, paint and of course time. From now on, he decided to paint 1D pictures only.\nChef's canvas is N millimeters long and is initially all white. For simpli... | [{"input": "3\n4\n1 6 4 -2\n0\n0 9 -1 10\n0\n-1 3 6", "output": "No\nNo\nNo\n"}, {"input": "3\n4\n1 6 4 0\n0\n-1 9 -1 10\n0\n-1 3 6", "output": "No\nNo\nNo\n"}, {"input": "3\n4\n1 6 4 1\n0\n-1 9 -1 10\n0\n-1 3 6", "output": "No\nNo\nNo\n"}, {"input": "3\n4\n2 9 1 3\n3\n1 1 1 10\n0\n18 3 1", "output": "No\nYes\nNo\n"}, ... | code_stdio |
[
{
"content": "Mr. Takahashi has a string s consisting of lowercase English letters. He repeats the following operation on s exactly K times.\n\n* Choose an arbitrary letter on s and change that letter to the next alphabet. Note that the next letter of `z` is `a`.\n\n\n\nFor example, if you perform an operation ... | [{"input": "codefestival\n101", "output": "aaaafeaaiaal\n"}, {"input": "cdoeffstival\n101", "output": "aaaaffaaiaal\n"}, {"input": "cdoeffstival\n111", "output": "aaaaafativam\n"}, {"input": "lavitsffeodc\n111", "output": "aaaaaaaaeadg\n"}, {"input": "caoeffstivdl\n111", "output": "aaaaaaativdo\n"}, {"input": "cdoefest... | code_stdio |
[
{
"content": "It is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts.\n\nThere are N houses along TopCoDeer street. The i-th house is located at coordinate a_i. He has decided to deliver gifts to all these houses.\n\nFind the minimum distance to be traveled ... | [{"input": "8\n121 1 -1 -1 -3 3 0 1", "output": "124\n"}, {"input": "8\n0 -4 -1 21 -2 -15 4 2", "output": "36\n"}, {"input": "8\n0 -3 -1 27 -6 -18 4 2", "output": "45\n"}, {"input": "8\n-2 -1 0 1 3 -143 0 1", "output": "146\n"}, {"input": "8\n-2 -1 0 1 3 -149 0 1", "output": "152\n"}, {"input": "8\n0 -5 0 15 -1 -10 2 1... | code_stdio |
[
{
"content": "Inna is a great piano player and Dima is a modest guitar player. Dima has recently written a song and they want to play it together. Of course, Sereja wants to listen to the song very much. \n\nA song is a sequence of notes. Dima and Inna want to play each note at the same time. At that, they can ... | [{"input": "10\n2 2 2 4 10 6 7 16 9 17\n1 2 3 5 5 6 7 8 18 10\n", "output": "157\n"}, {"input": "10\n1 2 0 4 10 4 7 16 9 17\n1 2 3 5 5 6 7 8 18 10\n", "output": "154\n"}, {"input": "10\n1 2 2 4 10 6 7 16 9 17\n1 2 3 5 5 6 7 8 18 10\n", "output": "157\n"}, {"input": "10\n1 2 2 4 10 4 7 16 9 17\n1 2 3 5 5 6 7 8 18 10\n",... | code_stdio |
[
{
"content": "# Don't give me five!\n\nIn this kata you get the start number and the end number of a region and should return the count of all numbers except numbers with a 5 in it. The start and the end number are both inclusive!\n\nExamples:\n\n```\n1,9 -> 1,2,3,4,6,7,8,9 -> Result 8\n4,17 -> 4,6,7,8,9,10,11,... | [{"input": "-14\n-1", "output": "[13]", "fn_name": "dont_give_me_five"}, {"input": "-4\n17", "output": "[20]", "fn_name": "dont_give_me_five"}, {"input": "-4\n37", "output": "[38]", "fn_name": "dont_give_me_five"}, {"input": "-14\n-6", "output": "[9]", "fn_name": "dont_give_me_five"}, {"input": "4\n17", "output": "[12]... | code_functional |
[
{
"content": "Many years have passed, and n friends met at a party again. Technologies have leaped forward since the last meeting, cameras with timer appeared and now it is not obligatory for one of the friends to stand with a camera, and, thus, being absent on the photo.\n\nSimply speaking, the process of phot... | [{"input": "10\n489 685\n857 870\n736 221\n687 697\n166 360\n265 200\n738 519\n393 760\n66 176\n798 160\n", "output": "3231747\n"}, {"input": "10\n489 685\n857 870\n736 221\n687 697\n166 360\n265 200\n738 519\n393 760\n66 176\n798 160\n", "output": "3231747\n"}, {"input": "10\n864 874\n534 702\n73 363\n856 895\n827 72\... | code_stdio |
[
{
"content": "Today is Chef's birthday. His mom has surprised him with truly fruity gifts: 2 fruit baskets. The first basket contains N apples, and the second one contains M oranges. Chef likes apples and oranges very much but he likes them equally, and therefore, wants to have the minimum possible difference b... | [{"input": "3\n-1 0 1\n13 0 5\n-1 4 3", "output": "0\n8\n2\n"}, {"input": "3\n-1 0 0\n13 0 5\n-1 4 3", "output": "1\n8\n2\n"}, {"input": "3\n10 -2 0\n7 0 2\n2 4 1", "output": "12\n5\n1\n"}, {"input": "3\n-1 0 0\n14 0 5\n-1 4 3", "output": "1\n9\n2\n"}, {"input": "3\n10 -2 0\n7 0 2\n2 6 1", "output": "12\n5\n3\n"}, {"in... | code_stdio |
[
{
"content": "Nadeko's birthday is approaching! As she decorated the room for the party, a long garland of Dianthus-shaped paper pieces was placed on a prominent part of the wall. Brother Koyomi will like it!\n\nStill unsatisfied with the garland, Nadeko decided to polish it again. The garland has n pieces numb... | [{"input": "100\ndddddccccdddddaaaaabbbbbbbbbbbbbaaacdcabbacccacccccbdbbadddbbddddbdaaccacdddbbbaddddbbbbdcbbbdddddda\n50\n54 b\n48 d\n45 b\n52 c\n52 a\n48 a\n54 b\n45 a\n47 d\n50 d\n53 a\n34 a\n51 b\n48 d\n47 d\n47 a\n48 d\n53 b\n52 d\n54 d\n46 a\n38 a\n52 b\n49 a\n49 b\n46 c\n99 a\n45 b\n35 c\n55 c\n51 c\n46 d\n54 d\... | code_stdio |
[
{
"content": "An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its... | [{"input": "50\n39 8 41 9 45 1 5 18 38 31 28 7 12 49 33 19 26 6 42 13 37 27 2 21 20 22 14 16 48 47 32 50 25 17 35 24 36 4 29 15 43 10 11 30 40 46 3 23 44 34\n", "output": "46\n"}, {"input": "50\n43 15 10 33 32 31 13 7 5 22 36 1 25 14 38 19 8 6 24 42 28 21 44 35 4 3 49 30 27 46 2 9 17 37 45 41 18 39 12 11 16 20 50 26 29... | code_stdio |
[
{
"content": "As we all know, Max is the best video game player among her friends. Her friends were so jealous of hers, that they created an actual game just to prove that she's not the best at games. The game is played on a directed acyclic graph (a DAG) with n vertices and m edges. There's a character written... | [{"input": "100 1\n92 93 p\n", "output": "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB... | code_stdio |
[
{
"content": "You are given a rectangular cake, represented as an r × c grid. Each cell either has an evil strawberry, or is empty. For example, a 3 × 4 cake may look as follows: [Image] \n\nThe cakeminator is going to eat the cake! Each time he eats, he chooses a row or a column that does not contain any evil ... | [{"input": "10 10\n.....SSSSS\n.....SSSSS\n.....SSSSS\n.....SSSSS\n.....SSSSS\n..........\n..........\n..........\n..........\n..........\n", "output": "75\n"}, {"input": "10 10\nS...SSSSSS\nS...SSSSSS\nS...SSSSSS\nS...SSSSSS\nS...SSSSSS\nS...SSSSSS\nS...SSSSSS\nS...SSSSSS\nS...SSSSSS\nS...SSSSSS\n", "output": "30\n"},... | code_stdio |
[
{
"content": "Take 2 strings `s1` and `s2` including only letters from `a`to `z`.\nReturn a new **sorted** string, the longest possible, containing distinct letters,\n- each taken only once - coming from s1 or s2.\n\n# Examples:\n```\na = \"xyaabbbccccdefww\"\nb = \"xxxxyyyyabklmopq\"\nlongest(a, b) -> \"abcdef... | [{"input": "\"loopingisfunbutdangerous\"\n\"lessdangerousthancoding\"", "output": "[\"abcdefghilnoprstu\"]", "fn_name": "longest"}, {"input": "\"agenerationmustconfrontthelooming\"\n\"codewarrs\"", "output": "[\"acdefghilmnorstuw\"]", "fn_name": "longest"}, {"input": "\"inmanylanguages\"\n\"theresapairoffunctions\"", "... | code_functional |
[
{
"content": "Emuskald is a well-known illusionist. One of his trademark tricks involves a set of magical boxes. The essence of the trick is in packing the boxes inside other boxes.\n\nFrom the top view each magical box looks like a square with side length equal to 2k (k is an integer, k ≥ 0) units. A magical b... | [{"input": "15\n999999986 268435456\n999999987 67108864\n999999988 16777216\n999999989 4194304\n999999990 1048576\n999999991 262144\n999999992 65536\n999999993 16384\n999999994 4096\n999999995 1024\n999999996 256\n999999997 64\n999999998 16\n999999999 4\n1000000000 1\n", "output": "1000000001\n"}, {"input": "15\n999999... | code_stdio |
[
{
"content": "Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities.\n\nTo bake muffins in her bakery, Masha needs to establish flour supply from some storage. There are only k storages, locate... | [{"input": "8 57 3\n1 3 15\n2 3 1\n1 7 21\n1 2 11\n2 1 16\n1 6 4\n1 3 2\n3 7 17\n5 8 3\n1 3 18\n1 4 3\n1 2 1\n2 8 14\n1 4 17\n4 5 21\n2 3 6\n3 5 11\n2 8 11\n3 4 1\n1 3 9\n1 4 3\n2 3 12\n1 5 9\n2 3 15\n1 2 14\n1 2 10\n1 4 19\n5 7 7\n5 8 20\n5 8 1\n1 4 3\n4 5 8\n5 7 1\n1 2 14\n4 5 9\n6 7 2\n2 6 9\n2 6 4\n3 7 4\n3 5 11\n4... | code_stdio |
[
{
"content": "# Task\n\nYou are given a function that should insert an asterisk (`*`) between every pair of **even digits** in the given input, and return it as a string. If the input is a sequence, concat the elements first as a string. \n\n\n## Input\n\nThe input can be an integer, a string of digits or a seq... | [{"input": "[1, 4, 64, 68, 67, 23, 1]", "output": "[\"14*6*4*6*8*67231\"]", "fn_name": "asterisc_it"}, {"input": "9682135", "output": "[\"96*8*2135\"]", "fn_name": "asterisc_it"}, {"input": "5312708", "output": "[\"531270*8\"]", "fn_name": "asterisc_it"}, {"input": "\"0000\"", "output": "[\"0*0*0*0\"]", "fn_name": "ast... | code_functional |
[
{
"content": "Vasya has the sequence consisting of n integers. Vasya consider the pair of integers x and y k-interesting, if their binary representation differs from each other exactly in k bits. For example, if k = 2, the pair of integers x = 5 and y = 3 is k-interesting, because their binary representation x=... | [{"input": "100 14\n8192 8192 8192 8192 8191 8192 8192 8192 8192 8192 8191 8191 8191 8192 8191 8191 8191 8192 8192 8192 8192 8192 8191 8191 8191 8192 8191 8192 8192 8192 8192 8192 8192 8191 8191 8192 8192 8191 8191 8192 8192 8192 8191 8191 8192 8191 8191 8191 8191 8191 8191 8192 8191 8191 8192 8191 8191 8192 8192 8191 ... | code_stdio |
[
{
"content": "Musicians of a popular band \"Flayer\" have announced that they are going to \"make their exit\" with a world tour. Of course, they will visit Berland as well.\n\nThere are n cities in Berland. People can travel between cities using two-directional train routes; there are exactly m routes, i-th ro... | [{"input": "7 7\n1 6 745325\n2 3 3581176\n2 4 19\n3 6 71263060078\n5 4 141198\n7 4 163953\n5 6 15994\n1 297404206755 82096176217 14663411 187389745 21385 704393\n", "output": "1 335807 7498159 335769 53373 21385 663675 \n"}, {"input": "7 7\n1 6 745325\n2 3 3581176\n2 4 19\n3 6 71263060078\n5 4 170098\n7 4 163953\n5 6 1... | code_stdio |
[
{
"content": "Little C loves number «3» very much. He loves all things about it.\n\nNow he is playing a game on a chessboard of size n × m. The cell in the x-th row and in the y-th column is called (x,y). Initially, The chessboard is empty. Each time, he places two chessmen on two different empty cells, the Man... | [{"input": "1000000000 1000000000\n", "output": "1000000000000000000\n"}, {"input": "1000001000 1000000000\n", "output": "1000001000000000000\n"}, {"input": "1000001000 1100000000\n", "output": "1100001100000000000\n"}, {"input": "567298709 2116937786\n", "output": "1200936073031118274\n"}, {"input": "567298709 1327099... | code_stdio |
[
{
"content": "After battling Shikamaru, Tayuya decided that her flute is too predictable, and replaced it with a guitar. The guitar has 6 strings and an infinite number of frets numbered from 1. Fretting the fret number j on the i-th string produces the note a_{i} + j.\n\nTayuya wants to play a melody of n note... | [{"input": "58260522 77914575 2436426 24979445 61648772 23690081\n10\n582107247 906728404 411434947 673536177 411497300 488012525 561127307 800305059 992325267 112738006\n", "output": "804109112\n"}, {"input": "58260522 77914575 2436426 24979445 61648772 23690081\n10\n582107247 906728404 411434947 673536177 411497300 4... | code_stdio |
[
{
"content": "Takahashi has a string S of length N consisting of digits from 0 through 9.\nHe loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S - there are N \\times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten.\nHere substrings ... | [{"input": "20 11\n33883322005544116655\n", "output": "68\n"}, {"input": "20 16\n10763178948652303319", "output": "136\n"}, {"input": "20 16\n46280926482052991001", "output": "139\n"}, {"input": "20 8\n33883322005544116655", "output": "171\n"}, {"input": "20 2\n33883322005544116655", "output": "103\n"}, {"input": "20 1... | code_stdio |
[
{
"content": "There are n employees working in company \"X\" (let's number them from 1 to n for convenience). Initially the employees didn't have any relationships among each other. On each of m next days one of the following events took place: either employee y became the boss of employee x (at that, employee... | [{"input": "2 10\n2 2\n1 2 1\n3 1 1\n3 2 1\n3 1 1\n2 2\n3 1 2\n3 1 1\n3 2 1\n3 1 2\n", "output": "NO\nYES\nNO\nYES\nNO\nYES\nYES\n"}, {"input": "2 10\n2 2\n1 2 1\n3 1 1\n3 1 1\n3 1 1\n2 2\n3 1 2\n3 1 1\n3 2 1\n3 1 2\n", "output": "NO\nNO\nNO\nYES\nNO\nYES\nYES\n"}, {"input": "2 10\n2 2\n1 2 1\n3 1 1\n3 1 1\n3 2 1\n2 2\... | code_stdio |
[
{
"content": "You are given four integers $n$, $B$, $x$ and $y$. You should build a sequence $a_0, a_1, a_2, \\dots, a_n$ where $a_0 = 0$ and for each $i \\ge 1$ you can choose:\n\neither $a_i = a_{i - 1} + x$\n\nor $a_i = a_{i - 1} - y$.\n\nYour goal is to build such a sequence $a$ that $a_i \\le B$ for all $i... | [{"input": "2\n100000 1000000000 1000000000 1\n100000 1 1000000000 10000\n", "output": "99995000050000\n-50000500000000\n"}, {"input": "7\n1 1 1 1\n2 2 2 2\n3 3 3 3\n4 4 4 4\n5 5 5 5\n6 6 6 6\n7 7 7 7\n", "output": "1\n2\n6\n8\n15\n18\n28\n"}, {"input": "3\n5 100 1 30\n7 1000000000 1000000000 1000000000\n4 1 7 3\n", "o... | code_stdio |
[
{
"content": "Память компьютера состоит из n ячеек, которые выстроены в ряд. Пронумеруем ячейки от 1 до n слева направо. Про каждую ячейку известно, свободна она или принадлежит какому-либо процессу (в таком случае известен процесс, которому она принадлежит).\n\nДля каждого процесса известно, что принадлежащие ... | [{"input": "24\n0 0 6 6 6 0 22 22 0 23 23 0 19 19 19 19 0 0 17 0 0 3 3 3\n", "output": "14\n"}, {"input": "21\n0 11 11 11 11 0 7 0 12 12 12 12 12 0 19 19 19 0 1 1 1\n", "output": "11\n"}, {"input": "24\n6 6 0 0 0 22 0 0 23 0 0 19 0 0 0 0 17 17 0 3 3 0 0 0\n", "output": "7\n"}, {"input": "21\n11 0 0 0 0 7 0 12 0 0 0 0 0... | code_stdio |
[
{
"content": "Create a function `close_compare` that accepts 3 parameters: `a`, `b`, and an optional `margin`. The function should return whether `a` is lower than, close to, or higher than `b`. `a` is \"close to\" `b` if `margin` is higher than or equal to the difference between `a` and `b`.\n\nWhen `a` is low... | [{"input": "1.99\n5\n3", "output": "[-1]", "fn_name": "close_compare"}, {"input": "8.1\n5\n3", "output": "[1]", "fn_name": "close_compare"}, {"input": "2\n5\n3", "output": "[0]", "fn_name": "close_compare"}, {"input": "5\n5\n3", "output": "[0]", "fn_name": "close_compare"}, {"input": "8\n5\n3", "output": "[0]", "fn_nam... | code_functional |
[
{
"content": "Let's imagine: there is a chess piece billiard ball. Its movements resemble the ones of a bishop chess piece. The only difference is that when a billiard ball hits the board's border, it can reflect from it and continue moving.\n\nMore formally, first one of four diagonal directions is chosen and ... | [{"input": "1000000 1000000\n", "output": "1000000\n"}, {"input": "666667 1000000\n", "output": "333334\n"}, {"input": "871866 348747\n", "output": "174374\n"}, {"input": "863029 287677\n", "output": "287677\n"}, {"input": "962963 1000000\n", "output": "37038\n"}, {"input": "701905 526429\n", "output": "175477\n"}, {"i... | code_stdio |
[
{
"content": "Petya loves hockey very much. One day, as he was watching a hockey match, he fell asleep. Petya dreamt of being appointed to change a hockey team's name. Thus, Petya was given the original team name w and the collection of forbidden substrings s1, s2, ..., sn. All those strings consist of uppercas... | [{"input": "100\nqn\nBE\nyN\nep\nPq\nXz\nLM\nEZ\ndb\nMn\nbn\nFe\nqA\nzc\nyq\npC\nyA\nWk\nYq\nrs\noD\nvD\nzW\nxZ\nbl\nur\nkf\ndf\nLS\nUW\nMy\nhR\nsh\nNh\nog\nCW\nor\nzo\nrO\nao\nXH\nDq\nKa\nlL\nYQ\nOh\nRZ\nAx\nta\nko\nDn\nNg\nNy\nDB\nYD\njO\nAp\nFT\noB\nNc\nwB\nHO\neW\nAc\nDr\nMt\nDf\nbF\nFP\nRa\nnF\nhF\nXC\nnG\nan\nZY\... | code_stdio |
[
{
"content": "You are given a directed graph consisting of $n$ vertices. Each directed edge (or arc) labeled with a single character. Initially, the graph is empty.\n\nYou should process $m$ queries with it. Each query is one of three types:\n\n\"$+$ $u$ $v$ $c$\" — add arc from $u$ to $v$ with label $c$. It's ... | [{"input": "3 11\n+ 1 2 a\n+ 1 3 c\n+ 3 2 a\n+ 2 1 a\n? 6\n? 5\n- 2 1\n- 3 2\n+ 2 1 c\n+ 3 2 d\n? 5\n", "output": "YES\nYES\nYES\n"}, {"input": "3 11\n+ 1 2 a\n+ 1 3 c\n+ 3 2 a\n+ 2 1 a\n? 6\n? 5\n- 2 1\n- 3 2\n+ 2 1 c\n+ 3 3 d\n? 5\n", "output": "YES\nYES\nYES\n"}, {"input": "3 11\n+ 1 2 a\n+ 1 3 c\n+ 3 2 a\n+ 2 1 a\n... | code_stdio |
[
{
"content": "n boys and m girls came to the party. Each boy presented each girl some integer number of sweets (possibly zero). All boys are numbered with integers from 1 to n and all girls are numbered with integers from 1 to m. For all 1 ≤ i ≤ n the minimal number of sweets, which i-th boy presented to some g... | [{"input": "2 2\n100000000 100000000\n100000000 100000000\n", "output": "400000000\n"}, {"input": "2 2\n100000000 100000000\n101000000 100000000\n", "output": "401000000\n"}, {"input": "2 2\n72765050 72765049\n108366500 77716490\n", "output": "331613089\n"}, {"input": "2 2\n23720786 43602829\n112215563 67248253\n", "ou... | code_stdio |
[
{
"content": "Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.\n\nLet's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters \"a\", \"e\", \"i\", \"o\", \"u\" are considered ... | [{"input": "7 3\nferwljzwakxedlgwl\noerwljzwakxedlgwl\nhyqombizhuhxedprb\netptjrizhuhxedprb\nurtuckar\ndkartmwramklcmi\nrurtuckar\nnurartmwramklcmi\niraziomsv\nsaziomsv\nbprapiqpayzurgij\nusyemayzurgij\nztstmeecvmkvuu\nquexlecvmkvuu\nrlhwecvmkvuu\nzecvmkvuu\niikymgbncljtub\nqiikymgbncljtub\nbcavhexqamyszgfya\nojexqamys... | code_stdio |
[
{
"content": "Story\nJumbo Juice makes a fresh juice out of fruits of your choice.Jumbo Juice charges $5 for regular fruits and $7 for special ones. Regular fruits are Banana, Orange, Apple, Lemon and Grapes. Special ones are Avocado, Strawberry and Mango. Others fruits that are not listed are also available up... | [{"input": "[\"blackBerry\", \"coconut\", \"avocado\"]", "output": "[8]", "fn_name": "mix_fruit"}, {"input": "[\"BlACKbeRrY\", \"cOcONuT\", \"avoCaDo\"]", "output": "[8]", "fn_name": "mix_fruit"}, {"input": "[\"watermelon\", \"cherry\", \"avocado\"]", "output": "[8]", "fn_name": "mix_fruit"}, {"input": "[\"watermelon\"... | code_functional |
[
{
"content": "Most of this problem is by the original author of [the harder kata](https://www.codewars.com/kata/556206664efbe6376700005c), I just made it simpler.\n\nI read a book recently, titled \"Things to Make and Do in the Fourth Dimension\" by comedian and mathematician Matt Parker ( [Youtube](https://www... | [{"input": "1073741823", "output": "[false]", "fn_name": "polydivisible"}, {"input": "381654729", "output": "[true]", "fn_name": "polydivisible"}, {"input": "123220", "output": "[false]", "fn_name": "polydivisible"}, {"input": "1020005", "output": "[true]", "fn_name": "polydivisible"}, {"input": "9876545", "output": "[... | code_functional |
[
{
"content": "Berland Football Cup starts really soon! Commentators from all over the world come to the event.\n\nOrganizers have already built $n$ commentary boxes. $m$ regional delegations will come to the Cup. Every delegation should get the same number of the commentary boxes. If any box is left unoccupied ... | [{"input": "500000000001 1000000000000 100 100\n", "output": "49999999999900\n"}, {"input": "500000000001 1000000000000 100 100\n", "output": "49999999999900\n"}, {"input": "500000000001 1000000000000 110 100\n", "output": "50000000000100\n"}, {"input": "1000000000000 750000000001 10 100\n", "output": "5000000000020\n"... | code_stdio |
[
{
"content": "Spoonerize... with numbers... numberize?... numboonerize?... noonerize? ...anyway! If you don't yet know what a spoonerism is and haven't yet tried my spoonerism kata, please do [check it out](http://www.codewars.com/kata/spoonerize-me) first.\n\nYou will create a function which takes an array of... | [{"input": "[1000000, \"hello\"]", "output": "[\"invalid array\"]", "fn_name": "noonerize"}, {"input": "[\"pippi\", 9999999]", "output": "[\"invalid array\"]", "fn_name": "noonerize"}, {"input": "[\"pippi\", \"hello\"]", "output": "[\"invalid array\"]", "fn_name": "noonerize"}, {"input": "[1000000, 9999999]", "output":... | code_functional |
[
{
"content": "From the FAQ:\n\nWhat am I allowed to post as a comment for a problem? \n\nDo NOT post code.\nDo NOT post a comment asking why your solution is wrong.\nDo NOT post a comment asking if you can be given the test case your program fails on.\nDo NOT post a comment asking how your solution can be impro... | [{"input": "7\n1\n?\n2\n0?\n11\n69259?087\n4\n??\n2\n0?1\n4\n?????\n3\n22", "output": "0\n01\n692591087\n01\nNO\n01012\nNO\n"}, {"input": "7\n1\n?\n2\n0?\n11\n69259?087\n4\n??\n2\n0?1\n4\n?????\n3\n15", "output": "0\n01\n692591087\n01\nNO\n01012\n15\n"}, {"input": "7\n1\n?\n2\n0?\n11\n69259?087\n4\n?>\n2\n0?1\n4\n?????... | code_stdio |
[
{
"content": "Daniel is watching a football team playing a game during their training session. They want to improve their passing skills during that session.\n\nThe game involves $n$ players, making multiple passes towards each other. Unfortunately, since the balls were moving too fast, after the session Daniel... | [{"input": "1\n200\n5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 ... | code_stdio |
[
{
"content": "This is a story in a depopulated area. In this area, houses are sparsely built along a straight road called Country Road. Until now, there was no electricity in this area, but this time the government will give us some generators. You can install the generators wherever you like, but in order for ... | [{"input": "6\n5 2\n10 30 40 70 100\n7 3\n3 5 10 53 21 26 28\n1 1\n100\n2 1\n-1 1000000\n3 5\n30 70 211\n6 5\n0 10 20 30 40 50", "output": "60\n-23\n0\n1000001\n0\n10\n"}, {"input": "6\n5 2\n10 30 40 70 100\n7 3\n3 5 10 53 21 26 28\n1 1\n100\n2 1\n-1 1000000\n3 5\n30 70 211\n6 5\n0 10 20 8 40 50", "output": "60\n-23\n0... | code_stdio |
[
{
"content": "Hakone Ekiden is one of the Japanese New Year's traditions. In Hakone Ekiden, 10 runners from each team aim for the goal while connecting the sashes at each relay station. In the TV broadcast, the ranking change from the previous relay station is displayed along with the passing order of each team... | [{"input": "10\nU\nD\nU\nD\nU\nD\nU\nD\nU\nD", "output": "608"}, {"input": "8\nT\nD\nD\nD\nD\nD\nD\nC", "output": "0\n"}, {"input": "8\nT\nD\nD\nD\nD\nD\nC\nC", "output": "0\n"}, {"input": "8\nT\nD\nD\nD\nD\nE\nC\nC", "output": "0\n"}, {"input": "8\nS\nD\nD\nD\nD\nE\nC\nC", "output": "0\n"}, {"input": "8\nS\nD\nD\nD\nD... | code_stdio |
[
{
"content": "For an integer N, we will choose a permutation \\{P_1, P_2, ..., P_N\\} of \\{1, 2, ..., N\\}.\nThen, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i.\nFind the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\n-----Constraints-----\n - N is an integer satisfying 1 \\... | [{"input": "1000000000\n", "output": "499999999500000000\n"}, {"input": "999999999\n", "output": "499999998500000001\n"}, {"input": "999999998\n", "output": "499999997500000003\n"}, {"input": "234679769\n", "output": "27537296871606796\n"}, {"input": "160767\n", "output": "12922933761\n"}, {"input": "569\n", "output": ... | code_stdio |
[
{
"content": "Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nLucky number is super lucky if it's decimal representation contains equal amou... | [{"input": "1000000000\n", "output": "4444477777\n"}, {"input": "1000100000\n", "output": "4444477777\n"}, {"input": "1211766791\n", "output": "4444477777\n"}, {"input": "1101704081\n", "output": "4444477777\n"}, {"input": "1010000000\n", "output": "4444477777\n"}, {"input": "444000000\n", "output": "4444477777\n"}, {"... | code_stdio |
[
{
"content": "Let S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(123) = 1 + 2 + 3 = 6.\nWe will call an integer n a Snuke number when, for all positive integers m such that m > n, \\frac{n}{S(n)} \\leq \\frac{m}{S(m)} holds.\nGiven an integer K, list the K smallest Snuke numbers... | [{"input": "792\n", "output": "1\n2\n3\n4\n5\n6\n7\n8\n9\n19\n29\n39\n49\n59\n69\n79\n89\n99\n199\n299\n399\n499\n599\n699\n799\n899\n999\n1099\n1199\n1299\n1399\n1499\n1599\n1699\n1799\n1899\n1999\n2999\n3999\n4999\n5999\n6999\n7999\n8999\n9999\n10999\n11999\n12999\n13999\n14999\n15999\n16999\n17999\n18999\n19999\n209... | code_stdio |
[
{
"content": "A tree is an undirected connected graph without cycles. The distance between two vertices is the number of edges in a simple path between them.\n\nLimak is a little polar bear. He lives in a tree that consists of n vertices, numbered 1 through n.\n\nLimak recently learned how to jump. He can jump ... | [{"input": "15 1\n12 9\n13 7\n1 3\n10 4\n9 2\n2 15\n11 4\n2 14\n10 8\n6 7\n12 5\n8 7\n3 10\n10 2\n", "output": "346\n"}, {"input": "15 1\n12 9\n13 7\n1 3\n10 4\n9 2\n2 15\n11 4\n2 14\n10 8\n6 7\n12 5\n8 7\n3 10\n10 2\n", "output": "346\n"}, {"input": "15 1\n12 9\n13 7\n1 3\n10 4\n9 2\n2 15\n11 4\n2 14\n10 8\n6 8\n12 5\... | code_stdio |
[
{
"content": "You've just recently been hired to calculate scores for a Dart Board game!\n\nScoring specifications:\n\n* 0 points - radius above 10\n* 5 points - radius between 5 and 10 inclusive\n* 10 points - radius less than 5\n\n**If all radii are less than 5, award 100 BONUS POINTS!**\n\nWrite a function ... | [{"input": "[15, 20, 30, 31, 32, 44, 100]", "output": "[0]", "fn_name": "score_throws"}, {"input": "[1, 2, 3, 4, 5, 6, 7, 8, 9]", "output": "[65]", "fn_name": "score_throws"}, {"input": "[0, 5, 10, 10.5, 4.5]", "output": "[30]", "fn_name": "score_throws"}, {"input": "[1, 2, 3, 4]", "output": "[140]", "fn_name": "score_... | code_functional |
[
{
"content": "During the lunch break all n Berland State University students lined up in the food court. However, it turned out that the food court, too, has a lunch break and it temporarily stopped working.\n\nStanding in a queue that isn't being served is so boring! So, each of the students wrote down the num... | [{"input": "10\n419946 201769\n245945 0\n842799 113073\n836998 245945\n0 794376\n692107 836998\n113073 904403\n904403 987165\n201769 692107\n794376 842799\n", "output": "419946 794376 201769 842799 692107 113073 836998 904403 245945 987165 \n"}, {"input": "10\n419946 201769\n245945 0\n842799 113073\n836998 245945\n0 79... | code_stdio |
[
{
"content": "You are given a permutation p of length n. Also you are given m foe pairs (a_{i}, b_{i}) (1 ≤ a_{i}, b_{i} ≤ n, a_{i} ≠ b_{i}). \n\nYour task is to count the number of different intervals (x, y) (1 ≤ x ≤ y ≤ n) that do not contain any foe pairs. So you shouldn't count intervals (x, y) that contain... | [{"input": "100 10\n19 55 91 50 31 23 60 84 38 1 22 51 27 76 28 98 11 44 61 63 15 93 52 3 66 16 53 36 18 62 35 85 78 37 73 64 87 74 46 26 82 69 49 33 83 89 56 67 71 25 39 94 96 17 21 6 47 68 34 42 57 81 13 10 54 2 48 80 20 77 4 5 59 30 90 95 45 75 8 88 24 41 40 14 97 32 7 9 65 70 100 99 72 58 92 29 79 12 86 43\n58 26\n... | code_stdio |
[
{
"content": "You are given an array $a_1, a_2, \\dots , a_n$. Array is good if for each pair of indexes $i < j$ the condition $j - a_j \\ne i - a_i$ holds. Can you shuffle this array so that it becomes good? To shuffle an array means to reorder its elements arbitrarily (leaving the initial order is also an opt... | [{"input": "3\n1\n7\n4\n1 1 3 5\n6\n3 2 1 5 6 4\n", "output": "7\n5 3 1 1\n6 5 4 3 2 1\n"}, {"input": "3\n1\n7\n4\n1 1 3 5\n6\n3 2 1 5 6 4\n", "output": "7\n5 3 1 1\n6 5 4 3 2 1\n"}, {"input": "3\n1\n7\n4\n0 1 3 5\n6\n3 2 1 5 6 4\n", "output": "7\n5 3 1 0\n6 5 4 3 2 1\n"}, {"input": "3\n1\n7\n4\n0 1 1 5\n6\n3 2 1 5 6 4... | code_stdio |
[
{
"content": "Vanya and his friend Vova play a computer game where they need to destroy n monsters to pass a level. Vanya's character performs attack with frequency x hits per second and Vova's character performs attack with frequency y hits per second. Each character spends fixed time to raise a weapon and the... | [{"input": "20 6 15\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n", "output": "Both\nBoth\nVova\nVova\nVanya\nVova\nVova\nBoth\nBoth\nVova\nVova\nVanya\nVova\nVova\nBoth\nBoth\nVova\nVova\nVanya\nVova\n"}, {"input": "20 5 15\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34... | code_stdio |
[
{
"content": "The well-known Fibonacci sequence $F_0, F_1, F_2,\\ldots $ is defined as follows: $F_0 = 0, F_1 = 1$. For each $i \\geq 2$: $F_i = F_{i - 1} + F_{i - 2}$. \n\nGiven an increasing arithmetic sequence of positive integers with $n$ elements: $(a, a + d, a + 2\\cdot d,\\ldots, a + (n - 1)\\cdot d)$... | [{"input": "1 123456 961946\n", "output": "11954016000000000001 3158031000000000000\n"}, {"input": "1 123456 961946\n", "output": "11954016000000000001 3158031000000000000\n"}, {"input": "10000 154768 13\n", "output": "11015448000000000001 9428455500000000000\n"}, {"input": "0 123456 961946\n", "output": "1195401600000... | code_stdio |
[
{
"content": "In this problem, we will deal with binary strings. Each character of a binary string is either a 0 or a 1. We will also deal with substrings; recall that a substring is a contiguous subsequence of a string. We denote the substring of string $s$ starting from the $l$-th character and ending with th... | [{"input": "50\n01110100101100100100011001100001110010010000000101\n50\n27 18 7\n22 35 2\n50 35 1\n41 16 1\n27 5 5\n11 6 33\n7 19 2\n9 12 33\n14 37 4\n1 22 8\n22 3 5\n50 42 1\n50 38 1\n29 20 2\n20 34 17\n20 4 29\n16 21 3\n11 43 3\n15 45 1\n12 28 3\n31 34 13\n43 1 8\n3 41 1\n18 3 13\n29 44 6\n47 44 3\n40 43 2\n6 46 5\n9... | code_stdio |
[
{
"content": "A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells.\n\nInput\n\nThe first inp... | [{"input": "200 2\nBABAABBABBABBABABBBABAAABABBABABBBAABBBBABBAABBABABAAAAABAABBBAAAAAAABBBABAAAABABBBAABABAABAABBBAABBABAAAABABAAAABABABBBABBBAAABAAABAAABABAAABABABBABABABBABBBABBBBBABABBBABAAABAAABAABBAABBABBBBBABBBAB\n", "output": "87\nABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA... | code_stdio |
[
{
"content": "A category page displays a set number of products per page, with pagination at the bottom allowing the user to move from page to page.\n\nGiven that you know the page you are on, how many products are in the category in total, and how many products are on any given page, how would you output a sim... | [{"input": "43\n15\n3456", "output": "[\"Showing 631 to 645 of 3456 Products.\"]", "fn_name": "pagination_text"}, {"input": "2\n30\n350", "output": "[\"Showing 31 to 60 of 350 Products.\"]", "fn_name": "pagination_text"}, {"input": "3\n10\n26", "output": "[\"Showing 21 to 26 of 26 Products.\"]", "fn_name": "pagination_... | code_functional |
[
{
"content": "# Description:\n\n Find the longest successive exclamation marks and question marks combination in the string. A successive exclamation marks and question marks combination must contains two part: a substring of \"!\" and a substring \"?\", they are adjacent. \n \n If more than one result are foun... | [{"input": "\"!!???!?????\"", "output": "[\"!?????\"]", "fn_name": "find"}, {"input": "\"!????!!!?\"", "output": "[\"????!!!\"]", "fn_name": "find"}, {"input": "\"!!???!????\"", "output": "[\"!!???\"]", "fn_name": "find"}, {"input": "\"!?!!??!!!?\"", "output": "[\"??!!!\"]", "fn_name": "find"}, {"input": "\"!?!!\"", "o... | code_functional |
[
{
"content": "A subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is a string x = sk1sk2... sk|x| (1 ≤ k1 < k2 < ... < k|x| ≤ |s|).\n\nYou've got two strings — s and t. Let's consider all subsequences of string s, coinciding with string t. Is it true that each character ... | [{"input": "ctkhagrifaztmnxhmqztzibnmzzkojiztvrkfeoqegvwtbxlvvjhebshqaicsovtkcdovytimjggglyxlvglgunbohnkxargymbqvzgsnvjzgxivdgnaesgxqcruaopjuqsyyorrobnelehjnxcetveehlbmeskptivsuhuqupbieumycwczxyqjtwfofehfkpqmjngygwxkaviuyouiippgvlxjgtkxmhcwtzacbllsybgiujyryngapfwjkkyapfgxtcdpc\nctkhagrifaztmnxhmqztzibnmzzkojiztvrkfeoqe... | code_stdio |
[
{
"content": "Nukes has an integer that can be represented as the bitwise OR of one or more integers between A and B (inclusive). How many possible candidates of the value of Nukes's integer there are?\n\nConstraints\n\n* 1 ≤ A ≤ B < 2^{60}\n* A and B are integers.\n\nInput\n\nThe input is given from Standard I... | [{"input": "271828182845904523\n1128816364578546661", "output": "881093321760942453\n"}, {"input": "271828182845904523\n1080587834201094862", "output": "881093321760942453\n"}, {"input": "271828182845904523\n1104519973481288013", "output": "881093321760942453\n"}, {"input": "271828182845904523\n1031296135146934819", "o... | code_stdio |
[
{
"content": "The ancient Berlanders believed that the longer the name, the more important its bearer is. Thus, Berland kings were famous for their long names. But long names are somewhat inconvenient, so the Berlanders started to abbreviate the names of their kings. They called every king by the first letters ... | [{"input": "50\nagecd\ncghafi\nfiide\niecc\njbdcfjhgd\ndiee\nhfeg\nehc\ngfijgjh\ngacaifebg\ndicbbddc\nhjgciaei\njjcdh\ng\ngc\ncf\nhfdjhd\nc\nicidbec\nji\neeh\ncgeejggc\nacfd\njjg\najefdj\neghhebiic\nbih\ngbb\njjaa\nidc\ngafi\necg\ndbigbjiehj\ncedif\nahidfaaajg\nhfhhiccbgb\ndgegjgieif\nhgjebhfdc\nj\nahehd\nahdah\nbijbhh... | code_stdio |
[
{
"content": "Vasya has recently developed a new algorithm to optimize the reception of customer flow and he considered the following problem.\n\nLet the queue to the cashier contain n people, at that each of them is characterized by a positive integer ai — that is the time needed to work with this customer. Wh... | [{"input": "100\n1525 7246 2782 4070 10420 5459 8162 8074 5197 4808 4599 8161 2110 2216 7434 9937 2350 9406 9497 8027 2100 1600 7508 3441 4356 3928 8448 3788 7189 9186 7923 5170 6940 6986 9909 8418 2963 9146 8411 6136 6753 3006 2726 4290 7310 8044 3558 6136 4781 1765 4242 5433 9937 8768 5103 4470 1000 5480 4834 3372 88... | code_stdio |
[
{
"content": "You've got a positive integer sequence a_1, a_2, ..., a_{n}. All numbers in the sequence are distinct. Let's fix the set of variables b_1, b_2, ..., b_{m}. Initially each variable b_{i} (1 ≤ i ≤ m) contains the value of zero. Consider the following sequence, consisting of n operations.\n\nThe firs... | [{"input": "23\n26988535 53977070 107954140 161931210 323862420 215908280 431816560 647724840 269885350 242896815 755678980 485793630 863633120 404828025 539770700 134942675 593747770 377839490 917610190 809656050 620736305 971587260 458805095\n", "output": "7\n"}, {"input": "23\n26988535 53977070 107954140 161931210 3... | code_stdio |
[
{
"content": "Find the symmetric difference of two sets $A = \\\\{a_0, a_1, ..., a_{n-1}\\\\}$ and $B = \\\\{b_0, b_1, ..., b_{m-1}\\\\}$.\n\nConstraints\n\n* $1 \\leq n, m \\leq 200,000$\n* $0 \\leq a_0 < a_1 < ... < a_{n-1} \\leq 10^9$\n* $0 \\leq b_0 < b_1 < ... < b_{m-1} \\leq 10^9$\n\nInput\n\nThe input is... | [{"input": "7\n1 2 3 4 5 7 10\n2\n0 11 6 11", "output": "0\n1\n2\n3\n4\n5\n7\n10\n11\n"}, {"input": "7\n1 2 3 4 5 7 12\n1\n0 14 3 11", "output": "0\n1\n2\n3\n4\n5\n7\n12\n"}, {"input": "7\n1 2 3 4 5 7 10\n1\n0 11 6 11", "output": "0\n1\n2\n3\n4\n5\n7\n10\n"}, {"input": "7\n1 2 3 4 5 6 10\n3\n0 4 11 8", "output": "0\n1\... | code_stdio |
[
{
"content": "The surveyor starship Hakodate-maru is famous for her two fuel containers with unbounded capacities. They hold the same type of atomic fuel balls.\n\nThere, however, is an inconvenience. The shapes of the fuel containers #1 and #2 are always cubic and regular tetrahedral respectively. Both of the ... | [{"input": "100\n160\n50\n20\n150323\n0", "output": "99\n160\n47\n20\n150303\n"}, {"input": "100\n31\n37\n104\n151200\n0", "output": "99\n31\n37\n99\n151200\n"}, {"input": "100\n84\n50\n20\n151200\n0", "output": "99\n84\n47\n20\n151200\n"}, {"input": "100\n84\n50\n20\n150323\n0", "output": "99\n84\n47\n20\n150303\n"}, ... | code_stdio |
[
{
"content": "The ACM ICPC judges are very careful about not leaking their problems, and all communications are encrypted. However, one does sometimes make mistakes, like using too weak an encryption scheme. Here is an example of that.\n\nThe encryption chosen was very simple: encrypt each chunk of the input by... | [{"input": "8\n1 1 1 1 1 1 2 1 8\n3 2 3 2 3 2 4 2 10\n6 4 7 13 7 b a 2 2e\ne1 13 ce 28 ca 6 ab 46 a5d\nb08 49e2 6128 f27 8cf2 bc50 7380 7fe1 722b\n4eba eb4 a352 fd14 6ac1 fed1 dd06 bb83 392bc\nef593c08 847e522f c9b20c47 26f3a4e1 e2720a01 6fe66007\n7a4e96ad 6ee5cef6 3853cd88\n8bf20206 757d6d66 9c3a9525 fbcd7983 82b9571c... | code_stdio |
[
{
"content": "Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:\n\n* North if the i-th letter of S is `N`\n... | [{"input": "NSNSNNSN", "output": "Yes\n"}, {"input": "NSSNSNNN", "output": "Yes\n"}, {"input": "NSNNSNSN", "output": "Yes"}, {"input": "SEWN", "output": "Yes\n"}, {"input": "ESWN", "output": "Yes\n"}, {"input": "WNES", "output": "Yes\n"}, {"input": "NEWS", "output": "Yes\n"}, {"input": "ENWS", "output": "Yes\n"}, {"inp... | code_stdio |
[
{
"content": "The Little Elephant has got a problem — somebody has been touching his sorted by non-decreasing array a of length n and possibly swapped some elements of the array.\n\nThe Little Elephant doesn't want to call the police until he understands if he could have accidentally changed the array himself. ... | [{"input": "128\n1 2 4 6 8 17 20 20 23 33 43 49 49 49 52 73 74 75 82 84 85 87 90 91 102 103 104 105 111 111 401 142 142 152 155 160 175 176 178 181 183 184 187 188 191 193 326 202 202 214 224 225 236 239 240 243 246 247 249 249 257 257 261 264 265 271 277 281 284 284 286 289 290 296 297 303 305 307 307 317 318 320 322 ... | 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": "Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm.\n\n\n.#.#.#.#.\n.#.#.#.#.#\n.#.#.#.#.\n.#.#.#.#.#\n.#.#.#.#.\n.#.#.#.#.#\n\n\nNote that the top left corner should be drawn by '#'... | [{"input": "11 21\n10 0\n5 0\n2 4\n2 0\n0 0", "output": "#.#.#.#.#.#.#.#.#.#.#\n.#.#.#.#.#.#.#.#.#.#.\n#.#.#.#.#.#.#.#.#.#.#\n.#.#.#.#.#.#.#.#.#.#.\n#.#.#.#.#.#.#.#.#.#.#\n.#.#.#.#.#.#.#.#.#.#.\n#.#.#.#.#.#.#.#.#.#.#\n.#.#.#.#.#.#.#.#.#.#.\n#.#.#.#.#.#.#.#.#.#.#\n.#.#.#.#.#.#.#.#.#.#.\n#.#.#.#.#.#.#.#.#.#.#\n\n\n\n\n\n... | code_stdio |
[
{
"content": "So the Beautiful Regional Contest (BeRC) has come to an end! n students took part in the contest. The final standings are already known: the participant in the i-th place solved p_i problems. Since the participants are primarily sorted by the number of solved problems, then p_1 ≥ p_2 ≥ ... ≥ p_n.\... | [{"input": "5\n12\n5 4 4 3 2 2 1 1 1 1 1 1\n4\n4 3 2 0\n1\n1000000\n20\n20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 10 3 2 1\n32\n64 64 63 58 58 58 58 58 37 37 37 37 34 34 28 28 28 28 28 28 24 24 19 17 17 17 17 16 17 16 16 11\n", "output": "1 2 3\n0 0 0\n0 0 0\n1 2 7\n2 6 6\n"}, {"input": "5\n12\n5 4 4 3 2 2 1 1 1 1 1 1... | code_stdio |
[
{
"content": "It's that time of the year when the Russians flood their countryside summer cottages (dachas) and the bus stop has a lot of people. People rarely go to the dacha on their own, it's usually a group, so the people stand in queue by groups.\n\nThe bus stop queue has n groups of people. The i-th group... | [{"input": "100 60\n34 21 39 17 48 46 23 56 46 52 50 39 55 48 54 38 32 38 24 26 44 12 28 9 25 26 10 52 42 60 41 3 16 60 44 29 27 55 19 19 19 57 45 59 29 35 5 14 50 47 57 48 16 7 12 36 58 31 37 58 30 50 19 11 10 41 59 57 49 41 33 9 12 11 53 50 60 51 21 9 44 23 1 16 4 15 17 57 15 17 46 50 18 52 43 24 47 50 19 18\n", "out... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nRecently Chef bought a bunch of robot-waiters. And now he needs to know how much to pay for the electricity that robots use for their work. All waiters serve food from the kitchen (which is in the point (0, 0)) and carry it to some tab... | [{"input": "2\n-1 -1\n7 -1", "output": "2\n14\n"}, {"input": "2\n-1 -1\n2 11", "output": "2\n21\n"}, {"input": "2\n-1 -2\n4 14", "output": "3\n28\n"}, {"input": "2\n1 -1\n10 14", "output": "2\n28\n"}, {"input": "2\n2 -1\n10 14", "output": "5\n28\n"}, {"input": "2\n-1 0\n7 -1", "output": "3\n14\n"}, {"input": "2\n-1 -1\... | code_stdio |
[
{
"content": "You are given a directed acyclic graph with n vertices and m edges. There are no self-loops or multiple edges between any pair of vertices. Graph can be disconnected.\n\nYou should assign labels to all vertices in such a way that:\n\n Labels form a valid permutation of length n — an integer seque... | [{"input": "101 10\n73 41\n29 76\n11 8\n94 46\n77 67\n76 18\n72 50\n45 40\n89 75\n27 22\n", "output": "1 2 3 4 5 6 7 9 10 11 8 12 13 14 15 16 17 20 21 22 23 25 26 27 28 29 24 30 18 31 32 33 34 35 36 37 38 39 40 42 44 45 46 47 41 49 50 51 52 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 72 73 74 75 76 53 43 77 79 1... | code_stdio |
[
{
"content": "In this Kata, we define an arithmetic progression as a series of integers in which the differences between adjacent numbers are the same. You will be given an array of ints of `length > 2` and your task will be to convert it into an arithmetic progression by the following rule:\n```Haskell\nFor ea... | [{"input": "[1, 1, 3, 5, 6, 5]", "output": "[4]", "fn_name": "solve"}, {"input": "[5, 4, 3, 2, 1, 1]", "output": "[1]", "fn_name": "solve"}, {"input": "[5, 6, 5, 3, 1, 1]", "output": "[4]", "fn_name": "solve"}, {"input": "[24, 21, 14, 10]", "output": "[3]", "fn_name": "solve"}, {"input": "[1, 3, 6, 9, 12]", "output": "... | code_functional |
[
{
"content": "Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains a_{i} liters of paint of color i.\n\nVika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. ... | [{"input": "10\n896619242 805194919 1680710614 848347723 816995848 856813612 805194919 954097478 816255448 566613186\n", "output": "5666131869\n"}, {"input": "10\n896619242 805194919 1680710614 848347723 816995848 856813612 805194919 545821022 816255448 805194919\n", "output": "5458210229\n"}, {"input": "10\n896619242 ... | code_stdio |
[
{
"content": "Inna and Dima decided to surprise Sereja. They brought a really huge candy matrix, it's big even for Sereja! Let's number the rows of the giant matrix from 1 to n from top to bottom and the columns — from 1 to m, from left to right. We'll represent the cell on the intersection of the i-th row and ... | [{"input": "63 67 18046757 61758841 85367218 68\n22 30\n25 40\n56 58\n29 11\n34 63\n28 66\n51 5\n39 64\n1 23\n24 61\n19 47\n10 31\n55 28\n52 26\n38 7\n28 31\n13 27\n37 42\n10 52\n19 33\n7 36\n13 1\n46 40\n21 41\n1 1\n6 35\n10 4\n46 9\n21 57\n1 49\n34 14\n14 35\n43 4\n1 41\n25 22\n18 25\n27 23\n43 17\n34 23\n29 4\n50 40... | code_stdio |
[
{
"content": "Shohag has an integer sequence $a_1, a_2, \\ldots, a_n$. He can perform the following operation any number of times (possibly, zero):\n\nSelect any positive integer $k$ (it can be different in different operations).\n\nChoose any position in the sequence (possibly the beginning or end of the seque... | [{"input": "1\n39\n481199252 336470888 728039650 446497694 740396295 773386884 579721198 396628655 503722503 971207868 202647942 2087506 268792718 46761498 443917727 16843338 125908043 1772709198 717268783 787375312 150414369 693319712 519096230 29277141 856168102 762263554 674936674 407246545 274667941 279198849 52726... | code_stdio |
[
{
"content": "You are given a rectangle grid. That grid's size is n × m. Let's denote the coordinate system on the grid. So, each point on the grid will have coordinates — a pair of integers (x, y) (0 ≤ x ≤ n, 0 ≤ y ≤ m).\n\nYour task is to find a maximum sub-rectangle on the grid (x1, y1, x2, y2) so that it co... | [{"input": "1000000000 1000001000 286536427 579261823 230782719 1150170645\n", "output": "209608854 195871608 363464000 962652038\n"}, {"input": "1000000000 1000000000 500000000 500000000 500000000 500000001\n", "output": "250000000 249999999 750000000 750000000\n"}, {"input": "1000000000 1000000000 286536427 579261823... | code_stdio |
[
{
"content": "You are given an array a_0, a_1, ..., a_{N-1} of length N. Process Q queries of the following types.\n\n* `0 p x`: a_p \\gets a_p + x\n* `1 l r`: Print \\sum_{i = l}^{r - 1}{a_i}.\n\nConstraints\n\n* 1 \\leq N, Q \\leq 500,000\n* 0 \\leq a_i, x \\leq 10^9\n* 0 \\leq p < N\n* 0 \\leq l_i < r_i \\le... | [{"input": "5 5\n1 2 9 4 5\n1 1 5\n1 2 4\n0 3 15\n1 0 5\n1 0 3", "output": "20\n13\n36\n12\n"}, {"input": "5 5\n1 2 8 4 5\n1 0 5\n1 2 4\n0 3 10\n1 0 5\n1 0 3", "output": "20\n12\n30\n11\n"}, {"input": "5 5\n1 2 8 4 5\n1 0 5\n1 2 4\n0 3 10\n1 0 4\n1 0 3", "output": "20\n12\n25\n11\n"}, {"input": "5 5\n1 0 4 0 5\n1 0 5\n... | code_stdio |
[
{
"content": "In recreational mathematics, a [Keith number](https://en.wikipedia.org/wiki/Keith_number) or repfigit number (short for repetitive Fibonacci-like digit) is a number in the following integer sequence:\n\n`14, 19, 28, 47, 61, 75, 197, 742, 1104, 1537, 2208, 2580, 3684, 4788, 7385, 7647, 7909, ...` (... | [{"input": "41796205765147426974704791528", "output": "[89]", "fn_name": "is_keith_number"}, {"input": "18354972585225358067718266", "output": "[78]", "fn_name": "is_keith_number"}, {"input": "855191324330802397989", "output": "[64]", "fn_name": "is_keith_number"}, {"input": "11812665388886672", "output": "[48]", "fn_n... | code_functional |
[
{
"content": "Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reach photo n. Similarly, by swiping right from the last photo you reach p... | [{"input": "100 20 100 15061\nwwwwhhwhhwhhwhhhhhwwwhhhwwwhwwhwhhwwhhwwwhwwhwwwhwhwhwwhhhwwwhhwhwwhhwhwhwwwhwwwwhwhwwwwhwhhhwhwhwwh\n", "output": "100\n"}, {"input": "100 20 110 15061\nwwwwhhwhhwhhwhhhhhwwwhhhwwwhwwhwhhwwhhwwwhwwhwwwhwhwhwwhhhwwwhhwhwwhhwhwhwwwhwwwwhwhwwwwhwhhhwhwhwwh\n", "output": "100\n"}, {"input": "... | code_stdio |
[
{
"content": "One rainy gloomy evening when all modules hid in the nearby cafes to drink hot energetic cocktails, the Hexadecimal virus decided to fly over the Mainframe to look for a Great Idea. And she has found one!\n\nWhy not make her own Codeforces, with blackjack and other really cool stuff? Many people w... | [{"input": "010\n", "output": "0\n"}, {"input": "011\n", "output": "4\n"}, {"input": "001\n", "output": "0\n"}, {"input": "20\n", "output": "15\n"}, {"input": "15\n", "output": "4\n"}, {"input": "13\n", "output": "4\n"}, {"input": "11\n", "output": "4\n"}, {"input": "17\n", "output": "4\n"}, {"input": "18\n", "output":... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.