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 |
|---|---|---|---|---|
You are given an integer sequence $1, 2, \dots, n$. You have to divide it into two sets $A$ and $B$ in such a way that each element belongs to exactly one set and $|sum(A) - sum(B)|$ is minimum possible.
The value $|x|$ is the absolute value of $x$ and $sum(S)$ is the sum of elements of the set $S$.
-----Input-----
... | [
"3\n",
"5\n",
"6\n",
"2000000000\n",
"1999999999\n",
"1999999997\n",
"1999999998\n",
"1\n",
"69420\n",
"999999998\n"
] | [
"0\n",
"1\n",
"1\n",
"0\n",
"0\n",
"1\n",
"1\n",
"1\n",
"0\n",
"1\n"
] | 1 | stdio |
Andrew, Fedor and Alex are inventive guys. Now they invent the game with strings for two players.
Given a group of n non-empty strings. During the game two players build the word together, initially the word is empty. The players move in turns. On his step player must add a single letter in the end of the word, the re... | [
"5 2\nwelcome\nto\nthe\nmatrix\nneo\n",
"6 4\ndog\ncat\ncow\nhot\nice\nlol\n",
"4 1\naa\naba\nba\nbba\n",
"2 2\naba\naa\n",
"5 6\nabas\ndsfdf\nabacaba\ndartsidius\nkolobok\n",
"3 8\nso\nbad\ntest\n",
"3 3\naa\nabb\ncc\n",
"1 3\nab\n",
"4 2\naaaa\nbbbb\nccccc\ndumbavumba\n",
"3 3\nabasdfabab\nabaaa... | [
"First\n",
"Second\n",
"Second\n",
"Second\n",
"Second\n",
"First\n",
"Second\n",
"Second\n",
"First\n",
"Second\n"
] | 1 | stdio |
# Task
John has an important number, and he doesn't want others to see it.
He decided to encrypt the number, using the following steps:
```
His number is always a non strict increasing sequence
ie. "123"
He converted each digit into English words.
ie. "123"--> "ONETWOTHREE"
And then, rearrange the letters randomly.... | [] | [] | 1 | stdio |
-----Input-----
The only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.
-----Output-----
Output "Yes" or "No".
-----Examples-----
Input
373
Output
Yes
Input
121
Output
No
Input
436
Output
Yes | [
"373\n",
"121\n",
"436\n",
"7\n",
"8\n",
"4357087936\n",
"806975480\n",
"3333333333\n",
"90785\n",
"7467467\n"
] | [
"Yes\n",
"No\n",
"Yes\n",
"Yes\n",
"No\n",
"Yes\n",
"Yes\n",
"Yes\n",
"Yes\n",
"Yes\n"
] | 1 | stdio |
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya has two strings a and b of the same length n. The strings consist only of lucky digits. Pety... | [
"74747474\n77777777\n",
"44447777447744444777777747477444777444447744444\n47444747774774744474747744447744477747777777447\n",
"44447774444474477747774774477777474774744744477444447777477477744747477774744444744777777777747777477447744774744444747477744744\n7777747447747774777477777747447447744447477747774774777... | [
"4\n",
"13\n",
"37\n",
"3\n",
"12\n",
"14\n",
"14\n",
"1\n",
"6\n",
"4\n"
] | 1 | stdio |
The concept of "[smooth number](https://en.wikipedia.org/wiki/Smooth_number)" is applied to all those numbers whose prime factors are lesser than or equal to `7`: `60` is a smooth number (`2 * 2 * 3 * 5`), `111` is not (`3 * 37`).
More specifically, smooth numbers are classified by their highest prime factor and your ... | [] | [] | 1 | stdio |
You have to create a function named reverseIt.
Write your function so that in the case a string or a number is passed in as the data , you will return the data in reverse order. If the data is any other type, return it as it is.
Examples of inputs and subsequent outputs:
```
"Hello" -> "olleH"
"314159" -> "951413"
... | [] | [] | 1 | stdio |
You have a multiset containing several integers. Initially, it contains $a_1$ elements equal to $1$, $a_2$ elements equal to $2$, ..., $a_n$ elements equal to $n$.
You may apply two types of operations: choose two integers $l$ and $r$ ($l \le r$), then remove one occurrence of $l$, one occurrence of $l + 1$, ..., one... | [
"4\n1 4 1 1\n",
"5\n1 0 1 0 1\n",
"1\n1000000000\n",
"4\n3 3 3 3\n",
"4\n3 3 2 3\n",
"16\n1 1 2 3 3 4 5 6 6 6 4 3 2 1 1 1\n",
"1\n1\n",
"20\n1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2\n",
"1\n0\n",
"2\n0 1\n"
] | [
"2\n",
"3\n",
"1\n",
"3\n",
"4\n",
"6\n",
"1\n",
"11\n",
"0\n",
"1\n"
] | 1 | stdio |
Write a function that accepts two parameters, i) a string (containing a list of words) and ii) an integer (n). The function should alphabetize the list based on the nth letter of each word.
The letters should be compared case-insensitive. If both letters are the same, order them normally (lexicographically), again, c... | [] | [] | 1 | stdio |
You are given a string $s$, consisting of $n$ lowercase Latin letters.
A substring of string $s$ is a continuous segment of letters from $s$. For example, "defor" is a substring of "codeforces" and "fors" is not.
The length of the substring is the number of letters in it.
Let's call some string of length $n$ divers... | [
"10\ncodeforces\n",
"5\naaaaa\n",
"5\noomph\n",
"1\ng\n",
"2\nab\n",
"3\naab\n",
"3\nabb\n",
"7\naaabaaa\n",
"9\naabbccaab\n",
"2\naz\n"
] | [
"YES\nco\n",
"NO\n",
"YES\nom\n",
"NO\n",
"YES\nab\n",
"YES\nab\n",
"YES\nab\n",
"YES\nab\n",
"YES\nab\n",
"YES\naz\n"
] | 1 | stdio |
Not so long ago as a result of combat operations the main Berland place of interest — the magic clock — was damaged. The cannon's balls made several holes in the clock, that's why the residents are concerned about the repair. The magic clock can be represented as an infinite Cartesian plane, where the origin correspond... | [
"-12 -35\n",
"-215 -996\n",
"-96 -556\n",
"-1000 0\n",
"20 -21\n",
"0 0\n",
"207 -224\n",
"-668 970\n",
"-496 -644\n",
"253 -204\n"
] | [
"black\n",
"black\n",
"black\n",
"black\n",
"black\n",
"black\n",
"black\n",
"black\n",
"black\n",
"black\n"
] | 1 | stdio |
Write a simple function that takes polar coordinates (an angle in degrees and a radius) and returns the equivalent cartesian coordinates (rouded to 10 places).
```
For example:
coordinates(90,1)
=> (0.0, 1.0)
coordinates(45, 1)
=> (0.7071067812, 0.7071067812)
```
Write your solution by modifying this code:
```pyth... | [] | [] | 1 | stdio |
You are given a string s consisting of |s| small english letters.
In one move you can replace any character of this string to the next character in alphabetical order (a will be replaced with b, s will be replaced with t, etc.). You cannot replace letter z with any other letter.
Your target is to make some number of ... | [
"aacceeggiikkmmooqqssuuwwyy\n",
"thereisnoanswer\n",
"jqcfvsaveaixhioaaeephbmsmfcgdyawscpyioybkgxlcrhaxs\n",
"rtdacjpsjjmjdhcoprjhaenlwuvpfqzurnrswngmpnkdnunaendlpbfuylqgxtndhmhqgbsknsy\n",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n",
"abcdefghijklmnopqrstuvwxxx\n",
"abcdefghijklmnopqrstuvwxya\n",
... | [
"abcdefghijklmnopqrstuvwxyz\n",
"-1\n",
"-1\n",
"-1\n",
"abcdefghijklmnopqrstuvwxyzaaaaaaaaaaaaaaaaaa\n",
"abcdefghijklmnopqrstuvwxyz\n",
"abcdefghijklmnopqrstuvwxyz\n",
"abcdefghijklmnopqrstuvwxyz\n",
"cdabcdefghijklmnopqrstuvwxyzxyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\n",
"zazbcdefghijklmnopqrstuvwxy... | 1 | stdio |
Recently Ivan the Fool decided to become smarter and study the probability theory. He thinks that he understands the subject fairly well, and so he began to behave like he already got PhD in that area.
To prove his skills, Ivan decided to demonstrate his friends a concept of random picture. A picture is a field of $n$... | [
"2 3\n",
"1 2\n",
"1 1\n",
"2 1\n",
"1 3\n",
"3 1\n",
"2 5\n",
"3 6\n",
"2 2\n",
"1 100000\n"
] | [
"8\n",
"4\n",
"2\n",
"4\n",
"6\n",
"6\n",
"18\n",
"30\n",
"6\n",
"935236457\n"
] | 1 | stdio |
Everybody know that you passed to much time awake during night time...
Your task here is to define how much coffee you need to stay awake after your night.
You will have to complete a function that take an array of events in arguments, according to this list you will return the number of coffee you need to stay awake... | [] | [] | 1 | stdio |
Calendars in widespread use today include the Gregorian calendar, which is the de facto international standard, and is used almost everywhere in the world for civil purposes. The Gregorian reform modified the Julian calendar's scheme of leap years as follows:
Every year that is exactly divisible by four is a leap yea... | [
"1900:01:01\n2038:12:31\n",
"1996:03:09\n1991:11:12\n",
"1999:12:31\n2000:02:29\n",
"1903:09:27\n1988:06:15\n",
"1913:11:14\n1901:05:11\n",
"1915:01:01\n2007:07:01\n",
"1925:07:15\n2010:06:22\n",
"1935:10:08\n1923:01:07\n",
"1986:08:24\n1926:04:13\n",
"1932:11:18\n2028:09:25\n"
] | [
"50768\n",
"1579\n",
"60\n",
"30943\n",
"4570\n",
"33784\n",
"31023\n",
"4657\n",
"22048\n",
"35010\n"
] | 1 | stdio |
Mike and Joe are playing a game with some stones. Specifically, they have $n$ piles of stones of sizes $a_1, a_2, \ldots, a_n$. These piles are arranged in a circle.
The game goes as follows. Players take turns removing some positive number of stones from a pile in clockwise order starting from pile $1$. Formally, if ... | [
"2\n1\n37\n2\n100 100\n",
"1\n1\n1\n",
"1\n1\n1000000000\n",
"1\n50\n260939408 52936453 298470524 981491199 699765 834662291 553329721 651730905 665925345 395625534 162042985 788733611 54572656 795877605 826562363 882540598 190947839 644851021 335204703 226590818 150893107 902210973 547195018 694426040 952704... | [
"Mike\nJoe\n",
"Mike\n",
"Mike\n",
"Joe\n",
"Mike\n"
] | 1 | stdio |
Problem
Given a natural number N less than or equal to 12, find the smallest natural number such that the number of divisors is exactly N.
Constraints
* 1 ≤ N ≤ 12
Input
One natural number N is given in one line.
Output
Output the smallest natural number on a line so that the number of divisors is exactly N.
Ex... | [
"5",
"4",
"6",
"11",
"8",
"7",
"10",
"9",
"12",
"001"
] | [
"16\n",
"6\n",
"12\n",
"1024\n",
"24\n",
"64\n",
"48\n",
"36\n",
"60\n",
"1\n"
] | 1 | stdio |
A rabbit is playing a role-playing game. Just before entering the castle, he was ambushed by an enemy!
It was a battle between one hero operated by a rabbit and n enemies. Each character has four stats, health hi, attack power ai, defense power di, and agility si. I = 0 is the information of the main character, 1 ≤ i ... | [
"1\n1 0 1 1\n10000 10000 10000 10000",
"2\n10 3 1 2\n2 4 1 3\n1 2 1 1",
"2\n10 3 1 2\n2 4 1 3\n1 3 1 1",
"2\n10 3 1 2\n3 4 1 3\n1 3 1 1",
"2\n10 3 2 2\n3 4 1 3\n1 3 1 1",
"1\n1 0 1 1\n10000 10010 10000 10000",
"1\n1 0 1 1\n10000 10010 10000 10100",
"1\n1 0 1 1\n10000 10010 10000 10101",
"1\n1 0 1 1\... | [
"-1\n",
"4\n",
"5\n",
"9\n",
"6\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n"
] | 1 | stdio |
There are N persons called Person 1 through Person N.
You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times.
If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts.
Takah... | [
"5 3\n1 2\n3 4\n5 1\n",
"4 10\n1 2\n2 1\n1 2\n2 1\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n",
"10 4\n3 1\n4 1\n5 9\n2 6\n",
"10 4\n3 1\n3 1\n5 9\n2 6",
"4 10\n1 1\n2 1\n1 2\n2 1\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4",
"2 0\n1 1\n2 1\n1 6\n2 1\n1 2\n1 3\n1 4\n3 3\n2 4\n4 4",
"10 4\n6 1\n3 1\n5 6\n2 6",
"5 2\n1 4\n3 4\n3... | [
"3\n",
"4\n",
"3\n",
"2\n",
"4\n",
"1\n",
"5\n",
"3\n",
"4\n",
"4\n"
] | 1 | stdio |
Soma is a fashionable girl. She absolutely loves shiny stones that she can put on as jewellery accessories. She has been collecting stones since her childhood - now she has become really good with identifying which ones are fake and which ones are not. Her King requested for her help in mining precious stones, so she ... | [
"4\nabc\nabcdef\naA\nabAZ\naaa\na\nwhat\nnone",
"4\nacb\nabcdef\naA\nabAZ\naaa\na\nwhat\nnone",
"4\nacb\nabcdef\nAa\nabZA\naaa\n`\nwhat\nnone",
"4\naca\nebcdaf\naA\nAbZa\n`aa\n`\nswha\nnomf",
"4\nac`\nebcdae\naA\nAbZa\n`aa\n_\nsvha\nnome",
"4\nac`\nebcdae\naA\nAbZ`\n`aa\n_\nsvha\nemon",
"4\n`ca\neacdae\... | [
"3\n2\n1\n0",
"3\n2\n1\n0\n",
"3\n2\n0\n0\n",
"2\n2\n1\n0\n",
"2\n2\n0\n0\n",
"2\n1\n0\n0\n",
"3\n1\n0\n0\n",
"3\n0\n0\n0\n",
"2\n0\n0\n0\n",
"1\n1\n0\n0\n"
] | 1 | stdio |
In a public bath, there is a shower which emits water for T seconds when the switch is pushed.
If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds.
Note that it does not mean that the shower emits water for T additional seconds.
N people will push ... | [
"2 4\n0 3\n",
"2 4\n0 5\n",
"4 1000000000\n0 1000 1000000 1000000000\n",
"1 1\n0\n",
"9 10\n0 3 5 7 100 110 200 300 311\n"
] | [
"7\n",
"8\n",
"2000000000\n",
"1\n",
"67\n"
] | 1 | stdio |
You are given matrix with n rows and n columns filled with zeroes. You should put k ones in it in such a way that the resulting matrix is symmetrical with respect to the main diagonal (the diagonal that goes from the top left to the bottom right corner) and is lexicographically maximal.
One matrix is lexicographically... | [
"2 1\n",
"3 2\n",
"2 5\n",
"1 0\n",
"1 1\n",
"20 401\n",
"100 10001\n",
"2 3\n",
"4 5\n",
"5 6\n"
] | [
"1 0 \n0 0 \n",
"1 0 0 \n0 1 0 \n0 0 0 \n",
"-1\n",
"0 \n",
"1 \n",
"-1\n",
"-1\n",
"1 1 \n1 0 \n",
"1 1 1 0 \n1 0 0 0 \n1 0 0 0 \n0 0 0 0 \n",
"1 1 1 0 0 \n1 1 0 0 0 \n1 0 0 0 0 \n0 0 0 0 0 \n0 0 0 0 0 \n"
] | 1 | stdio |
Polycarpus is an amateur businessman. Recently he was surprised to find out that the market for paper scissors is completely free! Without further ado, Polycarpus decided to start producing and selling such scissors.
Polycaprus calculated that the optimal celling price for such scissors would be p bourles. However, he... | [
"393776794010351632 4138311260892\n",
"559198116944738707 0\n",
"159171676706847083 28512592184962\n",
"199 198\n",
"20 1\n",
"621306590487786841 47851896849379\n",
"925835698451819219 232827103605000\n",
"559198116944738707 8\n",
"234522568185994645 14536016333590\n",
"559198116944738999 1\n"
] | [
"393775999999999999\n",
"559198116944738707\n",
"159169999999999999\n",
"199\n",
"19\n",
"621299999999999999\n",
"925799999999999999\n",
"559198116944738699\n",
"234519999999999999\n",
"559198116944738999\n"
] | 1 | stdio |
Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of Mysterious Light.
Three mirrors of length N are set so that they form an equilateral triangle. Let the vertices of the triangle be a, b and c.
Inside the triangle, the rifle is placed at the point p on segment ab such that ap ... | [
"5 4",
"7 4",
"6 1",
"9 4",
"6 3",
"14 4",
"8 1",
"28 4",
"15 2",
"28 3"
] | [
"12\n",
"18\n",
"15\n",
"24\n",
"9\n",
"36\n",
"21\n",
"72\n",
"42\n",
"81\n"
] | 1 | stdio |
Let us define the oddness of a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n} as \sum_{i = 1}^n |i - p_i|.
Find the number of permutations of {1,\ 2,\ ...,\ n} of oddness k, modulo 10^9+7.
-----Constraints-----
- All values in input are integers.
- 1 \leq n \leq 50
- 0 \leq k \leq n^2
-----Input-----... | [
"3 2\n",
"39 14\n",
"44 350\n",
"22 444\n",
"1 0\n",
"34 712\n",
"10 82\n",
"17 222\n",
"40 1062\n",
"38 716\n"
] | [
"2\n",
"74764168\n",
"15060087\n",
"0\n",
"1\n",
"0\n",
"0\n",
"0\n",
"0\n",
"810790165\n"
] | 1 | stdio |
Given a string, return the minimal number of parenthesis reversals needed to make balanced parenthesis.
For example:
```Javascript
solve(")(") = 2 Because we need to reverse ")" to "(" and "(" to ")". These are 2 reversals.
solve("(((())") = 1 We need to reverse just one "(" parenthesis to make it balanced.
solve("(... | [] | [] | 1 | stdio |
Let w be a string consisting of lowercase letters.
We will call w beautiful if the following condition is satisfied:
- Each lowercase letter of the English alphabet occurs even number of times in w.
You are given the string w. Determine if w is beautiful.
-----Constraints-----
- 1 \leq |w| \leq 100
- w consists of ... | [
"abaccaba\n",
"hthth\n",
"ab`ccaba",
"ab`cc`ba",
"hthtg",
"hghtt",
"`b`cc`ba",
"hgtth",
"ab`cc`b`",
"hgtuh"
] | [
"Yes\n",
"No\n",
"No\n",
"Yes\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n"
] | 1 | stdio |
Sam is an avid collector of numbers. Every time he finds a new number he throws it on the top of his number-pile. Help Sam organise his collection so he can take it to the International Number Collectors Conference in Cologne.
Given an array of numbers, your function should return an array of arrays, where each subar... | [] | [] | 1 | stdio |
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int... | [
"0 0\n0 1\n0 2\n1 0\n1 2\n2 0\n2 1\n2 2\n",
"0 0\n1 0\n2 0\n3 0\n4 0\n5 0\n6 0\n7 0\n",
"1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n",
"0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n",
"1000000 1000000\n1000000 999999\n1000000 999998\n999999 1000000\n999999 999998\n999998 1000000\n999998 999999\n999998 999998\n",
... | [
"respectable\n",
"ugly\n",
"ugly\n",
"ugly\n",
"respectable\n",
"ugly\n",
"ugly\n",
"ugly\n",
"ugly\n",
"ugly\n"
] | 1 | stdio |
Consider some square matrix A with side n consisting of zeros and ones. There are n rows numbered from 1 to n from top to bottom and n columns numbered from 1 to n from left to right in this matrix. We'll denote the element of the matrix which is located at the intersection of the i-row and the j-th column as Ai, j.
L... | [
"61\n",
"13\n",
"38\n",
"98\n",
"84\n",
"43\n",
"60\n",
"53\n",
"10\n",
"12\n"
] | [
"11",
"5",
"9",
"15",
"13",
"11",
"11",
"11",
"5",
"5"
] | 1 | stdio |
Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.
Circle inside a rectangle
Cons... | [
"2 4 2 2 1",
"2 8 2 0 0",
"5 4 2 0 1",
"2 4 2 2 2",
"5 8 2 0 1",
"2 6 2 2 2",
"2 8 2 0 1",
"3 6 2 2 2",
"0 6 2 2 2",
"2 8 1 0 0"
] | [
"No\n",
"Yes\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"Yes\n"
] | 1 | stdio |
Please find the greatest common divisor of two natural numbers. A clue is: The Euclid's algorithm is a way to resolve this task.
Input
The input file consists of several lines with pairs of two natural numbers in each line. The numbers do not exceed 100000.
The number of pairs (datasets) is less than 50.
Output
... | [
"57 38\n19 84",
"57 38\n6 84",
"101 38\n6 84",
"101 47\n6 88",
"100 47\n11 88",
"57 18\n19 84",
"101 47\n6 37",
"101 47\n6 21",
"100 38\n10 84",
"100 88\n6 169"
] | [
"19\n1\n",
"19\n6\n",
"1\n6\n",
"1\n2\n",
"1\n11\n",
"3\n1\n",
"1\n1\n",
"1\n3\n",
"2\n2\n",
"4\n1\n"
] | 1 | stdio |
Given a non-negative integer, return an array / a list of the individual digits in order.
Examples:
```
123 => [1,2,3]
1 => [1]
8675309 => [8,6,7,5,3,0,9]
```
Write your solution by modifying this code:
```python
def digitize(n):
```
Your solution should implemented in the function "digitize". The inputs will ... | [] | [] | 1 | stdio |
Given two arrays of integers `m` and `n`, test if they contain *at least* one identical element. Return `true` if they do; `false` if not.
Your code must handle any value within the range of a 32-bit integer, and must be capable of handling either array being empty (which is a `false` result, as there are no duplicate... | [] | [] | 1 | stdio |
Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively.
An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to m... | [
"3 4 9 0\n",
"3 4 10 40\n",
"1 1 2 11\n",
"1000 1000 2 11\n",
"1000 1000 6 1\n",
"114 514 6 0\n",
"364 364 2 0\n",
"889 464 0 0\n",
"889 464 0 1\n",
"911 311 0 30\n"
] | [
"5.00000000000000000000\n",
"4.56425719433005567605\n",
"0.00872661856949313926\n",
"8.72661856949313604736\n",
"1997.69677296990135817456\n",
"628.00000000000000000000\n",
"364.00000000000000000000\n",
"425.00000000000000000000\n",
"429.44510652313227103138\n",
"1214.07419133267561284217\n"
] | 1 | stdio |
Deoxyribonucleic acid (DNA) is a chemical found in the nucleus of cells and carries the "instructions" for the development and functioning of living organisms.
If you want to know more http://en.wikipedia.org/wiki/DNA
In DNA strings, symbols "A" and "T" are complements of each other, as "C" and "G".
You have functio... | [] | [] | 1 | stdio |
There is a square in the xy-plane. The coordinates of its four vertices are (x_1,y_1),(x_2,y_2),(x_3,y_3) and (x_4,y_4) in counter-clockwise order.
(Assume that the positive x-axis points right, and the positive y-axis points up.)
Takahashi remembers (x_1,y_1) and (x_2,y_2), but he has forgot (x_3,y_3) and (x_4,y_4).
G... | [
"0 0 0 1\n",
"2 3 6 6\n",
"31 -41 -59 26\n",
"0 1 1 0\n",
"0 -100 -100 100\n",
"100 100 99 100\n",
"100 100 100 99\n",
"67 -89 -90 -11\n",
"-100 100 100 -100\n",
"99 77 55 -99\n"
] | [
"-1 1 -1 0\n",
"3 10 -1 7\n",
"-126 -64 -36 -131\n",
"2 1 1 2\n",
"-300 0 -200 -200\n",
"99 99 100 99\n",
"101 99 101 100\n",
"-168 -168 -11 -246\n",
"300 100 100 300\n",
"231 -143 275 33\n"
] | 1 | stdio |
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied:
* For each i = 1,2,..., n-2, a_i = a_{i+2}.
* Exactly two different numbers appear in the sequence.
You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing s... | [
"4\n3 2 3 2",
"6\n105 119 204 119 105 119",
"4\n4 1 3 2",
"6\n105 120 54 119 105 78",
"6\n105 120 54 119 190 78",
"6\n105 119 204 119 105 78",
"4\n4 1 3 0",
"6\n105 119 54 119 105 78",
"4\n4 1 3 1",
"4\n4 1 6 1"
] | [
"0\n",
"1\n",
"2\n",
"3\n",
"4\n",
"2\n",
"2\n",
"2\n",
"1\n",
"1\n"
] | 1 | stdio |
Write a function that takes an integer and returns an array `[A, B, C]`, where `A` is the number of multiples of 3 (but not 5) below the given integer, `B` is the number of multiples of 5 (but not 3) below the given integer and `C` is the number of multiples of 3 and 5 below the given integer.
For example, `solution(... | [] | [] | 1 | stdio |
You probably know the 42 number as "The answer to life, the universe and everything" according to Douglas Adams' "The Hitchhiker's Guide to the Galaxy". For Freud, the answer was quite different.
In the society he lived in, people-women in particular- had to repress their sexual needs and desires. This was simply how ... | [] | [] | 1 | stdio |
Little boy Petya loves stairs very much. But he is bored from simple going up and down them — he loves jumping over several stairs at a time. As he stands on some stair, he can either jump to the next one or jump over one or two stairs at a time. But some stairs are too dirty and Petya doesn't want to step on them.
No... | [
"10 5\n2 4 8 3 6\n",
"10 5\n2 4 5 7 9\n",
"10 9\n2 3 4 5 6 7 8 9 10\n",
"5 2\n4 5\n",
"123 13\n36 73 111 2 92 5 47 55 48 113 7 78 37\n",
"10 10\n7 6 4 2 5 10 8 3 9 1\n",
"12312 0\n",
"9817239 1\n6323187\n",
"1 1\n1\n",
"5 4\n4 2 5 1\n"
] | [
"NO",
"YES",
"NO",
"NO",
"YES",
"NO",
"YES",
"YES",
"NO",
"NO"
] | 1 | stdio |
Hiking club "Up the hill" just returned from a walk. Now they are trying to remember which hills they've just walked through.
It is known that there were N stops, all on different integer heights between 1 and N kilometers (inclusive) above the sea level. On the first day they've traveled from the first stop to the se... | [
"0\n1\n",
"2\n1\n",
"0\n3\n",
"1\n1\n",
"3\n7\n",
"37\n29\n",
"1\n0\n",
"0\n1\n",
"0\n0\n",
"2\n0\n"
] | [
"2 1 \n",
"2 3 4 1 \n",
"4 3 2 1 \n",
"2 3 1 \n",
"8 9 10 11 7 6 5 4 3 2 1 \n",
"30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 \n",
"1 2 \n",
"2 1 \n",
"1... | 1 | stdio |
Given three distinct integers $a$, $b$, and $c$, find the medium number between all of them.
The medium number is the number that is neither the minimum nor the maximum of the given three numbers.
For example, the median of $5,2,6$ is $5$, since the minimum is $2$ and the maximum is $6$.
-----Input-----
The first ... | [
"9\n5 2 6\n14 3 4\n20 2 1\n1 2 3\n11 19 12\n10 8 20\n6 20 3\n4 1 3\n19 8 4\n",
"1\n1 3 2\n",
"2\n1 2 3\n2 3 1\n",
"3\n1 2 3\n1 2 3\n1 2 3\n",
"4\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n",
"5\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n",
"6\n1 2 3\n1 3 2\n2 1 3\n2 3 1\n3 1 2\n3 2 1\n",
"7\n1 2 3\n1 3 2\n2 1 3\n2 3 1\n3 ... | [
"5\n4\n2\n2\n12\n10\n6\n3\n8\n",
"2\n",
"2\n2\n",
"2\n2\n2\n",
"2\n2\n2\n2\n",
"2\n2\n2\n2\n2\n",
"2\n2\n2\n2\n2\n2\n",
"2\n2\n2\n2\n2\n2\n7\n",
"2\n2\n2\n2\n2\n2\n7\n2\n",
"2\n2\n2\n2\n2\n2\n7\n2\n7\n2\n"
] | 1 | stdio |
Polycarp plays "Game 23". Initially he has a number $n$ and his goal is to transform it to $m$. In one move, he can multiply $n$ by $2$ or multiply $n$ by $3$. He can perform any number of moves.
Print the number of moves needed to transform $n$ to $m$. Print -1 if it is impossible to do so.
It is easy to prove that ... | [
"120 51840\n",
"42 42\n",
"48 72\n",
"1 1\n",
"1 2\n",
"1 4\n",
"1 5\n",
"1 6\n",
"3024 94058496\n",
"1953125 500000000\n"
] | [
"7\n",
"0\n",
"-1\n",
"0\n",
"1\n",
"2\n",
"-1\n",
"2\n",
"12\n",
"8\n"
] | 1 | stdio |
Are you fond of collecting some kind of stuff? Mike is crazy about collecting stamps. He is an active member of Stamp Collecting Сommunity(SCC).
SCC consists of N members which are fond of philately. A few days ago Mike argued with the others from SCC. Mike told them that all stamps of the members could be divided in... | [
"5\n7 4 1 1 2\n\n\n",
"5\n1 1 1 1 1\n\n\n",
"5\n13 4 1 1 2",
"5\n13 1 1 1 -1",
"5\n1 1 1 1 0",
"5\n13 4 1 1 0",
"5\n1 2 1 1 0",
"5\n13 1 1 1 0",
"5\n0 2 1 1 0",
"5\n0 3 1 1 0"
] | [
"YES\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n"
] | 1 | stdio |
Example
Input
anagram
grandmother
Output
4 | [
"anagram\ngrandmosher",
"anbgram\ngrandmosher",
"anbfram\ngrandmosher",
"narfamb\nreoahmodsrg",
"nbgaqnb\ntohtheodscl",
"anagram\ngrandlother",
"anagram\nrehtoldnarg",
"anagram\nsehtoldnarg",
"anbfram\ngrandmhsoer",
"anagram\nsehtolndarg"
] | [
"4\n",
"3\n",
"2\n",
"1\n",
"0\n",
"4\n",
"4\n",
"4\n",
"2\n",
"3\n"
] | 1 | stdio |
Introduction
Mr. Safety loves numeric locks and his Nokia 3310. He locked almost everything in his house. He is so smart and he doesn't need to remember the combinations. He has an algorithm to generate new passcodes on his Nokia cell phone.
Task
Can you crack his numeric locks? Mr. Safety's treasures wait for ... | [] | [] | 1 | stdio |
Background
There is a message that is circulating via public media that claims a reader can easily read a message where the inner letters of each words is scrambled, as long as the first and last letters remain the same and the word contains all the letters.
Another example shows that it is quite difficult to read the... | [] | [] | 1 | stdio |
You are given two positive integer numbers a and b. Permute (change order) of the digits of a to construct maximal number not exceeding b. No number in input and/or output can start with the digit 0.
It is allowed to leave a as it is.
-----Input-----
The first line contains integer a (1 ≤ a ≤ 10^18). The second lin... | [
"123\n222\n",
"3921\n10000\n",
"4940\n5000\n",
"23923472834\n23589234723\n",
"102391019\n491010301\n",
"123456789123456789\n276193619183618162\n",
"1000000000000000000\n1000000000000000000\n",
"1\n1000000000000000000\n",
"999999999999999999\n1000000000000000000\n",
"2475345634895\n3455834583479\n"... | [
"213\n",
"9321\n",
"4940\n",
"23498743322\n",
"399211100\n",
"276193618987554432\n",
"1000000000000000000\n",
"1\n",
"999999999999999999\n",
"3455834579642\n"
] | 1 | stdio |
A certain type of steel is graded according to the following conditions.
1. Hardness of the steel must be greater than 50
2. Carbon content of the steel must be less than 0.7
3. Tensile strength must be greater than 5600
The grades awarded are as follows:
Grade is 10 if all three conditions are met
Grade is 9 if cond... | [
"3 \n53 0.6 5602\n45 0 4500\n0 0 0 \n",
"3 \n67 0.6 5602\n45 0 4500\n0 0 0",
"3 \n67 0.6 5602\n78 0 4500\n0 0 0",
"3 \n74 0.7029782275732623 13440\n78 -1 4466\n0 -1 0",
"3 \n127 1.5460478864469624 13440\n71 -1 8462\n1 -1 0",
"3 \n127 1.5460478864469624 13440\n16 -1 8462\n1 -1 0",
"3 \n000 4.094246707215... | [
"10\n6\n6\n",
"10\n6\n6\n",
"10\n9\n6\n",
"7\n9\n6\n",
"7\n10\n6\n",
"7\n8\n6\n",
"6\n8\n6\n",
"6\n6\n6\n",
"7\n6\n6\n",
"6\n5\n6\n"
] | 1 | stdio |
Natsuki and her friends were taken to the space by an alien and made friends with a lot of aliens. During the space travel, she discovered that aliens’ hands were often very different from humans’. Generally speaking, in a kind of aliens, there are N fingers and M bend rules on a hand. Each bend rule describes that a f... | [
"6 0",
"5 5\n1 2\n2 3\n3 1\n4 5\n5 1",
"7 0",
"6 4\n2 3\n3 4\n4 3\n5 4",
"4 0",
"8 0",
"1 0",
"11 0",
"13 0",
"6 4\n2 3\n3 5\n4 3\n5 4"
] | [
"64\n",
"4\n",
"128\n",
"20\n",
"16\n",
"256\n",
"2\n",
"2048\n",
"8192\n",
"12\n"
] | 1 | stdio |
In order to celebrate Twice's 5th anniversary, Tzuyu and Sana decided to play a game.
Tzuyu gave Sana two integers $a$ and $b$ and a really important quest.
In order to complete the quest, Sana has to output the smallest possible value of ($a \oplus x$) + ($b \oplus x$) for any given $x$, where $\oplus$ denotes the b... | [
"6\n6 12\n4 9\n59 832\n28 14\n4925 2912\n1 1\n",
"6\n6 12\n4 9\n59 832\n28 14\n4925 2912\n2 1\n",
"6\n6 12\n4 5\n59 832\n28 14\n4925 2912\n2 1\n",
"6\n6 12\n4 2\n59 832\n28 14\n4925 2912\n2 1\n",
"6\n6 12\n4 2\n90 832\n28 14\n4925 2912\n2 1\n",
"6\n6 12\n4 2\n90 832\n28 8\n4925 2912\n2 1\n",
"6\n6 12\n4... | [
"10\n13\n891\n18\n6237\n0\n",
"10\n13\n891\n18\n6237\n3\n",
"10\n1\n891\n18\n6237\n3\n",
"10\n6\n891\n18\n6237\n3\n",
"10\n6\n794\n18\n6237\n3\n",
"10\n6\n794\n20\n6237\n3\n",
"10\n7\n794\n20\n6237\n3\n",
"10\n7\n794\n20\n6237\n2\n",
"10\n7\n794\n20\n6237\n1\n",
"10\n7\n794\n20\n6237\n4\n"
] | 1 | stdio |
##Task:
You have to write a function **pattern** which creates the following pattern upto n number of rows. *If the Argument is 0 or a Negative Integer then it should return "" i.e. empty string.*
##Examples:
pattern(4):
1234
234
34
4
pattern(6):
123456
23456
3456
456
5... | [] | [] | 1 | stdio |
Create a function with two arguments that will return an array of the first (n) multiples of (x).
Assume both the given number and the number of times to count will be positive numbers greater than 0.
Return the results as an array (or list in Python, Haskell or Elixir).
Examples:
```python
count_by(1,10) #should... | [] | [] | 1 | stdio |
Given the number pledged for a year, current value and name of the month, return string that gives information about the challenge status:
- ahead of schedule
- behind schedule
- on track
- challenge is completed
Examples:
`(12, 1, "February")` - should return `"You are on track."`
`(12, 1, "March")` - should retur... | [] | [] | 1 | stdio |
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya loves long lucky numbers very much. He is interested in the minimum lucky number d that meet... | [
"1 10 1 2\n",
"2 1 3 1\n",
"4 7 2 1\n",
"1 4 1 1\n",
"45 65 31 32\n",
"1 1000000 4 5\n",
"25 94 11 12\n",
"7 1000 1 2\n",
"70 60 20 21\n",
"69 84 25 24\n"
] | [
"-1\n",
"-1\n",
"44474777777\n",
"74777\n",
"74444444444444474747474747474747474747474747474747474747474747474747474747477777777777777777777777777777777774\n",
"-1\n",
"74444444444444474747474747474747474777777777777777777777777777777777777777777777777777777777777777777777777777777777774\n",
"74444447... | 1 | stdio |
It's been a tough week at work and you are stuggling to get out of bed in the morning.
While waiting at the bus stop you realise that if you could time your arrival to the nearest minute you could get valuable extra minutes in bed.
There is a bus that goes to your office every 15 minute, the first bus is at `06:00`, ... | [] | [] | 1 | stdio |
## Your Job
Find the sum of all multiples of `n` below `m`
## Keep in Mind
* `n` and `m` are natural numbers (positive integers)
* `m` is **excluded** from the multiples
## Examples
Write your solution by modifying this code:
```python
def sum_mul(n, m):
```
Your solution should implemented in... | [] | [] | 1 | stdio |
There is Kannon-do in the mountain behind Ichiro's house. There are 30 steps from the foot to this Kannon-do, and Ichiro goes to Kannon-do almost every day. Ichiro can go up the stairs up to 3 steps with one foot. While playing, I noticed that there are so many types of stair climbing (the number of steps to skip).
So... | [
"1\n10\n14\n25\n0",
"1\n10\n14\n23\n0",
"1\n10\n14\n6\n0",
"1\n1\n20\n25\n0",
"1\n10\n14\n24\n0",
"1\n10\n0\n25\n0",
"1\n19\n14\n5\n0",
"1\n18\n0\n25\n0",
"1\n18\n1\n25\n0",
"1\n0\n14\n6\n0"
] | [
"1\n1\n1\n701\n",
"1\n1\n1\n207\n",
"1\n1\n1\n1\n",
"1\n1\n34\n701\n",
"1\n1\n1\n381\n",
"1\n1\n",
"1\n19\n1\n1\n",
"1\n10\n",
"1\n10\n1\n701\n",
"1\n"
] | 1 | stdio |
Problem
Find the angle between the two given angles θ1 and θ2. Here, the angle between them is defined as "θ1 & plus; t'when t'is the one with the smallest absolute value among the t satisfying θ1 & plus; t = θ2 − t" as shown in the figure below.
A image of angles
Constraints
The input satisfies the following condi... | [
"20\n594",
"10\n26",
"20\n704",
"10\n27",
"20\n41",
"10\n15",
"20\n2",
"10\n29",
"20\n0",
"10\n52"
] | [
"127.0000000000\n",
"18.0000000000\n",
"182.0000000000\n",
"18.5000000000\n",
"30.5000000000\n",
"12.5000000000\n",
"11.0000000000\n",
"19.5000000000\n",
"10.0000000000\n",
"31.0000000000\n"
] | 1 | stdio |
Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.)
We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base.
When ... | [
"2 2 4\n",
"12 21 10\n",
"3 1 8\n",
"100 100 1000000\n",
"100 100 1\n",
"22 75 24126\n",
"45 72 83481\n",
"47 29 44734\n",
"2 75 25\n",
"82 84 416241\n"
] | [
"45.0000000000\n",
"89.7834636934\n",
"4.2363947991\n",
"0.0000000000\n",
"89.9998854084\n",
"66.3790171829\n",
"53.8288157430\n",
"20.4206366709\n",
"89.7453537677\n",
"28.3216596827\n"
] | 1 | stdio |
# altERnaTIng cAsE <=> ALTerNAtiNG CaSe
Define `String.prototype.toAlternatingCase` (or a similar function/method *such as* `to_alternating_case`/`toAlternatingCase`/`ToAlternatingCase` in your selected language; **see the initial solution for details**) such that each lowercase letter becomes uppercase and each upper... | [] | [] | 1 | stdio |
The goal of this Kata is to reduce the passed integer to a single digit (if not already) by converting the number to binary, taking the sum of the binary digits, and if that sum is not a single digit then repeat the process.
- n will be an integer such that 0 < n < 10^20
- If the passed integer is already a single dig... | [] | [] | 1 | stdio |
In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019.
Integers M_1, D_1, M_2, and D_2 will be given as input.
It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1.
Determine whether the date 2019-M_1-D_1 is the last day of a month.
Constraints
* Both 2019-M_1-D_1 and 20... | [
"11 30\n6 1",
"11 17\n11 17",
"6 30\n12 1",
"11 16\n11 28",
"11 24\n11 28",
"11 30\n18 1",
"11 8\n11 28",
"11 8\n11 17",
"11 16\n11 31",
"11 30\n35 1"
] | [
"1\n",
"0\n",
"1\n",
"0\n",
"0\n",
"1\n",
"0\n",
"0\n",
"0\n",
"1\n"
] | 1 | stdio |
Are you going to Scarborough Fair?
Parsley, sage, rosemary and thyme.
Remember me to one who lives there.
He once was the true love of mine.
Willem is taking the girl to the highest building in island No.28, however, neither of them knows how to get there.
Willem asks his friend, Grick for directions, Grick helped... | [
"3 1\nioi\n1 1 i n\n",
"5 3\nwxhak\n3 3 h x\n1 5 x a\n1 3 w g\n",
"9 51\nbhfbdcgff\n2 3 b b\n2 8 e f\n3 8 g f\n5 7 d a\n1 5 e b\n3 4 g b\n6 7 c d\n3 6 e g\n3 6 e h\n5 6 a e\n7 9 a c\n4 9 a h\n3 7 c b\n6 9 b g\n1 7 h b\n4 5 a e\n3 9 f a\n1 2 c h\n4 8 a c\n3 5 e d\n3 4 g f\n2 3 d h\n2 3 d e\n1 7 d g\n2 6 e g\n2 3... | [
"noi",
"gaaak",
"aahaddddh",
"fcbbajjfjaaefefehfahfagggfha",
"nfinedeohadjmgafnaogemfjmjfncnliagfchjfcmellgigddckkdekkddlchdcecljdeblmheimkibkgdkcdml",
"acebb",
"bcaaaaaaccacddcdaacddaaddcdbdddccdccddddddbdddddcdddcdddccdddcdcdcdcccdcddcdcdcddcdcdcdcdcdbcd",
"accccccccaaaaaaaaaaaaaaaaaaacccccccccccccc... | 1 | stdio |
You will be given an integer a and a string s consisting of lowercase English letters as input.
Write a program that prints s if a is not less than 3200 and prints red if a is less than 3200.
-----Constraints-----
- 2800 \leq a < 5000
- s is a string of length between 1 and 10 (inclusive).
- Each character of s is ... | [
"3200\npink\n",
"3199\npink\n",
"4049\nred\n",
"2800\na\n",
"4999\nzzzzzzzzzz\n",
"2999\nwhite\n",
"3201\npurple\n",
"3198\nred\n",
"4998\nrainbow\n",
"4049\nrdd"
] | [
"pink\n",
"red\n",
"red\n",
"red\n",
"zzzzzzzzzz\n",
"red\n",
"purple\n",
"red\n",
"rainbow\n",
"rdd\n"
] | 1 | stdio |
**An [isogram](https://en.wikipedia.org/wiki/Isogram)** (also known as a "nonpattern word") is a logological term for a word or phrase without a repeating letter. It is also used by some to mean a word or phrase in which each letter appears the same number of times, not necessarily just once.
You task is to write a me... | [] | [] | 1 | stdio |
The numbers of all offices in the new building of the Tax Office of IT City will have lucky numbers.
Lucky number is a number that consists of digits 7 and 8 only. Find the maximum number of offices in the new building of the Tax Office given that a door-plate can hold a number not longer than n digits.
-----Input--... | [
"2\n",
"1\n",
"3\n",
"5\n",
"12\n",
"34\n",
"43\n",
"49\n",
"54\n",
"55\n"
] | [
"6",
"2",
"14",
"62",
"8190",
"34359738366",
"17592186044414",
"1125899906842622",
"36028797018963966",
"72057594037927934"
] | 1 | stdio |
Snuke received a triangle as a birthday present. The coordinates of the three vertices were (x_1, y_1), (x_2, y_2), and (x_3, y_3).
He wants to draw two circles with the same radius inside the triangle such that the two circles do not overlap (but they may touch). Compute the maximum possible radius of the circles.
C... | [
"3 1\n1 5\n1 9",
"0 -1\n1 1\n2 0",
"3 1\n1 5\n1 15",
"0 -1\n1 1\n1 0",
"3 2\n1 5\n1 15",
"-1 -1\n1 1\n1 0",
"3 2\n2 5\n1 15",
"-1 -1\n1 1\n2 0",
"3 4\n2 5\n1 15",
"-1 0\n1 1\n2 0"
] | [
"0.428755972649\n",
"0.350073412538\n",
"0.636077716757\n",
"0.180352124618\n",
"0.671149015941\n",
"0.26742584712\n",
"0.255199693676\n",
"0.402627528107\n",
"0.371066723425\n",
"0.346809521305\n"
] | 1 | stdio |
Find the number, modulo 998244353, of sequences of length N consisting of 0, 1 and 2 such that none of their contiguous subsequences totals to X.
Constraints
* 1 \leq N \leq 3000
* 1 \leq X \leq 2N
* N and X are integers.
Input
Input is given from Standard Input in the following format:
N X
Output
Print the nu... | [
"5 3",
"1 6",
"13 13",
"15 1",
"56 159",
"5 1",
"19 13",
"15 2",
"43 159",
"1 1"
] | [
"47\n",
"3\n",
"762218\n",
"32768\n",
"554719028\n",
"32\n",
"51048803\n",
"16\n",
"298877020\n",
"2\n"
] | 1 | stdio |
The city administration of IT City decided to fix up a symbol of scientific and technical progress in the city's main square, namely an indicator board that shows the effect of Moore's law in real time.
Moore's law is the observation that the number of transistors in a dense integrated circuit doubles approximately ev... | [
"1000 1000000\n",
"1000 0\n",
"1000 1\n",
"1000 2\n",
"10000 3\n",
"10000 2000000000\n",
"4907 244618708\n",
"9030 982505993\n",
"4054 287739817\n",
"1587 1941728048\n"
] | [
"1011.060722383550382782399454922040\n",
"1000\n",
"1000.000011000\n",
"1000.000022000000121000\n",
"10000.000330000003630000013310000\n",
"35849124123571.66604124267909180280\n",
"72346.60521729832602747499118899866\n",
"446019624.4250800721903194914485562\n",
"96047.41901816849953518710733057692\n... | 1 | stdio |
You received as a gift a very clever robot walking on a rectangular board. Unfortunately, you understood that it is broken and behaves rather strangely (randomly). The board consists of N rows and M columns of cells. The robot is initially at some cell on the i-th row and the j-th column. Then at every step the robot c... | [
"1000 1\n777 1\n",
"126 125\n115 22\n",
"1000 1000\n1 1\n",
"1000 2\n987 2\n",
"1000 1\n1 1\n",
"1 2\n1 1\n",
"663 904\n192 518\n",
"2 1\n1 1\n",
"1000 2\n1 1\n",
"293 183\n279 21\n"
] | [
"446.0000000000",
"43.9999127943",
"3960.8375934644",
"39.0000000000",
"1998.0000000000",
"0.0000000000",
"1883.9999999999",
"2.0000000000",
"2997.0000000000",
"55.9993687291"
] | 1 | stdio |
Ehab is interested in the bitwise-xor operation and the special graphs. Mahmoud gave him a problem that combines both. He has a complete graph consisting of n vertices numbered from 0 to n - 1. For all 0 ≤ u < v < n, vertex u and vertex v are connected with an undirected edge that has weight $u \oplus v$ (where $\oplus... | [
"4\n",
"10\n",
"2\n",
"1000000000000\n",
"999999999999\n",
"23131234\n",
"100000\n",
"1024\n",
"536870912\n",
"536870911\n"
] | [
"4",
"21",
"1",
"20140978692096",
"20140978692095",
"293058929",
"877968",
"5120",
"7784628224",
"7784628223"
] | 1 | stdio |
# Write Number in Expanded Form - Part 2
This is version 2 of my ['Write Number in Exanded Form' Kata](https://www.codewars.com/kata/write-number-in-expanded-form).
You will be given a number and you will need to return it as a string in [Expanded Form](https://www.mathplacementreview.com/arithmetic/decimals.php#writ... | [] | [] | 1 | stdio |
An X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have... | [
"4\n10\n8\n8\n6\n",
"3\n15\n15\n15\n",
"7\n50\n30\n50\n100\n50\n80\n30\n",
"7\n50\n30\n50\n100\n50\n80\n35",
"3\n29\n15\n15",
"4\n10\n8\n14\n6",
"3\n29\n15\n14",
"7\n50\n40\n91\n110\n50\n34\n59",
"7\n50\n40\n91\n110\n3\n34\n59",
"3\n1\n1\n1"
] | [
"3\n",
"1\n",
"4\n",
"5\n",
"2\n",
"4\n",
"3\n",
"6\n",
"7\n",
"1\n"
] | 1 | stdio |
Pavel loves grid mazes. A grid maze is an n × m rectangle maze where each cell is either empty, or is a wall. You can go from one cell to another only if both cells are empty and have a common side.
Pavel drew a grid maze with all empty cells forming a connected area. That is, you can go from any empty cell to any oth... | [
"19 20 196\n###.....##.#..#..##.\n####............##..\n###....#..#.#....#.#\n##....###......#...#\n.####...#.....#.##..\n.###......#...#.#.#.\n...##.#...#..#..#...\n.....#.....#..#....#\n.#.....##..#........\n.##....#......#....#\n....#.......#.......\n......##..#........#\n......#.#.##....#...\n..................... | [
"###..XXX##X#XX#XX##X\n####.XXXXXXXXXXX##XX\n###..XX#XX#X#XXXX#X#\n##....###XXXXXX#XXX#\n.####...#XXXXX#X##XX\n.###......#XXX#X#X#X\n...##X#...#XX#XX#XXX\n.....#X...X#XX#XXXX#\n.#....X##.X#XXXXXXXX\n.##...X#X.XXXX#XXXX#\n..X.#.XXX.XX#XXXXXXX\nX.X.X.##X.#XXXXXXXX#\nX.X.X.#X#.##XXXX#XXX\nX...X.....XXXXXXXX#X\nX..##X#... | 1 | stdio |
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh.
In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he rem... | [
"4 1257\n",
"25095 2372924\n",
"20 15\n",
"7 11\n",
"7 3\n",
"28768 33384329\n",
"2 96996900\n",
"8 10\n",
"205 110\n",
"10 1000004\n"
] | [
"1256 2512 2513 2514 ",
"2360378 4720756 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 ... | 1 | stdio |
Pair of gloves
=============
Winter is coming, you must prepare your ski holidays. The objective of this kata is to determine the number of pair of gloves you can constitute from the gloves you have in your drawer.
A pair of gloves is constituted of two gloves of the same color.
You are given an array containing the... | [] | [] | 1 | stdio |
Apparently "Put A Pillow On Your Fridge Day is celebrated on the 29th of May each year, in Europe and the U.S. The day is all about prosperity, good fortune, and having bit of fun along the way."
All seems very weird to me.
Nevertheless, you will be given an array of two strings (s). First find out if the first strin... | [] | [] | 1 | stdio |
Example
Input
3
NNN
NNN
NNN
Output
Taro | [
"3\nNNN\nNNO\nNNN",
"3\nNMN\nNNO\nNNN",
"3\nNMN\nNNP\nNNN",
"3\nMMN\nNNO\nNNN",
"3\nMMN\nONN\nNNN",
"3\nMMN\nONN\nMNN",
"3\nMMN\nNNO\nMNN",
"3\nMMN\nNNO\nMON",
"3\nNMN\nNNO\nMON",
"3\nNMN\nNNO\nMNN"
] | [
"Taro\n",
"Taro\n",
"Taro\n",
"Taro\n",
"Taro\n",
"Taro\n",
"Taro\n",
"Taro\n",
"Taro\n",
"Taro\n"
] | 1 | stdio |
Rng is baking cookies.
Initially, he can bake one cookie per second.
He can also eat the cookies baked by himself. When there are x cookies not yet eaten, he can choose to eat all those cookies. After he finishes eating those cookies, the number of cookies he can bake per second becomes x. Note that a cookie always n... | [
"1000000000000 1000000100000",
"9 1",
"7 0",
"1000010000000 1000100100001",
"1000110000000 1000100100001",
"13 1",
"1000100000000 1000100100001",
"13 0",
"1000101000000 1000110100011",
"12 -1"
] | [
"1000000000000\n",
"7\n",
"6\n",
"1000010000000\n",
"1000102100111\n",
"9\n",
"1000100000000\n",
"8\n",
"1000101000000\n",
"5\n"
] | 1 | stdio |
You are given a positive integer $n$.
Let $S(x)$ be sum of digits in base 10 representation of $x$, for example, $S(123) = 1 + 2 + 3 = 6$, $S(0) = 0$.
Your task is to find two integers $a, b$, such that $0 \leq a, b \leq n$, $a + b = n$ and $S(a) + S(b)$ is the largest possible among all such pairs.
-----Input-----... | [
"35\n",
"10000000000\n",
"4394826\n",
"96\n",
"9999991\n",
"999999999992\n",
"290687942106\n",
"1000000000000\n",
"1\n",
"8\n"
] | [
"17\n",
"91\n",
"90\n",
"24\n",
"109\n",
"200\n",
"153\n",
"109\n",
"1\n",
"8\n"
] | 1 | stdio |
You are given an array of positive integers a_1, a_2, ..., a_{n} × T of length n × T. We know that for any i > n it is true that a_{i} = a_{i} - n. Find the length of the longest non-decreasing sequence of the given array.
-----Input-----
The first line contains two space-separated integers: n, T (1 ≤ n ≤ 100, 1 ≤ T... | [
"4 3\n3 1 4 2\n",
"1 1000\n42\n",
"31 3767\n16 192 152 78 224 202 186 52 118 19 13 38 199 196 35 295 100 64 205 37 166 124 169 214 66 243 134 192 253 270 92\n",
"15 12226\n18 125 213 221 124 147 154 182 134 184 51 49 267 88 251\n",
"81 10683\n3 52 265 294 213 242 185 151 27 165 128 237 124 14 43 147 104 162... | [
"5\n",
"1000\n",
"7546\n",
"12234\n",
"32070\n",
"15919\n",
"2128\n",
"767\n",
"13102\n",
"3845\n"
] | 1 | stdio |
Divisors of 42 are : 1, 2, 3, 6, 7, 14, 21, 42.
These divisors squared are: 1, 4, 9, 36, 49, 196, 441, 1764.
The sum of the squared divisors is 2500 which is 50 * 50, a square!
Given two integers m, n (1 <= m <= n) we want to find all integers
between m and n whose sum of squared divisors is itself a square.
42 is su... | [] | [] | 1 | stdio |
You are the judge at a competitive eating competition and you need to choose a winner!
There are three foods at the competition and each type of food is worth a different amount of points.
Points are as follows:
- Chickenwings: 5 points
- Hamburgers: 3 points
- Hotdogs: 2 points
Write a function that helps yo... | [] | [] | 1 | stdio |
Given a positive integer n, find k integers (not necessary distinct) such that all these integers are strictly greater than 1, and their product is equal to n.
Input
The first line contains two integers n and k (2 ≤ n ≤ 100000, 1 ≤ k ≤ 20).
Output
If it's impossible to find the representation of n as a product of k... | [
"15 6\n",
"13 3\n",
"35557 5\n",
"95477 1\n",
"11 1\n",
"95477 4\n",
"66049 2\n",
"4 5\n",
"16 5\n",
"42439 3\n"
] | [
"-1\n",
"-1\n",
"-1\n",
"95477\n",
"11\n",
"-1\n",
"257 257\n",
"-1\n",
"-1\n",
"31 37 37\n"
] | 1 | stdio |
Email address in Berland is a string of the form A@B, where A and B are arbitrary strings consisting of small Latin letters.
Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as a large string, where all addresses are written in arbitrary order... | [
"a@mc@ks@gu@rl@gq@zq@iz@da@uq@mi@nf@zs@hi@we@ej@ke@vb@az@yz@yl@rr@gh@um@nv@qe@qq@de@dy@op@gt@vx@ak@q\n",
"aglvesxsmivijisod@mxcnbfcfgqfwjouidlsueaswf@obehqpvbkmukxkicyoknkbol@kutunggpoxxfpbe@qkhv@llddqqoyjeex@byvtlhbifqmvlukmrvgvpwrscwfhpuwyknwchqhrdqgarmnsdlqgf@lseltghg@bhuwbfjpsvayzk@fvwow@zapklumefauly\n",
"... | [
"a@m,c@k,s@g,u@r,l@g,q@z,q@i,z@d,a@u,q@m,i@n,f@z,s@h,i@w,e@e,j@k,e@v,b@a,z@y,z@y,l@r,r@g,h@u,m@n,v@q,e@q,q@d,e@d,y@o,p@g,t@v,x@a,k@q\n",
"aglvesxsmivijisod@m,xcnbfcfgqfwjouidlsueaswf@o,behqpvbkmukxkicyoknkbol@k,utunggpoxxfpbe@q,khv@l,lddqqoyjeex@b,yvtlhbifqmvlukmrvgvpwrscwfhpuwyknwchqhrdqgarmnsdlqgf@l,seltghg@b,h... | 1 | stdio |
Pete and his mate Phil are out in the countryside shooting clay pigeons with a shotgun - amazing fun.
They decide to have a competition. 3 rounds, 2 shots each. Winner is the one with the most hits.
Some of the clays have something attached to create lots of smoke when hit, guarenteed by the packaging to generate 'r... | [] | [] | 1 | stdio |
You are given circle $A$ with radius $r_a$ and with central coordinate $(x_a, y_a)$ and circle $B$ with radius $r_b$ and with central coordinate $(x_b, y_b)$.
Write a program which prints:
* "2" if $B$ is in $A$,
* "-2" if $A$ is in $B$,
* "1" if circumference of $A$ and $B$ intersect, and
* "0" if $A$ and $B$ do not... | [
"2\n0.0 0.0 5.0 0.0 0.0 4.0\n0.0 0.0 2.0 4.1 0.0 2.4515674947137622",
"2\n0.0 0.0 5.0 0.0 1.5542884595470625 4.0\n0.0 0.0 2.0 4.1 0.0 2.4515674947137622",
"2\n3.1147350602004042 10.32674830176415 10.748453312336865 4.001069425760041 6.490549081480047 6.328774266228958\n7.521092820860991 2.963851942354593 7.4741... | [
"2\n1\n",
"1\n1\n",
"2\n2\n",
"1\n2\n",
"2\n1\n",
"1\n1\n",
"1\n1\n",
"1\n1\n",
"1\n1\n",
"1\n1\n"
] | 1 | stdio |
Create a function that takes an input String and returns a String, where all the uppercase words of the input String are in front and all the lowercase words at the end.
The order of the uppercase and lowercase words should be the order in which they occur.
If a word starts with a number or special character, skip the... | [] | [] | 1 | stdio |
You are given several queries. Each query consists of three integers p, q and b. You need to answer whether the result of p/q in notation with base b is a finite fraction.
A fraction in notation with base b is finite if it contains finite number of numerals after the decimal point. It is also possible that a fraction ... | [
"10\n10 8 5\n0 6 9\n0 7 6\n5 7 3\n7 6 8\n0 4 8\n2 6 3\n10 2 9\n6 7 9\n9 1 4\n",
"1\n1 5244319080000 30030\n",
"10\n10 5 3\n1 7 10\n7 5 7\n4 4 9\n6 5 2\n6 7 5\n9 9 7\n7 5 5\n6 6 4\n10 8 2\n",
"1\n1 864691128455135232 2\n",
"10\n5 8 2\n0 5 8\n5 9 7\n0 7 2\n6 7 2\n10 3 7\n8 1 10\n9 1 8\n0 7 10\n9 1 4\n",
"1\... | [
"Infinite\nFinite\nFinite\nInfinite\nInfinite\nFinite\nFinite\nFinite\nInfinite\nFinite\n",
"Finite\n",
"Finite\nInfinite\nInfinite\nFinite\nInfinite\nInfinite\nFinite\nFinite\nFinite\nFinite\n",
"Infinite\n",
"Finite\nFinite\nInfinite\nFinite\nInfinite\nInfinite\nFinite\nFinite\nFinite\nFinite\n",
"Finit... | 1 | stdio |
Vasya studies positional numeral systems. Unfortunately, he often forgets to write the base of notation in which the expression is written. Once he saw a note in his notebook saying a + b = ?, and that the base of the positional notation wasn’t written anywhere. Now Vasya has to choose a base p and regard the expressio... | [
"208 997\n",
"12 34\n",
"104 938\n",
"1000 539\n",
"840 975\n",
"999 1\n",
"1 11\n",
"9 7\n",
"1 999\n",
"998 998\n"
] | [
"4\n",
"3\n",
"4\n",
"4\n",
"4\n",
"4\n",
"3\n",
"2\n",
"4\n",
"4\n"
] | 1 | stdio |
Two strings ```a``` and b are called isomorphic if there is a one to one mapping possible for every character of ```a``` to every character of ```b```. And all occurrences of every character in ```a``` map to same character in ```b```.
## Task
In this kata you will create a function that return ```True``` if two give... | [] | [] | 1 | stdio |
Your task it to return ```true``` if the fractional part (rounded to 1 digit) of the result (```a``` / ```b```) exists, more than ```0``` and is multiple of ```n```.
Otherwise return ```false```. (For Python return True or False)
All arguments are positive digital numbers.
Rounding works like toFixed() method. (if mo... | [] | [] | 1 | stdio |
Ringo Kingdom Congress is voting on a bill.
N members are present, and the i-th member (1 ≤ i ≤ N) has w_i white ballots and b_i blue ballots. Each member i will put all the w_i white ballots into the box if he/she is in favor of the bill, and put all the b_i blue ballots into the box if he/she is not in favor of the ... | [
"5 60\n6 3\n5 9\n3 4\n7 0\n4 7",
"4 17\n1 1\n1 1\n1 1\n000 1",
"4 75\n1 1\n1 1\n1 1\n000 2",
"2 93\n8 3\n8 8\n3 3\n7 8\n4 7",
"5 87\n6 3\n5 9\n3 4\n7 8\n4 7",
"4 75\n1 1\n1 1\n1 1\n000 1",
"5 60\n11 3\n5 9\n3 4\n7 0\n4 7",
"5 60\n11 3\n5 9\n3 4\n13 0\n4 7",
"4 17\n1 1\n1 1\n1 1\n001 1",
"1 60\n11 ... | [
"3\n",
"1\n",
"4\n",
"2\n",
"5\n",
"3\n",
"3\n",
"3\n",
"1\n",
"1\n"
] | 1 | stdio |
Amicable numbers are two different numbers so related that the sum of the proper divisors of each is equal to the other number. (A proper divisor of a number is a positive factor of that number other than the number itself. For example, the proper divisors of 6 are 1, 2, and 3.)
For example, the smallest pair of amic... | [] | [] | 1 | stdio |
One day Vasya decided to have a look at the results of Berland 1910 Football Championship’s finals. Unfortunately he didn't find the overall score of the match; however, he got hold of a profound description of the match's process. On the whole there are n lines in that description each of which described one goal. Eve... | [
"100\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA... | [
"HA\n",
"QCCYXL\n",
"XBCP\n",
"W\n",
"G\n",
"VOCI\n",
"EERWBC\n",
"WL\n",
"A\n",
"HNCGYL\n"
] | 1 | stdio |
Monocarp wrote down two numbers on a whiteboard. Both numbers follow a specific format: a positive integer $x$ with $p$ zeros appended to its end.
Now Monocarp asks you to compare these two numbers. Can you help him?
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of t... | [
"5\n2 1\n19 0\n10 2\n100 1\n1999 0\n2 3\n1 0\n1 0\n99 0\n1 2\n",
"1\n100000 1\n100 4\n",
"1\n999999 0\n999999 0\n",
"1\n999999 0\n1000000 0\n",
"1\n12 2\n1201 0\n",
"3\n1 3\n100 1\n2 3\n200 1\n6 3\n600 1\n",
"1\n12 2\n1205 0\n",
"1\n12001 59\n12 62\n",
"7\n1 3\n100 1\n2 3\n200 1\n3 3\n300 1\n4 3\n40... | [
">\n=\n<\n=\n<\n",
"=\n",
"=\n",
"<\n",
"<\n",
"=\n=\n=\n",
"<\n",
">\n",
"=\n=\n=\n=\n=\n=\n=\n",
"=\n"
] | 1 | stdio |
Twilight Sparkle once got a crystal from the Crystal Mine. A crystal of size n (n is odd; n > 1) is an n × n matrix with a diamond inscribed into it.
You are given an odd integer n. You need to draw a crystal of size n. The diamond cells of the matrix should be represented by character "D". All other cells of the matr... | [
"3\n",
"5\n",
"7\n",
"11\n",
"15\n",
"21\n",
"101\n",
"11\n",
"81\n",
"21\n"
] | [
"*D*\nDDD\n*D*\n",
"**D**\n*DDD*\nDDDDD\n*DDD*\n**D**\n",
"***D***\n**DDD**\n*DDDDD*\nDDDDDDD\n*DDDDD*\n**DDD**\n***D***\n",
"*****D*****\n****DDD****\n***DDDDD***\n**DDDDDDD**\n*DDDDDDDDD*\nDDDDDDDDDDD\n*DDDDDDDDD*\n**DDDDDDD**\n***DDDDD***\n****DDD****\n*****D*****\n",
"*******D*******\n******DDD******\n*... | 1 | stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.