info
stringlengths
120
50k
question
stringlengths
504
10.4k
avg@8_qwen3_4b_instruct_2507
float64
0
0.88
{"tests": "{\"inputs\": [\"4\\n\", \"5\\n\", \"1\\n\", \"2\\n\", \"3\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"1000000000000\\n\", \"963201794869\\n\", \"902076349729\\n\", \"549755813888\\n\", \"951069502319\\n\", \"442654694329\\n\", \"930881829259\\n\", \"974059904437\\n\", \"912943012301\\n\", \"934464422329\...
Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate. The path consists of $n$ consecutive tiles, numbered from $1$ to $n$. Ujan will paint each tile in some color. He will consider the path aesthetic if for any two different til...
0.5
{"tests": "{\"inputs\": [\"5 4\\n3\\n1 1\\n3 4\\n5 6\", \"6 4\\n3\\n1 1\\n1 4\\n5 6\", \"6 4\\n3\\n1 1\\n1 4\\n5 12\", \"6 4\\n3\\n0 1\\n1 4\\n5 12\", \"5 4\\n3\\n1 1\\n3 4\\n5 2\", \"5 4\\n3\\n1 1\\n3 4\\n7 6\", \"6 4\\n3\\n1 0\\n1 4\\n5 6\", \"6 4\\n3\\n1 1\\n1 3\\n5 12\", \"6 4\\n3\\n0 1\\n1 4\\n5 0\", \"5 4\\n3\\n1...
At the end of last year, Santa Claus forgot to give Christmas presents to the children in JOI village. Therefore, I decided to deliver the chocolate cake to the children as an apology. The day to deliver is approaching tomorrow, so it's time to come up with a move plan. JOI village is divided into a grid shape by W ro...
0
{"tests": "{\"inputs\": [[[1, 120], [2, 60], 4], [[1, 120], [2, 60], 8], [[1, 120], [4, 30], 8], [[1, 120], [3, 60], 9], [[1, 120], [3, 60], 27], [[1, 120], [9, 30], 27], [[1, 81], [2, 27], 4], [[1, 81], [2, 27], 8], [[1, 81], [4, 9], 8], [[1, 81], [5, 27], 25], [[1, 81], [5, 27], 125], [[1, 81], [25, 9], 125], [[4, 30...
A [Power Law](https://en.wikipedia.org/wiki/Power_law) distribution occurs whenever "a relative change in one quantity results in a proportional relative change in the other quantity." For example, if *y* = 120 when *x* = 1 and *y* = 60 when *x* = 2 (i.e. *y* halves whenever *x* doubles) then when *x* = 4, *y* = 30 and...
0
{"tests": "{\"inputs\": [\"4\\n4 3\\nBRBB\\nRBR\\n4 7\\nBRBR\\nRRBRBRB\\n3 4\\nRBR\\nBRBR\\n5 4\\nBRBRR\\nBRBR\\n\", \"23\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n1 1\\nR\\nB\\n...
There are two towers consisting of blocks of two colors: red and blue. Both towers are represented by strings of characters B and/or R denoting the order of blocks in them from the bottom to the top, where B corresponds to a blue block, and R corresponds to a red block. These two towers are represented by strings BRBB...
0
{"tests": "{\"inputs\": [\"1 5\\n\", \"2 3\\n\", \"4 6\\n\", \"6 3\\n\", \"1 1\\n\", \"10 1\\n\", \"20 10\\n\", \"1000 10000\\n\", \"139 9252\\n\", \"859 8096\\n\", \"987 4237\\n\", \"411 3081\\n\", \"539 9221\\n\", \"259 770\\n\", \"387 5422\\n\", \"515 1563\\n\", \"939 407\\n\", \"518 6518\\n\", \"646 1171\\n\", \"70...
Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees. Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≤ x, y. There is a tree in such a point, and it has x + y bananas. There are no trees nor bananas in other point...
0
{"tests": "{\"inputs\": [\"2\\n4\\n2 6\\n5 4\\n\", \"96\\n4\\n1 5\\n5 1\\n6 5\\n2 1\\n2 1\\n2 6\\n6 5\\n6 5\\n6 2\\n2 6\\n1 5\\n6 5\\n1 5\\n2 6\\n6 5\\n5 6\\n2 1\\n2 6\\n1 2\\n1 5\\n2 6\\n2 6\\n2 1\\n1 5\\n5 1\\n1 2\\n2 6\\n2 6\\n6 5\\n1 5\\n2 1\\n2 6\\n1 2\\n5 6\\n1 5\\n2 6\\n6 2\\n2 6\\n6 5\\n1 5\\n6 5\\n6 5\\n1 5\\n...
A dice is a cube, its faces contain distinct integers from 1 to 6 as black points. The sum of numbers at the opposite dice faces always equals 7. Please note that there are only two dice (these dices are mirror of each other) that satisfy the given constraints (both of them are shown on the picture on the left). <imag...
0.25
{"tests": "{\"inputs\": [\"1\\n8 6\\n1 2 3 4 5 6\\n7 8 9 10 11 12\\n13 14 15 16 17 18\\n19 20 21 22 23 24\\n26 27 28 29 30 31\\n33 34 35 36 34 35\\n37 38 39 40 41 42\\n44 45 46 47 48 49\\n\", \"1\\n8 6\\n1 2 3 4 5 6\\n7 8 9 10 11 12\\n13 14 15 16 17 18\\n19 20 21 22 23 24\\n26 27 28 29 30 31\\n33 2 35 36 34 35\\n37 38 ...
You are playing one famous sandbox game with the three-dimensional world. The map of the world can be represented as a matrix of size n × m, where the height of the cell (i, j) is a_{i, j}. You are in the cell (1, 1) right now and want to get in the cell (n, m). You can move only down (from the cell (i, j) to the cell...
0.25
{"tests": "{\"inputs\": [\"5\\n1 0 1\\n20 1 0\\n300 0 1\\n4000 0 0\\n50000 1 0\\n1 2\\n2 3\\n2 4\\n1 5\\n\", \"5\\n10000 0 1\\n2000 1 0\\n300 0 1\\n40 0 0\\n1 1 0\\n1 2\\n2 3\\n2 4\\n1 5\\n\", \"2\\n109 0 1\\n205 0 1\\n1 2\\n\", \"8\\n82 0 0\\n3 1 1\\n53 0 0\\n5 0 0\\n81 0 1\\n56 1 0\\n99 1 0\\n87 0 1\\n5 7\\n2 8\\n4 7...
Ashish has a tree consisting of $n$ nodes numbered $1$ to $n$ rooted at node $1$. The $i$-th node in the tree has a cost $a_i$, and binary digit $b_i$ is written in it. He wants to have binary digit $c_i$ written in the $i$-th node in the end. To achieve this, he can perform the following operation any number of times...
0
{"tests": "{\"inputs\": [\"0 0 0 1\\n\", \"0 0 1 1\\n\", \"0 0 1 2\\n\", \"-100 -100 100 100\\n\", \"-100 -100 99 100\\n\", \"0 -100 0 100\\n\", \"27 -74 27 74\\n\", \"0 1 2 3\\n\", \"-100 100 100 -100\\n\", \"-100 -100 -100 100\\n\", \"100 100 100 -100\\n\", \"100 -100 -100 -100\\n\", \"-100 100 100 100\\n\", \"0 1 0 ...
Pashmak has fallen in love with an attractive girl called Parmida since one year ago... Today, Pashmak set up a meeting with his partner in a romantic garden. Unfortunately, Pashmak has forgotten where the garden is. But he remembers that the garden looks like a square with sides parallel to the coordinate axes. He al...
0.375
{"tests": "{\"inputs\": [[[80]], [[100, 50]], [[50, 60, 70, 80]], [[13, 27, 49]], [[70, 58, 75, 34, 91]], [[29, 83, 67, 53, 19, 28, 96]], [[0]], [[100, 51, 50, 100]], [[39, 84, 74, 18, 59, 72, 35, 61]], [[0, 1, 0]]], \"outputs\": [[[80, 0]], [[100, 50]], [[120, 140]], [[62, 27]], [[236, 92]], [[211, 164]], [[0, 0]], [[...
# Scenario **_Several people_** are standing in *a row divided into two teams*. The **_first person_** goes into **_team 1_**, **_the second_** goes into **_team 2_**, **_the third_** goes into **_team 1_**, and so on. ___ # Task **_Given_** *an array of positive integers (the weights of the people)*, **_return_** ...
0
{"tests": "{\"inputs\": [\"4 100 90 91\\n0 7 8 100\\n\", \"3 10 1 8\\n0 3 10\\n\", \"4 100 3 5\\n0 40 48 100\\n\", \"4 500 30 50\\n0 20 40 500\\n\", \"4 10 8 9\\n0 4 5 10\\n\", \"3 10 7 8\\n0 9 10\\n\", \"4 100 7 8\\n0 3 4 100\\n\", \"3 350 150 160\\n0 310 350\\n\", \"3 10 2 3\\n0 1 10\\n\", \"5 550 300 400\\n0 151 251...
Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler! However, there is no reason for disappointment, as Valery has found another ruler, its length is l centimeters. The ruler already has n marks, with which he can make measure...
0
{"tests": "{\"inputs\": [\"7\\n1198733\\n\", \"22\\n7135498415686025907059\\n\", \"72\\n491925337784111770500147619881727525570039735507439360627744863794794290\\n\", \"9\\n988808426\\n\", \"49\\n2429965524999668169991253653390090510755018570235\\n\", \"100\\n400422312494273064023538324443825761458153432035606098724165...
Phone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-33. Your task is to find for a given phone number any of its divisions into groups of two or three d...
0
{"tests": "{\"inputs\": [\"0?0?\", \"00??\", \"??00????0??1????0?0??00??1???11?1?1???1?11?111???1\", \"1???11??11?1???1?1?11???1??00??0?0?1??1??0>>??00??\", \"1???111?11?1???111?11???1??00??0?0?@?????0????00??\", \"????111?11?1?1?111?11???1??00??0???@?????0???000??\", \"????111111?1???0?1?11???1??00????00?0????0???0>0?...
Given is a string S, where each character is `0`, `1`, or `?`. Consider making a string S' by replacing each occurrence of `?` with `0` or `1` (we can choose the character for each `?` independently). Let us define the unbalancedness of S' as follows: * (The unbalancedness of S') = \max \\{ The absolute difference be...
0
{"tests": "{\"inputs\": [\"3\\n8\\n1 2 7 3 2 1 2 3\\n2\\n2 1\\n7\\n4 1 5 2 6 3 7\\n\", \"3\\n8\\n1 2 7 3 2 1 2 5\\n2\\n2 1\\n7\\n4 1 5 2 6 3 7\\n\", \"3\\n8\\n1 2 7 6 2 1 1 3\\n2\\n2 1\\n7\\n4 1 5 2 6 3 7\\n\", \"3\\n8\\n1 2 7 1 2 1 1 3\\n2\\n2 1\\n7\\n4 1 5 2 6 3 7\\n\", \"3\\n8\\n1 2 7 6 2 1 4 4\\n2\\n2 1\\n7\\n7 3 3...
Let's call a sequence $b_1, b_2, b_3 \dots, b_{k - 1}, b_k$ almost increasing if $$\min(b_1, b_2) \le \min(b_2, b_3) \le \dots \le \min(b_{k - 1}, b_k).$$ In particular, any sequence with no more than two elements is almost increasing. You are given a sequence of integers $a_1, a_2, \dots, a_n$. Calculate the length o...
0.375
{"tests": "{\"inputs\": [\"abcdadbcd\\nabcd\\n\", \"cctckkhatkgrhktihcgififfgfctctkrgiakrifazzggfzczfkkahhafhcfgacccfakkarcatkfiktczkficahgiriakccfiztkhkgrfkrimgamighhtamrhxftaadwxgfggytwjccgkdpyyatctfdygxggkyycpjyfxyfdwtgytcacawjddjdctyfgddkfkypyxftxxtaddcxxpgfgxgdfggfdggdcddtgpxpctpddcdcpc\\nctkhagrifaztmnxhmqztzibnm...
A subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is a string x = sk1sk2... sk|x| (1 ≤ k1 < k2 < ... < k|x| ≤ |s|). You've got two strings — s and t. Let's consider all subsequences of string s, coinciding with string t. Is it true that each character of string s occurs in at...
0.125
{"tests": "{\"inputs\": [\"2\\n7 4\\n1 2 3\\n3 4 5\\n5 6 7\\n6 5 4\\n5 3\\n1 2 0\\n2 3 4\\n3 4 5\\n\", \"2\\n7 4\\n1 2 3\\n3 4 10\\n5 6 7\\n6 5 4\\n5 3\\n1 1 0\\n2 3 4\\n3 4 5\\n\", \"2\\n7 4\\n1 2 3\\n6 4 10\\n5 6 7\\n6 5 4\\n10 3\\n1 1 -1\\n2 3 4\\n3 4 6\\n\", \"2\\n12 4\\n1 2 3\\n6 4 10\\n5 6 7\\n6 5 4\\n10 3\\n1 1 ...
Lord Omkar would like to have a tree with n nodes (3 ≤ n ≤ 10^5) and has asked his disciples to construct the tree. However, Lord Omkar has created m (1 ≤ m < n) restrictions to ensure that the tree will be as heavenly as possible. A tree with n nodes is an connected undirected graph with n nodes and n-1 edges. Note ...
0.125
{"tests": "{\"inputs\": [\"ABBACCBACCBCAABCB\", \"B\", \"ACBAACBCCABCCBBBA\", \"ABCAACBCAABCCBBBC\", \"ACCAAABCAABCCBBBC\", \"CBAABC\", \"ABBBCCBACCBCAABCB\", \"D\", \"DBAABC\", \"ABBBCCBACCBCAABCA\", \"E\", \"DBAAAC\", \"F\", \"DAAAAC\", \"ACBAACBCAABCCBBBC\", \"A\", \"AAADAC\", \"ACCAACBCAABCCBBBC\", \"G\", \"AAADAD\...
You are given a string s consisting of `A`, `B` and `C`. Snuke wants to perform the following operation on s as many times as possible: * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`. Find the maximum possible number of operations. Constraints * 1 \leq |s| \leq 200000 * Each char...
0.375
{"tests": "{\"inputs\": [\"1\\n4 1\\n0011\\n0011\\n1 4\\n\", \"1\\n4 1\\n0011\\n0111\\n1 4\\n\", \"1\\n4 1\\n0011\\n0011\\n4 4\\n\", \"4\\n5 2\\n00000\\n00111\\n1 5\\n1 3\\n2 1\\n00\\n01\\n1 2\\n10 6\\n1111111111\\n0110000110\\n1 10\\n5 9\\n7 10\\n1 7\\n3 5\\n6 10\\n5 2\\n10000\\n11000\\n2 5\\n1 3\\n\", \"4\\n5 2\\n000...
Nezzar has a binary string s of length n that he wants to share with his best friend, Nanako. Nanako will spend q days inspecting the binary string. At the same time, Nezzar wants to change the string s into string f during these q days, because it looks better. It is known that Nanako loves consistency so much. On th...
0.25
{"tests": "{\"inputs\": [\"3\\n7\\n3 1 6 6 3 1 1\\n8\\n1 1 4 4 4 7 8 8\\n7\\n2 2 5 2 6 2 7\\n\", \"3\\n7\\n3 1 6 6 3 1 1\\n8\\n1 1 4 4 4 7 8 2\\n7\\n2 2 5 2 6 2 7\\n\", \"3\\n7\\n3 1 6 6 3 1 1\\n8\\n1 1 4 4 4 3 8 2\\n7\\n2 2 5 2 6 2 7\\n\", \"3\\n7\\n3 1 6 6 3 1 1\\n8\\n1 1 4 4 4 3 8 2\\n7\\n2 2 5 4 6 2 7\\n\", \"3\\n7...
You are given a sequence a_1, a_2, ..., a_n, consisting of integers. You can apply the following operation to this sequence: choose some integer x and move all elements equal to x either to the beginning, or to the end of a. Note that you have to move all these elements in one direction in one operation. For example,...
0
{"tests": "{\"inputs\": [\"1\\n\", \"2\\n\", \"123\\n\", \"36018\\n\", \"1000\\n\", \"450002\\n\", \"450010\\n\", \"450015\\n\", \"450020\\n\", \"450030\\n\", \"91304885\\n\", \"7803372\\n\", \"89317875\\n\", \"1060874\\n\", \"78876118\\n\", \"18434582\\n\", \"15764866\\n\", \"79528725\\n\", \"52556425\\n\", \"86801054...
For a positive integer n, let us define f(n) as the number of digits in base 10. You are given an integer S. Count the number of the pairs of positive integers (l, r) (l \leq r) such that f(l) + f(l + 1) + ... + f(r) = S, and find the count modulo 10^9 + 7. -----Constraints----- - 1 \leq S \leq 10^8 -----Input----- ...
0
{"tests": "{\"inputs\": [\"5 3 5\\n4 4\\n3 5\\n2 4\\n3 4\\n3 5\\n\", \"50 50 1\\n1 50\\n\", \"50 50 1\\n1 50\\n\", \"50 41 1\\n1 50\\n\", \"5 5 5\\n4 4\\n3 5\\n2 4\\n3 4\\n3 5\\n\", \"5 5 5\\n4 4\\n3 5\\n2 3\\n3 3\\n3 5\\n\", \"5 5 5\\n1 4\\n3 5\\n2 3\\n3 3\\n3 5\\n\", \"50 50 1\\n2 50\\n\", \"5 3 5\\n4 2\\n3 5\\n2 4\\...
You are given a chessboard consisting of $n$ rows and $n$ columns. Rows are numbered from bottom to top from $1$ to $n$. Columns are numbered from left to right from $1$ to $n$. The cell at the intersection of the $x$-th column and the $y$-th row is denoted as $(x, y)$. Furthermore, the $k$-th column is a special colum...
0
{"tests": "{\"inputs\": [\"3 3 3\\n000\\n111\\n000\\n1 1 1\\n2 2 2\\n3 3 3\\n\", \"5 2 2\\n01\\n10\\n01\\n10\\n01\\n1 1 4\\n5 1 4\\n\", \"5 5 3\\n01011\\n10110\\n01101\\n11010\\n10101\\n1 1 4\\n1 2 3\\n5 5 3\\n\", \"1 1 3\\n0\\n1 1 1\\n1 1 2\\n1 1 3\\n\", \"1 1 1\\n1\\n1 1 1\\n\", \"2 2 1\\n10\\n11\\n1 2 10000000000000...
Please notice the unusual memory limit of this problem. Orac likes games. Recently he came up with the new game, "Game of Life". You should play this game on a black and white grid with $n$ rows and $m$ columns. Each cell is either black or white. For each iteration of the game (the initial iteration is $0$), the co...
0.125
{"tests": "{\"inputs\": [[0], [1], [2], [3], [4], [5], [6]], \"outputs\": [[1], [20], [400], [8000], [160000], [3200000], [64000000]]}", "source": "taco"}
The Menger Sponge is a three-dimensional fractal, first described by Karl Menger in 1926. ![Mengers Sponge (Level 0-3)](http://i.imgur.com/V6Rb4Za.jpg) ###### _An illustration of the iterative construction of a Menger sponge_ A method of constructing a Menger Sponge can be visualized as follows: 1. Start from a cube ...
0.125
{"tests": "{\"inputs\": [\"3\\n1 2 3\\n\", \"4\\n2 1 3 2\\n\", \"17\\n1 45 22 39 28 23 23 100 500 778 777 778 1001 1002 1005 1003 1005\\n\", \"101\\n1 50 170 148 214 153 132 234 181 188 180 225 226 200 197 122 181 168 87 220 223 160 235 94 257 145 199 235 102 146 119 60 109 134 209 260 210 191 180 271 236 195 155 169 1...
One day Squidward, Spongebob and Patrick decided to go to the beach. Unfortunately, the weather was bad, so the friends were unable to ride waves. However, they decided to spent their time building sand castles. At the end of the day there were n castles built by friends. Castles are numbered from 1 to n, and the heig...
0.25
{"tests": "{\"inputs\": [\"3\\n6 10 14 15 27 35\\n2\\n30 42 35\\n0\", \"3\\n6 10 14 15 27 35\\n0\\n30 42 35\\n0\", \"3\\n6 10 22 15 27 35\\n0\\n3 56 35\\n-1\", \"3\\n6 10 26 15 27 35\\n2\\n30 42 35\\n0\", \"3\\n6 10 24 15 27 35\\n0\\n30 42 8\\n0\", \"3\\n6 10 28 15 31 35\\n2\\n30 42 35\\n0\", \"3\\n6 10 26 15 27 35\\n0...
Problem H: Squid Multiplication Squid Eiko loves mathematics. Especially she loves to think about integer. One day, Eiko found a math problem from a website. "A sequence b ={ai + aj | i < j } is generated from a sequence a ={a0 , ... , an | ai is even if i is 0, otherwise ai is odd}. Given the sequence b , find the s...
0.25
{"tests": "{\"inputs\": [\"3 3\\n3 8 1 1\\n2 1 5\\n2 3 3\\n3 3\\n3 2 3 1\\n2 1 5\\n2 3 3\\n0 0\", \"3 6\\n3 8 1 1\\n2 1 5\\n2 3 3\\n3 3\\n3 2 5 1\\n2 1 8\\n2 3 3\\n0 0\", \"3 3\\n3 4 1 1\\n2 1 5\\n2 3 3\\n3 6\\n3 2 5 1\\n2 1 5\\n2 3 3\\n0 0\", \"3 3\\n3 8 1 1\\n2 1 6\\n2 3 3\\n3 3\\n3 2 3 1\\n2 2 5\\n2 2 3\\n0 0\", \"3...
This is a story of a world somewhere far from the earth. In this world, the land is parted into a number of countries ruled by empires. This world is not very peaceful: they have been involved in army race. They are competing in production of missiles in particular. Nevertheless, no countries have started wars for yea...
0
{"tests": "{\"inputs\": [\"8\\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 13\\n\", \"3\\n13 17 21\\n\", \"3\\n13 28 21\\n\", \"3\\n6 8 100\\n\", \"3\\n13 28 7\\n\", \"3\\n13 19 7\\n\", \"3\\n13 19 3\\n\", \"3\\n13 19 1\\n\", \"3\\n26 19 1\\n\", \"3\\n42 19 1\\n\", \"3\\n32 19 1\\n\", \...
There is a square painted on a piece of paper, the square's side equals n meters. John Doe draws crosses on the square's perimeter. John paints the first cross in the lower left corner of the square. Then John moves along the square's perimeter in the clockwise direction (first upwards, then to the right, then downward...
0.5
{"tests": "{\"inputs\": [\"10\\n9 5\\n9 3\\n8 1\\n4 5\\n8 2\\n7 2\\n7 5\\n3 6\\n10 5\\n\", \"10\\n4 5\\n9 7\\n1 6\\n2 5\\n7 4\\n6 10\\n8 3\\n4 3\\n6 7\\n\", \"10\\n10 8\\n9 2\\n3 2\\n10 6\\n1 3\\n10 4\\n5 9\\n7 8\\n10 2\\n\", \"10\\n1 10\\n7 1\\n6 2\\n1 3\\n8 4\\n1 9\\n1 4\\n1 6\\n5 1\\n\", \"10\\n7 4\\n7 1\\n3 7\\n6 1...
[INSPION FullBand Master - INSPION](https://www.youtube.com/watch?v=kwsciXm_7sA) [INSPION - IOLITE-SUNSTONE](https://www.youtube.com/watch?v=kwsciXm_7sA) On another floor of the A.R.C. Markland-N, the young man Simon "Xenon" Jackson, takes a break after finishing his project early (as always). Having a lot of free ti...
0
{"tests": "{\"inputs\": [\"3 8\\n6 5 8\\n\", \"7 20\\n21 15 12 11 20 19 12\\n\", \"3 1\\n1 2 5\\n\", \"1 100\\n105\\n\", \"5 1\\n2 2 4 6 1\\n\", \"1 100\\n88\\n\", \"1 1\\n100000\\n\", \"3 4\\n1 2 5\\n\", \"1 1\\n1\\n\", \"3 10\\n5 5 10\\n\", \"3 1\\n1 2 5\\n\", \"1 1\\n100000\\n\", \"5 1\\n2 2 4 6 1\\n\", \"3 10\\n5 5...
You are given an array $a$ of $n$ integers and an integer $s$. It is guaranteed that $n$ is odd. In one operation you can either increase or decrease any single element by one. Calculate the minimum number of operations required to make the median of the array being equal to $s$. The median of the array with odd leng...
0.875
{"tests": "{\"inputs\": [\"12 12\\n9\\n11\\n5\\n3\\n7\\n2\\n8\\n6\\n4\\n10\\n12\\n1\\n\", \"3 3\\n3\\n2\\n1\\n\", \"2 2\\n1\\n2\\n\", \"1 1\\n1\\n\", \"12 12\\n9\\n10\\n5\\n3\\n7\\n2\\n8\\n6\\n4\\n10\\n12\\n1\\n\", \"2 2\\n2\\n2\\n\", \"4 3\\n2\\n2\\n4\\n\", \"15 12\\n9\\n10\\n5\\n3\\n7\\n2\\n8\\n6\\n4\\n10\\n12\\n1\\n...
Dima is a beginner programmer. During his working process, he regularly has to repeat the following operation again and again: to remove every second element from the array. One day he has been bored with easy solutions of this problem, and he has come up with the following extravagant algorithm. Let's consider that i...
0
{"tests": "{\"inputs\": [\"3 5\\n00100\\n10110\\n11001\\n\", \"3 5\\n00100\\n00110\\n11001\\n\", \"3 5\\n00100\\n00110\\n11011\\n\", \"3 5\\n00100\\n00110\\n01001\\n\", \"3 5\\n00100\\n00110\\n11111\\n\", \"3 5\\n00110\\n00110\\n01001\\n\", \"3 5\\n00000\\n00110\\n11111\\n\", \"3 5\\n00110\\n00110\\n01000\\n\", \"3 5\\...
You are given an image, that can be represented with a 2-d n by m grid of pixels. Each pixel of the image is either on or off, denoted by the characters "0" or "1", respectively. You would like to compress this image. You want to choose an integer k > 1 and split the image into k by k blocks. If n and m are not divisib...
0.125
{"tests": "{\"inputs\": [\"3 1\\nerase -1\\nerase 0\\nerase -2147483648\\n\", \"26 25\\ndefragment\\nerase 1\\nerase -1560200883\\nalloc 44\\ndefragment\\nalloc 75\\nalloc 22\\ndefragment\\nerase 4\\ndefragment\\nalloc 57\\nalloc 53\\nerase 4\\nerase -1639632026\\nerase -2121605039\\nerase 3\\nalloc 51\\nalloc 65\\ndef...
There is little time left before the release of the first national operating system BerlOS. Some of its components are not finished yet — the memory manager is among them. According to the developers' plan, in the first release the memory manager will be very simple and rectilinear. It will support three operations: ...
0.5
{"tests": "{\"inputs\": [[[1, 2, 34, 2, 1, 5, 3, 5, 7, 234, 2, 1]], [[2, 4, 6, 8, 10, 2, 2, 2, 1, 1, 1, 5, 3]], [[2, 4, 5, 3, 6, 3, 1, 56, 7, 6, 3, 12]], [[1, 3, 5]], [[1, 3, 2]], [[1, 3, 5, 7, 9, 11, 13, 15]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 3, 5]], [[-5, -4, -2, 0, 1, 2, 3, 4, 5]], [[-8, -25, 21, -7, -5]], [[8, 5, 20...
# Kata Task Given a list of random integers, return the Three Amigos. These are 3 numbers that live next to each other in the list, and who have the **most** in common with each other by these rules: * lowest statistical range * same parity # Notes * The list will contain at least 3 numbers * If there is more than ...
0
{"tests": "{\"inputs\": [\"3\\n156 120\\n100 50\\n80 100\", \"3\\n52 5\\n100 85\\n37 000\", \"3\\n19 5\\n000 49\\n43 010\", \"3\\n156 120\\n100 50\\n80 000\", \"3\\n156 159\\n100 50\\n80 000\", \"3\\n156 11\\n100 50\\n80 000\", \"3\\n156 22\\n100 50\\n80 000\", \"3\\n156 22\\n100 50\\n152 000\", \"3\\n156 6\\n100 50\\n...
There was a powerful school where powerful people gathered. At the athletic meet of the powerful school, powerful people march in a formation. While the powerhouses always want to show off their power, most of them don't want to walk on their own. So I thought that some of them would be at the bottom, and a lot of peo...
0
{"tests": "{\"inputs\": [\"6\\nooxoox\\n\", \"3\\noox\\n\", \"10\\noxooxoxoox\\n\", \"3\\nxoo\", \"6\\nxooxoo\", \"10\\nxooxoxooxo\", \"10\\nxxooxoxooo\", \"10\\noxooooxxox\", \"10\\nxoxxooooxo\", \"10\\noooxoxooxx\", \"10\\noxooooxxxo\", \"10\\noxoooxxoox\", \"10\\noxooooxoxx\", \"10\\noxoooxooxx\", \"10\\nxxoxxooooo\...
Snuke, who loves animals, built a zoo. There are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle. The animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered ...
0.125
{"tests": "{\"inputs\": [[\"babad\"], [\"madam\"], [\"dde\"], [\"ababbab\"], [\"abababa\"], [\"banana\"], [\"abba\"], [\"cbbd\"], [\"zz\"], [\"dddd\"], [\"\"], [\"abcdefghijklmnopqrstuvwxyz\"], [\"ttaaftffftfaafatf\"], [\"bbaaacc\"], [\"m\"]], \"outputs\": [[\"bab\"], [\"madam\"], [\"dd\"], [\"babbab\"], [\"abababa\"],...
# Longest Palindromic Substring (Linear) A palindrome is a word, phrase, or sequence that reads the same backward as forward, e.g., 'madam' or 'racecar'. Even the letter 'x' is considered a palindrome. For this Kata, you are given a string ```s```. Write a function that returns the longest _contiguous_ palindromic s...
0
{"tests": "{\"inputs\": [\"3 9\\nABCDEFGHI\\nJKLMNOPQR\\nSTUVWXYZ_\\nICPC\\n5 11\\n___________\\n____A______\\n________M__\\n___________\\n_C_________\\nACM\\n4 21\\n1_2_3_4_5_6_7_8_9_0_-\\nQqWwEeRrTtYyUuIiOoPp@\\nAaSsDdFfGgHhJjKkLl;^:\\nZzXxCcVvBbNnMm,_._/__\\nICPC2019,AsiaYokohamaRegional,QualificationRound\\n0 0\", ...
<!-- Problem B --> On-Screen Keyboard You are to input a string with an OSK (on-screen keyboard). A remote control with five buttons, four arrows and an OK (Fig. B-1), is used for the OSK. Find the minimum number of button presses required to input a given string with the given OSK. <image> Fig. B-1 Remote control...
0.5
{"tests": "{\"inputs\": [\"8\\n1 4\\n10 5\\n3 3\\n4 11\\n8 9\\n22 11\\n8 36\\n314159265 358979323\", \"8\\n1 4\\n10 5\\n3 3\\n4 11\\n8 9\\n22 3\\n8 36\\n314159265 358979323\", \"8\\n1 4\\n10 5\\n3 3\\n4 11\\n8 9\\n22 3\\n8 36\\n314159265 541984339\", \"8\\n1 4\\n10 5\\n3 3\\n4 11\\n8 9\\n22 3\\n7 36\\n314159265 5419843...
10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th. The score of a participant is the product of his/her ranks in the two contests. Process the following Q queries: * In the i-th query, you are ...
0
{"tests": "{\"inputs\": [[\"a\"], [\"aaaa\"], [\"abcd\"], [\"abababab\"], [\"ababababa\"], [\"123a123a123a\"], [\"123A123a123a\"], [\"abbaabbaabba\"], [\"abbabbabba\"], [\"abcdabcabcd\"]], \"outputs\": [[false], [true], [false], [true], [false], [true], [false], [true], [false], [false]]}", "source": "taco"}
In this kata you need to build a function to return either `true/True` or `false/False` if a string can be seen as the repetition of a simpler/shorter subpattern or not. For example: ```cpp,java hasSubpattern("a") == false; //no repeated pattern hasSubpattern("aaaa") == true; //created repeating "a" hasSubpattern("ab...
0
{"tests": "{\"inputs\": [\"5\\n1 2\\n2 1\\n5 10\\n10 9\\n19 1\\n\", \"5\\n1 2\\n2 1\\n5 10\\n10 9\\n20 1\\n\", \"4\\n10 4\\n15 1\\n19 3\\n20 1\\n\", \"35\\n1 7\\n3 11\\n6 12\\n7 6\\n8 5\\n9 11\\n15 3\\n16 10\\n22 2\\n23 3\\n25 7\\n27 3\\n34 5\\n35 10\\n37 3\\n39 4\\n40 5\\n41 1\\n44 1\\n47 7\\n48 11\\n50 6\\n52 5\\n57 ...
Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below. There are n trees located along the road at points with coordinates x_1, x_2, ..., x_{n}. ...
0
{"tests": "{\"inputs\": [\"abab\\nba\\n\", \"defineintlonglong\\nsignedmain\\n\", \"rotator\\nrotator\\n\", \"cacdcdbbbb\\nbdcaccdbbb\\n\", \"f\\np\\n\", \"baabbaaaaa\\nababa\\n\", \"cbaabccadacadbaacbadddcdabcacdbbabccbbcbbcbbaadcabadcbdcadddccbbbbdacdbcbaddacaadbcddadbabbdbbacabdd\\ncccdacdabbacbbcacdca\\n\", \"tqlrr...
Kaavi, the mysterious fortune teller, deeply believes that one's fate is inevitable and unavoidable. Of course, she makes her living by predicting others' future. While doing divination, Kaavi believes that magic spells can provide great power for her to see the future. [Image]  Kaavi has a string $T$ of length $m$ an...
0
{"tests": "{\"inputs\": [[[3, 2, 9], [1, 2]], [[4, 7, 3], [1, 2, 3]], [[1], [5, 7, 6]], [[3, 2, 6, 6], [-7, 2, 2, 8]], [[-4, 5, 7, 3, 6], [5, 3, 4, 5]], [[], []], [[0], []], [[], [1, 2]], [[1, 4, 5], []], [[0], [0]]], \"outputs\": [[[3, 4, 1]], [[5, 9, 6]], [[5, 7, 7]], [[-3, 9, 6, 2]], [[-4, 0, 3, 9, 1]], [[]], [[0]],...
Your task is to create a function called ```sum_arrays()``` in Python or ```addArrays``` in Javascript, which takes two arrays consisting of integers, and returns the sum of those two arrays. The twist is that (for example) ```[3,2,9]``` does not equal ``` 3 + 2 + 9```, it would equal ```'3' + '2' + '9'``` converted t...
0
{"tests": "{\"inputs\": [\"19 2\\n1 3\\n2 3\\n0 1\\n1 1\\n2 1\\n3 1\\n4 4\\n5 4\\n6 4\\n7 4\\n8 4\\n8 1\\n8 2\\n8 1\\n8 0\\n7 0\\n6 0\\n5 0\\n4 0\", \"3 2\\n0 0\\n1 0\\n2 0\", \"1 4\\n0 0\\n2 1\\n2 0\", \"8 3\\n0 0\\n0 3\\n6 0\\n1 3\\n2 0\\n2 10\\n5 2\\n0 8\", \"17 2\\n0 5\\n2 3\\n1 0\\n1 2\\n3 1\\n3 1\\n3 5\\n5 1\\n5 ...
Niwango-kun, an employee of Dwango Co., Ltd., likes Niconico TV-chan, so he collected a lot of soft toys of her and spread them on the floor. Niwango-kun has N black rare soft toys of Niconico TV-chan and they are spread together with ordinary ones. He wanted these black rare soft toys to be close together, so he deci...
0
{"tests": "{\"inputs\": [\"3 3\\n1 2 5 L\\n1 2 7 S\\n2 3 11 S\\n3\\n1 2 3\\n5 5\\n1 2 15 L\\n2 3 10 L\\n4 5 7 L\\n1 3 30 S\\n3 5 100 S\\n5\\n1 3 5 4 1\\n0 0\", \"3 3\\n1 2 5 L\\n1 2 7 S\\n2 3 11 S\\n3\\n1 2 3\\n7 5\\n1 2 15 L\\n2 3 10 L\\n4 5 7 L\\n1 3 30 S\\n3 4 000 S\\n5\\n1 3 5 4 1\\n0 0\", \"3 3\\n1 2 5 L\\n1 2 7 S...
Problem D: Mr. Rito Post Office You are a programmer working at a post office on a remote island. The area you live in consists of multiple islands. There is one or more port towns on each island. There may be other towns and villages in addition to them. You have to use a boat to go from one island to another. You ca...
0
{"tests": "{\"inputs\": [\"4\\n5 -1\\n9 1\\n3 10\\n11 3\\n1\\n999983 20\\n0\", \"4\\n5 -1\\n9 1\\n3 10\\n8 3\\n1\\n999983 20\\n0\", \"4\\n3 -1\\n14 1\\n3 10\\n8 3\\n1\\n999983 20\\n0\", \"4\\n3 -1\\n14 1\\n3 24\\n8 3\\n1\\n999983 20\\n0\", \"4\\n5 0\\n9 1\\n3 10\\n8 3\\n1\\n999983 20\\n0\", \"4\\n5 -1\\n9 1\\n2 10\\n11...
The king of a country loves prime numbers and gambling. The unit of currency in this country is called prime. As of November 1, 2007, Prime's cross-yen rate was just prime at 9973, so the King is overjoyed. Subsidiary coins with 1/101 prime as one subprime are used in this country. The government of this country has d...
0
{"tests": "{\"inputs\": [\"8\\n1\\n2\\n\", \"5\\n3\\n4\\n\", \"6\\n4\\n2\\n\", \"20\\n5\\n6\\n\", \"1\\n1\\n1\\n\", \"3\\n1\\n2\\n\", \"3\\n2\\n1\\n\", \"1000\\n1\\n1\\n\", \"1000\\n1000\\n1000\\n\", \"1000\\n1\\n999\\n\", \"1000\\n1\\n498\\n\", \"1000\\n1\\n998\\n\", \"31\\n5\\n6\\n\", \"400\\n100\\n2\\n\", \"399\\n10...
Petya has equal wooden bars of length n. He wants to make a frame for two equal doors. Each frame has two vertical (left and right) sides of length a and one top side of length b. A solid (i.e. continuous without breaks) piece of bar is needed for each side. Determine a minimal number of wooden bars which are needed t...
0
{"tests": "{\"inputs\": [[\"3\", \"2\", \"5 -5\", \"2\", \"-5 5\", \"3\", \"1 2 -3\"], \"3\\n1\\n5 -5\\n2\\n-5 5\\n3\\n1 2 -3\", \"3\\n2\\n5 -5\\n2\\n-5 5\\n3\\n0 3 -3\", \"3\\n1\\n5 -5\\n1\\n-5 5\\n2\\n1 3 -4\", \"3\\n1\\n5 -5\\n2\\n-8 8\\n2\\n1 2 -3\", \"3\\n1\\n5 -5\\n1\\n-5 5\\n3\\n1 2 -3\", \"3\\n2\\n5 -5\\n2\\n-5...
DevuLand is a very strange place. There are n villages in it. Some of the villages are occupied by dinosaurs while the remaining ones by villagers. You are given the information of DevuLand by an array D of size n. If D[i] is non-negative, it means that there are D[i] villagers in that village. Otherwise, it means...
0
{"tests": "{\"inputs\": [\"3 1\\n139\\n2 1\\n\", \"2 3\\n14\\n2 4\\n2 1\\n1 1\\n\", \"2 3\\n11\\n2 4\\n2 1\\n1 0\\n\", \"2 3\\n11\\n1 4\\n2 1\\n1 0\\n\", \"2 3\\n14\\n2 4\\n2 1\\n2 0\\n\", \"2 3\\n11\\n1 4\\n2 2\\n1 0\\n\", \"2 3\\n11\\n1 5\\n2 2\\n1 0\\n\", \"3 1\\n139\\n3 1\\n\", \"2 3\\n11\\n1 5\\n2 4\\n1 0\\n\", \"...
Let a and b be some non-negative integers. Let's define strange addition of a and b as following: 1. write down the numbers one under another and align them by their least significant digit; 2. add them up digit by digit and concatenate the respective sums together. Assume that both numbers have an infinite n...
0
{"tests": "{\"inputs\": [\"1\\n\", \"2\\n\", \"13\\n\", \"101\\n\", \"1023\\n\", \"9999\\n\", \"10000\\n\", \"2333\\n\", \"9139\\n\", \"9859\\n\", \"5987\\n\", \"3\\n\", \"4\\n\", \"5\\n\", \"7\\n\", \"9\\n\", \"10\\n\", \"15\\n\", \"51\\n\", \"99\\n\", \"138\\n\", \"233\\n\", \"666\\n\", \"1234\\n\", \"3567\\n\", \"44...
We consider a positive integer perfect, if and only if the sum of its digits is exactly $10$. Given a positive integer $k$, your task is to find the $k$-th smallest perfect positive integer. -----Input----- A single line with a positive integer $k$ ($1 \leq k \leq 10\,000$). -----Output----- A single number, deno...
0
{"tests": "{\"inputs\": [\"6 6\\n6\\n1 1\\n6 1\\n3 2\\n3 5\\n1 6\\n5 6\\n2\\n1 3\\n5 3\\n6 6\\n6\\n3 2\\n3 5\\n6 1\\n1 1\\n1 6\\n5 6\\n2\\n2 3\\n6 3\\n0 0\", \"6 6\\n6\\n1 1\\n6 1\\n3 2\\n3 5\\n0 6\\n5 6\\n2\\n1 3\\n2 3\\n6 6\\n6\\n3 2\\n3 5\\n6 1\\n1 1\\n1 6\\n5 6\\n2\\n1 3\\n6 3\\n0 0\", \"6 6\\n6\\n1 1\\n4 1\\n3 2\\...
Convenience store Deven Eleven is planning to open its first store in Aizuwakamatsu City to expand its business. There are already many other convenience stores in Aizuwakamatsu, so the place to open a new store is likely to be the key to success. Under the premise that "customers use the convenience store closest to t...
0
{"tests": "{\"inputs\": [\"3\\n1 3 2\\n\", \"5\\n1 4 3 1 2\\n\", \"51\\n45 37 1 8 4 41 35 15 17 2 7 48 20 42 41 5 26 25 37 1 19 43 3 49 33 2 45 43 39 14 1 21 22 17 18 8 49 24 35 26 22 43 45 1 3 17 1 16 35 33 5\\n\", \"100\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 ...
In this problem MEX of a certain array is the smallest positive integer not contained in this array. Everyone knows this definition, including Lesha. But Lesha loves MEX, so he comes up with a new problem involving MEX every day, including today. You are given an array $a$ of length $n$. Lesha considers all the non-e...
0
{"tests": "{\"inputs\": [\"6\\n2 3 5 7 11 13\\n5\\n3 4 5 5 6\\n\", \"6\\n2 3 5 7 11 13\\n9\\n1 2 2 3 3 4 5 5 6\\n\", \"3\\n10 200 300\\n4\\n1 2 2 3\\n\", \"3\\n1 2 3\\n4\\n1 2 2 3\\n\", \"2\\n1 1000000000\\n1\\n1\\n\", \"2\\n1 1000000000\\n1\\n2\\n\", \"2\\n1 1000000000\\n2\\n1 2\\n\", \"2\\n1 1000000000\\n3\\n1 1 2\\n...
In Berland a bus travels along the main street of the capital. The street begins from the main square and looks like a very long segment. There are n bus stops located along the street, the i-th of them is located at the distance a_{i} from the central square, all distances are distinct, the stops are numbered in the o...
0
{"tests": "{\"inputs\": [\"700 300 200\\n500 200 300\\n500 200 500\\n275 110 330\\n275 010 385\\n648 375 4002\\n3 1 10000\\n0 0 0\", \"700 300 200\\n500 200 300\\n500 200 500\\n275 110 330\\n275 010 385\\n1067 375 4002\\n3 1 10000\\n0 0 0\", \"700 300 200\\n993 200 300\\n500 200 500\\n275 110 330\\n275 010 385\\n1067 3...
Ms. Iyo Kiffa-Australis has a balance and only two kinds of weights to measure a dose of medicine. For example, to measure 200mg of aspirin using 300mg weights and 700mg weights, she can put one 700mg weight on the side of the medicine and three 300mg weights on the opposite side (Figure 1). Although she could put fou...
0.125
{"tests": "{\"inputs\": [\"2 2 1\\n24 25\\n18 23\\n\", \"5 9 5\\n25 27\\n23 24\\n9 29\\n25 30\\n20 20\\n\", \"11 4 3\\n26 29\\n5 28\\n20 27\\n12 16\\n27 27\\n25 28\\n20 25\\n9 15\\n18 21\\n9 20\\n6 10\\n\", \"20 10 2\\n11 30\\n20 27\\n24 25\\n24 29\\n16 21\\n30 30\\n28 29\\n29 30\\n21 29\\n20 26\\n29 29\\n29 30\\n25 28...
There are n TV shows you want to watch. Suppose the whole time is split into equal parts called "minutes". The i-th of the shows is going from l_i-th to r_i-th minute, both ends inclusive. You need a TV to watch a TV show and you can't watch two TV shows which air at the same time on the same TV, so it is possible you...
0
{"tests": "{\"inputs\": [[\"Something\", \"Home\"], [\"Something\", \"Fun\"], [\"Something\", \"\"], [\"\", \"Something\"], [\"BANANA\", \"banana\"], [\"test\", \"lllt\"], [\"\", \"\"], [\"1234567\", \"541265\"], [\"supercalifragilisticexpialidocious\", \"SoundOfItIsAtrocious\"], [\"Loremipsumdolorsitametconsecteturadi...
Given 2 strings, your job is to find out if there is a substring that appears in both strings. You will return true if you find a substring that appears in both strings, or false if you do not. We only care about substrings that are longer than one letter long. #Examples: ```` *Example 1* SubstringTest("Something","F...
0
{"tests": "{\"inputs\": [\"9293 -6547\\n4895 -9479\\n2738 -1395 8489 -8324\\n3540 -4860 -8555 1675\\n\", \"-8193 -8833\\n4353 -8260\\n2214 683 -8074 -8978\\n5548 -850 -1486 -8372\\n\", \"0 0\\n2 0\\n1 1 1 -1\\n-10 2 -12 2\\n\", \"0 0\\n10 0\\n0 1 10 1\\n1 0 9 0\\n\", \"3680 2196\\n8736 8904\\n7532 2465 3709 -8961\\n643...
Victor and Peter are playing hide-and-seek. Peter has hidden, and Victor is to find him. In the room where they are playing, there is only one non-transparent wall and one double-sided mirror. Victor and Peter are points with coordinates (xv, yv) and (xp, yp) respectively. The wall is a segment joining points with coor...
0
{"tests": "{\"inputs\": [\"7 5\\n2 1 1 4 3 3 1\\n3 2 1 1 4\\n\", \"5 1\\n1 2 3 4 5\\n1\\n\", \"5 2\\n6 4 3 2 1\\n1 6\\n\", \"5 15\\n1 2 3 4 5\\n5 5 5 5 5 5 5 5 5 5 5 5 5 5 5\\n\", \"7 5\\n20 10 10 40 30 30 10\\n30 20 10 10 40\\n\", \"5 4\\n3 15 50 50 3\\n50 15 3 50\\n\", \"5 2\\n6 4 3 2 1\\n1 6\\n\", \"5 1\\n1 2 3 4 5\...
You have a card deck of $n$ cards, numbered from top to bottom, i. e. the top card has index $1$ and bottom card — index $n$. Each card has its color: the $i$-th card has color $a_i$. You should process $q$ queries. The $j$-th query is described by integer $t_j$. For each query you should: find the highest card in th...
0.5
{"tests": "{\"inputs\": [\"5\\n1 2 3 2 1\\n\", \"28\\n415546599 415546599 415546599 415546599 415546599 415546599 415546599 415546599 415546599 2 802811737 802811737 802811737 802811737 802811737 802811737 802811737 802811737 1 550595901 550595901 550595901 550595901 550595901 550595901 550595901 550595901 550595901\\n...
Limak is a little bear who loves to play. Today he is playing by destroying block towers. He built n towers in a row. The i-th tower is made of hi identical blocks. For clarification see picture for the first sample. Limak will repeat the following operation till everything is destroyed. Block is called internal if i...
0
{"tests": "{\"inputs\": [\"5071\\n\", \"705\\n\", \"1241367\\n\", \"7501\\n\", \"507\\n\", \"17010\\n\", \"52231\\n\", \"50267\\n\", \"574196831896431419\\n\", \"1\\n\", \"10\\n\", \"123456123450\\n\", \"1000000000000000000\\n\", \"100000000000762582\\n\", \"123456789987654321\\n\", \"213716413141380147\\n\", \"5284691...
You are given an integer $n$ from $1$ to $10^{18}$ without leading zeroes. In one move you can swap any two adjacent digits in the given number in such a way that the resulting number will not contain leading zeroes. In other words, after each move the number you have cannot contain any leading zeroes. What is the mi...
0
{"tests": "{\"inputs\": [\"5 10\\n2 5 2 2 3 5 3 2 1 3\\n\", \"1000 10\\n1 1 1 1 1 1000 1000 1000 1000 1000\\n\", \"10 20\\n6 3 9 6 1 9 1 9 8 2 7 6 9 8 4 7 1 2 4 2\\n\", \"100000 1\\n14542\\n\", \"100000 50\\n43104 45692 17950 43454 99127 33540 80887 7990 116 79790 66870 61322 5479 24876 7182 99165 81535 3498 54340 7460...
Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes what she sees and what she hears on the notebook, and the notebook became her memory. Though Ryouko is forgetful, she is also bo...
0
{"tests": "{\"inputs\": [\"2,5,3\\n3,6,1\\n3,4,2\\n4,5,2\\n3,6,3\\n1,4,1\", \"2,5,3\\n1,6,3\\n3,4,2\\n4,5,2\\n3,6,3\\n2,4,1\", \"2,5,3\\n3,6,1\\n2,4,2\\n4,5,2\\n3,6,3\\n1,4,1\", \"2,5,3\\n3,6,1\\n3,4,2\\n5,5,2\\n3,6,3\\n1,4,1\", \"2,5,3\\n3,6,1\\n2,4,2\\n4,6,2\\n3,6,3\\n1,4,1\", \"2,5,3\\n3,6,1\\n3,4,2\\n4,5,2\\n3,6,3\...
As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (x, y) coordinate system. We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as sho...
0
{"tests": "{\"inputs\": [\"4 2 3 10\\nwwhw\\n\", \"5 2 4 13\\nhhwhh\\n\", \"5 2 4 1000\\nhhwhh\\n\", \"3 1 100 10\\nwhw\\n\", \"10 2 3 32\\nhhwwhwhwwh\\n\", \"1 2 3 3\\nw\\n\", \"100 20 100 10202\\nwwwwhhwhhwhhwhhhhhwwwhhhwwwhwwhwhhwwhhwwwhwwhwwwhwhwhwwhhhwhwhhwhwwhhwhwhwwwhwwwwhwhwwwwhwhhhwhwhwww\\n\", \"20 10 10 1\\n...
Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reach photo n. Similarly, by swiping right from the last photo you reach photo 1. It takes a sec...
0
{"tests": "{\"inputs\": [\"30 4 5 6\\n8 5 5 5\\n50 3 3 3 10 10\\n49 3 3 3 10 10\", \"30 3 5 6\\n6 5 5 5\\n50 3 3 3 13 10\\n49 3 3 3 10 10\", \"3 3 5 6\\n5 5 5 5\\n37 3 3 3 4 10\\n4 1 3 3 10 10\", \"3 3 5 2\\n5 10 5 5\\n37 3 3 3 4 3\\n4 1 3 3 10 10\", \"30 4 5 6\\n30 5 5 5\\n50 3 3 3 10 10\\n49 3 3 3 4 10\", \"30 4 5 6\...
The cake shop made a lot of roll cakes of various sizes. You have been tasked with arranging this cake in a box. The roll cake is so soft that it will collapse if another roll cake is on top. Therefore, as shown in Fig. (A), all roll cakes must be arranged so that they touch the bottom of the box. Sorting also changes...
0
{"tests": "{\"inputs\": [[[2, 3, 7, 4]], [[5, 6, 7, 8]], [[2, 2, 2, 2]], [[1, 2, 5]], [[1, 2, 3, 10, 20, 30, 4]], [[1, 2, 3]]], \"outputs\": [[1], [4], [4], [0], [1], [0]]}", "source": "taco"}
# Task Given some sticks by an array `V` of positive integers, where V[i] represents the length of the sticks, find the number of ways we can choose three of them to form a triangle. # Example For `V = [2, 3, 7, 4]`, the result should be `1`. There is only `(2, 3, 4)` can form a triangle. For `V = [5, 6, 7, 8]`...
0
{"tests": "{\"inputs\": [[[\"bat\", \"tab\", \"cat\"]], [[\"dog\", \"cow\", \"tap\", \"god\", \"pat\"]], [[\"abcd\", \"dcba\", \"lls\", \"s\", \"sssll\"]], [[]], [[\"adgdfsh\", \"wertewry\", \"zxcbxcb\", \"efveyn\"]], [[5, 2, \"abc\", true, [false]]], [[5777, \"dog\", \"god\", true, 75]]], \"outputs\": [[[[0, 1], [1, 0...
Given a list of unique words. Find all pairs of distinct indices (i, j) in the given list so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome. Examples: Non-string inputs should be converted to strings. Return an array of arrays containing pairs of distinct indices that form palindro...
0
{"tests": "{\"inputs\": [[\"20151208\"], [\"20140728\"], [\"20160229\"], [\"20160301\"], [\"19000228\"], [\"19000301\"]], \"outputs\": [[\"Tuesday\"], [\"Monday\"], [\"Monday\"], [\"Tuesday\"], [\"Wednesday\"], [\"Thursday\"]]}", "source": "taco"}
If I give you a date, can you tell me what day that date is? For example, december 8th, 2015 is a tuesday. Your job is to write the function ```day(d)``` which takes a string representation of a date as input, in the format YYYYMMDD. The example would be "20151208". The function needs to output the string representati...
0
{"tests": "{\"inputs\": [\"2\\n1.0\\n4.0\\n12.0\\n16.0\\n25.0\\n1\\n-30.5893962764\\n5.76397083962\\n39.3853798058\\n74.3727663177\\n0\\n42.4715310246\\n79.5420238202\\n28.0282396675\\n-30.3627807522\\n-49.8363481393\\n-25.5101480106\\n7.58575761381\\n5\\n-21.9161699038\\n-48.469304271\\n-24.3188578417\\n-2.35085940324...
Professor Abacus has just built a new computing engine for making numerical tables. It was designed to calculate the values of a polynomial function in one variable at several points at a time. With the polynomial function f(x) = x2 + 2x + 1, for instance, a possible expected calculation result is 1 (= f(0)), 4 (= f(1)...
0
{"tests": "{\"inputs\": [\"4\\n0 20\\n2 19\\n3 18\\n4 17\", \"4\\n4 7\\n1 4\\n5 8\\n2 8\", \"10\\n457835016 996058008\\n456475528 529149798\\n455108441 512701454\\n455817105 523506955\\n457368248 814532746\\n455073228 459494089\\n888688315 774276744\\n457667152 974637457\\n457293701 800549465\\n456580262 636471526\", \...
10^9 contestants, numbered 1 to 10^9, will compete in a competition. There will be two contests in this competition. The organizer prepared N problems, numbered 1 to N, to use in these contests. When Problem i is presented in a contest, it will be solved by all contestants from Contestant L_i to Contestant R_i (inclus...
0
{"tests": "{\"inputs\": [\"1\\n10 10 10\\n761 599 561 998 446 576 705 131 556 821\\n896 115 882 957 169 475 289 661 760 434\\n131 383 139 446 908 799 56 991 360 189\\n\", \"1\\n1 1 1\\n1000000000\\n1\\n1000000000\\n\", \"1\\n1 1 6\\n1\\n11\\n1 6 7 7 8 9\\n\", \"1\\n10 10 10\\n761 599 561 998 446 576 705 131 556 821\\n8...
Xenia is a girl being born a noble. Due to the inflexibility and harshness of her family, Xenia has to find some ways to amuse herself. <image> Recently Xenia has bought n_r red gems, n_g green gems and n_b blue gems. Each of the gems has a weight. Now, she is going to pick three gems. Xenia loves colorful things, ...
0.75
{"tests": "{\"inputs\": [\"15\\n3\\n1\\n4\\n1\\n5\\n9\\n2\\n6\\n5\\n3\\n5\\n8\\n9\\n6\\n9\", \"3\\n3\\n2\\n10\", \"3\\n6\\n2\\n10\", \"3\\n6\\n3\\n10\", \"3\\n7\\n3\\n10\", \"3\\n7\\n5\\n10\", \"3\\n7\\n9\\n10\", \"3\\n7\\n13\\n10\", \"15\\n3\\n1\\n4\\n1\\n5\\n9\\n2\\n11\\n5\\n3\\n5\\n8\\n9\\n7\\n9\", \"15\\n3\\n1\\n1\...
N people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i. Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a product, sets a positive integer P indicating its price, and shows this product...
0
{"tests": "{\"inputs\": [\"9 530792195 6\\n\", \"0 0 10\\n\", \"1944219055 454183506 1369298327\\n\", \"914835 2742837 9234739\\n\", \"10 10 0\\n\", \"2 2 0\\n\", \"0 0 1\\n\", \"3 10 1007169359\\n\", \"0 1 0\\n\", \"1016450951 2 9\\n\", \"0 2 10\\n\", \"2147483648 0 2147483647\\n\", \"92134834 23742837 92374738\\n\", ...
Flatland is inhabited by pixels of three colors: red, green and blue. We know that if two pixels of different colors meet in a violent fight, only one of them survives the fight (that is, the total number of pixels decreases by one). Besides, if pixels of colors x and y (x ≠ y) meet in a violent fight, then the pixel t...
0
{"tests": "{\"inputs\": [\"3\\n......\\n......\\n......\\n......\\n......\\n......\\n......\\n......\\n.RGB..\\nRGOP..\\nRGBPB.\\nRGBPP.\\nGBRGYP\\nGBRRYP\\nBGGRBB\\nBPRGYY\\nGGPRRY\\nBYPPRB\\nYGGGPB\\nRPYYYG\\nYRBRBR\\nYBRBRB\\nBRBRBR\\nBRBRBR\\n......\\n......\\n......\\n......\\n......\\n......\\n......\\n......\\n....
Masa Kita, who entered the University of Tokyo, joined a circle called TSG (University of Tokyo Super Gamers). This circle exhibits games at the Komaba Festival every year, and Masa Kita decided to create and display the games as well. The game created by Kitamasa is a common falling block puzzle game such as the fol...
0
{"tests": "{\"inputs\": [\"4 1\\n1 2\\n2 1\", \"4 1\\n1 3\\n2 1\", \"4 1\\n2 1\\n2 1\", \"4 1\\n2 3\\n2 1\", \"2 0\\n1 2\\n2 1\", \"4 0\\n2 3\\n2 1\", \"2 0\\n1 2\\n3 1\", \"4 0\\n2 3\\n2 0\", \"4 0\\n2 3\\n1 0\", \"3 1\\n1 2\\n2 1\", \"8 1\\n1 3\\n2 1\", \"4 1\\n4 3\\n2 1\", \"4 -1\\n2 3\\n2 1\", \"2 0\\n1 2\\n3 0\", ...
ICP city has an express company whose trucks run from the crossing S to the crossing T. The president of the company is feeling upset because all the roads in the city are one-way, and are severely congested. So, he planned to improve the maximum flow (edge disjoint paths) from the crossing S to the crossing T by rever...
0
{"tests": "{\"inputs\": [\"3 10\\n0\\n1 1\\n2 2 3\\n4 20\\n2 1 2\\n1 3\\n1 4\\n1 5\\n2 1 2\\n0\\n0\\n3 3\\n0\\n1 1\\n2 2 3\\n0 0\", \"3 8\\n0\\n1 1\\n2 2 3\\n4 7\\n2 1 2\\n1 3\\n1 4\\n1 5\\n2 1 2\\n0\\n0\\n3 6\\n0\\n1 1\\n2 2 3\\n0 0\", \"3 10\\n0\\n1 1\\n2 2 3\\n4 7\\n2 1 2\\n1 2\\n1 4\\n1 5\\n2 1 2\\n0\\n0\\n3 6\\n0\...
There are n cups of different sizes and three trays (bon festivals) A, B, and C, and these cups are placed on top of each of the three trays in a pile. However, in any tray, the smallest cup in the tray is on the bottom, the second smallest cup is on top, and the third smallest cup is on top, in ascending order. .. For...
0
{"tests": "{\"inputs\": [[11], [100], [766], [160], [70], [389]], \"outputs\": [[5], [3], [4], [null], [6], [2]]}", "source": "taco"}
An expression is formed by taking the digits 1 to 9 in numerical order and then inserting into each gap between the numbers either a plus sign or a minus sign or neither. Your task is to write a method which takes one parameter and returns the **smallest possible number** of plus and minus signs necessary to form such...
0.125
{"tests": "{\"inputs\": [\"59 56\\n-8 -8 -4 5 -4 4 4 -5 -10 -2 0 6 -9 -2 10 1 -8 -2 9 5 2 -1 -5 7 -7 7 2 -7 -5 2 -2 -8 4 10 5 -9 5 9 6 10 7 6 -6 -4 -8 5 9 6 1 -7 5 -9 8 10 -7 1 3 -6 8\\n6 -2 -7 4 -2 -5 -9 -5 0 8 5 5 -4 -6 -5 -10 4 3 -4 -4 -8 2 -6 -10 -10 4 -3 8 -1 8 -8 -5 -2 3 7 3 -8 10 6 0 -8 0 9 -3 9 0 9 0 -3 4 -3 10...
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
0
{"tests": "{\"inputs\": [\"3\\n4 8 2\\n\", \"3\\n3 5 6\\n\", \"2\\n50000 100000\\n\", \"2\\n99999 99998\\n\", \"17\\n1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536\\n\", \"19\\n1 2 3 4 6 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536\\n\", \"20\\n1 2 3 4 6 8 16 20 32 64 128 256 512 102...
Amr loves Chemistry, and specially doing experiments. He is preparing for a new interesting experiment. Amr has n different types of chemicals. Each chemical i has an initial volume of a_{i} liters. For this experiment, Amr has to mix all the chemicals together, but all the chemicals volumes must be equal first. So hi...
0
{"tests": "{\"inputs\": [\"4\\n0 0\\n1 1\\n0 2\\n2 5\", \"4\\n0 0\\n1 1\\n2 2\\n2 2\", \"4\\n0 0\\n1 1\\n0 2\\n2 2\", \"4\\n0 0\\n1 1\\n0 2\\n2 3\", \"4\\n0 0\\n1 1\\n1 2\\n2 2\", \"4\\n0 0\\n1 1\\n1 2\\n3 2\", \"4\\n0 0\\n1 1\\n1 4\\n3 2\", \"4\\n0 1\\n1 1\\n1 4\\n3 2\", \"4\\n0 1\\n1 1\\n1 7\\n3 2\", \"4\\n0 1\\n1 1\...
Problem B Parallel Lines Given an even number of distinct planar points, consider coupling all of the points into pairs. All the possible couplings are to be considered as long as all the given points are coupled to one and only one other point. When lines are drawn connecting the two points of all the coupled point ...
0.25
{"tests": "{\"inputs\": [\"2\\n0 1\\n0 1\\n\", \"2\\n0 1\\n1 0\\n\", \"3\\n1 2 0\\n2 1 0\\n\", \"2\\n0 1\\n1 0\\n\", \"5\\n2 1 3 0 4\\n2 0 4 3 1\\n\", \"3\\n0 2 1\\n1 0 2\\n\", \"4\\n2 0 1 3\\n0 2 1 3\\n\", \"1\\n0\\n0\\n\", \"75\\n71 69 34 23 13 68 19 45 40 6 74 11 53 24 27 7 50 5 70 47 4 21 25 54 62 30 17 33 52 16 67...
Let's define the sum of two permutations p and q of numbers 0, 1, ..., (n - 1) as permutation [Image], where Perm(x) is the x-th lexicographically permutation of numbers 0, 1, ..., (n - 1) (counting from zero), and Ord(p) is the number of permutation p in the lexicographical order. For example, Perm(0) = (0, 1, ..., n...
0.375
{"tests": "{\"inputs\": [[[56, 335, 195, 443, 6, 494, 252]], [[154, 428, 455, 346]], [[39, 135, 47, 275, 37, 108, 265, 457, 2, 133, 316, 330, 153, 253, 321, 411]], [[136, 376, 10, 146, 105, 63, 234]], [[354, 463, 165, 62, 472, 53, 347, 293, 252, 378, 420, 398, 255, 89]], [[346, 446, 26, 425, 432, 349, 123, 269, 285, 93...
Rick wants a faster way to get the product of the largest pair in an array. Your task is to create a performant solution to find the product of the largest two integers in a unique array of positive numbers. All inputs will be valid. Passing [2, 6, 3] should return 18, the product of [6, 3]. ```Disclaimer: Mr. Roll wi...
0
{"tests": "{\"inputs\": [[-5, 0], [10, 0], [15, 0], [-5, -5], [10, -5], [15, -5]], \"outputs\": [[[]], [[]], [[]], [[]], [[]], [[]]]}", "source": "taco"}
There are some candies that need to be distributed to some children as fairly as possible (i.e. the variance of result needs to be as small as possible), but I don't know how to distribute them, so I need your help. Your assignment is to write a function with signature `distribute(m, n)` in which `m` represents how man...
0
{"tests": "{\"inputs\": [\"4 3 0\\n\", \"4 3 11\\n\", \"4 3 7\\n\", \"1000000000 2 1999999999\\n\", \"1000000000 1000000000 999999999999999999\\n\", \"1000000000 1000000000 999999999\\n\", \"1000000000 1000000000 2000000500\\n\", \"2 2 2\\n\", \"28 3 1\\n\", \"2 3 3\\n\", \"4 6 8\\n\", \"6 6 18\\n\", \"4 3 8\\n\", \"4 ...
You might have heard about the next game in Lara Croft series coming out this year. You also might have watched its trailer. Though you definitely missed the main idea about its plot, so let me lift the veil of secrecy. Lara is going to explore yet another dangerous dungeon. Game designers decided to use good old 2D e...
0
{"tests": "{\"inputs\": [\"8 3\\n0 0 0 0 0 0 0 1\\n2 3 0 1 4 0 0 1\\n3 3 0 0 0 0 0 4\\n9 9 1 9\\n4 4\\n3 3 4 0\\n1 2 4 4\\n1 1 1 0\\n0 2 2 4\\n8 7 2 1\\n2 8\\n2 2\\n4 1\\n0 4\\n1 3\\n1 0\\n2 1\\n0 3\\n1 4\\n1 9 3 1\\n0 0\", \"8 3\\n0 0 0 0 0 0 0 1\\n2 3 0 1 4 0 0 1\\n3 3 0 0 0 0 0 4\\n9 9 1 9\\n4 4\\n3 3 4 0\\n1 2 4 4\...
Let's play a game using a robot on a rectangular board covered with a square mesh (Figure D-1). The robot is initially set at the start square in the northwest corner facing the east direction. The goal of this game is to lead the robot to the goal square in the southeast corner. <image> Figure D-1: Example of a boar...
0
{"tests": "{\"inputs\": [\"5\\n3 5 9 2 8 9 2 11 6 5\\n2 5 9 2 8 9 2 11 12 6\\n2 5 9 2 8 9 2 11 11 9\\n14 1 25 7 17 12 17 9 20 5\\n14 1 25 7 17 12 22 13 20 5\", \"5\\n3 5 9 2 8 9 0 11 6 5\\n3 5 9 2 8 9 2 11 12 6\\n2 5 9 4 8 9 2 11 11 9\\n14 1 25 7 17 12 24 9 20 5\\n14 1 25 7 17 12 22 13 20 5\", \"5\\n3 5 9 2 8 9 0 11 6 ...
Zhinü was a child of the Emperor, but he was weaving the machine even if he opened it at the request of his father. It was a pleasure of the Emperor to wear clothes made of a splendid cloth called Unnishiki woven by Zhinü. Unnishiki has a short lifespan and deteriorates quickly, but there was no problem because the ha...
0.875
{"tests": "{\"inputs\": [\"3 2 30 3 26 226\\n9 0 18 3 20 118\\n5 5 12 0 15 203\\n7 4 19 2 22 197\\n7 4 24 4 17 209\\n0 0 0 0 0 0\", \"3 2 30 3 41 226\\n9 0 18 3 20 118\\n5 5 12 0 15 203\\n7 4 19 2 22 197\\n7 4 24 4 17 209\\n0 0 0 0 0 0\", \"3 2 30 3 41 226\\n9 0 18 4 20 118\\n5 5 12 0 15 203\\n7 4 19 2 22 197\\n7 4 24 ...
Ataru Oafoot of Aizu Gakuen University High School decided to play with a slot machine. When you insert a medal on this machine, three reels will start spinning and each reel will stop automatically. In a normal game (normal game), 3 medals are inserted, and when the symbols are aligned, the following medals are obtai...
0
{"tests": "{\"inputs\": [\"13 10\", \"20 10\", \"20 1\", \"15 1\", \"1 1\", \"2 1\", \"2 0\", \"1 0\", \"-1 1\", \"-1 2\", \"-1 4\", \"-1 3\", \"-1 0\", \"-1 -1\", \"0 0\", \"1 3\", \"2 3\", \"4 0\", \"4 -2\", \"7 -2\", \"0 -2\", \"2 2\", \"5 2\", \"10 2\", \"10 3\", \"10 0\", \"19 0\", \"19 1\", \"19 2\", \"8 1\", \"-...
Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits. Constraints * $0 \leq a, b \leq 2^{32} - 1$ Input The input is given in the following format. $a \; b$ Outp...
0
{"tests": "{\"inputs\": [\"5 2\\n\", \"6 8\\n\", \"20 4\\n\", \"1000000000000000000 1000000000000000000\\n\", \"1 1\\n\", \"1 1000000000000000000\\n\", \"1000000000000000000 1\\n\", \"1036191544337895 45523434\\n\", \"1036191544337896 45523434\\n\", \"1036191544337895 45523433\\n\", \"1036191544337895 1\\n\", \"1036191...
You are going to the beach with the idea to build the greatest sand castle ever in your head! The beach is not as three-dimensional as you could have imagined, it can be decribed as a line of spots to pile up sand pillars. Spots are numbered 1 through infinity from left to right. Obviously, there is not enough sand o...
0
{"tests": "{\"inputs\": [\"1 4 100 10 30 5\\n6\\n101 104 105 110 130 200\\n\", \"1 1 2 2 3 3\\n7\\n13 4 11 12 11 13 12\\n\", \"58260522 77914575 2436426 24979445 61648772 23690081\\n10\\n582107247 906728404 411434947 673536177 411497300 488012525 561127307 800305059 992325267 112738006\\n\", \"11 16 12 20 12 13\\n10\\n...
After battling Shikamaru, Tayuya decided that her flute is too predictable, and replaced it with a guitar. The guitar has $6$ strings and an infinite number of frets numbered from $1$. Fretting the fret number $j$ on the $i$-th string produces the note $a_{i} + j$. Tayuya wants to play a melody of $n$ notes. Each note...
0.75
{"tests": "{\"inputs\": [\"4 1\\n2 3 4 1\\n1 2 3 4\\n\", \"4 1\\n4 3 1 2\\n3 4 2 1\\n\", \"4 3\\n4 3 1 2\\n3 4 2 1\\n\", \"4 2\\n4 3 1 2\\n2 1 4 3\\n\", \"4 1\\n4 3 1 2\\n2 1 4 3\\n\", \"4 3\\n4 3 1 2\\n2 1 4 3\\n\", \"4 3\\n2 1 4 3\\n4 3 1 2\\n\", \"4 1\\n2 1 4 3\\n2 1 4 3\\n\", \"4 2\\n2 1 4 3\\n2 1 4 3\\n\", \"4 2\\...
Little Petya likes permutations a lot. Recently his mom has presented him permutation q_1, q_2, ..., q_{n} of length n. A permutation a of length n is a sequence of integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ n), all integers there are distinct. There is only one thing Petya likes more than permutations: playing with...
0
{"tests": "{\"inputs\": [[[0]], [[0, 0]], [[-1]], [[1]], [[1, -1]], [[0, -2, -3]], [[0, 2, 3]], [[1, 2, 3, 4, 5]]], \"outputs\": [[\"x = 0\"], [\"x^2 = 0\"], [\"x + 1 = 0\"], [\"x - 1 = 0\"], [\"x^2 - 1 = 0\"], [\"x^3 + 5x^2 + 6x = 0\"], [\"x^3 - 5x^2 + 6x = 0\"], [\"x^5 - 15x^4 + 85x^3 - 225x^2 + 274x - 120 = 0\"]]}",...
# Task Given an array of roots of a polynomial equation, you should reconstruct this equation. ___ ## Output details: * If the power equals `1`, omit it: `x = 0` instead of `x^1 = 0` * If the power equals `0`, omit the `x`: `x - 2 = 0` instead of `x - 2x^0 = 0` * There should be no 2 signs in a row: `x - 1 = 0` ins...
0
{"tests": "{\"inputs\": [\"6\\n4 5 3 8 3 7\\n\", \"4\\n4 3 2 4\\n\", \"6\\n5 6 4 9 4 8\\n\", \"4\\n5 4 1 5\\n\", \"2\\n3 2\\n\", \"10\\n39 9 18 13 6 16 47 15 1 24\\n\", \"20\\n43 49 46 46 40 41 49 49 48 30 35 36 33 34 42 38 40 46 50 45\\n\", \"30\\n6 1 26 13 16 30 16 23 9 1 5 14 7 2 17 22 21 23 16 3 5 17 22 10 1 24 4 3...
One day Vasya was on a physics practical, performing the task on measuring the capacitance. He followed the teacher's advice and did as much as n measurements, and recorded the results in the notebook. After that he was about to show the results to the teacher, but he remembered that at the last lesson, the teacher had...
0.875
{"tests": "{\"inputs\": [\"1\\n2 1 343417335313797025\\n\", \"2\\n1 100 50 1\\n2 4294967396 1\\n\", \"2\\n1 562949953421312 562949953421311 1\\n2 562949953421312 562949953421311\\n\", \"1\\n2 666077344481199252 881371880336470888\\n\", \"2\\n1 239841676148963 1 20\\n2 2112405731 1\\n\", \"2\\n1 4294967298 4294967299 10...
Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two...
0
{"tests": "{\"inputs\": [\"4\\n+\\n- 1\\n+\\n+\\n- 4\\n+\\n- 2\\n- 3\\n\", \"4\\n+\\n+\\n+\\n- 3\\n- 4\\n+\\n- 1\\n- 2\\n\", \"10\\n+\\n- 3\\n+\\n+\\n+\\n+\\n- 1\\n- 7\\n- 9\\n- 10\\n+\\n+\\n+\\n- 4\\n- 5\\n- 8\\n+\\n+\\n- 6\\n- 2\\n\", \"5\\n+\\n+\\n+\\n- 3\\n- 4\\n+\\n- 1\\n- 2\\n+\\n- 5\\n\", \"5\\n+\\n- 5\\n+\\n+\\...
Tenten runs a weapon shop for ninjas. Today she is willing to sell n shurikens which cost 1, 2, ..., n ryo (local currency). During a day, Tenten will place the shurikens onto the showcase, which is empty at the beginning of the day. Her job is fairly simple: sometimes Tenten places another shuriken (from the available...
0
{"tests": "{\"inputs\": [\"7\\n3 4 1 2 2 1 1\\n\", \"5\\n1 1 3 1 1\\n\", \"5\\n10 40 20 50 30\\n\", \"100\\n10 10 15 12 15 13 15 12 10 10 15 11 13 14 13 14 10 13 12 10 14 12 13 11 14 15 12 11 11 15 12 12 11 14 14 14 15 10 10 15 15 13 13 15 10 12 14 10 12 13 11 15 11 13 14 12 10 12 11 14 13 15 13 15 13 14 14 11 12 13 11...
You are given an array of positive integers. While there are at least two equal elements, we will perform the following operation. We choose the smallest value $x$ that occurs in the array $2$ or more times. Take the first two occurrences of $x$ in this array (the two leftmost occurrences). Remove the left of these two...
0
{"tests": "{\"inputs\": [[[4, 0], 1, false, [2, 2, 2, 2, 2]], [[4, 2], 1, true, [2, 2, 2, 2, 2]], [[4, 4], 2, false, [2, 2, 2, 2, 2]], [[4, 6], 2, true, [2, 2, 2, 2, 2]], [[7, 2], 1, false, [1, 2, 2, 2, 2]], [[7, 4], 1, true, [1, 2, 2, 2, 2]], [[7, 6], 2, false, [1, 2, 2, 2, 2]], [[7, 7], 2, true, [1, 2, 2, 2, 2]], [[5...
You are playing euchre and you want to know the new score after finishing a hand. There are two teams and each hand consists of 5 tricks. The team who wins the majority of the tricks will win points but the number of points varies. To determine the number of points, you must know which team called trump, how many trick...
0
{"tests": "{\"inputs\": [\"131231231 35435 63 153459\\n\", \"165467464 5416516 45 364545697\\n\", \"64 64 64 64\\n\", \"1000000000000000000 1 64 911\\n\", \"999999999999999999 999999999999999999 63 3\\n\", \"154165741654 154168764 54 546546\\n\", \"13713712721 13458749846 38 546863217\\n\", \"6 0 0 1\\n\", \"2 0 0 1000...
We all know that GukiZ often plays with arrays. Now he is thinking about this problem: how many arrays a, of length n, with non-negative elements strictly less then 2l meet the following condition: <image>? Here operation <image> means bitwise AND (in Pascal it is equivalent to and, in C/C++/Java/Python it is equival...
0
{"tests": "{\"inputs\": [\"13\\n92 194 580495 0 10855 41704 13 96429 33 213 0 92 140599\\n\", \"1\\n120287\\n\", \"35\\n130212 3176 77075 8071 18 1369 7539 1683 80757 1847 0 1374 122 8524 4 2 21333 270264 4 9254 151921 0 1 33596 73002 54382 0 1 29233 75952 15 38892 1877 6167 4\\n\", \"2\\n95745 95745\\n\", \"35\\n0 0 2...
Recently, Duff has been practicing weight lifting. As a hard practice, Malek gave her a task. He gave her a sequence of weights. Weight of i-th of them is 2wi pounds. In each step, Duff can lift some of the remaining weights and throw them away. She does this until there's no more weight left. Malek asked her to minimi...
0.5
{"tests": "{\"inputs\": [[\"Ryan\"], [2.3], [26], [true], [\"True\"], [false], [1.98528462]], \"outputs\": [[\"Who ate the last cookie? It was Zach!\"], [\"Who ate the last cookie? It was Monica!\"], [\"Who ate the last cookie? It was Monica!\"], [\"Who ate the last cookie? It was the dog!\"], [\"Who ate the last cooki...
For this problem you must create a program that says who ate the last cookie. If the input is a string then "Zach" ate the cookie. If the input is a float or an int then "Monica" ate the cookie. If the input is anything else "the dog" ate the cookie. The way to return the statement is: "Who ate the last cookie? It was ...
0
{"tests": "{\"inputs\": [\"3 3 100\\n2\\n5 20 3 10\\n2\\n10 50 16 60\\n2\\n8 30 22 100\\n0 1 2\\n\\n1 1 30\\n1\\n13 8\\n0\", \"3 3 100\\n2\\n5 20 3 10\\n2\\n13 50 16 60\\n2\\n0 30 22 100\\n0 1 2\\n\\n1 1 30\\n1\\n13 8\\n0\", \"3 3 100\\n2\\n5 20 3 10\\n2\\n13 50 16 60\\n2\\n0 30 22 100\\n0 0 2\\n\\n1 1 30\\n1\\n13 8\\n...
Problem KND is a student programmer at the University of Aizu. His neighbor is known to be very annoying. Neighbors find out that he is a sweet tooth and plan to add more sweetness than necessary to make him fat. To that end, your neighbor, you, was introduced to a sweets shop by a friend. However, the way products a...
0
{"tests": "{\"inputs\": [\"3 2\\n2 0 2\\n\", \"5 3\\n1 0 0 4 1\\n\", \"1 1\\n0\\n\", \"2 1\\n0 0\\n\", \"2 1\\n0 1\\n\", \"2 1\\n1 0\\n\", \"2 1\\n1 1\\n\", \"2 2\\n0 0\\n\", \"2 2\\n0 1\\n\", \"9 1\\n0 1 1 1 1 1 6 7 8\\n\", \"9 1\\n0 1 1 1 1 5 6 7 8\\n\", \"6 1\\n0 1 2 2 0 0\\n\", \"2 2\\n1 1\\n\", \"2 2\\n1 0\\n\", \...
There are n workers in a company, each of them has a unique id from 1 to n. Exaclty one of them is a chief, his id is s. Each worker except the chief has exactly one immediate superior. There was a request to each of the workers to tell how how many superiors (not only immediate). Worker's superiors are his immediate ...
0