messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "Math hasn't always been your best subject, and these programming symbols always trip you up!\n\nI mean, does `**` mean *\"Times, Times\"* or *\"To the power of\"*?\n\nLuckily, you can create the function `expression_out()` to write out the expressions for you!\n\nThe operators you'll need to use a...
[{"input": "\"8 != 5\"", "output": "[\"Eight Does Not Equal Five\"]", "fn_name": "expression_out"}, {"input": "\"6 ** 9\"", "output": "[\"Six To The Power Of Nine\"]", "fn_name": "expression_out"}, {"input": "\"2 / 2\"", "output": "[\"Two Divided By Two\"]", "fn_name": "expression_out"}, {"input": "\"5 = 5\"", "output"...
code_functional
[ { "content": "We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of substrings \"ab\" in the string and replace it with the string \"bba\". If we have no \"ab\" as a substring, our job is done. Print the minimum number of steps we should perform to make...
[{"input": "abaaaaaabaaaabbabbaaabbbbabababaaaaabbaabbaaaaabbbaababaaaaaaabbbbbaaaaabaababbabababbabbbbaabbaabbabbbabaabbaabbaaaaaab\n", "output": "235606597\n"}, {"input": "abaaaaaabaaaabbabbaaabbbbabababaaaaabbaabbaaaaabbbaababaaaaaaabbbbbaaaaabaababbabababbabbbbaabbaabbabbbabaabbaabbaaaaaab\n", "output": "235606597\...
code_stdio
[ { "content": "There is a $n \\times m$ grid. You are standing at cell $(1, 1)$ and your goal is to finish at cell $(n, m)$.\n\nYou can move to the neighboring cells to the right or down. In other words, suppose you are standing at cell $(x, y)$. You can:\n\nmove right to the cell $(x, y + 1)$ — it costs $x$ bur...
[{"input": "9\n1 1 0\n2 2 4\n2 2 3\n2 2 -2\n1 1 1\n100 100 11000\n2 3 7\n3 1 9\n2 6 11\n", "output": "YES\nNO\nYES\nNO\nNO\nNO\nNO\nNO\nYES\n"}, {"input": "9\n1 1 0\n2 2 4\n2 2 3\n2 2 -1\n2 1 1\n100 100 10000\n2 4 7\n3 1 9\n2 6 8\n", "output": "YES\nNO\nYES\nNO\nYES\nNO\nYES\nNO\nNO\n"}, {"input": "9\n1 1 0\n2 1 4\n2 2...
code_stdio
[ { "content": "A frog lives on the axis Ox and needs to reach home which is in the point n. She starts from the point 1. The frog can jump to the right at a distance not more than d. So, after she jumped from the point x she can reach the point x + a, where a is an integer from 1 to d.\n\nFor each point from 1 t...
[{"input": "100 11\n1000010100011100011011100000010011001111011110100100001011010100011011111001101101110110010110001101\n", "output": "10\n"}, {"input": "100 10\n1110110000000110000000101110100000111000001011100000100110010001110111001010101000011000000001011011\n", "output": "12\n"}, {"input": "100 11\n10000000001000...
code_stdio
[ { "content": "Sum all the numbers of the array (in F# and Haskell you get a list) except the highest and the lowest element (the value, not the index!).\n(The highest/lowest element is respectively only one element at each edge, even if there are more than one with the same value!)\nExample:\n```\n{ 6, 2, 1, 8,...
[{"input": "[-6, -20, -1, -10, -12]", "output": "[-28]", "fn_name": "sum_array"}, {"input": "[-6, 20, -1, 10, -12]", "output": "[3]", "fn_name": "sum_array"}, {"input": "[6, 0, 1, 10, 10]", "output": "[17]", "fn_name": "sum_array"}, {"input": "[6, 2, 1, 8, 10]", "output": "[16]", "fn_name": "sum_array"}, {"input": "[-3...
code_functional
[ { "content": "Bees Alice and Alesya gave beekeeper Polina famous card game \"Set\" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to ...
[{"input": "24 4\nSETS\nETES\nSSST\nESTE\nTSES\nSSES\nTESS\nSEEE\nETEE\nETSS\nSSEE\nESTT\nSTSS\nTTTT\nTEEE\nTSEE\nESET\nTTTE\nETTT\nSTEE\nSTTE\nESSS\nTEET\nTETE\n", "output": "31\n"}, {"input": "24 4\nSETS\nETES\nSSST\nESTE\nTSES\nSSES\nTESS\nEESE\nETEE\nETSS\nSSEE\nESTT\nSTSS\nTTTT\nTEEE\nTSEE\nESET\nTTTE\nETTT\nSTEE\...
code_stdio
[ { "content": "There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate.\n\nYou will given M pieces of information regarding the positions of these p...
[{"input": "10 0\n12 2 100\n7 18 010\n10 12 100", "output": "Yes\n"}, {"input": "10 0\n12 2 100\n7 18 011\n10 12 100", "output": "Yes\n"}, {"input": "10 0\n12 2 100\n7 18 011\n10 22 100", "output": "Yes\n"}, {"input": "10 0\n12 2 110\n7 18 011\n10 22 100", "output": "Yes\n"}, {"input": "10 0\n12 2 000\n11 13 100\n12 8 ...
code_stdio
[ { "content": "*** No Loops Allowed ***\n\nYou will be given an array (a) and a value (x). All you need to do is check whether the provided array contains the value, without using a loop.\n\nArray can contain numbers or strings. X can be either. Return true if the array contains the value, false if not. With str...
[{"input": "[66, \"codewars\", 11, \"alex loves pushups\"]\n\"alex loves pushups\"", "output": "[true]", "fn_name": "check"}, {"input": "[\"when's\", \"the\", \"next\", \"Katathon?\", 9, 7]\n\"Katathon?\"", "output": "[true]", "fn_name": "check"}, {"input": "[8, 7, 5, \"bored\", \"of\", \"writing\", \"tests\", 115]\n45...
code_functional
[ { "content": "You've got a list of program warning logs. Each record of a log stream is a string in this format: \"2012-MM-DD HH:MM:SS:MESSAGE\" (without the quotes). \n\nString \"MESSAGE\" consists of spaces, uppercase and lowercase English letters and characters \"!\", \".\", \",\", \"?\". String \"2012-MM-D...
[{"input": "60 3\n2012-03-16 16:15:25: Disk size is\n2012-03-16 16:15:25: Network failute\n2012-03-16 16:16:29: Cant write varlog\n2012-03-16 16:16:42: Unable to start process\n2012-03-16 16:16:43: Disk size is too small\n2012-03-16 16:16:53: Timeout detected\n", "output": "2012-03-16 16:16:43\n"}, {"input": "60 3\n201...
code_stdio
[ { "content": "Calculate the trace of a square matrix. A square matrix has `n` rows and `n` columns, where `n` is any integer > 0. The entries of the matrix can contain any number of integers. The function should return the calculated trace of the matrix, or `nil/None` if the array is empty or not square; you ca...
[{"input": "[[1, 2, 3], [4, 5, 6], [7, 8, 9]]", "output": "[15]", "fn_name": "trace"}, {"input": "[[1, 0, 0], [0, 1, 0], [0, 0, -2]]", "output": "[0]", "fn_name": "trace"}, {"input": "[[0, 0, 0], [0, 0, 0], [0, 0, 0]]", "output": "[0]", "fn_name": "trace"}, {"input": "[[1, 2], [1, 2], [1, 2]]", "output": "[null]", "fn_...
code_functional
[ { "content": "There are N towns in JOI, which are connected by M bidirectional roads. There are shopping malls in K towns, and the people go to one of those towns through the road to shop.\n\nDepending on the location of your home, you may have to travel long distances to go shopping, which is very inconvenient...
[{"input": "10 3 1\n1 2 5\n3 3 2\n3 1 1\n2", "output": "7\n"}, {"input": "11 3 1\n1 1 1\n2 3 0\n3 1 1\n1", "output": "1\n"}, {"input": "10 3 1\n1 2 2\n2 3 2\n3 1 1\n1", "output": "3\n"}, {"input": "10 3 1\n1 2 2\n2 3 2\n2 1 1\n1", "output": "3\n"}, {"input": "10 3 1\n1 2 3\n2 3 2\n3 1 1\n1", "output": "3\n"}, {"input":...
code_stdio
[ { "content": "If the strings are consecutive, you can replace the characters with a rule to shorten the string. For example, for the string AAAA, the expression @ 4A will compress one character. Create a program that restores the character string compressed by this rule to the original character string. However...
[{"input": "ab@5C1@8050\n@99,1=1@90", "output": "abCCCCC10000000050\n999999999,1=1000000000"}, {"input": "ab@5C2@8050\n@99,1=1@90", "output": "abCCCCC20000000050\n999999999,1=1000000000"}, {"input": "ab@5C1@8050\n@99+1<1@90", "output": "abCCCCC10000000050\n999999999+1<1000000000"}, {"input": "ab@5C1@8050\n@99,1=1@9/", ...
code_stdio
[ { "content": "Facetook is a well known social network website, and it will launch a new feature called Facetook Priority Wall. This feature will sort all posts from your friends according to the priority factor (it will be described).\n\nThis priority factor will be affected by three types of actions: \n\n * 1...
[{"input": "kmircqsffq\n14\nfrnf likes xgmmp's post\nfnfdpupayp commented on syz's post\nxefshpn commented on xgmmp's post\nm posted on gdwydzktok's wall\neskm likes pqmbnuc's post\npnqiapduhz likes zzqvjdz's post\nx likes nouuurc's post\nvnyxhoukuo posted on uhblapjab's wall\nblpjpxn likes zvwbger's post\nj posted on ...
code_stdio
[ { "content": "Mike has a frog and a flower. His frog is named Xaniar and his flower is named Abol. Initially(at time 0), height of Xaniar is h_1 and height of Abol is h_2. Each second, Mike waters Abol and Xaniar.\n\n [Image] \n\nSo, if height of Xaniar is h_1 and height of Abol is h_2, after one second height ...
[{"input": "999983\n651224 992349\n803017 393514\n258455 402487\n888310 244420\n", "output": "126531\n"}, {"input": "999983\n651224 992349\n803017 393514\n258455 402487\n888310 244420\n", "output": "126531\n"}, {"input": "1000000\n220036 846131\n698020 485511\n656298 242999\n766802 905433\n", "output": "5297\n"}, {"inp...
code_stdio
[ { "content": "You are given two non-negative integers L and R.\nWe will choose two integers i and j such that L \\leq i < j \\leq R.\nFind the minimum possible value of (i \\times j) \\mbox{ mod } 2019.\n\n-----Constraints-----\n - All values in input are integers.\n - 0 \\leq L < R \\leq 2 \\times 10^9\n\n----...
[{"input": "1999999216 1999999234\n", "output": "650\n"}, {"input": "1999999264 1999999270\n", "output": "26\n"}, {"input": "1999999266 1999999276\n", "output": "18\n"}, {"input": "1999997173 1999999190\n", "output": "0\n"}, {"input": "1999999262 1999999281\n", "output": "2\n"}, {"input": "1999999218 1999999237\n", "ou...
code_stdio
[ { "content": "Advanced Creative Mobile (ACM) has decided to develop a GUI application to be installed in a new portable computer.\n\nAs shown in the figure below, the GUI has a nested structure in which it has one main panel, several panels are arranged on it, and some panels are arranged on top of those panels...
[{"input": "5\n<main>10,10,190,150<menu>20,20,70,140</menu><primary>80,20,180,140</primary></main>\n9 10\n0 17\n40 190\n2 3\n130 80\n0", "output": "OUT OF MAIN PANEL 1\nOUT OF MAIN PANEL 1\nOUT OF MAIN PANEL 1\nOUT OF MAIN PANEL 1\nprimary 0\n"}, {"input": "5\n<main>10,10,190,150<menu>20,20,70,140</menu><primary>80,20,...
code_stdio
[ { "content": "A total of n depots are located on a number line. Depot i lies at the point x_i for 1 ≤ i ≤ n.\n\nYou are a salesman with n bags of goods, attempting to deliver one bag to each of the n depots. You and the n bags are initially at the origin 0. You can carry up to k bags at a time. You must collect...
[{"input": "4\n5 1\n1 2 3 4 5\n9 1\n-5 -10 -15 6 7 8 3 14 7\n5 1\n2 3 3 5 3\n4 5\n1000000000 1000000000 1000000010 1010010000\n", "output": "25\n135\n27\n1010010000\n"}, {"input": "4\n5 1\n0 2 3 4 5\n9 1\n-5 -10 -15 6 7 8 3 14 7\n5 1\n2 3 3 5 3\n4 5\n1000000000 1000000001 1000000010 1010010000\n", "output": "23\n135\n2...
code_stdio
[ { "content": "Snuke has an empty sequence a.\n\nHe will perform N operations on this sequence.\n\nIn the i-th operation, he chooses an integer j satisfying 1 \\leq j \\leq i, and insert j at position j in a (the beginning is position 1).\n\nYou are given a sequence b of length N. Determine if it is possible tha...
[{"input": "9\n1 1 1 1 2 1 2 3 2", "output": "1\n2\n2\n3\n1\n2\n1\n1\n1\n"}, {"input": "9\n1 1 1 2 1 1 2 3 2", "output": "1\n2\n2\n3\n1\n1\n2\n1\n1\n"}, {"input": "9\n1 1 1 1 2 1 4 3 2", "output": "1\n2\n1\n3\n2\n4\n1\n1\n1\n"}, {"input": "9\n1 1 1 2 2 1 4 3 2", "output": "1\n2\n1\n3\n2\n4\n2\n1\n1\n"}, {"input": "9\n1...
code_stdio
[ { "content": "Heidi found out that the Daleks have created a network of bidirectional Time Corridors connecting different destinations (at different times!). She suspects that they are planning another invasion on the entire Space and Time. In order to counter the invasion, she plans to deploy a trap in the Tim...
[{"input": "10 26\n9 5 277429172\n10 8 789225932\n5 2 992601916\n9 8 277294258\n8 6 245446241\n9 2 378979732\n7 1 895407000\n10 6 699661758\n1 9 865851152\n2 8 397672809\n7 10 756200111\n8 3 431547893\n5 6 465205287\n7 4 957301499\n3 4 308491540\n3 7 258504473\n10 5 282875145\n1 8 262659451\n5 4 981921705\n2 4 16048245...
code_stdio
[ { "content": "Once upon a time in the thicket of the mushroom forest lived mushroom gnomes. They were famous among their neighbors for their magic mushrooms. Their magic nature made it possible that between every two neighboring mushrooms every minute grew another mushroom with the weight equal to the sum of we...
[{"input": "62 47 14 888621154\n202 268 300 401 422 660 782 822 1164 1300 1571 1670 1713 1807 2677 2700 2747 2873 2956 3068 3798 4159 4221 4232 4485 4507 4803 5071 5161 5161 5595 5600 5623 5846 5867 5949 6140 6560 6727 6781 6873 7159 7218 7232 7241 7333 7369 7415 7486 7506 7538 7681 7781 8074 8783 8861 9208 9313 9339 9...
code_stdio
[ { "content": "In this Kata, you will be given two numbers, `a` and `b`, and your task is to determine if the first number `a` is divisible by `all` the prime factors of the second number `b`. For example: `solve(15,12) = False` because `15` is not divisible by all the prime factors of `12` (which include`2`).\n...
[{"input": "1000013\n7187762", "output": "[false]", "fn_name": "solve"}, {"input": "1000013\n7187761", "output": "[true]", "fn_name": "solve"}, {"input": "21\n2893406", "output": "[false]", "fn_name": "solve"}, {"input": "54\n2834359", "output": "[false]", "fn_name": "solve"}, {"input": "21\n2893401", "output": "[true]...
code_functional
[ { "content": "A team of three programmers is going to play a contest. The contest consists of $n$ problems, numbered from $1$ to $n$. Each problem is printed on a separate sheet of paper. The participants have decided to divide the problem statements into three parts: the first programmer took some prefix of th...
[{"input": "11 7 9\n4 8 9 12 14 16 19 21 22 23 27\n1 2 3 11 17 18 26\n5 6 7 10 13 15 20 24 25\n", "output": "15\n"}, {"input": "11 7 9\n4 8 9 12 14 16 19 21 22 23 27\n1 2 3 11 17 18 26\n5 6 7 10 13 15 20 24 25\n", "output": "15"}, {"input": "5 10 6\n14 3 6 12 21\n7 1 5 8 10 11 13 17 18 20\n9 2 4 15 16 19\n", "output": ...
code_stdio
[ { "content": "Mahmoud has n line segments, the i-th of them has length a_{i}. Ehab challenged him to use exactly 3 line segments to form a non-degenerate triangle. Mahmoud doesn't accept challenges unless he is sure he can win, so he asked you to tell him if he should accept the challenge. Given the lengths of ...
[{"input": "40\n740553458 532562042 138583675 75471987 487348843 476240280 972115023 103690894 546736371 1412788259 35356828 819948191 138721993 24257926 761587264 767176616 608310208 78275645 386063134 227581756 672567198 177797611 87579917 941781518 274774331 843623616 981221615 630282032 118843963 749160513 35413486...
code_stdio
[ { "content": "You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order:\n - Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster rec...
[{"input": "2 1000000000\n1 1\n1 00000000\n0 30000000\n2 164820504", "output": "1000000000\n"}, {"input": "4 1000000000\n1 1\n1 10000000\n1 30000000\n1 99999999\n", "output": "860000004\n"}, {"input": "4 1000000000\n1 1\n1 00000000\n1 30000000\n1 164820504", "output": "805179498\n"}, {"input": "4 1000000000\n1 1\n1 000...
code_stdio
[ { "content": "The king Copa often has been reported about the Codeforces site, which is rapidly getting more and more popular among the brightest minds of the humanity, who are using it for training and competing. Recently Copa understood that to conquer the world he needs to organize the world Codeforces tourn...
[{"input": "02.05.90\n08.03.50\n", "output": "YES\n"}, {"input": "29.02.80\n29.02.60\n", "output": "YES\n"}, {"input": "15.12.62\n17.12.21\n", "output": "YES\n"}, {"input": "08.07.20\n27.01.01\n", "output": "YES\n"}, {"input": "28.02.20\n11.01.29\n", "output": "YES\n"}, {"input": "06.08.91\n05.12.73\n", "output": "YES\...
code_stdio
[ { "content": "Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.\n\nAlice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made ...
[{"input": "34 33\n2 1\n3 2\n4 3\n5 2\n6 3\n7 2\n8 1\n9 7\n10 12\n11 7\n12 7\n13 8\n14 2\n15 10\n16 1\n17 2\n18 14\n19 1\n20 2\n21 16\n22 21\n23 1\n24 6\n25 2\n26 20\n27 5\n28 20\n29 2\n30 10\n31 14\n32 12\n33 15\n34 8\n", "output": "12\n"}, {"input": "34 33\n2 1\n3 2\n4 3\n5 2\n6 3\n7 2\n8 1\n9 7\n10 8\n11 7\n12 10\n1...
code_stdio
[ { "content": "problem\n\nYou are looking for a constellation in a picture of the starry sky. The photo always contains exactly one figure with the same shape, orientation, and size as the constellation you are looking for. However, there is a possibility that extra stars are shown in the photograph other than t...
[{"input": "5\n8 5\n6 4\n4 3\n7 10\n0 10\n10\n10 5\n2 7\n9 7\n8 10\n10 2\n1 2\n8 1\n6 7\n6 0\n0 0\n5\n904207 809784\n845370 244806\n499091 59863\n638406 182509\n435076 362268\n10\n757559 866424\n114810 239537\n519926 989458\n461089 424480\n674361 448440\n81851 150384\n459107 795405\n299682 6700\n254125 362183\n50795 54...
code_stdio
[ { "content": "Polycarp has created his own training plan to prepare for the programming contests. He will train for $n$ days, all days are numbered from $1$ to $n$, beginning from the first.\n\nOn the $i$-th day Polycarp will necessarily solve $a_i$ problems. One evening Polycarp plans to celebrate the equator....
[{"input": "69\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "35\n"}, {"input": "69\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
code_stdio
[ { "content": "A flow network is a directed graph which has a $source$ and a $sink$. In a flow network, each edge $(u, v)$ has a capacity $c(u, v)$. Each edge receives a flow, but the amount of flow on the edge can not exceed the corresponding capacity. Find the maximum flow from the $source$ to the $sink$.\n\nC...
[{"input": "6 2\n0 1 0\n0 2 1\n1 2 1\n1 3 1\n3 3 10", "output": "0\n"}, {"input": "6 2\n0 1 0\n0 2 1\n1 2 1\n1 0 1\n3 3 10", "output": "0\n"}, {"input": "6 2\n0 1 0\n0 2 1\n1 2 1\n1 0 1\n3 3 20", "output": "0\n"}, {"input": "6 2\n0 1 0\n0 2 1\n1 2 1\n1 0 1\n3 5 20", "output": "0\n"}, {"input": "6 2\n1 1 0\n0 2 1\n1 2 1...
code_stdio
[ { "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 2^{k} (k is an integer, k ≥ 0) units. A magica...
[{"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": "Vasya decided to write an anonymous letter cutting the letters out of a newspaper heading. He knows heading s1 and text s2 that he wants to send. Vasya can use every single heading letter no more than once. Vasya doesn't have to cut the spaces out of the heading — he just leaves some blank space t...
[{"input": "kKhuIwRPLCwPFfcnsyCfBdnsraGeOCcLTfXuGjqFSGPSAeDZJSS bXKFanNqWjpFnvRpWxHJspvisDlADJBioxXNbVoXeUedoPcNEpUyEeYxdJXhGzFAmpAiHotSVwbZQsuWjIVhVaEGgqbZHIoDpiEmjTtFylCwCkWWzUOoUfOHxEZvDwNpXhBWamHn\nK VpJjGhNbwCRhcfmNGVjewBFpEmPlIKeTuWiukDtEWpjgqciqglkyNfWrBLbGAKvlNWxaUelJmSlSoakSpRzePvJsshOsTYrMPXdxKpaShjyVIXGhRIAd...
code_stdio
[ { "content": "A programming contest will be held at White Tiger University this year as well. There are several questions in the contest, each of which is assigned a score according to the difficulty level.\n\nThe executive committee decided to calculate the score for each team based on the following rules, tak...
[{"input": "7\n-1 -1 19 1 0 4 -2", "output": "2\n"}, {"input": "7\n-1 -1 19 2 0 4 -2", "output": "2\n"}, {"input": "7\n-1 1 19 2 2 4 -1", "output": "2\n"}, {"input": "7\n-1 1 19 2 3 4 -1", "output": "3\n"}, {"input": "7\n-2 1 19 2 3 4 -1", "output": "3\n"}, {"input": "7\n-2 1 19 3 3 4 -1", "output": "3\n"}, {"input": "...
code_stdio
[ { "content": "Find the sum of the weights of edges of the Minimum-Cost Arborescence with the root r for a given weighted directed graph G = (V, E).\n\nConstraints\n\n* 1 ≤ |V| ≤ 100\n* 0 ≤ |E| ≤ 1,000\n* 0 ≤ wi ≤ 10,000\n* G has arborescence(s) with the root r\n\nInput\n\n\n|V| |E| r\ns0 t0 w0\ns1 t1 w1\n:\ns|E...
[{"input": "6 10 0\n0 2 14\n0 0 1\n0 3 5\n1 4 7\n2 1 6\n1 3 2\n4 1 3\n4 2 2\n1 3 10\n0 5 3", "output": "32\n"}, {"input": "6 10 0\n0 2 14\n0 0 1\n0 3 5\n1 4 7\n2 1 6\n1 3 2\n4 1 3\n4 2 2\n1 3 0\n0 5 3", "output": "30\n"}, {"input": "6 10 0\n0 2 14\n0 0 1\n0 3 5\n1 4 7\n2 1 6\n1 2 2\n4 1 3\n4 2 2\n1 3 1\n0 5 3", "output...
code_stdio
[ { "content": "Create a function that takes in the sum and age difference of two people, calculates their individual ages, and returns a pair of values (oldest age first) if those exist or `null/None` if:\n\n* `sum < 0`\n* `difference < 0`\n* Either of the calculated ages come out to be negative\n\nWrite Python ...
[{"input": "63\n14", "output": "[[38.5, 24.5]]", "fn_name": "get_ages"}, {"input": "70\n10", "output": "[[40, 30]]", "fn_name": "get_ages"}, {"input": "24\n4", "output": "[[14, 10]]", "fn_name": "get_ages"}, {"input": "30\n6", "output": "[[18, 12]]", "fn_name": "get_ages"}, {"input": "80\n80", "output": "[[80, 0]]", "f...
code_functional
[ { "content": "You've got an array a, consisting of n integers. The array elements are indexed from 1 to n. Let's determine a two step operation like that:\n\n 1. First we build by the array a an array s of partial sums, consisting of n elements. Element number i (1 ≤ i ≤ n) of array s equals <image>. The opera...
[{"input": "42 42\n42 42 42 42 42 42 42 42 42 42 24 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 14 17 42 10 42 42 42 42 42 42 42 42 42 42 42 42\n", "output": "42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012574 397605357 289211244 684954865 738091104 190263863 460871887 121426337 37...
code_stdio
[ { "content": "You need to play around with the provided string (s).\n\nMove consonants forward 9 places through the alphabet.\nIf they pass 'z', start again at 'a'.\n\nMove vowels back 5 places through the alphabet.\nIf they pass 'a', start again at 'z'.\nFor our Polish friends this kata does not count 'y' as a...
[{"input": "\"returnofthespacecamel\"", "output": "[\"aatpawnftqabyvbabvvau\"]", "fn_name": "vowel_back"}, {"input": "\"bringonthebootcamp\"", "output": "[\"kaiwpnwtqaknntbvvy\"]", "fn_name": "vowel_back"}, {"input": "\"weneedanofficedog\"", "output": "[\"fawaaavwnffibaanp\"]", "fn_name": "vowel_back"}, {"input": "\"ex...
code_functional
[ { "content": "Find the difference of two sets $A = \\\\{a_0, a_1, ..., a_{n-1}\\\\}$ and $B = \\\\{b_0, b_1, ..., b_{m-1}\\\\}$, $A - B$.\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": "5\n-1 2 4 13 17\n1\n-2 2", "output": "-1\n2\n4\n13\n17\n"}, {"input": "5\n-1 2 4 13 25\n1\n-2 1", "output": "-1\n2\n4\n13\n25\n"}, {"input": "5\n-2 2 3 9 14\n0\n-1 28", "output": "-2\n2\n3\n9\n14\n"}, {"input": "5\n-2 2 4 9 14\n0\n-1 28", "output": "-2\n2\n4\n9\n14\n"}, {"input": "5\n-1 2 3 5 27\n0\n0 18", ...
code_stdio
[ { "content": "Welcome! Everything is fine.\n\nYou have arrived in The Medium Place, the place between The Good Place and The Bad Place. You are assigned a task that will either make people happier or torture them for eternity.\n\nYou have a list of $k$ pairs of people who have arrived in a new inhabited neighbo...
[{"input": "2\n3\n1 2 3\n3 2 4\n2 4 3\n4 5 6\n5 6 5\n2\n1 2 1\n1 3 2\n1 4 3\n", "output": "15 33\n6 6\n"}, {"input": "2\n3\n1 2 0\n3 2 4\n2 4 3\n4 5 6\n5 6 5\n2\n1 2 1\n1 3 2\n1 4 3\n", "output": "12 30\n6 6\n"}, {"input": "2\n3\n1 2 0\n3 1 4\n2 4 3\n4 5 6\n5 6 5\n2\n1 2 1\n1 3 2\n1 4 2\n", "output": "12 30\n5 5\n"}, {...
code_stdio
[ { "content": "Alice and Bob are decorating a Christmas Tree. \n\nAlice wants only $3$ types of ornaments to be used on the Christmas Tree: yellow, blue and red. They have $y$ yellow ornaments, $b$ blue ornaments and $r$ red ornaments.\n\nIn Bob's opinion, a Christmas Tree will be beautiful if: the number of bl...
[{"input": "100 100 100\n", "output": "297\n"}, {"input": "156 101 100\n", "output": "297\n"}, {"input": "156 111 100\n", "output": "297\n"}, {"input": "100 100 100\n", "output": "297"}, {"input": "99 100 100\n", "output": "297\n"}, {"input": "99 101 100\n", "output": "297\n"}, {"input": "65 122 115\n", "output": "198\...
code_stdio
[ { "content": "New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $h$ hours and $m$ minutes, where $0 \\le hh < 24$ and $0 \\le mm < 60$. We use 24-hour time format!\n\nYour task is to find the number of minutes before the New Year....
[{"input": "5\n3 55\n22 30\n21 10\n20 21\n19 59\n", "output": "1205\n90\n170\n219\n241\n"}, {"input": "5\n4 55\n22 30\n21 10\n20 21\n19 59\n", "output": "1145\n90\n170\n219\n241\n"}, {"input": "5\n15 14\n22 45\n21 2\n0 21\n19 59\n", "output": "526\n75\n178\n1419\n241\n"}, {"input": "5\n14 14\n22 45\n21 2\n0 21\n19 59\n...
code_stdio
[ { "content": "You are given a rooted tree. Each vertex contains a_i tons of gold, which costs c_i per one ton. Initially, the tree consists only a root numbered 0 with a_0 tons of gold and price c_0 per ton.\n\nThere are q queries. Each query has one of two types: \n\n 1. Add vertex i (where i is an index of q...
[{"input": "5 5 2\n2 0 2\n1 0 3 4\n2 2 4\n1 0 1 3\n2 4 2\n", "output": "\n2 4\n4 10\n1 3\n"}, {"input": "5 5 2\n2 0 2\n1 0 1 4\n2 2 4\n1 0 1 3\n2 4 2\n", "output": "2 4\n4 10\n1 3\n"}, {"input": "5 10 2\n2 0 2\n1 0 3 4\n2 2 4\n1 0 1 3\n2 4 2\n", "output": "2 4\n4 8\n2 4\n"}, {"input": "5 3 2\n2 0 2\n1 0 3 4\n2 2 4\n1 0...
code_stdio
[ { "content": "Bajtek, known for his unusual gifts, recently got an integer array $x_0, x_1, \\ldots, x_{k-1}$.\n\nUnfortunately, after a huge array-party with his extraordinary friends, he realized that he'd lost it. After hours spent on searching for a new toy, Bajtek found on the arrays producer's website ano...
[{"input": "100\n57 81 176 211 251 311 346 404 469 506 563 587 682 717 757 817 852 910 975 1012 1069 1093 1188 1223 1263 1323 1358 1416 1481 1518 1575 1599 1694 1729 1769 1829 1864 1922 1987 2024 2081 2105 2200 2235 2275 2335 2370 2428 2493 2530 2587 2611 2706 2741 2781 2841 2876 2934 2999 3036 3093 3117 3212 3247 3287...
code_stdio
[ { "content": "You are given an integer array $a$ of length $n$.\n\nDoes there exist an array $b$ consisting of $n+1$ positive integers such that $a_i=\\gcd (b_i,b_{i+1})$ for all $i$ ($1 \\leq i \\leq n$)?\n\nNote that $\\gcd(x, y)$ denotes the greatest common divisor (GCD) of integers $x$ and $y$.\n\n\n-----In...
[{"input": "3\n7\n48 27 99 27 93 72 2\n5\n86 73 29 1 37\n9\n45 59 22 6 75 4 14 57 23\n", "output": "NO\nYES\nNO\n"}, {"input": "4\n1\n343\n2\n4 2\n3\n4 2 4\n4\n1 1 1 1\n", "output": "YES\nYES\nNO\nYES\n"}, {"input": "1\n8\n157 5487 4421 1774 4662 5343 1366 5393\n", "output": "NO\n"}, {"input": "1\n3\n101 1 101\n", "out...
code_stdio
[ { "content": "You are given two integers $n$ and $k$.\n\nYour task is to construct such a string $s$ of length $n$ that for each $i$ from $1$ to $k$ there is at least one $i$-th letter of the Latin alphabet in this string (the first letter is 'a', the second is 'b' and so on) and there are no other letters exce...
[{"input": "66\n1 1\n1 1\n2 1\n1 1\n1 1\n1 1\n1 1\n2 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n2 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n2 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\...
code_stdio
[ { "content": "Consider the sequence `a(1) = 7, a(n) = a(n-1) + gcd(n, a(n-1)) for n >= 2`: \n\n`7, 8, 9, 10, 15, 18, 19, 20, 21, 22, 33, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 69, 72, 73...`.\n\nLet us take the differences between successive elements of the sequence and\nget a second sequence `g: 1, 1, 1, ...
[{"input": "100000", "output": "[99955]", "fn_name": "count_ones"}, {"input": "10000", "output": "[9968]", "fn_name": "count_ones"}, {"input": "1000", "output": "[975]", "fn_name": "count_ones"}, {"input": "200", "output": "[184]", "fn_name": "count_ones"}, {"input": "100", "output": "[90]", "fn_name": "count_ones"}, {...
code_functional
[ { "content": "This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.\n\nAlice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of n stations, enumerated from 1 through n. The train...
[{"input": "100 50\n29 35\n10 75\n29 34\n10 87\n29 13\n29 38\n41 21\n10 6\n29 94\n10 47\n31 27\n41 24\n41 8\n10 93\n41 52\n41 36\n31 32\n85 81\n31 32\n41 79\n41 99\n85 88\n41 25\n31 68\n41 93\n10 87\n85 97\n41 85\n10 64\n10 68\n85 22\n10 45\n85 15\n10 16\n10 21\n41 66\n29 68\n41 96\n29 34\n10 22\n41 72\n85 54\n29 48\n1...
code_stdio
[ { "content": "### Longest Palindrome\n\nFind the length of the longest substring in the given string `s` that is the same in reverse. \n\nAs an example, if the input was “I like racecars that go fast”, the substring (`racecar`) length would be `7`. \n\nIf the length of the input string is `0`, the return...
[{"input": "\"FourscoreandsevenyearsagoourfaathersbroughtforthonthiscontainentanewnationconceivedinzLibertyanddedicatedtothepropositionthatallmenarecreatedequalNowweareengagedinagreahtcivilwartestingwhetherthatnaptionoranynartionsoconceivedandsodedicatedcanlongendureWeareqmetonagreatbattlefiemldoftzhatwarWehavecometode...
code_functional
[ { "content": "You have a string of decimal digits s. Let's define bij = si·sj. Find in matrix b the number of such rectangles that the sum bij for all cells (i, j) that are the elements of the rectangle equals a in each rectangle.\n\nA rectangle in a matrix is a group of four integers (x, y, z, t) (x ≤ y, z ≤ t...
[{"input": "700\n100101011011001100111101100101000100000000011001111000111110001011011100010110000000000100100000001100000011110011101110011101101110111011011100001001101011000100000000000110001000101001100011111110011010101011010100010100001011011111001011000101001101000111010100110000100100110011111100010111100010000...
code_stdio
[ { "content": "Let us denote by f(x, m) the remainder of the Euclidean division of x by m.\nLet A be the sequence that is defined by the initial value A_1=X and the recurrence relation A_{n+1} = f(A_n^2, M).\nFind \\displaystyle{\\sum_{i=1}^N A_i}.\n\n-----Constraints-----\n - 1 \\leq N \\leq 10^{10}\n - 0 \\leq...
[{"input": "10000000000 99201 99975\n", "output": "992010000000000\n"}, {"input": "9999999995 82382 99996\n", "output": "309280000028478\n"}, {"input": "9999999997 38566 99996\n", "output": "309280000067758\n"}, {"input": "9999999999 91639 99996\n", "output": "463120000035189\n"}, {"input": "8376384666 27793 31932\n", ...
code_stdio
[ { "content": "A string $s$ of length $n$ can be encrypted by the following algorithm: iterate over all divisors of $n$ in decreasing order (i.e. from $n$ to $1$), for each divisor $d$, reverse the substring $s[1 \\dots d]$ (i.e. the substring which starts at position $1$ and ends at position $d$). \n\nFor exa...
[{"input": "100\nedykhvzcntljuuoqghptioetqnfllwekzohiuaxelgecabvsbibgqodqxvyfkbyjwtgbyhvssntinkwsinwsmalusiwnjmtcoovf\n", "output": "fvooctmjnwisulamswniswknitnssvhybgtwjybkfyvxqdoqgbqteoitnczvkyedhljuuoqghptnfllwekzohiuaxelgecabvsbi\n"}, {"input": "100\nooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo...
code_stdio
[ { "content": "Chef Palin, as his name suggests, is always very interested in palindromic strings. Recently, he made a pretty interesting discovery on palindromes and that made him feel really Lucky. He came across something known as Lucky Palindromes. He defines a string as being a lucky palindrome if it is a p...
[{"input": "3\nlatbcdkfy\nfeicedocljbux\naaaaaaba", "output": "luckykcul 8\nfluckyoykculf 10\nunlucky\n"}, {"input": "3\nytkdadfbl\ntobjlcedechwf\naabaaaba", "output": "luckykcul 8\nfluckyeykculf 10\nunlucky\n"}, {"input": "3\nytkdadfbl\ntobjlcfdechwf\naabaaaba", "output": "luckykcul 8\nfluckyfykculf 10\nunlucky\n"}, {...
code_stdio
[ { "content": "William has an array of $n$ integers $a_1, a_2, \\dots, a_n$. In one move he can swap two neighboring items. Two items $a_i$ and $a_j$ are considered neighboring if the condition $|i - j| = 1$ is satisfied.\n\nWilliam wants you to calculate the minimal number of swaps he would need to perform to m...
[{"input": "5\n3\n2 4 6\n5\n4 4 4 4 4\n5\n1 3 5 10 12\n5\n1 1 1 1 1\n5\n4 8 10 6 2\n", "output": "-1\n-1\n3\n-1\n-1\n"}, {"input": "5\n3\n2 4 12\n5\n4 4 4 4 4\n5\n1 2 5 14 9\n5\n2 2 0 1 2\n5\n4 0 10 6 2\n", "output": "-1\n-1\n0\n-1\n-1\n"}, {"input": "5\n3\n2 4 6\n5\n4 4 4 4 4\n5\n1 3 5 7 12\n5\n1 1 1 1 1\n5\n4 8 10 6 ...
code_stdio
[ { "content": "Famous Brazil city Rio de Janeiro holds a tennis tournament and Ostap Bender doesn't want to miss this event. There will be n players participating, and the tournament will follow knockout rules from the very first game. That means, that if someone loses a game he leaves the tournament immediately...
[{"input": "1000000000000000000\n", "output": "85\n"}, {"input": "1000000000000000000\n", "output": "85\n"}, {"input": "123456789123456789\n", "output": "81\n"}, {"input": "679891637638612257\n", "output": "84\n"}, {"input": "679891637638612258\n", "output": "85\n"}, {"input": "679891637638612259\n", "output": "85\n"},...
code_stdio
[ { "content": "There are N students in a school.\nWe will divide these students into some groups, and in each group they will discuss some themes.\nYou think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students...
[{"input": "1000\n", "output": "333\n"}, {"input": "303\n", "output": "101\n"}, {"input": "807\n", "output": "269\n"}, {"input": "596\n", "output": "198\n"}, {"input": "604\n", "output": "201\n"}, {"input": "296\n", "output": "98\n"}, {"input": "100\n", "output": "33\n"}, {"input": "8\n", "output": "2\n"}, {"input": "2...
code_stdio
[ { "content": "Does the card fit in a snack? (Are Cards Snacks?)\n\nsquare1001 You have $ N $ cards.\n\nEach of these cards has an integer written on it, and the integer on the $ i $ th card is $ A_i $.\n\nsquare1001 Your random number today is $ K $. square1001 You want to choose some of these $ N $ cards so th...
[{"input": "0 9\n22 11 57 2 -1", "output": "0\n"}, {"input": "0 9\n10 11 57 2 -1", "output": "0\n"}, {"input": "10 9\n18 6 37 2 0", "output": "0\n"}, {"input": "0 10\n22 6 57 2 0", "output": "0\n"}, {"input": "0 10\n26 6 57 2 0", "output": "0\n"}, {"input": "0 10\n26 6 57 2 1", "output": "0\n"}, {"input": "7 9\n18 6 23...
code_stdio
[ { "content": "Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.\n\nIn Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day.\n\nDu will chat in the group for n days. On the i-th day:\n\n * If Du can speak...
[{"input": "100 61 71\n11 18 0 47 33 75 91 13 8 21 73 64 50 97 62 50 2 36 68 32 64 74 32 77 81 41 23 44 40 36 45 33 21 68 57 79 75 23 67 37 99 27 30 56 75 62 75 63 46 19 79 42 11 66 21 25 2 12 89 48 75 7 57 85 80 14 82 29 66 47 29 10 1 84 79 39 33 81 73 51 80 67 52 25 38 68 57 53 38 83 83 3 86 29 50 46 3 68 88 10\n", "...
code_stdio
[ { "content": "The only difference between problems C1 and C2 is that all values in input of problem C1 are distinct (this condition may be false for problem C2).\n\nYou are given a sequence $a$ consisting of $n$ integers.\n\nYou are making a sequence of moves. During each move you must take either the leftmost ...
[{"input": "93\n6 6 10 10 8 4 7 10 2 3 4 10 7 2 8 8 4 2 4 4 7 7 3 2 3 1 5 3 7 2 4 9 10 8 10 5 1 6 2 1 10 3 5 6 6 9 3 10 1 10 1 6 2 3 8 7 1 5 4 10 4 3 5 8 8 1 3 8 2 3 10 7 2 4 5 2 6 4 10 4 4 8 5 1 6 3 1 9 5 4 9 4 3\n", "output": "4\nRRLR\n"}, {"input": "93\n6 6 10 10 9 4 7 10 2 3 4 10 7 2 8 8 4 2 4 4 7 7 3 2 3 1 5 3 7 2...
code_stdio
[ { "content": "Read problems statements in Russian here \nPolo, the Penguin, has a lot of tests tomorrow at the university.\nHe knows that there are N different questions that will be on the tests. For each question i (i = 1..N), he knows C[i] - the number of tests that will contain this question, P[i] - the num...
[{"input": "1\n3 20\n1 -2 0\n6 4 8\n4 -1 3", "output": "24\n"}, {"input": "1\n3 12\n1 0 1\n1 3 14\n13 4 3", "output": "52\n"}, {"input": "1\n3 7\n0 -1 1\n4 0 5\n12 5 3", "output": "60\n"}, {"input": "1\n3 7\n1 1 0\n2 3 20\n3 11 3", "output": "34\n"}, {"input": "1\n3 7\n1 2 3\n1 3 5\n9 12 3", "output": "110\n"}, {"input...
code_stdio
[ { "content": "There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $n$ different matryoshkas. Any matryoshka is a figure of volume $out_i$ with an empty space inside of volume $in_i$ (of course, $out_i > in_i$).\...
[{"input": "20\n51 47\n46 42\n25 22\n41 31\n11 2\n27 24\n18 13\n49 45\n16 11\n19 14\n10 1\n30 27\n10 1\n41 31\n16 11\n10 1\n41 31\n41 31\n31 28\n49 45\n", "output": "256\n"}, {"input": "20\n51 47\n46 42\n25 22\n41 31\n11 2\n27 24\n18 13\n49 45\n16 11\n19 14\n10 1\n30 27\n10 1\n41 31\n16 11\n10 1\n41 31\n41 31\n31 28\n4...
code_stdio
[ { "content": "There are N computers and N sockets in a one-dimensional world. The coordinate of the i-th computer is a_i, and the coordinate of the i-th socket is b_i. It is guaranteed that these 2N coordinates are pairwise distinct.\n\nSnuke wants to connect each computer to a socket using a cable. Each socket...
[{"input": "3\n3\n4\n18\n11\n0\n10", "output": "1\n"}, {"input": "3\n3\n4\n18\n20\n0\n10", "output": "1\n"}, {"input": "3\n3\n10\n8\n7\n0\n10", "output": "1\n"}, {"input": "3\n3\n10\n9\n7\n0\n10", "output": "1\n"}, {"input": "3\n3\n11\n8\n7\n0\n10", "output": "1\n"}, {"input": "3\n5\n10\n9\n7\n0\n10", "output": "1\n"},...
code_stdio
[ { "content": "You love coffee and want to know what beans you can afford to buy it.\n\nThe first argument to your search function will be a number which represents your budget.\n\nThe second argument will be an array of coffee bean prices.\n\nYour 'search' function should return the stores that sell coffee with...
[{"input": "14\n[13, 15, 14, 14, 15, 13]", "output": "[\"13,13,14,14\"]", "fn_name": "search"}, {"input": "14\n[7, 3, 23, 9, 14, 20, 7]", "output": "[\"3,7,7,9,14\"]", "fn_name": "search"}, {"input": "24\n[2.7, 0, 100.9, 1, 5.5]", "output": "[\"0,1,2.7,5.5\"]", "fn_name": "search"}, {"input": "14\n[17, 33, 23, 19, 19, ...
code_functional
[ { "content": "For a positive integer n\n\n* If n is even, divide by 2.\n* If n is odd, multiply by 3 and add 1.\n\n\n\nIf you repeat the above operation, the result will be 1. A problem called \"Colatz conjecture\" is that repeating this operation for any positive integer n will always result in 1. This problem...
[{"input": "3\n1043\n0", "output": "7\n124\n"}, {"input": "3\n3340\n0", "output": "7\n136\n"}, {"input": "3\n109\n0", "output": "7\n113\n"}, {"input": "3\n440\n0", "output": "7\n115\n"}, {"input": "3\n125\n0", "output": "7\n108\n"}, {"input": "3\n221\n0", "output": "7\n114\n"}, {"input": "3\n259\n0", "output": "7\n122\...
code_stdio
[ { "content": "Your task is to find the first element of an array that is not consecutive.\n\nBy not consecutive we mean not exactly 1 larger than the previous element of the array.\n\nE.g. If we have an array `[1,2,3,4,6,7,8]` then `1` then `2` then `3` then `4` are all consecutive but `6` is not, so that's the...
[{"input": "[1, 2, 3, 4, 5, 6, 7, 8]", "output": "[null]", "fn_name": "first_non_consecutive"}, {"input": "[4, 5, 6, 7, 8, 9, 11]", "output": "[11]", "fn_name": "first_non_consecutive"}, {"input": "[1, 2, 3, 4, 6, 7, 8]", "output": "[6]", "fn_name": "first_non_consecutive"}, {"input": "[4, 6, 7, 8, 9, 11]", "output": "...
code_functional
[ { "content": "Baby is getting his frst tooth. This means more sleepless nights, but with the fun of feeling round his gums and trying to guess which will be first out! \n\nProbably best have a sweepstake with your friends - because you have the best chance of knowing. You can feel the gums and see where the rai...
[{"input": "[1, 2, 5, 7, 1, 0, 9]", "output": "[6]", "fn_name": "first_tooth"}, {"input": "[20, 9, 16, 19]", "output": "[0]", "fn_name": "first_tooth"}, {"input": "[1, 1, 1, 1]", "output": "[-1]", "fn_name": "first_tooth"}, {"input": "[1, 2, 3, 4]", "output": "[3]", "fn_name": "first_tooth"}, {"input": "[1, 2, 6, 4]", ...
code_functional
[ { "content": "Let's define $p_i(n)$ as the following permutation: $[i, 1, 2, \\dots, i - 1, i + 1, \\dots, n]$. This means that the $i$-th permutation is almost identity (i.e. which maps every element to itself) permutation but the element $i$ is on the first position. Examples: $p_1(4) = [1, 2, 3, 4]$; $p_2(...
[{"input": "30 5\n4 2 8 3 4\n", "output": "14 16 16 14 12 12 12 8 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14\n"}, {"input": "30 5\n4 4 8 3 4\n", "output": "10 10 14 14 8 8 8 8 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10\n"}, {"input": "25 5\n4 2 8 3 4\n", "output": "14 16 16...
code_stdio
[ { "content": "Aizuwakamatsu City is known as the \"City of History\". About 400 years ago, the skeleton of the castle town was created by Gamo Ujisato, but after that, it became the central city of the Aizu clan 230,000 stones, whose ancestor was Hoshina Masayuki, the half-brother of Tokugawa's third shogun Iem...
[{"input": "4\n4\n0,1,1500\n0,2,2000\n1,2,600\n2,3,500\n0", "output": "23\n"}, {"input": "4\n4\n0,1,1500\n0,2,2000\n1,2,600\n2,3,400\n0", "output": "22\n"}, {"input": "4\n4\n0,1,0500\n0,2,2000\n0,2,600\n2,3,400\n0", "output": "12\n"}, {"input": "4\n4\n0,1,0400\n0002,2,0\n0,2,600\n2,3,400\n0", "output": "11\n"}, {"input...
code_stdio
[ { "content": "Takahashi is practicing shiritori alone again today.\nShiritori is a game as follows:\n - In the first turn, a player announces any one word.\n - In the subsequent turns, a player announces a word that satisfies the following conditions:\n - That word is not announced before.\n - The first charact...
[{"input": "100\nlkykrymhey\nyujwmjhnzx\nxgmkqgsajk\nkkvqjyapln\nnkcubvbxdx\nxheccrzfne\neqeizvicxx\nxesnssfeuz\nzsjdhxndds\nsuvxanfkpe\neodirlsywl\nlmiwshvenl\nluomflsyiq\nqcjuajhxme\nelfadfvxvm\nmknedshbyv\nvnboqueaai\niwexnqgqvj\njzfofokvkg\nggzhwrtktd\nderapdnumy\nyfobbqcozo\noivhkngvyy\nytjgsdfnos\nslrxpzfenf\nfhw...
code_stdio
[ { "content": "The Little Elephant very much loves sums on intervals.\n\nThis time he has a pair of integers l and r (l ≤ r). The Little Elephant has to find the number of such integers x (l ≤ x ≤ r), that the first digit of integer x equals the last one (in decimal notation). For example, such numbers as 101, 4...
[{"input": "100000000000000000 1000000000000000000\n", "output": "90000000000000000\n"}, {"input": "645762257531682046 885295120956158518\n", "output": "23953286342447648\n"}, {"input": "819875140559301752 946247219812473271\n", "output": "12637207925317152\n"}, {"input": "522842183413115088 853628713003942530\n", "out...
code_stdio
[ { "content": "Chef has N subordinates. In order to complete a very important order he will choose exactly K of them. He can't choose less than K since it will be not enough to complete the order in time. On the other hand if he chooses more than K subordinates he can't control them during the operation. Help hi...
[{"input": "3\n5 2\n10 4\n10 5", "output": "10\n210\n252\n"}, {"input": "3\n5 2\n19 6\n9 3", "output": "10\n27132\n84\n"}, {"input": "3\n5 2\n19 9\n9 3", "output": "10\n92378\n84\n"}, {"input": "3\n9 1\n2 5\n20 12", "output": "9\n0\n125970\n"}, {"input": "3\n8 1\n2 9\n20 12", "output": "8\n0\n125970\n"}, {"input": "3\n...
code_stdio
[ { "content": "Complete the function which takes two arguments and returns all numbers which are divisible by the given divisor. First argument is an array of `numbers` and the second is the `divisor`.\n\n## Example\n\n```python\ndivisible_by([1, 2, 3, 4, 5, 6], 2) == [2, 4, 6]\n```\n\nWrite Python code to solve...
[{"input": "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n1", "output": "[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]", "fn_name": "divisible_by"}, {"input": "[1, 2, 3, 4, 5, 6]\n2", "output": "[[2, 4, 6]]", "fn_name": "divisible_by"}, {"input": "[0, 1, 2, 3, 4, 5, 6]\n4", "output": "[[0, 4]]", "fn_name": "divisible_by"}, {"input": "[1,...
code_functional
[ { "content": "For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.\n\n* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.\n* find($x$): Report the number of $x$ in $S$ (0 or 1).\n* delete($x$): Delete $x...
[{"input": "8\n0 1\n0 10\n0 4\n0 2\n1 0\n0 7\n0 3\n0 2", "output": "1\n2\n3\n4\n0\n5\n6\n6\n"}, {"input": "8\n0 1\n0 7\n0 4\n0 2\n1 0\n0 7\n0 3\n0 2", "output": "1\n2\n3\n4\n0\n4\n5\n5\n"}, {"input": "8\n0 0\n0 0\n0 4\n1 2\n1 1\n1 2\n1 0\n1 2", "output": "1\n1\n2\n0\n0\n0\n1\n0\n"}, {"input": "8\n0 2\n0 3\n0 2\n2 4\n1 ...
code_stdio
[ { "content": "George woke up and saw the current time s on the digital clock. Besides, George knows that he has slept for time t. \n\nHelp George! Write a program that will, given time s and t, determine the time p when George went to bed. Note that George could have gone to bed yesterday relatively to the curr...
[{"input": "05:50\n05:44\n", "output": "00:06\n"}, {"input": "00:00\n01:00\n", "output": "23:00\n"}, {"input": "00:01\n00:00\n", "output": "00:01\n"}, {"input": "23:59\n23:59\n", "output": "00:00\n"}, {"input": "23:44\n23:55\n", "output": "23:49\n"}, {"input": "00:00\n13:12\n", "output": "10:48\n"}, {"input": "12:00\n2...
code_stdio
[ { "content": "We need a function (for commercial purposes) that may perform integer partitions with some constraints.\nThe function should select how many elements each partition should have.\nThe function should discard some \"forbidden\" values in each partition.\nSo, create ```part_const()```, that receives ...
[{"input": "15\n5\n3", "output": "[15]", "fn_name": "part_const"}, {"input": "15\n5\n4", "output": "[19]", "fn_name": "part_const"}, {"input": "15\n3\n3", "output": "[13]", "fn_name": "part_const"}, {"input": "10\n3\n2", "output": "[4]", "fn_name": "part_const"}, {"input": "10\n3\n0", "output": "[8]", "fn_name": "part_...
code_functional
[ { "content": "You are given a permutation P_1 ... P_N of the set {1, 2, ..., N}.\n\nYou can apply the following operation to this permutation, any number of times (possibly zero):\n\n* Choose two indices i,j (1 ≦ i < j ≦ N), such that j - i ≧ K and |P_i - P_j| = 1. Then, swap the values of P_i and P_j.\n\n\n\nA...
[{"input": "8 2\n4 5 7 8 3 1 2 6", "output": "1\n2\n3\n6\n5\n4\n7\n8\n"}, {"input": "8 6\n4 5 7 8 3 1 2 6", "output": "4\n5\n7\n8\n3\n1\n2\n6\n"}, {"input": "8 5\n4 5 7 8 3 1 2 6", "output": "4\n5\n6\n8\n3\n1\n2\n7\n"}, {"input": "8 1\n4 5 7 8 3 1 2 6", "output": "1\n2\n3\n4\n5\n6\n7\n8\n"}, {"input": "8 4\n4 5 7 8 3 1...
code_stdio
[ { "content": "Bob is a competitive programmer. He wants to become red, and for that he needs a strict training regime. He went to the annual meeting of grandmasters and asked $n$ of them how much effort they needed to reach red.\n\n\"Oh, I just spent $x_i$ hours solving problems\", said the $i$-th of them. \n\n...
[{"input": "15\n5318008\n379009\n06\n79153975193751375917591379919397337913333535330\n791539751937513759175913799193973379133301353533\n123456789023487138475693874561834576138495713485673485364857638475673465873457346581495713641\n7915397519375137511917591379919397337913333535330\n3155355553535353532535535833353535\n13...
code_stdio
[ { "content": "Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other.\n\nGalya doesn't know the ships location. She can shoot to some ce...
[{"input": "100 2 1 11\n0100000100000000000000001000000000010001100000000000101000000000000000000000001000001000010000000000\n", "output": "88\n1 3 4 5 6 7 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 27 28 29 30 31 32 33 34 35 37 38 39 42 43 44 45 46 47 48 49 50 51 52 54 56 57 58 59 60 61 62 63 64 65 66 67 68 69 ...
code_stdio
[ { "content": "Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.\nThe bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)\nAssuming that nothing other than the interest affects Takahashi's balance, in how many years does the bala...
[{"input": "1000000000000000000\n", "output": "3760\n"}, {"input": "822981260158260822\n", "output": "3740\n"}, {"input": "779547116602436626\n", "output": "3735\n"}, {"input": "578223540024980345\n", "output": "3705\n"}, {"input": "335408917861649372\n", "output": "3650\n"}, {"input": "974755271730884810\n", "output":...
code_stdio
[ { "content": "Create a program that will return whether an input value is a str, int, float, or bool. Return the name of the value.\n\n### Examples\n- Input = 23 --> Output = int\n- Input = 2.3 --> Output = float\n- Input = \"Hello\" --> Output = str\n- Input = True --> Output = bool\n\nWrite Python code to sol...
[{"input": "{\"name\": \"John\", \"age\": 32}", "output": "[\"dict\"]", "fn_name": "types"}, {"input": "\"Hello World!\"", "output": "[\"str\"]", "fn_name": "types"}, {"input": "[1, 2, 3, 4]", "output": "[\"list\"]", "fn_name": "types"}, {"input": "null", "output": "[\"NoneType\"]", "fn_name": "types"}, {"input": "3.14...
code_functional
[ { "content": "It is known that there are k fish species in the polar ocean, numbered from 1 to k. They are sorted by non-decreasing order of their weight, which is a positive number. Let the weight of the i-th type of fish be w_{i}, then 0 < w_1 ≤ w_2 ≤ ... ≤ w_{k} holds.\n\nPolar bears Alice and Bob each have ...
[{"input": "100 50 10\n7 8 7 1 6 7 9 2 4 6 7 7 3 9 4 5 1 7 8 10 4 1 3 6 8 10 4 6 6 1 6 12 7 4 10 3 10 1 3 2 10 6 9 9 5 2 9 2 9 8 10 2 10 3 3 2 3 8 6 2 7 10 7 2 7 2 8 9 6 2 5 4 4 5 3 3 9 10 9 4 9 3 9 5 3 6 6 1 3 6 10 3 10 2 6 10 10 10 4 8\n3 3 2 9 4 4 10 2 7 3 3 2 6 3 3 4 7 4 1 2 3 8 1 6 7 7 2 10 1 1 1 5 7 7 5 1 6 8 7 5...
code_stdio
[ { "content": "~~~if-not:java\nYou have to code a function **getAllPrimeFactors** wich take an integer as parameter and return an array containing its prime decomposition by ascending factors, if a factors appears multiple time in the decomposition it should appear as many time in the array. \n\nexemple: `getAll...
[{"input": "1000", "output": "[[2, 2, 2, 5, 5, 5]]", "fn_name": "getAllPrimeFactors"}, {"input": "1000001", "output": "[[101, 9901]]", "fn_name": "getAllPrimeFactors"}, {"input": "100", "output": "[[2, 2, 5, 5]]", "fn_name": "getAllPrimeFactors"}, {"input": "10", "output": "[[2, 5]]", "fn_name": "getAllPrimeFactors"}, ...
code_functional
[ { "content": "Given are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).\nConsider a sequence A satisfying the following conditions:\n - A is a sequence of N positive integers.\n - 1 \\leq A_1 \\leq A_2 \\le \\cdots \\leq A_N \\leq M.\nLet us define a score of this sequence as ...
[{"input": "10 10 50\n9 10 0 100000\n4 8 5 100000\n1 3 1 100000\n2 6 3 100000\n9 10 1 84\n2 9 4 72167\n5 9 6 100000\n6 8 2 100000\n1 5 2 100000\n3 6 3 100000\n1 9 8 100000\n2 4 0 100000\n3 5 1 100000\n4 8 7 7354\n3 4 0 100000\n5 10 6 100000\n1 6 4 100000\n7 10 3 100000\n8 10 2 100000\n4 6 3 100000\n1 4 1 100000\n6 9 4 ...
code_stdio
[ { "content": "There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string s. The i-th (1-based) character of s represents the color of the i-th stone. If the character is \"R\", \"G\", or \"B\", the color of the corresponding stone is red, green, or blue...
[{"input": "BRRBGBRGRBGRGRRGGBGBGBRGBRGRGGGRBRRRBRBBBGRRRGGBBB\nBBRBGGRGRGBBBRBGRBRBBBBRBRRRBGBBGBBRRBBGGRBRRBRGRB\n", "output": "15\n"}, {"input": "BRGRRGRGRRGBBGBBBRRBBRRBGBBGRGBBGGRGBRBGGGRRRBGGBB\nRGBBGRRBBBRRGRRBRBBRGBBGGGRGBGRRRRBRBGGBRBGGGRGBRR\n", "output": "16\n"}, {"input": "GGRGGBRRGRGBRRGGRBBGGRRGBBBGBBBGGR...
code_stdio
[ { "content": "Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands \"ping a\" and \"ping b\". Each ping command sends exactly ten packets to the server specified in the argument of the comma...
[{"input": "14\n1 7 3\n1 0 10\n1 7 3\n1 1 9\n2 2 8\n2 0 10\n1 1 9\n2 8 2\n2 6 4\n1 3 7\n1 3 7\n2 6 4\n2 1 9\n2 7 3\n", "output": "DEAD\nDEAD\n"}, {"input": "14\n1 7 3\n1 0 10\n1 7 3\n1 1 9\n2 2 8\n2 0 10\n1 1 9\n2 8 2\n2 6 4\n1 3 7\n1 3 7\n2 6 4\n2 1 9\n2 7 3\n", "output": "DEAD\nDEAD\n"}, {"input": "14\n1 5 3\n1 0 10\...
code_stdio
[ { "content": "*This kata is inspired by [Project Euler Problem #387](https://projecteuler.net/problem=387)*\n\n---\n\nA [Harshad number](https://en.wikipedia.org/wiki/Harshad_number) (or Niven number) is a number that is divisible by the sum of its digits. A *right truncatable Harshad number* is any Harshad num...
[{"input": "1000\n2000", "output": "[[1000, 1002, 1008, 1020, 1026, 1080, 1088, 1200, 1204, 1206, 1260, 1800, 2000]]", "fn_name": "rthn_between"}, {"input": "30\n100", "output": "[[30, 36, 40, 42, 45, 48, 50, 54, 60, 63, 70, 72, 80, 81, 84, 90, 100]]", "fn_name": "rthn_between"}, {"input": "9000002182976\n9000195371842...
code_functional
[ { "content": "DZY has a hash table with p buckets, numbered from 0 to p - 1. He wants to insert n numbers, in the order they are given, into the hash table. For the i-th number x_{i}, DZY will put it into the bucket numbered h(x_{i}), where h(x) is the hash function. In this problem we will assume, that h(x) = ...
[{"input": "101 15\n139988797\n524419455\n1205904463\n153341038\n146759898\n171753194\n163710849\n42060733\n1382862835\n979451110\n1200809750\n37821717\n446728232\n850870259\n221398500\n", "output": "12\n"}, {"input": "101 15\n139988797\n524419455\n1205904463\n153341038\n146759898\n198834293\n163710849\n42060733\n13828...
code_stdio
[ { "content": "Problem\n\nA graph is given in which N vertices, each numbered from 1 to N, are connected by N-1 undirected edges. For each vertex, output the shortest number of steps to start from that vertex and visit all vertices.\n\nHowever, one step is to follow one side from one vertex and move to another v...
[{"input": "6\n1 2\n2 3\n3 4\n3 5\n5 6", "output": "6\n7\n8\n7\n7\n6\n"}, {"input": "6\n1 2\n2 3\n6 4\n3 5\n5 6", "output": "5\n6\n7\n5\n7\n6\n"}, {"input": "6\n1 2\n2 3\n6 4\n3 4\n5 6", "output": "5\n6\n7\n7\n5\n6\n"}, {"input": "6\n1 2\n2 3\n3 4\n3 5\n1 6", "output": "7\n8\n7\n6\n6\n6\n"}, {"input": "6\n1 2\n1 3\n3 4...
code_stdio
[ { "content": "A number is called 2050-number if it is $2050$, $20500$, ..., ($2050 \\cdot 10^k$ for integer $k \\ge 0$).\n\nGiven a number $n$, you are asked to represent $n$ as the sum of some (not necessarily distinct) 2050-numbers. Compute the minimum number of 2050-numbers required for that.\n\n\n-----Input...
[{"input": "9\n204926935685243951\n999999999999999000\n1000000000000000000\n204999999999997950\n983999999999997950\n205\n1266\n50\n20\n", "output": "-1\n81\n-1\n126\n128\n-1\n-1\n-1\n-1\n"}, {"input": "9\n375241037050488412\n999999999999999000\n1000000000000000000\n204999999999997950\n1691361554995086523\n205\n2255\n50...
code_stdio
[ { "content": "You've got table a, consisting of n rows, numbered from 1 to n. The i-th line of table a contains ci cells, at that for all i (1 < i ≤ n) holds ci ≤ ci - 1. \n\nLet's denote s as the total number of cells of table a, that is, <image>. We know that each cell of the table contains a single integer f...
[{"input": "4\n40 40 24 5\n56 14 59 76 92 34 43 96 33 44 72 37 81 27 42 5 7 95 22 4 60 18 61 103 74 84 93 55 3 62 70 82 77 51 86 102 29 67 91 9\n71 53 21 64 17 45 46 101 97 30 109 100 57 16 80 87 28 12 94 23 39 98 32 52 54 10 19 41 90 11 66 65 99 89 40 36 58 20 78 108\n35 88 73 75 104 63 79 31 1 26 2 50 24 83 15 49 106...
code_stdio
[ { "content": "Permutation p is an ordered set of integers p_1, p_2, ..., p_{n}, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as p_{i}. We'll call number n the size or the length of permutation p_1, p_2, ..., p_{n}.\n\nWe'll call ...
[{"input": "1000 500\n", "output": "979041279\n"}, {"input": "1000 700\n", "output": "642759746\n"}, {"input": "1000 900\n", "output": "301804159\n"}, {"input": "1000 998\n", "output": "583666213\n"}, {"input": "1000 900\n", "output": "301804159\n"}, {"input": "1000 998\n", "output": "583666213\n"}, {"input": "1000 700...
code_stdio
[ { "content": "Ikta loves fast programs. Recently, I'm trying to speed up the division program. However, it doesn't get much faster, so I thought it would be better to make it faster only for \"common sense and typical\" inputs. The problem Ikta is trying to solve is as follows.\n\nFor a given non-negative integ...
[{"input": "001", "output": "2\n"}, {"input": "000", "output": "1\n"}, {"input": "178", "output": "0\n"}, {"input": "209", "output": "0\n"}, {"input": "375", "output": "0\n"}, {"input": "112", "output": "0\n"}, {"input": "143", "output": "0\n"}, {"input": "277", "output": "0\n"}, {"input": "164", "output": "0\n"}, {"in...
code_stdio
[ { "content": "Tokitsukaze and CSL are playing a little game of stones.\n\nIn the beginning, there are n piles of stones, the i-th pile of which has a_i stones. The two players take turns making moves. Tokitsukaze moves first. On each turn the player chooses a nonempty pile and removes exactly one stone from the...
[{"input": "14\n9 9 1000 2000 39999 48888 16 32 123456 959658 111 987584 125632 125468\n", "output": "sjfnb\n"}, {"input": "14\n9 9 1000 2000 39999 48888 16 32 123456 959658 111 987584 125632 125477\n", "output": "cslnb\n"}, {"input": "14\n9 9 1000 2000 67494 48888 16 32 123456 959658 111 987584 125632 125468\n", "outp...
code_stdio
[ { "content": "The marmots need to prepare k problems for HC^2 over n days. Each problem, once prepared, also has to be printed.\n\nThe preparation of a problem on day i (at most one per day) costs a_{i} CHF, and the printing of a problem on day i (also at most one per day) costs b_{i} CHF. Of course, a problem ...
[{"input": "13 13\n93 19 58 34 96 7 35 46 60 5 36 40 41\n57 3 42 68 26 85 25 45 50 21 60 23 79\n", "output": "1154\n"}, {"input": "13 13\n93 19 58 34 96 7 35 46 60 5 66 40 41\n57 3 42 68 26 85 25 45 50 21 60 23 79\n", "output": "1184\n"}, {"input": "13 13\n93 19 58 34 96 7 35 46 60 5 66 40 41\n57 1 42 68 26 85 25 45 50...
code_stdio
[ { "content": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr...
[{"input": "15\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n", "output": "YES\n"}, {"input": "15\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n", "output": "YES\n"}, {"input": "15\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n", ...
code_stdio
[ { "content": "Xenia the beginner programmer has a sequence a, consisting of 2^{n} non-negative integers: a_1, a_2, ..., a_2^{n}. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.\n\nNamely, it takes several iterations to calculate valu...
[{"input": "2 10\n47 17 22 0\n2 15\n2 42\n1 9\n3 13\n3 28\n1 20\n1 13\n1 50\n2 20\n2 12\n", "output": "57\n57\n61\n38\n55\n34\n51\n38\n42\n34\n"}, {"input": "2 10\n47 17 22 0\n4 15\n2 42\n1 9\n3 13\n3 28\n1 20\n1 13\n1 50\n2 20\n2 12\n", "output": "32\n48\n52\n36\n52\n33\n48\n37\n41\n33\n"}, {"input": "2 10\n47 17 22 1...
code_stdio
[ { "content": "You are given an array of integers $b_1, b_2, \\ldots, b_n$.\n\nAn array $a_1, a_2, \\ldots, a_n$ of integers is hybrid if for each $i$ ($1 \\leq i \\leq n$) at least one of these conditions is true:\n\n$b_i = a_i$, or\n\n$b_i = \\sum_{j=1}^{i} a_j$.\n\nFind the number of hybrid arrays $a_1, a_2, ...
[{"input": "4\n3\n2 -1 1\n4\n-1 2 2 6\n10\n2 -1 1 -2 1 0 -11 0 2 -1\n4\n-1 -2 -1 1\n", "output": "4\n8\n210\n8\n"}, {"input": "4\n3\n2 -1 2\n4\n-1 2 2 5\n10\n2 -1 1 -2 0 0 -11 0 2 -1\n4\n-1 -2 -1 1\n", "output": "4\n8\n150\n8\n"}, {"input": "4\n3\n2 0 2\n4\n-1 2 2 4\n10\n2 -1 1 -2 -1 0 -38 0 2 -1\n4\n-1 -2 -1 1\n", "ou...
code_stdio
[ { "content": "There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times:\n\n* Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on t...
[{"input": "5 19\n10 2 11 6 1", "output": "IMPOSSIBLE\n"}, {"input": "5 11\n12 2 10 8 2", "output": "IMPOSSIBLE\n"}, {"input": "5 15\n10 2 11 6 1", "output": "IMPOSSIBLE\n"}, {"input": "5 19\n10 2 8 6 4", "output": "IMPOSSIBLE\n"}, {"input": "5 19\n10 2 8 6 1", "output": "IMPOSSIBLE\n"}, {"input": "5 19\n10 2 7 6 1", "...
code_stdio
[ { "content": "It's March and you just can't seem to get your mind off brackets. However, it is not due to basketball. You need to extract statements within strings that are contained within brackets.\n\nYou have to write a function that returns a list of statements that are contained within brackets given a str...
[{"input": "\"logger?]?system...12.12.133333 at [12-32-1432-16]\"", "output": "[[\"12-32-1432-16\"]]", "fn_name": "bracket_buster"}, {"input": "\"Big [L][e][B][r][o][n]!][[\"", "output": "[[\"L\", \"e\", \"B\", \"r\", \"o\", \"n\"]]", "fn_name": "bracket_buster"}, {"input": "\"[][]]]][[[[[[][]\"", "output": "[[\"\", \"...
code_functional
[ { "content": "Let's define a function $f(x)$ ($x$ is a positive integer) as follows: write all digits of the decimal representation of $x$ backwards, then get rid of the leading zeroes. For example, $f(321) = 123$, $f(120) = 21$, $f(1000000) = 1$, $f(111) = 111$.\n\nLet's define another function $g(x) = \\dfrac...
[{"input": "100\n1\n2\n3\n4\n5\n4\n7\n8\n9\n10\n11\n12\n13\n17\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n17\n28\n29\n30\n31\n32\n31\n34\n35\n36\n27\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n29\n54\n100\n56\n57\n58\n59\n109\n61\n62\n63\n120\n65\n66\n67\n68\n69\n70\n71\n72\n73\n74\n75\n76\n77\n7...
code_stdio
[ { "content": "You are playing another computer game, and now you have to slay $n$ monsters. These monsters are standing in a circle, numbered clockwise from $1$ to $n$. Initially, the $i$-th monster has $a_i$ health.\n\nYou may shoot the monsters to kill them. Each shot requires exactly one bullet and decreases...
[{"input": "10\n8\n7 4\n9 10\n4 8\n3 1\n1 7\n9 5\n1 4\n2 5\n8\n9 8\n4 7\n7 7\n3 6\n14 9\n2 5\n4 9\n2 8\n7\n2 2\n2 7\n2 10\n8 6\n1 4\n2 6\n3 10\n4\n4 10\n7 5\n6 10\n9 5\n7\n8 9\n8 1\n3 4\n5 1\n3 10\n9 3\n5 5\n5\n6 1\n7 3\n6 5\n6 1\n1 8\n2\n7 8\n7 10\n4\n6 8\n9 3\n8 1\n9 7\n4\n13 7\n5 7\n10 10\n8 8\n6\n6 5\n7 10\n7 1\n10...
code_stdio
[ { "content": "There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region.\nThe front and back sides of these cards can be distinguished, and initially every card faces up.\nWe will p...
[{"input": "1000000000 1000000000\n", "output": "999999996000000004\n"}, {"input": "198278012 119900227\n", "output": "23773578011552250\n"}, {"input": "17890722 23878637\n", "output": "427205972767200\n"}, {"input": "1 1000000000\n", "output": "999999998\n"}, {"input": "237891668 1\n", "output": "237891666\n"}, {"inpu...
code_stdio