info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [\"winlose???winl???w??\\nwin\\n\", \"glo?yto?e??an?\\nor\\n\", \"??c?????\\nabcab\\n\", \"ddddd\\nd\\n\", \"ww?ww\\nw\\n\", \"?????\\nn\\n\", \"xznxr\\nxznxr\\n\", \"wnfbhg?dkhdbh?hdmfjkcunzbh?hdbjjrbh?hddmh?zubhgh?qbjbhghdpwr?bhghdfjnjf?qbhghdqq?qebhgh?umvbhghdivvj\\nbhghd\\n\", \"emnd?t??m?gd... | Berland has a long and glorious history. To increase awareness about it among younger citizens, King of Berland decided to compose an anthem.
Though there are lots and lots of victories in history of Berland, there is the one that stand out the most. King wants to mention it in the anthem as many times as possible.
H... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 2 4 3\\n\", \"4\\n2 1 4 3\\n\", \"10\\n1 2 10 9 7 4 8 3 6 5\\n\", \"10\\n1 7 10 6 5 2 3 8 9 4\\n\", \"4\\n4 3 2 1\\n\", \"4\\n2 1 3 4\\n\", \"10\\n1 10 9 5 3 2 4 7 8 6\\n\", \"4\\n2 3 1 4\\n\", \"4\\n2 4 3 1\\n\", \"10\\n1 5 10 8 4 3 9 2 7 6\\n\", \"4\\n1 4 3 2\\n\", \"10\\n1 8 10 6 2 4... | Some time ago Mister B detected a strange signal from the space, which he started to study.
After some transformation the signal turned out to be a permutation p of length n or its cyclic shift. For the further investigation Mister B need some basis, that's why he decided to choose cyclic shift of this permutation whi... | 0.875 |
{"tests": "{\"inputs\": [\"6\\n1 1 1 2 1 1\\n6\\n+ 2\\n+ 1\\n- 1\\n+ 2\\n- 1\\n+ 2\\n\", \"10\\n5 1 5 1 4 4 2 2 4 4\\n15\\n- 1\\n- 4\\n+ 2\\n+ 2\\n- 5\\n- 5\\n- 4\\n- 4\\n+ 10\\n+ 10\\n+ 10\\n+ 10\\n- 2\\n+ 1\\n- 4\\n\", \"1\\n1\\n34\\n- 1\\n+ 1\\n+ 1\\n+ 1\\n+ 1\\n+ 1\\n+ 1\\n+ 1\\n+ 1\\n+ 1\\n- 1\\n- 1\\n- 1\\n- 1\\n... | This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the shape of a rectangle (which possibly can be a square as well).
A... | 0.125 |
{"tests": "{\"inputs\": [\"1 1 1 8\\n\", \"4 2 2 6\\n\", \"3 7 4 6\\n\", \"4 5 1 1\\n\", \"12 12 1 1000\\n\", \"12 1 1000 1000\\n\", \"3 4 701 703\\n\", \"12 12 13 1000000000\\n\", \"3 4 999999999 1000000000\\n\", \"5 6 1000000000 1000000000\\n\", \"1 1 1 1\\n\", \"12 1 100000011 100000024\\n\", \"10 12 220000011 22000... | Sometimes Mister B has free evenings when he doesn't know what to do. Fortunately, Mister B found a new game, where the player can play against aliens.
All characters in this game are lowercase English letters. There are two players: Mister B and his competitor.
Initially the players have a string s consisting of the... | 0 |
{"tests": "{\"inputs\": [\"13\\n....LLLLLL...\\n\", \"3\\n.L.\\n\", \"3\\n.R.\\n\", \"4\\n.RL.\\n\", \"17\\n.......RRRRR.....\\n\", \"13\\n...LLLLLL....\\n\", \"17\\n.....RRRRR.......\\n\", \"4\\n..RL\\n\", \"17\\n......RRRRR......\\n\", \"11\\n.RRRLLLLL..\\n\", \"9\\n..RRLL...\\n\"], \"outputs\": [\"10 4\\n\", \"2 1\\... | There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ... | 0 |
{"tests": "{\"inputs\": [[1], [10], [11], [15], [18], [21], [26], [30], [30.49], [35], [100], [1000000], [0], [-3], [null], [\"monkey\"], [[]], [{}]], \"outputs\": [[0.1], [1], [1.07], [1.35], [1.56], [1.75], [2], [2.2], [2.21], [2.35], [4.3], [30001.3], [0], [0], [0], [0], [0], [0]]}", "source": "taco"} | Write a function to calculate compound tax using the following table:
For $10 and under, the tax rate should be 10%.
For $20 and under, the tax rate on the first $10 is %10, and the tax on the rest is 7%.
For $30 and under, the tax rate on the first $10 is still %10, the rate for the next $10 is still 7%, and everythi... | 0 |
{"tests": "{\"inputs\": [[440], [220], [880], [523.25], [261.625], [1046.5]], \"outputs\": [[\"A\"], [\"A\"], [\"A\"], [\"C\"], [\"C\"], [\"C\"]]}", "source": "taco"} | In music, if you double (or halve) the pitch of any note you will get to the same note again.
"Concert A" is fixed at 440 Hz, and every other note is defined based on that. 880 Hz is also an A, as is 1760 Hz, as is 220 Hz.
There are 12 notes in Western music: A, A#, B, C, C#, D, D#, E, F, F#, G, G#. You are given a p... | 0.5 |
{"tests": "{\"inputs\": [\"4 5\\n8 8 8 8 8\", \"5 2\\n5 5 6 5\", \"100 3\\n1 3 3\", \"4 5\\n8 8 2 8 8\", \"4 5\\n8 8 2 0 8\", \"4 5\\n8 7 2 0 8\", \"1 5\\n8 7 2 0 8\", \"1 5\\n8 7 4 0 8\", \"0 5\\n8 7 4 0 8\", \"5 4\\n2 7 5 10\", \"0 5\\n8 7 4 0 15\", \"0 5\\n11 7 4 0 15\", \"0 1\\n11 7 4 0 15\", \"5 2\\n1 15 11 10\", ... | I’m planning to have a party on my birthday. Many of my friends will come to the party. Some of them will come with one or more pieces of cakes, but it is not certain if the number of the cakes is a multiple of the number of people coming.
I wish to enjoy the cakes equally among the partiers. So, I decided to apply th... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 2\\n3 4\\n5 6\\n\", \"3\\n1010 10\\n1000 1\\n20 1020\\n\", \"2\\n1 1\\n1000000000 1000000000\\n\", \"2\\n1 1\\n1000000000 1000000100\", \"3\\n1 2\\n3 4\\n3 6\", \"3\\n1010 10\\n1000 1\\n20 294\", \"2\\n1 1\\n1000000000 1000100100\", \"3\\n1010 10\\n1000 1\\n26 294\", \"3\\n1 2\\n3 4\\n3... | There are N bags, each containing two white balls. The i-th box contains two balls with integers x_i and y_i written on them, respectively.
For each of these bags, you will paint one of the balls red, and paint the other blue.
Afterwards, the 2N balls will be classified according to color.
Then, we will define the foll... | 0.125 |
{"tests": "{\"inputs\": [\"3\\n3 1\\n2 1\\n4 0\\n\", \"5\\n200000 200000\\n24567 23423\\n1 200000\\n200000 1\\n200000 0\\n\", \"5\\n2 200000\\n199991 200000\\n100000 1024\\n1024 0\\n200000 2048\\n\", \"5\\n199991 200000\\n199992 200000\\n199992 200000\\n199992 200000\\n199996 200000\\n\", \"5\\n200000 200000\\n200000 2... | Moamen and Ezzat are playing a game. They create an array $a$ of $n$ non-negative integers where every element is less than $2^k$.
Moamen wins if $a_1 \,\&\, a_2 \,\&\, a_3 \,\&\, \ldots \,\&\, a_n \ge a_1 \oplus a_2 \oplus a_3 \oplus \ldots \oplus a_n$.
Here $\&$ denotes the bitwise AND operation , and $\oplus$ deno... | 0 |
{"tests": "{\"inputs\": [\"5 2\\n50 110 130 40 120\\n\", \"4 1\\n2 3 4 1\\n\", \"1 1\\n4\\n\", \"2 2\\n7 5\\n\", \"3 2\\n34 3 75\\n\", \"5 2\\n932 328 886 96 589\\n\", \"10 4\\n810 8527 9736 3143 2341 6029 7474 707 2513 2023\\n\", \"20 11\\n924129 939902 178964 918687 720767 695035 577430 407131 213304 810868 596349 26... | Evlampiy has found one more cool application to process photos. However the application has certain limitations.
Each photo i has a contrast v_{i}. In order for the processing to be truly of high quality, the application must receive at least k photos with contrasts which differ as little as possible.
Evlampiy alread... | 0 |
{"tests": "{\"inputs\": [\"2\\n4 3\\n5 0\\n1 4\\n2 2\\n\\n5 3\\n5 2\\n4 2\\n3 1\\n\", \"1\\n1 7\\n334569692 287790954\\n828776938 450248098\\n812787473 543828736\\n353202854 229469066\\n105035292 19740770\\n294918734 142174357\\n944609166 419900619\\n\", \"1\\n7 7\\n875211518 78149272\\n372527826 28528254\\n777595365 6... | Vladimir would like to prepare a present for his wife: they have an anniversary! He decided to buy her exactly $n$ flowers.
Vladimir went to a flower shop, and he was amazed to see that there are $m$ types of flowers being sold there, and there is unlimited supply of flowers of each type. Vladimir wants to choose flow... | 0 |
{"tests": "{\"inputs\": [\"3\\n2 2 1 0\\n1 1 1 1\\n1 2 3 2\\n\", \"2\\n23 1 2 1\\n1 1 1 46\\n\", \"1\\n1 1 1 46\\n\", \"1\\n1 2 2 114514\\n\", \"1\\n114514 1 1 1919810\\n\", \"1\\n1 1 1 1919810\\n\", \"1\\n1 2 2 114514\\n\", \"1\\n1 1 1 1919810\\n\", \"1\\n1 1 1 46\\n\", \"1\\n114514 1 1 1919810\\n\", \"2\\n23 1 2 1\\n... | You are given four integer values $a$, $b$, $c$ and $m$.
Check if there exists a string that contains:
$a$ letters 'A';
$b$ letters 'B';
$c$ letters 'C';
no other letters;
exactly $m$ pairs of adjacent equal letters (exactly $m$ such positions $i$ that the $i$-th letter is equal to the $(i+1)$-th one).
-----Inp... | 0 |
{"tests": "{\"inputs\": [\"H 1\\nHe 4\\nC 12\\nO 16\\nF 19\\nNe 24\\nCu 64\\nCc 333\\nEND_OF_FIRST_PART\\nH2C\\n(MgF)2As\\nCu(OH)2\\nH((CO)2F)99\\n0\", \"H 1\\nHe 4\\nC 12\\nO 16\\nF 22\\nNe 24\\nCu 64\\nCc 333\\nEND_OF_FIRST_PART\\nH2C\\n(MgF)2As\\nCu(OH)2\\nH((CO)2F)99\\n0\", \"H 1\\nHe 4\\nC 12\\nO 16\\nF 19\\nNe 20... | Your mission in this problem is to write a computer program that manipulates molecular for- mulae in virtual chemistry. As in real chemistry, each molecular formula represents a molecule consisting of one or more atoms. However, it may not have chemical reality.
The following are the definitions of atomic symbols and ... | 0.25 |
{"tests": "{\"inputs\": [[\"K\", \"A\"], [\"S\", \"A\"], [\"k\", \"s\"], [\"a\", \"a\"], [\"k\", \"A\"], [\"K\", \"a\"]], \"outputs\": [[-1], [-1], [-1], [-1], [\"k\"], [\"K\"]]}", "source": "taco"} | You are making your very own boardgame. The game is played by two opposing players, featuring a 6 x 6 tile system, with the players taking turns to move their pieces (similar to chess). The design is finished, now it's time to actually write and implement the features. Being the good programmer you are, you carefully p... | 0 |
{"tests": "{\"inputs\": [\"4 5\\n1 2\\n1 3\\n1 4\\n2 3\\n2 4\", \"4 6\\n1 2\\n1 4\\n2 3\\n2 4\\n3 2\\n3 4\", \"7 13\\n6 1\\n7 2\\n3 7\\n6 5\\n3 6\\n7 4\\n3 5\\n4 1\\n3 1\\n1 5\\n1 6\\n6 2\\n2 4\\n\", \"8 12\\n6 1\\n7 5\\n2 5\\n4 1\\n6 3\\n4 3\\n5 7\\n1 3\\n5 2\\n2 7\\n4 6\\n7 2\\n\", \"10 10\\n10 6\\n9 4\\n7 8\\n1 5\\n... | Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n.
Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha... | 0 |
{"tests": "{\"inputs\": [\"tinkoff\\nzscoder\\n\", \"xxxxxx\\nxxxxxx\\n\", \"ioi\\nimo\\n\", \"abc\\naaa\\n\", \"reddit\\nabcdef\\n\", \"cbxz\\naaaa\\n\", \"bcdef\\nabbbc\\n\", \"z\\ny\\n\", \"y\\nz\\n\", \"bcdef\\nabbbc\\n\", \"z\\ny\\n\", \"reddit\\nabcdef\\n\", \"abc\\naaa\\n\", \"y\\nz\\n\", \"cbxz\\naaaa\\n\", \"f... | Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the company.
To settle this problem, they've decided to play a game. The company name will consist of n letters. Oleg and Igor ea... | 0 |
{"tests": "{\"inputs\": [\"x^1-2\", \"x^1-1\", \"x^1-3\", \"x^1-4\", \"x^2-4\", \"x^1-5\", \"x^1-6\", \"x^1+6\", \"x^1+5\", \"x^1+7\", \"x^2+4x+3\", \"x^1+8\", \"x^1+9\", \"x^1+2\", \"x^1+4\", \"x^1-7\", \"x^1+3\", \"x^1-8\", \"x^1+1\", \"x^1-1\", \"x^1-2\", \"x^1-3\", \"x^1-4\", \"x^1-5\", \"x^1+5\", \"x^1+4\", \"x^1+... | Problem
Mr. ukuku1333 is a little sloppy, so when I expanded the product of the linear expressions of x, I couldn't figure out the original linear expression.
Given the nth degree polynomial of x, factor it into the product of the original linear expressions of x.
The nth degree polynomial of x is given by the follow... | 0 |
{"tests": "{\"inputs\": [\"56,65\\n97,54\\n64,-4\\n55,76\\n42,-27\\n43,80\\n87,-86\\n55,-6\\n89,34\\n5,59\\n0,0\", \"56,65\\n97,54\\n64,-4\\n55,76\\n42,-27\\n43,80\\n77,-86\\n55,-6\\n89,34\\n95,5\\n0,0\", \"56,65\\n97,54\\n64,-4\\n65,76\\n42,-27\\n43,80\\n77,-86\\n55,-6\\n89,34\\n95,5\\n0,0\", \"56,65\\n97,54\\n64,-4\\... | When a boy was cleaning up after his grand father passing, he found an old paper:
<image>
In addition, other side of the paper says that "go ahead a number of steps equivalent to the first integer, and turn clockwise by degrees equivalent to the second integer".
His grand mother says that Sanbonmatsu was standing ... | 0 |
{"tests": "{\"inputs\": [\"3 2\\n1 2\\n2 3\\n2 0\\n100000 0\\n0 0\", \"3 2\\n1 2\\n2 3\\n3 0\\n100000 0\\n0 0\", \"5 2\\n1 2\\n2 3\\n5 0\\n100000 0\\n0 0\", \"3 2\\n1 2\\n2 3\\n4 0\\n100000 0\\n0 0\", \"5 2\\n1 2\\n2 3\\n2 0\\n100000 0\\n0 0\", \"5 2\\n1 2\\n2 1\\n2 0\\n100000 0\\n0 0\", \"5 2\\n1 2\\n2 1\\n3 0\\n10000... | Problem Statement
"Everlasting -One-" is an award-winning online game launched this year. This game has rapidly become famous for its large number of characters you can play.
In this game, a character is characterized by attributes. There are $N$ attributes in this game, numbered $1$ through $N$. Each attribute takes... | 0.625 |
{"tests": "{\"inputs\": [\"1001\\n\", \"0100101110\\n\", \"0011\\n\", \"1011\\n\", \"1000\\n\", \"01\\n\", \"1010\\n\", \"0000\\n\", \"0010\\n\", \"100\\n\", \"101\\n\", \"001\\n\", \"1101111000011110111111110101100111111110111100001111011010111001101100010110000001010101101010111000\\n\", \"00\\n\", \"0\\n\", \"000\\n... | Toad Rash has a binary string s. A binary string consists only of zeros and ones.
Let n be the length of s.
Rash needs to find the number of such pairs of integers l, r that 1 ≤ l ≤ r ≤ n and there is at least one pair of integers x, k such that 1 ≤ x, k ≤ n, l ≤ x < x + 2k ≤ r, and s_x = s_{x+k} = s_{x+2k}.
Find th... | 0.125 |
{"tests": "{\"inputs\": [\"1\\n300000\\n\", \"10\\n9 8 7 7 6 4 3 2 1 1\\n\", \"100\\n1980 1932 1906 1898 1892 1883 1877 1858 1842 1833 1777 1710 1689 1678 1660 1653 1648 1647 1644 1639 1635 1635 1593 1571 1534 1470 1440 1435 1389 1272 1269 1268 1263 1255 1249 1237 1174 1174 1128 1069 1067 981 979 979 951 915 911 906 86... | You are given a Young diagram.
Given diagram is a histogram with n columns of lengths a_1, a_2, …, a_n (a_1 ≥ a_2 ≥ … ≥ a_n ≥ 1).
<image> Young diagram for a=[3,2,2,2,1].
Your goal is to find the largest number of non-overlapping dominos that you can draw inside of this histogram, a domino is a 1 × 2 or 2 × 1 recta... | 0 |
{"tests": "{\"inputs\": [[2863311530], [128], [131], [2], [24082], [0], [85], [1024], [1], [1365]], \"outputs\": [[true], [true], [true], [true], [true], [false], [false], [false], [false], [false]]}", "source": "taco"} | ~~~if-not:ruby,python
Return `1` when *any* odd bit of `x` equals 1; `0` otherwise.
~~~
~~~if:ruby,python
Return `true` when *any* odd bit of `x` equals 1; `false` otherwise.
~~~
Assume that:
* `x` is an unsigned, 32-bit integer;
* the bits are zero-indexed (the least significant bit is position 0)
## Examples
```
... | 0 |
{"tests": "{\"inputs\": [\"7\\n1 2\\n2 3\\n2 4\\n4 5\\n4 6\\n5 7\\n\", \"7\\n1 2\\n1 3\\n2 4\\n2 5\\n3 6\\n1 7\\n\", \"7\\n1 2\\n2 3\\n3 4\\n3 5\\n3 6\\n3 7\\n\", \"7\\n1 2\\n2 3\\n2 4\\n2 5\\n3 6\\n1 7\\n\", \"7\\n1 2\\n2 3\\n2 4\\n2 5\\n2 6\\n1 7\\n\", \"7\\n1 2\\n4 6\\n2 4\\n3 5\\n3 2\\n3 7\\n\", \"7\\n1 2\\n2 3\\n2... | You are given an undirected tree consisting of $n$ vertices. An undirected tree is a connected undirected graph with $n - 1$ edges.
Your task is to add the minimum number of edges in such a way that the length of the shortest path from the vertex $1$ to any other vertex is at most $2$. Note that you are not allowed to... | 0 |
{"tests": "{\"inputs\": [\"oyh\\nni\\nEND_OF_TEXT\\nf\\nd\\nf\\nf\\nk\\np\\np\\ne\\ny\\na\\nk\\ny\\ny\\nn\\ny\\n-\", \"hyo\\nnh\\nEND_OF_TEXT\\nf\\nd\\nf\\nf\\nk\\np\\np\\ne\\ny\\na\\nk\\ny\\ny\\nn\\ny\\n-\", \"hyo\\nni\\nEND_OF_TEXT\\nf\\nd\\ng\\nf\\nk\\np\\np\\ne\\ny\\na\\nk\\ny\\ny\\nn\\ny\\n-\", \"hyo\\nnh\\nEND_OF... | Emacs is a text editor which is widely used by many programmers.
The advantage of Emacs is that we can move a cursor without arrow keys and the mice. For example, the cursor can be moved right, left, down, and up by pushing f, b, n, p with the Control Key respectively. In addition, cut-and-paste can be performed witho... | 0 |
{"tests": "{\"inputs\": [\"7 3\\nabb 2\\naaa -3\\nbba -1\\nzyz -4\\nabb 5\\naaa 7\\nxyx 4\\n\", \"3 1\\na 1\\na 2\\na 3\\n\", \"2 5\\nabcde 10000\\nabcde 10000\\n\", \"10 10\\nnjxbzflaka -1\\nfelbvvtkja 6\\ngxiuztqkcw 5\\naomvscmtti 6\\njsqmkoyuca -2\\nwckqtzuixg 5\\najktvvblef -5\\nittmcsvmoa -1\\nakalfzbxjn 10\\nacuy... | Santa Claus likes palindromes very much. There was his birthday recently. k of his friends came to him to congratulate him, and each of them presented to him a string s_{i} having the same length n. We denote the beauty of the i-th string by a_{i}. It can happen that a_{i} is negative — that means that Santa doesn't fi... | 0 |
{"tests": "{\"inputs\": [\"4 10\\n3 4 3 3\\n2\\n4 3\\n\", \"5 9\\n4 4 2 3 2\\n5\\n1 4 2 3 5\\n\", \"6 15\\n4 3 5 4 2 1\\n6\\n1 2 3 4 5 6\\n\", \"5 9\\n4 4 2 3 4\\n5\\n1 4 2 3 5\", \"6 15\\n4 3 5 4 2 1\\n6\\n1 2 3 0 5 6\", \"6 15\\n4 3 5 4 2 1\\n6\\n1 2 4 0 5 6\", \"6 15\\n4 3 5 4 0 1\\n6\\n1 2 3 4 5 6\", \"4 10\\n3 2 3... | Alice lives on a line. Today, she will travel to some place in a mysterious vehicle.
Initially, the distance between Alice and her destination is D. When she input a number x to the vehicle, it will travel in the direction of the destination by a distance of x if this move would shorten the distance between the vehicle... | 0 |
{"tests": "{\"inputs\": [\"3\\n10\\n2 1 3 8 1\\n0\\n10\\n2 1 3 8 5\\n0\\n10\\n2 2 3 8 5\\n3 1 2 1 4 3 2 9 1 1\", \"3\\n10\\n2 1 3 8 1\\n0\\n10\\n2 1 3 8 5\\n0\\n10\\n2 2 3 8 3\\n3 1 2 1 4 3 2 9 1 1\", \"3\\n10\\n2 1 3 8 1\\n0\\n10\\n2 1 3 8 5\\n0\\n10\\n2 2 1 8 5\\n3 1 2 1 4 3 2 9 1 1\", \"3\\n10\\n2 1 3 8 1\\n0\\n10\\... | Read problems statements in Mandarin Chinese and Russian.
Suraj, the Chief Prankster is back in action now and this time he has stolen the valentine's day gift given by Ashi (the love of Chef) to the Chef and ran away with it to Byteland.
Byteland is a not a regular place like Chef's town. The safest way from Chef's... | 0 |
{"tests": "{\"inputs\": [\"6 1\\n2\\n1\\n3\", \"5 1\\n2\\n1\\n0\", \"6 1\\n2\\n1\\n4\", \"5 1\\n1\\n1\\n0\", \"6 1\\n2\\n1\\n8\", \"5 1\\n1\\n1\\n1\", \"7 1\\n1\\n1\\n0\", \"8 1\\n1\\n1\\n0\", \"10 1\\n1\\n1\\n1\", \"11 1\\n6\\n1\\n5\", \"15 1\\n3\\n1\\n2\", \"15 1\\n6\\n1\\n5\", \"15 1\\n3\\n1\\n3\", \"15 1\\n1\\n1\\n... | D: Arrow / Arrow
problem
rodea is in a one-dimensional coordinate system and stands at x = 0. From this position, throw an arrow of positive integer length that always moves at speed 1 towards the target at x = N. However, rodea is powerless, so we have decided to put a total of M blowers in the section 0 \ leq x \ l... | 0 |
{"tests": "{\"inputs\": [\"5\\n3 1\\n1 1\\n-1 0\\n2 1\\n3 0\\n\", \"5\\n-1 0\\n1 1\\n1 1\\n2 0\\n3 0\\n\", \"8\\n2 1\\n-1 0\\n1 0\\n1 1\\n1 1\\n4 0\\n5 1\\n7 0\\n\", \"1\\n-1 0\\n\", \"1\\n-1 0\\n\", \"5\\n-1 0\\n1 0\\n1 1\\n2 0\\n3 0\\n\", \"8\\n2 1\\n-1 0\\n1 1\\n1 1\\n1 1\\n4 0\\n5 1\\n7 0\\n\", \"8\\n2 1\\n-1 0\\n1... | You are given a rooted tree with vertices numerated from $1$ to $n$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.
Ancestors of the vertex $i$ are all vertices on the path from the root to the vertex $i$, except the vertex $i$ itself. The parent of the vertex $i$ is the nea... | 0.75 |
{"tests": "{\"inputs\": [\"5\\n3 21 14 5 13\", \"5\\n2 3 24 6 13\", \"5\\n2 3 38 3 10\", \"5\\n3 24 14 5 13\", \"5\\n3 24 14 10 13\", \"5\\n3 24 16 10 13\", \"5\\n3 36 16 10 13\", \"5\\n3 36 16 14 13\", \"5\\n3 3 16 14 13\", \"5\\n3 3 24 14 13\", \"5\\n3 3 24 6 13\", \"5\\n2 3 24 6 9\", \"5\\n2 3 24 6 14\", \"5\\n2 3 3... | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pai... | 0 |
{"tests": "{\"inputs\": [[\"Carlos Ray Norris\", \"Carlos Ray Norris\"], [\"Carlos Ray Norris\", \"Carlos Ray\"], [\"Carlos Ray Norris\", \"Ray Norris\"], [\"Carlos Ray Norris\", \"Carlos Norris\"], [\"Carlos Ray Norris\", \"Norris\"], [\"Carlos Ray Norris\", \"Carlos\"], [\"Carlos Ray Norris\", \"Norris Carlos\"], [\"... | The objective is to disambiguate two given names: the original with another
This kata is slightly more evolved than the previous one: [Author Disambiguation: to the point!](https://www.codewars.com/kata/580a429e1cb4028481000019).
The function ```could_be``` is still given the original name and another one to test
aga... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 3\\n3 3\\n4 3\", \"3\\n2 4\\n3 3\\n4 3\", \"3\\n2 4\\n3 3\\n3 3\", \"3\\n1 4\\n3 2\\n4 3\", \"3\\n2 4\\n3 6\\n3 3\", \"3\\n2 2\\n3 2\\n2 3\", \"3\\n4 4\\n3 6\\n3 3\", \"3\\n2 2\\n4 2\\n1 3\", \"3\\n1 3\\n3 3\\n4 4\", \"3\\n1 4\\n3 7\\n4 3\", \"3\\n1 5\\n3 2\\n3 3\", \"3\\n1 1\\n3 3\\n4 ... | Problem statement
There are rectangles with vertical and horizontal lengths of h and w, and square squares with a side length of 1 are spread inside. If the upper left cell is (0,0) and the cell to the right of j below (0,0) is represented as (i, j), (i, j) is i + j. If is even, it is painted red, and if it is odd, it... | 0 |
{"tests": "{\"inputs\": [\"2 1\", \"2 2\", \"2 4\", \"0 4\", \"-1 4\", \"-1 0\", \"1 -1\", \"-1 2\", \"-1 -4\", \"-2 -7\", \"-1 -7\", \"-1 -5\", \"1 -6\", \"2 -6\", \"2 -8\", \"5 -10\", \"5 -8\", \"9 -8\", \"9 -14\", \"9 -25\", \"9 -20\", \"18 -20\", \"18 -36\", \"18 -33\", \"18 -27\", \"33 -27\", \"33 -33\", \"66 -33\... | problem
AOR Ika and you came to the tournament-style table tennis tournament singles section for reconnaissance. For AOR Ika-chan, who wants to record all the games, you decide to ask for the number of games that will be played in this tournament.
There are $ N $ players in the tournament, each with a uniform number ... | 0 |
{"tests": "{\"inputs\": [\"4 6\\n1 2 3 4 3 2\\n\", \"10 5\\n9 4 3 8 8\\n\", \"5 10\\n2 5 2 2 3 5 3 2 1 3\\n\", \"10 20\\n6 3 9 6 1 9 1 9 8 2 7 6 9 8 4 7 1 2 4 2\\n\", \"100 100\\n28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 ... | Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes what she sees and what she hears on the notebook, and the notebook became her memory.
Though Ryouko is forgetful, she is also bo... | 0.125 |
{"tests": "{\"inputs\": [[1], [2], [3], [4], [12], [13], [100], [110]], \"outputs\": [[1], [5], [6], [25], [2890625], [7109376], [6188999442576576769103890995893380022607743740081787109376], [9580863811000557423423230896109004106619977392256259918212890625]]}", "source": "taco"} | This is a very simply formulated task. Let's call an integer number `N` 'green' if `N²` ends with all of the digits of `N`. Some examples:
`5` is green, because `5² = 25` and `25` ends with `5`.
`11` is not green, because `11² = 121` and `121` does not end with `11`.
`376` is green, because `376² = 141376` and `1413... | 0 |
{"tests": "{\"inputs\": [[7.4, 10215, 24, 20], [7.9, 107090, 48, 41], [6.8, 105097, 36, 4], [3.8, 48603, 24, 10], [1.9, 182840, 48, 18], [1.9, 19121, 48, 2], [2.2, 112630, 60, 11], [5.6, 133555, 60, 53], [9.8, 67932, 60, 34], [3.7, 64760, 36, 24], [4.6, 85591, 36, 5], [7.0, 168742, 48, 16], [9.6, 17897, 60, 23], [5.2, ... | The description is rather long but it tries to explain what a financing plan is.
The fixed monthly payment for a fixed rate mortgage is the amount paid by the borrower every month that ensures
that the loan is paid off in full with interest at the end of its term.
The monthly payment formula is based on the annuit... | 0 |
{"tests": "{\"inputs\": [\"4\\n4\\n0001\\n1000\\n0011\\n0111\\n3\\n010\\n111\\n0\\n2\\n00000\\n00001\\n4\\n01\\n001\\n0001\\n00001\\n\", \"4\\n4\\n0001\\n1000\\n0011\\n0111\\n3\\n010\\n111\\n0\\n2\\n00000\\n00001\\n4\\n0\\n001\\n0001\\n00001\\n\", \"4\\n4\\n0001\\n0000\\n0011\\n0111\\n3\\n010\\n111\\n1\\n2\\n00000\\n00... | Polycarp has n different binary words. A word called binary if it contains only characters '0' and '1'. For example, these words are binary: "0001", "11", "0" and "0011100".
Polycarp wants to offer his set of n binary words to play a game "words". In this game, players name words and each next word (starting from the ... | 0 |
{"tests": "{\"inputs\": [[[1]], [[3, 5]], [[3, 9, 4]], [[5, 6, 7, 8]], [[13, 1, 21, 9]], [[13, 76, 21, 42, 63]]], \"outputs\": [[1], [8], [25], [52], [88], [674]]}", "source": "taco"} | ## Number pyramid
Number pyramid is a recursive structure where each next row is constructed by adding adjacent values of the current row. For example:
```
Row 1 [1 2 3 4]
Row 2 [3 5 7]
Row 3 [8 12]
Row 4 [20]
```
___
## Task
Given the first row of the number... | 0 |
{"tests": "{\"inputs\": [\"8 3\\naeabcaez\\n\", \"8 3\\nabcddcbb\\n\", \"4 4\\nrkoa\\n\", \"39 30\\nyehuqwaffoiyxhkmdipxroolhahbhzprioobxfy\\n\", \"40 23\\nvwjzsgpdsopsrpsyccavfkyyahdgkmdxrquhcplw\\n\", \"10 5\\nabcdeedcba\\n\", \"5 5\\npjfjb\\n\", \"57 9\\nibkypcbtpdlhhpmghwrmuwaqoqxxexxqoqawumrwhgmphhldixezvfpqh\\n\"... | Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down.
There is a cursor pointing at some symbol of the string. Suppose that c... | 0 |
{"tests": "{\"inputs\": [\"3\\n3 1 2\", \"3\\n1 2 3\", \"4\\n2 3 1 4\", \"4\\n1 3 4 2\", \"8\\n5 3 8 1 2 6 7 4\", \"4\\n3 2 4 1\", \"8\\n4 5 8 1 2 6 7 3\", \"3\\n1 3 2\", \"3\\n2 3 1\", \"3\\n3 2 1\", \"4\\n2 3 4 1\", \"4\\n1 2 3 4\", \"3\\n3 1 2\", \"3\\n3 2 1\", \"3\\n1 2 3\", \"3\\n1 3 2\", \"3\\n2 3 1\", \"4\\n1 4 ... | One day, Snuke was given a permutation of length N, a_1, a_2, ..., a_N, from his friend.
Find the following:
<image>
Constraints
* 1 ≦ N ≦ 200,000
* (a_1, a_2, ..., a_N) is a permutation of (1, 2, ..., N).
Input
The input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
Output
Print th... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 2 2 4 3\\n\", \"3\\n4 1 1\\n\", \"4\\n0 3 0 4\\n\", \"5\\n4 4 3 3 1\\n\", \"5\\n4 3 4 2 4\\n\", \"10\\n2 1 2 3 4 1 3 4 4 4\\n\", \"10\\n2 3 3 1 3 1 3 2 2 4\\n\", \"120\\n1 1 1 1 1 1 1 4 4 1 1 1 1 1 1 1 2 1 1 1 1 1 2 1 1 1 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 4 1 1 4 1 1 1 1 3 1 1 1 1 1 1... | A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they ge... | 0 |
{"tests": "{\"inputs\": [\"5 82\\n22 11 6 7 13\", \"10 100000\\n13715 50001 50002 50003 50004 50005 50006 50007 50008 50009\", \"2 19\\n3 11\", \"5 134\\n22 11 6 7 13\", \"10 100000\\n13715 50001 50002 50003 50004 50005 50006 50532 50008 50009\", \"10 000000\\n13715 50001 50002 50003 50004 50005 50006 50532 50008 50009... | Snuke has a blackboard and a set S consisting of N integers. The i-th element in S is S_i.
He wrote an integer X on the blackboard, then performed the following operation N times:
* Choose one element from S and remove it.
* Let x be the number written on the blackboard now, and y be the integer removed from S. Repla... | 0 |
{"tests": "{\"inputs\": [\"1000000000 10000000 10000000\\n\", \"646139320 570870045 9580639\\n\", \"458000643 743974603 152040411\\n\", \"999999999 1000000000 1\\n\", \"167035009 877444310 205461190\\n\", \"999999123 999999789 123456789\\n\", \"192837483 829387483 828374\\n\", \"628145517 207579013 1361956\\n\", \"9467... | Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements:
* each cut should be straight (horizontal or vertical);
* each cut should go along edges of unit squares (it is prohibited to divide any unit choc... | 0 |
{"tests": "{\"inputs\": [\"7\\n5\\n-1 10 -1 12 -1\\n5\\n-1 40 35 -1 35\\n6\\n-1 -1 9 -1 3 -1\\n2\\n-1 -1\\n2\\n0 -1\\n4\\n1 -1 3 -1\\n7\\n1 -1 7 5 2 -1 5\\n\", \"7\\n5\\n-1 10 -1 12 -1\\n5\\n-1 40 35 -1 35\\n6\\n-1 -1 9 -1 3 -1\\n2\\n-1 -1\\n2\\n0 -1\\n4\\n1 -1 3 -1\\n7\\n1 -1 7 5 2 -1 5\\n\", \"7\\n5\\n-1 10 -1 12 -1\... | Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $a$ of $n$ non-negative integers.
Dark created that array $1000$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elements with ... | 0 |
{"tests": "{\"inputs\": [\"6 1\\n5 6 7 8 10 2\\n3 5 6 7 1 10\\n\", \"4 0\\n5 3 2 2\\n13 8 5 1\\n\", \"5 0\\n1 1 1 1 1\\n10 10 10 10 10\\n\", \"5 1\\n1 1 1 1 1\\n10 10 10 10 10\\n\", \"4 2\\n1 1 1 1\\n10 10 10 10\\n\", \"4 2\\n1 2 4 8\\n1 5 3 5\\n\", \"4 2\\n1 2 4 8\\n5 1 3 5\\n\", \"4 2\\n1 2 4 8\\n5 3 1 5\\n\", \"4 2\... | Mr. Chanek is currently participating in a science fair that is popular in town. He finds an exciting puzzle in the fair and wants to solve it.
There are $N$ atoms numbered from $1$ to $N$. These atoms are especially quirky. Initially, each atom is in normal state. Each atom can be in an excited. Exciting atom $i$ req... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 2 3 4 5 6\\n1 3 5 6 8 4\\n1 2 3 4 5 8\\n1 2 4 5 10 11\\n1 3 3 6 9 11\", \"5\\n1 2 3 4 5 6\\n1 3 5 6 8 4\\n1 2 3 4 5 8\\n1 2 3 5 10 5\\n1 3 3 6 9 11\", \"5\\n1 2 3 4 5 6\\n1 3 5 6 8 4\\n1 2 3 4 6 8\\n1 2 3 5 10 11\\n1 3 3 6 9 11\", \"5\\n1 2 3 4 5 6\\n1 3 5 6 8 4\\n1 2 3 4 5 8\\n1 2 4 5 ... | There is "7 rows" in the game using playing cards. Here we consider a game that simplifies it. Arrange 7 using 13 cards with numbers 1 to 13 written on each. In the match, the game progresses as follows with only two players.
1. Place 7 cards in the "field".
2. Six remaining cards will be randomly distributed to the t... | 0 |
{"tests": "{\"inputs\": [\"3\\n12 3 45\\n\", \"2\\n123 456\\n\", \"20\\n80 9 55 1 98 29 81 10 96 100 70 87 86 12 58 82 10 22 59 13\\n\", \"100\\n3615 1436 2205 5695 9684 7621 391 1579 557 420 1756 5265 247 5494 3509 6089 2931 7372 4939 8030 2901 1150 5389 7168 6213 2723 4301 7250 3857 9178 4723 1932 1161 1412 8200 5226... | This problem differs from the previous one only in the absence of the constraint on the equal length of all numbers $a_1, a_2, \dots, a_n$.
A team of SIS students is going to make a trip on a submarine. Their target is an ancient treasure in a sunken ship lying on the bottom of the Great Rybinsk sea. Unfortunately, th... | 0.625 |
{"tests": "{\"inputs\": [\"2 1\\n-1000000000 1000000000\\n2 1\\n2 1 2\\n\", \"4 4\\n2 -1000 100 3\\n2 1\\n3 2\\n4 1\\n2 1 3\\n2 2 2\\n1 1 -1000000000\\n2 1 4\\n\", \"6 4\\n10 -9 2 -1 4 -6\\n1 5\\n5 4\\n5 6\\n6 2\\n6 3\\n2 1 4\\n1 1 -3\\n2 1 2\\n2 3 3\\n\", \"6 4\\n0 -9 2 -1 4 -6\\n1 5\\n5 4\\n5 6\\n6 2\\n6 3\\n2 1 4\\n... | Chanek Jones is back, helping his long-lost relative Indiana Jones, to find a secret treasure in a maze buried below a desert full of illusions.
The map of the labyrinth forms a tree with n rooms numbered from 1 to n and n - 1 tunnels connecting them such that it is possible to travel between each pair of rooms throug... | 0.625 |
{"tests": "{\"inputs\": [\"6 7\", \"12 2\", \"16 38\", \"1 7\", \"12 1\", \"16 25\", \"2 7\", \"12 0\", \"16 29\", \"2 9\", \"16 46\", \"3 9\", \"16 31\", \"4 9\", \"27 31\", \"4 18\", \"27 51\", \"4 10\", \"27 102\", \"1 10\", \"42 102\", \"42 123\", \"46 123\", \"70 123\", \"70 2\", \"121 2\", \"63 2\", \"63 4\", \"6... | E869120 defined a sequence $a$ like this:
* $a_1=a_2=1$, $a_{k+2}=a_{k+1}+a_k \ (k \ge 1)$
He also defined sequences $d_1, d_2, d_3, \dots , d_n$, as the following recurrence relation :
* $d_{1, j} = a_j$
* $d_{i, j} = \sum_{k = 1}^j d_{i - 1, k} \ (i \ge 2)$
You are given integers $n$ and $m$. Please calculate... | 0 |
{"tests": "{\"inputs\": [\"4\\n0 0 0\\n2 0 0\\n2 2 0\\n0 2 0\\n4\\n1 1 -1\\n1 1 1\\n1 3 1\\n1 3 -1\\n\", \"4\\n4 -2 0\\n4 3 0\\n-3 3 0\\n-3 -2 0\\n4\\n6 -2 0\\n3 2 2\\n-3 7 0\\n3 4 6\\n\", \"4\\n-6 6 0\\n13 9 0\\n15 -7 0\\n-5 -5 0\\n4\\n2 0 4\\n2 6 8\\n2 12 1\\n2 4 -4\\n\", \"3\\n2 16 0\\n8 -6 -8\\n8 3 8\\n4\\n-10 5 0\... | Cowboy Beblop is a funny little boy who likes sitting at his computer. He somehow obtained two elastic hoops in the shape of 2D polygons, which are not necessarily convex. Since there's no gravity on his spaceship, the hoops are standing still in the air. Since the hoops are very elastic, Cowboy Beblop can stretch, rot... | 0 |
{"tests": "{\"inputs\": [\"0-(2+3-4+5)\", \"0-(2+3-3+5)\", \"2-(2+3-4+5)\", \"1-(3+2-4+5)\", \"2-(2-3+4+5)\", \"0-(3+4-4+5)\", \"3+(2-4-4+5)\", \"2-(2+2-4+5)\", \"2+(2-4-4+5)\", \"2-(2+2-5+5)\", \"2-(2-3+4+6)\", \"3+(2-4-4+6)\", \"4-(2+5-0+2)\", \"2-(2-3+4+7)\", \"0-(4+5-1+6)\", \"0-(4+5-1+5)\", \"0-(2+3+4-4)\", \"0-(4... | Tunnel formula
One day while exploring an abandoned mine, you found a long formula S written in the mine. If you like large numbers, you decide to take out the choke and add `(` or `)` so that the result of the formula calculation is as large as possible. If it has to be a mathematical formula even after adding it, ho... | 0 |
{"tests": "{\"inputs\": [[2, 1, 2], [2, 1, 1], [1, 1, 1], [1, 2, 3], [1, 3, 1], [2, 2, 2], [5, 1, 3], [3, 5, 7], [5, 6, 1], [1, 6, 1], [2, 6, 1], [6, 7, 1], [2, 10, 3], [1, 8, 3], [9, 7, 2], [1, 1, 10], [9, 1, 1], [10, 5, 6], [1, 10, 1]], \"outputs\": [[6], [4], [3], [9], [5], [8], [20], [105], [35], [8], [14], [48], [... | # Task
* **_Given_** *three integers* `a` ,`b` ,`c`, **_return_** *the **_largest number_** obtained after inserting the following operators and brackets*: `+`, `*`, `()`
* In other words , **_try every combination of a,b,c with [*+()] , and return the Maximum Obtained_**
___
# Consider an Example :
**_With the numbe... | 0 |
{"tests": "{\"inputs\": [[\"5\", \"????CIELIS???E?\", \"????CIELISOUR???F\", \"T?KEITE?SY\", \"????????\", \"???C???\"], \"5\\n????CIELIS???E?\\n????CIELISOUR???F\\nT?KEITE?SY\\n????????\\n@??C???\", \"5\\n????CIELIS???E?\\n????CIELISOUR???F\\nYS?ETIEK?T\\n????????\\n@??C???\", \"5\\n????CIELIS???E?\\n????CIELISOUR???F... | Chef Ciel wants to put a fancy neon signboard over the entrance of her restaurant. She has not enough money to buy the new one so she bought some old neon signboard through the internet. Ciel was quite disappointed when she received her order - some of its letters were broken. But she realized that this is even better ... | 0 |
{"tests": "{\"inputs\": [\"10\\n1598114589\", \"11\\n18396312558\", \"10\\n2555486547\", \"10\\n2722382398\", \"10\\n2713182985\", \"10\\n4333783596\", \"11\\n24764186449\", \"10\\n1859787539\", \"10\\n1888971773\", \"10\\n6843843631\", \"10\\n3639938767\", \"10\\n3398916166\", \"11\\n31342613688\", \"10\\n1138256531\"... | Problem
Den, the phone number of Ukunikia Co., Ltd., enters a very long phone number into the phone every day.
One day, too tired, Den came up with a surprising idea.
"Isn't it even a little easier if you rearrange the arrangement of the buttons on the phone ?!"
The phone has squares evenly spaced at $ 3 \ times 3 $,... | 0 |
{"tests": "{\"inputs\": [\"3 3 2\\n1 2\\n2 1\\n3 3\\n3 2\\n\", \"5 4 3\\n3 4\\n3 1\\n3 3\\n5 3\\n1 3\\n1 4\\n\", \"1 1 10\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n\", \"10 10 20\\n7 5\\n4 5\\n5 4\\n7 4\\n1 5\\n6 7\\n9 5\\n8 4\\n1 4\\n2 10\... | Petya has a rectangular Board of size $n \times m$. Initially, $k$ chips are placed on the board, $i$-th chip is located in the cell at the intersection of $sx_i$-th row and $sy_i$-th column.
In one action, Petya can move all the chips to the left, right, down or up by $1$ cell.
If the chip was in the $(x, y)$ cell, ... | 0 |
{"tests": "{\"inputs\": [\"2\\n\", \"13\\n\", \"720\\n\", \"0\\n\", \"1\\n\", \"3\\n\", \"4\\n\", \"5\\n\", \"6\\n\", \"637\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"10\\n\", \"11\\n\", \"100\\n\", \"99\\n\", \"245\\n\", \"118\\n\", \"429\\n\", \"555\\n\", \"660\\n\", \"331\\n\", \"987\\n\", \"123456789\\n\", \"234567890\\... | You know that Japan is the country with almost the largest 'electronic devices per person' ratio. So you might be quite surprised to find out that the primary school in Japan teaches to count using a Soroban — an abacus developed in Japan. This phenomenon has its reasons, of course, but we are not going to speak about ... | 0 |
{"tests": "{\"inputs\": [[100], [2], [3], [8], [1111], [3000]], \"outputs\": [[null], [7], [0], [7], [9], [5]]}", "source": "taco"} | Looking at consecutive powers of `2`, starting with `2^1`:
`2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, ...`
Note that out of all the digits `0-9`, the last one ever to appear is `7`. It only shows up for the first time in the number `32768 (= 2^15)`.
So let us define LAST DIGIT TO APPE... | 0 |
{"tests": "{\"inputs\": [\"4181 6765\\n\", \"416445288135075809 416445288135075809\\n\", \"964542760623675601 965233603018687501\\n\", \"2 1000000000000000000\\n\", \"999999999999999999 999999999999999998\\n\", \"498454011879264 806515533049393\\n\", \"1 1000000000000000000\\n\", \"519421744863260201 572972909476222789... | Alice and Bob decided to eat some fruit. In the kitchen they found a large bag of oranges and apples. Alice immediately took an orange for herself, Bob took an apple. To make the process of sharing the remaining fruit more fun, the friends decided to play a game. They put multiple cards and on each one they wrote a let... | 0 |
{"tests": "{\"inputs\": [\"1 100\\n79\\n\", \"50 3\\n33 7 96 30 68 37 44 50 100 71 12 100 72 43 17 75 59 96 16 34 25 3 90 45 7 55 92 59 30 25 96 23 40 41 95 99 93 79 89 11 76 60 4 100 75 14 37 39 87 47\\n\", \"100 10\\n3 114 77 78 105 87 6 122 141 100 75 118 64 18 88 37 109 72 31 101 36 10 62 18 52 17 149 115 22 150 13... | Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab.
There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing p... | 0.375 |
{"tests": "{\"inputs\": [[7, 3], [11, 19], [40, 3], [14, 2], [100, 1], [1, 300], [2, 300], [5, 300], [7, 300], [300, 300]], \"outputs\": [[4], [10], [28], [13], [100], [1], [1], [1], [7], [265]]}", "source": "taco"} | In this kata you have to correctly return who is the "survivor", ie: the last element of a Josephus permutation.
Basically you have to assume that n people are put into a circle and that they are eliminated in steps of k elements, like this:
```
josephus_survivor(7,3) => means 7 people in a circle;
one every 3 is eli... | 0 |
{"tests": "{\"inputs\": [[\"lamppu\"], [\"lamppu sofia\"], [\"silly game\"], [\"aeiou\"], [\"xyz lamppu\"], [\"\"], [\"lAmppU\"], [\"silly grrr\"]], \"outputs\": [[\"komppu-lantti\"], [\"komppu-lantti kofia-sontti\"], [\"kolly-sintti kome-gantti\"], [\"koeiou-antti\"], [\"koz-xyntti komppu-lantti\"], [\"\"], [\"komppU-... | Kontti language is a finnish word play game.
You add `-kontti` to the end of each word and then swap their characters until and including the first vowel ("aeiouy");
For example the word `tame` becomes `kome-tantti`; `fruity` becomes `koity-fruntti` and so on.
If no vowel is present, the word stays the same.
Write... | 0 |
{"tests": "{\"inputs\": [\"6\\n(?????\\n\", \"10\\n(???(???(?\\n\", \"4\\n))((\\n\", \"6\\n))??((\\n\", \"10\\n((?()??())\\n\", \"10\\n())))()(((\\n\", \"6\\n(?((??\\n\", \"18\\n?(?(?(?(?(?(?(?(??\\n\", \"18\\n??)??))?)?)???))))\\n\", \"18\\n((?((((???(??(????\\n\", \"2\\n??\\n\", \"1\\n?\\n\", \"4\\n????\\n\", \"6\\n(... | Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | 0.125 |
{"tests": "{\"inputs\": [[\"I am applying for the role of Base Manager on Titan.\", 60, true], [\"I am looking to relocate to the vicinity of Saturn for family reasons.\", 70, true], [\"As Deputy Base Manager on Phobos for five Martian years, I have significant relevant experience.\", 90, false], [\"A challenging caree... | Cara is applying for several different jobs.
The online application forms ask her to respond within a specific character count.
Cara needs to check that her answers fit into the character limit.
Annoyingly, some application forms count spaces as a character, and some don't.
Your challenge:
Write Cara a function `ch... | 0 |
{"tests": "{\"inputs\": [\"10 7\\n1 5 18\\n3 4 8\\n1 3 5\\n4 7 10\\n5 9 8\\n6 10 5\\n8 10 5\", \"4 2\\n1 2 2\\n3 4 2\", \"10 7\\n1 5 18\\n3 4 8\\n1 3 5\\n4 7 10\\n5 9 8\\n6 10 5\\n5 10 5\", \"10 7\\n1 5 18\\n3 4 8\\n1 3 5\\n4 7 10\\n3 9 8\\n6 10 5\\n5 10 5\", \"10 7\\n1 5 18\\n3 4 13\\n1 3 5\\n4 7 10\\n3 9 1\\n6 10 5\\... | We have N points numbered 1 to N arranged in a line in this order.
Takahashi decides to make an undirected graph, using these points as the vertices. In the beginning, the graph has no edge. Takahashi will do M operations to add edges in this graph. The i-th operation is as follows:
* The operation uses integers L_i ... | 0 |
{"tests": "{\"inputs\": [\"10\\nGGGSGGGSGG\\n\", \"4\\nGGGG\\n\", \"3\\nSSS\\n\", \"11\\nSGGGGSGGGGS\\n\", \"300\\nSSGSGSSSGSGSSSSGGSGSSGGSGSGGSSSGSSGSGGSSGGSGSSGGSGGSSGSSSGSGSGSSGSGGSSSGSSGSSGGGGSSGSSGSSGSGGSSSSGGGGSSGSSSSSSSSGSSSSGSGSSSSSSSSGSGSSSSGSSGGSSGSGSSSSSSGSGSSSGGSSGSGSSGSSSSSSGGGSSSGSGSGSGGSGGGSSGSGSSSGSSGGS... | Vova has won $n$ trophies in different competitions. Each trophy is either golden or silver. The trophies are arranged in a row.
The beauty of the arrangement is the length of the longest subsegment consisting of golden trophies. Vova wants to swap two trophies (not necessarily adjacent ones) to make the arrangement a... | 0 |
{"tests": "{\"inputs\": [\"10\\n1 1\\n8 10\\n1 7\\n6 8\\n5 7\\n1 9\\n8 8\\n6 10\\n1 4\\n3 4\\n\", \"10\\n1 4\\n1 12\\n5 7\\n5 5\\n2 5\\n1 7\\n1 10\\n7 9\\n8 9\\n9 11\\n\", \"10\\n6 7\\n5 11\\n5 10\\n9 10\\n11 12\\n6 12\\n7 11\\n1 1\\n5 9\\n2 8\\n\", \"10\\n6 9\\n1 8\\n6 12\\n8 15\\n2 5\\n1 2\\n7 15\\n12 15\\n5 12\\n8 1... | On a history lesson the teacher asked Vasya to name the dates when n famous events took place. He doesn't remembers the exact dates but he remembers a segment of days [li, ri] (inclusive) on which the event could have taken place. However Vasya also remembers that there was at most one event in one day. Help him choose... | 0 |
{"tests": "{\"inputs\": [\"160\\n1 1 4 0\\n160\\n1 0 2 10\\n0\", \"160\\n1 1 4 0\\n58\\n2 0 4 10\\n0\", \"160\\n1 1 4 0\\n46\\n2 0 4 10\\n0\", \"160\\n1 1 4 0\\n160\\n0 0 2 10\\n0\", \"160\\n1 1 2 0\\n160\\n1 -1 1 10\\n0\", \"160\\n1 1 4 0\\n109\\n2 0 7 10\\n0\", \"160\\n0 1 4 0\\n160\\n0 1 2 10\\n0\", \"160\\n1 1 4 0\... | Mr. Bill is shopping at the store. There are some coins in his wallet (10-yen coins, 50-yen coins, 100-yen coins, 500-yen coins), but he is now trying to consume as much of this coin as possible. In other words, by paying for the goods with an appropriate number of coins, we are trying to minimize the total number of c... | 0 |
{"tests": "{\"inputs\": [\"3\\n2 1 3\\n\", \"3\\n3 1 4\\n\", \"1\\n1\\n\", \"4\\n7 7 1 1\\n\", \"2\\n3 4\\n\", \"10\\n582366931603099761 314858607473442114 530263190370309150 871012489649491233 877068367969362781 671646356752418008 390155369686708364 958695211216189893 919124874293325142 196726357117434998\\n\", \"20\\... | Ridhiman challenged Ashish to find the maximum valued subsequence of an array $a$ of size $n$ consisting of positive integers.
The value of a non-empty subsequence of $k$ elements of $a$ is defined as $\sum 2^i$ over all integers $i \ge 0$ such that at least $\max(1, k - 2)$ elements of the subsequence have the $i$-t... | 0 |
{"tests": "{\"inputs\": [\"3\", \"100010\", \"6\", \"110010\", \"9\", \"110011\", \"11\", \"110001\", \"13\", \"111001\", \"26\", \"101001\", \"12\", \"101101\", \"8\", \"101100\", \"14\", \"101000\", \"21\", \"111000\", \"10\", \"111011\", \"28\", \"011011\", \"7\", \"011111\", \"15\", \"111111\", \"111110\", \"101110... | There are N squares lining up in a row, numbered 1 through N from left to right. Initially, all squares are white. We also have N-1 painting machines, numbered 1 through N-1. When operated, Machine i paints Square i and i+1 black.
Snuke will operate these machines one by one. The order in which he operates them is rep... | 0 |
{"tests": "{\"inputs\": [\"5\\n10 0 -7 2 6\\n\", \"7\\n0 0 1 -1 0 0 2\\n\", \"5\\n0 0 0 1 1\\n\", \"1\\n777\\n\", \"2\\n1 0\\n\", \"100\\n39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39... | You are given an array of $n$ integers: $a_1, a_2, \ldots, a_n$. Your task is to find some non-zero integer $d$ ($-10^3 \leq d \leq 10^3$) such that, after each number in the array is divided by $d$, the number of positive numbers that are presented in the array is greater than or equal to half of the array size (i.e.,... | 0 |
{"tests": "{\"inputs\": [\"3 4 5\\n10 30 15\\n12 31 14 18\\n0 1 2 3 4\\n\", \"1 1 1\\n1\\n1\\n1\\n\", \"1 1 1\\n1\\n1\\n1\\n\", \"3 4 5\\n10 30 15\\n12 31 14 7\\n0 1 2 3 4\\n\", \"3 4 5\\n10 30 15\\n12 31 14 7\\n0 1 2 1 4\\n\", \"3 4 5\\n10 30 15\\n12 31 27 7\\n0 1 2 1 4\\n\", \"3 4 5\\n10 30 15\\n12 31 17 7\\n0 1 2 1 ... | Monocarp plays a computer game (yet again!). This game has a unique trading mechanics.
To trade with a character, Monocarp has to choose one of the items he possesses and trade it for some item the other character possesses. Each item has an integer price. If Monocarp's chosen item has price $x$, then he can trade it ... | 0 |
{"tests": "{\"inputs\": [\"4\\n0 1 1 0\\n\", \"2\\n1 1\\n\", \"1\\n0\\n\", \"4\\n0 0 0 0\\n\", \"6\\n0 0 0 0 0 1\\n\", \"20\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\", \"20\\n1 1 1 0 1 0 1 1 0 1 1 1 0 1 0 0 1 1 0 0\\n\", \"1\\n1\\n\", \"2\\n0 0\\n\", \"2\\n0 1\\n\", \"2\\n1 0\\n\", \"3\\n0 0 0\\n\", \"3\\n0 0 1\\n\... | Implication is a function of two logical arguments, its value is false if and only if the value of the first argument is true and the value of the second argument is false.
Implication is written by using character '$\rightarrow$', and the arguments and the result of the implication are written as '0' (false) and '1'... | 0 |
{"tests": "{\"inputs\": [[\"yvvi\"], [\"Blf zoivzwb szw 10 yvvih\"], [\"Ovg'h hdrn rm gsv ulfmgzrm!\"], [{\"brand\": \"Starobrno\"}], [\"Tl slnv, blf'iv wifmp\"], [\"Hfiv r xzm wzmxv lm xlk'h xzi, slow nb yvvi\"], [true], [\"Hvv? R'n mlg gszg wifmp, r xzm hgroo gzpv nb xolgsvh luu\"], [123], [[\"Beer\"]]], \"outputs\":... | You're hanging out with your friends in a bar, when suddenly one of them is so drunk, that he can't speak, and when he wants to say something, he writes it down on a paper. However, none of the words he writes make sense to you. He wants to help you, so he points at a beer and writes "yvvi". You start to understand wha... | 0 |
{"tests": "{\"inputs\": [\"9 6\\n1 1 1 3 5 3 5 7\\n3 1\\n1 5\\n3 4\\n7 3\\n1 8\\n1 9\\n\", \"2 1\\n1\\n1 1\\n\", \"13 12\\n1 1 1 1 1 1 1 1 1 1 1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n\", \"2 1\\n1\\n1 1\\n\", \"13 12\\n1 1 1 1 1 1 1 1 1 1 1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n1... | In this problem you will have to help Berland army with organizing their command delivery system.
There are $n$ officers in Berland army. The first officer is the commander of the army, and he does not have any superiors. Every other officer has exactly one direct superior. If officer $a$ is the direct superior of off... | 0.75 |
{"tests": "{\"inputs\": [\"7\\nbanana\\nta\\ntomb\\nbus\\nsound\\ndoes\\nsome\", \"7\\nananab\\nta\\nsomb\\nbus\\nsound\\ndoes\\nsemo\", \"7\\nbanaoa\\nta\\ntomb\\nbus\\nsound\\ndoes\\nsome\", \"7\\nbanaoa\\nta\\nuomb\\nbus\\nsound\\ndoes\\nsome\", \"7\\nbanaoa\\nua\\ntomb\\nbus\\nsound\\ndoes\\nsome\", \"7\\nbanaoa\\n... | D: Shiritori Compression
problem
Ebi-chan and Kana-chan did a shiritori. Ebi-chan is looking at the memo of the word that came out in Shiritori.
Ebi-chan wants to remove redundant continuous subsequences from this word sequence w_1, w_2, ..., w_N until they no longer exist. The redundant continuous subsequence that ... | 0.375 |
{"tests": "{\"inputs\": [\"2\\n2 1\\n\", \"3\\n1 2\\n3 2\\n\", \"6\\n1 5\\n3 4\\n6 1\\n3 2\\n3 1\\n\", \"4\\n4 3\\n4 1\\n4 2\\n\", \"5\\n4 1\\n4 5\\n1 2\\n1 3\\n\", \"7\\n5 7\\n2 5\\n2 1\\n1 6\\n3 6\\n4 1\\n\", \"8\\n8 6\\n7 4\\n8 5\\n2 7\\n3 2\\n5 2\\n1 2\\n\", \"9\\n3 1\\n2 7\\n9 2\\n2 1\\n6 9\\n8 9\\n9 5\\n2 4\\n\",... | Eric is the teacher of graph theory class. Today, Eric teaches independent set and edge-induced subgraph.
Given a graph $G=(V,E)$, an independent set is a subset of vertices $V' \subset V$ such that for every pair $u,v \in V'$, $(u,v) \not \in E$ (i.e. no edge in $E$ connects two vertices from $V'$).
An edge-induced ... | 0 |
{"tests": "{\"inputs\": [[\"a\"], [\"aaaa\"], [\"abcd\"], [\"babababababababa\"], [\"bbabbaaabbaaaabb\"], [\"123a123a123a\"], [\"123A123a123a\"], [\"12aa13a21233\"], [\"12aa13a21233A\"], [\"abcdabcaccd\"]], \"outputs\": [[\"a\"], [\"a\"], [\"abcd\"], [\"ab\"], [\"ab\"], [\"123a\"], [\"111222333Aaa\"], [\"123a\"], [\"11... | Similar to the [previous kata](https://www.codewars.com/kata/string-subpattern-recognition-ii/), but this time you need to operate with shuffled strings to identify if they are composed repeating a subpattern
Since there is no deterministic way to tell which pattern was really the original one among all the possible p... | 0 |
{"tests": "{\"inputs\": [\"5 4\\n1 4 5 60 4\\n\", \"3 1\\n1 1 1\\n\", \"15 2\\n1 2 3 1 2 3 1 2 3 1 2 3 1 2 3\\n\", \"1 1\\n1\\n\", \"2 1\\n1 2\\n\", \"2 1\\n2 1\\n\", \"2 2\\n1 2\\n\", \"2 2\\n2 1\\n\", \"3 1\\n1 2 3\\n\", \"3 1\\n1 3 2\\n\", \"3 1\\n2 1 3\\n\", \"3 1\\n2 3 1\\n\", \"3 1\\n3 1 2\\n\", \"3 1\\n3 2 1\\n\... | You are given an integer sequence $a_1, a_2, \dots, a_n$.
Find the number of pairs of indices $(l, r)$ ($1 \le l \le r \le n$) such that the value of median of $a_l, a_{l+1}, \dots, a_r$ is exactly the given number $m$.
The median of a sequence is the value of an element which is in the middle of the sequence after s... | 0.125 |
{"tests": "{\"inputs\": [\"10\\n206158430208 206162624513 68719476737 137506062337 206162624513 4194305 68719476737 206225539072 137443147777 68719476736\\n202243898 470292528 170057449 290025540 127995253 514454151 607963029 768676450 611202521 68834463\\n\", \"2\\n0 1\\n1 1\\n\", \"10\\n3 3 5 5 6 6 1 2 4 7\\n1 1 1 1 ... | Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.
Let's focus on the students. They are indexed with integers from 1 to n. Each of them can be described with two integers a_i... | 0 |
{"tests": "{\"inputs\": [\"2\\n?rum??mer\\nc??a??mp\", \"3\\nsnuje\\n????e\\neluns\", \"2\\n?rum??mer\\nc@?a??mp\", \"3\\nsunje\\n????e\\neluns\", \"2\\n?rum??mer\\ncA?a??mp\", \"3\\nsunje\\n@???e\\neluns\", \"2\\nrem??mur?\\ncA?a??mp\", \"3\\nsunje\\n@???e\\nsnule\", \"2\\nsem??mur?\\ncA?a??mp\", \"3\\njunse\\n@???e\\... | Sunuke-kun's dictionary contains the words s1, ..., sn, which consist of n lowercase letters. This satisfies s1 <... <sn when compared in lexicographical order. Unfortunately, some characters are faint and unreadable. Unreadable characters are represented by?. Find out how many ways to restore the dictionary by replaci... | 0.125 |
{"tests": "{\"inputs\": [\"3 2\\n1 2\\n2 3\\n1 2 1\\n\", \"4 2\\n1 2\\n3 4\\n1 2 3 3\\n\", \"1 0\\n1\\n\", \"2 1\\n2 1\\n2 2\\n\", \"2 1\\n2 1\\n1 2\\n\", \"4 3\\n1 2\\n2 3\\n3 4\\n1 1 3 2\\n\", \"4 3\\n4 3\\n3 2\\n2 1\\n3 4 4 4\\n\", \"4 3\\n1 2\\n2 3\\n3 4\\n1 1 1 2\\n\", \"1 0\\n1\\n\", \"4 3\\n4 3\\n3 2\\n2 1\\n3 4... | Sasha lives in a big happy family. At the Man's Day all the men of the family gather to celebrate it following their own traditions. There are n men in Sasha's family, so let's number them with integers from 1 to n.
Each man has at most one father but may have arbitrary number of sons.
Man number A is considered to b... | 0 |
{"tests": "{\"inputs\": [\"445762753 268435456\\n\", \"144342486 67108864\\n\", \"257655784 16384\\n\", \"341001112 155173936\\n\", \"329622201 19482151\\n\", \"987654321987 1048576\\n\", \"58797441 33554432\\n\", \"4890852 16\\n\", \"70 32\\n\", \"163985731 33554432\\n\", \"9581849 1024\\n\", \"8670529 16384\\n\", \"3... | Maxim loves to fill in a matrix in a special manner. Here is a pseudocode of filling in a matrix of size (m + 1) × (m + 1):
<image>
Maxim asks you to count, how many numbers m (1 ≤ m ≤ n) are there, such that the sum of values in the cells in the row number m + 1 of the resulting matrix equals t.
Expression (x xor y... | 0 |
{"tests": "{\"inputs\": [\"4\\n3 1\\n0 1 3\\n5 5\\n0 2 1\\n1 1 5\\n1 5 4\\n0 5 2\\n1 3 5\\n4 5\\n1 1 2\\n0 4 3\\n1 3 1\\n0 2 3\\n1 2 4\\n4 5\\n1 4 1\\n1 1 3\\n0 1 2\\n1 2 4\\n1 3 2\\n\", \"4\\n3 1\\n0 1 3\\n5 5\\n1 2 1\\n1 1 5\\n1 5 4\\n0 5 2\\n1 3 5\\n4 5\\n1 1 2\\n0 4 3\\n1 3 1\\n0 2 3\\n1 2 4\\n4 5\\n1 4 1\\n1 1 3\\... | You are given a graph consisting of $n$ vertices and $m$ edges. It is not guaranteed that the given graph is connected. Some edges are already directed and you can't change their direction. Other edges are undirected and you have to choose some direction for all these edges.
You have to direct undirected edges in such... | 0 |
{"tests": "{\"inputs\": [[\"Too Easy?\"], [\"does\"], [\"your\"], [\"solution\"], [\"work\"], [\"for\"], [\"these\"], [\"words\"], [\"DOES\"], [\"YOUR\"], [\"SOLUTION\"], [\"WORK\"], [\"FOR\"], [\"THESE\"], [\"WORDS\"], [\"^does^\"], [\"$your$\"], [\"#solution#\"], [\"¿work¿\"], [\"{for}\"], [\"£these£\"], [\"?symbols?... | ---
# Hint
This Kata is an extension of the earlier ones in this series. Completing those first will make this task easier.
# Background
My TV remote control has arrow buttons and an `OK` button.
I can use these to move a "cursor" on a logical screen keyboard to type words...
# Keyboard
The screen "keyboard" la... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 4 1\\n1 3 2\\n2 2 4\\n2 3 5\\n1\\n1 5 1\\n7\\n2 2 2\\n1 4 1\\n2 1 3\\n1 4 1\\n1 1 1\\n2 5 5\\n1 4 2\\n0\", \"4\\n1 4 1\\n1 3 2\\n1 2 4\\n2 3 5\\n1\\n1 5 1\\n7\\n2 2 2\\n1 4 1\\n2 1 3\\n1 4 1\\n1 1 1\\n2 5 5\\n1 4 2\\n0\", \"4\\n1 4 1\\n1 3 1\\n2 2 4\\n2 3 5\\n1\\n1 5 1\\n7\\n2 2 2\\n1 1... | Tetris is a game in which falling blocks are lined up on the board and erased. Here, let's consider a game that arranges it a little.
The size of the board of this game is 5 frames wide, and it is high enough to accommodate all the blocks that appear. The falling blocks are straight and come in two types, landscape an... | 0 |
{"tests": "{\"inputs\": [\"5 2 3\\n1 -1 1 -1 2\\n\", \"6 3 2\\n1 1 -1 -1 -1 -1\\n\", \"10 42 7\\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1\\n\", \"1 100 1\\n-1\\n\", \"1 100 1\\n-1\\n\", \"1 100 2\\n-1\\n\", \"6 3 2\\n1 1 -1 -1 0 -1\\n\", \"5 2 3\\n2 -1 1 -1 2\\n\", \"5 2 3\\n2 -1 2 -1 2\\n\", \"6 3 4\\n1 1 -1 -1 1 -1\\n\", \"6 3 ... | Vasya has got an array consisting of $n$ integers, and two integers $k$ and $len$ in addition. All numbers in the array are either between $1$ and $k$ (inclusive), or equal to $-1$. The array is good if there is no segment of $len$ consecutive equal numbers.
Vasya will replace each $-1$ with some number from $1$ to $k... | 0.125 |
{"tests": "{\"inputs\": [\"4\\n1 0\\n2 2\\n0 2\\n0 1\", \"7\\n2 1\\n0 0\\n1 2\\n2 0\\n4 2\\n1 3\\n3 3\", \"4\\n1 0\\n3 2\\n0 2\\n0 1\", \"7\\n4 1\\n0 0\\n1 2\\n2 0\\n4 2\\n1 3\\n3 3\", \"7\\n4 1\\n0 0\\n1 2\\n3 0\\n4 2\\n1 3\\n3 3\", \"7\\n2 1\\n0 0\\n1 2\\n2 2\\n4 2\\n1 3\\n0 3\", \"4\\n1 0\\n2 2\\n1 2\\n0 1\", \"7\\n... | Find the convex hull of a given set of points P. In other words, find the smallest convex polygon containing all the points of P. Here, in a convex polygon, all interior angles are less than or equal to 180 degrees.
Please note that you should find all the points of P on both corner and boundary of the convex polygon.... | 0 |
{"tests": "{\"inputs\": [\"6 7\\n1 2\\n1 4\\n2 3\\n2 5\\n3 4\\n4 5\\n4 6\\n2 1\\n1 2\\n3 3\\n1 2\\n2 3\\n2 3\\n4 3\\n1 2\\n2 3\\n3 4\\n5 4\\n1 2\\n2 3\\n3 4\\n4 5\\n0 0\", \"6 7\\n1 4\\n1 4\\n2 3\\n2 5\\n3 4\\n4 5\\n4 6\\n2 1\\n1 2\\n3 3\\n1 2\\n1 3\\n2 3\\n4 3\\n1 2\\n2 3\\n3 4\\n5 4\\n1 2\\n2 3\\n3 4\\n4 5\\n0 0\", \... | Divide and rule
Taro, Hanako, and Jiro rule the JAG Kingdom together. There are N cities in the JAG Kingdom, some of which are connected by two-way roads. You can always reach all the other cities from any city via one or more roads.
One day, Taro and Hanako finally made a mistake and decided to share the city and go... | 0 |
{"tests": "{\"inputs\": [\"12 5 3\\n100 9999 98\\n10000 10000 10000\\n0 0 0\", \"12 2 3\\n100 9999 98\\n10000 10000 10000\\n0 0 0\", \"12 2 3\\n100 15522 98\\n10000 10000 10000\\n0 0 0\", \"12 2 3\\n100 15914 98\\n10000 10000 10000\\n0 0 0\", \"12 2 3\\n100 15914 98\\n10001 10000 10000\\n0 0 0\", \"12 2 3\\n100 15914 1... | Let’s play a stone removing game.
Initially, n stones are arranged on a circle and numbered 1, ... , n clockwise (Figure 1). You are also given two numbers k and m. From this state, remove stones one by one following the rules explained below, until only one remains. In step 1, remove stone m. In step 2, locate the k-... | 0.5 |
{"tests": "{\"inputs\": [\"7\\nafxfxfg\\n3\\nf 3\\nx 2\\nfxf 6\\n1\\n\", \"11\\nfghdgrakmnq\\n8\\nfgh 4\\ngh 3\\nh 10\\nhdg 6\\nhdgra 7\\nakm 12\\nrakm 5\\na 15\\n3\\n\", \"6\\nabacba\\n5\\naba 6\\nba 3\\nbac 4\\ncb 3\\nc 6\\n1\\n\", \"8\\naxghcdex\\n5\\naxgh 13\\nhc 35\\ncde 17\\nxghcd 29\\nghcdex 30\\n3\\n\", \"6\\na... | You have recently fallen through a hole and, after several hours of unconsciousness, have realized you are in an underground city. On one of your regular, daily walks through the unknown, you have encountered two unusually looking skeletons called Sanz and P’pairus, who decided to accompany you and give you some puzzle... | 0 |
{"tests": "{\"inputs\": [\"5\\n2 6 3\\nRRRRRR\\nRRRRRR\\n1 5 3\\nRRRRR\\n2 9 3\\n.R..R..R.\\n.R..R..R.\\n7 4 10\\nR.RR\\nRRR.\\nR.R.\\nR...\\nRRRR\\nRRRR\\nR.RR\\n1 1 1\\nR\\n\", \"4\\n3 5 3\\n..R..\\n...R.\\n....R\\n6 4 6\\nR..R\\nR..R\\nRRRR\\nRRRR\\nR..R\\nR..R\\n5 5 4\\nRRR..\\nR.R..\\nRRR..\\nR..R.\\nR...R\\n2 31 ... | Long is a huge fan of CFC (Codeforces Fried Chicken). But the price of CFC is increasing, so he decides to breed the chicken on his own farm.
His farm is presented by a rectangle grid with r rows and c columns. Some of these cells contain rice, others are empty. k chickens are living on his farm. The number of chicken... | 0 |
{"tests": "{\"inputs\": [[1, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [5, 4], [5, 5], [5, 6], [100, 100]], \"outputs\": [[\"R\"], [\"L\"], [\"L\"], [\"L\"], [\"D\"], [\"U\"], [\"R\"], [\"R\"], [\"R\"], [\"U\"], [\"D\"], [\"L\"], [\"L\"], [\"L\"], [\"U\"... | # Task
You're standing at the top left corner of an `n × m` grid and facing towards the `right`.
Then you start walking one square at a time in the direction you are facing.
If you reach the border of the grid or if the next square you are about to visit has already been visited, you turn right.
You stop w... | 0.125 |
{"tests": "{\"inputs\": [\"4\\n3 6 28 9\\n\", \"5\\n5 12 9 16 48\\n\", \"4\\n1 2 4 8\\n\", \"1\\n1000000000000000000\\n\", \"4\\n70369817919488 281474976710657 70368744177665 281476050452480\\n\", \"5\\n292733975779082240 18014398509482240 306244774661193728 4504699138998272 1099511628032\\n\", \"30\\n550292684800 2149... | You are given $n$ integer numbers $a_1, a_2, \dots, a_n$. Consider graph on $n$ nodes, in which nodes $i$, $j$ ($i\neq j$) are connected if and only if, $a_i$ AND $a_j\neq 0$, where AND denotes the bitwise AND operation.
Find the length of the shortest cycle in this graph or determine that it doesn't have cycles at al... | 0.25 |
{"tests": "{\"inputs\": [\"6 7\\n1 2\\n1 3\\n2 4\\n3 4\\n3 5\\n4 6\\n5 6\\n\", \"5 6\\n1 2\\n1 4\\n2 3\\n3 4\\n2 5\\n3 5\\n\", \"1 0\\n\", \"8 9\\n1 2\\n1 3\\n2 4\\n2 7\\n3 5\\n3 6\\n4 8\\n2 3\\n3 4\\n\", \"4 4\\n1 2\\n1 3\\n3 4\\n1 4\\n\", \"6 7\\n1 2\\n1 3\\n2 3\\n3 4\\n3 5\\n4 6\\n5 6\\n\", \"6 7\\n1 2\\n1 3\\n2 3\\... | We define a spanning tree of a graph to be a BFS tree rooted at vertex s if and only if for every node t the shortest distance between s and t in the graph is equal to the shortest distance between s and t in the spanning tree.
Given a graph, we define f(x,y) to be the number of spanning trees of that graph that are ... | 0 |
{"tests": "{\"inputs\": [\"3\\n2\\n3\\n5\\n\", \"9\\n15\\n7\\n12\\n122\\n127\\n99\\n1999999\\n255\\n8388607\\n\", \"1\\n228\\n\", \"1\\n228\\n\", \"9\\n15\\n7\\n12\\n122\\n127\\n99\\n1999999\\n255\\n8388607\\n\", \"1\\n88\\n\", \"9\\n15\\n7\\n12\\n122\\n127\\n99\\n1984716\\n255\\n8388607\\n\", \"1\\n11\\n\", \"9\\n30\\... | Can the greatest common divisor and bitwise operations have anything in common? It is time to answer this question.
Suppose you are given a positive integer $a$. You want to choose some integer $b$ from $1$ to $a - 1$ inclusive in such a way that the greatest common divisor (GCD) of integers $a \oplus b$ and $a \> \& ... | 0 |
{"tests": "{\"inputs\": [\"4 3 4\\nH 2\\nV 2\\nV 3\\nV 1\\n\", \"7 6 5\\nH 4\\nV 3\\nV 5\\nH 2\\nV 1\\n\", \"2 2 1\\nV 1\\n\", \"2 2 1\\nH 1\\n\", \"2 2 2\\nV 1\\nH 1\\n\", \"2 2 2\\nH 1\\nV 1\\n\", \"10 10 10\\nV 6\\nH 8\\nV 4\\nV 8\\nH 2\\nH 5\\nV 9\\nH 7\\nH 3\\nV 7\\n\", \"5 15 10\\nH 8\\nH 9\\nV 1\\nH 2\\nH 6\\nH ... | Leonid wants to become a glass carver (the person who creates beautiful artworks by cutting the glass). He already has a rectangular w mm × h mm sheet of glass, a diamond glass cutter and lots of enthusiasm. What he lacks is understanding of what to carve and how.
In order not to waste time, he decided to practice t... | 0.25 |
{"tests": "{\"inputs\": [\"2\\n3\\n4\", \"2\\n1\\n4\", \"2\\n2\\n4\", \"2\\n2\\n1\", \"2\\n1\\n1\", \"2\\n4\\n4\", \"2\\n5\\n4\", \"2\\n1\\n6\", \"2\\n-1\\n4\", \"2\\n6\\n4\", \"2\\n4\\n1\", \"2\\n-1\\n7\", \"2\\n6\\n2\", \"2\\n6\\n1\", \"2\\n-1\\n8\", \"2\\n6\\n3\", \"2\\n10\\n1\", \"2\\n4\\n3\", \"2\\n1\\n7\", \"2\\n... | Asmany strings are strings of '0's and '1's that have as many 00 as 11. A string such as 00110001 consists of 3 "00" and
1 "11". Of course this is not an Asmany string. 0011, 1100, 000111000111 are Asmany strings. An L'th Asmany number is the number of
Asmany strings of length L for all positive integers L.
For esoter... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 2 3\\n\", \"3\\n3 1 2\\n\", \"1\\n13\\n\", \"10\\n67 67 67 67 67 67 67 67 67 67\\n\", \"10\\n16 17 16 15 14 15 16 17 16 15\\n\", \"4\\n54 54 54 55\\n\", \"3\\n68 67 67\\n\", \"5\\n46 46 47 46 45\\n\", \"4\\n14 15 15 16\\n\", \"6\\n59 59 60 60 59 58\\n\", \"3\\n40 40 40\\n\", \"4\\n90 91... | Everybody knows of spaghetti sort. You decided to implement an analog sorting algorithm yourself, but as you survey your pantry you realize you're out of spaghetti! The only type of pasta you have is ravioli, but you are not going to let this stop you...
You come up with the following algorithm. For each number in the... | 0.125 |
{"tests": "{\"inputs\": [\"5\\n2 3\\n1 2 3\\n1 1 1\\n2 2\\n4 1\\n2 3\\n2 2\\n2 1\\n1 1\\n2 3\\n6 2 1\\n5 4 3\\n2 1\\n1\\n2\\n\", \"1\\n1 7\\n1 2 4 3 3 3 5\\n\", \"4\\n1 10\\n1 2 3 2 2 2 2 2 3 3\\n1 10\\n1 2 3 3 3 3 3 2 3 3\\n1 10\\n1 2 3 3 3 3 2 2 3 3\\n1 5\\n1 4 3 2 5\\n\", \"1\\n2 4\\n2 1 1 1\\n2 2 2 1\\n\", \"1\\n1 ... | You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$.
You ha... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.