message stringlengths 2 39.6k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 219 108k | cluster float64 11 11 | __index_level_0__ int64 438 217k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants.
Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the n-th place participant has rating an. Then changing the rating on the Codesecrof site is calculated by the formula <image>.
After the round was over, the Codesecrof management published the participants' results table. They decided that if for a participant di < k, then the round can be considered unrated for him. But imagine the management's surprise when they found out that the participants' rating table is dynamic. In other words, when some participant is removed from the rating, he is removed from the results' table and the rating is recalculated according to the new table. And of course, all applications for exclusion from the rating are considered in view of the current table.
We know that among all the applications for exclusion from the rating the first application to consider is from the participant with the best rank (the rank with the minimum number), for who di < k. We also know that the applications for exclusion from rating were submitted by all participants.
Now Sereja wonders, what is the number of participants to be excluded from the contest rating, and the numbers of the participants in the original table in the order of their exclusion from the rating. Pay attention to the analysis of the first test case for a better understanding of the statement.
Input
The first line contains two integers n, k (1 β€ n β€ 2Β·105, - 109 β€ k β€ 0). The second line contains n space-separated integers a1, a2, ..., an (1 β€ ai β€ 109) β ratings of the participants in the initial table.
Output
Print the numbers of participants in the order in which they were removed from the table. Print the initial numbers of the participants, that is, the numbers that the participants had in the initial table.
Examples
Input
5 0
5 3 4 1 2
Output
2
3
4
Input
10 -10
5 5 1 7 5 1 2 4 9 2
Output
2
4
5
7
8
9
Note
Consider the first test sample.
1. Initially the sequence of the contest participants' ratings equals [5, 3, 4, 1, 2]. You can use this sequence to calculate the sequence of rating changes: [0, -9, -13, 8, 14]. According to the problem statement, the application of the participant who won the second place will be considered first.
2. As soon as the second place winner is out from the ratings, the participants' rating sequence will equal [5, 4, 1, 2]. By this sequence you can count the new sequence of rating changes: [0, -8, 2, 6]. According to the problem statement, the application of the participant who won the second place will be considered. Initially this participant won third place.
3. The new rating sequence equals [5, 1, 2], the new sequence of rating changes equals [0, -1, 1]. The second place participant's application is taken into consideration, initially this participant won the fourth place.
4. The new rating sequence equals [5, 2], the new sequence of rating changes equals [0, 0]. No more applications will be considered.
Thus, you should print 2, 3, 4.
Submitted Solution:
```
f = lambda: map(int, input().split())
n, k = f()
s = j = 0
for i, q in enumerate(f(), 1):
if s - j * (n - i) * q < k: print(i)
else:
s += q * (i - 1)
j += 1
``` | instruction | 0 | 85,299 | 11 | 170,598 |
No | output | 1 | 85,299 | 11 | 170,599 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake.
However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change.
Can you help B find out exactly what two errors he corrected?
Input
The first line of the input contains integer n (3 β€ n β€ 105) β the initial number of compilation errors.
The second line contains n space-separated integers a1, a2, ..., an (1 β€ ai β€ 109) β the errors the compiler displayed for the first time.
The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one.
The fourth line contains n - 2 space-separated integers Ρ1, Ρ2, ..., Ρn - 2 β the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one.
Output
Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively.
Examples
Input
5
1 5 8 123 7
123 7 5 1
5 1 7
Output
8
123
Input
6
1 4 3 3 5 7
3 7 5 4 3
4 3 7 5
Output
1
3
Note
In the first test sample B first corrects the error number 8, then the error number 123.
In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. | instruction | 0 | 86,086 | 11 | 172,172 |
Tags: data structures, implementation, sortings
Correct Solution:
```
a=int(input())
b=input().split()
c=input().split()
d=input().split()
b=[int(i) for i in b]
c=[int(i) for i in c]
d=[int(i) for i in d]
b=sum(b)
c=sum(c)
d=sum(d)
print(b-c)
print(c-d)
``` | output | 1 | 86,086 | 11 | 172,173 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake.
However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change.
Can you help B find out exactly what two errors he corrected?
Input
The first line of the input contains integer n (3 β€ n β€ 105) β the initial number of compilation errors.
The second line contains n space-separated integers a1, a2, ..., an (1 β€ ai β€ 109) β the errors the compiler displayed for the first time.
The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one.
The fourth line contains n - 2 space-separated integers Ρ1, Ρ2, ..., Ρn - 2 β the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one.
Output
Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively.
Examples
Input
5
1 5 8 123 7
123 7 5 1
5 1 7
Output
8
123
Input
6
1 4 3 3 5 7
3 7 5 4 3
4 3 7 5
Output
1
3
Note
In the first test sample B first corrects the error number 8, then the error number 123.
In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. | instruction | 0 | 86,087 | 11 | 172,174 |
Tags: data structures, implementation, sortings
Correct Solution:
```
input()
x=list(map(int,input().split()))
y=list(map(int,input().split()))
z=list(map(int,input().split()))
print(sum(x)-sum(y))
print(sum(y)-sum(z))
``` | output | 1 | 86,087 | 11 | 172,175 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake.
However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change.
Can you help B find out exactly what two errors he corrected?
Input
The first line of the input contains integer n (3 β€ n β€ 105) β the initial number of compilation errors.
The second line contains n space-separated integers a1, a2, ..., an (1 β€ ai β€ 109) β the errors the compiler displayed for the first time.
The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one.
The fourth line contains n - 2 space-separated integers Ρ1, Ρ2, ..., Ρn - 2 β the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one.
Output
Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively.
Examples
Input
5
1 5 8 123 7
123 7 5 1
5 1 7
Output
8
123
Input
6
1 4 3 3 5 7
3 7 5 4 3
4 3 7 5
Output
1
3
Note
In the first test sample B first corrects the error number 8, then the error number 123.
In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. | instruction | 0 | 86,088 | 11 | 172,176 |
Tags: data structures, implementation, sortings
Correct Solution:
```
from collections import Counter
a = int(input())
b = list(int(x) for x in input().split())
c = list(int(x) for x in input().split())
d = list(int(x) for x in input().split())
p = list((Counter(b) - Counter(c)).elements())
for i in p:
print(i)
p = list((Counter(c) - Counter(d)).elements())
for i in p:
print(i)
``` | output | 1 | 86,088 | 11 | 172,177 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake.
However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change.
Can you help B find out exactly what two errors he corrected?
Input
The first line of the input contains integer n (3 β€ n β€ 105) β the initial number of compilation errors.
The second line contains n space-separated integers a1, a2, ..., an (1 β€ ai β€ 109) β the errors the compiler displayed for the first time.
The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one.
The fourth line contains n - 2 space-separated integers Ρ1, Ρ2, ..., Ρn - 2 β the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one.
Output
Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively.
Examples
Input
5
1 5 8 123 7
123 7 5 1
5 1 7
Output
8
123
Input
6
1 4 3 3 5 7
3 7 5 4 3
4 3 7 5
Output
1
3
Note
In the first test sample B first corrects the error number 8, then the error number 123.
In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. | instruction | 0 | 86,089 | 11 | 172,178 |
Tags: data structures, implementation, sortings
Correct Solution:
```
n=int(input())
l=list(map(int,input().split()))
b=[]
for i in range(2):
b=list(map(int,input().split()))
print(sum(l)-sum(b))
l=b.copy()
``` | output | 1 | 86,089 | 11 | 172,179 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake.
However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change.
Can you help B find out exactly what two errors he corrected?
Input
The first line of the input contains integer n (3 β€ n β€ 105) β the initial number of compilation errors.
The second line contains n space-separated integers a1, a2, ..., an (1 β€ ai β€ 109) β the errors the compiler displayed for the first time.
The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one.
The fourth line contains n - 2 space-separated integers Ρ1, Ρ2, ..., Ρn - 2 β the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one.
Output
Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively.
Examples
Input
5
1 5 8 123 7
123 7 5 1
5 1 7
Output
8
123
Input
6
1 4 3 3 5 7
3 7 5 4 3
4 3 7 5
Output
1
3
Note
In the first test sample B first corrects the error number 8, then the error number 123.
In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. | instruction | 0 | 86,090 | 11 | 172,180 |
Tags: data structures, implementation, sortings
Correct Solution:
```
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
suma = sum(a)
sumb = sum(b)
sumc = sum(c)
print(suma-sumb)
print(sumb-sumc)
``` | output | 1 | 86,090 | 11 | 172,181 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake.
However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change.
Can you help B find out exactly what two errors he corrected?
Input
The first line of the input contains integer n (3 β€ n β€ 105) β the initial number of compilation errors.
The second line contains n space-separated integers a1, a2, ..., an (1 β€ ai β€ 109) β the errors the compiler displayed for the first time.
The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one.
The fourth line contains n - 2 space-separated integers Ρ1, Ρ2, ..., Ρn - 2 β the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one.
Output
Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively.
Examples
Input
5
1 5 8 123 7
123 7 5 1
5 1 7
Output
8
123
Input
6
1 4 3 3 5 7
3 7 5 4 3
4 3 7 5
Output
1
3
Note
In the first test sample B first corrects the error number 8, then the error number 123.
In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. | instruction | 0 | 86,091 | 11 | 172,182 |
Tags: data structures, implementation, sortings
Correct Solution:
```
n = int(input())
e = [sum(map(int, input().split())) for i in range(3)]
print(e[0] - e[1])
print(e[1] - e[2])
``` | output | 1 | 86,091 | 11 | 172,183 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake.
However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change.
Can you help B find out exactly what two errors he corrected?
Input
The first line of the input contains integer n (3 β€ n β€ 105) β the initial number of compilation errors.
The second line contains n space-separated integers a1, a2, ..., an (1 β€ ai β€ 109) β the errors the compiler displayed for the first time.
The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one.
The fourth line contains n - 2 space-separated integers Ρ1, Ρ2, ..., Ρn - 2 β the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one.
Output
Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively.
Examples
Input
5
1 5 8 123 7
123 7 5 1
5 1 7
Output
8
123
Input
6
1 4 3 3 5 7
3 7 5 4 3
4 3 7 5
Output
1
3
Note
In the first test sample B first corrects the error number 8, then the error number 123.
In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. | instruction | 0 | 86,092 | 11 | 172,184 |
Tags: data structures, implementation, sortings
Correct Solution:
```
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
suma=sum(a)
sumb=sum(b)
sumc=sum(c)
print(suma-sumb)
print(sumb-sumc)
``` | output | 1 | 86,092 | 11 | 172,185 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake.
However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change.
Can you help B find out exactly what two errors he corrected?
Input
The first line of the input contains integer n (3 β€ n β€ 105) β the initial number of compilation errors.
The second line contains n space-separated integers a1, a2, ..., an (1 β€ ai β€ 109) β the errors the compiler displayed for the first time.
The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one.
The fourth line contains n - 2 space-separated integers Ρ1, Ρ2, ..., Ρn - 2 β the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one.
Output
Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively.
Examples
Input
5
1 5 8 123 7
123 7 5 1
5 1 7
Output
8
123
Input
6
1 4 3 3 5 7
3 7 5 4 3
4 3 7 5
Output
1
3
Note
In the first test sample B first corrects the error number 8, then the error number 123.
In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. | instruction | 0 | 86,093 | 11 | 172,186 |
Tags: data structures, implementation, sortings
Correct Solution:
```
n=input()
n=list(input().split())
m=list(input().split())
l=list(input().split())
n.sort()
m.sort()
l.sort()
i=0
while i<len(n):
if i==len(m):
q=n[i]
break
elif n[i]!=m[i]:
q=n[i]
break
i+=1
i=0
while i<len(m):
if i==len(l):
w=m[i]
break
elif m[i]!=l[i]:
w=m[i]
break
i+=1
print(q)
print(w)
``` | output | 1 | 86,093 | 11 | 172,187 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake.
However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change.
Can you help B find out exactly what two errors he corrected?
Input
The first line of the input contains integer n (3 β€ n β€ 105) β the initial number of compilation errors.
The second line contains n space-separated integers a1, a2, ..., an (1 β€ ai β€ 109) β the errors the compiler displayed for the first time.
The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one.
The fourth line contains n - 2 space-separated integers Ρ1, Ρ2, ..., Ρn - 2 β the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one.
Output
Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively.
Examples
Input
5
1 5 8 123 7
123 7 5 1
5 1 7
Output
8
123
Input
6
1 4 3 3 5 7
3 7 5 4 3
4 3 7 5
Output
1
3
Note
In the first test sample B first corrects the error number 8, then the error number 123.
In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step.
Submitted Solution:
```
n = int(input())
a = [num for num in input().split()]
b = [num for num in input().split()]
c = [num for num in input().split()]
x = "x"
y = "y"
a.sort()
b.sort()
c.sort()
for i in range(n-1):
if a[i] != b[i]:
x = a[i]
break
if x == "x":
x = a[n-1]
for i in range(n-2):
if b[i] != c[i]:
y = b[i]
break
if y =="y":
y = b[n-2]
print(x)
print(y)
``` | instruction | 0 | 86,094 | 11 | 172,188 |
Yes | output | 1 | 86,094 | 11 | 172,189 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake.
However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change.
Can you help B find out exactly what two errors he corrected?
Input
The first line of the input contains integer n (3 β€ n β€ 105) β the initial number of compilation errors.
The second line contains n space-separated integers a1, a2, ..., an (1 β€ ai β€ 109) β the errors the compiler displayed for the first time.
The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one.
The fourth line contains n - 2 space-separated integers Ρ1, Ρ2, ..., Ρn - 2 β the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one.
Output
Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively.
Examples
Input
5
1 5 8 123 7
123 7 5 1
5 1 7
Output
8
123
Input
6
1 4 3 3 5 7
3 7 5 4 3
4 3 7 5
Output
1
3
Note
In the first test sample B first corrects the error number 8, then the error number 123.
In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step.
Submitted Solution:
```
n=int(input())
x=-1
y=-1
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
#print("",a,'\n',b,'\n',c)
for i in range(n-1):
if x==-1 and a[i] != b[i]:
x=a[i]
if y==-1 and i<n-2 and b[i] != c[i] :
y=b[i]
if x==-1:
x=a[n-1]
if y==-1:
y=b[n-2]
print(x)
print(y)
"""
5
1 5 8 123 7
123 7 5 1
5 1 7
outputCopy
8
123
inputCopy
6
1 4 3 3 5 7
3 7 5 4 3
4 3 7 5
outputCopy
1
3
"""
``` | instruction | 0 | 86,095 | 11 | 172,190 |
Yes | output | 1 | 86,095 | 11 | 172,191 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake.
However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change.
Can you help B find out exactly what two errors he corrected?
Input
The first line of the input contains integer n (3 β€ n β€ 105) β the initial number of compilation errors.
The second line contains n space-separated integers a1, a2, ..., an (1 β€ ai β€ 109) β the errors the compiler displayed for the first time.
The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one.
The fourth line contains n - 2 space-separated integers Ρ1, Ρ2, ..., Ρn - 2 β the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one.
Output
Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively.
Examples
Input
5
1 5 8 123 7
123 7 5 1
5 1 7
Output
8
123
Input
6
1 4 3 3 5 7
3 7 5 4 3
4 3 7 5
Output
1
3
Note
In the first test sample B first corrects the error number 8, then the error number 123.
In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step.
Submitted Solution:
```
n=int(input())
l=input().split(" ",n)
m=input().split(" ",n-1)
j=input().split(" ",n-2)
sum2=0
sum1=0
sum3=0
for i in range(n):
sum1 += int(l[i]);
for i in range(n-1):
sum2 +=int(m[i])
for i in range(n-2):
sum3 +=int(j[i])
print(sum1-sum2)
print(sum2-sum3)
``` | instruction | 0 | 86,096 | 11 | 172,192 |
Yes | output | 1 | 86,096 | 11 | 172,193 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake.
However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change.
Can you help B find out exactly what two errors he corrected?
Input
The first line of the input contains integer n (3 β€ n β€ 105) β the initial number of compilation errors.
The second line contains n space-separated integers a1, a2, ..., an (1 β€ ai β€ 109) β the errors the compiler displayed for the first time.
The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one.
The fourth line contains n - 2 space-separated integers Ρ1, Ρ2, ..., Ρn - 2 β the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one.
Output
Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively.
Examples
Input
5
1 5 8 123 7
123 7 5 1
5 1 7
Output
8
123
Input
6
1 4 3 3 5 7
3 7 5 4 3
4 3 7 5
Output
1
3
Note
In the first test sample B first corrects the error number 8, then the error number 123.
In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step.
Submitted Solution:
```
input()
first_compile = sum(map(int, input().split()))
second_compile = sum(map(int, input().split()))
third_compile = sum(map(int, input().split()))
print(first_compile - second_compile, second_compile - third_compile)
``` | instruction | 0 | 86,097 | 11 | 172,194 |
Yes | output | 1 | 86,097 | 11 | 172,195 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake.
However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change.
Can you help B find out exactly what two errors he corrected?
Input
The first line of the input contains integer n (3 β€ n β€ 105) β the initial number of compilation errors.
The second line contains n space-separated integers a1, a2, ..., an (1 β€ ai β€ 109) β the errors the compiler displayed for the first time.
The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one.
The fourth line contains n - 2 space-separated integers Ρ1, Ρ2, ..., Ρn - 2 β the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one.
Output
Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively.
Examples
Input
5
1 5 8 123 7
123 7 5 1
5 1 7
Output
8
123
Input
6
1 4 3 3 5 7
3 7 5 4 3
4 3 7 5
Output
1
3
Note
In the first test sample B first corrects the error number 8, then the error number 123.
In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step.
Submitted Solution:
```
# -*- coding: utf-8 -*-
"""
Created on Mon Dec 23 18:19:49 2019
@author: Tuan
"""
ord1 = [int(i) for i in input().split()]
ord2 = [int(i) for i in input().split()]
ord3 = [int(i) for i in input().split()]
err1 = sum(ord1)- sum(ord2)
err2 = sum(ord2)- sum(ord3)
print(err1, err2, sep='\n')
``` | instruction | 0 | 86,098 | 11 | 172,196 |
No | output | 1 | 86,098 | 11 | 172,197 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake.
However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change.
Can you help B find out exactly what two errors he corrected?
Input
The first line of the input contains integer n (3 β€ n β€ 105) β the initial number of compilation errors.
The second line contains n space-separated integers a1, a2, ..., an (1 β€ ai β€ 109) β the errors the compiler displayed for the first time.
The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one.
The fourth line contains n - 2 space-separated integers Ρ1, Ρ2, ..., Ρn - 2 β the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one.
Output
Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively.
Examples
Input
5
1 5 8 123 7
123 7 5 1
5 1 7
Output
8
123
Input
6
1 4 3 3 5 7
3 7 5 4 3
4 3 7 5
Output
1
3
Note
In the first test sample B first corrects the error number 8, then the error number 123.
In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step.
Submitted Solution:
```
n = int(input())
arr = list(map(int,input().split()))
arr1 = list(map(int,input().split()))
arr2 = list(map(int,input().split()))
a = set(arr) - set(arr1)
b = set(arr1) - set(arr2)
print(a)
print(b)
``` | instruction | 0 | 86,099 | 11 | 172,198 |
No | output | 1 | 86,099 | 11 | 172,199 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake.
However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change.
Can you help B find out exactly what two errors he corrected?
Input
The first line of the input contains integer n (3 β€ n β€ 105) β the initial number of compilation errors.
The second line contains n space-separated integers a1, a2, ..., an (1 β€ ai β€ 109) β the errors the compiler displayed for the first time.
The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one.
The fourth line contains n - 2 space-separated integers Ρ1, Ρ2, ..., Ρn - 2 β the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one.
Output
Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively.
Examples
Input
5
1 5 8 123 7
123 7 5 1
5 1 7
Output
8
123
Input
6
1 4 3 3 5 7
3 7 5 4 3
4 3 7 5
Output
1
3
Note
In the first test sample B first corrects the error number 8, then the error number 123.
In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step.
Submitted Solution:
```
n = input()
a = [a for a in input().split()]
b = [b for b in input().split()]
c = [c for c in input().split()]
print(set(a).difference(b))
print(set(b).difference(c))
``` | instruction | 0 | 86,100 | 11 | 172,200 |
No | output | 1 | 86,100 | 11 | 172,201 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake.
However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change.
Can you help B find out exactly what two errors he corrected?
Input
The first line of the input contains integer n (3 β€ n β€ 105) β the initial number of compilation errors.
The second line contains n space-separated integers a1, a2, ..., an (1 β€ ai β€ 109) β the errors the compiler displayed for the first time.
The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one.
The fourth line contains n - 2 space-separated integers Ρ1, Ρ2, ..., Ρn - 2 β the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one.
Output
Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively.
Examples
Input
5
1 5 8 123 7
123 7 5 1
5 1 7
Output
8
123
Input
6
1 4 3 3 5 7
3 7 5 4 3
4 3 7 5
Output
1
3
Note
In the first test sample B first corrects the error number 8, then the error number 123.
In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step.
Submitted Solution:
```
n=input()
a1=input()
a2=input()
a3=input()
a1=a1.split()
a2=a2.split()
a3=a3.split()
l=[]
m=[]
for i in a1:
l.append(i)
if l.count(i) - a2.count(i)==1:
print (i)
if l.count(i) - a3.count(i)==1 and i in a2:
print (i)
``` | instruction | 0 | 86,101 | 11 | 172,202 |
No | output | 1 | 86,101 | 11 | 172,203 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some positive integer from 1 to n, such that equality holds.
Input
The only line of the input contains a rebus. It's guaranteed that it contains no more than 100 question marks, integer n is positive and doesn't exceed 1 000 000, all letters and integers are separated by spaces, arithmetic operations are located only between question marks.
Output
The first line of the output should contain "Possible" (without quotes) if rebus has a solution and "Impossible" (without quotes) otherwise.
If the answer exists, the second line should contain any valid rebus with question marks replaced by integers from 1 to n. Follow the format given in the samples.
Examples
Input
? + ? - ? + ? + ? = 42
Output
Possible
9 + 13 - 39 + 28 + 31 = 42
Input
? - ? = 1
Output
Impossible
Input
? = 1000000
Output
Possible
1000000 = 1000000
Submitted Solution:
```
#!/usr/bin/env python3
# 664B_rebus.py - Codeforces.com/problemset/problem/664/B by Sergey 2016
import unittest
import sys
import re
###############################################################################
# Rebus Class (Main Program)
###############################################################################
class Rebus:
""" Rebus representation """
def __init__(self, test_inputs=None):
""" Default constructor """
it = iter(test_inputs.split("\n")) if test_inputs else None
def uinput():
return next(it) if it else sys.stdin.readline().rstrip()
# Reading single elements
self.str = uinput()
# End value
self.n = 0
m = re.search("(\d+)", self.str)
if m:
self.n = int(m.group(1))
# Signs
self.signs = ["+"] + re.findall("\? ([+-])", self.str)
def summ(self, nums, signs):
result = 0
for i in range(len(self.signs)):
if self.signs[i] == "+":
result += nums[i]
else:
result -= nums[i]
return result
def calculate(self):
""" Main calcualtion function of the class """
nums = [0] * len(self.signs)
for i in range(len(self.signs)):
nums[i] = 1
sum = self.summ(nums, self.signs)
for i in range(len(self.signs)):
if sum != self.n:
if self.signs[i] == "+" and sum < self.n:
nums[i] = min(self.n - sum + 1, self.n)
sum -= 1
sum += nums[i]
if self.signs[i] == "-" and sum > self.n:
nums[i] = min(sum + 1 - self.n, self.n)
sum += 1
sum -= nums[i]
if sum == self.n:
result = "Possible\n"
for i in range(len(self.signs)):
if i != 0:
result += self.signs[i] + " "
result += str(nums[i]) + " "
result += "= " + str(self.n)
else:
result = "Impossible"
return str(result)
###############################################################################
# Unit Tests
###############################################################################
class unitTests(unittest.TestCase):
def test_single_test(self):
""" Rebus class testing """
# Constructor test
test = "? + ? - ? + ? + ? = 42"
d = Rebus(test)
self.assertEqual(d.str, "? + ? - ? + ? + ? = 42")
self.assertEqual(d.n, 42)
self.assertEqual(d.signs, ["+", "+", "-", "+", "+"])
# Sample test
self.assertEqual(Rebus(test).calculate(), "Possible\n40 + 1 - 1 + 1 + 1 = 42")
# Sample test
test = "? - ? = 1"
self.assertEqual(Rebus(test).calculate(), "Impossible")
# Sample test
test = "? = 1000000"
self.assertEqual(Rebus(test).calculate(), "Possible\n1000000 = 1000000")
test = "? + ? + ? + ? - ? = 2"
self.assertEqual(Rebus(test).calculate(), "Possible\n1 + 1 + 1 + 1 - 2 = 2")
# My tests
test = ""
# self.assertEqual(Rebus(test).calculate(), "0")
# Time limit test
# self.time_limit_test(5000)
def time_limit_test(self, nmax):
""" Timelimit testing """
import random
import timeit
# Random inputs
test = str(nmax) + " " + str(nmax) + "\n"
numnums = [str(i) + " " + str(i+1) for i in range(nmax)]
test += "\n".join(numnums) + "\n"
nums = [random.randint(1, 10000) for i in range(nmax)]
test += " ".join(map(str, nums)) + "\n"
# Run the test
start = timeit.default_timer()
d = Rebus(test)
calc = timeit.default_timer()
d.calculate()
stop = timeit.default_timer()
print("\nTimelimit Test: " +
"{0:.3f}s (init {1:.3f}s calc {2:.3f}s)".
format(stop-start, calc-start, stop-calc))
if __name__ == "__main__":
# Avoiding recursion limitaions
sys.setrecursionlimit(100000)
if sys.argv[-1] == "-ut":
unittest.main(argv=[" "])
# Print the result string
sys.stdout.write(Rebus().calculate())
``` | instruction | 0 | 86,162 | 11 | 172,324 |
Yes | output | 1 | 86,162 | 11 | 172,325 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some positive integer from 1 to n, such that equality holds.
Input
The only line of the input contains a rebus. It's guaranteed that it contains no more than 100 question marks, integer n is positive and doesn't exceed 1 000 000, all letters and integers are separated by spaces, arithmetic operations are located only between question marks.
Output
The first line of the output should contain "Possible" (without quotes) if rebus has a solution and "Impossible" (without quotes) otherwise.
If the answer exists, the second line should contain any valid rebus with question marks replaced by integers from 1 to n. Follow the format given in the samples.
Examples
Input
? + ? - ? + ? + ? = 42
Output
Possible
9 + 13 - 39 + 28 + 31 = 42
Input
? - ? = 1
Output
Impossible
Input
? = 1000000
Output
Possible
1000000 = 1000000
Submitted Solution:
```
#!/usr/bin/env python3
import re
try:
while True:
s = input()
n = int(s[s.rfind(' '):])
pos = s.count('+') + 1
neg = s.count('-')
if n * pos - neg < n or pos - n * neg > n:
print("Impossible")
else:
print("Possible")
need = n - (pos - neg)
prev = '+'
first = True
for m in re.finditer(r"[+-]", s):
if first:
first = False
else:
print(prev, end=' ')
if prev == '+' and need > 0:
x = min(need + 1, n)
need -= x - 1
elif prev == '-' and need < 0:
x = min(-need + 1, n)
need += x - 1
else:
x = 1
print(x, end=' ')
prev = m.group()
if not first:
print(prev, end=' ')
if prev == '+' and need > 0:
x = min(need + 1, n)
need -= x - 1
elif prev == '-' and need < 0:
x = min(-need + 1, n)
need += x - 1
else:
x = 1
print(x, '=', n)
except EOFError:
pass
``` | instruction | 0 | 86,163 | 11 | 172,326 |
Yes | output | 1 | 86,163 | 11 | 172,327 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some positive integer from 1 to n, such that equality holds.
Input
The only line of the input contains a rebus. It's guaranteed that it contains no more than 100 question marks, integer n is positive and doesn't exceed 1 000 000, all letters and integers are separated by spaces, arithmetic operations are located only between question marks.
Output
The first line of the output should contain "Possible" (without quotes) if rebus has a solution and "Impossible" (without quotes) otherwise.
If the answer exists, the second line should contain any valid rebus with question marks replaced by integers from 1 to n. Follow the format given in the samples.
Examples
Input
? + ? - ? + ? + ? = 42
Output
Possible
9 + 13 - 39 + 28 + 31 = 42
Input
? - ? = 1
Output
Impossible
Input
? = 1000000
Output
Possible
1000000 = 1000000
Submitted Solution:
```
ar, ans = input().split('=')
ans = int(ans)
pl = ar.count('+') + 1
mn = ar.count('-')
if pl*ans - mn*1 < ans or pl*1 - mn*ans > ans:
print("Impossible")
exit(0)
print("Possible")
mat = [1]*(pl+mn)
sig = ('+' + ar).replace(' ', '').split('?')
del sig[-1]
while True:
i = 0
s = ""
for ch in ar:
if ch == '?':
s += str(mat[i])
i += 1
else:
s += ch
t = eval(s)
if t == ans:
print("{0}= {1}".format(s, ans))
exit(0)
d = ans - t
for i in range(len(mat)):
if sig[i] == '+' and d > 0:
mat[i] = min(1 + d, ans)
d -= mat[i] - 1
elif sig[i] == '-' and d < 0:
mat[i] = min(1 + abs(d), ans)
d += mat[i] - 1
``` | instruction | 0 | 86,164 | 11 | 172,328 |
Yes | output | 1 | 86,164 | 11 | 172,329 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some positive integer from 1 to n, such that equality holds.
Input
The only line of the input contains a rebus. It's guaranteed that it contains no more than 100 question marks, integer n is positive and doesn't exceed 1 000 000, all letters and integers are separated by spaces, arithmetic operations are located only between question marks.
Output
The first line of the output should contain "Possible" (without quotes) if rebus has a solution and "Impossible" (without quotes) otherwise.
If the answer exists, the second line should contain any valid rebus with question marks replaced by integers from 1 to n. Follow the format given in the samples.
Examples
Input
? + ? - ? + ? + ? = 42
Output
Possible
9 + 13 - 39 + 28 + 31 = 42
Input
? - ? = 1
Output
Impossible
Input
? = 1000000
Output
Possible
1000000 = 1000000
Submitted Solution:
```
expr = input().split()
target_number = int(expr[-1])
result_expr = None
def spread(number_sum, quantity):
spreaded = []
acc = number_sum
remaining = quantity - 1
for i in range(quantity):
next_number = min(target_number, acc - remaining)
spreaded.append(next_number)
acc -= next_number
remaining -= 1
return spreaded
plus_count = 1 + expr.count('+')
minus_count = expr.count('-')
if minus_count == 0:
if plus_count <= target_number <= plus_count*target_number:
spreaded = spread(target_number, plus_count)
result_expr = "{0} = {1}".format(" + ".join(map(str, spreaded)), target_number)
else:
negative = minus_count
if negative <= minus_count*target_number:
positive = negative + target_number
if plus_count <= positive <= plus_count*target_number:
spreaded_positive = spread(positive, plus_count)
spreaded_negative = spread(negative, minus_count)
result_expr = "{0} ".format(spreaded_positive.pop())
for i in range(1, len(expr) - 2):
if expr[i] == '+':
result_expr += '+ {0} '.format(spreaded_positive.pop())
elif expr[i] == '-':
result_expr += '- {0} '.format(spreaded_negative.pop())
result_expr += "= {0}".format(target_number)
if result_expr:
print("Possible")
print(result_expr)
else:
print("Impossible")
``` | instruction | 0 | 86,165 | 11 | 172,330 |
No | output | 1 | 86,165 | 11 | 172,331 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some positive integer from 1 to n, such that equality holds.
Input
The only line of the input contains a rebus. It's guaranteed that it contains no more than 100 question marks, integer n is positive and doesn't exceed 1 000 000, all letters and integers are separated by spaces, arithmetic operations are located only between question marks.
Output
The first line of the output should contain "Possible" (without quotes) if rebus has a solution and "Impossible" (without quotes) otherwise.
If the answer exists, the second line should contain any valid rebus with question marks replaced by integers from 1 to n. Follow the format given in the samples.
Examples
Input
? + ? - ? + ? + ? = 42
Output
Possible
9 + 13 - 39 + 28 + 31 = 42
Input
? - ? = 1
Output
Impossible
Input
? = 1000000
Output
Possible
1000000 = 1000000
Submitted Solution:
```
s = input()
plus = 1
minus = 0
for i in s :
if i=='+':
plus+=1
if i=='-':
minus+=1
n= int (s[s.rfind(' '):])
if plus<=minus :
print('Impossible')
else:
if plus>minus:
ras=plus-minus
znak=0
if (ras>n):
print('Impossible')
else:
out = str(n-ras+1);
for i in s[1:s.rfind(' ')]:
if i=='?':
out+='1'
if i=='+':
out+='+'
if i=='-':
out+='-'
if i=='=':
out=out+'= '+str(n)
if i==' ':
out+=' '
print(out)
``` | instruction | 0 | 86,168 | 11 | 172,336 |
No | output | 1 | 86,168 | 11 | 172,337 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You and your friend are participating in a TV show "Run For Your Prize".
At the start of the show n prizes are located on a straight line. i-th prize is located at position ai. Positions of all prizes are distinct. You start at position 1, your friend β at position 106 (and there is no prize in any of these two positions). You have to work as a team and collect all prizes in minimum possible time, in any order.
You know that it takes exactly 1 second to move from position x to position x + 1 or x - 1, both for you and your friend. You also have trained enough to instantly pick up any prize, if its position is equal to your current position (and the same is true for your friend). Carrying prizes does not affect your speed (or your friend's speed) at all.
Now you may discuss your strategy with your friend and decide who will pick up each prize. Remember that every prize must be picked up, either by you or by your friend.
What is the minimum number of seconds it will take to pick up all the prizes?
Input
The first line contains one integer n (1 β€ n β€ 105) β the number of prizes.
The second line contains n integers a1, a2, ..., an (2 β€ ai β€ 106 - 1) β the positions of the prizes. No two prizes are located at the same position. Positions are given in ascending order.
Output
Print one integer β the minimum number of seconds it will take to collect all prizes.
Examples
Input
3
2 3 9
Output
8
Input
2
2 999995
Output
5
Note
In the first example you take all the prizes: take the first at 1, the second at 2 and the third at 8.
In the second example you take the first prize in 1 second and your friend takes the other in 5 seconds, you do this simultaneously, so the total time is 5.
Submitted Solution:
```
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 16 21:31:15 2018
@author: Anuroop Behera
"""
n = int(input())
a = input().split()
for i in range(len(a)):
a[i] = int(a[i])
if a[n-1] <= 1000000/2:
print(a[n-1]-1)
elif a[0] > 1000000/2:
print(1000001-a[0]-1)
else:
for i in range(len(a)):
if a[i] > 500000:
break
print(max(a[i-1]-1,1000001-a[i]-1))
``` | instruction | 0 | 86,273 | 11 | 172,546 |
Yes | output | 1 | 86,273 | 11 | 172,547 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You and your friend are participating in a TV show "Run For Your Prize".
At the start of the show n prizes are located on a straight line. i-th prize is located at position ai. Positions of all prizes are distinct. You start at position 1, your friend β at position 106 (and there is no prize in any of these two positions). You have to work as a team and collect all prizes in minimum possible time, in any order.
You know that it takes exactly 1 second to move from position x to position x + 1 or x - 1, both for you and your friend. You also have trained enough to instantly pick up any prize, if its position is equal to your current position (and the same is true for your friend). Carrying prizes does not affect your speed (or your friend's speed) at all.
Now you may discuss your strategy with your friend and decide who will pick up each prize. Remember that every prize must be picked up, either by you or by your friend.
What is the minimum number of seconds it will take to pick up all the prizes?
Input
The first line contains one integer n (1 β€ n β€ 105) β the number of prizes.
The second line contains n integers a1, a2, ..., an (2 β€ ai β€ 106 - 1) β the positions of the prizes. No two prizes are located at the same position. Positions are given in ascending order.
Output
Print one integer β the minimum number of seconds it will take to collect all prizes.
Examples
Input
3
2 3 9
Output
8
Input
2
2 999995
Output
5
Note
In the first example you take all the prizes: take the first at 1, the second at 2 and the third at 8.
In the second example you take the first prize in 1 second and your friend takes the other in 5 seconds, you do this simultaneously, so the total time is 5.
Submitted Solution:
```
import sys
n = sys.stdin.readline()
prizes = map(int, sys.stdin.readline().strip().split())
max_steps = 0
max_steps2 = 0
pos2 = int(10 ** 6)
border = int(pos2 / 2)
for i in prizes:
if i < border:
max_steps = max(max_steps, i - 1)
else:
print(i)
max_steps2 = max(max_steps2, pos2 - i)
print(max(max_steps, max_steps2))
``` | instruction | 0 | 86,275 | 11 | 172,550 |
No | output | 1 | 86,275 | 11 | 172,551 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.
The problem has N test cases.
For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.
See the Output section for the output format.
Constraints
* 1 \leq N \leq 10^5
* S_i is `AC`, `WA`, `TLE`, or `RE`.
Input
Input is given from Standard Input in the following format:
N
S_1
\vdots
S_N
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Examples
Input
6
AC
TLE
AC
AC
WA
TLE
Output
AC x 3
WA x 1
TLE x 2
RE x 0
Input
10
AC
AC
AC
AC
AC
AC
AC
AC
AC
AC
Output
AC x 10
WA x 0
TLE x 0
RE x 0 | instruction | 0 | 86,297 | 11 | 172,594 |
"Correct Solution:
```
N = int(input())
lst = [input() for _ in range(N)]
V=["AC","WA","TLE","RE"]
for v in V:
print("{} x {}".format(v, lst.count(v)))
``` | output | 1 | 86,297 | 11 | 172,595 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.
The problem has N test cases.
For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.
See the Output section for the output format.
Constraints
* 1 \leq N \leq 10^5
* S_i is `AC`, `WA`, `TLE`, or `RE`.
Input
Input is given from Standard Input in the following format:
N
S_1
\vdots
S_N
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Examples
Input
6
AC
TLE
AC
AC
WA
TLE
Output
AC x 3
WA x 1
TLE x 2
RE x 0
Input
10
AC
AC
AC
AC
AC
AC
AC
AC
AC
AC
Output
AC x 10
WA x 0
TLE x 0
RE x 0 | instruction | 0 | 86,298 | 11 | 172,596 |
"Correct Solution:
```
t = int(input())
d = {'AC':0, 'WA':0,'TLE':0, 'RE':0}
while t:
d[input()]+=1
t-=1
for i in d:
print(i,'x',d[i])
``` | output | 1 | 86,298 | 11 | 172,597 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.
The problem has N test cases.
For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.
See the Output section for the output format.
Constraints
* 1 \leq N \leq 10^5
* S_i is `AC`, `WA`, `TLE`, or `RE`.
Input
Input is given from Standard Input in the following format:
N
S_1
\vdots
S_N
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Examples
Input
6
AC
TLE
AC
AC
WA
TLE
Output
AC x 3
WA x 1
TLE x 2
RE x 0
Input
10
AC
AC
AC
AC
AC
AC
AC
AC
AC
AC
Output
AC x 10
WA x 0
TLE x 0
RE x 0 | instruction | 0 | 86,299 | 11 | 172,598 |
"Correct Solution:
```
n=int(input())
S = []
for i in range(n):
S.append(input())
for t in ["AC","WA","TLE","RE"]:
print(f"{t} x {S.count(t)}")
``` | output | 1 | 86,299 | 11 | 172,599 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.
The problem has N test cases.
For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.
See the Output section for the output format.
Constraints
* 1 \leq N \leq 10^5
* S_i is `AC`, `WA`, `TLE`, or `RE`.
Input
Input is given from Standard Input in the following format:
N
S_1
\vdots
S_N
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Examples
Input
6
AC
TLE
AC
AC
WA
TLE
Output
AC x 3
WA x 1
TLE x 2
RE x 0
Input
10
AC
AC
AC
AC
AC
AC
AC
AC
AC
AC
Output
AC x 10
WA x 0
TLE x 0
RE x 0 | instruction | 0 | 86,300 | 11 | 172,600 |
"Correct Solution:
```
import sys
input()
d=dict.fromkeys('AC WA TLE RE'.split(),0)
for ln in sys.stdin:
d[ln.strip()]+=1
for k,v in d.items():
print(k,'x',v)
``` | output | 1 | 86,300 | 11 | 172,601 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.
The problem has N test cases.
For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.
See the Output section for the output format.
Constraints
* 1 \leq N \leq 10^5
* S_i is `AC`, `WA`, `TLE`, or `RE`.
Input
Input is given from Standard Input in the following format:
N
S_1
\vdots
S_N
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Examples
Input
6
AC
TLE
AC
AC
WA
TLE
Output
AC x 3
WA x 1
TLE x 2
RE x 0
Input
10
AC
AC
AC
AC
AC
AC
AC
AC
AC
AC
Output
AC x 10
WA x 0
TLE x 0
RE x 0 | instruction | 0 | 86,301 | 11 | 172,602 |
"Correct Solution:
```
N = int(input())
D = {"AC":0, "WA":0, "TLE":0, "RE":0}
for _ in range(N):
S = input()
D[S] += 1
for i, x in D.items():
print(i+" x "+str(x))
``` | output | 1 | 86,301 | 11 | 172,603 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.
The problem has N test cases.
For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.
See the Output section for the output format.
Constraints
* 1 \leq N \leq 10^5
* S_i is `AC`, `WA`, `TLE`, or `RE`.
Input
Input is given from Standard Input in the following format:
N
S_1
\vdots
S_N
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Examples
Input
6
AC
TLE
AC
AC
WA
TLE
Output
AC x 3
WA x 1
TLE x 2
RE x 0
Input
10
AC
AC
AC
AC
AC
AC
AC
AC
AC
AC
Output
AC x 10
WA x 0
TLE x 0
RE x 0 | instruction | 0 | 86,302 | 11 | 172,604 |
"Correct Solution:
```
n,*s=open(0).read().split()
for t in['AC','WA','TLE','RE']:print(f'{t} x {s.count(t)}')
``` | output | 1 | 86,302 | 11 | 172,605 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.
The problem has N test cases.
For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.
See the Output section for the output format.
Constraints
* 1 \leq N \leq 10^5
* S_i is `AC`, `WA`, `TLE`, or `RE`.
Input
Input is given from Standard Input in the following format:
N
S_1
\vdots
S_N
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Examples
Input
6
AC
TLE
AC
AC
WA
TLE
Output
AC x 3
WA x 1
TLE x 2
RE x 0
Input
10
AC
AC
AC
AC
AC
AC
AC
AC
AC
AC
Output
AC x 10
WA x 0
TLE x 0
RE x 0 | instruction | 0 | 86,303 | 11 | 172,606 |
"Correct Solution:
```
n = int(input())
s = [input() for i in range(n)]
a = ["AC","WA","TLE","RE"]
for i in a:
print(i,'x',s.count(i))
``` | output | 1 | 86,303 | 11 | 172,607 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.
The problem has N test cases.
For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.
See the Output section for the output format.
Constraints
* 1 \leq N \leq 10^5
* S_i is `AC`, `WA`, `TLE`, or `RE`.
Input
Input is given from Standard Input in the following format:
N
S_1
\vdots
S_N
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Examples
Input
6
AC
TLE
AC
AC
WA
TLE
Output
AC x 3
WA x 1
TLE x 2
RE x 0
Input
10
AC
AC
AC
AC
AC
AC
AC
AC
AC
AC
Output
AC x 10
WA x 0
TLE x 0
RE x 0 | instruction | 0 | 86,304 | 11 | 172,608 |
"Correct Solution:
```
n=int(input())
c={}
for _ in range(n):
s=input()
c[s]=c.get(s,0)+1
for j in ('AC','WA','TLE','RE'):
print(j,'x',c.get(j,0))
``` | output | 1 | 86,304 | 11 | 172,609 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.
The problem has N test cases.
For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.
See the Output section for the output format.
Constraints
* 1 \leq N \leq 10^5
* S_i is `AC`, `WA`, `TLE`, or `RE`.
Input
Input is given from Standard Input in the following format:
N
S_1
\vdots
S_N
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Examples
Input
6
AC
TLE
AC
AC
WA
TLE
Output
AC x 3
WA x 1
TLE x 2
RE x 0
Input
10
AC
AC
AC
AC
AC
AC
AC
AC
AC
AC
Output
AC x 10
WA x 0
TLE x 0
RE x 0
Submitted Solution:
```
from collections import Counter
ans = Counter(input() for _ in range(int(input())))
for i in ['AC', 'WA', 'TLE', 'RE']:
print(f'{i} x {ans[i]}')
``` | instruction | 0 | 86,305 | 11 | 172,610 |
Yes | output | 1 | 86,305 | 11 | 172,611 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.
The problem has N test cases.
For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.
See the Output section for the output format.
Constraints
* 1 \leq N \leq 10^5
* S_i is `AC`, `WA`, `TLE`, or `RE`.
Input
Input is given from Standard Input in the following format:
N
S_1
\vdots
S_N
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Examples
Input
6
AC
TLE
AC
AC
WA
TLE
Output
AC x 3
WA x 1
TLE x 2
RE x 0
Input
10
AC
AC
AC
AC
AC
AC
AC
AC
AC
AC
Output
AC x 10
WA x 0
TLE x 0
RE x 0
Submitted Solution:
```
n = int(input())
C = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}
for i in range(n):
C[input()] += 1
for s in C:
print(f'{s} x {C[s]}')
``` | instruction | 0 | 86,306 | 11 | 172,612 |
Yes | output | 1 | 86,306 | 11 | 172,613 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.
The problem has N test cases.
For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.
See the Output section for the output format.
Constraints
* 1 \leq N \leq 10^5
* S_i is `AC`, `WA`, `TLE`, or `RE`.
Input
Input is given from Standard Input in the following format:
N
S_1
\vdots
S_N
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Examples
Input
6
AC
TLE
AC
AC
WA
TLE
Output
AC x 3
WA x 1
TLE x 2
RE x 0
Input
10
AC
AC
AC
AC
AC
AC
AC
AC
AC
AC
Output
AC x 10
WA x 0
TLE x 0
RE x 0
Submitted Solution:
```
n = int(input())
di = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}
for _ in range(n):
di[input()] += 1
for i, j in di.items():
print(i, 'x', j)
``` | instruction | 0 | 86,307 | 11 | 172,614 |
Yes | output | 1 | 86,307 | 11 | 172,615 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.
The problem has N test cases.
For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.
See the Output section for the output format.
Constraints
* 1 \leq N \leq 10^5
* S_i is `AC`, `WA`, `TLE`, or `RE`.
Input
Input is given from Standard Input in the following format:
N
S_1
\vdots
S_N
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Examples
Input
6
AC
TLE
AC
AC
WA
TLE
Output
AC x 3
WA x 1
TLE x 2
RE x 0
Input
10
AC
AC
AC
AC
AC
AC
AC
AC
AC
AC
Output
AC x 10
WA x 0
TLE x 0
RE x 0
Submitted Solution:
```
dict={"AC":0,"WA":0,"TLE":0,"RE":0}
n,*s=map(str,open(0).read().split())
for i in s:
dict[i]+=1
for k, v in dict.items():
print(k+" x "+str(v))
``` | instruction | 0 | 86,308 | 11 | 172,616 |
Yes | output | 1 | 86,308 | 11 | 172,617 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.
The problem has N test cases.
For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.
See the Output section for the output format.
Constraints
* 1 \leq N \leq 10^5
* S_i is `AC`, `WA`, `TLE`, or `RE`.
Input
Input is given from Standard Input in the following format:
N
S_1
\vdots
S_N
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Examples
Input
6
AC
TLE
AC
AC
WA
TLE
Output
AC x 3
WA x 1
TLE x 2
RE x 0
Input
10
AC
AC
AC
AC
AC
AC
AC
AC
AC
AC
Output
AC x 10
WA x 0
TLE x 0
RE x 0
Submitted Solution:
```
n = int(input())
judge = list(input() for _ in range(n))
ac, wa, tle, re = 0
for i in judge:
if i == 'AC':
ac = ac + 1
elif i == 'WA':
wa = wa + 1
elif i == 'TLE':
tle = tle + 1
elif i == 'RE':
re = re + 1
print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))
``` | instruction | 0 | 86,309 | 11 | 172,618 |
No | output | 1 | 86,309 | 11 | 172,619 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.
The problem has N test cases.
For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.
See the Output section for the output format.
Constraints
* 1 \leq N \leq 10^5
* S_i is `AC`, `WA`, `TLE`, or `RE`.
Input
Input is given from Standard Input in the following format:
N
S_1
\vdots
S_N
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Examples
Input
6
AC
TLE
AC
AC
WA
TLE
Output
AC x 3
WA x 1
TLE x 2
RE x 0
Input
10
AC
AC
AC
AC
AC
AC
AC
AC
AC
AC
Output
AC x 10
WA x 0
TLE x 0
RE x 0
Submitted Solution:
```
n = int(input())
c0, c1, c2, c3 = 0
for _ in range(n):
if _ == "AC":
c0 += 1
if _ == "WA":
c1 += 1
if _ == "TLE":
c2 += 1
if _ == "RE":
c3 += 1
print("AC x", c0)
print("WA x", c1)
print("TLE x", c2)
print("RE x", c3)
``` | instruction | 0 | 86,310 | 11 | 172,620 |
No | output | 1 | 86,310 | 11 | 172,621 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.
The problem has N test cases.
For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.
See the Output section for the output format.
Constraints
* 1 \leq N \leq 10^5
* S_i is `AC`, `WA`, `TLE`, or `RE`.
Input
Input is given from Standard Input in the following format:
N
S_1
\vdots
S_N
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Examples
Input
6
AC
TLE
AC
AC
WA
TLE
Output
AC x 3
WA x 1
TLE x 2
RE x 0
Input
10
AC
AC
AC
AC
AC
AC
AC
AC
AC
AC
Output
AC x 10
WA x 0
TLE x 0
RE x 0
Submitted Solution:
```
from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math
from bisect import bisect,bisect_right,bisect_left
def get_int():
return int(stdin.readline().strip())
def get_tuple():
return map(int, stdin.readline().split())
def get_list():
return list(map(int, stdin.readline().split()))
n = get_int()
dic = defaultdict(int)
for _ in range(n):
st = input()
dic[st] += 1
for val in ['AC','WA','TLE','RE']:
print(val+" * "+str(dic[val]))
``` | instruction | 0 | 86,311 | 11 | 172,622 |
No | output | 1 | 86,311 | 11 | 172,623 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.
The problem has N test cases.
For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.
See the Output section for the output format.
Constraints
* 1 \leq N \leq 10^5
* S_i is `AC`, `WA`, `TLE`, or `RE`.
Input
Input is given from Standard Input in the following format:
N
S_1
\vdots
S_N
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Output
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
Examples
Input
6
AC
TLE
AC
AC
WA
TLE
Output
AC x 3
WA x 1
TLE x 2
RE x 0
Input
10
AC
AC
AC
AC
AC
AC
AC
AC
AC
AC
Output
AC x 10
WA x 0
TLE x 0
RE x 0
Submitted Solution:
```
n = int(input())
j = list()
for _ in range(n):
string = input()
j.append(string)
ac = j.count("AC")
wa = j.count("WA")
tel = j.count("TEL")
re = j.count("RE")
print(f"AC x {ac}")
print(f"WA x {wa}")
print(f"TEL x {tel}")
print(f"RE x {re}")
``` | instruction | 0 | 86,312 | 11 | 172,624 |
No | output | 1 | 86,312 | 11 | 172,625 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Example
Input
2 1
1 2 2
Output
1
Submitted Solution:
```
from collections import deque
n, m = map(int, input().split())
G = [[] for i in range(n)]
for i in range(m):
x, y, w = map(int, input().split())
G[x-1].append((y-1, i))
if w == 2:
G[y-1].append((x-1, i))
used = {(i, -1) for i in range(n)}
prev = {(i, -1): [] for i in range(n)}
counter = {}
que = deque((i, -1) for i in range(n))
while que:
v, e = source = que.popleft()
counter[source] = 0
for target in G[v]:
t, f = target
if e == f:
continue
if target not in used:
used.add(target)
prev[target] = []
que.append(target)
prev[target].append(source)
counter[source] += 1
rest = len(counter)
for p in counter:
if counter[p] == 0:
que.append(p)
rest -= 1
while que:
target = que.popleft()
for source in prev[target]:
counter[source] -= 1
if counter[source] == 0:
que.append(source)
rest -= 1
if rest > 0:
print("Infinite")
exit(0)
memo = {}
def dfs(source):
if source in memo:
return memo[source]
res = 0
v, e = source
for target in G[v]:
t, f = target
if e == f:
continue
res = max(res, dfs(target) + 1)
memo[source] = res
return res
print(max(dfs((i, -1)) for i in range(n)))
``` | instruction | 0 | 86,491 | 11 | 172,982 |
No | output | 1 | 86,491 | 11 | 172,983 |
Provide a correct Python 3 solution for this coding contest problem.
Problem statement
A programming contest will be held in the Russian Federation. The contest has N questions and has M participants. Question i has a score a_i, and it is known that participant j's ability is b_j. For problem i and participant j, participant j can always solve problem i if a_i β€ b_j and only then. The score of a participant through the contest is the sum of the scores of the problems that the person was able to solve. Participant j also sets a target score c_j for this contest.
Determine if each participant can score more than the target score.
input
The input is given in the following format.
N
a_ {0} a_ {1} a_ {2}β¦ a_ {Nβ1}
M
b_ {0} b_ {1} b_ {2}β¦ b_ {Mβ1}
c_ {0} c_ {1} c_ {2}β¦ c_ {Mβ1}
Constraint
* All inputs are integers
* 1 \ β€ N \ β€ 300 \,000
* 1 \ β€ M \ β€ 300 \,000
* 0 \ β€ a_ {i} \ β€ 1 \, 000 \,000
* 0 \ β€ b_ {i} \ β€ 1 \, 000 \,000
* 0 \ β€ c_ {i} \ β€ βa_k
output
Print the answer on line M. On the i-line, output `Yes` if the participant i-1 can get more points than the target score, and` No` if not.
sample
Sample input 1
6
1 2 1 3 4 5
7
1 3 4 5 3 1 0
2 4 5 3 4 5 3
Sample output 1
Yes
Yes
Yes
Yes
Yes
No
No
The points obtained by each participant are as follows.
* Participant 0: 1 + 1 = 2
* Participant 1: 1 + 2 + 1 + 3 = 7
* Participant 2: 1 + 2 + 1 + 3 + 4 = 11
* Participant 3: 1 + 2 + 1 + 3 + 4 + 5 = 16
* Participant 4: 1 + 2 + 1 + 3 = 7
* Participant 5: 1 + 1 = 2
* Participants 6: 0
Sample input 2
8
1 1 2 3 3 4 6 100
Four
1 3 4 99
1 10 15 120
Sample output 2
Yes
Yes
No
No
Example
Input
6
1 2 1 3 4 5
7
1 3 4 5 3 1 0
2 4 5 3 4 5 3
Output
Yes
Yes
Yes
Yes
Yes
No
No | instruction | 0 | 87,470 | 11 | 174,940 |
"Correct Solution:
```
import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
d=[0]*(n+1)
for i in range(1,n+1):d[i]=d[i-1]+a[i-1]
m=int(input())
b,c=[list(map(int,input().split())) for _ in [0,0]]
[print(['Yes','No'][d[bisect.bisect_right(a,b[i])]<c[i]]) for i in range(m)]
``` | output | 1 | 87,470 | 11 | 174,941 |
Provide a correct Python 3 solution for this coding contest problem.
Problem statement
A programming contest will be held in the Russian Federation. The contest has N questions and has M participants. Question i has a score a_i, and it is known that participant j's ability is b_j. For problem i and participant j, participant j can always solve problem i if a_i β€ b_j and only then. The score of a participant through the contest is the sum of the scores of the problems that the person was able to solve. Participant j also sets a target score c_j for this contest.
Determine if each participant can score more than the target score.
input
The input is given in the following format.
N
a_ {0} a_ {1} a_ {2}β¦ a_ {Nβ1}
M
b_ {0} b_ {1} b_ {2}β¦ b_ {Mβ1}
c_ {0} c_ {1} c_ {2}β¦ c_ {Mβ1}
Constraint
* All inputs are integers
* 1 \ β€ N \ β€ 300 \,000
* 1 \ β€ M \ β€ 300 \,000
* 0 \ β€ a_ {i} \ β€ 1 \, 000 \,000
* 0 \ β€ b_ {i} \ β€ 1 \, 000 \,000
* 0 \ β€ c_ {i} \ β€ βa_k
output
Print the answer on line M. On the i-line, output `Yes` if the participant i-1 can get more points than the target score, and` No` if not.
sample
Sample input 1
6
1 2 1 3 4 5
7
1 3 4 5 3 1 0
2 4 5 3 4 5 3
Sample output 1
Yes
Yes
Yes
Yes
Yes
No
No
The points obtained by each participant are as follows.
* Participant 0: 1 + 1 = 2
* Participant 1: 1 + 2 + 1 + 3 = 7
* Participant 2: 1 + 2 + 1 + 3 + 4 = 11
* Participant 3: 1 + 2 + 1 + 3 + 4 + 5 = 16
* Participant 4: 1 + 2 + 1 + 3 = 7
* Participant 5: 1 + 1 = 2
* Participants 6: 0
Sample input 2
8
1 1 2 3 3 4 6 100
Four
1 3 4 99
1 10 15 120
Sample output 2
Yes
Yes
No
No
Example
Input
6
1 2 1 3 4 5
7
1 3 4 5 3 1 0
2 4 5 3 4 5 3
Output
Yes
Yes
Yes
Yes
Yes
No
No | instruction | 0 | 87,471 | 11 | 174,942 |
"Correct Solution:
```
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
a.sort()
import bisect
c = list(map(int, input().split()))
d = [0] * (n+1)
for i in range(n):
d[i+1] = a[i]
for i in range(n):
d[i+1] += d[i]
for i in range(m):
n = bisect.bisect_right(a,b[i])
n = d[n]
if c[i] <= n:
print("Yes")
else:
print("No")
``` | output | 1 | 87,471 | 11 | 174,943 |
Provide a correct Python 3 solution for this coding contest problem.
Problem statement
A programming contest will be held in the Russian Federation. The contest has N questions and has M participants. Question i has a score a_i, and it is known that participant j's ability is b_j. For problem i and participant j, participant j can always solve problem i if a_i β€ b_j and only then. The score of a participant through the contest is the sum of the scores of the problems that the person was able to solve. Participant j also sets a target score c_j for this contest.
Determine if each participant can score more than the target score.
input
The input is given in the following format.
N
a_ {0} a_ {1} a_ {2}β¦ a_ {Nβ1}
M
b_ {0} b_ {1} b_ {2}β¦ b_ {Mβ1}
c_ {0} c_ {1} c_ {2}β¦ c_ {Mβ1}
Constraint
* All inputs are integers
* 1 \ β€ N \ β€ 300 \,000
* 1 \ β€ M \ β€ 300 \,000
* 0 \ β€ a_ {i} \ β€ 1 \, 000 \,000
* 0 \ β€ b_ {i} \ β€ 1 \, 000 \,000
* 0 \ β€ c_ {i} \ β€ βa_k
output
Print the answer on line M. On the i-line, output `Yes` if the participant i-1 can get more points than the target score, and` No` if not.
sample
Sample input 1
6
1 2 1 3 4 5
7
1 3 4 5 3 1 0
2 4 5 3 4 5 3
Sample output 1
Yes
Yes
Yes
Yes
Yes
No
No
The points obtained by each participant are as follows.
* Participant 0: 1 + 1 = 2
* Participant 1: 1 + 2 + 1 + 3 = 7
* Participant 2: 1 + 2 + 1 + 3 + 4 = 11
* Participant 3: 1 + 2 + 1 + 3 + 4 + 5 = 16
* Participant 4: 1 + 2 + 1 + 3 = 7
* Participant 5: 1 + 1 = 2
* Participants 6: 0
Sample input 2
8
1 1 2 3 3 4 6 100
Four
1 3 4 99
1 10 15 120
Sample output 2
Yes
Yes
No
No
Example
Input
6
1 2 1 3 4 5
7
1 3 4 5 3 1 0
2 4 5 3 4 5 3
Output
Yes
Yes
Yes
Yes
Yes
No
No | instruction | 0 | 87,472 | 11 | 174,944 |
"Correct Solution:
```
from itertools import accumulate
from bisect import bisect_right as br
n = int(input())
alst = sorted(map(int, input().split()))
acc = list(accumulate(alst))
m = int(input())
blst = list(map(int, input().split()))
clst = list(map(int, input().split()))
for b, c in zip(blst, clst):
index = br(alst, b)
print(["No", "Yes"][(acc[index - 1] if index > 0 else 0) >= c])
``` | output | 1 | 87,472 | 11 | 174,945 |
Provide a correct Python 3 solution for this coding contest problem.
Problem statement
A programming contest will be held in the Russian Federation. The contest has N questions and has M participants. Question i has a score a_i, and it is known that participant j's ability is b_j. For problem i and participant j, participant j can always solve problem i if a_i β€ b_j and only then. The score of a participant through the contest is the sum of the scores of the problems that the person was able to solve. Participant j also sets a target score c_j for this contest.
Determine if each participant can score more than the target score.
input
The input is given in the following format.
N
a_ {0} a_ {1} a_ {2}β¦ a_ {Nβ1}
M
b_ {0} b_ {1} b_ {2}β¦ b_ {Mβ1}
c_ {0} c_ {1} c_ {2}β¦ c_ {Mβ1}
Constraint
* All inputs are integers
* 1 \ β€ N \ β€ 300 \,000
* 1 \ β€ M \ β€ 300 \,000
* 0 \ β€ a_ {i} \ β€ 1 \, 000 \,000
* 0 \ β€ b_ {i} \ β€ 1 \, 000 \,000
* 0 \ β€ c_ {i} \ β€ βa_k
output
Print the answer on line M. On the i-line, output `Yes` if the participant i-1 can get more points than the target score, and` No` if not.
sample
Sample input 1
6
1 2 1 3 4 5
7
1 3 4 5 3 1 0
2 4 5 3 4 5 3
Sample output 1
Yes
Yes
Yes
Yes
Yes
No
No
The points obtained by each participant are as follows.
* Participant 0: 1 + 1 = 2
* Participant 1: 1 + 2 + 1 + 3 = 7
* Participant 2: 1 + 2 + 1 + 3 + 4 = 11
* Participant 3: 1 + 2 + 1 + 3 + 4 + 5 = 16
* Participant 4: 1 + 2 + 1 + 3 = 7
* Participant 5: 1 + 1 = 2
* Participants 6: 0
Sample input 2
8
1 1 2 3 3 4 6 100
Four
1 3 4 99
1 10 15 120
Sample output 2
Yes
Yes
No
No
Example
Input
6
1 2 1 3 4 5
7
1 3 4 5 3 1 0
2 4 5 3 4 5 3
Output
Yes
Yes
Yes
Yes
Yes
No
No | instruction | 0 | 87,473 | 11 | 174,946 |
"Correct Solution:
```
import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
d=[0]*(n+1)
for i in range(1,n+1):d[i]=d[i-1]+a[i-1]
m=int(input())
b,c=[list(map(int,input().split())) for _ in [0,0]]
for i in range(m):
p=bisect.bisect_right(a,b[i])
print(['Yes','No'][d[p]<c[i]])
``` | output | 1 | 87,473 | 11 | 174,947 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Problem statement
A programming contest will be held in the Russian Federation. The contest has N questions and has M participants. Question i has a score a_i, and it is known that participant j's ability is b_j. For problem i and participant j, participant j can always solve problem i if a_i β€ b_j and only then. The score of a participant through the contest is the sum of the scores of the problems that the person was able to solve. Participant j also sets a target score c_j for this contest.
Determine if each participant can score more than the target score.
input
The input is given in the following format.
N
a_ {0} a_ {1} a_ {2}β¦ a_ {Nβ1}
M
b_ {0} b_ {1} b_ {2}β¦ b_ {Mβ1}
c_ {0} c_ {1} c_ {2}β¦ c_ {Mβ1}
Constraint
* All inputs are integers
* 1 \ β€ N \ β€ 300 \,000
* 1 \ β€ M \ β€ 300 \,000
* 0 \ β€ a_ {i} \ β€ 1 \, 000 \,000
* 0 \ β€ b_ {i} \ β€ 1 \, 000 \,000
* 0 \ β€ c_ {i} \ β€ βa_k
output
Print the answer on line M. On the i-line, output `Yes` if the participant i-1 can get more points than the target score, and` No` if not.
sample
Sample input 1
6
1 2 1 3 4 5
7
1 3 4 5 3 1 0
2 4 5 3 4 5 3
Sample output 1
Yes
Yes
Yes
Yes
Yes
No
No
The points obtained by each participant are as follows.
* Participant 0: 1 + 1 = 2
* Participant 1: 1 + 2 + 1 + 3 = 7
* Participant 2: 1 + 2 + 1 + 3 + 4 = 11
* Participant 3: 1 + 2 + 1 + 3 + 4 + 5 = 16
* Participant 4: 1 + 2 + 1 + 3 = 7
* Participant 5: 1 + 1 = 2
* Participants 6: 0
Sample input 2
8
1 1 2 3 3 4 6 100
Four
1 3 4 99
1 10 15 120
Sample output 2
Yes
Yes
No
No
Example
Input
6
1 2 1 3 4 5
7
1 3 4 5 3 1 0
2 4 5 3 4 5 3
Output
Yes
Yes
Yes
Yes
Yes
No
No
Submitted Solution:
```
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright : @Huki_Hara
# Created : 2015-03-14
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
c = list(map(int, input().split()))
l = [True] * m
for i in range(m):
sum = 0
for j in range(n):
if a[j] <= b[i]:
sum += a[j]
if sum < c[i]:
l[i] = False
for i in range(m):
if l[i] :
print("Yes")
else:
print("No")
``` | instruction | 0 | 87,474 | 11 | 174,948 |
No | output | 1 | 87,474 | 11 | 174,949 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Problem statement
A programming contest will be held in the Russian Federation. The contest has N questions and has M participants. Question i has a score a_i, and it is known that participant j's ability is b_j. For problem i and participant j, participant j can always solve problem i if a_i β€ b_j and only then. The score of a participant through the contest is the sum of the scores of the problems that the person was able to solve. Participant j also sets a target score c_j for this contest.
Determine if each participant can score more than the target score.
input
The input is given in the following format.
N
a_ {0} a_ {1} a_ {2}β¦ a_ {Nβ1}
M
b_ {0} b_ {1} b_ {2}β¦ b_ {Mβ1}
c_ {0} c_ {1} c_ {2}β¦ c_ {Mβ1}
Constraint
* All inputs are integers
* 1 \ β€ N \ β€ 300 \,000
* 1 \ β€ M \ β€ 300 \,000
* 0 \ β€ a_ {i} \ β€ 1 \, 000 \,000
* 0 \ β€ b_ {i} \ β€ 1 \, 000 \,000
* 0 \ β€ c_ {i} \ β€ βa_k
output
Print the answer on line M. On the i-line, output `Yes` if the participant i-1 can get more points than the target score, and` No` if not.
sample
Sample input 1
6
1 2 1 3 4 5
7
1 3 4 5 3 1 0
2 4 5 3 4 5 3
Sample output 1
Yes
Yes
Yes
Yes
Yes
No
No
The points obtained by each participant are as follows.
* Participant 0: 1 + 1 = 2
* Participant 1: 1 + 2 + 1 + 3 = 7
* Participant 2: 1 + 2 + 1 + 3 + 4 = 11
* Participant 3: 1 + 2 + 1 + 3 + 4 + 5 = 16
* Participant 4: 1 + 2 + 1 + 3 = 7
* Participant 5: 1 + 1 = 2
* Participants 6: 0
Sample input 2
8
1 1 2 3 3 4 6 100
Four
1 3 4 99
1 10 15 120
Sample output 2
Yes
Yes
No
No
Example
Input
6
1 2 1 3 4 5
7
1 3 4 5 3 1 0
2 4 5 3 4 5 3
Output
Yes
Yes
Yes
Yes
Yes
No
No
Submitted Solution:
```
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
c = map(int, input().split())
l = [False] * m
a.sort()
for i in range(m):
sum = 0
for j in range(n):
if a[j] > b[i]:
break
sum += a[j]
if sum >= c.__next__():
l[i] = True
for i in range(m):
if l[i]:
print("Yes")
else:
print("No")
``` | instruction | 0 | 87,475 | 11 | 174,950 |
No | output | 1 | 87,475 | 11 | 174,951 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Problem statement
A programming contest will be held in the Russian Federation. The contest has N questions and has M participants. Question i has a score a_i, and it is known that participant j's ability is b_j. For problem i and participant j, participant j can always solve problem i if a_i β€ b_j and only then. The score of a participant through the contest is the sum of the scores of the problems that the person was able to solve. Participant j also sets a target score c_j for this contest.
Determine if each participant can score more than the target score.
input
The input is given in the following format.
N
a_ {0} a_ {1} a_ {2}β¦ a_ {Nβ1}
M
b_ {0} b_ {1} b_ {2}β¦ b_ {Mβ1}
c_ {0} c_ {1} c_ {2}β¦ c_ {Mβ1}
Constraint
* All inputs are integers
* 1 \ β€ N \ β€ 300 \,000
* 1 \ β€ M \ β€ 300 \,000
* 0 \ β€ a_ {i} \ β€ 1 \, 000 \,000
* 0 \ β€ b_ {i} \ β€ 1 \, 000 \,000
* 0 \ β€ c_ {i} \ β€ βa_k
output
Print the answer on line M. On the i-line, output `Yes` if the participant i-1 can get more points than the target score, and` No` if not.
sample
Sample input 1
6
1 2 1 3 4 5
7
1 3 4 5 3 1 0
2 4 5 3 4 5 3
Sample output 1
Yes
Yes
Yes
Yes
Yes
No
No
The points obtained by each participant are as follows.
* Participant 0: 1 + 1 = 2
* Participant 1: 1 + 2 + 1 + 3 = 7
* Participant 2: 1 + 2 + 1 + 3 + 4 = 11
* Participant 3: 1 + 2 + 1 + 3 + 4 + 5 = 16
* Participant 4: 1 + 2 + 1 + 3 = 7
* Participant 5: 1 + 1 = 2
* Participants 6: 0
Sample input 2
8
1 1 2 3 3 4 6 100
Four
1 3 4 99
1 10 15 120
Sample output 2
Yes
Yes
No
No
Example
Input
6
1 2 1 3 4 5
7
1 3 4 5 3 1 0
2 4 5 3 4 5 3
Output
Yes
Yes
Yes
Yes
Yes
No
No
Submitted Solution:
```
input()
a=list(map(int,input().split()))
m=int(input())
b,c=[list(map(int,input().split())) for _ in [0,0]]
[print(['Yes','No'][sum([j for j in a if j<=b[i]])<c[i]])for i in range(m)]
``` | instruction | 0 | 87,476 | 11 | 174,952 |
No | output | 1 | 87,476 | 11 | 174,953 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Problem statement
A programming contest will be held in the Russian Federation. The contest has N questions and has M participants. Question i has a score a_i, and it is known that participant j's ability is b_j. For problem i and participant j, participant j can always solve problem i if a_i β€ b_j and only then. The score of a participant through the contest is the sum of the scores of the problems that the person was able to solve. Participant j also sets a target score c_j for this contest.
Determine if each participant can score more than the target score.
input
The input is given in the following format.
N
a_ {0} a_ {1} a_ {2}β¦ a_ {Nβ1}
M
b_ {0} b_ {1} b_ {2}β¦ b_ {Mβ1}
c_ {0} c_ {1} c_ {2}β¦ c_ {Mβ1}
Constraint
* All inputs are integers
* 1 \ β€ N \ β€ 300 \,000
* 1 \ β€ M \ β€ 300 \,000
* 0 \ β€ a_ {i} \ β€ 1 \, 000 \,000
* 0 \ β€ b_ {i} \ β€ 1 \, 000 \,000
* 0 \ β€ c_ {i} \ β€ βa_k
output
Print the answer on line M. On the i-line, output `Yes` if the participant i-1 can get more points than the target score, and` No` if not.
sample
Sample input 1
6
1 2 1 3 4 5
7
1 3 4 5 3 1 0
2 4 5 3 4 5 3
Sample output 1
Yes
Yes
Yes
Yes
Yes
No
No
The points obtained by each participant are as follows.
* Participant 0: 1 + 1 = 2
* Participant 1: 1 + 2 + 1 + 3 = 7
* Participant 2: 1 + 2 + 1 + 3 + 4 = 11
* Participant 3: 1 + 2 + 1 + 3 + 4 + 5 = 16
* Participant 4: 1 + 2 + 1 + 3 = 7
* Participant 5: 1 + 1 = 2
* Participants 6: 0
Sample input 2
8
1 1 2 3 3 4 6 100
Four
1 3 4 99
1 10 15 120
Sample output 2
Yes
Yes
No
No
Example
Input
6
1 2 1 3 4 5
7
1 3 4 5 3 1 0
2 4 5 3 4 5 3
Output
Yes
Yes
Yes
Yes
Yes
No
No
Submitted Solution:
```
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright : @Huki_Hara
# Created : 2015-03-14
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
c = list(map(int, input().split()))
l = []
i = 0
while i < m:
sum = 0
j = 0
while j < n:
if a[j] <= b[i]:
sum += a[j]
j += 1
i += 1
l.append(sum)
i = 0
while i < m:
if l[i] >= c[i]:
print("Yes")
else:
print("No")
i += 1
``` | instruction | 0 | 87,477 | 11 | 174,954 |
No | output | 1 | 87,477 | 11 | 174,955 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab.
There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time.
At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution.
Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as
$$$d = round\left(100β
m/n\right),$$$
where round(x) = β{x + 0.5}β is a function which maps every real to the nearest integer.
Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions.
Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter.
Input
The first line contains two positive integers n and k (1 β€ n β€ 1000, 1 β€ k β€ 100) standing for the number of submissions and the number of testing processes respectively.
The second line contains n positive integers a_1, a_2, β¦, a_n (1 β€ a_i β€ 150), where a_i is equal to the number of tests the i-th submission is to be run on.
Output
Output the only integer β the number of interesting submissions.
Examples
Input
2 2
49 100
Output
1
Input
4 2
32 100 33 1
Output
2
Input
14 5
48 19 6 9 50 20 3 42 38 43 36 21 44 6
Output
5
Note
Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting.
Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. | instruction | 0 | 87,593 | 11 | 175,186 |
Tags: implementation
Correct Solution:
```
n, k = map(int, input().split())
a = list(map(int, input().split()))
s, ans = [-2]*k, [0]*n
q1 = q2 = naw = 0
while q1 < n or any(q != -1 for q in s):
for q in range(k):
naw += (s[q] != -1 and s[q] != -2 and s[q][1] == q2)/n
if q2 == 74:
q3 = 0
for q in range(k):
if s[q] != -1:
if s[q] == -2 and q1 < n:
s[q] = [0, a[q1], q1]
q1 += 1
elif s[q] == -2 or q1 == n and q2 == s[q][1]:
s[q] = -1
elif q2 == s[q][1]:
s[q] = [s[q][1], s[q][1]+a[q1], q1]
ans[s[q][2]] |= (naw * 100+0.5)//1 == q2 - s[q][0] + 1
q1 += 1
else:
ans[s[q][2]] |= (naw * 100+0.5)//1 == q2-s[q][0]+1
q2 += 1
print(ans.count(1))
``` | output | 1 | 87,593 | 11 | 175,187 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.