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 |
|---|---|---|---|---|
Take an input string and return a string that is made up of the number of occurences of each english letter in the input followed by that letter, sorted alphabetically. The output string shouldn't contain chars missing from input (chars with 0 occurence); leave them out.
An empty string, or one with no letters, should return an empty string.
Notes:
* the input will always be valid;
* treat letters as **case-insensitive**
## Examples
```
"This is a test sentence." ==> "1a1c4e1h2i2n4s4t"
"" ==> ""
"555" ==> ""
```
Write your solution by modifying this code:
```python
def string_letter_count(s):
```
Your solution should implemented in the function "string_letter_count". The inputs will be passed to it and it should return the correct solution.
Now solve the problem and return the code.
|
[] |
[] | 1
|
stdio
|
Mobile Display Keystrokes
Do you remember the old mobile display keyboards? Do you also remember how inconvenient it was to write on it?
Well, here you have to calculate how much keystrokes you have to do for a specific word.
This is the layout:
Return the amount of keystrokes of input str (! only letters, digits and special characters in lowercase included in layout without whitespaces !)
e.g:
mobileKeyboard("123") => 3 (1+1+1)
mobileKeyboard("abc") => 9 (2+3+4)
mobileKeyboard("codewars") => 26 (4+4+2+3+2+2+4+5)
Write your solution by modifying this code:
```python
def mobile_keyboard(s):
```
Your solution should implemented in the function "mobile_keyboard". The inputs will be passed to it and it should return the correct solution.
Now solve the problem and return the code.
|
[] |
[] | 1
|
stdio
|
At a geometry lesson Bob learnt that a triangle is called right-angled if it is nondegenerate and one of its angles is right. Bob decided to draw such a triangle immediately: on a sheet of paper he drew three points with integer coordinates, and joined them with segments of straight lines, then he showed the triangle to Peter. Peter said that Bob's triangle is not right-angled, but is almost right-angled: the triangle itself is not right-angled, but it is possible to move one of the points exactly by distance 1 so, that all the coordinates remain integer, and the triangle become right-angled. Bob asks you to help him and find out if Peter tricks him. By the given coordinates of the triangle you should find out if it is right-angled, almost right-angled, or neither of these.
Input
The first input line contains 6 space-separated integers x1, y1, x2, y2, x3, y3 — coordinates of the triangle's vertices. All the coordinates are integer and don't exceed 100 in absolute value. It's guaranteed that the triangle is nondegenerate, i.e. its total area is not zero.
Output
If the given triangle is right-angled, output RIGHT, if it is almost right-angled, output ALMOST, and if it is neither of these, output NEITHER.
Examples
Input
0 0 2 0 0 1
Output
RIGHT
Input
2 3 4 5 6 6
Output
NEITHER
Input
-1 0 2 0 0 1
Output
ALMOST
|
[
"30 8 49 13 25 27\n",
"-67 49 89 -76 -37 87\n",
"34 74 -2 -95 63 -33\n",
"-66 24 8 -29 17 62\n",
"-10 -11 62 6 -12 -3\n",
"49 -7 19 -76 26 3\n",
"0 0 1 0 4 1\n",
"-50 -1 0 50 0 -50\n",
"0 0 1 0 2 1\n",
"-100 -100 100 100 -100 100\n"
] |
[
"RIGHT\n",
"NEITHER\n",
"NEITHER\n",
"NEITHER\n",
"ALMOST\n",
"RIGHT\n",
"NEITHER\n",
"ALMOST\n",
"ALMOST\n",
"RIGHT\n"
] | 1
|
stdio
|
This kata is about multiplying a given number by eight if it is an even number and by nine otherwise.
Write your solution by modifying this code:
```python
def simple_multiplication(number) :
```
Your solution should implemented in the function "simple_multiplication". The inputs will be passed to it and it should return the correct solution.
Now solve the problem and return the code.
|
[] |
[] | 1
|
stdio
|
Description overhauled by V
---
I've invited some kids for my son's birthday, during which I will give to each kid some amount of candies.
Every kid hates receiving less amount of candies than any other kids, and I don't want to have any candies left - giving it to my kid would be bad for his teeth.
However, not every kid invited will come to my birthday party.
What is the minimum amount of candies I have to buy, so that no matter how many kids come to the party in the end, I can still ensure that each kid can receive the same amount of candies, while leaving no candies left?
It's ensured that at least one kid will participate in the party.
Write your solution by modifying this code:
```python
def candies_to_buy(n):
```
Your solution should implemented in the function "candies_to_buy". The inputs will be passed to it and it should return the correct solution.
Now solve the problem and return the code.
|
[] |
[] | 1
|
stdio
|
An bydrocarbon is an organic compound which contains only carbons and hydrogens. An isomer is a compound that has the same number of carbons but different structures. Heptane, for example, is a hydrocarbon with 7 carbons. It has nine isomers. The structural formula of three are shown in Figure 1. Carbons are represented by the letter C, and bonds between carbons are represented by a straight line. In all figures, hydrogens are not represented for simplicity. Each carbon can be connected to a maximum of 4 carbons.
<image>
---
Figure 1: These three examples of isomers of heptane have the same number of carbons but different structures.
---
Let define a chain in an isomer as a sequence of connected carbons without branches. An isomer can have many chains of the same length. Figure 2 shows the longest chain of carbons for each of the represented isomer. Note that there can be many instances of longest chain in an isomer.
<image>
---
Figure 2: The figures shows one instance of longest chain of carbons in each isomer. The first and the second isomers show longest chains of 5 carbons. The longest chain in the third isomer has 4 carbons.
---
Your task is to identify the number of carbons of the largest possible carbon compound whose longest carbon chain has n (1 ≤ n ≤ 30) carbons.
Input
Each input contains a list of number of carbons, i.e. the length of a carbon chain.
The number of input lines is less than or equal to 30.
Output
For each number n in input, identify the number of carbons of the largest possible carbon compound whose longest carbon chain has n carbons.
Example
Input
1
4
Output
1
8
|
[
"1\n6",
"1\n8",
"1\n12",
"1\n16",
"1\n1",
"1\n13",
"1\n25",
"1\n5",
"1\n2",
"1\n3"
] |
[
"1\n26\n",
"1\n80\n",
"1\n728\n",
"1\n6560\n",
"1\n1\n",
"1\n1457\n",
"1\n1062881\n",
"1\n17\n",
"1\n2\n",
"1\n5\n"
] | 1
|
stdio
|
You are given an array $a$ consisting of $n$ integers.
You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$.
Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array.
Recall that the contiguous subarray $a$ with indices from $l$ to $r$ is $a[l \dots r] = a_l, a_{l + 1}, \dots, a_r$. The subarray $a[l \dots r]$ is called strictly increasing if $a_l < a_{l+1} < \dots < a_r$.
-----Input-----
The first line of the input contains one integer $n$ ($2 \le n \le 2 \cdot 10^5$) — the number of elements in $a$.
The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$), where $a_i$ is the $i$-th element of $a$.
-----Output-----
Print one integer — the maximum possible length of the strictly increasing contiguous subarray of the array $a$ after removing at most one element.
-----Examples-----
Input
5
1 2 5 3 4
Output
4
Input
2
1 2
Output
2
Input
7
6 5 4 3 2 4 3
Output
2
-----Note-----
In the first example, you can delete $a_3=5$. Then the resulting array will be equal to $[1, 2, 3, 4]$ and the length of its largest increasing subarray will be equal to $4$.
|
[
"5\n1 2 5 3 4\n",
"2\n1 2\n",
"7\n6 5 4 3 2 4 3\n",
"4\n6 5 4 3\n",
"2\n2 1\n",
"5\n111 111 100 22 3\n",
"4\n26 18 26 9\n",
"2\n1 1\n",
"5\n1 2 3 4 4\n",
"7\n5 2 3 4 5 6 3\n"
] |
[
"4\n",
"2\n",
"2\n",
"1\n",
"1\n",
"1\n",
"2\n",
"1\n",
"4\n",
"5\n"
] | 1
|
stdio
|
Vasya and Petya wrote down all integers from 1 to n to play the "powers" game (n can be quite large; however, Vasya and Petya are not confused by this fact).
Players choose numbers in turn (Vasya chooses first). If some number x is chosen at the current turn, it is forbidden to choose x or all of its other positive integer powers (that is, x^2, x^3, ...) at the next turns. For instance, if the number 9 is chosen at the first turn, one cannot choose 9 or 81 later, while it is still allowed to choose 3 or 27. The one who cannot make a move loses.
Who wins if both Vasya and Petya play optimally?
-----Input-----
Input contains single integer n (1 ≤ n ≤ 10^9).
-----Output-----
Print the name of the winner — "Vasya" or "Petya" (without quotes).
-----Examples-----
Input
1
Output
Vasya
Input
2
Output
Petya
Input
8
Output
Petya
-----Note-----
In the first sample Vasya will choose 1 and win immediately.
In the second sample no matter which number Vasya chooses during his first turn, Petya can choose the remaining number and win.
|
[
"1\n",
"2\n",
"8\n",
"52\n",
"53\n",
"3\n",
"4\n",
"5\n",
"6\n",
"7\n"
] |
[
"Vasya\n",
"Petya\n",
"Petya\n",
"Petya\n",
"Vasya\n",
"Vasya\n",
"Vasya\n",
"Vasya\n",
"Vasya\n",
"Vasya\n"
] | 1
|
stdio
|
## Task:
You have to create a function `isPronic` to check whether the argument passed is a Pronic Number and return true if it is & false otherwise.
### Description:
`Pronic Number` -A pronic number, oblong number, rectangular number or heteromecic number, is a number which is the product of two consecutive integers, that is, n(n + 1).
> The first few Pronic Numbers are - 0, 2, 6, 12, 20, 30, 42...
### Explanation:
0 = 0 × 1 // ∴ 0 is a Pronic Number
2 = 1 × 2 // ∴ 2 is a Pronic Number
6 = 2 × 3 // ∴ 6 is a Pronic Number
12 = 3 × 4 // ∴ 12 is a Pronic Number
20 = 4 × 5 // ∴ 20 is a Pronic Number
30 = 5 × 6 // ∴ 30 is a Pronic Number
42 = 6 × 7 // ∴ 42 is a Pronic Number
Write your solution by modifying this code:
```python
def is_pronic(n):
```
Your solution should implemented in the function "is_pronic". The inputs will be passed to it and it should return the correct solution.
Now solve the problem and return the code.
|
[] |
[] | 1
|
stdio
|
A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward. Examples of numerical palindromes are:
2332
110011
54322345
You'll be given 2 numbers as arguments: ```(num,s)```. Write a function which returns an array of ```s``` number of numerical palindromes that come after ```num```. If ```num``` is a palindrome itself, it should be included in the count.
Return "Not valid" instead if any one of the inputs is not an integer or is less than 0.
For this kata, single digit numbers will NOT be considered numerical palindromes.
```
palindrome(6,4) => [11,22,33,44]
palindrome(59,3) => [66,77,88]
palindrome(101,2) => [101,111]
palindrome("15651",5) => "Not valid"
palindrome(1221,"8") => "Not valid"
```
```Haskell
In Haskell, the return type is a Maybe which returns Nothing if either of the inputs is negative."
```
Other Kata in this Series:
Numerical Palindrome #1
Numerical Palindrome #1.5
Numerical Palindrome #2
Numerical Palindrome #3
Numerical Palindrome #3.5
Numerical Palindrome #4
Numerical Palindrome #5
Write your solution by modifying this code:
```python
def palindrome(num,s):
```
Your solution should implemented in the function "palindrome". The inputs will be passed to it and it should return the correct solution.
Now solve the problem and return the code.
|
[] |
[] | 1
|
stdio
|
The cows have just learned what a primitive root is! Given a prime p, a primitive root $\operatorname{mod} p$ is an integer x (1 ≤ x < p) such that none of integers x - 1, x^2 - 1, ..., x^{p} - 2 - 1 are divisible by p, but x^{p} - 1 - 1 is.
Unfortunately, computing primitive roots can be time consuming, so the cows need your help. Given a prime p, help the cows find the number of primitive roots $\operatorname{mod} p$.
-----Input-----
The input contains a single line containing an integer p (2 ≤ p < 2000). It is guaranteed that p is a prime.
-----Output-----
Output on a single line the number of primitive roots $\operatorname{mod} p$.
-----Examples-----
Input
3
Output
1
Input
5
Output
2
-----Note-----
The only primitive root $\operatorname{mod} 3$ is 2.
The primitive roots $\operatorname{mod} 5$ are 2 and 3.
|
[
"3\n",
"5\n",
"7\n",
"11\n",
"17\n",
"19\n",
"1583\n",
"997\n",
"2\n",
"1987\n"
] |
[
"1\n",
"2\n",
"2\n",
"4\n",
"8\n",
"6\n",
"672\n",
"328\n",
"1\n",
"660\n"
] | 1
|
stdio
|
There is data that records the altitude of mountains that have been climbed so far. Create a program that reads this data and outputs the elevation difference between the highest and lowest mountains.
Input
The input is given in the following format:
Mountain height
...
...
The height of the mountain is given over multiple lines. All values entered are real numbers greater than or equal to 0 and less than or equal to 1,000,000. The number of mountain heights entered is 50 or less.
Output
The elevation difference between the highest mountain and the lowest mountain is output as a real number. The output may contain an error of 0.01 or less.
Example
Input
3776.0
1819.0
645.2
2004.1
1208.6
Output
3130.8
|
[
"3776.5765005393655\n1819.0\n645.2\n2004.1\n1208.6",
"3777.502968017379\n1819.0\n645.2\n2004.1\n1208.6",
"3778.4165917426626\n1819.0\n645.2\n2004.2183724359945\n1208.6",
"3779.3515835085277\n1819.169376096264\n645.2\n2004.5930566110492\n1208.6",
"3779.3515835085277\n1819.169376096264\n645.463437143232\n2005.3577164478409\n1209.3337144467619",
"3779.3515835085277\n1819.169376096264\n645.8367231919477\n2005.3577164478409\n1209.3337144467619",
"3779.3515835085277\n1819.169376096264\n645.8829036094434\n2005.3577164478409\n1209.3337144467619",
"3780.0351746720435\n1819.169376096264\n645.8829036094434\n2005.3577164478409\n1209.3337144467619",
"3780.0804815259103\n1819.169376096264\n645.8829036094434\n2005.3577164478409\n1209.3337144467619",
"3780.0804815259103\n1819.169376096264\n646.6571280527984\n2005.3577164478409\n1209.3337144467619"
] |
[
"3131.37650054\n",
"3132.30296802\n",
"3133.21659174\n",
"3134.15158351\n",
"3133.88814637\n",
"3133.51486032\n",
"3133.4686799\n",
"3134.15227106\n",
"3134.19757792\n",
"3133.42335347\n"
] | 1
|
stdio
|
There are n workers in a company, each of them has a unique id from 1 to n. Exaclty one of them is a chief, his id is s. Each worker except the chief has exactly one immediate superior.
There was a request to each of the workers to tell how how many superiors (not only immediate). Worker's superiors are his immediate superior, the immediate superior of the his immediate superior, and so on. For example, if there are three workers in the company, from which the first is the chief, the second worker's immediate superior is the first, the third worker's immediate superior is the second, then the third worker has two superiors, one of them is immediate and one not immediate. The chief is a superior to all the workers except himself.
Some of the workers were in a hurry and made a mistake. You are to find the minimum number of workers that could make a mistake.
Input
The first line contains two positive integers n and s (1 ≤ n ≤ 2·105, 1 ≤ s ≤ n) — the number of workers and the id of the chief.
The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ n - 1), where ai is the number of superiors (not only immediate) the worker with id i reported about.
Output
Print the minimum number of workers that could make a mistake.
Examples
Input
3 2
2 0 2
Output
1
Input
5 3
1 0 0 4 1
Output
2
Note
In the first example it is possible that only the first worker made a mistake. Then:
* the immediate superior of the first worker is the second worker,
* the immediate superior of the third worker is the first worker,
* the second worker is the chief.
|
[
"3 2\n2 1 1\n",
"3 3\n2 1 2\n",
"7 1\n4 4 6 6 6 6 5\n",
"3 2\n2 0 1\n",
"3 1\n2 1 1\n",
"3 1\n0 1 2\n",
"10 6\n3 0 0 0 0 0 0 1 0 0\n",
"5 5\n0 1 1 0 0\n",
"3 2\n2 2 1\n",
"5 1\n0 0 1 3 4\n"
] |
[
"1\n",
"1\n",
"4\n",
"0\n",
"1\n",
"0\n",
"7\n",
"2\n",
"1\n",
"1\n"
] | 1
|
stdio
|
We have a string S consisting of lowercase English letters.
If the length of S is at most K, print S without change.
If the length of S exceeds K, extract the first K characters in S, append ... to the end of them, and print the result.
-----Constraints-----
- K is an integer between 1 and 100 (inclusive).
- S is a string consisting of lowercase English letters.
- The length of S is between 1 and 100 (inclusive).
-----Input-----
Input is given from Standard Input in the following format:
K
S
-----Output-----
Print a string as stated in Problem Statement.
-----Sample Input-----
7
nikoandsolstice
-----Sample Output-----
nikoand...
nikoandsolstice has a length of 15, which exceeds K=7.
We should extract the first 7 characters in this string, append ... to the end of them, and print the result nikoand....
|
[
"7\nnikoandsolstice\n",
"40\nferelibenterhominesidquodvoluntcredunt\n",
"1\nz\n",
"2\nz\n",
"9\ncfmfbfbnyigsejhwuhs\n",
"35\npemetdsjkmxuadhyrsyngoawfywyylglksmprtues\n",
"26\newwcjswgwdeijtbfkrlojvygql\n",
"27\nohgmguyzmrwntvrxzzwxtxzlbuc\n",
"51\neelettrhmmoakwpdmfkrvyhtxxtxrxcdimffomblxtoicov\n",
"22\nvyfuehycdnzpmjojdak\n"
] |
[
"nikoand...\n",
"ferelibenterhominesidquodvoluntcredunt\n",
"z\n",
"z\n",
"cfmfbfbny...\n",
"pemetdsjkmxuadhyrsyngoawfywyylglksm...\n",
"ewwcjswgwdeijtbfkrlojvygql\n",
"ohgmguyzmrwntvrxzzwxtxzlbuc\n",
"eelettrhmmoakwpdmfkrvyhtxxtxrxcdimffomblxtoicov\n",
"vyfuehycdnzpmjojdak\n"
] | 1
|
stdio
|
Kavi has 2n points lying on the OX axis, i-th of which is located at x = i.
Kavi considers all ways to split these 2n points into n pairs. Among those, he is interested in good pairings, which are defined as follows:
Consider n segments with ends at the points in correspondent pairs. The pairing is called good, if for every 2 different segments A and B among those, at least one of the following holds:
* One of the segments A and B lies completely inside the other.
* A and B have the same length.
Consider the following example:
<image>
A is a good pairing since the red segment lies completely inside the blue segment.
B is a good pairing since the red and the blue segment have the same length.
C is not a good pairing since none of the red or blue segments lies inside the other, neither do they have the same size.
Kavi is interested in the number of good pairings, so he wants you to find it for him. As the result can be large, find this number modulo 998244353.
Two pairings are called different, if some two points are in one pair in some pairing and in different pairs in another.
Input
The single line of the input contains a single integer n (1≤ n ≤ 10^6).
Output
Print the number of good pairings modulo 998244353.
Examples
Input
1
Output
1
Input
2
Output
3
Input
3
Output
6
Input
100
Output
688750769
Note
The good pairings for the second example are:
<image>
In the third example, the good pairings are:
<image>
|
[
"333625\n",
"693549\n",
"757606\n",
"1000000\n",
"999228\n",
"443013\n",
"825195\n",
"160945\n",
"489857\n",
"563368\n"
] |
[
"668510586",
"721751076",
"162462618",
"126330412",
"996260068",
"95736273",
"937989636",
"650435832",
"498405873",
"170858430"
] | 1
|
stdio
|
Snuke lives at position x on a number line.
On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B.
Find out which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented by |s-t|.
-----Constraints-----
- 1 \leq x \leq 1000
- 1 \leq a \leq 1000
- 1 \leq b \leq 1000
- x, a and b are pairwise distinct.
- The distances between Snuke's residence and stores A and B are different.
-----Input-----
Input is given from Standard Input in the following format:
x a b
-----Output-----
If store A is closer, print A; if store B is closer, print B.
-----Sample Input-----
5 2 7
-----Sample Output-----
B
The distances between Snuke's residence and stores A and B are 3 and 2, respectively.
Since store B is closer, print B.
|
[
"5 2 7\n",
"1 999 1000\n",
"1 999 0000",
"1 381 1110",
"5 1 7",
"1 999 0100",
"10 1 7",
"1 999 0101",
"10 2 7",
"1 999 0001"
] |
[
"B\n",
"A\n",
"B\n",
"A\n",
"B\n",
"B\n",
"B\n",
"B\n",
"B\n",
"B\n"
] | 1
|
stdio
|
Simple transposition is a basic and simple cryptography technique. We make 2 rows and put first a letter in the Row 1, the second in the Row 2, third in Row 1 and so on until the end. Then we put the text from Row 2 next to the Row 1 text and thats it.
Complete the function that receives a string and encrypt it with this simple transposition.
## Example
For example if the text to encrypt is: `"Simple text"`, the 2 rows will be:
Row 1
S
m
l
e
t
Row 2
i
p
e
t
x
So the result string will be: `"Sml etipetx"`
Write your solution by modifying this code:
```python
def simple_transposition(text):
```
Your solution should implemented in the function "simple_transposition". The inputs will be passed to it and it should return the correct solution.
Now solve the problem and return the code.
|
[] |
[] | 1
|
stdio
|
Example
Input
2 2 2 1
0 0 0
Output
24
|
[
"2 2 2 0\n0 0 0",
"2 1 2 0\n-1 -1 0",
"2 0 2 0\n-1 0 0",
"4 2 2 0\n0 0 1",
"3 1 2 0\n-1 0 -1",
"1 2 1 0\n-2 -1 0",
"2 2 3 0\n-1 -1 -1",
"1 1 4 0\n0 1 -1",
"3 2 0 0\n-1 -1 -1",
"1 0 1 0\n0 1 -1"
] |
[
"24\n",
"16\n",
"8\n",
"40\n",
"22\n",
"10\n",
"32\n",
"18\n",
"12\n",
"2\n"
] | 1
|
stdio
|
You are given a string of length N. Calculate the number of distinct substrings of S.
Constraints
* 1 \leq N \leq 500,000
* S consists of lowercase English letters.
Input
Input is given from Standard Input in the following format:
S
Output
Print the answer.
Examples
Input
abcbcba
Output
21
Input
mississippi
Output
53
Input
ababacaca
Output
33
Input
aaaaa
Output
5
|
[
"abcacbb",
"baaaa",
"aaabacacb",
"mjssissippi",
"abbacbb",
"baaba",
"mjssisrippi",
"bcacabaa`",
"mjssisripph",
"bcacabab`"
] |
[
"24\n",
"9\n",
"37\n",
"57\n",
"23\n",
"11\n",
"61\n",
"39\n",
"62\n",
"38\n"
] | 1
|
stdio
|
The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a player gains or loses a particular number of points. In the course of the game the number of points is registered in the line "name score", where name is a player's name, and score is the number of points gained in this round, which is an integer number. If score is negative, this means that the player has lost in the round. So, if two or more players have the maximum number of points (say, it equals to m) at the end of the game, than wins the one of them who scored at least m points first. Initially each player has 0 points. It's guaranteed that at the end of the game at least one player has a positive number of points.
Input
The first line contains an integer number n (1 ≤ n ≤ 1000), n is the number of rounds played. Then follow n lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is an integer number between -1000 and 1000, inclusive.
Output
Print the name of the winner.
Examples
Input
3
mike 3
andrew 5
mike 2
Output
andrew
Input
3
andrew 3
andrew 2
mike 5
Output
andrew
|
[
"15\naawtvezfntstrcpgbzjbf 681\nzhahpvqiptvksnbjkdvmknb -74\naawtvezfntstrcpgbzjbf 661\njpdwmyke 474\naawtvezfntstrcpgbzjbf -547\naawtvezfntstrcpgbzjbf 600\nzhahpvqiptvksnbjkdvmknb -11\njpdwmyke 711\nbjmj 652\naawtvezfntstrcpgbzjbf -1000\naawtvezfntstrcpgbzjbf -171\nbjmj -302\naawtvezfntstrcpgbzjbf 961\nzhahpvqiptvksnbjkdvmknb 848\nbjmj -735\n",
"12\natrtthfpcvishmqbakprquvnejr 185\natrtthfpcvishmqbakprquvnejr -699\natrtthfpcvishmqbakprquvnejr -911\natrtthfpcvishmqbakprquvnejr -220\nfcgslzkicjrpbqaifgweyzreajjfdo 132\nfcgslzkicjrpbqaifgweyzreajjfdo -242\nm 177\nm -549\natrtthfpcvishmqbakprquvnejr -242\nm 38\natrtthfpcvishmqbakprquvnejr -761\nfcgslzkicjrpbqaifgweyzreajjfdo 879\n",
"7\nksjuuerbnlklcfdjeyq 312\ndthjlkrvvbyahttifpdewvyslsh -983\nksjuuerbnlklcfdjeyq 268\ndthjlkrvvbyahttifpdewvyslsh 788\nksjuuerbnlklcfdjeyq -79\nksjuuerbnlklcfdjeyq -593\nksjuuerbnlklcfdjeyq 734\n",
"17\nqdplghhx -649\nivhgbxiv 424\nivhgbxiv -72\nivhgbxiv 479\nugowfouebkelargxylsxn 83\nugowfouebkelargxylsxn -840\nivhgbxiv 382\nqdplghhx -904\nivhgbxiv -710\nugowfouebkelargxylsxn -838\nqdplghhx -974\nqdplghhx 571\nivhgbxiv -145\nugowfouebkelargxylsxn -788\nivhgbxiv 209\nivhgbxiv 420\nqdplghhx -158\n",
"5\nkaxqybeultn -352\nmgochgrmeyieyskhuourfg -910\nkaxqybeultn 691\nmgochgrmeyieyskhuourfg -76\nkaxqybeultn -303\n",
"15\naawtvezfntstrcpgbzjbf 681\nzhahpvqiptvksnbjkdvmknb -139\naawtvezfntstrcpgbzjbf 661\njpdwmyke 474\naawtvezfntstrcpgbzjbf -547\naawtvezfntstrcpgbzjbf 600\nzhahpvqiptvksnbjkdvmknb -11\njpdwmyke 711\nbjmj 652\naawtvezfntstrcpgbzjbf -1000\naawtvezfntstrcpgbzjbf -171\nbjmj -302\naawtvezfntstrcpgbzjbf 961\nzhahpvqiptvksnbjkdvmknb 848\nbjmj -735\n",
"12\natrtthfpcvishmqbakprquvnejr 185\natrtthfpcvishmqbakprquvnejr -699\natrtthfpcvishmqbakprquvnejr -911\natrtthfpcvishmqbakprquvnejr -74\nfcgslzkicjrpbqaifgweyzreajjfdo 132\nfcgslzkicjrpbqaifgweyzreajjfdo -242\nm 177\nm -549\natrtthfpcvishmqbakprquvnejr -242\nm 38\natrtthfpcvishmqbakprquvnejr -761\nfcgslzkicjrpbqaifgweyzreajjfdo 879\n",
"7\nksjuuerbnlklcfdjeyq 430\ndthjlkrvvbyahttifpdewvyslsh -983\nksjuuerbnlklcfdjeyq 268\ndthjlkrvvbyahttifpdewvyslsh 788\nksjuuerbnlklcfdjeyq -79\nksjuuerbnlklcfdjeyq -593\nksjuuerbnlklcfdjeyq 734\n",
"17\nqdplghhx -649\nivhgbxiv 424\nivhgbxiv -72\nivhgbxiv 479\nugowfouebkelargxylsxn 83\nugowfouebkelargxylsxn -840\nivhgbxiv 382\nqdplghhx -904\nivhgbxiv -710\nugowfouebkelargxylsxn -838\nqdplghhx -974\nqdplghhx 571\nivhgbxiv -145\nugowfouebkelargxylsxn -788\nivhgbxiv 209\nivhgbxiv 547\nqdplghhx -158\n",
"5\nkaxqybeultn -53\nmgochgrmeyieyskhuourfg -910\nkaxqybeultn 691\nmgochgrmeyieyskhuourfg -76\nkaxqybeultn -303\n"
] |
[
"aawtvezfntstrcpgbzjbf\n",
"fcgslzkicjrpbqaifgweyzreajjfdo\n",
"ksjuuerbnlklcfdjeyq\n",
"ivhgbxiv\n",
"kaxqybeultn\n",
"aawtvezfntstrcpgbzjbf\n",
"fcgslzkicjrpbqaifgweyzreajjfdo\n",
"ksjuuerbnlklcfdjeyq\n",
"ivhgbxiv\n",
"kaxqybeultn\n"
] | 1
|
stdio
|
A permutation p of size n is an array such that every integer from 1 to n occurs exactly once in this array.
Let's call a permutation an almost identity permutation iff there exist at least n - k indices i (1 ≤ i ≤ n) such that p_{i} = i.
Your task is to count the number of almost identity permutations for given numbers n and k.
-----Input-----
The first line contains two integers n and k (4 ≤ n ≤ 1000, 1 ≤ k ≤ 4).
-----Output-----
Print the number of almost identity permutations for given n and k.
-----Examples-----
Input
4 1
Output
1
Input
4 2
Output
7
Input
5 3
Output
31
Input
5 4
Output
76
|
[
"4 1\n",
"4 2\n",
"5 3\n",
"5 4\n",
"200 1\n",
"200 2\n",
"200 3\n",
"200 4\n",
"400 1\n",
"400 2\n"
] |
[
"1\n",
"7\n",
"31\n",
"76\n",
"1\n",
"19901\n",
"2646701\n",
"584811251\n",
"1\n",
"79801\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 calls a mask of a positive integer n the number that is obtained after successive writing of all lucky digits of number n from the left to the right. For example, the mask of number 72174994 is number 7744, the mask of 7 is 7, the mask of 9999047 is 47. Obviously, mask of any number is always a lucky number.
Petya has two numbers — an arbitrary integer a and a lucky number b. Help him find the minimum number c (c > a) such that the mask of number c equals b.
Input
The only line contains two integers a and b (1 ≤ a, b ≤ 105). It is guaranteed that number b is lucky.
Output
In the only line print a single number — the number c that is sought by Petya.
Examples
Input
1 7
Output
7
Input
100 47
Output
147
|
[
"39999 4774\n",
"40007 74\n",
"31975 74\n",
"69700 77477\n",
"74 77\n",
"45679 77777\n",
"1 4\n",
"40007 74444\n",
"740 4\n",
"369 47\n"
] |
[
"40774\n",
"50074\n",
"32074\n",
"77477\n",
"77\n",
"77777\n",
"4\n",
"74444\n",
"804\n",
"407\n"
] | 1
|
stdio
|
Our master carpenter is designing a condominium called Bange Hills Mansion. The condominium is constructed by stacking up floors of the same height. The height of each floor is designed so that the total height of the stacked floors coincides with the predetermined height of the condominium. The height of each floor can be adjusted freely with a certain range.
The final outcome of the building depends on clever height allotment for each floor. So, he plans to calculate possible combinations of per-floor heights to check how many options he has.
Given the height of the condominium and the adjustable range of each floor’s height, make a program to enumerate the number of choices for a floor.
Input
The input is given in the following format.
$H$ $A$ $B$
The input line provides the height of the condominium $H$ ($1 \leq H \leq 10^5$) and the upper and lower limits $A$ and $B$ of the height adjustable range for one floor ($1 \leq A \leq B \leq H$). All data are given as integers.
Output
Output the number of possible height selections for each floor in a line.
Examples
Input
100 2 4
Output
2
Input
101 3 5
Output
0
|
[
"101 2 5",
"100 2 5",
"111 2 5",
"000 2 5",
"000 2 10",
"000 2 12",
"000 2 18",
"000 2 30",
"000 2 51",
"000 2 50"
] |
[
"0\n",
"3\n",
"1\n",
"4\n",
"9\n",
"11\n",
"17\n",
"29\n",
"50\n",
"49\n"
] | 1
|
stdio
|
Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced programmer. Actually he is not a programmer at all. So he wasn't able to solve them. That's why he asked you to help him with these tasks. One of these tasks is the following.
A sequence of l integers b1, b2, ..., bl (1 ≤ b1 ≤ b2 ≤ ... ≤ bl ≤ n) is called good if each number divides (without a remainder) by the next number in the sequence. More formally <image> for all i (1 ≤ i ≤ l - 1).
Given n and k find the number of good sequences of length k. As the answer can be rather large print it modulo 1000000007 (109 + 7).
Input
The first line of input contains two space-separated integers n, k (1 ≤ n, k ≤ 2000).
Output
Output a single integer — the number of good sequences of length k modulo 1000000007 (109 + 7).
Examples
Input
3 2
Output
5
Input
6 4
Output
39
Input
2 1
Output
2
Note
In the first sample the good sequences are: [1, 1], [2, 2], [3, 3], [1, 2], [1, 3].
|
[
"2000 2000\n",
"1544 1794\n",
"1639 1056\n",
"56 48\n",
"1066 995\n",
"49 110\n",
"478 1301\n",
"158 772\n",
"162 161\n",
"83 37\n"
] |
[
"585712681",
"933285446",
"467464129",
"20742237",
"180753612",
"956247348",
"476483030",
"850911301",
"591739753",
"22793555"
] | 1
|
stdio
|
Takahashi is standing on a two-dimensional plane, facing north. Find the minimum positive integer K such that Takahashi will be at the starting position again after he does the following action K times:
* Go one meter in the direction he is facing. Then, turn X degrees counter-clockwise.
Constraints
* 1 \leq X \leq 179
* X is an integer.
Input
Input is given from Standard Input in the following format:
X
Output
Print the number of times Takahashi will do the action before he is at the starting position again.
Examples
Input
90
Output
4
Input
1
Output
360
|
[
"155",
"2",
"297",
"408",
"643",
"810",
"928",
"1780",
"33",
"70"
] |
[
"72\n",
"180\n",
"40\n",
"15\n",
"360\n",
"4\n",
"45\n",
"18\n",
"120\n",
"36\n"
] | 1
|
stdio
|
You are given an array of non-negative integers, your task is to complete the series from 0 to the highest number in the array.
If the numbers in the sequence provided are not in order you should order them, but if a value repeats, then you must return a sequence with only one item, and the value of that item must be 0. like this:
```
inputs outputs
[2,1] -> [0,1,2]
[1,4,4,6] -> [0]
```
Notes: all numbers are positive integers.
This is set of example outputs based on the input sequence.
```
inputs outputs
[0,1] -> [0,1]
[1,4,6] -> [0,1,2,3,4,5,6]
[3,4,5] -> [0,1,2,3,4,5]
[0,1,0] -> [0]
```
Write your solution by modifying this code:
```python
def complete_series(seq):
```
Your solution should implemented in the function "complete_series". The inputs will be passed to it and it should return the correct solution.
Now solve the problem and return the code.
|
[] |
[] | 1
|
stdio
|
To celebrate the start of the Rio Olympics (and the return of 'the Last Leg' on C4 tonight) this is an Olympic inspired kata.
Given a string of random letters, you need to examine each. Some letters naturally have 'rings' in them. 'O' is an obvious example, but 'b', 'p', 'e', 'A', etc are all just as applicable. 'B' even has two!! Please note for this kata you can count lower case 'g' as only one ring.
Your job is to count the 'rings' in each letter and divide the total number by 2. Round the answer down. Once you have your final score:
if score is 1 or less, return 'Not even a medal!';
if score is 2, return 'Bronze!';
if score is 3, return 'Silver!';
if score is more than 3, return 'Gold!';
Dots over i's and any other letters don't count as rings.
Write your solution by modifying this code:
```python
def olympic_ring(string):
```
Your solution should implemented in the function "olympic_ring". The inputs will be passed to it and it should return the correct solution.
Now solve the problem and return the code.
|
[] |
[] | 1
|
stdio
|
Reca company makes monitors, the most popular of their models is AB999 with the screen size a × b centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ratio x: y became popular with users. That's why the company wants to reduce monitor AB999 size so that its screen sides ratio becomes x: y, at the same time they want its total area to be maximal of all possible variants. Your task is to find the screen parameters of the reduced size model, or find out that such a reduction can't be performed.
Input
The first line of the input contains 4 integers — a, b, x and y (1 ≤ a, b, x, y ≤ 2·109).
Output
If the answer exists, output 2 positive integers — screen parameters of the reduced size model. Output 0 0 otherwise.
Examples
Input
800 600 4 3
Output
800 600
Input
1920 1200 16 9
Output
1920 1080
Input
1 1 1 2
Output
0 0
|
[
"2000000000 2000000000 1999999998 1999999999\n",
"721746595 799202881 143676564 380427290\n",
"266102152 594841161 15854566 13392106\n",
"548893795 861438648 131329677 177735812\n",
"1243276346 1975662240 38441120 291740200\n",
"625166755 843062051 1463070160 1958300154\n",
"1 1 2 1\n",
"912724694 1268739154 440710604 387545692\n",
"1561963718 450925486 475523188 136236856\n",
"754199095 348965411 161206703 67014029\n"
] |
[
"1999999998 1999999999",
"287353128 760854580",
"266043102 224722482",
"525318708 710943248",
"259477560 1969246350",
"0 0",
"0 0",
"881421208 775091384",
"1561914768 447486816",
"754119492 313489356"
] | 1
|
stdio
|
Programmer Sasha has recently begun to study data structures. His coach Stas told him to solve the problem of finding a minimum on the segment of the array in <image>, which Sasha coped with. For Sasha not to think that he had learned all, Stas gave him a new task. For each segment of the fixed length Sasha must find the maximum element of those that occur on the given segment exactly once. Help Sasha solve this problem.
Input
The first line contains two positive integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ n) — the number of array elements and the length of the segment.
Then follow n lines: the i-th one contains a single number ai ( - 109 ≤ ai ≤ 109).
Output
Print n–k + 1 numbers, one per line: on the i-th line print of the maximum number of those numbers from the subarray ai ai + 1 … ai + k - 1 that occur in this subarray exactly 1 time. If there are no such numbers in this subarray, print "Nothing".
Examples
Input
5 3
1
2
2
3
3
Output
1
3
2
Input
6 4
3
3
3
4
4
2
Output
4
Nothing
3
|
[
"10 3\n-55\n-35\n-80\n91\n-96\n-93\n-39\n-77\n4\n29\n",
"10 3\n-6\n2\n79\n-49\n86\n13\n-31\n-71\n57\n93\n",
"10 3\n-38\n68\n-77\n57\n-35\n28\n-61\n-9\n3\n60\n",
"10 3\n-20\n-63\n-64\n45\n-84\n-13\n79\n-31\n70\n-100\n",
"10 3\n2\n-100\n50\n-85\n-48\n68\n-96\n-31\n85\n-29\n",
"10 3\n-13\n26\n-97\n-38\n43\n-12\n80\n3\n8\n45\n",
"10 3\n-84\n25\n-25\n8\n60\n-74\n-98\n48\n-55\n38\n",
"10 3\n-62\n-81\n46\n22\n-84\n19\n-86\n44\n-84\n-73\n",
"10 3\n-55\n-35\n-80\n91\n-119\n-93\n-39\n-77\n4\n29\n",
"10 3\n-6\n2\n79\n-24\n86\n13\n-31\n-71\n57\n93\n"
] |
[
"-35\n91\n91\n91\n-39\n-39\n4\n29\n",
"79\n79\n86\n86\n86\n13\n57\n93\n",
"68\n68\n57\n57\n28\n28\n3\n60\n",
"-20\n45\n45\n45\n79\n79\n79\n70\n",
"50\n50\n50\n68\n68\n68\n85\n85\n",
"26\n26\n43\n43\n80\n80\n80\n45\n",
"25\n25\n60\n60\n60\n48\n48\n48\n",
"46\n46\n46\n22\n19\n44\n44\n44\n",
"-35\n91\n91\n91\n-39\n-39\n4\n29",
"79\n79\n86\n86\n86\n13\n57\n93"
] | 1
|
stdio
|
Division of Big Integers
Given two integers $A$ and $B$, compute the quotient, $\frac{A}{B}$. Round down to the nearest decimal.
Input
Two integers $A$ and $B$ separated by a space character are given in a line.
Output
Print the quotient in a line.
Constraints
* $-1 \times 10^{1000} \leq A, B \leq 10^{1000}$
* $B \ne 0$
Sample Input 1
5 8
Sample Output 1
0
Sample Input 2
100 25
Sample Output 2
4
Sample Input 3
-1 3
Sample Output 3
0
Sample Input 4
12 -3
Sample Output 4
-4
Example
Input
5 8
Output
0
|
[
"5 16",
"9 6",
"18 6",
"18 3",
"21 3",
"21 4",
"16 4",
"2 1",
"52 6",
"36 4"
] |
[
"0\n",
"1\n",
"3\n",
"6\n",
"7\n",
"5\n",
"4\n",
"2\n",
"8\n",
"9\n"
] | 1
|
stdio
|
Rng is going to a festival.
The name of the festival is given to you as a string S, which ends with `FESTIVAL`, from input. Answer the question: "Rng is going to a festival of what?" Output the answer.
Here, assume that the name of "a festival of s" is a string obtained by appending `FESTIVAL` to the end of s. For example, `CODEFESTIVAL` is a festival of `CODE`.
Constraints
* 9 \leq |S| \leq 50
* S consists of uppercase English letters.
* S ends with `FESTIVAL`.
Input
Input is given from Standard Input in the following format:
S
Output
Print the answer to the question: "Rng is going to a festival of what?"
Examples
Input
CODEFESTIVAL
Output
CODE
Input
CODEFESTIVALFESTIVAL
Output
CODEFESTIVAL
Input
YAKINIKUFESTIVAL
Output
YAKINIKU
|
[
"YAKINIJUFESTIVAL",
"CODEFESTIVALFERTIVAL",
"CODEFESTIVAM",
"LAVITSEFUJINIKAY",
"CPDEFESTIVAM",
"LAVITSEEUJINIKAY",
"CODEFESTIWALFESTIWAL",
"LAWITSEFLAWITSEFEDOC",
"BPDEFDSTIVBM",
"CODEFWSTIWALFESTIEAL"
] |
[
"YAKINIJU\n",
"CODEFESTIVAL\n",
"CODE\n",
"LAVITSEF\n",
"CPDE\n",
"LAVITSEE\n",
"CODEFESTIWAL\n",
"LAWITSEFLAWI\n",
"BPDE\n",
"CODEFWSTIWAL\n"
] | 1
|
stdio
|
problem
I want to put as many rectangular tiles as possible on a rectangular wall with a size of $ h $ in height and $ w $ in width, and a size of $ a $ in height and $ b $ in width.
The following conditions must be met when attaching tiles.
* Do not stack tiles.
* Do not apply tiles diagonally, that is, any edge of the tile is parallel or perpendicular to any edge of the wall.
* Do not change the orientation of the tiles, that is, do not swap the vertical and horizontal directions.
When as many tiles as possible are pasted, find the sum of the areas not covered by the tiles.
output
Output the total area of the part not covered by the tile. Also, output a line break at the end.
Example
Input
5 8
2 2
Output
8
|
[
"5 8\n3 2",
"5 8\n6 2",
"6 8\n6 3",
"12 8\n6 3",
"12 8\n9 3",
"16 8\n9 3",
"27 8\n9 6",
"27 8\n9 9",
"27 14\n9 9",
"27 14\n9 16"
] |
[
"16\n",
"40\n",
"12\n",
"24\n",
"42\n",
"74\n",
"54\n",
"216\n",
"135\n",
"378\n"
] | 1
|
stdio
|
You are given three integers $a$, $b$, and $c$. Determine if one of them is the sum of the other two.
-----Input-----
The first line contains a single integer $t$ ($1 \leq t \leq 9261$) — the number of test cases.
The description of each test case consists of three integers $a$, $b$, $c$ ($0 \leq a, b, c \leq 20$).
-----Output-----
For each test case, output "YES" if one of the numbers is the sum of the other two, and "NO" otherwise.
You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
-----Examples-----
Input
7
1 4 3
2 5 8
9 11 20
0 0 0
20 20 20
4 12 3
15 7 8
Output
YES
NO
YES
YES
NO
NO
YES
-----Note-----
In the first test case, $1 + 3 = 4$.
In the second test case, none of the numbers is the sum of the other two.
In the third test case, $9 + 11 = 20$.
|
[
"7\n1 4 3\n2 5 8\n9 11 20\n0 0 0\n20 20 20\n4 12 3\n15 7 8\n",
"12\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n",
"47\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n",
"1\n14 5 14\n",
"19\n19 8 10\n19 8 10\n19 8 10\n19 8 10\n19 8 10\n19 8 10\n19 8 10\n19 8 10\n19 8 10\n19 8 10\n19 8 10\n19 8 10\n19 8 10\n19 8 10\n19 8 10\n19 8 10\n19 8 10\n19 8 10\n19 8 10\n",
"1\n19 18 16\n"
] |
[
"YES\nNO\nYES\nYES\nNO\nNO\nYES\n",
"NO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\n",
"NO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\n",
"NO\n"
] | 1
|
stdio
|
As a strict big brother, I do limit my young brother Vasya on time he spends on computer games. I define a prime-time as a time period till which Vasya have a permission to play computer games. I specify start hour and end hour as pair of integers.
I need a function which will take three numbers - a present moment (current hour), a start hour of allowed time period and an end hour of allowed time period. The function should give answer to a question (as a boolean): "Can Vasya play in specified time?"
If I say that prime-time is from 12 till 15 that means that at 12:00 it's OK to play computer but at 15:00 there should be no more games.
I will allow Vasya to play at least one hour a day.
Write your solution by modifying this code:
```python
def can_i_play(now_hour, start_hour, end_hour):
```
Your solution should implemented in the function "can_i_play". The inputs will be passed to it and it should return the correct solution.
Now solve the problem and return the code.
|
[] |
[] | 1
|
stdio
|
You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so as to meet the following conditions:
1. Each domino completely covers two squares.
2. No two dominoes overlap.
3. Each domino lies entirely inside the board. It is allowed to touch the edges of the board.
Find the maximum number of dominoes, which can be placed under these restrictions.
Input
In a single line you are given two integers M and N — board sizes in squares (1 ≤ M ≤ N ≤ 16).
Output
Output one number — the maximal number of dominoes, which can be placed.
Examples
Input
2 4
Output
4
Input
3 3
Output
4
|
[
"2 6\n",
"1 5\n",
"3 6\n",
"2 5\n",
"3 16\n",
"2 7\n",
"3 10\n",
"14 16\n",
"1 16\n",
"5 16\n"
] |
[
"6\n",
"2\n",
"9\n",
"5\n",
"24\n",
"7\n",
"15\n",
"112\n",
"8\n",
"40\n"
] | 1
|
stdio
|
You need to find if a number can be expressed as sum of two perfect powers. That is, given x find if there exists non negative integers a, b, m, n such that a^m + b^n = x.
Input
First line of the input contains number of test cases T. It is followed by T lines, each line contains a sinle number x.
Output
For each test case, print "Yes" (without quotes) if the number can be expressed as sum of two perfect powers. Otherwise print "No" (without quotes).
Constraints
1 ≤ T ≤ 1000
1 ≤ x ≤ 1000000
m > 1, n > 1
SAMPLE INPUT
5
5
15
9
77
100
SAMPLE OUTPUT
Yes
No
Yes
No
Yes
|
[
"20\n178461\n767271\n143872\n917783\n642681\n496408\n735441\n899441\n265715\n772194\n797342\n833227\n479407\n800158\n613225\n498438\n818615\n750993\n597881\n142739\n",
"20\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n",
"20\n61\n62\n63\n64\n65\n66\n67\n68\n69\n70\n71\n72\n73\n74\n75\n76\n77\n78\n79\n80\n",
"20\n9783\n879497\n203664\n981484\n588099\n299151\n782262\n108971\n368524\n643461\n815444\n33663\n479878\n908619\n879890\n768921\n703812\n628957\n849817\n569957\n",
"20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n",
"20\n81\n82\n83\n84\n85\n86\n87\n88\n89\n90\n91\n92\n93\n94\n95\n96\n97\n98\n99\n100\n",
"20\n27955\n637815\n90575\n561777\n622205\n466162\n379336\n195938\n91560\n894581\n799253\n948756\n448870\n26762\n507653\n176200\n175215\n499651\n82441\n354697\n",
"20\n89532\n52860\n154942\n702927\n555262\n45319\n154538\n378417\n514950\n823559\n293517\n42254\n465184\n818182\n517039\n54600\n844697\n367974\n240024\n775492\n",
"20\n264222\n464589\n278778\n512505\n720206\n948799\n760706\n765895\n179271\n919305\n920275\n327537\n100541\n533079\n570278\n502602\n599706\n473784\n928170\n422924\n",
"20\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\n60\n"
] |
[
"No\nYes\nNo\nNo\nNo\nNo\nYes\nNo\nNo\nYes\nNo\nNo\nYes\nNo\nNo\nNo\nNo\nNo\nNo\nYes\n",
"No\nYes\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nYes\nYes\n",
"No\nNo\nNo\nYes\nYes\nYes\nNo\nYes\nYes\nNo\nYes\nYes\nYes\nYes\nYes\nYes\nYes\nNo\nNo\nYes\n",
"Yes\nNo\nYes\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nNo\nYes\nYes\nYes\nNo\nNo\nYes\nYes\nYes\nNo\n",
"No\nYes\nNo\nNo\nYes\nNo\nNo\nYes\nYes\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nYes\nYes\nNo\nYes\n",
"Yes\nNo\nYes\nYes\nYes\nNo\nNo\nYes\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nYes\nNo\nNo\nNo\nYes\n",
"No\nNo\nNo\nNo\nNo\nNo\nYes\nNo\nNo\nYes\nNo\nYes\nNo\nNo\nNo\nNo\nYes\nNo\nYes\nNo\n",
"Yes\nYes\nNo\nNo\nYes\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nYes\n",
"Yes\nNo\nYes\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nYes\nNo\nNo\nNo\nNo\nNo\nNo\nNo\nNo\n",
"No\nNo\nNo\nNo\nNo\nYes\nYes\nYes\nYes\nYes\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\nYes\n"
] | 1
|
stdio
|
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt.
Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number.
input
The input is given in the following format.
n
a1 v1
a2 v2
::
an vn
n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai.
output
Output the winner's participant number and the number of fish caught on one line separated by blanks.
Example
Input
6
1 14
2 25
3 42
4 11
5 40
6 37
Output
3 42
|
[
"6\n1 14\n4 25\n3 42\n4 11\n5 40\n6 37",
"6\n1 14\n4 25\n3 42\n4 11\n5 60\n6 37",
"6\n1 14\n2 25\n3 81\n4 11\n5 40\n6 37",
"6\n1 14\n4 25\n3 72\n4 11\n5 60\n6 37",
"6\n1 14\n2 25\n3 63\n4 11\n5 40\n6 37",
"6\n1 14\n2 25\n3 55\n4 11\n4 40\n6 59",
"6\n1 14\n2 6\n3 3\n4 3\n5 40\n6 37",
"6\n1 14\n2 25\n3 74\n4 11\n4 40\n6 59",
"6\n1 14\n2 17\n3 131\n4 11\n4 61\n6 66",
"6\n2 14\n2 6\n3 1\n4 3\n5 31\n6 37"
] |
[
"3 42\n",
"5 60\n",
"3 81\n",
"3 72\n",
"3 63\n",
"6 59\n",
"5 40\n",
"3 74\n",
"3 131\n",
"6 37\n"
] | 1
|
stdio
|
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is defined as follows:$f(l, r) = \sum_{i = l}^{r - 1}|a [ i ] - a [ i + 1 ]|\cdot(- 1)^{i - l}$
In the above formula, 1 ≤ l < r ≤ n must hold, where n is the size of the Main Uzhlyandian Array a, and |x| means absolute value of x. But the heroes skipped their math lessons in school, so they asked you for help. Help them calculate the maximum value of f among all possible values of l and r for the given array a.
-----Input-----
The first line contains single integer n (2 ≤ n ≤ 10^5) — the size of the array a.
The second line contains n integers a_1, a_2, ..., a_{n} (-10^9 ≤ a_{i} ≤ 10^9) — the array elements.
-----Output-----
Print the only integer — the maximum value of f.
-----Examples-----
Input
5
1 4 2 3 1
Output
3
Input
4
1 5 4 7
Output
6
-----Note-----
In the first sample case, the optimal value of f is reached on intervals [1, 2] and [2, 5].
In the second case maximal value of f is reachable only on the whole array.
|
[
"5\n1 4 2 3 1\n",
"4\n1 5 4 7\n",
"8\n16 14 12 10 8 100 50 0\n",
"2\n1 1\n",
"50\n-5 -9 0 44 -10 37 34 -49 11 -22 -26 44 8 -13 23 -46 34 12 -24 2 -40 -15 -28 38 -40 -42 -42 7 -43 5 2 -11 10 43 9 49 -13 36 2 24 46 50 -15 -26 -6 -6 8 4 -44 -3\n",
"100\n23 64 60 -45 -36 -64 -59 15 -75 69 -30 -7 -20 17 -77 58 93 -76 -98 -22 -31 16 -50 6 -20 -85 1 64 -88 -8 -15 -6 -57 25 91 10 2 -90 74 -66 -42 73 28 49 -85 59 96 79 -25 49 -59 -89 -75 12 -96 -33 -65 -8 -100 -81 17 99 -91 -5 7 -21 1 85 63 86 -26 85 -31 11 -75 35 -82 15 98 93 -55 66 70 36 -38 8 92 -63 -5 60 -78 -7 -22 -1 4 54 36 16 32 -20\n",
"3\n0 0 0\n",
"3\n0 1 -1\n",
"5\n1000000000 0 0 1000000000 -1000000000\n",
"2\n1000000000 -1000000000\n"
] |
[
"3",
"6",
"92",
"0",
"208",
"632",
"0",
"2",
"2000000000",
"2000000000"
] | 1
|
stdio
|
A little weird green frog speaks in a very strange variation of English: it reverses sentence, omitting all puntuation marks `, ; ( ) - ` except the final exclamation, question or period. We urgently need help with building a proper translator.
To simplify the task, we always use lower-case letters. Apostrophes are forbidden as well.
Translator should be able to process multiple sentences in one go. Sentences are separated by arbitrary amount of spaces.
**Examples**
`you should use python.` -> `python use should you.`
`look, a fly!` -> `fly a look!`
`multisentence is good. is not it?` -> `good is multisentence. it not is?`
Write your solution by modifying this code:
```python
def frogify(s):
```
Your solution should implemented in the function "frogify". The inputs will be passed to it and it should return the correct solution.
Now solve the problem and return the code.
|
[] |
[] | 1
|
stdio
|
The cat Snuke wants to play a popular Japanese game called ÅtCoder, so Iroha has decided to teach him Japanese.
When counting pencils in Japanese, the counter word "本" follows the number. The pronunciation of this word varies depending on the number. Specifically, the pronunciation of "本" in the phrase "N 本" for a positive integer N not exceeding 999 is as follows:
- hon when the digit in the one's place of N is 2, 4, 5, 7, or 9;
- pon when the digit in the one's place of N is 0, 1, 6 or 8;
- bon when the digit in the one's place of N is 3.
Given N, print the pronunciation of "本" in the phrase "N 本".
-----Constraints-----
- N is a positive integer not exceeding 999.
-----Input-----
Input is given from Standard Input in the following format:
N
-----Output-----
Print the answer.
-----Sample Input-----
16
-----Sample Output-----
pon
The digit in the one's place of 16 is 6, so the "本" in "16 本" is pronounced pon.
|
[
"16\n",
"2\n",
"183\n",
"999\n",
"1\n",
"440\n",
"73\n",
"24\n",
"438\n",
"575\n"
] |
[
"pon\n",
"hon\n",
"bon\n",
"hon\n",
"pon\n",
"pon\n",
"bon\n",
"hon\n",
"pon\n",
"hon\n"
] | 1
|
stdio
|
Given a standard english sentence passed in as a string, write a method that will return a sentence made up of the same words, but sorted by their first letter. However, the method of sorting has a twist to it:
* All words that begin with a lower case letter should be at the beginning of the sorted sentence, and sorted in ascending order.
* All words that begin with an upper case letter should come after that, and should be sorted in descending order.
If a word appears multiple times in the sentence, it should be returned multiple times in the sorted sentence. Any punctuation must be discarded.
## Example
For example, given the input string `"Land of the Old Thirteen! Massachusetts land! land of Vermont and Connecticut!"`, your method should return `"and land land of of the Vermont Thirteen Old Massachusetts Land Connecticut"`. Lower case letters are sorted `a -> l -> l -> o -> o -> t` and upper case letters are sorted `V -> T -> O -> M -> L -> C`.
Write your solution by modifying this code:
```python
def pseudo_sort(st):
```
Your solution should implemented in the function "pseudo_sort". The inputs will be passed to it and it should return the correct solution.
Now solve the problem and return the code.
|
[] |
[] | 1
|
stdio
|
You are given a secret message you need to decipher. Here are the things you need to know to decipher it:
For each word:
- the second and the last letter is switched (e.g. `Hello` becomes `Holle`)
- the first letter is replaced by its character code (e.g. `H` becomes `72`)
Note: there are no special characters used, only letters and spaces
Examples
```
decipherThis('72olle 103doo 100ya'); // 'Hello good day'
decipherThis('82yade 115te 103o'); // 'Ready set go'
```
Write your solution by modifying this code:
```python
def decipher_this(string):
```
Your solution should implemented in the function "decipher_this". The inputs will be passed to it and it should return the correct solution.
Now solve the problem and return the code.
|
[] |
[] | 1
|
stdio
|
Consider the following numbers (where `n!` is `factorial(n)`):
```
u1 = (1 / 1!) * (1!)
u2 = (1 / 2!) * (1! + 2!)
u3 = (1 / 3!) * (1! + 2! + 3!)
...
un = (1 / n!) * (1! + 2! + 3! + ... + n!)
```
Which will win: `1 / n!` or `(1! + 2! + 3! + ... + n!)`?
Are these numbers going to `0` because of `1/n!` or to infinity due
to the sum of factorials or to another number?
## Task
Calculate `(1 / n!) * (1! + 2! + 3! + ... + n!)`
for a given `n`, where `n` is an integer greater or equal to `1`.
To avoid discussions about rounding, return the result **truncated** to 6 decimal places, for example:
```
1.0000989217538616 will be truncated to 1.000098
1.2125000000000001 will be truncated to 1.2125
```
## Remark
Keep in mind that factorials grow rather rapidly, and you need to handle large inputs.
## Hint
You could try to simplify the expression.
Write your solution by modifying this code:
```python
def going(n):
```
Your solution should implemented in the function "going". The inputs will be passed to it and it should return the correct solution.
Now solve the problem and return the code.
|
[] |
[] | 1
|
stdio
|
Mrs Jefferson is a great teacher. One of her strategies that helped her to reach astonishing results in the learning process is to have some fun with her students. At school, she wants to make an arrangement of her class to play a certain game with her pupils. For that, she needs to create the arrangement with **the minimum amount of groups that have consecutive sizes**.
Let's see. She has ```14``` students. After trying a bit she could do the needed arrangement:
```[5, 4, 3, 2]```
- one group of ```5``` students
- another group of ```4``` students
- then, another one of ```3```
- and finally, the smallest group of ```2``` students.
As the game was a success, she was asked to help to the other classes to teach and show the game. That's why she desperately needs some help to make this required arrangements that make her spend a lot of time.
To make things worse, she found out that there are some classes with some special number of students that is impossible to get that arrangement.
Please, help this teacher!
Your code will receive the number of students of the class. It should output the arrangement as an array with the consecutive sizes of the groups in decreasing order.
For the special case that no arrangement of the required feature is possible the code should output ```[-1] ```
The value of n is unknown and may be pretty high because some classes joined to to have fun with the game.
You may see more example tests in the Example Tests Cases Box.
Write your solution by modifying this code:
```python
def shortest_arrang(n):
```
Your solution should implemented in the function "shortest_arrang". The inputs will be passed to it and it should return the correct solution.
Now solve the problem and return the code.
|
[] |
[] | 1
|
stdio
|
Write a function that returns the number of '2's in the factorization of a number.
For example,
```python
two_count(24)
```
should return 3, since the factorization of 24 is 2^3 x 3
```python
two_count(17280)
```
should return 7, since the factorization of 17280 is 2^7 x 5 x 3^3
The number passed to two_count (twoCount) will always be a positive integer greater than or equal to 1.
Write your solution by modifying this code:
```python
def two_count(n):
```
Your solution should implemented in the function "two_count". The inputs will be passed to it and it should return the correct solution.
Now solve the problem and return the code.
|
[] |
[] | 1
|
stdio
|
Given a set of $N$ axis-aligned rectangular seals, find the number of overlapped seals on the region which has the maximum number of overlapped seals.
Constraints
* $ 1 \leq N \leq 100000 $
* $ 0 \leq x1_i < x2_i \leq 1000 $
* $ 0 \leq y1_i < y2_i \leq 1000 $
* $ x1_i, y1_i, x2_i, y2_i$ are given in integers
Input
The input is given in the following format.
$N$
$x1_1$ $y1_1$ $x2_1$ $y2_1$
$x1_2$ $y1_2$ $x2_2$ $y2_2$
:
$x1_N$ $y1_N$ $x2_N$ $y2_N$
($x1_i, y1_i$) and ($x2_i, y2_i$) are the coordinates of the top-left and the bottom-right corner of the $i$-th seal respectively.
Output
Print the maximum number of overlapped seals in a line.
Examples
Input
2
0 0 3 2
2 1 4 3
Output
2
Input
2
0 0 2 2
2 0 4 2
Output
1
Input
3
0 0 2 2
0 0 2 2
0 0 2 2
Output
3
|
[
"2\n0 0 2 2\n2 0 4 4",
"3\n0 0 1 2\n0 0 2 2\n0 0 2 2",
"2\n0 0 3 2\n2 1 4 2",
"2\n0 0 0 1\n2 2 4 2",
"2\n0 0 3 1\n2 1 4 3",
"2\n0 0 3 1\n2 1 4 2",
"2\n0 0 3 1\n2 1 4 4",
"2\n0 0 2 2\n2 0 2 2",
"3\n0 0 2 4\n0 0 2 2\n0 0 2 2",
"3\n0 0 1 2\n0 0 2 3\n0 0 2 2"
] |
[
"1\n",
"3\n",
"2\n",
"0\n",
"1\n",
"1\n",
"1\n",
"1\n",
"3\n",
"3\n"
] | 1
|
stdio
|
It is 2050 and romance has long gone, relationships exist solely for practicality.
MatchMyHusband is a website that matches busy working women with perfect house husbands. You have been employed by MatchMyHusband to write a function that determines who matches!!
The rules are... a match occurs providing the husband's "usefulness" rating is greater than or equal to the woman's "needs".
The husband's "usefulness" is the SUM of his cooking, cleaning and childcare abilities and takes the form of an array .
usefulness example --> [15, 26, 19] (15 + 26 + 19) = 60
Every woman that signs up, begins with a "needs" rating of 100. However, it's realised that the longer women wait for their husbands, the more dissatisfied they become with our service. They also become less picky, therefore their needs are subject to exponential decay of 15% per month. https://en.wikipedia.org/wiki/Exponential_decay
Given the number of months since sign up, write a function that returns "Match!" if the husband is useful enough, or "No match!" if he's not.
Write your solution by modifying this code:
```python
def match(usefulness, months):
```
Your solution should implemented in the function "match". The inputs will be passed to it and it should return the correct solution.
Now solve the problem and return the code.
|
[] |
[] | 1
|
stdio
|
# Valid HK Phone Number
## Overview
In Hong Kong, a valid phone number has the format ```xxxx xxxx``` where ```x``` is a decimal digit (0-9). For example:
## Task
Define two functions, ```isValidHKPhoneNumber``` and ```hasValidHKPhoneNumber```, that ```return```s whether a given string is a valid HK phone number and contains a valid HK phone number respectively (i.e. ```true/false``` values).
If in doubt please refer to the example tests.
Write your solution by modifying this code:
```python
def is_valid_HK_phone_number(number):
```
Your solution should implemented in the function "is_valid_HK_phone_number". The inputs will be passed to it and it should return the correct solution.
Now solve the problem and return the code.
|
[] |
[] | 1
|
stdio
|
```if-not:sql
Create a function (or write a script in Shell) that takes an integer as an argument and returns "Even" for even numbers or "Odd" for odd numbers.
```
```if:sql
## SQL Notes:
You will be given a table, `numbers`, with one column `number`.
Return a table with a column `is_even` containing "Even" or "Odd" depending on `number` column values.
### numbers table schema
* number INT
### output table schema
* is_even STRING
```
Write your solution by modifying this code:
```python
def even_or_odd(number):
```
Your solution should implemented in the function "even_or_odd". The inputs will be passed to it and it should return the correct solution.
Now solve the problem and return the code.
|
[] |
[] | 1
|
stdio
|
In this Kata, you will be given a multi-dimensional array containing `2 or more` sub-arrays of integers. Your task is to find the maximum product that can be formed by taking any one element from each sub-array.
```
Examples:
solve( [[1, 2],[3, 4]] ) = 8. The max product is given by 2 * 4
solve( [[10,-15],[-1,-3]] ) = 45, given by (-15) * (-3)
solve( [[1,-1],[2,3],[10,-100]] ) = 300, given by (-1) * 3 * (-100)
```
More examples in test cases. Good luck!
Write your solution by modifying this code:
```python
def solve(arr):
```
Your solution should implemented in the function "solve". The inputs will be passed to it and it should return the correct solution.
Now solve the problem and return the code.
|
[] |
[] | 1
|
stdio
|
Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical.
Constraints
* $0 \leq $ the integer assigned to a face $ \leq 100$
Input
In the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels.
In the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels.
Output
Print "Yes" if two dices are identical, otherwise "No" in a line.
Examples
Input
1 2 3 4 5 6
6 2 4 3 5 1
Output
Yes
Input
1 2 3 4 5 6
6 5 4 3 2 1
Output
No
|
[
"1 2 3 2 5 6\n6 5 4 3 2 1",
"1 2 3 2 5 6\n6 1 4 3 2 1",
"1 2 3 2 5 6\n6 0 4 3 2 1",
"1 2 3 2 5 6\n6 0 4 3 4 1",
"1 2 3 2 7 6\n6 0 4 3 4 1",
"1 2 3 2 7 3\n6 0 4 3 4 1",
"1 2 2 2 7 6\n6 0 4 3 4 1",
"1 2 2 2 7 9\n6 0 4 3 4 1",
"1 2 2 2 7 9\n6 0 4 5 4 1",
"1 0 2 2 7 9\n6 0 4 5 4 1"
] |
[
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n"
] | 1
|
stdio
|
Given a triangle of consecutive odd numbers:
```
1
3 5
7 9 11
13 15 17 19
21 23 25 27 29
...
```
find the triangle's row knowing its index (the rows are 1-indexed), e.g.:
```
odd_row(1) == [1]
odd_row(2) == [3, 5]
odd_row(3) == [7, 9, 11]
```
**Note**: your code should be optimized to handle big inputs.
___
The idea for this kata was taken from this kata: [Sum of odd numbers](https://www.codewars.com/kata/sum-of-odd-numbers)
Write your solution by modifying this code:
```python
def odd_row(n):
```
Your solution should implemented in the function "odd_row". The inputs will be passed to it and it should return the correct solution.
Now solve the problem and return the code.
|
[] |
[] | 1
|
stdio
|
You are given an array a consisting of n positive integers. You pick two integer numbers l and r from 1 to n, inclusive (numbers are picked randomly, equiprobably and independently). If l > r, then you swap values of l and r. You have to calculate the expected value of the number of unique elements in segment of the array from index l to index r, inclusive (1-indexed).
-----Input-----
The first line contains one integer number n (1 ≤ n ≤ 10^6). The second line contains n integer numbers a_1, a_2, ... a_{n} (1 ≤ a_{i} ≤ 10^6) — elements of the array.
-----Output-----
Print one number — the expected number of unique elements in chosen segment.
Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 4} — formally, the answer is correct if $\operatorname{min}(|x - y|, \frac{|x - y|}{x}) \leq 10^{-4}$, where x is jury's answer, and y is your answer.
-----Examples-----
Input
2
1 2
Output
1.500000
Input
2
2 2
Output
1.000000
|
[
"2\n1 2\n",
"2\n2 2\n",
"10\n9 6 8 5 5 2 8 9 2 2\n",
"20\n49 33 9 8 50 21 12 44 23 39 24 10 17 4 17 40 24 19 27 21\n",
"1\n1000000\n",
"10\n9 6 8 5 5 2 8 9 2 2\n",
"20\n49 33 9 8 50 21 12 44 23 39 24 10 17 4 17 40 24 19 27 21\n",
"1\n1000000\n",
"10\n9 6 8 5 5 2 8 9 2 1\n",
"20\n49 33 9 8 50 21 12 44 23 39 24 10 17 4 17 40 24 19 3 21\n"
] |
[
"1.500000\n",
"1.000000\n",
"3.100000\n",
"7.010000\n",
"1.000000\n",
"3.1000",
"7.0100",
"1.0000",
"3.28\n",
"7.01\n"
] | 1
|
stdio
|
You should write a simple function that takes string as input and checks if it is a valid Russian postal code, returning `true` or `false`.
A valid postcode should be 6 digits with no white spaces, letters or other symbols. Empty string should also return false.
Please also keep in mind that a valid post code **cannot start with** `0, 5, 7, 8 or 9`
## Examples
Valid postcodes:
* 198328
* 310003
* 424000
Invalid postcodes:
* 056879
* 12A483
* 1@63
* 111
Write your solution by modifying this code:
```python
def zipvalidate(postcode):
```
Your solution should implemented in the function "zipvalidate". The inputs will be passed to it and it should return the correct solution.
Now solve the problem and return the code.
|
[] |
[] | 1
|
stdio
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.