info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [[6, 2, 2, 3], [6, 2, 2, 5], [6, 2, 2, 7], [8, 4, 2, 3], [15, 3, 3, 1], [15, 3, 3, 5], [15, 3, 3, 7], [15, 3, 3, 14], [15, 3, 3, 18]], \"outputs\": [[[1, 0, 1]], [[2, 1, 1]], [[-1, -1, -1]], [[1, 2, 1]], [[1, 2, 2]], [[1, 1, 1]], [[1, 0, 2]], [[2, 1, 1]], [[-1, -1, -1]]]}", "source": "taco"} | # Task
Mr.Nam has `n` candies, he wants to put one candy in each cell of a table-box. The table-box has `r` rows and `c` columns.
Each candy was labeled by its cell number. The cell numbers are in range from 1 to N and the direction begins from right to left and from bottom to top.
Nam wants to know the position o... | 0.75 |
{"tests": "{\"inputs\": [\"1111\\n00001\\n0110\\n01011\\n0010\\n01111\\n0010\\n01011\\n0111\", \"1111\\n00001\\n0110\\n01011\\n0010\\n01111\\n1010\\n01011\\n0111\", \"1111\\n00001\\n0110\\n01111\\n0010\\n00011\\n1010\\n01011\\n0111\", \"1111\\n00001\\n0110\\n01111\\n1010\\n00011\\n1010\\n01011\\n0111\", \"1111\\n00001\... | Seen from above, there is a grid-like square shaped like Figure 1. The presence or absence of "walls" on each side of this grid is represented by a sequence of 0s and 1s. Create a program that stands at point A, puts your right hand on the wall, keeps walking in the direction of the arrow, and outputs the route to retu... | 0 |
{"tests": "{\"inputs\": [\"5\\n2 2 1\\nBB\\n1 1 1\\nAB\\n3 2 8\\nAABBBBAABB\\n5 3 4\\nBBBBB\\n2 1 1\\nABABAB\\n\", \"5\\n2 1 1\\nBB\\n1 1 1\\nAB\\n3 2 8\\nAABBBBAABB\\n5 3 4\\nBBBBB\\n2 1 1\\nABABAB\\n\", \"5\\n2 1 1\\nBB\\n1 1 1\\nAB\\n3 0 8\\nAABBBBAABB\\n5 3 4\\nBBBBB\\n2 1 1\\nABABAB\\n\", \"5\\n3 1 0\\nBB\\n1 1 2\... | After a long party Petya decided to return home, but he turned out to be at the opposite end of the town from his home. There are $n$ crossroads in the line in the town, and there is either the bus or the tram station at each crossroad.
The crossroads are represented as a string $s$ of length $n$, where $s_i = \texttt... | 0.375 |
{"tests": "{\"inputs\": [\"5\\n4 1 5 4 1\\n6\\n1\\n6\\n2\\n3\\n4\\n5\\n\", \"5\\n4 4 4 4 4\\n6\\n1\\n3\\n6\\n5\\n2\\n4\\n\", \"1\\n1000000000\\n1\\n1000000000\\n\", \"50\\n13 41 88 93 19 85 19 79 56 17 9 50 73 26 46 5 8 52 77 62 71 86 2 88 4 97 85 90 95 93 5 71 51 48 26 23 5 56 52 96 7 9 70 63 15 89 55 11 97 31\\n50\\n... | Recently in Divanovo, a huge river locks system was built. There are now $n$ locks, the $i$-th of them has the volume of $v_i$ liters, so that it can contain any amount of water between $0$ and $v_i$ liters. Each lock has a pipe attached to it. When the pipe is open, $1$ liter of water enters the lock every second.
Th... | 0 |
{"tests": "{\"inputs\": [\"4 10 1 4\\n1 2 52\\n1 3 68\\n3 4 79\", \"4 10 1 4\\n1 2 52\\n1 3 0\\n3 4 79\", \"4 10 1 4\\n1 2 52\\n2 3 68\\n3 4 79\", \"4 10 1 4\\n1 2 52\\n1 3 68\\n3 4 74\", \"4 10 1 4\\n1 2 52\\n1 3 68\\n3 4 17\", \"4 10 1 4\\n1 2 93\\n1 3 68\\n3 4 74\", \"4 10 2 4\\n1 2 52\\n1 3 68\\n3 4 17\", \"4 10 1 ... | problem
There are $ N $ islands numbered from $ 1 $ to $ N $.
Each island has $ N-1 $ bridges, allowing any $ 2 $ island to move to each other across several bridges.
Each bridge has durability, and the durability of the $ i $ th bridge given the input is $ w_i $.
There are $ 1 $ treasures on each island, and you can ... | 0.125 |
{"tests": "{\"inputs\": [\"-210 783 -260 833\\n10\\n406 551 1000\\n372 -373 999\\n-12 -532 999\\n371 -30 999\\n258 480 558\\n648 -957 1000\\n-716 654 473\\n156 813 366\\n-870 425 707\\n-288 -426 1000\\n\", \"0 0 1 1\\n1\\n-1 -1000 1000\\n\", \"-705 595 -702 600\\n1\\n-589 365 261\\n\", \"1 1 1000 1000\\n1\\n50 50 1\\n\... | The Super Duper Secret Meeting of the Super Duper Secret Military Squad takes place in a Super Duper Secret Place. The place is an infinite plane with introduced Cartesian coordinate system. The meeting table is represented as a rectangle whose sides are parallel to the coordinate axes and whose vertexes are located at... | 0.625 |
{"tests": "{\"inputs\": [\"4 2 1\\n2 2 1 2 3 2 2 3\\n\", \"2 1 0\\n10 10\\n\", \"1 2 1\\n5 2\\n\", \"3 2 1\\n1 2 3 4 5 6\\n\", \"10 3 189\\n267 697 667 4 52 128 85 616 142 344 413 660 962 194 618 329 266 593 558 447 89 983 964 716 32 890 267 164 654 71\\n\", \"10 3 453\\n277 706 727 812 692 686 196 507 911 40 498 704 5... | You have m = n·k wooden staves. The i-th stave has length a_{i}. You have to assemble n barrels consisting of k staves each, you can use any k staves to construct a barrel. Each stave must belong to exactly one barrel.
Let volume v_{j} of barrel j be equal to the length of the minimal stave in it. [Image]
You want t... | 0 |
{"tests": "{\"inputs\": [\"1 1 5 5\\n\", \"-1 -3 1 3\\n\", \"-2 -2 2 2\\n\", \"0 0 2 2\\n\", \"0 0 2 0\\n\", \"0 0 0 0\\n\", \"0 -2 0 2\\n\", \"-2 -2 -2 0\\n\", \"-1000000000 -1000000000 1000000000 1000000000\\n\", \"-999999999 -999999999 999999999 999999999\\n\", \"-999999999 -999999999 -1 -1\\n\", \"-411495869 338346... | Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem.
A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will... | 0.375 |
{"tests": "{\"inputs\": [\"7 2\\n0 1 0 2 1 0 2\\n2 1\\n\", \"10 3\\n0 0 1 2 3 0 2 0 1 2\\n1 1 4\\n\", \"5 1\\n1 1 1 1 1\\n5\\n\", \"100 10\\n1 1 6 6 6 2 5 7 6 5 3 7 10 10 8 9 7 6 9 2 6 7 8 6 7 5 2 5 10 1 10 1 8 10 2 9 7 1 6 8 3 10 9 4 4 8 8 6 6 1 5 5 6 5 6 6 6 9 4 7 5 4 6 6 1 1 2 1 8 10 6 2 1 7 2 1 8 10 9 2 7 3 1 5 10 ... | Vasiliy has an exam period which will continue for n days. He has to pass exams on m subjects. Subjects are numbered from 1 to m.
About every day we know exam for which one of m subjects can be passed on that day. Perhaps, some day you can't pass any exam. It is not allowed to pass more than one exam on any day.
On ... | 0 |
{"tests": "{\"inputs\": [\"4 5\\n1 2\\n1 3\\n3 4\\n2 4\\n1 4\\n\", \"3 3\\n1 2\\n2 3\\n3 1\\n\", \"6 8\\n1 2\\n2 3\\n3 1\\n4 3\\n5 4\\n6 5\\n1 6\\n6 2\\n\", \"3 4\\n1 2\\n2 3\\n3 2\\n3 1\\n\", \"3 6\\n1 2\\n2 3\\n3 1\\n2 1\\n1 3\\n3 2\\n\", \"3 6\\n1 2\\n2 3\\n3 1\\n2 1\\n3 2\\n1 3\\n\", \"10 2\\n8 7\\n10 5\\n\", \"12 ... | You are given a directed graph with $n$ vertices and $m$ directed edges without self-loops or multiple edges.
Let's denote the $k$-coloring of a digraph as following: you color each edge in one of $k$ colors. The $k$-coloring is good if and only if there no cycle formed by edges of same color.
Find a good $k$-colorin... | 0 |
{"tests": "{\"inputs\": [\"6\\n3 1 0\\n0 3 0\\n2 2 0\\n1 0 0\\n1 3 0\\n0 1 0\\n\", \"8\\n0 1 1\\n1 0 1\\n1 1 0\\n1 1 1\\n2 2 2\\n3 2 2\\n2 3 2\\n2 2 3\\n\", \"2\\n-32839949 -68986721 41592956\\n-32839949 -31435211 41592956\\n\", \"2\\n34319950 -11299623 -19866275\\n34319950 -11299623 98728529\\n\", \"2\\n62887961 73879... | This is a harder version of the problem. In this version, $n \le 50\,000$.
There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even.
You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snap... | 0 |
{"tests": "{\"inputs\": [\"bbbgggbgbbgbbgggbgbgggggbbbbgggbgbbgbbgggbgbgggggbbbbgggbgbbgbbgggbgbgggggbbbbgggbgbbgbbgggbgbggggggggggbgbgggbbgbbgbgggbbbbgggggbgbgggbbgbbgbgggbbbbgggggbgbgggbbgbbgbgggbbbbgggggbgbgggbbgbbgbgggbbbbbbgggbgbbgbbgggbgbgggggbbbbgggbgbbgbbgggbgbgggggbbbbgggbgbbgbbgggbgbgggggbbbbgggbgbbgbbgggbgbg... | Reading books is one of Sasha's passions. Once while he was reading one book, he became acquainted with an unusual character. The character told about himself like that: "Many are my names in many countries. Mithrandir among the Elves, Tharkûn to the Dwarves, Olórin I was in my youth in the West that is forgotten, in t... | 0.75 |
{"tests": "{\"inputs\": [\"3\\n6 6 3\\n19 7 4\\n21 8 1\\n6\\n5 4 2 11\\n12 4 2 11\\n11 9 2 11\\n14 3 22 5\\n17 9 20 5\\n20 10 20 5\\n0\", \"3\\n6 6 3\\n19 7 6\\n42 8 1\\n6\\n5 4 2 11\\n12 4 2 11\\n11 9 1 11\\n14 3 22 5\\n17 9 20 5\\n20 10 20 5\\n0\", \"3\\n6 6 3\\n19 7 6\\n42 8 1\\n6\\n5 4 2 11\\n12 4 2 15\\n11 9 1 11\... | Taro is not good at hide-and-seek. As soon as you hide, you will find it, and it will be difficult to find the hidden child. My father, who couldn't see it, made an ultra-high performance location search system. You can use it to know exactly where your friends are, including your own. Once you become a demon, you can ... | 0 |
{"tests": "{\"inputs\": [\"MFM\\n\", \"MMFF\\n\", \"FFMMM\\n\", \"MMFMMFFFFM\\n\", \"MFFFMMFMFMFMFFFMMMFFMMMMMMFMMFFMMMFMMFMFFFMMFMMMFFMMFFFFFMFMFFFMMMFFFMFMFMFMFFFMMMMFMMFMMFFMMMMMMFFM\\n\", \"MFFMFMFFMM\\n\", \"MFFFFFMFFM\\n\", \"MMMFMFFFFF\\n\", \"MMMMMFFMFMFMFMMFMMFFMMFMFFFFFFFMFFFMMMMMMFFMMMFMFMMFMFFMMFMMMFFFFFMMM... | There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.
Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning... | 0.25 |
{"tests": "{\"inputs\": [\"4\\n3 2 4 1\\n\", \"2\\n1 2\\n\", \"8\\n4 6 3 2 8 5 7 1\\n\", \"2\\n0 2\", \"8\\n4 6 5 2 8 5 7 1\", \"4\\n3 3 4 1\", \"2\\n-1 2\", \"8\\n4 6 5 2 8 5 0 1\", \"2\\n-1 0\", \"8\\n2 6 5 2 8 5 0 1\", \"2\\n-1 1\", \"8\\n2 6 5 2 8 4 0 1\", \"2\\n0 1\", \"8\\n2 6 5 2 1 4 0 1\", \"2\\n0 0\", \"2\\n0 ... | Let N be a positive even number.
We have a permutation of (1, 2, ..., N), p = (p_1, p_2, ..., p_N).
Snuke is constructing another permutation of (1, 2, ..., N), q, following the procedure below.
First, let q be an empty sequence.
Then, perform the following operation until p becomes empty:
- Select two adjacent elemen... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 2 3 4\\n4 3 2 1\\n0 1 1 0\\n\", \"7\\n8 5 7 6 1 8 9\\n2 7 9 5 4 3 1\\n2 3 3 4 1 1 3\\n\", \"3\\n1 1 1\\n1 2 1\\n1 1 1\\n\", \"7\\n1 3 8 9 3 4 4\\n6 0 6 6 1 8 4\\n9 6 3 7 8 8 2\\n\", \"2\\n3 5\\n9 8\\n4 0\\n\", \"7\\n3 6 1 5 4 2 0\\n9 7 3 7 2 6 0\\n1 6 5 7 5 4 1\\n\", \"1\\n0\\n1\\n4\\n\... | Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more.
Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with c... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 2 3 4\\n4 3 2 1\\n1009\\n\", \"100\\n2 2 10 3 5 6 4 7 9 8 2 7 5 5 1 7 5 9 2 2 10 3 6 10 9 9 10 7 3 9 7 8 8 3 9 3 9 3 3 6 3 7 9 9 7 10 9 1 1 3 6 2 9 5 9 9 6 2 6 5 6 8 2 10 1 1 6 8 8 4 5 2 6 8 8 5 9 2 3 3 7 7 10 5 4 2 10 6 7 6 5 4 10 6 10 3 9 9 1 5\\n3 5 6 4 2 3 2 9 3 8 3 1 10 7 4 3 6 9 3... | Little Dima has two sequences of points with integer coordinates: sequence (a1, 1), (a2, 2), ..., (an, n) and sequence (b1, 1), (b2, 2), ..., (bn, n).
Now Dima wants to count the number of distinct sequences of points of length 2·n that can be assembled from these sequences, such that the x-coordinates of points in th... | 0 |
{"tests": "{\"inputs\": [\"369727\\n\", \"123456789987654321\\n\", \"1\\n\", \"3636363636363454545454543636363636454545452727272727218181818181999111777\\n\", \"1188\\n\", \"121212912121291299129191219\\n\", \"181818918181891918918181918189181818181891818191818191819189\\n\", \"12191219121912191219121912191219121912191... | Inna loves digit 9 very much. That's why she asked Dima to write a small number consisting of nines. But Dima must have misunderstood her and he wrote a very large number a, consisting of digits from 1 to 9.
Inna wants to slightly alter the number Dima wrote so that in the end the number contained as many digits nine ... | 0 |
{"tests": "{\"inputs\": [\"4\\nsandwich 80 120\\napple 50 200\\ncheese 20 40\\ncake 100 100\\n9\\nonigiri 80 300\\nonigiri 80 300\\nanpan 70 280\\nmikan 50 80\\nkanzume 100 500\\nchocolaue 50 350\\ncookie 30 80\\npurin 40 400\\ncracker 40 160\\n0\", \"4\\nsandwich 80 120\\napple 50 200\\ncheese 20 40\\ncake 100 100\\n9... | I bought food at the store to make a lunch box to eat at lunch. At the store, I only got an elongated bag to put food in, so I had to stack all the food vertically and put it in the bag. I want to pack the bag with the heavy ones down so that it won't fall over, but some foods are soft and will collapse if I put a heav... | 0.125 |
{"tests": "{\"inputs\": [[[43, 23, 40, 13], 4], [[18, 15], 2], [[43, 23, 40, 13], 3], [[33, 8, 16, 47, 30, 30, 46], 5], [[6, 24, 6, 8, 28, 8, 23, 47, 17, 29, 37, 18, 40, 49], 2], [[50, 50], 2], [[50, 50, 25, 50, 24], 3], [[50, 51, 25, 50, 25], 3], [[50, 100, 25, 50, 26], 3], [[100], 2], [[50, 50], 3], [[50, 51], 3]], \... | # A History Lesson
The Pony Express was a mail service operating in the US in 1859-60.
It reduced the time for messages to travel between the Atlantic and Pacific coasts to about 10 days, before it was made obsolete by the transcontinental telegraph.
# How it worked
There were a number of *stations*, where:
*... | 0 |
{"tests": "{\"inputs\": [\"4\\n\", \"11\\n\", \"22\\n\", \"3\\n\", \"1024\\n\", \"101\\n\", \"30\\n\", \"1000000\\n\", \"1\\n\", \"2\\n\", \"5\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"10\\n\", \"999000\\n\", \"999001\\n\", \"999999\\n\", \"933206\\n\", \"718351\\n\", \"607443\\n\", \"347887\\n\", \"246206\\n\", ... | Your security guard friend recently got a new job at a new security company. The company requires him to patrol an area of the city encompassing exactly N city blocks, but they let him choose which blocks. That is, your friend must walk the perimeter of a region whose area is exactly N blocks. Your friend is quite lazy... | 0 |
{"tests": "{\"inputs\": [\"2019/04/30\\n\", \"2019/11/01\\n\", \"2019/01/01\\n\", \"2019/02/28\\n\", \"2019/04/29\\n\", \"2019/05/01\\n\", \"2019/10/10\\n\", \"2019/12/31\\n\", \"2019/03/30\", \"2019/11/00\", \"2019/04/20\", \"2019/12/01\", \"2019/14/20\", \"2119/12/01\", \"2019/24/10\", \"1019/04/30\", \"2119/10/01\",... | You are given a string S as input. This represents a valid date in the year 2019 in the yyyy/mm/dd format. (For example, April 30, 2019 is represented as 2019/04/30.)
Write a program that prints Heisei if the date represented by S is not later than April 30, 2019, and prints TBD otherwise.
-----Constraints-----
- S i... | 0 |
{"tests": "{\"inputs\": [[1, 2, 3, 1, 2], [1, 1], [1, 0], [\"a\", \"b\"], [\"a\", \"b\", \"a\"], [1, 2, 42, 3, 4, 5, 42], [\"a\", \"b\", \"c\", \"d\"], [\"a\", \"b\", \"c\", \"c\"], [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"f\", \"b\"]], \"outputs\": [[true], [true], [false], [false], [true], [true], [false], [true]... | Complete the solution so that it returns true if it contains any duplicate argument values. Any number of arguments may be passed into the function.
The array values passed in will only be strings or numbers. The only valid return values are `true` and `false`.
Examples:
```
solution(1, 2, 3) --> false
s... | 0.875 |
{"tests": "{\"inputs\": [\"4\\n3 2 1 2\\n\", \"3\\n2 3 8\\n\", \"5\\n2 1 2 1 2\\n\", \"1\\n1\\n\", \"2\\n4 3\\n\", \"6\\n100 40 60 20 1 80\\n\", \"10\\n10 8 6 7 5 3 4 2 9 1\\n\", \"10\\n1 2 3 4 5 6 7 8 9 10\\n\", \"100\\n82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 13 49 41 36 41 7... | Little Chris is bored during his physics lessons (too easy), so he has built a toy box to keep himself occupied. The box is special, since it has the ability to change gravity.
There are n columns of toy cubes in the box arranged in a line. The i-th column contains a_{i} cubes. At first, the gravity in the box is pull... | 0.875 |
{"tests": "{\"inputs\": [[\"mmm\"], [\"apple\"], [\"super\"], [\"orange\"], [\"grapes\"], [\"supercalifragilisticexpialidocious\"], [\"123456\"], [\"crIssUm\"], [\"Implied\"], [\"rIc\"], [\"UNDISARMED\"], [\"bialy\"], [\"stumpknocker\"], [\"narboonnee\"], [\"carlstadt\"], [\"ephodee\"], [\"spicery\"], [\"oftenness\"], ... | We want to know the index of the vowels in a given word, for example, there are two vowels in the word super (the second and fourth letters).
So given a string "super", we should return a list of [2, 4].
Some examples:
Mmmm => []
Super => [2,4]
Apple => [1,5]
YoMama -> [1,2,4... | 0.875 |
{"tests": "{\"inputs\": [\"3\\n3\\n2 2 2\\n3\\n2 2 3\\n5\\n0 0 0 2 2\\n\", \"4\\n5\\n4 1 3 1 3\\n4\\n1 0 1 6\\n1\\n0\\n2\\n5 4\\n\", \"3\\n3\\n2 2 0\\n3\\n2 2 3\\n5\\n0 0 0 2 2\\n\", \"3\\n3\\n4 2 0\\n3\\n2 2 3\\n5\\n0 0 0 2 2\\n\", \"3\\n3\\n4 2 0\\n3\\n2 2 4\\n5\\n0 0 0 2 2\\n\", \"4\\n5\\n4 1 5 1 3\\n4\\n1 0 1 6\\n1... | Koa the Koala and her best friend want to play a game.
The game starts with an array a of length n consisting of non-negative integers. Koa and her best friend move in turns and each have initially a score equal to 0. Koa starts.
Let's describe a move in the game:
* During his move, a player chooses any element of... | 0 |
{"tests": "{\"inputs\": [\"2\\n1 2\\n\", \"4\\n1 1 2 3\\n\", \"5\\n1 1 1 1 1\\n\", \"7\\n1 2 1 3 1 2 1\\n\", \"1\\n1\\n\", \"3\\n1 1 3\\n\", \"10\\n1 1 3 2 2 1 3 4 7 5\\n\", \"20\\n1 2 2 2 2 1 4 7 8 6 5 3 5 3 8 11 5 10 16 10\\n\", \"32\\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 1 1 1\\n\", \"10\\n1 1 3... | One day, little Vasya found himself in a maze consisting of (n + 1) rooms, numbered from 1 to (n + 1). Initially, Vasya is at the first room and to get out of the maze, he needs to get to the (n + 1)-th one.
The maze is organized as follows. Each room of the maze has two one-way portals. Let's consider room number i (... | 0 |
{"tests": "{\"inputs\": [\"3\\n101\\n\", \"1\\n1\\n\", \"2\\n01\\n\", \"2\\n00\\n\", \"1\\n0\\n\", \"2\\n11\\n\", \"3\\n000\\n\", \"3\\n010\\n\", \"3\\n111\\n\", \"4\\n0000\\n\", \"4\\n0100\\n\", \"4\\n0110\\n\", \"4\\n1011\\n\", \"4\\n1111\\n\", \"5\\n10110\\n\", \"5\\n01100\\n\", \"6\\n111000\\n\", \"6\\n101111\\n\",... | $2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played in that phase). When a ... | 0 |
{"tests": "{\"inputs\": [[[5, 3, 2, 8, 1, 4, 11]], [[2, 22, 37, 11, 4, 1, 5, 0]], [[1, 111, 11, 11, 2, 1, 5, 0]], [[]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 0]], [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], [[0, 1, 2, 3, 4, 9, 8, 7, 6, 5]]], \"outputs\": [[[1, 3, 8, 4, 5, 2, 11]], [[22, 4, 1, 5, 2, 11, 37, 0]], [[1, 1, 5, 11, 2, 11, 111,... | You are given an array of integers. Your task is to sort odd numbers within the array in ascending order, and even numbers in descending order.
Note that zero is an even number. If you have an empty array, you need to return it.
For example:
```
[5, 3, 2, 8, 1, 4] --> [1, 3, 8, 4, 5, 2]
odd numbers ascending: [... | 0 |
{"tests": "{\"inputs\": [\"4 3\\n1 3\\n2 4\\n3 4\\n\", \"6 4\\n3 2\\n1 3\\n6 5\\n4 6\\n\", \"4 3\\n1 3\\n1 4\\n3 4\\n\", \"3 1\\n1 2\\n\", \"5 9\\n4 3\\n4 2\\n3 1\\n5 1\\n4 1\\n2 1\\n5 2\\n3 2\\n5 4\\n\", \"4 2\\n2 3\\n1 4\\n\", \"4 4\\n1 2\\n4 1\\n3 4\\n3 1\\n\", \"20 55\\n20 11\\n14 5\\n4 9\\n17 5\\n16 5\\n20 16\\n11... | One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties:
* G has exactly n vertices, numbered from 1 to... | 0 |
{"tests": "{\"inputs\": [\"4 6\\nbaba\\nR++\\nL++\\nR++\\nL++\\nR++\\nL++\", \"6 4\\nabcde\\nR++\\nR++\\nL++\\nL--\", \"6 2\\nabdde\\nR++\\nR++\\nL++\\nL--\", \"4 6\\nbaab\\nR++\\nL++\\nR++\\nL++\\nR++\\nL++\", \"5 0\\nabcde\\nR++\\nR++\\nL++\\nL--\", \"6 1\\nabcde\\nR++\\nR++\\nL++\\nL--\", \"8 6\\nbacb\\nR++\\nL++\\n... | Given a string of length n s = s1, s2,…, sn and m queries. Each query qk (1 ≤ k ≤ m) is one of four types, "L ++", "L-", "R ++", "R-", and l [for the kth query qk. k] and r [k] are defined below.
* L ++: l [k] = l [k-1] + 1, r [k] = r [k-1]
* L-: l [k] = l [k-1] -1, r [k] = r [k-1]
* R ++: l [k] = l [k-1], r [k] = r... | 0.875 |
{"tests": "{\"inputs\": [\"CBA\\ncba\\ncCa\\nX\\nYZ\\nZ\\n-\", \"CBA\\ncba\\ncCa\\nY\\nYZ\\nZ\\n-\", \"CBA\\ncca\\ncCa\\nX\\nZY\\nZ\\n-\", \"CAB\\ncba\\ncCa\\nX\\nYZ\\nZ\\n-\", \"CAB\\ncca\\ncCa\\nX\\nYZ\\nZ\\n-\", \"CAA\\ncca\\ncCa\\nX\\nYZ\\nZ\\n-\", \"CBA\\nabc\\naCc\\nX\\nZY\\nZ\\n-\", \"CBA\\ncba\\ncCa\\nX\\nXZ\\n... | Nantendo Co., Ltd. has released a game software called Packet Monster. This game was intended to catch, raise, and fight monsters, and was a very popular game all over the world.
This game had features not found in traditional games. There are two versions of this game, Red and Green, and the monsters that can be caug... | 0 |
{"tests": "{\"inputs\": [\"5\\n! abc\\n. ad\\n. b\\n! cd\\n? c\\n\", \"8\\n! hello\\n! codeforces\\n? c\\n. o\\n? d\\n? h\\n. l\\n? e\\n\", \"7\\n! ababahalamaha\\n? a\\n? b\\n? a\\n? b\\n? a\\n? h\\n\", \"4\\n! abcd\\n! cdef\\n? d\\n? c\\n\", \"1\\n? q\\n\", \"15\\n. r\\n? e\\n. s\\n. rw\\n? y\\n. fj\\n. zftyd\\n? r\\... | Valentin participates in a show called "Shockers". The rules are quite easy: jury selects one letter which Valentin doesn't know. He should make a small speech, but every time he pronounces a word that contains the selected letter, he receives an electric shock. He can make guesses which letter is selected, but for eac... | 0 |
{"tests": "{\"inputs\": [\"6\\n8\\n1 1 2 2 3 2 1 1\\n3\\n1 3 3\\n4\\n1 10 10 1\\n1\\n26\\n2\\n2 1\\n3\\n1 1 1\\n\", \"6\\n8\\n1 1 2 2 3 2 1 1\\n3\\n1 3 3\\n4\\n1 10 10 1\\n1\\n26\\n2\\n2 2\\n3\\n1 1 1\\n\", \"6\\n8\\n1 1 2 2 3 2 1 1\\n3\\n1 3 2\\n4\\n1 10 10 1\\n1\\n26\\n2\\n2 1\\n3\\n1 1 1\\n\", \"6\\n8\\n1 1 2 2 1 2 ... | The only difference between easy and hard versions is constraints.
You are given a sequence $a$ consisting of $n$ positive integers.
Let's define a three blocks palindrome as the sequence, consisting of at most two distinct elements (let these elements are $a$ and $b$, $a$ can be equal $b$) and is as follows: $[\unde... | 0.125 |
{"tests": "{\"inputs\": [\"4\\n1 2\\n2 3\\n3 4\\n\", \"6\\n1 2\\n2 3\\n3 4\\n2 5\\n3 6\\n\", \"5\\n1 2\\n1 3\\n1 4\\n1 5\\n\", \"2\\n1 2\\n\", \"8\\n1 2\\n1 3\\n1 4\\n1 8\\n7 8\\n6 8\\n5 8\\n\", \"9\\n1 2\\n1 3\\n1 4\\n1 5\\n1 6\\n6 7\\n7 8\\n7 9\\n\", \"3\\n2 3\\n1 2\\n\", \"9\\n1 2\\n1 3\\n1 4\\n1 5\\n1 6\\n6 7\\n7 8... | Ramesses knows a lot about problems involving trees (undirected connected graphs without cycles)!
He created a new useful tree decomposition, but he does not know how to construct it, so he asked you for help!
The decomposition is the splitting the edges of the tree in some simple paths in such a way that each two pa... | 0 |
{"tests": "{\"inputs\": [\"3\\n2 1\\n1 0\\n0 1\\n\", \"5\\n0 0\\n0 1\\n0 2\\n0 3\\n0 4\\n\", \"10\\n-1 2\\n-3 0\\n5 5\\n4 4\\n-2 1\\n1 1\\n3 3\\n2 2\\n0 0\\n-1000000000 0\\n\", \"10\\n-678318184 2\\n-678318182 3\\n580731357 2\\n-678318182 1\\n-678318184 1\\n-678318183 0\\n-678318181 2\\n580731357 1\\n580731358 0\\n-678... | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 0 |
{"tests": "{\"inputs\": [[193150], [300], [20001], [800], [1001], [100], [260], [1111], [1234], [99999], [10], [234], [193241], [79], [270]], \"outputs\": [[5], [0], [6], [5], [1], [5], [5], [9], [7], [6], [5], [2], [1], [1], [0]]}", "source": "taco"} | As you probably know, Fibonacci sequence are the numbers in the following integer sequence:
1, 1, 2, 3, 5, 8, 13...
Write a method that takes the index as an argument and returns last digit from fibonacci number. Example:
getLastDigit(15) - 610. Your method must return 0 because the last digit of 610 is 0.
Fibonacci ... | 0.125 |
{"tests": "{\"inputs\": [\"000\\n\", \"0101\\n\", \"0001111\\n\", \"00101100011100\\n\", \"0\\n\", \"11\\n\", \"01011111111101101100000100000000100000111001011011110110110010010001011110100011000011100100010001\\n\", \"01001111001001010011011110010111010110011111001101111011100010010101111000100111000110111011110101111... | Koa the Koala has a binary string $s$ of length $n$. Koa can perform no more than $n-1$ (possibly zero) operations of the following form:
In one operation Koa selects positions $i$ and $i+1$ for some $i$ with $1 \le i < |s|$ and sets $s_i$ to $max(s_i, s_{i+1})$. Then Koa deletes position $i+1$ from $s$ (after the rem... | 0 |
{"tests": "{\"inputs\": [\"6\\n1 3 4 5 6 9\\n\", \"3\\n998 999 1000\\n\", \"5\\n1 2 3 4 5\\n\", \"1\\n1\\n\", \"2\\n1 2\\n\", \"2\\n999 1000\\n\", \"9\\n1 4 5 6 7 100 101 102 103\\n\", \"100\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 4... | JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \le a_1 < a_2 < \ldots < a_n \le 10^3$, and then went to the bathroom.
JATC decided to prank his friend by erasing some consecutive elements in th... | 0 |
{"tests": "{\"inputs\": [\"9\\n0 0 4 4\\n-1 5 4 0\\n4 0 4 4\\n5 2 11 2\\n6 1 6 7\\n5 6 11 6\\n10 1 10 7\\n7 0 9 8\\n10 -1 11 -1\\n\", \"4\\n-1 2 1 2\\n-1 0 1 0\\n-1 0 0 3\\n0 3 1 0\\n\", \"4\\n13 13 6 6\\n6 13 9 10\\n8 3 8 4\\n7 9 12 9\\n\", \"3\\n-2 5 0 2\\n6 6 8 8\\n-1 7 11 7\\n\", \"2\\n664158 4316 723615 981791\\n2... | You are given $n$ segments on a Cartesian plane. Each segment's endpoints have integer coordinates. Segments can intersect with each other. No two segments lie on the same line.
Count the number of distinct points with integer coordinates, which are covered by at least one segment.
-----Input-----
The first line co... | 0 |
{"tests": "{\"inputs\": [\"7\\n1101001\\n3 4 9 100 1 2 3\\n\", \"5\\n10101\\n3 10 15 15 15\\n\", \"1\\n1\\n1337\\n\", \"30\\n010010010010010010010010010010\\n1 1 1000000000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\", \"99\\n10101010101010101010101010101010101010101010101010101010101010101010101010101010... | Vasya has a string $s$ of length $n$ consisting only of digits 0 and 1. Also he has an array $a$ of length $n$.
Vasya performs the following operation until the string becomes empty: choose some consecutive substring of equal characters, erase it from the string and glue together the remaining parts (any of them can ... | 0 |
{"tests": "{\"inputs\": [\"2\\n1 1\\n\", \"3\\n2 1 2\\n\", \"100\\n61 41 85 52 22 82 98 25 60 35 67 78 65 69 55 86 34 91 92 36 24 2 26 15 76 99 4 95 79 31 13 16 100 83 21 90 73 32 19 33 77 40 72 62 88 43 84 14 10 9 46 70 23 45 42 96 94 38 97 58 47 93 59 51 57 7 27 74 1 30 64 3 63 49 50 54 5 37 48 11 81 44 12 17 75 71 8... | Some time ago Leonid have known about idempotent functions. Idempotent function defined on a set {1, 2, ..., n} is such function <image>, that for any <image> the formula g(g(x)) = g(x) holds.
Let's denote as f(k)(x) the function f applied k times to the value x. More formally, f(1)(x) = f(x), f(k)(x) = f(f(k - 1)(x))... | 0 |
{"tests": "{\"inputs\": [\"5 5\\n50 2\\n13 13\", \"2 5\\n50 1\\n13 13\", \"2 5\\n50 1\\n15 13\", \"5 10\\n50 1\\n13 20\", \"5 10\\n50 1\\n22 20\", \"8 10\\n50 1\\n22 20\", \"8 2\\n50 1\\n22 20\", \"8 2\\n50 2\\n22 20\", \"5 5\\n50 1\\n13 18\", \"5 5\\n50 2\\n13 4\", \"2 5\\n25 1\\n13 13\", \"2 5\\n6 1\\n15 13\", \"5 10... | Fibonacci number f(i) appear in a variety of puzzles in nature and math, including packing problems, family trees or Pythagorean triangles. They obey the rule f(i) = f(i - 1) + f(i - 2), where we set f(0) = 1 = f(-1).
Let V and d be two certain positive integers and be N ≡ 1001 a constant. Consider a set of V nodes, e... | 0.125 |
{"tests": "{\"inputs\": [\"4\\n3 0 0\\n1 1 1\\n9 4 2\\n0 1 2\", \"4\\n2 0 0\\n1 1 1\\n9 4 2\\n0 1 2\", \"4\\n3 0 1\\n1 1 1\\n9 4 1\\n0 1 2\", \"4\\n3 0 0\\n1 2 1\\n0 4 2\\n0 1 2\", \"4\\n0 0 0\\n1 2 1\\n0 4 2\\n0 1 3\", \"4\\n2 1 0\\n2 2 2\\n9 8 2\\n0 1 3\", \"4\\n0 1 2\\n3 0 2\\n9 19 0\\n0 2 3\", \"4\\n0 1 2\\n3 0 2\\... | At Akabe High School, which is a programmer training school, the roles of competition programmers in team battles are divided into the following three types.
C: | Coder | I am familiar with the language and code.
--- | --- | ---
A: | Algorithm | I am good at logical thinking and think about algorithms.
N: | Navigator |... | 0 |
{"tests": "{\"inputs\": [[\"LF5(RF3)(RF3R)F7\"], [\"(L(F5(RF3))(((R(F3R)F7))))\"], [\"F4L(F4RF4RF4LF4L)2F4RF4RF4\"], [\"F4L((F4R)2(F4L)2)2(F4R)2F4\"], [\"F2LF3L(F2)2LF5L(F3)2LF7L((F2)2)2L(F3)3L(F5)2\"], [\"F2LF3L(F2)2LF5L(F3)2LF7L(F4)2L((F3)1)3L(F5)2\"], [\"(F5RF5R(F3R)2)3\"], [\"((F5R)2(F3R)2)3\"], [\"((F3LF3R)2FRF6L)... | # RoboScript #3 - Implement the RS2 Specification
## Disclaimer
The story presented in this Kata Series is purely fictional; any resemblance to actual programming languages, products, organisations or people should be treated as purely coincidental.
## About this Kata Series
This Kata Series is based on a fictional... | 0 |
{"tests": "{\"inputs\": [\"1\\n1 1 9\\n\", \"2\\n2 3 20\\n2 4 40\\n\", \"2\\n1 2 5\\n2 3 5\\n\", \"2\\n1 2 5\\n2 3 10\\n\", \"2\\n2 2 20\\n2 4 40\\n\", \"2\\n2 2 20\\n2 7 16\\n\", \"1\\n1 1 8\\n\", \"2\\n2 2 5\\n2 -1 10\\n\", \"2\\n1 2 5\\n2 0 10\\n\", \"2\\n2 2 20\\n2 7 40\\n\", \"2\\n1 2 5\\n2 1 10\\n\", \"2\\n1 2 5\... | A rectangle with sides $A$ and $B$ is cut into rectangles with cuts parallel to its sides. For example, if $p$ horizontal and $q$ vertical cuts were made, $(p + 1) \cdot (q + 1)$ rectangles were left after the cutting. After the cutting, rectangles were of $n$ different types. Two rectangles are different if at least o... | 0 |
{"tests": "{\"inputs\": [\"5\\n3 5 2 1 4\\n4 3 2 5 1\\n\", \"7\\n5 2 3 6 7 1 4\\n2 3 6 7 1 4 5\\n\", \"2\\n1 2\\n1 2\\n\", \"2\\n1 2\\n2 1\\n\", \"2\\n0 2\\n0 2\\n\", \"2\\n2 1\\n1 2\\n\", \"2\\n0 1\\n0 1\\n\", \"2\\n2 1\\n2 1\\n\", \"2\\n1 2\\n1 2\\n\", \"7\\n5 2 3 6 7 1 4\\n2 3 6 7 1 4 5\\n\", \"5\\n3 5 2 1 4\\n4 3 2... | Consider a tunnel on a one-way road. During a particular day, $n$ cars numbered from $1$ to $n$ entered and exited the tunnel exactly once. All the cars passed through the tunnel at constant speeds.
A traffic enforcement camera is mounted at the tunnel entrance. Another traffic enforcement camera is mounted at the tun... | 0 |
{"tests": "{\"inputs\": [\"153\\n\", \"99\\n\", \"154\\n\", \"3\\n\", \"98\\n\", \"1000000000000\\n\", \"571684826707\\n\", \"152\\n\", \"663938115190\\n\", \"903398973606\\n\", \"420182289478\\n\", \"155\\n\", \"1\\n\", \"4\\n\", \"178573947413\\n\", \"1894100308\\n\", \"2\\n\", \"156\\n\", \"71\\n\", \"149302282966\\... | Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make:
1. The house consists of some non-zero number of floors.
2. Each ... | 0.875 |
{"tests": "{\"inputs\": [\"6 8\\nBBBBBBBB\\nBBBBBBBB\\nBBBBBBBB\\nWWWWWWWW\\nWWWWWWWW\\nWWWWWWWW\\n\", \"3 3\\nWBW\\nBWW\\nWWW\\n\", \"3 6\\nWWBBWW\\nWWBBWW\\nWWBBWW\\n\", \"4 4\\nBBBB\\nBBBB\\nBBBB\\nBBBW\\n\", \"10 9\\nBWWWBWWBB\\nBBWWBWBBW\\nBBWBWBWBB\\nBWBWBBBBB\\nBBWBWBWBW\\nBWWBWWBBW\\nWBWWWBWWW\\nWBBWBWBWW\\nBBW... | The first algorithm for detecting a face on the image working in realtime was developed by Paul Viola and Michael Jones in 2001. A part of the algorithm is a procedure that computes Haar features. As part of this task, we consider a simplified model of this concept.
Let's consider a rectangular image that is represent... | 0 |
{"tests": "{\"inputs\": [\"100\\n85 50 17 89 65 89 5 20 86 26 16 21 85 14 44 31 87 31 6 2 48 67 8 80 79 1 48 36 97 1 5 30 79 50 78 12 2 55 76 100 54 40 26 81 97 96 68 56 87 14 51 17 54 37 52 33 69 62 38 63 74 15 62 78 9 19 67 2 60 58 93 60 18 96 55 48 34 7 79 82 32 58 90 67 20 50 27 15 7 89 98 10 11 15 99 49 4 51 77 52... | Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers).
The key in football is to divide into teams fairly before the ... | 0 |
{"tests": "{\"inputs\": [\"0\", \"4\", \"1\", \"2\", \"000\", \"001\", \"2\", \"0\", \"1\", \"4\", \"001\", \"000\", \"3\"], \"outputs\": [\"0\\n\", \"4\\n1 2\\n1 3\\n2 4\\n3 4\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"4\\n1 2\\n1 3\\n2 4\\n3 4\\n\", \"0\\n\", \"0\\n\", \"2\\n1 3\\n2... | You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions:
* The graph is simple and connected.
* There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S.
It can be proved t... | 0 |
{"tests": "{\"inputs\": [\"6\\n1 3\\n2 3\\n3 4\\n4 5\\n4 6\\n\", \"4\\n1 2\\n2 3\\n3 4\\n\", \"3\\n1 3\\n2 3\\n\", \"14\\n1 2\\n2 3\\n3 4\\n4 5\\n5 6\\n6 7\\n7 8\\n8 9\\n5 10\\n10 11\\n10 12\\n10 13\\n10 14\\n\", \"28\\n2 24\\n2 4\\n2 3\\n1 2\\n1 17\\n1 21\\n1 22\\n10 22\\n22 23\\n22 26\\n25 26\\n16 25\\n7 26\\n5 7\\n5... | You have a tree of $n$ vertices. You are going to convert this tree into $n$ rubber bands on infinitely large plane. Conversion rule follows:
For every pair of vertices $a$ and $b$, rubber bands $a$ and $b$ should intersect if and only if there is an edge exists between $a$ and $b$ in the tree.
Shape of rubber bands ... | 0 |
{"tests": "{\"inputs\": [[\"Bryan Joubert\"], [\"Jesse Cox, !Selena Gomez\"], [\"!Eleena Daru, Obi-Wan Kenobi, Eleena Daru, Jar-Jar Binks\"], [\"Digital Daggers, !Kiny Nimaj, Rack Istley, Digital Daggers, Digital Daggers\"], [\"Albert Einstein, !Sarah Connor, Marilyn Monroe, Abraham Lincoln, Sarah Connor, Sean Connery,... | _A mad sociopath scientist just came out with a brilliant invention! He extracted his own memories to forget all the people he hates! Now there's a lot of information in there, so he needs your talent as a developer to automatize that task for him._
> You are given the memories as a string containing people's surname ... | 0 |
{"tests": "{\"inputs\": [\"4 6\\nX...XX\\n...XX.\\n.X..X.\\n......\\n1 6\\n2 2\\n\", \"5 4\\n.X..\\n...X\\nX.X.\\n....\\n.XX.\\n5 3\\n1 1\\n\", \"4 7\\n..X.XX.\\n.XX..X.\\nX...X..\\nX......\\n2 2\\n1 6\\n\", \"5 3\\n.XX\\n...\\n.X.\\n.X.\\n...\\n1 3\\n4 1\\n\", \"1 1\\nX\\n1 1\\n1 1\\n\", \"1 6\\n.X...X\\n1 2\\n1 5\\n\... | You play a computer game. Your character stands on some level of a multilevel ice cave. In order to move on forward, you need to descend one level lower and the only way to do this is to fall through the ice.
The level of the cave where you are is a rectangular square grid of n rows and m columns. Each cell consists e... | 0 |
{"tests": "{\"inputs\": [[[], [\"Philadelphia\", \"Osaka\", \"Tokyo\", \"Melbourne\"]], [[], [\"Brussels\", \"Madrid\", \"London\"]], [[], [\"Sydney\", \"Tokyo\"]], [[\"London\", \"Berlin\", \"Mexico City\", \"Melbourne\", \"Buenos Aires\", \"Hong Kong\", \"Madrid\", \"Paris\"], [\"Berlin\", \"Melbourne\"]], [[\"Beijin... | Lucy loves to travel. Luckily she is a renowned computer scientist and gets to travel to international conferences using her department's budget.
Each year, Society for Exciting Computer Science Research (SECSR) organizes several conferences around the world. Lucy always picks one conference from that list that is hos... | 0 |
{"tests": "{\"inputs\": [\"3 1\\n3 4 6 0\\n\", \"4 3\\n4 10 14 1\\n3 6 6 0\\n2 3 3 1\\n\", \"4 2\\n3 4 6 1\\n4 12 15 1\\n\", \"4 2\\n3 4 5 1\\n2 3 3 1\\n\", \"1 0\\n\", \"1 1\\n1 1 1 0\\n\", \"1 1\\n1 1 1 0\\n\", \"1 0\\n\", \"4 3\\n4 10 14 1\\n3 7 6 0\\n2 3 3 1\\n\", \"4 2\\n3 4 5 1\\n2 3 6 1\\n\", \"1 1\\n1 1 1 1\\n\... | Amr bought a new video game "Guess Your Way Out! II". The goal of the game is to find an exit from the maze that looks like a perfect binary tree of height h. The player is initially standing at the root of the tree and the exit from the tree is located at some leaf node.
Let's index all the nodes of the tree such tha... | 0.25 |
{"tests": "{\"inputs\": [\"4\\n2 1 4 1\", \"8\\n347554626 129662684 181537270 324043958 468214806 916875077 825989291 319670097\", \"5\\n1 2 2 4 5\", \"8\\n67210447 129662684 181537270 324043958 468214806 916875077 825989291 319670097\", \"5\\n1 2 2 8 5\", \"4\\n3 1 4 4\", \"8\\n989919 129662684 181537270 289484339 259... | There are N positive integers A_1, A_2, ..., A_N. Takahashi can perform the following operation on these integers any number of times:
* Choose 1 \leq i \leq N and multiply the value of A_i by -2.
Notice that he multiplies it by minus two.
He would like to make A_1 \leq A_2 \leq ... \leq A_N holds. Find the minimu... | 0 |
{"tests": "{\"inputs\": [\"10\\n10 71 113 33 6 47 23 25 52 64\", \"7\\n1 2 3 1100000000 4 5 6\", \"5\\n3 2 4 2 2\", \"10\\n10 102 113 33 6 47 23 25 52 64\", \"7\\n1 2 3 1100000000 4 5 2\", \"10\\n10 102 113 60 6 47 23 25 52 64\", \"5\\n5 2 4 2 1\", \"10\\n10 102 113 60 6 47 23 25 52 118\", \"7\\n1 2 3 1100000000 1 20 2... | Snuke has an integer sequence A of length N.
He will make three cuts in A and divide it into four (non-empty) contiguous subsequences B, C, D and E. The positions of the cuts can be freely chosen.
Let P,Q,R,S be the sums of the elements in B,C,D,E, respectively. Snuke is happier when the absolute difference of the ma... | 0.625 |
{"tests": "{\"inputs\": [\"5 2\\n0 1 5\\n1 1 4\\n\", \"7 3\\n1 1 4\\n1 4 6\\n0 1 7\\n\", \"5 4\\n0 1 2\\n1 2 3\\n0 3 4\\n1 4 5\\n\", \"10 2\\n0 1 4\\n1 1 4\\n\", \"7 2\\n1 1 4\\n0 4 5\\n\", \"5 3\\n0 1 3\\n1 2 4\\n0 4 5\\n\", \"4 3\\n1 1 2\\n0 2 3\\n0 3 4\\n\", \"7 5\\n1 1 2\\n1 6 7\\n0 2 3\\n0 3 4\\n0 2 4\\n\", \"10 2... | Vasya has an array a_1, a_2, ..., a_n.
You don't know this array, but he told you m facts about this array. The i-th fact is a triple of numbers t_i, l_i and r_i (0 ≤ t_i ≤ 1, 1 ≤ l_i < r_i ≤ n) and it means:
* if t_i=1 then subbarray a_{l_i}, a_{l_i + 1}, ..., a_{r_i} is sorted in non-decreasing order;
* if t_i... | 0 |
{"tests": "{\"inputs\": [\"48 9297 240 126 32\\n20 3010 157 141 7\\n30 117002 5680 962 15\\n8 1673 1712 190 22\\n64 8478 87 54 307\\n23 5477 117 92 12\\n50 7558 1396 187 17\\n279 88677 2825 514 14\\n0\", \"48 9297 240 126 32\\n20 3010 157 141 7\\n30 117002 5843 962 15\\n8 1673 1712 190 22\\n64 8478 87 54 307\\n23 5477 ... | In April 2008, Aizuwakamatsu City succeeded in making yakitori with a length of 20 m 85 cm. The chicken used at this time is Aizu local chicken, which is a specialty of Aizu. Aizu local chicken is very delicious, but it is difficult to breed, so the production volume is small and the price is high.
<image>
Relative... | 0 |
{"tests": "{\"inputs\": [[11], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 22, 9], [\"4\"], [\"4\", 7, \"9\"], [\"words\"], [[1, 2]], [407, 8208], [-1], [\"\"], [\"\", 407], [407, \"\"], [5, \"\", 407], [9474], [{}]], \"outputs\": [[false], [true], [false], [true], [true], [false], [false], [true], [false]... | Well, those numbers were right and we're going to feed their ego.
Write a function, isNarcissistic, that takes in any amount of numbers and returns true if all the numbers are narcissistic. Return false for invalid arguments (numbers passed in as strings are ok).
For more information about narcissistic numbers (and b... | 0 |
{"tests": "{\"inputs\": [[\"X\"], [\"X\\n.\"], [\".X\\n..\"], [\"..\\n.X\"], [\"..\\nX.\"], [\".......\\nX.......\"], [\"..........\\n..........\\n.......X..\\n..........\\n..........\"], [\"..........\\n..........\\n..........\\n........X.\\n..........\"], [\"........................\"], [\"\\n\\n\\n\\n\"]], \"outputs... | Late last night in the Tanner household, ALF was repairing his spaceship so he might get back to Melmac. Unfortunately for him, he forgot to put on the parking brake, and the spaceship took off during repair. Now it's hovering in space.
ALF has the technology to bring the spaceship home if he can lock on to its locati... | 0 |
{"tests": "{\"inputs\": [[\"\"], [\"a\"], [\"ab\"], [\"abc\"], [\"abab\"], [\"abcde\"], [\"aaaaaaaaaaaaaa\"], [\"abaabaaab\"], [\"dbdbebedbddbedededeeddbbdeddbeddeebdeddeebbbb\"], [\"vttussvutvuvvtustsvsvtvu\"]], \"outputs\": [[\"\"], [\"a\"], [\"a\"], [\"aba\"], [\"a\"], [\"aecea\"], [\"a\"], [\"aba\"], [\"deededebdde... | # Task
Christmas is coming. In the [previous kata](https://www.codewars.com/kata/5a405ba4e1ce0e1d7800012e), we build a custom Christmas tree with the specified characters and the specified height.
Now, we are interested in the center of the Christmas tree.
Please imagine that we build a Christmas tree with `chars =... | 0 |
{"tests": "{\"inputs\": [\"3\\n\", \"10\\n\", \"1\\n\", \"2\", \"16\", \"0\", \"9\", \"-2\", \"4\", \"-4\", \"5\", \"8\", \"-7\", \"-13\", \"-8\", \"-11\", \"13\", \"14\", \"-16\", \"-18\", \"11\", \"-21\", \"-37\", \"-19\", \"24\", \"-38\", \"-27\", \"44\", \"-47\", \"-48\", \"-78\", \"-33\", \"-73\", \"-57\", \"-123\... | There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
-----Constraints-----
- 1≦N≦100
-----Input-----
The input is given... | 0.875 |
{"tests": "{\"inputs\": [\"3 500\\n\", \"371 306\\n\", \"222 500\\n\", \"421 44\\n\", \"124 212\\n\", \"300 500\\n\", \"271 208\\n\", \"99 333\\n\", \"224 375\\n\", \"5 40\\n\", \"365 500\\n\", \"444 500\\n\", \"499 499\\n\", \"92 270\\n\", \"6 26\\n\", \"13 337\\n\", \"71 439\\n\", \"171 489\\n\", \"298 51\\n\", \"2 5... | There are n heroes fighting in the arena. Initially, the i-th hero has a_i health points.
The fight in the arena takes place in several rounds. At the beginning of each round, each alive hero deals 1 damage to all other heroes. Hits of all heroes occur simultaneously. Heroes whose health is less than 1 at the end of t... | 0 |
{"tests": "{\"inputs\": [\"1 1\\n\", \"3 2\\n\", \"3 3\\n\", \"1 11\\n\", \"4 20\\n\", \"45902564 24\\n\", \"330 8\\n\", \"10 10\\n\", \"0 2\\n\", \"1000000 55\\n\", \"1 60\\n\", \"1000000000 52\\n\", \"101628400788615604 30\\n\", \"101628400798615604 31\\n\", \"55 55\\n\", \"14240928 10\\n\", \"1000000000 10\\n\", \"1... | One day, after a difficult lecture a diligent student Sasha saw a graffitied desk in the classroom. She came closer and read: "Find such positive integer n, that among numbers n + 1, n + 2, ..., 2·n there are exactly m numbers which binary representation contains exactly k digits one".
The girl got interested in the t... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 2\\n2 3\\n\", \"4\\n1 2\\n3 2\\n4 2\\n\", \"19\\n2 19\\n7 15\\n8 10\\n16 1\\n12 5\\n11 5\\n6 18\\n12 14\\n14 15\\n2 6\\n9 14\\n4 17\\n16 10\\n4 2\\n7 18\\n3 2\\n9 13\\n11 10\\n\", \"20\\n12 10\\n5 19\\n12 18\\n4 2\\n3 16\\n11 8\\n3 2\\n17 4\\n14 7\\n6 5\\n10 20\\n14 9\\n16 12\\n9 13\\n1... | The Resistance is trying to take control over as many planets of a particular solar system as possible. Princess Heidi is in charge of the fleet, and she must send ships to some planets in order to maximize the number of controlled planets.
The Galaxy contains N planets, connected by bidirectional hyperspace tunnels i... | 0 |
{"tests": "{\"inputs\": [\"1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1...1\\n\", \",...,,...,,...,,...,,...,,...,,... | Polycarp is very careful. He even types numeric sequences carefully, unlike his classmates. If he sees a sequence without a space after the comma, with two spaces in a row, or when something else does not look neat, he rushes to correct it. For example, number sequence written like "1,2 ,3,..., 10" will be corrected to... | 0 |
{"tests": "{\"inputs\": [\"3\\nabcxyx\\ncyx\\nabb\", \"3\\nabxxyc\\ncyx\\nabb\", \"6\\nb\\na\\nabb\\nc\\nd\\nab\", \"6\\nb\\na\\nabb\\nc\\nd\\nba\", \"3\\naxxbyc\\ncyx\\nabb\", \"3\\naxxbyc\\ncyx\\naab\", \"3\\naxxbyc\\ncyw\\naab\", \"3\\naxxbyc\\ncyw\\nbaa\", \"3\\ncybxxa\\ncyw\\nbaa\", \"3\\ncabxxy\\ncyw\\nbaa\", \"3... | Limak can repeatedly remove one of the first two characters of a string, for example abcxyx \rightarrow acxyx \rightarrow cxyx \rightarrow cyx.
You are given N different strings S_1, S_2, \ldots, S_N. Among N \cdot (N-1) / 2 pairs (S_i, S_j), in how many pairs could Limak obtain one string from the other?
Constraints... | 0 |
{"tests": "{\"inputs\": [\"3\\n\\n5 0\\n0 0 1\\n0 1 4\\n1 0 2\\n1 1 3\\n2 2 9\\n\\n5 2\\n0 0 1\\n0 1 4\\n1 0 2\\n1 1 3\\n2 2 9\\n\\n6 1\\n1 -1 3\\n0 -1 9\\n0 1 7\\n-1 0 1\\n-1 1 9\\n-1 -1 7\\n\", \"3\\n\\n5 0\\n0 0 1\\n0 1 4\\n1 0 2\\n1 1 3\\n2 2 9\\n\\n5 2\\n0 0 1\\n0 1 4\\n1 0 2\\n1 1 3\\n2 2 9\\n\\n6 1\\n1 -1 3\\n0 ... | Polycarp is very fond of playing the game Minesweeper. Recently he found a similar game and there are such rules.
There are mines on the field, for each the coordinates of its location are known ($x_i, y_i$). Each mine has a lifetime in seconds, after which it will explode. After the explosion, the mine also detonates... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 3 2\\n\", \"3\\n1000000000 1000000000 1000000000\\n\", \"20\\n51261 11877 300 30936722 84 75814681 352366 23 424 16392314 27267 832 4 562873474 33 516967731 158909407 32148531 66 757\\n\", \"3\\n1 912387428 4\\n\", \"4\\n5 5 5 5\\n\", \"4\\n1 2 984127392 912830214\\n\", \"5\\n1 1 912380... | Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$.
Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to: Reorder the list (i.e. pick a permutation $p$ of $\{0,1,...,n -... | 0.625 |
{"tests": "{\"inputs\": [\"6 3\\n\", \"8 5\\n\", \"22 4\\n\", \"4 3\\n\", \"57 27\\n\", \"61 3\\n\", \"5 4\\n\", \"10 6\\n\", \"20 10\\n\", \"30 5\\n\", \"25 24\\n\", \"25 3\\n\", \"12 7\\n\", \"18 6\\n\", \"100000 3\\n\", \"100000 9999\\n\", \"9999 3\\n\", \"5323 32\\n\", \"6666 66\\n\", \"38578 32201\\n\", \"49449 52... | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 0 |
{"tests": "{\"inputs\": [\"4\\n5 4 0\\n1 5 4 3 2\\n5 4 1\\n1 5 4 3 2\\n5 4 4\\n10 20 30 40 50\\n10 7 3\\n4 6 8 2 9 9 7 4 10 9\\n\", \"2\\n5 4 1\\n1 5 4 3 2\\n5 4 1\\n1 5 4 3 2\\n\", \"2\\n5 4 1\\n1 5 4 3 2\\n5 4 1\\n1 5 4 3 2\\n\", \"2\\n5 4 1\\n1 5 2 3 2\\n5 4 1\\n1 5 4 3 2\\n\", \"4\\n5 4 0\\n1 5 4 3 2\\n5 4 1\\n1 5 ... | You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers.
Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x... | 0 |
{"tests": "{\"inputs\": [\"redocta\", \"azcdefghijklmnopqrstuvwbyx\", \"cba\", \"redoctb\", \"bca\", \"bac\", \"abd\", \"atcodes\", \"abcdefghijklmnopqrytuvwzsx\", \"btcoder\", \"bad\", \"acb\", \"cab\", \"dba\", \"atcored\", \"qedoctb\", \"ascored\", \"btcodeq\", \"ascorfd\", \"btcedoq\", \"atcorfd\", \"qodectb\", \"b... | Gotou just received a dictionary. However, he doesn't recognize the language used in the dictionary. He did some analysis on the dictionary and realizes that the dictionary contains all possible diverse words in lexicographical order.
A word is called diverse if and only if it is a nonempty string of English lowercase... | 0 |
{"tests": "{\"inputs\": [[1], [12], [24], [25], [101101291], [12345676], [1251562], [625], [9801], [30858025]], \"outputs\": [[1], [8], [11], [3], [5], [68], [41], [5], [23], [63]]}", "source": "taco"} | A pair of numbers has a unique LCM but a single number can be the LCM of more than one possible
pairs. For example `12` is the LCM of `(1, 12), (2, 12), (3,4)` etc. For a given positive integer N, the number of different integer pairs with LCM is equal to N can be called the LCM cardinality of that number N. In this ka... | 0 |
{"tests": "{\"inputs\": [\"7\\n1\\n2\\n3\\n4\\n5\\n100\\n2000000\\n\", \"3\\n1234567\\n1268501\\n1268499\\n\", \"3\\n1234567\\n1268501\\n1268499\\n\", \"3\\n60615\\n1268501\\n1268499\\n\", \"7\\n1\\n2\\n3\\n4\\n5\\n110\\n2000000\\n\", \"3\\n89610\\n1268501\\n1268499\\n\", \"7\\n2\\n2\\n5\\n4\\n5\\n110\\n2000000\\n\", \... | Lee tried so hard to make a good div.2 D problem to balance his recent contest, but it still doesn't feel good at all. Lee invented it so tediously slow that he managed to develop a phobia about div.2 D problem setting instead. And now he is hiding behind the bushes...
Let's define a Rooted Dead Bush (RDB) of level $n... | 0 |
{"tests": "{\"inputs\": [\"4 2\\n1 2\\n2 2\\n\", \"6 2\\n2 3\\n4 1\\n\", \"3 2\\n1 1\\n2 2\\n\", \"1 1\\n1 1\\n\", \"25 2\\n1 23\\n3 1\\n\", \"300 4\\n1 200\\n2 200\\n50 100\\n70 100\\n\", \"1000 1\\n1 1000\\n\", \"1001 1\\n60 10001\\n\", \"999999999 1\\n100 1000000000\\n\", \"1000000000 1\\n1 1000000000\\n\", \"999999... | 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\": [\"200\\nNESENEESEESWWWNWWSWSWNWNNWNNESWSWNNWNWNENESENNESSWSESWWSSSEEEESSENNNESSWWSSSSESWSWWNNEESSWWNNWSWSSWWNWNNEENNENWWNESSSENWNESWNESWNESEESSWNESSSSSESESSWNNENENESSWWNNWWSWWNESEENWWWWNWWNWWNENESESSWWSWWSES\\nNWNESESSENNNESWNWWSWWWNWSESSSWWNWWNNWSENWSWNENNNWWSWWSWNNNESWWWSSESSWWWSSENWSENWWNENE... | In the spirit of the holidays, Saitama has given Genos two grid paths of length n (a weird gift even by Saitama's standards). A grid path is an ordered sequence of neighbouring squares in an infinite grid. Two squares are neighbouring if they share a side.
One example of a grid path is (0, 0) → (0, 1) → (0, 2) → (1, 2... | 0 |
{"tests": "{\"inputs\": [\"Thank you for your mail amd your lectures\", \"ahTnk you for your mail and your serutcel\", \"Uhank you for your mail mad your lrctuees\", \"ahTnk you for your mail and your leeturcs\", \"khTna you for your mail and your sequtcel\", \"khTna you for your mail dna your sequucel\", \"Uhank uzp g... | Your task is to write a program which reads a text and prints two words. The first one is the word which is arise most frequently in the text. The second one is the word which has the maximum number of letters.
The text includes only alphabetical characters and spaces. A word is a sequence of letters which is separate... | 0.875 |
{"tests": "{\"inputs\": [\"9 33\\n5 7\\n5 9\\n9 6\\n9 1\\n7 4\\n3 5\\n7 8\\n8 6\\n3 6\\n8 2\\n3 8\\n1 6\\n1 8\\n1 4\\n4 2\\n1 2\\n2 5\\n3 4\\n8 5\\n2 6\\n3 1\\n1 5\\n1 7\\n3 2\\n5 4\\n9 4\\n3 9\\n7 3\\n6 4\\n9 8\\n7 9\\n8 4\\n6 5\\n\", \"51 23\\n46 47\\n31 27\\n1 20\\n49 16\\n2 10\\n29 47\\n13 27\\n34 26\\n31 2\\n28 20... | Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f... | 0.875 |
{"tests": "{\"inputs\": [\"0 2 4 8 16 32\\nEESWN\", \"1 2 4 6 16 32\\nSE\", \"0 2 4 8 16 30\\nEESWN\", \"1 2 4 0 16 32\\nSE\", \"1 2 4 -1 16 32\\nSE\", \"0 2 0 8 16 23\\nEESWN\", \"1 2 4 8 16 32\\nES\", \"1 2 4 8 27 32\\nES\", \"0 4 4 8 16 5\\nEESWN\", \"1 4 4 -1 24 32\\nES\", \"1 2 4 8 48 32\\nES\", \"1 2 3 0 21 32\\n... | Write a program to simulate rolling a dice, which can be constructed by the following net.
<image>
<image>
As shown in the figures, each face is identified by a different label from 1 to 6.
Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the d... | 0 |
{"tests": "{\"inputs\": [\"3 \\n100 120\\n10 20\\n1200 20\\n\", \"3 \\n100 120\\n10 20\\n1200 40\", \"3 \\n100 215\\n10 20\\n1200 40\", \"3 \\n100 215\\n10 20\\n1200 44\", \"3 \\n000 215\\n10 20\\n1200 44\", \"3 \\n001 215\\n10 20\\n1200 44\", \"3 \\n001 215\\n10 20\\n1237 44\", \"3 \\n001 215\\n10 20\\n1869 44\", \"3 ... | While purchasing certain items, a discount of 10% is offered if the quantity purchased is more than 1000.
If the quantity and price per item are input, write a program to calculate the total expenses.
------ Input Format ------
The first line contains an integer T, total number of test cases. Then follow T lines, e... | 0.875 |
{"tests": "{\"inputs\": [\"6\\n2\\n1 3\\n3\\n1 2 3\\n4\\n6 2 3 9\\n4\\n6 8 4 5\\n7\\n1 2 4 6 7 7 3\\n8\\n8 6 5 1 2 2 3 6\\n\", \"6\\n2\\n1 3\\n3\\n1 2 3\\n4\\n2 2 3 9\\n4\\n6 8 4 5\\n7\\n1 2 4 6 7 7 3\\n8\\n8 6 5 1 2 2 3 6\\n\", \"6\\n2\\n1 3\\n3\\n1 2 3\\n4\\n2 2 3 14\\n4\\n6 8 4 5\\n7\\n1 2 4 6 7 7 3\\n8\\n8 6 5 1 2 ... | You are given $n$ lengths of segments that need to be placed on an infinite axis with coordinates.
The first segment is placed on the axis so that one of its endpoints lies at the point with coordinate $0$. Let's call this endpoint the "start" of the first segment and let's call its "end" as that endpoint that is not ... | 0 |
{"tests": "{\"inputs\": [\"6 1 0 0\\n7 1 0 0\\n7 2 0 0\\n6 6 1 1\\n2\\n5\\n7 10 0 6\\n2\\n2\\n3\\n4\\n5\\n6\\n0 0 0 0\", \"6 1 0 0\\n7 1 0 0\\n7 2 0 0\\n6 6 1 1\\n2\\n5\\n7 5 0 6\\n1\\n2\\n3\\n4\\n5\\n6\\n0 0 0 0\", \"6 2 0 0\\n7 1 0 0\\n7 2 0 0\\n6 6 1 1\\n2\\n5\\n7 10 0 6\\n2\\n2\\n3\\n4\\n5\\n6\\n0 0 0 0\", \"6 1 0 ... | Here is a very simple variation of the game backgammon, named “Minimal Backgammon”. The game is played by only one player, using only one of the dice and only one checker (the token used by the player).
The game board is a line of (N + 1) squares labeled as 0 (the start) to N (the goal). At the beginning, the checker ... | 0 |
{"tests": "{\"inputs\": [\"6 6\\n1 2 3 4 5 6\\n8 6 9 1 2 0\\n3 1 4 1 5 9\\n2 6 5 3 5 8\\n1 4 1 4 2 1\\n2 10 1 8 2 8\", \"3 3\\n1 0 5\\n1 2 3\\n4 2 4\", \"6 6\\n1 2 3 4 5 6\\n8 6 9 1 2 0\\n1 1 4 1 5 9\\n2 6 5 3 5 8\\n1 4 1 4 2 1\\n2 10 1 8 2 8\", \"3 3\\n1 0 5\\n1 2 3\\n4 2 5\", \"6 6\\n1 2 3 4 5 6\\n8 8 9 0 2 0\\n1 1 4... | Input
The input is given from standard input in the following format.
> $H \ W$ $a_{1, 1} \ a_{1, 2} \ \cdots \ a_{1, W}$ $a_{2, 1} \ a_{2, 2} \ \cdots \ a_{2, W}$ $\vdots \ \ \ \ \ \ \ \ \ \ \vdots \ \ \ \ \ \ \ \ \ \ \vdots$ $a_{H, 1} \ a_{H, 2} \ \cdots \ a_{H, W}$
Output
* Print the maximum number of souvenirs... | 0 |
{"tests": "{\"inputs\": [\"53 3\\n1 3 4 4 5 7 10 14 19 25 32 40 49 59 70 82 95 109 124 140 157 175 194 214 235 257 280 304 329 355 382 410 439 469 500 532 565 599 634 670 707 745 784 824 865 907 950 994 1039 1085 1132 1180 1229\\n1 2 40\\n\", \"8 4\\n1 2 3 4 5 6 7 8\\n10 11 12 13\\n\", \"10 5\\n172960147 951061917 5026... | Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got hold of lots of wooden cubes somewhere. They started making cube towers by placing the cubes one on top of the other. They defined multiple towers standing in a line as a wall. A wall can consist of towers of di... | 0.875 |
{"tests": "{\"inputs\": [\"180\\n3\\n60 120 180\\n3\\n30 90\\n61 1\\n180 180\\n\", \"100\\n1\\n100000\\n4\\n0 100\\n90 100\\n100 100\\n101 100\\n\", \"100\\n5\\n48 141 231 314 425\\n7\\n0 19\\n50 98\\n143 30\\n231 55\\n342 0\\n365 100\\n600 10\\n\", \"100\\n5\\n48 141 231 554 425\\n7\\n0 19\\n50 98\\n143 30\\n231 55\\n... | We have a sandglass consisting of two bulbs, bulb A and bulb B. These bulbs contain some amount of sand.
When we put the sandglass, either bulb A or B lies on top of the other and becomes the upper bulb. The other bulb becomes the lower bulb.
The sand drops from the upper bulb to the lower bulb at a rate of 1 gram per ... | 0 |
{"tests": "{\"inputs\": [\"enw\\nbbc\\nabcdefghijklmnopqrst\\nz\\n#\", \"enw\\ncbb\\nabcdefggijklmnopqrst\\nz\\n#\", \"enw\\ncbb\\nabcsefggijklmnopqrdt\\nz\\n#\", \"enw\\nabb\\nabcdefghijklmnopqrst\\nz\\n#\", \"enw\\nbcc\\nabcdefghijklmnopqrst\\nz\\n#\", \"enw\\ncbb\\ntsrqponmlkjihgfedcba\\nz\\n#\", \"enw\\nabb\\ntsrqp... | Encryption System
A programmer developed a new encryption system. However, his system has an issue that two or more distinct strings are `encrypted' to the same string.
We have a string encrypted by his system. To decode the original string, we want to enumerate all the candidates of the string before the encryption.... | 0 |
{"tests": "{\"inputs\": [\"3\\n3 2 1\\n\", \"2\\n1 2\\n\", \"4\\n4 2 3 1\\n\", \"10\\n10 9 8 7 6 5 4 3 2 1\\n\", \"1\\n1\\n\", \"5\\n2 1 4 3 5\\n\", \"8\\n1 3 5 7 8 6 4 2\\n\", \"3\\n1 2 3\\n\", \"4\\n3 4 1 2\\n\", \"5\\n1 4 2 3 5\\n\", \"6\\n5 3 6 1 4 2\\n\", \"2\\n2 1\\n\", \"3\\n2 1 3\\n\", \"3\\n1 2 3\\n\", \"3\\n1... | You have an array a[1], a[2], ..., a[n], containing distinct integers from 1 to n. Your task is to sort this array in increasing order with the following operation (you may need to apply it multiple times):
choose two indexes, i and j (1 ≤ i < j ≤ n; (j - i + 1) is a prime number); swap the elements on positions i ... | 0 |
{"tests": "{\"inputs\": [[[\"43-45\", \"1021-55\", \"000-18888\", \"92-34\", \"76-32\", \"99-1\", \"1020-54\"]], [[\"1-2\", \"2-4\", \"5-7\", \"8-9\", \"44-45\"]], [[\"1-1000\", \"2-1000\", \"100-67\", \"98-45\", \"8-9\"]], [[\"33-33\", \"77-77\"]], [[\"23-67\", \"67-23\", \"88-88\", \"45-46\"]], [[\"45896-2354\", \"46... | Your task is to find the number couple with the greatest difference from a given array of number-couples.
All number couples will be given as strings and all numbers in them will be positive integers.
For instance: ['56-23','1-100']; in this case, you should identify '1-100' as the number couple with the greatest ... | 0 |
{"tests": "{\"inputs\": [\"1 1\\n\", \"7 6\\n\", \"25 38\\n\", \"8311 2468\\n\", \"250708 857756\\n\", \"957985574 24997558\\n\", \"999963734 999994456\\n\", \"1000000000 1000000000\\n\", \"946 879\\n\", \"10819 45238\\n\", \"101357 236928\\n\", \"1033090 7376359\\n\", \"9754309 9525494\\n\", \"90706344 99960537\\n\", ... | At regular competition Vladik and Valera won a and b candies respectively. Vladik offered 1 his candy to Valera. After that Valera gave Vladik 2 his candies, so that no one thought that he was less generous. Vladik for same reason gave 3 candies to Valera in next turn.
More formally, the guys take turns giving each ot... | 0.625 |
{"tests": "{\"inputs\": [\"4\\n5 2\\n2 3 4 4 3\\n3 1\\n2 10 1000\\n4 5\\n0 1 1 100\\n1 8\\n89\\n\", \"1\\n1 2\\n88\\n\", \"1\\n20 22328\\n2572 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\\n\", \"1\\n20 22328\\n2572 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\\n\", \"1\\n25 2\\n2 3 4 6 7 9 12 13 15 22 23 24 26 30 37 40 41 42 43 44 ... | Johnny has just found the new, great tutorial: "How to become a grandmaster?". The tutorial tells many strange and unexpected for Johnny things, such as you have to be patient or that very important is solving many harder and harder problems.
The boy has found an online judge with tasks divided by topics they cover. ... | 0 |
{"tests": "{\"inputs\": [\"14 30 9\\n\", \"911637544 536870912 134217728\\n\", \"114514534 999950443 31601\\n\", \"907605112 935821597 11274959\\n\", \"1 9 3\\n\", \"81 180 53\\n\", \"1 999999938 999999937\\n\", \"623425842 999002449 10\\n\", \"327082339 935821597 11274959\\n\", \"763677180 999999937 111\\n\", \"100000... | Two beavers, Timur and Marsel, play the following game.
There are n logs, each of exactly m meters in length. The beavers move in turns. For each move a beaver chooses a log and gnaws it into some number (more than one) of equal parts, the length of each one is expressed by an integer and is no less than k meters. Eac... | 0.125 |
{"tests": "{\"inputs\": [\"2 2 1 2\\n1 2\\n2 1\\n\", \"13 4 1 3\\n3 2 6 4 1 4 4 7 1 3 3 2 4\\n4 3 4\\n\", \"2 2 1 2\\n1 2\\n1 1\\n\", \"10 5 2 2\\n2 2 2 2 2 1 1 1 1 1\\n3 3\\n\", \"100 15 6 10\\n3 2 3 1 3 1 2 3 2 3 3 1 1 3 2 3 2 3 1 3 3 3 1 3 3 2 1 2 1 2 3 2 2 2 3 2 1 1 2 2 1 2 1 3 3 2 3 3 1 1 2 3 1 2 2 2 1 3 2 3 1 3 3... | At the first holiday in spring, the town Shortriver traditionally conducts a flower festival. Townsfolk wear traditional wreaths during these festivals. Each wreath contains exactly k flowers.
The work material for the wreaths for all n citizens of Shortriver is cut from the longest flowered liana that grew in the tow... | 0 |
{"tests": "{\"inputs\": [\"5\\n2 2\\n1 3\\n1 2\\n5 5\\n3 3 3 3 3\\n1 2\\n2 3\\n1 4\\n4 5\\n5 2\\n1 7 2 3 5\\n1 2\\n2 3\\n1 4\\n4 5\\n5 3\\n1 6 4 1 2\\n1 2\\n2 3\\n1 4\\n4 5\\n3 3\\n1 7 4\\n1 2\\n2 3\\n\", \"2\\n3 2\\n1 1 1\\n1 2\\n1 3\\n3 3\\n3 3 1\\n1 2\\n2 3\\n\", \"1\\n7 3\\n2 2 3 3 3 3 3\\n1 2\\n2 3\\n3 4\\n4 5\\n5... | Bakry faced a problem, but since he's lazy to solve it, he asks for your help.
You are given a tree of $n$ nodes, the $i$-th node has value $a_i$ assigned to it for each $i$ from $1$ to $n$. As a reminder, a tree on $n$ nodes is a connected graph with $n-1$ edges.
You want to delete at least $1$, but at most $k-1$ ed... | 0 |
{"tests": "{\"inputs\": [\"2 3\\n6\\n8\\n1 5 6\\n1 9 4\\n2 4 2\\n\", \"1 3\\n4\\n1 5 3\\n1 9 4\\n4 6 6\\n\", \"0 2\\n1 1000000000 4\\n1 1000000000 2\\n\", \"0 0\\n\", \"2 3\\n4\\n6\\n1 4 3\\n1 5 2\\n1 6 5\\n\", \"0 5\\n1 96762320 50510976\\n243235878 312125306 50510976\\n326016273 338641867 50510976\\n385105810 4452248... | On a chessboard with a width of $10^9$ and a height of $10^9$, the rows are numbered from bottom to top from $1$ to $10^9$, and the columns are numbered from left to right from $1$ to $10^9$. Therefore, for each cell of the chessboard you can assign the coordinates $(x,y)$, where $x$ is the column number and $y$ is the... | 0 |
{"tests": "{\"inputs\": [\"3\\n7\\n15\", \"2\\n000\\n200\", \"14\\n12\\n47\", \"2\\n000\\n217\", \"3\\n7\\n45\", \"14\\n16\\n2\", \"3\\n7\\n76\", \"2\\n000\\n4\", \"3\\n10\\n43\", \"14\\n12\\n183\", \"2\\n000\\n311\", \"2\\n000\\n17\", \"3\\n7\\n54\", \"3\\n0\\n76\", \"3\\n2\\n43\", \"2\\n000\\n406\", \"2\\n000\\n12\",... | We have a grid with H rows and W columns, where all the squares are initially white.
You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions:
* Choose one row, then paint all the squares in that row black.
* Choose one column, then paint all the s... | 0 |
{"tests": "{\"inputs\": [\"2\\n6 3\\n001000\\n2 4\\n1 3\\n3 5\\n4 2\\n1111\\n1 4\\n2 3\\n\", \"2\\n6 3\\n001000\\n2 4\\n1 3\\n3 5\\n4 2\\n1111\\n1 4\\n1 3\\n\", \"2\\n6 3\\n001000\\n2 5\\n1 3\\n3 5\\n4 2\\n1111\\n1 4\\n1 3\\n\", \"2\\n6 3\\n001000\\n2 5\\n1 3\\n3 5\\n4 2\\n1011\\n1 4\\n1 3\\n\", \"2\\n6 3\\n001000\\n2 ... | Hr0d1y has $q$ queries on a binary string $s$ of length $n$. A binary string is a string containing only characters '0' and '1'.
A query is described by a pair of integers $l_i$, $r_i$ $(1 \leq l_i \lt r_i \leq n)$.
For each query, he has to determine whether there exists a good subsequence in $s$ that is equal to th... | 0 |
{"tests": "{\"inputs\": [\"247 499\\n\", \"18 198\\n\", \"1 1\\n\", \"855 225\\n\", \"840 780\\n\", \"139 433\\n\", \"420 380\\n\", \"535 59\\n\", \"22 326\\n\", \"20 11\\n\", \"790 64\\n\", \"1 11\\n\", \"1 571\\n\", \"991 931\\n\", \"57 447\\n\", \"2 6\\n\", \"810 704\\n\", \"26 104\\n\", \"31 31\\n\", \"902 34\\n\",... | Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?
You are given a system of equations:
<image>
You should count, how many there are pai... | 0.25 |
{"tests": "{\"inputs\": [\"4 3 2 2\\n3 1 3 2\\n1 2\\n2 3\\n4 4\\n\", \"5 2 1 1\\n1 2 3 4 5\\n2 4\\n1 5\\n\", \"5 3 3 5\\n5 5 2 1 1\\n1 2\\n2 3\\n3 4\\n\", \"1 5 2 1\\n1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n\", \"10 1 1 8\\n1 1 1 991992993 1 991992993 3 6664666 1000000000 999999999\\n3 10\\n\", \"5 10 1 1\\n1000000000 100000... | You are a given a list of integers $a_1, a_2, \ldots, a_n$ and $s$ of its segments $[l_j; r_j]$ (where $1 \le l_j \le r_j \le n$).
You need to select exactly $m$ segments in such a way that the $k$-th order statistic of the multiset of $a_i$, where $i$ is contained in at least one segment, is the smallest possible. If... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.