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 |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When Serezha was three years old, he was given a set of cards with letters for his birthday. They were arranged into words in the way which formed the boy's mother favorite number in binary notation. Serezha started playing with them immediately and shuffled them because he wasn't yet able to read. His father decided to rearrange them. Help him restore the original number, on condition that it was the maximum possible one.
Input
The first line contains a single integer n (1 β©½ n β©½ 10^5) β the length of the string. The second line contains a string consisting of English lowercase letters: 'z', 'e', 'r', 'o' and 'n'.
It is guaranteed that it is possible to rearrange the letters in such a way that they form a sequence of words, each being either "zero" which corresponds to the digit 0 or "one" which corresponds to the digit 1.
Output
Print the maximum possible number in binary notation. Print binary digits separated by a space. The leading zeroes are allowed.
Examples
Input
4
ezor
Output
0
Input
10
nznooeeoer
Output
1 1 0
Note
In the first example, the correct initial ordering is "zero".
In the second example, the correct initial ordering is "oneonezero".
Submitted Solution:
```
a = int(input())
b = str(input())
g =[]
for i in range(0, len(b)-1):
if b[i] == "z":
g.append(0)
if b[i] == "n":
g.append(1)
print(*g)
``` | instruction | 0 | 103,006 | 20 | 206,012 |
No | output | 1 | 103,006 | 20 | 206,013 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When Serezha was three years old, he was given a set of cards with letters for his birthday. They were arranged into words in the way which formed the boy's mother favorite number in binary notation. Serezha started playing with them immediately and shuffled them because he wasn't yet able to read. His father decided to rearrange them. Help him restore the original number, on condition that it was the maximum possible one.
Input
The first line contains a single integer n (1 β©½ n β©½ 10^5) β the length of the string. The second line contains a string consisting of English lowercase letters: 'z', 'e', 'r', 'o' and 'n'.
It is guaranteed that it is possible to rearrange the letters in such a way that they form a sequence of words, each being either "zero" which corresponds to the digit 0 or "one" which corresponds to the digit 1.
Output
Print the maximum possible number in binary notation. Print binary digits separated by a space. The leading zeroes are allowed.
Examples
Input
4
ezor
Output
0
Input
10
nznooeeoer
Output
1 1 0
Note
In the first example, the correct initial ordering is "zero".
In the second example, the correct initial ordering is "oneonezero".
Submitted Solution:
```
n = int(input())
cards = list(input())
zeros = cards.count("z")
ones = cards.count("o") - zeros
bn = []
for i in range(ones):
bn.append("1")
for i in range(zeros):
bn.append("0")
print("".join(bn))
``` | instruction | 0 | 103,007 | 20 | 206,014 |
No | output | 1 | 103,007 | 20 | 206,015 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When Serezha was three years old, he was given a set of cards with letters for his birthday. They were arranged into words in the way which formed the boy's mother favorite number in binary notation. Serezha started playing with them immediately and shuffled them because he wasn't yet able to read. His father decided to rearrange them. Help him restore the original number, on condition that it was the maximum possible one.
Input
The first line contains a single integer n (1 β©½ n β©½ 10^5) β the length of the string. The second line contains a string consisting of English lowercase letters: 'z', 'e', 'r', 'o' and 'n'.
It is guaranteed that it is possible to rearrange the letters in such a way that they form a sequence of words, each being either "zero" which corresponds to the digit 0 or "one" which corresponds to the digit 1.
Output
Print the maximum possible number in binary notation. Print binary digits separated by a space. The leading zeroes are allowed.
Examples
Input
4
ezor
Output
0
Input
10
nznooeeoer
Output
1 1 0
Note
In the first example, the correct initial ordering is "zero".
In the second example, the correct initial ordering is "oneonezero".
Submitted Solution:
```
n=int(input())
s=input()
d={"n":0,"z":0}
for i in s:
if i in d:
d[i]+=1
x,y=d["n"],d["z"]
l="1"*x+"0"*y
l=int(l)
print(l)
``` | instruction | 0 | 103,008 | 20 | 206,016 |
No | output | 1 | 103,008 | 20 | 206,017 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When Serezha was three years old, he was given a set of cards with letters for his birthday. They were arranged into words in the way which formed the boy's mother favorite number in binary notation. Serezha started playing with them immediately and shuffled them because he wasn't yet able to read. His father decided to rearrange them. Help him restore the original number, on condition that it was the maximum possible one.
Input
The first line contains a single integer n (1 β©½ n β©½ 10^5) β the length of the string. The second line contains a string consisting of English lowercase letters: 'z', 'e', 'r', 'o' and 'n'.
It is guaranteed that it is possible to rearrange the letters in such a way that they form a sequence of words, each being either "zero" which corresponds to the digit 0 or "one" which corresponds to the digit 1.
Output
Print the maximum possible number in binary notation. Print binary digits separated by a space. The leading zeroes are allowed.
Examples
Input
4
ezor
Output
0
Input
10
nznooeeoer
Output
1 1 0
Note
In the first example, the correct initial ordering is "zero".
In the second example, the correct initial ordering is "oneonezero".
Submitted Solution:
```
s = input()
n = s.count('n')
r = s.count('r')
for i in range(n):
print(1,end=' ')
for i in range(r):
print(0,end=' ')
``` | instruction | 0 | 103,009 | 20 | 206,018 |
No | output | 1 | 103,009 | 20 | 206,019 |
Provide tags and a correct Python 3 solution for this coding contest problem.
When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us arithmetics from the start. And what is the best way to teach students add and subtract? β That's right, using counting sticks! An here's our new task:
An expression of counting sticks is an expression of type:
[ A sticks][sign +][B sticks][sign =][C sticks] (1 β€ A, B, C).
Sign + consists of two crossed sticks: one vertical and one horizontal. Sign = consists of two horizontal sticks. The expression is arithmetically correct if A + B = C.
We've got an expression that looks like A + B = C given by counting sticks. Our task is to shift at most one stick (or we can shift nothing) so that the expression became arithmetically correct. Note that we cannot remove the sticks from the expression, also we cannot shift the sticks from the signs + and =.
We really aren't fabulous at arithmetics. Can you help us?
Input
The single line contains the initial expression. It is guaranteed that the expression looks like A + B = C, where 1 β€ A, B, C β€ 100.
Output
If there isn't a way to shift the stick so the expression becomes correct, print on a single line "Impossible" (without the quotes). If there is a way, print the resulting expression. Follow the format of the output from the test samples. Don't print extra space characters.
If there are multiple correct answers, print any of them. For clarifications, you are recommended to see the test samples.
Examples
Input
||+|=|||||
Output
|||+|=||||
Input
|||||+||=||
Output
Impossible
Input
|+|=||||||
Output
Impossible
Input
||||+||=||||||
Output
||||+||=||||||
Note
In the first sample we can shift stick from the third group of sticks to the first one.
In the second sample we cannot shift vertical stick from + sign to the second group of sticks. So we cannot make a - sign.
There is no answer in the third sample because we cannot remove sticks from the expression.
In the forth sample the initial expression is already arithmetically correct and that is why we don't have to shift sticks. | instruction | 0 | 103,207 | 20 | 206,414 |
Tags: brute force, implementation
Correct Solution:
```
# https://codeforces.com/problemset/problem/394/A
# A. Counting Sticks
input_str = input()
b1, b2, b3 = 0, 0, 0
in_b1, in_b2 = True, False
for x in input_str:
if x == '|':
if in_b1:
b1 += 1
elif in_b2:
b2 += 1
else:
b3 += 1
elif x == '+':
in_b1, in_b2 = False, True
else:
in_b2 = False
if b1 + b2 == b3:
pass
elif b1 + b2 == b3 + 2:
if b1 > 1:
b1 -= 1
else:
b2 -= 1
b3 += 1
elif b1 + b2 + 2 == b3:
b2 += 1
b3 -= 1
else:
print("Impossible")
exit()
print('|' * b1 + '+' + '|' * b2 + '=' + b3 * '|')
``` | output | 1 | 103,207 | 20 | 206,415 |
Provide tags and a correct Python 3 solution for this coding contest problem.
When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us arithmetics from the start. And what is the best way to teach students add and subtract? β That's right, using counting sticks! An here's our new task:
An expression of counting sticks is an expression of type:
[ A sticks][sign +][B sticks][sign =][C sticks] (1 β€ A, B, C).
Sign + consists of two crossed sticks: one vertical and one horizontal. Sign = consists of two horizontal sticks. The expression is arithmetically correct if A + B = C.
We've got an expression that looks like A + B = C given by counting sticks. Our task is to shift at most one stick (or we can shift nothing) so that the expression became arithmetically correct. Note that we cannot remove the sticks from the expression, also we cannot shift the sticks from the signs + and =.
We really aren't fabulous at arithmetics. Can you help us?
Input
The single line contains the initial expression. It is guaranteed that the expression looks like A + B = C, where 1 β€ A, B, C β€ 100.
Output
If there isn't a way to shift the stick so the expression becomes correct, print on a single line "Impossible" (without the quotes). If there is a way, print the resulting expression. Follow the format of the output from the test samples. Don't print extra space characters.
If there are multiple correct answers, print any of them. For clarifications, you are recommended to see the test samples.
Examples
Input
||+|=|||||
Output
|||+|=||||
Input
|||||+||=||
Output
Impossible
Input
|+|=||||||
Output
Impossible
Input
||||+||=||||||
Output
||||+||=||||||
Note
In the first sample we can shift stick from the third group of sticks to the first one.
In the second sample we cannot shift vertical stick from + sign to the second group of sticks. So we cannot make a - sign.
There is no answer in the third sample because we cannot remove sticks from the expression.
In the forth sample the initial expression is already arithmetically correct and that is why we don't have to shift sticks. | instruction | 0 | 103,208 | 20 | 206,416 |
Tags: brute force, implementation
Correct Solution:
```
s = input()
p = s.find('+')
r = s.find('=')
if r - 1 == len(s) - r - 1:
print(s)
exit(0)
if abs((r - 1) - (len(s) - r - 1)) != 2:
print('Impossible')
exit(0)
if (r - 1) > (len(s) - r - 1):
if p != 1:
print(s[1:] + s[0])
else:
print('|+' + '|' * (r - 3) + '=' + '|' * (len(s) - r))
else:
print(s[-1] + s[:-1])
``` | output | 1 | 103,208 | 20 | 206,417 |
Provide tags and a correct Python 3 solution for this coding contest problem.
When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us arithmetics from the start. And what is the best way to teach students add and subtract? β That's right, using counting sticks! An here's our new task:
An expression of counting sticks is an expression of type:
[ A sticks][sign +][B sticks][sign =][C sticks] (1 β€ A, B, C).
Sign + consists of two crossed sticks: one vertical and one horizontal. Sign = consists of two horizontal sticks. The expression is arithmetically correct if A + B = C.
We've got an expression that looks like A + B = C given by counting sticks. Our task is to shift at most one stick (or we can shift nothing) so that the expression became arithmetically correct. Note that we cannot remove the sticks from the expression, also we cannot shift the sticks from the signs + and =.
We really aren't fabulous at arithmetics. Can you help us?
Input
The single line contains the initial expression. It is guaranteed that the expression looks like A + B = C, where 1 β€ A, B, C β€ 100.
Output
If there isn't a way to shift the stick so the expression becomes correct, print on a single line "Impossible" (without the quotes). If there is a way, print the resulting expression. Follow the format of the output from the test samples. Don't print extra space characters.
If there are multiple correct answers, print any of them. For clarifications, you are recommended to see the test samples.
Examples
Input
||+|=|||||
Output
|||+|=||||
Input
|||||+||=||
Output
Impossible
Input
|+|=||||||
Output
Impossible
Input
||||+||=||||||
Output
||||+||=||||||
Note
In the first sample we can shift stick from the third group of sticks to the first one.
In the second sample we cannot shift vertical stick from + sign to the second group of sticks. So we cannot make a - sign.
There is no answer in the third sample because we cannot remove sticks from the expression.
In the forth sample the initial expression is already arithmetically correct and that is why we don't have to shift sticks. | instruction | 0 | 103,209 | 20 | 206,418 |
Tags: brute force, implementation
Correct Solution:
```
org = input()
S = org.split("+")
A = S[0].count("|")
S = S[1].split("=")
B = S[0].count("|")
C = S[1].count("|")
if (A+B) - C == -2:
print("|"*(A+1) + "+"+ "|"*B + "=" +"|"*(C-1))
elif (A+B) - C == 2:
if A > 1:
print("|"*(A-1) + "+"+ "|"*B + "=" +"|"*(C+1))
else:
print("|"*A + "+"+ "|"*(B-1) + "=" +"|"*(C+1))
elif A+B == C:
print(org)
else:
print("Impossible")
``` | output | 1 | 103,209 | 20 | 206,419 |
Provide tags and a correct Python 3 solution for this coding contest problem.
When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us arithmetics from the start. And what is the best way to teach students add and subtract? β That's right, using counting sticks! An here's our new task:
An expression of counting sticks is an expression of type:
[ A sticks][sign +][B sticks][sign =][C sticks] (1 β€ A, B, C).
Sign + consists of two crossed sticks: one vertical and one horizontal. Sign = consists of two horizontal sticks. The expression is arithmetically correct if A + B = C.
We've got an expression that looks like A + B = C given by counting sticks. Our task is to shift at most one stick (or we can shift nothing) so that the expression became arithmetically correct. Note that we cannot remove the sticks from the expression, also we cannot shift the sticks from the signs + and =.
We really aren't fabulous at arithmetics. Can you help us?
Input
The single line contains the initial expression. It is guaranteed that the expression looks like A + B = C, where 1 β€ A, B, C β€ 100.
Output
If there isn't a way to shift the stick so the expression becomes correct, print on a single line "Impossible" (without the quotes). If there is a way, print the resulting expression. Follow the format of the output from the test samples. Don't print extra space characters.
If there are multiple correct answers, print any of them. For clarifications, you are recommended to see the test samples.
Examples
Input
||+|=|||||
Output
|||+|=||||
Input
|||||+||=||
Output
Impossible
Input
|+|=||||||
Output
Impossible
Input
||||+||=||||||
Output
||||+||=||||||
Note
In the first sample we can shift stick from the third group of sticks to the first one.
In the second sample we cannot shift vertical stick from + sign to the second group of sticks. So we cannot make a - sign.
There is no answer in the third sample because we cannot remove sticks from the expression.
In the forth sample the initial expression is already arithmetically correct and that is why we don't have to shift sticks. | instruction | 0 | 103,210 | 20 | 206,420 |
Tags: brute force, implementation
Correct Solution:
```
str = input()
i = 0
A = str.split('+')[0].count('|')
A_ = str.split('+')[1]
B = A_.split('=')[0].count('|')
C = A_.split('=')[1].count('|')
if A + B == C:
print(str)
else:
if A + 1 + B == C - 1:
print('|' * ( A + 1 ) + '+' + '|' * B + '=' + '|' * ( C - 1 ) )
elif A + B - 1 == C + 1:
if A - 1 <= 0:
print('|' * A + '+' + '|' * ( B - 1 ) + '=' + '|' * (C + 1))
else:
print('|' * (A - 1) + '+' + '|' * B + '=' + '|' * (C + 1))
else:
print('Impossible')
``` | output | 1 | 103,210 | 20 | 206,421 |
Provide tags and a correct Python 3 solution for this coding contest problem.
When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us arithmetics from the start. And what is the best way to teach students add and subtract? β That's right, using counting sticks! An here's our new task:
An expression of counting sticks is an expression of type:
[ A sticks][sign +][B sticks][sign =][C sticks] (1 β€ A, B, C).
Sign + consists of two crossed sticks: one vertical and one horizontal. Sign = consists of two horizontal sticks. The expression is arithmetically correct if A + B = C.
We've got an expression that looks like A + B = C given by counting sticks. Our task is to shift at most one stick (or we can shift nothing) so that the expression became arithmetically correct. Note that we cannot remove the sticks from the expression, also we cannot shift the sticks from the signs + and =.
We really aren't fabulous at arithmetics. Can you help us?
Input
The single line contains the initial expression. It is guaranteed that the expression looks like A + B = C, where 1 β€ A, B, C β€ 100.
Output
If there isn't a way to shift the stick so the expression becomes correct, print on a single line "Impossible" (without the quotes). If there is a way, print the resulting expression. Follow the format of the output from the test samples. Don't print extra space characters.
If there are multiple correct answers, print any of them. For clarifications, you are recommended to see the test samples.
Examples
Input
||+|=|||||
Output
|||+|=||||
Input
|||||+||=||
Output
Impossible
Input
|+|=||||||
Output
Impossible
Input
||||+||=||||||
Output
||||+||=||||||
Note
In the first sample we can shift stick from the third group of sticks to the first one.
In the second sample we cannot shift vertical stick from + sign to the second group of sticks. So we cannot make a - sign.
There is no answer in the third sample because we cannot remove sticks from the expression.
In the forth sample the initial expression is already arithmetically correct and that is why we don't have to shift sticks. | instruction | 0 | 103,211 | 20 | 206,422 |
Tags: brute force, implementation
Correct Solution:
```
from sys import stdin
a=list(stdin.readline())
a.pop()
cont=0
pos=0
cont1=0
cont2=0
while(a[pos]!="+"):
cont=cont+1
pos=pos+1
pos+=1
while(a[pos]!="="):
cont2=cont2+1
pos=pos+1
pos=-1
while(a[pos]!="="):
cont1=cont1+1
pos=pos-1
if((cont+cont2)<cont1):
del(a[-1])
a.insert(0, "|")
cont=cont+1
cont1=cont1-1
elif((cont+cont2)>cont1):
del(a[0])
a.insert(-1, "|")
cont=cont-1
cont1=cont1+1
if (cont==0)and(cont2>1):
cont2=cont2-1
cont=cont+1
if(cont2==0)and(cont>1):
cont2=cont2+1
cont=cont-1
if((cont+cont2)<cont1)or((cont+cont2)>cont1):
print("Impossible")
elif((cont+cont2)==cont1):
print(("|"*cont)+"+"+("|"*cont2)+"="+("|"*cont1))
``` | output | 1 | 103,211 | 20 | 206,423 |
Provide tags and a correct Python 3 solution for this coding contest problem.
When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us arithmetics from the start. And what is the best way to teach students add and subtract? β That's right, using counting sticks! An here's our new task:
An expression of counting sticks is an expression of type:
[ A sticks][sign +][B sticks][sign =][C sticks] (1 β€ A, B, C).
Sign + consists of two crossed sticks: one vertical and one horizontal. Sign = consists of two horizontal sticks. The expression is arithmetically correct if A + B = C.
We've got an expression that looks like A + B = C given by counting sticks. Our task is to shift at most one stick (or we can shift nothing) so that the expression became arithmetically correct. Note that we cannot remove the sticks from the expression, also we cannot shift the sticks from the signs + and =.
We really aren't fabulous at arithmetics. Can you help us?
Input
The single line contains the initial expression. It is guaranteed that the expression looks like A + B = C, where 1 β€ A, B, C β€ 100.
Output
If there isn't a way to shift the stick so the expression becomes correct, print on a single line "Impossible" (without the quotes). If there is a way, print the resulting expression. Follow the format of the output from the test samples. Don't print extra space characters.
If there are multiple correct answers, print any of them. For clarifications, you are recommended to see the test samples.
Examples
Input
||+|=|||||
Output
|||+|=||||
Input
|||||+||=||
Output
Impossible
Input
|+|=||||||
Output
Impossible
Input
||||+||=||||||
Output
||||+||=||||||
Note
In the first sample we can shift stick from the third group of sticks to the first one.
In the second sample we cannot shift vertical stick from + sign to the second group of sticks. So we cannot make a - sign.
There is no answer in the third sample because we cannot remove sticks from the expression.
In the forth sample the initial expression is already arithmetically correct and that is why we don't have to shift sticks. | instruction | 0 | 103,212 | 20 | 206,424 |
Tags: brute force, implementation
Correct Solution:
```
v = input().split('+')
a = len(v[0])
v = v[1].split('=')
b = len(v[0])
c = len(v[1])
def good(a, b, c):
return a+b==c and a>0 and b>0 and c>0
if good(a-1, b, c+1):
a = a-1
c = c+1
if good(a, b-1, c+1):
b = b-1
c = c+1
if good(a+1, b, c-1):
a = a+1
c = c-1
if good(a, b+1, c-1):
b = b+1
c = c-1
if a+b==c:
print('|'*a+'+'+'|'*b+'='+'|'*c)
else:
print("Impossible")
``` | output | 1 | 103,212 | 20 | 206,425 |
Provide tags and a correct Python 3 solution for this coding contest problem.
When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us arithmetics from the start. And what is the best way to teach students add and subtract? β That's right, using counting sticks! An here's our new task:
An expression of counting sticks is an expression of type:
[ A sticks][sign +][B sticks][sign =][C sticks] (1 β€ A, B, C).
Sign + consists of two crossed sticks: one vertical and one horizontal. Sign = consists of two horizontal sticks. The expression is arithmetically correct if A + B = C.
We've got an expression that looks like A + B = C given by counting sticks. Our task is to shift at most one stick (or we can shift nothing) so that the expression became arithmetically correct. Note that we cannot remove the sticks from the expression, also we cannot shift the sticks from the signs + and =.
We really aren't fabulous at arithmetics. Can you help us?
Input
The single line contains the initial expression. It is guaranteed that the expression looks like A + B = C, where 1 β€ A, B, C β€ 100.
Output
If there isn't a way to shift the stick so the expression becomes correct, print on a single line "Impossible" (without the quotes). If there is a way, print the resulting expression. Follow the format of the output from the test samples. Don't print extra space characters.
If there are multiple correct answers, print any of them. For clarifications, you are recommended to see the test samples.
Examples
Input
||+|=|||||
Output
|||+|=||||
Input
|||||+||=||
Output
Impossible
Input
|+|=||||||
Output
Impossible
Input
||||+||=||||||
Output
||||+||=||||||
Note
In the first sample we can shift stick from the third group of sticks to the first one.
In the second sample we cannot shift vertical stick from + sign to the second group of sticks. So we cannot make a - sign.
There is no answer in the third sample because we cannot remove sticks from the expression.
In the forth sample the initial expression is already arithmetically correct and that is why we don't have to shift sticks. | instruction | 0 | 103,213 | 20 | 206,426 |
Tags: brute force, implementation
Correct Solution:
```
class CodeforcesTask394ASolution:
def __init__(self):
self.result = ''
self.expression = ''
def read_input(self):
self.expression = input()
def process_task(self):
expr = self.expression.split("=")
c = len(expr[1])
a = len(expr[0].split("+")[0])
b = len(expr[0].split("+")[1])
# print(a, b, c)
diff = abs((a + b) - c)
if diff == 0 or diff == 2:
if c > a + b:
a += 1
c -= 1
self.result = "|" * a + "+" + "|" * b + "=" + "|" * c
elif not diff:
self.result = self.expression
elif a + b > 2:
if a > 1:
a -= 1
else:
b -= 1
c += 1
self.result = "|" * a + "+" + "|" * b + "=" + "|" * c
else:
self.result = "Impossible"
else:
self.result = "Impossible"
def get_result(self):
return self.result
if __name__ == "__main__":
Solution = CodeforcesTask394ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())
``` | output | 1 | 103,213 | 20 | 206,427 |
Provide tags and a correct Python 3 solution for this coding contest problem.
When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us arithmetics from the start. And what is the best way to teach students add and subtract? β That's right, using counting sticks! An here's our new task:
An expression of counting sticks is an expression of type:
[ A sticks][sign +][B sticks][sign =][C sticks] (1 β€ A, B, C).
Sign + consists of two crossed sticks: one vertical and one horizontal. Sign = consists of two horizontal sticks. The expression is arithmetically correct if A + B = C.
We've got an expression that looks like A + B = C given by counting sticks. Our task is to shift at most one stick (or we can shift nothing) so that the expression became arithmetically correct. Note that we cannot remove the sticks from the expression, also we cannot shift the sticks from the signs + and =.
We really aren't fabulous at arithmetics. Can you help us?
Input
The single line contains the initial expression. It is guaranteed that the expression looks like A + B = C, where 1 β€ A, B, C β€ 100.
Output
If there isn't a way to shift the stick so the expression becomes correct, print on a single line "Impossible" (without the quotes). If there is a way, print the resulting expression. Follow the format of the output from the test samples. Don't print extra space characters.
If there are multiple correct answers, print any of them. For clarifications, you are recommended to see the test samples.
Examples
Input
||+|=|||||
Output
|||+|=||||
Input
|||||+||=||
Output
Impossible
Input
|+|=||||||
Output
Impossible
Input
||||+||=||||||
Output
||||+||=||||||
Note
In the first sample we can shift stick from the third group of sticks to the first one.
In the second sample we cannot shift vertical stick from + sign to the second group of sticks. So we cannot make a - sign.
There is no answer in the third sample because we cannot remove sticks from the expression.
In the forth sample the initial expression is already arithmetically correct and that is why we don't have to shift sticks. | instruction | 0 | 103,214 | 20 | 206,428 |
Tags: brute force, implementation
Correct Solution:
```
s = input()
ind = s.index('=')
left, right = s[:ind], s[ind+1:]
ind = left.index('+')
a, b = left[:ind], left[ind+1:]
A, B, C = len(a), len(b), len(right)
if abs(1 - abs(A + B - C)) != 1:
print('Impossible')
exit()
if A + B == C:
print(s)
exit()
if A + B + 1 == C - 1:
print((A + 1) * '|' + '+' + B * '|' + '=' + (C - 1) * '|')
exit()
if A + B - 1 == C + 1:
if 1 < A >= B:
print((A - 1) * '|' + '+' + B * '|' + '=' + (C + 1) * '|')
exit()
if A < B > 1:
print(A * '|' + '+' + (B - 1) * '|' + '=' + (C + 1) * '|')
exit()
``` | output | 1 | 103,214 | 20 | 206,429 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us arithmetics from the start. And what is the best way to teach students add and subtract? β That's right, using counting sticks! An here's our new task:
An expression of counting sticks is an expression of type:
[ A sticks][sign +][B sticks][sign =][C sticks] (1 β€ A, B, C).
Sign + consists of two crossed sticks: one vertical and one horizontal. Sign = consists of two horizontal sticks. The expression is arithmetically correct if A + B = C.
We've got an expression that looks like A + B = C given by counting sticks. Our task is to shift at most one stick (or we can shift nothing) so that the expression became arithmetically correct. Note that we cannot remove the sticks from the expression, also we cannot shift the sticks from the signs + and =.
We really aren't fabulous at arithmetics. Can you help us?
Input
The single line contains the initial expression. It is guaranteed that the expression looks like A + B = C, where 1 β€ A, B, C β€ 100.
Output
If there isn't a way to shift the stick so the expression becomes correct, print on a single line "Impossible" (without the quotes). If there is a way, print the resulting expression. Follow the format of the output from the test samples. Don't print extra space characters.
If there are multiple correct answers, print any of them. For clarifications, you are recommended to see the test samples.
Examples
Input
||+|=|||||
Output
|||+|=||||
Input
|||||+||=||
Output
Impossible
Input
|+|=||||||
Output
Impossible
Input
||||+||=||||||
Output
||||+||=||||||
Note
In the first sample we can shift stick from the third group of sticks to the first one.
In the second sample we cannot shift vertical stick from + sign to the second group of sticks. So we cannot make a - sign.
There is no answer in the third sample because we cannot remove sticks from the expression.
In the forth sample the initial expression is already arithmetically correct and that is why we don't have to shift sticks.
Submitted Solution:
```
#! /usr/bin/python
def sol():
z = input()
a = z.split('+')
b = list(map(len, [a[0]] + a[1].split('=')))
a, b, c = b
if (a + b == c):
# do nothing
pass
elif (a + b == c - 2):
c -= 1
a += 1
elif (a + b == c + 2):
if a == 1:
b -= 1
c += 1
else:
a -= 1
c += 1
else:
print("Impossible")
return
exp = ""
for i in range(a):
exp += '|'
exp += '+'
for i in range(b):
exp += '|'
exp += '='
for i in range(c):
exp += '|'
print(exp)
sol()
``` | instruction | 0 | 103,215 | 20 | 206,430 |
Yes | output | 1 | 103,215 | 20 | 206,431 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us arithmetics from the start. And what is the best way to teach students add and subtract? β That's right, using counting sticks! An here's our new task:
An expression of counting sticks is an expression of type:
[ A sticks][sign +][B sticks][sign =][C sticks] (1 β€ A, B, C).
Sign + consists of two crossed sticks: one vertical and one horizontal. Sign = consists of two horizontal sticks. The expression is arithmetically correct if A + B = C.
We've got an expression that looks like A + B = C given by counting sticks. Our task is to shift at most one stick (or we can shift nothing) so that the expression became arithmetically correct. Note that we cannot remove the sticks from the expression, also we cannot shift the sticks from the signs + and =.
We really aren't fabulous at arithmetics. Can you help us?
Input
The single line contains the initial expression. It is guaranteed that the expression looks like A + B = C, where 1 β€ A, B, C β€ 100.
Output
If there isn't a way to shift the stick so the expression becomes correct, print on a single line "Impossible" (without the quotes). If there is a way, print the resulting expression. Follow the format of the output from the test samples. Don't print extra space characters.
If there are multiple correct answers, print any of them. For clarifications, you are recommended to see the test samples.
Examples
Input
||+|=|||||
Output
|||+|=||||
Input
|||||+||=||
Output
Impossible
Input
|+|=||||||
Output
Impossible
Input
||||+||=||||||
Output
||||+||=||||||
Note
In the first sample we can shift stick from the third group of sticks to the first one.
In the second sample we cannot shift vertical stick from + sign to the second group of sticks. So we cannot make a - sign.
There is no answer in the third sample because we cannot remove sticks from the expression.
In the forth sample the initial expression is already arithmetically correct and that is why we don't have to shift sticks.
Submitted Solution:
```
x = input()
y = list(x)
a = len(y[:y.index('+')])
b = len(y[y.index('+')+1:y.index('=')])
c = len(y[y.index('=')+1:])
if a + b == c:
print(x)
elif a+b+1 == c-1:
print((a+1)*'|' + '+' + b*'|' + '=' + (c-1)*'|')
elif a+b-1 == c+1 and a>1:
print((a-1)*'|' + '+' + b*'|' + '=' + (c+1)*'|')
elif a+b-1 == c+1 and b>1:
print((a)*'|' + '+' + (b-1)*'|' + '=' + (c+1)*'|')
else:
print('Impossible')
``` | instruction | 0 | 103,216 | 20 | 206,432 |
Yes | output | 1 | 103,216 | 20 | 206,433 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us arithmetics from the start. And what is the best way to teach students add and subtract? β That's right, using counting sticks! An here's our new task:
An expression of counting sticks is an expression of type:
[ A sticks][sign +][B sticks][sign =][C sticks] (1 β€ A, B, C).
Sign + consists of two crossed sticks: one vertical and one horizontal. Sign = consists of two horizontal sticks. The expression is arithmetically correct if A + B = C.
We've got an expression that looks like A + B = C given by counting sticks. Our task is to shift at most one stick (or we can shift nothing) so that the expression became arithmetically correct. Note that we cannot remove the sticks from the expression, also we cannot shift the sticks from the signs + and =.
We really aren't fabulous at arithmetics. Can you help us?
Input
The single line contains the initial expression. It is guaranteed that the expression looks like A + B = C, where 1 β€ A, B, C β€ 100.
Output
If there isn't a way to shift the stick so the expression becomes correct, print on a single line "Impossible" (without the quotes). If there is a way, print the resulting expression. Follow the format of the output from the test samples. Don't print extra space characters.
If there are multiple correct answers, print any of them. For clarifications, you are recommended to see the test samples.
Examples
Input
||+|=|||||
Output
|||+|=||||
Input
|||||+||=||
Output
Impossible
Input
|+|=||||||
Output
Impossible
Input
||||+||=||||||
Output
||||+||=||||||
Note
In the first sample we can shift stick from the third group of sticks to the first one.
In the second sample we cannot shift vertical stick from + sign to the second group of sticks. So we cannot make a - sign.
There is no answer in the third sample because we cannot remove sticks from the expression.
In the forth sample the initial expression is already arithmetically correct and that is why we don't have to shift sticks.
Submitted Solution:
```
a, b =input().split('+')
c,d = b.split('=')
if (len(a)+len(c))==len(d):
print(a+"+"+c+"="+d)
elif len(d)!=1 and (len(a)+len(c)+1)==len(d)-1:
print(a+"+"+c+"|"+"="+d[:-1])
elif len(c)!=1 and (len(a)+len(c)-1)==len(d)+1:
print(a+"+"+c[:-1]+"="+d+"|")
elif len(a)!=1 and (len(a)-1+len(c))==len(d)+1:
print(a[:-1]+"+"+c+"="+d+"|")
else:
print("Impossible")
``` | instruction | 0 | 103,217 | 20 | 206,434 |
Yes | output | 1 | 103,217 | 20 | 206,435 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us arithmetics from the start. And what is the best way to teach students add and subtract? β That's right, using counting sticks! An here's our new task:
An expression of counting sticks is an expression of type:
[ A sticks][sign +][B sticks][sign =][C sticks] (1 β€ A, B, C).
Sign + consists of two crossed sticks: one vertical and one horizontal. Sign = consists of two horizontal sticks. The expression is arithmetically correct if A + B = C.
We've got an expression that looks like A + B = C given by counting sticks. Our task is to shift at most one stick (or we can shift nothing) so that the expression became arithmetically correct. Note that we cannot remove the sticks from the expression, also we cannot shift the sticks from the signs + and =.
We really aren't fabulous at arithmetics. Can you help us?
Input
The single line contains the initial expression. It is guaranteed that the expression looks like A + B = C, where 1 β€ A, B, C β€ 100.
Output
If there isn't a way to shift the stick so the expression becomes correct, print on a single line "Impossible" (without the quotes). If there is a way, print the resulting expression. Follow the format of the output from the test samples. Don't print extra space characters.
If there are multiple correct answers, print any of them. For clarifications, you are recommended to see the test samples.
Examples
Input
||+|=|||||
Output
|||+|=||||
Input
|||||+||=||
Output
Impossible
Input
|+|=||||||
Output
Impossible
Input
||||+||=||||||
Output
||||+||=||||||
Note
In the first sample we can shift stick from the third group of sticks to the first one.
In the second sample we cannot shift vertical stick from + sign to the second group of sticks. So we cannot make a - sign.
There is no answer in the third sample because we cannot remove sticks from the expression.
In the forth sample the initial expression is already arithmetically correct and that is why we don't have to shift sticks.
Submitted Solution:
```
s = input()
n = len(s)
i = s.find('=')
l = s[0:i].count('|')
r = s[i:n].count('|')
if (l == r):
print(s)
else:
k = s.find("||")
if (l-r == 2):
print(s[0:k] + s[k+1:n] + '|')
elif (l-r == -2):
print(s[0:i] + '|' + s[i:n-1])
else:
print("Impossible")
``` | instruction | 0 | 103,218 | 20 | 206,436 |
Yes | output | 1 | 103,218 | 20 | 206,437 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us arithmetics from the start. And what is the best way to teach students add and subtract? β That's right, using counting sticks! An here's our new task:
An expression of counting sticks is an expression of type:
[ A sticks][sign +][B sticks][sign =][C sticks] (1 β€ A, B, C).
Sign + consists of two crossed sticks: one vertical and one horizontal. Sign = consists of two horizontal sticks. The expression is arithmetically correct if A + B = C.
We've got an expression that looks like A + B = C given by counting sticks. Our task is to shift at most one stick (or we can shift nothing) so that the expression became arithmetically correct. Note that we cannot remove the sticks from the expression, also we cannot shift the sticks from the signs + and =.
We really aren't fabulous at arithmetics. Can you help us?
Input
The single line contains the initial expression. It is guaranteed that the expression looks like A + B = C, where 1 β€ A, B, C β€ 100.
Output
If there isn't a way to shift the stick so the expression becomes correct, print on a single line "Impossible" (without the quotes). If there is a way, print the resulting expression. Follow the format of the output from the test samples. Don't print extra space characters.
If there are multiple correct answers, print any of them. For clarifications, you are recommended to see the test samples.
Examples
Input
||+|=|||||
Output
|||+|=||||
Input
|||||+||=||
Output
Impossible
Input
|+|=||||||
Output
Impossible
Input
||||+||=||||||
Output
||||+||=||||||
Note
In the first sample we can shift stick from the third group of sticks to the first one.
In the second sample we cannot shift vertical stick from + sign to the second group of sticks. So we cannot make a - sign.
There is no answer in the third sample because we cannot remove sticks from the expression.
In the forth sample the initial expression is already arithmetically correct and that is why we don't have to shift sticks.
Submitted Solution:
```
s=input()
s1=s[:s.index('+')]
s2=s[s.index('+')+1:s.index('=')]
s3=s[s.index('=')+1:]
s1=s1.replace(' ','')
s2=s2.replace(' ','')
s3=s3.replace(' ','')
#print(s1,s2,s3)
l=len(s2)+len(s1)
#print(l,len(s3))
if(l==len(s3)):
print(s)
elif(abs(len(s3)-l)<=2):
if l<len(s3):
s1=list(s1)
s1.append('|')
s3=list(s3)
s3.remove('|')
#print(s1,s3)
else:
s3=list(s3)
s3.remove('|')
s1=list(s1)
s1.append('|')
#print(s1,s3)
if (len(s1)+len(s2))==len(s3):
s1=''.join(s1)
s2=''.join(s2)
s3=''.join(s3)
print(s1+' '+'+'+' '+s2+' = '+s3)
else:
print('Impossible')
else:
print('Impossible')
``` | instruction | 0 | 103,219 | 20 | 206,438 |
No | output | 1 | 103,219 | 20 | 206,439 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us arithmetics from the start. And what is the best way to teach students add and subtract? β That's right, using counting sticks! An here's our new task:
An expression of counting sticks is an expression of type:
[ A sticks][sign +][B sticks][sign =][C sticks] (1 β€ A, B, C).
Sign + consists of two crossed sticks: one vertical and one horizontal. Sign = consists of two horizontal sticks. The expression is arithmetically correct if A + B = C.
We've got an expression that looks like A + B = C given by counting sticks. Our task is to shift at most one stick (or we can shift nothing) so that the expression became arithmetically correct. Note that we cannot remove the sticks from the expression, also we cannot shift the sticks from the signs + and =.
We really aren't fabulous at arithmetics. Can you help us?
Input
The single line contains the initial expression. It is guaranteed that the expression looks like A + B = C, where 1 β€ A, B, C β€ 100.
Output
If there isn't a way to shift the stick so the expression becomes correct, print on a single line "Impossible" (without the quotes). If there is a way, print the resulting expression. Follow the format of the output from the test samples. Don't print extra space characters.
If there are multiple correct answers, print any of them. For clarifications, you are recommended to see the test samples.
Examples
Input
||+|=|||||
Output
|||+|=||||
Input
|||||+||=||
Output
Impossible
Input
|+|=||||||
Output
Impossible
Input
||||+||=||||||
Output
||||+||=||||||
Note
In the first sample we can shift stick from the third group of sticks to the first one.
In the second sample we cannot shift vertical stick from + sign to the second group of sticks. So we cannot make a - sign.
There is no answer in the third sample because we cannot remove sticks from the expression.
In the forth sample the initial expression is already arithmetically correct and that is why we don't have to shift sticks.
Submitted Solution:
```
IN=input().split('=')
a,b=IN[0].split('+')
c=IN[1]
if len(a) + len (b) + 1 == len(c) - 1 :
a = '|' + a
c=c.replace('|','',1)
print(f'{a}+{b}={c}')
elif len(a) + len (b) -1 == len(c) + 1:
if len(a) == len(b) == 1 :
print('Impossible')
elif len(a) == 1 :
c = '|' + c
b=b.replace('|','',1)
elif len(b)==1 :
c = '|' + c
a=a.replace('|','',1)
print(f'{a}+{b}={c}')
elif len(a) +len(b) == len(c):
print(f'{a}+{b}={c}')
elif (len(a)+len(b))-len(c) > 1 or len(c)-(len(a)+len(b)) > 1 :
print('Impossible')
else :
print('Impossible')
``` | instruction | 0 | 103,220 | 20 | 206,440 |
No | output | 1 | 103,220 | 20 | 206,441 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us arithmetics from the start. And what is the best way to teach students add and subtract? β That's right, using counting sticks! An here's our new task:
An expression of counting sticks is an expression of type:
[ A sticks][sign +][B sticks][sign =][C sticks] (1 β€ A, B, C).
Sign + consists of two crossed sticks: one vertical and one horizontal. Sign = consists of two horizontal sticks. The expression is arithmetically correct if A + B = C.
We've got an expression that looks like A + B = C given by counting sticks. Our task is to shift at most one stick (or we can shift nothing) so that the expression became arithmetically correct. Note that we cannot remove the sticks from the expression, also we cannot shift the sticks from the signs + and =.
We really aren't fabulous at arithmetics. Can you help us?
Input
The single line contains the initial expression. It is guaranteed that the expression looks like A + B = C, where 1 β€ A, B, C β€ 100.
Output
If there isn't a way to shift the stick so the expression becomes correct, print on a single line "Impossible" (without the quotes). If there is a way, print the resulting expression. Follow the format of the output from the test samples. Don't print extra space characters.
If there are multiple correct answers, print any of them. For clarifications, you are recommended to see the test samples.
Examples
Input
||+|=|||||
Output
|||+|=||||
Input
|||||+||=||
Output
Impossible
Input
|+|=||||||
Output
Impossible
Input
||||+||=||||||
Output
||||+||=||||||
Note
In the first sample we can shift stick from the third group of sticks to the first one.
In the second sample we cannot shift vertical stick from + sign to the second group of sticks. So we cannot make a - sign.
There is no answer in the third sample because we cannot remove sticks from the expression.
In the forth sample the initial expression is already arithmetically correct and that is why we don't have to shift sticks.
Submitted Solution:
```
array_input = input()
first_split = array_input.split('=')
after_equal = first_split[1]
# print('first_equal -> ')
# print(first_split[1])
second_split = (first_split[0]).split('+')
# print('second_split -> ')
# print(second_split)
first_operand = second_split[0]
second_operand = second_split[1]
list_operands = [first_operand, second_operand, after_equal]
number_of_sticks = [0,0,0]
for counter in range(0,len(list_operands)):
number_of_sticks[counter] = list_operands[counter].count('|')
# print('number_of_sticks')
# print(number_of_sticks)
if abs((number_of_sticks[0] + number_of_sticks[1]) - number_of_sticks[2]) > 2:
print('Impossible')
elif number_of_sticks[2] > (number_of_sticks[0] + number_of_sticks[1]):
number_of_sticks[2]-=1
number_of_sticks[0]+=1
the_string = '|' * number_of_sticks[0]
the_string += '+'
the_string += '|' * number_of_sticks[1]
the_string += '='
the_string += '|' * number_of_sticks[2]
# print('the string -> ')
print(the_string)
# print('|' * number_of_sticks[0] + '+' + '|' * number_of_sticks[1]+1 + '=' + '|' * number_of_sticks[2]-1)
``` | instruction | 0 | 103,221 | 20 | 206,442 |
No | output | 1 | 103,221 | 20 | 206,443 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us arithmetics from the start. And what is the best way to teach students add and subtract? β That's right, using counting sticks! An here's our new task:
An expression of counting sticks is an expression of type:
[ A sticks][sign +][B sticks][sign =][C sticks] (1 β€ A, B, C).
Sign + consists of two crossed sticks: one vertical and one horizontal. Sign = consists of two horizontal sticks. The expression is arithmetically correct if A + B = C.
We've got an expression that looks like A + B = C given by counting sticks. Our task is to shift at most one stick (or we can shift nothing) so that the expression became arithmetically correct. Note that we cannot remove the sticks from the expression, also we cannot shift the sticks from the signs + and =.
We really aren't fabulous at arithmetics. Can you help us?
Input
The single line contains the initial expression. It is guaranteed that the expression looks like A + B = C, where 1 β€ A, B, C β€ 100.
Output
If there isn't a way to shift the stick so the expression becomes correct, print on a single line "Impossible" (without the quotes). If there is a way, print the resulting expression. Follow the format of the output from the test samples. Don't print extra space characters.
If there are multiple correct answers, print any of them. For clarifications, you are recommended to see the test samples.
Examples
Input
||+|=|||||
Output
|||+|=||||
Input
|||||+||=||
Output
Impossible
Input
|+|=||||||
Output
Impossible
Input
||||+||=||||||
Output
||||+||=||||||
Note
In the first sample we can shift stick from the third group of sticks to the first one.
In the second sample we cannot shift vertical stick from + sign to the second group of sticks. So we cannot make a - sign.
There is no answer in the third sample because we cannot remove sticks from the expression.
In the forth sample the initial expression is already arithmetically correct and that is why we don't have to shift sticks.
Submitted Solution:
```
s1=input()
list(s1)
# print(s1)
a=s1.index('+')
b=s1.index('=')
c=len(s1)
block1=a
block2=b-a-1
block3=c-b-1
# print(block1)
# print(block2)
# print(block3)
if block1+block2 == block3:
print(''.join(str(i) for i in s1))
elif block3 == block1+block2+2:
s2=[]
s2.append('|')
for i in s1:
s2.append(i)
s2.pop()
print(''.join(str(i) for i in s2))
else:
print("Impossible")
``` | instruction | 0 | 103,222 | 20 | 206,444 |
No | output | 1 | 103,222 | 20 | 206,445 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is the easy version of the problem. The only difference is that in this version q=1. You can make hacks only if all versions of the problem are solved.
Zookeeper has been teaching his q sheep how to write and how to add. The i-th sheep has to write exactly k non-negative integers with the sum n_i.
Strangely, sheep have superstitions about digits and believe that the digits 3, 6, and 9 are lucky. To them, the fortune of a number depends on the decimal representation of the number; the fortune of a number is equal to the sum of fortunes of its digits, and the fortune of a digit depends on its value and position and can be described by the following table. For example, the number 319 has fortune F_{2} + 3F_{0}.
<image>
Each sheep wants to maximize the sum of fortune among all its k written integers. Can you help them?
Input
The first line contains a single integer k (1 β€ k β€ 999999): the number of numbers each sheep has to write.
The next line contains six integers F_0, F_1, F_2, F_3, F_4, F_5 (1 β€ F_i β€ 10^9): the fortune assigned to each digit.
The next line contains a single integer q (q = 1): the number of sheep.
Each of the next q lines contains a single integer n_i (1 β€ n_i β€ 999999): the sum of numbers that i-th sheep has to write. In this version, there is only one line.
Output
Print q lines, where the i-th line contains the maximum sum of fortune of all numbers of the i-th sheep. In this version, you should print only one line.
Examples
Input
3
1 2 3 4 5 6
1
57
Output
11
Input
3
1 2 3 4 5 6
1
63
Output
8
Note
In the first test case, 57 = 9 + 9 + 39. The three 9's contribute 1 β
3 and 3 at the tens position contributes 2 β
1. Hence the sum of fortune is 11.
In the second test case, 63 = 35 + 19 + 9. The sum of fortune is 8.
Submitted Solution:
```
tc = {}
score_cache = {}
best_cache = {}
def score(num):
fortunes = tc['f']
if num in score_cache:
return score_cache[num]
num_s = str(num)
place = 0
s = 0
for n in num_s[::-1]:
if n == '3':
s += fortunes[place]
elif n == '6':
s += fortunes[place] * 2
elif n == '9':
s += fortunes[place] * 3
place += 1
score_cache[num] = s
return s
# return best score for number, k digits long
def best_score(number, k):
key = "{} {}".format(number, k)
if key in best_cache:
return best_cache[key]
if k == 1:
return score(number)
digits = [(d, score(d)) for d in range(number) if '3' in str(d) or '6' in str(d) or '9' in str(d)]
digits.sort(key=lambda x: x[1], reverse=True)
# print(number, k, digits)
if not digits:
best_cache[key] = 0
return 0
num, s = digits[0]
rest = number - num
best_cache[key] = s + best_score(rest, k - 1)
return s + best_score(rest, k - 1)
def solve():
return best_score(tc['sum'], tc['k'])
if __name__ == "__main__":
tc['k'], = [int(s) for s in input().split(" ")]
tc['f'] = [int(s) for s in input().split(" ")]
tc['s'], = [int(s) for s in input().split(" ")]
tc['sum'], = [int(s) for s in input().split(" ")]
print("{}".format(solve()))
``` | instruction | 0 | 103,883 | 20 | 207,766 |
No | output | 1 | 103,883 | 20 | 207,767 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is the easy version of the problem. The only difference is that in this version q=1. You can make hacks only if all versions of the problem are solved.
Zookeeper has been teaching his q sheep how to write and how to add. The i-th sheep has to write exactly k non-negative integers with the sum n_i.
Strangely, sheep have superstitions about digits and believe that the digits 3, 6, and 9 are lucky. To them, the fortune of a number depends on the decimal representation of the number; the fortune of a number is equal to the sum of fortunes of its digits, and the fortune of a digit depends on its value and position and can be described by the following table. For example, the number 319 has fortune F_{2} + 3F_{0}.
<image>
Each sheep wants to maximize the sum of fortune among all its k written integers. Can you help them?
Input
The first line contains a single integer k (1 β€ k β€ 999999): the number of numbers each sheep has to write.
The next line contains six integers F_0, F_1, F_2, F_3, F_4, F_5 (1 β€ F_i β€ 10^9): the fortune assigned to each digit.
The next line contains a single integer q (q = 1): the number of sheep.
Each of the next q lines contains a single integer n_i (1 β€ n_i β€ 999999): the sum of numbers that i-th sheep has to write. In this version, there is only one line.
Output
Print q lines, where the i-th line contains the maximum sum of fortune of all numbers of the i-th sheep. In this version, you should print only one line.
Examples
Input
3
1 2 3 4 5 6
1
57
Output
11
Input
3
1 2 3 4 5 6
1
63
Output
8
Note
In the first test case, 57 = 9 + 9 + 39. The three 9's contribute 1 β
3 and 3 at the tens position contributes 2 β
1. Hence the sum of fortune is 11.
In the second test case, 63 = 35 + 19 + 9. The sum of fortune is 8.
Submitted Solution:
```
def solve(t):
cache = {}
def score(num, fortunes):
nonlocal cache
if num in cache:
return cache[num]
num_s = str(num)
place = 0
s = 0
for n in num_s[::-1]:
if n == '3':
s += fortunes[place]
elif n == '6':
s += fortunes[place] * 2
elif n == '9':
s += fortunes[place] * 3
place += 1
cache[num] = s
return s
digits = [i for i in range(1, int(tc['sum']//1.4), 1) if '3' in str(i) or '9' in str(i) or '6' in str(i)]
digits.sort(key=lambda x: score(x, tc['f']), reverse=True)
best_score = 0
for d1 in digits:
for d2 in digits:
if tc['sum'] > d1 + d2:
d3 = tc['sum'] - (d1 + d2)
if d1 + d2 + d3 == tc['sum']:
s = score(d1, tc['f']) + score(d2, tc['f']) + score(d3, tc['f'])
# return s
# print(d1, d2, d3, s)
if best_score < s:
best_score = s
if tc['sum'] / 3 > d1:
return best_score
return best_score
if __name__ == "__main__":
tc = {}
tc['k'], = [int(s) for s in input().split(" ")]
tc['f'] = [int(s) for s in input().split(" ")]
tc['s'], = [int(s) for s in input().split(" ")]
tc['sum'], = [int(s) for s in input().split(" ")]
print("{}".format(solve(tc)))
``` | instruction | 0 | 103,884 | 20 | 207,768 |
No | output | 1 | 103,884 | 20 | 207,769 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is the easy version of the problem. The only difference is that in this version q=1. You can make hacks only if all versions of the problem are solved.
Zookeeper has been teaching his q sheep how to write and how to add. The i-th sheep has to write exactly k non-negative integers with the sum n_i.
Strangely, sheep have superstitions about digits and believe that the digits 3, 6, and 9 are lucky. To them, the fortune of a number depends on the decimal representation of the number; the fortune of a number is equal to the sum of fortunes of its digits, and the fortune of a digit depends on its value and position and can be described by the following table. For example, the number 319 has fortune F_{2} + 3F_{0}.
<image>
Each sheep wants to maximize the sum of fortune among all its k written integers. Can you help them?
Input
The first line contains a single integer k (1 β€ k β€ 999999): the number of numbers each sheep has to write.
The next line contains six integers F_0, F_1, F_2, F_3, F_4, F_5 (1 β€ F_i β€ 10^9): the fortune assigned to each digit.
The next line contains a single integer q (q = 1): the number of sheep.
Each of the next q lines contains a single integer n_i (1 β€ n_i β€ 999999): the sum of numbers that i-th sheep has to write. In this version, there is only one line.
Output
Print q lines, where the i-th line contains the maximum sum of fortune of all numbers of the i-th sheep. In this version, you should print only one line.
Examples
Input
3
1 2 3 4 5 6
1
57
Output
11
Input
3
1 2 3 4 5 6
1
63
Output
8
Note
In the first test case, 57 = 9 + 9 + 39. The three 9's contribute 1 β
3 and 3 at the tens position contributes 2 β
1. Hence the sum of fortune is 11.
In the second test case, 63 = 35 + 19 + 9. The sum of fortune is 8.
Submitted Solution:
```
def solve(t):
cache = {}
def score(num, fortunes):
nonlocal cache
if num in cache:
return cache[num]
num_s = str(num)
place = 0
s = 0
for n in num_s[::-1]:
if n == '3':
s += fortunes[place]
elif n == '6':
s += fortunes[place] * 2
elif n == '9':
s += fortunes[place] * 3
place += 1
cache[num] = s
return s
digits = [i for i in range(1, tc['sum'], 1) if '3' in str(i) or '9' in str(i) or '6' in str(i)]
digits.sort(key=lambda x: score(x, tc['f']), reverse=True)
best_score = 0
for d1 in digits:
for d2 in digits:
if tc['sum'] > d1 + d2:
d3 = tc['sum'] - (d1 + d2)
if d1 + d2 + d3 == tc['sum']:
s = score(d1, tc['f']) + score(d2, tc['f']) + score(d3, tc['f'])
# return s
# print(d1, d2, d3, s)
if best_score < s:
best_score = s
if tc['sum'] / 4 > d1:
return best_score
return best_score
if __name__ == "__main__":
tc = {}
tc['k'], = [int(s) for s in input().split(" ")]
tc['f'] = [int(s) for s in input().split(" ")]
tc['s'], = [int(s) for s in input().split(" ")]
tc['sum'], = [int(s) for s in input().split(" ")]
print("{}".format(solve(tc)))
``` | instruction | 0 | 103,885 | 20 | 207,770 |
No | output | 1 | 103,885 | 20 | 207,771 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is the easy version of the problem. The only difference is that in this version q=1. You can make hacks only if all versions of the problem are solved.
Zookeeper has been teaching his q sheep how to write and how to add. The i-th sheep has to write exactly k non-negative integers with the sum n_i.
Strangely, sheep have superstitions about digits and believe that the digits 3, 6, and 9 are lucky. To them, the fortune of a number depends on the decimal representation of the number; the fortune of a number is equal to the sum of fortunes of its digits, and the fortune of a digit depends on its value and position and can be described by the following table. For example, the number 319 has fortune F_{2} + 3F_{0}.
<image>
Each sheep wants to maximize the sum of fortune among all its k written integers. Can you help them?
Input
The first line contains a single integer k (1 β€ k β€ 999999): the number of numbers each sheep has to write.
The next line contains six integers F_0, F_1, F_2, F_3, F_4, F_5 (1 β€ F_i β€ 10^9): the fortune assigned to each digit.
The next line contains a single integer q (q = 1): the number of sheep.
Each of the next q lines contains a single integer n_i (1 β€ n_i β€ 999999): the sum of numbers that i-th sheep has to write. In this version, there is only one line.
Output
Print q lines, where the i-th line contains the maximum sum of fortune of all numbers of the i-th sheep. In this version, you should print only one line.
Examples
Input
3
1 2 3 4 5 6
1
57
Output
11
Input
3
1 2 3 4 5 6
1
63
Output
8
Note
In the first test case, 57 = 9 + 9 + 39. The three 9's contribute 1 β
3 and 3 at the tens position contributes 2 β
1. Hence the sum of fortune is 11.
In the second test case, 63 = 35 + 19 + 9. The sum of fortune is 8.
Submitted Solution:
```
def solve(t):
def score(num, fortunes):
num = str(num)
place = 0
s = 0
for n in num[::-1]:
if n == '3':
s += fortunes[place]
elif n == '6':
s += fortunes[place] * 2
elif n == '9':
s += fortunes[place] * 3
place += 1
return s
digits = [i for i in range(1, tc['sum'], 1)]
digits.sort(key=lambda x: score(x, tc['f']), reverse=True)
sofar = []
for _ in range(3):
for d in digits:
if tc['sum'] - sum(sofar) - d - (3-len(sofar)-1) >= 0:
sofar.append(d)
if len(sofar) == 3 and sum(sofar) != tc['sum']:
del sofar[-1]
if len(sofar) != 3:
sofar.append(tc['sum'] - sum(sofar))
return score(sofar[0], tc['f']) + score(sofar[1], tc['f']) + score(sofar[2], tc['f'])
if __name__ == "__main__":
tc = {}
tc['k'], = [int(s) for s in input().split(" ")]
tc['f'] = [int(s) for s in input().split(" ")]
tc['s'], = [int(s) for s in input().split(" ")]
tc['sum'], = [int(s) for s in input().split(" ")]
print("{}".format(solve(tc)))
``` | instruction | 0 | 103,886 | 20 | 207,772 |
No | output | 1 | 103,886 | 20 | 207,773 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vanya invented an interesting trick with a set of integers.
Let an illusionist have a set of positive integers S. He names a positive integer x. Then an audience volunteer must choose some subset (possibly, empty) of S without disclosing it to the illusionist. The volunteer tells the illusionist the size of the chosen subset. And here comes the trick: the illusionist guesses whether the sum of the subset elements does not exceed x. The sum of elements of an empty subset is considered to be 0.
Vanya wants to prepare the trick for a public performance. He prepared some set of distinct positive integers S. Vasya wants the trick to be successful. He calls a positive number x unsuitable, if he can't be sure that the trick would be successful for every subset a viewer can choose.
Vanya wants to count the number of unsuitable integers for the chosen set S.
Vanya plans to try different sets S. He wants you to write a program that finds the number of unsuitable integers for the initial set S, and after each change to the set S. Vanya will make q changes to the set, and each change is one of the following two types:
* add a new integer a to the set S, or
* remove some integer a from the set S.
Input
The first line contains two integers n, q (1 β€ n, q β€ 200 000) β the size of the initial set S and the number of changes.
The next line contains n distinct integers s_1, s_2, β¦, s_n (1 β€ s_i β€ 10^{13}) β the initial elements of S.
Each of the following q lines contain two integers t_i, a_i (1 β€ t_i β€ 2, 1 β€ a_i β€ 10^{13}), describing a change:
* If t_i = 1, then an integer a_i is added to the set S. It is guaranteed that this integer is not present in S before this operation.
* If t_i = 2, then an integer a_i is removed from the set S. In is guaranteed that this integer is present in S before this operation.
Output
Print q + 1 lines.
In the first line print the number of unsuitable integers for the initial set S. In the next q lines print the number of unsuitable integers for S after each change.
Example
Input
3 11
1 2 3
2 1
1 5
1 6
1 7
2 6
2 2
2 3
1 10
2 5
2 7
2 10
Output
4
1
6
12
19
13
8
2
10
3
0
0
Note
In the first example the initial set is S = \{1, 2, 3\}. For this set the trick can be unsuccessful for x β \{1, 2, 3, 4\}. For example, if x = 4, the volunteer can choose the subset \{1, 2\} with sum 3 β€ x, and can choose the subset \{2, 3\} with sum 5 > x. However, in both cases the illusionist only know the same size of the subset (2), so he can't be sure answering making a guess. Since there is only one subset of size 3, and the sum of each subset of smaller size does not exceed 5, all x β₯ 5 are suitable.
Submitted Solution:
```
def CountError(arr):
set1 = set()
for i in range(1,len(arr)+1):
min=0
max=0
for j in range(i):
min=min+arr[j]
max=max+arr[len(arr)-j-1]
for j in range(min+1, max+1):
set1.add(j)
count = len(set1)
del set1
return count
def change(arr,t, x):
if t==1:
arr.append(x)
else:
arr.remove(x)
return arr
n,q=map(int,input().split())
del n
arr = list(map(int,input().split()))
print(len(arr))
arr = sorted(arr)
print(CountError(arr))
for i in range(q):
t,x = map(int,input().split())
arr=change(arr,t,x)
print(CountError(arr))
``` | instruction | 0 | 103,919 | 20 | 207,838 |
No | output | 1 | 103,919 | 20 | 207,839 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vanya invented an interesting trick with a set of integers.
Let an illusionist have a set of positive integers S. He names a positive integer x. Then an audience volunteer must choose some subset (possibly, empty) of S without disclosing it to the illusionist. The volunteer tells the illusionist the size of the chosen subset. And here comes the trick: the illusionist guesses whether the sum of the subset elements does not exceed x. The sum of elements of an empty subset is considered to be 0.
Vanya wants to prepare the trick for a public performance. He prepared some set of distinct positive integers S. Vasya wants the trick to be successful. He calls a positive number x unsuitable, if he can't be sure that the trick would be successful for every subset a viewer can choose.
Vanya wants to count the number of unsuitable integers for the chosen set S.
Vanya plans to try different sets S. He wants you to write a program that finds the number of unsuitable integers for the initial set S, and after each change to the set S. Vanya will make q changes to the set, and each change is one of the following two types:
* add a new integer a to the set S, or
* remove some integer a from the set S.
Input
The first line contains two integers n, q (1 β€ n, q β€ 200 000) β the size of the initial set S and the number of changes.
The next line contains n distinct integers s_1, s_2, β¦, s_n (1 β€ s_i β€ 10^{13}) β the initial elements of S.
Each of the following q lines contain two integers t_i, a_i (1 β€ t_i β€ 2, 1 β€ a_i β€ 10^{13}), describing a change:
* If t_i = 1, then an integer a_i is added to the set S. It is guaranteed that this integer is not present in S before this operation.
* If t_i = 2, then an integer a_i is removed from the set S. In is guaranteed that this integer is present in S before this operation.
Output
Print q + 1 lines.
In the first line print the number of unsuitable integers for the initial set S. In the next q lines print the number of unsuitable integers for S after each change.
Example
Input
3 11
1 2 3
2 1
1 5
1 6
1 7
2 6
2 2
2 3
1 10
2 5
2 7
2 10
Output
4
1
6
12
19
13
8
2
10
3
0
0
Note
In the first example the initial set is S = \{1, 2, 3\}. For this set the trick can be unsuccessful for x β \{1, 2, 3, 4\}. For example, if x = 4, the volunteer can choose the subset \{1, 2\} with sum 3 β€ x, and can choose the subset \{2, 3\} with sum 5 > x. However, in both cases the illusionist only know the same size of the subset (2), so he can't be sure answering making a guess. Since there is only one subset of size 3, and the sum of each subset of smaller size does not exceed 5, all x β₯ 5 are suitable.
Submitted Solution:
```
import bisect
def solve(s):
if s==[]:
return 0
i=0
j=len(s)-1
left=right=0
x=s[0]
y=0
while j>0:
left+=s[i]
right+=s[j]
#print(left,right)
if left<=x:
if right>x:
x=right
else:
y=left-x
x=right
i+=1
j-=1
return x-s[0]-y
inp=input()
inp=inp.split(' ')
inp=[int(i) for i in inp]
n=inp[0]
q=inp[1]
inp=input()
inp=inp.split(' ')
s=[int(i) for i in inp]
s=sorted(s)
print(solve(s))
for k in range(q):
inp=input()
inp=inp.split(' ')
inp=[int(i) for i in inp]
a=inp[0]
b=inp[1]
if a==1:
bisect.insort(s,b)
else:
s.remove(b)
print(solve(s))
``` | instruction | 0 | 103,920 | 20 | 207,840 |
No | output | 1 | 103,920 | 20 | 207,841 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vanya invented an interesting trick with a set of integers.
Let an illusionist have a set of positive integers S. He names a positive integer x. Then an audience volunteer must choose some subset (possibly, empty) of S without disclosing it to the illusionist. The volunteer tells the illusionist the size of the chosen subset. And here comes the trick: the illusionist guesses whether the sum of the subset elements does not exceed x. The sum of elements of an empty subset is considered to be 0.
Vanya wants to prepare the trick for a public performance. He prepared some set of distinct positive integers S. Vasya wants the trick to be successful. He calls a positive number x unsuitable, if he can't be sure that the trick would be successful for every subset a viewer can choose.
Vanya wants to count the number of unsuitable integers for the chosen set S.
Vanya plans to try different sets S. He wants you to write a program that finds the number of unsuitable integers for the initial set S, and after each change to the set S. Vanya will make q changes to the set, and each change is one of the following two types:
* add a new integer a to the set S, or
* remove some integer a from the set S.
Input
The first line contains two integers n, q (1 β€ n, q β€ 200 000) β the size of the initial set S and the number of changes.
The next line contains n distinct integers s_1, s_2, β¦, s_n (1 β€ s_i β€ 10^{13}) β the initial elements of S.
Each of the following q lines contain two integers t_i, a_i (1 β€ t_i β€ 2, 1 β€ a_i β€ 10^{13}), describing a change:
* If t_i = 1, then an integer a_i is added to the set S. It is guaranteed that this integer is not present in S before this operation.
* If t_i = 2, then an integer a_i is removed from the set S. In is guaranteed that this integer is present in S before this operation.
Output
Print q + 1 lines.
In the first line print the number of unsuitable integers for the initial set S. In the next q lines print the number of unsuitable integers for S after each change.
Example
Input
3 11
1 2 3
2 1
1 5
1 6
1 7
2 6
2 2
2 3
1 10
2 5
2 7
2 10
Output
4
1
6
12
19
13
8
2
10
3
0
0
Note
In the first example the initial set is S = \{1, 2, 3\}. For this set the trick can be unsuccessful for x β \{1, 2, 3, 4\}. For example, if x = 4, the volunteer can choose the subset \{1, 2\} with sum 3 β€ x, and can choose the subset \{2, 3\} with sum 5 > x. However, in both cases the illusionist only know the same size of the subset (2), so he can't be sure answering making a guess. Since there is only one subset of size 3, and the sum of each subset of smaller size does not exceed 5, all x β₯ 5 are suitable.
Submitted Solution:
```
s=input().split(" ")
n=int(s[0])
q=int(s[1])
l=input().split(" ")
for i in range(n):
l[i]=int(l[i])
l=sorted(l)
ma=0
mi=0
s=0
j=0
while j<len(l):
mi1=mi+l[j]
ma1=ma+l[len(l)-j-1]
if mi1<ma:
s+=ma1-ma-1
else:
s+=ma1-mi1
ma=ma1
mi=mi1
j+=1
print(s)
for i in range(q):
s=input().split(" ")
a=int(s[1])
if s[0]=="2":
l.remove(a)
else:
l.append(a)
j=len(l)-1
while j>0 and l[j]<l[j-1]:
l[j],l[j-1]=l[j-1],l[j]
j-=1
ma=0
mi=0
s=0
j=0
while j<len(l):
mi1=mi+l[j]
ma1=ma+l[len(l)-j-1]
if mi1<ma:
s+=ma1-ma
else:
s+=ma1-mi1
ma=ma1
mi=mi1
j+=1
print(s)
``` | instruction | 0 | 103,921 | 20 | 207,842 |
No | output | 1 | 103,921 | 20 | 207,843 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vanya invented an interesting trick with a set of integers.
Let an illusionist have a set of positive integers S. He names a positive integer x. Then an audience volunteer must choose some subset (possibly, empty) of S without disclosing it to the illusionist. The volunteer tells the illusionist the size of the chosen subset. And here comes the trick: the illusionist guesses whether the sum of the subset elements does not exceed x. The sum of elements of an empty subset is considered to be 0.
Vanya wants to prepare the trick for a public performance. He prepared some set of distinct positive integers S. Vasya wants the trick to be successful. He calls a positive number x unsuitable, if he can't be sure that the trick would be successful for every subset a viewer can choose.
Vanya wants to count the number of unsuitable integers for the chosen set S.
Vanya plans to try different sets S. He wants you to write a program that finds the number of unsuitable integers for the initial set S, and after each change to the set S. Vanya will make q changes to the set, and each change is one of the following two types:
* add a new integer a to the set S, or
* remove some integer a from the set S.
Input
The first line contains two integers n, q (1 β€ n, q β€ 200 000) β the size of the initial set S and the number of changes.
The next line contains n distinct integers s_1, s_2, β¦, s_n (1 β€ s_i β€ 10^{13}) β the initial elements of S.
Each of the following q lines contain two integers t_i, a_i (1 β€ t_i β€ 2, 1 β€ a_i β€ 10^{13}), describing a change:
* If t_i = 1, then an integer a_i is added to the set S. It is guaranteed that this integer is not present in S before this operation.
* If t_i = 2, then an integer a_i is removed from the set S. In is guaranteed that this integer is present in S before this operation.
Output
Print q + 1 lines.
In the first line print the number of unsuitable integers for the initial set S. In the next q lines print the number of unsuitable integers for S after each change.
Example
Input
3 11
1 2 3
2 1
1 5
1 6
1 7
2 6
2 2
2 3
1 10
2 5
2 7
2 10
Output
4
1
6
12
19
13
8
2
10
3
0
0
Note
In the first example the initial set is S = \{1, 2, 3\}. For this set the trick can be unsuccessful for x β \{1, 2, 3, 4\}. For example, if x = 4, the volunteer can choose the subset \{1, 2\} with sum 3 β€ x, and can choose the subset \{2, 3\} with sum 5 > x. However, in both cases the illusionist only know the same size of the subset (2), so he can't be sure answering making a guess. Since there is only one subset of size 3, and the sum of each subset of smaller size does not exceed 5, all x β₯ 5 are suitable.
Submitted Solution:
```
def CountError(arr):
set1 = set()
min = 0
max = 0
for i in range(1,len(arr)+1):
for j in range(i):
min=min+arr[j]
max=max+arr[len(arr)-j-1]
for j in range(min+1, max+1):
set1.add(j)
count = len(set1)
del set1
return count
def change(arr,t, x):
if t==1:
arr.append(x)
else:
arr.remove(x)
return arr
n,q=map(int,input().split())
del n
arr = list(map(int,input().split()))
arr = sorted(arr)
print(CountError(arr))
for i in range(q):
t,x = map(int,input().split())
arr=change(arr,t,x)
print(CountError(arr))
``` | instruction | 0 | 103,922 | 20 | 207,844 |
No | output | 1 | 103,922 | 20 | 207,845 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between the easy and the hard versions is the maximum value of k.
You are given an infinite sequence of form "112123123412345..." which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from 1 to 1, the second one β from 1 to 2, the third one β from 1 to 3, ..., the i-th block consists of all numbers from 1 to i.
So the first 56 elements of the sequence are "11212312341234512345612345671234567812345678912345678910". Elements of the sequence are numbered from one. For example, the 1-st element of the sequence is 1, the 3-rd element of the sequence is 2, the 20-th element of the sequence is 5, the 38-th element is 2, the 56-th element of the sequence is 0.
Your task is to answer q independent queries. In the i-th query you are given one integer k_i. Calculate the digit at the position k_i of the sequence.
Input
The first line of the input contains one integer q (1 β€ q β€ 500) β the number of queries.
The i-th of the following q lines contains one integer k_i (1 β€ k_i β€ 10^9) β the description of the corresponding query.
Output
Print q lines. In the i-th line print one digit x_i (0 β€ x_i β€ 9) β the answer to the query i, i.e. x_i should be equal to the element at the position k_i of the sequence.
Examples
Input
5
1
3
20
38
56
Output
1
2
5
2
0
Input
4
2132
506
999999999
1000000000
Output
8
2
9
8
Note
Answers on queries from the first example are described in the problem statement. | instruction | 0 | 104,509 | 20 | 209,018 |
Tags: binary search, brute force, math
Correct Solution:
```
def isqrt(x):
if x < 0:
raise ValueError('square root not defined for negative numbers')
n = int(x)
if n == 0:
return 0
a, b = divmod(n.bit_length(), 2)
x = 2**(a+b)
while True:
y = (x + n//x)//2
if y >= x:
return x
x = y
p = [0, 45, 9045, 1395495, 189414495, 23939649495, 2893942449495, 339393974949495, 38939394344949495, 1000000000000000001];
nx = [0, 9, 189, 2889, 38889, 488889, 5888889, 68888889, 788888889, 8888888889]
q = int(input())
for ut in range(q):
lk = int(input())
k = lk
idx = 0;
for i in range(len(p)-1):
if (p[i] <= k) and (p[i + 1] > k):
idx = i;
idx = idx;
k-=1
k -= p[idx];
a = idx + 1
b = 2 * nx[idx] + idx + 1;
k = -2 * k;
d = isqrt(b*b-4 * a*k);
x1 = (-b + d) / (2. * a);
x2 = (-b - d) / (2. * a);
a1 = int(x1);
z = lk - p[idx] - nx[idx] * a1 - (a1 * (a1 + 1) // 2) * (idx + 1);
cnt = 0
ww = 1
pow = 0;
pow = 1;
while ((cnt + pow * ww) * 9 < z) :
cnt += pow * ww;
ww+=1
pow *= 10;
sym_cnt = (z - (cnt * 9)) - 1;
ok = (pow)+sym_cnt / ww;
s = str(ok);
if (z < 10):
print(z)
else:
print(s[sym_cnt % ww])
``` | output | 1 | 104,509 | 20 | 209,019 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Lengths are measures in Baden in inches and feet. To a length from centimeters it is enough to know that an inch equals three centimeters in Baden and one foot contains 12 inches.
You are given a length equal to n centimeters. Your task is to convert it to feet and inches so that the number of feet was maximum. The result should be an integer rounded to the closest value containing an integral number of inches.
Note that when you round up, 1 cm rounds up to 0 inches and 2 cm round up to 1 inch.
Input
The only line contains an integer n (1 β€ n β€ 10000).
Output
Print two non-negative space-separated integers a and b, where a is the numbers of feet and b is the number of inches.
Examples
Input
42
Output
1 2
Input
5
Output
0 2 | instruction | 0 | 104,523 | 20 | 209,046 |
Tags: math
Correct Solution:
```
n = round(int(input())/3)
print(n//12, n%12)
``` | output | 1 | 104,523 | 20 | 209,047 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Lengths are measures in Baden in inches and feet. To a length from centimeters it is enough to know that an inch equals three centimeters in Baden and one foot contains 12 inches.
You are given a length equal to n centimeters. Your task is to convert it to feet and inches so that the number of feet was maximum. The result should be an integer rounded to the closest value containing an integral number of inches.
Note that when you round up, 1 cm rounds up to 0 inches and 2 cm round up to 1 inch.
Input
The only line contains an integer n (1 β€ n β€ 10000).
Output
Print two non-negative space-separated integers a and b, where a is the numbers of feet and b is the number of inches.
Examples
Input
42
Output
1 2
Input
5
Output
0 2 | instruction | 0 | 104,524 | 20 | 209,048 |
Tags: math
Correct Solution:
```
n=int(input())
a = n//3
b = n%3
if b==2:
a+=1
s = a//12
y = a%12
print(s,y)
``` | output | 1 | 104,524 | 20 | 209,049 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Lengths are measures in Baden in inches and feet. To a length from centimeters it is enough to know that an inch equals three centimeters in Baden and one foot contains 12 inches.
You are given a length equal to n centimeters. Your task is to convert it to feet and inches so that the number of feet was maximum. The result should be an integer rounded to the closest value containing an integral number of inches.
Note that when you round up, 1 cm rounds up to 0 inches and 2 cm round up to 1 inch.
Input
The only line contains an integer n (1 β€ n β€ 10000).
Output
Print two non-negative space-separated integers a and b, where a is the numbers of feet and b is the number of inches.
Examples
Input
42
Output
1 2
Input
5
Output
0 2 | instruction | 0 | 104,525 | 20 | 209,050 |
Tags: math
Correct Solution:
```
x=(int(input())+1)//3
print(x//12,x%12)
``` | output | 1 | 104,525 | 20 | 209,051 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Lengths are measures in Baden in inches and feet. To a length from centimeters it is enough to know that an inch equals three centimeters in Baden and one foot contains 12 inches.
You are given a length equal to n centimeters. Your task is to convert it to feet and inches so that the number of feet was maximum. The result should be an integer rounded to the closest value containing an integral number of inches.
Note that when you round up, 1 cm rounds up to 0 inches and 2 cm round up to 1 inch.
Input
The only line contains an integer n (1 β€ n β€ 10000).
Output
Print two non-negative space-separated integers a and b, where a is the numbers of feet and b is the number of inches.
Examples
Input
42
Output
1 2
Input
5
Output
0 2 | instruction | 0 | 104,526 | 20 | 209,052 |
Tags: math
Correct Solution:
```
n=int(input())
i=int(n/3)+(n%3)-1
if n%3==0:
i+=1
print(i//12," ",i%12)
``` | output | 1 | 104,526 | 20 | 209,053 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Lengths are measures in Baden in inches and feet. To a length from centimeters it is enough to know that an inch equals three centimeters in Baden and one foot contains 12 inches.
You are given a length equal to n centimeters. Your task is to convert it to feet and inches so that the number of feet was maximum. The result should be an integer rounded to the closest value containing an integral number of inches.
Note that when you round up, 1 cm rounds up to 0 inches and 2 cm round up to 1 inch.
Input
The only line contains an integer n (1 β€ n β€ 10000).
Output
Print two non-negative space-separated integers a and b, where a is the numbers of feet and b is the number of inches.
Examples
Input
42
Output
1 2
Input
5
Output
0 2 | instruction | 0 | 104,527 | 20 | 209,054 |
Tags: math
Correct Solution:
```
cm = int(input())
inches = cm // 3
if cm % 3 == 2:
inches += 1
feet = inches // 12
inches %= 12
print(feet, inches)
``` | output | 1 | 104,527 | 20 | 209,055 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Lengths are measures in Baden in inches and feet. To a length from centimeters it is enough to know that an inch equals three centimeters in Baden and one foot contains 12 inches.
You are given a length equal to n centimeters. Your task is to convert it to feet and inches so that the number of feet was maximum. The result should be an integer rounded to the closest value containing an integral number of inches.
Note that when you round up, 1 cm rounds up to 0 inches and 2 cm round up to 1 inch.
Input
The only line contains an integer n (1 β€ n β€ 10000).
Output
Print two non-negative space-separated integers a and b, where a is the numbers of feet and b is the number of inches.
Examples
Input
42
Output
1 2
Input
5
Output
0 2 | instruction | 0 | 104,528 | 20 | 209,056 |
Tags: math
Correct Solution:
```
cms=int(input())
al=cms%3
if al==1 or al==0 :
ans=cms//3
else:
ans=cms//3+1
feet=ans//12
print(feet,ans%12)
``` | output | 1 | 104,528 | 20 | 209,057 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Lengths are measures in Baden in inches and feet. To a length from centimeters it is enough to know that an inch equals three centimeters in Baden and one foot contains 12 inches.
You are given a length equal to n centimeters. Your task is to convert it to feet and inches so that the number of feet was maximum. The result should be an integer rounded to the closest value containing an integral number of inches.
Note that when you round up, 1 cm rounds up to 0 inches and 2 cm round up to 1 inch.
Input
The only line contains an integer n (1 β€ n β€ 10000).
Output
Print two non-negative space-separated integers a and b, where a is the numbers of feet and b is the number of inches.
Examples
Input
42
Output
1 2
Input
5
Output
0 2 | instruction | 0 | 104,529 | 20 | 209,058 |
Tags: math
Correct Solution:
```
n=(int(input())+1)//3
print(n//12,n%12)
``` | output | 1 | 104,529 | 20 | 209,059 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Lengths are measures in Baden in inches and feet. To a length from centimeters it is enough to know that an inch equals three centimeters in Baden and one foot contains 12 inches.
You are given a length equal to n centimeters. Your task is to convert it to feet and inches so that the number of feet was maximum. The result should be an integer rounded to the closest value containing an integral number of inches.
Note that when you round up, 1 cm rounds up to 0 inches and 2 cm round up to 1 inch.
Input
The only line contains an integer n (1 β€ n β€ 10000).
Output
Print two non-negative space-separated integers a and b, where a is the numbers of feet and b is the number of inches.
Examples
Input
42
Output
1 2
Input
5
Output
0 2 | instruction | 0 | 104,530 | 20 | 209,060 |
Tags: math
Correct Solution:
```
n = int(input())
inch = n//3
if n%3 == 2: inch += 1
feet = inch//12
inch = inch%12
print(feet,inch)
``` | output | 1 | 104,530 | 20 | 209,061 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Lengths are measures in Baden in inches and feet. To a length from centimeters it is enough to know that an inch equals three centimeters in Baden and one foot contains 12 inches.
You are given a length equal to n centimeters. Your task is to convert it to feet and inches so that the number of feet was maximum. The result should be an integer rounded to the closest value containing an integral number of inches.
Note that when you round up, 1 cm rounds up to 0 inches and 2 cm round up to 1 inch.
Input
The only line contains an integer n (1 β€ n β€ 10000).
Output
Print two non-negative space-separated integers a and b, where a is the numbers of feet and b is the number of inches.
Examples
Input
42
Output
1 2
Input
5
Output
0 2
Submitted Solution:
```
s = int(input())
f = 0
i = 0
while s >= 36:
s -= 36
f += 1
while s >= 3:
s -= 3
i += 1
if s == 2:
i += 1
print(f, end= ' ')
print(i)
``` | instruction | 0 | 104,538 | 20 | 209,076 |
No | output | 1 | 104,538 | 20 | 209,077 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Chilly Willy loves playing with numbers. He only knows prime numbers that are digits yet. These numbers are 2, 3, 5 and 7. But Willy grew rather bored of such numbers, so he came up with a few games that were connected with them.
Chilly Willy wants to find the minimum number of length n, such that it is simultaneously divisible by all numbers Willy already knows (2, 3, 5 and 7). Help him with that.
A number's length is the number of digits in its decimal representation without leading zeros.
Input
A single input line contains a single integer n (1 β€ n β€ 105).
Output
Print a single integer β the answer to the problem without leading zeroes, or "-1" (without the quotes), if the number that meet the problem condition does not exist.
Examples
Input
1
Output
-1
Input
5
Output
10080 | instruction | 0 | 104,735 | 20 | 209,470 |
Tags: math, number theory
Correct Solution:
```
def main():
n = int(input())
if (n < 3):
print(-1)
else:
n -= 1
p = n
b = 10
res = 1
while p:
if p & 0x1: res *= b
b *= b
p >>= 1
for i in range(0, 1000):
if (res + i) % 210 == 0:
print(10 ** n + i)
exit()
main()
``` | output | 1 | 104,735 | 20 | 209,471 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Chilly Willy loves playing with numbers. He only knows prime numbers that are digits yet. These numbers are 2, 3, 5 and 7. But Willy grew rather bored of such numbers, so he came up with a few games that were connected with them.
Chilly Willy wants to find the minimum number of length n, such that it is simultaneously divisible by all numbers Willy already knows (2, 3, 5 and 7). Help him with that.
A number's length is the number of digits in its decimal representation without leading zeros.
Input
A single input line contains a single integer n (1 β€ n β€ 105).
Output
Print a single integer β the answer to the problem without leading zeroes, or "-1" (without the quotes), if the number that meet the problem condition does not exist.
Examples
Input
1
Output
-1
Input
5
Output
10080 | instruction | 0 | 104,736 | 20 | 209,472 |
Tags: math, number theory
Correct Solution:
```
n=int(input())
if n==1 or n==2:
print(-1)
elif n==3:
print(210)
else:
x=10**(n-1)
while x%210!=0:
x=x+1
print(x)
``` | output | 1 | 104,736 | 20 | 209,473 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Chilly Willy loves playing with numbers. He only knows prime numbers that are digits yet. These numbers are 2, 3, 5 and 7. But Willy grew rather bored of such numbers, so he came up with a few games that were connected with them.
Chilly Willy wants to find the minimum number of length n, such that it is simultaneously divisible by all numbers Willy already knows (2, 3, 5 and 7). Help him with that.
A number's length is the number of digits in its decimal representation without leading zeros.
Input
A single input line contains a single integer n (1 β€ n β€ 105).
Output
Print a single integer β the answer to the problem without leading zeroes, or "-1" (without the quotes), if the number that meet the problem condition does not exist.
Examples
Input
1
Output
-1
Input
5
Output
10080 | instruction | 0 | 104,737 | 20 | 209,474 |
Tags: math, number theory
Correct Solution:
```
import math
n = int(input())
n -= 1
if n >= 2:
print(10 ** n + 210 - (10 ** n) % 210)
else:
print(-1)
``` | output | 1 | 104,737 | 20 | 209,475 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Chilly Willy loves playing with numbers. He only knows prime numbers that are digits yet. These numbers are 2, 3, 5 and 7. But Willy grew rather bored of such numbers, so he came up with a few games that were connected with them.
Chilly Willy wants to find the minimum number of length n, such that it is simultaneously divisible by all numbers Willy already knows (2, 3, 5 and 7). Help him with that.
A number's length is the number of digits in its decimal representation without leading zeros.
Input
A single input line contains a single integer n (1 β€ n β€ 105).
Output
Print a single integer β the answer to the problem without leading zeroes, or "-1" (without the quotes), if the number that meet the problem condition does not exist.
Examples
Input
1
Output
-1
Input
5
Output
10080 | instruction | 0 | 104,738 | 20 | 209,476 |
Tags: math, number theory
Correct Solution:
```
n = int(input())
if n <= 2:
print(-1)
elif n==3:
print(210)
else:
x = 2*pow(10,n-1,21)%21
a,b = x//10, x%10
print("1"+"0"*(n-4)+str(a)+str(b)+"0")
``` | output | 1 | 104,738 | 20 | 209,477 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Chilly Willy loves playing with numbers. He only knows prime numbers that are digits yet. These numbers are 2, 3, 5 and 7. But Willy grew rather bored of such numbers, so he came up with a few games that were connected with them.
Chilly Willy wants to find the minimum number of length n, such that it is simultaneously divisible by all numbers Willy already knows (2, 3, 5 and 7). Help him with that.
A number's length is the number of digits in its decimal representation without leading zeros.
Input
A single input line contains a single integer n (1 β€ n β€ 105).
Output
Print a single integer β the answer to the problem without leading zeroes, or "-1" (without the quotes), if the number that meet the problem condition does not exist.
Examples
Input
1
Output
-1
Input
5
Output
10080 | instruction | 0 | 104,739 | 20 | 209,478 |
Tags: math, number theory
Correct Solution:
```
n = int(input())
if n < 3 :
print(-1)
else :
ans = pow(10, (n - 1)) + (210 - (pow(10, (n - 1)) % 210))
print(ans)
``` | output | 1 | 104,739 | 20 | 209,479 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Chilly Willy loves playing with numbers. He only knows prime numbers that are digits yet. These numbers are 2, 3, 5 and 7. But Willy grew rather bored of such numbers, so he came up with a few games that were connected with them.
Chilly Willy wants to find the minimum number of length n, such that it is simultaneously divisible by all numbers Willy already knows (2, 3, 5 and 7). Help him with that.
A number's length is the number of digits in its decimal representation without leading zeros.
Input
A single input line contains a single integer n (1 β€ n β€ 105).
Output
Print a single integer β the answer to the problem without leading zeroes, or "-1" (without the quotes), if the number that meet the problem condition does not exist.
Examples
Input
1
Output
-1
Input
5
Output
10080 | instruction | 0 | 104,740 | 20 | 209,480 |
Tags: math, number theory
Correct Solution:
```
n = int(input())
if (n < 3):
print(-1)
exit()
cur = 10 ** (n - 1)
ans = 2 * 3 * 5 * 7
nex = cur//ans
print(ans * (nex + 1))
``` | output | 1 | 104,740 | 20 | 209,481 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Chilly Willy loves playing with numbers. He only knows prime numbers that are digits yet. These numbers are 2, 3, 5 and 7. But Willy grew rather bored of such numbers, so he came up with a few games that were connected with them.
Chilly Willy wants to find the minimum number of length n, such that it is simultaneously divisible by all numbers Willy already knows (2, 3, 5 and 7). Help him with that.
A number's length is the number of digits in its decimal representation without leading zeros.
Input
A single input line contains a single integer n (1 β€ n β€ 105).
Output
Print a single integer β the answer to the problem without leading zeroes, or "-1" (without the quotes), if the number that meet the problem condition does not exist.
Examples
Input
1
Output
-1
Input
5
Output
10080 | instruction | 0 | 104,741 | 20 | 209,482 |
Tags: math, number theory
Correct Solution:
```
n = int(input())
z = 10**(n-1)
if n<3:
print(-1)
else:
print(z+(210-z%210))
``` | output | 1 | 104,741 | 20 | 209,483 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Chilly Willy loves playing with numbers. He only knows prime numbers that are digits yet. These numbers are 2, 3, 5 and 7. But Willy grew rather bored of such numbers, so he came up with a few games that were connected with them.
Chilly Willy wants to find the minimum number of length n, such that it is simultaneously divisible by all numbers Willy already knows (2, 3, 5 and 7). Help him with that.
A number's length is the number of digits in its decimal representation without leading zeros.
Input
A single input line contains a single integer n (1 β€ n β€ 105).
Output
Print a single integer β the answer to the problem without leading zeroes, or "-1" (without the quotes), if the number that meet the problem condition does not exist.
Examples
Input
1
Output
-1
Input
5
Output
10080 | instruction | 0 | 104,742 | 20 | 209,484 |
Tags: math, number theory
Correct Solution:
```
n = int(input())
x = 10 ** (n-1)
res = x + 210 - x % 210
if res % 210 == 0 and res >= x and res <= x * 10:
print(res)
else:
print(-1)
``` | output | 1 | 104,742 | 20 | 209,485 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Chilly Willy loves playing with numbers. He only knows prime numbers that are digits yet. These numbers are 2, 3, 5 and 7. But Willy grew rather bored of such numbers, so he came up with a few games that were connected with them.
Chilly Willy wants to find the minimum number of length n, such that it is simultaneously divisible by all numbers Willy already knows (2, 3, 5 and 7). Help him with that.
A number's length is the number of digits in its decimal representation without leading zeros.
Input
A single input line contains a single integer n (1 β€ n β€ 105).
Output
Print a single integer β the answer to the problem without leading zeroes, or "-1" (without the quotes), if the number that meet the problem condition does not exist.
Examples
Input
1
Output
-1
Input
5
Output
10080
Submitted Solution:
```
n = int(input()) - 1
print(10 ** n + 210 - 10 * pow(10, n - 1, 21) if n > 1 else -1)
``` | instruction | 0 | 104,743 | 20 | 209,486 |
Yes | output | 1 | 104,743 | 20 | 209,487 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Chilly Willy loves playing with numbers. He only knows prime numbers that are digits yet. These numbers are 2, 3, 5 and 7. But Willy grew rather bored of such numbers, so he came up with a few games that were connected with them.
Chilly Willy wants to find the minimum number of length n, such that it is simultaneously divisible by all numbers Willy already knows (2, 3, 5 and 7). Help him with that.
A number's length is the number of digits in its decimal representation without leading zeros.
Input
A single input line contains a single integer n (1 β€ n β€ 105).
Output
Print a single integer β the answer to the problem without leading zeroes, or "-1" (without the quotes), if the number that meet the problem condition does not exist.
Examples
Input
1
Output
-1
Input
5
Output
10080
Submitted Solution:
```
from fractions import gcd
from random import randint
if __name__ == "__main__":
n = int(input())
if n < 3:
print(-1)
exit(0)
res = (210 -(10**(n-1) % 210)) + 10**(n-1);
print(res)
``` | instruction | 0 | 104,744 | 20 | 209,488 |
Yes | output | 1 | 104,744 | 20 | 209,489 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Chilly Willy loves playing with numbers. He only knows prime numbers that are digits yet. These numbers are 2, 3, 5 and 7. But Willy grew rather bored of such numbers, so he came up with a few games that were connected with them.
Chilly Willy wants to find the minimum number of length n, such that it is simultaneously divisible by all numbers Willy already knows (2, 3, 5 and 7). Help him with that.
A number's length is the number of digits in its decimal representation without leading zeros.
Input
A single input line contains a single integer n (1 β€ n β€ 105).
Output
Print a single integer β the answer to the problem without leading zeroes, or "-1" (without the quotes), if the number that meet the problem condition does not exist.
Examples
Input
1
Output
-1
Input
5
Output
10080
Submitted Solution:
```
n=int(input())
rem=10**(n-1)%210
var=210-rem
if n<3: #248B
print(-1)
elif n==3:
print(210)
else:
print(10**(n-1)+var)
``` | instruction | 0 | 104,745 | 20 | 209,490 |
Yes | output | 1 | 104,745 | 20 | 209,491 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Chilly Willy loves playing with numbers. He only knows prime numbers that are digits yet. These numbers are 2, 3, 5 and 7. But Willy grew rather bored of such numbers, so he came up with a few games that were connected with them.
Chilly Willy wants to find the minimum number of length n, such that it is simultaneously divisible by all numbers Willy already knows (2, 3, 5 and 7). Help him with that.
A number's length is the number of digits in its decimal representation without leading zeros.
Input
A single input line contains a single integer n (1 β€ n β€ 105).
Output
Print a single integer β the answer to the problem without leading zeroes, or "-1" (without the quotes), if the number that meet the problem condition does not exist.
Examples
Input
1
Output
-1
Input
5
Output
10080
Submitted Solution:
```
n = int(input())
s = 10 ** (n - 1)
while s % 21 != 0:
s += 10
if n > 2:
print(s)
else:
print(-1)
``` | instruction | 0 | 104,746 | 20 | 209,492 |
Yes | output | 1 | 104,746 | 20 | 209,493 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.