info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [\"3 0\\n\", \"1 1\\nTo the right of 1\\n\", \"1000 1\\nTo the right of 117\\n\", \"2 1\\nTo the right of 2\\n\", \"1 0\\n\", \"2 0\\n\", \"6 2\\nTo the right of 2\\nTo the left of 4\\n\", \"2 2\\nTo the left of 2\\nTo the left of 2\\n\", \"459 16\\nTo the right of 9\\nTo the right of 148\\nTo t... | <image>
One morning the Cereal Guy found out that all his cereal flakes were gone. He found a note instead of them. It turned out that his smart roommate hid the flakes in one of n boxes. The boxes stand in one row, they are numbered from 1 to n from the left to the right. The roommate left hints like "Hidden to the l... | 0.75 |
{"tests": "{\"inputs\": [[\"2\", \"7 4\", \"3 1 2 4 5 7 6\", \"1 2\", \"4 4\", \"6 7\", \"2 3\", \"4 2\", \"2 1 3 4\", \"2 4\", \"2 3\"], \"2\\n7 4\\n6 1 2 4 5 7 6\\n1 2\\n4 4\\n6 7\\n2 3\\n4 2\\n2 1 3 4\\n2 4\\n2 3\", \"2\\n7 4\\n3 1 2 4 5 7 6\\n1 2\\n4 4\\n6 7\\n2 3\\n4 2\\n2 1 3 6\\n2 4\\n2 3\", \"2\\n7 4\\n6 1 2 4 ... | You are given a permutation of natural integers from 1 to N, inclusive. Initially, the permutation is 1, 2, 3, ..., N.
You are also given M pairs of integers, where the i-th is (Li Ri). In a single turn you can choose any of these pairs (let's say with the index j) and arbitrarily shuffle the elements of our permutatio... | 0 |
{"tests": "{\"inputs\": [\"2\\n1 999\\n999 1\\n\", \"3\\n400 600\\n400 600\\n400 600\\n\", \"2\\n500 500\\n500 500\\n\", \"1\\n1 999\\n\", \"10\\n1 999\\n1 999\\n1 999\\n1 999\\n1 999\\n1 999\\n1 999\\n1 999\\n1 999\\n1 999\\n\", \"2\\n499 501\\n501 499\\n\", \"3\\n500 500\\n1 999\\n400 600\\n\", \"1\\n0 1000\\n\", \"1... | The Bitlandians are quite weird people. They have very peculiar customs.
As is customary, Uncle J. wants to have n eggs painted for Bitruz (an ancient Bitland festival). He has asked G. and A. to do the work.
The kids are excited because just as is customary, they're going to be paid for the job!
Overall uncle J. h... | 0 |
{"tests": "{\"inputs\": [[0], [360], [90], [180], [270], [30], [40], [45], [50], [60]], \"outputs\": [[\"12:00\"], [\"12:00\"], [\"03:00\"], [\"06:00\"], [\"09:00\"], [\"01:00\"], [\"01:20\"], [\"01:30\"], [\"01:40\"], [\"02:00\"]]}", "source": "taco"} | # Story
Due to lack of maintenance the minute-hand has fallen off Town Hall clock face.
And because the local council has lost most of our tax money to a Nigerian email scam there are no funds to fix the clock properly.
Instead, they are asking for volunteer programmers to write some code that tell the time by only... | 0 |
{"tests": "{\"inputs\": [\"3\\n4\\n2 1 4 3\\n6\\n4 6 1 2 5 3\\n5\\n5 3 1 2 4\\n\", \"3\\n4\\n2 1 4 3\\n6\\n4 6 1 2 5 3\\n5\\n5 3 1 2 4\\n\", \"3\\n4\\n2 1 4 3\\n6\\n4 10 1 2 5 3\\n5\\n5 3 1 2 4\\n\", \"3\\n4\\n2 1 4 3\\n6\\n4 12 1 2 5 3\\n5\\n5 7 1 2 4\\n\", \"3\\n4\\n2 1 4 3\\n6\\n4 6 1 2 5 3\\n5\\n5 2 1 2 4\\n\", \"3... | You are given a permutation $p_1, p_2, \dots, p_n$. Recall that sequence of $n$ integers is called a permutation if it contains all integers from $1$ to $n$ exactly once.
Find three indices $i$, $j$ and $k$ such that: $1 \le i < j < k \le n$; $p_i < p_j$ and $p_j > p_k$. Or say that there are no such indices.
--... | 0.625 |
{"tests": "{\"inputs\": [\"23\\n1 1 3 1\\n3 1 3 3\\n3 3 1 3\\n1 3 1 5\\n1 5 3 5\\n5 2 7 2\\n7 2 7 4\\n7 4 5 4\\n5 4 5 6\\n5 6 7 6\\n11 4 13 4\\n13 0 15 0\\n15 0 15 4\\n18 2 18 2\\n21 5 23 5\\n21 5 21 7\\n21 7 23 7\\n23 7 23 8\\n23 9 21 9\\n24 0 26 0\\n24 0 24 4\\n24 4 26 4\\n26 0 26 4\", \"23\\n1 1 3 1\\n3 1 3 3\\n3 3 ... | Hint
* One grid may be filled more than once
* Even if it can be represented by one line segment such as '1', it may be represented by two or more line segments.
Sample Input 1
Formula for Sample Input 1.
Sample Input 2
Sample Input 2 formula. Another character may get inside the smallest rectangle that covers one... | 0 |
{"tests": "{\"inputs\": [\"7\\n0 1\\n1 2\\n2 3\\n0 4\\n0 5\\n0 6\", \"7\\n0 1\\n1 2\\n0 3\\n3 4\\n0 5\\n0 6\", \"3\\n0 2\\n0 1\", \"7\\n0 1\\n1 2\\n0 3\\n3 4\\n0 5\\n1 6\", \"3\\n1 2\\n0 1\", \"7\\n0 1\\n1 2\\n2 3\\n2 4\\n0 5\\n0 6\", \"7\\n0 1\\n0 2\\n2 3\\n0 4\\n0 5\\n0 6\", \"7\\n0 1\\n1 2\\n1 3\\n3 4\\n0 5\\n1 6\",... | There are N towers in the town where Ikta lives. Each tower is given a different number from 0 to N-1, and the tower with number i is called tower i. Curious Ikta was interested in the height of the N towers and decided to make a table T showing the magnitude relationship between them. T has N × N elements, and each el... | 0 |
{"tests": "{\"inputs\": [\"10 2 1\\n1 1 1\\n1 1 1\\n1 1 1\\n2 2 2\\n2 2 2\\n2 2 2\\n\", \"8 1 1\\n2 2 1\\n3 3 1\\n3 1 3\\n1 1 1\\n2 1 1\\n1 2 3\\n\", \"5 1 1\\n1 2 2\\n2 2 2\\n2 2 2\\n1 2 2\\n2 2 2\\n2 2 2\\n\", \"1 1 1\\n3 3 1\\n1 1 1\\n3 2 2\\n2 2 2\\n1 3 1\\n3 3 2\\n\", \"1 3 1\\n1 3 3\\n2 3 2\\n2 1 3\\n1 3 2\\n3 3 ... | Ilya is working for the company that constructs robots. Ilya writes programs for entertainment robots, and his current project is "Bob", a new-generation game robot. Ilya's boss wants to know his progress so far. Especially he is interested if Bob is better at playing different games than the previous model, "Alice".
... | 0.25 |
{"tests": "{\"inputs\": [\"3 2\\n1 2\\n1 3\\n\", \"3 1\\n1 2\\n2 3\\n\", \"20 7\\n9 7\\n3 7\\n15 9\\n1 3\\n11 9\\n18 7\\n17 18\\n20 1\\n4 11\\n2 11\\n12 18\\n8 18\\n13 2\\n19 2\\n10 9\\n6 13\\n5 8\\n14 1\\n16 13\\n\", \"2 1\\n1 2\\n\", \"3 1\\n1 2\\n1 3\\n\", \"3 0\\n1 2\\n2 3\\n\", \"20 7\\n9 7\\n3 7\\n15 9\\n1 4\\n11... | Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.
<image>
There are n cities and n-1 two-way roads connecting pairs of cities in the ki... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 1 1\\n\", \"8\\n8 7 6 5 4 3 2 1\\n\", \"24\\n1 8 1 2 8 2 3 8 3 4 8 4 5 8 5 6 8 6 7 8 7 8 8 8\\n\", \"1\\n8\\n\", \"2\\n5 4\\n\", \"3\\n3 3 2\\n\", \"18\\n3 6 6 8 8 1 1 4 4 3 3 5 5 7 7 2 2 3\\n\", \"5\\n2 6 1 2 6\\n\", \"6\\n4 3 1 6 7 4\\n\", \"7\\n8 8 2 6 1 8 5\\n\", \"8\\n2 8 4 7 5 3 6... | Vladik was bored on his way home and decided to play the following game. He took n cards and put them in a row in front of himself. Every card has a positive integer number not exceeding 8 written on it. He decided to find the longest subsequence of cards which satisfies the following conditions:
the number of occur... | 0 |
{"tests": "{\"inputs\": [[[0, 0, 17], 1], [[1, 1, 15], 2], [[34, 32, 35], 0], [[34, 32, 35], 1], [[33, 0, 35], 2], [[673905669, 673905681, 174867657], 2], [[74356, 0, 0], 0], [[1, 2147483646, 1], 1], [[0, 1, 0], 2], [[0, 1, 0], 1], [[0, 333, 0], 0]], \"outputs\": [[-1], [1], [35], [-1], [33], [673905681], [0], [1], [-1... | **Story**
On some island lives a chameleon population. Chameleons here can be of only one of three colors - red, green and blue. Whenever two chameleons of different colors meet, they can change their colors to a third one (i.e. when red and blue chameleons meet, they can both become green). There is no other way for... | 0 |
{"tests": "{\"inputs\": [\"4 4\\n\", \"5 3\\n\", \"1 1\\n\", \"744 18\\n\", \"47879 10\\n\", \"1000000000000000000 1000000000000000000\\n\", \"657180569218773599 42\\n\", \"442762254977842799 30\\n\", \"474158606260730555 1\\n\", \"807873101233533988 39\\n\", \"423 7\\n\", \"264306177888923090 5\\n\", \"998857801526481... | Imp is watching a documentary about cave painting. [Image]
Some numbers, carved in chaotic order, immediately attracted his attention. Imp rapidly proposed a guess that they are the remainders of division of a number n by all integers i from 1 to k. Unfortunately, there are too many integers to analyze for Imp.
Imp ... | 0.25 |
{"tests": "{\"inputs\": [\"2\\n3\\n0 2 2\\n4\\n2 3 1 10\\n\", \"15\\n2\\n660632533 660632533\\n2\\n774306959 774306959\\n2\\n971739496 784083784\\n2\\n775353256 672614891\\n2\\n403290217 403290217\\n2\\n651261320 651261320\\n2\\n894672621 894672621\\n2\\n46281693 620415865\\n2\\n92929999 409128591\\n2\\n26890011 630323... | Baby Ehab is known for his love for a certain operation. He has an array $a$ of length $n$, and he decided to keep doing the following operation on it:
he picks $2$ adjacent elements; he then removes them and places a single integer in their place: their bitwise XOR . Note that the length of the array decreases by one... | 0 |
{"tests": "{\"inputs\": [\"5\\n2 2 1 2\\n9 5\\n1 17\\n3 2 2 1\\n6 1 20\\n8 18 3\\n8\\n5 4 1 3\\n5 5 4 5 5\\n8 2 1 9 7\\n1 1 3 5 1\\n7 2 7 1 3\\n6 5 6 2\\n2 3 5 8 2 7\\n1 6 9 4 5 1\\n2 5 5 4 2 2\\n5 4 2 5 3 3\\n7 1 5 1 5 6\\n6\\n3 3 2 2\\n2 9 2\\n9 1 9\\n2 9 2\\n2 2 1 1\\n1 3\\n5 7\\n0\", \"5\\n2 2 1 2\\n6 5\\n1 17\\n3 ... | problem
Do you know Just Odd Inventions? The business of this company is to "just odd inventions". Here we call it JOI for short.
JOI has two offices, each of which has square rooms of the same size arranged in a grid pattern. All the rooms that are in contact with each other have an ID card authentication function. ... | 0 |
{"tests": "{\"inputs\": [\"4\\n2 1 2\", \"4\\n2 1 3\", \"4\\n0 0 2\", \"4\\n1 1 2\", \"4\\n1 0 2\", \"4\\n2 1 0\", \"4\\n1 2 0\", \"4\\n2 0 3\", \"4\\n2 2 0\", \"4\\n1 3 2\", \"4\\n2 2 3\", \"4\\n0 0 3\", \"4\\n0 0 1\", \"4\\n0 -1 1\", \"4\\n0 1 2\", \"4\\n1 0 3\", \"4\\n1 1 0\", \"4\\n0 -1 3\", \"4\\n1 0 1\", \"4\\n0 ... | You are given a set $T$, which is a subset of $U$. The set $U$ consists of $0, 1, ... n-1$. Print all sets, each of which is a subset of $U$ and includes $T$ as a subset. Note that we represent $0, 1, ... n-1$ as 00...0001, 00...0010, 00...0100, ..., 10...0000 in binary respectively and the integer representation of a ... | 0 |
{"tests": "{\"inputs\": [\"5\\n7500 South\\n10000 East\\n3500 North\\n4444 West\\n4000 North\\n\", \"2\\n15000 South\\n4000 East\\n\", \"5\\n20000 South\\n1000 North\\n1000000 West\\n9000 North\\n10000 North\\n\", \"3\\n20000 South\\n10 East\\n20000 North\\n\", \"2\\n1000 North\\n1000 South\\n\", \"4\\n50 South\\n50 No... | In this problem we assume the Earth to be a completely round ball and its surface a perfect sphere. The length of the equator and any meridian is considered to be exactly 40 000 kilometers. Thus, travelling from North Pole to South Pole or vice versa takes exactly 20 000 kilometers.
Limak, a polar bear, lives on the N... | 0.125 |
{"tests": "{\"inputs\": [[[1, 1, 1], 25], [[1, 2, 3], 25], [[3, 2, 1], 25], [[6, 7, 2], 25], [[1, 1, 1], 35], [[1, 2, 3], 35], [[3, 2, 1], 35], [[6, 7, 2], 35], [[3, 2, 1], 0], [[6, 7, 2], 2]], \"outputs\": [[1219856746], [2052198929], [2827228055], [-2575238999], [10127083068293], [17037073417493], [23471258855679], [... | Much cooler than your run-of-the-mill Fibonacci numbers, the Triple Shiftian are so defined: `T[n] = 4 * T[n-1] - 5 * T[n-2] + 3 * T[n-3]`.
You are asked to create a function which accept a base with the first 3 numbers and then returns the nth element.
```python
triple_shiftian([1,1,1],25) == 1219856746
triple_shifti... | 0 |
{"tests": "{\"inputs\": [[26], [8], [14], [80], [100], [50], [10], [101]], \"outputs\": [[\"More than a handful!\"], [\"Hardly any\"], [\"More than a handful!\"], [\"Woah that's a lot of dogs!\"], [\"Woah that's a lot of dogs!\"], [\"More than a handful!\"], [\"Hardly any\"], [\"101 DALMATIONS!!!\"]]}", "source": "taco... | Your friend has been out shopping for puppies (what a time to be alive!)... He arrives back with multiple dogs, and you simply do not know how to respond!
By repairing the function provided, you will find out exactly how you should respond, depending on the number of dogs he has.
The number of dogs will always be a n... | 0 |
{"tests": "{\"inputs\": [\"4\\n8 2 5\\n00110010\\n8 1 1\\n00110010\\n9 100000000 100000000\\n010101010\\n2 5 1\\n00\\n\", \"2\\n2 3 5\\n00\\n12 4 7\\n011101011100\\n\", \"2\\n2 3 5\\n00\\n12 4 7\\n011101011100\\n\", \"2\\n8 2 5\\n01111110\\n6 2 5\\n001010\\n\", \"2\\n2 3 8\\n00\\n12 4 7\\n011101011100\\n\", \"2\\n8 2 5... | You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string... | 0 |
{"tests": "{\"inputs\": [\"7\\n4 7\\n5 0\\n0 0\\n6 1\\n0 2\\n0 4\\n1 0\\n\", \"2\\n2 0\\n0 1\\n\", \"1\\n0 0\\n\", \"4\\n0 2\\n1 0\\n0 4\\n3 0\\n\", \"5\\n0 0\\n0 0\\n0 0\\n0 0\\n0 0\\n\", \"2\\n0 0\\n0 0\\n\", \"2\\n0 2\\n1 0\\n\", \"5\\n5 3\\n4 0\\n1 4\\n3 2\\n0 1\\n\", \"5\\n2 0\\n0 1\\n0 4\\n3 5\\n4 0\\n\", \"5\\n3... | Doubly linked list is one of the fundamental data structures. A doubly linked list is a sequence of elements, each containing information about the previous and the next elements of the list. In this problem all lists have linear structure. I.e. each element except the first has exactly one previous element, each eleme... | 0.375 |
{"tests": "{\"inputs\": [\"6\\n4 0\\n5 8\\n0 1000000\\n0 0\\n1 0\\n1000000 1000000\\n\", \"1\\n1000000 0\\n\", \"1\\n15 0\\n\", \"1\\n3 0\\n\", \"1\\n7 0\\n\", \"1\\n5 0\\n\", \"1\\n5 0\\n\", \"1\\n7 0\\n\", \"1\\n15 0\\n\", \"1\\n1000000 0\\n\", \"1\\n3 0\\n\", \"1\\n7 1\\n\", \"6\\n6 0\\n5 8\\n0 1000000\\n0 0\\n1 0\\... | We have a point $A$ with coordinate $x = n$ on $OX$-axis. We'd like to find an integer point $B$ (also on $OX$-axis), such that the absolute difference between the distance from $O$ to $B$ and the distance from $A$ to $B$ is equal to $k$. [Image] The description of the first test case.
Since sometimes it's impossible... | 0.125 |
{"tests": "{\"inputs\": [\"5\\n4 2 5 3 0\", \"5\\n14 3 0 1 -1\", \"5\\n19 3 0 2 -1\", \"5\\n8 1 1 -1 0\", \"5\\n48 -2 1 -2 -1\", \"5\\n48 0 1 -2 -2\", \"5\\n78 0 -2 -1 -3\", \"5\\n6 0 -2 0 -3\", \"5\\n-1 6 0 3 0\", \"5\\n-2 11 1 1 0\", \"5\\n-4 2 -2 -2 2\", \"5\\n2 -12 1 -1 16\", \"5\\n0 -12 2 -1 32\", \"5\\n-2 -12 7 -... | G: Working
Kou decided to do the same number of jobs every day for the next $ N $.
$ A_i $ jobs are added on the $ i $ day of the $ N $ day.
Mr. Kou has no work to do now, and he doesn't have to finish all the work by the $ N $ day.
How many jobs can you do in a day?
However, Mr. Kou is excellent, so he can do as ... | 0.125 |
{"tests": "{\"inputs\": [\"2\\n2 1\\n\", \"9\\n-2 0 -1 0 -1 2 1 0 -1\\n\", \"9\\n0 0 1 1 0 0 1 0 1\\n\", \"8\\n0 1 2 -1 -2 1 -2 2\\n\", \"24\\n-1 -1 2 2 0 -2 2 -1 0 0 2 -2 3 0 2 -3 0 -3 -1 1 0 0 -1 -2\\n\", \"1\\n0\\n\", \"31\\n-2 2 -2 -1 0 0 1 2 1 1 -1 -2 1 -1 -2 2 0 1 -1 -2 -1 -2 -1 2 2 2 2 1 1 0 1\\n\", \"9\\n1 -1 -... | Jeff's friends know full well that the boy likes to get sequences and arrays for his birthday. Thus, Jeff got sequence p_1, p_2, ..., p_{n} for his birthday.
Jeff hates inversions in sequences. An inversion in sequence a_1, a_2, ..., a_{n} is a pair of indexes i, j (1 ≤ i < j ≤ n), such that an inequality a_{i} > a_{j... | 0 |
{"tests": "{\"inputs\": [\"4 3\\n1 2\\n2 3\\n3 4\\n1 4\\n\", \"4 4\\n1 2\\n2 3\\n3 4\\n1 3\\n\", \"4 2\\n1 2\\n2 4\\n3 4\\n1 4\\n\", \"4 3\\n1 2\\n2 3\\n3 4\\n1 3\\n\", \"4 3\\n1 2\\n2 3\\n3 4\\n2 3\\n\", \"4 3\\n1 2\\n2 3\\n3 4\\n1 5\\n\", \"4 3\\n1 2\\n2 3\\n3 4\\n0 3\\n\", \"4 3\\n1 2\\n2 3\\n3 4\\n0 5\\n\", \"4 3\\... | LiLand is a country, consisting of n cities. The cities are numbered from 1 to n. The country is well known because it has a very strange transportation system. There are many one-way flights that make it possible to travel between the cities, but the flights are arranged in a way that once you leave a city you will ne... | 0 |
{"tests": "{\"inputs\": [[\"Dipper Pines\"], [\"Morty Smith\"], [\"Anna Bell\"], [\"Anna\"], [\"Bell Anna\"], [\"Jewel Bell\"], [\"Bell Jewel\"]], \"outputs\": [[\"Does not work here!\"], [\"Truck Driver\"], [\"Admin\"], [\"Does not work here!\"], [\"Does not work here!\"], [\"Receptionist\"], [\"Does not work here!\"]... | You get a new job working for Eggman Movers. Your first task is to write a method that will allow the admin staff to enter a person’s name and return what that person's role is in the company.
You will be given an array of object literals holding the current employees of the company. You code must find the employee ... | 0 |
{"tests": "{\"inputs\": [\"2\\n2 2\\n3 5\\n3 7\\n10 16 18\", \"2\\n2 2\\n3 5\\n3 7\\n8 16 18\", \"2\\n2 2\\n3 8\\n3 7\\n8 16 18\", \"2\\n2 2\\n3 8\\n3 7\\n8 16 7\", \"2\\n2 1\\n5 8\\n3 7\\n8 16 7\", \"2\\n2 2\\n5 8\\n2 7\\n7 16 7\", \"2\\n2 2\\n3 5\\n3 7\\n10 1 18\", \"2\\n2 2\\n5 8\\n3 7\\n8 11 7\", \"2\\n2 1\\n5 8\\n... | Read problems statements in Mandarin Chinese and Russian.
Grapes of Coderpur are very famous. Devu went to the market and saw that there were N people selling grapes. He didn’t like it because things were not very structured. So, he gave a task to Dhinwa to make things better. If Dhinwa successfully completes the ta... | 0.25 |
{"tests": "{\"inputs\": [\"dotdotdotdotdotdotdotdotdotdotdotdoatdotdotdotdotdotdotdotdotdotdotdotdotdotdotdotdotdotdotdotdotdot\\n\", \"zdotdotatdotz\\n\", \"hatatatdotcatqatdotwhvdotatdotsatattatatcdotddotdotvasatdottxdotatatdotatmdotvvatkatdotxatcdotdotzsx\\n\", \"dotatdotat\\n\", \"dotdotatat\\n\", \"edotdotdotsatoa... | Sometimes one has to spell email addresses over the phone. Then one usually pronounces a dot as dot, an at sign as at. As a result, we get something like vasyaatgmaildotcom. Your task is to transform it into a proper email address (vasya@gmail.com).
It is known that a proper email address contains only such symbols a... | 0 |
{"tests": "{\"inputs\": [\"19 28 3\", \"19 51 3\", \"19 51 1\", \"30 51 1\", \"30 33 1\", \"30 7 1\", \"37 7 1\", \"19 30 2\", \"32 51 1\", \"35 7 1\", \"32 86 1\", \"35 1 1\", \"7 26 3\", \"35 2 1\", \"19 2 2\", \"7 42 3\", \"35 0 1\", \"19 1 2\", \"7 64 3\", \"7 4 3\", \"27 0 6\", \"35 2 2\", \"43 1 6\", \"10 2 6\", ... | Problem statement
AOR Ika-chan is in a bad mood lately. Apparently, I don't like the ratio of the number of followers to the number of followers of "Ikatta". Currently, AOR Ika-chan has $ A $ followers, $ B $ followers, and a ratio of $ A: B $.
Therefore, AOR Ika decided to increase or decrease the number of follower... | 0 |
{"tests": "{\"inputs\": [\"3 4\\nAAAA\\nABCA\\nAAAA\\n\", \"3 4\\nAAAA\\nABCA\\nAADA\\n\", \"4 4\\nYYYR\\nBYBY\\nBBBY\\nBBBY\\n\", \"7 6\\nAAAAAB\\nABBBAB\\nABAAAB\\nABABBB\\nABAAAB\\nABBBAB\\nAAAAAB\\n\", \"2 13\\nABCDEFGHIJKLM\\nNOPQRSTUVWXYZ\\n\", \"2 2\\nAA\\nAA\\n\", \"2 2\\nAA\\nAB\\n\", \"3 3\\nAAA\\nABA\\nAAA\\... | Fox Ciel is playing a mobile puzzle game called "Two Dots". The basic levels are played on a board of size n × m cells, like this:
[Image]
Each cell contains a dot that has some color. We will use different uppercase Latin characters to express different colors.
The key of this game is to find a cycle that contain d... | 0.125 |
{"tests": "{\"inputs\": [\"841746 527518\\n595261 331297\\n10\\n-946901 129987 670374\\n-140388 -684770 309555\\n-302589 415564 -387435\\n-565799 -72069 -395358\\n-523453 -511446 854898\\n-846967 -749453 -341866\\n-622388 434663 264157\\n-638453 625357 344195\\n-255265 -676356 -772398\\n-824723 -319141 33585\\n\", \"0 ... | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 0.75 |
{"tests": "{\"inputs\": [\"997824195 298198038 671030405 831526 973640\\n694897941 219757278 695597597 220039071\\n\", \"78 15 967084213 68 15\\n6 1 9 1\\n\", \"1000000000 1000000000 1000000000 999987 999995\\n555555555 555555555 555555553 555555554\\n\", \"284251850 196700229 713578389 995979 967011\\n237351355 756339... | Mr. Chanek wants to knit a batik, a traditional cloth from Indonesia. The cloth forms a grid a with size n × m. There are k colors, and each cell in the grid can be one of the k colors.
Define a sub-rectangle as an ordered pair of two cells ((x_1, y_1), (x_2, y_2)), denoting the top-left cell and bottom-right cell (in... | 0.25 |
{"tests": "{\"inputs\": [\"999998\\n\", \"4\\n\", \"123455\\n\", \"10000\\n\", \"998756\\n\", \"1000000\\n\", \"999879\\n\", \"345612\\n\", \"6\\n\", \"999997\\n\", \"990001\\n\", \"8\\n\", \"623423\\n\", \"2\\n\", \"345634\\n\", \"777777\\n\", \"9009\\n\", \"100000\\n\", \"2009\\n\", \"976438\\n\", \"3\\n\", \"434563\... | Let's assume that we have a pair of numbers (a, b). We can get a new pair (a + b, b) or (a, a + b) from the given pair in a single step.
Let the initial pair of numbers be (1,1). Your task is to find number k, that is, the least number of steps needed to transform (1,1) into the pair where at least one number equals n... | 0 |
{"tests": "{\"inputs\": [[[2]], [[1, 2, 1, 2, 1]], [[4, 2, 3, 3, 2]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]], [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]], [[1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]], [[1, 2, 3, 4, 5, 1, 5, 4, 3, 2, 1]], [[1, 1, 1, 2, 1, 2, 10, 2, 3, 3]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20... | Little Petya often visits his grandmother in the countryside. The grandmother has a large vertical garden, which can be represented as a set of `n` rectangles of varying height. Due to the newest irrigation system we can create artificial rain above them.
Creating artificial rain is an expensive operation. That's why ... | 0 |
{"tests": "{\"inputs\": [\"3 4\\n1 3 5\\n\", \"3 40\\n10 30 50\\n\", \"20 53\\n32 64 20 41 97 50 20 66 68 22 60 74 61 97 54 80 30 72 59 18\\n\", \"100 82\\n51 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 79 16 87 87 69 3 76 80 60 100 49 70 59 72 8 38 71 45 97 71 14 76 54 8... | Vladimir wants to modernize partitions in his office. To make the office more comfortable he decided to remove a partition and plant several bamboos in a row. He thinks it would be nice if there are n bamboos in a row, and the i-th from the left is a_{i} meters high.
Vladimir has just planted n bamboos in a row, each... | 0 |
{"tests": "{\"inputs\": [\"5 6\\n3 3 3 3 3\\n\", \"3 5\\n1 2 4\\n\", \"5 5\\n2 3 1 4 4\\n\", \"1 1000\\n548\\n\", \"3 3\\n3 1 1\\n\", \"10 17\\n12 16 6 9 12 6 12 1 12 13\\n\", \"24 1\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\", \"5 2\\n2 1 2 2 2\\n\", \"21 19\\n19 13 2 16 8 15 14 15 7 8 3 17 11 6 1 18 16 6 2... | You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | 0 |
{"tests": "{\"inputs\": [\"4 2\\n\", \"2525 425\\n\", \"3000 1\\n\", \"2929 1\\n\", \"2525 1\\n\", \"1 1\\n\", \"2 1\\n\", \"2 2\\n\", \"2874 2\\n\", \"3 1\\n\", \"2952 1\\n\", \"2969 2\\n\", \"2987 3\\n\", \"2964 4\\n\", \"2919 5\\n\", \"2992 6\\n\", \"2905 7\\n\", \"2990 8\\n\", \"2963 9\\n\", \"2996 10\\n\", \"2952 ... | You are given two positive integers N and K. How many multisets of rational numbers satisfy all of the following conditions?
- The multiset has exactly N elements and the sum of them is equal to K.
- Each element of the multiset is one of 1, \frac{1}{2}, \frac{1}{4}, \frac{1}{8}, \dots. In other words, each element c... | 0 |
{"tests": "{\"inputs\": [\"4 4\\n3 5 8 14\\n\", \"6 7\\n11 45 14 9 19 81\\n\", \"1 0\\n0\\n\", \"30 35\\n11712212162 13887261936 9226451478 5810578422 4558800999 2160186631 25345435752 20420262166 16723017889 4041013095 17986671533 30276157972 27290831854 10571984774 24307466845 32173907391 15769943440 28953863917 1549... | This is the easy version of the problem. The only difference between easy and hard versions is the constraint of $m$. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom![Image]
As a doll collector, Chiori has got $n$ dolls. The $i$-th doll has a non-n... | 0.125 |
{"tests": "{\"inputs\": [\"((?))\\n\", \"??()??\\n\", \"?????)(???\\n\", \"()()((?(()(((()()(())(((()((())))(()))(()(((((())))()))(((()()()))))))(((((()))))))))\\n\", \"))((()(()((((()))())()())((())())(((()()(())))))((())()()(()()(())()))()()(()()()(((()(()(()(()))))(\\n\", \"??????????????????????????????????????????... | As Will is stuck in the Upside Down, he can still communicate with his mom, Joyce, through the Christmas lights (he can turn them on and off with his mind). He can't directly tell his mom where he is, because the monster that took him to the Upside Down will know and relocate him. [Image]
Thus, he came up with a puz... | 0.125 |
{"tests": "{\"inputs\": [\"4\\nababcd\\nabcba\\na\\nb\\ndefi\\nfed\\nxyz\\nx\\n\", \"3\\nababc\\nabcba\\nfeded\\ndefed\\nababcfeded\\nabcdebafed\\n\", \"1\\nbbbaaaaabbabaabbbbaabbbbabbaabbaababbbbbbababbababbbaaaaaaabaababbbaababbbbababbbabbbbbabaabbaaaabaa\\nbbbababbaabbbbbaabaaabaababaaaabaabbbabbababaaabba\\n\", \"3... | You are given a string $s$. You can build new string $p$ from $s$ using the following operation no more than two times: choose any subsequence $s_{i_1}, s_{i_2}, \dots, s_{i_k}$ where $1 \le i_1 < i_2 < \dots < i_k \le |s|$; erase the chosen subsequence from $s$ ($s$ can become empty); concatenate chosen subsequenc... | 0 |
{"tests": "{\"inputs\": [[[1, 2, 3], 3], [[1, 2, 3], 6], [[1, 2, 3], 7], [[1, 2, 3, 6], 6], [[1, 2, 3, 4, 5, 6], 15], [[0, 0, 2], 4], [[0, 0, 2, 2], 4], [[-3, -2, -2, -1, 0, 1, 2, 3, 4], 4], [[-3, -2, -2, -1, 0, 1, 2, 3, 4], 0], [[-3, -2, -1, 0, 1, 2, 3, 4], 4]], \"outputs\": [[[1, 3]], [[2, 3]], [null], [[1, 6]], [[3,... | This is the simple version of Fastest Code series. If you need some challenges, please try the [Performance version](http://www.codewars.com/kata/5714594d2817ff681c000783)
## Task:
Give you a number array ```numbers``` and a number ```c```.
Find out a pair of numbers(we called them number a and number b) from t... | 0 |
{"tests": "{\"inputs\": [[\"a\", \"b\"], [\"a\", \"a\"], [\"abc\", \"ac\"], [\"abcdef\", \"abc\"], [\"abcdef\", \"acf\"], [\"anothertest\", \"notatest\"], [\"132535365\", \"123456789\"], [\"finaltest\", \"zzzfinallyzzz\"]], \"outputs\": [[\"\"], [\"a\"], [\"ac\"], [\"abc\"], [\"acf\"], [\"nottest\"], [\"12356\"], [\"fi... | Write a function called `LCS` that accepts two sequences and returns the longest subsequence common to the passed in sequences.
### Subsequence
A subsequence is different from a substring. The terms of a subsequence need not be consecutive terms of the original sequence.
### Example subsequence
Subsequences of `"abc"... | 0 |
{"tests": "{\"inputs\": [\"snow affects sports such as skiing, snowboarding, and snowmachine travel.\\nsnowboarding is a recreational activity and olympic and paralympic sport.\\n\", \"'co-co-co, codeforces?!'\\n\", \"thun-thun-thunder, thunder, thunder\\nthunder, thun-, thunder\\nthun-thun-thunder, thunder\\nthunder, ... | Arcady is a copywriter. His today's task is to type up an already well-designed story using his favorite text editor.
Arcady types words, punctuation signs and spaces one after another. Each letter and each sign (including line feed) requires one keyboard click in order to be printed. Moreover, when Arcady has a non-e... | 0 |
{"tests": "{\"inputs\": [\"3 5 7 5\\n\", \"4 5 7 5\\n\", \"37 4 2 3\\n\", \"40 5 7 5\\n\", \"37 4 3 3\", \"5 4 3 3\", \"5 4 2 3\", \"0 4 2 3\", \"8 5 7 5\", \"3 3 7 5\", \"7 4 2 3\", \"37 3 3 3\", \"5 8 3 3\", \"8 4 2 3\", \"8 5 7 3\", \"7 4 1 3\", \"37 3 2 3\", \"7 8 3 3\", \"8 5 2 3\", \"8 4 7 3\", \"7 5 1 3\", \"7 3... | Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.
Iroha is looking for X,Y,Z-Haiku (defined below) in integer sequences.
Consider all integer sequences of length N whose elements are between 1 and 10, inclusive. Out of those 10^N sequences, how many co... | 0 |
{"tests": "{\"inputs\": [[\"Get me the bacon!\"], [\"Codewars is bacon\"], [\"France is also bacon\"], [\"AaAAaAAabB!B!B3b23jdc\"], [\"\"], [\"!!!@@@\"], [\"Mississippi\"], [\"Hello. Hello? HELLO!\"], [\"aaa...bb...c!\"], [\"abc123\"], [\"aaabbbccc\"]], \"outputs\": [[{\"3\": [\"e\"], \"2\": [\"t\"], \"1\": [\"a\", \"b... | Write a method that takes a string as an argument and groups the number of time each character appears in the string as a hash sorted by the highest number of occurrences.
The characters should be sorted alphabetically e.g:
```python
get_char_count("cba") == {1: ["a", "b", "c"]}
```
You should ignore spaces, special... | 0 |
{"tests": "{\"inputs\": [\"4\\n2\\n)(\\n4\\n()()\\n8\\n())()()(\\n10\\n)))((((())\\n\", \"4\\n2\\n)(\\n4\\n)()(\\n8\\n())()()(\\n10\\n)))((((())\\n\", \"4\\n2\\n)(\\n4\\n()()\\n8\\n())()()(\\n10\\n())((()())\\n\", \"4\\n2\\n)(\\n4\\n()()\\n8\\n()()())(\\n10\\n)))((((())\\n\", \"4\\n2\\n)(\\n4\\n)()(\\n8\\n())()()(\\n10... | You are given a bracket sequence $s$ of length $n$, where $n$ is even (divisible by two). The string $s$ consists of $\frac{n}{2}$ opening brackets '(' and $\frac{n}{2}$ closing brackets ')'.
In one move, you can choose exactly one bracket and move it to the beginning of the string or to the end of the string (i.e. yo... | 0.75 |
{"tests": "{\"inputs\": [\"4 2 3 1 6\\n\", \"4 2 3 1 7\\n\", \"1 2 3 2 6\\n\", \"1 1 2 1 1\\n\", \"1 0 1000 999 2000000000\\n\", \"10 1 6 4 20\\n\", \"10 3 6 5 30\\n\", \"10 3 5 1 30\\n\", \"10 32 312 72 1000\\n\", \"1 102 123 27 2321\\n\", \"2000000000 159 1000 870 2000000000\\n\", \"200000000 794 1000 117 2000000000\... | Arthur and Alexander are number busters. Today they've got a competition.
Arthur took a group of four integers a, b, w, x (0 ≤ b < w, 0 < x < w) and Alexander took integer с. Arthur and Alexander use distinct approaches to number bustings. Alexander is just a regular guy. Each second, he subtracts one from his number... | 0 |
{"tests": "{\"inputs\": [\"10\\n\", \"12\\n\", \"1\\n\", \"2\\n\", \"4\\n\", \"8\\n\", \"3\\n\", \"31\\n\", \"97\\n\", \"1000000000000\\n\", \"15\\n\", \"894\\n\", \"271\\n\", \"2457\\n\", \"2829\\n\", \"5000\\n\", \"20\\n\", \"68\\n\", \"3096\\n\", \"1024\\n\", \"1048576\\n\", \"413933789280\\n\", \"817634153013\\n\",... | Duff is in love with lovely numbers! A positive integer x is called lovely if and only if there is no such positive integer a > 1 such that a^2 is a divisor of x. [Image]
Malek has a number store! In his store, he has only divisors of positive integer n (and he has all of them). As a birthday present, Malek wants to ... | 0 |
{"tests": "{\"inputs\": [[\"abcdeXghi\", [\"\", \"\", \"CCCCC\", \"\", \"EEEEEEEEEE\", \"FFFFFF\", \"\", \"\", \"IIIIII\"]], [\"abcdefX\", []], [\"abcXdef\", []], [\"Xabcdef\", []], [\"abcdefghijklmX\", [\"\", \"\", \"\", \"BBBBBB\", \"\", \"\", \"\", \"\", \"CCCCC\"]], [\"abcdefghijkX\", [\"\", \"AAAAAAAAAA\", \"\", \... | # Story
Well, here I am stuck in another traffic jam.
*Damn all those courteous people!*
Cars are trying to enter the main road from side-streets somewhere ahead of me and people keep letting them cut in.
Each time somebody is let in the effect ripples back down the road, so pretty soon I am not moving at all.
(S... | 0 |
{"tests": "{\"inputs\": [\"4\\n3\\n1 2 3\\n4\\n3 1 2 4\\n3\\n2 3 1\\n6\\n2 4 6 1 3 5\\n\", \"4\\n3\\n1 2 3\\n4\\n3 1 2 4\\n3\\n2 3 1\\n6\\n2 4 12 1 3 5\\n\", \"4\\n3\\n1 2 3\\n4\\n3 1 2 2\\n3\\n2 1 1\\n6\\n2 4 7 1 6 10\\n\", \"4\\n3\\n1 0 4\\n4\\n3 1 2 4\\n3\\n2 3 1\\n6\\n2 4 6 1 5 1\\n\", \"4\\n3\\n1 2 3\\n4\\n3 1 2 4... | You are given an array $a$ of length $n$, which initially is a permutation of numbers from $1$ to $n$. In one operation, you can choose an index $i$ ($1 \leq i < n$) such that $a_i < a_{i + 1}$, and remove either $a_i$ or $a_{i + 1}$ from the array (after the removal, the remaining parts are concatenated).
For exampl... | 0 |
{"tests": "{\"inputs\": [\"4\\n0 -3 2 0 3 2\\n0 0 9 8 8 2\\n0 0 9 10 10 5\\n0 0 707 1000 1000 245\", \"4\\n0 -3 2 0 3 2\\n0 0 9 8 8 2\\n0 0 9 10 10 5\\n0 0 707 1000 1010 707\", \"4\\n0 -3 2 0 3 2\\n0 0 6 8 8 2\\n0 0 9 10 10 5\\n0 0 707 1000 1010 707\", \"4\\n1 -6 2 0 3 2\\n0 0 9 8 8 2\\n0 0 9 10 10 5\\n0 0 707 1000 100... | Two circles A, B are given on a two-dimensional plane. The coordinate of the center and radius of circle A is (x_A, y_A) and r_A respectively. The coordinate of the center and radius of circle B is (x_B, y_B) and r_B respectively. These two circles have no intersection inside. Here, we consider a set of circles S that ... | 0 |
{"tests": "{\"inputs\": [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [18], [19], [20], [21], [22], [23], [24], [25], [26], [28], [29], [30], [31], [32], [33], [35], [36], [37], [38], [39], [40], [41], [42], [44], [45], [46], [47], [48], [49], [50], [51], [52], [53], [55], [56]... | It's 3AM and you get the dreaded call from a customer: the program your company sold them is hanging. You eventually trace the problem down to a call to a function named `mystery`. Usually, `mystery` works fine and produces an integer result for an integer input. However, on certain inputs, the `mystery` function just ... | 0 |
{"tests": "{\"inputs\": [\"10 5\\n0\\n0\\n5\\n6\\n-3\\n8\\n1\\n8\\n-4\\n0\\n1\\n3\\n5\\n1\\n5\\n10 10\\n0\\n-1\\n-1\\n4\\n4\\n-5\\n0\\n1\\n-6\\n0\\n1\\n5\\n2\\n5\\n6\\n5\\n5\\n4\\n1\\n6\\n0 0\", \"10 5\\n0\\n0\\n5\\n6\\n-2\\n8\\n1\\n8\\n-4\\n0\\n1\\n3\\n5\\n1\\n5\\n10 10\\n0\\n-1\\n-1\\n4\\n4\\n-5\\n0\\n1\\n-6\\n0\\n2\... | Sugoroku
problem
JOI is playing sugoroku alone. There are N squares in a straight line in this sugoroku, and each has a movement instruction written on it. The starting point is the 1st square and the goal is the Nth square. JOI repeats the following until he reaches the goal.
Roll the dice and proceed from the curr... | 0.625 |
{"tests": "{\"inputs\": [\"5\\n2 2\\n2 2\\n2 0\\n2 2\\n2 2\", \"3\\n1 3\\n2 5\\n2 9\", \"22\\n93 6440\\n78 6647\\n1028 11\\n8306 9689\\n798 99\\n801 521\\n188 206\\n6079 971\\n4559 209\\n50 94\\n92 6270\\n5403 560\\n803 83\\n1855 99\\n42 504\\n75 484\\n629 11\\n92 122\\n3359 37\\n28 16\\n648 14\\n11 269\", \"3\\n2 3\\n... | Snuke loves flags.
Snuke is placing N flags on a line.
The i-th flag can be placed at either coordinate x_i or coordinate y_i.
Snuke thinks that the flags look nicer when the smallest distance between two of them, d, is larger. Find the maximum possible value of d.
Constraints
* 2 ≤ N ≤ 10^{4}
* 1 ≤ x_i, y_i ≤ 10^... | 0 |
{"tests": "{\"inputs\": [\"7 74\\n4777774\\n\", \"3 99\\n447\\n\", \"47 7\\n77774477747474477477477774747747447447774777474\\n\", \"74 1000000000\\n77474447774774747474777447474777777477474444477747444777447444474744744444\\n\", \"10 200\\n6860544593\\n\", \"100 1000000000\\n58493474544786447747474794371704932496344748... | Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya has a number consisting of n digits without leading zeroes. He represented it as an array of d... | 0.375 |
{"tests": "{\"inputs\": [\"(((#)((#)\\n\", \"()((#((#(#()\\n\", \"#\\n\", \"(#)\\n\", \"(((((#(#(#(#()\\n\", \"#))))\\n\", \"((#(()#(##\\n\", \"##((((((()\\n\", \"(((((((((((((((((((###################\\n\", \"((#)(\\n\", \"((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((##\\n\", \")((##((###\\n\", \"(#))... | Malek has recently found a treasure map. While he was looking for a treasure he found a locked door. There was a string s written on the door consisting of characters '(', ')' and '#'. Below there was a manual on how to open the door. After spending a long time Malek managed to decode the manual and found out that the ... | 0.125 |
{"tests": "{\"inputs\": [\"3\\n1 0\\n1 1\\n2 1\", \"3\\n1 0\\n2 1\\n2 1\", \"3\\n1 0\\n2 1\\n1 0\", \"3\\n1 0\\n2 1\\n2 0\", \"3\\n1 2\\n1 1\\n2 1\", \"3\\n2 0\\n1 1\\n2 1\", \"3\\n1 0\\n2 1\\n2 2\", \"3\\n1 1\\n2 1\\n1 1\", \"3\\n1 0\\n0 1\\n2 0\", \"3\\n2 0\\n1 1\\n3 1\", \"3\\n2 1\\n2 1\\n1 1\", \"3\\n0 2\\n1 1\\n0 ... | Snuke is having another barbeque party.
This time, he will make one serving of Skewer Meal.
He has a stock of N Skewer Meal Packs. The i-th Skewer Meal Pack contains one skewer, A_i pieces of beef and B_i pieces of green pepper. All skewers in these packs are different and distinguishable, while all pieces of beef an... | 0.5 |
{"tests": "{\"inputs\": [\"5\\nAABBB\\n\", \"3\\nAAA\\n\", \"7\\nAAABABB\\n\", \"3\\nABA\\n\", \"7\\nBBABAAA\\n\", \"7\\nBAAAABB\\n\", \"5\\nBBBBA\\n\", \"7\\nABABAAB\\n\", \"7\\nBBAAABA\\n\", \"3\\nBBB\\n\", \"5\\nABBAA\\n\", \"5\\nABBBA\\n\", \"7\\nBAAAAAB\\n\", \"7\\nAAAAAAA\\n\", \"3\\nBAA\\n\", \"3\\nAAB\\n\", \"7... | The string $t_1t_2 \dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.
A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.
Here are some e... | 0 |
{"tests": "{\"inputs\": [\"6\\nbababa\\n2\\nba\\naba\\ncaba\\n2\\nbac\\nacab\\nabacabaca\\n3\\naba\\nbac\\naca\\nbaca\\n3\\na\\nc\\nb\\ncodeforces\\n4\\ndef\\ncode\\nefo\\nforces\\naaaabbbbcccceeee\\n4\\neeee\\ncccc\\naaaa\\nbbbb\\n\", \"1\\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... | You are given some text $t$ and a set of $n$ strings $s_1, s_2, \dots, s_n$.
In one step, you can choose any occurrence of any string $s_i$ in the text $t$ and color the corresponding characters of the text in red. For example, if $t={bababa}$ and $s_1={ba}$, $s_2={aba}$, you can get $t={{ba}}{baba}$, $t={b}{{aba}}{ba... | 0 |
{"tests": "{\"inputs\": [[\"2 \", \"TTTT\", \"1\", \"TTSTTTS\", \"3\", \"\", \"\"], \"2 \\nTTTT\\n0\\nTTSTTTS\\n3\", \"2 \\nTTTT\\n0\\nTTSTTTS\\n1\", \"2 \\nTTTT\\n0\\nTTSSTTS\\n1\", \"2 \\nTTTT\\n1\\nTTSSTTS\\n-3\", \"2 \\nTTST\\n1\\nTTSSTTR\\n-3\", \"2 \\nTTST\\n2\\nTTSSTTR\\n-3\", \"2 \\nTTST\\n4\\nTTSSTTR\\n-3\", \... | Recently, Chef got obsessed with piano. He is a just a rookie in this stuff and can not move his fingers from one key to other fast enough. He discovered that the best way to train finger speed is to play scales.
There are different kinds of scales which are divided on the basis of their interval patterns. For instanc... | 0.125 |
{"tests": "{\"inputs\": [\"3\\n1 1 1\\n3 3\\n4\\n3 1 3 3\\n1 1 1\\n5\\n1 2 3 4 5\\n4 3 2 1\\n0\", \"3\\n1 1 1\\n3 3\\n4\\n3 1 3 3\\n1 1 1\\n5\\n1 2 3 4 5\\n3 3 2 1\\n0\", \"3\\n0 1 1\\n3 3\\n4\\n3 1 3 3\\n1 1 1\\n5\\n1 2 3 4 5\\n3 3 2 1\\n0\", \"3\\n0 1 1\\n3 3\\n4\\n3 1 5 3\\n1 1 1\\n5\\n1 2 3 4 5\\n3 3 2 1\\n0\", \"3... | I am a pipe tie craftsman. As long as you get the joints and pipes that connect the pipes, you can connect any pipe. Every day, my master gives me pipes and joints, which I connect and give to my master. But if you have too many pipes, you can't connect them all in one day. Even in such a case, the master smiles and gi... | 0.5 |
{"tests": "{\"inputs\": [[[[2, 3], [1, 4]], [[3, 3], [4, 1]]], [[], []], [[[1, 1]], [[1, 1]]], [[[2, 1]], [[2, 1]]], [[[1, 2]], [[1, 2]]], [[[2, 3]], [[3, 2]]], [[[2, 7]], [[3, 5]]], [[[2, 5]], [[6, 6]]], [[[6, 6]], [[2, 5]]], [[], [[1, 1], [2, 2]]], [[[1, 1], [2, 2]], []], [[[1, 3], [3, 5], [4, 6], [5, 2]], [[2, 4], [... | Magic The Gathering is a collectible card game that features wizards battling against each other with spells and creature summons. The game itself can be quite complicated to learn. In this series of katas, we'll be solving some of the situations that arise during gameplay. You won't need any prior knowledge of the gam... | 0 |
{"tests": "{\"inputs\": [\"100 37\\n20 20 3 35 36 14 30 9 33 36 32 46 43 22 43 50 34 6 13 25 1 34 10 6 21 30 19 17 1 23 9 23 38 21 7 43 49 28 33 42 4 19 39 23 12 42 31 13 26 23 1 26 24 48 10 6 12 48 40 18 10 26 9 5 22 45 46 23 46 34 34 45 3 7 16 39 14 29 48 1 12 37 4 20 29 26 35 38 20 47 39 29 12 35 4 32 26 1 50 33\\n\... | A median in an array with the length of n is an element which occupies position number <image> after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2, 6, 1, 2, 3) is the number 2, and a median of array (0, 96, 17, 23) — the number 17.
We define... | 0 |
{"tests": "{\"inputs\": [[1], [2], [3], [4], [5], [6], [10], [10000000]], \"outputs\": [[4], [10], [20], [35], [56], [83], [244], [489999753]]}", "source": "taco"} | Many years ago, Roman numbers were defined by only `4` digits: `I, V, X, L`, which represented `1, 5, 10, 50`. These were the only digits used. The value of a sequence was simply the sum of digits in it. For instance:
```
IV = VI = 6
IX = XI = 11
XXL = LXX = XLX = 70
```
It is easy to see that this system is ambiguous,... | 0 |
{"tests": "{\"inputs\": [[\"IMG <index_no>\", 4, 1], [\"image #<index_no>.jpg\", 3, 7], [\"#<index_no> #<index_no>\", 3, -2], [\"<file> number <index_no>\", 5, 0], [\"<file_no> number <index_no>\", 2, -1], [\"file\", 2, 3], [\"<file_no> number <index_no>\", -1, 0], [\"file <index_no>\", 2, 0.1], [\"file <index_no>\", 0... | Naming multiple files can be a pain sometimes.
#### Task:
Your job here is to create a function that will take three parameters, `fmt`, `nbr` and `start`, and create an array of `nbr` elements formatted according to `frm` with the starting index `start`. `fmt` will have `` inserted at various locations; this is where... | 0 |
{"tests": "{\"inputs\": [\"3\\n10 40\\n15 40\\n20 30\", \"4\\n1 2\\n3 3\\n3 4\\n4 1\", \"3\\n10 40\\n15 40\\n40 30\", \"4\\n1 2\\n3 3\\n3 7\\n4 1\", \"4\\n2 2\\n3 3\\n3 7\\n4 1\", \"3\\n10 40\\n15 40\\n20 32\", \"4\\n2 4\\n3 3\\n3 7\\n4 1\", \"3\\n10 36\\n15 40\\n20 32\", \"3\\n10 42\\n6 40\\n20 32\", \"4\\n1 4\\n1 3\\... | Training is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well.
Today's training is to gain dexterity that never mistypes by carefully stacking blocks. Since there are many building blocks, let's build a tall tower.
There are N blocks, and the i-th (... | 0 |
{"tests": "{\"inputs\": [\"4\\n2 4\\n1 3\\n3 12\\n3 4 5\\n1 5\\n5\\n2 10\\n15 4\\n\", \"1\\n10 999999733\\n25 68 91 55 36 29 96 4 63 3\\n\", \"1\\n19 1000000000\\n15 8 22 12 10 16 2 17 14 7 20 23 9 18 3 19 21 11 1\\n\", \"1\\n1 11\\n5\\n\", \"1\\n1 5\\n2\\n\", \"1\\n2 9\\n2 4\\n\", \"1\\n10 999999733\\n25 68 91 55 36 2... | Bessie has way too many friends because she is everyone's favorite cow! Her new friend Rabbit is trying to hop over so they can play!
More specifically, he wants to get from $(0,0)$ to $(x,0)$ by making multiple hops. He is only willing to hop from one point to another point on the 2D plane if the Euclidean distance ... | 0 |
{"tests": "{\"inputs\": [\"23.72975180461117\\n158.1\\n-1.0\", \"23.5\\n158.1\\n-0.5246083014985048\", \"23.72975180461117\\n158.1\\n-0.5449258499657357\", \"24.206542817215936\\n158.1\\n-1.0\", \"24.615346202775605\\n158.1\\n-1.0\", \"23.72975180461117\\n158.6852941341954\\n-0.5449258499657357\", \"25.190547978615548\... | "What are your shoe sizes?"
Suddenly, the doctor asked me when I met him for the first time.
"It's 23.5"
"Oh, that's a really nice number. It's 2 to the 4th power plus 2 to the 2nd power, 2 to the 1st power, 2 to the 0th power, and 2 to the 1st power."
Then the doctor asked.
"You, how tall are you?"
"Yes, it's 158.... | 0.875 |
{"tests": "{\"inputs\": [\"2\\n1 1\\n\", \"2\\n1 2\\n\", \"5\\n0 0 0 0 35\\n\", \"5\\n8 4 2 0 1\\n\", \"5\\n24348 15401 19543 206086 34622\\n\", \"10\\n7758 19921 15137 1138 90104 17467 82544 55151 3999 6781\\n\", \"2\\n0 1\\n\", \"2\\n184931 115069\\n\", \"100\\n9 0 2 8 3 6 55 1 11 12 3 8 32 18 38 16 0 27 6 3 3 4 25 2... | Slime and his $n$ friends are at a party. Slime has designed a game for his friends to play.
At the beginning of the game, the $i$-th player has $a_i$ biscuits. At each second, Slime will choose a biscuit randomly uniformly among all $a_1 + a_2 + \ldots + a_n$ biscuits, and the owner of this biscuit will give it to a ... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 1 4 1 5\", \"3\\n1 1 1\", \"3\\n1 1 2\", \"3\\n1 2 2\", \"3\\n2 1 2\", \"3\\n2 1 1\", \"3\\n2 2 4\", \"3\\n2 4 4\", \"3\\n2 2 1\", \"5\\n1 1 1 1 1\", \"5\\n1 1 1 1 2\", \"3\\n1 4 3\", \"4\\n0 2 3 2\", \"5\\n1 1 2 1 5\", \"3\\n0 4 3\", \"4\\n0 0 3 2\", \"5\\n1 1 2 0 5\", \"3\\n1 5 3\", \... | Given are an integer K and integers a_1,\dots, a_K. Determine whether a sequence P satisfying below exists. If it exists, find the lexicographically smallest such sequence.
* Every term in P is an integer between 1 and K (inclusive).
* For each i=1,\dots, K, P contains a_i occurrences of i.
* For each term in P, there... | 0 |
{"tests": "{\"inputs\": [[[2, 10], [2, 15]], [[1, 10], [3, 10]], [[2, 10], [2, 10]], [[3, 9], [1, 6]], [[1, 7], [1, 8]], [[2, 100], [2, 150]], [[2, 100], [3, 100]], [[2, 100], [2, 100]], [[34, 98], [51, 67]], [[1024, 97], [1024, 81]]], \"outputs\": [[1], [1], [0], [-1], [0], [1], [1], [0], [-1], [-1]]}", "source": "tac... | You certainly can tell which is the larger number between 2^(10) and 2^(15).
But what about, say, 2^(10) and 3^(10)? You know this one too.
Things tend to get a bit more complicated with **both** different bases and exponents: which is larger between 3^(9) and 5^(6)?
Well, by now you have surely guessed that you hav... | 0 |
{"tests": "{\"inputs\": [\"0 0 2 -1\\n3\\n-1 0\\n0 0\\n3 0\", \"0 0 4 0\\n2\\n-1 1\\n-1 -1\", \"0 1 2 0\\n3\\n-1 0\\n0 0\\n3 0\", \"0 0 2 -1\\n3\\n-1 0\\n0 1\\n3 0\", \"0 0 2 -1\\n1\\n-2 0\\n0 1\\n3 1\", \"1 2 0 -2\\n2\\n0 -1\\n0 0\\n1 2\", \"1 2 -1 -2\\n2\\n-1 0\\n0 0\\n0 2\", \"0 2 -1 -2\\n2\\n-1 1\\n0 0\\n1 0\", \"-... | <image>
For given three points p0, p1, p2, print
COUNTER_CLOCKWISE
if p0, p1, p2 make a counterclockwise turn (1),
CLOCKWISE
if p0, p1, p2 make a clockwise turn (2),
ONLINE_BACK
if p2 is on a line p2, p0, p1 in this order (3),
ONLINE_FRONT
if p2 is on a line p0, p1, p2 in this order (4),
ON_SEGMENT
... | 0.625 |
{"tests": "{\"inputs\": [\"rbgrg\\nrbbgbbr\\nbgr\\nrgbbrgbr\\nbggrgbgrr\\ngbrggrbggr\\nrrrrr\\nbgbr\\n0\", \"rbgrg\\ngbbrbbr\\ngbr\\nrgbbrgbr\\nrrgbgrggb\\ngbrggrbggr\\nrrrrr\\nbgbr\\n0\", \"rbgrg\\nrbbgbbr\\nbgr\\nbgbrrgbr\\nbggrgbgrr\\ngbrggrbggr\\nrrrrr\\nbgbr\\n0\", \"rbgrg\\nrgbrbbb\\nrbg\\nrgbbrgbr\\nrrgbgrggb\\n... | Dr. A of the Aizu Institute of Biological Research discovered a mysterious insect on a certain southern island. The shape is elongated like a hornworm, but since one segment is shaped like a ball, it looks like a beaded ball connected by a thread. What was strange was that there were many variations in body color, and ... | 0.875 |
{"tests": "{\"inputs\": [\"5 10\\n1 3 3 2 3\", \"6 1000000000000\\n1 2 2 2 3 3\", \"6 1000000000000\\n1 2 2 4 3 3\", \"11 97\\n3 2 4 1 5 9 2 6 5 3 5\", \"6 1000000000000\\n1 1 2 4 3 3\", \"11 97\\n0 2 4 1 5 9 2 6 2 3 5\", \"11 97\\n0 2 4 2 5 4 2 6 2 3 5\", \"11 97\\n0 2 0 2 5 4 2 6 2 3 5\", \"11 97\\n0 0 0 2 5 4 2 6 2 ... | We have a sequence of N \times K integers: X=(X_0,X_1,\cdots,X_{N \times K-1}). Its elements are represented by another sequence of N integers: A=(A_0,A_1,\cdots,A_{N-1}). For each pair i, j (0 \leq i \leq K-1,\ 0 \leq j \leq N-1), X_{i \times N + j}=A_j holds.
Snuke has an integer sequence s, which is initially empty... | 0 |
{"tests": "{\"inputs\": [\"3 5\\n4 2 1\\n2 3 1\\n\", \"3 8\\n4 2 1\\n2 3 1\\n\", \"11 14\\n3 1 4 1 5 9 2 6 5 3 5\\n8 9 7 9 3 2 3 8 4 6 2\\n\", \"3 1\\n4 2 1\\n2 3 1\", \"3 6\\n4 2 1\\n2 3 1\", \"11 14\\n3 1 4 1 5 9 2 6 5 3 5\\n8 9 7 9 3 1 3 8 4 6 2\", \"3 1\\n8 2 1\\n2 3 1\", \"11 14\\n3 1 4 1 2 9 2 6 5 3 5\\n8 9 7 26 ... | Takahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The consumption coefficient of Member i is A_i.
In the contest, N foods numbered 1 through N will be presented, and the difficulty of F... | 0 |
{"tests": "{\"inputs\": [\"2\\n6 3\\n7 3\\n\", \"1\\n69 68\\n\", \"2\\n69 68\\n11 9\\n\", \"2\\n69 68\\n11 9\\n\", \"1\\n69 68\\n\", \"2\\n69 120\\n11 9\\n\", \"1\\n69 37\\n\", \"2\\n6 3\\n7 5\\n\", \"2\\n6 3\\n7 1\\n\", \"1\\n3 1\\n\", \"1\\n70 37\\n\", \"2\\n2 3\\n7 5\\n\", \"1\\n13 37\\n\", \"1\\n13 44\\n\", \"1\\n1... | You are given two integers $n$ and $m$ ($m < n$). Consider a convex regular polygon of $n$ vertices. Recall that a regular polygon is a polygon that is equiangular (all angles are equal in measure) and equilateral (all sides have the same length). [Image] Examples of convex regular polygons
Your task is to say if it ... | 0.75 |
{"tests": "{\"inputs\": [\"4\\n2 1 4 3\\n\", \"3\\n2 3 1\\n\", \"3\\n1 3 2\\n\", \"3\\n3 1 2\\n\", \"3\\n1 2 3\\n\", \"3\\n3 2 1\\n\", \"4\\n2 3 4 1\\n\", \"5\\n1 2 3 4 5\\n\", \"3\\n2 1 3\\n\"], \"outputs\": [\"4\\n1 3\\n1 4\\n3 2\\n3 1\\n\", \"4\\n1 2\\n2 3\\n1 3\\n1 2\\n\", \"3\\n2 1\\n1 3\\n1 2\\n\", \"4\\n1 3\\n3 ... | There are n coins labeled from 1 to n. Initially, coin c_i is on position i and is facing upwards ((c_1, c_2, ..., c_n) is a permutation of numbers from 1 to n). You can do some operations on these coins.
In one operation, you can do the following:
* Choose 2 distinct indices i and j.
* Then, swap the coins on ... | 0 |
{"tests": "{\"inputs\": [[\"1 2\", \"1\", \"1\", \"2\"], [\"2 4\", \"1 3\", \"1\", \"2\", \"3\", \"4\"], \"2 4\\n1 3\\n1\\n4\\n3\\n4\", \"2 4\\n1 3\\n1\\n2\\n3\\n3\", \"1 2\\n1 3\\n1\\n4\\n3\\n4\", \"2 4\\n1 3\\n1\\n2\\n3\\n5\", \"2 4\\n1 3\\n1\\n2\\n5\\n4\", \"1 2\\n2 3\\n1\\n4\\n3\\n4\", \"2 4\\n1 3\\n1\\n0\\n3\\n2\"... | Devu has an array A consisting of N positive integers. He would like to perform following operation on array.
- Pick some two elements a, b in the array (a could be same as b, but their corresponding indices in the array should not be same).
Remove both the elements a and b and instead add a number x such that x lies ... | 0.5 |
{"tests": "{\"inputs\": [\"5\\n-3 -4 -2 -3 3\\n\", \"5\\n2 -3 -1 -4 3\\n\", \"6\\n94 65 -33 -43 60 -24\\n\", \"3\\n-10000 10000 -10000\\n\", \"2\\n0 0\\n\", \"7\\n-1 -2 -4 -10 6 6 5\\n\", \"10\\n-10 3 -16 -15 14 -16 13 -6 -8 18\\n\", \"50\\n-67 -84 -89 80 40 42 -38 30 74 -12 -66 27 1 11 -45 -44 2 -70 -59 -70 -59 -59 62... | The Physical education teacher at SESC is a sort of mathematician too. His most favorite topic in mathematics is progressions. That is why the teacher wants the students lined up in non-decreasing height form an arithmetic progression.
To achieve the goal, the gym teacher ordered a lot of magical buns from the dining ... | 0 |
{"tests": "{\"inputs\": [[\"06:35\"], [\"11:59\"], [\"12:02\"], [\"04:00\"], [\"06:00\"], [\"12:00\"]], \"outputs\": [[\"05:25\"], [\"12:01\"], [\"11:58\"], [\"08:00\"], [\"06:00\"], [\"12:00\"]]}", "source": "taco"} | Peter can see a clock in the mirror from the place he sits in the office.
When he saw the clock shows 12:22
1
2
3
4
5
6
7
8
9
10
11
12
He knows that the time is 11:38
1
2
3
4
5
6
7
8
9
10
11
12
in the same manner:
05:25 --> 06:35
01:50 --> 10:10
11:58 --> 12:02
12:01 --> 11:59
Please complete the fun... | 0 |
{"tests": "{\"inputs\": [\"7 2\\n1 5 6 2\\n1 3\\n3 2\\n4 5\\n3 7\\n4 3\\n4 6\\n\", \"9 3\\n3 2 1 6 5 9\\n8 9\\n3 2\\n2 7\\n3 4\\n7 6\\n4 5\\n2 1\\n2 8\\n\", \"41 3\\n11 10 15 35 34 6\\n28 2\\n25 3\\n9 4\\n11 5\\n7 6\\n24 7\\n19 8\\n1 9\\n34 10\\n23 11\\n17 12\\n32 13\\n32 14\\n32 15\\n33 16\\n8 17\\n19 18\\n40 19\\n15 ... | Treeland is a country in which there are n towns connected by n - 1 two-way road such that it's possible to get from any town to any other town.
In Treeland there are 2k universities which are located in different towns.
Recently, the president signed the decree to connect universities by high-speed network.The Min... | 0.125 |
{"tests": "{\"inputs\": [\"3\\n4\\n1 2 1 2\\n3\\n2 4 2\\n5\\n1 2 3 4 5\\n\", \"1\\n30\\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\\n\", \"1\\n13\\n1 2 3 4 5 6 7 8 9 10 11 12 13\\n\", \"2\\n3\\n1 2 1\\n4\\n1 1 1 1\\n\", \"1\\n4\\n1 2 3 34\\n\", \"1\\n43\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1... | Monocarp is playing a computer game. He's going to kill $n$ monsters, the $i$-th of them has $h_i$ health.
Monocarp's character has two spells, either of which he can cast an arbitrary number of times (possibly, zero) and in an arbitrary order:
choose exactly two alive monsters and decrease their health by $1$;
choo... | 0.125 |
{"tests": "{\"inputs\": [\"100\\n-93 -100 -99 -100 -99 -100 -99 -99 -99 -100 -99 -99 -100 -98 -98 -100 -99 -100 -95 -100 -100 -99 -98 -100 -96 -99 -99 -100 -97 -98 -100 -98 -98 -93 -100 -100 -99 -100 -100 -98 -100 -98 -100 -98 -97 -99 -98 -99 -99 -99 -100 -100 -100 -100 -98 -93 -100 -100 -97 -100 -100 -100 -98 -99 -100... | Vasya has gotten interested in programming contests in TCMCF+++ rules. On the contest n problems were suggested and every problem had a cost — a certain integral number of points (perhaps, negative or even equal to zero). According to TCMCF+++ rules, only accepted problems can earn points and the overall number of poin... | 0 |
{"tests": "{\"inputs\": [\"15 5\\n0 3 7 14 15\\n11 11\\n\", \"13 4\\n0 3 7 13\\n9 9\\n\", \"4 5\\n0 3 1 2 4\\n1 1\\n\", \"4 5\\n0 3 1 2 4\\n2 1\\n\", \"15 5\\n15 3 7 0 14\\n11 11\\n\", \"15 5\\n15 14 7 3 0\\n11 11\\n\", \"4 3\\n0 4 2\\n2 2\\n\", \"100 5\\n3 100 7 13 0\\n99 5\\n\", \"30 8\\n0 1 9 10 23 24 26 30\\n40 7\\... | If the girl doesn't go to Denis, then Denis will go to the girl. Using this rule, the young man left home, bought flowers and went to Nastya.
On the way from Denis's house to the girl's house is a road of $n$ lines. This road can't be always crossed in one green light. Foreseeing this, the good mayor decided to place... | 0 |
{"tests": "{\"inputs\": [[[[0, 2], [5, 1]]], [[[4, 5, 3, 21, 3, 8], [2, 2, 6, 5, 10, 9], [7, 5, 6, 8, 2, 6], [1, 4, 7, 8, 9, 0], [1, 3, 6, 5, 5, 1], [2, 7, 3, 4, 4, 3]]], [[[4, 5, 3, -4, 3, 8], [2, 0, 6, 5, 4, 9], [7, 5, 6, 8, 2, 6], [1, 4, 7, 8, 9, 11], [1, 3, 10, 5, 5, 1], [12, 7, 3, 4, 4, 3]]], [[[1, 2], [3, 4]]], [... | # Task
You're given a two-dimensional array of integers `matrix`. Your task is to determine the smallest non-negative integer that is not present in this array.
# Input/Output
- `[input]` 2D integer array `matrix`
A non-empty rectangular matrix.
`1 ≤ matrix.length ≤ 10`
`1 ≤ matrix[0].length ≤ 10`
- `[o... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 4\\n4 6\\n11 8\", \"2\\n1 2\\n2 2\", \"4\\n1 1\\n1 4\\n2 1\\n2 2\", \"3\\n1 4\\n4 6\\n11 3\", \"3\\n0 4\\n4 6\\n11 3\", \"3\\n-1 4\\n4 6\\n11 3\", \"3\\n-2 4\\n4 6\\n11 3\", \"3\\n-2 4\\n5 6\\n11 3\", \"3\\n-2 4\\n5 6\\n11 4\", \"3\\n-1 4\\n5 6\\n11 4\", \"3\\n-1 4\\n5 10\\n11 4\", \"3\... | There are N balls in a two-dimensional plane. The i-th ball is at coordinates (x_i, y_i).
We will collect all of these balls, by choosing two integers p and q such that p \neq 0 or q \neq 0 and then repeating the following operation:
* Choose a ball remaining in the plane and collect it. Let (a, b) be the coordinates... | 0.125 |
{"tests": "{\"inputs\": [\"3\\n5\\n6\\n1\", \"6\\n6\\n1\\n4\\n1\\n5\\n9\", \"5\\n6\\n8\\n1\\n1\\n3\", \"3\\n5\\n3\\n1\", \"6\\n6\\n1\\n4\\n1\\n1\\n9\", \"5\\n6\\n4\\n1\\n1\\n3\", \"3\\n0\\n3\\n1\", \"6\\n6\\n1\\n7\\n1\\n1\\n9\", \"5\\n6\\n4\\n1\\n2\\n3\", \"3\\n0\\n0\\n1\", \"6\\n6\\n1\\n7\\n0\\n1\\n9\", \"5\\n6\\n4\\n... | You are given N integers; the i-th of them is A_i. Find the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like.
Constraints
* 2 \leq N \leq 10^5
* 1 \leq A_i \leq 10^9
* All values in input are integers.
Input
Input is given f... | 0 |
{"tests": "{\"inputs\": [\"10 10\\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1\\n6 7\\n8 3\\n6 4\\n4 2\\n9 2\\n5 10\\n9 8\\n10 7\\n5 1\\n6 2\\n\", \"3 2\\n1 0 1\\n1 2\\n2 3\\n\", \"4 5\\n0 0 0 -1\\n1 2\\n3 3\\n3 4\\n1 4\\n2 4\\n\", \"1 -1\\n1\\n\", \"3 2\\n0 -1 1\\n1 2\\n2 3\\n1 3\\n\", \"4 5\\n0 1 0 -1\\n2 2\\n3 3\\n3 4\\n1 4\\n2 4... | Leha plays a computer game, where is on each level is given a connected graph with n vertices and m edges. Graph can contain multiple edges, but can not contain self loops. Each vertex has an integer di, which can be equal to 0, 1 or - 1. To pass the level, he needs to find a «good» subset of edges of the graph or say... | 0 |
{"tests": "{\"inputs\": [[1, [1, 1, 1, 1, 1]], [2, [1, 1, 1, 1, 1]], [1, [1, 2, 1, 2, 1]], [2, [1, 2, 1, 2, 1]], [9, [1, 2, 3, 4, 5, 6, 7, 8, 9, 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, ... | From Wikipedia : "The n-back task is a continuous performance task that is commonly used as an assessment in cognitive neuroscience to measure a part of working memory and working memory capacity. [...] The subject is presented with a sequence of stimuli, and the task consists of indicating when the current stimulus ma... | 0 |
{"tests": "{\"inputs\": [\"5\\n2 1\\n5 2\\n10 3\\n25 4\\n15441 33\\n\", \"5\\n2 1\\n5 2\\n10 3\\n25 4\\n25479 33\\n\", \"5\\n2 1\\n9 1\\n10 3\\n25 4\\n25479 33\\n\", \"5\\n1 1\\n9 1\\n10 3\\n46 4\\n25479 33\\n\", \"5\\n2 1\\n5 1\\n10 3\\n25 3\\n25479 33\\n\", \"5\\n2 1\\n9 1\\n10 3\\n25 4\\n25479 57\\n\", \"5\\n2 1\\n9... | Utkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first.
Consider the 2D plane. There is a token which is initially at $(0,0)$. In one move a player must increase either the $x$ coordinate or the $y$ coordinate of the token by exactly $k$. In doing... | 0 |
{"tests": "{\"inputs\": [\"2\\n1 2\\n\", \"10\\n1 2 1 3 2 4 2 5 8 1\\n\", \"10\\n1 2 2 3 2 4 2 5 8 1\", \"10\\n1 3 2 3 2 4 2 5 8 1\", \"10\\n1 3 2 3 2 4 4 5 8 1\", \"2\\n1 0\", \"10\\n1 2 1 3 2 4 1 5 8 1\", \"10\\n1 2 1 3 2 4 2 5 8 0\", \"10\\n1 3 2 4 2 4 2 5 8 1\", \"10\\n1 3 2 6 2 4 4 5 8 1\", \"2\\n1 1\", \"10\\n1 2... | Snuke loves constructing integer sequences.
There are N piles of stones, numbered 1 through N.
The pile numbered i consists of a_i stones.
Snuke will construct an integer sequence s of length Σa_i, as follows:
- Among the piles with the largest number of stones remaining, let x be the index of the pile with the smalle... | 0 |
{"tests": "{\"inputs\": [\"3\\n2\\n1 2\\n10\\n2\\n1 1\\n10\\n6\\n2 3 4 9 6 7\\n111000\", \"3\\n2\\n0 2\\n10\\n2\\n1 1\\n10\\n6\\n2 3 4 9 6 7\\n111000\", \"3\\n2\\n1 2\\n10\\n2\\n1 2\\n10\\n6\\n2 3 1 9 6 7\\n111000\", \"3\\n2\\n1 2\\n14\\n0\\n2 0\\n10\\n6\\n2 3 5 9 7 7\\n111000\", \"3\\n2\\n0 2\\n10\\n2\\n1 2\\n10\\n6\\... | There are two persons, numbered 0 and 1, and a variable x whose initial value is 0. The two persons now play a game. The game is played in N rounds. The following should be done in the i-th round (1 \leq i \leq N):
* Person S_i does one of the following:
* Replace x with x \oplus A_i, where \oplus represents bitwise X... | 0 |
{"tests": "{\"inputs\": [\"2\\n3\\n1 2 3\\n5\\n2 3 1 5 4\", \"2\\n2\\n1 2 3\\n5\\n2 3 1 5 4\", \"2\\n3\\n1 2 3\\n5\\n4 3 1 5 2\", \"2\\n3\\n2 1 3\\n5\\n4 3 1 5 2\", \"2\\n2\\n1 2 3\\n5\\n4 3 1 5 2\", \"2\\n1\\n1 2 3\\n5\\n2 3 1 5 4\", \"2\\n1\\n1 2 3\\n5\\n4 3 1 5 2\", \"2\\n2\\n2 1 3\\n5\\n4 3 1 5 2\", \"2\\n2\\n1 2 3... | Read problems statements in Mandarin Chinese and Russian.
All bandits are afraid of Sheriff. Sheriff constantly fights crime, but when bandits lay low, he gets bored and starts to entertain himself.
This time Sheriff gathered all the bandits in his garden and ordered them to line up. After the whistle all bandits sh... | 0.625 |
{"tests": "{\"inputs\": [\"6\\nLRU\\nDURLDRUDRULRDURDDL\\nLRUDDLRUDRUL\\nLLLLRRRR\\nURDUR\\nLLL\\n\", \"6\\nLRU\\nDURLDRUDRULRDURDDL\\nLRUDDLRUDRUL\\nLLLLRRRR\\nURDUR\\nLLL\\n\", \"6\\nLRU\\nDURLDRUDRULRDURDDL\\nLURDURLDDURL\\nLLLLRRRR\\nURDUR\\nLLL\\n\", \"6\\nLRU\\nLDDRUDRLURDURDLRUD\\nLURDURLDDURL\\nLLLLRRRR\\nURDUR... | Recently you have bought a snow walking robot and brought it home. Suppose your home is a cell $(0, 0)$ on an infinite grid.
You also have the sequence of instructions of this robot. It is written as the string $s$ consisting of characters 'L', 'R', 'U' and 'D'. If the robot is in the cell $(x, y)$ right now, he can m... | 0 |
{"tests": "{\"inputs\": [\"1\\n3\\n1 137438953474 274877906947\\n\", \"5\\n1\\n13\\n1\\n1\\n6\\n7 19 28 25 4 10\\n3\\n3 19 10\\n9\\n26 1 28 8 24 27 12 16 17\\n\", \"1\\n69\\n2 4 10 16 22 28 34 40 46 52 58 64 70 76 82 88 94 100 106 112 118 124 130 136 142 148 154 160 166 172 178 184 190 196 202 208 214 220 226 232 238 2... | British mathematician John Littlewood once said about Indian mathematician Srinivasa Ramanujan that "every positive integer was one of his personal friends."
It turns out that positive integers can also be friends with each other! You are given an array a of distinct positive integers.
Define a subarray a_i, a_{i+1}... | 0.5 |
{"tests": "{\"inputs\": [\"7\\n1 3 2 2 4 5 4\\n\", \"1\\n1\\n\", \"2\\n1000000000 1000000000\\n\", \"5\\n1 2 2 4 5\\n\", \"4\\n1 1 2 4\\n\", \"4\\n1 1 2 4\\n\", \"10\\n1 2 3 3 3 3 3 3 4 5\\n\", \"2\\n1000000000 1000000000\\n\", \"1\\n1\\n\", \"5\\n1 2 2 4 5\\n\", \"4\\n1 1 2 7\\n\", \"10\\n1 2 3 3 3 3 3 6 4 5\\n\", \"1... | This is the hard version of the problem. The difference between the versions is that in the easy version all prices $a_i$ are different. You can make hacks if and only if you solved both versions of the problem.
Today is Sage's birthday, and she will go shopping to buy ice spheres. All $n$ ice spheres are placed in a ... | 0 |
{"tests": "{\"inputs\": [[[\"Kenjiro Mori\", \"Susumu Tokugawa\", \"Juzo Okita\", \"Akira Sanada\"]], [[]], [[\"Yasuo Kodai\", \"Kenjiro Sado\", \"Daisuke Aihara\", \"Susumu Shima\", \"Akira Sanada\", \"Yoshikazu Okita\", \"Shiro Yabu\", \"Sukeharu Nanbu\", \"Sakezo Yamamoto\", \"Hikozaemon Ohta\", \"Juzo Mori\", \"Sab... | ### Happy Holidays fellow Code Warriors!
Now, Dasher! Now, Dancer! Now, Prancer, and Vixen! On, Comet! On, Cupid! On, Donder and Blitzen! That's the order Santa wanted his reindeer...right? What do you mean he wants them in order by their last names!? Looks like we need your help Code Warrior!
### Sort Santa's Reinde... | 0 |
{"tests": "{\"inputs\": [[\"(Sensei says yes!)\", \"()\"], [\"(Sensei says no!\", \"()\"], [\"(Sensei [says] yes!)\", \"()[]\"], [\"(Sensei [says) no!]\", \"()[]\"], [\"Sensei says -yes-!\", \"--\"], [\"Sensei -says no!\", \"--\"], [\"Hello Mother can you hear me?\", \"()\"], [\"(Hello Mother can you hear me?)\", \"()\... | ### Background
We **all** know about "balancing parentheses" (plus brackets, braces and chevrons) and even balancing characters that are identical.
Read that last sentence again, I balanced different characters and identical characters twice and you didn't even notice... :)
### Kata
Your challenge in this kata is ... | 0 |
{"tests": "{\"inputs\": [\"10 6\\n1 2\\n1 3\\n1 4\\n2 5\\n2 6\\n3 7\\n7 8\\n7 9\\n9 10\\n4 3 8 9 10\\n3 2 4 6\\n3 2 1 5\\n3 4 8 2\\n2 6 10\\n3 5 4 7\\n\", \"2 3\\n1 2\\n1 1\\n1 2\\n2 1 2\\n\", \"3 7\\n1 2\\n2 3\\n1 1\\n1 2\\n1 3\\n2 1 2\\n2 1 3\\n2 2 3\\n3 1 2 3\\n\", \"2 3\\n1 2\\n1 1\\n1 2\\n2 1 2\\n\", \"3 7\\n1 2\\... | You are given a rooted tree consisting of $n$ vertices numbered from $1$ to $n$. The root of the tree is a vertex number $1$.
A tree is a connected undirected graph with $n-1$ edges.
You are given $m$ queries. The $i$-th query consists of the set of $k_i$ distinct vertices $v_i[1], v_i[2], \dots, v_i[k_i]$. Your task... | 0.5 |
{"tests": "{\"inputs\": [\"7\\nabacaba\\n\", \"6\\naabcfg\\n\", \"12\\nparapapapaaa\\n\", \"4\\npara\\n\", \"5\\nbadec\\n\", \"7\\nbcbcbdc\\n\", \"7\\nstoopid\\n\", \"2\\nba\\n\", \"7\\nbaaaccb\\n\", \"6\\nbabcdc\\n\", \"3\\nacb\\n\", \"3\\nbac\\n\", \"2\\naa\\n\", \"7\\nyxyzyyx\\n\", \"3\\naba\\n\", \"3\\naaa\\n\", \"... | You are given a string $s$ consisting of $n$ lowercase Latin letters.
Let's define a substring as a contiguous subsegment of a string. For example, "acab" is a substring of "abacaba" (it starts in position $3$ and ends in position $6$), but "aa" or "d" aren't substrings of this string. So the substring of the string $... | 0.5 |
{"tests": "{\"inputs\": [\"4\\n1 5\\n5 2\\n3 7\\n7 3\\n\", \"5\\n1 10\\n2 10\\n3 10\\n4 10\\n5 5\\n\", \"1\\n1 2\\n\", \"30\\n22 37\\n12 37\\n37 58\\n29 57\\n43 57\\n57 58\\n58 53\\n45 4\\n1 4\\n4 51\\n35 31\\n21 31\\n31 51\\n51 53\\n53 48\\n60 55\\n52 55\\n55 33\\n36 9\\n10 9\\n9 33\\n33 19\\n5 23\\n47 23\\n23 32\\n50... | A new set of desks just arrived, and it's about time! Things were getting quite cramped in the office. You've been put in charge of creating a new seating chart for the engineers. The desks are numbered, and you sent out a survey to the engineering team asking each engineer the number of the desk they currently sit at,... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.