info
stringlengths
120
50k
question
stringlengths
504
10.4k
avg@8_qwen3_4b_instruct_2507
float64
0
0.88
{"tests": "{\"inputs\": [\"5\\n2 1 1 3 2\\n\", \"3\\n30 10 20\\n\", \"2\\n10 20\\n\", \"5\\n900 153 2825 93 2819\\n\", \"5\\n752149229 401123316 96604198 413974932 634465929\\n\", \"5\\n1 10000000 1 228 9000000\\n\", \"99\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 ...
Cowboy Vlad has a birthday today! There are $n$ children who came to the celebration. In order to greet Vlad, the children decided to form a circle around him. Among the children who came, there are both tall and low, so if they stand in a circle arbitrarily, it may turn out, that there is a tall and low child standing...
0
{"tests": "{\"inputs\": [[\"test\", 7], [\"hello world\", 7], [\"a lot of words for a single line\", 10], [\"this is a test\", 4], [\"a longword\", 6], [\"areallylongword\", 6], [\"aa\", 3], [\"aaa\", 3], [\"aaaa\", 3], [\"a a\", 3], [\"a aa\", 3], [\"a aaa\", 3], [\"a aaaa\", 3], [\"a aaaaa\", 3], [\"a a a\", 3], [\"a...
Your job is to write a function that takes a string and a maximum number of characters per line and then inserts line breaks as necessary so that no line in the resulting string is longer than the specified limit. If possible, line breaks should not split words. However, if a single word is longer than the limit, it o...
0
{"tests": "{\"inputs\": [\"3\\n10 3\\n1 32 1\\n23 4\\n16 1 4 1\\n20 5\\n2 1 16 1 8\\n\", \"3\\n8 3\\n1 32 1\\n23 4\\n16 1 4 1\\n20 5\\n2 1 16 1 8\\n\", \"3\\n14 3\\n1 32 1\\n23 4\\n16 1 4 1\\n20 5\\n2 1 16 2 8\\n\", \"3\\n14 3\\n1 32 1\\n14 4\\n16 1 4 1\\n26 5\\n2 1 16 2 8\\n\", \"3\\n8 3\\n1 32 1\\n23 4\\n16 1 4 1\\n6...
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two. You can divide boxes into two parts of equal size. Your goal is to fill the bag completely. For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of s...
0
{"tests": "{\"inputs\": [\"6 2\\n2 3 6 5 4 10\\n\", \"10 2\\n1 2 3 4 5 6 7 8 9 10\\n\", \"1 1\\n1\\n\", \"100 2\\n191 17 61 40 77 95 128 88 26 69 79 10 131 106 142 152 68 39 182 53 83 81 6 89 65 148 33 22 5 47 107 121 52 163 150 158 189 118 75 180 177 176 112 167 140 184 29 166 25 46 169 145 187 123 196 18 115 126 155 ...
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x < y) from the set, such that y = x·k. You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-mu...
0
{"tests": "{\"inputs\": [\"3 5 6\\n1 18\\n2 31\\n1 2\\n3 4 1\\n1 1\\n2 1\\n3 1\\n0 2 5\\n0 0 0\", \"3 5 6\\n1 35\\n2 31\\n1 2\\n3 4 1\\n1 1\\n2 1\\n3 1\\n0 2 5\\n0 0 0\", \"3 5 6\\n1 48\\n2 31\\n1 2\\n3 4 1\\n1 1\\n2 1\\n3 1\\n0 2 5\\n0 0 0\", \"3 5 6\\n1 48\\n2 6\\n1 2\\n3 4 1\\n1 1\\n2 1\\n3 1\\n0 2 5\\n0 0 0\", \"3 ...
Today is the birthday of Mr. Bon Vivant, who is known as one of the greatest patissiers in the world. Those who are invited to his birthday party are gourmets from around the world. They are eager to see and eat his extremely creative cakes. Now a large box-shaped cake is being carried into the party. It is not beautif...
0
{"tests": "{\"inputs\": [\"6 3\\n1\\n4\\n5\\n\", \"1 0\\n\", \"1000000000 0\\n\", \"1 1\\n1\\n\", \"2 2\\n1\\n2\\n\", \"3 3\\n1\\n2\\n3\\n\", \"4 4\\n1\\n2\\n3\\n4\\n\", \"5 5\\n1\\n2\\n3\\n4\\n5\\n\", \"6 6\\n1\\n2\\n3\\n4\\n5\\n6\\n\", \"7 7\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n\", \"8 8\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n\"...
Let's say Pak Chanek has an array $A$ consisting of $N$ positive integers. Pak Chanek will do a number of operations. In each operation, Pak Chanek will do the following: Choose an index $p$ ($1 \leq p \leq N$). Let $c$ be the number of operations that have been done on index $p$ before this operation. Decrease the ...
0
{"tests": "{\"inputs\": [\"3\\n1 2\\n2 3\\n\", \"5\\n1 2\\n2 3\\n1 4\\n4 5\\n\", \"4\\n1 2\\n2 3\\n3 4\\n\", \"5\\n1 5\\n2 5\\n3 5\\n4 5\\n\", \"5\\n1 2\\n2 3\\n1 4\\n3 5\\n\", \"4\\n1 2\\n2 3\\n2 4\\n\", \"6\\n1 6\\n2 3\\n3 4\\n4 5\\n5 6\\n\", \"4\\n1 4\\n2 3\\n3 4\\n\", \"6\\n1 6\\n2 6\\n3 4\\n4 5\\n5 6\\n\", \"5\\n1...
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold: * For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of weights of all edges on the simple path between v_...
0
{"tests": "{\"inputs\": [[100, 2], [1000, 2], [2000, 2], [200, 3], [370, 3], [400, 3], [500, 3], [1000, 3], [1500, 3]], \"outputs\": [[[]], [[]], [[]], [[153]], [[153, 370]], [[153, 370, 371]], [[153, 370, 371, 407]], [[153, 370, 371, 407]], [[153, 370, 371, 407]]]}", "source": "taco"}
Not considering number 1, the integer 153 is the first integer having this property: the sum of the third-power of each of its digits is equal to 153. Take a look: 153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153 The next number that experiments this particular behaviour is 370 with the same power. Write the function `eq_...
0
{"tests": "{\"inputs\": [\"19 29\\n\", \"3 6\\n\", \"39 91\\n\", \"76 134\\n\", \"93 95\\n\", \"17 35\\n\", \"94 95\\n\", \"51 52\\n\", \"47 52\\n\", \"38 98\\n\", \"30 37\\n\", \"56 92\\n\", \"900000000 1000000000\\n\", \"37622224 162971117\\n\", \"760632746 850720703\\n\", \"908580370 968054552\\n\", \"951594860 9535...
Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path. You are given l and r. For all integers from l to r, inclusive, we wrote down all of their integer divisors except 1. Find the integer that we wrote down the maximum number of times. Solve...
0
{"tests": "{\"inputs\": [\"5\\n5 6 5 2 1\\n9053 1108 6890 4343 8704\", \"3\\n1 1 1\\n13 1 7\", \"4\\n0 2 3 4\\n2 3 4 5\", \"3\\n2 1 1\\n13 5 7\", \"5\\n5 6 5 2 1\\n9053 1108 6890 4343 13928\", \"4\\n0 2 3 4\\n2 2 4 5\", \"3\\n2 1 1\\n13 1 7\", \"5\\n5 6 5 2 1\\n9053 1108 6890 4343 12481\", \"4\\n0 2 3 4\\n2 0 4 5\", \"...
There are N positive integers arranged in a circle. Now, the i-th number is A_i. Takahashi wants the i-th number to be B_i. For this objective, he will repeatedly perform the following operation: * Choose an integer i such that 1 \leq i \leq N. * Let a, b, c be the (i-1)-th, i-th, and (i+1)-th numbers, respectively. ...
0.25
{"tests": "{\"inputs\": [\"3 4\\n4 6\\n10 -2\\n8 -1\\n\", \"5 20\\n45 -6\\n34 -15\\n10 34\\n1 27\\n40 -45\\n\", \"3 2\\n300 -300\\n1 299\\n1 123\\n\", \"20 15000\\n57 -299\\n354 -298\\n156 -298\\n102 -298\\n862 -300\\n134 -300\\n1446 -289\\n23 -298\\n1012 -298\\n901 -300\\n97 -300\\n172 -297\\n108 -265\\n209 -294\\n307...
The only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version. Polycarp is a very famous freelancer. His current rating is $r$ units. Some very rich customers asked him to complete some projects for their companies. To complet...
0
{"tests": "{\"inputs\": [\"5 8\\n....#..#\\n.#......\\n##.#....\\n##..#.##\\n........\\n4\\n1 1 2 3\\n4 1 4 1\\n1 2 4 5\\n2 5 5 8\\n\", \"7 39\\n.......................................\\n.###..###..#..###.....###..###..#..###.\\n...#..#.#..#..#.........#..#.#..#..#...\\n.###..#.#..#..###.....###..#.#..#..###.\\n.#....#...
They say "years are like dominoes, tumbling one after the other". But would a year fit into a grid? I don't think so. Limak is a little polar bear who loves to play. He has recently got a rectangular grid with h rows and w columns. Each cell is a square, either empty (denoted by '.') or forbidden (denoted by '#'). Row...
0.25
{"tests": "{\"inputs\": [\"3\\n2 1 2\\n\", \"5\\n1 2 3 4 5\\n\", \"4\\n1 3 3 3\\n\", \"4\\n1 3 1 3\", \"4\\n1 3 3 2\", \"3\\n2 2 2\", \"4\\n2 3 2 2\", \"5\\n1 2 3 3 5\", \"5\\n2 2 3 3 5\", \"4\\n2 3 4 1\", \"4\\n2 2 2 2\", \"5\\n4 2 2 4 4\", \"3\\n2 2 1\", \"5\\n4 4 5 4 4\", \"5\\n5 1 2 3 4\", \"4\\n2 3 1 3\", \"4\\n1 ...
Takahashi has N cards. The i-th of these cards has an integer A_i written on it. Takahashi will choose an integer K, and then repeat the following operation some number of times: - Choose exactly K cards such that the integers written on them are all different, and eat those cards. (The eaten cards disappear.) For eac...
0
{"tests": "{\"inputs\": [\"3 3 4\\n1 1\\n1 2\\n2 1\\n2 2\\n\", \"3 4 6\\n1 1\\n2 1\\n1 2\\n2 2\\n1 3\\n2 3\\n\", \"7 4 5\\n1 3\\n2 2\\n5 1\\n5 3\\n4 3\\n\", \"10 10 10\\n3 8\\n1 7\\n2 3\\n4 2\\n4 8\\n3 3\\n2 8\\n5 5\\n6 3\\n3 1\\n\", \"10 10 10\\n3 8\\n1 7\\n2 3\\n4 2\\n4 8\\n3 3\\n2 8\\n5 5\\n6 3\\n3 1\\n\", \"3 3 4\\...
There are k sensors located in the rectangular room of size n × m meters. The i-th sensor is located at point (x_{i}, y_{i}). All sensors are located at distinct points strictly inside the rectangle. Opposite corners of the room are located at points (0, 0) and (n, m). Walls of the room are parallel to coordinate axe...
0.125
{"tests": "{\"inputs\": [\"2 3\\n\", \"4 2\\n\", \"4 6\\n\", \"1337 424242424242\\n\", \"300000 1000000000\\n\", \"300000 1\\n\", \"2 1\\n\", \"2 1000000000000\\n\", \"17957 2\\n\"], \"outputs\": [\"6\\n\", \"26\\n\", \"1494\\n\", \"119112628\\n\", \"590856313\\n\", \"299999\\n\", \"1\\n\", \"138131255\\n\", \"65364796...
Consider an array $a$ of length $n$ with elements numbered from $1$ to $n$. It is possible to remove the $i$-th element of $a$ if $gcd(a_i, i) = 1$, where $gcd$ denotes the greatest common divisor. After an element is removed, the elements to the right are shifted to the left by one position. An array $b$ with $n$ int...
0
{"tests": "{\"inputs\": [\"5\\n2\\n3\\n9\\n1010\\n1001\\n0100\\n1001\\n0010\\n1000\\n0000\\n0101\\n1010\\n0\", \"5\\n2\\n3\\n9\\n1010\\n1001\\n0100\\n1001\\n0010\\n1000\\n0000\\n0101\\n1000\\n0\", \"5\\n2\\n3\\n9\\n1010\\n1001\\n0000\\n1001\\n0010\\n1000\\n0000\\n0101\\n1001\\n0\", \"5\\n2\\n3\\n9\\n1010\\n1001\\n1000\...
There are n vertical lines in the Amidakuji. This Amidakuji meets the following conditions. * Draw a horizontal line right next to it. Do not pull diagonally. * Horizontal lines always connect adjacent vertical lines. In other words, the horizontal line does not cross the vertical line. * For any vertical line, horizo...
0
{"tests": "{\"inputs\": [\"4\\n1 2 1 2\\n\", \"10\\n1 1 2 2 2 1 1 2 2 1\\n\", \"200\\n2 1 1 2 1 2 2 2 2 2 1 2 2 1 1 2 2 1 1 1 2 1 1 2 2 2 2 2 1 1 2 1 2 1 1 2 1 1 1 1 2 1 2 2 1 2 1 1 1 2 1 1 1 2 2 2 1 1 1 1 2 2 2 1 2 2 2 1 2 2 2 1 2 1 2 1 2 1 1 1 1 2 2 2 1 1 2 1 2 1 2 1 2 2 1 1 1 2 2 2 2 1 2 2 2 1 1 1 1 2 1 1 1 2 2 1 2 ...
A dragon symbolizes wisdom, power and wealth. On Lunar New Year's Day, people model a dragon with bamboo strips and clothes, raise them with rods, and hold the rods high and low to resemble a flying dragon. A performer holding the rod low is represented by a 1, while one holding it high is represented by a 2. Thus, th...
0
{"tests": "{\"inputs\": [\"3\\n1 10\\n3 14\\n1 10\\n\", \"3\\n6969 696969\\n6969 696969\\n6969 696969\\n\", \"1\\n696969 100000000\\n\", \"1\\n69696969 998244353\\n\", \"1\\n69696969 998244353\\n\", \"1\\n696969 100000000\\n\", \"3\\n6969 696969\\n6969 696969\\n6969 696969\\n\", \"3\\n1 10\\n3 14\\n1 10\\n\", \"1\\n813...
You are given a range of positive integers from $l$ to $r$. Find such a pair of integers $(x, y)$ that $l \le x, y \le r$, $x \ne y$ and $x$ divides $y$. If there are multiple answers, print any of them. You are also asked to answer $T$ independent queries. -----Input----- The first line contains a single integer...
0.875
{"tests": "{\"inputs\": [\"2 2\\n1 1\\n\", \"3 6\\n1 1 1\\n\", \"3 1\\n1 0 1\\n\", \"3 1000000000000000000\\n5 4 5\\n\", \"4 1000000000000000000\\n0 4 4 5\\n\", \"5 1000000000000000000\\n5 7 4 2 5\\n\", \"3 999999999000999944\\n7 2 6\\n\", \"4 999999999000531216\\n8 7 4 6\\n\", \"5 152742477016321721\\n0 0 2 6 2\\n\", ...
Consider the function p(x), where x is an array of m integers, which returns an array y consisting of m + 1 integers such that y_{i} is equal to the sum of first i elements of array x (0 ≤ i ≤ m). You have an infinite sequence of arrays A^0, A^1, A^2..., where A^0 is given in the input, and for each i ≥ 1 A^{i} = p(A^...
0
{"tests": "{\"inputs\": [\"3\\n2\\n<>\\n3\\n><<\\n1\\n>\\n\", \"13\\n1\\n>\\n1\\n>\\n1\\n>\\n1\\n>\\n1\\n>\\n1\\n>\\n1\\n>\\n1\\n>\\n1\\n>\\n1\\n>\\n1\\n>\\n1\\n>\\n1\\n>\\n\", \"14\\n1\\n>\\n1\\n>\\n1\\n>\\n1\\n>\\n1\\n>\\n1\\n>\\n1\\n>\\n1\\n>\\n1\\n>\\n1\\n>\\n1\\n>\\n1\\n>\\n1\\n>\\n1\\n<\\n\", \"1\\n9\\n>>>>>>>><\...
You have a string $s$ of length $n$ consisting of only characters > and <. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character >, the character that comes right after it is deleted (if the character you chose was t...
0.75
{"tests": "{\"inputs\": [\"pkjlxzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\\npkjlyaaaaaaaaaaaaaaaaaaaaaaaaaaaahr\\n\", \"kexdbtpkjbwwyibjndbtmwqzolopqitgkomqggojevoankiepxirrcidxldlzsppehmoazdywltmjbxgsxgihwnwpmczjrcwpywl\\nkexdbtpkjbwwyibjndbtmwqzolopqitgkomqggojevoankiepxirrcidxldlzsppehmoazdywltmjbxgsxgihwnwpmczjrcwpywm\\n\", \...
Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time. During the last lesson the teacher has provided two strings s and t to Vitaly. The strings have the same length, they consist of lowercase English l...
0
{"tests": "{\"inputs\": [[\"ThisIsAUnitTest\"], [\"ThisShouldBeSplittedCorrectIntoUnderscore\"], [\"Calculate1Plus1Equals2\"], [\"Calculate15Plus5Equals20\"], [\"Calculate500DividedBy5Equals100\"], [\"Adding_3To_3ShouldBe_6\"], [\"This_Is_Already_Splitted_Correct\"], [\"ThisIs_Not_SplittedCorrect\"], [\"_IfATestStartAn...
You wrote all your unit test names in camelCase. But some of your colleagues have troubles reading these long test names. So you make a compromise to switch to underscore separation. To make these changes fast you wrote a class to translate a camelCase name into an underscore separated name. Implement the ToUnderscor...
0
{"tests": "{\"inputs\": [\"1000\\n111\\n\", \"00100\\n11\\n\", \"110\\n101\\n\", \"0\\n0\\n\", \"1\\n10\\n\", \"11\\n10\\n\", \"00111\\n10100\\n\", \"00\\n1\\n\", \"01\\n010\\n\", \"111\\n00\\n\", \"1100\\n11\\n\", \"0110\\n001\\n\", \"1111\\n0110\\n\", \"01010\\n0011\\n\", \"0\\n1\\n\", \"1\\n0\\n\", \"1\\n1\\n\", \"0...
Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \frac{\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it "golden system". In golden sys...
0
{"tests": "{\"inputs\": [\"2\\n1 2\\n\", \"6\\n5 3\\n5 6\\n5 1\\n5 4\\n5 2\\n\", \"7\\n7 5\\n7 3\\n7 6\\n7 4\\n7 1\\n7 2\\n\", \"4\\n4 3\\n3 2\\n2 1\\n\", \"4\\n2 1\\n1 3\\n3 4\\n\", \"10\\n7 10\\n10 6\\n6 4\\n4 5\\n5 8\\n8 2\\n2 1\\n1 3\\n3 9\\n\", \"9\\n9 4\\n4 6\\n6 2\\n2 1\\n1 3\\n3 5\\n5 8\\n8 7\\n\", \"6\\n5 3\\n...
You are given a tree (an undirected connected acyclic graph) consisting of n vertices. You are playing a game on this tree. Initially all vertices are white. On the first turn of the game you choose one vertex and paint it black. Then on each turn you choose a white vertex adjacent (connected by an edge) to any black ...
0.125
{"tests": "{\"inputs\": [[\"\"], [\"a\"], [\"ogl\"], [\"alel\"], [\"MaXwElL\"], [\"ggg\"], [\"Alex is Super Cool\"], [\"ydjkpwqrzto\"], [\"abtlcgs\"]], \"outputs\": [[[\"shell\", \"shell\"]], [[\"shell\", \"beef\", \"shell\"]], [[\"shell\", \"beef\", \"guacamole\", \"lettuce\", \"shell\"]], [[\"shell\", \"beef\", \"let...
If you like Taco Bell, you will be familiar with their signature doritos locos taco. They're very good. Why can't everything be a taco? We're going to attempt that here, turning every word we find into the taco bell recipe with each ingredient. We want to input a word as a string, and return a list representing tha...
0
{"tests": "{\"inputs\": [\"3 3\\n2 1 9\\n\", \"4 20\\n10 3 6 3\\n\", \"1 1000000000\\n1\\n\", \"1 1\\n3\\n\", \"50 100\\n74 55 33 5 83 24 75 59 30 36 13 4 62 28 96 17 6 35 45 53 33 11 37 93 34 79 61 72 13 31 44 75 7 3 63 46 18 16 44 89 62 25 32 12 38 55 75 56 61 82\\n\", \"100 10\\n246 286 693 607 87 612 909 312 621 37...
Makes solves problems on Decoforces and lots of other different online judges. Each problem is denoted by its difficulty — a positive integer number. Difficulties are measured the same across all the judges (the problem with difficulty d on Decoforces is as hard as the problem with difficulty d on any other judge). M...
0
{"tests": "{\"inputs\": [\"2 3\\n1\\n0 1\", \"2 3\\n1\\n0 2\", \"1000000 1000000\\n0\\n0 0\", \"2 4\\n1\\n0 1\", \"2 4\\n0\\n0 1\", \"1000001 1000000\\n0\\n0 1\", \"4 4\\n0\\n0 1\", \"6 4\\n0\\n0 1\", \"11 4\\n0\\n0 1\", \"12 4\\n0\\n0 1\", \"21 4\\n0\\n0 2\", \"21 8\\n0\\n-1 2\", \"14 8\\n0\\n-1 2\", \"3 3\\n1\\n0 1\"...
You are given an H \times W grid. The square at the top-left corner will be represented by (0, 0), and the square at the bottom-right corner will be represented by (H-1, W-1). Of those squares, N squares (x_1, y_1), (x_2, y_2), ..., (x_N, y_N) are painted black, and the other squares are painted white. Let the shorte...
0.125
{"tests": "{\"inputs\": [\"5 2 1\\n0 1 0 1 0\\n\", \"6 2 1\\n1 0 0 1 0 1\\n\", \"100 1 1\\n0 0 0 1 1 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 0 1 1 1 1 1 1 1 0 1 1 1 0 0 0 0 0 0 1 1 0 0 0 1 0 1 0 0 1 0 1 1 0 0 1 0 0 0 1 1 1 1 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 1 1 0 1 1 0 1 1 1 0 1 1 0 1 1 0 0 1 1 0 1 1\\n\", \"100 1 1\\n0 0 1 0 0 0...
There is a robot staying at $X=0$ on the $Ox$ axis. He has to walk to $X=n$. You are controlling this robot and controlling how he goes. The robot has a battery and an accumulator with a solar panel. The $i$-th segment of the path (from $X=i-1$ to $X=i$) can be exposed to sunlight or not. The array $s$ denotes which s...
0
{"tests": "{\"inputs\": [\"3\\n8 8 18\\n32 32 32\\n57 2 57\\n5\\n49 3 49\\n7 30 44\\n27 21 21\\n33 56 56\\n21 46 4\\n3\\n45 52 28\\n36 26 36\\n40 55 50\\n10\\n33 8 39\\n50 57 43\\n35 21 12\\n21 17 11\\n16 21 58\\n45 40 53\\n45 30 53\\n39 1 8\\n55 48 30\\n7 48 15\\n0\", \"3\\n8 8 18\\n32 32 32\\n57 2 57\\n5\\n49 3 49\\n...
In the middle of Tyrrhenian Sea, there is a small volcanic island called Chronus. The island is now uninhabited but it used to be a civilized island. Some historical records imply that the island was annihilated by an eruption of a volcano about 800 years ago and that most of the people in the island were killed by pyr...
0
{"tests": "{\"inputs\": [\"30\\n001110011011011101010101011100\", \"3\\n011\", \"6\\n100101\", \"30\\n001010011011011101010101011100\", \"3\\n001\", \"6\\n100100\", \"30\\n001010011010011101010101011100\", \"3\\n000\", \"6\\n101100\", \"30\\n001010011010011111010101011100\", \"3\\n010\", \"6\\n101101\", \"30\\n00111001...
Given are integers N and X. For each integer k between 0 and X (inclusive), find the answer to the following question, then compute the sum of all those answers, modulo 998244353. * Let us repeat the following operation on the integer k. Operation: if the integer is currently odd, subtract 1 from it and divide it by 2...
0
{"tests": "{\"inputs\": [\"2 2 10\\n5 5\\n7 6\\n\", \"4 5 2\\n8 1 1 2\\n6 3 7 5 2\\n\", \"1 1 2\\n1\\n2\\n\", \"4 1 1\\n3 2 3 2\\n3\\n\", \"1 4 1\\n3\\n2 4 5 5\\n\", \"3 3 3\\n1 1 2\\n3 5 6\\n\", \"4 5 6\\n5 1 7 2\\n8 7 3 9 8\\n\", \"4 8 10\\n2 1 2 2\\n10 12 10 8 7 9 10 9\\n\", \"8 4 18\\n9 4 2 2 7 5 1 1\\n11 12 8 9\\n...
A group of n schoolboys decided to ride bikes. As nobody of them has a bike, the boys need to rent them. The renting site offered them m bikes. The renting price is different for different bikes, renting the j-th bike costs p_{j} rubles. In total, the boys' shared budget is a rubles. Besides, each of them has his own...
0
{"tests": "{\"inputs\": [\"3\\n1 3 2\\n0 0 1\\n\", \"3\\n1 3 2\\n0 1 0\\n\", \"3\\n3 1 2\\n0 0 0\\n\", \"2\\n1 2\\n0 0\\n\", \"3\\n2 1 3\\n0 0 0\\n\", \"3\\n1 2 3\\n1 0 0\\n\", \"1\\n1\\n0\\n\", \"3\\n3 1 2\\n1 1 0\\n\", \"3\\n3 1 2\\n1 1 1\\n\", \"3\\n3 2 1\\n1 1 0\\n\", \"3\\n1 2 3\\n1 1 0\\n\", \"3\\n1 2 3\\n1 1 1\\...
Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: in the one it was directed originally and in the reversed direction. Pavel has a plan: a permutation p and a sequence b1, b2, ...
0
{"tests": "{\"inputs\": [[\"Factor y\"], [\"O f fi ce\"], [\"BusStation\"], [\"Suite \"], [\"YourHouse\"], [\"H o t e l \"]], \"outputs\": [[\"Factory\"], [\"Office\"], [\"You just wanted my autograph didn't you?\"], [\"Suite\"], [\"You just wanted my autograph didn't you?\"], [\"Hotel\"]]}", "source": "taco"}
Oh no! Ghosts have reportedly swarmed the city. It's your job to get rid of them and save the day! In this kata, strings represent buildings while whitespaces within those strings represent ghosts. So what are you waiting for? Return the building(string) without any ghosts(whitespaces)! Example: Should return: If ...
0
{"tests": "{\"inputs\": [[\"abc\"], [\"abc\", \"123\"], [\"abcd\", \"123\"], [\"abc\", \"1234\"], [\"abc\", \"123\", \"$%\"], [\"abcd\", \"123\", \"$%\"], [\"abcd\", \"123\", \"$%^&\"], [\"abcd\", \"123\", \"$%^&\", \"qwertyuiop\"], [\"abcd\", \"123\", \"$%^&\", \"qwertyuiop\", \"X\"]], \"outputs\": [[\"abc\"], [\"a1b2...
Write a function that takes an arbitrary number of strings and interlaces them (combines them by alternating characters from each string). For example `combineStrings('abc', '123')` should return `'a1b2c3'`. If the strings are different lengths the function should interlace them until each string runs out, continuing...
0
{"tests": "{\"inputs\": [\"4\\n2 3\\n2 2\\n3 1\\n1 3\\n\", \"3\\n1 1\\n1 500\\n500 250\\n\", \"1\\n1000 1000\\n\", \"8\\n36 151\\n43 187\\n37 189\\n46 186\\n44 146\\n73 37\\n37 73\\n557 17\\n\", \"1\\n991 983\\n\", \"37\\n30 16\\n22 37\\n37 43\\n25 31\\n12 12\\n15 30\\n42 11\\n29 28\\n26 32\\n12 32\\n18 12\\n11 48\\n24...
Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age $k-1$. If a particle...
0
{"tests": "{\"inputs\": [\"3\\n4 5\\n2 9\\n6 2\", \"2\\n1 1000100000\\n1000000000 1\", \"3\\n4 5\\n2 9\\n6 3\", \"2\\n1 1000100000\\n1000000010 1\", \"3\\n8 3\\n2 14\\n3 3\", \"2\\n0 1000110010\\n1000001010 1\", \"2\\n0 1000100010\\n1000001010 0\", \"2\\n-1 1000000011\\n1100001010 0\", \"2\\n-1 1000000011\\n1100001010 ...
A group of people played a game. All players had distinct scores, which are positive integers. Takahashi knows N facts on the players' scores. The i-th fact is as follows: the A_i-th highest score among the players is B_i. Find the maximum possible number of players in the game. Constraints * 1 \leq N \leq 10^5 * 1...
0.25
{"tests": "{\"inputs\": [\"06,04,1,1,1,1,1,1,1,1,1,1\\n1,1,1,1,1,3,3,3,3,3,50,50\\n10,10,10,10,10,10,10,10,10,10,50,49\", \"1,1,1,1,1,1,1,1,1,0,40,60\\n1,1,1,1,1,3,3,3,3,3,50,50\\n10,10,10,10,10,10,10,10,10,10,50,49\", \"06,04,1,1,0,1,1,1,1,1,1,1\\n1,1,1,1,1,3,3,3,3,3,50,50\\n94,05,01,01,01,01,01,01,01,01,01,01\", \"1,...
There is a double-track line (up and down are separate lines and pass each other everywhere). There are 11 stations on this line, including the terminal station, and each station is called by the section number shown in the figure. <image> Trains depart from both terminal stations on this line at the same time and r...
0.125
{"tests": "{\"inputs\": [\"5\\noof\\n\", \"37564\\nwhydidyoudesertme\\n\", \"5\\nooe\", \"37564\\nwhydidzoudesertme\", \"5\\neoo\", \"37564\\nwhxdidzoudesertme\", \"5\\ndoo\", \"37564\\nwhxdidzoudesertne\", \"5\\ndop\", \"37564\\nwhxdiczoudesertne\", \"5\\nodp\", \"37564\\nwhxdiczovdesertne\", \"5\\npdo\", \"37564\\nen...
How many strings can be obtained by applying the following operation on a string S exactly K times: "choose one lowercase English letter and insert it somewhere"? The answer can be enormous, so print it modulo (10^9+7). -----Constraints----- - K is an integer between 1 and 10^6 (inclusive). - S is a string of length...
0
{"tests": "{\"inputs\": [\"3 2 2\\nabc\\nab\\n\", \"9 12 4\\nbbaaababb\\nabbbabbaaaba\\n\", \"11 11 4\\naaababbabbb\\nbbbaaaabaab\\n\", \"15 9 4\\nababaaabbaaaabb\\nbbaababbb\\n\", \"2 7 1\\nbb\\nbbaabaa\\n\", \"13 4 3\\nabbaababaaaab\\naaab\\n\", \"2 3 2\\nab\\naab\\n\", \"13 9 1\\noaflomxegekyv\\nbgwwqizfo\\n\", \"5 ...
After returned from forest, Alyona started reading a book. She noticed strings s and t, lengths of which are n and m respectively. As usual, reading bored Alyona and she decided to pay her attention to strings s and t, which she considered very similar. Alyona has her favourite positive integer k and because she is to...
0
{"tests": "{\"inputs\": [\"5\\n1 2 2 1 2\\n\", \"8\\n1 2 2 1 2 1 1 2\\n\", \"1\\n2\\n\", \"1\\n1\\n\", \"2\\n2 2\\n\", \"2\\n1 2\\n\", \"2\\n1 1\\n\", \"10\\n2 2 2 2 2 2 1 2 1 1\\n\", \"10\\n2 1 1 2 1 2 1 2 2 1\\n\", \"10\\n1 1 1 1 1 1 1 1 1 1\\n\", \"10\\n1 1 1 1 2 1 1 1 1 1\\n\", \"10\\n2 1 2 2 2 2 2 2 2 2\\n\", \"10...
Smart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One of his favorite warm-up exercises is throwing balls. Students line up. Each one gets a single ball in the beginning....
0
{"tests": "{\"inputs\": [\"4 3\\n\", \"5 2\\n\", \"7 2\\n\", \"2 1\\n\", \"100000000000000 1\\n\", \"100000000000000 99999999999999\\n\", \"12 1\\n\", \"12 5\\n\", \"12 7\\n\", \"12 11\\n\", \"1117 1\\n\", \"1117 2\\n\", \"1117 3\\n\", \"1117 4\\n\", \"1117 5\\n\", \"1117 6\\n\", \"1117 7\\n\", \"1117 8\\n\", \"1117 9\...
The campus has $m$ rooms numbered from $0$ to $m - 1$. Also the $x$-mouse lives in the campus. The $x$-mouse is not just a mouse: each second $x$-mouse moves from room $i$ to the room $i \cdot x \mod{m}$ (in fact, it teleports from one room to another since it doesn't visit any intermediate room). Starting position of ...
0
{"tests": "{\"inputs\": [\"4\\n4 6\\n*.*..*\\n*.....\\n...-..\\n^.*#..\\n10\\nSRSSRRUSSR\\n2 2\\n<.\\n..\\n12\\nDDSRRSUUSLLS\\n3 5\\n>-#**\\n.-*#*\\n.-**#\\n15\\nSSSDRSSSDRSSSUU\\n5 5\\nv****\\n*****\\n*****\\n*****\\n*****\\n44\\nSSSSDDRSDRSRDSULUURSSSSRRRRDSSSSDDLSDLSDLSSD\", \"4\\n4 6\\n*.*..*\\n*.....\\n..-...\\n^....
You decide to develop a game with your friends. The title of the game is "Battle Town". This is a game with the theme of urban warfare with tanks. As the first step in game development, we decided to develop the following prototype. In this prototype, the only tanks that appear are the player's tanks, not the enemy ta...
0
{"tests": "{\"inputs\": [\"2 2\\n1 2 3 4\\n1 5 3 4\\n\", \"2 2\\n1 2 3 4\\n1 5 6 4\\n\", \"2 3\\n1 2 4 5\\n1 2 1 3 2 3\\n\", \"2 1\\n1 2 1 3\\n1 2\\n\", \"4 4\\n1 2 3 4 5 6 7 8\\n2 3 4 5 6 7 8 1\\n\", \"3 3\\n1 2 5 6 7 8\\n2 3 4 5 8 9\\n\", \"4 3\\n1 2 4 5 6 7 8 9\\n1 2 8 9 3 1\\n\", \"3 4\\n2 1 8 9 3 1\\n1 2 4 5 6 7 8...
Two participants are each given a pair of distinct numbers from 1 to 9 such that there's exactly one number that is present in both pairs. They want to figure out the number that matches by using a communication channel you have access to without revealing it to you. Both participants communicated to each other a set ...
0.125
{"tests": "{\"inputs\": [\"10\\n44 22 14 9 93 81 52 64 3 99\\n43 23 13 10 92 82 51 65 2 100\\n\", \"1\\n1\\n1\\n\", \"10\\n1 5 4 3 2 1 5 8 2 3\\n1 1 1 1 5 5 5 5 5 5\\n\", \"1\\n1000000000\\n1000000000\\n\", \"20\\n31 16 20 30 19 35 8 11 20 45 10 26 21 39 29 52 8 10 37 49\\n16 33 41 32 43 24 35 48 19 37 28 26 7 10 23 48...
Little Vasya's uncle is a postman. The post offices are located on one circular road. Besides, each post office has its own gas station located next to it. Petya's uncle works as follows: in the morning he should leave the house and go to some post office. In the office he receives a portion of letters and a car. Then ...
0
{"tests": "{\"inputs\": [\"5\\n6\\n111010\\n1\\n0\\n1\\n1\\n2\\n11\\n6\\n101010\\n\", \"5\\n6\\n111010\\n1\\n1\\n1\\n1\\n2\\n11\\n6\\n101010\\n\", \"5\\n6\\n111000\\n1\\n1\\n1\\n1\\n2\\n11\\n6\\n101010\\n\", \"5\\n6\\n011011\\n1\\n0\\n1\\n1\\n2\\n11\\n6\\n111000\\n\", \"5\\n6\\n111111\\n1\\n0\\n1\\n1\\n2\\n11\\n6\\n101...
You have a string $s$ consisting of $n$ characters. Each character is either 0 or 1. You can perform operations on the string. Each operation consists of two steps: select an integer $i$ from $1$ to the length of the string $s$, then delete the character $s_i$ (the string length gets reduced by $1$, the indices of ch...
0
{"tests": "{\"inputs\": [\"3\\n3\\n1 2\\n2 3\\n1 3\\n4\\n1 2\\n2 3\\n3 4\\n4 2\\n5\\n1 2\\n2 3\\n1 3\\n2 5\\n4 3\\n\", \"3\\n3\\n1 2\\n2 3\\n1 3\\n4\\n1 4\\n2 3\\n3 4\\n4 2\\n5\\n1 2\\n2 3\\n1 3\\n2 5\\n4 3\\n\", \"3\\n3\\n1 2\\n2 3\\n1 3\\n4\\n1 2\\n1 3\\n3 4\\n4 2\\n5\\n1 2\\n2 3\\n1 3\\n2 5\\n4 3\\n\", \"3\\n3\\n1 2...
You are given an undirected graph consisting of $n$ vertices and $n$ edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph. Your task is to calculate the number of simple paths of length at ...
0
{"tests": "{\"inputs\": [[\"3\", \"25\", \"46\", \"99\", \"\", \"\"], \"3\\n2\\n46\\n99\", \"3\\n0\\n7\\n61\", \"3\\n25\\n46\\n24\", \"3\\n2\\n60\\n99\", \"3\\n0\\n8\\n24\", \"3\\n25\\n46\\n35\", \"3\\n0\\n5\\n153\", \"3\\n0\\n12\\n5\", \"3\\n61\\n4\\n32\", \"3\\n4\\n1\\n132\", \"3\\n0\\n13\\n131\", \"3\\n3\\n4\\n70\",...
Chef 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. Chef has a positive integer N. He can apply any of the following operations as many times as he want ...
0.75
{"tests": "{\"inputs\": [\"3 4\\n1 2\\n1 3\", \"3 2\\n1 2\\n2 3\", \"3 2\\n2 2\\n1 3\", \"3 1\\n1 2\\n2 3\", \"3 1\\n1 2\\n3 3\", \"1 2\\n1 2\\n2 3\", \"3 4\\n1 2\\n2 3\", \"1 1\\n1 2\\n2 3\", \"1 1\\n2 2\\n2 3\", \"1 1\\n2 3\\n2 3\", \"1 1\\n2 3\\n1 3\", \"1 2\\n2 3\\n1 3\", \"1 2\\n2 3\\n1 2\", \"1 2\\n2 3\\n0 2\", \...
G: Tree problem Given a tree consisting of N vertices. Each vertex of the tree is numbered from 1 to N. Of the N-1 edges, the i \ (= 1, 2, ..., N-1) edge connects the vertex u_i and the vertex v_i. Write a program to find the number of K non-empty subgraph sets of this tree, each of which is concatenated and no two ...
0
{"tests": "{\"inputs\": [\"3 2\\n1 2 1\\n3 4\\n\", \"2 2\\n0 1\\n1 0\\n\", \"2 3\\n1 0\\n1 1 2\\n\", \"2 2\\n0 0\\n100000000 100000000\\n\", \"2 2\\n14419485 34715515\\n45193875 34715515\\n\", \"2 2\\n4114169 4536507\\n58439428 4536507\\n\", \"2 2\\n89164828 36174769\\n90570286 89164829\\n\", \"2 2\\n23720786 67248252\...
$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 \leq i \leq n$ the minimal number of sweets, which $i$-th boy presented to some g...
0
{"tests": "{\"inputs\": [[1], [10], [17], [50], [100], [200], [400], [800], [1000], [1200], [1500], [2000]], \"outputs\": [[0.5], [0.026314], [0.015193], [0.005073], [0.002524], [0.001259], [0.000628], [0.000314], [0.000251], [0.000209], [0.000167], [0.000125]]}", "source": "taco"}
## Euler's Method We want to calculate the shape of an unknown curve which starts at a given point with a given slope. This curve satisfies an ordinary differential equation (ODE): ```math \frac{dy}{dx} = f(x, y);\\ y(x_0) = y_0 ``` The starting point `$ A_0 (x_0, y_0) $` is known as well as the slope to the curve ...
0.125
{"tests": "{\"inputs\": [\"6 1\\n3 6 10 12 13 16\\n\", \"5 3\\n8 21 52 15 77\\n\", \"13 11\\n55 16 26 40 84 80 48 52 25 43 75 21 58\\n\", \"18 9\\n85 29 29 15 17 71 46 69 48 80 44 73 40 55 61 57 22 68\\n\", \"25 7\\n67 18 36 85 64 22 32 66 17 64 66 65 82 36 16 52 19 70 38 51 17 32 85 16 64\\n\", \"7 1\\n12 84 21 60 33 ...
Vasya's got a birthday coming up and his mom decided to give him an array of positive integers a of length n. Vasya thinks that an array's beauty is the greatest common divisor of all its elements. His mom, of course, wants to give him as beautiful an array as possible (with largest possible beauty). Unfortunately, th...
0.375
{"tests": "{\"inputs\": [\"()#(#())()()#)(#)()##)#((()#)((#)()#())((#((((((((#)()()(()()(((((#)#(#((((#((##()(##(((#(()(#((#))#\\n\", \"##((((((()\\n\", \"(((()#(#)(\\n\", \"(((((#(#(#(#()\\n\", \"#(#(#((##((()))(((#)(#()#(((()()(()#(##(((()(((()))#(((((()(((((((()#((#((()(#(((()(()##(()(((()((#(\\n\", \"(#(\\n\", \")(...
Malek has recently found a treasure map. While he was looking for a treasure he found a locked door. There was a string s written on the door consisting of characters '(', ')' and '#'. Below there was a manual on how to open the door. After spending a long time Malek managed to decode the manual and found out that the ...
0.375
{"tests": "{\"inputs\": [\"3 2\\n\", \"50 57129577186267\\n\", \"6 12\\n\", \"50 161245081749292\\n\", \"5 3\\n\", \"49 40394027154620\\n\", \"7 15\\n\", \"49 36309684494664\\n\", \"50 250144743882708\\n\", \"49 140149194635018\\n\", \"5 10\\n\", \"6 2\\n\", \"6 19\\n\", \"50 8840088596980\\n\", \"6 4\\n\", \"6 13\\n\"...
One Martian boy called Zorg wants to present a string of beads to his friend from the Earth — Masha. He knows that Masha likes two colours: blue and red, — and right in the shop where he has come, there is a variety of adornments with beads of these two colours. All the strings of beads have a small fastener, and if on...
0
{"tests": "{\"inputs\": [\"10 20 30\\n\", \"1 1 5\\n\", \"100 33 34\\n\", \"777 777 777\\n\", \"2 2 8\\n\", \"12 34 56\\n\", \"789 101112 131415\\n\", \"27485716 99999999 35182\\n\", \"1 293548 5\\n\", \"12059 259855 5874875\\n\", \"46981 105809 585858\\n\", \"9889 1221 2442\\n\", \"100500 200600 300700\\n\", \"318476 ...
Today Patrick waits for a visit from his friend Spongebob. To prepare for the visit, Patrick needs to buy some goodies in two stores located near his house. There is a d_1 meter long road between his house and the first shop and a d_2 meter long road between his house and the second shop. Also, there is a road of lengt...
0
{"tests": "{\"inputs\": [\"7.6\\n\", \"1950583094879039694852660558765931995628486712128191844305265555887022812284005463780616067.500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there. Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Ki...
0.375
{"tests": "{\"inputs\": [\"1 1 1\\n3\\n5\\n4\\n\", \"2 1 3\\n9 5\\n1\\n2 8 5\\n\", \"10 1 1\\n11 7 20 15 19 14 2 4 13 14\\n8\\n11\\n\", \"2 2 2\\n3 10\\n6 9\\n10 9\\n\", \"1 3 6\\n2\\n8 6 7\\n5 2 4 1 10 4\\n\", \"9 4 7\\n17 19 19 9 20 6 1 14 11\\n15 12 10 20\\n15 10 3 20 1 16 7\\n\", \"16 26 8\\n44 13 2 24 56 74 72 4 8...
You are given three multisets of pairs of colored sticks: $R$ pairs of red sticks, the first pair has length $r_1$, the second pair has length $r_2$, $\dots$, the $R$-th pair has length $r_R$; $G$ pairs of green sticks, the first pair has length $g_1$, the second pair has length $g_2$, $\dots$, the $G$-th pair has l...
0
{"tests": "{\"inputs\": [\"3 26 30\\n3 1 2\", \"4 20 30\\n3 2 3 1\", \"9 40 87\\n5 3 4 7 6 1 2 9 8\", \"4 8 30\\n3 2 3 1\", \"4 11 30\\n3 2 3 1\", \"4 20 36\\n4 2 3 1\", \"4 20 46\\n4 2 3 1\", \"9 67 87\\n5 3 4 7 6 1 3 12 8\", \"9 72 87\\n5 3 4 7 6 1 3 12 8\", \"1 8 10\\n1\", \"4 10 30\\n4 2 3 1\", \"3 14 30\\n3 1 2\",...
You are given a permutation p = (p_1, \ldots, p_N) of \\{ 1, \ldots, N \\}. You can perform the following two kinds of operations repeatedly in any order: * Pay a cost A. Choose integers l and r (1 \leq l < r \leq N), and shift (p_l, \ldots, p_r) to the left by one. That is, replace p_l, p_{l + 1}, \ldots, p_{r - 1}, ...
0
{"tests": "{\"inputs\": [\"3 4\\n2\\n01\\n1011\\n01001110\", \"4 6\\n1\\n01\\n1111\\n10111010\\n1101110011111101\", \"3 2\\n1\\n01\\n1011\\n01001110\", \"3 0\\n1\\n3\\n1111\\n01000110\", \"3 4\\n2\\n01\\n1001\\n01001110\", \"4 1\\n1\\n01\\n1101\\n01011110\\n1101110011011100\", \"4 1\\n1\\n01\\n1111\\n00111110\\n0101110...
You are given a set S of strings consisting of `0` and `1`, and an integer K. Find the longest string that is a subsequence of K or more different strings in S. If there are multiple strings that satisfy this condition, find the lexicographically smallest such string. Here, S is given in the format below: * The data...
0
{"tests": "{\"inputs\": [\"4 1 3 4 3\\n3 2 5 1\\n\", \"4 2 4 4 1\\n4 5 1 2\\n\", \"2 2 5 7 3\\n4 5\\n\", \"100 4 8 9 1\\n1 8 1 8 7 8 1 8 10 4 7 7 3 2 6 7 3 7 3 7 1 8 5 7 4 10 9 7 3 4 7 7 4 9 6 10 4 5 5 2 5 3 9 2 8 3 7 8 8 8 10 4 7 2 3 6 2 8 9 9 7 4 8 6 5 8 5 2 5 10 3 6 2 8 1 3 3 7 6 1 5 8 9 9 2 2 9 3 7 3 3 3 10 10 3 5 ...
Ziota found a video game called "Monster Invaders". Similar to every other shooting RPG game, "Monster Invaders" involves killing monsters and bosses with guns. For the sake of simplicity, we only consider two different types of monsters and three different types of guns. Namely, the two types of monsters are: a n...
0
{"tests": "{\"inputs\": [\"AprilFool\\n14\\n\", \"abcdefabc\\n3\\n\", \"fgWjSAlPOvcAbCdDEFjz\\n7\\n\", \"sm\\n26\\n\", \"GnlFOqPeZtPiBkvvLhaDvGPgFqBTnLgMT\\n12\\n\", \"sPWSFWWqZBPon\\n3\\n\", \"fQHHXCdeaintxHWcFcaSGWFvqnYMEByMlSNKumiFgnJB\\n0\\n\", \"RtsUOGkraqKyjTktAXloOEmQj\\n18\\n\", \"DuFhhnq\\n4\\n\", \"RvpuYTxsbD...
[Image] -----Input----- The first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase. The second line of the input is an integer between 0 and 26, inclusive. -----Output----- Output the required string. -----...
0.125
{"tests": "{\"inputs\": [[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 5], [[4, 3, 5], 2], [[10, 8, 7, 9], 3], [[8, 6, 4, 6], 3], [[10, 2, 3, 8, 1, 10, 4], 5], [[13, 12, -27, -302, 25, 37, 133, 155, -1], 5], [[-4, -27, -15, -6, -1], 2], [[-17, -8, -102, -309], 2], [[10, 3, -27, -1], 3], [[14, 29, -28, 39, -16, -48], 4]], \"outputs\...
### Introduction and Warm-up (Highly recommended) ### [Playing With Lists/Arrays Series](https://www.codewars.com/collections/playing-with-lists-slash-arrays) ___ ## Task **_Given_** an *array/list [] of integers* , **_Find the product of the k maximal_** numbers. ___ ### Notes * **_Array/list_** size is *at leas...
0
{"tests": "{\"inputs\": [\"3 3 0\\n\", \"3 2 1\\n\", \"3 3 2\\n\", \"123 45 67\\n\", \"1234 567 890\\n\", \"2000 23 45\\n\", \"50 2000 40\\n\", \"2000 2 1999\\n\", \"3 1 0\\n\", \"3 1 1\\n\", \"1 1 0\\n\", \"1 534 0\\n\", \"1926 817 0\\n\", \"1999 233 1998\\n\", \"1139 1252 348\\n\", \"1859 96 1471\\n\", \"1987 237 128...
On his free time, Chouti likes doing some housework. He has got one new task, paint some bricks in the yard. There are $n$ bricks lined in a row on the ground. Chouti has got $m$ paint buckets of different colors at hand, so he painted each brick in one of those $m$ colors. Having finished painting all bricks, Chouti...
0.375
{"tests": "{\"inputs\": [\"5\\n1 2 5 4 3\\n\", \"7\\n1 2 4 6 5 3 7\\n\", \"7\\n2 5 7 3 1 4 6\\n\", \"2\\n1 2\\n\", \"7\\n7 3 5 6 4 2 1\\n\", \"50\\n3 10 13 26 31 27 22 20 9 8 33 30 12 21 16 7 17 11 6 24 14 5 19 25 29 36 37 40 41 44 45 46 47 48 49 50 43 42 39 38 35 34 32 28 23 18 15 4 2 1\\n\", \"3\\n1 3 2\\n\", \"3\\n1...
On a weekend, Qingshan suggests that she and her friend Daniel go hiking. Unfortunately, they are busy high school students, so they can only go hiking on scratch paper. A permutation $p$ is written from left to right on the paper. First Qingshan chooses an integer index $x$ ($1\le x\le n$) and tells it to Daniel. Aft...
0
{"tests": "{\"inputs\": [[1], [7], [12], [86], [99], [1149], [983212]], \"outputs\": [[2], [9], [15], [100], [150], [1500], [1500000]]}", "source": "taco"}
Adding tip to a restaurant bill in a graceful way can be tricky, thats why you need make a function for it. The function will receive the restaurant bill (always a positive number) as an argument. You need to 1) **add at least 15%** in tip, 2) round that number up to an *elegant* value and 3) return it. What is an *e...
0
{"tests": "{\"inputs\": [\"5\\n\", \"3\\n\", \"54321\\n\", \"4\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"10\\n\", \"54320\\n\", \"54319\\n\", \"54318\\n\", \"54317\\n\", \"54316\\n\", \"54315\\n\", \"54314\\n\", \"8153\\n\", \"51689\\n\", \"16659\\n\", \"47389\\n\", \"314\\n\", \"23481\\n\", \"20380\\n\", \"1994\...
Ari the monster always wakes up very early with the first ray of the sun and the first thing she does is feeding her squirrel. Ari draws a regular convex polygon on the floor and numbers it's vertices 1, 2, ..., n in clockwise order. Then starting from the vertex 1 she draws a ray in the direction of each other vertex...
0.5
{"tests": "{\"inputs\": [\"5\\n11010\\n\", \"7\\n1110010\\n\", \"4\\n0000\\n\", \"5\\n10110\\n\", \"5\\n10111\\n\", \"5\\n11011\\n\", \"5\\n11000\\n\", \"5\\n10000\\n\", \"5\\n10110\\n\", \"5\\n10111\\n\"], \"outputs\": [\"11111\\n\", \"1111110\\n\", \"0\\n\", \"11111\\n\", \"11111\\n\", \"11111\\n\", \"11110\\n\", \"1...
You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1. A substring of $s$ is a contiguous subsequence of its characters. You have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing th...
0
{"tests": "{\"inputs\": [\"8\\n-2.14 2.06\\n-1.14 2.04\\n-2.16 1.46\\n-2.14 0.70\\n-1.42 0.40\\n-0.94 -0.48\\n-1.42 -1.28\\n-2.16 -1.62\\n\", \"5\\n2.26 1.44\\n2.28 0.64\\n2.30 -0.30\\n1.58 0.66\\n3.24 0.66\\n\", \"8\\n6.98 2.06\\n6.40 1.12\\n5.98 0.24\\n5.54 -0.60\\n7.16 0.30\\n7.82 1.24\\n8.34 0.24\\n8.74 -0.76\\n\",...
-----Input----- The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points on a plane. Each of the next n lines contains two real coordinates x_{i} and y_{i} of the $i^{\text{th}}$ point, specified with exactly 2 fractional digits. All coordinates are between - 1000 and 1000, inclusive. -----...
0
{"tests": "{\"inputs\": [\"2\\n-3 1\\n1 3 5 7 9 11\\n1000000000 1000000000\\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\\n\", \"1\\n0 0\\n1 2 3 4 5 6\\n\", \"1\\n-1000000000 -1000000000\\n10000 20000 30000 40000 50000 60000\\n\", \"1\\n-1000000000 -1000000000\\n10000 20000 30000 40000 50000 60000...
Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world. Consider a hexagonal tiling of the plane as on the picture below. [Image] Nicks wishes to go from the cell marked $(0, 0)$ to a certain cell given by the coordi...
0
{"tests": "{\"inputs\": [\"2\\n\", \"654321\\n\", \"1000000\\n\", \"999745\\n\", \"999880\\n\", \"999999\\n\", \"1\\n\", \"14\\n\", \"22\\n\", \"25002\\n\", \"2956\\n\", \"3\\n\", \"380467\\n\", \"407774\\n\", \"52228\\n\", \"68\\n\", \"804783\\n\", \"85984\\n\", \"894324\\n\", \"93\\n\", \"963981\\n\", \"968416\\n\", ...
How many infinite sequences a_1, a_2, ... consisting of {{1, ... ,n}} satisfy the following conditions? - The n-th and subsequent elements are all equal. That is, if n \leq i,j, a_i = a_j. - For every integer i, the a_i elements immediately following the i-th element are all equal. That is, if i < j < k\leq i+a_i, a_...
0
{"tests": "{\"inputs\": [\"())(())(())(\\n7\\n1 1\\n2 3\\n1 2\\n1 12\\n8 12\\n5 11\\n2 10\\n\", \"(((((()((((((((((()((()(((((\\n1\\n8 15\\n\", \"((()((())(((((((((()(()(()(((((((((((((((()(()((((((((((((((()(((((((((((((((((((()(((\\n39\\n28 56\\n39 46\\n57 63\\n29 48\\n51 75\\n14 72\\n5 70\\n51 73\\n10 64\\n31 56\\n5...
Sereja has a bracket sequence s_1, s_2, ..., s_{n}, or, in other words, a string s of length n, consisting of characters "(" and ")". Sereja needs to answer m queries, each of them is described by two integers l_{i}, r_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n). The answer to the i-th query is the length of the maximum correct brack...
0
{"tests": "{\"inputs\": [\"4 4\\n1 4\\n7 8\\n9 10\\n12 14\\n4 5 3 8\\n\", \"2 2\\n11 14\\n17 18\\n2 9\\n\", \"2 1\\n1 1\\n1000000000000000000 1000000000000000000\\n999999999999999999\\n\", \"5 10\\n1 2\\n3 3\\n5 7\\n11 13\\n14 20\\n9 10 2 9 10 4 9 9 9 10\\n\", \"5 9\\n1 2\\n3 3\\n5 7\\n11 13\\n14 20\\n2 3 4 10 6 2 6 9 ...
Andrewid the Android is a galaxy-famous detective. He is now chasing a criminal hiding on the planet Oxa-5, the planet almost fully covered with water. The only dry land there is an archipelago of n narrow islands located in a row. For more comfort let's represent them as non-intersecting segments on a straight line: ...
0.5
{"tests": "{\"inputs\": [[[3, 7], [1, 2], [-1, 1], 13], [[1, 2], [0, 0], [1, 1], 6], [[2, 2], [1, 0], [1, 1], 12], [[1, 1], [0, 0], [1, -1], 1000000000], [[2, 3], [1, 2], [-1, -1], 41], [[17, 19], [14, 8], [1, -1], 239239], [[17, 19], [16, 18], [1, 1], 239239239]], \"outputs\": [[[0, 1]], [[0, 1]], [[1, 0]], [[0, 0]], ...
# Task In ChessLand there is a small but proud chess bishop with a recurring dream. In the dream the bishop finds itself on an `n × m` chessboard with mirrors along each edge, and it is not a bishop but a ray of light. This ray of light moves only along diagonals (the bishop can't imagine any other types of moves ...
0
{"tests": "{\"inputs\": [\"4 4 6\\n2 2\\n3 2 \\n3 2 \\n4 3\\n4 4\\n4 3\", \"4 4 6\\n3 2\\n3 2 \\n3 2 \\n4 3\\n4 4\\n4 3\", \"4 4 6\\n3 2\\n3 2 \\n3 2 \\n4 3\\n4 4\\n4 1\", \"4 4 6\\n3 2\\n3 3 \\n3 2 \\n4 3\\n4 4\\n4 3\", \"4 6 6\\n3 2\\n2 3 \\n3 2 \\n4 3\\n4 4\\n4 3\", \"4 6 2\\n3 2\\n2 3 \\n3 2 \\n4 3\\n4 4\\n4 3\", \...
Read problems statements in Mandarin Chinese and Russian. Spring is interesting season of year. Chef is thinking about different things, but last time he thinks about interesting game - "Strange Matrix". Chef has a matrix that consists of n rows, each contains m elements. Initially, the element a_{i}_{j} of matrix e...
0
{"tests": "{\"inputs\": [\"1\\n1\\n2\\n7\\n\", \"2\\n1 2\\n2 3\\n11\\n\", \"100\\n1 8 10 6 5 3 2 3 4 2 3 7 1 1 5 1 4 1 8 1 5 5 6 5 3 7 4 5 5 3 8 7 8 6 8 9 10 7 8 5 8 9 1 3 7 2 6 1 7 7 2 8 1 5 4 2 10 4 9 8 1 10 1 5 9 8 1 9 5 1 5 7 1 6 7 8 8 2 2 3 3 7 2 10 6 3 6 3 5 3 10 4 4 6 9 9 3 2 6 6\\n4 3 8 4 4 2 4 6 6 3 3 5 8 4 1 ...
Little Dima has two sequences of points with integer coordinates: sequence (a_1, 1), (a_2, 2), ..., (a_{n}, n) and sequence (b_1, 1), (b_2, 2), ..., (b_{n}, n). Now Dima wants to count the number of distinct sequences of points of length 2·n that can be assembled from these sequences, such that the x-coordinates of po...
0
{"tests": "{\"inputs\": [\"2\\n0\\n0\\n\", \"3\\n-1 5\\n-4\\n\", \"7\\n0 0 0 10\\n1\\n\", \"10\\n-1 -1 -1 -1 6\\n-1\\n\", \"5\\n17 -1345 246\\n541\\n\", \"2\\n10\\n-10\\n\", \"6\\n200 -99 -299\\n67\\n\", \"2\\n57\\n179\\n\", \"6\\n0 0 -15\\n5\\n\", \"2\\n2\\n2\\n\", \"2\\n1000000000\\n-1000000000\\n\", \"17\\n-54247064...
Levian works as an accountant in a large company. Levian knows how much the company has earned in each of the n consecutive months — in the i-th month the company had income equal to a_i (positive income means profit, negative income means loss, zero income means no change). Because of the general self-isolation, the f...
0
{"tests": "{\"inputs\": [\"10264\\n\", \"217\\n\", \"7\\n\", \"777777\\n\", \"47248\\n\", \"13\\n\", \"301\\n\", \"1034\\n\", \"6\\n\", \"6486\\n\", \"225481\\n\", \"1\\n\", \"403\\n\", \"6726\\n\", \"43\\n\", \"9\\n\", \"21352\\n\", \"999811\\n\", \"10000\\n\", \"999998\\n\", \"51\\n\", \"498598\\n\", \"5832\\n\", \"2...
A breakthrough among computer games, "Civilization XIII", is striking in its scale and elaborate details. Let's take a closer look at one of them. The playing area in the game is split into congruent cells that are regular hexagons. The side of each cell is equal to 1. Each unit occupies exactly one cell of the playin...
0
{"tests": "{\"inputs\": [\"5 1000000000\\n3 1 1000000000\\n7 6 1000000000\\n4 4 1000000000\\n6 8 1000000000\\n2 5 1000000000\", \"4 8\\n4 3 2\\n2 1 1\\n1 2 4\\n2 2 2\", \"5 1000000000\\n4 1 1000000000\\n7 6 1000100000\\n4 4 1000000000\\n6 14 1000000000\\n2 5 1000000000\", \"5 1000000000\\n3 5 1000000000\\n7 6 100000000...
You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$. You want to find a subset of items to put such that: * The total value of the items is as large as possible. * The items have combined weight at most $W$, that is capacity of the knapsack. * You ...
0.25
{"tests": "{\"inputs\": [[10000, true], [25000, true], [10000, false], [60000, false], [2, true], [78, false], [67890, true]], \"outputs\": [[\"$100000\"], [\"$250000\"], [\"$10000\"], [\"$60000\"], [\"$20\"], [\"$78\"], [\"$678900\"]]}", "source": "taco"}
It's bonus time in the big city! The fatcats are rubbing their paws in anticipation... but who is going to make the most money? Build a function that takes in two arguments (salary, bonus). Salary will be an integer, and bonus a boolean. If bonus is true, the salary should be multiplied by 10. If bonus is false, the...
0
{"tests": "{\"inputs\": [\"9\\n1 10 7 1\\n3 3 3 0\\n8 2 10 4\\n8 2 10 100\\n-10 20 -17 2\\n-3 2 2 0\\n-3 1 2 0\\n2 3 2 3\\n-1 3 -2 2\\n\", \"9\\n1 10 7 1\\n3 3 3 0\\n8 2 10 4\\n8 2 10 100\\n-10 20 -17 2\\n-3 1 2 0\\n-3 1 2 0\\n2 3 2 3\\n-1 3 -2 2\\n\", \"9\\n1 10 7 1\\n3 3 3 0\\n8 2 10 4\\n8 2 10 100\\n-10 13 -17 2\\n-...
Polycarp lives on the coordinate axis $Ox$ and travels from the point $x=a$ to $x=b$. It moves uniformly rectilinearly at a speed of one unit of distance per minute. On the axis $Ox$ at the point $x=c$ the base station of the mobile operator is placed. It is known that the radius of its coverage is $r$. Thus, if Polyc...
0.625
{"tests": "{\"inputs\": [\"2\\n3 2\\n1 2\\n2 3\\n3 3\\n1 2\\n2 3\\n1 3\", \"2\\n3 2\\n1 2\\n2 3\\n3 3\\n1 2\\n2 3\\n2 3\", \"2\\n4 2\\n1 2\\n4 3\\n3 3\\n1 2\\n3 3\\n2 2\", \"2\\n3 2\\n1 2\\n2 5\\n3 2\\n1 2\\n2 3\\n1 1\", \"2\\n7 4\\n1 2\\n2 3\\n4 3\\n1 2\\n2 0\\n2 4\", \"2\\n4 2\\n1 2\\n2 3\\n3 3\\n1 2\\n2 3\\n2 3\", \...
Read problems statements in Mandarin Chinese and Russian. The following is an easy game that the setter of this problem played when he was 8: A boatman, a wolf, a sheep, and a cabbage are on the bank of a river. They have a small boat that is capable of carrying the boatman and at most one other animal/item with hi...
0
{"tests": "{\"inputs\": [\"7 3\\n1 2 6 1 1 7 1\\n\", \"1 1\\n100\\n\", \"2 1\\n10 20\\n\", \"10 5\\n1 2 3 1 2 2 3 1 4 5\\n\", \"10 2\\n3 1 4 1 4 6 2 1 4 6\\n\", \"2 2\\n20 10\\n\", \"2 1\\n20 1\\n\", \"3 1\\n1 2 3\\n\", \"3 1\\n2 1 3\\n\", \"3 1\\n3 2 1\\n\", \"3 2\\n1 2 3\\n\", \"3 2\\n3 2 1\\n\", \"3 3\\n1 2 3\\n\", ...
There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is h_{i} meters, distinct planks can have distinct heights. [Image] Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] Polycarpus has bought a posh pi...
0.875
{"tests": "{\"inputs\": [\"1\\n5\\n4 4 4 4 4\\n5 5 5 5 5\\n\", \"1\\n8\\n7 8 6 4 6 4 2 3\\n2 4 7 6 4 8 3 6\\n\", \"1\\n9\\n5 4 3 2 1 3 2 2 1\\n1 2 3 4 1 2 2 3 5\\n\", \"1\\n5\\n3 1 2 4 5\\n2 5 4 3 1\\n\", \"1\\n10\\n10 9 8 7 6 5 4 3 2 1\\n9 8 7 6 5 4 3 2 1 10\\n\", \"1\\n4\\n4 3 2 1\\n3 4 1 2\\n\", \"1\\n6\\n6 4 4 2 5 ...
You are given an array a_1, a_2, ..., a_n and an array b_1, b_2, ..., b_n. For one operation you can sort in non-decreasing order any subarray a[l ... r] of the array a. For example, if a = [4, 2, 2, 1, 3, 1] and you choose subbarray a[2 ... 5], then the array turns into [4, 1, 2, 2, 3, 1]. You are asked to determi...
0
{"tests": "{\"inputs\": [\"abacabaca\\n\", \"abaca\\n\", \"gzqgchv\\n\", \"iosdwvzerqfi\\n\", \"oawtxikrpvfuzugjweki\\n\", \"abcdexyzzzz\\n\", \"affviytdmexpwfqplpyrlniprbdphrcwlboacoqec\\n\", \"lmnxtobrknqjvnzwadpccrlvisxyqbxxmghvl\\n\", \"hzobjysjhbebobkoror\\n\", \"glaoyryxrgsysy\\n\", \"aaaaaxyxxxx\\n\", \"aaaaax\\...
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
0.125
{"tests": "{\"inputs\": [\"4\\n3 2 0\\n6 5 1\\n7 4 0\\n8 1 1\\n\", \"1\\n454971987 406874902 1\\n\", \"5\\n243385510 42245605 0\\n644426565 574769163 0\\n708622105 208990040 0\\n786625660 616437691 0\\n899754846 382774619 0\\n\", \"5\\n200000000 100000000 1\\n600000000 400000000 0\\n800000000 300000000 0\\n900000000 70...
An ant moves on the real line with constant speed of $1$ unit per second. It starts at $0$ and always moves to the right (so its position increases by $1$ each second). There are $n$ portals, the $i$-th of which is located at position $x_i$ and teleports to position $y_i < x_i$. Each portal can be either active or ina...
0.125
{"tests": "{\"inputs\": [\"0 0 1 2\\n1\\n0 1\\n2 2\", \"0 -1 0 2\\n0\\n2 2\", \"1 0 0 2\\n0\\n2 2\", \"0 0 0 2\\n6\\n0 1\\n1 -1\\n1 0\\n0 -1\\n-1 -1\\n-1 0\\n2 2\", \"1 2 0 0\\n1\\n-1 0\\n4 2\", \"-11 -1 1 0\\n1\\n-1 -2\\n21 33\", \"-11 -1 1 -1\\n1\\n-1 -2\\n21 33\", \"-6 -1 1 -1\\n1\\n-1 -2\\n21 33\", \"-17 -1 1 -1\\n...
The full exploration sister is a very talented woman. Your sister can easily count the number of routes in a grid pattern if it is in the thousands. You and your exploration sister are now in a room lined with hexagonal tiles. The older sister seems to be very excited about the hexagon she sees for the first time. The ...
0
{"tests": "{\"inputs\": [\"100020001\\n\", \"100000000000000000222\\n\", \"8008\\n\", \"10000555\\n\", \"20020201\\n\", \"7\\n\", \"10001\\n\", \"2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002\\n\", \"8059\\n\", \"100000001\\n\", \"200000000000000111\\n\", \"200093\...
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible. The number is called beautiful if it consists of at least one digit, doesn't have leading zer...
0
{"tests": "{\"inputs\": [[\"A6C2E5Z9A4.-F%8.08.\"], [\"PP P6A6T5F5S3.-Z%1.11.hgr\"], [\"A6A1E3A8M2.-Q%8.88.\"], [\"d G8H1E2O9N3.-W%8.56. f\"], [\"B4A1D1I8B4.-E%8.76.\"], [\"ffr65A C8K4D9U7V5.-Y%8.00.\"], [\" 76 B2L4D0A8C6.-T%8.90. lkd\"], [\"B2L4D0A8C6.-T%8.90\"], [\"B2L4D0AFC6.-T%8.90.\"], [\"B4A1D1I8B4\"], ...
Chuck has lost count of how many asses he has kicked... Chuck stopped counting at 100,000 because he prefers to kick things in the face instead of counting. That's just who he is. To stop having to count like a mere mortal chuck developed his own special code using the hairs on his beard. You do not need to know the ...
0
{"tests": "{\"inputs\": [\"8\\n285 224 U\\n130 175 R\\n111 198 D\\n121 188 L\\n201 116 U\\n112 121 R\\n145 239 D\\n185 107 L\", \"4\\n20 30 U\\n30 20 R\\n20 10 D\\n19 20 L\", \"4\\n20 9 U\\n30 20 R\\n20 10 D\\n10 20 L\", \"8\\n285 68 U\\n70 175 R\\n111 192 D\\n15 123 L\\n200 116 U\\n0 121 R\\n119 240 D\\n99 107 L\", \"...
M-kun is a brilliant air traffic controller. On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all flying at the same altitude. Each of the airplanes flies at a constant speed of 0.1 per second in a constant direction. The current coordinates of the airplane numbered i are (X_i, Y_i), and the d...
0.5
{"tests": "{\"inputs\": [\"4\\n25 4\\n9 20\\n1 1 10\\n25 4\\n12 20\\n1 1 10\\n100 1\\n45 2\\n0 4 10\\n9 2\\n69 2\\n4 2 7\\n\", \"1\\n1 1\\n10000100000 1\\n200000 1 1\\n\", \"1\\n1 1\\n10000100000 1\\n199999 1 1\\n\", \"1\\n1 1\\n10000100000 1\\n199998 1 1\\n\", \"1\\n1 1\\n10000200001 1\\n199999 1 1\\n\", \"1\\n1 1\\n1...
Monocarp is playing a computer game. In this game, his character fights different monsters. A fight between a character and a monster goes as follows. Suppose the character initially has health $h_C$ and attack $d_C$; the monster initially has health $h_M$ and attack $d_M$. The fight consists of several steps: the ch...
0.375
{"tests": "{\"inputs\": [\"4 1\\n1 2 1 5\\n\", \"4 1\\n1 2 3 4\\n\", \"50 1\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50\\n\", \"10 1\\n1 2 3 4 5 6 7 8 9 10\\n\", \"50 5\\n232 6 11 16 21 26 31 36 41 46 665 56 61 66 71 76 6...
The Queen of England has n trees growing in a row in her garden. At that, the i-th (1 ≤ i ≤ n) tree from the left has height a_{i} meters. Today the Queen decided to update the scenery of her garden. She wants the trees' heights to meet the condition: for all i (1 ≤ i < n), a_{i} + 1 - a_{i} = k, where k is the number ...
0.375
{"tests": "{\"inputs\": [\"5\\n1000000000 1000000000 1000000000 1000000000 1000000000\\n100000 100000 100000 100000 100000\\n\", \"10\\n14 31 50 67 42 44 86 82 35 63\\n76 17 26 44 60 54 50 73 71 70\\n\", \"10\\n4 4 1 2 2 2 5 4 1 5\\n28 81 36 44 2 40 39 43 36 33\\n\", \"10\\n69564153 558821634 273092444 121621442 354953...
VK news recommendation system daily selects interesting publications of one of n disjoint categories for each user. Each publication belongs to exactly one category. For each category i batch algorithm selects a_i publications. The latest A/B test suggests that users are reading recommended publications more actively ...
0
{"tests": "{\"inputs\": [[[2, 3, 5, 2], 3], [[1, 3, 3, 1, 1], 0], [[5, 1, 3, 4, 1], 0], [[1, 1, 1, 1], 1], [[1, 1, 1, 1], 0], [[3, 1, 1, 3, 1], 2]], \"outputs\": [[2], [0], [1], [4], [0], [2]]}", "source": "taco"}
# Task Elections are in progress! Given an array of numbers representing votes given to each of the candidates, and an integer which is equal to the number of voters who haven't cast their vote yet, find the number of candidates who still have a chance to win the election. The winner of the election must secure stri...
0
{"tests": "{\"inputs\": [[10, 10, 10], [10, 10, 5], [100, 5, 5], [50, 12, 1], [47.5, 8, 8], [100, 1, 1], [10, 1, 1], [100, 1, 5]], \"outputs\": [[22], [29], [59], [37], [31], [459], [459], [299]]}", "source": "taco"}
This program tests the life of an evaporator containing a gas. We know the content of the evaporator (content in ml), the percentage of foam or gas lost every day (evap_per_day) and the threshold (threshold) in percentage beyond which the evaporator is no longer useful. All numbers are strictly positive. The program...
0
{"tests": "{\"inputs\": [\"2\\n2\\n2 2\\n1\\n6\", \"2\\n2\\n2 1\\n1\\n6\", \"2\\n2\\n2 2\\n1\\n8\", \"2\\n2\\n4 2\\n1\\n6\", \"2\\n1\\n2 1\\n1\\n1\", \"2\\n3\\n3 2\\n1\\n8\", \"2\\n3\\n4 2\\n0\\n1\", \"2\\n3\\n4 7\\n0\\n6\", \"2\\n3\\n5 2\\n0\\n2\", \"2\\n4\\n4 9\\n0\\n6\", \"2\\n6\\n4 11\\n0\\n6\", \"2\\n0\\n2 2\\n1\\...
Read problems statements in Mandarin Chinese and Russian. Rupsa recently started to intern under Chef. He gave her N type of ingredients of varying quantity A_{1}, A_{2}, ..., A_{N} respectively to store it. But as she is lazy to arrange them she puts them all in a storage box. Chef comes up with a new recipe and ...
0
{"tests": "{\"inputs\": [\"8 5\", \"0 7\", \"25732 234567\", \"0 5\", \"3 4\", \"0 11\", \"29001 234567\", \"4 7\", \"2 5\", \"4 8\", \"3 5\", \"4 12\", \"3 6\", \"4 18\", \"7 10\", \"4 13\", \"7 7\", \"4 15\", \"4 17\", \"7 17\", \"7 21\", \"10 21\", \"4 21\", \"2 21\", \"1 21\", \"1 39\", \"2 39\", \"2 36\", \"2 57\"...
In Republic of AtCoder, Snuke Chameleons (Family: Chamaeleonidae, Genus: Bartaberia) are very popular pets. Ringo keeps N Snuke Chameleons in a cage. A Snuke Chameleon that has not eaten anything is blue. It changes its color according to the following rules: * A Snuke Chameleon that is blue will change its color to ...
0
{"tests": "{\"inputs\": [\"aab\\n\", \"bcbc\\n\", \"ddd\\n\", \"ddc\", \"aaa\", \"adad\", \"bbcc\", \"dec\", \"aa`\", \"ccbb\", \"eec\", \"aa_\", \"ccbc\", \"cee\", \"ba_\", \"cbbc\", \"ece\", \"_ab\", \"ccba\", \"eed\", \"`ab\", \"ccab\", \"dee\", \"`ba\", \"bcac\", \"eee\", \"`b`\", \"bcca\", \"dfe\", \"ab`\", \"bcc`...
Let x be a string of length at least 1. We will call x a good string, if for any string y and any integer k (k \geq 2), the string obtained by concatenating k copies of y is different from x. For example, a, bbc and cdcdc are good strings, while aa, bbbb and cdcdcd are not. Let w be a string of length at least 1. For a...
0.875
{"tests": "{\"inputs\": [\"6\\n1\\n4\\n12\\n6\\n2\", \"6\\n1\\n7\\n12\\n6\\n2\", \"6\\n1\\n4\\n3\\n5\\n3\", \"6\\n1\\n0\\n5\\n4\\n1\", \"6\\n0\\n0\\n5\\n0\\n1\", \"6\\n0\\n7\\n11\\n5\\n3\", \"6\\n1\\n0\\n5\\n4\\n2\", \"6\\n0\\n0\\n5\\n-1\\n1\", \"6\\n1\\n14\\n11\\n3\\n2\", \"6\\n2\\n8\\n17\\n6\\n2\", \"6\\n-1\\n0\\n14\...
problem There is one bar-shaped candy with a length of N mm (where N is an even number). Two JOI officials decided to cut this candy into multiple pieces and divide them into a total of N / 2 mm. did. For unknown reasons, this candy has different ease of cutting depending on the location. The two examined the candy e...
0
{"tests": "{\"inputs\": [\"4\\n1 -5 3 2\\n\", \"5\\n4 -2 3 -9 2\\n\", \"9\\n-1 1 -1 1 -1 1 1 -1 -1\\n\", \"8\\n16 -5 -11 -15 10 5 4 -4\\n\", \"2\\n1000000000 1000000000\\n\", \"2\\n-1000000000 -1000000000\\n\", \"2\\n1000000000 -1000000000\\n\", \"2\\n-1000000000 1000000000\\n\", \"3\\n1000000000 1000000000 1000000000\...
Kolya got an integer array $a_1, a_2, \dots, a_n$. The array can contain both positive and negative integers, but Kolya doesn't like $0$, so the array doesn't contain any zeros. Kolya doesn't like that the sum of some subsegments of his array can be $0$. The subsegment is some consecutive segment of elements of the ar...
0.375
{"tests": "{\"inputs\": [\"5\\n1 2 3 4 5\\n\", \"6\\n6 12 3 15 9 18\\n\", \"6\\n28 4 13 29 17 8\\n\", \"9\\n23 1 2 26 9 11 23 10 26\\n\", \"7\\n18 29 23 23 1 14 5\\n\", \"5\\n22 19 19 16 14\\n\", \"9\\n17 16 8 13 6 29 22 27 18\\n\", \"6\\n12 12 29 10 30 32\\n\", \"7\\n31 1 19 3 11 20 31\\n\", \"5\\n27 30 8 32 3\\n\", \...
From "ftying rats" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? The upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as r...
0
{"tests": "{\"inputs\": [\"3\\n1 2 3\\n\", \"3\\n2 1 2\\n\", \"6\\n8 6 5 10 9 14\\n\", \"6\\n4 6 1 9 6 10\\n\", \"6\\n6 8 10 5 7 4\\n\", \"5\\n4 5 7 10 9\\n\", \"6\\n7 4 4 2 6 1\\n\", \"5\\n9 7 4 4 1\\n\", \"6\\n9 7 3 6 10 10\\n\", \"6\\n5 10 7 2 3 5\\n\", \"6\\n6 3 4 5 5 5\\n\", \"6\\n4 5 10 1 2 2\\n\", \"6\\n2 10 3 7...
Given is an integer sequence of length N: A_1, A_2, \cdots, A_N. An integer sequence X, which is also of length N, will be chosen randomly by independently choosing X_i from a uniform distribution on the integers 1, 2, \ldots, A_i for each i (1 \leq i \leq N). Compute the expected value of the length of the longest inc...
0