info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [\"3\\n3\\n111\\n2\\n21\\n4\\n2122\\n\", \"3\\n3\\n111\\n2\\n21\\n4\\n2122\\n\", \"3\\n3\\n111\\n2\\n12\\n4\\n2122\\n\", \"3\\n3\\n111\\n2\\n11\\n4\\n2122\\n\", \"3\\n3\\n111\\n1\\n1\\n4\\n2122\\n\", \"3\\n3\\n111\\n2\\n22\\n4\\n2122\\n\", \"3\\n3\\n111\\n2\\n21\\n4\\n2122\\n\"], \"outputs\": [\... | A chess tournament will be held soon, where $n$ chess players will take part. Every participant will play one game against every other participant. Each game ends in either a win for one player and a loss for another player, or a draw for both players.
Each of the players has their own expectations about the tournamen... | 0 |
{"tests": "{\"inputs\": [[[2], 2, 1], [[1], 10, 10], [[1], 1, 0], [[1, 2], 1, 0], [[1, 2, 3], 456546, 23532], [[1, 5, 3, 7, 9], 7, 8], [[1, 1, 1, 1, 1, 1, 1, 1, 1], 0, 1]], \"outputs\": [[true], [true], [false], [true], [true], [false], [false]]}", "source": "taco"} | # Task
You are the manager of the famous rescue team: The Knights. Your task is to assign your knights to a rescue missions on an infinite 2D-plane.
Your knights can move only by `n-knight` jumps.
For example, if a knight has n = 2, they can only move exactly as a knight on a chess board.
If n = 3, they can ... | 0 |
{"tests": "{\"inputs\": [\"2 2 4 4\\n1 1 3 5\\n3 1 5 5\\n\", \"3 3 7 5\\n0 0 4 6\\n0 0 7 4\\n\", \"5 2 10 5\\n3 1 7 6\\n8 1 11 7\\n\", \"0 0 1000000 1000000\\n0 0 499999 1000000\\n500000 0 1000000 1000000\\n\", \"50 100 100000 99000\\n13 4654 99999 1000000\\n0 0 1000000 45653\\n\", \"0 0 1000000 1000000\\n0 0 1000000 9... | There is a white sheet of paper lying on a rectangle table. The sheet is a rectangle with its sides parallel to the sides of the table. If you will take a look from above and assume that the bottom left corner of the table has coordinates $(0, 0)$, and coordinate axes are left and bottom sides of the table, then the bo... | 0 |
{"tests": "{\"inputs\": [\"5 3\\nabbbc\\nabc\\n\", \"5 2\\naaaaa\\naa\\n\", \"5 5\\nabcdf\\nabcdf\\n\", \"2 2\\nab\\nab\\n\", \"3 3\\ncad\\ncad\\n\", \"4 3\\ndbbd\\ndbd\\n\", \"5 4\\nddada\\nddda\\n\", \"5 4\\nbacbb\\nbabb\\n\", \"5 3\\nabaab\\nabb\\n\", \"5 2\\nddaca\\nda\\n\", \"5 2\\nbaaac\\nac\\n\", \"5 2\\naabaa\\... | Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: $s$ of length $n$ and $t$ of length $m$.
A sequence $p_1, p_2, \ldots, p_m$, where $1 \leq p_1 < p_2 < \ldots < p_m \leq n$, is called beautiful, if $s_{p_i} = t_i$ for all $i$ from $1$ to $m$. The width... | 0 |
{"tests": "{\"inputs\": [\"1\\n1 0 1 1\\n10000 10000 10000 10000\", \"2\\n10 3 1 2\\n2 4 1 3\\n1 2 1 1\", \"2\\n10 3 1 2\\n2 4 1 3\\n1 3 1 1\", \"2\\n10 3 1 2\\n3 4 1 3\\n1 3 1 1\", \"2\\n10 3 2 2\\n3 4 1 3\\n1 3 1 1\", \"1\\n1 0 1 1\\n10000 10010 10000 10000\", \"1\\n1 0 1 1\\n10000 10010 10000 10100\", \"1\\n1 0 1 1\... | A rabbit is playing a role-playing game. Just before entering the castle, he was ambushed by an enemy!
It was a battle between one hero operated by a rabbit and n enemies. Each character has four stats, health hi, attack power ai, defense power di, and agility si. I = 0 is the information of the main character, 1 β€ i ... | 0 |
{"tests": "{\"inputs\": [\"2 1\\n1 2 0\\n\", \"4 4\\n1 2 1\\n1 3 0\\n2 3 1\\n3 4 1\\n\", \"8 9\\n1 2 0\\n8 3 0\\n2 3 1\\n1 4 1\\n8 7 0\\n1 5 1\\n4 6 1\\n5 7 0\\n6 8 0\\n\", \"9 10\\n1 2 0\\n2 3 0\\n1 4 1\\n4 5 1\\n4 6 1\\n6 7 1\\n1 7 0\\n1 8 0\\n7 8 0\\n9 7 1\\n\", \"5 6\\n1 2 0\\n3 2 0\\n5 1 1\\n1 3 1\\n5 3 0\\n4 3 1\... | Breaking Good is a new video game which a lot of gamers want to have. There is a certain level in the game that is really difficult even for experienced gamers.
Walter William, the main character of the game, wants to join a gang called Los Hermanos (The Brothers). The gang controls the whole country which consists of... | 0 |
{"tests": "{\"inputs\": [\"blue blue blue blue bluf blue blue blue\\nred blue blue blue blue blue blue blue\\nred red blue blue blue blue blue blue\", \"blue blue blue blue bluf clue blue blue\\nred blue blue blue blue blue blue blue\\nred red blue blue blue blue blue blue\", \"blue blue blue blue bluf cleu blue blue\\... | A young boy John is playing with eight triangular panels. These panels are all regular triangles of the same size, each painted in a single color; John is forming various octahedra with them.
While he enjoys his playing, his father is wondering how many octahedra can be made of these panels since he is a pseudo-mathem... | 0 |
{"tests": "{\"inputs\": [\"5 3\\n10 14 19 34 33\\n\", \"9 14\\n1 3 5 110 24 21 34 5 3\\n\", \"9 73\\n67597 52981 5828 66249 75177 64141 40773 79105 16076\\n\", \"5 3\\n10 4 19 34 33\", \"9 14\\n1 3 5 110 24 21 34 2 3\", \"9 73\\n67597 52981 5828 18 75177 64141 40773 79105 16076\", \"5 1\\n10 4 19 34 33\", \"9 14\\n1 3 ... | Takahashi has come to a party as a special guest.
There are N ordinary guests at the party. The i-th ordinary guest has a power of A_i.
Takahashi has decided to perform M handshakes to increase the happiness of the party (let the current happiness be 0).
A handshake will be performed as follows:
- Takahashi chooses on... | 0 |
{"tests": "{\"inputs\": [\"5\\n3 4 3 2 4\\n\", \"3\\n4 4 4\\n\", \"99\\n1401 2019 1748 3785 3236 3177 3443 3772 2138 1049 353 908 310 2388 1322 88 2160 2783 435 2248 1471 706 2468 2319 3156 3506 2794 1999 1983 2519 2597 3735 537 344 3519 3772 3872 2961 3895 2010 10 247 3269 671 2986 942 758 1146 77 1545 3745 1547 2250 ... | Caisa solved the problem with the sugar and now he is on the way back to home.
Caisa is playing a mobile game during his path. There are (n + 1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (i > 0) has height h_{i}. The goal of the game is to reach n-th py... | 0 |
{"tests": "{\"inputs\": [\"9\\n88 22 83 14 95 91 98 53 11\\n3 24\\n7 -8\\n1 67\\n1 64\\n9 65\\n5 12\\n6 -80\\n3 8\\n\", \"6\\n53 82 15 77 71 23\\n5 -77\\n6 -73\\n2 0\\n1 26\\n4 -92\\n\", \"10\\n99 60 68 46 51 11 96 41 48 99\\n4 50\\n6 -97\\n3 -92\\n7 1\\n9 99\\n2 79\\n1 -15\\n8 -68\\n5 -84\\n\", \"8\\n53 41 22 22 34 95... | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.
The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call ver... | 0 |
{"tests": "{\"inputs\": [\"4\\n00110011\\n00000111\\n11110000\\n00011111\\n\", \"1\\n11001110\\n\", \"2\\n11001110\\n01001001\\n\", \"3\\n10001001\\n10111011\\n10111101\\n\", \"4\\n11000010\\n11000010\\n11001110\\n10001001\\n\", \"5\\n01111000\\n00110110\\n00011100\\n01110111\\n01010011\\n\", \"4\\n11000010\\n11000010\... | You are given a boolean function of three variables which is defined by its truth table. You need to find an expression of minimum length that equals to this function. The expression may consist of: Operation AND ('&', ASCII code 38) Operation OR ('|', ASCII code 124) Operation NOT ('!', ASCII code 33) Variables x... | 0 |
{"tests": "{\"inputs\": [[\"1 tomato\"], [\"0 tomato\"], [\"1 ananas\"], [\"2 bananas\"], [\"3 bananas\"], [\"10 bananas\"], [\"111 bananas\"], [\"6 birds with 2 wings each = 12 legs\"], [\"\\n3 pigs\\nmet 1 wolf\\n2 days ago\"]], \"outputs\": [[\"1 tomato\"], [\"0 tomato\"], [\"1 ananas\"], [\"2 bubanana\"], [\"3 bana... | Once upon a time, a CodeWarrior, after reading a [discussion on what can be the plural](http://www.codewars.com/kata/plural/discuss/javascript), took a look at [this page](http://en.wikipedia.org/wiki/Grammatical_number#Types_of_number
) and discovered that **more than 1** "kind of plural" may exist.
For example [Sur... | 0 |
{"tests": "{\"inputs\": [\"3 2\\n\", \"39 14\\n\", \"44 350\\n\", \"22 444\\n\", \"1 0\\n\", \"34 712\\n\", \"10 82\\n\", \"17 222\\n\", \"40 1062\\n\", \"38 716\\n\", \"11 102\\n\", \"20 350\\n\", \"32 1000\\n\", \"15 154\\n\", \"1 0\\n\", \"12 55\\n\", \"35 289\\n\", \"12 0\\n\", \"34 123\\n\", \"7 1\\n\", \"31 344\\... | Let us define the oddness of a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n} as \sum_{i = 1}^n |i - p_i|.
Find the number of permutations of {1,\ 2,\ ...,\ n} of oddness k, modulo 10^9+7.
-----Constraints-----
- All values in input are integers.
- 1 \leq n \leq 50
- 0 \leq k \leq n^2
-----Input-----... | 0 |
{"tests": "{\"inputs\": [\"1 2 2 2 1\\n2 4\\n5 1\\n3\\n\", \"2 2 2 2 2\\n8 6\\n9 1\\n2 1\\n\", \"2 2 4 4 4\\n11 12 13 14\\n21 22 23 24\\n1 2 3 4\\n\", \"2 2 2 2 3\\n8 6\\n9 1\\n2 1\", \"1 2 2 2 1\\n3 4\\n5 1\\n3\", \"2 2 4 4 4\\n11 12 13 14\\n21 22 23 22\\n1 2 3 4\", \"2 2 2 2 3\\n8 1\\n9 1\\n2 1\", \"0 2 2 2 3\\n8 1\\... | You are going to eat X red apples and Y green apples.
You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C.
Before eating a colorless apple, you can paint it red or green, and it will count as a red... | 0.25 |
{"tests": "{\"inputs\": [\"3\\n-1 -1 -1\\n\", \"2\\n2 -1\\n\", \"40\\n3 3 -1 -1 4 4 -1 -1 -1 -1 -1 10 10 10 10 10 10 4 20 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 3 3 3 3 3 3 3 3\\n\", \"8\\n-1 3 -1 -1 -1 3 -1 -1\\n\", \"10\\n3 -1 -1 -1 -1 -1 -1 -1 2 2\\n\", \"50\\n36 36 45 44 -1 -1 13 -1 36 -1 44 36 -1 -1 -1 35 -1 36 36... | There are $n$ startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup.
The following steps happe... | 0 |
{"tests": "{\"inputs\": [\"4\\n\", \"5\\n\", \"4000\\n\", \"3000\\n\", \"42\\n\", \"3555\\n\", \"2999\\n\", \"999\\n\", \"3789\\n\", \"6\\n\", \"133\\n\", \"2000\\n\", \"8\\n\", \"345\\n\", \"3333\\n\", \"2345\\n\", \"1730\\n\", \"3999\\n\", \"555\\n\", \"2500\\n\", \"20\\n\", \"666\\n\", \"2780\\n\", \"10\\n\", \"7\\n... | Little Johnny has recently learned about set theory. Now he is studying binary relations. You've probably heard the term "equivalence relation". These relations are very important in many areas of mathematics. For example, the equality of the two numbers is an equivalence relation.
A set Ο of pairs (a, b) of elements ... | 0.125 |
{"tests": "{\"inputs\": [\"7 3\\n0011100\\n3\\n1 4 6\\n3\\n3 4 7\\n2\\n2 3\\n\", \"8 6\\n00110011\\n3\\n1 3 8\\n5\\n1 2 5 6 7\\n2\\n6 8\\n2\\n3 5\\n2\\n4 7\\n1\\n2\\n\", \"5 3\\n00011\\n3\\n1 2 3\\n1\\n4\\n3\\n3 4 5\\n\", \"19 5\\n1001001001100000110\\n2\\n2 3\\n2\\n5 6\\n2\\n8 9\\n5\\n12 13 14 15 16\\n1\\n19\\n\", \"1... | There are $n$ lamps on a line, numbered from $1$ to $n$. Each one has an initial state off ($0$) or on ($1$).
You're given $k$ subsets $A_1, \ldots, A_k$ of $\{1, 2, \dots, n\}$, such that the intersection of any three subsets is empty. In other words, for all $1 \le i_1 < i_2 < i_3 \le k$, $A_{i_1} \cap A_{i_2} \cap ... | 0 |
{"tests": "{\"inputs\": [[2, [\"e|-------5-7-----7-|-8-----8-2-----2-|-0---------0-----|-----------------|\", \"B|-----5-----5-----|---5-------3-----|---1---1-----1---|-0-1-1-----------|\", \"G|---5---------5---|-----5-------2---|-----2---------2-|-0-2-2-----------|\", \"D|-7-------6-------|-5-------4-------|-3--------... | You are to write a function to transpose a guitar tab up or down a number of semitones. The amount to transpose is a number, positive or negative. The tab is given as an array, with six elements for each guitar string (fittingly passed as strings). Output your tab in a similar form.
Guitar tablature (or 'tab') is an a... | 0 |
{"tests": "{\"inputs\": [\"4\\n2:2,3-1:4\\n3:4,3,1\\n3:2,4,1\\n1:2-2:1,3\\n\", \"10\\n2:7,4-2:5,8-1:3-1:6-1:2-2:10,9\\n9:6,7,3,4,10,8,9,5,1\\n9:2,1,7,6,9,4,8,10,5\\n8:5,2,1,3,6,9,10,8-1:7\\n1:8-8:9,10,2,6,3,1,7,4\\n9:8,4,1,2,10,9,7,3,5\\n9:1,3,6,2,9,10,5,8,4\\n9:5,2,7,3,6,4,10,1,9\\n9:3,7,6,8,10,5,1,2,4\\n1:9-8:2,7,3,6... | In the computer network of the Berland State University there are n routers numbered from 1 to n. Some pairs of routers are connected by patch cords. Information can be transmitted over patch cords in both direction. The network is arranged in such a way that communication between any two routers (directly or through o... | 0 |
{"tests": "{\"inputs\": [\"5 10\\n-1 5 0 -5 3\\n\", \"3 4\\n-10 0 20\\n\", \"5 10\\n-5 0 10 -11 0\\n\", \"5 13756\\n-2 -9 -10 0 10\\n\", \"20 23036\\n-1 1 -1 -1 -1 -1 1 -1 -1 0 0 1 1 0 0 1 0 0 -1 -1\\n\", \"12 82016\\n1 -2 -1 -1 -2 -1 0 -2 -1 1 -2 2\\n\", \"7 8555\\n-2 -3 -2 3 0 -2 0\\n\", \"16 76798\\n-1 11 -7 -4 0 -1... | Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.
She starts with 0 money on her account.
In the evening of i-th day a transaction a_{i} occurs. If a_{i} > 0, then a_{i} bourles are deposited to Luba's account. If a_{i} < 0, then a_{i} bourles are withdrawn. ... | 0 |
{"tests": "{\"inputs\": [\"3 6\\n..#..#\\n......\\n#####.\\n1 1 2 1 1 1\\n\", \"3 10\\n#..###..##\\n...#..###.\\n.###..##..\\n1 1 1 3 1 1 2 2 2 1\\n\", \"1 1\\n.\\n0\\n\", \"1 1\\n#\\n1\\n\", \"3 3\\n#.#\\n#..\\n##.\\n2 1 1\\n\", \"3 3\\n#.#\\n.#.\\n##.\\n2 2 1\\n\", \"3 3\\n#.#\\n#..\\n##.\\n3 1 0\\n\", \"3 3\\n#.#\\n... | This is the easy version of the problem. The difference between the versions is the constraints on a_i. You can make hacks only if all versions of the problem are solved.
Little Dormi has recently received a puzzle from his friend and needs your help to solve it.
The puzzle consists of an upright board with n rows a... | 0 |
{"tests": "{\"inputs\": [\"3\\n6 7 14\\n\", \"4\\n1 2 1 16\\n\", \"1\\n4\\n\", \"1\\n15\\n\", \"5\\n1000000000000000000 352839520853234088 175235832528365792 753467583475385837 895062156280564685\\n\", \"5\\n1000000000000000000 352839520853234088 175235832528365792 753467583475385837 895062156280564685\\n\", \"1\\n15\\... | Vasya has a sequence $a$ consisting of $n$ integers $a_1, a_2, \dots, a_n$. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform number $6$ $(\dots 00000000110_2)$ into $3$ $(\dots 00000000011_2)$, $12$ $(... | 0.25 |
{"tests": "{\"inputs\": [[[]], [[1, 2, 3]], [[\"x\", \"y\", [\"z\"]]], [[1, 2, [3, 4, [5]]]], [[[[[[[[[[]]]]]]]]]], [[\"a\"]], [[[\"a\"]]], [[[\"a\"], []]], [[\"[a]\"]], [[[[[[[[[[\"Everybody!\"]]]]]]]]]], [[\"cat\", [[\"dog\"]], [\"[bird]\"]]]], \"outputs\": [[0], [3], [4], [7], [8], [1], [2], [3], [1], [9], [6]]}", "... | ```if:javascript
`Array.prototype.length` will give you the number of top-level elements in an array.
```
```if:ruby
`Array#length` will give you the number of top-level elements in an array.
```
```if:csharp
The `Length` property of an array will give you the number of top-level elements in an array.
```
```if:php
`co... | 0 |
{"tests": "{\"inputs\": [\"2 -1\\nba\\n\", \"3 -7\\nabc\\n\", \"7 -475391\\nqohshra\\n\", \"3 -3\\nabc\\n\", \"3 -1\\nabc\\n\", \"3 1\\nabc\\n\", \"3 3\\nabc\\n\", \"3 5\\nabc\\n\", \"3 7\\nabc\\n\", \"2 393216\\nrt\\n\", \"3 1536\\nljm\\n\", \"4 -16777248\\nfyyy\\n\", \"2 393217\\nrt\\n\", \"3 3404\\nljm\\n\", \"4 962... | You've got a string $S$ consisting of $n$ lowercase English letters from your friend. It turned out that this is a number written in poman numerals. The poman numeral system is long forgotten. All that's left is the algorithm to transform number from poman numerals to the numeral system familiar to us. Characters of $S... | 0 |
{"tests": "{\"inputs\": [[\"professionals\"], [\"i\"], [\"\"], [\"me\"], [\"you\"], [\"card-carrying\"], [\"shan't\"], [\"-dcba\"], [\"dcba.\"], [\"you've gotta dance like there's nobody watching, love like you'll never be hurt, sing like there's nobody listening, and live like it's heaven on earth.\"]], \"outputs\": [... | Background
There is a message that is circulating via public media that claims a reader can easily read a message where the inner letters of each words is scrambled, as long as the first and last letters remain the same and the word contains all the letters.
Another example shows that it is quite difficult to read the... | 0 |
{"tests": "{\"inputs\": [\"123\\n222\\n\", \"3921\\n10000\\n\", \"4940\\n5000\\n\", \"23923472834\\n23589234723\\n\", \"102391019\\n491010301\\n\", \"123456789123456789\\n276193619183618162\\n\", \"1000000000000000000\\n1000000000000000000\\n\", \"1\\n1000000000000000000\\n\", \"999999999999999999\\n1000000000000000000... | You are given two positive integer numbers a and b. Permute (change order) of the digits of a to construct maximal number not exceeding b. No number in input and/or output can start with the digit 0.
It is allowed to leave a as it is.
-----Input-----
The first line contains integer a (1 β€ a β€ 10^18). The second lin... | 0 |
{"tests": "{\"inputs\": [\"50 100\\n1 71 96\\n2 34 52\\n2 16 95\\n1 54 55\\n1 65 85\\n1 76 92\\n2 19 91\\n1 26 43\\n2 83 95\\n2 70 88\\n2 67 88\\n1 9 75\\n2 4 50\\n2 9 11\\n1 77 92\\n1 28 58\\n1 23 72\\n1 24 75\\n2 12 50\\n1 54 55\\n2 45 93\\n1 88 93\\n2 98 99\\n1 40 58\\n2 40 42\\n1 16 61\\n2 94 94\\n1 82 86\\n2 81 85... | You are running through a rectangular field. This field can be represented as a matrix with 3 rows and m columns. (i, j) denotes a cell belonging to i-th row and j-th column.
You start in (2, 1) and have to end your path in (2, m). From the cell (i, j) you may advance to:
* (i - 1, j + 1) β only if i > 1,
* (i, ... | 0 |
{"tests": "{\"inputs\": [\"2 1\\n2 1\\n1\\n2 1\\n\", \"6 7\\n2 1\\n2 3\\n3 5\\n1 2\\n6 1\\n5 6\\n4 5\\n3\\n1 4\\n5 1\\n4 5\\n\", \"6 7\\n2 1\\n2 3\\n3 5\\n1 2\\n6 1\\n5 6\\n4 5\\n3\\n1 4\\n5 1\\n4 3\\n\", \"6 7\\n2 1\\n2 3\\n2 5\\n1 4\\n6 1\\n5 6\\n4 5\\n3\\n1 4\\n5 1\\n4 5\\n\", \"6 7\\n2 1\\n2 3\\n3 5\\n1 4\\n6 1\\n5... | She does her utmost to flawlessly carry out a person's last rites and preserve the world's balance of yin and yang.
Hu Tao, being the little prankster she is, has tried to scare you with this graph problem! You are given a connected undirected graph of n nodes with m edges. You also have q queries. Each query consists... | 0 |
{"tests": "{\"inputs\": [\"1 1\\n\", \"2 1\\n\", \"3 2\\n\", \"5 3\\n\", \"5 5\\n\", \"5 31\\n\", \"11994 11995\\n\", \"99999 3123\\n\", \"100000 1000000000\\n\", \"100000 1\\n\", \"100000 13\\n\", \"100000 53228\\n\", \"87532 32150\\n\", \"30 99999999\\n\"], \"outputs\": [\"2\\n\", \"3\\n\", \"7\\n\", \"26\\n\", \"32\... | Madoka decided to entrust the organization of a major computer game tournament "OSU"!
In this tournament, matches are held according to the "Olympic system". In other words, there are $2^n$ participants in the tournament, numbered with integers from $1$ to $2^n$. There are $n$ rounds in total in the tournament. In the... | 0 |
{"tests": "{\"inputs\": [\"6 0\", \"5 5\\n1 2\\n2 3\\n3 1\\n4 5\\n5 1\", \"7 0\", \"6 4\\n2 3\\n3 4\\n4 3\\n5 4\", \"4 0\", \"8 0\", \"1 0\", \"11 0\", \"13 0\", \"6 4\\n2 3\\n3 5\\n4 3\\n5 4\", \"3 0\", \"5 5\\n1 2\\n2 3\\n3 4\\n4 5\\n5 2\", \"6 4\\n2 2\\n3 4\\n4 3\\n5 4\", \"17 0\", \"6 4\\n2 3\\n1 5\\n4 3\\n5 4\", \... | Natsuki and her friends were taken to the space by an alien and made friends with a lot of aliens. During the space travel, she discovered that aliensβ hands were often very different from humansβ. Generally speaking, in a kind of aliens, there are N fingers and M bend rules on a hand. Each bend rule describes that a f... | 0 |
{"tests": "{\"inputs\": [\"7 2\\n1 2 1 1 3 5 1\\n3 5\\n\", \"3 3\\n1 3 2\\n1 2 3\\n\", \"5 0\\n4 3 1 2 3\\n\", \"10 3\\n1 3 5 6 12 9 8 10 13 15\\n2 4 9\\n\", \"20 5\\n19 4 11 10 7 18 7 10 12 13 14 15 16 17 22 26 29 23 30 22\\n2 9 11 12 14\\n\", \"50 15\\n1 2 3 5 9 10 14 15 17 16 18 19 21 23 22 27 27 36 26 23 23 32 27 3... | You are given an array of $n$ integers $a_1$, $a_2$, ..., $a_n$, and a set $b$ of $k$ distinct integers from $1$ to $n$.
In one operation, you may choose two integers $i$ and $x$ ($1 \le i \le n$, $x$ can be any integer) and assign $a_i := x$. This operation can be done only if $i$ does not belong to the set $b$.
Cal... | 0 |
{"tests": "{\"inputs\": [\"4\\n4 3 2 1\\n0 1 1 1\\n\", \"3\\n2 3 1\\n0 0 0\\n\", \"1\\n1\\n0\\n\", \"2\\n1 2\\n0 0\\n\", \"2\\n2 1\\n0 0\\n\", \"2\\n1 2\\n0 1\\n\", \"2\\n2 1\\n1 0\\n\", \"2\\n1 2\\n1 1\\n\", \"2\\n2 1\\n1 1\\n\", \"5\\n2 1 3 4 5\\n1 0 0 0 1\\n\", \"10\\n4 10 5 1 6 8 9 2 3 7\\n0 1 0 0 1 0 0 1 0 0\\n\",... | Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: in the one it was directed originally and in the reversed direction.
Pavel has a plan: a permutation p and a sequence b_1, b_2... | 0 |
{"tests": "{\"inputs\": [[\"$20.18\"], [\"$5.62\"], [\"$83.47\"], [\"$16.93\"], [\"$0.00\"], [\"$0.01\"], [\"$0.63\"], [\"$0.28\"], [\"$1.00\"], [\"$2.00\"], [\"$31.00\"], [\"$45.00\"], [\"$-5843.21\"], [\"$-45.32\"], [\"$-2.63\"], [\"$-234.48\"]], \"outputs\": [[\"20 dollars and 18 cents.\"], [\"5 dollars and 62 cents... | You start with a value in dollar form, e.g. $5.00. You must convert this value to a string in which the value is said, like '5 dollars' for example. This should account for ones, cents, zeroes, and negative values. Here are some examples:
```python
dollar_to_speech('$0.00') == '0 dollars.'
dollar_to_speech('$1.00') == ... | 0.125 |
{"tests": "{\"inputs\": [\"3 4\\nWWBW\\nBWWW\\nWWWB\\n\", \"3 1\\nB\\nB\\nW\\n\", \"1 1\\nB\\n\", \"1 2\\nBB\\n\", \"2 1\\nB\\nB\\n\", \"1 2\\nBW\\n\", \"2 1\\nW\\nB\\n\", \"5 5\\nWBBBW\\nWBBBW\\nWBBWW\\nWBBBW\\nWWWWW\\n\", \"5 5\\nWBBWW\\nBBBWW\\nBBBWW\\nBBBWW\\nBBBBB\\n\", \"5 5\\nWWWBB\\nBBBBB\\nWWWBB\\nWWWBB\\nWWWB... | Consider an n Γ m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during the pa... | 0.25 |
{"tests": "{\"inputs\": [[12, 5, \"January\"], [12, 1, \"February\"], [12, 1, \"March\"], [12, 12, \"September\"], [12, 5, \"March\"], [100, 5, \"March\"], [100, 52, \"July\"], [100, 51, \"July\"], [100, 53, \"July\"]], \"outputs\": [[\"You are on track.\"], [\"You are on track.\"], [\"You are 1 behind schedule.\"], [\... | Given the number pledged for a year, current value and name of the month, return string that gives information about the challenge status:
- ahead of schedule
- behind schedule
- on track
- challenge is completed
Examples:
`(12, 1, "February")` - should return `"You are on track."`
`(12, 1, "March")` - should retur... | 0 |
{"tests": "{\"inputs\": [\"5 6\\n1 2 0 2 0\\n2 4\\n3 3\\n1 5\\n1 2\\n1 5\\n2 3\\n\", \"5 3\\n4 2 1 3 2\\n3 5\\n4 2\\n2 5\\n\", \"78 36\\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0\\n1 52\\n2 6\\n9 43\\n10 52... | The only difference between easy and hard versions is constraints.
Ivan plays a computer game that contains some microtransactions to make characters look cooler. Since Ivan wants his character to be really cool, he wants to use some of these microtransactions β and he won't start playing until he gets all of them.
E... | 0 |
{"tests": "{\"inputs\": [\"2 2\\n0 0 0 1\\n1 0 1 1\\n\", \"1 3\\n1 1 0 1 0 0\\n\", \"3 3\\n1 1 1 1 1 1\\n1 1 0 1 1 0\\n1 0 0 0 1 1\\n\", \"1 5\\n1 0 1 1 1 0 1 1 1 1\\n\", \"1 100\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1... | One day Vitaly was going home late at night and wondering: how many people aren't sleeping at that moment? To estimate, Vitaly decided to look which windows are lit in the house he was passing by at that moment.
Vitaly sees a building of n floors and 2Β·m windows on each floor. On each floor there are m flats numbered ... | 0 |
{"tests": "{\"inputs\": [\"2\\n6\\nLRRRLL\\n3\\nLRL\\n\", \"2\\n6\\nLLRRRL\\n3\\nLRL\\n\", \"2\\n6\\nLLRRRL\\n3\\nRLL\\n\", \"2\\n6\\nLRRRLL\\n3\\nRLL\\n\", \"2\\n6\\nLLRRRL\\n3\\nLLR\\n\", \"2\\n6\\nLRRRLL\\n3\\nLLR\\n\", \"2\\n6\\nLRLRRL\\n3\\nLRL\\n\", \"2\\n6\\nRRLRLL\\n3\\nRLL\\n\", \"2\\n6\\nRRRLLL\\n3\\nLLR\\n\"... | There are $n + 1$ cities, numbered from $0$ to $n$. $n$ roads connect these cities, the $i$-th road connects cities $i - 1$ and $i$ ($i \in [1, n]$).
Each road has a direction. The directions are given by a string of $n$ characters such that each character is either L or R. If the $i$-th character is L, it means that ... | 0 |
{"tests": "{\"inputs\": [[\"10:00\"], [\"10:45\"], [\"15:05\"], [\"06:10\"], [\"05:10\"], [\"04:50\"], [\"05:55\"], [\"23:57\"], [\"00:00\"], [\"23:55\"]], \"outputs\": [[10], [10], [5], [0], [45], [65], [0], [358], [355], [0]]}", "source": "taco"} | It's been a tough week at work and you are stuggling to get out of bed in the morning.
While waiting at the bus stop you realise that if you could time your arrival to the nearest minute you could get valuable extra minutes in bed.
There is a bus that goes to your office every 15 minute, the first bus is at `06:00`, ... | 0 |
{"tests": "{\"inputs\": [\"5 5\\n.....\\n.#...\\n.....\\n.....\\n#.###\\n\", \"3 4\\n..##\\n....\\n..#.\\n\", \"2 42\\n..........#.......#..........###........#.\\n.....#######.......#..#....#...##.........\\n\", \"6 8\\n...##...\\n.#.#.#.#\\n#.#.#.#.\\n.#.#.#.#\\n#.#.#.#.\\n#.......\\n\", \"4 3\\n#.#\\n.##\\n...\\n.#.... | "The Chamber of Secrets has been opened again" β this news has spread all around Hogwarts and some of the students have been petrified due to seeing the basilisk. Dumbledore got fired and now Harry is trying to enter the Chamber of Secrets. These aren't good news for Lord Voldemort. The problem is, he doesn't want anyb... | 0 |
{"tests": "{\"inputs\": [\"4\\n0 0\\n131072 0\\n131072 131072\\n200000 0\\n\", \"10\\n999999999 1\\n999999998 1\\n999999997 1\\n1000000000 1\\n999999996 1\\n999999995 1\\n999999994 1\\n999999992 1\\n999999993 1\\n0 0\\n\", \"4\\n0 0\\n0 1\\n0 2\\n3 3\\n\", \"4\\n0 1\\n0 2\\n0 3\\n7 7\\n\", \"4\\n0 0\\n1 1\\n2 2\\n3 4\\... | Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars numbered from 1 to n. For each i, the i-th star is located at coordinates (xi, yi). No two stars are located at the same position.
In the evening Noku is going to take a look at the night sky. He would like to find three d... | 0 |
{"tests": "{\"inputs\": [\"3 1\\n3 1 4\\n5 3 2\\n\", \"7 3\\n27 18 28 18 28 46 1000000000\\n1000000000 1 7\\n1000000000 2 10\\n1000000000 3 12\\n\", \"3 1\\n2 1 4\\n5 3 2\", \"7 3\\n27 18 28 18 28 46 1000000000\\n1000000010 1 7\\n1000000000 2 10\\n1000000000 3 12\", \"7 3\\n27 18 28 18 28 46 1000000000\\n1000000010 1 7... | We have a sequence of k numbers: d_0,d_1,...,d_{k - 1}.
Process the following q queries in order:
- The i-th query contains three integers n_i, x_i, and m_i.
Let a_0,a_1,...,a_{n_i - 1} be the following sequence of n_i numbers: \begin{eqnarray} a_j = \begin{cases} x_i & ( j = 0 ) \\ a_{j - 1} + d_{(j - 1)~\text... | 0 |
{"tests": "{\"inputs\": [\"5 20\\n5 5 1 4\\n1 4 3\\n2 4 1\\n1 5 5\\n5 1 4\\n5 1 5\\n1 5 5\\n5 4 4\\n2 3 3\\n4 4 1\\n1 4 1\\n4 5 4\\n1 4 5\\n4 1 5\\n2 4 2\\n4 3 3\\n2 5 5\\n1 5 4\\n3 3 4\\n5 5 1\\n3 4 1\\n\", \"2 4\\n1\\n1 1 1\\n1 1 2\\n1 2 2\\n2 2 2\\n\", \"5 20\\n4 1 1 4\\n2 2 5\\n3 2 5\\n2 3 4\\n4 2 5\\n4 1 2\\n5 3 1... | Misha and Grisha are funny boys, so they like to use new underground. The underground has n stations connected with n - 1 routes so that each route connects two stations, and it is possible to reach every station from any other.
The boys decided to have fun and came up with a plan. Namely, in some day in the morning M... | 0.25 |
{"tests": "{\"inputs\": [\"3\\n3\\n3\\n4\", \"3\\n001\\n100\\n100\", \"3\\n2\\n3\\n3\", \"3\\n2\\n1\\n3\", \"3\\n4\\n5\\n8\", \"3\\n101\\n100\\n100\", \"3\\n3\\n5\\n4\", \"3\\n3\\n4\\n4\", \"3\\n011\\n100\\n100\", \"3\\n100\\n110\\n100\", \"3\\n3\\n5\\n8\", \"3\\n010\\n100\\n100\", \"3\\n3\\n1\\n4\", \"3\\n011\\n100\\n... | A cheetah and a cheater are going to play the game of Nim. In this game they use N piles of stones. Initially the i-th pile contains a_i stones. The players take turns alternately, and the cheetah plays first. In each turn, the player chooses one of the piles, and takes one or more stones from the pile. The player who ... | 0.75 |
{"tests": "{\"inputs\": [\"2\\n17 25\\n4\\n17 45\\n4\\n17 25\\n7\\n1 35\\n0\", \"2\\n19 25\\n4\\n17 37\\n4\\n17 47\\n7\\n0 63\\n0\", \"2\\n14 25\\n4\\n3 37\\n4\\n17 47\\n7\\n0 63\\n0\", \"2\\n13 25\\n3\\n17 45\\n4\\n17 25\\n7\\n1 35\\n0\", \"2\\n14 25\\n4\\n17 37\\n0\\n17 47\\n7\\n0 63\\n0\", \"2\\n13 25\\n3\\n17 45\\n... | In 20XX, the Aizu Chuo Road, which has a total distance of 58km and 6 sections from Atsushiokanomachi, Kitakata City to Minamiaizucho, is scheduled to be completed and opened.
For half a year after opening, the toll will be halved for vehicles that pass the departure IC or arrival IC between 17:30 and 19:30 and have a... | 0 |
{"tests": "{\"inputs\": [\"2\\n-10 1 10 1\\n4\\n-6 2 -2 -2 0 1\\n-6 -2 -2 2 1 0\\n6 2 2 -2 0 0\\n6 -2 2 2 1 1\\n8 12 -7 -3\\n8\\n4 -5 4 -2 1 1\\n4 -2 4 9 1 0\\n6 9 6 14 1 1\\n-5 6 7 6 0 0\\n1 0 1 10 0 0\\n-5 0 -5 10 0 1\\n-7 0 7 0 0 1\\n-1 0 -1 -5 0 1\", \"2\\n-10 1 10 1\\n4\\n-6 2 -2 -2 0 1\\n-6 -2 -2 2 1 0\\n6 2 2 -2... | Nate U. Smith runs a railroad company in a metropolitan area. In addition to his railroad company, there are rival railroad companies in this metropolitan area. The two companies are in a competitive relationship with each other.
In this metropolitan area, all lines are routed by the line segment connecting the statio... | 0.125 |
{"tests": "{\"inputs\": [\"2 2 0 0 0 1\", \"421 435 196 169 388 5\", \"1 2 0 0 0 0\", \"421 435 196 91 388 9\", \"5 6 0 0 4 4\", \"1 10 0 1 0 9\", \"421 435 196 169 388 12\", \"421 435 196 169 388 10\", \"421 435 196 118 388 0\", \"421 92 17 19 388 10\", \"1 18 0 0 0 9\", \"421 435 196 169 135 9\", \"5 11 0 0 4 4\", \"... | Problem
There is a grid of $ R \ times C $ squares with $ (0, 0) $ in the upper left and $ (R-1, C-1) $ in the lower right. When you are in a square ($ e $, $ f $), from there $ (e + 1, f) $, $ (e-1, f) $, $ (e, f + 1) $, $ (e) , f-1) $, $ (e, 0) $, $ (e, C-1) $, $ (0, f) $, $ (R-1, f) $ can be moved at a cost of $ 1 ... | 0.75 |
{"tests": "{\"inputs\": [\"2 2\\nmain 192.168.0.2\\nreplica 192.168.0.1\\nblock 192.168.0.1;\\nproxy 192.168.0.2;\\n\", \"3 5\\ngoogle 8.8.8.8\\ncodeforces 212.193.33.27\\nserver 138.197.64.57\\nredirect 138.197.64.57;\\nblock 8.8.8.8;\\ncf 212.193.33.27;\\nunblock 8.8.8.8;\\ncheck 138.197.64.57;\\n\", \"10 10\\nittmcs... | As the guys fried the radio station facilities, the school principal gave them tasks as a punishment. Dustin's task was to add comments to nginx configuration for school's website. The school has n servers. Each server has a name and an ip (names aren't necessarily unique, but ips are). Dustin knows the ip and name of ... | 0.875 |
{"tests": "{\"inputs\": [\"4 1 2\\n\", \"2 1 5\\n\", \"3 1 1\\n\", \"5 5 5\\n\", \"4 0 0\\n\", \"6 0 6\\n\", \"6 6 0\\n\", \"2 1 2\\n\", \"100000000 1 0\\n\", \"2 0 0\\n\", \"2 100000000 100000000\\n\", \"2 100000000 0\\n\", \"2 0 100000000\\n\", \"100000000 0 0\\n\", \"100000000 100000000 100000000\\n\", \"100000000 1... | R3D3 spent some time on an internship in MDCS. After earning enough money, he decided to go on a holiday somewhere far, far away. He enjoyed suntanning, drinking alcohol-free cocktails and going to concerts of popular local bands. While listening to "The White Buttons" and their hit song "Dacan the Baker", he met anoth... | 0 |
{"tests": "{\"inputs\": [\"4\\n3 0 3\\n4 -3 5\\n42 -33 55\\n69 -42 146\\n\", \"10\\n20000 -431912570 597469643\\n20000 -13928452 414987414\\n20000 -472808872 367983694\\n20000 -84913058 517394906\\n20000 -514402152 597357115\\n20000 -720971736 526102810\\n20000 -416160739 748291750\\n20000 -665939649 743938438\\n20000 ... | Let's call an integer array $a_1, a_2, \dots, a_n$ good if $a_i \neq i$ for each $i$.
Let $F(a)$ be the number of pairs $(i, j)$ ($1 \le i < j \le n$) such that $a_i + a_j = i + j$.
Let's say that an array $a_1, a_2, \dots, a_n$ is excellent if:
$a$ is good;
$l \le a_i \le r$ for each $i$;
$F(a)$ is the maximum po... | 0 |
{"tests": "{\"inputs\": [\"6 37\\n5\\n9\\n24\\n18\\n26\\n33\", \"4 1\\n1\\n2\\n7\\n9\", \"4 1\\n1\\n1\\n11\\n2\", \"6 37\\n5\\n16\\n13\\n18\\n26\\n33\", \"4 25\\n9\\n15\\n20\\n15\", \"6 37\\n5\\n6\\n24\\n18\\n26\\n33\", \"6 37\\n6\\n16\\n13\\n18\\n26\\n16\", \"6 37\\n5\\n9\\n24\\n9\\n26\\n35\", \"6 37\\n6\\n16\\n13\\n1... | I have a lot of friends. Every friend is very small.
I often go out with my friends. Put some friends in your backpack and go out together.
Every morning I decide which friends to go out with that day. Put friends one by one in an empty backpack.
I'm not very strong. Therefore, there is a limit to the weight of friends... | 0 |
{"tests": "{\"inputs\": [[null], [3], [\"Dermatoglyphics\"], [\"isogram\"], [\"eleven\"], [\"moOse\"], [\"isIsogram\"], [\"\"], [\"-.-\"], [\"subdermatoglyphic\"], [\"Alphabet\"], [\"thumbscrew-japingly\"], [\"Hjelmqvist-Gryb-Zock-Pfund-Wax\"], [\"Emily Jung Schwartzkopf\"], [\"aabbccddeeffgg\"]], \"outputs\": [[false]... | **An [isogram](https://en.wikipedia.org/wiki/Isogram)** (also known as a "nonpattern word") is a logological term for a word or phrase without a repeating letter. It is also used by some to mean a word or phrase in which each letter appears the same number of times, not necessarily just once.
You task is to write a me... | 0 |
{"tests": "{\"inputs\": [\"3\\n3 1\\n1 3 2\\n1 2\\n2 2\\n1 2\\n1 2\\n1 2\\n7 5\\n1 2 5 4 3 6 7\\n1 2\\n6 7\\n3 4\\n1 2\\n2 3\\n\", \"5\\n2 0\\n1 2\\n2 1\\n1 2\\n1 2\\n2 1\\n2 1\\n1 2\\n3 9\\n1 2 3\\n1 2\\n1 3\\n2 3\\n1 2\\n1 3\\n2 3\\n1 2\\n1 3\\n2 3\\n3 0\\n3 2 1\\n\", \"5\\n2 0\\n1 2\\n2 1\\n1 2\\n1 2\\n2 1\\n2 1\\n1... | This is the hard version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.
Pikachu is a cute and friendly pokΓ©mon living in the wild pikachu herd.
But it has become known recently that infamous team R... | 0.25 |
{"tests": "{\"inputs\": [\"5\\n2 1 3 5 4\", \"5\\n2 1 0 5 4\", \"5\\n4 1 0 5 4\", \"5\\n4 1 0 5 6\", \"5\\n4 0 0 5 6\", \"5\\n4 0 0 10 6\", \"5\\n4 0 0 10 12\", \"5\\n4 0 0 10 3\", \"5\\n4 0 0 11 3\", \"5\\n4 0 0 0 3\", \"5\\n4 0 1 0 3\", \"5\\n7 0 1 0 3\", \"5\\n7 0 2 0 3\", \"5\\n7 1 2 0 3\", \"5\\n2 1 0 1 4\", \"5\\... | G --Derangement / Derangement
Story
Person D is doing research on permutations. At one point, D found a permutation class called "Derangement". "It's cool to have a perfect permutation !!! And it starts with D !!!", the person of D who had a crush on Chunibyo decided to rewrite all the permutations given to him.
Pro... | 0.25 |
{"tests": "{\"inputs\": [\"5 3\", \"1 6\", \"13 13\", \"15 1\", \"56 159\", \"5 1\", \"19 13\", \"15 2\", \"43 159\", \"1 1\", \"27 2\", \"61 159\", \"0 2\", \"2 13\", \"16 2\", \"39 159\", \"11 2\", \"89 205\", \"102 205\", \"169 205\", \"3 6\", \"16 6\", \"5 13\", \"613 159\", \"13 15\", \"13 1\", \"5 2\", \"23 13\",... | Find the number, modulo 998244353, of sequences of length N consisting of 0, 1 and 2 such that none of their contiguous subsequences totals to X.
Constraints
* 1 \leq N \leq 3000
* 1 \leq X \leq 2N
* N and X are integers.
Input
Input is given from Standard Input in the following format:
N X
Output
Print the nu... | 0 |
{"tests": "{\"inputs\": [\"6\\n3 5 4 7 10 12\\n\", \"5\\n-1 2 5 8 11\\n\", \"1\\n42\\n\", \"3\\n0 -536870912 536870912\\n\", \"2\\n536870912 -536870912\\n\", \"3\\n1 2 3\\n\", \"4\\n1 2 3 8\\n\", \"2\\n1 2\\n\", \"3\\n0 1 2\\n\", \"2\\n-3 -2\\n\", \"2\\n-4 -2\\n\", \"2\\n2 1\\n\", \"1\\n1\\n\", \"3\\n0 2 6\\n\", \"3\\n... | There are $n$ distinct points on a coordinate line, the coordinate of $i$-th point equals to $x_i$. Choose a subset of the given set of points such that the distance between each pair of points in a subset is an integral power of two. It is necessary to consider each pair of points, not only adjacent. Note that any sub... | 0.75 |
{"tests": "{\"inputs\": [\"4\\n\", \"10\\n\", \"2\\n\", \"1000000000000\\n\", \"999999999999\\n\", \"23131234\\n\", \"100000\\n\", \"1024\\n\", \"536870912\\n\", \"536870911\\n\", \"536870913\\n\", \"123456789\\n\", \"200\\n\", \"3\\n\", \"5\\n\", \"6\\n\", \"7\\n\", \"1000\\n\", \"12000\\n\", \"65536\\n\", \"1048576\\... | Ehab is interested in the bitwise-xor operation and the special graphs. Mahmoud gave him a problem that combines both. He has a complete graph consisting of n vertices numbered from 0 to n - 1. For all 0 β€ u < v < n, vertex u and vertex v are connected with an undirected edge that has weight $u \oplus v$ (where $\oplus... | 0 |
{"tests": "{\"inputs\": [\"2\\n11 8\\n\", \"5\\n10 9 7 10 6\\n\", \"3\\n12 3 3\\n\", \"4\\n7 3 9 10\\n\", \"1\\n1\\n\", \"5\\n15 5 8 6 3\\n\", \"1\\n1000000000\\n\", \"2\\n2 1\\n\", \"3\\n11 1 9\\n\", \"1\\n0\\n\", \"20\\n38 32 21 44 26 24 15 32 34 40 31 33 33 13 26 28 12 10 14 18\\n\", \"20\\n43 38 20 41 16 37 27 29 1... | Do you like summer? Residents of Berland do. They especially love eating ice cream in the hot summer. So this summer day a large queue of n Berland residents lined up in front of the ice cream stall. We know that each of them has a certain amount of berland dollars with them. The residents of Berland are nice people, s... | 0 |
{"tests": "{\"inputs\": [\"5 4 2\\n2 1 10\\n5 4 3\", \"5 5 2\\n1 1 10\\n5 4 3\", \"8 4 2\\n2 1 10\\n5 4 5\", \"5 6 2\\n2 2 1\\n2 4 3\", \"5 6 2\\n2 1 10\\n5 4 4\", \"8 5 2\\n2 1 7\\n5 4 3\", \"5 6 2\\n1 3 0\\n5 1 2\", \"5 7 2\\n1 3 0\\n5 1 2\", \"5 6 2\\n2 2 3\\n2 4 3\", \"8 4 2\\n2 1 10\\n6 4 5\", \"8 5 2\\n4 1 1\\n1 ... | Estimating the Flood Risk
Mr. Boat is the owner of a vast extent of land. As many typhoons have struck Japan this year, he became concerned of flood risk of his estate and he wants to know the average altitude of his land. The land is too vast to measure the altitude at many spots. As no steep slopes are in the estate... | 0 |
{"tests": "{\"inputs\": [[1.24], [7.304], [0.04], [1.04], [7.3004], [0.004], [693.230459]], \"outputs\": [[\"1 + 2/10 + 4/100\"], [\"7 + 3/10 + 4/1000\"], [\"4/100\"], [\"1 + 4/100\"], [\"7 + 3/10 + 4/10000\"], [\"4/1000\"], [\"600 + 90 + 3 + 2/10 + 3/100 + 4/10000 + 5/100000 + 9/1000000\"]]}", "source": "taco"} | # Write Number in Expanded Form - Part 2
This is version 2 of my ['Write Number in Exanded Form' Kata](https://www.codewars.com/kata/write-number-in-expanded-form).
You will be given a number and you will need to return it as a string in [Expanded Form](https://www.mathplacementreview.com/arithmetic/decimals.php#writ... | 0 |
{"tests": "{\"inputs\": [\"20 491\\n\", \"35 706065\\n\", \"37 27668397\\n\", \"18 1809\\n\", \"34 2412850\\n\", \"36 7074882\\n\", \"21 14921\\n\", \"22 731\\n\", \"49 12586269025\\n\", \"48 4534695914\\n\", \"49 1\\n\", \"38 23790805\\n\", \"46 1176411936\\n\", \"7 20\\n\", \"50 5608642004\\n\", \"14 356\\n\", \"12 1... | Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, value 2 into the value p2 and so on.
Kyota Ootori has just learned about cyclic representation of a permutation. A cycle is a... | 0 |
{"tests": "{\"inputs\": [\"4 4\\n0 1 2 2\", \"10 3\\n5 1 3 2 4 1 2 2 3 4\", \"10 3\\n5 1 3 4 8 1 2 2 3 4\", \"10 3\\n3 2 3 4 8 1 2 2 3 4\", \"5 2\\n2 1 4 2 1\", \"10 1\\n5 1 3 2 4 1 2 2 3 8\", \"10 1\\n5 2 3 2 4 1 2 2 3 8\", \"4 4\\n0 1 2 4\", \"4 4\\n-1 1 2 4\", \"4 4\\n-2 1 2 4\", \"4 6\\n-2 1 2 4\", \"4 6\\n-2 1 2 1... | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball.
He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls.
Find the minimum number of balls that Takahashi needs to rewrite the integers on them.
Constraints
* 1 \leq K \leq N... | 0.5 |
{"tests": "{\"inputs\": [\"3 3\\n0 0 0\\n0 10000 0\\n0 0 0\\n\", \"3 3\\n1 10 1\\n1 10 1\\n1 10 1\\n\", \"3 3\\n0 0 0\\n0 100 0\\n0 0 0\\n\", \"4 5\\n87882 40786 3691 85313 46694\\n28884 16067 3242 97367 78518\\n4250 35501 9780 14435 19004\\n64673 65438 56977 64495 27280\\n\", \"3 3\\n1 1 1\\n0 10000 0\\n1 1 1\\n\", \"... | Summer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the beach. The gym where they go is a matrix a with n lines and m columns. Let number a[i][j] represents the calories burned by performing workout at the cell of gym in the i-th line and the j-th column.
Iahub starts with ... | 0 |
{"tests": "{\"inputs\": [\"4 3\\n3 1 4 2\\n\", \"1 1000\\n42\\n\", \"31 3767\\n16 192 152 78 224 202 186 52 118 19 13 38 199 196 35 295 100 64 205 37 166 124 169 214 66 243 134 192 253 270 92\\n\", \"15 12226\\n18 125 213 221 124 147 154 182 134 184 51 49 267 88 251\\n\", \"81 10683\\n3 52 265 294 213 242 185 151 27 16... | You are given an array of positive integers a_1, a_2, ..., a_{n} Γ T of length n Γ T. We know that for any i > n it is true that a_{i} = a_{i} - n. Find the length of the longest non-decreasing sequence of the given array.
-----Input-----
The first line contains two space-separated integers: n, T (1 β€ n β€ 100, 1 β€ T... | 0 |
{"tests": "{\"inputs\": [\"696\\n\", \"6\\n\", \"928\\n\", \"589\\n\", \"657\\n\", \"617\\n\", \"11\\n\", \"14\\n\", \"1000\\n\", \"1\\n\", \"2\\n\", \"298\\n\", \"823\\n\", \"262\\n\", \"69\\n\", \"4\\n\", \"910\\n\", \"857\\n\", \"0\\n\", \"561\\n\", \"15\\n\", \"226\\n\", \"7\\n\", \"850\\n\", \"853\\n\", \"664\\n\"... | Fangy collects cookies. Once he decided to take a box and put cookies into it in some way. If we take a square k Γ k in size, divided into blocks 1 Γ 1 in size and paint there the main diagonal together with cells, which lie above it, then the painted area will be equal to the area occupied by one cookie k in size. Fan... | 0 |
{"tests": "{\"inputs\": [\"4 3\\n0 1 0 1\\n0 1\\n1 2\\n2 3\\n\", \"4 3\\n1 1 1 0\\n0 1\\n0 2\\n3 0\\n\", \"10 39\\n0 1 0 1 0 1 1 0 1 1\\n0 1\\n0 2\\n0 3\\n0 4\\n0 5\\n0 6\\n1 2\\n1 3\\n1 4\\n1 5\\n1 6\\n1 7\\n1 8\\n1 9\\n2 3\\n2 4\\n2 5\\n2 6\\n2 7\\n2 8\\n2 9\\n3 4\\n3 6\\n3 7\\n3 8\\n3 9\\n4 5\\n4 6\\n4 7\\n4 9\\n5 6... | You are given a program you want to execute as a set of tasks organized in a dependency graph. The dependency graph is a directed acyclic graph: each task can depend on results of one or several other tasks, and there are no directed circular dependencies between tasks. A task can only be executed if all tasks it depen... | 0 |
{"tests": "{\"inputs\": [\"a@mc@ks@gu@rl@gq@zq@iz@da@uq@mi@nf@zs@hi@we@ej@ke@vb@az@yz@yl@rr@gh@um@nv@qe@qq@de@dy@op@gt@vx@ak@q\\n\", \"aglvesxsmivijisod@mxcnbfcfgqfwjouidlsueaswf@obehqpvbkmukxkicyoknkbol@kutunggpoxxfpbe@qkhv@llddqqoyjeex@byvtlhbifqmvlukmrvgvpwrscwfhpuwyknwchqhrdqgarmnsdlqgf@lseltghg@bhuwbfjpsvayzk@fvwo... | Email address in Berland is a string of the form A@B, where A and B are arbitrary strings consisting of small Latin letters.
Bob is a system administrator in Β«BersoftΒ» company. He keeps a list of email addresses of the company's staff. This list is as a large string, where all addresses are written in arbitrary order... | 0.25 |
{"tests": "{\"inputs\": [\"2\\n5 23 1 2\\n3 13 2 3\\n\", \"3\\n12 9 2 1\\n12 8 1 3\\n12 8 2 2\\n\", \"1\\n1 10 1 13\\n\", \"3\\n3 16 25 1\\n3 15 9 34\\n3 14 90 87\\n\", \"4\\n2 15 52 53\\n2 15 35 81\\n2 15 39 96\\n2 14 87 7\\n\", \"5\\n3 6 40 89\\n3 4 24 64\\n2 28 83 1\\n3 3 15 32\\n3 8 54 28\\n\", \"10\\n8 8 4 18\\n8 ... | In 2013, the writers of Berland State University should prepare problems for n Olympiads. We will assume that the Olympiads are numbered with consecutive integers from 1 to n. For each Olympiad we know how many members of the jury must be involved in its preparation, as well as the time required to prepare the problems... | 0.75 |
{"tests": "{\"inputs\": [\"0100\\n0101\\n10100\\n01000\\n0101011\\n0011\\n011110\\n#\", \"0100\\n1101\\n10100\\n11000\\n0001011\\n0011\\n011110\\n#\", \"0100\\n1101\\n10000\\n10000\\n0001011\\n0011\\n011110\\n#\", \"0100\\n0101\\n10100\\n10001\\n0011011\\n1011\\n011110\\n#\", \"0100\\n0100\\n10100\\n10001\\n0011011\\n1... | Aka Beko, trying to escape from 40 bandits, got lost in the city of A. Aka Beko wants to go to City B, where the new hideout is, but the map has been stolen by a bandit.
Kobborg, one of the thieves, sympathized with Aka Beko and felt sorry for him. So I secretly told Aka Beko, "I want to help you go to City B, but I w... | 0 |
{"tests": "{\"inputs\": [[4.5], [7.1], [19.00384], [109.1], [66.4], [\"pippi\"], [{}]], \"outputs\": [[\"X--X--X\\n-X-X-X-\\n--XXX--\\nXXXXXXX\\n--XXX--\\n-X-X-X-\\nX--X--X\"], [\"X--XX--X\\n-X-XX-X-\\n--XXXX--\\nXXXXXXXX\\nXXXXXXXX\\n--XXXX--\\n-X-XX-X-\\nX--XX--X\"], [\"X--------XX--------X\\n-X-------XX-------X-\\n-... | Your aged grandfather is tragically optimistic about Team GB's chances in the upcoming World Cup, and has enlisted you to help him make [Union Jack](https://en.wikipedia.org/wiki/Union_Jack) flags to decorate his house with.
## Instructions
* Write a function which takes as a parameter a number which represents the d... | 0 |
{"tests": "{\"inputs\": [\"3\\nRBR\\n\", \"4\\nRBBR\\n\", \"5\\nRBBRR\\n\", \"5\\nRBRBR\\n\", \"10\\nRRBRRBBRRR\\n\", \"10\\nBRBRRRRRRR\\n\", \"10\\nBRRRRRRRRR\\n\", \"20\\nBRBRRRRRRRRRRRRRRRRR\\n\", \"30\\nRRBBBBBBBBBBBBBBBBBBBBBBBBBBBB\\n\", \"50\\nBRRRBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\\n\", \"20\\nRRRBR... | User ainta has a stack of n red and blue balls. He can apply a certain operation which changes the colors of the balls inside the stack.
While the top ball inside the stack is red, pop the ball from the top of the stack. Then replace the blue ball on the top with a red ball. And finally push some blue balls to the... | 0 |
{"tests": "{\"inputs\": [\"2008 2 29\\n2015 1 1\", \"1505 9 9\\n2001 11 3\", \"1505 9 9\\n2619 11 3\", \"1505 13 9\\n2619 11 3\", \"573 1 44\\n2015 1 1\", \"595 2 44\\n2015 2 1\", \"597 2 44\\n2015 2 1\", \"246 21 0\\n2619 11 5\", \"246 21 0\\n5129 11 5\", \"431 21 0\\n5129 11 5\", \"597 2 19\\n895 -2 1\", \"51 16 1\\n... | A trick of fate caused Hatsumi and Taku to come to know each other. To keep the encounter in memory, they decided to calculate the difference between their ages. But the difference in ages varies depending on the day it is calculated. While trying again and again, they came to notice that the difference of their ages w... | 0.125 |
{"tests": "{\"inputs\": [\"6 5\\n1 1 . 0 0 4\\n1 . . . . .\\n. . 2 2 . .\\n. . 2 2 3 3\\nP . - . . .\\n5\\n0 50 5 10\\n1 20 0 10\\n2 10 5 15\\n3 150 3 5\\n4 100 8 9\\n0 0\", \"6 5\\n1 1 . 0 0 4\\n1 . . . . .\\n. . 2 2 . .\\n. . 2 2 3 3\\nP . . . . .\\n5\\n0 50 8 10\\n0 20 0 10\\n2 10 5 15\\n3 150 3 5\\n4 100 8 9\\n0 0\... | Better things, cheaper. There is a fierce battle at the time sale held in some supermarkets today. "LL-do" here in Aizu is one such supermarket, and we are holding a slightly unusual time sale to compete with other chain stores. In a general time sale, multiple products are cheaper at the same time, but at LL-do, the t... | 0 |
{"tests": "{\"inputs\": [\"1\\n3 31\\n############################..#\\n.............................L.\\n############################..#\\n\", \"1\\n3 25\\n######################..#\\n.......................L.\\n######################..#\\n\", \"1\\n3 31\\n#############################..\\n............................... | There is a grid, consisting of n rows and m columns. Each cell of the grid is either free or blocked. One of the free cells contains a lab. All the cells beyond the borders of the grid are also blocked.
A crazy robot has escaped from this lab. It is currently in some free cell of the grid. You can send one of the foll... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 0 1\", \"2\\n0 3\", \"3\\n1 1 3\", \"3\\n2 0 1\", \"3\\n1 1 4\", \"3\\n3 0 1\", \"3\\n1 0 4\", \"3\\n5 0 1\", \"3\\n0 0 4\", \"3\\n1 0 2\", \"3\\n1 4 1\", \"2\\n1 4\", \"3\\n1 2 5\", \"2\\n1 0\", \"3\\n1 1 6\", \"3\\n2 1 1\", \"3\\n1 0 6\", \"3\\n4 0 1\", \"3\\n2 -1 4\", \"3\\n0 0 2\", ... | There are N piles of candies on the table. The piles are numbered 1 through N. At first, pile i contains a_i candies.
Snuke and Ciel are playing a game. They take alternating turns. Snuke goes first. In each turn, the current player must perform one of the following two operations:
1. Choose a pile with the largest n... | 0 |
{"tests": "{\"inputs\": [\"1\\n5 5 4 3 4\\n1 2\\n4 1\\n5 1\\n5 3\\n\", \"1\\n9 1 5 3 7\\n1 2\\n2 3\\n3 4\\n4 5\\n3 6\\n7 8\\n8 9\\n6 7\\n\", \"10\\n10 9 10 6 6\\n6 1\\n7 6\\n4 2\\n4 10\\n5 1\\n9 5\\n6 8\\n3 4\\n4 5\\n2 1 2 1 1\\n2 1\\n9 7 4 2 3\\n5 1\\n2 4\\n4 8\\n8 6\\n8 9\\n7 8\\n1 8\\n1 3\\n11 2 11 6 8\\n1 10\\n6 11... | Alice and Bob are playing a fun game of tree tag.
The game is played on a tree of n vertices numbered from 1 to n. Recall that a tree on n vertices is an undirected, connected graph with n-1 edges.
Initially, Alice is located at vertex a, and Bob at vertex b. They take turns alternately, and Alice makes the first mov... | 0 |
{"tests": "{\"inputs\": [\"1 1 2 1 1\\n2 1\\n\", \"1 1 2 0 1\\n2 1\\n\", \"5 4 10 1 6\\n1 1 5\\n1 5 5\\n1 3 2\\n1 5 1\\n2 1\\n2 2\\n\", \"5 2 2 1 8\\n1 1 2\\n1 5 3\\n1 2 1\\n2 2\\n1 4 0\\n1 3 2\\n2 1\\n2 3\\n\", \"5 2 2 1 8\\n1 1 1\\n1 5 3\\n1 2 1\\n2 2\\n1 4 2\\n1 3 2\\n2 1\\n2 3\\n\", \"5 2 2 1 8\\n1 1 2\\n1 5 3\\n1 ... | A factory produces thimbles in bulk. Typically, it can produce up to a thimbles a day. However, some of the machinery is defective, so it can currently only produce b thimbles each day. The factory intends to choose a k-day period to do maintenance and construction; it cannot produce any thimbles during this time, but ... | 0.75 |
{"tests": "{\"inputs\": [\"9\\npair int int int pair pair int int int int int pair pair pair pair pair pair int\\n\", \"2\\npair int int\\n\", \"4\\npair pair pair int int int int\\n\", \"5\\npair pair pair pair int int int int int\\n\", \"10\\npair int int int pair pair pair int int pair int pair int int int pair pair... | Vasya used to be an accountant before the war began and he is one of the few who knows how to operate a computer, so he was assigned as the programmer.
We all know that programs often store sets of integers. For example, if we have a problem about a weighted directed graph, its edge can be represented by three integer... | 0 |
{"tests": "{\"inputs\": [[220, 284], [220, 280], [1184, 1210], [220221, 282224], [10744, 10856], [299920, 9284], [999220, 2849], [122265, 139815]], \"outputs\": [[true], [false], [true], [false], [true], [false], [false], [true]]}", "source": "taco"} | Amicable numbers are two different numbers so related that the sum of the proper divisors of each is equal to the other number. (A proper divisor of a number is a positive factor of that number other than the number itself. For example, the proper divisors of 6 are 1, 2, and 3.)
For example, the smallest pair of amic... | 0 |
{"tests": "{\"inputs\": [[[\"blue\", \"blue\", \"red\", \"red\", \"blue\", \"green\"]], [[\"blue\", \"red\", \"blue\", \"blue\", \"red\", \"blue\", \"red\"]], [[\"brown\", \"brown\", \"red\", \"green\"]], [[\"red\", \"blue\", \"blue\", \"red\"]], [[\"red\", \"blue\"]], [[\"blue\", \"green\", \"red\", \"green\", \"blue\... | Your friend has invited you to a party, and tells you to meet them in the line to get in. The one problem is it's a masked party. Everyone in line is wearing a colored mask, including your friend. Find which people in line could be your friend.
Your friend has told you that he will be wearing a `RED` mask, and has **T... | 0 |
{"tests": "{\"inputs\": [\"1 0 0 1\\n0 1 0 0\\n0 0 1 0\\n0 0 0 1\\n\", \"0 1 1 0\\n1 0 1 0\\n1 1 0 0\\n0 0 0 1\\n\", \"1 0 0 0\\n0 0 0 1\\n0 0 0 0\\n1 0 1 0\\n\", \"0 0 0 0\\n0 0 0 1\\n0 0 0 1\\n0 0 0 1\\n\", \"1 1 1 0\\n0 1 0 1\\n1 1 1 0\\n1 1 1 1\\n\", \"0 1 1 0\\n0 1 0 0\\n1 0 0 1\\n1 0 0 0\\n\", \"1 0 0 0\\n0 1 0 0... | Sagheer is walking in the street when he comes to an intersection of two roads. Each road can be represented as two parts where each part has 3 lanes getting into the intersection (one for each direction) and 3 lanes getting out of the intersection, so we have 4 parts in total. Each part has 4 lights, one for each lane... | 0 |
{"tests": "{\"inputs\": [\"11\\n23\\n0\", \"11\\n45\\n0\", \"11\\n77\\n0\", \"11\\n13\\n0\", \"11\\n17\\n0\", \"11\\n25\\n0\", \"11\\n37\\n0\", \"11\\n5\\n0\", \"11\\n69\\n0\", \"11\\n19\\n0\", \"11\\n21\\n0\", \"11\\n27\\n0\", \"11\\n11\\n0\", \"11\\n31\\n0\", \"11\\n33\\n0\", \"11\\n29\\n0\", \"11\\n7\\n0\", \"11\\n3... | A prime number n (11, 19, 23, etc.) that divides by 4 and has 3 has an interesting property. The results of calculating the remainder of the square of a natural number (1, 2, ..., n -1) of 1 or more and less than n divided by n are the same, so they are different from each other. The number is (n -1) / 2.
The set of n... | 0 |
{"tests": "{\"inputs\": [\"869 80 1001\", \"328 80 1001\", \"328 102 1011\", \"328 102 1111\", \"279 102 1111\", \"25 102 1111\", \"25 122 1111\", \"25 63 1111\", \"25 89 1111\", \"1486 120 1001\", \"869 80 1101\", \"328 117 1011\", \"40 102 1111\", \"328 60 1111\", \"117 102 1111\", \"24 102 1111\", \"9 122 1111\", \"... | In 2937, DISCO creates a new universe called DISCOSMOS to celebrate its 1000-th anniversary.
DISCOSMOS can be described as an H \times W grid. Let (i, j) (1 \leq i \leq H, 1 \leq j \leq W) denote the square at the i-th row from the top and the j-th column from the left.
At time 0, one robot will be placed onto each s... | 0 |
{"tests": "{\"inputs\": [\"8\\n1000000000000 0 0 1000000000000 0 0 999999999999 1000000000000\\n1 2\\n2 3\\n3 4\\n4 5\\n5 6\\n6 7\\n7 8\\n\", \"4\\n6 10 15 0\\n1 4\\n2 4\\n3 4\\n\", \"2\\n123456789234 987654321432\\n1 2\\n\", \"2\\n987987987987 987987987987\\n2 1\\n\", \"32\\n402528994560 0 0 0 0 0 0 932646223872 89319... | Kamil likes streaming the competitive programming videos. His MeTube channel has recently reached 100 million subscribers. In order to celebrate this, he posted a video with an interesting problem he couldn't solve yet. Can you help him?
You're given a tree β a connected undirected graph consisting of n vertices conne... | 0 |
{"tests": "{\"inputs\": [\"8\", \"10010000000\", \"14\", \"10010000001\", \"13\", \"10000000001\", \"2\", \"10000001001\", \"4\", \"3\", \"10000000010\", \"6\", \"10010001000\", \"25\", \"10010010001\", \"23\", \"10000000011\", \"11000001001\", \"5\", \"10010100000\", \"11\", \"10010000100\", \"38\", \"11010010001\", \... | FizzBuzz is a game in which integers of 1 or more are spoken in order according to the following rules.
* "Fizz" when divisible by 3
* "Buzz" when divisible by 5
* "FizzBuzz" when divisible by both 3 and 5
* At other times, that number
An example of the progress of the game is shown below.
1, 2, Fizz, 4, Buzz,... | 0 |
{"tests": "{\"inputs\": [\"0?1\\n2 3\\n\", \"?????\\n13 37\\n\", \"?10?\\n239 7\\n\", \"01101001\\n5 7\\n\", \"0101010??01???101????10101??11??00\\n1000000 1000000\\n\", \"?00?0?0??00100?00?001111?11???1010110100?00?0?1?1?1001??001010?011???0000???????1111?1?101100110?001\\n801448 0\\n\", \"?\\n940946 502068\\n\", \"1?... | Currently, XXOC's rap is a string consisting of zeroes, ones, and question marks. Unfortunately, haters gonna hate. They will write $x$ angry comments for every occurrence of subsequence 01 and $y$ angry comments for every occurrence of subsequence 10. You should replace all the question marks with 0 or 1 in such a way... | 0.125 |
{"tests": "{\"inputs\": [\"4\\n1 1 2 2\\n1 2 2 4\\n179 1 179 100000\\n5 7 5 7\\n\", \"1\\n1 1 3 6\\n\", \"1\\n118730819 699217111 995255402 978426672\\n\", \"2\\n57 179 1329 2007\\n179 444 239 1568\\n\", \"1\\n1 1 3 6\\n\", \"1\\n118730819 699217111 995255402 978426672\\n\", \"2\\n57 179 1329 2007\\n179 444 239 1568\\n... | During the quarantine, Sicromoft has more free time to create the new functions in "Celex-2021". The developers made a new function GAZ-GIZ, which infinitely fills an infinite table to the right and down from the upper left corner as follows:
[Image] The cell with coordinates $(x, y)$ is at the intersection of $x$-t... | 0.125 |
{"tests": "{\"inputs\": [\"3 2\\n1 1 1\\n\", \"5 1\\n1 1 1 1 1\\n\", \"4 3\\n3 2 1 1\\n\", \"1 2000\\n2000\\n\", \"3 2\\n2 1 1\\n\", \"3 4\\n4 3 2\\n\", \"10 6\\n5 4 4 4 5 4 4 4 4 5\\n\", \"10 6\\n5 4 4 4 5 4 4 4 4 5\\n\", \"7 4\\n3 3 4 4 4 3 3\\n\", \"3 6\\n5 6 5\\n\", \"3 2\\n1 0 1\\n\", \"6 1\\n0 1 0 0 0 1\\n\", \"6... | Peter has a sequence of integers a_1, a_2, ..., a_{n}. Peter wants all numbers in the sequence to equal h. He can perform the operation of "adding one on the segment [l, r]": add one to all elements of the sequence with indices from l to r (inclusive). At that, Peter never chooses any element as the beginning of the se... | 0 |
{"tests": "{\"inputs\": [[\"3\", \"1 1 1 1\", \"1\", \"2\", \"3\", \"1 1 1 1\", \"2\", \"4\", \"6\", \"3 2 2 2\", \"1 2 3\", \"2 4\", \"6 8\"], \"3\\n1 1 1 1\\n1\\n2\\n3\\n1 1 1 1\\n3\\n4\\n6\\n3 2 2 2\\n1 2 3\\n2 4\\n6 8\", \"3\\n1 1 1 1\\n1\\n4\\n5\\n1 1 1 1\\n3\\n4\\n6\\n3 2 2 2\\n2 2 3\\n2 7\\n6 8\", \"3\\n1 1 1 1\... | Naturally, the magical girl is very good at performing magic. She recently met her master wizard Devu, who gifted her R potions of red liquid,
B potions of blue liquid, and G potions of green liquid.
-
The red liquid potions have liquid amounts given by r[1], ..., r[R] liters.
-
The green liquid potions have liqu... | 0 |
{"tests": "{\"inputs\": [\"4\\n2 1 -1 2\", \"2\\n1 1\", \"10\\n2 6 9 -1 7 9 -1 -1 -1 -1\", \"4\\n2 2 -1 3\", \"10\\n2 9 5 -1 7 9 -1 -1 -1 -1\", \"2\\n1 2\", \"4\\n1 1 -1 4\", \"4\\n2 3 -1 4\", \"10\\n2 9 5 -1 6 9 -1 -1 -1 -1\", \"4\\n1 2 -1 4\", \"10\\n2 9 8 -1 7 9 -1 -1 -1 -1\", \"10\\n2 9 5 -1 3 9 -1 -1 -1 -1\", \"4\... | There are N towns numbered 1, 2, \cdots, N.
Some roads are planned to be built so that each of them connects two distinct towns bidirectionally. Currently, there are no roads connecting towns.
In the planning of construction, each town chooses one town different from itself and requests the following: roads are built... | 0 |
{"tests": "{\"inputs\": [\"2 2\\n1 1\\n6 1\\n1 6\\n1 1\\n\", \"2 2\\n4 4\\n4 5\\n5 4\\n4 4\\n\", \"3 3\\n1 2 3\\n4 5 6\\n7 8 9\\n1 4 7\\n2 5 6\\n3 8 9\\n\", \"3 2\\n5 3\\n5 5\\n2 3\\n5 5\\n3 5\\n2 3\\n\", \"3 4\\n3 4 3 3\\n3 7 5 5\\n1 1 5 3\\n3 3 7 3\\n4 1 5 5\\n3 1 5 3\\n\", \"1 1\\n321\\n371\\n\", \"1 1\\n212055293\\... | Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task.
Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix... | 0.875 |
{"tests": "{\"inputs\": [\"5 4\\n+ 1\\n+ 2\\n- 2\\n- 1\\n\", \"3 2\\n+ 1\\n- 2\\n\", \"2 4\\n+ 1\\n- 1\\n+ 2\\n- 2\\n\", \"5 6\\n+ 1\\n- 1\\n- 3\\n+ 3\\n+ 4\\n- 4\\n\", \"2 4\\n+ 1\\n- 2\\n+ 2\\n- 1\\n\", \"1 1\\n+ 1\\n\", \"2 1\\n- 2\\n\", \"3 5\\n- 1\\n+ 1\\n+ 2\\n- 2\\n+ 3\\n\", \"10 8\\n+ 1\\n- 1\\n- 2\\n- 3\\n+ 3\... | Nearly each project of the F company has a whole team of developers working on it. They often are in different rooms of the office in different cities and even countries. To keep in touch and track the results of the project, the F company conducts shared online meetings in a Spyke chat.
One day the director of the F ... | 0 |
{"tests": "{\"inputs\": [\"0001\\n1011\\n\", \"000\\n111\\n\", \"1010101011111110111111001111111111111111111111101101110111111111111110110110101011111110110111111101\\n0101111111000100010100001100010101000000011000000000011011000001100100001110111011111000001110011111\\n\", \"0000000001000000000000100000100001000000\\n... | Little Susie loves strings. Today she calculates distances between them. As Susie is a small girl after all, her strings contain only digits zero and one. She uses the definition of Hamming distance:
We will define the distance between two strings s and t of the same length consisting of digits zero and one as the num... | 0 |
{"tests": "{\"inputs\": [\"2\\n3 2 7 4\\n9 9 1 9\", \"2\\n3 2 7 4\\n9 3 1 9\", \"2\\n3 2 7 4\\n9 3 1 15\", \"2\\n3 2 7 4\\n7 3 1 15\", \"2\\n3 2 4 4\\n7 3 1 15\", \"2\\n3 2 4 4\\n7 3 1 9\", \"2\\n3 2 6 4\\n7 3 1 9\", \"2\\n3 2 6 4\\n4 3 1 9\", \"2\\n3 2 6 4\\n4 3 2 9\", \"2\\n3 2 6 4\\n4 3 2 4\", \"2\\n3 4 6 4\\n4 3 2 ... | For a non-negative integer K, we define a fractal of level K as follows:
* A fractal of level 0 is a grid with just one white square.
* When K > 0, a fractal of level K is a 3^K \times 3^K grid. If we divide this grid into nine 3^{K-1} \times 3^{K-1} subgrids:
* The central subgrid consists of only black squares.
* Ea... | 0 |
{"tests": "{\"inputs\": [\"10\\n96759 970434747560290241\\n95684 985325796232084031\\n99418 855577012478917561\\n98767 992053283401739711\\n99232 381986776210191990\\n97804 22743067342252513\\n95150 523980900658652001\\n98478 290982116558877566\\n98012 642382931526919655\\n96374 448615375338644407\\n\", \"10\\n72939 67... | What are you doing at the end of the world? Are you busy? Will you save us?
<image>
Nephren is playing a game with little leprechauns.
She gives them an infinite array of strings, f0... β.
f0 is "What are you doing at the end of the world? Are you busy? Will you save us?".
She wants to let more people know about i... | 0 |
{"tests": "{\"inputs\": [\"3\\n6 3\\n0 0 2 5 1 1\\n2 3\\n0 2\\n3 2\\n3 0 2\\n\", \"1\\n2 2\\n2 8\\n\", \"1\\n2 2\\n4 8\\n\", \"1\\n2 4\\n21 56\\n\", \"1\\n2 3\\n10 0\\n\", \"1\\n2 10\\n7 4\\n\", \"1\\n2 2\\n3 9\\n\", \"1\\n2 3\\n10 2\\n\", \"5\\n2 2\\n0 0\\n2 2\\n0 1\\n2 2\\n1 0\\n2 2\\n0 2\\n2 2\\n2 0\\n\", \"1\\n2 3\... | You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side.
Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ... | 0 |
{"tests": "{\"inputs\": [\"333625\\n\", \"693549\\n\", \"757606\\n\", \"1000000\\n\", \"999228\\n\", \"443013\\n\", \"825195\\n\", \"160945\\n\", \"489857\\n\", \"563368\\n\", \"372544\\n\", \"315936\\n\", \"446167\\n\", \"797112\\n\", \"75417\\n\", \"119444\\n\", \"916542\\n\", \"5\\n\", \"4\\n\", \"101\\n\", \"533946... | Kavi has 2n points lying on the OX axis, i-th of which is located at x = i.
Kavi considers all ways to split these 2n points into n pairs. Among those, he is interested in good pairings, which are defined as follows:
Consider n segments with ends at the points in correspondent pairs. The pairing is called good, if fo... | 0 |
{"tests": "{\"inputs\": [\"1\\n4 2 2\\n\", \"1\\n1000 999 1\\n\", \"1\\n7 2 1\\n\", \"1\\n1000 1 1\\n\", \"1\\n2 1 1\\n\", \"1\\n1000 1 1000\\n\", \"1\\n8 7 2\\n\", \"1\\n1000 998 1000\\n\", \"1\\n1000 500 123\\n\", \"1\\n1000 1 2\\n\", \"1\\n1000 999 2\\n\", \"1\\n7 2 2\\n\", \"1\\n1100 999 1\\n\", \"1\\n8 2 1\\n\", \... | Have you ever tasted Martian food? Well, you should.
Their signature dish is served on a completely black plate with the radius of R, flat as a pancake.
First, they put a perfectly circular portion of the Golden Honduras on the plate. It has the radius of r and is located as close to the edge of the plate as possible... | 0 |
{"tests": "{\"inputs\": [\"3\\n0 0\\n0 1 1\\n\", \"6\\n0 1 1 0 4\\n1 1 0 0 1 0\\n\", \"10\\n0 1 2 1 4 4 4 0 8\\n0 0 0 1 0 1 1 0 0 1\\n\", \"5\\n0 1 1 3\\n0 0 0 1 1\\n\", \"10\\n0 1 1 2 4 3 3 3 2\\n1 0 1 1 1 0 0 1 1 0\\n\", \"100\\n0 0 2 2 0 3 5 0 6 2 0 4 0 2 3 7 8 3 15 19 13 8 18 19 3 14 23 9 6 3 6 17 26 24 20 6 4 27 8... | Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white.
Consider a set consisting of k (0 β€ k < n) edges of Appleman's tree. If Appleman deletes these edges from the tree, then it will split into (k + 1) parts. Note, that each part will be a tree... | 0 |
{"tests": "{\"inputs\": [[1], [2], [3], [8], [15], [16], [18], [20], [24], [32], [4], [7], [9], [10], [12], [13], [14], [50], [80], [200]], \"outputs\": [[\"1\"], [\"sqrt 2\"], [\"sqrt 3\"], [\"2 sqrt 2\"], [\"sqrt 15\"], [\"4\"], [\"3 sqrt 2\"], [\"2 sqrt 5\"], [\"2 sqrt 6\"], [\"4 sqrt 2\"], [\"2\"], [\"sqrt 7\"], [\... | ### What is simplifying a square root?
If you have a number, like 80, for example, you would start by finding the greatest perfect square divisible by 80. In this case, that's 16. Find the square root of 16, and multiply it by 80 / 16. Answer = 4 β5.
##### The above example:
![simplify_roots_example.png](https://i.... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.