info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [[1, 3], [3, 3], [2, 3], [3, 5], [7, 11], [10, 22], [20, 3400], [9, 26], [20, 10]], \"outputs\": [[6], [4], [5], [8], [16], [35], [6781], [44], [1]]}", "source": "taco"} | ### Task
You've just moved into a perfectly straight street with exactly ```n``` identical houses on either side of the road. Naturally, you would like to find out the house number of the people on the other side of the street. The street looks something like this:
--------------------
### Street
```
1| |6
3| |4
5... | 0.375 |
{"tests": "{\"inputs\": [\"4 3\\n1 7 3 5\\n\", \"5 5\\n1 10 100 1000 10000\\n\", \"2 2\\n52233 12247\\n\", \"3 2\\n4 4 4\\n\", \"10 3\\n10000 20000 30000 40000 50000 60000 70000 80000 90000 100000\\n\", \"6 4\\n36874 16401 3128 2000 1343 1260\\n\", \"12 7\\n15809 57514 78998 84734 87276 90593 95915 97387 98583 99971 99... | Let's call beauty of an array $b_1, b_2, \ldots, b_n$ ($n > 1$) — $\min\limits_{1 \leq i < j \leq n} |b_i - b_j|$.
You're given an array $a_1, a_2, \ldots a_n$ and a number $k$. Calculate the sum of beauty over all subsequences of the array of length exactly $k$. As this number can be very large, output it modulo $99... | 0 |
{"tests": "{\"inputs\": [[[3, 6], [14, 6]], [[-2, 5], [-2, -10], 2], [[1, 2], [4, 6]], [[5, 3], [10, 15], 2], [[-2, -10], [6, 5]], [[4, 7], [6, 2], 3], [[-4, -5], [-5, -4], 1], [[3, 8], [3, 8]], [[-3, 8], [3, 8]], [[3, 8], [3, -8]]], \"outputs\": [[11], [15], [5], [13], [17], [5.385], [1.4], [0], [6], [16]]}", "source"... | Construct a function 'coordinates', that will return the distance between two points on a cartesian plane, given the x and y coordinates of each point.
There are two parameters in the function, ```p1``` and ```p2```. ```p1``` is a list ```[x1,y1]``` where ```x1``` and ```y1``` are the x and y coordinates of the first ... | 0 |
{"tests": "{\"inputs\": [\"3 1\\n2 2\\n\", \"3 0\\n\", \"4 3\\n3 1\\n3 2\\n3 3\\n\", \"2 1\\n1 1\\n\", \"2 3\\n1 2\\n2 1\\n2 2\\n\", \"5 1\\n3 2\\n\", \"5 1\\n2 3\\n\", \"1000 0\\n\", \"999 0\\n\", \"5 5\\n3 2\\n5 4\\n3 3\\n2 3\\n1 2\\n\", \"5 5\\n3 2\\n1 4\\n5 1\\n4 5\\n3 1\\n\", \"5 5\\n2 2\\n5 3\\n2 3\\n5 1\\n4 4\\n... | Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute moves each chip into an adjacent cell. He moves each chip from its original... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n6\\n1 2 2 3 0 3\", \"1 3\\n3\\n3 2 1\", \"1 5\\n3\\n3 2 1\", \"1 5\\n3\\n3 0 1\", \"3 3\\n6\\n0 2 2 3 3 3\", \"2 3\\n3\\n3 0 1\", \"2 3\\n3\\n2 1 2\", \"4 2\\n3\\n2 1 2\", \"3 3\\n6\\n1 2 2 2 0 3\", \"0 5\\n3\\n3 2 1\", \"1 9\\n3\\n3 0 1\", \"2 4\\n3\\n2 1 2\", \"4 2\\n3\\n0 1 2\", \"6 ... | There are N arrays. The length of each array is M and initially each array contains integers (1,2,...,M) in this order.
Mr. Takahashi has decided to perform Q operations on those N arrays. For the i-th (1≤i≤Q) time, he performs the following operation.
* Choose an arbitrary array from the N arrays and move the intege... | 0 |
{"tests": "{\"inputs\": [\"2 2\\n0 1\\n\", \"100 10\\n8 4 4 9 0 7 9 5 1 1 2 3 7 1 8 4 8 8 6 0 8 7 8 3 7 0 6 4 8 4 2 7 0 0 3 8 4 4 2 0 0 4 7 2 4 7 9 1 3 3 6 2 9 6 0 6 3 5 6 5 5 3 0 0 8 7 1 4 2 4 1 3 9 7 9 0 6 6 7 4 2 3 7 1 7 3 5 1 4 3 7 5 7 5 0 5 1 9 0 9\\n\", \"10 10\\n5 0 5 9 4 6 4 5 0 0\\n\", \"6 4\\n1 3 0 2 1 0\\n\"... | Toad Zitz has an array of integers, each integer is between 0 and m-1 inclusive. The integers are a_1, a_2, …, a_n.
In one operation Zitz can choose an integer k and k indices i_1, i_2, …, i_k such that 1 ≤ i_1 < i_2 < … < i_k ≤ n. He should then change a_{i_j} to ((a_{i_j}+1) mod m) for each chosen integer i_j. The i... | 0 |
{"tests": "{\"inputs\": [\"7\\nabcabca\\n\", \"8\\nabcdefgh\\n\", \"100\\nmhnzadklojbuumkrxjayikjhwuxihgkinllackcavhjpxlydxcmhnzadklojbuumkrxjayikjhwuxihgkinllackcavhjpxlydxc\\n\", \"99\\ntrolnjmzxxrfxuexcqpjvefndwuxwsukxwmjhhkqmlzuhrplrtrolnjmzxxrfxuexcqpjvefndwuxwsukxwmjhhkqmlzuhrplrm\\n\", \"100\\nyeywsnxcwslfyiqbbe... | You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.
Initially, you have an empty string. Until you type the whole string, you may perform the following operation: add a character to the end of the string.
Besides, at most once you may perform one addit... | 0.5 |
{"tests": "{\"inputs\": [[1], [2], [13], [19], [41], [42], [74], [86], [93], [101]], \"outputs\": [[1], [8], [2197], [6859], [68921], [74088], [405224], [636056], [804357], [1030301]]}", "source": "taco"} | Given the triangle of consecutive odd numbers:
```
1
3 5
7 9 11
13 15 17 19
21 23 25 27 29
...
```
Calculate the row sums of this triangle from the row index (starting at index 1) e.g.:
```python
row_sum_odd_numbers(1); # 1
row_sum_odd_numbers(2); # 3 ... | 0.75 |
{"tests": "{\"inputs\": [[1024, \"4:3\"], [1280, \"16:9\"], [3840, \"32:9\"], [1600, \"4:3\"], [1280, \"5:4\"], [2160, \"3:2\"], [1920, \"16:9\"], [5120, \"32:9\"]], \"outputs\": [[\"1024x768\"], [\"1280x720\"], [\"3840x1080\"], [\"1600x1200\"], [\"1280x1024\"], [\"2160x1440\"], [\"1920x1080\"], [\"5120x1440\"]]}", "so... | Cheesy Cheeseman just got a new monitor! He is happy with it, but he just discovered that his old desktop wallpaper no longer fits. He wants to find a new wallpaper, but does not know which size wallpaper he should be looking for, and alas, he just threw out the new monitor's box. Luckily he remembers the width and the... | 0.5 |
{"tests": "{\"inputs\": [[\"p0F2LF2RqP0\"], [\"p1P2P3qp2P1qp3P1qP3\"], [\"p1P2qp2P3qP4p3P4qp4P1q\"], [\"p1P2P4qp2P3qp3P4qP1p4P1q\"], [\"p1P2P3qP2P1p2P3qp3P4qp4P1q\"], [\"p1P2qp2P3qp3P4qP6p4P1qp5P7qp6P5qp7P6qP1\"], [\"P1P2P7p1P2qp2P3qp3P4qp4P1qp5P7qp6P5qp7P5q\"], [\"P2P7P6p1P2qp2P3qp3P4qp4P1qp5P8qp6P5qp7P5qp8P7q\"], [\"... | # 'Magic' recursion call depth number
This Kata was designed as a Fork to the one from donaldsebleung Roboscript series with a reference to:
https://www.codewars.com/collections/roboscript
It is not more than an extension of Roboscript infinite "single-" mutual recursion handling to a "multiple-" case.
One can supp... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n\", \"7 4\\n\", \"2 8\\n\", \"34 69\\n\", \"8935891487501725 71487131900013807\\n\", \"470060730774588924 727173667167621133\\n\", \"95 427\\n\", \"985 1653\\n\", \"435 1515\\n\", \"1717 879\\n\", \"407 113\\n\", \"753 271\\n\", \"6261 668\\n\", \"2651 1994\\n\", \"4997 4748\\n\", \"407... | You are given two positive integers $x$ and $y$. You can perform the following operation with $x$: write it in its binary form without leading zeros, add $0$ or $1$ to the right of it, reverse the binary form and turn it into a decimal number which is assigned as the new value of $x$.
For example:
$34$ can be turned ... | 0 |
{"tests": "{\"inputs\": [[0], [1], [2], [3], [4], [5], [6], [10], [20], [50]], \"outputs\": [[0], [0], [0], [525], [8325], [95046], [987048], [9999722967], [99999999999959940181], [99999999999999999999999999999999999999912040301674]]}", "source": "taco"} | A `bouncy number` is a positive integer whose digits neither increase nor decrease. For example, 1235 is an increasing number, 5321 is a decreasing number, and 2351 is a bouncy number. By definition, all numbers under 100 are non-bouncy, and 101 is the first bouncy number.
Determining if a number is bouncy is easy, bu... | 0 |
{"tests": "{\"inputs\": [\"5\\n0 1 5 2 6\\n\", \"7\\n6 9 8 7 3 5 2\\n\", \"7\\n32 35 2 20 52 59 28\\n\", \"31\\n59 189 95 1 107 144 39 5 174 124 100 46 94 84 67 26 56 165 140 157 128 130 35 14 24 182 90 66 173 62 109\\n\", \"2\\n0 1000000000\\n\", \"3\\n4 9 1\\n\", \"7\\n12 11 0 13 3 1 9\\n\", \"2\\n9 8\\n\", \"13\\n30... | For a given sequence of distinct non-negative integers $(b_1, b_2, \dots, b_k)$ we determine if it is good in the following way:
Consider a graph on $k$ nodes, with numbers from $b_1$ to $b_k$ written on them.
For every $i$ from $1$ to $k$: find such $j$ ($1 \le j \le k$, $j\neq i$), for which $(b_i \oplus b_j)$ is t... | 0 |
{"tests": "{\"inputs\": [\"3\\n4\\n1 1 1 0\\n5\\n4 3 2 1 0\\n9\\n4 1 4 3 1 0 2 1 0\\n\", \"3\\n4\\n1 1 1 0\\n5\\n4 3 2 1 0\\n9\\n4 1 4 2 1 0 2 0 0\\n\", \"3\\n4\\n1 1 1 0\\n5\\n2 3 2 1 0\\n9\\n3 1 4 1 1 0 2 1 0\\n\", \"3\\n4\\n1 1 1 0\\n5\\n4 3 2 1 0\\n9\\n4 2 4 3 1 0 2 1 0\\n\", \"3\\n4\\n2 1 1 0\\n5\\n2 3 2 1 0\\n9\\... | Gildong is now developing a puzzle game. The puzzle consists of n platforms numbered from 1 to n. The player plays the game as a character that can stand on each platform and the goal of the game is to move the character from the 1-st platform to the n-th platform.
The i-th platform is labeled with an integer a_i (0 ≤... | 0 |
{"tests": "{\"inputs\": [\"15\\n9 10\\n9 15\\n15 4\\n4 13\\n13 2\\n13 11\\n2 14\\n13 6\\n11 1\\n1 12\\n12 3\\n12 7\\n2 5\\n14 8\\n1154 890 2240 883 2930 2076 1590 1104 1726 1791 1091 1226 841 1000 901\", \"5\\n1 2\\n1 3\\n1 4\\n1 5\\n5 13 16 19 22\", \"15\\n9 10\\n9 15\\n15 4\\n4 13\\n13 2\\n13 11\\n2 14\\n13 6\\n11 1\... | Snuke found a record of a tree with N vertices in ancient ruins. The findings are as follows:
* The vertices of the tree were numbered 1,2,...,N, and the edges were numbered 1,2,...,N-1.
* Edge i connected Vertex a_i and b_i.
* The length of each edge was an integer between 1 and 10^{18} (inclusive).
* The sum of the ... | 0 |
{"tests": "{\"inputs\": [[[1, 2, 3, 6, 4, 1, 2, 3, 2, 1]], [[3, 2, 3, 6, 4, 1, 2, 3, 2, 1, 2, 3]], [[3, 2, 3, 6, 4, 1, 2, 3, 2, 1, 2, 2, 2, 1]], [[2, 1, 3, 1, 2, 2, 2, 2, 1]], [[2, 1, 3, 1, 2, 2, 2, 2]], [[2, 1, 3, 2, 2, 2, 2, 5, 6]], [[2, 1, 3, 2, 2, 2, 2, 1]], [[1, 2, 5, 4, 3, 2, 3, 6, 4, 1, 2, 3, 3, 4, 5, 3, 2, 1, 2... | In this kata, you will write a function that returns the positions and the values of the "peaks" (or local maxima) of a numeric array.
For example, the array `arr = [0, 1, 2, 5, 1, 0]` has a peak at position `3` with a value of `5` (since `arr[3]` equals `5`).
~~~if-not:php,cpp,java,csharp
The output will be returned... | 0 |
{"tests": "{\"inputs\": [\"4 4 1\\n3 1 2\\n2 2 4\\n3 3 4\\n1 3 4\\n0 0 0\", \"4 4 1\\n3 1 2\\n2 2 3\\n4 3 4\\n1 3 4\\n0 0 0\", \"4 4 1\\n3 1 2\\n2 2 4\\n3 3 4\\n1 1 4\\n0 0 0\", \"4 4 1\\n0 1 2\\n2 2 3\\n3 3 4\\n0 3 4\\n0 0 0\", \"4 3 1\\n3 1 2\\n0 1 3\\n4 3 4\\n1 0 1\\n0 0 0\", \"4 3 1\\n3 1 1\\n0 1 3\\n4 3 4\\n1 0 1\... | The mayor of Amida, the City of Miracle, is not elected like any other city. Once exhausted by long political struggles and catastrophes, the city has decided to leave the fate of all candidates to the lottery in order to choose all candidates fairly and to make those born under the lucky star the mayor. I did. It is a... | 0 |
{"tests": "{\"inputs\": [\"999 0\\n\", \"6 5\\n2 6\\n5 2\\n4 3\\n6 6\\n2 5\\n\", \"5 1\\n3 2\\n\", \"6 5\\n2 6\\n6 5\\n3 1\\n2 2\\n1 2\\n\", \"2 3\\n1 2\\n2 1\\n2 2\\n\", \"5 5\\n3 2\\n1 4\\n5 1\\n4 5\\n3 1\\n\", \"1000 0\\n\", \"5 1\\n2 3\\n\", \"5 5\\n2 2\\n5 3\\n2 3\\n5 1\\n4 4\\n\", \"2 1\\n1 1\\n\", \"5 5\\n3 2\\n... | Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute moves each chip into an adjacent cell. He moves each chip from its original... | 0 |
{"tests": "{\"inputs\": [\"3 1\\n2 3\\n6 4\\n0 0\", \"4 1\\n2 3\\n6 4\\n0 0\", \"3 1\\n4 3\\n6 4\\n0 0\", \"4 1\\n1 3\\n6 6\\n0 0\", \"5 1\\n4 3\\n6 6\\n0 0\", \"8 1\\n1 3\\n6 6\\n0 0\", \"5 1\\n4 3\\n12 4\\n0 0\", \"8 1\\n1 3\\n2 6\\n0 0\", \"5 1\\n4 3\\n23 4\\n0 0\", \"16 1\\n1 3\\n2 6\\n0 0\", \"19 1\\n1 3\\n2 6\\n0... | Dr. Asimov, a robotics researcher, released cleaning robots he developed (see Problem B). His robots soon became very popular and he got much income. Now he is pretty rich. Wonderful.
First, he renovated his house. Once his house had 9 rooms that were arranged in a square, but now his house has N × N rooms arranged in... | 0 |
{"tests": "{\"inputs\": [\"3+5*7+8*4\\n\", \"2+3*5\\n\", \"3*4*5\\n\", \"5*5*5*5*5*5*5*5*5*5*5*5*5*5*5*5\\n\", \"2*2+2*2\\n\", \"1+1+1+1+1+1+1\\n\", \"1+5*6+7*8\\n\", \"9*8+7*6+5*4+3*2+1\\n\", \"3*3*9+4+6+8*4+5+1*4*6\\n\", \"4*9+4+5+8*4+6+9+8+2+5+2+5*7+6+8\\n\", \"9+9+9*9*9*9+9+9\\n\", \"9+9+9+9+9*9*9*9\\n\", \"1*1*1*1... | Vanya is doing his maths homework. He has an expression of form $x_{1} \diamond x_{2} \diamond x_{3} \diamond \ldots \diamond x_{n}$, where x_1, x_2, ..., x_{n} are digits from 1 to 9, and sign [Image] represents either a plus '+' or the multiplication sign '*'. Vanya needs to add one pair of brackets in this expressio... | 0.125 |
{"tests": "{\"inputs\": [\"2\\n8 8\\n\", \"4\\n3 1 4 1\\n\", \"4\\n42 49 42 42\\n\", \"8\\n11 21 31 41 41 31 21 11\\n\", \"10\\n21 4 7 21 18 38 12 17 21 13\\n\", \"12\\n33 26 11 11 32 25 18 24 27 47 28 7\\n\", \"14\\n4 10 7 13 27 28 13 34 16 18 39 26 29 22\\n\", \"16\\n47 27 33 49 2 47 48 9 37 39 5 24 38 38 4 32\\n\", ... | Alice and Bob are playing a game with $n$ piles of stones. It is guaranteed that $n$ is an even number. The $i$-th pile has $a_i$ stones.
Alice and Bob will play a game alternating turns with Alice going first.
On a player's turn, they must choose exactly $\frac{n}{2}$ nonempty piles and independently remove a positi... | 0 |
{"tests": "{\"inputs\": [\"1\\n.\\n\", \"6\\n.EEEEE\\n.EEEEE\\n......\\n......\\n......\\nEEEEEE\\n\", \"3\\nEEE\\n..E\\n...\\n\", \"3\\nE..\\nEEE\\nE..\\n\", \"17\\nEE...E.EE.EE..E..\\nE.....EE..E..E..E\\nEEEE.EEEE..E..E.E\\n.E.E.EEE.EEEEE...\\nEEEEEEEEEEEEEEEEE\\nEE.E.EEEEE.E.....\\n..E.EE.EEE.E....E\\n.E..E..E...EE.... | You are an adventurer currently journeying inside an evil temple. After defeating a couple of weak zombies, you arrived at a square room consisting of tiles forming an n × n grid. The rows are numbered 1 through n from top to bottom, and the columns are numbered 1 through n from left to right. At the far side of the ro... | 0 |
{"tests": "{\"inputs\": [[1], [2], [3], [4], [15], [150], [100], [500], [1000], [10000]], \"outputs\": [[1], [5], [15], [34], [1695], [1687575], [500050], [62500250], [500000500], [500000005000]]}", "source": "taco"} | Imagine a triangle of numbers which follows this pattern:
* Starting with the number "1", "1" is positioned at the top of the triangle. As this is the 1st row, it can only support a single number.
* The 2nd row can support the next 2 numbers: "2" and "3"
* Likewise, the 3rd row, can only support the next 3 numbers:... | 0.875 |
{"tests": "{\"inputs\": [\"2\\n8\\n1 5 2\\n2 6 1\\n2\\n9\\n1 3 2\\n2 6 1\\n0\", \"2\\n8\\n1 5 2\\n3 6 1\\n2\\n7\\n1 5 2\\n2 6 1\\n0\", \"2\\n8\\n1 5 2\\n2 6 1\\n0\\n9\\n0 3 2\\n2 6 1\\n0\", \"2\\n14\\n1 5 2\\n3 6 1\\n2\\n7\\n1 5 2\\n2 6 1\\n0\", \"2\\n8\\n1 5 2\\n2 6 1\\n2\\n7\\n1 8 2\\n2 6 1\\n0\", \"2\\n14\\n1 5 2\\n... | Interest rates are attached to the money deposited in banks, and the calculation method and interest rates vary from bank to bank. The combination of interest and principal is called principal and interest, but as a method of calculating principal and interest, there are "single interest" that calculates without incorp... | 0.625 |
{"tests": "{\"inputs\": [\"10 5\\n6 4\\n4 1\\n7 5\\n8 7\\n2 6\\n3 6\\n8 6\\n10 3\\n4 9\\n\", \"10 4\\n9 6\\n10 8\\n9 2\\n7 10\\n3 7\\n7 9\\n10 4\\n1 7\\n9 5\\n\", \"10 9\\n1 2\\n3 1\\n6 10\\n6 1\\n10 9\\n4 5\\n7 1\\n5 6\\n8 5\\n\", \"10 2\\n7 10\\n2 1\\n6 5\\n10 6\\n3 1\\n10 4\\n3 4\\n9 3\\n8 4\\n\", \"10 0\\n5 6\\n4 3... | Ostap already settled down in Rio de Janiero suburb and started to grow a tree in his garden. Recall that a tree is a connected undirected acyclic graph.
Ostap's tree now has n vertices. He wants to paint some vertices of the tree black such that from any vertex u there is at least one black vertex v at distance no m... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 1\\n5 2\\n6 3\", \"4\\n1 5\\n4 7\\n2 1\\n6 4\", \"10\\n1375710043 178537096\\n705445072 318106937\\n472381277 579910117\\n353498483 865935868\\n383133839 231371336\\n378371075 681212831\\n304570952 16537461\\n955719384 267238505\\n844917655 218662351\\n550309930 62731178\", \"10\\n13757... | We have N balance beams numbered 1 to N. The length of each beam is 1 meters. Snuke walks on Beam i at a speed of 1/A_i meters per second, and Ringo walks on Beam i at a speed of 1/B_i meters per second.
Snuke and Ringo will play the following game:
* First, Snuke connects the N beams in any order of his choice and m... | 0 |
{"tests": "{\"inputs\": [[[10], 90], [[20, 10], 55], [[0], 90], [[0, 0, 0], 90], [[10, 0], 90], [[0, 10], 90], [[10, 0, 0, 10], 81], [[0, 10, 0, 10], 81], [[0, 10, 10, 0], 81], [[10, 20, 30, 40, 50, 60, 70, 80, 90], 25], [[90, 80, 70, 60, 50, 40, 30, 20, 10], 20], [[10, 0, 30, 0, 50, 0, 70, 0, 90], 25], [[22, 33, 44, 1... | # Explanation
It's your first day in the robot factory and your supervisor thinks that you should start with an easy task. So you are responsible for purchasing raw materials needed to produce the robots.
A complete robot weights `50` kilogram. Iron is the only material needed to create a robot. All iron is inserted ... | 0 |
{"tests": "{\"inputs\": [\"5 8\\n121351 0 13513 0 165454\\n\", \"9 5\\n0 0 0 0 0 0 0 0 6\\n\", \"6 6\\n0 10 0 0 10 0\\n\", \"6 2\\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\\n\", \"19 100000\\n1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1\\n\", \"1 1\\n15141354\\n\", \"5 3\\n0 0 14 0 0\\n\", \"20 20\\n0... | Professor GukiZ is concerned about making his way to school, because massive piles of boxes are blocking his way.
In total there are n piles of boxes, arranged in a line, from left to right, i-th pile (1 ≤ i ≤ n) containing ai boxes. Luckily, m students are willing to help GukiZ by removing all the boxes from his way... | 0 |
{"tests": "{\"inputs\": [\"5 0\\n5 3 4 1 2\\n\", \"10 -10\\n5 5 1 7 5 1 2 4 9 2\\n\", \"5 0\\n5 3 5 1 2\\n\", \"10 -10\\n5 4 1 7 5 1 2 4 9 2\\n\", \"10 -10\\n5 4 1 7 5 1 1 4 9 2\\n\", \"10 -4\\n5 4 1 7 5 1 2 4 9 2\\n\", \"10 -13\\n5 7 1 1 5 1 1 4 9 2\\n\", \"10 -6\\n5 2 1 9 5 2 4 4 9 2\\n\", \"10 -10\\n4 4 1 7 5 1 1 1 ... | During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants.
Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a_1, the second place participant has rating a_2, ..., t... | 0 |
{"tests": "{\"inputs\": [\"9\\n2\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n\", \"9\\n2\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n17\\n\", \"9\\n2\\n2\\n3\\n4\\n5\\n6\\n13\\n8\\n17\\n\", \"9\\n2\\n2\\n3\\n4\\n5\\n6\\n13\\n8\\n19\\n\", \"9\\n2\\n2\\n3\\n4\\n5\\n6\\n13\\n8\\n33\\n\", \"9\\n2\\n2\\n3\\n4\\n5\\n9\\n13\\n8\\n33\\n\", \"9\\n2\\n... | Consider the infinite sequence s of positive integers, created by repeating the following steps:
1. Find the lexicographically smallest triple of positive integers (a, b, c) such that
* a ⊕ b ⊕ c = 0, where ⊕ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).
* a, b, ... | 0 |
{"tests": "{\"inputs\": [\"100 10000\\nababbabaaabababbabbaaabbbaaabbbbbbaabbbbaabbabbaabbbaaaaaaababaabaaaaaaaababbaabbbaabaababbbaababbba\\nbbbbabbabbbbbabbbbbbbbabaaabbbbababbababaabaaabbbabbababbabaabbababbabbaaaaabbababaaababbaabaaaababb\\n\", \"10 100\\naaabaabaaa\\nbaaaaaaaaa\\n\", \"10 100\\naabaaaaaab\\naabbaa... | Recently, the Fair Nut has written k strings of length n, consisting of letters "a" and "b". He calculated c — the number of strings that are prefixes of at least one of the written strings. Every string was counted only one time.
Then, he lost his sheet with strings. He remembers that all written strings were lexicog... | 0 |
{"tests": "{\"inputs\": [\"4 5\\n1 2 1\\n1 2 2\\n2 3 1\\n2 3 3\\n2 4 3\\n3\\n1 2\\n3 4\\n1 4\\n\", \"5 7\\n1 5 1\\n2 5 1\\n3 5 1\\n4 5 1\\n1 2 2\\n2 3 2\\n3 4 2\\n5\\n1 5\\n5 1\\n2 5\\n1 5\\n1 4\\n\", \"2 1\\n1 2 1\\n1\\n1 2\\n\", \"2 3\\n1 2 3\\n1 2 2\\n1 2 1\\n1\\n1 2\\n\", \"2 5\\n1 2 1\\n1 2 2\\n1 2 3\\n1 2 4\\n1 2... | Mr. Kitayuta has just bought an undirected graph consisting of n vertices and m edges. The vertices of the graph are numbered from 1 to n. Each edge, namely edge i, has a color c_{i}, connecting vertex a_{i} and b_{i}.
Mr. Kitayuta wants you to process the following q queries.
In the i-th query, he gives you two inte... | 0.75 |
{"tests": "{\"inputs\": [\"5 3\\n3 2 2\\n\", \"10 1\\n1\\n\", \"1 1\\n1\\n\", \"2 2\\n1 2\\n\", \"200 50\\n49 35 42 47 134 118 14 148 58 159 33 33 8 123 99 126 75 94 1 141 61 79 122 31 48 7 66 97 141 43 25 141 7 56 120 55 49 37 154 56 13 59 153 133 18 1 141 24 151 125\\n\", \"3 3\\n3 3 1\\n\", \"100000 1\\n100000\\n\",... | Dreamoon likes coloring cells very much.
There is a row of $n$ cells. Initially, all cells are empty (don't contain any color). Cells are numbered from $1$ to $n$.
You are given an integer $m$ and $m$ integers $l_1, l_2, \ldots, l_m$ ($1 \le l_i \le n$)
Dreamoon will perform $m$ operations.
In $i$-th operation, Dre... | 0 |
{"tests": "{\"inputs\": [\"3\\n3 26\\n10 12\\n1 4\\n10 11\\n1 1337\\n1 1000000000\\n5 26\\n4 4\\n2 4\\n6 8\\n5 6\\n2 7\\n\", \"1\\n1 1000000000\\n1000000000 1000000000\\n\", \"1\\n1 1000000000\\n1000000000 1000000000\\n\", \"3\\n3 26\\n10 12\\n1 4\\n10 11\\n1 1337\\n1 1000000000\\n5 26\\n4 4\\n0 4\\n6 8\\n5 6\\n2 7\\n\... | You are the head of a large enterprise. $n$ people work at you, and $n$ is odd (i. e. $n$ is not divisible by $2$).
You have to distribute salaries to your employees. Initially, you have $s$ dollars for it, and the $i$-th employee should get a salary from $l_i$ to $r_i$ dollars. You have to distribute salaries in such... | 0 |
{"tests": "{\"inputs\": [\"3 4\\nabac\\ncaab\\nacba\\n\", \"3 4\\nkbbu\\nkbub\\nubkb\\n\", \"5 4\\nabcd\\ndcba\\nacbd\\ndbca\\nzzzz\\n\", \"3 2\\nxh\\nxh\\nxh\\n\", \"3 4\\nkbub\\nkbbu\\nubkb\\n\", \"1 2\\nyu\\n\", \"1 3\\nvts\\n\", \"2 2\\nnm\\nnm\\n\", \"2 3\\nghn\\nghn\\n\", \"3 2\\ncg\\ncg\\ncg\\n\", \"3 3\\nuvh\\n... | We had a string s consisting of n lowercase Latin letters. We made k copies of this string, thus obtaining k identical strings s_1, s_2, ..., s_{k}. After that, in each of these strings we swapped exactly two characters (the characters we swapped could be identical, but they had different indices in the string).
You a... | 0 |
{"tests": "{\"inputs\": [\"10\\n10 11 10 11 10 11 10 11 10 11\\n\", \"20\\n2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1 5 6 5 6\\n\", \"8\\n1 2 2 2 2 3 3 3\\n\", \"4\\n294368194 294368194 294368194 294368195\\n\", \"3\\n1 2 1000000000\\n\", \"5\\n650111756 650111755 650111754 650111755 650111756\\n\", \"8\\n1 2 3 2 3 2 3 2\\n\", \"... | One day Anna got the following task at school: to arrange several numbers in a circle so that any two neighboring numbers differs exactly by 1. Anna was given several numbers and arranged them in a circle to fulfill the task. Then she wanted to check if she had arranged the numbers correctly, but at this point her youn... | 0 |
{"tests": "{\"inputs\": [\"5\\n2 0\\n0 0\\n1 0\\n1 1\\n0 1\\n0 -1 -2 1 0\\n\", \"3\\n1 0\\n0 0\\n2 0\\n0 1 2\\n\", \"9\\n0 0\\n1 0\\n2 0\\n0 1\\n1 1\\n2 1\\n1 2\\n2 2\\n0 2\\n0 0 0 -1 -1 -2 1 1 2\\n\", \"18\\n0 0\\n0 1\\n0 2\\n0 3\\n0 4\\n0 5\\n0 6\\n0 7\\n0 8\\n0 9\\n0 10\\n0 11\\n0 12\\n0 13\\n0 14\\n0 15\\n0 16\\n1 ... | Wilbur is playing with a set of n points on the coordinate plane. All points have non-negative integer coordinates. Moreover, if some point (x, y) belongs to the set, then all points (x', y'), such that 0 ≤ x' ≤ x and 0 ≤ y' ≤ y also belong to this set.
Now Wilbur wants to number the points in the set he has, that is ... | 0 |
{"tests": "{\"inputs\": [\"2 1\\n\", \"10 7\\n\", \"1000000000000 1\\n\", \"3 1\\n\", \"4 1\\n\", \"3 2\\n\", \"4 2\\n\", \"1000 700\\n\", \"959986566087 524054155168\\n\", \"4 3\\n\", \"7 6\\n\", \"1000 999\\n\", \"1000 998\\n\", \"1000 997\\n\", \"42 1\\n\", \"1000 1\\n\", \"8 5\\n\", \"13 8\\n\", \"987 610\\n\", \"4... | One day Vasya was sitting on a not so interesting Maths lesson and making an origami from a rectangular a mm × b mm sheet of paper (a > b). Usually the first step in making an origami is making a square piece of paper from the rectangular sheet by folding the sheet along the bisector of the right angle, and cutting t... | 0.875 |
{"tests": "{\"inputs\": [\"3\\n100 50 50\\n\", \"3\\n80 60 60\\n\", \"2\\n6 5\\n\", \"4\\n51 25 99 25\\n\", \"100\\n2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\"... | Alice is the leader of the State Refactoring Party, and she is about to become the prime minister.
The elections have just taken place. There are $n$ parties, numbered from $1$ to $n$. The $i$-th party has received $a_i$ seats in the parliament.
Alice's party has number $1$. In order to become the prime minister, sh... | 0.25 |
{"tests": "{\"inputs\": [\"4\\n24 99\\n15 68\\n12 90\\n95 66\", \"3\\n0 46\\n94 8\\n46 57\", \"4\\n24 99\\n15 44\\n12 90\\n95 66\", \"3\\n0 46\\n9 8\\n46 57\", \"4\\n18 99\\n15 44\\n12 90\\n95 66\", \"3\\n1 46\\n9 8\\n46 57\", \"4\\n18 99\\n15 44\\n3 90\\n95 66\", \"3\\n1 63\\n9 8\\n46 57\", \"4\\n18 99\\n15 44\\n3 90\... | Playing with Stones
Koshiro and Ukiko are playing a game with black and white stones. The rules of the game are as follows:
1. Before starting the game, they define some small areas and place "one or more black stones and one or more white stones" in each of the areas.
2. Koshiro and Ukiko alternately select an area ... | 0 |
{"tests": "{\"inputs\": [\"3\\nA sample input\\n9\\nforward word\\ndelete char\\nforward word\\ndelete char\\nforward word\\ndelete char\\nbackward word\\nbackward word\\nforward word\\nHallow, Word.\\n7\\nforward char\\ndelete word\\ninsert \\\"ello, \\\"\\nforward word\\nbackward char\\nbackward char\\ninsert \\\"l\\... | A text editor is a useful software tool that can help people in various situations including writing and programming. Your job in this problem is to construct an offline text editor, i.e., to write a program that first reads a given text and a sequence of editing commands and finally reports the text obtained by perfor... | 0 |
{"tests": "{\"inputs\": [\"3 5\\nabc\\nxaybz\\n\", \"4 10\\nabcd\\nebceabazcd\\n\", \"1 1\\na\\na\\n\", \"1 1\\na\\nz\\n\", \"3 5\\naaa\\naaaaa\\n\", \"3 5\\naaa\\naabaa\\n\", \"5 5\\ncoder\\ncored\\n\", \"1 1\\nz\\nz\\n\", \"1 2\\nf\\nrt\\n\", \"1 2\\nf\\nfg\\n\", \"1 2\\nf\\ngf\\n\", \"2 5\\naa\\naabaa\\n\", \"2 5\\n... | Erelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It's well known that it is a very interesting occupation though it can be very difficult from time to time. In the course of solving one of the crosswords, Leha had to solve a simple ta... | 0 |
{"tests": "{\"inputs\": [[[\"a\", \"a\", \"a\", \"a\", \"a\"], [2, 4]], [[0, 1, 5, 2, 1, 8, 9, 1, 5], [1, 4, 7]], [[1, 2, 3, 4, 5], [0]], [[\"this\", \"is\", \"test\"], [0, 1, 2]], [[0, 3, 4], [2, 6]], [[1], []], [[], [2]], [[], []]], \"outputs\": [[[\"a\", \"a\"]], [[1, 1, 1]], [[1]], [[\"this\", \"is\", \"test\"]], [... | You are given two arrays `arr1` and `arr2`, where `arr2` always contains integers.
Write the function `find_array(arr1, arr2)` such that:
For `arr1 = ['a', 'a', 'a', 'a', 'a']`, `arr2 = [2, 4]`
`find_array returns ['a', 'a']`
For `arr1 = [0, 1, 5, 2, 1, 8, 9, 1, 5]`, `arr2 = [1, 4, 7]`
`find_array returns [1, 1, 1]`... | 0 |
{"tests": "{\"inputs\": [\"25\\n\", \"_00\\n\", \"_XX\\n\", \"0\\n\", \"0_25\\n\", \"5\\n\", \"_\\n\", \"X\\n\", \"__\\n\", \"_X\\n\", \"_5\\n\", \"X5\\n\", \"XX\\n\", \"___X_X25\\n\", \"_X8__725\\n\", \"85X1X525\\n\", \"79XX_925\\n\", \"_7XX16X_\\n\", \"1_07XXX_\\n\", \"X2XXX9X_\\n\", \"XX9_X_X_\\n\", \"2___2__X\\n\",... | Mr. Chanek has an integer represented by a string $s$. Zero or more digits have been erased and are denoted by the character _. There are also zero or more digits marked by the character X, meaning they're the same digit.
Mr. Chanek wants to count the number of possible integer $s$, where $s$ is divisible by $25$. Of ... | 0.125 |
{"tests": "{\"inputs\": [\"2\\n1\\n1 2\\n2\\n1 2 1\", \"2\\n1\\n1 2\\n2\\n2 2 1\", \"2\\n1\\n1 2\\n2\\n2 2 0\", \"2\\n1\\n1 0\\n2\\n2 2 0\", \"2\\n1\\n1 0\\n2\\n3 2 0\", \"2\\n1\\n1 0\\n2\\n3 2 -1\", \"2\\n1\\n1 0\\n2\\n3 4 -1\", \"2\\n1\\n1 2\\n2\\n1 2 2\", \"2\\n1\\n1 2\\n2\\n2 3 1\", \"2\\n1\\n1 2\\n2\\n2 1 0\", \"2... | Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Princess Rupsa saw one of her friends playing a special game. The game goes as follows:
N+1 numbers occur sequentially (one at a time) from A_{0} to A_{N}.
You must write the numbers on a sheet of paper, such that A_{0} is written first. T... | 0 |
{"tests": "{\"inputs\": [\"4\\nabcc\\nbcab\\n\", \"4\\nacca\\nbabb\\n\", \"4\\naabc\\naacb\\n\", \"100\\naaabaabbbababbbaabbbbbaaababbabbaaabbabaabbabbabbbbbabbaaabbbbbbbbbbbbbbbababaaababbaaabeabbabaabbab\\naaabaabbbababbbaabbbbbaaababbabbaaabbabaabbabbabbbbbabbaaabbbbbbbbbbbbbbbababaaababbaaabtabbabaabbab\\n\", \"100... | Analyzing the mistakes people make while typing search queries is a complex and an interesting work. As there is no guaranteed way to determine what the user originally meant by typing some query, we have to use different sorts of heuristics.
Polycarp needed to write a code that could, given two words, check whether t... | 0 |
{"tests": "{\"inputs\": [\"7 8 25\\n1 2 1\\n2 3 10\\n3 4 2\\n1 5 2\\n5 6 7\\n6 4 15\\n5 3 1\\n1 7 3\\n\", \"2 1 5\\n1 2 4\\n\", \"15 15 23\\n13 10 12\\n11 14 12\\n2 15 5\\n4 10 8\\n10 2 4\\n10 7 5\\n3 10 1\\n5 6 11\\n1 13 8\\n9 15 4\\n4 2 9\\n11 15 1\\n11 12 14\\n10 8 12\\n3 6 11\\n\", \"5 10 10000000\\n2 4 798\\n1 5 8... | You are given a simple weighted connected undirected graph, consisting of $n$ vertices and $m$ edges.
A path in the graph of length $k$ is a sequence of $k+1$ vertices $v_1, v_2, \dots, v_{k+1}$ such that for each $i$ $(1 \le i \le k)$ the edge $(v_i, v_{i+1})$ is present in the graph. A path from some vertex $v$ also... | 0 |
{"tests": "{\"inputs\": [\"2 1 2\\n12 9\\n\", \"2 2 2\\n60 59\\n\", \"5 1 3\\n1 5 13 8 16\\n\", \"5 10 8\\n1000000000 1000000000 1000000000 1000000000 1000000000\\n\", \"3 1 2\\n20 17 8\\n\", \"2 1 8\\n18 17\\n\", \"5 10 8\\n0 0 0 0 0\\n\", \"3 1 3\\n3 2 0\\n\", \"3 1 8\\n10 17 18\\n\", \"1 1 2\\n1\\n\", \"2 2 2\\n9 10... | You are given n numbers a1, a2, ..., an. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make <image> as large as possible, where <image> denotes the bitwise OR.
Find the maximum possible value of <image> after performing at most k operations optimally.
I... | 0.375 |
{"tests": "{\"inputs\": [\"6\\n2\\n8 12 8 12\\n2\\n7 7 9 11\\n2\\n7 11 7 11\\n1\\n1 1\\n4\\n40 56 48 40 80 56 80 48\\n6\\n240 154 210 162 174 154 186 240 174 186 162 210\\n\", \"1\\n2\\n8 12 12 12\\n\", \"1\\n2\\n8 12 12 12\\n\", \"1\\n2\\n10 12 12 12\\n\", \"6\\n2\\n3 12 8 12\\n2\\n7 7 9 11\\n2\\n7 11 7 11\\n1\\n1 1\\... | Long time ago there was a symmetric array $a_1,a_2,\ldots,a_{2n}$ consisting of $2n$ distinct integers. Array $a_1,a_2,\ldots,a_{2n}$ is called symmetric if for each integer $1 \le i \le 2n$, there exists an integer $1 \le j \le 2n$ such that $a_i = -a_j$.
For each integer $1 \le i \le 2n$, Nezzar wrote down an intege... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n2 3 1\\n\", \"7 4\\n1 3 1 2 2 4 3\\n\", \"3 3\\n3 1 3\\n\", \"8 8\\n6 2 1 8 5 7 3 4\\n\", \"10 5\\n5 1 2 2 3 3 4 4 5 1\\n\", \"100 100\\n98 52 63 2 18 96 31 58 84 40 41 45 66 100 46 71 26 48 81 20 73 91 68 76 13 93 17 29 64 95 79 21 55 75 19 85 54 51 89 78 15 87 43 59 36 1 90 35 65 56 6... | You are given an array consisting of $n$ integers $a_1, a_2, \dots , a_n$ and an integer $x$. It is guaranteed that for every $i$, $1 \le a_i \le x$.
Let's denote a function $f(l, r)$ which erases all values such that $l \le a_i \le r$ from the array $a$ and returns the resulting array. For example, if $a = [4, 1, 1, ... | 0 |
{"tests": "{\"inputs\": [[\"8\", \"0\", \"BB\", \"0\", \"BG\", \"0\", \"BBGG\", \"1\", \"BGG\", \"1\", \"BGGB\", \"1\", \"BBBGG\", \"2\", \"BBGG\", \"2\", \"BGB\"], \"8\\n1\\nBB\\n0\\nBG\\n0\\nBBGG\\n1\\nBGG\\n1\\nBGGB\\n1\\nBBBGG\\n2\\nBBGG\\n2\\nBGB\", \"8\\n1\\nBB\\n0\\nBG\\n0\\nBBGG\\n1\\nGBG\\n1\\nBGGB\\n1\\nBBBGG... | Devu is a class teacher of a class of n students. One day, in the morning prayer of the school, all the students of his class were standing in a line. You are given information of their arrangement by a string s. The string s consists of only letters 'B' and 'G', where 'B' represents a boy and 'G' represents a girl.
De... | 0 |
{"tests": "{\"inputs\": [\"3 3 2\\n\", \"3 3 3\\n\", \"4 3 2\\n\", \"4 5 2\\n\", \"28 6 3\\n\", \"5 100 1\\n\", \"50 6 3\\n\", \"10 13 6\\n\", \"20 16 14\\n\", \"1 10 1\\n\", \"8 11 4\\n\", \"16 5 4\\n\", \"5 26 17\\n\", \"35 47 42\\n\", \"11 6 2\\n\", \"54 60 16\\n\", \"47 5 1\\n\", \"70 6 1\\n\", \"40 77 77\\n\", \"9... | Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | 0.625 |
{"tests": "{\"inputs\": [\"3\\n1 2 1\\n\", \"5\\n20 4 3 2 1\\n\", \"7\\n77486105 317474713 89523018 332007362 7897847 949616701 54820086\\n\", \"14\\n245638694 2941428 4673577 12468 991349408 44735727 14046308 60637707 81525 104620306 88059371 53742651 8489205 3528194\\n\", \"19\\n479740 7703374 196076708 180202968 579... | [Image]
As some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore.
A famous sculptor Cicasso, whose self-portrait you can contemplate, hates cubism. He is more impressed by the idea to tra... | 0.75 |
{"tests": "{\"inputs\": [\"5\\n15 2 1 5 3\\n\", \"15\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\", \"10\\n13 2 5 55 21 34 1 8 1 3\\n\", \"10\\n8 256 16 1 2 1 64 4 128 32\\n\", \"10\\n10000 40000 10000 50000 20000 100000 10000 100 30000 500\\n\", \"1\\n1000000000\\n\", \"15\\n9 11 45 86 52 65 35 3 93 7 21 45 15 11 39\\n\", \"20... | Little girl Susie went shopping with her mom and she wondered how to improve service quality.
There are n people in the queue. For each person we know time t_{i} needed to serve him. A person will be disappointed if the time he waits is more than the time needed to serve him. The time a person waits is the total time... | 0.375 |
{"tests": "{\"inputs\": [\"???(?)??(??)?)(?(?????????(?()????)(????(?)????)???)??))(?(?????????))???(??)?????))???????(????????\\n9 10\\n6 3\\n8 2\\n9 10\\n9 3\\n6 2\\n8 5\\n6 7\\n2 6\\n7 8\\n6 10\\n1 7\\n1 7\\n10 7\\n10 7\\n8 4\\n5 9\\n9 3\\n3 10\\n1 10\\n8 2\\n8 8\\n4 8\\n6 6\\n4 10\\n4 5\\n5 2\\n5 6\\n7 7\\n7 3\\n10... | This is yet another problem on regular bracket sequences.
A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequenc... | 0 |
{"tests": "{\"inputs\": [\"4\\n2 3\\n3 1\\n6 1\\n0 2\\n\", \"1\\n42 23\\n\", \"2\\n1 5\\n2 6\\n\", \"2\\n1 5\\n12 6\\n\", \"1\\n0 1\\n\", \"1\\n1000000000 1000000000\\n\", \"2\\n4 4\\n12 5\\n\", \"2\\n4 4\\n12 4\\n\", \"2\\n4 4\\n12 3\\n\", \"3\\n0 1\\n2 1\\n4 1\\n\", \"3\\n0 1\\n2 2\\n4 1\\n\", \"2\\n0 1\\n1000000000 ... | The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset of vertices C of the maximum size such that any two of them are connected by an edge in graph G. Sounds simple, doesn't it? No... | 0.25 |
{"tests": "{\"inputs\": [\"10\\n630\\n624\\n85\\n955\\n757\\n841\\n967\\n377\\n932\\n309\\n\", \"10\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n\", \"10\\n392\\n605\\n903\\n154\\n293\\n383\\n422\\n717\\n719\\n896\\n\", \"10\\n447\\n806\\n891\\n730\\n371\\n351\\n7\\n102\\n394\\n549\\n\", \"10\\n317\\n36\\n191\\n843\\n289\... | Yaroslav likes algorithms. We'll describe one of his favorite algorithms.
1. The algorithm receives a string as the input. We denote this input string as a.
2. The algorithm consists of some number of command. Сommand number i looks either as si >> wi, or as si <> wi, where si and wi are some possibly empty strin... | 0 |
{"tests": "{\"inputs\": [\"9\\nbrie soft\\ncamembert soft\\nfeta soft\\ngoat soft\\nmuenster soft\\nasiago hard\\ncheddar hard\\ngouda hard\\nswiss hard\\n\", \"6\\nparmesan hard\\nemmental hard\\nedam hard\\ncolby hard\\ngruyere hard\\nasiago hard\\n\", \"9\\ngorgonzola soft\\ncambozola soft\\nmascarpone soft\\nricott... | Not to be confused with chessboard.
[Image]
-----Input-----
The first line of input contains a single integer N (1 ≤ N ≤ 100) — the number of cheeses you have.
The next N lines describe the cheeses you have. Each line contains two space-separated strings: the name of the cheese and its type. The name is a string... | 0 |
{"tests": "{\"inputs\": [\"5 5 5\\nRRGGB\\nRRGGY\\nYYBBG\\nYYBBR\\nRBBRG\\n1 1 5 5\\n2 2 5 5\\n2 2 3 3\\n1 1 3 5\\n4 4 5 5\\n\", \"6 10 5\\nRRRGGGRRGG\\nRRRGGGRRGG\\nRRRGGGYYBB\\nYYYBBBYYBB\\nYYYBBBRGRG\\nYYYBBBYBYB\\n1 1 6 10\\n1 3 3 10\\n2 2 6 6\\n1 7 6 10\\n2 1 5 10\\n\", \"8 8 8\\nRRRRGGGG\\nRRRRGGGG\\nRRRRGGGG\\nR... | Warawreh created a great company called Nanosoft. The only thing that Warawreh still has to do is to place a large picture containing its logo on top of the company's building.
The logo of Nanosoft can be described as four squares of the same size merged together into one large square. The top left square is colored w... | 0 |
{"tests": "{\"inputs\": [\"14 2\\n1 4\\n2 4\\n3 4\\n4 13\\n10 5\\n11 5\\n12 5\\n14 5\\n5 13\\n6 7\\n8 6\\n13 6\\n9 6\\n\", \"3 1\\n1 3\\n2 3\\n\", \"16 2\\n1 12\\n2 12\\n3 12\\n4 13\\n5 13\\n6 13\\n7 14\\n8 14\\n9 15\\n10 15\\n11 15\\n12 16\\n13 16\\n14 16\\n15 16\\n\", \"13 2\\n7 5\\n10 11\\n5 12\\n1 2\\n10 7\\n2 6\\n... | Someone give a strange birthday present to Ivan. It is hedgehog — connected undirected graph in which one vertex has degree at least $3$ (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself $k$-multihedgehog.
Let us define $k$-multihedgehog ... | 0 |
{"tests": "{\"inputs\": [\"4\\n2 2 1\\n2 2 3\\n2 2 2\\n2 2 4\\n\", \"4\\n2 2 1\\n2 2 1\\n2 2 2\\n2 2 4\\n\", \"4\\n2 2 2\\n2 2 1\\n2 2 2\\n2 2 4\\n\", \"4\\n2 2 4\\n2 2 1\\n2 2 2\\n2 2 4\\n\", \"4\\n2 1 1\\n2 2 3\\n2 2 2\\n2 2 4\\n\", \"4\\n2 1 1\\n2 2 3\\n2 2 2\\n4 2 4\\n\", \"4\\n2 2 2\\n2 2 1\\n4 2 2\\n2 2 2\\n\", \... | You have a rectangular chocolate bar consisting of n × m single squares. You want to eat exactly k squares, so you may need to break the chocolate bar.
In one move you can break any single rectangular piece of chocolate in two rectangular pieces. You can break only by lines between squares: horizontally or vertically... | 0.125 |
{"tests": "{\"inputs\": [\"15\\n2 6 6 6 3 3 3 15 5 5 5 7 5 5 5\\n\", \"3\\n30 14 21\\n\", \"12\\n10 10 14 14 14 14 14 14 14 14 21 21\\n\", \"2\\n1 1\\n\", \"2\\n1000000000 1000000000\\n\", \"5\\n2 1 1 1 2\\n\", \"6\\n6 15 10 6 15 10\\n\", \"4\\n2 1 1 1\\n\", \"4\\n1 1 1 1\\n\", \"3\\n15 6 10\\n\", \"3\\n42 15 35\\n\", ... | You have an array a with length n, you can perform operations. Each operation is like this: choose two adjacent elements from a, say x and y, and replace one of them with gcd(x, y), where gcd denotes the [greatest common divisor](https://en.wikipedia.org/wiki/Greatest_common_divisor).
What is the minimum number of ope... | 0 |
{"tests": "{\"inputs\": [\"5 3 2\\n\", \"5 4 2\\n\", \"300 300 3\\n\", \"300 282 7\\n\", \"1000000000 1000000000 1000000000\\n\", \"1000000000 800000000 2\\n\", \"2 0 2\\n\", \"2 1 2\\n\", \"2 2 2\\n\", \"3 2 2\\n\", \"3 3 2\\n\", \"10 7 3\\n\", \"10 8 3\\n\", \"10 8 5\\n\", \"10 9 5\\n\", \"972 100 2\\n\", \"972 600 2... | Manao is taking part in a quiz. The quiz consists of n consecutive questions. A correct answer gives one point to the player. The game also has a counter of consecutive correct answers. When the player answers a question correctly, the number on this counter increases by 1. If the player answers a question incorrectly,... | 0 |
{"tests": "{\"inputs\": [\"5 5\\n1 1\\n4 5\\n2 3\\n2 4\\n1 4\", \"100000 1\\n0 99999\", \"4 3\\n1 3\\n2 3\\n3 4\", \"5 5\\n1 1\\n4 5\\n1 3\\n2 4\\n1 4\", \"100100 1\\n0 99999\", \"4 3\\n1 3\\n3 3\\n3 4\", \"5 5\\n2 3\\n4 5\\n2 3\\n2 4\\n1 4\", \"100000 1\\n1 69651\", \"4 3\\n1 1\\n2 3\\n3 4\", \"5 5\\n1 1\\n4 5\\n2 3\\... | In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N.
There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i.
Cat Snuk... | 0.125 |
{"tests": "{\"inputs\": [\"abc\\ncbaabc\\n\", \"aaabrytaaa\\nayrat\\n\", \"ami\\nno\\n\", \"r\\nr\\n\", \"r\\nb\\n\", \"randb\\nbandr\\n\", \"aaaaaa\\naaaaa\\n\", \"aaaaaa\\naaaaaaa\\n\", \"qwerty\\nywertyrewqqq\\n\", \"qwerty\\nytrewq\\n\", \"azaza\\nzazaz\\n\", \"mnbvcxzlkjhgfdsapoiuytrewq\\nqwertyuiopasdfghjklzxcvbn... | A boy named Ayrat lives on planet AMI-1511. Each inhabitant of this planet has a talent. Specifically, Ayrat loves running, moreover, just running is not enough for him. He is dreaming of making running a real art.
First, he wants to construct the running track with coating t. On planet AMI-1511 the coating of the tra... | 0 |
{"tests": "{\"inputs\": [\"1000000000000000\\n\", \"994\\n\", \"200385\\n\", \"3842529393411\\n\", \"8\\n\", \"409477218238717\\n\", \"2\\n\", \"419477218238718\\n\", \"909383000\\n\", \"7\\n\", \"999088000000000\\n\", \"265\\n\", \"415000000238718\\n\", \"780869426483087\\n\", \"9\\n\", \"850085504652042\\n\", \"56700... | Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many blocks of each side length.
A block with side a has volume a3. A tower consisting of blocks with sides a1, a2, ..., ak has the total volume a13 + a23 + ... + ak3.... | 0 |
{"tests": "{\"inputs\": [\"200 100\\ncxqtpwtozcnavklpcksprgecocdraaryxzztqkcfzsrhdrzabtwdukzmsgpnvvgigbtyaxubrngiomfatojjvnvhogqqlujsrglodzwmpyjijtzdzcczlxvhmkkefuereazzwfqbndaccpvlupgixdezadhvwdfzxqzmnkcgwktubylaiezruthgdzqqdrsrorvganxf\\nwt\\n\", \"200 20\\nbcbabacbaaaccbbaaabcabccaacaccccbbcbcacaacbaaababcbcaccbbbbc... | You are given two strings s and t consisting of lowercase Latin letters. The length of t is 2 (i.e. this string consists only of two characters).
In one move, you can choose any character of s and replace it with any lowercase Latin letter. More formally, you choose some i and replace s_i (the character at the positio... | 0 |
{"tests": "{\"inputs\": [\"5856 500 2000\", \"4000 2000 312\", \"1000000000000000000 2 0\", \"1100000000000000000 2 0\", \"5856 883 583\", \"1100000000000000000 4 0\", \"6439 2000 572\", \"1100000000100000000 4 0\", \"6439 987 572\", \"1101000000100000000 4 0\", \"6439 1177 572\", \"1101000010100000000 4 0\", \"6439 22... | ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Ka... | 0.125 |
{"tests": "{\"inputs\": [\"5\\n7\\n1 2\\n1 3\\n1 4\\n2 5\\n2 6\\n4 7\\n6\\n1 2\\n1 3\\n2 4\\n2 5\\n3 6\\n2\\n1 2\\n7\\n7 3\\n1 5\\n1 3\\n4 6\\n4 7\\n2 1\\n6\\n2 1\\n2 3\\n4 5\\n3 4\\n3 6\\n\", \"5\\n7\\n1 2\\n1 3\\n1 4\\n2 5\\n2 6\\n4 7\\n6\\n1 2\\n1 3\\n2 4\\n2 5\\n3 6\\n2\\n1 2\\n7\\n6 3\\n1 5\\n1 3\\n4 6\\n4 7\\n2 1... | A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex $v$ (different from root) is the previous to $v$ vertex on the shortest path from the root to the vertex $v$. Children of the vertex $v$ are all vertices for which $v$ is the parent.
A vertex is a lea... | 0 |
{"tests": "{\"inputs\": [[[\"hello\", \"world\"]], [[\"Quick\", \"brown\", \"fox\", \"jumped\", \"over\", \"the\", \"lazy\", \"dog\"]], [[\"hello\", \",\", \"my\", \"dear\"]], [[\"one\", \",\", \"two\", \",\", \"three\"]], [[\"One\", \",\", \"two\", \"two\", \",\", \"three\", \"three\", \"three\", \",\", \"4\", \"4\", ... | Implement a function, so it will produce a sentence out of the given parts.
Array of parts could contain:
- words;
- commas in the middle;
- multiple periods at the end.
Sentence making rules:
- there must always be a space between words;
- there must not be a space between a comma and word on the left;
- there must ... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 2 3 4\\n2\\n2 3\\n2 2\\n\", \"4\\n1 2 3 4\\n2\\n2 1000\\n2 1\\n\", \"1\\n1\\n3\\n2 4\\n1 1 2\\n2 10\\n\", \"5\\n1 2 3 4 5\\n10\\n1 1 0\\n2 1\\n1 2 0\\n2 2\\n1 3 0\\n2 3\\n1 4 0\\n2 4\\n1 5 0\\n2 5\\n\", \"10\\n1 2 3 4 5 6 7 8 9 10\\n10\\n2 1\\n2 2\\n2 3\\n2 4\\n2 5\\n2 6\\n2 7\\n2 8\\n2... | There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have.
Sometimes the governm... | 0.875 |
{"tests": "{\"inputs\": [[\"Nothing Else Matters.mp3\"], [\"NothingElseMatters.mp3\"], [\"DaftPunk.FLAC\"], [\"DaftPunk.flac\"], [\"AmonTobin.aac\"], [\" Amon Tobin.alac\"], [\"tobin.alac\"]], \"outputs\": [[false], [true], [false], [true], [true], [false], [true]]}", "source": "taco"} | *Are you a file extension master? Let's find out by checking if Bill's files are images or audio files. Please use regex if available natively for your language.*
You will create 2 string methods:
- **isAudio/is_audio**, matching 1 or + uppercase/lowercase letter(s) (combination possible), with the extension .mp3, .f... | 0 |
{"tests": "{\"inputs\": [\"28 5 4 26\\n\", \"4 3 3 4\\n\", \"14 8 2 12\\n\", \"7 3 2 6\\n\", \"79 8 41 64\\n\", \"63 11 23 48\\n\", \"51474721 867363452 12231088 43489285\\n\", \"7 3 1 3\\n\", \"8 3 6 6\\n\", \"9 2 4 7\\n\", \"7 3 5 7\\n\", \"149 49 92 129\\n\", \"192293793 2864 5278163 190776899\\n\", \"7 3 1 7\\n\", ... | Throughout Igor K.'s life he has had many situations worthy of attention. We remember the story with the virus, the story of his mathematical career and of course, his famous programming achievements. However, one does not always adopt new hobbies, one can quit something as well.
This time Igor K. got disappointed in ... | 0 |
{"tests": "{\"inputs\": [\"2\\n)\\n(()\\n\", \"2\\n)(\\n()\\n\", \"4\\n((()))\\n((((((\\n))))))\\n()()()\\n\", \"3\\n(((\\n)\\n)\\n\", \"3\\n()(\\n)\\n)\", \"2\\n)\\n()(\", \"4\\n((()))\\n((((()\\n))))))\\n()()()\", \"2\\n)(\\n)(\", \"3\\n()(\\n)\\n(\", \"2\\n((\\n)(\", \"3\\n())\\n)\\n(\", \"2\\n((\\n()\", \"3\\n(((\\... | A bracket sequence is a string that is one of the following:
- An empty string;
- The concatenation of (, A, and ) in this order, for some bracket sequence A ;
- The concatenation of A and B in this order, for some non-empty bracket sequences A and B /
Given are N strings S_i. Can a bracket sequence be formed by con... | 0.125 |
{"tests": "{\"inputs\": [[2, 0, 0], [3, 1, 2], [0, 3, 2], [13, 0, 0], [6, 2, 4], [6, 1, 3], [5, 3, 4]], \"outputs\": [[13], [14.5], [19], [39.5], [26], [19], [29]]}", "source": "taco"} | The pizza store wants to know how long each order will take. They know:
- Prepping a pizza takes 3 mins
- Cook a pizza takes 10 mins
- Every salad takes 3 mins to make
- Every appetizer takes 5 mins to make
- There are 2 pizza ovens
- 5 pizzas can fit in a oven
- Prepping for a pizza must be done before it can be put ... | 0 |
{"tests": "{\"inputs\": [\"BBBSSC\\n6 4 1\\n1 2 3\\n4\\n\", \"BBC\\n1 10 1\\n1 10 1\\n21\\n\", \"BSC\\n1 1 1\\n1 1 3\\n1000000000000\\n\", \"B\\n1 1 1\\n1 1 1\\n381\\n\", \"BSC\\n3 5 6\\n7 3 9\\n100\\n\", \"BSC\\n100 1 1\\n100 1 1\\n100\\n\", \"SBBCCSBB\\n1 50 100\\n31 59 21\\n100000\\n\", \"BBBBCCCCCCCCCCCCCCCCCCCCSSS... | Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (... | 0.25 |
{"tests": "{\"inputs\": [[\"4x+1\"], [\"-4x-1\"], [\"x^2+2x+1\"], [\"0\"], [\"-100\"], [\"-x^2+3x+4\"], [\"-x^5-x^4-x^3\"], [\"10x^9+10x^3+10x\"], [\"100x^5+12x^3-3x-3\"], [\"-1000x^7+200x^4+6x^2+x+1000\"]], \"outputs\": [[\"4\"], [\"-4\"], [\"2x+2\"], [\"0\"], [\"0\"], [\"-2x+3\"], [\"-5x^4-4x^3-3x^2\"], [\"90x^8+30x^... | Complete the function that calculates the derivative of a polynomial. A polynomial is an expression like: 3x^(4) - 2x^(2) + x - 10
### How to calculate the derivative:
* Take the exponent and multiply it with the coefficient
* Reduce the exponent by 1
For example: 3x^(4) --> (4*3)x^((4-1)) = 12x^(3)
### Good to kno... | 0 |
{"tests": "{\"inputs\": [\"13\\n8380011223344\\n\", \"15\\n807345619350641\\n\", \"19\\n8181818181111111111\\n\", \"29\\n88811188118181818118111111111\\n\", \"15\\n980848088815548\\n\", \"13\\n9999999998888\\n\", \"13\\n0000008888888\\n\", \"13\\n2480011223348\\n\", \"17\\n87879887989788999\\n\", \"21\\n123456788888812... | A telephone number is a sequence of exactly $11$ digits such that its first digit is 8.
Vasya and Petya are playing a game. Initially they have a string $s$ of length $n$ ($n$ is odd) consisting of digits. Vasya makes the first move, then players alternate turns. In one move the player must choose a character and eras... | 0.125 |
{"tests": "{\"inputs\": [\"110011\", \"11101111011111000000000110000001111100011111000000001101111110000000111111111\", \"0000\", \"110010\", \"11101111011101000000000110000001111100011111000000001101111110000000111111111\", \"0010\", \"110000\", \"11101111011100000000000110000001111100011111000000001101111110000000111... | Given is a string S consisting of `0` and `1`. Find the number of strings, modulo 998244353, that can result from applying the following operation on S zero or more times:
* Remove the two characters at the beginning of S, erase one of them, and reinsert the other somewhere in S. This operation can be applied only whe... | 0 |
{"tests": "{\"inputs\": [[1500, 5, 100, 5000], [1500000, 2.5, 10000, 2000000], [1500000, 0.25, 1000, 2000000], [1500000, 0.25, -1000, 2000000], [1500000, 0.25, 1, 2000000], [1500000, 0.0, 10000, 2000000]], \"outputs\": [[15], [10], [94], [151], [116], [50]]}", "source": "taco"} | In a small town the population is `p0 = 1000` at the beginning of a year. The population
regularly increases by `2 percent` per year and moreover `50` new inhabitants per year
come to live in the town.
How many years does the town need to see its population
greater or equal to `p = 1200` inhabitants?
```
At the end o... | 0.75 |
{"tests": "{\"inputs\": [\"2 4 6 8 10\\n\", \"50 27 17 31 89\\n\", \"50 87 29 81 21\\n\", \"74 21 36 68 80\\n\", \"75 82 48 95 12\\n\", \"41 85 14 43 23\\n\", \"94 28 3 29 9\\n\", \"94 21 36 89 20\\n\", \"60 92 82 71 53\\n\", \"46 68 3 0 51\\n\", \"12 39 3 50 84\\n\", \"12 31 47 31 84\\n\", \"79 2 93 92 16\\n\", \"65 4... | Salve, mi amice.
Et tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.
Rp:
I Aqua Fortis
I Aqua Regia
II Amalgama
VII Minium
IV Vitriol
Misce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci... | 0 |
{"tests": "{\"inputs\": [\"2\\n0\\n\", \"4\\n1010\\n\", \"20\\n10101010101010\\n\", \"2\\n11\\n\", \"5\\n00101\\n\", \"10\\n100101\\n\", \"4\\n0011\\n\", \"7\\n1100\\n\", \"8\\n01010001\\n\", \"6\\n10\\n\", \"17\\n011100101100110\\n\", \"22\\n1110011010100111\\n\", \"17\\n1110110111010101\\n\", \"11\\n10100000100\\n\",... | You are given a binary string $s$.
Find the number of distinct cyclical binary strings of length $n$ which contain $s$ as a substring.
The cyclical string $t$ contains $s$ as a substring if there is some cyclical shift of string $t$, such that $s$ is a substring of this cyclical shift of $t$.
For example, the cyclic... | 0 |
{"tests": "{\"inputs\": [\"6 1\\n10\\n6 4 3 3 1 2 0 5 4 6 1 8 5 9 7 7 8 6 8 3\\n6 1\\n10\\n6 4 3 3 1 2 0 5 4 6 1 8 5 7 7 7 8 6 9 0\\n0 0\", \"6 1\\n10\\n6 4 3 3 1 2 0 5 4 6 1 8 5 9 7 7 8 6 3 3\\n6 1\\n10\\n6 4 3 3 1 2 0 5 4 6 1 8 5 7 7 7 8 6 9 0\\n0 0\", \"6 1\\n10\\n6 4 3 3 1 2 0 5 4 6 1 8 5 9 7 7 8 6 3 3\\n6 1\\n10\\... | The University of Aizu has a park covered with grass, and there are no trees or buildings that block the sunlight. On sunny summer days, sprinklers installed in the park operate to sprinkle water on the lawn. The frog Pyonkichi lives in this park. Pyonkichi is not good at hot weather, and on summer days when the sun is... | 0 |
{"tests": "{\"inputs\": [[0], [1], [62], [120], [3600], [3662], [15731080], [132030240], [205851834], [253374061], [242062374], [101956166], [33243586]], \"outputs\": [[\"now\"], [\"1 second\"], [\"1 minute and 2 seconds\"], [\"2 minutes\"], [\"1 hour\"], [\"1 hour, 1 minute and 2 seconds\"], [\"182 days, 1 hour, 44 mi... | Your task in order to complete this Kata is to write a function which formats a duration, given as a number of seconds, in a human-friendly way.
The function must accept a non-negative integer. If it is zero, it just returns `"now"`. Otherwise, the duration is expressed as a combination of `years`, `days`, `hours`, `... | 0 |
{"tests": "{\"inputs\": [[5], [1], [[]], [11], [\"treasure\"], [\"5\"], [-1], [3], [2], [0.5]], \"outputs\": [[\"X X\\n X X\\n X\\n X X\\nX X\\n\"], [\"X\\n\"], [\"?\"], [\"X X\\n X X\\n X X\\n X X\\n X X\\n X\\n X ... | You've made it through the moat and up the steps of knowledge. You've won the temples games and now you're hunting for treasure in the final temple run. There's good news and bad news. You've found the treasure but you've triggered a nasty trap. You'll surely perish in the temple chamber.
With your last movements, you... | 0 |
{"tests": "{\"inputs\": [\"10 3 5\\n10 3 3\\n30\\n1\\n6\\n10\", \"10 3 1\\n10 3 3\\n30\\n1\\n6\\n10\", \"10 3 5\\n10 3 3\\n32\\n1\\n6\\n10\", \"10 3 1\\n10 3 3\\n30\\n1\\n8\\n10\", \"10 3 1\\n10 3 0\\n51\\n0\\n6\\n10\", \"10 3 5\\n10 3 6\\n32\\n2\\n6\\n10\", \"10 3 10\\n10 3 6\\n8\\n2\\n6\\n10\", \"10 3 10\\n10 3 3\\n8... | The JOI Railways is the only railway company in the Kingdom of JOI. There are $N$ stations numbered from $1$ to $N$ along a railway. Currently, two kinds of trains are operated; one is express and the other one is local.
A local train stops at every station. For each $i$ ($1 \leq i < N$), by a local train, it takes $A... | 0 |
{"tests": "{\"inputs\": [\"2 1\\n\", \"17 2\\n\", \"2000 1000\\n\", \"12 4\\n\", \"1058 839\\n\", \"36 36\\n\", \"177 115\\n\", \"1 1\\n\", \"4 1\\n\", \"18 7\\n\", \"44 24\\n\", \"1899 1672\\n\", \"11 5\\n\", \"13 13\\n\", \"1862 1782\\n\", \"151 51\\n\", \"1981 668\\n\", \"536 485\\n\", \"1999 686\\n\", \"2000 546\\n... | Snuke has decided to play with N cards and a deque (that is, a double-ended queue).
Each card shows an integer from 1 through N, and the deque is initially empty.
Snuke will insert the cards at the beginning or the end of the deque one at a time, in order from 1 to N.
Then, he will perform the following action N times:... | 0 |
{"tests": "{\"inputs\": [\"73\\n\", \"444000000\\n\", \"447777\\n\", \"3696\\n\", \"12\\n\", \"100\\n\", \"1024\\n\", \"123\\n\", \"74777443\\n\", \"1007\\n\", \"4\\n\", \"7748\\n\", \"474\\n\", \"74710000\\n\", \"19\\n\", \"70070077\\n\", \"888999577\\n\", \"2145226\\n\", \"7474747\\n\", \"10\\n\", \"47474774\\n\", \"... | Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | 0 |
{"tests": "{\"inputs\": [\"5 3\\n0 1 2 2 0\\n1 2 2 3 2\\n5\\n3\\n2\\n4\\n5\\n1\\n\", \"5 3\\n0 1 2 2 1\\n1 3 2 3 2\\n5\\n4\\n2\\n3\\n5\\n1\\n\", \"5 5\\n0 1 2 4 5\\n1 2 3 4 5\\n4\\n2\\n3\\n5\\n4\\n\", \"10 10\\n8 5 1 3 9 2 7 0 6 4\\n6 4 8 2 7 9 5 1 10 3\\n10\\n9\\n2\\n1\\n7\\n5\\n6\\n8\\n3\\n10\\n4\\n\", \"10 10\\n2 0 ... | There are $n$ students and $m$ clubs in a college. The clubs are numbered from $1$ to $m$. Each student has a potential $p_i$ and is a member of the club with index $c_i$. Initially, each student is a member of exactly one club. A technical fest starts in the college, and it will run for the next $d$ days. There is a c... | 0 |
{"tests": "{\"inputs\": [[\"glorytoukraine\", \"ukraineaineaine\"], [\"glorytoukraine\", \"ukraineaineainee\"], [\"glorytoukraine\", \"einene\"], [\"programming\", \"ingmingmming\"], [\"mcoecqwmjdudc\", \"dcoecqwmjdudcdcudc\"], [\"erjernhxvbqfjsj\", \"ernhxvbqfjsjjrnhxvbqfjsjjernhxvbqfjsj\"], [\"dhgusdlifons\", \"lifon... | # Task
You know the slogan `p`, which the agitators have been chanting for quite a while now. Roka has heard this slogan a few times, but he missed almost all of them and grasped only their endings. You know the string `r` that Roka has heard.
You need to determine what is the `minimal number` of times agitators r... | 0.375 |
{"tests": "{\"inputs\": [\"8\\nabababacababa\\naba\\nddddddd\\ndddd\\nxyzxyz\\nxyz\\nabc\\nabcd\\nabacaba\\nabaca\\nabc\\ndef\\naaaaaaaa\\na\\naaaaaaaa\\naa\\n\", \"1\\nabababacabababababababacababababacacababababababababacababababababacabacabababababababacabababababababababacabababacabababababababacababababababacabaca... | You are given two non-empty strings $s$ and $t$, consisting of Latin letters.
In one move, you can choose an occurrence of the string $t$ in the string $s$ and replace it with dots.
Your task is to remove all occurrences of the string $t$ in the string $s$ in the minimum number of moves, and also calculate how many d... | 0 |
{"tests": "{\"inputs\": [\"-744\\n672*a++-975*a++-394*a+++968*a+++222*a+++988*++a+504*++a-782*a++-321*++a+980*++a-483*a++-554*++a-347*++a-180*++a-390*a+++403*a++-617*a+++378*a+++544*++a-978*a+++952*a++-618*a++-516*++a-990*++a+540*++a-398*++a-187*++a+401*++a+829*a++-187*++a-185*a++-529*a++\\n\", \"1000\\n++a\\n\", \"7\\... | C*++ language is quite similar to C++. The similarity manifests itself in the fact that the programs written in C*++ sometimes behave unpredictably and lead to absolutely unexpected effects. For example, let's imagine an arithmetic expression in C*++ that looks like this (expression is the main term):
* expression :... | 0 |
{"tests": "{\"inputs\": [\"5 2\\n5 2 3\\n3 1 4 5 2\\n3 5\\n\", \"4 4\\n5 1 4\\n4 3 1 2\\n2 4 3 1\\n\", \"4 4\\n2 1 11\\n1 3 2 4\\n1 3 2 4\\n\", \"23 5\\n10 3 3\\n2 1 4 11 8 10 5 6 7 9 12 3 14 13 16 18 21 15 17 19 20 23 22\\n4 6 3 18 23\\n\", \"23 5\\n10 3 4\\n2 1 4 11 8 10 5 6 7 9 12 3 14 13 16 18 21 15 17 19 20 23 22\... | There are $n$ warriors in a row. The power of the $i$-th warrior is $a_i$. All powers are pairwise distinct.
You have two types of spells which you may cast: Fireball: you spend $x$ mana and destroy exactly $k$ consecutive warriors; Berserk: you spend $y$ mana, choose two consecutive warriors, and the warrior with ... | 0 |
{"tests": "{\"inputs\": [[2, 0.5], [4, 0.5], [10, 0.1], [100, 0.1], [9, 0.3], [30, 0.3]], \"outputs\": [[1], [2], [1], [2], [2], [3]]}", "source": "taco"} | You drop a ball from a given height. After each bounce, the ball returns to some fixed proportion of its previous height. If the ball bounces to height 1 or less, we consider it to have stopped bouncing. Return the number of bounces it takes for the ball to stop moving.
```
bouncingBall(initialHeight, bouncingProporti... | 0.875 |
{"tests": "{\"inputs\": [\"3\\n2 1 4\\n\", \"4\\n3 1 4 4\\n\", \"4\\n3 1 4 1\\n\", \"5\\n3 1 4 1 5\\n\", \"11\\n5000 5000 5000 5000 5000 5000 0 1 0 1 0\\n\", \"1\\n0\\n\", \"1\\n1\\n\", \"4\\n0 1 1 0\\n\", \"17\\n1 9 2 8 4 5 7 3 8 4 6 2 8 4 1 0 5\\n\", \"4\\n57 918 827 953\\n\", \"51\\n17 26 14 0 41 18 40 14 29 25 5 23... | Æsir - CHAOS Æsir - V.
"Everything has been planned out. No more hidden concerns. The condition of Cytus is also perfect.
The time right now...... 00:01:12......
It's time."
The emotion samples are now sufficient. After almost 3 years, it's time for Ivy to awake her bonded sister, Vanessa.
The system inside A.R.C.... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 2 3 1 5\", \"4\\n2 0 4 6\", \"5\\n1 2 3 0 5\", \"4\\n1 0 4 6\", \"5\\n1 2 4 0 5\", \"4\\n1 0 2 6\", \"5\\n1 2 6 0 5\", \"4\\n1 0 2 2\", \"5\\n1 4 6 0 5\", \"4\\n2 0 2 2\", \"4\\n2 0 3 2\", \"4\\n2 0 6 2\", \"5\\n1 4 3 4 5\", \"4\\n2 3 4 1\", \"5\\n2 2 3 1 5\", \"4\\n2 0 3 6\", \"5\\n1 7... | There are N integers written on a blackboard. The i-th integer is A_i.
Takahashi and Aoki will arrange these integers in a row, as follows:
* First, Takahashi will arrange the integers as he wishes.
* Then, Aoki will repeatedly swap two adjacent integers that are coprime, as many times as he wishes.
We will assume... | 0 |
{"tests": "{\"inputs\": [[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 1], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 2], [[\"C\", \"o\", \"d\", \"e\", \"W\", \"a\", \"r\", \"s\"], 4], [[\"C\", 0, \"d\", 3, \"W\", 4, \"r\", 5], 4], [[1, 2, 3, 4, 5, 6, 7], 3], [[], 3], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,... | This problem takes its name by arguably the most important event in the life of the ancient historian Josephus: according to his tale, he and his 40 soldiers were trapped in a cave by the Romans during a siege.
Refusing to surrender to the enemy, they instead opted for mass suicide, with a twist: **they formed a circl... | 0 |
{"tests": "{\"inputs\": [\"6\\n2 1 4\\n1 2 4\\n3 4 4\\n2 8 3\\n3 16 3\\n1 32 2\\n\", \"7\\n1 100000 1\\n1 100000 2\\n1 100000 2\\n4 50000 3\\n3 50000 4\\n4 50000 4\\n3 50000 3\\n\", \"4\\n1 1000 1\\n2 500 2\\n3 250 3\\n4 125 4\\n\", \"2\\n3 96 2\\n4 8 4\\n\", \"5\\n3 21 3\\n1 73 2\\n1 55 1\\n4 30 1\\n4 59 2\\n\", \"6\\... | You are given $n$ blocks, each of them is of the form [color$_1$|value|color$_2$], where the block can also be flipped to get [color$_2$|value|color$_1$].
A sequence of blocks is called valid if the touching endpoints of neighboring blocks have the same color. For example, the sequence of three blocks A, B and C is v... | 0 |
{"tests": "{\"inputs\": [\"4\\n4\\nabcd\\nabdc\\n5\\nababa\\nbaaba\\n4\\nasdf\\nasdg\\n4\\nabcd\\nbadc\\n\", \"4\\n4\\nabcd\\nabdc\\n5\\nababa\\nbaaba\\n4\\nasdf\\nasdg\\n4\\nabdd\\nbadc\\n\", \"4\\n4\\nabcd\\nabdc\\n5\\nababa\\nabaab\\n4\\nasdf\\nasdg\\n4\\nabcd\\nbadc\\n\", \"4\\n4\\nabcd\\nabdc\\n5\\naaabc\\nbabaa\\... | You are given two strings $s$ and $t$ both of length $n$ and both consisting of lowercase Latin letters.
In one move, you can choose any length $len$ from $1$ to $n$ and perform the following operation: Choose any contiguous substring of the string $s$ of length $len$ and reverse it; at the same time choose any con... | 0 |
{"tests": "{\"inputs\": [[[16, 22, 31, 44, 3, 38, 27, 41, 88]], [[5, 8, 72, 98, 41, 16, 55]], [[57, 99, 14, 32]], [[62, 0, 3, 77, 88, 102, 26, 44, 55]], [[2, 44, 34, 67, 88, 76, 31, 67]], [[46, 86, 33, 29, 87, 47, 28, 12, 1, 4, 78, 92]], [[66, 73, 88, 24, 36, 65, 5]], [[12, 76, 49, 37, 29, 17, 3, 65, 84, 38]], [[0, 110... | At the annual family gathering, the family likes to find the oldest living family member’s age and the youngest family member’s age and calculate the difference between them.
You will be given an array of all the family members' ages, in any order. The ages will be given in whole numbers, so a baby of 5 months, will ... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.