info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [\"3 3\\n1 3\\n1 2\\n1 2 3\\n\", \"3 1\\n3 1\\n3 2\\n1 2 3\\n\", \"4 3\\n1 2\\n1 3\\n3 4\\n1000000000 999999999 0 1\\n\", \"3 20\\n1 2\\n1 3\\n1 2 3\\n\", \"6 1\\n1 2\\n1 3\\n3 4\\n2 5\\n5 6\\n1 3 3 4 5 0\\n\", \"3 3\\n1 3\\n1 2\\n1 3 3\\n\", \"6 1\\n1 2\\n1 3\\n3 4\\n2 5\\n5 6\\n1 3 3 0 5 0\\n\... | Alice and Bob are going to celebrate Christmas by playing a game with a tree of presents. The tree has n nodes (numbered 1 to n, with some node r as its root). There are a_i presents are hanging from the i-th node.
Before beginning the game, a special integer k is chosen. The game proceeds as follows:
* Alice begin... | 0 |
{"tests": "{\"inputs\": [\"2\\n2 2\\n1.0000 1.0000\\n0.0000 0.0000\\n2 3\\n0.5000 0.5000 0.5000\\n0.5000 0.5000 0.5000 \", \"2\\n2 2\\n1.0000 1.0000\\n0.0000 0.0000\\n2 3\\n1.2649803683768097 0.5000 0.5000\\n0.5000 0.5000 0.5000\", \"2\\n2 2\\n1.0000 1.7642945663583927\\n0.0000 0.0000\\n2 3\\n0.5000 0.5000 0.5000\\n0.5... | Read problems statements in Mandarin Chinese and Russian.
Sereja is playing a game called Winner Eats Sandwich with his friends. There are N persons in total, including Sereja. Sereja is allotted the number 1, while his friends are allotted numbers from 2 to N. A set of this game consists of M parts. Probability that... | 0.375 |
{"tests": "{\"inputs\": [\"8 2\\n4 1 4 3 1 2 3 4\", \"8 2\\n4 1 2 3 1 2 3 6\", \"3 1\\n3 3 1\", \"4 4\\n1 1 2 2\", \"8 1\\n-1 1 4 5 1 1 5 4\", \"8 1\\n4 1 2 3 2 2 4 7\", \"8 1\\n4 1 3 3 2 2 4 5\", \"8 1\\n3 1 2 2 2 1 2 4\", \"3 1\\n2 1 1\", \"8 2\\n4 1 4 3 1 2 1 4\", \"8 2\\n4 1 4 3 1 4 1 4\", \"8 3\\n4 1 4 3 1 4 1 4\"... | There are N towns in Snuke Kingdom, conveniently numbered 1 through N. Town 1 is the capital.
Each town in the kingdom has a Teleporter, a facility that instantly transports a person to another place. The destination of the Teleporter of town i is town a_i (1≤a_i≤N). It is guaranteed that one can get to the capital fr... | 0 |
{"tests": "{\"inputs\": [\"10\\n31181 6 72281 7\\n65255 10 17867 2\\n96212 8 32852 10\\n69668 6 37236 1\\n6031 7 61541 0\\n12286 4 40227 2\\n30573 9 36317 3\\n97429 6 35399 9\\n20907 5 19251 8\\n86446 8 56301 10\\n\", \"10\\n1000000000 0 1000000000 0\\n1000000000 0 1000000000 0\\n1000000000 0 1000000000 0\\n1000000000 ... | Alice and Bonnie are sisters, but they don't like each other very much. So when some old family photos were found in the attic, they started to argue about who should receive which photos. In the end, they decided that they would take turns picking photos. Alice goes first.
There are n stacks of photos. Each stack con... | 0 |
{"tests": "{\"inputs\": [[\"K\", 200, 10], [\"M\", 0, 10], [\"M\", -5, 10], [\"F\", 160, 0], [\"F\", 160, -10], [\",\", 0, 1100], [\"??\", -10, -10], [\"llama\", 1, -10], [\"F\", -461.9, 0.0], [\"M\", 250, 5], [\"F\", 190, 8], [\"M\", 405, 12], [\"F\", 130, 7]], \"outputs\": [[\"Invalid gender\"], [\"Invalid weight\"],... | ###BACKGROUND:
Jacob recently decided to get healthy and lose some weight. He did a lot of reading and research and after focusing on steady exercise and a healthy diet for several months, was able to shed over 50 pounds! Now he wants to share his success, and has decided to tell his friends and family how much weight ... | 0 |
{"tests": "{\"inputs\": [\"3\\n\", \"4\\n\", \"10\\n\", \"1\\n\", \"2\\n\", \"5\\n\", \"1248\\n\", \"1000000\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"11\\n\", \"12\\n\", \"13\\n\", \"14\\n\", \"15\\n\", \"16\\n\", \"17\\n\", \"18\\n\", \"19\\n\", \"20\\n\", \"623847\\n\", \"771623\\n\", \"324\\n\", \"98232\\n\",... | Let $n$ be an integer. Consider all permutations on integers $1$ to $n$ in lexicographic order, and concatenate them into one big sequence $p$. For example, if $n = 3$, then $p = [1, 2, 3, 1, 3, 2, 2, 1, 3, 2, 3, 1, 3, 1, 2, 3, 2, 1]$. The length of this sequence will be $n \cdot n!$.
Let $1 \leq i \leq j \leq n \cdot... | 0 |
{"tests": "{\"inputs\": [[[]], [[\"e3\", \"e6\", \"d3\", \"g6\"]], [[\"d3\", \"e5\", \"d4\", \"f5\"]], [[\"d3\", \"e5\", \"d4\", \"f5\", \"dxe5\", \"f4\"]], [[\"d4\", \"f6\", \"d5\", \"f6\", \"dxe5\", \"f4\"]], [[\"d4\", \"a5\", \"d5\", \"f6\", \"dxe7\", \"f4\"]], [[\"a4\", \"a5\", \"b4\", \"b5\", \"c4\", \"b4\"]], [[\... | A chess board is normally played with 16 pawns and 16 other pieces, for this kata a variant will be played with only the pawns. All other pieces will not be on the board.
For information on how pawns move, refer [here](http://www.chesscorner.com/tutorial/basic/pawn/pawn.htm)
Write a function that can turn a li... | 0 |
{"tests": "{\"inputs\": [\"5 30\\n13 51 32 9 2 1 10 2 5 10\", \"1 10\\n1 2 3 4 7 6 7 8 9 10\", \"5 100\\n101 101 101 101 101 101 101 101 100 101\", \"5 10\\n8 4 5 3 5 6 9 10 11 2\", \"5 35\\n13 51 32 14 2 1 10 2 5 10\", \"7 35\\n13 51 32 14 2 1 10 2 5 10\", \"7 35\\n13 51 1 14 2 1 10 2 5 10\", \"5 30\\n25 51 32 9 2 1 1... | Hint
In solving this problem, the following may be referred to. Shows how to convert an integer value to a string. Assign value as a string to str.
For C
include <stdio.h>
int main () {
int value = 123; // Convert this value to a string
char str [6]; // This variable contains a string of value
sprintf (str, "% d",... | 0.5 |
{"tests": "{\"inputs\": [\"3 3\\n1 2 3\", \"10 6\\n1 8 4 9 2 3 7 10 5 6\", \"3 2\\n2 1 3\", \"10 5\\n1 8 4 9 2 3 7 10 5 6\", \"10 7\\n1 8 4 9 2 3 7 10 5 6\", \"3 2\\n2 3 1\", \"10 8\\n1 8 4 9 2 3 7 10 5 6\", \"10 4\\n1 8 4 9 2 3 7 10 5 6\", \"3 3\\n1 2 2\", \"3 3\\n1 2 1\", \"3 3\\n1 3 3\", \"3 3\\n2 3 3\", \"3 3\\n2 3... | Given are a permutation p_1, p_2, \dots, p_N of (1, 2, ..., N) and an integer K. Maroon performs the following operation for i = 1, 2, \dots, N - K + 1 in this order:
* Shuffle p_i, p_{i + 1}, \dots, p_{i + K - 1} uniformly randomly.
Find the expected value of the inversion number of the sequence after all the oper... | 0 |
{"tests": "{\"inputs\": [\"2 3 2\\n2 1\\n1 2 3\\n1 2 2\\n2 2 1\\n\", \"4 5 3\\n1 2 3\\n1 2 5\\n4 2 1\\n2 3 2\\n1 4 4\\n1 3 3\\n\", \"5 7 4\\n1 2 3 4\\n1 2 3\\n5 1 4\\n3 1 1\\n4 2 5\\n2 5 6\\n2 3 3\\n3 4 6\\n\", \"2 1 2\\n1 2\\n1 2 1000000000\\n\", \"3 2 2\\n2 3\\n1 2 2\\n2 3 1\\n\", \"3 2 2\\n2 3\\n1 2 5\\n2 3 1\\n\", ... | Chouti was tired of the tedious homework, so he opened up an old programming problem he created years ago.
You are given a connected undirected graph with $n$ vertices and $m$ weighted edges. There are $k$ special vertices: $x_1, x_2, \ldots, x_k$.
Let's define the cost of the path as the maximum weight of the edges ... | 0.875 |
{"tests": "{\"inputs\": [\"25 2\\n1 23\\n3 1\\n\", \"1000000000 3\\n30490 19232\\n45250 999980767\\n264372930 1\\n\", \"999999999 1\\n999999999 999999999\\n\", \"1000000000 1\\n1 1000000000\\n\", \"1 1\\n1 1\\n\", \"1001 1\\n60 10001\\n\", \"999999999 1\\n100 1000000000\\n\", \"300 4\\n1 200\\n2 200\\n50 100\\n70 100\\... | A famous gang of pirates, Sea Dogs, has come back to their hideout from one of their extravagant plunders. They want to split their treasure fairly amongst themselves, that is why You, their trusted financial advisor, devised a game to help them:
All of them take a sit at their round table, some of them with the golde... | 0 |
{"tests": "{\"inputs\": [\"010\\n\", \"100000000\\n\", \"00001111\\n\", \"100000010\", \"011\", \"00001101\", \"111\", \"00011101\", \"100000101\", \"11111111\", \"000000000\", \"100000011\", \"100001011\", \"101\", \"10011101\", \"100101011\", \"001\", \"00011001\", \"100001111\", \"000\", \"10011001\", \"100001101\",... | You are given a string S consisting of 0 and 1.
Find the maximum integer K not greater than |S| such that we can turn all the characters of S into 0 by repeating the following operation some number of times.
- Choose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\geq K must be satisfied). F... | 0 |
{"tests": "{\"inputs\": [\"5 2 6\\n5 2 1 4 2\\n\", \"5 1 4\\n4 2 3 4 1\\n\", \"5 3 3\\n1 2 3 1 1\\n\", \"5 4 2\\n1 2 1 2 1\\n\", \"1 1 1\\n1\\n\", \"5 5 5\\n5 5 5 5 5\\n\", \"5 4 2\\n1 2 1 2 1\\n\", \"5 5 5\\n5 5 5 5 5\\n\", \"1 1 1\\n1\\n\", \"5 4 2\\n1 2 2 2 1\\n\", \"1 1 1\\n0\\n\", \"5 3 3\\n1 2 3 1 2\\n\", \"5 3 3... | Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | 0 |
{"tests": "{\"inputs\": [\"3\\nAND 2 3\\nIN 1\\nIN 0\\n\", \"3\\nOR 2 3\\nIN 1\\nIN 1\\n\", \"40\\nOR 9 2\\nAND 30 31\\nIN 1\\nIN 1\\nIN 0\\nOR 25 21\\nIN 1\\nXOR 20 10\\nAND 24 34\\nIN 0\\nIN 0\\nNOT 16\\nAND 14 4\\nIN 0\\nAND 18 27\\nIN 1\\nAND 15 22\\nOR 26 12\\nIN 1\\nAND 36 3\\nXOR 11 38\\nIN 1\\nIN 1\\nNOT 29\\nI... | 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, whi... | 0.5 |
{"tests": "{\"inputs\": [[\"red\", \"bumpy\"], [\"green\", \"bumpy\"], [\"yellow\", \"smooth\"], [\"red\", \"smooth\"], [\"green\", \"smooth\"], [\"yellow\", \"bumpy\"]], \"outputs\": [[\"0.57\"], [\"0.14\"], [\"0.33\"], [\"0.33\"], [\"0.33\"], [\"0.28\"]]}", "source": "taco"} | You're playing a game with a friend involving a bag of marbles. In the bag are ten marbles:
* 1 smooth red marble
* 4 bumpy red marbles
* 2 bumpy yellow marbles
* 1 smooth yellow marble
* 1 bumpy green marble
* 1 smooth green marble
You can see that the probability of picking a smooth red marble from the bag is `1 / ... | 0.5 |
{"tests": "{\"inputs\": [\"3\\n1 2 3\\n\", \"3\\n2 3 1\\n\", \"3\\n3 2 1\\n\", \"2\\n1 2\\n\", \"2\\n2 1\\n\", \"10\\n10 1 9 2 8 3 7 4 6 5\\n\", \"108\\n1 102 33 99 6 83 4 20 61 100 76 71 44 9 24 87 57 2 81 82 90 85 12 30 66 53 47 36 43 29 31 64 96 84 77 23 93 78 58 68 42 55 13 70 62 19 92 14 10 65 63 75 91 48 11 105 3... | Some time ago Mister B detected a strange signal from the space, which he started to study.
After some transformation the signal turned out to be a permutation p of length n or its cyclic shift. For the further investigation Mister B need some basis, that's why he decided to choose cyclic shift of this permutation whi... | 0.625 |
{"tests": "{\"inputs\": [\"3\\n3 3 3\\n\", \"5\\n5 4 5 4 4\\n\", \"28\\n2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033\\n\", \"7\\n10 10 10 10 10 10 10\\n\", \"28\\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 10... | Stepan has n pens. Every day he uses them, and on the i-th day he uses the pen number i. On the (n + 1)-th day again he uses the pen number 1, on the (n + 2)-th — he uses the pen number 2 and so on.
On every working day (from Monday to Saturday, inclusive) Stepan spends exactly 1 milliliter of ink of the pen he uses t... | 0 |
{"tests": "{\"inputs\": [\"2\\n2 1\\n1 2\\n\", \"2\\n1 4\\n2 1\\n\", \"10\\n46 -55\\n46 45\\n46 45\\n83 -55\\n46 45\\n83 -55\\n46 45\\n83 45\\n83 45\\n46 -55\\n\", \"2\\n1 1000000000\\n2 -1000000000\\n\", \"1\\n-5 -90\\n\", \"2\\n1000000000 0\\n-7 1\\n\", \"2\\n1 0\\n0 2333333\\n\", \"2\\n-1 1000000000\\n0 -1\\n\", \"2... | Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. There are n watchmen on a plane, the i-th watchman is located at point (xi, yi).
They need to arrange a plan, but there are some difficulties on their way. As you know, Doctor Manhattan consider... | 0.75 |
{"tests": "{\"inputs\": [\"20 4 5 2\\n\", \"30 9 4 1\\n\", \"2 2 1 1\\n\", \"42 20 5 29\\n\", \"1000000000000000000 135 1000000000000000 1000\\n\", \"100 33 100 100\\n\", \"1000000000 1000000000 1000000000 1000\\n\", \"1000000000 32428 1000000000 1000\\n\", \"1000000000 324934 1000 1000\\n\", \"1000000000000000000 3240... | $k$ people want to split $n$ candies between them. Each candy should be given to exactly one of them or be thrown away.
The people are numbered from $1$ to $k$, and Arkady is the first of them. To split the candies, Arkady will choose an integer $x$ and then give the first $x$ candies to himself, the next $x$ candies ... | 0 |
{"tests": "{\"inputs\": [\"4\\n2 4\\n4 3\\n3 0\\n1 3\\n\", \"3\\n0 0\\n0 2\\n2 0\\n\", \"8\\n0 3\\n2 2\\n3 0\\n2 -2\\n0 -3\\n-2 -2\\n-3 0\\n-2 2\\n\", \"4\\n-100000000 -100000000\\n-100000000 100000000\\n100000000 100000000\\n100000000 -100000000\\n\", \"4\\n0 0\\n10 10\\n10 9\\n1 0\\n\", \"4\\n12345678 99999999\\n1234... | You are given $n$ points on the plane. The polygon formed from all the $n$ points is strictly convex, that is, the polygon is convex, and there are no three collinear points (i.e. lying in the same straight line). The points are numbered from $1$ to $n$, in clockwise order.
We define the distance between two points $p... | 0 |
{"tests": "{\"inputs\": [[15], [393], [31133], [4], [100], [594], [1500]], \"outputs\": [[[]], [[]], [[]], [[\"2+2\"]], [[\"3+97\", \"11+89\", \"17+83\", \"29+71\", \"41+59\", \"47+53\"]], [[\"7+587\", \"17+577\", \"23+571\", \"31+563\", \"37+557\", \"47+547\", \"53+541\", \"71+523\", \"73+521\", \"103+491\", \"107+487... | German mathematician Christian Goldbach (1690-1764) [conjectured](https://en.wikipedia.org/wiki/Goldbach%27s_conjecture) that every even number greater than 2 can be represented by the sum of two prime numbers. For example, `10` can be represented as `3+7` or `5+5`.
Your job is to make the function return a list conta... | 0 |
{"tests": "{\"inputs\": [\"4\\n2\\n1 7\\n3\\n1 5 4\\n4\\n12345678 87654321 20211218 23571113\\n9\\n1 2 3 4 18 19 5 6 7\\n\", \"8\\n2\\n2 3\\n3\\n3 4 5\\n1\\n1\\n1\\n2\\n1\\n3\\n1\\n4\\n1\\n12071207\\n5\\n5 5 5 9 14\\n\", \"8\\n2\\n2 3\\n3\\n3 4 5\\n1\\n1\\n1\\n2\\n1\\n3\\n1\\n4\\n1\\n12071207\\n5\\n5 5 5 9 14\\n\", \"8... | Paprika loves permutations. She has an array $a_1, a_2, \dots, a_n$. She wants to make the array a permutation of integers $1$ to $n$.
In order to achieve this goal, she can perform operations on the array. In each operation she can choose two integers $i$ ($1 \le i \le n$) and $x$ ($x > 0$), then perform $a_i := a_i ... | 0 |
{"tests": "{\"inputs\": [\"17\\n0 0\\n0 8\\n1 8\\n36 39\\n3 4\\n3 7\\n2 17\\n8 12\\n9 12\\n10 12\\n10 15\\n6 14\\n8 15\\n9 15\\n15 15\\n100000000000000000 1000000000000000000\\n99999999999999999 1000000000000000000\\n\", \"55\\n1 1\\n1 2\\n1 3\\n1 4\\n1 5\\n1 6\\n1 7\\n1 8\\n1 9\\n1 10\\n2 2\\n2 3\\n2 4\\n2 5\\n2 6\\n2... | Let's denote as <image> the number of bits set ('1' bits) in the binary representation of the non-negative integer x.
You are given multiple queries consisting of pairs of integers l and r. For each query, find the x, such that l ≤ x ≤ r, and <image> is maximum possible. If there are multiple such numbers find the sma... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 2 3 4\\n1 2 3 4\\n1 2 3 4\\n2 2 3 4\\n1 2 3 4\\n1 2 3 4\\n1 2 3 4\\n1 2 3 4\\noooo\\noooo\\noooo\\noooo\", \"3\\n1 1 1\\n1 1 1\\n1 1 1\\n1 1 1\\n1 0 1\\n1 1 1\\no..\\n.o.\\n..o\", \"3\\n1 1 1\\n1 1 1\\n1 1 1\\n0 1 1\\n1 1 1\\n1 1 1\\no.o\\n...\\n.o.\", \"3\\n1 0 1\\n1 2 1\\n1 0 1\\n-1 2... | Taro is an elementary school student and has graffiti on the back of the leaflet. At one point, Taro came up with the next game.
* Write n × n grid-like squares.
* The initial state of each square is either marked or unmarked.
* Erase or write these circles so that there is always exactly one circle no matter which co... | 0 |
{"tests": "{\"inputs\": [\"4\\n5\\n00100\\n8\\n00000000\\n5\\n11111\\n3\\n110\\n\", \"14\\n1\\n0\\n1\\n1\\n2\\n00\\n2\\n01\\n2\\n10\\n2\\n11\\n3\\n000\\n3\\n001\\n3\\n010\\n3\\n011\\n3\\n100\\n3\\n101\\n3\\n110\\n3\\n111\\n\", \"1\\n100\\n000000000000000000000000000000000000000000000000000000000000000000000000000000000... | Nikolay lives in a two-storied house. There are $n$ rooms on each floor, arranged in a row and numbered from one from left to right. So each room can be represented by the number of the floor and the number of the room on this floor (room number is an integer between $1$ and $n$).
If Nikolay is currently in some room... | 0 |
{"tests": "{\"inputs\": [\"2 1 1 1\\n1 1\\n0 0\\n1 3 2 1\\n2 1\\n2 1\\n0 0\\n10 8 3 2\\n2 2\\n1 2\\n1 1\\n0 1\\n3 4\\n3 3 3 2\\n1 2\\n2 1\\n1 1\\n0 1\\n0 0\\n0 0 0 0\", \"2 1 1 1\\n1 1\\n0 0\\n1 3 2 1\\n2 1\\n2 1\\n0 0\\n10 8 3 2\\n2 2\\n1 3\\n1 1\\n0 1\\n3 4\\n3 3 3 2\\n1 2\\n1 1\\n1 1\\n0 1\\n0 0\\n0 0 0 0\", \"2 1 1... | Origami, or the art of folding paper
Master Grus is a famous origami (paper folding) artist, who is enthusiastic about exploring the possibility of origami art. For future creation, he is now planning fundamental experiments to establish the general theory of origami.
One rectangular piece of paper is used in each of... | 0 |
{"tests": "{\"inputs\": [\"1 1 3 4\\n7\\n\", \"4 3 4 2\\n7 9 11\\n\", \"10 10 51 69\\n154 170 170 183 251 337 412 426 445 452\\n\", \"70 10 26 17\\n361 371 579 585 629 872 944 1017 1048 1541\\n\", \"100 20 49 52\\n224 380 690 1585 1830 1973 2490 2592 3240 3341 3406 3429 3549 3560 3895 3944 4344 4390 4649 4800\\n\", \"1... | There is an automatic door at the entrance of a factory. The door works in the following way: when one or several people come to the door and it is closed, the door immediately opens automatically and all people immediately come inside, when one or several people come to the door and it is open, all people immediatel... | 0 |
{"tests": "{\"inputs\": [\"2 100 50\\n\", \"100 821 25\\n\", \"2 10 10\\n\", \"10 72 17\\n\", \"100 100 5\\n\", \"10 1000 237\\n\", \"2 2 1\\n\", \"59 486 43\\n\", \"7 997 332\\n\", \"1 100 45\\n\", \"13 927 179\\n\", \"85 449 16\\n\", \"93 857 28\\n\", \"2 1000 500\\n\", \"23 100 12\\n\", \"3 2 1\\n\", \"2 20 10\\n\",... | Gerald is setting the New Year table. The table has the form of a circle; its radius equals R. Gerald invited many guests and is concerned whether the table has enough space for plates for all those guests. Consider all plates to be round and have the same radii that equal r. Each plate must be completely inside the ta... | 0.75 |
{"tests": "{\"inputs\": [[[7, 11]], [[1, 7, 15]], [[2, 10]], [[687, 829, 998]], [[]], [[1]]], \"outputs\": [[59], [0], [-1], [45664], [-1], [0]]}", "source": "taco"} | Story:
In the realm of numbers, the apocalypse has arrived. Hordes of zombie numbers have infiltrated and are ready to turn everything into undead. The properties of zombies are truly apocalyptic: they reproduce themselves unlimitedly and freely interact with each other. Anyone who equals them is doomed. Out of an infi... | 0 |
{"tests": "{\"inputs\": [\"106\\n\", \"1024\\n\", \"10460353208\\n\", \"748307129767950488\\n\", \"450283905890997368\\n\", \"298023223876953128\\n\", \"8\\n\", \"258489532\\n\", \"2541865828954\\n\", \"19073486347808\\n\", \"150094635296999246\\n\", \"61457664964242466\\n\", \"11920928955078134\\n\", \"1\\n\", \"2\\n\... | Given is an integer N.
Determine whether there is a pair of positive integers (A, B) such that 3^A + 5^B = N, and find one such pair if it exists.
-----Constraints-----
- 1 \leq N \leq 10^{18}
- All values in input are integers.
-----Input-----
Input is given from Standard Input in the following format:
N
-----Out... | 0.5 |
{"tests": "{\"inputs\": [\"4 5\\n1 3 0\\n2 4 0\\n2 3 1\\n4 2 1\\n4 4 1\", \"2 1\\n1 1 1\\n3 1 0\\n2 3 1\", \"2 0\\n1 1 0\\n3 1 0\\n2 3 1\", \"4 0\\n1 1 1\\n1 2 0\\n3 2 1\\n1 4 0\\n2 1 1\\n1 3 0\\n3 4 1\\n4 4 1\", \"3 0\\n1 1 1\\n5 1 0\\n2 6 2\", \"4 1\\n1 1 1\\n2 2 0\\n0 2 1\\n1 4 0\\n2 1 0\\n1 3 0\\n5 4 1\\n4 8 1\", \... | Takahashi has an N \times N grid. The square at the i-th row and the j-th column of the grid is denoted by (i,j). Particularly, the top-left square of the grid is (1,1), and the bottom-right square is (N,N).
An integer, 0 or 1, is written on M of the squares in the Takahashi's grid. Three integers a_i,b_i and c_i desc... | 0 |
{"tests": "{\"inputs\": [\"5R3D\", \"5D2R\", \"5T2D\", \"5D3R\", \"5U2D\", \"4D2R\", \"6T2D\", \"3R5D\", \"4R2D\", \"6D2T\", \"4R5D\", \"4R3D\", \"5D2T\", \"5U1D\", \"7T2D\", \"4D3R\", \"4R6D\", \"3R3D\", \"3D3R\", \"5R4D\", \"6R3D\", \"6U2D\", \"5D1T\", \"8T2D\", \"3R4D\", \"5T1D\", \"4U2D\", \"6D1T\", \"5U0D\", \"7D2... | A: Flick input
A college student who loves 2D, commonly known as 2D, replaced his long-used Galapagos mobile phone with a smartphone. 2D, who operated the smartphone for the first time, noticed that the character input method was a little different from that of old mobile phones. On smartphones, a method called flick ... | 0 |
{"tests": "{\"inputs\": [\"3 2 30 4\\n6 14 25 48\\n\", \"123 1 2143435 4\\n123 11 -5453 141245\\n\", \"123 1 2143435 4\\n54343 -13 6 124\\n\", \"3 2 25 2\\n379195692 -69874783\\n\", \"3 2 30 3\\n-691070108 -934106649 -220744807\\n\", \"3 3 104 17\\n9 -73896485 -290898562 5254410 409659728 -916522518 -435516126 94354167... | Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise.
You are given geometric progression b defined by two integers b_1 and q. Remind that a geometric progression is a sequence of integers b_1, b_2, b_3, ..., where for each i > 1 the respective term satisfies the condition b... | 0 |
{"tests": "{\"inputs\": [\"6\\n17236 1106911\\n1 5\\n108 112\\n12345 1023412\\n1 11\\n1 20\\n\", \"1\\n12 1034\\n\", \"1\\n1078 1112\\n\", \"1\\n12 1034\\n\", \"1\\n1078 1112\\n\", \"1\\n23 1034\\n\", \"1\\n1078 1547\\n\", \"6\\n17236 1106911\\n1 5\\n108 112\\n12345 799289\\n1 11\\n1 20\\n\", \"6\\n17236 1106911\\n1 5\... | Tanya is learning how to add numbers, but so far she is not doing it correctly. She is adding two numbers $a$ and $b$ using the following algorithm:
If one of the numbers is shorter than the other, Tanya adds leading zeros so that the numbers are the same length.
The numbers are processed from right to left (that is,... | 0 |
{"tests": "{\"inputs\": [\"nniinneetteeeenn\\n\", \"nneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\\n\", \"nineteenineteen\\n\", \"nssemsnnsitjtihtthij\\n\", \"eehihnttehtherjsihihnrhimihrjinjiehmtjimnrss\\n\", \"rrrteiehtesisntnjirtitijnjjjthrsmhtneirjimniemmnrhirssjnhetmnmjejjnjjritjttnnrhnjs\\n\", \"mmrehtrets... | Alice likes word "nineteen" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.
For example, if she has string "xiineteenppnnnewtnee", she can get string "xnineteenppnineteenw", containing (the occurrences marked) tw... | 0 |
{"tests": "{\"inputs\": [[\"hello\"], [\"abcdefghijklmnopqrstuvwxyz\"], [\"hellllllllllllooooo\"], [\"pixxa\"], [\"xpixax\"], [\"z\"]], \"outputs\": [[\"hIJKMNPQRSTUVWXYZeFGIJKMNPQRSTUVWXYZlMNPQRSTUVWXYZloPQRSTUVWXYZ\"], [\"abcdefghijklmnopqrstuvwxyz\"], [\"hIJKMNPQRSTUVWXYZeFGIJKMNPQRSTUVWXYZlMNPQRSTUVWXYZlllllllllllo... | You have to create a function,named `insertMissingLetters`, that takes in a `string` and outputs the same string processed in a particular way.
The function should insert **only after the first occurrence** of each character of the input string, all the **alphabet letters** that:
-**are NOT** in the original string ... | 0 |
{"tests": "{\"inputs\": [[[4, 4, 4, 3, 3], 12], [[4, 4, 4, 3, 3], 11], [[4, 8, 15, 16, 23, 42], 108], [[13], 13], [[1, 2, 3, 4], 250], [[100], 500], [[11, 13, 15, 17, 19], 8], [[45], 12]], \"outputs\": [[3], [2], [6], [1], [4], [1], [0], [0]]}", "source": "taco"} | Your task is to determine how many files of the copy queue you will be able to save into your Hard Disk Drive. The files must be saved in the order they appear in the queue.
### Input:
* Array of file sizes `(0 <= s <= 100)`
* Capacity of the HD `(0 <= c <= 500)`
### Output:
* Number of files that can be fully sav... | 0 |
{"tests": "{\"inputs\": [\"4\\n0 0 0 0 2\", \"3\\n0 1 1 1\", \"10\\n0 0 1 0 2 3 5 8 13 21 34\", \"2\\n0 3 2\", \"10\\n0 0 1 0 2 3 5 8 13 23 34\", \"10\\n0 0 1 0 3 3 5 8 13 23 34\", \"2\\n-1 3 2\", \"10\\n0 0 1 1 3 3 5 8 13 23 34\", \"2\\n-2 3 2\", \"4\\n0 1 0 1 2\", \"10\\n0 0 1 1 3 3 4 8 13 23 34\", \"4\\n0 1 0 1 3\",... | Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1.
Constraints
* 0 \leq N \... | 0 |
{"tests": "{\"inputs\": [\"1111\\n\", \"1110\\n\", \"1010\\n\", \"1011\", \"0111\", \"1000\", \"1100\", \"0011\", \"1001\", \"0100\", \"0110\", \"0001\", \"0101\", \"0010\", \"1101\", \"0000\", \"0111\", \"1011\", \"0010\", \"0101\", \"0011\", \"0000\", \"0100\", \"1001\", \"1100\", \"0110\", \"1101\", \"1000\", \"0001... | You are given a string s of length n.
Does a tree with n vertices that satisfies the following conditions exist?
- The vertices are numbered 1,2,..., n.
- The edges are numbered 1,2,..., n-1, and Edge i connects Vertex u_i and v_i.
- If the i-th character in s is 1, we can have a connected component of size i by rem... | 0.25 |
{"tests": "{\"inputs\": [\"5\\n\", \"12\\n\", \"999999\\n\", \"41\\n\", \"1000000\\n\", \"1\\n\", \"2\\n\", \"3\\n\", \"4\\n\", \"534204\\n\", \"469569\\n\", \"502877\\n\", \"942212\\n\", \"97\\n\", \"53\\n\", \"89\\n\", \"574\\n\", \"716\\n\", \"729\\n\", \"8901\\n\", \"3645\\n\", \"4426\\n\", \"46573\\n\", \"86380\\n... | An elephant decided to visit his friend. It turned out that the elephant's house is located at point 0 and his friend's house is located at point x(x > 0) of the coordinate line. In one step the elephant can move 1, 2, 3, 4 or 5 positions forward. Determine, what is the minimum number of steps he need to make in order ... | 0.125 |
{"tests": "{\"inputs\": [\"2\\n33 15 51 7 101\\n41 80 40 13 46\\n\", \"2\\n0 0 0 0 1\\n0 0 0 1 0\\n\", \"4\\n66 55 95 78 114\\n70 98 8 95 95\\n17 47 88 71 18\\n23 22 9 104 38\\n\", \"17\\n66 15 -1 42 90\\n67 108 104 16 110\\n76 -1 -1 -1 96\\n108 32 100 91 17\\n87 -1 85 10 -1\\n70 55 102 15 23\\n-1 33 111 105 63\\n-1 56... | Vasya and Petya take part in a Codeforces round. The round lasts for two hours and contains five problems.
For this round the dynamic problem scoring is used. If you were lucky not to participate in any Codeforces round with dynamic problem scoring, here is what it means. The maximum point value of the problem depends... | 0 |
{"tests": "{\"inputs\": [[121], [625], [319225], [15241383936], [155], [342786627]], \"outputs\": [[144], [676], [320356], [15241630849], [-1], [-1]]}", "source": "taco"} | You might know some pretty large perfect squares. But what about the NEXT one?
Complete the `findNextSquare` method that finds the next integral perfect square after the one passed as a parameter. Recall that an integral perfect square is an integer n such that sqrt(n) is also an integer.
If the parameter is itse... | 0.75 |
{"tests": "{\"inputs\": [\"8\\n71\\n34\\n65\\n11\\n41\\n39\\n3\\n5\\n4\\n67\\n81\\n78\\n65\\n0\", \"8\\n71\\n34\\n65\\n11\\n12\\n39\\n6\\n5\\n4\\n67\\n81\\n78\\n65\\n0\", \"8\\n71\\n34\\n65\\n0\\n41\\n39\\n3\\n5\\n4\\n67\\n81\\n78\\n65\\n0\", \"8\\n71\\n34\\n65\\n11\\n12\\n39\\n6\\n5\\n4\\n16\\n81\\n78\\n65\\n0\", \"8\... | Tsuruga Castle, a symbol of Aizuwakamatsu City, was named "Tsuruga Castle" after Gamo Ujisato built a full-scale castle tower. You can overlook the Aizu basin from the castle tower. On a clear day, you can see Tsuruga Castle from the summit of Mt. Iimori, which is famous for Byakkotai.
<image>
We decided to conduct... | 0 |
{"tests": "{\"inputs\": [\"10 5 5\\n2 3 4 5 6\\n\", \"1 1 1\\n1\\n\", \"1000000000000000000 10 68\\n9818112234872670 233245257111863071 266483628625876079 375103213040049805 431982380866113633 489732004669478331 501030096787260719 541800997319766183 551892546260532408 696178619227890200\\n\", \"1000000000000000000 2 1\... | Recently, Tokitsukaze found an interesting game. Tokitsukaze had n items at the beginning of this game. However, she thought there were too many items, so now she wants to discard m (1 ≤ m ≤ n) special items of them.
These n items are marked with indices from 1 to n. In the beginning, the item with index i is placed o... | 0 |
{"tests": "{\"inputs\": [\"1\\n12 12\\n#000#0#0##00\\n0##########0\\n0#0##0#0###0\\n00#0##000###\\n#0######0###\\n#0####0####0\\n#######000##\\n0##0#00#00##\\n##000##0####\\n0########00#\\n###000#000##\\n####00####0#\\n\", \"1\\n10 10\\n0####0###0\\n00#000##00\\n##0#0###00\\n0#0##00#00\\n####0###00\\n###00#0#0#\\n###00... | Omkar's most recent follower, Ajit, has entered the Holy Forest. Ajit realizes that Omkar's forest is an n by m grid (1 ≤ n, m ≤ 2000) of some non-negative integers. Since the forest is blessed by Omkar, it satisfies some special conditions:
1. For any two adjacent (sharing a side) cells, the absolute value of the d... | 0 |
{"tests": "{\"inputs\": [\"8\\n4 4 2\\n2 3 0\\n3 2 3\\n1 2 0\\n2 4 2\\n5 2 2\\n2 17 16\\n2 1 1\\n\", \"10\\n4 1 1\\n10 2 2\\n2 1 1\\n5 2 2\\n5 6 8\\n2 2 1\\n1 32 8\\n11 2 3\\n2 17 16\\n2 7 3\\n\", \"10\\n92 11 0\\n27 22 0\\n18 26 0\\n81 88 0\\n24 6 0\\n100 61 3050\\n48 9 216\\n20 32 320\\n82 64 2624\\n28 23 322\\n\", \... | The only difference between this problem and D2 is that you don't have to provide the way to construct the answer in this problem, but you have to do it in D2.
There's a table of $n \times m$ cells ($n$ rows and $m$ columns). The value of $n \cdot m$ is even.
A domino is a figure that consists of two cells having a c... | 0 |
{"tests": "{\"inputs\": [\"5\\n20 10 30 10 20\\n\", \"3\\n1 8 1\\n\", \"6\\n7 6 6 8 5 8\\n\", \"6\\n14 3 8 10 15 4\\n\", \"4\\n1 100 100 1\\n\", \"3\\n40 10 10\\n\", \"2\\n1000000 1000000\\n\", \"5\\n9 6 7 9 7\\n\", \"6\\n6 7 7 7 7 7\\n\", \"7\\n7 6 9 10 8 10 6\\n\", \"5\\n7 9 6 7 7\\n\", \"7\\n7 6 7 7 8 7 6\\n\", \"5\... | Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.
The wall consists of $n$ sections, aligned in a row. The $i$-th section initi... | 0 |
{"tests": "{\"inputs\": [\"4\\n0110\\n0010\\n0001\\n1000\\n4\\n1 2 3 4\\n\", \"4\\n0110\\n0010\\n1001\\n1000\\n20\\n1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4\\n\", \"3\\n011\\n101\\n110\\n7\\n1 2 3 1 3 2 1\\n\", \"4\\n0110\\n0001\\n0001\\n1000\\n3\\n1 2 4\\n\", \"2\\n01\\n00\\n2\\n1 2\\n\", \"16\\n0011101010011011\\n1001... | The main characters have been omitted to be short.
You are given a directed unweighted graph without loops with $n$ vertexes and a path in it (that path is not necessary simple) given by a sequence $p_1, p_2, \ldots, p_m$ of $m$ vertexes; for each $1 \leq i < m$ there is an arc from $p_i$ to $p_{i+1}$.
Define the seq... | 0 |
{"tests": "{\"inputs\": [[4, 5], [10, 7], [\"eight\", [3]], [12, -4], [0, 9], [123, 987]], \"outputs\": [[\"â– |â– â– |â– â– |â– â– |â– â– |â– \\nâ– â– |â– â– |â– â– |â– â– |â– â– \\nâ– |â– â– |â– â– |â– â– |â– â– |â– \\nâ– â– |â– â– |â– â– |â– â– |â– â– \"], [\"â– |â– â– |â– â– |â– â– |â– â– |â– â– |â– â– |â– \\nâ– â– |â– â– |â– â– |â– â– |â– â– |â– â– |â– â– \\nâ– |â– â– |â– â– |â– â– |â– â– |â– â– |â– â– |â– \\nâ– â– |â– â– |â– â– |â– â– |â– â– |â– â– |â– â– \\nâ– |â– â– |â– â– |â– â– |â– â– |â– â– |â– â– |â– \\nâ– â– |â– â– |â– â– |â– â– |â– â– |â– â– |â– ... | In this Kata you are a builder and you are assigned a job of building a wall with a specific size (God knows why...).
Create a function called `build_a_wall` (or `buildAWall` in JavaScript) that takes `x` and `y` as integer arguments (which represent the number of rows of bricks for the wall and the number of bricks i... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 2 3 4 5\\n00001\\n\", \"10\\n-10 -9 -8 -7 -6 6 7 8 9 10\\n0000111110\\n\", \"10\\n-8 -9 -9 -7 -10 -10 -8 -8 -9 -10\\n0000000011\\n\", \"11\\n226 226 226 226 226 227 1000000000 1000000000 228 1000000000 1000000000\\n00001111110\\n\", \"95\\n-97 -98 -92 -93 94 96 91 98 95 85 90 86 84 83 8... | "We've tried solitary confinement, waterboarding and listening to Just In Beaver, to no avail. We need something extreme."
"Little Alena got an array as a birthday present..."
The array b of length n is obtained from the array a of length n and two integers l and r (l ≤ r) using the following procedure:
b_1 = b_2 = ... | 0 |
{"tests": "{\"inputs\": [\"3 1\\n1 5 6\\n1 3\\n3\\n\", \"1 0\\n268435456\\n2 1\\n0 536870912\\n\", \"2 0\\n0 2\\n4 1000000000\\n0 2 4 6\\n\", \"5 999999999\\n999999996 999999997 999999998 999999999 1000000000\\n5 1000000000\\n999999996 999999997 999999998 999999999 1000000000\\n\", \"13 968288\\n0 67108864 134217728 20... | You are given a tube which is reflective inside represented as two non-coinciding, but parallel to $Ox$ lines. Each line has some special integer points — positions of sensors on sides of the tube.
You are going to emit a laser ray in the tube. To do so, you have to choose two integer points $A$ and $B$ on the first a... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 2\\n1 3\\n1 -1 1\\n\", \"5\\n2 3\\n4 5\\n2 5\\n1 3\\n0 2 1 4 3\\n\", \"10\\n5 6\\n8 2\\n9 3\\n4 1\\n6 10\\n9 8\\n7 10\\n7 4\\n5 2\\n0 -6 -9 -1 -5 -4 -2 -7 -8 -3\\n\", \"5\\n3 1\\n2 4\\n3 4\\n2 5\\n0 -3 -1 2 4\\n\", \"12\\n1 6\\n10 1\\n4 1\\n7 1\\n1 2\\n5 1\\n1 8\\n1 11\\n3 1\\n12 1\\n9 ... | A tree is a graph with n vertices and exactly n - 1 edges; this graph should meet the following condition: there exists exactly one shortest (by number of edges) path between any pair of its vertices.
A subtree of a tree T is a tree with both vertices and edges as subsets of vertices and edges of T.
You're given a tr... | 0 |
{"tests": "{\"inputs\": [\"11 3\\n1 1\\n1 1\\n1 1\\n1 1\\n2 2\\n2 2\\n2 2\\n3 3\\n3 3\\n3 3\\n3 3\\n\", \"43 1319\\n750 1030\\n857 946\\n941 1203\\n407 1034\\n947 1290\\n546 585\\n630 1201\\n72 342\\n693 1315\\n34 719\\n176 1097\\n36 931\\n198 973\\n5 1025\\n892 1054\\n461 1287\\n195 1273\\n832 1039\\n308 955\\n642 866... | Young Teodor enjoys drawing. His favourite hobby is drawing segments with integer borders inside his huge [1;m] segment. One day Teodor noticed that picture he just drawn has one interesting feature: there doesn't exist an integer point, that belongs each of segments in the picture. Having discovered this fact, Teodor ... | 0 |
{"tests": "{\"inputs\": [\"100 11 13\\n\", \"100 2 0\\n\", \"100 1 0\\n\", \"100 3 0\\n\", \"4 1 2\\n\", \"10 7 0\\n\", \"4 1 0\\n\", \"4 3 0\\n\", \"4 2 0\\n\", \"7 4 0\\n\", \"15 10 0\\n\", \"2 1 0\\n\", \"2 0 0\\n\", \"5 2 2\\n\", \"16 0 15\\n\", \"4 2 1\\n\", \"10 5 0\\n\", \"100 0 2\\n\", \"100 9 0\\n\", \"100 15 ... | «Next please», — the princess called and cast an estimating glance at the next groom.
The princess intends to choose the most worthy groom, this is, the richest one. Whenever she sees a groom who is more rich than each of the previous ones, she says a measured «Oh...». Whenever the groom is richer than all previous on... | 0 |
{"tests": "{\"inputs\": [\"1\\n2\\n0 0 1 1 1 2\\n3 0 0 4 4 7\", \"2\\n6\\n0 0 4 1 1 3\\n0 0 1 0 1 2\\n0 0 1 1 1 2\\n0 0 2 1 1 2\\n3 0 0 4 4 7\\n0 0 2 1 4 0\", \"1\\n2\\n0 1 1 1 1 2\\n3 0 0 4 4 7\", \"1\\n2\\n0 2 1 0 1 1\\n3 0 0 4 4 7\", \"1\\n1\\n0 2 1 0 1 1\\n3 0 0 4 4 7\", \"1\\n1\\n0 2 2 0 1 1\\n3 0 0 8 4 7\", \"1\\... | Read problems statements in Mandarin Chinese , Russian and Vietnamese as well.
Triangle classification is an important problem in modern mathematics. Mathematicians have developed many criteria according to which a triangle can be classified. In this problem, you will be asked to classify some triangles according to ... | 0.75 |
{"tests": "{\"inputs\": [\"5\\n3\\n0 1 3\\n7\\n0 1 2 3 4 3 2\\n4\\n3 0 0 0\\n7\\n4 6 2 3 5 0 5\\n5\\n4 0 1 0 4\\n\", \"5\\n3\\n0 1 3\\n7\\n0 1 2 3 4 3 2\\n4\\n3 0 0 0\\n7\\n4 6 2 3 6 0 5\\n5\\n4 0 1 0 4\\n\", \"5\\n3\\n0 1 3\\n7\\n0 1 2 3 4 3 2\\n4\\n3 0 0 0\\n7\\n4 0 2 3 5 0 5\\n5\\n4 0 1 0 4\\n\", \"5\\n3\\n0 1 3\\n7... | Dmitry has an array of $n$ non-negative integers $a_1, a_2, \dots, a_n$.
In one operation, Dmitry can choose any index $j$ ($1 \le j \le n$) and increase the value of the element $a_j$ by $1$. He can choose the same index $j$ multiple times.
For each $i$ from $0$ to $n$, determine whether Dmitry can make the $\mathrm... | 0 |
{"tests": "{\"inputs\": [\"25 6\\n1 10 5\\n1 8 4\\n1 8 2\\n4 8 9\\n3 2 8\\n1 9 5\\n2 10 10\\n3 9 6\\n3 5 4\\n2 7 8\\n2 3 2\\n2 6 8\\n3 7 8\\n4 3 7\\n1 8 1\\n3 6 4\\n3 2 8\\n2 2 1\\n4 8 8\\n4 8 4\\n3 10 2\\n3 6 6\\n2 2 5\\n1 6 2\\n4 1 5\\n\", \"3 5\\n6 4 5\\n6 5 5\\n8 7 5\\n\", \"2 9\\n6 1 7\\n6 7 1\\n\", \"2 10\\n7 2 1... | It's another Start[c]up finals, and that means there is pizza to order for the onsite contestants. There are only 2 types of pizza (obviously not, but let's just pretend for the sake of the problem), and all pizzas contain exactly S slices.
It is known that the i-th contestant will eat si slices of pizza, and gain ai ... | 0.25 |
{"tests": "{\"inputs\": [\"1\\n3 4\\n1 2 3\", \"1\\n3 4\\n0 2 3\", \"1\\n0 4\\n0 2 2\", \"1\\n0 8\\n0 2 0\", \"1\\n0 13\\n0 2 0\", \"1\\n0 13\\n0 4 -2\", \"1\\n3 1\\n1 2 3\", \"1\\n0 4\\n0 0 0\", \"1\\n0 8\\n0 3 0\", \"1\\n0 14\\n0 3 0\", \"1\\n0 2\\n0 2 -2\", \"1\\n0 5\\n1 4 -2\", \"1\\n0 26\\n0 7 -2\", \"1\\n0 26\\n0... | Read problems statements in Mandarin Chinese and Russian.
You have an array of integers A_{1}, A_{2}, ..., A_{N}. The function F(P), where P is a subset of A, is defined as the XOR (represented by the symbol ⊕) of all the integers present in the subset. If P is empty, then F(P)=0.
Given an integer K, what is the ma... | 0.75 |
{"tests": "{\"inputs\": [\"1\\n6\\n1\\n2 3\\n\", \"9\\n9999991 9999943 9999883 4658161 4657997 2315407 2315263 1000003 1000033\\n13\\n9999991 9999991\\n9999943 9999943\\n9999883 9999883\\n4658161 4658161\\n4657997 4657997\\n2315407 2315407\\n2315263 2315263\\n1000003 1000003\\n1000033 1000033\\n2 2000000000\\n200000000... | Recently, the bear started studying data structures and faced the following problem.
You are given a sequence of integers x1, x2, ..., xn of length n and m queries, each of them is characterized by two integers li, ri. Let's introduce f(p) to represent the number of such indexes k, that xk is divisible by p. The answe... | 0.5 |
{"tests": "{\"inputs\": [\"1 1000000000000000000\\n-1000 1000\\n1000 -1000\\n\", \"1 1\\n-1000 -1000\\n1000 1000\\n\", \"1 900000000000000001\\n-1000 -1000\\n-1000 -1000\\n\", \"1 1000000000000000000\\n-1000 1000\\n1001 -1000\\n\", \"1 1\\n-1000 -1000\\n1100 1000\\n\", \"1 900000000000000001\\n-1000 -1000\\n-802 -1000\... | You are given the following points with integer coordinates on the plane: M0, A0, A1, ..., An - 1, where n is odd number. Now we define the following infinite sequence of points Mi: Mi is symmetric to Mi - 1 according <image> (for every natural number i). Here point B is symmetric to A according M, if M is the center o... | 0.375 |
{"tests": "{\"inputs\": [\"9\\n8 6 4 2 1 4 7 10 2\\n\", \"9\\n-1 6 -1 2 -1 4 7 -1 2\\n\", \"5\\n-1 -1 -1 -1 -1\\n\", \"7\\n-1 -1 4 5 1 2 3\\n\", \"1\\n1\\n\", \"1\\n65\\n\", \"1\\n1000000000\\n\", \"1\\n-1\\n\", \"2\\n1000000000 1000000000\\n\", \"2\\n1000000000 -1\\n\", \"2\\n-1 1000000000\\n\", \"2\\n-1 -1\\n\", \"3\... | Polycarpus develops an interesting theory about the interrelation of arithmetic progressions with just everything in the world. His current idea is that the population of the capital of Berland changes over time like an arithmetic progression. Well, or like multiple arithmetic progressions.
Polycarpus believes that if... | 0 |
{"tests": "{\"inputs\": [\"3 4\\n\", \"3 5\\n\", \"42 1337\\n\", \"100000 200000\\n\", \"150000 200000\\n\", \"2 2\\n\", \"3 3\\n\", \"3 200000\\n\", \"200000 200000\\n\", \"20 20\\n\", \"2 3\\n\", \"1000 200000\\n\", \"2 10\\n\", \"3 3\\n\", \"20 20\\n\", \"3 200000\\n\", \"2 2\\n\", \"150000 200000\\n\", \"200000 200... | Your task is to calculate the number of arrays such that: each array contains $n$ elements; each element is an integer from $1$ to $m$; for each array, there is exactly one pair of equal elements; for each array $a$, there exists an index $i$ such that the array is strictly ascending before the $i$-th element and s... | 0 |
{"tests": "{\"inputs\": [\"-99 -91 523666385\\n\", \"1 -999999999 239239239\\n\", \"-1000000000000000000 -1000000000000000000 -999999999999999999\\n\", \"-100000000000000 1 233\\n\", \"-134 -345 -133\\n\", \"36 -58 428518679\\n\", \"-47 -31 -669106932\\n\", \"171 185 534908267\\n\", \"-1000000000 -1000000000 -100000000... | Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not.
Two integers x, y are written on the blackboard. It is allowed to erase one of them and replace it with the sum of the number... | 0 |
{"tests": "{\"inputs\": [\"5 15\\n\", \"7 44\\n\", \"48 114212593995090\\n\", \"50 7\\n\", \"3 4\\n\", \"50 562949953421312\\n\", \"6 23\\n\", \"8 127\\n\", \"49 120715613380345\\n\", \"42 1422110928669\\n\", \"3 3\\n\", \"7 7\\n\", \"4 8\\n\", \"50 500000000000007\\n\", \"5 2\\n\", \"50 562949953421310\\n\", \"8 1\\n\... | You are given a permutation p of numbers 1, 2, ..., n. Let's define f(p) as the following sum:
<image>
Find the lexicographically m-th permutation of length n in the set of permutations having the maximum possible value of f(p).
Input
The single line of input contains two integers n and m (1 ≤ m ≤ cntn), where cntn... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 2\\n1 3\\n2 4\\n4 5\", \"5\\n1 2\\n2 3\\n1 5\\n4 5\", \"5\\n1 2\\n1 3\\n2 4\\n4 0\", \"6\\n2 2\\n2 4\\n5 1\\n6 3\\n3 2\", \"6\\n2 2\\n2 4\\n5 1\\n6 4\\n3 2\", \"6\\n2 2\\n2 2\\n5 1\\n6 4\\n3 2\", \"6\\n2 2\\n2 2\\n5 1\\n0 4\\n3 2\", \"6\\n2 4\\n2 2\\n5 1\\n0 4\\n3 2\", \"6\\n2 4\\n4 2\\... | There is a tree with N vertices numbered 1, 2, ..., N. The edges of the tree are denoted by (x_i, y_i).
On this tree, Alice and Bob play a game against each other. Starting from Alice, they alternately perform the following operation:
* Select an existing edge and remove it from the tree, disconnecting it into two se... | 0.25 |
{"tests": "{\"inputs\": [[[1, 3, 7]], [[7, 1, 2, 3]], [[1, 3, 5, 7]], [[1, 5, 6, 7, 3]], [[5, 6, 7]], [[5, 6, 7, 8]], [[6, 7, 8]], [[7, 8]]], \"outputs\": [[true], [false], [false], [true], [true], [true], [false], [true]]}", "source": "taco"} | Now we will confect a reagent. There are eight materials to choose from, numbered 1,2,..., 8 respectively.
We know the rules of confect:
```
material1 and material2 cannot be selected at the same time
material3 and material4 cannot be selected at the same time
material5 and material6 must be selected at the same time
... | 0 |
{"tests": "{\"inputs\": [[12, 4, 3, 2], [9, 4, 2, 7], [13, 4, 3, 1], [13, 4, 3, 50], [36, 4, 3, 2], [15, 4, 3, 12], [100000, 99999, 100000, 100000], [100000, 100000, 100000, 100000], [100000, 1, 50000, 49999], [100000, 1, 1000, 999], [17, 4, 4, 16], [23, 4, 4, 13], [1, 4, 4, 15], [22, 4, 4, 13], [16, 4, 4, 16], [20, 4,... | Have you heard about Megamind? Megamind and Metro Man are two aliens who came to earth. Megamind wanted to destroy the earth, while Metro Man wanted to stop him and protect mankind. After a lot of fighting, Megamind finally threw Metro Man up into the sky. Metro Man was defeated and was never seen again. Megamind wante... | 0 |
{"tests": "{\"inputs\": [\"20\\n15\", \"20\\n4\", \"20\\n8\", \"20\\n2\", \"20\\n6\", \"20\\n1\", \"20\\n-1\", \"20\\n3\", \"20\\n5\", \"20\\n24\", \"20\\n12\", \"20\\n20\", \"20\\n25\", \"20\\n30\", \"20\\n50\", \"20\\n60\", \"20\\n75\", \"20\\n40\", \"20\\n100\", \"20\\n120\", \"20\\n150\", \"20\\n200\", \"20\\n010\"... | Write a program which computes the area of a shape represented by the following three lines:
$y = x^2$
$y = 0$
$x = 600$
It is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by adding up areas of many rectangles... | 0.875 |
{"tests": "{\"inputs\": [\"3\\n0\\n5\\n1\\n1\\n1\\n-1\", \"3\\n0\\n9\\n1\\n1\\n0\\n-1\", \"3\\n0\\n5\\n1\\n1\\n2\\n-1\", \"3\\n1\\n9\\n1\\n1\\n0\\n-1\", \"3\\n0\\n6\\n1\\n1\\n2\\n-1\", \"3\\n1\\n9\\n0\\n1\\n0\\n-1\", \"3\\n0\\n5\\n0\\n1\\n0\\n-1\", \"3\\n1\\n5\\n1\\n1\\n0\\n-1\", \"3\\n0\\n6\\n1\\n1\\n1\\n-1\", \"3\\n0... | The screen that displays digital numbers that you often see on calculators is called a "7-segment display" because the digital numbers consist of seven parts (segments).
The new product to be launched by Wakamatsu will incorporate a 7-segment display into the product, and as an employee, you will create a program to d... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n1 2\\n2 3\\n3 3\\n\", \"7 9\\n1 7\\n5 9\\n5 7\\n5 9\\n1 1\\n6 8\\n3 4\\n\", \"7 9\\n1 9\\n5 9\\n5 7\\n5 9\\n1 1\\n6 8\\n3 4\", \"7 9\\n1 9\\n9 9\\n5 7\\n5 9\\n1 1\\n6 8\\n3 4\", \"7 11\\n1 9\\n5 9\\n5 7\\n5 9\\n1 1\\n6 8\\n3 4\", \"7 9\\n1 9\\n9 9\\n5 7\\n5 9\\n1 1\\n8 8\\n3 4\", \"7 9\... | Snuke has decided to play a game, where the player runs a railway company.
There are M+1 stations on Snuke Line, numbered 0 through M.
A train on Snuke Line stops at station 0 and every d-th station thereafter, where d is a predetermined constant for each train.
For example, if d = 3, the train stops at station 0, 3, 6... | 0.875 |
{"tests": "{\"inputs\": [\"??????????????????????????????????????????????????????????????????????????????????????0\\n\", \"1011110101010001110000110111011011101011010100001001101?101010101110010110001101110111110100001100010000111001010111000111111001001001100111001010000111101110100110110101101111110100000000010101001... | Little Petya very much likes playing with little Masha. Recently he has received a game called "Zero-One" as a gift from his mother. Petya immediately offered Masha to play the game with him.
Before the very beginning of the game several cards are lain out on a table in one line from the left to the right. Each card c... | 0 |
{"tests": "{\"inputs\": [[\"~O~O~O~O P\"], [\"P O~ O~ ~O O~\"], [\"~O~O~O~OP~O~OO~\"], [\"O~~OO~~OO~~OO~P~OO~~OO~~OO~~O\"], [\"~OP\"], [\"PO~\"], [\"O~P\"], [\"P~O\"], [\" P\"], [\"P \"], [\" P \"], [\"P\"]], \"outputs\": [[0], [1], [2], [8], [0], [0], [1], [1], [0], [0], [0], [0]]}", "sour... | ---
# Story
The Pied Piper has been enlisted to play his magical tune and coax all the rats out of town.
But some of the rats are deaf and are going the wrong way!
# Kata Task
How many deaf rats are there?
# Legend
* ```P``` = The Pied Piper
* ```O~``` = Rat going left
* ```~O``` = Rat going right
# Example
* ... | 0 |
{"tests": "{\"inputs\": [\"10\\n54972 0\\n48015 1\\n7114 1\\n68273 2\\n53650 4\\n1716 1\\n16165 2\\n96062 5\\n57750 1\\n21071 5\\n\", \"20\\n68260 0\\n819 1\\n54174 1\\n20460 1\\n25696 2\\n81647 4\\n17736 4\\n91307 5\\n5210 4\\n87730 2\\n4653 8\\n11044 6\\n15776 4\\n17068 7\\n73738 7\\n36004 12\\n83183 7\\n75700 12\\n8... | Little Petya loves looking for numbers' divisors. One day Petya came across the following problem:
You are given n queries in the form "xi yi". For each query Petya should count how many divisors of number xi divide none of the numbers xi - yi, xi - yi + 1, ..., xi - 1. Help him.
Input
The first line contains an int... | 0 |
{"tests": "{\"inputs\": [\"3\\n2 1 3\\n\", \"3\\n1 2 3\\n\", \"99\\n3 1 3 1 3 1 2 1 3 1 3 1 2 1 3 1 3 1 3 1 3 1 2 1 2 1 3 1 2 1 2 1 3 1 3 1 2 1 3 1 3 1 3 1 3 1 2 1 2 1 3 1 3 1 2 1 2 1 2 1 3 1 3 1 3 1 2 1 2 1 3 1 2 1 2 1 3 1 3 1 2 1 3 1 3 1 2 1 3 1 3 1 3 1 3 1 2 1 2\\n\", \"100\\n3 1 3 1 2 1 2 3 1 2 3 2 3 2 3 2 3 1 2 1 ... | The math faculty of Berland State University has suffered the sudden drop in the math skills of enrolling students. This year the highest grade on the entrance math test was 8. Out of 100! Thus, the decision was made to make the test easier.
Future students will be asked just a single question. They are given a sequen... | 0 |
{"tests": "{\"inputs\": [\"1000000 1000000 1000000 1000000000\\n\", \"1000 988 1000000 3000\\n\", \"418223 118667 573175 776998\\n\", \"2 2 2 0\\n\", \"2 1000 1000000 1000000000\\n\", \"500000 1000000 750000 100000\\n\", \"797745 854005 98703 735186\\n\", \"100500 5000 500 100000000\\n\", \"781081 414037 495753 892089\... | Vasya plays The Elder Trolls IV: Oblivon. Oh, those creators of computer games! What they do not come up with! Absolutely unique monsters have been added to the The Elder Trolls IV: Oblivon. One of these monsters is Unkillable Slug. Why it is "Unkillable"? Firstly, because it can be killed with cutting weapon only, so ... | 0 |
{"tests": "{\"inputs\": [\"13 16\\nfzfdfqffqzdbf\\nqqdkffdffzqdfdam\\n\", \"121 144\\niqqqqqqiiqqqqqiqqqqqqqqqqqqqqiqqqqiqiqqvvqqqiqqqiqqvqqqqqqqqqqqqvqqqiiqqqqiqqiqqiqqiqiqqqqqqiqqqiqiqqqqqqqvqqiqqqqqqqiqqq\\nqqiqqqiqqqiiqqqqviqqqiqiqqqqqqqqqqqqiqqqqqqqqqqqqqqqqqqiiiqqiqvqqqqqqiqqqqqqqvqqqvqqqqqqpqqvqqqqqqiqiqiqiqqqqv... | You are given two strings A and B representing essays of two students who are suspected cheaters. For any two strings C, D we define their similarity score S(C,D) as 4â‹… LCS(C,D) - |C| - |D|, where LCS(C,D) denotes the length of the Longest Common Subsequence of strings C and D.
You believe that only some part of the ... | 0 |
{"tests": "{\"inputs\": [\"6\\n3 2 1 3 2 1\\n4 5\\n3 4\\n1 4\\n2 1\\n6 1\\n\", \"4\\n2 1 1 1\\n1 2\\n1 3\\n1 4\\n\", \"5\\n2 2 2 2 2\\n1 2\\n2 3\\n3 4\\n4 5\\n\", \"1\\n25\\n\", \"10\\n7 4 6 7 6 6 7 5 7 5\\n8 7\\n4 5\\n9 6\\n2 5\\n4 8\\n9 10\\n4 3\\n9 4\\n1 8\\n\", \"20\\n4 1 3 4 7 3 8 7 7 3 1 1 7 1 9 5 1 10 6 3\\n6 15... | You are given a tree consisting of $n$ vertices. A number is written on each vertex; the number on vertex $i$ is equal to $a_i$.
Recall that a simple path is a path that visits each vertex at most once. Let the weight of the path be the bitwise XOR of the values written on vertices it consists of. Let's say that a tre... | 0 |
{"tests": "{\"inputs\": [\"10\\nUR\\nDR\\nUL\\nDR\\nUL\\nULDR\\nUR\\nUL\\nULDR\\nUL\\n\", \"6\\nUL\\nDL\\nDL\\nUL\\nUL\\nDL\\n\", \"1\\nDR\\n\", \"1\\nUR\\n\", \"1\\nULDR\\n\", \"1\\nUL\\n\", \"4\\nULDR\\nUR\\nULDR\\nUR\\n\", \"10\\nUL\\nUL\\nUL\\nUL\\nUL\\nUL\\nUL\\nUL\\nUL\\nUL\\n\", \"10\\nUL\\nUR\\nUR\\nDR\\nDR\\nD... | Sensation, sensation in the two-dimensional kingdom! The police have caught a highly dangerous outlaw, member of the notorious "Pihters" gang. The law department states that the outlaw was driving from the gang's headquarters in his car when he crashed into an ice cream stall. The stall, the car, and the headquarters e... | 0 |
{"tests": "{\"inputs\": [\"3\\n3\\n-2\\n1\\n0\\n2\\n4\\n2\\n1\\n-1\\n-2\\n2\\n2\\n-2\\n-2\\n0\", \"3\\n3\\n-2\\n1\\n0\\n2\\n4\\n2\\n1\\n-1\\n-3\\n2\\n2\\n-2\\n-2\\n0\", \"3\\n3\\n-2\\n1\\n0\\n2\\n4\\n2\\n1\\n-1\\n-3\\n4\\n2\\n-2\\n-2\\n0\", \"3\\n3\\n0\\n1\\n0\\n2\\n4\\n2\\n1\\n-1\\n-2\\n4\\n2\\n-2\\n-4\\n0\", \"3\\n3\... | Taro made a sugoroku so that everyone can play at the children's association event. In order to make the game interesting, I wrote instructions such as "advance 6" and "back 5" in some of the sugoroku squares other than "Furidashi" and "Agari". Turn the roulette wheel to advance as many times as you can, and if an inst... | 0 |
{"tests": "{\"inputs\": [\"5\\n7\\n135\", \"5\\n8\\n135\", \"5\\n5\\n135\", \"5\\n4\\n135\", \"5\\n4\\n218\", \"5\\n2\\n218\", \"5\\n2\\n143\", \"5\\n2\\n167\", \"5\\n2\\n89\", \"5\\n3\\n89\", \"5\\n1\\n89\", \"5\\n1\\n155\", \"5\\n2\\n155\", \"5\\n4\\n155\", \"5\\n4\\n233\", \"5\\n2\\n233\", \"5\\n2\\n351\", \"5\\n2\\... | <image>
My grandmother uses a balance. The balance will balance if you place the same size on both of the two dishes, otherwise it will tilt to the heavier side. The weights of the 10 weights are 1g, 2g, 4g, 8g, 16g, 32g, 64g, 128g, 256g, 512g in order of lightness.
My grandmother says, "Weigh up to about 1 kg in gr... | 0.125 |
{"tests": "{\"inputs\": [\"8\\n........\\n........\\n........\\n........\\n........\\n........\\n........\\n........\\n\", \"20\\n..............S.....\\n....................\\n.............S.....S\\n....................\\n....................\\n...S................\\n....................\\n....................\\n......... | Omkar is creating a mosaic using colored square tiles, which he places in an n × n grid. When the mosaic is complete, each cell in the grid will have either a glaucous or sinoper tile. However, currently he has only placed tiles in some cells.
A completed mosaic will be a mastapeece if and only if each tile is adjace... | 0.75 |
{"tests": "{\"inputs\": [\"4\\n1\\n8\\n6\\n1000000000000000000\\n\", \"4\\n1\\n8\\n1\\n1000000000000000000\\n\", \"4\\n1\\n3\\n1\\n1000000100000000000\\n\", \"4\\n1\\n8\\n10\\n1100000000000000100\\n\", \"4\\n1\\n4\\n10\\n1110000000000000100\\n\", \"4\\n1\\n4\\n10\\n0111000000000000100\\n\", \"4\\n1\\n8\\n10\\n011110000... | Jett is tired after destroying the town and she wants to have a rest. She likes high places, that's why for having a rest she wants to get high and she decided to craft staircases.
A staircase is a squared figure that consists of square cells. Each staircase consists of an arbitrary number of stairs. If a staircase ha... | 0 |
{"tests": "{\"inputs\": [\"7\\n1 2 5 4 3 6 7\", \"4\\n2 4 2 2\", \"4\\n1 4 3 2\", \"7\\n1 3 2 4 5 6 7\", \"4\\n3 4 1 2\", \"8\\n7 2 1 3 8 5 4 6\", \"7\\n1 2 8 1 3 6 7\", \"5\\n2 5 3 1 4\", \"8\\n5 2 1 3 8 6 4 7\", \"7\\n2 1 5 4 3 6 7\", \"4\\n2 4 1 3\", \"5\\n1 6 3 1 4\", \"5\\n1 4 3 2 5\", \"7\\n1 2 3 5 4 6 7\", \"4\\... | Taro has decided to move. Taro has a lot of luggage, so I decided to ask a moving company to carry the luggage. Since there are various weights of luggage, I asked them to arrange them in order from the lightest one for easy understanding, but the mover left the luggage in a different order. So Taro tried to sort the l... | 0 |
{"tests": "{\"inputs\": [[12, 15, 5], [12, -15, 6], [-14, -5, 5], [23, 16, 5], [0, 0, 7], [12, 0, 10], [0, 15, 17], [-24, 0, 10], [0, -18, 14], [32, -14, 14]], \"outputs\": [[\"60.00\"], [\"6.67\"], [\"7.78\"], [\"52.57\"], [\"0.00\"], [\"12.00\"], [\"15.00\"], [\"24.00\"], [\"18.00\"], [\"9.74\"]]}", "source": "taco"} | Two moving objects A and B are moving accross the same orbit (those can be anything: two planets, two satellites, two spaceships,two flying saucers, or spiderman with batman if you prefer).
If the two objects start to move from the same point and the orbit is circular, write a function that gives the time the two objec... | 0 |
{"tests": "{\"inputs\": [\"2\\n1 5\\n12 6\\n\", \"1\\n1000000000 1000000000\\n\", \"2\\n1 5\\n2 6\\n\", \"2\\n4 4\\n12 5\\n\", \"2\\n0 1000000000\\n1000000000 1000000000\\n\", \"1\\n0 1000000000\\n\", \"3\\n0 1\\n2 2\\n4 1\\n\", \"12\\n66 4\\n12 4\\n60 4\\n24 4\\n48 4\\n0 4\\n36 4\\n30 4\\n6 4\\n54 4\\n42 4\\n18 4\\n\"... | 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.375 |
{"tests": "{\"inputs\": [[\"2\", \"1\", \"2\"], \"2\\n2\\n2\", \"2\\n2\\n3\", \"2\\n3\\n2\", \"2\\n2\\n5\", \"2\\n4\\n5\", \"2\\n3\\n5\", \"2\\n5\\n5\", \"2\\n5\\n8\", \"2\\n4\\n8\", \"2\\n1\\n1\", \"2\\n2\\n4\", \"2\\n1\\n3\", \"2\\n6\\n2\", \"2\\n2\\n1\", \"2\\n6\\n5\", \"2\\n4\\n6\", \"2\\n5\\n4\", \"2\\n4\\n16\", \... | ----- Statement -----
You need to find a string which has exactly K positions in it such that the character at that position comes alphabetically later than the character immediately after it. If there are many such strings, print the one which has the shortest length. If there is still a tie, print the string which c... | 0 |
{"tests": "{\"inputs\": [[[]], [[-1]], [[-1, 5, 10, -100, 3, 2]], [[1, 2, 3, 3, 2, 1, 2, 3, 1, 1, 3, 2]], [[1, 3, 2, 3, 2, 1, 2, 3, 1, 1, 3, 2]], [[3, 2, 3, 3, 2, 1, 2, 3, 1, 1, 3, 2]]], \"outputs\": [[[]], [[-1]], [[-1, 5, 10, -100, 3, 2]], [[1, 2, 3]], [[1, 3, 2]], [[3, 2, 1]]]}", "source": "taco"} | # Remove Duplicates
You are to write a function called `unique` that takes an array of integers and returns the array with duplicates removed. It must return the values in the same order as first seen in the given array. Thus no sorting should be done, if 52 appears before 10 in the given array then it should also be ... | 0 |
{"tests": "{\"inputs\": [\"5 2\\n3 1\\n3 1\\n10 3\\n1 10\\n10 1\\n8 0\\n0 0\", \"5 0\\n3 1\\n3 1\\n10 3\\n1 10\\n10 1\\n8 0\\n0 0\", \"5 0\\n3 1\\n3 1\\n10 2\\n1 10\\n10 1\\n11 0\\n0 0\", \"5 2\\n3 1\\n3 1\\n10 3\\n1 11\\n10 1\\n8 3\\n0 0\", \"6 2\\n3 1\\n3 1\\n10 3\\n1 10\\n10 1\\n8 0\\n0 0\", \"5 0\\n3 1\\n3 1\\n10 3... | There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling.
There is a deck of n cards. Starting from the p-th card from the top of the deck, c cards are pulled out and put on the top of the deck, a... | 0.375 |
{"tests": "{\"inputs\": [\"5\\n.#...\\n####.\\n.####\\n...#.\\n.....\\n\", \"4\\n####\\n####\\n####\\n####\\n\", \"6\\n.#....\\n####..\\n.####.\\n.#.##.\\n######\\n.#..#.\\n\", \"6\\n.#..#.\\n######\\n.####.\\n.####.\\n######\\n.#..#.\\n\", \"3\\n...\\n...\\n...\\n\", \"5\\n.....\\n.#...\\n####.\\n.####\\n...#.\\n\", \... | Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a symbol '#'.
A cross on the board is a connected set of exactly five cells of the board that looks like a cross. The picture below shows how it looks.[Image]
Ciel wants to draw several (m... | 0.875 |
{"tests": "{\"inputs\": [\"5\\napple 1 1 1 1 1 1 1 10 1\\nbanana 1 2 2 2 2 2 1 10 1\\ncarrot 1 2 2 2 2 2 1 10 2\\ndurian 1 3 0 3 3 3 1 10 1\\neggplant 1 3 3 3 3 3 1 100 1\\n4\\nenoki 1 3 3 3 3 3 1 10 1\\ntomato 1 3 3 3 3 3 1 10 1\\npotato 1 3 3 3 3 3 1 10 1\\nonion 1 3 3 3 3 3 1 10 1\\n3\\na 10 1 1 1 1 1 1 10 1\\nb 10 ... | You are enthusiastic about the popular web game "Moonlight Ranch". The purpose of this game is to grow crops in the fields, sell them to earn income, and use that income to grow the ranch.
You wanted to grow the field quickly. Therefore, we decided to arrange the crops that can be grown in the game based on the income... | 0 |
{"tests": "{\"inputs\": [\"1\\n1\\n\", \"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 62 28 86 5 82 49 3 99 33 9 92 32 74 69 27 22 77 16 44 94 34 6 57 70 23 12 61 25 8 11 67 47 83 88 10 14 30 7 97 60 42 37 24 3... | You are given a permutation p_1, p_2, …, p_n.
In one move you can swap two adjacent values.
You want to perform a minimum number of moves, such that in the end there will exist a subsegment 1,2,…, k, in other words in the end there should be an integer i, 1 ≤ i ≤ n-k+1 such that p_i = 1, p_{i+1} = 2, …, p_{i+k-1}=k.
... | 0 |
{"tests": "{\"inputs\": [\"3 4 2 1\\n1 2 3 59\\n\", \"3 4 3 3\\n4 4 0 5\\n\", \"1 1 1 1\\n1 3 4 7\\n\", \"1 10 1 4\\n11 12 17 29\\n\", \"3 3 1 2\\n23 8 4 37\\n\", \"10 10 5 5\\n478741118 470168785 859734009 999999937\\n\", \"10 15 7 3\\n680853366 753941356 522057812 999999937\\n\", \"3000 10 1 6\\n709202316 281605678 5... | Seryozha conducts a course dedicated to building a map of heights of Stepanovo recreation center. He laid a rectangle grid of size $n \times m$ cells on a map (rows of grid are numbered from $1$ to $n$ from north to south, and columns are numbered from $1$ to $m$ from west to east). After that he measured the average h... | 0 |
{"tests": "{\"inputs\": [\"6\\n8 10 9 9 8 10\\n1 1 1 1 1 1\\n\", \"6\\n8 10 9 9 8 10\\n1 10 5 5 1 10\\n\", \"1\\n1\\n100\\n\", \"50\\n83 43 73 75 11 53 6 43 67 38 83 12 70 27 60 13 9 79 61 30 29 71 10 11 95 87 26 26 19 99 13 47 66 93 91 47 90 75 68 3 22 29 59 12 44 41 64 3 99 100\\n31 36 69 25 18 33 15 70 12 91 41 44 1... | You need to execute several tasks, each associated with number of processors it needs, and the compute power it will consume.
You have sufficient number of analog computers, each with enough processors for any task. Each computer can execute up to one task at a time, and no more than two tasks total. The first task ca... | 0 |
{"tests": "{\"inputs\": [\"3\\n0\\n2\\n1\", \"4\\n0\\n0\\n1\\n2\", \"3\\n0\\n1\\n0\", \"3\\n0\\n0\\n0\", \"9\\n0\\n1\\n1\\n0\\n2\\n2\\n2\\n1\\n2\", \"3\\n0\\n2\\n2\", \"9\\n0\\n1\\n1\\n0\\n2\\n2\\n2\\n1\\n4\", \"4\\n0\\n0\\n0\\n2\", \"3\\n0\\n1\\n2\", \"9\\n0\\n1\\n1\\n0\\n2\\n2\\n2\\n1\\n3\", \"4\\n1\\n0\\n0\\n2\", \"... | There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X.
You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required.
* Choose... | 0 |
{"tests": "{\"inputs\": [\"4 3\\n1 2 4 5 6 7 8 9\\n1 2 8 9 3 1\\n\", \"4 12\\n2 8 3 1 2 1 9 4\\n9 5 5 3 1 6 3 7 7 1 8 5 6 5 4 6 1 9 1 4 2 5 9 8\\n\", \"12 12\\n1 6 2 6 8 3 6 4 4 8 7 2 7 5 9 4 2 4 9 5 8 5 3 6\\n2 8 6 9 2 6 7 4 6 5 6 3 5 8 7 8 7 1 1 9 9 7 7 3\\n\", \"3 8\\n8 9 8 5 9 2\\n8 4 8 3 2 6 4 2 4 3 3 7 3 6 1 6\\n... | Two participants are each given a pair of distinct numbers from 1 to 9 such that there's exactly one number that is present in both pairs. They want to figure out the number that matches by using a communication channel you have access to without revealing it to you.
Both participants communicated to each other a set ... | 0.25 |
{"tests": "{\"inputs\": [[3], [4], [5], [7], [10], [33], [101], [1], [2], [11213], [8191], [8192]], \"outputs\": [[true], [false], [true], [true], [false], [false], [true], [false], [true], [true], [true], [false]]}", "source": "taco"} | The AKS algorithm for testing whether a number is prime is a polynomial-time test based on the following theorem:
A number p is prime if and only if all the coefficients of the polynomial expansion of `(x − 1)^p − (x^p − 1)` are divisible by `p`.
For example, trying `p = 3`:
(x − 1)^3 − (x^3 − 1) = (x^3 − 3x^2... | 0.75 |
{"tests": "{\"inputs\": [\"3\\n+ 489111368\\n+ 489111368\\n+ 489111368\\n\", \"3\\n+ 202794029\\n+ 810021800\\n+ 810021800\\n\", \"2\\n+ 717107178\\n+ 717107178\\n\", \"4\\n+ 68335221\\n+ 68335221\\n+ 68335221\\n-\\n\", \"3\\n-\\n-\\n-\\n\", \"4\\n+ 637139306\\n-\\n+ 637139306\\n-\\n\", \"3\\n+ 59671102\\n+ 59671102\\n... | You are given a sequence A, where its elements are either in the form + x or -, where x is an integer.
For such a sequence S where its elements are either in the form + x or -, define f(S) as follows:
* iterate through S's elements from the first one to the last one, and maintain a multiset T as you iterate through... | 0 |
{"tests": "{\"inputs\": [\"250000000 250000000 2\\n\", \"1000000000 999998304 7355\\n\", \"999998212 999998211 499998210\\n\", \"778562195 708921647 4\\n\", \"23888888 23862367 812\\n\", \"901024556 901000000 1000\\n\", \"901024556 900000000 91\\n\", \"120009 70955 2\\n\", \"512871295 512870845 99712\\n\", \"875000005 ... | 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\": [\"2 1 10\", \"2 1 1\", \"2 1 2\", \"4 1 2\", \"2 1 0\", \"1 2 10\", \"2 2 10\", \"4 1 3\", \"2 2 0\", \"3 2 10\", \"4 2 10\", \"0 1 2\", \"7 1 3\", \"0 2 0\", \"3 4 10\", \"4 2 12\", \"10 1 3\", \"-1 2 0\", \"3 6 10\", \"4 3 12\", \"20 1 3\", \"-1 0 0\", \"6 6 10\", \"4 3 5\", \"4 1 6\", \"7 6 ... | C: Skewering
problem
One day, when Homura was playing with blocks, Tempura came. Homura decided to play with blocks with Tempura.
There is a rectangular parallelepiped of A \ times B \ times C, which is made by stacking A \ times B \ times C blocks of cubic blocks with a side length of 1 without any gaps. Each side ... | 0.375 |
{"tests": "{\"inputs\": [[\"13:34\"], [\"21:00\"], [\"11:15\"], [\"03:03\"], [\"14:30\"], [\"08:55\"], [\"00:00\"], [\"12:00\"]], \"outputs\": [[\"tick\"], [\"Cuckoo Cuckoo Cuckoo Cuckoo Cuckoo Cuckoo Cuckoo Cuckoo Cuckoo\"], [\"Fizz Buzz\"], [\"Fizz\"], [\"Cuckoo\"], [\"Buzz\"], [\"Cuckoo Cuckoo Cuckoo Cuckoo Cuckoo C... | ## Your story
You've always loved both Fizz Buzz katas and cuckoo clocks, and when you walked by a garage sale and saw an ornate cuckoo clock with a missing pendulum, and a "Beyond-Ultimate Raspberry Pi Starter Kit" filled with all sorts of sensors and motors and other components, it's like you were suddenly hit by a b... | 0.125 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.