message stringlengths 2 59.7k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 37 108k | cluster float64 20 20 | __index_level_0__ int64 74 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
You've got two numbers. As long as they are both larger than zero, they go through the same operation: subtract the lesser number from the larger one. If they equal substract one number from the another. For example, one operation transforms pair (4,17) to pair (4,13), it transforms (5,5) to (0,5).
You've got some number of pairs (ai, bi). How many operations will be performed for each of them?
Input
The first line contains the number of pairs n (1 ≤ n ≤ 1000). Then follow n lines, each line contains a pair of positive integers ai, bi (1 ≤ ai, bi ≤ 109).
Output
Print the sought number of operations for each pair on a single line.
Examples
Input
2
4 17
7 987654321
Output
8
141093479 | instruction | 0 | 96,427 | 20 | 192,854 |
Tags: math, number theory
Correct Solution:
```
T = int(input())
for t in range(T):
x, y = [int(n) for n in input().split()]
ops = 0
while x and y:
if x < y:
ops += int(y/x)
y = y % x
elif y < x:
ops += int(x/y)
x = x % y
else:
ops += 1
break
print(ops)
``` | output | 1 | 96,427 | 20 | 192,855 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You've got two numbers. As long as they are both larger than zero, they go through the same operation: subtract the lesser number from the larger one. If they equal substract one number from the another. For example, one operation transforms pair (4,17) to pair (4,13), it transforms (5,5) to (0,5).
You've got some number of pairs (ai, bi). How many operations will be performed for each of them?
Input
The first line contains the number of pairs n (1 ≤ n ≤ 1000). Then follow n lines, each line contains a pair of positive integers ai, bi (1 ≤ ai, bi ≤ 109).
Output
Print the sought number of operations for each pair on a single line.
Examples
Input
2
4 17
7 987654321
Output
8
141093479 | instruction | 0 | 96,428 | 20 | 192,856 |
Tags: math, number theory
Correct Solution:
```
#!/usr/bin/env python3
N = int(input())
def ans(a, b):
if a == 0 or b == 0: return 0
return (a // b) + ans(b, a % b)
for _ in range(N):
a, b = input().split(' ')
a = int(a)
b = int(b)
print(ans(a, b))
``` | output | 1 | 96,428 | 20 | 192,857 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You've got two numbers. As long as they are both larger than zero, they go through the same operation: subtract the lesser number from the larger one. If they equal substract one number from the another. For example, one operation transforms pair (4,17) to pair (4,13), it transforms (5,5) to (0,5).
You've got some number of pairs (ai, bi). How many operations will be performed for each of them?
Input
The first line contains the number of pairs n (1 ≤ n ≤ 1000). Then follow n lines, each line contains a pair of positive integers ai, bi (1 ≤ ai, bi ≤ 109).
Output
Print the sought number of operations for each pair on a single line.
Examples
Input
2
4 17
7 987654321
Output
8
141093479 | instruction | 0 | 96,429 | 20 | 192,858 |
Tags: math, number theory
Correct Solution:
```
for i in range(int(input())):
a,b=map(int,input().split())
sm=0
while a and b:
sm+=a//b
t=b
b=a%b
a=t
print(sm)
``` | output | 1 | 96,429 | 20 | 192,859 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Input
The input contains a single integer a (1 ≤ a ≤ 40).
Output
Output a single string.
Examples
Input
2
Output
Adams
Input
8
Output
Van Buren
Input
29
Output
Harding | instruction | 0 | 96,438 | 20 | 192,876 |
Tags: *special, implementation
Correct Solution:
```
ssr = [0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]
n = int(input())
print(ssr[n])
``` | output | 1 | 96,438 | 20 | 192,877 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Input
The input contains a single integer a (1 ≤ a ≤ 40).
Output
Output a single string.
Examples
Input
2
Output
Adams
Input
8
Output
Van Buren
Input
29
Output
Harding | instruction | 0 | 96,439 | 20 | 192,878 |
Tags: *special, implementation
Correct Solution:
```
# oeis 000001
x = [ 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]
print(x[int(input()) - 1])
``` | output | 1 | 96,439 | 20 | 192,879 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Input
The input contains a single integer a (1 ≤ a ≤ 40).
Output
Output a single string.
Examples
Input
2
Output
Adams
Input
8
Output
Van Buren
Input
29
Output
Harding | instruction | 0 | 96,443 | 20 | 192,886 |
Tags: *special, implementation
Correct Solution:
```
a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]
n=int(input())
print(a[n])
``` | output | 1 | 96,443 | 20 | 192,887 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Input
The input contains a single integer a (1 ≤ a ≤ 40).
Output
Output a single string.
Examples
Input
2
Output
Adams
Input
8
Output
Van Buren
Input
29
Output
Harding | instruction | 0 | 96,444 | 20 | 192,888 |
Tags: *special, implementation
Correct Solution:
```
lis=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]
print(lis[int(input())])
``` | output | 1 | 96,444 | 20 | 192,889 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Input
The input contains a single integer a (1 ≤ a ≤ 40).
Output
Output a single string.
Examples
Input
2
Output
Adams
Input
8
Output
Van Buren
Input
29
Output
Harding | instruction | 0 | 96,445 | 20 | 192,890 |
Tags: *special, implementation
Correct Solution:
```
OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]
print(OeisA000001[int(input())])
``` | output | 1 | 96,445 | 20 | 192,891 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Special Agent Smart Beaver works in a secret research department of ABBYY. He's been working there for a long time and is satisfied with his job, as it allows him to eat out in the best restaurants and order the most expensive and exotic wood types there.
The content special agent has got an important task: to get the latest research by British scientists on the English Language. These developments are encoded and stored in a large safe. The Beaver's teeth are strong enough, so the authorities assured that upon arriving at the place the beaver won't have any problems with opening the safe.
And he finishes his aspen sprig and leaves for this important task. Of course, the Beaver arrived at the location without any problems, but alas. He can't open the safe with his strong and big teeth. At this point, the Smart Beaver get a call from the headquarters and learns that opening the safe with the teeth is not necessary, as a reliable source has sent the following information: the safe code consists of digits and has no leading zeroes. There also is a special hint, which can be used to open the safe. The hint is string s with the following structure:
* if si = "?", then the digit that goes i-th in the safe code can be anything (between 0 to 9, inclusively);
* if si is a digit (between 0 to 9, inclusively), then it means that there is digit si on position i in code;
* if the string contains letters from "A" to "J", then all positions with the same letters must contain the same digits and the positions with distinct letters must contain distinct digits.
* The length of the safe code coincides with the length of the hint.
For example, hint "?JGJ9" has such matching safe code variants: "51919", "55959", "12329", "93539" and so on, and has wrong variants such as: "56669", "00111", "03539" and "13666".
After receiving such information, the authorities change the plan and ask the special agents to work quietly and gently and not to try to open the safe by mechanical means, and try to find the password using the given hint.
At a special agent school the Smart Beaver was the fastest in his platoon finding codes for such safes, but now he is not in that shape: the years take their toll ... Help him to determine the number of possible variants of the code to the safe, matching the given hint. After receiving this information, and knowing his own speed of entering codes, the Smart Beaver will be able to determine whether he will have time for tonight's show "Beavers are on the trail" on his favorite TV channel, or he should work for a sleepless night...
Input
The first line contains string s — the hint to the safe code. String s consists of the following characters: ?, 0-9, A-J. It is guaranteed that the first character of string s doesn't equal to character 0.
The input limits for scoring 30 points are (subproblem A1):
* 1 ≤ |s| ≤ 5.
The input limits for scoring 100 points are (subproblems A1+A2):
* 1 ≤ |s| ≤ 105.
Here |s| means the length of string s.
Output
Print the number of codes that match the given hint.
Examples
Input
AJ
Output
81
Input
1?AA
Output
100
Submitted Solution:
```
import sys
s = input()
use = [0] * 30
diff = 0
for i in s:
c = ord(i) - ord('A')
if (0 <= c and c <= 25): use[c] = True
for i in range(0, 30):
if (use[i]): diff += 1
ans = 1
for i in range(10, 10 - diff, -1):
if (i == 10 and (ord('A') <= ord(s[0]) and ord(s[0]) <= ord('Z'))): ans *= 9
else: ans *= i
j = 0
for i in s:
if (i == '?'):
if (j == 0): ans *= 9
else: ans *= 10
j += 1
print(ans)
``` | instruction | 0 | 96,462 | 20 | 192,924 |
Yes | output | 1 | 96,462 | 20 | 192,925 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Special Agent Smart Beaver works in a secret research department of ABBYY. He's been working there for a long time and is satisfied with his job, as it allows him to eat out in the best restaurants and order the most expensive and exotic wood types there.
The content special agent has got an important task: to get the latest research by British scientists on the English Language. These developments are encoded and stored in a large safe. The Beaver's teeth are strong enough, so the authorities assured that upon arriving at the place the beaver won't have any problems with opening the safe.
And he finishes his aspen sprig and leaves for this important task. Of course, the Beaver arrived at the location without any problems, but alas. He can't open the safe with his strong and big teeth. At this point, the Smart Beaver get a call from the headquarters and learns that opening the safe with the teeth is not necessary, as a reliable source has sent the following information: the safe code consists of digits and has no leading zeroes. There also is a special hint, which can be used to open the safe. The hint is string s with the following structure:
* if si = "?", then the digit that goes i-th in the safe code can be anything (between 0 to 9, inclusively);
* if si is a digit (between 0 to 9, inclusively), then it means that there is digit si on position i in code;
* if the string contains letters from "A" to "J", then all positions with the same letters must contain the same digits and the positions with distinct letters must contain distinct digits.
* The length of the safe code coincides with the length of the hint.
For example, hint "?JGJ9" has such matching safe code variants: "51919", "55959", "12329", "93539" and so on, and has wrong variants such as: "56669", "00111", "03539" and "13666".
After receiving such information, the authorities change the plan and ask the special agents to work quietly and gently and not to try to open the safe by mechanical means, and try to find the password using the given hint.
At a special agent school the Smart Beaver was the fastest in his platoon finding codes for such safes, but now he is not in that shape: the years take their toll ... Help him to determine the number of possible variants of the code to the safe, matching the given hint. After receiving this information, and knowing his own speed of entering codes, the Smart Beaver will be able to determine whether he will have time for tonight's show "Beavers are on the trail" on his favorite TV channel, or he should work for a sleepless night...
Input
The first line contains string s — the hint to the safe code. String s consists of the following characters: ?, 0-9, A-J. It is guaranteed that the first character of string s doesn't equal to character 0.
The input limits for scoring 30 points are (subproblem A1):
* 1 ≤ |s| ≤ 5.
The input limits for scoring 100 points are (subproblems A1+A2):
* 1 ≤ |s| ≤ 105.
Here |s| means the length of string s.
Output
Print the number of codes that match the given hint.
Examples
Input
AJ
Output
81
Input
1?AA
Output
100
Submitted Solution:
```
import math
'''
r,c,n,k = map(int,input().split())
matrix = [['*' for row in range(c)] for column in range(r)]
for i in range(n):
x,y = map(int,input().split())
matrix[x-1][y-1] = '#'
ans = 0
for row1 in range(r):
for row2 in range(r):
if matrix[row1:row2+1].count('#') >= k:
ans+=1
for column1 in range(c):
for column2 in range(column1,c):
count = 0
for row in range(r):
count+=matrix[r][column1:column2+1].count('#')
if count >=k:
ans+=1
print(ans)
'''
s = input()
d = {'?':5,'1':5,'2':5,'3':5,'4':5,'5':5,'6':5,'7':5,'8':5,'9':5,'0':5,'A':0,\
'B':0,'C':0,'D':0,'E':0,'F':0,'G':0,'H':0,'I':0,'J':0}
digit = set([str(i) for i in range(0,10)])
digit.add('?')
ans = 1
count =0
for i in range(1,len(s)):
if d[s[i]] == 0:
count+=1
d[s[i]] = 1
elif s[i] == '?':
d[s[i]]+=1
ans*=pow(10,d['?']-5)
start = 10
if d[s[0]] == 1:
count-=1
ans*=9
start = 9
if d[s[0]] == 0:
ans*=9
start = 9
while count!=0:
ans*=start
start-=1
count-=1
if s[0] == '?':
ans*=9
print(ans)
``` | instruction | 0 | 96,463 | 20 | 192,926 |
Yes | output | 1 | 96,463 | 20 | 192,927 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Special Agent Smart Beaver works in a secret research department of ABBYY. He's been working there for a long time and is satisfied with his job, as it allows him to eat out in the best restaurants and order the most expensive and exotic wood types there.
The content special agent has got an important task: to get the latest research by British scientists on the English Language. These developments are encoded and stored in a large safe. The Beaver's teeth are strong enough, so the authorities assured that upon arriving at the place the beaver won't have any problems with opening the safe.
And he finishes his aspen sprig and leaves for this important task. Of course, the Beaver arrived at the location without any problems, but alas. He can't open the safe with his strong and big teeth. At this point, the Smart Beaver get a call from the headquarters and learns that opening the safe with the teeth is not necessary, as a reliable source has sent the following information: the safe code consists of digits and has no leading zeroes. There also is a special hint, which can be used to open the safe. The hint is string s with the following structure:
* if si = "?", then the digit that goes i-th in the safe code can be anything (between 0 to 9, inclusively);
* if si is a digit (between 0 to 9, inclusively), then it means that there is digit si on position i in code;
* if the string contains letters from "A" to "J", then all positions with the same letters must contain the same digits and the positions with distinct letters must contain distinct digits.
* The length of the safe code coincides with the length of the hint.
For example, hint "?JGJ9" has such matching safe code variants: "51919", "55959", "12329", "93539" and so on, and has wrong variants such as: "56669", "00111", "03539" and "13666".
After receiving such information, the authorities change the plan and ask the special agents to work quietly and gently and not to try to open the safe by mechanical means, and try to find the password using the given hint.
At a special agent school the Smart Beaver was the fastest in his platoon finding codes for such safes, but now he is not in that shape: the years take their toll ... Help him to determine the number of possible variants of the code to the safe, matching the given hint. After receiving this information, and knowing his own speed of entering codes, the Smart Beaver will be able to determine whether he will have time for tonight's show "Beavers are on the trail" on his favorite TV channel, or he should work for a sleepless night...
Input
The first line contains string s — the hint to the safe code. String s consists of the following characters: ?, 0-9, A-J. It is guaranteed that the first character of string s doesn't equal to character 0.
The input limits for scoring 30 points are (subproblem A1):
* 1 ≤ |s| ≤ 5.
The input limits for scoring 100 points are (subproblems A1+A2):
* 1 ≤ |s| ≤ 105.
Here |s| means the length of string s.
Output
Print the number of codes that match the given hint.
Examples
Input
AJ
Output
81
Input
1?AA
Output
100
Submitted Solution:
```
def main():
hint = input()
hint_nodigits = [h for h in hint if not h.isdigit()]
letters = [h for h in hint_nodigits if h != '?']
combs_letters = 1
for i in range(10, 10 - len(set(letters)), -1):
combs_letters *= i
combs_jolly = 10 ** (len(hint_nodigits) - len(letters))
if hint[0] == '?':
combs_jolly = (combs_jolly // 10) * 9
elif hint[0].isalpha():
combs_letters = (combs_letters // 10) * 9
print(combs_letters * combs_jolly)
if __name__ == '__main__':
main()
``` | instruction | 0 | 96,464 | 20 | 192,928 |
Yes | output | 1 | 96,464 | 20 | 192,929 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Special Agent Smart Beaver works in a secret research department of ABBYY. He's been working there for a long time and is satisfied with his job, as it allows him to eat out in the best restaurants and order the most expensive and exotic wood types there.
The content special agent has got an important task: to get the latest research by British scientists on the English Language. These developments are encoded and stored in a large safe. The Beaver's teeth are strong enough, so the authorities assured that upon arriving at the place the beaver won't have any problems with opening the safe.
And he finishes his aspen sprig and leaves for this important task. Of course, the Beaver arrived at the location without any problems, but alas. He can't open the safe with his strong and big teeth. At this point, the Smart Beaver get a call from the headquarters and learns that opening the safe with the teeth is not necessary, as a reliable source has sent the following information: the safe code consists of digits and has no leading zeroes. There also is a special hint, which can be used to open the safe. The hint is string s with the following structure:
* if si = "?", then the digit that goes i-th in the safe code can be anything (between 0 to 9, inclusively);
* if si is a digit (between 0 to 9, inclusively), then it means that there is digit si on position i in code;
* if the string contains letters from "A" to "J", then all positions with the same letters must contain the same digits and the positions with distinct letters must contain distinct digits.
* The length of the safe code coincides with the length of the hint.
For example, hint "?JGJ9" has such matching safe code variants: "51919", "55959", "12329", "93539" and so on, and has wrong variants such as: "56669", "00111", "03539" and "13666".
After receiving such information, the authorities change the plan and ask the special agents to work quietly and gently and not to try to open the safe by mechanical means, and try to find the password using the given hint.
At a special agent school the Smart Beaver was the fastest in his platoon finding codes for such safes, but now he is not in that shape: the years take their toll ... Help him to determine the number of possible variants of the code to the safe, matching the given hint. After receiving this information, and knowing his own speed of entering codes, the Smart Beaver will be able to determine whether he will have time for tonight's show "Beavers are on the trail" on his favorite TV channel, or he should work for a sleepless night...
Input
The first line contains string s — the hint to the safe code. String s consists of the following characters: ?, 0-9, A-J. It is guaranteed that the first character of string s doesn't equal to character 0.
The input limits for scoring 30 points are (subproblem A1):
* 1 ≤ |s| ≤ 5.
The input limits for scoring 100 points are (subproblems A1+A2):
* 1 ≤ |s| ≤ 105.
Here |s| means the length of string s.
Output
Print the number of codes that match the given hint.
Examples
Input
AJ
Output
81
Input
1?AA
Output
100
Submitted Solution:
```
#essi will come back as soon as possible
s = input()
si = len(s)
res = 1
seen = {}
Len = 0
if '0'<= s[0] <='9':
pass
else:
if s[0] == '?':
res *= 9
else:
res*= 9
seen[s[0]] = 1
Len+= 1
tmp = ""
for i in range(1, si):
if '0'<=s[i] <='9':
pass
else:
if s[i] != '?':
if seen.get(s[i], 0) == 0:
res*= (10 - Len)
seen[s[i]] = 1
Len+= 1
else:
pass
else:
tmp+= '0'
print(res, tmp, sep = "")
``` | instruction | 0 | 96,465 | 20 | 192,930 |
Yes | output | 1 | 96,465 | 20 | 192,931 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Special Agent Smart Beaver works in a secret research department of ABBYY. He's been working there for a long time and is satisfied with his job, as it allows him to eat out in the best restaurants and order the most expensive and exotic wood types there.
The content special agent has got an important task: to get the latest research by British scientists on the English Language. These developments are encoded and stored in a large safe. The Beaver's teeth are strong enough, so the authorities assured that upon arriving at the place the beaver won't have any problems with opening the safe.
And he finishes his aspen sprig and leaves for this important task. Of course, the Beaver arrived at the location without any problems, but alas. He can't open the safe with his strong and big teeth. At this point, the Smart Beaver get a call from the headquarters and learns that opening the safe with the teeth is not necessary, as a reliable source has sent the following information: the safe code consists of digits and has no leading zeroes. There also is a special hint, which can be used to open the safe. The hint is string s with the following structure:
* if si = "?", then the digit that goes i-th in the safe code can be anything (between 0 to 9, inclusively);
* if si is a digit (between 0 to 9, inclusively), then it means that there is digit si on position i in code;
* if the string contains letters from "A" to "J", then all positions with the same letters must contain the same digits and the positions with distinct letters must contain distinct digits.
* The length of the safe code coincides with the length of the hint.
For example, hint "?JGJ9" has such matching safe code variants: "51919", "55959", "12329", "93539" and so on, and has wrong variants such as: "56669", "00111", "03539" and "13666".
After receiving such information, the authorities change the plan and ask the special agents to work quietly and gently and not to try to open the safe by mechanical means, and try to find the password using the given hint.
At a special agent school the Smart Beaver was the fastest in his platoon finding codes for such safes, but now he is not in that shape: the years take their toll ... Help him to determine the number of possible variants of the code to the safe, matching the given hint. After receiving this information, and knowing his own speed of entering codes, the Smart Beaver will be able to determine whether he will have time for tonight's show "Beavers are on the trail" on his favorite TV channel, or he should work for a sleepless night...
Input
The first line contains string s — the hint to the safe code. String s consists of the following characters: ?, 0-9, A-J. It is guaranteed that the first character of string s doesn't equal to character 0.
The input limits for scoring 30 points are (subproblem A1):
* 1 ≤ |s| ≤ 5.
The input limits for scoring 100 points are (subproblems A1+A2):
* 1 ≤ |s| ≤ 105.
Here |s| means the length of string s.
Output
Print the number of codes that match the given hint.
Examples
Input
AJ
Output
81
Input
1?AA
Output
100
Submitted Solution:
```
s = input()
l = []
n = '0123456789'
c = 1
z = True
for i in s:
if i == '?':
c*=10
elif i in n:
continue
else:
if i in l:
continue
else:
if z:
c *= 9
l.append(i)
else:
c *= (10 - len(l))
l.append(i)
z = False
print(c)
``` | instruction | 0 | 96,466 | 20 | 192,932 |
No | output | 1 | 96,466 | 20 | 192,933 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Special Agent Smart Beaver works in a secret research department of ABBYY. He's been working there for a long time and is satisfied with his job, as it allows him to eat out in the best restaurants and order the most expensive and exotic wood types there.
The content special agent has got an important task: to get the latest research by British scientists on the English Language. These developments are encoded and stored in a large safe. The Beaver's teeth are strong enough, so the authorities assured that upon arriving at the place the beaver won't have any problems with opening the safe.
And he finishes his aspen sprig and leaves for this important task. Of course, the Beaver arrived at the location without any problems, but alas. He can't open the safe with his strong and big teeth. At this point, the Smart Beaver get a call from the headquarters and learns that opening the safe with the teeth is not necessary, as a reliable source has sent the following information: the safe code consists of digits and has no leading zeroes. There also is a special hint, which can be used to open the safe. The hint is string s with the following structure:
* if si = "?", then the digit that goes i-th in the safe code can be anything (between 0 to 9, inclusively);
* if si is a digit (between 0 to 9, inclusively), then it means that there is digit si on position i in code;
* if the string contains letters from "A" to "J", then all positions with the same letters must contain the same digits and the positions with distinct letters must contain distinct digits.
* The length of the safe code coincides with the length of the hint.
For example, hint "?JGJ9" has such matching safe code variants: "51919", "55959", "12329", "93539" and so on, and has wrong variants such as: "56669", "00111", "03539" and "13666".
After receiving such information, the authorities change the plan and ask the special agents to work quietly and gently and not to try to open the safe by mechanical means, and try to find the password using the given hint.
At a special agent school the Smart Beaver was the fastest in his platoon finding codes for such safes, but now he is not in that shape: the years take their toll ... Help him to determine the number of possible variants of the code to the safe, matching the given hint. After receiving this information, and knowing his own speed of entering codes, the Smart Beaver will be able to determine whether he will have time for tonight's show "Beavers are on the trail" on his favorite TV channel, or he should work for a sleepless night...
Input
The first line contains string s — the hint to the safe code. String s consists of the following characters: ?, 0-9, A-J. It is guaranteed that the first character of string s doesn't equal to character 0.
The input limits for scoring 30 points are (subproblem A1):
* 1 ≤ |s| ≤ 5.
The input limits for scoring 100 points are (subproblems A1+A2):
* 1 ≤ |s| ≤ 105.
Here |s| means the length of string s.
Output
Print the number of codes that match the given hint.
Examples
Input
AJ
Output
81
Input
1?AA
Output
100
Submitted Solution:
```
letras = [0 for i in range(10)]
s = input()
res = 1
for c in range(len(s)):
if s[c] == '?':
if c == 0:
res *= 9
else:
res*=10
if s[c].isalpha():
letras[ord(s[c])-65] += 1
cont = 10
for i in range(10):
if s[0].isalpha() and i == 0:
res *= 9
cont -=1
elif letras[i] != 0:
res *= cont
cont-=1
print(res)
``` | instruction | 0 | 96,467 | 20 | 192,934 |
No | output | 1 | 96,467 | 20 | 192,935 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Special Agent Smart Beaver works in a secret research department of ABBYY. He's been working there for a long time and is satisfied with his job, as it allows him to eat out in the best restaurants and order the most expensive and exotic wood types there.
The content special agent has got an important task: to get the latest research by British scientists on the English Language. These developments are encoded and stored in a large safe. The Beaver's teeth are strong enough, so the authorities assured that upon arriving at the place the beaver won't have any problems with opening the safe.
And he finishes his aspen sprig and leaves for this important task. Of course, the Beaver arrived at the location without any problems, but alas. He can't open the safe with his strong and big teeth. At this point, the Smart Beaver get a call from the headquarters and learns that opening the safe with the teeth is not necessary, as a reliable source has sent the following information: the safe code consists of digits and has no leading zeroes. There also is a special hint, which can be used to open the safe. The hint is string s with the following structure:
* if si = "?", then the digit that goes i-th in the safe code can be anything (between 0 to 9, inclusively);
* if si is a digit (between 0 to 9, inclusively), then it means that there is digit si on position i in code;
* if the string contains letters from "A" to "J", then all positions with the same letters must contain the same digits and the positions with distinct letters must contain distinct digits.
* The length of the safe code coincides with the length of the hint.
For example, hint "?JGJ9" has such matching safe code variants: "51919", "55959", "12329", "93539" and so on, and has wrong variants such as: "56669", "00111", "03539" and "13666".
After receiving such information, the authorities change the plan and ask the special agents to work quietly and gently and not to try to open the safe by mechanical means, and try to find the password using the given hint.
At a special agent school the Smart Beaver was the fastest in his platoon finding codes for such safes, but now he is not in that shape: the years take their toll ... Help him to determine the number of possible variants of the code to the safe, matching the given hint. After receiving this information, and knowing his own speed of entering codes, the Smart Beaver will be able to determine whether he will have time for tonight's show "Beavers are on the trail" on his favorite TV channel, or he should work for a sleepless night...
Input
The first line contains string s — the hint to the safe code. String s consists of the following characters: ?, 0-9, A-J. It is guaranteed that the first character of string s doesn't equal to character 0.
The input limits for scoring 30 points are (subproblem A1):
* 1 ≤ |s| ≤ 5.
The input limits for scoring 100 points are (subproblems A1+A2):
* 1 ≤ |s| ≤ 105.
Here |s| means the length of string s.
Output
Print the number of codes that match the given hint.
Examples
Input
AJ
Output
81
Input
1?AA
Output
100
Submitted Solution:
```
import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(map(int, input().split()))
def lcm(a, b): return abs(a * b) // math.gcd(a, b)
def revn(n): return str(n)[::-1]
def dd(): return collections.defaultdict(int)
def ddl(): return collections.defaultdict(list)
def sieve(n):
if n < 2: return list()
prime = [True for _ in range(n + 1)]
p = 3
while p * p <= n:
if prime[p]:
for i in range(p * 2, n + 1, p):
prime[i] = False
p += 2
r = [2]
for p in range(3, n + 1, 2):
if prime[p]:
r.append(p)
return r
def divs(n, start=1):
r = []
for i in range(start, int(math.sqrt(n) + 1)):
if (n % i == 0):
if (n / i == i):
r.append(i)
else:
r.extend([i, n // i])
return r
def divn(n, primes):
divs_number = 1
for i in primes:
if n == 1:
return divs_number
t = 1
while n % i == 0:
t += 1
n //= i
divs_number *= t
def prime(n):
if n == 2: return True
if n % 2 == 0 or n <= 1: return False
sqr = int(math.sqrt(n)) + 1
for d in range(3, sqr, 2):
if n % d == 0: return False
return True
def convn(number, base):
newnumber = 0
while number > 0:
newnumber += number % base
number //= base
return newnumber
def cdiv(n, k): return n // k + (n % k != 0)
s = input()
d = {}
for c in s:
if c == '?':
pass
elif not c.isdigit():
if c in d:
d[c] += 1
else:
d[c] = 1
if s[0] == '?':
print(9 * 10 ** (s.count('?') - 1) * math.factorial(10) // math.factorial(10 - len(d.keys())))
elif s[0].isalpha():
print(10 ** s.count('?') * 9 * math.factorial(9) // math.factorial(10 - len(d.keys())))
else:
print(10 ** s.count('?') * 10 ** len(d.keys()))
``` | instruction | 0 | 96,468 | 20 | 192,936 |
No | output | 1 | 96,468 | 20 | 192,937 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Special Agent Smart Beaver works in a secret research department of ABBYY. He's been working there for a long time and is satisfied with his job, as it allows him to eat out in the best restaurants and order the most expensive and exotic wood types there.
The content special agent has got an important task: to get the latest research by British scientists on the English Language. These developments are encoded and stored in a large safe. The Beaver's teeth are strong enough, so the authorities assured that upon arriving at the place the beaver won't have any problems with opening the safe.
And he finishes his aspen sprig and leaves for this important task. Of course, the Beaver arrived at the location without any problems, but alas. He can't open the safe with his strong and big teeth. At this point, the Smart Beaver get a call from the headquarters and learns that opening the safe with the teeth is not necessary, as a reliable source has sent the following information: the safe code consists of digits and has no leading zeroes. There also is a special hint, which can be used to open the safe. The hint is string s with the following structure:
* if si = "?", then the digit that goes i-th in the safe code can be anything (between 0 to 9, inclusively);
* if si is a digit (between 0 to 9, inclusively), then it means that there is digit si on position i in code;
* if the string contains letters from "A" to "J", then all positions with the same letters must contain the same digits and the positions with distinct letters must contain distinct digits.
* The length of the safe code coincides with the length of the hint.
For example, hint "?JGJ9" has such matching safe code variants: "51919", "55959", "12329", "93539" and so on, and has wrong variants such as: "56669", "00111", "03539" and "13666".
After receiving such information, the authorities change the plan and ask the special agents to work quietly and gently and not to try to open the safe by mechanical means, and try to find the password using the given hint.
At a special agent school the Smart Beaver was the fastest in his platoon finding codes for such safes, but now he is not in that shape: the years take their toll ... Help him to determine the number of possible variants of the code to the safe, matching the given hint. After receiving this information, and knowing his own speed of entering codes, the Smart Beaver will be able to determine whether he will have time for tonight's show "Beavers are on the trail" on his favorite TV channel, or he should work for a sleepless night...
Input
The first line contains string s — the hint to the safe code. String s consists of the following characters: ?, 0-9, A-J. It is guaranteed that the first character of string s doesn't equal to character 0.
The input limits for scoring 30 points are (subproblem A1):
* 1 ≤ |s| ≤ 5.
The input limits for scoring 100 points are (subproblems A1+A2):
* 1 ≤ |s| ≤ 105.
Here |s| means the length of string s.
Output
Print the number of codes that match the given hint.
Examples
Input
AJ
Output
81
Input
1?AA
Output
100
Submitted Solution:
```
import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(map(int, input().split()))
def lcm(a, b): return abs(a * b) // math.gcd(a, b)
def revn(n): return str(n)[::-1]
def dd(): return collections.defaultdict(int)
def ddl(): return collections.defaultdict(list)
def sieve(n):
if n < 2: return list()
prime = [True for _ in range(n + 1)]
p = 3
while p * p <= n:
if prime[p]:
for i in range(p * 2, n + 1, p):
prime[i] = False
p += 2
r = [2]
for p in range(3, n + 1, 2):
if prime[p]:
r.append(p)
return r
def divs(n, start=1):
r = []
for i in range(start, int(math.sqrt(n) + 1)):
if (n % i == 0):
if (n / i == i):
r.append(i)
else:
r.extend([i, n // i])
return r
def divn(n, primes):
divs_number = 1
for i in primes:
if n == 1:
return divs_number
t = 1
while n % i == 0:
t += 1
n //= i
divs_number *= t
def prime(n):
if n == 2: return True
if n % 2 == 0 or n <= 1: return False
sqr = int(math.sqrt(n)) + 1
for d in range(3, sqr, 2):
if n % d == 0: return False
return True
def convn(number, base):
newnumber = 0
while number > 0:
newnumber += number % base
number //= base
return newnumber
def cdiv(n, k): return n // k + (n % k != 0)
s = input()
d = {}
for c in s:
if c == '?':
pass
elif not c.isdigit():
if c in d:
d[c] += 1
else:
d[c] = 1
if s[0] == '?':
print(9 * 10 ** (s.count('?') - 1) * (11 - len(d.keys())) ** len(d.keys()))
elif s[0].isalpha():
print(10 ** s.count('?') * 9 * (11 - len(d.keys())) ** (len(d.keys()) - 1))
else:
print(10 ** s.count('?') * (11 - len(d.keys())) ** len(d.keys()))
``` | instruction | 0 | 96,469 | 20 | 192,938 |
No | output | 1 | 96,469 | 20 | 192,939 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark.
Note, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.
Input
The first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 109, inclusive.
Output
Print the maximum possible even sum that can be obtained if we use some of the given integers.
Examples
Input
3
1 2 3
Output
6
Input
5
999999999 999999999 999999999 999999999 999999999
Output
3999999996
Note
In the first sample, we can simply take all three integers for a total sum of 6.
In the second sample Wet Shark should take any four out of five integers 999 999 999. | instruction | 0 | 96,583 | 20 | 193,166 |
Tags: implementation
Correct Solution:
```
n=input()
a=[int(i) for i in input().split()]
ma=[i for i in a if i%2==1]
sm=sum(a)
if sm%2!=0:
sm=sm-min(ma)
print(sm)
``` | output | 1 | 96,583 | 20 | 193,167 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark.
Note, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.
Input
The first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 109, inclusive.
Output
Print the maximum possible even sum that can be obtained if we use some of the given integers.
Examples
Input
3
1 2 3
Output
6
Input
5
999999999 999999999 999999999 999999999 999999999
Output
3999999996
Note
In the first sample, we can simply take all three integers for a total sum of 6.
In the second sample Wet Shark should take any four out of five integers 999 999 999. | instruction | 0 | 96,584 | 20 | 193,168 |
Tags: implementation
Correct Solution:
```
n = int(input())
g = []
k = []
for i in range(n):
a = map(int, input().split())
g += a
break
c = sum(g)
for j in g:
if j % 2 != 0:
k.append(j)
for u in g:
if c % 2 == 0:
break
elif c % 2 != 0:
c = c - min(k)
g.remove(min(k))
print(c)
``` | output | 1 | 96,584 | 20 | 193,169 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark.
Note, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.
Input
The first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 109, inclusive.
Output
Print the maximum possible even sum that can be obtained if we use some of the given integers.
Examples
Input
3
1 2 3
Output
6
Input
5
999999999 999999999 999999999 999999999 999999999
Output
3999999996
Note
In the first sample, we can simply take all three integers for a total sum of 6.
In the second sample Wet Shark should take any four out of five integers 999 999 999. | instruction | 0 | 96,585 | 20 | 193,170 |
Tags: implementation
Correct Solution:
```
n = int(input())
a = list(map(int,input().split()))
a.sort()
b = sum(a)
if b % 2 == 0:
print(b)
exit(0)
else:
i = 0
while a[i] % 2 == 0:
i += 1
print(b - a[i])
``` | output | 1 | 96,585 | 20 | 193,171 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark.
Note, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.
Input
The first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 109, inclusive.
Output
Print the maximum possible even sum that can be obtained if we use some of the given integers.
Examples
Input
3
1 2 3
Output
6
Input
5
999999999 999999999 999999999 999999999 999999999
Output
3999999996
Note
In the first sample, we can simply take all three integers for a total sum of 6.
In the second sample Wet Shark should take any four out of five integers 999 999 999. | instruction | 0 | 96,586 | 20 | 193,172 |
Tags: implementation
Correct Solution:
```
n = int(input())
l = list(map(int,input().split()))
o = [i for i in l if i&1]
o.sort()
e = [i for i in l if not i&1]
if len(o)&1:
print(sum(o)+sum(e)-o[0])
else:
print(sum(o)+sum(e))
``` | output | 1 | 96,586 | 20 | 193,173 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark.
Note, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.
Input
The first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 109, inclusive.
Output
Print the maximum possible even sum that can be obtained if we use some of the given integers.
Examples
Input
3
1 2 3
Output
6
Input
5
999999999 999999999 999999999 999999999 999999999
Output
3999999996
Note
In the first sample, we can simply take all three integers for a total sum of 6.
In the second sample Wet Shark should take any four out of five integers 999 999 999. | instruction | 0 | 96,587 | 20 | 193,174 |
Tags: implementation
Correct Solution:
```
n=int(input())
l=list(map(int,input().split()))
a=[]
b=[]
if sum(l)%2==0:
print(sum(l))
else:
for i in l:
if i%2==0:
a.append(i)
else:
b.append(i)
b.sort()
print(sum(a)+sum(b[1:]))
``` | output | 1 | 96,587 | 20 | 193,175 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark.
Note, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.
Input
The first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 109, inclusive.
Output
Print the maximum possible even sum that can be obtained if we use some of the given integers.
Examples
Input
3
1 2 3
Output
6
Input
5
999999999 999999999 999999999 999999999 999999999
Output
3999999996
Note
In the first sample, we can simply take all three integers for a total sum of 6.
In the second sample Wet Shark should take any four out of five integers 999 999 999. | instruction | 0 | 96,588 | 20 | 193,176 |
Tags: implementation
Correct Solution:
```
n=int(input())
l=list(map(int,input().split()))
o=[]
e=[]
for i in l:
if(i%2==0):
e.append(i)
else:
o.append(i)
if(len(o)%2==0):
print(sum(l))
else:
s=0
o.sort()
s=s+sum(o[1:])+sum(e[0:])
print(s)
``` | output | 1 | 96,588 | 20 | 193,177 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark.
Note, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.
Input
The first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 109, inclusive.
Output
Print the maximum possible even sum that can be obtained if we use some of the given integers.
Examples
Input
3
1 2 3
Output
6
Input
5
999999999 999999999 999999999 999999999 999999999
Output
3999999996
Note
In the first sample, we can simply take all three integers for a total sum of 6.
In the second sample Wet Shark should take any four out of five integers 999 999 999. | instruction | 0 | 96,589 | 20 | 193,178 |
Tags: implementation
Correct Solution:
```
input()
a=[*map(int,input().split())]
s,o,m=sum(a),sum(x%2 for x in a),min([x for x in a if x%2],default=0)
print(s-o%2*m)
``` | output | 1 | 96,589 | 20 | 193,179 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark.
Note, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.
Input
The first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 109, inclusive.
Output
Print the maximum possible even sum that can be obtained if we use some of the given integers.
Examples
Input
3
1 2 3
Output
6
Input
5
999999999 999999999 999999999 999999999 999999999
Output
3999999996
Note
In the first sample, we can simply take all three integers for a total sum of 6.
In the second sample Wet Shark should take any four out of five integers 999 999 999. | instruction | 0 | 96,590 | 20 | 193,180 |
Tags: implementation
Correct Solution:
```
a=0
b=10**9
c=0
input()
for _ in map(int,input().split()):
a+=_
if (_%2):
b=min(b,_)
c+=1
if c%2:
a-=b
print(a)
``` | output | 1 | 96,590 | 20 | 193,181 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark.
Note, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.
Input
The first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 109, inclusive.
Output
Print the maximum possible even sum that can be obtained if we use some of the given integers.
Examples
Input
3
1 2 3
Output
6
Input
5
999999999 999999999 999999999 999999999 999999999
Output
3999999996
Note
In the first sample, we can simply take all three integers for a total sum of 6.
In the second sample Wet Shark should take any four out of five integers 999 999 999.
Submitted Solution:
```
n = int(input())
a = list(map(int, input().split()))
sum = 0
odd = []
for i in range(len(a)):
if(a[i] % 2 == 0):
sum += a[i]
else:
odd.append(a[i])
odd.sort(reverse = True)
if(len(odd) % 2 == 1):
odd.remove(odd[-1])
for i in range(len(odd)):
sum += odd[i]
print(sum)
``` | instruction | 0 | 96,591 | 20 | 193,182 |
Yes | output | 1 | 96,591 | 20 | 193,183 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark.
Note, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.
Input
The first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 109, inclusive.
Output
Print the maximum possible even sum that can be obtained if we use some of the given integers.
Examples
Input
3
1 2 3
Output
6
Input
5
999999999 999999999 999999999 999999999 999999999
Output
3999999996
Note
In the first sample, we can simply take all three integers for a total sum of 6.
In the second sample Wet Shark should take any four out of five integers 999 999 999.
Submitted Solution:
```
#!/usr/bin/python3
def main():
n = input()
data = [int(x) for x in input().split()]
_sum = 0
_min = 10**9
for value in data:
_sum += value
if value%2 and value < _min:
_min = value
print(_sum-_min if _sum%2 else _sum)
if __name__ == "__main__": main()
``` | instruction | 0 | 96,592 | 20 | 193,184 |
Yes | output | 1 | 96,592 | 20 | 193,185 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark.
Note, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.
Input
The first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 109, inclusive.
Output
Print the maximum possible even sum that can be obtained if we use some of the given integers.
Examples
Input
3
1 2 3
Output
6
Input
5
999999999 999999999 999999999 999999999 999999999
Output
3999999996
Note
In the first sample, we can simply take all three integers for a total sum of 6.
In the second sample Wet Shark should take any four out of five integers 999 999 999.
Submitted Solution:
```
n=int(input())
l=list(map(int,input().split()))
l.sort()
s=sum(l)
i=0
while s%2!=0:
if l[i]%2!=0:
s-=l[i]
i+=1
print(s)
``` | instruction | 0 | 96,593 | 20 | 193,186 |
Yes | output | 1 | 96,593 | 20 | 193,187 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark.
Note, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.
Input
The first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 109, inclusive.
Output
Print the maximum possible even sum that can be obtained if we use some of the given integers.
Examples
Input
3
1 2 3
Output
6
Input
5
999999999 999999999 999999999 999999999 999999999
Output
3999999996
Note
In the first sample, we can simply take all three integers for a total sum of 6.
In the second sample Wet Shark should take any four out of five integers 999 999 999.
Submitted Solution:
```
n = int(input())
nums = [int(num) for num in input().split()]
odds = []
for num in nums:
if num % 2:
odds.append(num)
if len(odds) % 2:
print(sum(nums) - min(odds))
else:
print(sum(nums))
``` | instruction | 0 | 96,594 | 20 | 193,188 |
Yes | output | 1 | 96,594 | 20 | 193,189 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark.
Note, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.
Input
The first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 109, inclusive.
Output
Print the maximum possible even sum that can be obtained if we use some of the given integers.
Examples
Input
3
1 2 3
Output
6
Input
5
999999999 999999999 999999999 999999999 999999999
Output
3999999996
Note
In the first sample, we can simply take all three integers for a total sum of 6.
In the second sample Wet Shark should take any four out of five integers 999 999 999.
Submitted Solution:
```
import sys
a=sys.stdin.readline()
b=sys.stdin.readline()
b=b.strip().split(" ")
total=0
countOdd=0
oddMin=sys.maxsize
for i in range(len(b)):
b[i]=int(b[i])
if(b[i]%2==0):
total+=b[i]
else:
countOdd+=1
if(b[i]<oddMin):
if(countOdd==1):
none=1
else:
total+=oddMin
oddMin=b[i]
else:
total+=b[i]
if(countOdd%2==0):
total+=oddMin
sys.stdout.write(str(total))
``` | instruction | 0 | 96,595 | 20 | 193,190 |
No | output | 1 | 96,595 | 20 | 193,191 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark.
Note, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.
Input
The first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 109, inclusive.
Output
Print the maximum possible even sum that can be obtained if we use some of the given integers.
Examples
Input
3
1 2 3
Output
6
Input
5
999999999 999999999 999999999 999999999 999999999
Output
3999999996
Note
In the first sample, we can simply take all three integers for a total sum of 6.
In the second sample Wet Shark should take any four out of five integers 999 999 999.
Submitted Solution:
```
N = int(input())
L = []
sumRes = 0
L = input().split(' ')
for i in range(N):
L[i] = int(L[i])
sumRes = sum(L)
while True:
if (sumRes % 2) == 0:
break
sumRes = sumRes - min(L)
L.remove(min(L))
print(sumRes)
``` | instruction | 0 | 96,596 | 20 | 193,192 |
No | output | 1 | 96,596 | 20 | 193,193 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark.
Note, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.
Input
The first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 109, inclusive.
Output
Print the maximum possible even sum that can be obtained if we use some of the given integers.
Examples
Input
3
1 2 3
Output
6
Input
5
999999999 999999999 999999999 999999999 999999999
Output
3999999996
Note
In the first sample, we can simply take all three integers for a total sum of 6.
In the second sample Wet Shark should take any four out of five integers 999 999 999.
Submitted Solution:
```
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 17 03:43:30 2018
@author: arsanuos
"""
def main():
n = int(input())
arr = [int(t) for t in input().split()]
s = 0
tmp = []
for item in arr:
if item % 2 == 0:
s += item
else:
if len(tmp) == 2:
s += tmp.pop()
s += tmp.pop()
tmp.append(item)
else:
tmp.append(item)
if len(tmp) == 2:
s += tmp.pop()
s += tmp.pop()
tmp.append(item)
print(s)
if __name__ == "__main__":
main()
``` | instruction | 0 | 96,597 | 20 | 193,194 |
No | output | 1 | 96,597 | 20 | 193,195 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark.
Note, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.
Input
The first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 109, inclusive.
Output
Print the maximum possible even sum that can be obtained if we use some of the given integers.
Examples
Input
3
1 2 3
Output
6
Input
5
999999999 999999999 999999999 999999999 999999999
Output
3999999996
Note
In the first sample, we can simply take all three integers for a total sum of 6.
In the second sample Wet Shark should take any four out of five integers 999 999 999.
Submitted Solution:
```
n = int(input())
a = list(map(int, input().split()))
s = sum(i for i in a if i % 2 == 0)
odd = sorted(i for i in a if i % 2 == 1)
if len(odd) % 2 == 1:
odd = odd[:-1]
s += sum(odd)
print(s)
``` | instruction | 0 | 96,598 | 20 | 193,196 |
No | output | 1 | 96,598 | 20 | 193,197 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the arithmetic task for first-graders. In the textbook, a certain positive integer x was given. The task was to add x to the sum of the digits of the number x written in decimal numeral system.
Since the number n on the board was small, Vova quickly guessed which x could be in the textbook. Now he wants to get a program which will search for arbitrary values of the number n for all suitable values of x or determine that such x does not exist. Write such a program for Vova.
Input
The first line contains integer n (1 ≤ n ≤ 109).
Output
In the first line print one integer k — number of different values of x satisfying the condition.
In next k lines print these values in ascending order.
Examples
Input
21
Output
1
15
Input
20
Output
0
Note
In the first test case x = 15 there is only one variant: 15 + 1 + 5 = 21.
In the second test case there are no such x. | instruction | 0 | 96,674 | 20 | 193,348 |
Tags: brute force, math
Correct Solution:
```
n = int(input())
def digit_sum(n):
dgsum = 0
while n > 0:
dgsum += n%10
n = n//10
return dgsum
xs = []
for sd in range(1, 100):
if sd > n:
continue
if digit_sum(n-sd) == sd:
xs.append(n-sd)
if len(xs) == 0:
print(0)
else:
print(len(xs))
xs.sort()
print("\n".join(map(str, xs)))
``` | output | 1 | 96,674 | 20 | 193,349 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the arithmetic task for first-graders. In the textbook, a certain positive integer x was given. The task was to add x to the sum of the digits of the number x written in decimal numeral system.
Since the number n on the board was small, Vova quickly guessed which x could be in the textbook. Now he wants to get a program which will search for arbitrary values of the number n for all suitable values of x or determine that such x does not exist. Write such a program for Vova.
Input
The first line contains integer n (1 ≤ n ≤ 109).
Output
In the first line print one integer k — number of different values of x satisfying the condition.
In next k lines print these values in ascending order.
Examples
Input
21
Output
1
15
Input
20
Output
0
Note
In the first test case x = 15 there is only one variant: 15 + 1 + 5 = 21.
In the second test case there are no such x. | instruction | 0 | 96,675 | 20 | 193,350 |
Tags: brute force, math
Correct Solution:
```
def sum(x):
l=str(x)
i=0
for j in range(len(l)):
i=i+int(l[j])
return i
x=int(input(''))
q=10*(len(str(x)))
q=max(x-q,0)
l=[]
for i in range(q,x):
if ((i+sum(i))==x):
l.append(i)
print(len(l))
for i in range(len(l)):
print(l[i])
``` | output | 1 | 96,675 | 20 | 193,351 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the arithmetic task for first-graders. In the textbook, a certain positive integer x was given. The task was to add x to the sum of the digits of the number x written in decimal numeral system.
Since the number n on the board was small, Vova quickly guessed which x could be in the textbook. Now he wants to get a program which will search for arbitrary values of the number n for all suitable values of x or determine that such x does not exist. Write such a program for Vova.
Input
The first line contains integer n (1 ≤ n ≤ 109).
Output
In the first line print one integer k — number of different values of x satisfying the condition.
In next k lines print these values in ascending order.
Examples
Input
21
Output
1
15
Input
20
Output
0
Note
In the first test case x = 15 there is only one variant: 15 + 1 + 5 = 21.
In the second test case there are no such x. | instruction | 0 | 96,676 | 20 | 193,352 |
Tags: brute force, math
Correct Solution:
```
n = int(input())
a = []
for i in range(n, n-100, -1):
temp = i
ans = temp
while(temp>0):
ans += temp%10
temp = temp//10
if ans == n:
a.insert(0,i)
print(len(a))
for x in a:
print(x)
``` | output | 1 | 96,676 | 20 | 193,353 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the arithmetic task for first-graders. In the textbook, a certain positive integer x was given. The task was to add x to the sum of the digits of the number x written in decimal numeral system.
Since the number n on the board was small, Vova quickly guessed which x could be in the textbook. Now he wants to get a program which will search for arbitrary values of the number n for all suitable values of x or determine that such x does not exist. Write such a program for Vova.
Input
The first line contains integer n (1 ≤ n ≤ 109).
Output
In the first line print one integer k — number of different values of x satisfying the condition.
In next k lines print these values in ascending order.
Examples
Input
21
Output
1
15
Input
20
Output
0
Note
In the first test case x = 15 there is only one variant: 15 + 1 + 5 = 21.
In the second test case there are no such x. | instruction | 0 | 96,677 | 20 | 193,354 |
Tags: brute force, math
Correct Solution:
```
n=int(input())
output=[]
for i in range(max(n-100,0),n):
listi=list(map(int,str(i)))
if(i+sum(listi)==n):
output.append(i)
print(len(output))
for i in range(len(output)):
print(output[i])
``` | output | 1 | 96,677 | 20 | 193,355 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the arithmetic task for first-graders. In the textbook, a certain positive integer x was given. The task was to add x to the sum of the digits of the number x written in decimal numeral system.
Since the number n on the board was small, Vova quickly guessed which x could be in the textbook. Now he wants to get a program which will search for arbitrary values of the number n for all suitable values of x or determine that such x does not exist. Write such a program for Vova.
Input
The first line contains integer n (1 ≤ n ≤ 109).
Output
In the first line print one integer k — number of different values of x satisfying the condition.
In next k lines print these values in ascending order.
Examples
Input
21
Output
1
15
Input
20
Output
0
Note
In the first test case x = 15 there is only one variant: 15 + 1 + 5 = 21.
In the second test case there are no such x. | instruction | 0 | 96,678 | 20 | 193,356 |
Tags: brute force, math
Correct Solution:
```
n=int(input())
result,res=0,[]
for i in range(1,min(90,n)):
x,summa=n-i,0
for j,y in enumerate(str(x)):
summa+=int(y)
if x+summa==n:result+=1;res.append(x)
print(result)
res.reverse()
for i,x in enumerate(res):print(x)
``` | output | 1 | 96,678 | 20 | 193,357 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the arithmetic task for first-graders. In the textbook, a certain positive integer x was given. The task was to add x to the sum of the digits of the number x written in decimal numeral system.
Since the number n on the board was small, Vova quickly guessed which x could be in the textbook. Now he wants to get a program which will search for arbitrary values of the number n for all suitable values of x or determine that such x does not exist. Write such a program for Vova.
Input
The first line contains integer n (1 ≤ n ≤ 109).
Output
In the first line print one integer k — number of different values of x satisfying the condition.
In next k lines print these values in ascending order.
Examples
Input
21
Output
1
15
Input
20
Output
0
Note
In the first test case x = 15 there is only one variant: 15 + 1 + 5 = 21.
In the second test case there are no such x. | instruction | 0 | 96,679 | 20 | 193,358 |
Tags: brute force, math
Correct Solution:
```
def som(x):
ans = 0
while x:
ans += x%10
x = x//10
return ans
x = int(input().strip())
n = x-1
ans = []
while n > max(0,x-101):
if som(n)+n == x:
ans.append(n)
n = n-1
print(len(ans))
print('\n'.join(list(map(str, sorted(ans)))))
``` | output | 1 | 96,679 | 20 | 193,359 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the arithmetic task for first-graders. In the textbook, a certain positive integer x was given. The task was to add x to the sum of the digits of the number x written in decimal numeral system.
Since the number n on the board was small, Vova quickly guessed which x could be in the textbook. Now he wants to get a program which will search for arbitrary values of the number n for all suitable values of x or determine that such x does not exist. Write such a program for Vova.
Input
The first line contains integer n (1 ≤ n ≤ 109).
Output
In the first line print one integer k — number of different values of x satisfying the condition.
In next k lines print these values in ascending order.
Examples
Input
21
Output
1
15
Input
20
Output
0
Note
In the first test case x = 15 there is only one variant: 15 + 1 + 5 = 21.
In the second test case there are no such x. | instruction | 0 | 96,680 | 20 | 193,360 |
Tags: brute force, math
Correct Solution:
```
n=int(input())
x=0
L=[]
if n>100:
for i in range(n-81,n):
s=i%10
for j in range(1,10):
s+=((i//(10**j))%10)
if i+s==n:
x+=1
L.append(i)
elif n<101:
for i in range(1,n):
s=i%10+i//10
if i+s==n:
x+=1
L.append(i)
if L==[]:
print(0)
else:
print(x)
for i in L:
print(i)
``` | output | 1 | 96,680 | 20 | 193,361 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the arithmetic task for first-graders. In the textbook, a certain positive integer x was given. The task was to add x to the sum of the digits of the number x written in decimal numeral system.
Since the number n on the board was small, Vova quickly guessed which x could be in the textbook. Now he wants to get a program which will search for arbitrary values of the number n for all suitable values of x or determine that such x does not exist. Write such a program for Vova.
Input
The first line contains integer n (1 ≤ n ≤ 109).
Output
In the first line print one integer k — number of different values of x satisfying the condition.
In next k lines print these values in ascending order.
Examples
Input
21
Output
1
15
Input
20
Output
0
Note
In the first test case x = 15 there is only one variant: 15 + 1 + 5 = 21.
In the second test case there are no such x. | instruction | 0 | 96,681 | 20 | 193,362 |
Tags: brute force, math
Correct Solution:
```
class CodeforcesTask875ASolution:
def __init__(self):
self.result = ''
self.n = 0
def read_input(self):
self.n = int(input())
def process_task(self):
sols = []
for x in range(100):
res = self.n - x
if res > 0:
well = res + sum([int(j) for j in str(res)])
if well == self.n:
sols.append(res)
sols.sort()
self.result = "{0}\n{1}".format(len(sols), "\n".join([str(x) for x in sols]))
def get_result(self):
return self.result
if __name__ == "__main__":
Solution = CodeforcesTask875ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())
``` | output | 1 | 96,681 | 20 | 193,363 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the arithmetic task for first-graders. In the textbook, a certain positive integer x was given. The task was to add x to the sum of the digits of the number x written in decimal numeral system.
Since the number n on the board was small, Vova quickly guessed which x could be in the textbook. Now he wants to get a program which will search for arbitrary values of the number n for all suitable values of x or determine that such x does not exist. Write such a program for Vova.
Input
The first line contains integer n (1 ≤ n ≤ 109).
Output
In the first line print one integer k — number of different values of x satisfying the condition.
In next k lines print these values in ascending order.
Examples
Input
21
Output
1
15
Input
20
Output
0
Note
In the first test case x = 15 there is only one variant: 15 + 1 + 5 = 21.
In the second test case there are no such x.
Submitted Solution:
```
from sys import stdin, stdout
n = int(stdin.readline())
ans = []
for i in range(max(1, n - 1000), n + 1000):
if sum(map(int, list(str(i)))) + i == n:
ans.append(i)
stdout.write(str(len(ans)) + '\n')
ans.sort()
stdout.write('\n'.join(list(map(str, ans))))
``` | instruction | 0 | 96,682 | 20 | 193,364 |
Yes | output | 1 | 96,682 | 20 | 193,365 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the arithmetic task for first-graders. In the textbook, a certain positive integer x was given. The task was to add x to the sum of the digits of the number x written in decimal numeral system.
Since the number n on the board was small, Vova quickly guessed which x could be in the textbook. Now he wants to get a program which will search for arbitrary values of the number n for all suitable values of x or determine that such x does not exist. Write such a program for Vova.
Input
The first line contains integer n (1 ≤ n ≤ 109).
Output
In the first line print one integer k — number of different values of x satisfying the condition.
In next k lines print these values in ascending order.
Examples
Input
21
Output
1
15
Input
20
Output
0
Note
In the first test case x = 15 there is only one variant: 15 + 1 + 5 = 21.
In the second test case there are no such x.
Submitted Solution:
```
#lst = list(map(int, input().strip().split(' ')))
#n,k = map(int, input().strip().split(' '))
n=int(input())
s=str(n)
l=len(s)
if n<11:
if n%2==0:
print(1)
print(n//2)
else:
print(0)
elif n<18 and n%2==0:
print(1)
print(n//2)
elif n==11:
print(1)
print(10)
elif n==13:
print(1)
print(11)
elif n==15:
print(1)
print(12)
elif n==17:
print(1)
print(13)
else:
x=n-l*9
i=x
f=0
c=0
lst=[]
s1=0
while(i<n):
s1=0
sx=str(i)
for j in range(len(sx)):
s1+=int(sx[j])
if s1+i==n:
f=1
c+=1
lst.append(i)
i+=1
if f==0:
print(0)
else:
print(c)
for j in range(c):
print(lst[j],end=" ")
``` | instruction | 0 | 96,683 | 20 | 193,366 |
Yes | output | 1 | 96,683 | 20 | 193,367 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the arithmetic task for first-graders. In the textbook, a certain positive integer x was given. The task was to add x to the sum of the digits of the number x written in decimal numeral system.
Since the number n on the board was small, Vova quickly guessed which x could be in the textbook. Now he wants to get a program which will search for arbitrary values of the number n for all suitable values of x or determine that such x does not exist. Write such a program for Vova.
Input
The first line contains integer n (1 ≤ n ≤ 109).
Output
In the first line print one integer k — number of different values of x satisfying the condition.
In next k lines print these values in ascending order.
Examples
Input
21
Output
1
15
Input
20
Output
0
Note
In the first test case x = 15 there is only one variant: 15 + 1 + 5 = 21.
In the second test case there are no such x.
Submitted Solution:
```
def main():
n = int(input())
solver(n)
def solver(n):
k = 0
nums = []
for x in range(n - 9 * digitCount(n) - 9, n):
if x + sumOfDigits(x) == n:
k += 1
nums.append(x)
print(k)
for x in nums:
print(x)
def digitCount(n):
count = 0
while n > 0:
n //= 10
count += 1
return count
def sumOfDigits(n):
total = 0
while n > 0:
total += n % 10
n //= 10
return total
#solver(21)
main()
``` | instruction | 0 | 96,684 | 20 | 193,368 |
Yes | output | 1 | 96,684 | 20 | 193,369 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the arithmetic task for first-graders. In the textbook, a certain positive integer x was given. The task was to add x to the sum of the digits of the number x written in decimal numeral system.
Since the number n on the board was small, Vova quickly guessed which x could be in the textbook. Now he wants to get a program which will search for arbitrary values of the number n for all suitable values of x or determine that such x does not exist. Write such a program for Vova.
Input
The first line contains integer n (1 ≤ n ≤ 109).
Output
In the first line print one integer k — number of different values of x satisfying the condition.
In next k lines print these values in ascending order.
Examples
Input
21
Output
1
15
Input
20
Output
0
Note
In the first test case x = 15 there is only one variant: 15 + 1 + 5 = 21.
In the second test case there are no such x.
Submitted Solution:
```
def sumDigits(x) :
return sum(list(map(int, str(x))))
n = int(input())
counter = 0
theNumbers = []
digits = len(str(n))
for i in range (max( n - digits *9, 0), n) :
if i+sumDigits(i)==n:
theNumbers.append(i)
counter += 1
print (counter)
for j in range(len(theNumbers)):
print(theNumbers[j])
``` | instruction | 0 | 96,685 | 20 | 193,370 |
Yes | output | 1 | 96,685 | 20 | 193,371 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the arithmetic task for first-graders. In the textbook, a certain positive integer x was given. The task was to add x to the sum of the digits of the number x written in decimal numeral system.
Since the number n on the board was small, Vova quickly guessed which x could be in the textbook. Now he wants to get a program which will search for arbitrary values of the number n for all suitable values of x or determine that such x does not exist. Write such a program for Vova.
Input
The first line contains integer n (1 ≤ n ≤ 109).
Output
In the first line print one integer k — number of different values of x satisfying the condition.
In next k lines print these values in ascending order.
Examples
Input
21
Output
1
15
Input
20
Output
0
Note
In the first test case x = 15 there is only one variant: 15 + 1 + 5 = 21.
In the second test case there are no such x.
Submitted Solution:
```
'''
http://codeforces.com/problemset/problem/875/A
Работает, но долго на значении 100000001
'''
value = int(input())
def display(lst):
for item in sorted(lst):
print(item)
def sum_a_string(integer):
# print(integer)
return sum([int(d) for d in str(integer)])
def make_all_nine(lenght):
return '9' * lenght
def d_max(value):
svalue = str(value)
value_len = len(svalue)
first = svalue[0]
if value_len == 1:
return value
if first == '1':
return sum_a_string(int(make_all_nine(value_len - 1)))
nines_count = value_len - 1
first = str(int(first) - 1)
return sum_a_string(int(first + make_all_nine(nines_count)))
def itter(value):
count = 0
possible_digits = []
if value == 1:
print(count)
display(possible_digits)
return
for num in range(value - d_max(value), value - 1):
result = num + sum_a_string(num)
if result == value:
count += 1
possible_digits.append(num)
print(count)
display(possible_digits)
itter(value)
``` | instruction | 0 | 96,686 | 20 | 193,372 |
No | output | 1 | 96,686 | 20 | 193,373 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the arithmetic task for first-graders. In the textbook, a certain positive integer x was given. The task was to add x to the sum of the digits of the number x written in decimal numeral system.
Since the number n on the board was small, Vova quickly guessed which x could be in the textbook. Now he wants to get a program which will search for arbitrary values of the number n for all suitable values of x or determine that such x does not exist. Write such a program for Vova.
Input
The first line contains integer n (1 ≤ n ≤ 109).
Output
In the first line print one integer k — number of different values of x satisfying the condition.
In next k lines print these values in ascending order.
Examples
Input
21
Output
1
15
Input
20
Output
0
Note
In the first test case x = 15 there is only one variant: 15 + 1 + 5 = 21.
In the second test case there are no such x.
Submitted Solution:
```
n = int(input())
ans = []
for s in range(1, min(n + 1, 99)):
x = n - s
sm = sum(int(i) for i in str(x))
if sm == s:
ans.append(x)
print(len(ans))
for i in ans:
print(i, end=' ')
``` | instruction | 0 | 96,687 | 20 | 193,374 |
No | output | 1 | 96,687 | 20 | 193,375 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the arithmetic task for first-graders. In the textbook, a certain positive integer x was given. The task was to add x to the sum of the digits of the number x written in decimal numeral system.
Since the number n on the board was small, Vova quickly guessed which x could be in the textbook. Now he wants to get a program which will search for arbitrary values of the number n for all suitable values of x or determine that such x does not exist. Write such a program for Vova.
Input
The first line contains integer n (1 ≤ n ≤ 109).
Output
In the first line print one integer k — number of different values of x satisfying the condition.
In next k lines print these values in ascending order.
Examples
Input
21
Output
1
15
Input
20
Output
0
Note
In the first test case x = 15 there is only one variant: 15 + 1 + 5 = 21.
In the second test case there are no such x.
Submitted Solution:
```
n = int(input())
a = 1
while(a<n):
j = 0
s = str(a)
c = a
while j<len(s):
c = c + int(s[j])
j = j + 1
if(c==n):
break
a = a + 1
print(a)
``` | instruction | 0 | 96,688 | 20 | 193,376 |
No | output | 1 | 96,688 | 20 | 193,377 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the arithmetic task for first-graders. In the textbook, a certain positive integer x was given. The task was to add x to the sum of the digits of the number x written in decimal numeral system.
Since the number n on the board was small, Vova quickly guessed which x could be in the textbook. Now he wants to get a program which will search for arbitrary values of the number n for all suitable values of x or determine that such x does not exist. Write such a program for Vova.
Input
The first line contains integer n (1 ≤ n ≤ 109).
Output
In the first line print one integer k — number of different values of x satisfying the condition.
In next k lines print these values in ascending order.
Examples
Input
21
Output
1
15
Input
20
Output
0
Note
In the first test case x = 15 there is only one variant: 15 + 1 + 5 = 21.
In the second test case there are no such x.
Submitted Solution:
```
def sumOfdig(x):
ans = 0
while x:
ans += x%10
x //= 10
return ans
n = int(input().strip())
x = n-1
ans = []
while x > max(0, n-101):
if sumOfdig(x) + x == n:
ans.append(str(x))
x -= 1
print(len(ans))
print('\n'.join(ans))
``` | instruction | 0 | 96,689 | 20 | 193,378 |
No | output | 1 | 96,689 | 20 | 193,379 |
Provide a correct Python 3 solution for this coding contest problem.
Find the smallest possible sum of the digits in the decimal notation of a positive multiple of K.
Constraints
* 2 \leq K \leq 10^5
* K is an integer.
Input
Input is given from Standard Input in the following format:
K
Output
Print the smallest possible sum of the digits in the decimal notation of a positive multiple of K.
Examples
Input
6
Output
3
Input
41
Output
5
Input
79992
Output
36 | instruction | 0 | 97,703 | 20 | 195,406 |
"Correct Solution:
```
from collections import deque
K = int(input())
cost = [-1] * K
deq = deque([(1,1)])
while deq:
x, d = deq.popleft()
if cost[x] >= 0: continue
cost[x] = d
if x == 0: break
for y, c in [(10*x%K, 0), ((x+1)%K, 1)]:
if c: deq.append((y, d + 1))
else: deq.appendleft((y, d))
print(cost[0])
``` | output | 1 | 97,703 | 20 | 195,407 |
Provide a correct Python 3 solution for this coding contest problem.
Find the smallest possible sum of the digits in the decimal notation of a positive multiple of K.
Constraints
* 2 \leq K \leq 10^5
* K is an integer.
Input
Input is given from Standard Input in the following format:
K
Output
Print the smallest possible sum of the digits in the decimal notation of a positive multiple of K.
Examples
Input
6
Output
3
Input
41
Output
5
Input
79992
Output
36 | instruction | 0 | 97,704 | 20 | 195,408 |
"Correct Solution:
```
from collections import deque
K = int(input())
d = [-1] * K
Q = [0] * (K + 1)
p = 0 # Qの先頭(次に取り出す場所)
q = 0 # Qの末尾(次に入れる場所)
d[1] = 1
Q[q] = 1
q += 1
while q - p > 0:
# 距離0の探索
sp = p
ep = q
while ep - sp > 0:
for i in range(sp, ep):
x = Q[i]
y = 10 * x % K
if d[y] < 0:
d[y] = d[x]
Q[q] = y
q += 1
sp, ep = ep, q
# 距離1の探索
for i in range(p, q):
x = Q[i]
p += 1
y = (x + 1) % K
if d[y] < 0:
d[y] = d[x] + 1
Q[q] = y
q += 1
print(d[0])
``` | output | 1 | 97,704 | 20 | 195,409 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.