question stringlengths 29 1.88k | test_input listlengths 0 10 | test_output listlengths 0 10 | test_time_limit int64 1 1 | test_method stringclasses 1
value |
|---|---|---|---|---|
The Little Elephant has got a problem — somebody has been touching his sorted by non-decreasing array a of length n and possibly swapped some elements of the array.
The Little Elephant doesn't want to call the police until he understands if he could have accidentally changed the array himself. He thinks that he could ... | [
"5\n1 4 3 2 1\n",
"6\n3 4 5 6 7 2\n",
"3\n1 3 2\n",
"50\n6 7 8 4 10 3 2 7 1 3 10 3 4 7 2 3 7 4 10 6 8 10 9 6 5 10 9 6 1 8 9 4 3 7 3 10 5 3 10 1 6 10 6 7 10 7 1 5 9 5\n",
"3\n2 3 1\n",
"5\n1 1 3 2 2\n",
"5\n1 4 5 2 3\n",
"5\n100 5 6 10 7\n",
"5\n1 2 5 3 4\n",
"5\n1 3 2 3 3\n"
] | [
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n"
] | 1 | stdio |
Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm.
.#.#.#.#.
.#.#.#.#.#
.#.#.#.#.
.#.#.#.#.#
.#.#.#.#.
.#.#.#.#.#
Note that the top left corner should be drawn by '#'.
Constraints
* 1 ≤ H ≤ 300
* 1... | [
"3 4\n5 6\n3 3\n2 2\n1 0\n0 0",
"3 7\n5 6\n3 3\n2 2\n1 0\n0 0",
"3 7\n5 6\n3 0\n2 2\n1 0\n0 0",
"6 7\n5 6\n3 0\n2 2\n1 0\n0 0",
"6 11\n5 6\n3 0\n2 2\n1 0\n0 0",
"3 4\n5 6\n2 3\n2 2\n1 1\n0 0",
"3 4\n5 6\n3 3\n2 4\n1 0\n0 0",
"3 7\n5 6\n4 3\n2 2\n1 0\n0 0",
"3 7\n5 5\n3 0\n2 2\n1 0\n0 0",
"6 7\n5 6... | [
"#.#.\n.#.#\n#.#.\n\n#.#.#.\n.#.#.#\n#.#.#.\n.#.#.#\n#.#.#.\n\n#.#\n.#.\n#.#\n\n#.\n.#\n\n\n\n",
"#.#.#.#\n.#.#.#.\n#.#.#.#\n\n#.#.#.\n.#.#.#\n#.#.#.\n.#.#.#\n#.#.#.\n\n#.#\n.#.\n#.#\n\n#.\n.#\n\n\n\n",
"#.#.#.#\n.#.#.#.\n#.#.#.#\n\n#.#.#.\n.#.#.#\n#.#.#.\n.#.#.#\n#.#.#.\n\n\n\n\n\n#.\n.#\n\n\n\n",
"#.#.#.#\n... | 1 | stdio |
Read problems statements in Mandarin Chinese and Russian.
Recently Chef bought a bunch of robot-waiters. And now he needs to know how much to pay for the electricity that robots use for their work. All waiters serve food from the kitchen (which is in the point (0, 0)) and carry it to some table (which is in some poi... | [
"2\n3 3\n3 4",
"2\n3 3\n3 0",
"2\n5 3\n3 0",
"2\n5 3\n6 0",
"2\n5 3\n6 1",
"2\n5 2\n6 1",
"2\n3 2\n6 1",
"2\n1 2\n6 1",
"2\n1 3\n6 1",
"2\n0 3\n6 1"
] | [
"6\n7",
"6\n7\n",
"10\n7\n",
"10\n12\n",
"10\n13\n",
"11\n13\n",
"7\n13\n",
"3\n13\n",
"6\n13\n",
"5\n13\n"
] | 1 | stdio |
Bob is travelling from one city to another. In his way, he sees many other cities pass by. What he does instead of learning the full names of the cities, he learns just the first character of the cities. For example, if he passes by "bhopal", he will just remember the 'b'.
Given the list of N cities that come in h... | [
"100\n4\nlrbbmqb\ncd\nr\nowkk\n7\nid\nqscdxrjmow\nrxsjybldbe\nsarcbyne\ndyggxxp\nlorel\nnmpa\n6\nfwkho\nkmcoqhnw\nkuewhsqmgb\nuqcljj\nvsw\ndkqtbxi\n10\nv\nrr\nlj\ntnsnfwzqfj\nafadr\nwsofsbcnuv\nhffbsaq\nwp\nc\ncehch\n2\nfrkmlnoz\nkpqpxrjx\n9\ntzyxacbhh\nicqcoendt\nmfgdwdw\ncgpxiq\nkuytdlcgde\nhtaciohor\ntq\nvwcsgsp... | [
"YES\nYES\nNO\nNO\nYES\nNO\nYES\nYES\nNO\nYES\nYES\nNO\nYES\nNO\nYES\nNO\nYES\nNO\nYES\nYES\nNO\nYES\nYES\nNO\nNO\nNO\nNO\nYES\nNO\nNO\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\nNO\nYES\nYES\nNO\nYES\nYES\nNO\nYES\nYES\nYES\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\nNO\nYES\nNO\nYES\nYES\nYES\nNO... | 1 | stdio |
Find the volume of a cone whose radius and height are provided as parameters to the function `volume`. Use the value of PI provided by your language (for example: `Math.PI` in JS, `math.pi` in Python or `Math::PI` in Ruby) and round down the volume to an Interger.
If you complete this kata and there are no issues, ple... | [] | [] | 1 | stdio |
Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset cons... | [
"1 1\n2 26\n0 0",
"2 1\n2 26\n0 0",
"1 1\n3 26\n0 0",
"2 1\n2 17\n0 0",
"2 1\n2 18\n0 0",
"2 1\n1 19\n0 0",
"2 2\n2 17\n0 0",
"2 2\n3 17\n0 0",
"2 1\n1 17\n0 0",
"2 1\n1 18\n0 0"
] | [
"Thursday\nThursday\n",
"Sunday\nThursday\n",
"Thursday\nFriday\n",
"Sunday\nTuesday\n",
"Sunday\nWednesday\n",
"Sunday\nMonday\n",
"Monday\nTuesday\n",
"Monday\nWednesday\n",
"Sunday\nSaturday\n",
"Sunday\nSunday\n"
] | 1 | stdio |
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.
Let next(x) be the minimum lucky number which is larger than or equals x. Petya is interested what i... | [
"47 47\n",
"747 748\n",
"963 85555574\n",
"474 747\n",
"77 77\n",
"777777777 1000000000\n",
"77777440 77777444\n",
"999999999 1000000000\n",
"1000000000 1000000000\n",
"654 987654\n"
] | [
"47",
"1521",
"7526978888069560",
"202794",
"77",
"987654325123456789",
"388887220",
"8888888888",
"4444444444",
"1339803940266"
] | 1 | stdio |
There are N children, numbered 1, 2, ..., N.
Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.
For each i (1 \leq i \leq N), Child i will be happy if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy ... | [
"3 70\n20 30 5",
"3 10\n20 18 10",
"2 10\n29 20",
"4 1111\n1 5 100 1000",
"4 1111\n-1 2 110 1000",
"3 70\n20 49 5",
"3 10\n20 9 10",
"2 10\n30 20",
"3 70\n4 49 5",
"3 10\n20 4 10"
] | [
"2\n",
"1\n",
"0\n",
"3\n",
"4\n",
"2\n",
"1\n",
"0\n",
"2\n",
"1\n"
] | 1 | stdio |
A prime number is an integer that is greater than 1 and can only be divided by itself or 1. For example, 2 is a prime number because it is divisible only by 2 and 1, but 12 is not a prime number because it is divisible by 2, 3, 4, 6 in addition to 12 and 1.
When you enter the integer n, write a program that outputs th... | [
"19\n5214",
"19\n3257",
"19\n6476",
"19\n10887",
"19\n17073",
"19\n30085",
"19\n357",
"19\n443",
"19\n631",
"19\n862"
] | [
"17 23\n5209 5227\n",
"17 23\n3253 3259\n",
"17 23\n6473 6481\n",
"17 23\n10883 10889\n",
"17 23\n17053 17077\n",
"17 23\n30071 30089\n",
"17 23\n353 359\n",
"17 23\n439 449\n",
"17 23\n619 641\n",
"17 23\n859 863\n"
] | 1 | stdio |
In this Kata you must convert integers numbers from and to a negative-base binary system.
Negative-base systems can accommodate all the same numbers as standard place-value systems, but both positive and negative numbers are represented without the use of a minus sign (or, in computer representation, a sign bit); this... | [] | [] | 1 | stdio |
Implement a function that adds two numbers together and returns their sum in binary. The conversion can be done before, or after the addition.
The binary number returned should be a string.
Write your solution by modifying this code:
```python
def add_binary(a,b):
```
Your solution should implemented in the funct... | [] | [] | 1 | stdio |
Given a string `s` of uppercase letters, your task is to determine how many strings `t` (also uppercase) with length equal to that of `s` satisfy the followng conditions:
* `t` is lexicographical larger than `s`, and
* when you write both `s` and `t` in reverse order, `t` is still lexicographical larger than `s`.
``... | [] | [] | 1 | stdio |
One day alice and bob were playing with their old toys , they had moved all the rakes and drawers to in the pursuit of their childhood toys.
Finally they found bunch of cubes ,with letters and digits written on it ,which they recalled they used to make words from.
They have already come up with a word they would li... | [
"nana 12\nb a 7 8 9 1\nn 1 7 7 7 6\na 9 6 3 7 8\nk 8 2 4 7 9\na 7 8 9 1 3\ns 7 1 1 2 7\nd a 7 8 9 1\nn 1 7 7 7 6\na 9 6 3 7 8\nn 8 2 4 7 9\na 7 8 9 1 3\ns 7 1 1 2 7",
"newworld 8\nf 1 w e h 9\no 2 a u v e\ng n c o o k\nw 3 i e s z\ne a 7 8 i 1\nf 1 w e 7 9\no 2 r u v e\ng n c o o l",
"cosmos 6\no 2 h a v e\ng 3... | [
"YES",
"YES",
"NO",
"YES",
"NO",
"NO"
] | 1 | stdio |
Sort array by last character
Complete the function to sort a given array or list by last character of elements.
```if-not:haskell
Element can be an integer or a string.
```
### Example:
```
['acvd', 'bcc'] --> ['bcc', 'acvd']
```
The last characters of the strings are `d` and `c`. As `c` comes before `d`, sortin... | [] | [] | 1 | stdio |
Joisino wants to evaluate the formula "A op B".
Here, A and B are integers, and the binary operator op is either + or -.
Your task is to evaluate the formula instead of her.
-----Constraints-----
- 1≦A,B≦10^9
- op is either + or -.
-----Input-----
The input is given from Standard Input in the following format:
A op... | [
"1 + 2\n",
"5 - 7\n",
"0 + 2",
"5 - 13",
"-1 + 2",
"5 - 14",
"1 - 14",
"1 - 1",
"1 - 7",
"-1 + 0"
] | [
"3\n",
"-2\n",
"2\n",
"-8\n",
"1\n",
"-9\n",
"-13\n",
"0\n",
"-6\n",
"-1\n"
] | 1 | stdio |
You are given an array of `n+1` integers `1` through `n`. In addition there is a single duplicate integer.
The array is unsorted.
An example valid array would be `[3, 2, 5, 1, 3, 4]`. It has the integers `1` through `5` and `3` is duplicated. `[1, 2, 4, 5, 5]` would not be valid as it is missing `3`.
You should retu... | [] | [] | 1 | stdio |
You receive some random elements as a space-delimited string. Check if the elements are part of an ascending sequence of integers starting with 1, with an increment of 1 (e.g. 1, 2, 3, 4).
Return:
* `0` if the elements can form such a sequence, and no number is missing ("not broken", e.g. `"1 2 4 3"`)
* `1` if there ... | [] | [] | 1 | stdio |
Determine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.
Constraints
* 1 ≤ length of T ≤ 1000000
* 1 ≤ length of P_i ≤ 1000
* 1 ≤ Q ≤ 10000
* The input consists of alphabetical characters and digits
Input
In the first line, a text T is given. In the second lin... | [
"aabaaa\n4\nab\nba\nbb\nxyz",
"aabaaa\n4\nab\nba\nba\nxyz",
"aabaaa\n4\nba\nbb\nac\nzyx",
"aabaaa\n4\nca\nab\nba\nzyx",
"aacaaa\n4\nba\nb`\nac\nzyx",
"aacaaa\n4\nca\nb`\nac\nzyx",
"aabaaa\n4\na`\nab\nca\nyzx",
"aadaaa\n4\nca\nb`\nca\nzyx",
"aabaaa\n4\nab\nab\nba\nxyz",
"aabaaa\n4\nba\nab\nba\nxyz"... | [
"1\n1\n0\n0\n",
"1\n1\n1\n0\n",
"1\n0\n0\n0\n",
"0\n1\n1\n0\n",
"0\n0\n1\n0\n",
"1\n0\n1\n0\n",
"0\n1\n0\n0\n",
"0\n0\n0\n0\n",
"1\n1\n1\n0\n",
"1\n1\n1\n0\n"
] | 1 | stdio |
Create a function that takes a string and returns that
string with the first half lowercased and the last half uppercased.
eg: foobar == fooBAR
If it is an odd number then 'round' it up to find which letters to uppercase. See example below.
sillycase("brian")
// --^-- midpoint
// bri ... | [] | [] | 1 | stdio |
Little Petya likes to play very much. And most of all he likes to play the following game:
He is given a sequence of N integer numbers. At each step it is allowed to increase the value of any number by 1 or to decrease it by 1. The goal of the game is to make the sequence non-decreasing with the smallest number of ste... | [
"5\n0 0 0 0 0\n",
"2\n10 2\n",
"20\n10 5 3 1 3 7 7 6 8 3 6 2 9 10 5 2 10 9 10 4\n",
"10\n8 8 2 2 2 2 10 10 10 8\n",
"5\n1 2 3 1 1\n",
"20\n10 6 1 9 10 10 7 0 10 5 9 1 5 7 4 9 3 9 7 2\n",
"20\n7 7 7 7 7 7 10 10 10 10 23 21 23 20 22 23 22 23 95 97\n",
"7\n1000000000 -1000000000 1000000000 -1000000000 10... | [
"0\n",
"8\n",
"41\n",
"14\n",
"3\n",
"55\n",
"6\n",
"6000000000\n",
"0\n",
"44\n"
] | 1 | stdio |
Complete the function that determines the score of a hand in the card game [Blackjack](https://en.wikipedia.org/wiki/Blackjack) (aka 21).
The function receives an array of strings that represent each card in the hand (`"2"`, `"3",` ..., `"10"`, `"J"`, `"Q"`, `"K"` or `"A"`) and should return the score of the hand (int... | [] | [] | 1 | stdio |
# Task
Your task is to find the sum for the range `0 ... m` for all powers from `0 ... n.
# Example
For `m = 2, n = 3`, the result should be `20`
`0^0+1^0+2^0 + 0^1+1^1+2^1 + 0^2+1^2+2^2 + 0^3+1^3+2^3 = 20`
Note, that no output ever exceeds 2e9.
# Input/Output
- `[input]` integer m
`0 <= m <= 50000`
... | [] | [] | 1 | stdio |
Create a function which answers the question "Are you playing banjo?".
If your name starts with the letter "R" or lower case "r", you are playing banjo!
The function takes a name as its only argument, and returns one of the following strings:
```
name + " plays banjo"
name + " does not play banjo"
```
Names given a... | [] | [] | 1 | stdio |
Write a function that calculates the *least common multiple* of its arguments; each argument is assumed to be a non-negative integer. In the case that there are no arguments (or the provided array in compiled languages is empty), return `1`.
~~~if:objc
NOTE: The first (and only named) argument of the function `n` spec... | [] | [] | 1 | stdio |
You are given a n × m field consisting only of periods ('.') and asterisks ('*'). Your task is to count all right triangles with two sides parallel to the square sides, whose vertices are in the centers of '*'-cells. A right triangle is a triangle in which one angle is a right angle (that is, a 90 degree angle).
Input... | [
"1 3\n*.*\n",
"5 2\n*.\n**\n.*\n..\n.*\n",
"5 2\n**\n**\n**\n*.\n*.\n",
"4 2\n.*\n.*\n..\n..\n",
"10 26\n..**..***.**.*.***.*.***.*\n*.*.*..***.*.**..*********\n*.*.*...***.*.*.*.**....*.\n..**.**.....*....***..***.\n**..*******.*..**.********\n*.**..****.***....***..***\n.*..**.*****.**.**..******\n.*.*...... | [
"0",
"3",
"18",
"0",
"12950",
"1",
"1129",
"0",
"541",
"15"
] | 1 | stdio |
You are given two integers $a$ and $m$. Calculate the number of integers $x$ such that $0 \le x < m$ and $\gcd(a, m) = \gcd(a + x, m)$.
Note: $\gcd(a, b)$ is the greatest common divisor of $a$ and $b$.
-----Input-----
The first line contains the single integer $T$ ($1 \le T \le 50$) — the number of test cases.
Nex... | [
"3\n4 9\n5 10\n42 9999999967\n",
"10\n1 2\n1 3\n1 4\n3 5\n3 6\n3 7\n1 8\n7 9\n8 10\n1 11\n",
"10\n20 52\n48 53\n36 54\n23 55\n14 56\n54 57\n34 58\n33 59\n10 60\n21 61\n",
"10\n37 102\n78 103\n31 104\n7 105\n80 106\n52 107\n26 108\n1 109\n40 110\n85 111\n",
"10\n119 152\n144 153\n41 154\n69 155\n57 156\n91 1... | [
"6\n1\n9999999966\n",
"1\n2\n2\n4\n1\n6\n4\n6\n4\n10\n",
"12\n52\n2\n40\n2\n18\n28\n58\n2\n60\n",
"32\n102\n48\n8\n52\n106\n18\n108\n10\n72\n",
"72\n16\n60\n120\n24\n156\n78\n52\n16\n132\n",
"100\n168\n32\n40\n102\n132\n96\n180\n48\n210\n",
"36\n220\n126\n128\n128\n256\n84\n216\n96\n168\n",
"36\n220\n... | 1 | stdio |
Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to River Song, giving her a new identity that allowed her to kill the Eleventh Doctor.
Heidi figured out that Madame Kovarian uses a... | [
"19\n",
"16\n",
"1\n",
"2\n",
"3\n",
"4\n",
"5\n",
"6\n",
"7\n",
"8\n"
] | [
"1 8\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"1 1\n",
"NO\n",
"1 2\n",
"NO\n"
] | 1 | stdio |
Little Petya loves looking for numbers' divisors. One day Petya came across the following problem:
You are given n queries in the form "xi yi". For each query Petya should count how many divisors of number xi divide none of the numbers xi - yi, xi - yi + 1, ..., xi - 1. Help him.
Input
The first line contains an int... | [
"15\n94836 0\n22780 1\n48294 0\n24834 3\n37083 2\n57862 0\n37231 1\n81795 7\n32835 2\n4696 8\n95612 0\n7536 6\n70084 5\n72956 10\n41647 7\n",
"20\n68260 0\n819 1\n54174 1\n20460 1\n25696 2\n81647 4\n17736 4\n91307 5\n5210 4\n87730 2\n4653 8\n11044 6\n15776 4\n17068 7\n73738 7\n36004 12\n83183 7\n75700 12\n84270 1... | [
"24\n21\n12\n4\n6\n8\n3\n27\n12\n5\n24\n15\n8\n21\n1\n",
"12\n11\n6\n44\n18\n1\n9\n7\n6\n12\n8\n8\n21\n3\n14\n3\n3\n13\n18\n26\n",
"4\n4\n4\n4\n4\n",
"4\n4\n11\n18\n12\n13\n4\n7\n6\n3\n",
"24\n21\n3\n3\n21\n22\n6\n6\n62\n3\n",
"24\n17\n4\n2\n11\n7\n12\n3\n3\n7\n2\n27\n4\n3\n2\n1\n18\n",
"2\n11\n7\n8\n13... | 1 | stdio |
In this Kata, you will be given two positive integers `a` and `b` and your task will be to apply the following operations:
```
i) If a = 0 or b = 0, return [a,b]. Otherwise, go to step (ii);
ii) If a ≥ 2*b, set a = a - 2*b, and repeat step (i). Otherwise, go to step (iii);
iii) If b ≥ 2*a, set b = b - 2*a, and repeat ... | [] | [] | 1 | stdio |
You are given a string $s$ of length $n$, which consists only of the first $k$ letters of the Latin alphabet. All letters in string $s$ are uppercase.
A subsequence of string $s$ is a string that can be derived from $s$ by deleting some of its symbols without changing the order of the remaining symbols. For example, "... | [
"9 3\nACAABCCAB\n",
"9 4\nABCABCABC\n",
"1 26\nA\n",
"22 1\nAAAAAAAAAAAAAAAAAAAAAA\n",
"15 26\nWEYYDIADTLCOUEG\n",
"2 2\nBA\n",
"6 3\nAABBCC\n",
"1 5\nA\n",
"10 2\nABBBBBBBBB\n",
"1 1\nA\n"
] | [
"6",
"0",
"0",
"22",
"0",
"2",
"6",
"0",
"2",
"1"
] | 1 | stdio |
Create a program that reads the attendance numbers of students in a class and the data that stores the ABO blood group and outputs the number of people for each blood type. There are four types of ABO blood types: A, B, AB, and O.
Input
A comma-separated pair of attendance numbers and blood types is given over mult... | [
"1,B\n2,A\n3,B\n4,AB\n5,B\n5,O\n7,A\n8,O\n9,AB\n10,A\n11,A\n12,B\n13,AB\n14,A",
"1,B\n2,B\n3,B\n4,AB\n5,B\n6,O\n7,A\n8,O\n9,AB\n10,A\n11,A\n12,B\n13,AB\n14,A",
"1,B\n2,A\n3,B\n4,AB\n5,A\n6,O\n7,A\n8,O\n9,AB\n11,A\n11,A\n12,B\n13,AB\n14,A",
"1,B\n2,B\n3,B\n4A,B\n5,B\n6,O\n7,A\n8,O\n9,AB\n10,A\n21,A\n12,B\n13,A... | [
"5\n4\n3\n2\n",
"4\n5\n3\n2\n",
"6\n3\n3\n2\n",
"4\n6\n2\n2\n",
"3\n6\n3\n2\n",
"3\n7\n2\n2\n",
"5\n5\n2\n2\n",
"6\n4\n2\n2\n",
"5\n4\n3\n2\n",
"5\n4\n3\n2\n"
] | 1 | stdio |
Complete the function to determine the number of bits required to convert integer `A` to integer `B` (where `A` and `B` >= 0)
The upper limit for `A` and `B` is 2^(16), `int.MaxValue` or similar.
For example, you can change 31 to 14 by flipping the 4th and 0th bit:
```
31 0 0 0 1 1 1 1 1
14 0 0 0 0 1 1 1 0
--- -... | [] | [] | 1 | stdio |
Problem statement
Meatishi can increase or decrease the number of fingers.
There are n buns in front of Nikunishi-kun.
Meatishi is trying to count the number of steamed buns by breaking his finger.
There are only two shapes that Nishikun's fingers can take, whether they are broken or not.
Nikunishi understands binary ... | [
"1",
"2",
"4",
"9",
"19",
"38",
"83",
"159",
"296",
"000"
] | [
"1\n",
"2\n",
"3\n",
"4\n",
"5\n",
"6\n",
"7\n",
"8\n",
"9\n",
"0\n"
] | 1 | stdio |
There is an ice cream shop named Ten Ice Cream. At this store, we always have 10 types of ice cream on the shelves. The store manager creates a daily graph showing how well ice cream is selling for reference in product development.
For such a store manager, you decided to create a program that displays the number of e... | [
"15\n2\n6\n7\n0\n1\n9\n8\n7\n3\n8\n9\n4\n8\n4\n2\n3\n9\n1\n5\n0",
"15\n2\n6\n7\n0\n0\n9\n8\n7\n3\n8\n9\n4\n8\n2\n2\n3\n9\n1\n5\n0",
"15\n2\n6\n7\n0\n1\n9\n8\n7\n3\n8\n9\n4\n8\n4\n2\n3\n9\n1\n2\n0",
"15\n2\n6\n7\n0\n0\n9\n8\n7\n3\n8\n9\n8\n8\n2\n2\n3\n9\n1\n5\n0",
"15\n2\n6\n7\n0\n1\n9\n8\n7\n3\n8\n9\n4\n8\n... | [
"*\n*\n**\n*\n**\n-\n*\n**\n***\n**\n-\n*\n-\n-\n-\n*\n-\n-\n-\n*\n",
"**\n-\n***\n*\n*\n-\n*\n**\n***\n**\n-\n*\n-\n-\n-\n*\n-\n-\n-\n*\n",
"*\n*\n**\n*\n**\n-\n*\n**\n***\n**\n-\n*\n*\n-\n-\n-\n-\n-\n-\n*\n",
"**\n-\n***\n*\n-\n-\n*\n**\n****\n**\n-\n*\n-\n-\n-\n*\n-\n-\n-\n*\n",
"*\n*\n**\n*\n**\n-\n*\n*... | 1 | stdio |
A string is called square if it is some string written twice in a row. For example, the strings "aa", "abcabc", "abab" and "baabaa" are square. But the strings "aaa", "abaaab" and "abcdabc" are not square.
For a given string $s$ determine if it is square.
-----Input-----
The first line of input data contains an int... | [
"10\na\naa\naaa\naaaa\nabab\nabcabc\nabacaba\nxxyy\nxyyx\nxyxy\n",
"1\nzz\n",
"1\nacascnakcn\n",
"1\nababab\n",
"1\nacascnakcn\n",
"1\nababab\n",
"1\nzz\n",
"1\nacascnajcn\n",
"10\na\naa\naaa\naaaa\nabab\nabcabc\nabacaba\nyxxy\nxyyx\nxyxy\n",
"1\n{{\n"
] | [
"NO\nYES\nNO\nYES\nYES\nYES\nNO\nNO\nNO\nYES\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\nYES\nNO\nYES\nYES\nYES\nNO\nNO\nNO\nYES\n",
"YES\n"
] | 1 | stdio |
Champernown constant is an irrational number represented in decimal by "0." followed by concatenation of all positive integers in the increasing order. The first few digits of this constant are: 0.123456789101112...
Your task is to write a program that outputs the K digits of Chapnernown constant starting at the N-th ... | [
"3 5\n6 7\n0 0",
"4 5\n1 7\n0 0",
"4 5\n1 13\n0 0",
"2 5\n1 13\n0 0",
"8 5\n6 7\n0 0",
"3 5\n6 5\n0 0",
"2 5\n1 0\n0 0",
"8 5\n6 14\n0 0",
"2 5\n0 0\n0 0",
"8 8\n6 14\n0 0"
] | [
"34567\n6789101\n",
"45678\n1234567\n",
"45678\n1234567891011\n",
"23456\n1234567891011\n",
"89101\n6789101\n",
"34567\n67891\n",
"23456\n\n",
"89101\n67891011121314\n",
"23456\n",
"89101112\n67891011121314\n"
] | 1 | stdio |
Let $LCM(x, y)$ be the minimum positive integer that is divisible by both $x$ and $y$. For example, $LCM(13, 37) = 481$, $LCM(9, 6) = 18$.
You are given two integers $l$ and $r$. Find two integers $x$ and $y$ such that $l \le x < y \le r$ and $l \le LCM(x, y) \le r$.
-----Input-----
The first line contains one inte... | [
"4\n1 1337\n13 69\n2 4\n88 89\n",
"1\n55556 55557\n",
"5\n2 4\n2 4\n2 4\n2 4\n2 4\n",
"1\n78788 157576\n",
"1\n8743 17489\n",
"1\n96777 19555557\n",
"1\n1000003 100000000\n",
"1\n80000000 160000000\n",
"69\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2... | [
"1 2\n13 26\n2 4\n-1 -1\n",
"-1 -1\n",
"2 4\n2 4\n2 4\n2 4\n2 4\n",
"78788 157576\n",
"8743 17486\n",
"96777 193554\n",
"1000003 2000006\n",
"80000000 160000000\n",
"1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\... | 1 | stdio |
Read problems statements in Mandarin Chinese and Russian.
You are given an array A of N integers. You are to fulfill M queries. Each query has one of the following three types:
C d : Rotate the array A clockwise by d units.
A d : Rotate the array A anticlockwise by d units.
R d : Query for the value of the element,... | [
"5 5\n5 4 3 3 9\nR 1\nC 4\nR 5\nA 3\nR 2",
"5 5\n5 4 3 3 9\nR 1\nC 4\nR 5\nA 6\nR 2",
"5 5\n5 4 3 3 9\nR 1\nC 4\nR 5\nA 3\nR 0",
"5 5\n5 4 3 3 9\nR 1\nC 1\nR 5\nA 6\nR 2",
"5 5\n5 3 3 3 9\nR 1\nC 1\nR 5\nA 6\nR 2",
"5 5\n5 3 6 3 9\nR 1\nC 1\nR 5\nA 0\nR 2",
"5 5\n5 7 3 3 9\nR 1\nC 4\nR 5\nA 3\nR 2",
"... | [
"5\n3\n3",
"5\n3\n9\n",
"5\n3\n5\n",
"5\n5\n4\n",
"5\n5\n3\n",
"5\n5\n6\n",
"5\n3\n3\n",
"5\n4\n3\n",
"5\n5\n5\n",
"5\n5\n0\n"
] | 1 | stdio |
Take an integer `n (n >= 0)` and a digit `d (0 <= d <= 9)` as an integer. Square all numbers `k (0 <= k <= n)` between 0 and n. Count the numbers of
digits `d` used in the writing of all the `k**2`. Call `nb_dig` (or nbDig or ...) the function taking `n` and `d` as parameters and returning this count.
#Examples:
```
... | [] | [] | 1 | stdio |
You have integer $n$. Calculate how many ways are there to fully cover belt-like area of $4n-2$ triangles with diamond shapes.
Diamond shape consists of two triangles. You can move, rotate or flip the shape, but you cannot scale it.
$2$ coverings are different if some $2$ triangles are covered by the same diamond s... | [
"2\n2\n1\n",
"1\n1000000000\n",
"1\n1000000000\n",
"1\n0000000000\n",
"2\n2\n2\n",
"1\n0010000000\n",
"2\n2\n4\n",
"1\n0001000000\n",
"2\n4\n4\n",
"1\n0001000001\n"
] | [
"2\n1\n",
"1000000000\n",
"1000000000\n",
"0\n",
"2\n2\n",
"10000000\n",
"2\n4\n",
"1000000\n",
"4\n4\n",
"1000001\n"
] | 1 | stdio |
Write a function which reduces fractions to their simplest form! Fractions will be presented as an array/tuple (depending on the language), and the reduced fraction must be returned as an array/tuple:
```
input: [numerator, denominator]
output: [newNumerator, newDenominator]
example: [45, 120] --> [3, 8]
```
All n... | [] | [] | 1 | stdio |
Let's imagine we have a popular online RPG. A player begins with a score of 0 in class E5. A1 is the highest level a player can achieve.
Now let's say the players wants to rank up to class E4. To do so the player needs to achieve at least 100 points to enter the qualifying stage.
Write a script that will check to see... | [] | [] | 1 | stdio |
Compare given two sequence $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and $B = \\{b_0, b_1, ..., b_{m-1}$ lexicographically.
Constraints
* $1 \leq n, m \leq 1,000$
* $0 \leq a_i, b_i \leq 1,000$
Input
The input is given in the following format.
$n$
$a_0 \; a_1, ..., \; a_{n-1}$
$m$
$b_0 \; b_1, ..., \; b_{m-1}$
The num... | [
"3\n1 1 2\n4\n1 2 2 2",
"4\n1 4 3 1\n4\n0 4 5 4 2",
"3\n1 4 3\n2\n2 4",
"4\n0 4 7 0\n5\n1 2 3 4 5",
"3\n1 1 2\n4\n1 3 2 2",
"3\n1 4 3\n2\n2 2",
"4\n0 4 7 0\n5\n1 2 3 4 1",
"3\n1 1 2\n4\n1 3 3 2",
"3\n1 4 3\n3\n2 2",
"4\n0 4 7 0\n5\n1 2 5 4 1"
] | [
"1\n",
"0\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n"
] | 1 | stdio |
Let N be a positive odd number.
There are N coins, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), when Coin i is tossed, it comes up heads with probability p_i and tails with probability 1 - p_i.
Taro has tossed all the N coins. Find the probability of having more heads than tails.
Constraints
* N is an od... | [
"5\n1.024501914223776 0.01 0.42 0.99 0.42",
"1\n1.0727834824798",
"3\n0.5605093833878567 0.60 0.80",
"5\n1.024501914223776 0.01 0.5446982864891694 0.99 0.42",
"1\n1.4147366857390051",
"3\n0.63370309829039 0.60 0.80",
"5\n1.024501914223776 0.01 0.5446982864891694 1.8265871769248951 0.42",
"1\n1.7909231... | [
"0.673932442782\n",
"1.07278348248\n",
"0.726624128691\n",
"0.745818245767\n",
"1.41473668574\n",
"0.758829363248\n",
"1.1736606376\n",
"1.7909231128\n",
"1.04452278651\n",
"1.57450547902\n"
] | 1 | stdio |
Everyone knows passphrases. One can choose passphrases from poems, songs, movies names and so on but frequently
they can be guessed due to common cultural references.
You can get your passphrases stronger by different means. One is the following:
choose a text in capital letters including or not digits and non alphab... | [] | [] | 1 | stdio |
We say that a odd number N is similar to 2017 when both N and (N+1)/2 are prime.
You are given Q queries.
In the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.
-----Constraints-----
- 1≤Q≤10^5
- 1≤l_i≤r_i≤10^5
- l_i and r_i are odd.
- All in... | [
"1\n3 7\n",
"4\n13 13\n7 11\n7 11\n2017 2017\n",
"6\n1 53\n13 91\n37 55\n19 51\n73 91\n13 49\n",
"1\n3 9",
"1\n5 9",
"1\n9 9",
"4\n13 13\n7 0\n7 11\n2017 2017",
"6\n1 53\n7 91\n37 55\n19 51\n73 91\n13 49",
"4\n11 13\n7 1\n7 13\n2017 2017",
"6\n1 53\n7 91\n37 55\n19 51\n73 169\n13 49"
] | [
"2\n",
"1\n0\n0\n1\n",
"4\n4\n1\n1\n1\n2\n",
"2\n",
"1\n",
"0\n",
"1\n-2\n0\n1\n",
"4\n4\n1\n1\n1\n2\n",
"1\n-2\n1\n1\n",
"4\n4\n1\n1\n2\n2\n"
] | 1 | stdio |
Takahashi likes the sound when he buys a drink from a vending machine.
That sound can be heard by spending A yen (the currency of Japan) each time.
Takahashi has B yen. He will hear the sound as many times as he can with that money, but at most C times, as he would be satisfied at that time.
How many times will he hear... | [
"2 11 4\n",
"3 9 5\n",
"100 1 10\n",
"51 90 3\n",
"1 100 99\n",
"5 49 10\n",
"8 64 9\n",
"100 100 100\n",
"4 99 23\n",
"11 66 5\n"
] | [
"4\n",
"3\n",
"0\n",
"1\n",
"99\n",
"9\n",
"8\n",
"1\n",
"23\n",
"5\n"
] | 1 | stdio |
Xenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation.
The teacher has written down the sum of multiple numbers. Pupils should calculate the sum. To make the calculation easier, the sum only contains numbers 1, 2 and 3. Still, that isn't enough for Xe... | [
"3+2+1\n",
"1+1+3+1+3\n",
"2\n",
"2+2+1+1+3\n",
"2+1+2+2+2+3+1+3+1+2\n",
"1+2+1+2+2+2+2+1+3+3\n",
"2+3+3+1+2+2+2+1+1+2+1+3+2+2+3+3+2+2+3+3+3+1+1+1+3+3+3+2+1+3+2+3+2+1+1+3+3+3+1+2+2+1+2+2+1+2+1+3+1+1\n",
"1\n",
"2+1+2+2+1+3+2+3+1+1+2+1+2+2+3+1+1+3+3+3+2+2+3+2+2+2+1+2+1+2+3+2+2+2+1+3+1+3+3+3+1+2+1+2+2... | [
"1+2+3\n",
"1+1+1+3+3\n",
"2\n",
"1+1+2+2+3\n",
"1+1+1+2+2+2+2+2+3+3\n",
"1+1+1+2+2+2+2+2+3+3\n",
"1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n",
"1\n",
"1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3... | 1 | stdio |
The development of algae in a pond is as follows.
Let the total weight of the algae at the beginning of the year i be x_i gram. For i≥2000, the following formula holds:
- x_{i+1} = rx_i - D
You are given r, D and x_{2000}. Calculate x_{2001}, ..., x_{2010} and print them in order.
-----Constraints-----
- 2 ≤ r ≤ 5
... | [
"2 10 20\n",
"4 40 60\n",
"2 1 2\n",
"2 100 105\n",
"3 1 2\n",
"4 49 188\n",
"5 1 200\n",
"0 10 20",
"8 40 60",
"1 10 20"
] | [
"30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n",
"200\n760\n3000\n11960\n47800\n191160\n764600\n3058360\n12233400\n48933560\n",
"3\n5\n9\n17\n33\n65\n129\n257\n513\n1025\n",
"110\n120\n140\n180\n260\n420\n740\n1380\n2660\n5220\n",
"5\n14\n41\n122\n365\n1094\n3281\n9842\n29525\n88574\n",
"703\n2763\... | 1 | stdio |
Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise.
You are given Smeke's current rating, x. Print ABC if Smeke will participate in ABC, and print ARC otherwise.
-----Constraints-----
- 1 ≦ x ≦ 3{,}000
... | [
"1000\n",
"2000\n",
"0000",
"2936",
"0100",
"1432",
"1100",
"146",
"1101",
"242"
] | [
"ABC\n",
"ARC\n",
"ABC\n",
"ARC\n",
"ABC\n",
"ARC\n",
"ABC\n",
"ABC\n",
"ABC\n",
"ABC\n"
] | 1 | stdio |
A checksum is an algorithm that scans a packet of data and returns a single number. The idea is that if the packet is changed, the checksum will also change, so checksums are often used for detecting
transmission errors, validating document contents, and in many other situations where it is necessary to detect undesira... | [] | [] | 1 | stdio |
The GCD table G of size n × n for an array of positive integers a of length n is defined by formula
<image>
Let us remind you that the greatest common divisor (GCD) of two positive integers x and y is the greatest integer that is divisor of both x and y, it is denoted as <image>. For example, for array a = {4, 3, 6,... | [
"5\n4 4 4 4 4 4 4 4 4 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1\n",
"4\n1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3\n",
"5\n27 675 1 1 347621274 5 2 13 189 738040275 5 1 189 13 1 959752125 770516962 769220855 5 5 2 675 1 1 27\n",
"3\n484799 1 1 744137 1 1 909312183 1 1\n",
"2\n54748096 1 641009859 1\n",
"4\n67025 13405 1915 19... | [
"4 4 4 2 1 ",
"3 3 1 1 ",
"959752125 770516962 769220855 738040275 347621274 ",
"909312183 744137 484799 ",
"641009859 54748096 ",
"676469920 660330300 533084295 380098775 ",
"143380513 695147 607844 188110 ",
"534447872 401939237 233427865 115704211 73701396 ",
"531222142 435485671 55451923 ",
"5... | 1 | stdio |
«One dragon. Two dragon. Three dragon», — the princess was counting. She had trouble falling asleep, and she got bored of counting lambs when she was nine.
However, just counting dragons was boring as well, so she entertained herself at best she could. Tonight she imagined that all dragons were here to steal her, and ... | [
"8\n4\n4\n3\n65437\n",
"10\n2\n1\n8\n63537\n",
"5\n5\n8\n9\n79228\n",
"3\n7\n7\n7\n84046\n",
"4\n1\n8\n7\n44835\n",
"1\n1\n1\n1\n100000\n",
"1\n5\n2\n6\n49547\n",
"2\n7\n4\n9\n56937\n",
"1\n2\n10\n4\n39901\n",
"7\n2\n3\n8\n21754\n"
] | [
"32718\n",
"63537\n",
"29931\n",
"36019\n",
"44835\n",
"100000\n",
"49547\n",
"35246\n",
"39901\n",
"15539\n"
] | 1 | stdio |
The `depth` of an integer `n` is defined to be how many multiples of `n` it is necessary to compute before all `10` digits have appeared at least once in some multiple.
example:
```
let see n=42
Multiple value digits comment
42*1 42 2,4
42*2 84 8 ... | [] | [] | 1 | stdio |
Prime numbers are widely applied for cryptographic and communication technology. A twin prime is a prime number that differs from another prime number by 2. For example, (5, 7) and (11, 13) are twin prime pairs.
In this problem, we call the greater number of a twin prime "size of the twin prime."
Your task is to crea... | [
"12\n110\n200\n300\n0",
"12\n110\n200\n227\n0",
"12\n110\n200\n329\n0",
"12\n010\n200\n329\n0",
"12\n010\n169\n329\n0",
"12\n100\n200\n482\n0",
"12\n110\n200\n87\n0",
"12\n010\n200\n227\n0",
"12\n110\n200\n239\n0",
"12\n010\n27\n329\n0"
] | [
"5 7\n107 109\n197 199\n281 283\n",
"5 7\n107 109\n197 199\n197 199\n",
"5 7\n107 109\n197 199\n311 313\n",
"5 7\n5 7\n197 199\n311 313\n",
"5 7\n5 7\n149 151\n311 313\n",
"5 7\n71 73\n197 199\n461 463\n",
"5 7\n107 109\n197 199\n71 73\n",
"5 7\n5 7\n197 199\n197 199\n",
"5 7\n107 109\n197 199\n227 ... | 1 | stdio |
DO YOU EXPECT ME TO FIND THIS OUT?
WHAT BASE AND/XOR LANGUAGE INCLUDES string?
DON'T BYTE OF MORE THAN YOU CAN CHEW
YOU CAN ONLY DISTORT THE LARGEST OF MATHEMATICS SO FAR
SAYING "ABRACADABRA" WITHOUT A MAGIC AND WON'T DO YOU ANY GOOD
THE LAST STACK RUPTURES. ALL DIE. OH, THE EMBARRASSMENT!
I HAVE NO ARRAY AND I M... | [
"4\n2 5 3 1\n",
"2\n1 5\n",
"1\n8\n",
"6\n1 1 1 3 2 9\n",
"5\n8 9 3 1 9\n",
"6\n1 5 2 1 7 11\n",
"8\n1 6 11 8 5 10 7 8\n",
"3\n4 9 6\n",
"2\n4 8\n",
"3\n1 1 5\n"
] | [
"4\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"3\n",
"15\n",
"0\n",
"0\n"
] | 1 | stdio |
## Find Mean
Find the mean (average) of a list of numbers in an array.
## Information
To find the mean (average) of a set of numbers add all of the numbers together and divide by the number of values in the list.
For an example list of `1, 3, 5, 7`
1. Add all of the numbers
```
1+3+5+7 = 16
```
2. Divide by the ... | [] | [] | 1 | stdio |
Make a program that filters a list of strings and returns a list with only your friends name in it.
If a name has exactly 4 letters in it, you can be sure that it has to be a friend of yours! Otherwise, you can be sure he's not...
Ex: Input = ["Ryan", "Kieran", "Jason", "Yous"], Output = ["Ryan", "Yous"]
i.e.
Note:... | [] | [] | 1 | stdio |
Leha like all kinds of strange things. Recently he liked the function F(n, k). Consider all possible k-element subsets of the set [1, 2, ..., n]. For subset find minimal element in it. F(n, k) — mathematical expectation of the minimal element among all k-element subsets.
But only function does not interest him. He wan... | [
"5\n7 3 5 3 4\n2 1 3 3 3\n",
"7\n4 6 5 8 8 2 6\n2 1 2 1 1 1 2\n",
"7\n4 12 5 8 8 2 6\n2 1 2 1 1 1 2\n",
"7\n4 12 5 8 8 2 5\n2 1 2 1 1 1 2\n",
"7\n4 12 5 8 8 2 5\n2 1 2 1 1 1 1\n",
"7\n4 12 5 8 8 2 5\n2 1 2 0 1 1 1\n",
"7\n4 12 5 8 8 2 5\n2 1 2 0 1 1 0\n",
"7\n8 6 5 8 8 2 6\n2 1 2 2 1 1 2\n",
"7\n4 6... | [
"5 7 4 3 3\n",
"5 8 4 8 6 6 2\n",
"5 12 4 8 8 6 2\n",
"5 12 4 8 8 5 2\n",
"4 12 2 8 8 5 5\n",
"4 8 2 12 8 5 5\n",
"4 8 2 12 5 5 8\n",
"6 8 6 5 8 8 2\n",
"5 11 4 8 8 6 2\n",
"4 12 3 8 8 5 2\n"
] | 1 | stdio |
Make a function **"add"** that will be able to sum elements of **list** continuously and return a new list of sums.
For example:
```
add [1,2,3,4,5] == [1, 3, 6, 10, 15], because it's calculated like
this : [1, 1 + 2, 1 + 2 + 3, 1 + 2 + 3 + 4, 1 + 2 + 3 + 4 + 5]
```
If you want to learn more see https://en.wikiped... | [] | [] | 1 | stdio |
Write a program which computes the digit number of sum of two integers a and b.
Constraints
* 0 ≤ a, b ≤ 1,000,000
* The number of datasets ≤ 200
Input
There are several test cases. Each test case consists of two non-negative integers a and b which are separeted by a space in a line. The input terminates with EOF.
... | [
"4 7\n1 99\n1000 999",
"10 10\n2 36\n1000 25",
"10 10\n2 3\n1000 6",
"0 1\n2 3\n1001 6",
"0 0\n3 0\n0101 6",
"1 1\n5 0\n0001 6",
"1 1\n5 0\n0001 9",
"2 0\n13 1\n1011 4",
"2 0\n13 1\n0011 4",
"0 -1\n0 0\n0010 7"
] | [
"2\n3\n4\n",
"2\n2\n4\n",
"2\n1\n4\n",
"1\n1\n4\n",
"1\n1\n3\n",
"1\n1\n1\n",
"1\n1\n2\n",
"1\n2\n4\n",
"1\n2\n2\n",
"2\n1\n2\n"
] | 1 | stdio |
Dothraki are planning an attack to usurp King Robert's throne. King Robert learns of this conspiracy from Raven and plans to lock the single door through which the enemy can enter his kingdom.
But, to lock the door he needs a key that is an anagram of a certain palindrome string.
The king has a string composed of low... | [
"cdefghmnopqrstuvw",
"aaabbbb",
"cdcdcdcdeeeef",
"wmtdtgddcldazqohcrpyjjebruxjxlstxmzqucvypaarrqyvhpurbyuuvteseyobmnuirrigsixjyweilabmzvhwpnovlexartiikrpcbmnckukwunkvktrziixwmwwgpeobxfgzstbepncmanhmibmrjlnxhldwpuxpzfotbryqeacgpmsypgrargxyrdwixwxybnscesviszqknlicrbcjhajafgkcekafxukcmfmhedrsqbwhczslbcngkxkohmvf... | [
"YES",
"NO",
"NO",
"YES",
"YES"
] | 1 | stdio |
Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.
When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
-----Constraints-----
- 1 \leq N,K \l... | [
"7 3\n",
"100 10\n",
"1 1\n",
"100 100\n",
"99 33\n",
"21 2\n",
"100 1\n",
"99 49\n",
"78 25\n",
"3 89\n"
] | [
"1\n",
"0\n",
"0\n",
"0\n",
"0\n",
"1\n",
"0\n",
"1\n",
"1\n",
"1\n"
] | 1 | stdio |
You are given an integer K. Print the string obtained by repeating the string `ACL` K times and concatenating them.
For example, if K = 3, print `ACLACLACL`.
Constraints
* 1 \leq K \leq 5
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
K
Output
Print the s... | [
"4",
"6",
"5",
"10",
"8",
"7",
"9",
"2",
"13",
"1"
] | [
"ACLACLACLACL\n",
"ACLACLACLACLACLACL\n",
"ACLACLACLACLACL\n",
"ACLACLACLACLACLACLACLACLACLACL\n",
"ACLACLACLACLACLACLACLACL\n",
"ACLACLACLACLACLACLACL\n",
"ACLACLACLACLACLACLACLACLACL\n",
"ACLACL\n",
"ACLACLACLACLACLACLACLACLACLACLACLACLACL\n",
"ACL\n"
] | 1 | stdio |
A tatami mat, a Japanese traditional floor cover, has a rectangular form with aspect ratio 1:2. When spreading tatami mats on a floor, it is prohibited to make a cross with the border of the tatami mats, because it is believed to bring bad luck.
Your task is to write a program that reports how many possible ways to sp... | [
"3 1\n4 4\n0 0",
"3 1\n6 4\n0 0",
"3 4\n4 1\n0 0",
"3 1\n4 2\n0 0",
"3 2\n6 4\n0 0",
"3 7\n4 1\n0 0",
"4 4\n4 1\n0 0",
"4 1\n4 2\n0 0",
"3 7\n7 1\n0 0",
"4 1\n6 4\n0 0"
] | [
"0\n2\n",
"0\n3\n",
"4\n1\n",
"0\n4\n",
"3\n3\n",
"0\n1\n",
"2\n1\n",
"1\n4\n",
"0\n0\n",
"1\n3\n"
] | 1 | stdio |
Brave Ponta and his best friend, Brave Gonta, have come to Luida's bar in search of friends to embark on an epic adventure. There are many warriors, monks and wizards in the tavern who are itching to go on an adventure.
Gonta, who is kind-hearted, cared for Ponta and said, "You can choose your friends first."
On the ... | [
"5\n1 2 3 4 5\n4\n2 3 5 10\n0",
"5\n1 2 3 4 5\n4\n1 3 5 10\n0",
"5\n1 2 3 4 5\n4\n1 3 4 10\n0",
"5\n1 3 3 4 5\n4\n2 3 5 7\n0",
"5\n1 2 3 4 4\n4\n1 3 4 10\n0",
"5\n1 3 3 4 5\n4\n2 3 5 10\n0",
"5\n1 2 3 4 5\n4\n0 3 5 11\n0",
"5\n1 4 3 4 20\n19\n1 3 4 10\n0",
"5\n1 2 3 4 5\n4\n2 1 0 7\n0",
"5\n1 4 3 ... | [
"1\n0\n",
"1\n1\n",
"1\n2\n",
"0\n1\n",
"0\n2\n",
"0\n0\n",
"1\n3\n",
"8\n2\n",
"1\n4\n",
"10\n2\n"
] | 1 | stdio |
# Task
Get the digits sum of `n`th number from the [Look-and-Say sequence](http://en.wikipedia.org/wiki/Look-and-say_sequence)(1-based).
`1, 11, 21, 1211, 111221, 312211, 13112221, 1113213211, ...`
# Input/Output
`[input]` integer `n`
`n`th number in the sequence to get where `1 <= n <= 55` and `n=1 is "1"`.
[out... | [] | [] | 1 | stdio |
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan).
In how many ways can we select some of these coins so that they are X yen in total?
Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coi... | [
"2\n2\n2\n100\n",
"5\n1\n0\n150\n",
"30\n40\n50\n6000\n",
"2\n2\n4\n100",
"30\n40\n77\n6000",
"5\n0\n0\n150",
"30\n47\n77\n6000",
"5\n0\n0\n0",
"2\n2\n5\n100",
"2\n2\n10\n100"
] | [
"2\n",
"0\n",
"213\n",
"2\n",
"293\n",
"0\n",
"319\n",
"1\n",
"2\n",
"2\n"
] | 1 | stdio |
Example
Input
5 3
4
2
5
Output
5
2
4
1
3 | [
"5 0\n4\n2\n5",
"2 0\n4\n2\n6",
"5 3\n5\n2\n5",
"3 0\n4\n0\n6",
"7 0\n3\n0\n6",
"9 0\n3\n0\n6",
"9 1\n4\n0\n6",
"1 0\n10\n0\n0",
"10 1\n4\n0\n6",
"10 1\n8\n0\n6"
] | [
"1\n2\n3\n4\n5\n",
"1\n2\n",
"5\n2\n1\n3\n4\n",
"1\n2\n3\n",
"1\n2\n3\n4\n5\n6\n7\n",
"1\n2\n3\n4\n5\n6\n7\n8\n9\n",
"4\n1\n2\n3\n5\n6\n7\n8\n9\n",
"1\n",
"4\n1\n2\n3\n5\n6\n7\n8\n9\n10\n",
"8\n1\n2\n3\n4\n5\n6\n7\n9\n10\n"
] | 1 | stdio |
You have n distinct points on a plane, none of them lie on OY axis. Check that there is a point after removal of which the remaining points are located on one side of the OY axis.
-----Input-----
The first line contains a single positive integer n (2 ≤ n ≤ 10^5).
The following n lines contain coordinates of the poi... | [
"3\n1 1\n-1 -1\n2 -1\n",
"4\n1 1\n2 2\n-1 1\n-2 2\n",
"3\n1 2\n2 1\n4 60\n",
"10\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n7 7\n8 8\n9 9\n-1 -1\n",
"2\n1000000000 -1000000000\n1000000000 1000000000\n",
"23\n-1 1\n-1 2\n-2 4\n-7 -8\n-3 3\n-9 -14\n-5 3\n-6 2\n-7 11\n-4 4\n-8 5\n1 1\n-1 -1\n-1 -2\n-2 -4\n-7 8\n-3 -3\n-... | [
"Yes",
"No",
"Yes",
"Yes",
"Yes",
"Yes",
"No",
"Yes",
"No",
"Yes"
] | 1 | stdio |
Write a function `getDrinkByProfession`/`get_drink_by_profession()` that receives as input parameter a string, and produces outputs according to the following table:
Input
Output
"Jabroni"
"Patron Tequila"
"School Counselor"
"Anything with Alcohol"
"Programmer"
"Hipster Craft Beer"
"Bike Gang Member"
"Mo... | [] | [] | 1 | stdio |
We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of substrings "ab" in the string and replace it with the string "bba". If we have no "ab" as a substring, our job is done. Print the minimum number of steps we should perform to make our job done modulo 10^9 + ... | [
"ab\n",
"aab\n",
"aaaaabaabababaaaaaba\n",
"abaabaaabbabaabab\n",
"abbaa\n",
"abbaaabaabaaaaabbbbaababaaaaabaabbaaaaabbaabbaaaabbbabbbabb\n",
"aababbaaaabbaabbbbbbbbabbababbbaaabbaaabbabbba\n",
"aabbaababbabbbaabbaababaaaabbaaaabaaaaaababbaaaabaababbabbbb\n",
"aaabaaaabbababbaabbababbbbaaaaaaabbabbb... | [
"1\n",
"3\n",
"17307\n",
"1795\n",
"2\n",
"690283580\n",
"2183418\n",
"436420225\n",
"8431094\n",
"8180\n"
] | 1 | stdio |
Sum all the numbers of the array (in F# and Haskell you get a list) except the highest and the lowest element (the value, not the index!).
(The highest/lowest element is respectively only one element at each edge, even if there are more than one with the same value!)
Example:
```
{ 6, 2, 1, 8, 10 } => 16
{ 1, 1, 11, 2,... | [] | [] | 1 | stdio |
*** No Loops Allowed ***
You will be given an array (a) and a value (x). All you need to do is check whether the provided array contains the value, without using a loop.
Array can contain numbers or strings. X can be either. Return true if the array contains the value, false if not. With strings you will need to acco... | [] | [] | 1 | stdio |
We have N dice arranged in a line from left to right. The i-th die from the left shows p_i numbers from 1 to p_i with equal probability when thrown.
We will choose K adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this s... | [
"5 3\n1 2 2 4 5\n",
"4 1\n6 6 6 6\n",
"10 4\n17 13 13 12 15 20 10 13 17 11\n",
"10 4\n17 21 13 12 15 20 10 13 17 11",
"3 1\n6 6 6 6",
"10 4\n15 21 13 12 15 20 10 13 17 11",
"3 1\n11 6 6 6",
"1 1\n15 6 6 6",
"10 4\n17 13 13 14 15 20 10 13 17 11",
"3 0\n6 6 6 6"
] | [
"7.000000000000\n",
"3.500000000000\n",
"32.000000000000\n",
"33.5000000000\n",
"3.5000000000\n",
"32.5000000000\n",
"6.0000000000\n",
"8.0000000000\n",
"33.0000000000\n",
"0.0000000000\n"
] | 1 | stdio |
If the strings are consecutive, you can replace the characters with a rule to shorten the string. For example, for the string AAAA, the expression @ 4A will compress one character. Create a program that restores the character string compressed by this rule to the original character string. However, it is assumed that t... | [
"ab@5C1@8050\n@99,1=1@90",
"ab@5C2@8050\n@99,1=1@90",
"ab@5C2?8050\n@99,1=1@90",
"ab@5C1@8050\nA99+1=1@90",
"ab@5C2@8050\n@89,1=1@90",
"ab@5C2?8050\n@91,1=9@90",
"`b@5C1@8050\nA99+1=1@90",
"ab@5C3@8050\n@89,1=1@90",
"`b@5C2@8050\nA99+1=1@90",
"aa@5C3@8050\n@89,1=1@90"
] | [
"abCCCCC10000000050\n999999999,1=1000000000",
"abCCCCC20000000050\n999999999,1=1000000000",
"abCCCCC2?8050\n999999999,1=1000000000",
"abCCCCC10000000050\nA99+1=1000000000",
"abCCCCC20000000050\n99999999,1=1000000000",
"abCCCCC2?8050\n111111111,1=9000000000",
"`bCCCCC10000000050\nA99+1=1000000000",
"ab... | 1 | stdio |
You are given two non-negative integers L and R.
We will choose two integers i and j such that L \leq i < j \leq R.
Find the minimum possible value of (i \times j) \mbox{ mod } 2019.
-----Constraints-----
- All values in input are integers.
- 0 \leq L < R \leq 2 \times 10^9
-----Input-----
Input is given from Stand... | [
"2020 2040\n",
"4 5\n",
"1090 1091\n",
"1999997173 1999999190\n",
"0 2000000000\n",
"1999999262 1999999281\n",
"1999999264 1999999270\n",
"1999999266 1999999276\n",
"1999999218 1999999237\n",
"1999999216 1999999234\n"
] | [
"2\n",
"20\n",
"2018\n",
"0\n",
"0\n",
"2\n",
"26\n",
"18\n",
"5\n",
"650\n"
] | 1 | stdio |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $h$ hours and $m$ minutes, where $0 \le hh < 24$ and $0 \le mm < 60$. We use 24-hour time format!
Your task is to find the number of minutes before the New Year. You know that New Year co... | [
"5\n23 55\n23 0\n0 1\n4 20\n23 59\n",
"5\n23 55\n22 30\n21 10\n20 21\n19 59\n",
"1\n1 2\n",
"5\n23 55\n22 30\n21 10\n20 21\n19 59\n",
"1\n1 2\n",
"5\n23 55\n22 45\n21 10\n20 21\n19 59\n",
"1\n1 3\n",
"5\n23 55\n22 45\n21 2\n20 21\n19 59\n",
"1\n2 3\n",
"5\n23 55\n22 45\n21 2\n0 21\n19 59\n"
] | [
"5\n60\n1439\n1180\n1\n",
"5\n90\n170\n219\n241\n",
"1378\n",
"5\n90\n170\n219\n241\n",
"1378\n",
"5\n75\n170\n219\n241\n",
"1377\n",
"5\n75\n178\n219\n241\n",
"1317\n",
"5\n75\n178\n1419\n241\n"
] | 1 | stdio |
### Longest Palindrome
Find the length of the longest substring in the given string `s` that is the same in reverse.
As an example, if the input was “I like racecars that go fast”, the substring (`racecar`) length would be `7`.
If the length of the input string is `0`, the return value must be `0`.
### Ex... | [] | [] | 1 | stdio |
Let us denote by f(x, m) the remainder of the Euclidean division of x by m.
Let A be the sequence that is defined by the initial value A_1=X and the recurrence relation A_{n+1} = f(A_n^2, M).
Find \displaystyle{\sum_{i=1}^N A_i}.
-----Constraints-----
- 1 \leq N \leq 10^{10}
- 0 \leq X < M \leq 10^5
- All values in... | [
"6 2 1001\n",
"1000 2 16\n",
"10000000000 10 99959\n",
"1 100 101\n",
"9999999999 0 1\n",
"9999999999 1 99999\n",
"10000000000 99201 99975\n",
"40000 2 99707\n",
"9999999990 2 99707\n",
"9999999994 19 98999\n"
] | [
"1369\n",
"6\n",
"492443256176507\n",
"100\n",
"0\n",
"9999999999\n",
"992010000000000\n",
"1985322059\n",
"497374957666942\n",
"489934858199549\n"
] | 1 | stdio |
A string $s$ of length $n$ can be encrypted by the following algorithm: iterate over all divisors of $n$ in decreasing order (i.e. from $n$ to $1$), for each divisor $d$, reverse the substring $s[1 \dots d]$ (i.e. the substring which starts at position $1$ and ends at position $d$).
For example, the above algorithm... | [
"10\nrocesfedoc\n",
"16\nplmaetwoxesisiht\n",
"1\nz\n",
"2\nir\n",
"3\nilj\n",
"4\njfyy\n",
"6\nkrdych\n",
"60\nfnebsopcvmlaoecpzmakqigyuutueuozjxutlwwiochekmhjgwxsgfbcrpqj\n",
"64\nhnlzzhrvqnldswxfsrowfhmyzbxtyoxhogudasgywxycyhzgiseerbislcncvnwy\n",
"97\nqnqrmdhmbubaijtwsecbidqouhlecladwgwcuxbigc... | [
"codeforces\n",
"thisisexampletwo\n",
"z\n",
"ri\n",
"jli\n",
"yyjf\n",
"hcyrkd\n",
"jqprcbfgsxwgjhmkehcoiwwltuxjzokamzpalobnfespcvmoecqigyuutueu\n",
"ywnvcnclsibreesigzhycyxwygsadugofxwsdlnqzlhnzhrvsrowfhmyzbxtyoxh\n",
"crgjulypijzhyypkqtxbibuoxhkagycauuqgchyaokulsbfbnsazfrkcgibxucwgwdalcelhuoqdi... | 1 | stdio |
Jack really likes his number five: the trick here is that you have to multiply each number by 5 raised to the number of digits of each numbers, so, for example:
```python
multiply(3)==15
multiply(10)==250
multiply(200)==25000
multiply(0)==0
multiply(-3)==-15
```
Write your solution by modifying this code:
```python
d... | [] | [] | 1 | stdio |
Chef Palin, as his name suggests, is always very interested in palindromic strings. Recently, he made a pretty interesting discovery on palindromes and that made him feel really Lucky. He came across something known as Lucky Palindromes. He defines a string as being a lucky palindrome if it is a palindrome containing t... | [
"3\nlaubcdkey\nluckycodechef\naaaaaaaa",
"3\nlaubcdkey\nlubkycodechef\naaaaaaaa",
"3\nlaubcdkey\nyubklcodechef\naaaaaaaa",
"3\nlatbcdkfy\nfeicedocljbux\naaaaaaba",
"3\nytkdadfbl\ntobjlcedechwf\naabaaaba",
"3\nytkdadfbl\ntobjlcfdechwf\naabaaaba",
"3\nytkdadlbf\ntobjlcfdechwf\naabaaaca",
"3\nytjdadlbf\n... | [
"luckykcul 8\nluckycocykcul 6\nunlucky",
"luckykcul 8\nluckycocykcul 7\nunlucky\n",
"luckykcul 8\nluckycocykcul 9\nunlucky\n",
"luckykcul 8\nfluckyoykculf 10\nunlucky\n",
"luckykcul 8\nfluckyeykculf 10\nunlucky\n",
"luckykcul 8\nfluckyfykculf 10\nunlucky\n",
"ykculucky 8\nfluckyfykculf 10\nunlucky\n",
... | 1 | stdio |
Create a function that takes a Roman numeral as its argument and returns its value as a numeric decimal integer. You don't need to validate the form of the Roman numeral.
Modern Roman numerals are written by expressing each decimal digit of the number to be encoded separately, starting with the leftmost digit and skip... | [] | [] | 1 | stdio |
There are N students in a school.
We will divide these students into some groups, and in each group they will discuss some themes.
You think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible.
Divide the... | [
"8\n",
"2\n",
"9\n",
"296\n",
"303\n",
"807\n",
"596\n",
"100\n",
"604\n",
"1000\n"
] | [
"2\n",
"0\n",
"3\n",
"98\n",
"101\n",
"269\n",
"198\n",
"33\n",
"201\n",
"333\n"
] | 1 | stdio |
Read problems statements in Russian here
Polo, the Penguin, has a lot of tests tomorrow at the university.
He knows that there are N different questions that will be on the tests. For each question i (i = 1..N), he knows C[i] - the number of tests that will contain this question, P[i] - the number of points that he wi... | [
"1\n3 7\n1 2 3\n2 3 5\n3 3 3",
"1\n3 7\n1 2 0\n2 3 5\n3 3 3",
"1\n3 7\n1 2 3\n2 3 5\n3 4 3",
"1\n3 7\n1 2 3\n2 3 5\n3 0 3",
"1\n3 7\n1 2 0\n2 3 10\n7 3 3",
"1\n3 7\n1 2 0\n2 3 8\n3 1 4",
"1\n3 7\n1 2 0\n2 2 10\n0 3 3",
"1\n3 12\n1 2 2\n4 3 5\n3 1 3",
"1\n3 7\n1 1 0\n2 3 5\n3 3 3",
"1\n3 7\n1 2 0\n... | [
"11",
"11\n",
"14\n",
"6\n",
"23\n",
"5\n",
"2\n",
"17\n",
"10\n",
"20\n"
] | 1 | stdio |
There are N computers and N sockets in a one-dimensional world. The coordinate of the i-th computer is a_i, and the coordinate of the i-th socket is b_i. It is guaranteed that these 2N coordinates are pairwise distinct.
Snuke wants to connect each computer to a socket using a cable. Each socket can be connected to onl... | [
"2\n0\n10\n20\n34",
"3\n3\n10\n8\n7\n0\n10",
"3\n3\n10\n8\n7\n0\n0",
"3\n3\n10\n8\n7\n2\n5",
"2\n0\n10\n20\n68",
"3\n3\n10\n8\n7\n1\n5",
"2\n1\n10\n20\n68",
"3\n3\n10\n8\n7\n0\n5",
"2\n0\n10\n20\n135",
"2\n0\n10\n20\n231"
] | [
"2\n",
"1\n",
"4\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n"
] | 1 | stdio |
You love coffee and want to know what beans you can afford to buy it.
The first argument to your search function will be a number which represents your budget.
The second argument will be an array of coffee bean prices.
Your 'search' function should return the stores that sell coffee within your budget.
The search... | [] | [] | 1 | stdio |
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer n will always result in 1. This problem is an unsolved problem, also k... | [
"3\n15\n0",
"3\n3\n0",
"3\n11\n0",
"3\n2\n0",
"3\n9\n0",
"3\n6\n0",
"3\n1\n0",
"3\n0\n0",
"3\n18\n0",
"3\n16\n0"
] | [
"7\n17\n",
"7\n7\n",
"7\n14\n",
"7\n1\n",
"7\n19\n",
"7\n8\n",
"7\n0\n",
"7\n",
"7\n20\n",
"7\n4\n"
] | 1 | stdio |
Baby is getting his frst tooth. This means more sleepless nights, but with the fun of feeling round his gums and trying to guess which will be first out!
Probably best have a sweepstake with your friends - because you have the best chance of knowing. You can feel the gums and see where the raised bits are - most rais... | [] | [] | 1 | stdio |
Takahashi is practicing shiritori alone again today.
Shiritori is a game as follows:
- In the first turn, a player announces any one word.
- In the subsequent turns, a player announces a word that satisfies the following conditions:
- That word is not announced before.
- The first character of that word is the same... | [
"4\nhoge\nenglish\nhoge\nenigma\n",
"9\nbasic\nc\ncpp\nphp\npython\nnadesico\nocaml\nlua\nassembly\n",
"8\na\naa\naaa\naaaa\naaaaa\naaaaaa\naaa\naaaaaaa\n",
"3\nabc\narc\nagc\n",
"100\nwzcitmdfbw\nziowcpggbu\nniopnjdjcw\nrixzquldia\nlwrdjmbhvk\ngysprovnzf\nrajessmyby\ncdqmsxsryd\nsoiktyfxjo\nmtwyskctdj\nfuv... | [
"No\n",
"Yes\n",
"No\n",
"No\n",
"No\n",
"Yes\n",
"No\n",
"No\n",
"No\n",
"No\n"
] | 1 | stdio |
The Little Elephant very much loves sums on intervals.
This time he has a pair of integers l and r (l ≤ r). The Little Elephant has to find the number of such integers x (l ≤ x ≤ r), that the first digit of integer x equals the last one (in decimal notation). For example, such numbers as 101, 477474 or 9 will be inclu... | [
"645762257531682046 885295120956158518\n",
"1 11\n",
"47 8545\n",
"10001 10000002\n",
"1827171 232817181719384635\n",
"9999999999999987 99999999999999711\n",
"819875140559301752 946247219812473271\n",
"2 3\n",
"522842183413115088 853628713003942530\n",
"235 236\n"
] | [
"23953286342447648\n",
"10\n",
"849\n",
"999001\n",
"23281718171755747\n",
"8999999999999973\n",
"12637207925317152\n",
"2\n",
"33078652959082744\n",
"0\n"
] | 1 | stdio |
Complete the function which takes two arguments and returns all numbers which are divisible by the given divisor. First argument is an array of `numbers` and the second is the `divisor`.
## Example
```python
divisible_by([1, 2, 3, 4, 5, 6], 2) == [2, 4, 6]
```
Write your solution by modifying this code:
```python
d... | [] | [] | 1 | stdio |
George woke up and saw the current time s on the digital clock. Besides, George knows that he has slept for time t.
Help George! Write a program that will, given time s and t, determine the time p when George went to bed. Note that George could have gone to bed yesterday relatively to the current time (see the second... | [
"05:50\n05:44\n",
"00:00\n01:00\n",
"00:01\n00:00\n",
"23:59\n23:59\n",
"23:44\n23:55\n",
"00:00\n13:12\n",
"12:00\n23:59\n",
"12:44\n12:44\n",
"05:55\n07:12\n",
"07:12\n05:55\n"
] | [
"00:06\n",
"23:00\n",
"00:01\n",
"00:00\n",
"23:49\n",
"10:48\n",
"12:01\n",
"00:00\n",
"22:43\n",
"01:17\n"
] | 1 | stdio |
You are given a permutation P_1 ... P_N of the set {1, 2, ..., N}.
You can apply the following operation to this permutation, any number of times (possibly zero):
* Choose two indices i,j (1 ≦ i < j ≦ N), such that j - i ≧ K and |P_i - P_j| = 1. Then, swap the values of P_i and P_j.
Among all permutations that can... | [
"4 4\n4 2 3 1",
"5 2\n5 4 3 2 1",
"4 1\n4 2 3 1",
"8 2\n4 5 7 8 3 1 2 6",
"4 2\n4 3 2 1",
"8 6\n4 5 7 8 3 1 2 6",
"8 5\n4 5 7 8 3 1 2 6",
"8 1\n4 5 7 8 3 1 2 6",
"8 4\n4 5 7 8 3 1 2 6",
"4 3\n4 1 3 2"
] | [
"4\n2\n3\n1\n",
"5\n4\n3\n2\n1\n",
"1\n2\n3\n4\n",
"1\n2\n3\n6\n5\n4\n7\n8\n",
"4\n3\n2\n1\n",
"4\n5\n7\n8\n3\n1\n2\n6\n",
"4\n5\n6\n8\n3\n1\n2\n7\n",
"1\n2\n3\n4\n5\n6\n7\n8\n",
"1\n5\n6\n7\n4\n2\n3\n8\n",
"4\n1\n3\n2\n"
] | 1 | stdio |
Iahub has drawn a set of n points in the cartesian plane which he calls "special points". A quadrilateral is a simple polygon without self-intersections with four sides (also called edges) and four vertices (also called corners). Please note that a quadrilateral doesn't have to be convex. A special quadrilateral is one... | [
"5\n0 0\n0 4\n4 0\n4 4\n2 3\n",
"10\n-6 -4\n-7 5\n-7 -7\n5 -7\n4 -9\n-6 7\n2 9\n-4 -6\n2 10\n-10 -4\n",
"4\n-3 3\n0 3\n-2 -1\n2 2\n",
"5\n-4 -3\n-3 -2\n3 3\n-1 2\n3 -3\n",
"6\n-4 -3\n-1 3\n0 0\n2 2\n2 1\n-3 1\n",
"7\n-2 -1\n4 3\n2 2\n-4 0\n-2 4\n0 0\n1 -3\n",
"4\n-874 606\n-996 -207\n897 847\n775 191\n"... | [
"16.000000",
"166.000000",
"11.000000",
"29.500000",
"15.000000",
"32.500000",
"1261820.500000",
"1129219.500000",
"2425414.000000",
"10.000000"
] | 1 | stdio |
Create a program that will return whether an input value is a str, int, float, or bool. Return the name of the value.
### Examples
- Input = 23 --> Output = int
- Input = 2.3 --> Output = float
- Input = "Hello" --> Output = str
- Input = True --> Output = bool
Write your solution by modifying this code:
```python
d... | [] | [] | 1 | stdio |
Problem
A graph is given in which N vertices, each numbered from 1 to N, are connected by N-1 undirected edges. For each vertex, output the shortest number of steps to start from that vertex and visit all vertices.
However, one step is to follow one side from one vertex and move to another vertex.
Constraints
* 2 ≤... | [
"6\n1 2\n2 3\n3 4\n3 5\n5 6",
"6\n1 2\n2 3\n6 4\n3 5\n5 6",
"6\n1 2\n2 3\n6 4\n3 4\n5 6",
"6\n1 2\n2 3\n3 4\n3 5\n1 6",
"6\n1 2\n1 3\n3 4\n3 5\n3 6",
"6\n1 2\n2 3\n3 4\n3 5\n2 6",
"6\n1 2\n2 5\n6 4\n3 4\n5 6",
"6\n1 2\n2 5\n6 4\n3 4\n2 6",
"6\n1 2\n2 5\n6 4\n3 4\n1 6",
"6\n1 2\n2 5\n6 4\n3 5\n5 6"... | [
"6\n7\n8\n7\n7\n6\n",
"5\n6\n7\n5\n7\n6\n",
"5\n6\n7\n7\n5\n6\n",
"7\n8\n7\n6\n6\n6\n",
"8\n7\n8\n7\n7\n7\n",
"7\n8\n8\n7\n7\n7\n",
"5\n6\n5\n6\n7\n7\n",
"6\n7\n6\n7\n6\n8\n",
"7\n6\n5\n6\n5\n7\n",
"6\n7\n7\n6\n8\n7\n"
] | 1 | stdio |
Given an array, return the reversed version of the array (a different kind of reverse though), you reverse portions of the array, you'll be given a length argument which represents the length of each portion you are to reverse.
E.g
if after reversing some portions of the array and the length of the remaining port... | [] | [] | 1 | stdio |
Ikta loves fast programs. Recently, I'm trying to speed up the division program. However, it doesn't get much faster, so I thought it would be better to make it faster only for "common sense and typical" inputs. The problem Ikta is trying to solve is as follows.
For a given non-negative integer n, divide p (n) − 1-dig... | [
"3",
"001",
"000",
"6",
"4",
"10",
"5",
"7",
"17",
"11"
] | [
"0\n",
"2\n",
"1\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n"
] | 1 | stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.