info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [\"5\\n3\\n1 2 2\\n4\\n5 5 5 5\\n3\\n1 2 4\\n4\\n1 3 4 4\\n1\\n100\\n\", \"2\\n3\\n1 2 2\\n4\\n5 5 5 5\\n\", \"2\\n3\\n1 2 3\\n4\\n1 2 3 4\\n\", \"2\\n3\\n1 2 3\\n4\\n1 2 3 4\\n\", \"2\\n3\\n1 2 2\\n4\\n5 5 5 5\\n\", \"5\\n2\\n2 3\\n4\\n2 2 8 8\\n3\\n3 3 3\\n4\\n5 5 5 5\\n4\\n1 1 1 1\\n\", \"1\\... | You are given the array $a$ consisting of $n$ positive (greater than zero) integers.
In one move, you can choose two indices $i$ and $j$ ($i \ne j$) such that the absolute difference between $a_i$ and $a_j$ is no more than one ($|a_i - a_j| \le 1$) and remove the smallest of these two elements. If two elements are equ... | 0 |
{"tests": "{\"inputs\": [\"4 2\\n1 2 2 3\\n\", \"5 2\\n3 2 1 2 3\\n\", \"5 2\\n2 1 1 2 1\\n\", \"5 4\\n1 1 1 2 2\\n\", \"11 9\\n1 1 2 2 2 2 2 2 3 4 5\\n\", \"4 4\\n1 2 2 3\\n\", \"5 5\\n1 1 2 1 1\\n\", \"4 4\\n1 1 2 2\\n\", \"5 4\\n1 2 1 2 3\\n\", \"5 5\\n1 1 2 1 3\\n\", \"10 10\\n1 2 3 1 2 3 4 5 6 7\\n\", \"8 6\\n1 2 ... | You are given an array $a$ consisting of $n$ integer numbers.
You have to color this array in $k$ colors in such a way that: Each element of the array should be colored in some color; For each $i$ from $1$ to $k$ there should be at least one element colored in the $i$-th color in the array; For each $i$ from $1$ t... | 0 |
{"tests": "{\"inputs\": [\"3\\n2 3 7 9 5 4 8 6 1\", \"3\\n1 3 7 9 5 8 4 6 2\", \"3\\n1 6 7 9 5 4 8 3 2\", \"3\\n2 4 7 9 5 3 8 6 1\", \"3\\n1 3 7 9 4 8 5 6 2\", \"3\\n2 3 7 9 5 4 8 6 1\", \"4\\n6 7 1 4 13 16 10 9 5 11 12 14 15 2 3 8\", \"6\\n11 21 35 22 7 36 27 34 8 20 15 13 16 1 24 3 2 17 26 9 18 32 31 23 19 14 4 25 10... | Tonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\times N square. We denote with 1, 2,\dots, N the viewers in the first row (from left to right); with N+1, \dots, 2N the viewers in the second row (from left to rig... | 0 |
{"tests": "{\"inputs\": [[-133.69, -147.38], [4.06, 0.71], [2.38, -6.06], [-5.43, 117.95], [-73.905, -95.94], [55.53, -87.95], [-145.19, 86.53]], \"outputs\": [[\"X\"], [\"DB\"], [\"SB\"], [\"20\"], [\"7\"], [\"T2\"], [\"D9\"]]}", "source": "taco"} | Create your own mechanical dartboard that gives back your score based on the coordinates of your dart.
Task:
Use the scoring rules for a standard dartboard:
Finish method:
```python
def get_score(x,y):
```
The coordinates are `(x, y)` are always relative to the center of the board (0, 0). The unit is millimeters.... | 0 |
{"tests": "{\"inputs\": [\"4\\n36\\n44\\n**\\n32\\n46\\n**\\n66\\n41\\n**\\n64\\n34\\n\", \"3\\n14\\n54\\n**\\n45\\n41\\n**\\n12\\n22\\n\", \"7\\n21\\n33\\n**\\n33\\n12\\n**\\n32\\n31\\n**\\n21\\n33\\n**\\n33\\n12\\n**\\n32\\n31\\n**\\n13\\n23\\n\", \"3\\n63\\n63\\n**\\n66\\n33\\n**\\n36\\n36\\n\", \"4\\n56\\n61\\n**\\... | Cheaterius is a famous in all the Berland astrologist, magician and wizard, and he also is a liar and a cheater. One of his latest inventions is Cheaterius' amulets! They bring luck and wealth, but are rather expensive. Cheaterius makes them himself. The technology of their making is kept secret. But we know that throu... | 0 |
{"tests": "{\"inputs\": [\"3 9 45\\n3 100 50\\n5 50 308\\n0 0 0\", \"3 12 45\\n3 100 75\\n5 50 308\\n0 0 0\", \"3 12 45\\n3 100 69\\n5 50 308\\n0 0 0\", \"3 12 45\\n3 100 69\\n5 90 548\\n0 0 0\", \"3 12 45\\n3 100 50\\n5 50 331\\n0 0 0\", \"3 3 45\\n3 100 69\\n5 50 308\\n0 0 0\", \"3 12 60\\n3 100 69\\n5 90 308\\n0 0 0... | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one posi... | 0 |
{"tests": "{\"inputs\": [\"2 3\\n2 3 6\\n3 4 3\\n\", \"2 5\\n3 7 11\\n10 12 15\\n\", \"5 42\\n42 42 42\\n42 43 42\\n43 44 42\\n44 45 42\\n45 45 1\\n\", \"1 10\\n100 111 1\\n\", \"1 1000000000\\n1 1 1000000000\\n\", \"10 89\\n1 2 82\\n2 2 31\\n3 4 63\\n6 7 18\\n9 9 44\\n10 11 95\\n13 13 52\\n13 15 39\\n15 16 70\\n17 18 ... | Recently you've discovered a new shooter. They say it has realistic game mechanics.
Your character has a gun with magazine size equal to $k$ and should exterminate $n$ waves of monsters. The $i$-th wave consists of $a_i$ monsters and happens from the $l_i$-th moment of time up to the $r_i$-th moments of time. All $a_i... | 0 |
{"tests": "{\"inputs\": [\"4\\n7 1\\n1 5 2 3 1 5 4\\n1 3 6 7 2 5 4\\n1 1\\n1000000000\\n1000000000\\n5 10\\n10 7 5 15 8\\n20 199 192 219 1904\\n10 10\\n15 19 8 17 20 10 9 2 10 19\\n12 13 6 17 1 14 7 9 19 3\\n\", \"4\\n1 1000000000\\n1\\n123456\\n1 1000000000\\n21345\\n987654321\\n1 1000000000\\n1000000000\\n1000000000\... | There are $n$ points on a plane. The $i$-th point has coordinates $(x_i, y_i)$. You have two horizontal platforms, both of length $k$. Each platform can be placed anywhere on a plane but it should be placed horizontally (on the same $y$-coordinate) and have integer borders. If the left border of the platform is $(x, y)... | 0 |
{"tests": "{\"inputs\": [\"6 1 2 2\\n2 1 1 5 0 2\", \"10 4 8 5\\n7 2 3 4 1 6 5 4 6 5\", \"6 1 5 2\\n2 1 1 3 1 2\", \"6 1 2 2\\n2 1 1 5 0 0\", \"10 4 8 5\\n7 2 6 4 1 6 5 4 6 5\", \"6 1 2 4\\n2 1 1 5 0 0\", \"10 4 5 5\\n7 2 6 4 1 6 5 4 6 5\", \"6 1 5 1\\n3 1 1 3 0 2\", \"6 1 2 1\\n1 1 1 5 0 2\", \"10 1 1 5\\n7 2 3 4 1 6 ... | N problems are proposed for an upcoming contest. Problem i has an initial integer score of A_i points.
M judges are about to vote for problems they like. Each judge will choose exactly V problems, independently from the other judges, and increase the score of each chosen problem by 1.
After all M judges cast their vo... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 12\\n1 3\\n2 15\\n2 5\\n2 1\\n\", \"3\\n1 10\\n2 1\\n2 4\\n\", \"10\\n2 10\\n2 4\\n2 8\\n2 3\\n2 5\\n2 6\\n1 2\\n1 10\\n1 10\\n2 5\\n\", \"1\\n2 7\\n\", \"50\\n1 24\\n1 16\\n1 33\\n2 34\\n1 26\\n2 35\\n1 39\\n2 44\\n2 29\\n2 28\\n1 44\\n2 48\\n2 50\\n2 41\\n2 9\\n1 22\\n2 11\\n2 27\\n1 ... | Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is t_{i} and its pages' width is equal to w_{i}. The thickness of each book is either 1 or 2. All books have the same page heights. $1$
Shaass puts the boo... | 0.125 |
{"tests": "{\"inputs\": [\"4 2 3\", \"5 2 8\", \"6 3 3\", \"6 3 5\", \"1 2 5\", \"0 3 4\", \"2 -1 0\", \"5 2 16\", \"5 2 27\", \"10 4 5\", \"5 1 27\", \"10 4 7\", \"6 0 28\", \"2 4 11\", \"0 2 27\", \"1 3 8\", \"0 3 27\", \"7 1 28\", \"7 0 12\", \"6 -1 36\", \"1 4 38\", \"0 -1 15\", \"-1 1 10\", \"12 -1 59\", \"1 3 38\... | 2N players are running a competitive table tennis training on N tables numbered from 1 to N.
The training consists of rounds. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As a result, one of them wins and the other one loses.
The winner of the... | 0 |
{"tests": "{\"inputs\": [\"2 0\\n\", \"5 10\\n1 2\\n3 4\\n1 3\\n2 3\\n5 4\\n5 1\\n4 1\\n5 3\\n5 2\\n2 4\\n\", \"3 2\\n2 3\\n1 3\\n\", \"7 9\\n2 6\\n7 4\\n2 5\\n2 7\\n4 2\\n3 5\\n5 6\\n6 7\\n7 3\\n\", \"6 3\\n4 2\\n5 4\\n4 3\\n\", \"7 8\\n4 1\\n5 7\\n6 4\\n7 1\\n6 3\\n3 4\\n3 1\\n6 7\\n\", \"3 0\\n\", \"7 2\\n5 1\\n3 5\... | Anadi has a set of dominoes. Every domino has two parts, and each part contains some dots. For every a and b such that 1 ≤ a ≤ b ≤ 6, there is exactly one domino with a dots on one half and b dots on the other half. The set contains exactly 21 dominoes. Here is an exact illustration of his set:
<image>
Also, Anadi ha... | 0.125 |
{"tests": "{\"inputs\": [\"129\\n\", \"0\\n\", \"4\\n\", \"6\\n\", \"16\\n\", \"299593\\n\", \"398929\\n\", \"860076\\n\", \"262144\\n\", \"1000000\\n\", \"266305\\n\", \"456910\\n\", \"953086\\n\", \"23982\\n\", \"9852\\n\", \"569\\n\", \"11249\\n\", \"73\\n\", \"2122\\n\", \"6218\\n\", \"33345\\n\", \"42705\\n\", \"1... | ++++++++[>+>++>+++>++++>+++++>++++++>+++++++>++++++++>+++++++++>++++++++++>+
++++++++++>++++++++++++>+++++++++++++>++++++++++++++>+++++++++++++++>+++++++
+++++++++<<<<<<<<<<<<<<<<-]>>>>>>>>>>.<<<<<<<<<<>>>>>>>>>>>>>>++.--<<<<<<<<<
<<<<<>>>>>>>>>>>>>+.-<<<<<<<<<<<<<>>>>>>>>>>>>>>--.++<<<<<<<<<<<<<<>>>>>>>>>
>>>>>>----.+... | 0 |
{"tests": "{\"inputs\": [\"9\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n\", \"9\\n1\\n3\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n\", \"9\\n1\\n5\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n\", \"9\\n1\\n5\\n3\\n4\\n5\\n6\\n7\\n8\\n12\\n\", \"9\\n1\\n2\\n3\\n4\\n5\\n6\\n11\\n8\\n9\\n\", \"9\\n1\\n3\\n3\\n2\\n5\\n6\\n7\\n8\\n9\\n\", \"9\\n1\\n5\\n3\\... | Consider the infinite sequence $s$ of positive integers, created by repeating the following steps:
Find the lexicographically smallest triple of positive integers $(a, b, c)$ such that $a \oplus b \oplus c = 0$, where $\oplus$ denotes the bitwise XOR operation. $a$, $b$, $c$ are not in $s$. Here triple of intege... | 0 |
{"tests": "{\"inputs\": [[[1, 2, 3], 3], [[1, 2], 5], [[3, 5, 7], 2], [[1, 2, 3, 4, 5], 3], [[2, 7, 13, 17], 2], [[2, 5, 8], 3], [[2, 4, 6, 8], 6], [[5, 10, 15], 4], [[3, 6, 9, 12], 3]], \"outputs\": [[30], [30], [68], [210], [472], [630], [312940], [61220], [2670]]}", "source": "taco"} | You are provided with array of positive non-zero ints and int n representing n-th power (n >= 2).
For the given array, calculate the sum of each value to the n-th power. Then subtract the sum of the original array.
Example 1: Input: {1, 2, 3}, 3 --> (1 ^ 3 + 2 ^ 3 + 3 ^ 3 ) - (1 + 2 + 3) --> 36 - 6 --> Output: 30
Ex... | 0 |
{"tests": "{\"inputs\": [\"5\\n0 5 0 2 3\\n\", \"7\\n1 0 0 5 0 0 2\\n\", \"1\\n0\\n\", \"20\\n7 0 9 0 5 0 15 0 0 1 17 0 11 19 0 0 3 0 13 0\\n\", \"20\\n9 0 0 0 18 0 11 0 0 4 0 15 0 0 0 14 0 0 5 0\\n\", \"20\\n13 0 0 12 14 0 19 0 15 0 8 0 7 0 9 0 20 0 0 10\\n\", \"20\\n1 0 0 13 0 0 16 0 0 4 0 0 7 0 19 0 0 10 0 0\\n\", \... | Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | 0.125 |
{"tests": "{\"inputs\": [\"2 2\\n\", \"2 4\\n\", \"20 10\\n\", \"1000 1000\\n\", \"1 1000\\n\", \"1000 122\\n\", \"1 2\\n\", \"1 1\\n\", \"2 1\\n\", \"15 22\\n\", \"2 3\\n\", \"2 5\\n\", \"432 333\\n\", \"17 23\\n\", \"843 134\\n\", \"912 584\\n\", \"88 88\\n\", \"3 16\\n\", \"2 1\\n\", \"2 3\\n\", \"17 23\\n\", \"2 5\... | Bob is decorating his kitchen, more precisely, the floor. He has found a prime candidate for the tiles he will use. They come in a simple form factor — a square tile that is diagonally split into white and black part as depicted in the figure below. [Image]
The dimension of this tile is perfect for this kitchen, as h... | 0.875 |
{"tests": "{\"inputs\": [\"4\\n54\\n50\\n2\\n178\\n\", \"1\\n179\\n\", \"69\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\\n1\... | You are given an angle $\text{ang}$.
The Jury asks You to find such regular $n$-gon (regular polygon with $n$ vertices) that it has three vertices $a$, $b$ and $c$ (they can be non-consecutive) with $\angle{abc} = \text{ang}$ or report that there is no such $n$-gon. [Image]
If there are several answers, print the m... | 0.375 |
{"tests": "{\"inputs\": [\"5\\n1 0 2 2 3\\n2\\n1 2\", \"3\\n2 2 3\\n1\\n5\", \"5\\n1 0 4 2 3\\n2\\n1 1\", \"5\\n1 2 3 4 1\\n5\\n2 4 1\", \"5\\n1 2 3 4 5\\n3\\n1 4 1\", \"5\\n1 0 4 2 3\\n2\\n1 2\", \"3\\n1 2 3\\n1\\n4\", \"5\\n1 4 3 4 5\\n3\\n1 4 1\", \"3\\n1 2 4\\n1\\n4\", \"5\\n1 4 3 4 6\\n3\\n1 4 1\", \"5\\n1 0 4 2 3... | You are given a sequence of n integers S and a sequence of different q integers T. Write a program which outputs C, the number of integers in T which are also in the set S.
Notes
Constraints
* Elements in S is sorted in ascending order
* n ≤ 100000
* q ≤ 50000
* 0 ≤ an element in S ≤ 109
* 0 ≤ an element in T ≤ 109
... | 0 |
{"tests": "{\"inputs\": [[[]], [[[0, 0], [0, 0]]], [[[0, 0], [0, 0], [0, 1], [0, 0], [0, 0]]], [[[0, 0], [3, 7], [0, 5]]], [[[1, 3], [7, 6], [7, 2], [1, 3], [2, 3], [4, 5], [7, 6]]], [[[1, 2], [6, 1], [5, 2], [6, 3], [1, 4], [2, 5], [7, 6], [0, 1]]], [[[0, 0], [1, 0], [0, 2], [3, 0], [4, 0], [0, 5], [0, 6], [7, 0]]], [... | Help a fruit packer sort out the bad apples.
There are 7 varieties of apples, all packaged as pairs and stacked in a fruit box. Some of the apples are spoiled. The fruit packer will have to make sure the spoiled apples are either removed from the fruit box or replaced. Below is the breakdown:
Apple varieties are rep... | 0 |
{"tests": "{\"inputs\": [\"2 1\\n3 4\\n\", \"1 2\\n3\\n\", \"4 5\\n20 21 22 25\\n\", \"5 1\\n1 7 7 6 6\\n\", \"7 1\\n8 6 10 10 1 5 8\\n\", \"10 1\\n2 3 5 2 7 4 7 7 4 2\\n\", \"10 1\\n5 6 3 10 6 6 1 1 5 3\\n\", \"6 1\\n1 4 4 4 2 2\\n\", \"10 2\\n3 10 10 8 6 10 9 9 5 7\\n\", \"6 2\\n5 3 5 6 2 2\\n\", \"9 2\\n8 2 9 4 7 5 ... | Kevin and Nicky Sun have invented a new game called Lieges of Legendre. In this game, two players take turns modifying the game state with Kevin moving first. Initially, the game is set up so that there are n piles of cows, with the i-th pile containing a_{i} cows. During each player's turn, that player calls upon the ... | 0 |
{"tests": "{\"inputs\": [\"3 3\\naaa\\naaa\\naaa\\n\", \"3 4\\nabab\\nbaba\\nabab\\n\", \"5 5\\nzbacg\\nbaaac\\naaaaa\\neaaad\\nweadd\\n\", \"1 1\\nn\\n\", \"1 1\\nn\\n\", \"3 4\\nabab\\nabab\\nabab\\n\", \"5 5\\nzbacg\\nbaaac\\naaaaa\\ndaaae\\nweadd\\n\", \"1 1\\nm\\n\", \"3 3\\naba\\naaa\\naaa\\n\", \"5 5\\nzbacf\\nb... | Carousel Boutique is busy again! Rarity has decided to visit the pony ball and she surely needs a new dress, because going out in the same dress several times is a sign of bad manners. First of all, she needs a dress pattern, which she is going to cut out from the rectangular piece of the multicolored fabric.
The piec... | 0.5 |
{"tests": "{\"inputs\": [\"1\\n0\\n1\\n\", \"2\\n0 5\\n4 0\\n1 2\\n\", \"4\\n0 3 1 1\\n6 0 400 1\\n2 4 0 1\\n1 1 1 0\\n4 1 2 3\\n\", \"4\\n0 57148 51001 13357\\n71125 0 98369 67226\\n49388 90852 0 66291\\n39573 38165 97007 0\\n2 3 1 4\\n\", \"5\\n0 27799 15529 16434 44291\\n47134 0 90227 26873 52252\\n41605 21269 0 913... | Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game: The game consists of n steps. On the i-th step Greg removes vertex number x_{i} from the graph. As... | 0.875 |
{"tests": "{\"inputs\": [\"2 3 2\\n**.\\n...\\n\", \"1 2 2\\n..\\n\", \"3 3 4\\n.*.\\n*.*\\n.*.\\n\", \"4 4 2\\n....\\n....\\n....\\n....\\n\", \"1 1 1\\n.\\n\", \"1 1 1\\n*\\n\", \"2 2 2\\n.*\\n*.\\n\", \"1 1 1000\\n.\\n\", \"1 1 2000\\n*\\n\", \"5 5 3\\n.....\\n.....\\n*...*\\n*....\\n.*...\\n\", \"3 3 1\\n.*.\\n.*.\... | Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and your friends went for class, and found out that some of the seats were occupied.
The classroom contains $n$ rows of seat... | 0 |
{"tests": "{\"inputs\": [\"8.549e2\\n\", \"8.549e3\\n\", \"0.33e0\\n\", \"1.31e1\\n\", \"1.038e0\\n\", \"8.25983e5\\n\", \"8.77056e6\\n\", \"4.28522890224373996236468418851564462623381500262405e30\\n\", \"4.09336275522154223604344399571355118601483591618747e85\\n\", \"2.0629094807595491132306264747042243928486303384791... | Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate. [Image]
Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the ... | 0.125 |
{"tests": "{\"inputs\": [\"3 3\\n2 3 1000000\\n4 0 4\\n3 0 1000000\\n4 0 1\\n2 0 5\\n3 1 1000000\\n\", \"0 1\\n242110 453990 1000000\\n\", \"1 1\\n500000 1 1000000\\n500000 0 999999\\n\", \"3 0\\n3 1 1000000\\n1 1 1000000\\n2 1 1000000\\n\", \"1 1\\n999999 999999 1000000\\n999999 0 999999\\n\", \"0 0\\n\", \"1 1\\n2314... | There is a square of size $10^6 \times 10^6$ on the coordinate plane with four points $(0, 0)$, $(0, 10^6)$, $(10^6, 0)$, and $(10^6, 10^6)$ as its vertices.
You are going to draw segments on the plane. All segments are either horizontal or vertical and intersect with at least one side of the square.
Now you are wond... | 0 |
{"tests": "{\"inputs\": [\"4\\n4 2 2 3\\n\", \"6\\n1 1 1 1 1 3\\n\", \"1\\n3\\n\", \"7\\n5 3 3 5 5 4 4\\n\", \"8\\n3 3 3 3 3 3 3 1\\n\", \"15\\n4 4 4 3 2 1 5 3 5 3 4 1 2 4 4\\n\", \"20\\n4 5 3 4 5 4 2 4 2 1 5 3 3 1 4 1 2 4 4 3\\n\", \"28\\n1 3 4 4 4 3 1 4 5 1 3 5 3 2 5 1 4 4 5 3 4 2 5 4 2 5 3 2\\n\", \"30\\n1 5 5 5 5 5... | One tradition of welcoming the New Year is launching fireworks into the sky. Usually a launched firework flies vertically upward for some period of time, then explodes, splitting into several parts flying in different directions. Sometimes those parts also explode after some period of time, splitting into even more par... | 0 |
{"tests": "{\"inputs\": [[[25, 25, 50]], [[25, 25, 50, 100]], [[25, 100]], [[25, 25, 25, 25, 25, 25, 25, 25, 25, 25]], [[50, 50, 50, 50, 50, 50, 50, 50, 50, 50]], [[100, 100, 100, 100, 100, 100, 100, 100, 100, 100]], [[25, 25, 25, 25, 50, 100, 50]], [[50, 100, 100]], [[25, 25, 100]], [[25, 25, 25, 25, 25, 25, 25, 50, 5... | The new "Avengers" movie has just been released! There are a lot of people at the cinema box office standing in a huge line. Each of them has a single `100`, `50` or `25` dollar bill. An "Avengers" ticket costs `25 dollars`.
Vasya is currently working as a clerk. He wants to sell a ticket to every single person in thi... | 0 |
{"tests": "{\"inputs\": [[[\"3\", \"K\", \"5\", \"A\", \"5\", \"6\", \"7\", \"J\", \"7\", \"9\", \"10\", \"Q\", \"Q\", \"6\", \"8\", \"7\", \"4\", \"J\", \"8\", \"9\", \"K\", \"J\", \"10\", \"4\", \"K\", \"4\"], [\"2\", \"8\", \"9\", \"Q\", \"A\", \"K\", \"6\", \"3\", \"J\", \"2\", \"4\", \"3\", \"3\", \"8\", \"A\", \"... | Flash has invited his nemesis The Turtle (He actually was a real villain! ) to play his favourite card game, SNAP. In this game a 52 card deck is dealt out so both Flash and the Turtle get 26 random cards.
Each players cards will be represented by an array like below
Flash’s pile:
```[ 'A', '5', 'Q', 'Q', '6', '2', ... | 0 |
{"tests": "{\"inputs\": [\"3\\n4\\n1 2 3 4\\n1 2 3 4\\n4\\n11 12 20 21\\n44 22 11 30\\n1\\n1000000000\\n1000000000\\n\", \"1\\n10\\n617560334 911871372 379798020 844017253 852316352 439889133 601615010 818102467 260171475 662484047\\n148682006 868690703 149843110 878510105 587798634 40092006 292693207 256527822 1287947... | $n$ players are playing a game.
There are two different maps in the game. For each player, we know his strength on each map. When two players fight on a specific map, the player with higher strength on that map always wins. No two players have the same strength on the same map.
You are the game master and want to org... | 0 |
{"tests": "{\"inputs\": [\"1\\n\", \"2\\n\", \"3\\n\", \"4\\n\", \"0\\n\", \"30426905\\n\", \"38450759\\n\", \"743404\\n\", \"3766137\\n\", \"19863843\\n\", \"24562258\\n\", \"24483528\\n\", \"25329968\\n\", \"31975828\\n\", \"2346673\\n\", \"17082858\\n\", \"22578061\\n\", \"17464436\\n\", \"18855321\\n\", \"614109\\n... | Imagine you have an infinite 2D plane with Cartesian coordinate system. Some of the integral points are blocked, and others are not. Two integral points A and B on the plane are 4-connected if and only if: the Euclidean distance between A and B is one unit and neither A nor B is blocked; or there is some integral poi... | 0 |
{"tests": "{\"inputs\": [\"... ... ...\\n... ... ...\\n... ... ...\\n\\n... ... ...\\n... ... ...\\n... x.. ...\\n\\n... ... ...\\n... ... ...\\n... ... ...\\n6 4\\n\", \"xoo x.. x..\\nooo ... ...\\nooo ... ...\\n\\nx.. x.. x..\\n... ... ...\\n... ... ...\\n\\nx.. x.. x..\\n... ... ...\\n... ... ...\\n7 4\\n\", \"o.. .... | Two bears are playing tic-tac-toe via mail. It's boring for them to play usual tic-tac-toe game, so they are a playing modified version of this game. Here are its rules.
The game is played on the following field. [Image]
Players are making moves by turns. At first move a player can put his chip in any cell of any sm... | 0 |
{"tests": "{\"inputs\": [[\"lovecodewars\", \"e\"], [\"aaaaa\", \"a\"], [\"aabbaabb\", \"a\"], [\"aaaabbbb\", \"b\"], [\"aaaaa\", \"b\"], [\"lovecoding\", \"\"], [\"\", \"\"]], \"outputs\": [[[3, 2, 1, 0, 1, 2, 1, 0, 1, 2, 3, 4]], [[0, 0, 0, 0, 0]], [[0, 0, 1, 1, 0, 0, 1, 2]], [[4, 3, 2, 1, 0, 0, 0, 0]], [[]], [[]], [[... | Given a string `S` and a character `C`, return an array of integers representing the shortest distance from the current character in `S` to `C`.
### Notes
* All letters will be lowercase.
* If the string is empty, return an empty array.
* If the character is not present, return an empty array.
## Examples
```python... | 0 |
{"tests": "{\"inputs\": [\"3\\n2118 2118 2118\\n\", \"5\\n763 763 763 763 763\\n\", \"10\\n5938 4836 5938 5938 4836 4836 2780 2780 1495 4836\\n\", \"10\\n4972 4972 4972 4858 4858 4972 4972 4972 4858 4972\\n\", \"5\\n3581 3581 305 305 3581\\n\", \"4\\n2440 2440 2440 2440\\n\", \"10\\n8097 8097 8097 8097 8097 8097 8097 8... | Everyone knows that long ago on the territory of present-day Berland there lived Bindian tribes. Their capital was surrounded by n hills, forming a circle. On each hill there was a watchman, who watched the neighbourhood day and night.
In case of any danger the watchman could make a fire on the hill. One watchman coul... | 0 |
{"tests": "{\"inputs\": [\"10 3\\n2 5 8\", \"10 3\\n3 5 7\", \"100001 1\\n1\", \"110001 1\\n1\", \"10 1\\n2 2 8\", \"3 1\\n2 2 12\", \"1 1\\n1 3 12\", \"10 3\\n2 5 6 8 10\", \"10 1\\n1 4 8\", \"8 1\\n2 2 7\", \"10 1\\n3 0 8\", \"17 2\\n2 2 12\", \"7 1\\n2 3 12\", \"100001 1\\n2\", \"110001 1\\n2\", \"12 1\\n2 0 29\", \... | Problem
N idols, numbered from 1 to n in order, are lined up in a row.
Idle i can transmit information to idle i-1 and idle i + 1 in a unit time. However, idol 1 can transmit information only to idol 2, and idol n can transmit information only to idol n-1.
At time 0, m idols with numbers a1, a2, ..., am have secret i... | 0 |
{"tests": "{\"inputs\": [\"8\\n3\\n2\\n3\\n1\\n4\\n6\\n20\\n4\\n4\\n10\\n8\\n16\\n7\\n7\\n11\\n8\\n0\", \"8\\n3\\n2\\n3\\n1\\n4\\n6\\n20\\n4\\n4\\n12\\n8\\n16\\n7\\n7\\n4\\n8\\n0\", \"8\\n3\\n2\\n3\\n1\\n4\\n6\\n20\\n4\\n4\\n14\\n8\\n16\\n7\\n7\\n11\\n8\\n0\", \"8\\n3\\n2\\n3\\n1\\n7\\n7\\n12\\n4\\n4\\n12\\n8\\n16\\n7\... | problem
JOI Pizza sells pizza home delivery along the d-meter-long ring road that runs through the city center.
JOI Pizza has n stores S1, ..., Sn on the loop line. The head office is S1. The distance from S1 to Si when moving the loop line clockwise is set to di meters. D2 , ..., dn is an integer greater than or equ... | 0 |
{"tests": "{\"inputs\": [\"9\\n1 3 6 13 15 18 19 29 31\\n10\\n4\\n1 8\\n7 3\\n6 7\\n8 5\\n\", \"9\\n1 3 6 13 15 18 19 29 31\\n10\\n2\\n1 8\\n7 3\\n6 7\\n8 5\", \"9\\n1 6 6 13 23 18 19 29 31\\n10\\n3\\n1 8\\n7 3\\n6 7\\n8 10\", \"9\\n1 3 6 13 23 18 19 29 31\\n10\\n2\\n1 8\\n7 5\\n6 7\\n8 5\", \"9\\n1 3 6 13 23 18 19 29 ... | N hotels are located on a straight line. The coordinate of the i-th hotel (1 \leq i \leq N) is x_i.
Tak the traveler has the following two personal principles:
- He never travels a distance of more than L in a single day.
- He never sleeps in the open. That is, he must stay at a hotel at the end of a day.
You are giv... | 0.125 |
{"tests": "{\"inputs\": [[[1, 4, 4, 4, 0, 4, 3, 3, 1]], [[1, 1, 7, 7, 3]], [[-5, -5, 7, 7, 12, 0]], [[3, 3, 3, 3, 1]], [[2, 2, -4, 4, 5, 5, 6, 6, 6, 6, 6, 1]], [[1, 1, 1, 1, 1, 3]], [[1, -1, -2, 2, 3, -3, 4, -4]], [[0, 1, 1, 2, 2]]], \"outputs\": [[[1, 12, 0, 4, 6, 1]], [[2, 14, 3]], [[-10, 14, 12, 0]], [[12, 1]], [[4,... | You are given a list/array which contains only integers (positive and negative). Your job is to sum only the numbers that are the same and consecutive. The result should be one list.
Extra credit if you solve it in one line. You can assume there is never an empty list/array and there will always be an integer.
Same ... | 0 |
{"tests": "{\"inputs\": [[[8, 1], [3, 0]], [[2, 0], [8, 1]], [[4, 0], [4, 0]], [[6, 0], [8, 0]], [[8, 0], [6, 0]], [[4, 3], [6, 0]], [[1, 0], [5, 0]], [[3, 3], [5, 3]], [[1, 10], [1, 4]], [[3, 3], [6, 0]], [[7, 2], [6, 8]]], \"outputs\": [[\"Auto-win\"], [\"Auto-lose\"], [\"Random\"], [\"(1..3)\"], [\"(5..6)\"], [\"(6.... | In the board game Talisman, when two players enter combat the outcome is decided by a combat score, equal to the players power plus any modifiers plus the roll of a standard 1-6 dice. The player with the highest combat score wins and the opposing player loses a life. In the case of a tie combat ends with neither player... | 0 |
{"tests": "{\"inputs\": [[-1], [0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10]], \"outputs\": [[[]], [[]], [[1]], [[1]], [[1, 3]], [[1]], [[1, 5]], [[1, 3]], [[1, 7]], [[1]], [[1, 3, 9]], [[1, 5]]]}", "source": "taco"} | No Story
No Description
Only by Thinking and Testing
Look at the results of the testcases, and guess the code!
---
## Series:
01. [A and B?](http://www.codewars.com/kata/56d904db9963e9cf5000037d)
02. [Incomplete string](http://www.codewars.com/kata/56d9292cc11bcc3629000533)
03. [True or False](http://www.codewars... | 0 |
{"tests": "{\"inputs\": [\"10\\nAND 9 4\\nIN 1\\nIN 1\\nXOR 6 5\\nAND 3 7\\nIN 0\\nNOT 10\\nIN 1\\nIN 1\\nAND 2 8\\n\", \"3\\nAND 2 3\\nIN 0\\nIN 0\\n\", \"3\\nAND 2 3\\nIN 1\\nIN 0\\n\", \"3\\nAND 2 3\\nIN 0\\nIN 1\\n\", \"3\\nAND 2 3\\nIN 1\\nIN 1\\n\", \"3\\nOR 2 3\\nIN 0\\nIN 0\\n\", \"3\\nOR 2 3\\nIN 1\\nIN 0\\n\"... | Natasha travels around Mars in the Mars rover. But suddenly it broke down, namely — the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the vertex $1$, in which every leaf (excluding root) is an input, and all other vertices are logical elements, including the root, w... | 0.375 |
{"tests": "{\"inputs\": [\"9\\n\", \"181\\n\", \"261\\n\", \"8\\n\", \"121\\n\", \"351\\n\", \"71\\n\", \"141\\n\", \"361\\n\", \"1\\n\", \"61\\n\", \"301\\n\", \"392\\n\", \"10\\n\", \"321\\n\", \"161\\n\", \"151\\n\", \"41\\n\", \"251\\n\", \"241\\n\", \"395\\n\", \"271\\n\", \"101\\n\", \"131\\n\", \"396\\n\", \"211... | It is known that passages in Singer house are complex and intertwined. Let's define a Singer k-house as a graph built by the following process: take complete binary tree of height k and add edges from each vertex to all its successors, if they are not yet present.
<image> Singer 4-house
Count the number of non-empty ... | 0 |
{"tests": "{\"inputs\": [\"010101\\n\", \"11001100\\n\", \"0\\n\", \"00\\n\", \"01\\n\", \"000\\n\", \"100\\n\", \"001\\n\", \"101\\n\", \"0000\\n\", \"0100101110\\n\", \"1101111000011110111111110101100111111110111100001111011010111001101100010110000001010101101010111000\\n\", \"1000\\n\", \"0010\\n\", \"1010\\n\", \"0... | Toad Rash has a binary string $s$. A binary string consists only of zeros and ones.
Let $n$ be the length of $s$.
Rash needs to find the number of such pairs of integers $l$, $r$ that $1 \leq l \leq r \leq n$ and there is at least one pair of integers $x$, $k$ such that $1 \leq x, k \leq n$, $l \leq x < x + 2k \leq r... | 0.75 |
{"tests": "{\"inputs\": [\"6 2\\nioi\\n1 3\\n\", \"5 2\\nioi\\n1 2\\n\", \"173700 6\\nbcabcbcbcbaaacaccaacaccaabacabaacbcacbbccaccbcacbabcaccccccaacacabbbbbacabbaaacbcbbaccaccabbbbaabbacacbabccaabcabbbcacaaccbabbcaaaaaabccbbcabcacbcbcabcbcbbaabacaaccccabacaaaccacaaabbacacabbcccacbaabcacacbbaaaccaccbaccccccbccaabcacaaca... | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. [Image]
Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions... | 0.625 |
{"tests": "{\"inputs\": [\"4\\n2332\", \"4\\n3121\", \"4\\n1311\", \"10\\n1806305381\", \"4\\n2465\", \"10\\n2192114600\", \"4\\n2113\", \"10\\n3104206232\", \"4\\n2121\", \"4\\n2010\", \"10\\n2763272837\", \"10\\n1238013900\", \"10\\n1665759416\", \"10\\n2224468077\", \"4\\n1200\", \"10\\n1876244682\", \"4\\n2881\", \... | Given is a sequence of N digits a_1a_2\ldots a_N, where each element is 1, 2, or 3. Let x_{i,j} defined as follows:
* x_{1,j} := a_j \quad (1 \leq j \leq N)
* x_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | \quad (2 \leq i \leq N and 1 \leq j \leq N+1-i)
Find x_{N,1}.
Constraints
* 2 \leq N \leq 10^6
* a_i = 1,2,3 (1 \leq... | 0 |
{"tests": "{\"inputs\": [[1, 2], [16, 8], [1, 1], [2, 3], [7, 10], [43, 77], [7, 15], [23, 7]], \"outputs\": [[false], [false], [false], [false], [false], [true], [true], [true]]}", "source": "taco"} | In this Kata you need to write the method SharedBits that returns true if 2 integers share at least two '1' bits. For simplicity assume that all numbers are positive
For example
int seven = 7; //0111
int ten = 10; //1010
int fifteen = 15; //1111
SharedBits(seven, ten); //false
SharedBits(seven, fifteen); //... | 0.625 |
{"tests": "{\"inputs\": [\"4\\n4\\n6\\n15\\n1000000000\", \"4\\n2\\n6\\n15\\n1001000000\", \"4\\n0\\n0\\n15\\n1001000000\", \"4\\n0\\n0\\n24\\n1001000000\", \"4\\n0\\n0\\n24\\n1001000001\", \"4\\n4\\n6\\n10\\n1100000000\", \"4\\n4\\n6\\n30\\n1000000000\", \"4\\n2\\n10\\n15\\n1000000000\", \"4\\n2\\n6\\n1\\n1001000000\"... | Given is an integer N. Snuke will choose integers s_1, s_2, n_1, n_2, u_1, u_2, k_1, k_2, e_1, and e_2 so that all of the following six conditions will be satisfied:
* 0 \leq s_1 < s_2
* 0 \leq n_1 < n_2
* 0 \leq u_1 < u_2
* 0 \leq k_1 < k_2
* 0 \leq e_1 < e_2
* s_1 + s_2 + n_1 + n_2 + u_1 + u_2 + k_1 + k_2 + e_1 + e_... | 0 |
{"tests": "{\"inputs\": [\"5 5 1 3\\n2 2\\n2 2\\n2 2\\n2 2\\n\", \"1 6 3 12\\n1 2\\n1 4\\n1 6\\n1 1\\n1 2\\n1 6\\n1 2\\n1 5\\n1 3\\n1 4\\n1 5\\n1 5\\n1 4\\n1 6\\n1 3\\n\", \"1 2 1 2\\n1 1\\n1 2\\n1 1\\n\", \"3 3 3 5\\n1 1\\n2 2\\n3 3\\n1 1\\n2 2\\n2 2\\n2 2\\n3 3\\n\", \"2 3 2 2\\n1 1\\n2 1\\n1 2\\n2 1\\n\", \"2 3 2 2\... | Fox Ciel saw a large field while she was on a bus. The field was a n × m rectangle divided into 1 × 1 cells. Some cells were wasteland, and other each cell contained crop plants: either carrots or kiwis or grapes.
After seeing the field carefully, Ciel found that the crop plants of each cell were planted in following... | 0 |
{"tests": "{\"inputs\": [\"40867 37466\\n\", \"278917 84398\\n\", \"11 1\\n\", \"274783 98997\\n\", \"7 6\\n\", \"4649 4648\\n\", \"375103 52131\\n\", \"990037 453792\\n\", \"69833 569\\n\", \"717887 1\\n\", \"65213 29960\\n\", \"649849 339573\\n\", \"13 5\\n\", \"586189 189159\\n\", \"450431 344107\\n\", \"5 2\\n\", \... | As behooves any intelligent schoolboy, Kevin Sun is studying psycowlogy, cowculus, and cryptcowgraphy at the Bovinia State University (BGU) under Farmer Ivan. During his Mathematics of Olympiads (MoO) class, Kevin was confronted with a weird functional equation and needs your help. For two fixed integers k and p, where... | 0 |
{"tests": "{\"inputs\": [\"1\\n4 5\", \"1\\n3 5\", \"1\\n3 2\", \"1\\n4 10\", \"1\\n6 6\", \"1\\n1 10\", \"1\\n0 0\", \"1\\n1 19\", \"1\\n1 22\", \"1\\n1 5\", \"1\\n1 8\", \"1\\n1 17\", \"1\\n1 1\", \"1\\n1 9\", \"1\\n1 23\", \"1\\n-1 -1\", \"1\\n1 18\", \"1\\n1 7\", \"1\\n1 14\", \"1\\n-2 -2\", \"1\\n1 63\", \"1\\n1 1... | Given two matrices A and B. Both have N rows and M columns. In the matrix A, numbers from 1 to MN have been written in row major order. Row major order numbers cells from left to right, and top to bottom. That is,
1 2 3 ... M
A = M+1 M+2 M+3 ... | 0 |
{"tests": "{\"inputs\": [\"1\\n10\\nG\\n\", \"2\\n10 10\\nWL\\n\", \"2\\n1 2\\nWL\\n\", \"3\\n10 10 10\\nGLW\\n\", \"2\\n2 10\\nGL\\n\", \"1\\n10\\nW\\n\", \"1\\n9\\nW\\n\", \"1\\n9\\nG\\n\", \"2\\n10 10\\nGL\\n\", \"3\\n10 10 50\\nWGL\\n\", \"3\\n10 9 10\\nGLW\\n\", \"2\\n100 100\\nWG\\n\", \"2\\n100 100\\nGW\\n\", \"... | Bob is a duck. He wants to get to Alice's nest, so that those two can duck! [Image] Duck is the ultimate animal! (Image courtesy of See Bang)
The journey can be represented as a straight line, consisting of $n$ segments. Bob is located to the left of the first segment, while Alice's nest is on the right of the last s... | 0 |
{"tests": "{\"inputs\": [\"8 4 5\\n(())()()\\nRDLD\\n\", \"12 5 3\\n((()())(()))\\nRRDLD\\n\", \"8 8 8\\n(())()()\\nLLLLLLDD\\n\", \"4 2 2\\n()()\\nLD\\n\", \"6 4 1\\n()()()\\nDRRD\\n\", \"8 2 4\\n(())()()\\nRR\\n\", \"10 7 3\\n(()())()()\\nRDLRDRD\\n\", \"12 10 11\\n(())()()()()\\nDLRDLRDDLR\\n\", \"14 8 13\\n((())())... | Recently Polycarp started to develop a text editor that works only with correct bracket sequences (abbreviated as CBS).
Note that a bracket sequence is correct if it is possible to get a correct mathematical expression by adding "+"-s and "1"-s to it. For example, sequences "(())()", "()" and "(()(()))" are correct, ... | 0 |
{"tests": "{\"inputs\": [\"6\\n7\\n2323216\\n1615124\\n1\\n3\\n4\\n2\\n13\\n24\\n2\\n12\\n34\\n3\\n536\\n345\\n2\\n46\\n54\\n\", \"6\\n7\\n2323216\\n1615124\\n1\\n3\\n4\\n2\\n14\\n24\\n2\\n12\\n34\\n3\\n536\\n345\\n2\\n46\\n54\\n\", \"6\\n7\\n2323216\\n1615124\\n1\\n3\\n4\\n2\\n13\\n24\\n2\\n12\\n34\\n3\\n536\\n525\\n2... | You are given a system of pipes. It consists of two rows, each row consists of $n$ pipes. The top left pipe has the coordinates $(1, 1)$ and the bottom right — $(2, n)$.
There are six types of pipes: two types of straight pipes and four types of curved pipes. Here are the examples of all six types:
[Image] Types of ... | 0 |
{"tests": "{\"inputs\": [\"FTFTFTFFFFTFTFTTTTTTFFTTTTFFTFFFTFTFTFFTFTFTFFFTTTFTTFTTTTTFFFFTTT\\n12\\n\", \"FTTFTFFTFTTTFTTFTFFTTFFFFFTFFFFTTFTFFFFFFTFFTTTFTTFTTTFFFTFTFTFFFFTFFTFTTTTTTTTFTTTTTTFFTTFTTT\\n35\\n\", \"FTTFTTTFTTFFFTFFTTFTFTTTFFFTFTFTFFTTTFFFFFFTFTTFFTFFFFTFTTFFFTFFTTTTTFFTFTTFFFTFFTFFTF\\n16\\n\", \"FFTFT... | A lot of people associate Logo programming language with turtle graphics. In this case the turtle moves along the straight line and accepts commands "T" ("turn around") and "F" ("move 1 unit forward").
You are given a list of commands that will be given to the turtle. You have to change exactly n commands from the lis... | 0 |
{"tests": "{\"inputs\": [[254], [256], [258], [-254], [-256], [-258]], \"outputs\": [[254], [0], [2], [2], [0], [254]]}", "source": "taco"} | # MOD 256 without the MOD operator
The MOD-operator % (aka mod/modulus/remainder):
```
Returns the remainder of a division operation.
The sign of the result is the same as the sign of the first operand.
(Different behavior in Python!)
```
The short unbelievable mad story for this kata:
I wrote a program and needed th... | 0.375 |
{"tests": "{\"inputs\": [\"7\\n1 4 2 5 4 3\\n2 1 5\\n3 1 6\\n4 1 7\\n5 2 7 6\\n6 1 1\\n7 0\\n6\\n1 2 2\\n1 5 3\\n1 2 0\\n5 1 3\\n6 3 3\\n1 7 4\", \"7\\n1 4 2 5 4 6\\n2 1 5\\n3 1 6\\n4 1 7\\n5 2 7 6\\n6 1 1\\n7 0\\n6\\n1 2 2\\n1 3 3\\n1 2 0\\n5 1 3\\n6 3 3\\n1 7 4\", \"7\\n1 4 2 5 4 3\\n2 1 5\\n3 1 6\\n4 1 7\\n5 2 7 6\\... | On the Internet, data is divided into packets, and each packet is transferred to a destination via a relay device called a router. Each router determines the next router to forward from the destination described in the packet. In addition, a value called TTL (Time To Live) is added to the packet to prevent it from bein... | 0 |
{"tests": "{\"inputs\": [\"2\\n3 2\\n2 4 7\\n5 3\\n1 2 3 4 5\", \"2\\n3 2\\n2 4 7\\n3 3\\n1 2 3 4 5\", \"2\\n3 2\\n2 4 7\\n3 3\\n1 2 3 4 9\", \"2\\n3 2\\n2 4 7\\n3 3\\n1 2 3 4 7\", \"2\\n3 2\\n2 4 10\\n3 3\\n1 2 3 4 7\", \"2\\n4 2\\n1 4 7\\n5 3\\n1 2 3 4 9\", \"2\\n4 1\\n1 4 7\\n5 6\\n1 2 5 6 9\", \"2\\n6 2\\n2 4 7\\n4... | There is a line with 1000 cells numbered from 1 to 1000 from left to right and N coins placed on it. Coin i is placed at cell X_{i}, and no two coins are placed at the same cell.
Bob would like to move the coins to the N leftmost cells of the line. To do this, he is allowed to take a coin from any cell T and move it t... | 0 |
{"tests": "{\"inputs\": [[[0, 1], 10], [[1, 1], 10], [[0, 0, 0, 0, 1], 10], [[1, 0, 0, 0, 0, 0, 1], 10], [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], 20], [[0.5, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10], [[0.5, 0, 0, 0, 0, 0, 0, 0, 0, 0], 20], [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 20], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 0], 9], [[1, 2, 3, 4, 5, 6, 7,... | If you have completed the Tribonacci sequence kata, you would know by now that mister Fibonacci has at least a bigger brother. If not, give it a quick look to get how things work.
Well, time to expand the family a little more: think of a Quadribonacci starting with a signature of 4 elements and each following element ... | 0 |
{"tests": "{\"inputs\": [\"4\\n1\\n2\\n3\\n4\\n\", \"1\\n100000\\n\", \"1\\n99988\\n\", \"1\\n99990\\n\", \"1\\n99992\\n\", \"1\\n99994\\n\", \"1\\n99996\\n\", \"1\\n99998\\n\", \"1\\n31704\\n\"], \"outputs\": [\"YES\\n1 2\\nNO\\nYES\\n1 6\\n2 4\\n3 5\\nNO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"... | You are given an integer $n$. Pair the integers $1$ to $2n$ (i.e. each integer should be in exactly one pair) so that each sum of matched pairs is consecutive and distinct.
Formally, let $(a_i, b_i)$ be the pairs that you matched. $\{a_1, b_1, a_2, b_2, \ldots, a_n, b_n\}$ should be a permutation of $\{1, 2, \ldots, 2... | 0 |
{"tests": "{\"inputs\": [\"4\\n2 1 6 4\\n3 4 4 2\\n\", \"4\\n10 5 6 4\\n1 11 4 2\\n\", \"3\\n10 1 10\\n1 10 1 1\\n\", \"4\\n2 1 6 4\\n4 2 3 5\\n\", \"3\\n20 3 20\\n1 20 1 1\\n\", \"2\\n10 1\\n1 3 2 1\\n\", \"20\\n3 1 9 9 6 1 3 4 5 6 7 3 1 9 9 1 9 1 5 7\\n17 7 19 5\\n\", \"20\\n81 90 11 68 23 18 78 75 45 86 58 37 21 15 ... | Vasya is pressing the keys on the keyboard reluctantly, squeezing out his ideas on the classical epos depicted in Homer's Odysseus... How can he explain to his literature teacher that he isn't going to become a writer? In fact, he is going to become a programmer. So, he would take great pleasure in writing a program, b... | 0 |
{"tests": "{\"inputs\": [\"6 1 2 3 4 7\", \"6 106 2 3 4 5\", \"6 2 2 3 4 7\", \"6 159 2 3 4 5\", \"6 200 2 3 8 8\", \"6 159 2 3 3 5\", \"6 3 1 3 4 8\", \"22 144 2 3 3 5\", \"17 144 2 3 6 5\", \"9 5 1 3 15 9\", \"17 22 2 3 6 7\", \"6 373 2 3 4 5\", \"6 200 2 4 8 5\", \"6 159 2 4 4 5\", \"9 4 2 3 8 7\", \"6 323 2 4 8 5\"... | I have n tickets for a train with a rabbit. Each ticket is numbered from 0 to n − 1, and you can use the k ticket to go to p⋅ak + q⋅bk station.
Rabbit wants to go to the all-you-can-eat carrot shop at the station m station ahead of the current station, but wants to walk as short as possible. The stations are lined up ... | 0 |
{"tests": "{\"inputs\": [\"4 4\\n2 3 5 7\\n1 2 7\\n1 3 9\\n2 3 21\\n3 4 18\", \"4 4\\n2 3 1 7\\n1 2 7\\n1 3 9\\n2 3 12\\n3 4 18\", \"4 4\\n2 3 5 7\\n1 4 7\\n1 2 9\\n1 3 15\\n3 4 18\", \"6 10\\n2 4 1 1 1 7\\n3 5 19\\n2 5 8\\n4 5 5\\n1 6 16\\n2 5 9\\n3 6 16\\n3 4 1\\n2 6 20\\n1 4 19\\n1 2 9\", \"6 10\\n2 8 1 1 1 7\\n3 5 ... | There is a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. Also, each of these vertices and edges has a specified weight. Vertex i has a weight of X_i; Edge i has a weight of Y_i and connects Vertex A_i and B_i.
We would like to remove zero o... | 0 |
{"tests": "{\"inputs\": [[[\"*****************************************\", \"** _O_ * _O_ * _O_ * _O_ **\", \"** /(.)J * C(.)J * /(.)J * C(.)J **\", \"** _| |_ * _| |_ * _( )_ * _( )_ *\"]], [[\"*** _O_ ** _O_ ** _O_ ** _O_ ***\", \"*** /(.)J ** /(.)J ** C(.)J ** C(.)J ***\"... | It's Friday night, and Chuck is bored. He's already run 1,000 miles, stopping only to eat a family sized bag of Heatwave Doritos and a large fistful of M&Ms. He just can't stop thinking about kicking something!
There is only one thing for it, Chuck heads down to his local MMA gym and immediately challenges every figh... | 0 |
{"tests": "{\"inputs\": [\"3\\n2 2 1\\n1 2\\n2 3\", \"6\\n3 2 2 2 2 2\\n1 2\\n2 3\\n1 6\\n1 5\\n4 6\", \"6\\n5 2 2 2 2 2\\n1 2\\n2 3\\n1 6\\n1 5\\n4 6\", \"6\\n5 2 4 2 2 2\\n1 2\\n2 3\\n1 6\\n1 5\\n4 6\", \"6\\n5 2 4 2 2 2\\n1 2\\n2 3\\n1 6\\n1 5\\n6 6\", \"6\\n5 2 4 2 2 2\\n1 0\\n2 3\\n1 6\\n1 5\\n6 6\", \"6\\n3 2 2 2... | There is a tree with N vertices, numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i.
Currently, there are A_i stones placed on vertex i. Determine whether it is possible to remove all the stones from the vertices by repeatedly performing the following operation:
* Select a pair of different... | 0 |
{"tests": "{\"inputs\": [[\"H1H10F1200120008F4F4\"], [\"D7D70F1200250015G8G8\"], [\"X7X7B7A201400058L0L0\"], [\"Y2Y2B7A210000902N5N5\"], [\"R5R5C3D900120008K4K4\"], [\"S2S2C3D900250005I9I9\"], [\"E4E40F1239128908Z3Z3\"], [\"A6A6C3D911150015M0M0\"], [\"T7T7B7A200258908P2P2\"], [\"S4S4B7A201153215U8U8\"]], \"outputs\": [... | We need you to implement a method of receiving commands over a network, processing the information and responding.
Our device will send a single packet to you containing data and an instruction which you must perform before returning your reply.
To keep things simple, we will be passing a single "packet" as a string.... | 0.75 |
{"tests": "{\"inputs\": [\"3\\n4\\n1 2 4 8\\n3\\n2 3 3\\n5\\n3 3 3 3 3\", \"3\\n4\\n1 2 4 8\\n3\\n2 3 3\\n5\\n1 3 3 3 3\", \"3\\n4\\n1 2 4 2\\n3\\n3 3 3\\n5\\n1 3 2 3 3\", \"3\\n4\\n1 2 8 7\\n3\\n2 1 3\\n5\\n1 3 1 3 3\", \"3\\n4\\n1 2 15 7\\n3\\n2 1 3\\n5\\n1 3 1 3 0\", \"3\\n4\\n1 2 4 8\\n3\\n3 3 3\\n5\\n1 3 3 3 3\", ... | Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Nim is a well-known combinatorial game, based on removing stones from piles. In this problem, we'll deal with a similar game, which we'll call Dual Nim. The rules of this game are as follows:
Initially, there are N piles of stones, numbered... | 0 |
{"tests": "{\"inputs\": [[2, 4], [3, 3], [3, 9], [2, 5], [4, 10], [4, 5], [1, 1], [2, 1], [5, 4], [5, 1]], \"outputs\": [[[[0, 1], [2, 3]]], [[[0], [1], [2]]], [[[0, 1, 2], [3, 4, 5], [6, 7, 8]]], [[[0, 1, 2], [3, 4]]], [[[0, 1, 2], [3, 4, 5], [6, 7], [8, 9]]], [[[0, 1], [2], [3], [4]]], [[[0]]], [[[0], []]], [[[0], [1... | Bob has a server farm crunching numbers. He has `nodes` servers in his farm. His company has a lot of work to do.
The work comes as a number `workload` which indicates how many jobs there are. Bob wants his servers to get an equal number of jobs each. If that is impossible, he wants the first servers to receive more ... | 0 |
{"tests": "{\"inputs\": [\"13 19\\n0000111111111111011\\n0111000001110001101\\n1110100110111011101\\n0001101011100001110\\n1101100100010000101\\n1010100011110011010\\n1010011101010000001\\n1011101000001111000\\n1101110001101011110\\n0110101010001111100\\n0001011010100111001\\n1111101000110001000\\n0010010000011100010\\... | You are given a matrix consisting of digits zero and one, its size is n × m. You are allowed to rearrange its rows. What is the maximum area of the submatrix that only consists of ones and can be obtained in the given problem by the described operations?
Let's assume that the rows of matrix a are numbered from 1 to n ... | 0.125 |
{"tests": "{\"inputs\": [\"6 11\\n1 3\\n1 4\\n1 5\\n1 6\\n2 3\\n2 4\\n2 5\\n2 6\\n3 4\\n3 5\\n3 6\\n\", \"3 0\\n\", \"2 0\\n\", \"1 0\\n\", \"2 1\\n1 2\\n\", \"4 2\\n3 2\\n1 4\\n\", \"3 3\\n1 2\\n3 1\\n2 3\\n\", \"7 5\\n7 5\\n1 5\\n3 2\\n2 6\\n3 6\\n\", \"10 10\\n1 5\\n1 8\\n1 9\\n5 8\\n8 9\\n4 7\\n2 3\\n3 10\\n2 6\\n2... | Ujan has a lot of useless stuff in his drawers, a considerable part of which are his math notebooks: it is time to sort them out. This time he found an old dusty graph theory notebook with a description of a graph.
It is an undirected weighted graph on $n$ vertices. It is a complete graph: each pair of vertices is con... | 0.125 |
{"tests": "{\"inputs\": [\"6 3\\n\", \"4 2\\n\", \"1000 1001\\n\", \"1000000000 999999999\\n\", \"81452244 81452247\\n\", \"188032448 86524683\\n\", \"365289629 223844571\\n\", \"247579518 361164458\\n\", \"424836699 793451637\\n\", \"602093880 930771525\\n\", \"779351061 773124120\\n\", \"661640950 836815080\\n\", \"5... | Imp likes his plush toy a lot.
[Image]
Recently, he found a machine that can clone plush toys. Imp knows that if he applies the machine to an original toy, he additionally gets one more original toy and one copy, and if he applies the machine to a copied toy, he gets two additional copies.
Initially, Imp has only ... | 0.875 |
{"tests": "{\"inputs\": [\"1\\n5 6\\n...a..\\n..bbb.\\n...a..\\n.cccc.\\n...a..\\n\", \"3\\n3 3\\n...\\n...\\n...\\n4 4\\n..c.\\nadda\\nbbcb\\n....\\n3 5\\n..b..\\naaaaa\\n..b..\\n\", \"2\\n3 3\\n...\\n.a.\\n...\\n2 2\\nbb\\ncc\\n\", \"2\\n1 1\\na\\n1 1\\nz\\n\", \"2\\n1 1\\na\\n1 1\\nz\\n\", \"3\\n3 3\\n...\\n...\\n..... | After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $n \times m$ (where $n$ is the number of rows, $m$ is the number of columns) and starts to draw snakes in cells.
Polycarp draws snakes with lowercase Lati... | 0 |
{"tests": "{\"inputs\": [[[\"fib\"], 0], [[], 10], [[\"fib\"], 10], [[\"tri\"], 10], [[\"tet\"], 10], [[\"pad\"], 10], [[\"pel\"], 10], [[\"jac\"], 10], [[\"fib\", \"tri\"], 10], [[\"tri\", \"fib\"], 10], [[\"pad\", \"fib\"], 10], [[\"tri\", \"tet\"], 10], [[\"fib\", \"pel\", \"tri\"], 10], [[\"tet\", \"jac\"], 10]], \... | # History
This kata is a sequel of my [Mixbonacci](https://www.codewars.com/kata/mixbonacci/python) kata. Zozonacci is a special integer sequence named after [**ZozoFouchtra**](https://www.codewars.com/users/ZozoFouchtra), who came up with this kata idea in the [Mixbonacci discussion](https://www.codewars.com/kata/mix... | 0 |
{"tests": "{\"inputs\": [\"2\\n3 3 3 3 -3 3 2 -5 3 2 -5 -3 0\\n3 5 3 -2 4 -3 -2 -2 -1 0\", \"2\\n3 3 3 3 -3 3 2 -5 3 2 -5 -3 0\\n3 5 4 -2 4 -1 -2 -2 -1 0\", \"2\\n3 3 3 3 -3 3 2 -5 3 2 -5 -3 0\\n3 2 4 -2 4 -3 -2 -2 -1 0\", \"2\\n3 3 3 3 -3 3 2 -5 3 2 -5 -3 0\\n3 2 4 -2 5 -3 -2 -2 -1 0\", \"2\\n3 3 3 3 -3 3 2 -5 3 2 -5 ... | An old document says that a Ninja House in Kanazawa City was in fact a defensive fortress, which was designed like a maze. Its rooms were connected by hidden doors in a complicated manner, so that any invader would become lost. Each room has at least two doors.
The Ninja House can be modeled by a graph, as shown in Fi... | 0 |
{"tests": "{\"inputs\": [\"3 -1 20 200\\n19 12\\n24 121\\n25 32\\n28 19\\n28 87\\n29 49\\n32 88\\n33 70\\n37 77\\n54 33\\n56 27\\n61 59\\n67 42\\n73 15\\n76 40\\n80 73\\n83 39\\n91 34\\n91 112\\n95 95\\n\", \"0 0 5 100\\n17 3\\n42 24\\n72 22\\n72 25\\n120 25\\n\", \"0 0 5 100\\n12 105\\n15 59\\n21 1\\n27 6\\n27 76\\n\"... | Anton and Dasha like to play different games during breaks on checkered paper. By the 11th grade they managed to play all the games of this type and asked Vova the programmer to come up with a new game. Vova suggested to them to play a game under the code name "dot" with the following rules:
* On the checkered pape... | 0.125 |
{"tests": "{\"inputs\": [\"1 2 3\\n15\\n10 19\\n20 11 13\\n\", \"2 3 4\\n16 40\\n20 12 19\\n13 21 11 10\\n\", \"4 4 5\\n15 16 19 6\\n8 11 9 18\\n5 3 1 12 14\\n\", \"6 7 7\\n32 35 26 33 16 23\\n4 40 36 12 28 24 3\\n39 11 31 37 1 25 6\\n\", \"9 10 7\\n935 433 848 137 548 958 758 576 592\\n780 129 631 991 575 421 245 944 ... | Завтра у хоккейной команды, которой руководит Евгений, важный матч. Евгению нужно выбрать шесть игроков, которые выйдут на лед в стартовом составе: один вратарь, два защитника и три нападающих.
Так как это стартовый состав, Евгения больше волнует, насколько красива будет команда на льду, чем способности игроков. А име... | 0 |
{"tests": "{\"inputs\": [[\"trisf\", [\"first\"]], [\"oob\", [\"bob\", \"baobab\"]], [\"ainstuomn\", [\"mountains\", \"hills\", \"mesa\"]], [\"oolp\", [\"donkey\", \"pool\", \"horse\", \"loop\"]], [\"ortsp\", [\"sport\", \"parrot\", \"ports\", \"matey\"]], [\"ourf\", [\"one\", \"two\", \"three\"]]], \"outputs\": [[[\"f... | Pirates have notorious difficulty with enunciating. They tend to blur all the letters together and scream at people.
At long last, we need a way to unscramble what these pirates are saying.
Write a function that will accept a jumble of letters as well as a dictionary, and output a list of words that the pirate might ... | 0 |
{"tests": "{\"inputs\": [\"CRWEYDMET BERLAND 6:2\\nJ CRWEYDMET 5:4\\nLYUTZZCGW BERLAND 8:4\\nLYUTZZCGW CRWEYDMET 3:4\\nLYUTZZCGW J 2:2\\n\", \"AERLAND DERLAND 1:0\\nDERLAND CERLAND 0:0\\nCERLAND AERLAND 1:0\\nAERLAND BERLAND 0:0\\nDERLAND BERLAND 1:0\\n\", \"QHA BERLAND 7:2\\nVROOBFARVCFK QHA 5:7\\nZLRZXLRDUKGQM BERLAN... | Any resemblance to any real championship and sport is accidental.
The Berland National team takes part in the local Football championship which now has a group stage. Let's describe the formal rules of the local championship:
* the team that kicked most balls in the enemy's goal area wins the game;
* the victor... | 0.25 |
{"tests": "{\"inputs\": [\"15 7\\n8 8 U\\n6 10 L\\n9 7 L\\n3 13 L\\n15 1 L\\n13 3 U\\n1 15 L\\n\", \"1000000000 1\\n117117117 882882884 U\\n\", \"10 10\\n5 6 U\\n4 7 U\\n8 3 L\\n8 3 L\\n1 10 U\\n9 2 U\\n10 1 L\\n10 1 L\\n8 3 U\\n8 3 U\\n\", \"1 2\\n1 1 L\\n1 1 U\\n\", \"20 10\\n10 11 U\\n12 9 U\\n6 15 L\\n17 4 U\\n11 1... | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n × n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 0 |
{"tests": "{\"inputs\": [\"10 3 5 2 3\\n\", \"5 3 1 6 7\\n\", \"982068341 55 57 106 109\\n\", \"930064129 32726326 25428197 83013449 64501049\\n\", \"927155987 21197 15994 54746 41309\\n\", \"902303498 609628987 152407246 8 2\\n\", \"942733698 9180 9072 1020 1008\\n\", \"951102310 39876134 24967176 70096104 43888451\\n... | A sweet little monster Om Nom loves candies very much. One day he found himself in a rather tricky situation that required him to think a bit in order to enjoy candies the most. Would you succeed with the same task if you were on his place? [Image]
One day, when he came to his friend Evan, Om Nom didn't find him at h... | 0 |
{"tests": "{\"inputs\": [\"7 4\\n\", \"6 2\\n\", \"3 0\\n\", \"2 2\\n\", \"9 1\\n\", \"2 0\\n\", \"543 110\\n\", \"924 576\\n\", \"1000 972\\n\", \"846 0\\n\", \"806 100\\n\", \"268 121\\n\", \"729 501\\n\", \"190 34\\n\", \"571 402\\n\", \"469 217\\n\", \"930 307\\n\", \"829 124\\n\", \"210 208\\n\", \"109 63\\n\", \"... | The three friends, Kuro, Shiro, and Katie, met up again! It's time for a party...
What the cats do when they unite? Right, they have a party. Since they wanted to have as much fun as possible, they invited all their friends. Now $n$ cats are at the party, sitting in a circle and eating soup. The rules are simple: anyo... | 0.875 |
{"tests": "{\"inputs\": [\"1\\n\", \"2\\n\", \"0\\n\", \"-1\\n\", \"-2\\n\", \"-3\\n\", \"-6\\n\", \"-8\\n\", \"-14\\n\", \"-17\\n\", \"-30\\n\", \"4\\n\", \"8\\n\", \"11\\n\", \"19\\n\", \"6\\n\", \"3\\n\", \"5\\n\", \"10\\n\", \"17\\n\", \"-4\\n\", \"-5\\n\", \"-9\\n\", \"-10\\n\", \"9\\n\", \"18\\n\", \"34\\n\", \"4... | You are given a mysterious language (codenamed "Secret") available in "Custom Invocation" tab. Figure out what this language is and write a program which prints its name. Note that the program must be written in this language.
Input
This program has only one test (your program doesn't have to read anything).
Output
... | 0 |
{"tests": "{\"inputs\": [\"5\\n2 2\\n1 1 2 2\\n1 1 2 2\\n3 4\\n2 2 3 2\\n3 1 4 3\\n1 5\\n1 1 5 1\\n3 1 5 1\\n4 4\\n1 1 4 2\\n1 3 4 4\\n3 4\\n1 2 4 2\\n2 1 3 3\\n\", \"1\\n3456 4567\\n1 234 678 1000\\n346 903 1005 2003\\n\", \"1\\n3456 4567\\n1 234 678 1000\\n346 903 1005 2003\\n\", \"5\\n2 2\\n1 1 2 2\\n1 1 2 2\\n3 5\\... | Recently, Masha was presented with a chessboard with a height of $n$ and a width of $m$.
The rows on the chessboard are numbered from $1$ to $n$ from bottom to top. The columns are numbered from $1$ to $m$ from left to right. Therefore, each cell can be specified with the coordinates $(x,y)$, where $x$ is the column n... | 0 |
{"tests": "{\"inputs\": [\"1 5000 1\\n1 1000000 1000000\\n\", \"999999 1000000 1\\n1 1000000 1000000\\n\", \"447 74474 4\\n47 777474 747\\n74 744744 74477\\n477 477447 777\\n7 477777 444444\\n\", \"1 1 4\\n1 1000000 1000000\\n1 1 1000000\\n1 1000000 1\\n1 1 1\\n\", \"1000000 1000000 1\\n1000000 1000000 1000000\\n\", \"... | Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs.
<image>
Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is ... | 0 |
{"tests": "{\"inputs\": [\"42 28\\n7 19\\n15 24\\n3 42\\n18 5\\n32 27\\n26 20\\n40 30\\n35 2\\n14 8\\n22 10\\n36 4\\n16 14\\n21 29\\n37 40\\n2 12\\n30 21\\n19 17\\n39 34\\n31 28\\n20 3\\n4 33\\n11 42\\n26 21\\n9 10\\n4 32\\n6 1\\n1 14\\n14 12\\n\", \"2 2\\n1 2\\n2 1\\n\", \"3 2\\n3 2\\n2 1\\n\", \"3 3\\n1 3\\n2 1\\n3 2... | Hexadecimal likes drawing. She has drawn many graphs already, both directed and not. Recently she has started to work on a still-life «interesting graph and apples». An undirected graph is called interesting, if each of its vertices belongs to one cycle only — a funny ring — and does not belong to any other cycles. A f... | 0 |
{"tests": "{\"inputs\": [[3, 3, 1], [3, 3, 3], [3, 3, 2], [7, 7, 3], [3, 3, 0], [3, 3, 10], [2, 2, 1], [2, 2, 0], [200, 2, 1], [2, 200, 1]], \"outputs\": [[4], [2], [0], [6], [8], [0], [2], [4], [200], [200]]}", "source": "taco"} | This is the simple version of Shortest Code series. If you need some challenges, please try the [challenge version](http://www.codewars.com/kata/570f45fab29c705d330004e3)
## Task:
There is a rectangular land and we need to plant trees on the edges of that land.
I will give you three parameters:
```width``` and ```l... | 0 |
{"tests": "{\"inputs\": [\"2 3\\n\", \"10 100\\n\", \"1 1000000000000000000\\n\", \"1 1\\n\", \"1 2\\n\", \"1 999999999999999999\\n\", \"2 2\\n\", \"2 999999999999999999\\n\", \"2 1000000000000000000\\n\", \"1 576460752303423487\\n\", \"1 576460752303423488\\n\", \"576460752303423487 576460752303423488\\n\", \"57646075... | Given are integers L and R. Find the number, modulo 10^9 + 7, of pairs of integers (x, y) (L \leq x \leq y \leq R) such that the remainder when y is divided by x is equal to y \mbox{ XOR } x.What is \mbox{ XOR }?
The XOR of integers A and B, A \mbox{ XOR } B, is defined as follows:
- When A \mbox{ XOR } B is written... | 0 |
{"tests": "{\"inputs\": [\"5\\n01\\n10\\n101\\n11111\\n0\\n3\\n1 2\\n6 5\\n4 4\\n\", \"5\\n01\\n1\\n0011\\n0\\n01\\n6\\n5 5\\n3 2\\n4 2\\n6 7\\n5 1\\n9 7\\n\", \"5\\n111101000111100011100110000100\\n000111001\\n01101000\\n0000110100100010011001000000010100100111110110\\n0110001\\n10\\n5 5\\n2 2\\n5 6\\n1 1\\n1 7\\n10 6... | You are given n strings s_1, s_2, ..., s_{n} consisting of characters 0 and 1. m operations are performed, on each of them you concatenate two existing strings into a new one. On the i-th operation the concatenation s_{a}_{i}s_{b}_{i} is saved into a new string s_{n} + i (the operations are numbered starting from 1). A... | 0 |
{"tests": "{\"inputs\": [\"1\\n270983380\\n\", \"1\\n877739788\\n\", \"100\\n44 188 149 152 200 131 152 1 15 101 15 64 51 48 5 189 65 105 90 143 60 54 82 149 66 89 191 182 46 92 51 19 77 88 175 192 89 4 135 126 89 68 116 92 159 71 160 97 200 89 109 100 120 95 183 85 187 125 93 65 101 51 172 65 195 4 108 123 152 30 9 88... | Mojtaba and Arpa are playing a game. They have a list of n numbers in the game.
In a player's turn, he chooses a number pk (where p is a prime number and k is a positive integer) such that pk divides at least one number in the list. For each number in the list divisible by pk, call it x, the player will delete x and a... | 0 |
{"tests": "{\"inputs\": [[[\"OXOOOX\", \"OXOXOO\", \"XXOOOX\", \"OXXXOO\", \"OOXOOX\", \"OXOOOO\", \"OOXOOX\", \"OOXOOO\", \"OXOOOO\", \"OXOOXX\"]], [[\"OXOOO\", \"OOXXX\", \"OXXOO\", \"XOOOO\", \"XOOOO\", \"XXXOO\", \"XOXOO\", \"OOOXO\", \"OXOOX\", \"XOOOO\", \"OOOXO\"]], [[\"XXXXXOOO\", \"OOXOOOOO\", \"OOOOOOXO\", \"... | Task:
Given an array arr of strings complete the function landPerimeter by calculating the total perimeter of all the islands. Each piece of land will be marked with 'X' while the water fields are represented as 'O'. Consider each tile being a perfect 1 x 1piece of land. Some examples for better visualization:
['XOOXO... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 3\\n5 7\\n1 3\\n\", \"3\\n2 5\\n4 6\\n1 4\\n\", \"5\\n999999999 1000000000\\n1 2\\n314 315\\n500000 500001\\n999999999 1000000000\\n\", \"5\\n123456 789012\\n123 456\\n12 345678901\\n123456 789012\\n1 23\\n\", \"1\\n1 400\\n\", \"3\\n2 5\\n4 6\\n2 4\", \"5\\n123456 789012\\n17 456\\n12 ... | AtCoDeer the deer found N rectangle lying on the table, each with height 1.
If we consider the surface of the desk as a two-dimensional plane, the i-th rectangle i(1≤i≤N) covers the vertical range of [i-1,i] and the horizontal range of [l_i,r_i], as shown in the following figure:
AtCoDeer will move these rectangles ho... | 0 |
{"tests": "{\"inputs\": [\"1 1 1 1 1 1\\n1 1 1 0 0 0\\n1 0 0 0 1 0\\n3 0 0 3 0 0\\n3 1 0 1 3 1\\n1 2 0 2 0 1\\n0 0 1 1 0 3\\n1 0 0 1 1 0\\n0 0 0 0 0 0\", \"1 1 1 1 1 1\\n1 1 1 0 0 0\\n1 0 0 0 1 0\\n3 0 0 0 0 0\\n3 1 0 1 3 1\\n1 2 0 2 0 1\\n0 0 1 1 0 3\\n1 0 0 1 1 0\\n0 0 0 0 0 0\", \"1 1 1 1 1 1\\n1 1 1 0 0 0\\n1 0 0 0... | Currently, people's entertainment is limited to programming contests. The activity of the entertainment club of a junior high school to which she belongs is to plan and run a programming contest. Her job is not to create problems. It's a behind-the-scenes job of soliciting issues from many, organizing referees, and pro... | 0 |
{"tests": "{\"inputs\": [[1984], [2000], [2004], [8], [0], [1234], [1100], [1194]], \"outputs\": [[true], [true], [true], [true], [true], [false], [false], [false]]}", "source": "taco"} | In this kata you should simply determine, whether a given year is a leap year or not. In case you don't know the rules, here they are:
* years divisible by 4 are leap years
* but years divisible by 100 are **not** leap years
* but years divisible by 400 are leap years
Additional Notes:
* Only valid years (positive i... | 0 |
{"tests": "{\"inputs\": [\"4\\nA\\nB\\nB\\nA\\n\", \"1000\\nB\\nB\\nB\\nB\\n\", \"2\\nB\\nA\\nA\\nA\\n\", \"2\\nA\\nB\\nA\\nA\\n\", \"2\\nB\\nB\\nA\\nA\\n\", \"2\\nA\\nA\\nB\\nA\\n\", \"2\\nB\\nA\\nB\\nA\\n\", \"2\\nA\\nB\\nB\\nA\\n\", \"2\\nB\\nB\\nB\\nA\\n\", \"2\\nA\\nA\\nA\\nB\\n\", \"2\\nB\\nA\\nA\\nB\\n\", \"2\\n... | Given are an integer N and four characters c_{\mathrm{AA}}, c_{\mathrm{AB}}, c_{\mathrm{BA}}, and c_{\mathrm{BB}}.
Here, it is guaranteed that each of those four characters is A or B.
Snuke has a string s, which is initially AB.
Let |s| denote the length of s.
Snuke can do the four kinds of operations below zero or mor... | 0 |
{"tests": "{\"inputs\": [\"30\\n000100000100000110000000001100\\n\", \"6\\n314159\\n\", \"3\\n000\\n\", \"15\\n522085220852208\\n\", \"300\\n51849955123882532841766314023795544655059625429948511546532555041357758442089311502553567597180892645169105593021958599780734407001184543473352601711893354858975964992001656857820... | n evenly spaced points have been marked around the edge of a circle. There is a number written at each point. You choose a positive real number k. Then you may repeatedly select a set of 2 or more points which are evenly spaced, and either increase all numbers at points in the set by k or decrease all numbers at points... | 0 |
{"tests": "{\"inputs\": [\"54\\n0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 20 13 14 14 15 15 15 16 16 16 17 17 17\", \"6\\n0 1 2 0 3 4\", \"6\\n0 1 1 3 4 5\", \"54\\n0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 9 13 14 14 ... | N people are standing in a queue, numbered 1, 2, 3, ..., N from front to back. Each person wears a hat, which is red, blue, or green.
The person numbered i says:
* "In front of me, exactly A_i people are wearing hats with the same color as mine."
Assuming that all these statements are correct, find the number of p... | 0.375 |
{"tests": "{\"inputs\": [\"3\\n4 2\\n1 13 7 17\\n1 3\\n6 2\\n10 10 10 10 11 11\\n3 3\\n4 4\\n1000000000 1000000000 1000000000 1000000000\\n1 1 1 1\\n\", \"3\\n4 2\\n1 13 7 0\\n1 3\\n6 2\\n10 10 10 10 11 11\\n3 3\\n4 4\\n1000000000 1000000000 1000000000 1000000000\\n1 1 1 1\\n\", \"3\\n4 2\\n1 13 7 1\\n1 3\\n6 2\\n10 10... | Lee just became Master in Codeforces, and so, he went out to buy some gifts for his friends. He bought $n$ integers, now it's time to distribute them between his friends rationally...
Lee has $n$ integers $a_1, a_2, \ldots, a_n$ in his backpack and he has $k$ friends. Lee would like to distribute all integers in his b... | 0 |
{"tests": "{\"inputs\": [[100000, 1, 2000, 15, 1], [100000, 1, 9185, 12, 1], [100000000, 1, 100000, 50, 1], [100000000, 1.5, 10000000, 50, 1], [100000000, 5, 1000000, 50, 1], [9999, 61.8161, 10000.0, 3, 0], [9998.5, 61.8155, 10000.0, 3, 0], [10000.0, 0, 10000.0, 2, 0], [999.5, 61.87, 1000.0, 3, 0]], \"outputs\": [[true... | John has some amount of money of which he wants to deposit a part `f0` to the bank at the beginning
of year `1`. He wants to withdraw each year for his living an amount `c0`.
Here is his banker plan:
- deposit `f0` at beginning of year 1
- his bank account has an interest rate of `p` percent per year, constant over t... | 0 |
{"tests": "{\"inputs\": [\"203 30\\n-3 3\\n-3 10\\n-7 -6\\n1 8\\n-5 2\\n-9 10\\n-6 4\\n8 2\\n-2 -5\\n-3 2\\n1 6\\n-6 -9\\n10 9\\n-3 -9\\n-7 5\\n3 8\\n1 -4\\n-4 -5\\n-2 1\\n-6 -10\\n10 10\\n4 -1\\n0 -2\\n9 9\\n-5 6\\n-9 -5\\n7 -10\\n-6 3\\n-3 -4\\n9 -4\\n\", \"25965 53\\n-1 -2\\n1 5\\n0 3\\n4 4\\n-3 -2\\n5 4\\n-3 -4\\n-... | It has been noted that if some ants are put in the junctions of the graphene integer lattice then they will act in the following fashion: every minute at each junction (x, y) containing at least four ants a group of four ants will be formed, and these four ants will scatter to the neighbouring junctions (x + 1, y), (x ... | 0 |
{"tests": "{\"inputs\": [\"5 5\\n1 2\\n1 3\\n3 4\\n3 5\\n4 5\\n\", \"5 1\\n1 2\\n\", \"4 3\\n1 2\\n1 3\\n2 3\\n\", \"10 39\\n7 2\\n7 1\\n5 6\\n5 8\\n9 10\\n2 8\\n8 7\\n3 10\\n10 1\\n8 10\\n2 3\\n7 4\\n3 9\\n4 10\\n3 4\\n6 1\\n6 7\\n9 5\\n9 7\\n6 9\\n9 4\\n4 6\\n7 5\\n8 3\\n2 5\\n9 2\\n10 7\\n8 6\\n8 9\\n7 3\\n5 3\\n4 5... | In the State of Takahashi in AtCoderian Federation, there are N cities, numbered 1, 2, ..., N.
M bidirectional roads connect these cities.
The i-th road connects City A_i and City B_i.
Every road connects two distinct cities.
Also, for any two cities, there is at most one road that directly connects them.
One day, it w... | 0 |
{"tests": "{\"inputs\": [\"150346839\", \"73\", \"3704579452095997258280591217784156184311155893966777597430447796450532\", \"19664274\", \"22\", \"4271374355872521214646189206931447259915557225329718337053006899386612\", \"4636365955583185577236629139430025754175155260406833067161877454344706\", \"2584175\", \"4450684... | We will call a non-negative integer increasing if, for any two adjacent digits in its decimal representation, the digit to the right is greater than or equal to the digit to the left. For example, 1558, 11, 3 and 0 are all increasing; 10 and 20170312 are not.
Snuke has an integer N. Find the minimum number of increasi... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.