text stringlengths 216 39.6k | conversation_id int64 219 108k | embedding list | cluster int64 11 11 |
|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day a well-known sponsor of a well-known contest decided to give every participant of the contest a T-shirt as a present. A natural problem occurred: on the one hand, it is not clear how many T-shirts of what sizes should be ordered, and on the other hand, one doesn't want to order too many T-shirts (and we do not exactly paper the walls with the oversupply). After considerable brain racking and some pre-estimating, the sponsor representatives ordered a certain number of T-shirts of sizes S, M, L, XL and XXL. The T-shirts turned out to bring good luck, that's why on the contest day there built up a line of K participants willing to get one. Every contestant is characterized by his/her desired T-shirt size (so it happens that for all the participants it is also one of the sizes S, M, L, XL and XXL). The participants come up to get a T-shirt one by one and try to choose the most suitable one, choosing it like this. If there is still a T-shirt of the optimal size left, that he/she takes it without further ado. Otherwise the contestant would prefer to choose a T-shirt with the size as close to the optimal one as possible (the distance between neighboring sizes is considered equal to one). If the variant of choice is not unique, the contestant will take a T-shirt of a bigger size (in case he/she grows more). For example, for a person whose optimal size is L the preference list looks like this: L, XL, M, XXL, S. Using the data on how many T-shirts of every size had been ordered by the organizers, on the size of contestants in the line determine who got a T-shirt of what size.
Input
The first line contains five non-negative integers NS, NM, NL, NXL, NXXL not exceeding 1000 which represent the number of T-shirts of the corresponding sizes. The second line contains an integer K (1 ≤ K ≤ 1000) which represents the number of participants. The next K lines contain the optimal T-shirt sizes for the contestants. The sizes are given in the order in which the participants stand in the line. It is guaranteed that NS + NM + NL + NXL + NXXL ≥ K.
Output
For each contestant, print a line containing the size of the T-shirt he/she got.
Examples
Input
1 0 2 0 1
3
XL
XXL
M
Output
XXL
L
L
Submitted Solution:
```
ns, nm, nl, nxl, nxl2 = map(int, input().split())
n = int(input())
g = []
for i in range(n):
j = input()
g.append(j)
z = []
for i in g:
if i == 'S':
if ns > 0:
z.append('S')
ns -= 1
continue
else:
if nm > 0:
z.append('M')
nm -= 1
continue
else:
if nl > 0:
nl -= 1
z.append('L')
else:
if nxl > 0:
nxl -= 1
z.append('XL')
else:
if nxl2 > 0:
nxl2 -= 1
z.append('XXL')
elif i == 'M':
if nm > 0:
z.append('M')
nm -= 1
continue
else:
if nl > 0:
z.append('L')
nl -= 1
continue
else:
if nxl > 0:
nxl -= 1
z.append('Xl')
else:
if nxl2 > 0:
nxl2 -= 1
z.append('XXL')
else:
if ns > 0:
ns -= 1
z.append('S')
elif i == 'L':
if nl > 0:
nl -= 1
z.append('L')
continue
else:
if nxl > 0:
nxl -= 1
z.append('XL')
continue
else:
if nxl2 > 0:
nxl2 -= 1
z.append('XXl')
else:
if nm > 0:
nm -= 1
z.append('M')
else:
if ns > 0:
ns -= 1
z.append('S')
elif i == 'XL':
if nxl > 0:
z.append('XL')
nxl -= 1
continue
else:
if nxl2 > 0:
nxl2 -= 1
z.append('XXL')
continue
else:
if nl > 0:
nl -= 1
z.append('L')
else:
if nm > 0:
nm -= 1
z.append('M')
else:
if ns > 0:
ns -= 1
z.append('S')
elif i == 'XXL':
if nxl2 > 0:
z.append('XXL')
nxl2 -= 1
continue
else:
if nxl > 0:
z.append('XL')
nxl -= 1
continue
else:
if nl > 0:
z.append('L')
nl -= 1
else:
if nm > 0:
z.append('M')
nm -= 1
else:
if ns > 0:
z.append('S')
ns -= 1
for j in z:
print(j)
```
No
| 22,455 | [
0.387451171875,
-0.016448974609375,
0.253662109375,
0.06451416015625,
-0.84765625,
-0.46875,
-0.117431640625,
0.307373046875,
-0.2421875,
0.83349609375,
0.556640625,
-0.247802734375,
0.11029052734375,
-0.287109375,
-0.332275390625,
0.0052947998046875,
-0.448486328125,
-0.80859375,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade ai for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write bi essays. He can raise the exam grade multiple times.
What is the minimum number of essays that Vanya needs to write to get scholarship?
Input
The first line contains three integers n, r, avg (1 ≤ n ≤ 105, 1 ≤ r ≤ 109, 1 ≤ avg ≤ min(r, 106)) — the number of exams, the maximum grade and the required grade point average, respectively.
Each of the following n lines contains space-separated integers ai and bi (1 ≤ ai ≤ r, 1 ≤ bi ≤ 106).
Output
In the first line print the minimum number of essays.
Examples
Input
5 5 4
5 2
4 7
3 1
3 2
2 5
Output
4
Input
2 5 4
5 2
5 2
Output
0
Note
In the first sample Vanya can write 2 essays for the 3rd exam to raise his grade by 2 points and 2 essays for the 4th exam to raise his grade by 1 point.
In the second sample, Vanya doesn't need to write any essays as his general point average already is above average.
Submitted Solution:
```
n, r, avg = map(int, input().split())
sum_of_marks = 0
sum_required = n * avg
a = n * [0]
ans = 0
for i in range(n):
x = list(map(int, input().split()))
a[i] = x
sum_of_marks += x[0]
a.sort(key=lambda x: x[1])
if sum_of_marks >= sum_required:
print(0)
else:
while sum_of_marks < sum_required:
for i in range(n):
if a[i][0] != r:
if r - a[i][0] + sum_of_marks < sum_required:
ans += (r - a[i][0]) * a[i][1]
sum_of_marks += r - a[i][0]
else:
ans += (sum_required - sum_of_marks) * a[i][1]
sum_of_marks = sum_required
if sum_of_marks >= sum_required:
break
break
print(ans)
```
Yes
| 22,464 | [
0.2314453125,
0.2305908203125,
-0.0792236328125,
0.1947021484375,
-0.515625,
0.102294921875,
0.093505859375,
0.267578125,
-0.2152099609375,
0.86279296875,
0.22412109375,
-0.03570556640625,
0.07513427734375,
-0.63232421875,
-0.0914306640625,
0.06976318359375,
-0.6943359375,
-0.87890... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade ai for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write bi essays. He can raise the exam grade multiple times.
What is the minimum number of essays that Vanya needs to write to get scholarship?
Input
The first line contains three integers n, r, avg (1 ≤ n ≤ 105, 1 ≤ r ≤ 109, 1 ≤ avg ≤ min(r, 106)) — the number of exams, the maximum grade and the required grade point average, respectively.
Each of the following n lines contains space-separated integers ai and bi (1 ≤ ai ≤ r, 1 ≤ bi ≤ 106).
Output
In the first line print the minimum number of essays.
Examples
Input
5 5 4
5 2
4 7
3 1
3 2
2 5
Output
4
Input
2 5 4
5 2
5 2
Output
0
Note
In the first sample Vanya can write 2 essays for the 3rd exam to raise his grade by 2 points and 2 essays for the 4th exam to raise his grade by 1 point.
In the second sample, Vanya doesn't need to write any essays as his general point average already is above average.
Submitted Solution:
```
n,r,avg=map(int,input().split())
l=[]
top=0
for i in range(n):
a,b=map(int,input().split())
top+=a
l.append((a,b))
ne=avg*n
l.sort(key= lambda x:x[1])
res=0
for i in l:
a,b=i
inc=r-a
t=inc*b
if top + inc < ne:
res+=t
top+=inc
elif top + inc >= ne:
kk=max(ne-top,0)
res+=kk*b
break
print(res)
```
Yes
| 22,465 | [
0.3046875,
0.262939453125,
-0.1029052734375,
0.217041015625,
-0.53076171875,
0.1141357421875,
0.05712890625,
0.35205078125,
-0.270263671875,
0.84814453125,
0.1788330078125,
-0.02960205078125,
0.0699462890625,
-0.6796875,
-0.10467529296875,
0.005123138427734375,
-0.642578125,
-0.885... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade ai for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write bi essays. He can raise the exam grade multiple times.
What is the minimum number of essays that Vanya needs to write to get scholarship?
Input
The first line contains three integers n, r, avg (1 ≤ n ≤ 105, 1 ≤ r ≤ 109, 1 ≤ avg ≤ min(r, 106)) — the number of exams, the maximum grade and the required grade point average, respectively.
Each of the following n lines contains space-separated integers ai and bi (1 ≤ ai ≤ r, 1 ≤ bi ≤ 106).
Output
In the first line print the minimum number of essays.
Examples
Input
5 5 4
5 2
4 7
3 1
3 2
2 5
Output
4
Input
2 5 4
5 2
5 2
Output
0
Note
In the first sample Vanya can write 2 essays for the 3rd exam to raise his grade by 2 points and 2 essays for the 4th exam to raise his grade by 1 point.
In the second sample, Vanya doesn't need to write any essays as his general point average already is above average.
Submitted Solution:
```
n, r, a = map(int, input().split())
ab = []
for i in range(n):
ab.append(list(map(int, input().split())))
def f(v):
return v[1]
ab.sort(key=f)
a *= n
for i in ab:
a -= i[0]
if a <= 0:
print(0)
else:
i = 0
ct = 0
while a != 0:
if r-ab[i][0] <= a:
ct += (r-ab[i][0])*ab[i][1]
a -= (r-ab[i][0])
else:
ct += a*ab[i][1]
break
i += 1
print(ct)
```
Yes
| 22,466 | [
0.265380859375,
0.2247314453125,
-0.0755615234375,
0.178466796875,
-0.55029296875,
0.107666015625,
0.0738525390625,
0.29736328125,
-0.258056640625,
0.87646484375,
0.2452392578125,
-0.0313720703125,
0.0428466796875,
-0.666015625,
-0.0859375,
0.01019287109375,
-0.65478515625,
-0.9008... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade ai for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write bi essays. He can raise the exam grade multiple times.
What is the minimum number of essays that Vanya needs to write to get scholarship?
Input
The first line contains three integers n, r, avg (1 ≤ n ≤ 105, 1 ≤ r ≤ 109, 1 ≤ avg ≤ min(r, 106)) — the number of exams, the maximum grade and the required grade point average, respectively.
Each of the following n lines contains space-separated integers ai and bi (1 ≤ ai ≤ r, 1 ≤ bi ≤ 106).
Output
In the first line print the minimum number of essays.
Examples
Input
5 5 4
5 2
4 7
3 1
3 2
2 5
Output
4
Input
2 5 4
5 2
5 2
Output
0
Note
In the first sample Vanya can write 2 essays for the 3rd exam to raise his grade by 2 points and 2 essays for the 4th exam to raise his grade by 1 point.
In the second sample, Vanya doesn't need to write any essays as his general point average already is above average.
Submitted Solution:
```
n, r, avg = [int(v.strip()) for v in input().split()]
grades = []
current = 0
for i in range(n):
a, b = [int(v.strip()) for v in input().split()]
current += a
grades.append([b, r - a])
required = avg * n
grades.sort(key=lambda x: x[0])
needs = 0
idx = 0
while idx < len(grades) and current < required:
t = min((required - current), grades[idx][1]) * grades[idx][0]
current += t
needs += t
idx += 1
print(needs)
```
No
| 22,468 | [
0.333251953125,
0.2008056640625,
-0.10284423828125,
0.21240234375,
-0.52734375,
0.10833740234375,
0.056915283203125,
0.283203125,
-0.250244140625,
0.92041015625,
0.1669921875,
-0.1290283203125,
0.0199737548828125,
-0.66015625,
-0.10882568359375,
0.036041259765625,
-0.6884765625,
-0... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade ai for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write bi essays. He can raise the exam grade multiple times.
What is the minimum number of essays that Vanya needs to write to get scholarship?
Input
The first line contains three integers n, r, avg (1 ≤ n ≤ 105, 1 ≤ r ≤ 109, 1 ≤ avg ≤ min(r, 106)) — the number of exams, the maximum grade and the required grade point average, respectively.
Each of the following n lines contains space-separated integers ai and bi (1 ≤ ai ≤ r, 1 ≤ bi ≤ 106).
Output
In the first line print the minimum number of essays.
Examples
Input
5 5 4
5 2
4 7
3 1
3 2
2 5
Output
4
Input
2 5 4
5 2
5 2
Output
0
Note
In the first sample Vanya can write 2 essays for the 3rd exam to raise his grade by 2 points and 2 essays for the 4th exam to raise his grade by 1 point.
In the second sample, Vanya doesn't need to write any essays as his general point average already is above average.
Submitted Solution:
```
n,r,avg = [int(i) for i in input().split()]
ls = []
aver = 0
cost = 0
for i in range(n):
x,y = [int(i) for i in input().split()]
ls.append((x,y))
aver+=x
a = aver//n
if a==avg:
print(0)
else:
br = 1
ls.sort(key=lambda item:item[1])
for tup in ls:
exam = tup[0]
while(exam<r):
exam+=1
cost+=tup[1]
aver+=1
if aver//n>=avg:
br = 0
break
if br == 0:
break
print(cost)
```
No
| 22,469 | [
0.24853515625,
0.265869140625,
-0.09521484375,
0.215576171875,
-0.541015625,
0.109619140625,
0.0726318359375,
0.262451171875,
-0.23193359375,
0.884765625,
0.1959228515625,
-0.04156494140625,
0.0236358642578125,
-0.671875,
-0.1395263671875,
0.020843505859375,
-0.6650390625,
-0.89990... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade ai for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write bi essays. He can raise the exam grade multiple times.
What is the minimum number of essays that Vanya needs to write to get scholarship?
Input
The first line contains three integers n, r, avg (1 ≤ n ≤ 105, 1 ≤ r ≤ 109, 1 ≤ avg ≤ min(r, 106)) — the number of exams, the maximum grade and the required grade point average, respectively.
Each of the following n lines contains space-separated integers ai and bi (1 ≤ ai ≤ r, 1 ≤ bi ≤ 106).
Output
In the first line print the minimum number of essays.
Examples
Input
5 5 4
5 2
4 7
3 1
3 2
2 5
Output
4
Input
2 5 4
5 2
5 2
Output
0
Note
In the first sample Vanya can write 2 essays for the 3rd exam to raise his grade by 2 points and 2 essays for the 4th exam to raise his grade by 1 point.
In the second sample, Vanya doesn't need to write any essays as his general point average already is above average.
Submitted Solution:
```
# ===================================
# (c) MidAndFeed aka ASilentVoice
# ===================================
# import math, fractions, collections
# ===================================
n, r, avg = [int(x) for x in input().split()]
q = []
sa = 0
for i in range(n):
a, b = [int(x) for x in input().split()]
sa += a
q.append([a,b])
q.sort(key = lambda x : x[1])
s = n*avg - sa
ans = 0
for x in q:
if s == 0:
break
else:
if x[0] < r:
t = min(abs(r-x[0]), s)
s -= t
ans += t*x[1]
print(ans)
```
No
| 22,470 | [
0.298828125,
0.1851806640625,
-0.1397705078125,
0.259521484375,
-0.52783203125,
0.0184173583984375,
0.0310211181640625,
0.3603515625,
-0.18798828125,
0.85302734375,
0.2347412109375,
-0.1134033203125,
0.0941162109375,
-0.68310546875,
-0.152587890625,
0.0584716796875,
-0.62646484375,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
M-kun is a student in Aoki High School, where a year is divided into N terms.
There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows:
* For the first through (K-1)-th terms: not given.
* For each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term.
M-kun scored A_i in the exam at the end of the i-th term.
For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is strictly greater than the grade for the (i-1)-th term.
Constraints
* 2 \leq N \leq 200000
* 1 \leq K \leq N-1
* 1 \leq A_i \leq 10^{9}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
A_1 A_2 A_3 \ldots A_N
Output
Print the answer in N-K lines.
The i-th line should contain `Yes` if the grade for the (K+i)-th term is greater than the grade for the (K+i-1)-th term, and `No` otherwise.
Examples
Input
5 3
96 98 95 100 20
Output
Yes
No
Input
3 2
1001 869120 1001
Output
No
Input
15 7
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9
Output
Yes
Yes
No
Yes
Yes
No
Yes
Yes
Submitted Solution:
```
n,k=map(int,input().split())
ar=list(map(int,input().split()))
for i in range(k,n):
print("Yes" if ar[i]>ar[i-k] else "No")
```
Yes
| 22,610 | [
0.478271484375,
0.0938720703125,
-0.1639404296875,
-0.08197021484375,
-0.36181640625,
-0.222412109375,
0.29052734375,
0.059844970703125,
0.022857666015625,
1.1220703125,
0.6328125,
0.2431640625,
0.285888671875,
-1.1201171875,
-0.386962890625,
-0.10321044921875,
-0.54736328125,
-0.7... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
M-kun is a student in Aoki High School, where a year is divided into N terms.
There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows:
* For the first through (K-1)-th terms: not given.
* For each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term.
M-kun scored A_i in the exam at the end of the i-th term.
For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is strictly greater than the grade for the (i-1)-th term.
Constraints
* 2 \leq N \leq 200000
* 1 \leq K \leq N-1
* 1 \leq A_i \leq 10^{9}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
A_1 A_2 A_3 \ldots A_N
Output
Print the answer in N-K lines.
The i-th line should contain `Yes` if the grade for the (K+i)-th term is greater than the grade for the (K+i-1)-th term, and `No` otherwise.
Examples
Input
5 3
96 98 95 100 20
Output
Yes
No
Input
3 2
1001 869120 1001
Output
No
Input
15 7
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9
Output
Yes
Yes
No
Yes
Yes
No
Yes
Yes
Submitted Solution:
```
n, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
for i in range(k, n):
print("Yes" if a[i] > a[i - k] else "No")
```
Yes
| 22,611 | [
0.48486328125,
0.03436279296875,
-0.11297607421875,
-0.0562744140625,
-0.36669921875,
-0.25439453125,
0.30712890625,
0.08209228515625,
0.05499267578125,
1.1259765625,
0.60205078125,
0.24560546875,
0.1917724609375,
-1.119140625,
-0.4228515625,
-0.076904296875,
-0.52783203125,
-0.858... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
M-kun is a student in Aoki High School, where a year is divided into N terms.
There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows:
* For the first through (K-1)-th terms: not given.
* For each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term.
M-kun scored A_i in the exam at the end of the i-th term.
For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is strictly greater than the grade for the (i-1)-th term.
Constraints
* 2 \leq N \leq 200000
* 1 \leq K \leq N-1
* 1 \leq A_i \leq 10^{9}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
A_1 A_2 A_3 \ldots A_N
Output
Print the answer in N-K lines.
The i-th line should contain `Yes` if the grade for the (K+i)-th term is greater than the grade for the (K+i-1)-th term, and `No` otherwise.
Examples
Input
5 3
96 98 95 100 20
Output
Yes
No
Input
3 2
1001 869120 1001
Output
No
Input
15 7
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9
Output
Yes
Yes
No
Yes
Yes
No
Yes
Yes
Submitted Solution:
```
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
for i in range(n-k):
if a[i+k] > a[i]:
print("Yes")
else:
print("No")
```
Yes
| 22,612 | [
0.476318359375,
0.051910400390625,
-0.1563720703125,
-0.051177978515625,
-0.345458984375,
-0.2237548828125,
0.2861328125,
0.06024169921875,
0.03369140625,
1.12890625,
0.5947265625,
0.255615234375,
0.252197265625,
-1.109375,
-0.392578125,
-0.07269287109375,
-0.5380859375,
-0.8261718... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
M-kun is a student in Aoki High School, where a year is divided into N terms.
There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows:
* For the first through (K-1)-th terms: not given.
* For each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term.
M-kun scored A_i in the exam at the end of the i-th term.
For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is strictly greater than the grade for the (i-1)-th term.
Constraints
* 2 \leq N \leq 200000
* 1 \leq K \leq N-1
* 1 \leq A_i \leq 10^{9}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
A_1 A_2 A_3 \ldots A_N
Output
Print the answer in N-K lines.
The i-th line should contain `Yes` if the grade for the (K+i)-th term is greater than the grade for the (K+i-1)-th term, and `No` otherwise.
Examples
Input
5 3
96 98 95 100 20
Output
Yes
No
Input
3 2
1001 869120 1001
Output
No
Input
15 7
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9
Output
Yes
Yes
No
Yes
Yes
No
Yes
Yes
Submitted Solution:
```
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(0,n-k):
if a[i]<a[k+i]:print("Yes")
else :print("No")
```
Yes
| 22,613 | [
0.473876953125,
0.060638427734375,
-0.1575927734375,
-0.0797119140625,
-0.3671875,
-0.2322998046875,
0.301513671875,
0.0712890625,
0.0259552001953125,
1.119140625,
0.5830078125,
0.259033203125,
0.296875,
-1.08984375,
-0.4072265625,
-0.08709716796875,
-0.54638671875,
-0.7958984375,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
M-kun is a student in Aoki High School, where a year is divided into N terms.
There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows:
* For the first through (K-1)-th terms: not given.
* For each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term.
M-kun scored A_i in the exam at the end of the i-th term.
For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is strictly greater than the grade for the (i-1)-th term.
Constraints
* 2 \leq N \leq 200000
* 1 \leq K \leq N-1
* 1 \leq A_i \leq 10^{9}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
A_1 A_2 A_3 \ldots A_N
Output
Print the answer in N-K lines.
The i-th line should contain `Yes` if the grade for the (K+i)-th term is greater than the grade for the (K+i-1)-th term, and `No` otherwise.
Examples
Input
5 3
96 98 95 100 20
Output
Yes
No
Input
3 2
1001 869120 1001
Output
No
Input
15 7
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9
Output
Yes
Yes
No
Yes
Yes
No
Yes
Yes
Submitted Solution:
```
import os
import sys
from io import BytesIO, IOBase
def modularInverse(n, prime) :
dp =[0]*(n+1)
dp[0] = dp[1] = 1
for i in range( 2, n+1) :
dp[i] = dp[prime % i] *(prime - prime // i) % prime
return dp
def main():
t = 1
MOD = 10089886811898868001
dp = modularInverse(2 * 10**5, MOD)
for _ in range(t):
# n = int(input)
n, k = map(int, input().split())
nums = list(map(int, input().split()))
prod = 1
for i in range(k):
prod = (prod*nums[i])%MOD
prev = prod
start = 0
for ind in range(k, n):
# new = (prev * nums[ind] * modInverse(nums[start], MOD))%MOD
new = (prev * nums[ind] * dp[nums[start]])%MOD
if new > prev:
print("Yes")
else:
print("No")
start += 1
prev = new
# def gcd(a, b) :
# if (a == 0) :
# return b
# return gcd(b % a, a)
# def modInverse(a, m) :
# g = gcd(a, m)
# if (g != 1) :
# return 1/a
# else :
# return power(a, m-2, m)
# # To compute x^y under modulo m
# def power(x, y, m) :
# if (y == 0) :
# return -1
# p = power(x, y // 2, m) % m
# p = (p * p) % m
# if(y % 2 == 0) :
# return p
# else :
# return ((x * p) % m)
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# endregion
if __name__ == "__main__":
main()
```
No
| 22,614 | [
0.486572265625,
-0.1436767578125,
-0.098876953125,
-0.0543212890625,
-0.44189453125,
-0.1571044921875,
0.283447265625,
0.009307861328125,
0.139404296875,
1.0546875,
0.5595703125,
0.0151214599609375,
0.28515625,
-0.93359375,
-0.274169921875,
0.1881103515625,
-0.471435546875,
-0.8686... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
M-kun is a student in Aoki High School, where a year is divided into N terms.
There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows:
* For the first through (K-1)-th terms: not given.
* For each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term.
M-kun scored A_i in the exam at the end of the i-th term.
For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is strictly greater than the grade for the (i-1)-th term.
Constraints
* 2 \leq N \leq 200000
* 1 \leq K \leq N-1
* 1 \leq A_i \leq 10^{9}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
A_1 A_2 A_3 \ldots A_N
Output
Print the answer in N-K lines.
The i-th line should contain `Yes` if the grade for the (K+i)-th term is greater than the grade for the (K+i-1)-th term, and `No` otherwise.
Examples
Input
5 3
96 98 95 100 20
Output
Yes
No
Input
3 2
1001 869120 1001
Output
No
Input
15 7
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9
Output
Yes
Yes
No
Yes
Yes
No
Yes
Yes
Submitted Solution:
```
import numpy as np
n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = []
point_before = np.prod(a[:k])
for i in range(n-k):
point = point_before / a[i] * a[k+i]
if point_before < point:
ans.append('Yes')
else:
ans.append('No')
point_before = point
# print(point_before)
for a in ans:
print(a)
```
No
| 22,615 | [
0.42041015625,
0.08660888671875,
-0.1641845703125,
-0.1300048828125,
-0.404296875,
-0.311767578125,
0.2222900390625,
0.0814208984375,
0.0528564453125,
1.1015625,
0.6435546875,
0.187255859375,
0.277099609375,
-1.087890625,
-0.382080078125,
-0.0081787109375,
-0.64501953125,
-0.861816... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
M-kun is a student in Aoki High School, where a year is divided into N terms.
There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows:
* For the first through (K-1)-th terms: not given.
* For each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term.
M-kun scored A_i in the exam at the end of the i-th term.
For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is strictly greater than the grade for the (i-1)-th term.
Constraints
* 2 \leq N \leq 200000
* 1 \leq K \leq N-1
* 1 \leq A_i \leq 10^{9}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
A_1 A_2 A_3 \ldots A_N
Output
Print the answer in N-K lines.
The i-th line should contain `Yes` if the grade for the (K+i)-th term is greater than the grade for the (K+i-1)-th term, and `No` otherwise.
Examples
Input
5 3
96 98 95 100 20
Output
Yes
No
Input
3 2
1001 869120 1001
Output
No
Input
15 7
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9
Output
Yes
Yes
No
Yes
Yes
No
Yes
Yes
Submitted Solution:
```
N, K = map(int, input().split())
A = list(map(int, input().split()))
sum_A = [0]*N
sum_A_k = 1
for i in range(K):
sum_A_k = sum_A_k*A[i]
sum_A[K-1] = sum_A_k
for i in range(N-K):
sum_A[K+i] = sum_A[K-1+i]*A[K+i]/A[i]
if sum_A[K+i] > sum_A[K-1+i]:
print('Yes')
else:
print('No')
```
No
| 22,616 | [
0.402587890625,
0.07275390625,
-0.1202392578125,
-0.1290283203125,
-0.3564453125,
-0.27294921875,
0.306884765625,
0.066162109375,
0.033721923828125,
1.0283203125,
0.61279296875,
0.2509765625,
0.260986328125,
-1.1044921875,
-0.47998046875,
-0.071533203125,
-0.58544921875,
-0.8002929... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
M-kun is a student in Aoki High School, where a year is divided into N terms.
There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows:
* For the first through (K-1)-th terms: not given.
* For each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term.
M-kun scored A_i in the exam at the end of the i-th term.
For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is strictly greater than the grade for the (i-1)-th term.
Constraints
* 2 \leq N \leq 200000
* 1 \leq K \leq N-1
* 1 \leq A_i \leq 10^{9}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
A_1 A_2 A_3 \ldots A_N
Output
Print the answer in N-K lines.
The i-th line should contain `Yes` if the grade for the (K+i)-th term is greater than the grade for the (K+i-1)-th term, and `No` otherwise.
Examples
Input
5 3
96 98 95 100 20
Output
Yes
No
Input
3 2
1001 869120 1001
Output
No
Input
15 7
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9
Output
Yes
Yes
No
Yes
Yes
No
Yes
Yes
Submitted Solution:
```
import os
import sys
from io import BytesIO, IOBase
def gcd(a, b) :
if (a == 0) :
return b
return gcd(b % a, a)
def modInverse(a, m) :
g = gcd(a, m)
if (g != 1) :
return -1
else :
return power(a, m-2, m)
# To compute x^y under modulo m
def power(x, y, m) :
if (y == 0) :
return 1
p = power(x, y // 2, m) % m
p = (p * p) % m
if(y % 2 == 0) :
return p
else :
return ((x * p) % m)
MOD = 10**9 + 7
def main():
t = 1
for _ in range(t):
# n = int(input)
n, k = map(int, input().split())
nums = list(map(int, input().split()))
prod = 1
for i in range(k):
prod *= nums[i]
prev = prod
start = 0
for ind in range(k, n):
new = (prev * nums[ind] * modInverse(nums[start], MOD))%MOD
if new > prev:
print("Yes")
else:
print("No")
start += 1
prev = new
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# endregion
if __name__ == "__main__":
main()
```
No
| 22,617 | [
0.4296875,
-0.1363525390625,
-0.02593994140625,
-0.1190185546875,
-0.34033203125,
-0.14794921875,
0.368408203125,
-0.08966064453125,
0.0244140625,
1.1533203125,
0.5791015625,
0.0299224853515625,
0.250732421875,
-1.138671875,
-0.342529296875,
0.055908203125,
-0.53662109375,
-0.85937... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is interactive.
We have hidden an array a of n pairwise different numbers (this means that no two numbers are equal). You can get some information about this array using a new device you just ordered on Amazon.
This device can answer queries of the following form: in response to the positions of k different elements of the array, it will return the position and value of the m-th among them in the ascending order.
Unfortunately, the instruction for the device was lost during delivery. However, you remember k, but don't remember m. Your task is to find m using queries to this device.
You can ask not more than n queries.
Note that the array a and number m are fixed before the start of the interaction and don't depend on your queries. In other words, interactor is not adaptive.
Note that you don't have to minimize the number of queries, and you don't need to guess array a. You just have to guess m.
Input
The first line contains two integers n and k (1≤ k < n ≤ 500) — the length of the array and the number of the elements in the query.
It is guaranteed that number m satisfies 1≤ m ≤ k, elements a_1, a_2, ..., a_n of the array satisfy 0≤ a_i ≤ 10^9, and all of them are different.
Interaction
You begin the interaction by reading n and k.
To ask a question about elements on positions x_1, x_2, ..., x_k, in a separate line output
? x_1 x_2 x_3 ... x_k
Numbers in the query have to satisfy 1 ≤ x_i ≤ n, and all x_i have to be different. Don't forget to 'flush', to get the answer.
In response, you will receive two integers pos and a_{pos} — the position in the array a of the m-th in ascending order element among a_{x_1}, a_{x_2}, ..., a_{x_k}, and the element on this position.
In case your query is invalid or you asked more than n queries, the program will print -1 and will finish interaction. You will receive a Wrong answer verdict. Make sure to exit immediately to avoid getting other verdicts.
When you determine m, output
! m
After printing a query do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:
* fflush(stdout) or cout.flush() in C++;
* System.out.flush() in Java;
* flush(output) in Pascal;
* stdout.flush() in Python;
* see documentation for other languages.
Hack format
For the hacks use the following format:
The first line has to contain three integers n, k, m (1 ≤ m ≤ k < n ≤ 500) — the length of the array, number of elements in the query, and which in the ascending order number the device returns.
In the next line output n integers a_1, a_2, ..., a_n (0≤ a_i ≤ 10^9) — the elements of the array. They have to be pairwise different.
Example
Input
4 3
4 9
4 9
4 9
1 2
Output
? 2 3 4
? 1 3 4
? 1 2 4
? 1 2 3
! 3
Note
In the example, n = 4, k = 3, m = 3, a = [2, 0, 1, 9].
Submitted Solution:
```
import sys
n, k = map(int,input().split())
kek = [i for i in range(1, k + 2)]
used = []
ans = {}
for i in range(k + 1):
print('?', end = ' ')
print( *kek[:i],*kek[i+1:] )
sys.stdout.flush()
p, num = map(int,input().split())
if num not in used:
if used:
m1 = max(num,used[0])
m0 = min(num,used[0])
ans[num] = 1
used.append(num)
else:
used.append(num)
ans[num] = 1
else:
ans[num] += 1
print('!', ans[m1])
'''
mas = [0] * n
kek = [i for i in range(1, k + 1)]
for i in range(n):
for v in kek:
print( v , end = ' ' )
print()
sys.stdout.flush()
c, num = map(int, input().split())
mas[c - 1] = num
add = kek[-1] + 1
kek.remove(c)
kek.append(add)
'''
#print(mas)
```
Yes
| 22,968 | [
0.17919921875,
0.1585693359375,
-0.62109375,
0.1085205078125,
-0.5966796875,
-0.52099609375,
-0.305419921875,
0.287109375,
0.259765625,
0.734375,
0.6484375,
-0.129150390625,
-0.375244140625,
-0.63720703125,
-0.80322265625,
-0.0784912109375,
-0.3935546875,
-0.66455078125,
-0.25244... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is interactive.
We have hidden an array a of n pairwise different numbers (this means that no two numbers are equal). You can get some information about this array using a new device you just ordered on Amazon.
This device can answer queries of the following form: in response to the positions of k different elements of the array, it will return the position and value of the m-th among them in the ascending order.
Unfortunately, the instruction for the device was lost during delivery. However, you remember k, but don't remember m. Your task is to find m using queries to this device.
You can ask not more than n queries.
Note that the array a and number m are fixed before the start of the interaction and don't depend on your queries. In other words, interactor is not adaptive.
Note that you don't have to minimize the number of queries, and you don't need to guess array a. You just have to guess m.
Input
The first line contains two integers n and k (1≤ k < n ≤ 500) — the length of the array and the number of the elements in the query.
It is guaranteed that number m satisfies 1≤ m ≤ k, elements a_1, a_2, ..., a_n of the array satisfy 0≤ a_i ≤ 10^9, and all of them are different.
Interaction
You begin the interaction by reading n and k.
To ask a question about elements on positions x_1, x_2, ..., x_k, in a separate line output
? x_1 x_2 x_3 ... x_k
Numbers in the query have to satisfy 1 ≤ x_i ≤ n, and all x_i have to be different. Don't forget to 'flush', to get the answer.
In response, you will receive two integers pos and a_{pos} — the position in the array a of the m-th in ascending order element among a_{x_1}, a_{x_2}, ..., a_{x_k}, and the element on this position.
In case your query is invalid or you asked more than n queries, the program will print -1 and will finish interaction. You will receive a Wrong answer verdict. Make sure to exit immediately to avoid getting other verdicts.
When you determine m, output
! m
After printing a query do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:
* fflush(stdout) or cout.flush() in C++;
* System.out.flush() in Java;
* flush(output) in Pascal;
* stdout.flush() in Python;
* see documentation for other languages.
Hack format
For the hacks use the following format:
The first line has to contain three integers n, k, m (1 ≤ m ≤ k < n ≤ 500) — the length of the array, number of elements in the query, and which in the ascending order number the device returns.
In the next line output n integers a_1, a_2, ..., a_n (0≤ a_i ≤ 10^9) — the elements of the array. They have to be pairwise different.
Example
Input
4 3
4 9
4 9
4 9
1 2
Output
? 2 3 4
? 1 3 4
? 1 2 4
? 1 2 3
! 3
Note
In the example, n = 4, k = 3, m = 3, a = [2, 0, 1, 9].
Submitted Solution:
```
import sys
def minp():
return sys.stdin.readline().strip()
def mint():
return int(minp())
def mints():
return map(int,minp().split())
def emit(x):
print('?',' '.join(map(str,x)))
sys.stdout.flush()
s = minp().split()
if len(s) == 1:
s.append('-1')
a, b = map(int,s)
return (b, a)
def emit1(x):
z = []
for j in x:
z.append((a[j-1],j))
z.sort()
s = z[m-1]
return tuple(map(int,s))
def solve():
n,k = mints()
#global n,k
#w = dict()
w = []
for i in range(k+1):
x = []
for j in range(k+1):
if i != j:
x.append(j+1)
y = emit(x)
if y[0] == -1:
return
w.append(y)
w.sort(reverse=True)
i = 0
while w[i] == w[0]:
i += 1
#print('!',w[max(w.keys())])
print('!',i)
sys.stdout.flush()
#return w[max(w.keys())]
#for i in range(mint()):
solve()
'''from random import randint
while True:
n = randint(2,500)
was = [False]*(1001)
a = [0]*n
for i in range(n):
while True:
x = randint(0,1000)
if not was[x]:
was[x] = True
break
a[i] = x
a = list(range(n,0,-1))
k = randint(1,n-1)
m = randint(1,k)
if m != solve():
print('k',k,'m', m,solve(),'a',a)
break
'''
```
Yes
| 22,969 | [
0.17919921875,
0.1585693359375,
-0.62109375,
0.1085205078125,
-0.5966796875,
-0.52099609375,
-0.305419921875,
0.287109375,
0.259765625,
0.734375,
0.6484375,
-0.129150390625,
-0.375244140625,
-0.63720703125,
-0.80322265625,
-0.0784912109375,
-0.3935546875,
-0.66455078125,
-0.25244... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is interactive.
We have hidden an array a of n pairwise different numbers (this means that no two numbers are equal). You can get some information about this array using a new device you just ordered on Amazon.
This device can answer queries of the following form: in response to the positions of k different elements of the array, it will return the position and value of the m-th among them in the ascending order.
Unfortunately, the instruction for the device was lost during delivery. However, you remember k, but don't remember m. Your task is to find m using queries to this device.
You can ask not more than n queries.
Note that the array a and number m are fixed before the start of the interaction and don't depend on your queries. In other words, interactor is not adaptive.
Note that you don't have to minimize the number of queries, and you don't need to guess array a. You just have to guess m.
Input
The first line contains two integers n and k (1≤ k < n ≤ 500) — the length of the array and the number of the elements in the query.
It is guaranteed that number m satisfies 1≤ m ≤ k, elements a_1, a_2, ..., a_n of the array satisfy 0≤ a_i ≤ 10^9, and all of them are different.
Interaction
You begin the interaction by reading n and k.
To ask a question about elements on positions x_1, x_2, ..., x_k, in a separate line output
? x_1 x_2 x_3 ... x_k
Numbers in the query have to satisfy 1 ≤ x_i ≤ n, and all x_i have to be different. Don't forget to 'flush', to get the answer.
In response, you will receive two integers pos and a_{pos} — the position in the array a of the m-th in ascending order element among a_{x_1}, a_{x_2}, ..., a_{x_k}, and the element on this position.
In case your query is invalid or you asked more than n queries, the program will print -1 and will finish interaction. You will receive a Wrong answer verdict. Make sure to exit immediately to avoid getting other verdicts.
When you determine m, output
! m
After printing a query do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:
* fflush(stdout) or cout.flush() in C++;
* System.out.flush() in Java;
* flush(output) in Pascal;
* stdout.flush() in Python;
* see documentation for other languages.
Hack format
For the hacks use the following format:
The first line has to contain three integers n, k, m (1 ≤ m ≤ k < n ≤ 500) — the length of the array, number of elements in the query, and which in the ascending order number the device returns.
In the next line output n integers a_1, a_2, ..., a_n (0≤ a_i ≤ 10^9) — the elements of the array. They have to be pairwise different.
Example
Input
4 3
4 9
4 9
4 9
1 2
Output
? 2 3 4
? 1 3 4
? 1 2 4
? 1 2 3
! 3
Note
In the example, n = 4, k = 3, m = 3, a = [2, 0, 1, 9].
Submitted Solution:
```
# stdout.flush()
from sys import stdout
from collections import Counter
def solved():
n, k = (int(x) for x in input().split())
arr = list(range(1, k + 2))
val___count = Counter()
for excluded in range(k + 1):
req =['?'] + arr[:excluded] + arr[excluded + 1:]
print(*req)
stdout.flush()
idx, val = (int(x) for x in input().split())
val___count[val] += 1
x = max(val___count)
print('!', val___count[x])
stdout.flush()
def solvec():
n = int(input())
arr = [int(x) for x in input().split()]
xor = 0
for x in arr:
xor ^= x
arr.append(xor)
sm = sum(arr)
arr.append(sm)
print(2)
print(xor, sm)
if __name__ == '__main__':
# t = int(input())
t = 1
for _ in range(t):
solved()
```
Yes
| 22,970 | [
0.17919921875,
0.1585693359375,
-0.62109375,
0.1085205078125,
-0.5966796875,
-0.52099609375,
-0.305419921875,
0.287109375,
0.259765625,
0.734375,
0.6484375,
-0.129150390625,
-0.375244140625,
-0.63720703125,
-0.80322265625,
-0.0784912109375,
-0.3935546875,
-0.66455078125,
-0.25244... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is interactive.
We have hidden an array a of n pairwise different numbers (this means that no two numbers are equal). You can get some information about this array using a new device you just ordered on Amazon.
This device can answer queries of the following form: in response to the positions of k different elements of the array, it will return the position and value of the m-th among them in the ascending order.
Unfortunately, the instruction for the device was lost during delivery. However, you remember k, but don't remember m. Your task is to find m using queries to this device.
You can ask not more than n queries.
Note that the array a and number m are fixed before the start of the interaction and don't depend on your queries. In other words, interactor is not adaptive.
Note that you don't have to minimize the number of queries, and you don't need to guess array a. You just have to guess m.
Input
The first line contains two integers n and k (1≤ k < n ≤ 500) — the length of the array and the number of the elements in the query.
It is guaranteed that number m satisfies 1≤ m ≤ k, elements a_1, a_2, ..., a_n of the array satisfy 0≤ a_i ≤ 10^9, and all of them are different.
Interaction
You begin the interaction by reading n and k.
To ask a question about elements on positions x_1, x_2, ..., x_k, in a separate line output
? x_1 x_2 x_3 ... x_k
Numbers in the query have to satisfy 1 ≤ x_i ≤ n, and all x_i have to be different. Don't forget to 'flush', to get the answer.
In response, you will receive two integers pos and a_{pos} — the position in the array a of the m-th in ascending order element among a_{x_1}, a_{x_2}, ..., a_{x_k}, and the element on this position.
In case your query is invalid or you asked more than n queries, the program will print -1 and will finish interaction. You will receive a Wrong answer verdict. Make sure to exit immediately to avoid getting other verdicts.
When you determine m, output
! m
After printing a query do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:
* fflush(stdout) or cout.flush() in C++;
* System.out.flush() in Java;
* flush(output) in Pascal;
* stdout.flush() in Python;
* see documentation for other languages.
Hack format
For the hacks use the following format:
The first line has to contain three integers n, k, m (1 ≤ m ≤ k < n ≤ 500) — the length of the array, number of elements in the query, and which in the ascending order number the device returns.
In the next line output n integers a_1, a_2, ..., a_n (0≤ a_i ≤ 10^9) — the elements of the array. They have to be pairwise different.
Example
Input
4 3
4 9
4 9
4 9
1 2
Output
? 2 3 4
? 1 3 4
? 1 2 4
? 1 2 3
! 3
Note
In the example, n = 4, k = 3, m = 3, a = [2, 0, 1, 9].
Submitted Solution:
```
import sys
n , m = map(int,input().split())
lis=[]
for i in range(1,m+2):
print("?",end=' ')
for j in range(1,m+2):
if i!=j:
print(j,end=' ')
print()
a ,b = map(int,input().split())
sys.stdout.flush()
lis.append(b)
aa=max(lis)
ans=0
for i in lis:
if i==aa:
ans+=1
print("!",ans)
```
Yes
| 22,971 | [
0.17919921875,
0.1585693359375,
-0.62109375,
0.1085205078125,
-0.5966796875,
-0.52099609375,
-0.305419921875,
0.287109375,
0.259765625,
0.734375,
0.6484375,
-0.129150390625,
-0.375244140625,
-0.63720703125,
-0.80322265625,
-0.0784912109375,
-0.3935546875,
-0.66455078125,
-0.25244... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is interactive.
We have hidden an array a of n pairwise different numbers (this means that no two numbers are equal). You can get some information about this array using a new device you just ordered on Amazon.
This device can answer queries of the following form: in response to the positions of k different elements of the array, it will return the position and value of the m-th among them in the ascending order.
Unfortunately, the instruction for the device was lost during delivery. However, you remember k, but don't remember m. Your task is to find m using queries to this device.
You can ask not more than n queries.
Note that the array a and number m are fixed before the start of the interaction and don't depend on your queries. In other words, interactor is not adaptive.
Note that you don't have to minimize the number of queries, and you don't need to guess array a. You just have to guess m.
Input
The first line contains two integers n and k (1≤ k < n ≤ 500) — the length of the array and the number of the elements in the query.
It is guaranteed that number m satisfies 1≤ m ≤ k, elements a_1, a_2, ..., a_n of the array satisfy 0≤ a_i ≤ 10^9, and all of them are different.
Interaction
You begin the interaction by reading n and k.
To ask a question about elements on positions x_1, x_2, ..., x_k, in a separate line output
? x_1 x_2 x_3 ... x_k
Numbers in the query have to satisfy 1 ≤ x_i ≤ n, and all x_i have to be different. Don't forget to 'flush', to get the answer.
In response, you will receive two integers pos and a_{pos} — the position in the array a of the m-th in ascending order element among a_{x_1}, a_{x_2}, ..., a_{x_k}, and the element on this position.
In case your query is invalid or you asked more than n queries, the program will print -1 and will finish interaction. You will receive a Wrong answer verdict. Make sure to exit immediately to avoid getting other verdicts.
When you determine m, output
! m
After printing a query do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:
* fflush(stdout) or cout.flush() in C++;
* System.out.flush() in Java;
* flush(output) in Pascal;
* stdout.flush() in Python;
* see documentation for other languages.
Hack format
For the hacks use the following format:
The first line has to contain three integers n, k, m (1 ≤ m ≤ k < n ≤ 500) — the length of the array, number of elements in the query, and which in the ascending order number the device returns.
In the next line output n integers a_1, a_2, ..., a_n (0≤ a_i ≤ 10^9) — the elements of the array. They have to be pairwise different.
Example
Input
4 3
4 9
4 9
4 9
1 2
Output
? 2 3 4
? 1 3 4
? 1 2 4
? 1 2 3
! 3
Note
In the example, n = 4, k = 3, m = 3, a = [2, 0, 1, 9].
Submitted Solution:
```
# ---------------------------iye ha aam zindegi---------------------------------------------
import math
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
#import threading
from collections import defaultdict
#threading.stack_size(10**8)
mod = 10 ** 9 + 7
mod1 = 998244353
# ------------------------------warmup----------------------------
import os
import sys
from io import BytesIO, IOBase
#sys.setrecursionlimit(300000)
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# -------------------game starts now----------------------------------------------------import math
class TreeNode:
def __init__(self, k, v):
self.key = k
self.value = v
self.left = None
self.right = None
self.parent = None
self.height = 1
self.num_left = 1
self.num_total = 1
class AvlTree:
def __init__(self):
self._tree = None
def add(self, k, v):
if not self._tree:
self._tree = TreeNode(k, v)
return
node = self._add(k, v)
if node:
self._rebalance(node)
def _add(self, k, v):
node = self._tree
while node:
if k < node.key:
if node.left:
node = node.left
else:
node.left = TreeNode(k, v)
node.left.parent = node
return node.left
elif node.key < k:
if node.right:
node = node.right
else:
node.right = TreeNode(k, v)
node.right.parent = node
return node.right
else:
node.value = v
return
@staticmethod
def get_height(x):
return x.height if x else 0
@staticmethod
def get_num_total(x):
return x.num_total if x else 0
def _rebalance(self, node):
n = node
while n:
lh = self.get_height(n.left)
rh = self.get_height(n.right)
n.height = max(lh, rh) + 1
balance_factor = lh - rh
n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
n.num_left = 1 + self.get_num_total(n.left)
if balance_factor > 1:
if self.get_height(n.left.left) < self.get_height(n.left.right):
self._rotate_left(n.left)
self._rotate_right(n)
elif balance_factor < -1:
if self.get_height(n.right.right) < self.get_height(n.right.left):
self._rotate_right(n.right)
self._rotate_left(n)
else:
n = n.parent
def _remove_one(self, node):
"""
Side effect!!! Changes node. Node should have exactly one child
"""
replacement = node.left or node.right
if node.parent:
if AvlTree._is_left(node):
node.parent.left = replacement
else:
node.parent.right = replacement
replacement.parent = node.parent
node.parent = None
else:
self._tree = replacement
replacement.parent = None
node.left = None
node.right = None
node.parent = None
self._rebalance(replacement)
def _remove_leaf(self, node):
if node.parent:
if AvlTree._is_left(node):
node.parent.left = None
else:
node.parent.right = None
self._rebalance(node.parent)
else:
self._tree = None
node.parent = None
node.left = None
node.right = None
def remove(self, k):
node = self._get_node(k)
if not node:
return
if AvlTree._is_leaf(node):
self._remove_leaf(node)
return
if node.left and node.right:
nxt = AvlTree._get_next(node)
node.key = nxt.key
node.value = nxt.value
if self._is_leaf(nxt):
self._remove_leaf(nxt)
else:
self._remove_one(nxt)
self._rebalance(node)
else:
self._remove_one(node)
def get(self, k):
node = self._get_node(k)
return node.value if node else -1
def _get_node(self, k):
if not self._tree:
return None
node = self._tree
while node:
if k < node.key:
node = node.left
elif node.key < k:
node = node.right
else:
return node
return None
def get_at(self, pos):
x = pos + 1
node = self._tree
while node:
if x < node.num_left:
node = node.left
elif node.num_left < x:
x -= node.num_left
node = node.right
else:
return (node.key, node.value)
raise IndexError("Out of ranges")
@staticmethod
def _is_left(node):
return node.parent.left and node.parent.left == node
@staticmethod
def _is_leaf(node):
return node.left is None and node.right is None
def _rotate_right(self, node):
if not node.parent:
self._tree = node.left
node.left.parent = None
elif AvlTree._is_left(node):
node.parent.left = node.left
node.left.parent = node.parent
else:
node.parent.right = node.left
node.left.parent = node.parent
bk = node.left.right
node.left.right = node
node.parent = node.left
node.left = bk
if bk:
bk.parent = node
node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
node.num_left = 1 + self.get_num_total(node.left)
def _rotate_left(self, node):
if not node.parent:
self._tree = node.right
node.right.parent = None
elif AvlTree._is_left(node):
node.parent.left = node.right
node.right.parent = node.parent
else:
node.parent.right = node.right
node.right.parent = node.parent
bk = node.right.left
node.right.left = node
node.parent = node.right
node.right = bk
if bk:
bk.parent = node
node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
node.num_left = 1 + self.get_num_total(node.left)
@staticmethod
def _get_next(node):
if not node.right:
return node.parent
n = node.right
while n.left:
n = n.left
return n
# -----------------------------------------------binary seacrh tree---------------------------------------
class SegmentTree1:
def __init__(self, data, default='z', func=lambda a, b: min(a, b)):
"""initialize the segment tree with data"""
self._default = default
self._func = func
self._len = len(data)
self._size = _size = 1 << (self._len - 1).bit_length()
self.data = [default] * (2 * _size)
self.data[_size:_size + self._len] = data
for i in reversed(range(_size)):
self.data[i] = func(self.data[i + i], self.data[i + i + 1])
def __delitem__(self, idx):
self[idx] = self._default
def __getitem__(self, idx):
return self.data[idx + self._size]
def __setitem__(self, idx, value):
idx += self._size
self.data[idx] = value
idx >>= 1
while idx:
self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
idx >>= 1
def __len__(self):
return self._len
def query(self, start, stop):
if start == stop:
return self.__getitem__(start)
stop += 1
start += self._size
stop += self._size
res = self._default
while start < stop:
if start & 1:
res = self._func(res, self.data[start])
start += 1
if stop & 1:
stop -= 1
res = self._func(res, self.data[stop])
start >>= 1
stop >>= 1
return res
def __repr__(self):
return "SegmentTree({0})".format(self.data)
# -------------------game starts now----------------------------------------------------import math
class SegmentTree:
def __init__(self, data, default=0, func=lambda a, b: a + b):
"""initialize the segment tree with data"""
self._default = default
self._func = func
self._len = len(data)
self._size = _size = 1 << (self._len - 1).bit_length()
self.data = [default] * (2 * _size)
self.data[_size:_size + self._len] = data
for i in reversed(range(_size)):
self.data[i] = func(self.data[i + i], self.data[i + i + 1])
def __delitem__(self, idx):
self[idx] = self._default
def __getitem__(self, idx):
return self.data[idx + self._size]
def __setitem__(self, idx, value):
idx += self._size
self.data[idx] = value
idx >>= 1
while idx:
self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
idx >>= 1
def __len__(self):
return self._len
def query(self, start, stop):
if start == stop:
return self.__getitem__(start)
stop += 1
start += self._size
stop += self._size
res = self._default
while start < stop:
if start & 1:
res = self._func(res, self.data[start])
start += 1
if stop & 1:
stop -= 1
res = self._func(res, self.data[stop])
start >>= 1
stop >>= 1
return res
def __repr__(self):
return "SegmentTree({0})".format(self.data)
# -------------------------------iye ha chutiya zindegi-------------------------------------
class Factorial:
def __init__(self, MOD):
self.MOD = MOD
self.factorials = [1, 1]
self.invModulos = [0, 1]
self.invFactorial_ = [1, 1]
def calc(self, n):
if n <= -1:
print("Invalid argument to calculate n!")
print("n must be non-negative value. But the argument was " + str(n))
exit()
if n < len(self.factorials):
return self.factorials[n]
nextArr = [0] * (n + 1 - len(self.factorials))
initialI = len(self.factorials)
prev = self.factorials[-1]
m = self.MOD
for i in range(initialI, n + 1):
prev = nextArr[i - initialI] = prev * i % m
self.factorials += nextArr
return self.factorials[n]
def inv(self, n):
if n <= -1:
print("Invalid argument to calculate n^(-1)")
print("n must be non-negative value. But the argument was " + str(n))
exit()
p = self.MOD
pi = n % p
if pi < len(self.invModulos):
return self.invModulos[pi]
nextArr = [0] * (n + 1 - len(self.invModulos))
initialI = len(self.invModulos)
for i in range(initialI, min(p, n + 1)):
next = -self.invModulos[p % i] * (p // i) % p
self.invModulos.append(next)
return self.invModulos[pi]
def invFactorial(self, n):
if n <= -1:
print("Invalid argument to calculate (n^(-1))!")
print("n must be non-negative value. But the argument was " + str(n))
exit()
if n < len(self.invFactorial_):
return self.invFactorial_[n]
self.inv(n) # To make sure already calculated n^-1
nextArr = [0] * (n + 1 - len(self.invFactorial_))
initialI = len(self.invFactorial_)
prev = self.invFactorial_[-1]
p = self.MOD
for i in range(initialI, n + 1):
prev = nextArr[i - initialI] = (prev * self.invModulos[i % p]) % p
self.invFactorial_ += nextArr
return self.invFactorial_[n]
class Combination:
def __init__(self, MOD):
self.MOD = MOD
self.factorial = Factorial(MOD)
def ncr(self, n, k):
if k < 0 or n < k:
return 0
k = min(k, n - k)
f = self.factorial
return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
# --------------------------------------iye ha combinations ka zindegi---------------------------------
def powm(a, n, m):
if a == 1 or n == 0:
return 1
if n % 2 == 0:
s = powm(a, n // 2, m)
return s * s % m
else:
return a * powm(a, n - 1, m) % m
# --------------------------------------iye ha power ka zindegi---------------------------------
def sort_list(list1, list2):
zipped_pairs = zip(list2, list1)
z = [x for _, x in sorted(zipped_pairs)]
return z
# --------------------------------------------------product----------------------------------------
def product(l):
por = 1
for i in range(len(l)):
por *= l[i]
return por
# --------------------------------------------------binary----------------------------------------
def binarySearchCount(arr, n, key):
left = 0
right = n - 1
count = 0
while (left <= right):
mid = int((right + left) / 2)
# Check if middle element is
# less than or equal to key
if (arr[mid] < key):
count = mid + 1
left = mid + 1
# If key is smaller, ignore right half
else:
right = mid - 1
return count
# --------------------------------------------------binary----------------------------------------
def countdig(n):
c = 0
while (n > 0):
n //= 10
c += 1
return c
def binary(x, length):
y = bin(x)[2:]
return y if len(y) >= length else "0" * (length - len(y)) + y
def countGreater(arr, n, k):
l = 0
r = n - 1
# Stores the index of the left most element
# from the array which is greater than k
leftGreater = n
# Finds number of elements greater than k
while (l <= r):
m = int(l + (r - l) / 2)
if (arr[m] >= k):
leftGreater = m
r = m - 1
# If mid element is less than
# or equal to k update l
else:
l = m + 1
# Return the count of elements
# greater than k
return (n - leftGreater)
# --------------------------------------------------binary------------------------------------
n,k=map(int,input().split())
a=[i+1 for i in range(k+1)]
d=defaultdict(int)
for i in range(k+1):
a1=a[:i]+a[i+1:]
print('?',*a1,flush=True)
a1,k=map(int,input().split())
d[a1]+=1
m=0
for i in d:
if d[i]>m:
m=d[i]
ind=i
else:
ind1=i
if ind>ind1:
print(m-d[ind1]+1)
else:
print(d[ind1])
```
No
| 22,972 | [
0.17919921875,
0.1585693359375,
-0.62109375,
0.1085205078125,
-0.5966796875,
-0.52099609375,
-0.305419921875,
0.287109375,
0.259765625,
0.734375,
0.6484375,
-0.129150390625,
-0.375244140625,
-0.63720703125,
-0.80322265625,
-0.0784912109375,
-0.3935546875,
-0.66455078125,
-0.25244... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is interactive.
We have hidden an array a of n pairwise different numbers (this means that no two numbers are equal). You can get some information about this array using a new device you just ordered on Amazon.
This device can answer queries of the following form: in response to the positions of k different elements of the array, it will return the position and value of the m-th among them in the ascending order.
Unfortunately, the instruction for the device was lost during delivery. However, you remember k, but don't remember m. Your task is to find m using queries to this device.
You can ask not more than n queries.
Note that the array a and number m are fixed before the start of the interaction and don't depend on your queries. In other words, interactor is not adaptive.
Note that you don't have to minimize the number of queries, and you don't need to guess array a. You just have to guess m.
Input
The first line contains two integers n and k (1≤ k < n ≤ 500) — the length of the array and the number of the elements in the query.
It is guaranteed that number m satisfies 1≤ m ≤ k, elements a_1, a_2, ..., a_n of the array satisfy 0≤ a_i ≤ 10^9, and all of them are different.
Interaction
You begin the interaction by reading n and k.
To ask a question about elements on positions x_1, x_2, ..., x_k, in a separate line output
? x_1 x_2 x_3 ... x_k
Numbers in the query have to satisfy 1 ≤ x_i ≤ n, and all x_i have to be different. Don't forget to 'flush', to get the answer.
In response, you will receive two integers pos and a_{pos} — the position in the array a of the m-th in ascending order element among a_{x_1}, a_{x_2}, ..., a_{x_k}, and the element on this position.
In case your query is invalid or you asked more than n queries, the program will print -1 and will finish interaction. You will receive a Wrong answer verdict. Make sure to exit immediately to avoid getting other verdicts.
When you determine m, output
! m
After printing a query do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:
* fflush(stdout) or cout.flush() in C++;
* System.out.flush() in Java;
* flush(output) in Pascal;
* stdout.flush() in Python;
* see documentation for other languages.
Hack format
For the hacks use the following format:
The first line has to contain three integers n, k, m (1 ≤ m ≤ k < n ≤ 500) — the length of the array, number of elements in the query, and which in the ascending order number the device returns.
In the next line output n integers a_1, a_2, ..., a_n (0≤ a_i ≤ 10^9) — the elements of the array. They have to be pairwise different.
Example
Input
4 3
4 9
4 9
4 9
1 2
Output
? 2 3 4
? 1 3 4
? 1 2 4
? 1 2 3
! 3
Note
In the example, n = 4, k = 3, m = 3, a = [2, 0, 1, 9].
Submitted Solution:
```
def query(a):
print('?', *a, flush=True)
pos, val = map(int, input().split())
return pos, val
def printAns(ans):
print('! %d' % ans, flush=True)
n, k = map(int, input().split())
d = {}
for i in range(1, k + 2):
a = list(filter(lambda x: x != i, range(1, k + 2)))
pos, val = query(a)
d[val] = pos
if len(d.keys()) != 2:
raise Exception
printAns(d[min(d.keys())])
```
No
| 22,973 | [
0.17919921875,
0.1585693359375,
-0.62109375,
0.1085205078125,
-0.5966796875,
-0.52099609375,
-0.305419921875,
0.287109375,
0.259765625,
0.734375,
0.6484375,
-0.129150390625,
-0.375244140625,
-0.63720703125,
-0.80322265625,
-0.0784912109375,
-0.3935546875,
-0.66455078125,
-0.25244... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is interactive.
We have hidden an array a of n pairwise different numbers (this means that no two numbers are equal). You can get some information about this array using a new device you just ordered on Amazon.
This device can answer queries of the following form: in response to the positions of k different elements of the array, it will return the position and value of the m-th among them in the ascending order.
Unfortunately, the instruction for the device was lost during delivery. However, you remember k, but don't remember m. Your task is to find m using queries to this device.
You can ask not more than n queries.
Note that the array a and number m are fixed before the start of the interaction and don't depend on your queries. In other words, interactor is not adaptive.
Note that you don't have to minimize the number of queries, and you don't need to guess array a. You just have to guess m.
Input
The first line contains two integers n and k (1≤ k < n ≤ 500) — the length of the array and the number of the elements in the query.
It is guaranteed that number m satisfies 1≤ m ≤ k, elements a_1, a_2, ..., a_n of the array satisfy 0≤ a_i ≤ 10^9, and all of them are different.
Interaction
You begin the interaction by reading n and k.
To ask a question about elements on positions x_1, x_2, ..., x_k, in a separate line output
? x_1 x_2 x_3 ... x_k
Numbers in the query have to satisfy 1 ≤ x_i ≤ n, and all x_i have to be different. Don't forget to 'flush', to get the answer.
In response, you will receive two integers pos and a_{pos} — the position in the array a of the m-th in ascending order element among a_{x_1}, a_{x_2}, ..., a_{x_k}, and the element on this position.
In case your query is invalid or you asked more than n queries, the program will print -1 and will finish interaction. You will receive a Wrong answer verdict. Make sure to exit immediately to avoid getting other verdicts.
When you determine m, output
! m
After printing a query do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:
* fflush(stdout) or cout.flush() in C++;
* System.out.flush() in Java;
* flush(output) in Pascal;
* stdout.flush() in Python;
* see documentation for other languages.
Hack format
For the hacks use the following format:
The first line has to contain three integers n, k, m (1 ≤ m ≤ k < n ≤ 500) — the length of the array, number of elements in the query, and which in the ascending order number the device returns.
In the next line output n integers a_1, a_2, ..., a_n (0≤ a_i ≤ 10^9) — the elements of the array. They have to be pairwise different.
Example
Input
4 3
4 9
4 9
4 9
1 2
Output
? 2 3 4
? 1 3 4
? 1 2 4
? 1 2 3
! 3
Note
In the example, n = 4, k = 3, m = 3, a = [2, 0, 1, 9].
Submitted Solution:
```
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 23 05:53:26 2020
@author: Dark Soul
"""
import sys
[n,k]=list(map(int,input().split()))
def query(arr):
print('?',*arr)
sys.stdout.flush()
[x,y]=list(map(int,input().split()))
return (x,y)
dic={}
cnt=0
for i in range(1,k+2):
dhukao=[]
for j in range(1,k+2):
if j!=i:
dhukao.append(j)
a=query(dhukao)
try:
dic[a]+=1
except:
dic[a]=1
ans=[]
for keys in dic:
ans.append(dic[keys])
ans.sort()
print('!',ans[len(ans)-1])
```
No
| 22,974 | [
0.17919921875,
0.1585693359375,
-0.62109375,
0.1085205078125,
-0.5966796875,
-0.52099609375,
-0.305419921875,
0.287109375,
0.259765625,
0.734375,
0.6484375,
-0.129150390625,
-0.375244140625,
-0.63720703125,
-0.80322265625,
-0.0784912109375,
-0.3935546875,
-0.66455078125,
-0.25244... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is interactive.
We have hidden an array a of n pairwise different numbers (this means that no two numbers are equal). You can get some information about this array using a new device you just ordered on Amazon.
This device can answer queries of the following form: in response to the positions of k different elements of the array, it will return the position and value of the m-th among them in the ascending order.
Unfortunately, the instruction for the device was lost during delivery. However, you remember k, but don't remember m. Your task is to find m using queries to this device.
You can ask not more than n queries.
Note that the array a and number m are fixed before the start of the interaction and don't depend on your queries. In other words, interactor is not adaptive.
Note that you don't have to minimize the number of queries, and you don't need to guess array a. You just have to guess m.
Input
The first line contains two integers n and k (1≤ k < n ≤ 500) — the length of the array and the number of the elements in the query.
It is guaranteed that number m satisfies 1≤ m ≤ k, elements a_1, a_2, ..., a_n of the array satisfy 0≤ a_i ≤ 10^9, and all of them are different.
Interaction
You begin the interaction by reading n and k.
To ask a question about elements on positions x_1, x_2, ..., x_k, in a separate line output
? x_1 x_2 x_3 ... x_k
Numbers in the query have to satisfy 1 ≤ x_i ≤ n, and all x_i have to be different. Don't forget to 'flush', to get the answer.
In response, you will receive two integers pos and a_{pos} — the position in the array a of the m-th in ascending order element among a_{x_1}, a_{x_2}, ..., a_{x_k}, and the element on this position.
In case your query is invalid or you asked more than n queries, the program will print -1 and will finish interaction. You will receive a Wrong answer verdict. Make sure to exit immediately to avoid getting other verdicts.
When you determine m, output
! m
After printing a query do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:
* fflush(stdout) or cout.flush() in C++;
* System.out.flush() in Java;
* flush(output) in Pascal;
* stdout.flush() in Python;
* see documentation for other languages.
Hack format
For the hacks use the following format:
The first line has to contain three integers n, k, m (1 ≤ m ≤ k < n ≤ 500) — the length of the array, number of elements in the query, and which in the ascending order number the device returns.
In the next line output n integers a_1, a_2, ..., a_n (0≤ a_i ≤ 10^9) — the elements of the array. They have to be pairwise different.
Example
Input
4 3
4 9
4 9
4 9
1 2
Output
? 2 3 4
? 1 3 4
? 1 2 4
? 1 2 3
! 3
Note
In the example, n = 4, k = 3, m = 3, a = [2, 0, 1, 9].
Submitted Solution:
```
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 23 05:53:26 2020
@author: Dark Soul
"""
import sys
[n,k]=list(map(int,input().split()))
def query(a,n):
prnt=['?']
for i in range(1,n+1):
if i!=a:
prnt.append(i)
print(*prnt)
sys.stdout.flush()
[x,y]=list(map(int,input().split()))
return (y,x)
dic={}
n=k+1
cnt=0
for i in range(1,n+1):
a=query(i,n)
try:
dic[a]+=1
except:
dic[a]=1
ans=[]
for keys in dic:
ans.append(dic[keys])
ans.sort()
print('!',ans[1])
```
No
| 22,975 | [
0.17919921875,
0.1585693359375,
-0.62109375,
0.1085205078125,
-0.5966796875,
-0.52099609375,
-0.305419921875,
0.287109375,
0.259765625,
0.734375,
0.6484375,
-0.129150390625,
-0.375244140625,
-0.63720703125,
-0.80322265625,
-0.0784912109375,
-0.3935546875,
-0.66455078125,
-0.25244... | 11 |
Provide tags and a correct Python 3 solution for this coding contest problem.
[3R2 - Standby for Action](https://www.youtube.com/watch?v=P2ZVC9aoiKo)
Our dear Cafe's owner, JOE Miller, will soon take part in a new game TV-show "1 vs. n"!
The game goes in rounds, where in each round the host asks JOE and his opponents a common question. All participants failing to answer are eliminated. The show ends when only JOE remains (we assume that JOE never answers a question wrong!).
For each question JOE answers, if there are s (s > 0) opponents remaining and t (0 ≤ t ≤ s) of them make a mistake on it, JOE receives \displaystylet/s dollars, and consequently there will be s - t opponents left for the next question.
JOE wonders what is the maximum possible reward he can receive in the best possible scenario. Yet he has little time before show starts, so can you help him answering it instead?
Input
The first and single line contains a single integer n (1 ≤ n ≤ 10^5), denoting the number of JOE's opponents in the show.
Output
Print a number denoting the maximum prize (in dollars) JOE could have.
Your answer will be considered correct if it's absolute or relative error won't exceed 10^{-4}. In other words, if your answer is a and the jury answer is b, then it must hold that (|a - b|)/(max(1, b)) ≤ 10^{-4}.
Examples
Input
1
Output
1.000000000000
Input
2
Output
1.500000000000
Note
In the second example, the best scenario would be: one contestant fails at the first question, the other fails at the next one. The total reward will be \displaystyle 1/2 + 1/1 = 1.5 dollars.
Tags: combinatorics, greedy, math
Correct Solution:
```
n = int(input())
SUM = 0
for i in range(n, 0, -1):
SUM += 1/i
print(SUM)
```
| 22,976 | [
0.43701171875,
0.0031986236572265625,
-0.2470703125,
0.81298828125,
-0.57763671875,
-0.95751953125,
0.093505859375,
0.19384765625,
0.1474609375,
0.8134765625,
0.6923828125,
0.217041015625,
0.394287109375,
-0.423095703125,
-0.44140625,
-0.2039794921875,
-0.6669921875,
-0.7900390625,... | 11 |
Provide tags and a correct Python 3 solution for this coding contest problem.
[3R2 - Standby for Action](https://www.youtube.com/watch?v=P2ZVC9aoiKo)
Our dear Cafe's owner, JOE Miller, will soon take part in a new game TV-show "1 vs. n"!
The game goes in rounds, where in each round the host asks JOE and his opponents a common question. All participants failing to answer are eliminated. The show ends when only JOE remains (we assume that JOE never answers a question wrong!).
For each question JOE answers, if there are s (s > 0) opponents remaining and t (0 ≤ t ≤ s) of them make a mistake on it, JOE receives \displaystylet/s dollars, and consequently there will be s - t opponents left for the next question.
JOE wonders what is the maximum possible reward he can receive in the best possible scenario. Yet he has little time before show starts, so can you help him answering it instead?
Input
The first and single line contains a single integer n (1 ≤ n ≤ 10^5), denoting the number of JOE's opponents in the show.
Output
Print a number denoting the maximum prize (in dollars) JOE could have.
Your answer will be considered correct if it's absolute or relative error won't exceed 10^{-4}. In other words, if your answer is a and the jury answer is b, then it must hold that (|a - b|)/(max(1, b)) ≤ 10^{-4}.
Examples
Input
1
Output
1.000000000000
Input
2
Output
1.500000000000
Note
In the second example, the best scenario would be: one contestant fails at the first question, the other fails at the next one. The total reward will be \displaystyle 1/2 + 1/1 = 1.5 dollars.
Tags: combinatorics, greedy, math
Correct Solution:
```
n = int(input())
ans = sum([1/i for i in range(1,n+1)])
print(ans)
```
| 22,979 | [
0.4404296875,
0.003986358642578125,
-0.255859375,
0.80224609375,
-0.59375,
-0.96826171875,
0.078857421875,
0.1763916015625,
0.15087890625,
0.83251953125,
0.68212890625,
0.197998046875,
0.399658203125,
-0.432861328125,
-0.43212890625,
-0.2266845703125,
-0.65283203125,
-0.79150390625... | 11 |
Provide tags and a correct Python 3 solution for this coding contest problem.
[3R2 - Standby for Action](https://www.youtube.com/watch?v=P2ZVC9aoiKo)
Our dear Cafe's owner, JOE Miller, will soon take part in a new game TV-show "1 vs. n"!
The game goes in rounds, where in each round the host asks JOE and his opponents a common question. All participants failing to answer are eliminated. The show ends when only JOE remains (we assume that JOE never answers a question wrong!).
For each question JOE answers, if there are s (s > 0) opponents remaining and t (0 ≤ t ≤ s) of them make a mistake on it, JOE receives \displaystylet/s dollars, and consequently there will be s - t opponents left for the next question.
JOE wonders what is the maximum possible reward he can receive in the best possible scenario. Yet he has little time before show starts, so can you help him answering it instead?
Input
The first and single line contains a single integer n (1 ≤ n ≤ 10^5), denoting the number of JOE's opponents in the show.
Output
Print a number denoting the maximum prize (in dollars) JOE could have.
Your answer will be considered correct if it's absolute or relative error won't exceed 10^{-4}. In other words, if your answer is a and the jury answer is b, then it must hold that (|a - b|)/(max(1, b)) ≤ 10^{-4}.
Examples
Input
1
Output
1.000000000000
Input
2
Output
1.500000000000
Note
In the second example, the best scenario would be: one contestant fails at the first question, the other fails at the next one. The total reward will be \displaystyle 1/2 + 1/1 = 1.5 dollars.
Tags: combinatorics, greedy, math
Correct Solution:
```
n=int(input())
i=n
sum=0.000000000000
for _ in range(n):
sum=sum+(1/i)
i=i-1
print(sum)
```
| 22,982 | [
0.44482421875,
-0.01568603515625,
-0.2469482421875,
0.8076171875,
-0.56103515625,
-0.94189453125,
0.104736328125,
0.1849365234375,
0.1390380859375,
0.80859375,
0.6953125,
0.20263671875,
0.378662109375,
-0.448486328125,
-0.4638671875,
-0.2152099609375,
-0.6904296875,
-0.78759765625,... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
[3R2 - Standby for Action](https://www.youtube.com/watch?v=P2ZVC9aoiKo)
Our dear Cafe's owner, JOE Miller, will soon take part in a new game TV-show "1 vs. n"!
The game goes in rounds, where in each round the host asks JOE and his opponents a common question. All participants failing to answer are eliminated. The show ends when only JOE remains (we assume that JOE never answers a question wrong!).
For each question JOE answers, if there are s (s > 0) opponents remaining and t (0 ≤ t ≤ s) of them make a mistake on it, JOE receives \displaystylet/s dollars, and consequently there will be s - t opponents left for the next question.
JOE wonders what is the maximum possible reward he can receive in the best possible scenario. Yet he has little time before show starts, so can you help him answering it instead?
Input
The first and single line contains a single integer n (1 ≤ n ≤ 10^5), denoting the number of JOE's opponents in the show.
Output
Print a number denoting the maximum prize (in dollars) JOE could have.
Your answer will be considered correct if it's absolute or relative error won't exceed 10^{-4}. In other words, if your answer is a and the jury answer is b, then it must hold that (|a - b|)/(max(1, b)) ≤ 10^{-4}.
Examples
Input
1
Output
1.000000000000
Input
2
Output
1.500000000000
Note
In the second example, the best scenario would be: one contestant fails at the first question, the other fails at the next one. The total reward will be \displaystyle 1/2 + 1/1 = 1.5 dollars.
Submitted Solution:
```
n = int(input())
l = [1 / i for i in range(1, n + 1)]
print(sum(l))
```
Yes
| 22,984 | [
0.525390625,
0.1251220703125,
-0.412353515625,
0.62841796875,
-0.640625,
-0.78466796875,
0.08673095703125,
0.404541015625,
0.06756591796875,
0.7685546875,
0.6025390625,
0.158935546875,
0.39208984375,
-0.548828125,
-0.484130859375,
-0.3173828125,
-0.6181640625,
-0.6806640625,
-0.4... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
[3R2 - Standby for Action](https://www.youtube.com/watch?v=P2ZVC9aoiKo)
Our dear Cafe's owner, JOE Miller, will soon take part in a new game TV-show "1 vs. n"!
The game goes in rounds, where in each round the host asks JOE and his opponents a common question. All participants failing to answer are eliminated. The show ends when only JOE remains (we assume that JOE never answers a question wrong!).
For each question JOE answers, if there are s (s > 0) opponents remaining and t (0 ≤ t ≤ s) of them make a mistake on it, JOE receives \displaystylet/s dollars, and consequently there will be s - t opponents left for the next question.
JOE wonders what is the maximum possible reward he can receive in the best possible scenario. Yet he has little time before show starts, so can you help him answering it instead?
Input
The first and single line contains a single integer n (1 ≤ n ≤ 10^5), denoting the number of JOE's opponents in the show.
Output
Print a number denoting the maximum prize (in dollars) JOE could have.
Your answer will be considered correct if it's absolute or relative error won't exceed 10^{-4}. In other words, if your answer is a and the jury answer is b, then it must hold that (|a - b|)/(max(1, b)) ≤ 10^{-4}.
Examples
Input
1
Output
1.000000000000
Input
2
Output
1.500000000000
Note
In the second example, the best scenario would be: one contestant fails at the first question, the other fails at the next one. The total reward will be \displaystyle 1/2 + 1/1 = 1.5 dollars.
Submitted Solution:
```
n=int(input())
sm=0
for i in range(n):
sm+=(1/(i+1))
print("%.12f"%sm)
```
Yes
| 22,985 | [
0.51953125,
0.126953125,
-0.410888671875,
0.6474609375,
-0.6474609375,
-0.78955078125,
0.09326171875,
0.394287109375,
0.036529541015625,
0.77685546875,
0.59130859375,
0.15625,
0.39208984375,
-0.57373046875,
-0.468994140625,
-0.31494140625,
-0.5908203125,
-0.669921875,
-0.39038085... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
[3R2 - Standby for Action](https://www.youtube.com/watch?v=P2ZVC9aoiKo)
Our dear Cafe's owner, JOE Miller, will soon take part in a new game TV-show "1 vs. n"!
The game goes in rounds, where in each round the host asks JOE and his opponents a common question. All participants failing to answer are eliminated. The show ends when only JOE remains (we assume that JOE never answers a question wrong!).
For each question JOE answers, if there are s (s > 0) opponents remaining and t (0 ≤ t ≤ s) of them make a mistake on it, JOE receives \displaystylet/s dollars, and consequently there will be s - t opponents left for the next question.
JOE wonders what is the maximum possible reward he can receive in the best possible scenario. Yet he has little time before show starts, so can you help him answering it instead?
Input
The first and single line contains a single integer n (1 ≤ n ≤ 10^5), denoting the number of JOE's opponents in the show.
Output
Print a number denoting the maximum prize (in dollars) JOE could have.
Your answer will be considered correct if it's absolute or relative error won't exceed 10^{-4}. In other words, if your answer is a and the jury answer is b, then it must hold that (|a - b|)/(max(1, b)) ≤ 10^{-4}.
Examples
Input
1
Output
1.000000000000
Input
2
Output
1.500000000000
Note
In the second example, the best scenario would be: one contestant fails at the first question, the other fails at the next one. The total reward will be \displaystyle 1/2 + 1/1 = 1.5 dollars.
Submitted Solution:
```
n = int(input())
s = 0
for i in range(n):
s += (1/(i+1))
print(s)
```
Yes
| 22,986 | [
0.53125,
0.1507568359375,
-0.41455078125,
0.640625,
-0.6376953125,
-0.77587890625,
0.075927734375,
0.3837890625,
0.046417236328125,
0.79248046875,
0.6044921875,
0.1461181640625,
0.388916015625,
-0.5615234375,
-0.468017578125,
-0.329833984375,
-0.61328125,
-0.6435546875,
-0.410644... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
[3R2 - Standby for Action](https://www.youtube.com/watch?v=P2ZVC9aoiKo)
Our dear Cafe's owner, JOE Miller, will soon take part in a new game TV-show "1 vs. n"!
The game goes in rounds, where in each round the host asks JOE and his opponents a common question. All participants failing to answer are eliminated. The show ends when only JOE remains (we assume that JOE never answers a question wrong!).
For each question JOE answers, if there are s (s > 0) opponents remaining and t (0 ≤ t ≤ s) of them make a mistake on it, JOE receives \displaystylet/s dollars, and consequently there will be s - t opponents left for the next question.
JOE wonders what is the maximum possible reward he can receive in the best possible scenario. Yet he has little time before show starts, so can you help him answering it instead?
Input
The first and single line contains a single integer n (1 ≤ n ≤ 10^5), denoting the number of JOE's opponents in the show.
Output
Print a number denoting the maximum prize (in dollars) JOE could have.
Your answer will be considered correct if it's absolute or relative error won't exceed 10^{-4}. In other words, if your answer is a and the jury answer is b, then it must hold that (|a - b|)/(max(1, b)) ≤ 10^{-4}.
Examples
Input
1
Output
1.000000000000
Input
2
Output
1.500000000000
Note
In the second example, the best scenario would be: one contestant fails at the first question, the other fails at the next one. The total reward will be \displaystyle 1/2 + 1/1 = 1.5 dollars.
Submitted Solution:
```
n = int(input())
ans = 0
for i in range (1,n+1):
ans+= 1.0/i
print(ans);
```
Yes
| 22,987 | [
0.53564453125,
0.1383056640625,
-0.40234375,
0.63916015625,
-0.6640625,
-0.80859375,
0.07708740234375,
0.38720703125,
0.0202789306640625,
0.80419921875,
0.5927734375,
0.156005859375,
0.37744140625,
-0.541015625,
-0.47216796875,
-0.322265625,
-0.60888671875,
-0.654296875,
-0.40039... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
[3R2 - Standby for Action](https://www.youtube.com/watch?v=P2ZVC9aoiKo)
Our dear Cafe's owner, JOE Miller, will soon take part in a new game TV-show "1 vs. n"!
The game goes in rounds, where in each round the host asks JOE and his opponents a common question. All participants failing to answer are eliminated. The show ends when only JOE remains (we assume that JOE never answers a question wrong!).
For each question JOE answers, if there are s (s > 0) opponents remaining and t (0 ≤ t ≤ s) of them make a mistake on it, JOE receives \displaystylet/s dollars, and consequently there will be s - t opponents left for the next question.
JOE wonders what is the maximum possible reward he can receive in the best possible scenario. Yet he has little time before show starts, so can you help him answering it instead?
Input
The first and single line contains a single integer n (1 ≤ n ≤ 10^5), denoting the number of JOE's opponents in the show.
Output
Print a number denoting the maximum prize (in dollars) JOE could have.
Your answer will be considered correct if it's absolute or relative error won't exceed 10^{-4}. In other words, if your answer is a and the jury answer is b, then it must hold that (|a - b|)/(max(1, b)) ≤ 10^{-4}.
Examples
Input
1
Output
1.000000000000
Input
2
Output
1.500000000000
Note
In the second example, the best scenario would be: one contestant fails at the first question, the other fails at the next one. The total reward will be \displaystyle 1/2 + 1/1 = 1.5 dollars.
Submitted Solution:
```
n=int(input())
c=1
while n>0:
n-=1
c+=n/(n+1)
print("%0.12f" %c)
```
No
| 22,988 | [
0.52099609375,
0.1492919921875,
-0.404052734375,
0.63671875,
-0.65380859375,
-0.7978515625,
0.061248779296875,
0.395751953125,
0.035003662109375,
0.775390625,
0.59423828125,
0.1533203125,
0.3994140625,
-0.564453125,
-0.4755859375,
-0.3154296875,
-0.6044921875,
-0.6630859375,
-0.4... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
[3R2 - Standby for Action](https://www.youtube.com/watch?v=P2ZVC9aoiKo)
Our dear Cafe's owner, JOE Miller, will soon take part in a new game TV-show "1 vs. n"!
The game goes in rounds, where in each round the host asks JOE and his opponents a common question. All participants failing to answer are eliminated. The show ends when only JOE remains (we assume that JOE never answers a question wrong!).
For each question JOE answers, if there are s (s > 0) opponents remaining and t (0 ≤ t ≤ s) of them make a mistake on it, JOE receives \displaystylet/s dollars, and consequently there will be s - t opponents left for the next question.
JOE wonders what is the maximum possible reward he can receive in the best possible scenario. Yet he has little time before show starts, so can you help him answering it instead?
Input
The first and single line contains a single integer n (1 ≤ n ≤ 10^5), denoting the number of JOE's opponents in the show.
Output
Print a number denoting the maximum prize (in dollars) JOE could have.
Your answer will be considered correct if it's absolute or relative error won't exceed 10^{-4}. In other words, if your answer is a and the jury answer is b, then it must hold that (|a - b|)/(max(1, b)) ≤ 10^{-4}.
Examples
Input
1
Output
1.000000000000
Input
2
Output
1.500000000000
Note
In the second example, the best scenario would be: one contestant fails at the first question, the other fails at the next one. The total reward will be \displaystyle 1/2 + 1/1 = 1.5 dollars.
Submitted Solution:
```
n = 1
ans = 0
s = n
i = 1
while s > 0:
ans += i/s
s-=i
print(ans)
```
No
| 22,989 | [
0.53759765625,
0.155517578125,
-0.383056640625,
0.63818359375,
-0.65966796875,
-0.79541015625,
0.055633544921875,
0.3798828125,
0.026885986328125,
0.7919921875,
0.59228515625,
0.164306640625,
0.388916015625,
-0.54248046875,
-0.48681640625,
-0.326904296875,
-0.595703125,
-0.63134765... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
[3R2 - Standby for Action](https://www.youtube.com/watch?v=P2ZVC9aoiKo)
Our dear Cafe's owner, JOE Miller, will soon take part in a new game TV-show "1 vs. n"!
The game goes in rounds, where in each round the host asks JOE and his opponents a common question. All participants failing to answer are eliminated. The show ends when only JOE remains (we assume that JOE never answers a question wrong!).
For each question JOE answers, if there are s (s > 0) opponents remaining and t (0 ≤ t ≤ s) of them make a mistake on it, JOE receives \displaystylet/s dollars, and consequently there will be s - t opponents left for the next question.
JOE wonders what is the maximum possible reward he can receive in the best possible scenario. Yet he has little time before show starts, so can you help him answering it instead?
Input
The first and single line contains a single integer n (1 ≤ n ≤ 10^5), denoting the number of JOE's opponents in the show.
Output
Print a number denoting the maximum prize (in dollars) JOE could have.
Your answer will be considered correct if it's absolute or relative error won't exceed 10^{-4}. In other words, if your answer is a and the jury answer is b, then it must hold that (|a - b|)/(max(1, b)) ≤ 10^{-4}.
Examples
Input
1
Output
1.000000000000
Input
2
Output
1.500000000000
Note
In the second example, the best scenario would be: one contestant fails at the first question, the other fails at the next one. The total reward will be \displaystyle 1/2 + 1/1 = 1.5 dollars.
Submitted Solution:
```
n=int(input("Enter the number of opponents of joe: "))
x=0
for i in range(1,n+1):
x+=(1/i)
print(x)
```
No
| 22,990 | [
0.51025390625,
0.1298828125,
-0.384765625,
0.6552734375,
-0.64697265625,
-0.81396484375,
0.049713134765625,
0.421875,
0.038665771484375,
0.779296875,
0.6103515625,
0.173095703125,
0.391357421875,
-0.54296875,
-0.458251953125,
-0.315185546875,
-0.60986328125,
-0.67529296875,
-0.38... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
[3R2 - Standby for Action](https://www.youtube.com/watch?v=P2ZVC9aoiKo)
Our dear Cafe's owner, JOE Miller, will soon take part in a new game TV-show "1 vs. n"!
The game goes in rounds, where in each round the host asks JOE and his opponents a common question. All participants failing to answer are eliminated. The show ends when only JOE remains (we assume that JOE never answers a question wrong!).
For each question JOE answers, if there are s (s > 0) opponents remaining and t (0 ≤ t ≤ s) of them make a mistake on it, JOE receives \displaystylet/s dollars, and consequently there will be s - t opponents left for the next question.
JOE wonders what is the maximum possible reward he can receive in the best possible scenario. Yet he has little time before show starts, so can you help him answering it instead?
Input
The first and single line contains a single integer n (1 ≤ n ≤ 10^5), denoting the number of JOE's opponents in the show.
Output
Print a number denoting the maximum prize (in dollars) JOE could have.
Your answer will be considered correct if it's absolute or relative error won't exceed 10^{-4}. In other words, if your answer is a and the jury answer is b, then it must hold that (|a - b|)/(max(1, b)) ≤ 10^{-4}.
Examples
Input
1
Output
1.000000000000
Input
2
Output
1.500000000000
Note
In the second example, the best scenario would be: one contestant fails at the first question, the other fails at the next one. The total reward will be \displaystyle 1/2 + 1/1 = 1.5 dollars.
Submitted Solution:
```
n = int(input())
ans = 0
for i in range(1, n+1):
ans += 1/i
print(i)
```
No
| 22,991 | [
0.52978515625,
0.13427734375,
-0.397216796875,
0.63671875,
-0.65478515625,
-0.7998046875,
0.079345703125,
0.385498046875,
0.03155517578125,
0.79931640625,
0.59912109375,
0.154541015625,
0.374755859375,
-0.54150390625,
-0.47607421875,
-0.318603515625,
-0.61669921875,
-0.65869140625,... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be n participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who solved the largest number of problems wins, the organizers came up with different rules.
Suppose in the first round participant A took x-th place and in the second round — y-th place. Then the total score of the participant A is sum x + y. The overall place of the participant A is the number of participants (including A) having their total score less than or equal to the total score of A. Note, that some participants may end up having a common overall place. It is also important to note, that in both the first and the second round there were no two participants tying at a common place. In other words, for every i from 1 to n exactly one participant took i-th place in first round and exactly one participant took i-th place in second round.
Right after the end of the Olympiad, Nikolay was informed that he got x-th place in first round and y-th place in the second round. Nikolay doesn't know the results of other participants, yet he wonders what is the minimum and maximum place he can take, if we consider the most favorable and unfavorable outcome for him. Please help Nikolay to find the answer to this question.
Input
The first line contains an integer t (1 ≤ t ≤ 100) — the number of test cases to solve.
Each of the following t lines contains integers n, x, y (1 ≤ n ≤ 10^9, 1 ≤ x, y ≤ n) — the number of participants in the olympiad, the place that Nikolay took in the first round and the place that Nikolay took in the second round.
Output
Print two integers — the minimum and maximum possible overall place Nikolay could take.
Examples
Input
1
5 1 3
Output
1 3
Input
1
6 3 4
Output
2 6
Note
Explanation for the first example:
Suppose there were 5 participants A-E. Let's denote Nikolay as A. The the most favorable results for Nikolay could look as follows:
<image>
However, the results of the Olympiad could also look like this:
<image>
In the first case Nikolay would have taken first place, and in the second — third place.
Submitted Solution:
```
t = int(input())
for _ in range(t):
n, x, y = list(map(int, input().split()))
a = 1
b = n
if x > y:
x, y = y, x
l, r = 1, n
while l < r:
m = (r + l) // 2
# x-(m-1) y-(m-1) n-(m-1):
if n-x > y-m:
r = m
else:
l = m+1
a = (l + r) // 2
l, r = 1, n
while l < r:
m = (l + r+1) // 2
if n - (n - x + 1) > (n - y + 1) - m:
r = m-1
else:
l = m
b = n + 1 - (l+r)//2
print(a, b)
```
Yes
| 23,000 | [
0.342529296875,
-0.2244873046875,
-0.23779296875,
0.3974609375,
-0.599609375,
-0.343505859375,
-0.0035610198974609375,
0.34423828125,
0.2303466796875,
0.75634765625,
0.892578125,
-0.2222900390625,
0.155517578125,
-0.6787109375,
-0.71728515625,
-0.031036376953125,
-0.6572265625,
-0.... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be n participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who solved the largest number of problems wins, the organizers came up with different rules.
Suppose in the first round participant A took x-th place and in the second round — y-th place. Then the total score of the participant A is sum x + y. The overall place of the participant A is the number of participants (including A) having their total score less than or equal to the total score of A. Note, that some participants may end up having a common overall place. It is also important to note, that in both the first and the second round there were no two participants tying at a common place. In other words, for every i from 1 to n exactly one participant took i-th place in first round and exactly one participant took i-th place in second round.
Right after the end of the Olympiad, Nikolay was informed that he got x-th place in first round and y-th place in the second round. Nikolay doesn't know the results of other participants, yet he wonders what is the minimum and maximum place he can take, if we consider the most favorable and unfavorable outcome for him. Please help Nikolay to find the answer to this question.
Input
The first line contains an integer t (1 ≤ t ≤ 100) — the number of test cases to solve.
Each of the following t lines contains integers n, x, y (1 ≤ n ≤ 10^9, 1 ≤ x, y ≤ n) — the number of participants in the olympiad, the place that Nikolay took in the first round and the place that Nikolay took in the second round.
Output
Print two integers — the minimum and maximum possible overall place Nikolay could take.
Examples
Input
1
5 1 3
Output
1 3
Input
1
6 3 4
Output
2 6
Note
Explanation for the first example:
Suppose there were 5 participants A-E. Let's denote Nikolay as A. The the most favorable results for Nikolay could look as follows:
<image>
However, the results of the Olympiad could also look like this:
<image>
In the first case Nikolay would have taken first place, and in the second — third place.
Submitted Solution:
```
import sys
import os
from io import BytesIO, IOBase
#########################
# imgur.com/Pkt7iIf.png #
#########################
# returns the list of prime numbers less than or equal to n:
'''def sieve(n):
if n < 2: return list()
prime = [True for _ in range(n + 1)]
p = 3
while p * p <= n:
if prime[p]:
for i in range(p * p, n + 1, p):
prime[i] = False
p += 2
r = [2]
for p in range(3, n + 1, 2):
if prime[p]:
r.append(p)
return r'''
# returns all the divisors of a number n(takes an additional parameter start):
'''def divs(n, start=1):
divisors = []
for i in range(start, int(n**.5) + 1):
if n % i == 0:
if n / i == i:
divisors.append(i)
else:
divisors.extend([i, n // i])
return len(divisors)'''
# returns the number of factors of a given number if a primes list is given:
'''def divn(n, primes):
divs_number = 1
for i in primes:
if n == 1:
return divs_number
t = 1
while n % i == 0:
t += 1
n //= i
divs_number *= t
return divs_number'''
# returns the leftmost and rightmost positions of x in a given list d(if x isnot present then returns (-1,-1)):
'''def flin(d, x, default=-1):
left = right = -1
for i in range(len(d)):
if d[i] == x:
if left == -1: left = i
right = i
if left == -1:
return (default, default)
else:
return (left, right)'''
#count xor of numbers from 1 to n:
'''def xor1_n(n):
d={0:n,1:1,2:n+1,3:0}
return d[n&3]'''
def cel(n, k): return n // k + (n % k != 0)
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(map(int, input().split()))
def lcm(a, b): return abs(a * b) // math.gcd(a, b)
def prr(a, sep=' '): print(sep.join(map(str, a)))
def dd(): return defaultdict(int)
def ddl(): return defaultdict(list)
def ddd(): return defaultdict(defaultdict(int))
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
from collections import defaultdict
#from collections import deque
#from collections import OrderedDict
#from math import gcd
#import time
#import itertools
#import timeit
#import random
#from bisect import bisect_left as bl
#from bisect import bisect_right as br
#from bisect import insort_left as il
#from bisect import insort_right as ir
#from heapq import *
#mod=998244353
#mod=10**9+7
# for counting path pass prev as argument:
# for counting level of each node w.r.t to s pass lvl instead of prev:
for _ in range(ii()):
n,x,y=mi()
w=min(n,x+y-1)
if x+y<=n:
g=1
else:
g=min(n,(x+y+1-n))
print(g,w)
```
Yes
| 23,001 | [
0.342529296875,
-0.2244873046875,
-0.23779296875,
0.3974609375,
-0.599609375,
-0.343505859375,
-0.0035610198974609375,
0.34423828125,
0.2303466796875,
0.75634765625,
0.892578125,
-0.2222900390625,
0.155517578125,
-0.6787109375,
-0.71728515625,
-0.031036376953125,
-0.6572265625,
-0.... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be n participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who solved the largest number of problems wins, the organizers came up with different rules.
Suppose in the first round participant A took x-th place and in the second round — y-th place. Then the total score of the participant A is sum x + y. The overall place of the participant A is the number of participants (including A) having their total score less than or equal to the total score of A. Note, that some participants may end up having a common overall place. It is also important to note, that in both the first and the second round there were no two participants tying at a common place. In other words, for every i from 1 to n exactly one participant took i-th place in first round and exactly one participant took i-th place in second round.
Right after the end of the Olympiad, Nikolay was informed that he got x-th place in first round and y-th place in the second round. Nikolay doesn't know the results of other participants, yet he wonders what is the minimum and maximum place he can take, if we consider the most favorable and unfavorable outcome for him. Please help Nikolay to find the answer to this question.
Input
The first line contains an integer t (1 ≤ t ≤ 100) — the number of test cases to solve.
Each of the following t lines contains integers n, x, y (1 ≤ n ≤ 10^9, 1 ≤ x, y ≤ n) — the number of participants in the olympiad, the place that Nikolay took in the first round and the place that Nikolay took in the second round.
Output
Print two integers — the minimum and maximum possible overall place Nikolay could take.
Examples
Input
1
5 1 3
Output
1 3
Input
1
6 3 4
Output
2 6
Note
Explanation for the first example:
Suppose there were 5 participants A-E. Let's denote Nikolay as A. The the most favorable results for Nikolay could look as follows:
<image>
However, the results of the Olympiad could also look like this:
<image>
In the first case Nikolay would have taken first place, and in the second — third place.
Submitted Solution:
```
import os
import sys
if os.path.exists('/mnt/c/Users/Square/square/codeforces'):
f = iter(open('B.txt').readlines())
def input():
return next(f)
# input = lambda: sys.stdin.readline().strip()
else:
input = lambda: sys.stdin.readline().strip()
fprint = lambda *args: print(*args, flush=True)
t = int(input())
for _ in range(t):
n, x, y = map(int, input().split())
r1 = n-y-1
r2 = n-x-1
# print(r1, r2)
u = min(n, max(1, n - r1 - r2 - 1))
# v = min(n, min(n-x, y-1) + min(n-y, x-1) + 1)
v = min(n, x+y-1)
print(u, v)
```
Yes
| 23,002 | [
0.342529296875,
-0.2244873046875,
-0.23779296875,
0.3974609375,
-0.599609375,
-0.343505859375,
-0.0035610198974609375,
0.34423828125,
0.2303466796875,
0.75634765625,
0.892578125,
-0.2222900390625,
0.155517578125,
-0.6787109375,
-0.71728515625,
-0.031036376953125,
-0.6572265625,
-0.... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be n participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who solved the largest number of problems wins, the organizers came up with different rules.
Suppose in the first round participant A took x-th place and in the second round — y-th place. Then the total score of the participant A is sum x + y. The overall place of the participant A is the number of participants (including A) having their total score less than or equal to the total score of A. Note, that some participants may end up having a common overall place. It is also important to note, that in both the first and the second round there were no two participants tying at a common place. In other words, for every i from 1 to n exactly one participant took i-th place in first round and exactly one participant took i-th place in second round.
Right after the end of the Olympiad, Nikolay was informed that he got x-th place in first round and y-th place in the second round. Nikolay doesn't know the results of other participants, yet he wonders what is the minimum and maximum place he can take, if we consider the most favorable and unfavorable outcome for him. Please help Nikolay to find the answer to this question.
Input
The first line contains an integer t (1 ≤ t ≤ 100) — the number of test cases to solve.
Each of the following t lines contains integers n, x, y (1 ≤ n ≤ 10^9, 1 ≤ x, y ≤ n) — the number of participants in the olympiad, the place that Nikolay took in the first round and the place that Nikolay took in the second round.
Output
Print two integers — the minimum and maximum possible overall place Nikolay could take.
Examples
Input
1
5 1 3
Output
1 3
Input
1
6 3 4
Output
2 6
Note
Explanation for the first example:
Suppose there were 5 participants A-E. Let's denote Nikolay as A. The the most favorable results for Nikolay could look as follows:
<image>
However, the results of the Olympiad could also look like this:
<image>
In the first case Nikolay would have taken first place, and in the second — third place.
Submitted Solution:
```
import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n, x, y = map(int, input().split())
if (x, y) in [(n, n), (n, n-1), (n-1, n)]:
ans0 = n
else:
ans0 = max(1, n-(n-((x+y+1)-n)))
ans1 = min(n, x+y-1)
print(ans0, ans1)
```
Yes
| 23,003 | [
0.342529296875,
-0.2244873046875,
-0.23779296875,
0.3974609375,
-0.599609375,
-0.343505859375,
-0.0035610198974609375,
0.34423828125,
0.2303466796875,
0.75634765625,
0.892578125,
-0.2222900390625,
0.155517578125,
-0.6787109375,
-0.71728515625,
-0.031036376953125,
-0.6572265625,
-0.... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be n participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who solved the largest number of problems wins, the organizers came up with different rules.
Suppose in the first round participant A took x-th place and in the second round — y-th place. Then the total score of the participant A is sum x + y. The overall place of the participant A is the number of participants (including A) having their total score less than or equal to the total score of A. Note, that some participants may end up having a common overall place. It is also important to note, that in both the first and the second round there were no two participants tying at a common place. In other words, for every i from 1 to n exactly one participant took i-th place in first round and exactly one participant took i-th place in second round.
Right after the end of the Olympiad, Nikolay was informed that he got x-th place in first round and y-th place in the second round. Nikolay doesn't know the results of other participants, yet he wonders what is the minimum and maximum place he can take, if we consider the most favorable and unfavorable outcome for him. Please help Nikolay to find the answer to this question.
Input
The first line contains an integer t (1 ≤ t ≤ 100) — the number of test cases to solve.
Each of the following t lines contains integers n, x, y (1 ≤ n ≤ 10^9, 1 ≤ x, y ≤ n) — the number of participants in the olympiad, the place that Nikolay took in the first round and the place that Nikolay took in the second round.
Output
Print two integers — the minimum and maximum possible overall place Nikolay could take.
Examples
Input
1
5 1 3
Output
1 3
Input
1
6 3 4
Output
2 6
Note
Explanation for the first example:
Suppose there were 5 participants A-E. Let's denote Nikolay as A. The the most favorable results for Nikolay could look as follows:
<image>
However, the results of the Olympiad could also look like this:
<image>
In the first case Nikolay would have taken first place, and in the second — third place.
Submitted Solution:
```
t = int(input())
for i in range(t):
n,x,y = list(map(int,input().split()))
if x+y < n+1:
minimum = 1
elif n+1 <= x+y:
minimum = x+y-n+1
print(minimum,min(x+y-1,n))
```
No
| 23,004 | [
0.342529296875,
-0.2244873046875,
-0.23779296875,
0.3974609375,
-0.599609375,
-0.343505859375,
-0.0035610198974609375,
0.34423828125,
0.2303466796875,
0.75634765625,
0.892578125,
-0.2222900390625,
0.155517578125,
-0.6787109375,
-0.71728515625,
-0.031036376953125,
-0.6572265625,
-0.... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be n participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who solved the largest number of problems wins, the organizers came up with different rules.
Suppose in the first round participant A took x-th place and in the second round — y-th place. Then the total score of the participant A is sum x + y. The overall place of the participant A is the number of participants (including A) having their total score less than or equal to the total score of A. Note, that some participants may end up having a common overall place. It is also important to note, that in both the first and the second round there were no two participants tying at a common place. In other words, for every i from 1 to n exactly one participant took i-th place in first round and exactly one participant took i-th place in second round.
Right after the end of the Olympiad, Nikolay was informed that he got x-th place in first round and y-th place in the second round. Nikolay doesn't know the results of other participants, yet he wonders what is the minimum and maximum place he can take, if we consider the most favorable and unfavorable outcome for him. Please help Nikolay to find the answer to this question.
Input
The first line contains an integer t (1 ≤ t ≤ 100) — the number of test cases to solve.
Each of the following t lines contains integers n, x, y (1 ≤ n ≤ 10^9, 1 ≤ x, y ≤ n) — the number of participants in the olympiad, the place that Nikolay took in the first round and the place that Nikolay took in the second round.
Output
Print two integers — the minimum and maximum possible overall place Nikolay could take.
Examples
Input
1
5 1 3
Output
1 3
Input
1
6 3 4
Output
2 6
Note
Explanation for the first example:
Suppose there were 5 participants A-E. Let's denote Nikolay as A. The the most favorable results for Nikolay could look as follows:
<image>
However, the results of the Olympiad could also look like this:
<image>
In the first case Nikolay would have taken first place, and in the second — third place.
Submitted Solution:
```
import os
import sys
if os.path.exists('/mnt/c/Users/Square/square/codeforces'):
f = iter(open('B.txt').readlines())
def input():
return next(f)
# input = lambda: sys.stdin.readline().strip()
else:
input = lambda: sys.stdin.readline().strip()
fprint = lambda *args: print(*args, flush=True)
t = int(input())
for _ in range(t):
n, x, y = map(int, input().split())
r1 = max(min(n-y, x-2), min(n-y-1, x-1))
r2 = max(min(n-x, y-2), min(n-x-1, y-1))
# print(r1, r2)
u = min(n, max(1, x+y-2 - (r1+r2)))
# v = min(n, min(n-x, y-1) + min(n-y, x-1) + 1)
v = min(n, x+y-1)
print(u, v)
```
No
| 23,005 | [
0.342529296875,
-0.2244873046875,
-0.23779296875,
0.3974609375,
-0.599609375,
-0.343505859375,
-0.0035610198974609375,
0.34423828125,
0.2303466796875,
0.75634765625,
0.892578125,
-0.2222900390625,
0.155517578125,
-0.6787109375,
-0.71728515625,
-0.031036376953125,
-0.6572265625,
-0.... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be n participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who solved the largest number of problems wins, the organizers came up with different rules.
Suppose in the first round participant A took x-th place and in the second round — y-th place. Then the total score of the participant A is sum x + y. The overall place of the participant A is the number of participants (including A) having their total score less than or equal to the total score of A. Note, that some participants may end up having a common overall place. It is also important to note, that in both the first and the second round there were no two participants tying at a common place. In other words, for every i from 1 to n exactly one participant took i-th place in first round and exactly one participant took i-th place in second round.
Right after the end of the Olympiad, Nikolay was informed that he got x-th place in first round and y-th place in the second round. Nikolay doesn't know the results of other participants, yet he wonders what is the minimum and maximum place he can take, if we consider the most favorable and unfavorable outcome for him. Please help Nikolay to find the answer to this question.
Input
The first line contains an integer t (1 ≤ t ≤ 100) — the number of test cases to solve.
Each of the following t lines contains integers n, x, y (1 ≤ n ≤ 10^9, 1 ≤ x, y ≤ n) — the number of participants in the olympiad, the place that Nikolay took in the first round and the place that Nikolay took in the second round.
Output
Print two integers — the minimum and maximum possible overall place Nikolay could take.
Examples
Input
1
5 1 3
Output
1 3
Input
1
6 3 4
Output
2 6
Note
Explanation for the first example:
Suppose there were 5 participants A-E. Let's denote Nikolay as A. The the most favorable results for Nikolay could look as follows:
<image>
However, the results of the Olympiad could also look like this:
<image>
In the first case Nikolay would have taken first place, and in the second — third place.
Submitted Solution:
```
for t in range(int(input())):
n,x,y = [int(j) for j in input().split()]
mx = int(x+y-1)
mn = max((x+y)-n+1, 1)
print(mn, mx)
```
No
| 23,006 | [
0.342529296875,
-0.2244873046875,
-0.23779296875,
0.3974609375,
-0.599609375,
-0.343505859375,
-0.0035610198974609375,
0.34423828125,
0.2303466796875,
0.75634765625,
0.892578125,
-0.2222900390625,
0.155517578125,
-0.6787109375,
-0.71728515625,
-0.031036376953125,
-0.6572265625,
-0.... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be n participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who solved the largest number of problems wins, the organizers came up with different rules.
Suppose in the first round participant A took x-th place and in the second round — y-th place. Then the total score of the participant A is sum x + y. The overall place of the participant A is the number of participants (including A) having their total score less than or equal to the total score of A. Note, that some participants may end up having a common overall place. It is also important to note, that in both the first and the second round there were no two participants tying at a common place. In other words, for every i from 1 to n exactly one participant took i-th place in first round and exactly one participant took i-th place in second round.
Right after the end of the Olympiad, Nikolay was informed that he got x-th place in first round and y-th place in the second round. Nikolay doesn't know the results of other participants, yet he wonders what is the minimum and maximum place he can take, if we consider the most favorable and unfavorable outcome for him. Please help Nikolay to find the answer to this question.
Input
The first line contains an integer t (1 ≤ t ≤ 100) — the number of test cases to solve.
Each of the following t lines contains integers n, x, y (1 ≤ n ≤ 10^9, 1 ≤ x, y ≤ n) — the number of participants in the olympiad, the place that Nikolay took in the first round and the place that Nikolay took in the second round.
Output
Print two integers — the minimum and maximum possible overall place Nikolay could take.
Examples
Input
1
5 1 3
Output
1 3
Input
1
6 3 4
Output
2 6
Note
Explanation for the first example:
Suppose there were 5 participants A-E. Let's denote Nikolay as A. The the most favorable results for Nikolay could look as follows:
<image>
However, the results of the Olympiad could also look like this:
<image>
In the first case Nikolay would have taken first place, and in the second — third place.
Submitted Solution:
```
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------- fast io --------------------
for j in range(int(input())):
n,x,y=map(int,input().split());score=x+y;min1=0;max1=0
if score==n+1:
if n!=1:
print(2,n)
else:
print(1,1)
else:
if score<n+1:
p2=score
if score-x>0 and score-x<=n:
p2-=1
if score-y>0 and score-y<=n and score-y!=x:
p2-=1
print(1,p2)
else:
v0=score+1;p1=n-(v0-n-1)
if v0-x>0 and v0-x<=n:
p1-=1
if v0-y>0 and v0-y<=n and v0-y!=v0-x and v0-y!=x:
p1-=1
print(n-p1,n)
```
No
| 23,007 | [
0.342529296875,
-0.2244873046875,
-0.23779296875,
0.3974609375,
-0.599609375,
-0.343505859375,
-0.0035610198974609375,
0.34423828125,
0.2303466796875,
0.75634765625,
0.892578125,
-0.2222900390625,
0.155517578125,
-0.6787109375,
-0.71728515625,
-0.031036376953125,
-0.6572265625,
-0.... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Problem
There are $ N $ Amidakuji with 3 vertical lines.
No matter which line you start from, the Amidakuji that ends at the starting line is considered a good Amidakuji.
You can select one or more Amidakuji and connect them vertically in any order.
Output "yes" if you can make a good Amidakuji, otherwise output "no".
There are $ w_i $ horizontal lines in the $ i $ th Amidakuji.
$ a_ {i, j} $ indicates whether the $ j $ th horizontal bar from the top of Amidakuji $ i $ extends from the central vertical line to the left or right.
If $ a_ {i, j} $ is 0, it means that it extends to the left, and if it is 1, it means that it extends to the right.
Constraints
The input satisfies the following conditions.
* $ 1 \ le N \ le 50 $
* $ 0 \ le w_i \ le 100 $
* $ a_ {i, j} $ is 0 or 1
Input
The input is given in the following format.
$ N $
$ w_1 $ $ a_ {1,1} $ $ a_ {1,2} $ ... $ a_ {1, w_1} $
$ w_2 $ $ a_ {2,1} $ $ a_ {2,2} $ ... $ a_ {2, w_2} $
...
$ w_N $ $ a_ {N, 1} $ $ a_ {N, 2} $ ... $ a_ {N, w_N} $
All inputs are given as integers.
$ N $ is given on the first line.
$ W_i $ and $ w_i $ $ a_ {i, j} $ are given on the following $ N $ line, separated by blanks.
Output
If you can make a good Amidakuji, it outputs "yes", otherwise it outputs "no".
Examples
Input
3
2 0 0
1 1
5 1 0 0 1 0
Output
yes
Input
2
1 1
1 0
Output
no
Submitted Solution:
```
N = int(input())
C = [0]*6
S = [[0, 1, 2], [0, 2, 1], [1, 0, 2], [1, 2, 0], [2, 0, 1], [2, 1, 0]]
L = [1, 2, 2, 3, 3, 2]
P = []
init = [0, 1, 2]
for i in range(N):
w, *A = map(int, input().split())
state = init[:]
for a in A:
if a:
state[1], state[2] = state[2], state[1]
else:
state[0], state[1] = state[1], state[0]
j = S.index(state)
C[j] += 1
if C[j] >= L[j]:
print('yes')
exit(0)
P.append(state)
# case: "L <= [0, 1, 1, 2, 2, 1]"
from itertools import permutations
for p in permutations(P):
s = init[:]
for q in p:
s[0], s[1], s[2] = s[q[0]], s[q[1]], s[q[2]]
if s == init:
print('yes')
exit(0)
print(s)
print('no')
```
No
| 23,798 | [
0.06402587890625,
0.1719970703125,
-0.1937255859375,
0.1951904296875,
-0.8857421875,
-0.6162109375,
-0.0088653564453125,
0.473876953125,
0.30126953125,
1.181640625,
0.131591796875,
0.400634765625,
-0.1065673828125,
-0.67041015625,
-0.55712890625,
0.034881591796875,
-0.541015625,
-0... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given $n$ packages of $w_i$ kg from a belt conveyor in order ($i = 0, 1, ... n-1$). You should load all packages onto $k$ trucks which have the common maximum load $P$. Each truck can load consecutive packages (more than or equals to zero) from the belt conveyor unless the total weights of the packages in the sequence does not exceed the maximum load $P$.
Write a program which reads $n$, $k$ and $w_i$, and reports the minimum value of the maximum load $P$ to load all packages from the belt conveyor.
Constraints
* $1 \leq n \leq 100,000$
* $1 \leq k \leq 100,000$
* $1 \leq w_i \leq 10,000$
Input
In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.
Output
Print the minimum value of $P$ in a line.
Examples
Input
5 3
8
1
7
3
9
Output
10
Input
4 2
1
2
2
6
Output
6
Submitted Solution:
```
#!/usr/bin/env python3
import sys,collections
n,k = map(int,sys.stdin.readline().split())
w = list(map(int,sys.stdin.readlines()))
ng = sum(w)//k-1
ok = sum(w)
def isOK(p):
j = 0
for i in range(k):
s = 0
while j < n and s + w[j] <= p:
s += w[j]
j += 1
return j == n
while ok - ng > 1:
mid = (ok+ng)//2
t = collections.Counter(w)
if isOK(mid):
ok = mid
else:
ng = mid
print(ok)
```
Yes
| 23,807 | [
0.400634765625,
0.2034912109375,
-0.0189361572265625,
0.51708984375,
-0.81396484375,
-0.2291259765625,
-0.27001953125,
0.0975341796875,
0.0195465087890625,
0.83251953125,
0.3671875,
0.007686614990234375,
0.4921875,
-0.73193359375,
-0.424560546875,
0.55126953125,
-0.57958984375,
-0.... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given $n$ packages of $w_i$ kg from a belt conveyor in order ($i = 0, 1, ... n-1$). You should load all packages onto $k$ trucks which have the common maximum load $P$. Each truck can load consecutive packages (more than or equals to zero) from the belt conveyor unless the total weights of the packages in the sequence does not exceed the maximum load $P$.
Write a program which reads $n$, $k$ and $w_i$, and reports the minimum value of the maximum load $P$ to load all packages from the belt conveyor.
Constraints
* $1 \leq n \leq 100,000$
* $1 \leq k \leq 100,000$
* $1 \leq w_i \leq 10,000$
Input
In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.
Output
Print the minimum value of $P$ in a line.
Examples
Input
5 3
8
1
7
3
9
Output
10
Input
4 2
1
2
2
6
Output
6
Submitted Solution:
```
#17D8104026C 宮地拓海 Air_conditioner123 Python
def check(mid):
global k, T, n
i = 0
for j in range(k):
s = 0
while s + T[i] <= mid:
s += T[i]
i += 1
if (i == n):
return n
return i
n, k = map(int, input().split())
T = [int(input()) for i in range(n)]
left = 0
right = 100000 * 10000
while right - left > 1:
mid = (left + right) // 2
v = check(mid)
if (v >= n):
right = mid
else:
left = mid
print(right)
```
Yes
| 23,808 | [
0.3564453125,
0.11767578125,
-0.050079345703125,
0.5625,
-0.81201171875,
-0.25048828125,
-0.2025146484375,
0.09613037109375,
0.0679931640625,
0.861328125,
0.408447265625,
0.02947998046875,
0.435791015625,
-0.79931640625,
-0.39208984375,
0.45068359375,
-0.48876953125,
-0.8759765625,... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given $n$ packages of $w_i$ kg from a belt conveyor in order ($i = 0, 1, ... n-1$). You should load all packages onto $k$ trucks which have the common maximum load $P$. Each truck can load consecutive packages (more than or equals to zero) from the belt conveyor unless the total weights of the packages in the sequence does not exceed the maximum load $P$.
Write a program which reads $n$, $k$ and $w_i$, and reports the minimum value of the maximum load $P$ to load all packages from the belt conveyor.
Constraints
* $1 \leq n \leq 100,000$
* $1 \leq k \leq 100,000$
* $1 \leq w_i \leq 10,000$
Input
In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.
Output
Print the minimum value of $P$ in a line.
Examples
Input
5 3
8
1
7
3
9
Output
10
Input
4 2
1
2
2
6
Output
6
Submitted Solution:
```
#Pの時に必要なトラックの数を求める関数
def unit_check(n, k, w_list, P):
i = 0
for j in range(k):
weight = 0
while weight + w_list[i] <= P:
weight += w_list[i]
i += 1
if i == n:
return 1
return 0
n, k = map(int,input().split())
w_list = [0] * n
for i in range(n):
w_list[i] = int(input())
left = 0
#荷物の最大数x荷物の最大の重さ
right = 100000*10000
while left+1 < right:
mid = (left+ right)//2
check = unit_check(n, k, w_list, mid)
if check == 1:
right = mid
else:
left = mid
print(right)
```
Yes
| 23,809 | [
0.328125,
0.12225341796875,
0.005977630615234375,
0.476318359375,
-0.8203125,
-0.2066650390625,
-0.241943359375,
0.1717529296875,
0.012725830078125,
0.86181640625,
0.384765625,
0.0469970703125,
0.449951171875,
-0.82958984375,
-0.42919921875,
0.50341796875,
-0.5048828125,
-0.9365234... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given $n$ packages of $w_i$ kg from a belt conveyor in order ($i = 0, 1, ... n-1$). You should load all packages onto $k$ trucks which have the common maximum load $P$. Each truck can load consecutive packages (more than or equals to zero) from the belt conveyor unless the total weights of the packages in the sequence does not exceed the maximum load $P$.
Write a program which reads $n$, $k$ and $w_i$, and reports the minimum value of the maximum load $P$ to load all packages from the belt conveyor.
Constraints
* $1 \leq n \leq 100,000$
* $1 \leq k \leq 100,000$
* $1 \leq w_i \leq 10,000$
Input
In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.
Output
Print the minimum value of $P$ in a line.
Examples
Input
5 3
8
1
7
3
9
Output
10
Input
4 2
1
2
2
6
Output
6
Submitted Solution:
```
import math
n, k = map(int, input().split())
w = [int(input()) for _ in range(n)]
wsum = sum(w)
def loadable(w, n, k, p, wsum):
wait = 0
for i in range(n):
wait += w[i]
wsum -= w[i]
if wait > p:
k -= 1
wait = w[i]
if k == 0:
return False
return True
P = max(int(math.ceil(wsum / k)), max(w))
while not loadable(w, n, k, P, wsum):
P += 1
print(P)
```
No
| 23,812 | [
0.3173828125,
0.24658203125,
0.015960693359375,
0.60888671875,
-0.78564453125,
-0.271728515625,
-0.24072265625,
0.081298828125,
-0.037139892578125,
0.84765625,
0.418212890625,
0.020355224609375,
0.51318359375,
-0.79443359375,
-0.40625,
0.429443359375,
-0.52294921875,
-0.9482421875,... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given $n$ packages of $w_i$ kg from a belt conveyor in order ($i = 0, 1, ... n-1$). You should load all packages onto $k$ trucks which have the common maximum load $P$. Each truck can load consecutive packages (more than or equals to zero) from the belt conveyor unless the total weights of the packages in the sequence does not exceed the maximum load $P$.
Write a program which reads $n$, $k$ and $w_i$, and reports the minimum value of the maximum load $P$ to load all packages from the belt conveyor.
Constraints
* $1 \leq n \leq 100,000$
* $1 \leq k \leq 100,000$
* $1 \leq w_i \leq 10,000$
Input
In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.
Output
Print the minimum value of $P$ in a line.
Examples
Input
5 3
8
1
7
3
9
Output
10
Input
4 2
1
2
2
6
Output
6
Submitted Solution:
```
def check(P):
for i, bag in enumerate(baggage):
cur = 0
while su(cur) + bag > P:
cur += 1
if cur == k:
return False
else:
lis[cur].append(bag)
su[cur] += bag
return True
def main():
n, k = map(int, input().rstrip().split(" "))
lis = [[] for i in range(k)]
su = [0 for i in range(k)]
baggage = [int(input()) for i in range(n)]
su.append(-1)
left = 1
right = 1000000000
while left < right:
mid = (left + right)//2 + 1
if check(mid):
right = mid
else:
left = mid
print(right)
```
No
| 23,813 | [
0.361328125,
0.049285888671875,
0.07275390625,
0.56884765625,
-0.810546875,
-0.1356201171875,
-0.26220703125,
0.13671875,
0.02325439453125,
0.8310546875,
0.452392578125,
0.0218505859375,
0.55810546875,
-0.763671875,
-0.52294921875,
0.501953125,
-0.56494140625,
-0.87109375,
-0.646... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given $n$ packages of $w_i$ kg from a belt conveyor in order ($i = 0, 1, ... n-1$). You should load all packages onto $k$ trucks which have the common maximum load $P$. Each truck can load consecutive packages (more than or equals to zero) from the belt conveyor unless the total weights of the packages in the sequence does not exceed the maximum load $P$.
Write a program which reads $n$, $k$ and $w_i$, and reports the minimum value of the maximum load $P$ to load all packages from the belt conveyor.
Constraints
* $1 \leq n \leq 100,000$
* $1 \leq k \leq 100,000$
* $1 \leq w_i \leq 10,000$
Input
In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.
Output
Print the minimum value of $P$ in a line.
Examples
Input
5 3
8
1
7
3
9
Output
10
Input
4 2
1
2
2
6
Output
6
Submitted Solution:
```
from collections import deque
def isPa(w,k,p):
tr = 0
c = 0
d = deque(w)
while(d):
tmp = d.popleft()
if(tmp > p):
return False
if( tr + tmp > p):
tr = tmp
c += 1
else:
tr += tmp
if c+1>k:
return False
return True
def MaxInP(w,k,p):
maxinp = 0
tmp = 0
d = deque(w)
while(d):
tmp += d.popleft();
if(tmp > p):
if(tmp > maxinp):
maxinp = tmp
tmp = 0
return maxinp
n,k = [int(x) for x in input().split()]
w = deque()
for i in range(n):
w.append(int(input()))
mean = int(sum(w)/k)
maxinp = MaxInP(w,k,mean)
l = range(mean,maxinp)
if k == 1:
print(mean)
else:
minP = mean
maxP = maxinp
while(True):
m = int ((minP + maxP)/2)
if ( isPa(w,k,m) ):
maxP = m
else:
minP = m
if (minP+1 == maxP):
print(maxP)
break
```
No
| 23,814 | [
0.406005859375,
0.17041015625,
0.09283447265625,
0.5791015625,
-0.81640625,
-0.08050537109375,
-0.280517578125,
0.033355712890625,
0.0660400390625,
0.86279296875,
0.395751953125,
0.1265869140625,
0.359130859375,
-0.69384765625,
-0.38525390625,
0.69091796875,
-0.436279296875,
-0.926... | 11 |
Provide tags and a correct Python 3 solution for this coding contest problem.
"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules.
A total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.
Input
The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space.
The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).
Output
Output the number of participants who advance to the next round.
Examples
Input
8 5
10 9 8 7 7 7 5 5
Output
6
Input
4 2
0 0 0 0
Output
0
Note
In the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.
In the second example nobody got a positive score.
Tags: *special, implementation
Correct Solution:
```
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=k
if a[k-1]>0:
for i in range(k,n):
if a[i]==a[i-1]: ans+=1
else: break
else:
ans=0
for i in range(0,k):
if a[i]>0: ans+=1
else: break
print(ans)
```
| 24,064 | [
0.186279296875,
0.22607421875,
-0.481201171875,
0.1214599609375,
-0.305419921875,
-0.4921875,
-0.348388671875,
0.27880859375,
0.10809326171875,
0.81298828125,
0.443115234375,
0.107177734375,
-0.123291015625,
-0.7138671875,
-0.267578125,
-0.1053466796875,
-0.6259765625,
-1.174804687... | 11 |
Provide tags and a correct Python 3 solution for this coding contest problem.
"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules.
A total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.
Input
The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space.
The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).
Output
Output the number of participants who advance to the next round.
Examples
Input
8 5
10 9 8 7 7 7 5 5
Output
6
Input
4 2
0 0 0 0
Output
0
Note
In the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.
In the second example nobody got a positive score.
Tags: *special, implementation
Correct Solution:
```
n, k = map(int, input().split())
arr = list(map(int, input().split()))
count = 0
for i in range(len(arr)):
if(arr[i] >= arr[k-1] and arr[i] > 0):
count += 1
print(count)
```
| 24,065 | [
0.2406005859375,
0.2451171875,
-0.50830078125,
0.146484375,
-0.260986328125,
-0.475830078125,
-0.384521484375,
0.3134765625,
0.08453369140625,
0.82568359375,
0.47900390625,
0.07342529296875,
-0.08978271484375,
-0.70068359375,
-0.26611328125,
-0.11480712890625,
-0.64599609375,
-1.11... | 11 |
Provide tags and a correct Python 3 solution for this coding contest problem.
"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules.
A total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.
Input
The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space.
The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).
Output
Output the number of participants who advance to the next round.
Examples
Input
8 5
10 9 8 7 7 7 5 5
Output
6
Input
4 2
0 0 0 0
Output
0
Note
In the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.
In the second example nobody got a positive score.
Tags: *special, implementation
Correct Solution:
```
# import sys
# sys.stdin = open("test.in","r")
# sys.stdout = open("test.out","w")
a,b=map(int,input().split())
c=list(map(int,input().split()))
d=c[b-1]
count=0
for i in range(a):
if c[i]>=d and c[i]>0:
count+=1
if c[i]<d or c[i]==0:
break
print(count)
```
| 24,066 | [
0.210693359375,
0.1973876953125,
-0.428466796875,
0.1544189453125,
-0.31982421875,
-0.41748046875,
-0.41796875,
0.28857421875,
0.060791015625,
0.7783203125,
0.343994140625,
0.07867431640625,
-0.09857177734375,
-0.6748046875,
-0.26171875,
-0.143310546875,
-0.65087890625,
-1.15527343... | 11 |
Provide tags and a correct Python 3 solution for this coding contest problem.
"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules.
A total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.
Input
The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space.
The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).
Output
Output the number of participants who advance to the next round.
Examples
Input
8 5
10 9 8 7 7 7 5 5
Output
6
Input
4 2
0 0 0 0
Output
0
Note
In the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.
In the second example nobody got a positive score.
Tags: *special, implementation
Correct Solution:
```
n,k=map(int,input().split())
arr=list(map(int,input().split()))
k=arr[k-1]
i=0
if(k<=0):
while(i<len(arr) and arr[i]>k and arr[i]>0):
i+=1
print(i)
else:
while(i<len(arr) and arr[i]>=k):
i+=1
print(i)
```
| 24,067 | [
0.2296142578125,
0.2783203125,
-0.51611328125,
0.12213134765625,
-0.283447265625,
-0.478271484375,
-0.389892578125,
0.28076171875,
0.10394287109375,
0.81494140625,
0.46728515625,
0.10137939453125,
-0.1239013671875,
-0.72265625,
-0.2415771484375,
-0.123291015625,
-0.634765625,
-1.17... | 11 |
Provide tags and a correct Python 3 solution for this coding contest problem.
"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules.
A total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.
Input
The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space.
The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).
Output
Output the number of participants who advance to the next round.
Examples
Input
8 5
10 9 8 7 7 7 5 5
Output
6
Input
4 2
0 0 0 0
Output
0
Note
In the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.
In the second example nobody got a positive score.
Tags: *special, implementation
Correct Solution:
```
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
res = 0
if sum(a) == 0:
print(0)
else:
for i in a:
if (i >= a[k - 1]) and (i != 0):
res += 1
print(res)
```
| 24,068 | [
0.2496337890625,
0.189453125,
-0.46630859375,
0.095458984375,
-0.288818359375,
-0.49072265625,
-0.29443359375,
0.239013671875,
0.09283447265625,
0.7490234375,
0.43896484375,
0.039337158203125,
-0.1575927734375,
-0.71923828125,
-0.2890625,
-0.1300048828125,
-0.6787109375,
-1.1611328... | 11 |
Provide tags and a correct Python 3 solution for this coding contest problem.
"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules.
A total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.
Input
The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space.
The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).
Output
Output the number of participants who advance to the next round.
Examples
Input
8 5
10 9 8 7 7 7 5 5
Output
6
Input
4 2
0 0 0 0
Output
0
Note
In the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.
In the second example nobody got a positive score.
Tags: *special, implementation
Correct Solution:
```
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in a:
ans += (i >= a[k-1] and i > 0)
print(ans)
```
| 24,069 | [
0.2578125,
0.2423095703125,
-0.498779296875,
0.12371826171875,
-0.310546875,
-0.466796875,
-0.3857421875,
0.3037109375,
0.07489013671875,
0.7705078125,
0.447998046875,
0.099609375,
-0.0836181640625,
-0.6875,
-0.217041015625,
-0.0870361328125,
-0.6259765625,
-1.1240234375,
-0.4301... | 11 |
Provide tags and a correct Python 3 solution for this coding contest problem.
"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules.
A total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.
Input
The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space.
The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).
Output
Output the number of participants who advance to the next round.
Examples
Input
8 5
10 9 8 7 7 7 5 5
Output
6
Input
4 2
0 0 0 0
Output
0
Note
In the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.
In the second example nobody got a positive score.
Tags: *special, implementation
Correct Solution:
```
a=input().split()
n=int(a[0])
k=int(a[1])
b=input().split()
for i in range(0,n):
b[i]=int(b[i])
while b[k-1]<=0:
k-=1
if k==0:break
if k!=n:
while b[k-1]==b[k] and k!=0:
k+=1
if k==n:break
print (k)
```
| 24,070 | [
0.24951171875,
0.203369140625,
-0.490234375,
0.11981201171875,
-0.31591796875,
-0.52392578125,
-0.349609375,
0.2734375,
0.103515625,
0.798828125,
0.398193359375,
0.088623046875,
-0.2230224609375,
-0.73486328125,
-0.228515625,
-0.12841796875,
-0.64697265625,
-1.2236328125,
-0.3774... | 11 |
Provide tags and a correct Python 3 solution for this coding contest problem.
"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules.
A total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.
Input
The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space.
The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).
Output
Output the number of participants who advance to the next round.
Examples
Input
8 5
10 9 8 7 7 7 5 5
Output
6
Input
4 2
0 0 0 0
Output
0
Note
In the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.
In the second example nobody got a positive score.
Tags: *special, implementation
Correct Solution:
```
n, k = map(int, input().split())
A = list(map(int, input().split()))
cnt = 0
for a in A:
if a > 0 and a >= A[k-1]:
cnt += 1
print(cnt)
```
| 24,071 | [
0.232666015625,
0.2398681640625,
-0.48779296875,
0.130615234375,
-0.2139892578125,
-0.447509765625,
-0.348388671875,
0.283447265625,
0.0611572265625,
0.796875,
0.452392578125,
0.1083984375,
-0.138916015625,
-0.7421875,
-0.26611328125,
-0.07659912109375,
-0.63232421875,
-1.12890625,... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules.
A total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.
Input
The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space.
The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).
Output
Output the number of participants who advance to the next round.
Examples
Input
8 5
10 9 8 7 7 7 5 5
Output
6
Input
4 2
0 0 0 0
Output
0
Note
In the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.
In the second example nobody got a positive score.
Submitted Solution:
```
n,k=map(int,input().split(' '))
p=input().split(' ')
for i in range(0,n):
if int(p[i])<int(p[k-1]) or p[i]=='0':
print(i)
break
else:
print(i+1)
```
Yes
| 24,072 | [
0.260986328125,
0.25341796875,
-0.4462890625,
0.0252227783203125,
-0.395751953125,
-0.375244140625,
-0.35986328125,
0.379638671875,
0.04400634765625,
0.81884765625,
0.350830078125,
0.06793212890625,
-0.1363525390625,
-0.712890625,
-0.2303466796875,
-0.24365234375,
-0.61767578125,
-... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules.
A total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.
Input
The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space.
The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).
Output
Output the number of participants who advance to the next round.
Examples
Input
8 5
10 9 8 7 7 7 5 5
Output
6
Input
4 2
0 0 0 0
Output
0
Note
In the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.
In the second example nobody got a positive score.
Submitted Solution:
```
n,k=map(int,input().split())
arr=[int(x) for x in input().split()]
max_score=arr[k-1]
count=0
for i in range(0,len(arr),1):
if arr[i]>0 and arr[i]>=max_score:
count+=1
print(count)
```
Yes
| 24,073 | [
0.262939453125,
0.289306640625,
-0.47216796875,
0.11590576171875,
-0.400146484375,
-0.44384765625,
-0.388671875,
0.37744140625,
0.0648193359375,
0.88671875,
0.3505859375,
0.133056640625,
-0.1309814453125,
-0.7607421875,
-0.25732421875,
-0.2420654296875,
-0.6279296875,
-1.06640625,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules.
A total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.
Input
The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space.
The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).
Output
Output the number of participants who advance to the next round.
Examples
Input
8 5
10 9 8 7 7 7 5 5
Output
6
Input
4 2
0 0 0 0
Output
0
Note
In the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.
In the second example nobody got a positive score.
Submitted Solution:
```
a = input().split()
b = input().split()
y = b[int(a[1])-1]
n = 0
for i, x in enumerate(b):
if int(x) >= int(y) and int(x) > 0:
n += 1
print(n)
```
Yes
| 24,074 | [
0.289306640625,
0.2607421875,
-0.44970703125,
0.03582763671875,
-0.409423828125,
-0.36669921875,
-0.35400390625,
0.385498046875,
0.1053466796875,
0.8447265625,
0.33740234375,
0.1328125,
-0.1824951171875,
-0.74755859375,
-0.2330322265625,
-0.290771484375,
-0.6337890625,
-1.076171875... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules.
A total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.
Input
The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space.
The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).
Output
Output the number of participants who advance to the next round.
Examples
Input
8 5
10 9 8 7 7 7 5 5
Output
6
Input
4 2
0 0 0 0
Output
0
Note
In the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.
In the second example nobody got a positive score.
Submitted Solution:
```
s = input().split()
n=int(s[0])
k=int(s[1])
st=input().split()[0:n]
res=int()
maks=int(st[k-1])
for i in st:
i=int(i)
if i>=maks and i>0:
res+=1
print(res)
```
Yes
| 24,075 | [
0.265625,
0.2186279296875,
-0.43310546875,
0.042327880859375,
-0.447998046875,
-0.436767578125,
-0.423583984375,
0.356689453125,
0.01476287841796875,
0.7890625,
0.251953125,
0.1627197265625,
-0.2059326171875,
-0.72705078125,
-0.2235107421875,
-0.32568359375,
-0.6337890625,
-1.09375... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules.
A total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.
Input
The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space.
The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).
Output
Output the number of participants who advance to the next round.
Examples
Input
8 5
10 9 8 7 7 7 5 5
Output
6
Input
4 2
0 0 0 0
Output
0
Note
In the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.
In the second example nobody got a positive score.
Submitted Solution:
```
n,k=map(int,input().split())
a=list(map(int,input().split()))
if(k<n):
res=a[k]
if(res>0):
if((a.count(res))==1):
tot=a.index(res)+a.count(res)-1
else:
tot=a.index(res)+a.count(res)
else:
tot=0
else:
i=n-1
while(a[i]<=0):
i=i-1
tot=i+1
print(tot)
```
No
| 24,076 | [
0.1788330078125,
0.2022705078125,
-0.44091796875,
-0.0145416259765625,
-0.390625,
-0.426513671875,
-0.3916015625,
0.35498046875,
0.0760498046875,
0.87646484375,
0.271484375,
0.052093505859375,
-0.100341796875,
-0.759765625,
-0.1895751953125,
-0.21533203125,
-0.59912109375,
-1.02832... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules.
A total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.
Input
The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space.
The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).
Output
Output the number of participants who advance to the next round.
Examples
Input
8 5
10 9 8 7 7 7 5 5
Output
6
Input
4 2
0 0 0 0
Output
0
Note
In the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.
In the second example nobody got a positive score.
Submitted Solution:
```
size, num = map(int, input().split())
ar = list(map(int, input().split()))
tmp = ar[num-1]
cnt = 0
for i in ar:
if i >= tmp:
cnt += 1
print(cnt)
```
No
| 24,077 | [
0.2666015625,
0.324462890625,
-0.45068359375,
0.0258026123046875,
-0.33642578125,
-0.32666015625,
-0.36279296875,
0.316650390625,
0.060089111328125,
0.8505859375,
0.390380859375,
0.102294921875,
-0.1497802734375,
-0.72412109375,
-0.234375,
-0.266845703125,
-0.59130859375,
-1.000976... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules.
A total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.
Input
The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space.
The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).
Output
Output the number of participants who advance to the next round.
Examples
Input
8 5
10 9 8 7 7 7 5 5
Output
6
Input
4 2
0 0 0 0
Output
0
Note
In the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.
In the second example nobody got a positive score.
Submitted Solution:
```
n,k = map(int,input().split())
a = list(map(int,input().split()))
c=0
for i in range(n):
if a[i]>=a[k-1]:
c+=1
print(c)
```
No
| 24,078 | [
0.28271484375,
0.301025390625,
-0.4580078125,
0.021881103515625,
-0.384521484375,
-0.373046875,
-0.38330078125,
0.38623046875,
0.046630859375,
0.83447265625,
0.35302734375,
0.10552978515625,
-0.13525390625,
-0.73681640625,
-0.204833984375,
-0.25439453125,
-0.609375,
-1.0146484375,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules.
A total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.
Input
The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space.
The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).
Output
Output the number of participants who advance to the next round.
Examples
Input
8 5
10 9 8 7 7 7 5 5
Output
6
Input
4 2
0 0 0 0
Output
0
Note
In the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.
In the second example nobody got a positive score.
Submitted Solution:
```
input1 = input().split()
n = int(input1[0])
k = int(input1[1])
total = 0
scores = input().split()
#scores = int(scores)
if(int(scores[0]) == int(scores[len(scores) - 1]) and int(scores[0]) == 0):
total = 0
else:
for i in scores:
if(int(i) >= int(scores[k-1])):
total += 1
print(total)
```
No
| 24,079 | [
0.19775390625,
0.2342529296875,
-0.429443359375,
0.0198516845703125,
-0.404296875,
-0.37890625,
-0.298583984375,
0.341796875,
0.09417724609375,
0.83447265625,
0.30322265625,
0.08172607421875,
-0.177978515625,
-0.74169921875,
-0.2529296875,
-0.2498779296875,
-0.6845703125,
-1.144531... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vanya is managed to enter his favourite site Codehorses. Vanya uses n distinct passwords for sites at all, however he can't remember which one exactly he specified during Codehorses registration.
Vanya will enter passwords in order of non-decreasing their lengths, and he will enter passwords of same length in arbitrary order. Just when Vanya will have entered the correct password, he is immediately authorized on the site. Vanya will not enter any password twice.
Entering any passwords takes one second for Vanya. But if Vanya will enter wrong password k times, then he is able to make the next try only 5 seconds after that. Vanya makes each try immediately, that is, at each moment when Vanya is able to enter password, he is doing that.
Determine how many seconds will Vanya need to enter Codehorses in the best case for him (if he spends minimum possible number of second) and in the worst case (if he spends maximum possible amount of seconds).
Input
The first line of the input contains two integers n and k (1 ≤ n, k ≤ 100) — the number of Vanya's passwords and the number of failed tries, after which the access to the site is blocked for 5 seconds.
The next n lines contains passwords, one per line — pairwise distinct non-empty strings consisting of latin letters and digits. Each password length does not exceed 100 characters.
The last line of the input contains the Vanya's Codehorses password. It is guaranteed that the Vanya's Codehorses password is equal to some of his n passwords.
Output
Print two integers — time (in seconds), Vanya needs to be authorized to Codehorses in the best case for him and in the worst case respectively.
Examples
Input
5 2
cba
abc
bb1
abC
ABC
abc
Output
1 15
Input
4 100
11
22
1
2
22
Output
3 4
Note
Consider the first sample case. As soon as all passwords have the same length, Vanya can enter the right password at the first try as well as at the last try. If he enters it at the first try, he spends exactly 1 second. Thus in the best case the answer is 1. If, at the other hand, he enters it at the last try, he enters another 4 passwords before. He spends 2 seconds to enter first 2 passwords, then he waits 5 seconds as soon as he made 2 wrong tries. Then he spends 2 more seconds to enter 2 wrong passwords, again waits 5 seconds and, finally, enters the correct password spending 1 more second. In summary in the worst case he is able to be authorized in 15 seconds.
Consider the second sample case. There is no way of entering passwords and get the access to the site blocked. As soon as the required password has length of 2, Vanya enters all passwords of length 1 anyway, spending 2 seconds for that. Then, in the best case, he immediately enters the correct password and the answer for the best case is 3, but in the worst case he enters wrong password of length 2 and only then the right one, spending 4 seconds at all.
Submitted Solution:
```
n,k=map(int,input().split())
l=[input() for i in range(n)]
z=[]
d={}
for i in l:
t=len(i)
if t in d:
d[t]+=1
else:
d[t]=1
z.append(t)
b,w=0,0
su=0
x=len(input())
z.sort()
for i in z:
if i==x:
break
su+=d[i]
b=((su)//k)*5+su+1
w=((su+d[x]-1)//k)*5+su+d[x]
print(b,w)
```
Yes
| 24,350 | [
0.62158203125,
0.06524658203125,
0.22265625,
0.1754150390625,
-0.24853515625,
-0.130859375,
0.1383056640625,
0.40087890625,
-0.140869140625,
0.66015625,
0.332275390625,
0.257568359375,
0.000576019287109375,
-0.71240234375,
-0.2298583984375,
-0.22705078125,
-0.62890625,
-0.753417968... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vanya is managed to enter his favourite site Codehorses. Vanya uses n distinct passwords for sites at all, however he can't remember which one exactly he specified during Codehorses registration.
Vanya will enter passwords in order of non-decreasing their lengths, and he will enter passwords of same length in arbitrary order. Just when Vanya will have entered the correct password, he is immediately authorized on the site. Vanya will not enter any password twice.
Entering any passwords takes one second for Vanya. But if Vanya will enter wrong password k times, then he is able to make the next try only 5 seconds after that. Vanya makes each try immediately, that is, at each moment when Vanya is able to enter password, he is doing that.
Determine how many seconds will Vanya need to enter Codehorses in the best case for him (if he spends minimum possible number of second) and in the worst case (if he spends maximum possible amount of seconds).
Input
The first line of the input contains two integers n and k (1 ≤ n, k ≤ 100) — the number of Vanya's passwords and the number of failed tries, after which the access to the site is blocked for 5 seconds.
The next n lines contains passwords, one per line — pairwise distinct non-empty strings consisting of latin letters and digits. Each password length does not exceed 100 characters.
The last line of the input contains the Vanya's Codehorses password. It is guaranteed that the Vanya's Codehorses password is equal to some of his n passwords.
Output
Print two integers — time (in seconds), Vanya needs to be authorized to Codehorses in the best case for him and in the worst case respectively.
Examples
Input
5 2
cba
abc
bb1
abC
ABC
abc
Output
1 15
Input
4 100
11
22
1
2
22
Output
3 4
Note
Consider the first sample case. As soon as all passwords have the same length, Vanya can enter the right password at the first try as well as at the last try. If he enters it at the first try, he spends exactly 1 second. Thus in the best case the answer is 1. If, at the other hand, he enters it at the last try, he enters another 4 passwords before. He spends 2 seconds to enter first 2 passwords, then he waits 5 seconds as soon as he made 2 wrong tries. Then he spends 2 more seconds to enter 2 wrong passwords, again waits 5 seconds and, finally, enters the correct password spending 1 more second. In summary in the worst case he is able to be authorized in 15 seconds.
Consider the second sample case. There is no way of entering passwords and get the access to the site blocked. As soon as the required password has length of 2, Vanya enters all passwords of length 1 anyway, spending 2 seconds for that. Then, in the best case, he immediately enters the correct password and the answer for the best case is 3, but in the worst case he enters wrong password of length 2 and only then the right one, spending 4 seconds at all.
Submitted Solution:
```
n,k=map(int,input().split())
val=[0 for i in range(105) ]
ck=[]
ml=[]
for i in range(n):
s=input()
if s not in ck:
ck+=[s]
ml+=[len(s)]
val[len(s)]+=1
s=input()
d=len(s)
c=0
p=val[d]
for i in range(1,d+1):
c+=val[i]
best=((c-p)//k)*5+c-p+1
worst=((c-1)//k)*5+c
print(best,worst)
```
Yes
| 24,351 | [
0.62158203125,
0.06524658203125,
0.22265625,
0.1754150390625,
-0.24853515625,
-0.130859375,
0.1383056640625,
0.40087890625,
-0.140869140625,
0.66015625,
0.332275390625,
0.257568359375,
0.000576019287109375,
-0.71240234375,
-0.2298583984375,
-0.22705078125,
-0.62890625,
-0.753417968... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vanya is managed to enter his favourite site Codehorses. Vanya uses n distinct passwords for sites at all, however he can't remember which one exactly he specified during Codehorses registration.
Vanya will enter passwords in order of non-decreasing their lengths, and he will enter passwords of same length in arbitrary order. Just when Vanya will have entered the correct password, he is immediately authorized on the site. Vanya will not enter any password twice.
Entering any passwords takes one second for Vanya. But if Vanya will enter wrong password k times, then he is able to make the next try only 5 seconds after that. Vanya makes each try immediately, that is, at each moment when Vanya is able to enter password, he is doing that.
Determine how many seconds will Vanya need to enter Codehorses in the best case for him (if he spends minimum possible number of second) and in the worst case (if he spends maximum possible amount of seconds).
Input
The first line of the input contains two integers n and k (1 ≤ n, k ≤ 100) — the number of Vanya's passwords and the number of failed tries, after which the access to the site is blocked for 5 seconds.
The next n lines contains passwords, one per line — pairwise distinct non-empty strings consisting of latin letters and digits. Each password length does not exceed 100 characters.
The last line of the input contains the Vanya's Codehorses password. It is guaranteed that the Vanya's Codehorses password is equal to some of his n passwords.
Output
Print two integers — time (in seconds), Vanya needs to be authorized to Codehorses in the best case for him and in the worst case respectively.
Examples
Input
5 2
cba
abc
bb1
abC
ABC
abc
Output
1 15
Input
4 100
11
22
1
2
22
Output
3 4
Note
Consider the first sample case. As soon as all passwords have the same length, Vanya can enter the right password at the first try as well as at the last try. If he enters it at the first try, he spends exactly 1 second. Thus in the best case the answer is 1. If, at the other hand, he enters it at the last try, he enters another 4 passwords before. He spends 2 seconds to enter first 2 passwords, then he waits 5 seconds as soon as he made 2 wrong tries. Then he spends 2 more seconds to enter 2 wrong passwords, again waits 5 seconds and, finally, enters the correct password spending 1 more second. In summary in the worst case he is able to be authorized in 15 seconds.
Consider the second sample case. There is no way of entering passwords and get the access to the site blocked. As soon as the required password has length of 2, Vanya enters all passwords of length 1 anyway, spending 2 seconds for that. Then, in the best case, he immediately enters the correct password and the answer for the best case is 3, but in the worst case he enters wrong password of length 2 and only then the right one, spending 4 seconds at all.
Submitted Solution:
```
n, k = map(int, input().split())
a = sorted([len(input()) for i in range(n)])
b = len(input())
ans1, ans2 = 0, 0
for i in range(n):
ans1 += 1
if a[i] == b:
break
if i % k == k - 1:
ans1 += 5
for i in range(n):
ans2 += 1
if i == n - 1 or a[i + 1] > b:
break
if i % k == k - 1:
ans2 += 5
print(ans1, ans2)
```
Yes
| 24,352 | [
0.62158203125,
0.06524658203125,
0.22265625,
0.1754150390625,
-0.24853515625,
-0.130859375,
0.1383056640625,
0.40087890625,
-0.140869140625,
0.66015625,
0.332275390625,
0.257568359375,
0.000576019287109375,
-0.71240234375,
-0.2298583984375,
-0.22705078125,
-0.62890625,
-0.753417968... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vanya is managed to enter his favourite site Codehorses. Vanya uses n distinct passwords for sites at all, however he can't remember which one exactly he specified during Codehorses registration.
Vanya will enter passwords in order of non-decreasing their lengths, and he will enter passwords of same length in arbitrary order. Just when Vanya will have entered the correct password, he is immediately authorized on the site. Vanya will not enter any password twice.
Entering any passwords takes one second for Vanya. But if Vanya will enter wrong password k times, then he is able to make the next try only 5 seconds after that. Vanya makes each try immediately, that is, at each moment when Vanya is able to enter password, he is doing that.
Determine how many seconds will Vanya need to enter Codehorses in the best case for him (if he spends minimum possible number of second) and in the worst case (if he spends maximum possible amount of seconds).
Input
The first line of the input contains two integers n and k (1 ≤ n, k ≤ 100) — the number of Vanya's passwords and the number of failed tries, after which the access to the site is blocked for 5 seconds.
The next n lines contains passwords, one per line — pairwise distinct non-empty strings consisting of latin letters and digits. Each password length does not exceed 100 characters.
The last line of the input contains the Vanya's Codehorses password. It is guaranteed that the Vanya's Codehorses password is equal to some of his n passwords.
Output
Print two integers — time (in seconds), Vanya needs to be authorized to Codehorses in the best case for him and in the worst case respectively.
Examples
Input
5 2
cba
abc
bb1
abC
ABC
abc
Output
1 15
Input
4 100
11
22
1
2
22
Output
3 4
Note
Consider the first sample case. As soon as all passwords have the same length, Vanya can enter the right password at the first try as well as at the last try. If he enters it at the first try, he spends exactly 1 second. Thus in the best case the answer is 1. If, at the other hand, he enters it at the last try, he enters another 4 passwords before. He spends 2 seconds to enter first 2 passwords, then he waits 5 seconds as soon as he made 2 wrong tries. Then he spends 2 more seconds to enter 2 wrong passwords, again waits 5 seconds and, finally, enters the correct password spending 1 more second. In summary in the worst case he is able to be authorized in 15 seconds.
Consider the second sample case. There is no way of entering passwords and get the access to the site blocked. As soon as the required password has length of 2, Vanya enters all passwords of length 1 anyway, spending 2 seconds for that. Then, in the best case, he immediately enters the correct password and the answer for the best case is 3, but in the worst case he enters wrong password of length 2 and only then the right one, spending 4 seconds at all.
Submitted Solution:
```
n,k=[int(a) for a in input().split()]
p=[]
for i in range(n):
p.append(input())
real=input()
l=len(real)
cmin,cmax=0,0
for s in p:
if len(s)<=l:
cmax=cmax+1
if len(s)<l:
cmin=cmin+1
def calc(c):
if c==0:
return 0
return c+5*(c//k)
print(calc(cmin)+1,calc(cmax-1)+1)
```
Yes
| 24,353 | [
0.62158203125,
0.06524658203125,
0.22265625,
0.1754150390625,
-0.24853515625,
-0.130859375,
0.1383056640625,
0.40087890625,
-0.140869140625,
0.66015625,
0.332275390625,
0.257568359375,
0.000576019287109375,
-0.71240234375,
-0.2298583984375,
-0.22705078125,
-0.62890625,
-0.753417968... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vanya is managed to enter his favourite site Codehorses. Vanya uses n distinct passwords for sites at all, however he can't remember which one exactly he specified during Codehorses registration.
Vanya will enter passwords in order of non-decreasing their lengths, and he will enter passwords of same length in arbitrary order. Just when Vanya will have entered the correct password, he is immediately authorized on the site. Vanya will not enter any password twice.
Entering any passwords takes one second for Vanya. But if Vanya will enter wrong password k times, then he is able to make the next try only 5 seconds after that. Vanya makes each try immediately, that is, at each moment when Vanya is able to enter password, he is doing that.
Determine how many seconds will Vanya need to enter Codehorses in the best case for him (if he spends minimum possible number of second) and in the worst case (if he spends maximum possible amount of seconds).
Input
The first line of the input contains two integers n and k (1 ≤ n, k ≤ 100) — the number of Vanya's passwords and the number of failed tries, after which the access to the site is blocked for 5 seconds.
The next n lines contains passwords, one per line — pairwise distinct non-empty strings consisting of latin letters and digits. Each password length does not exceed 100 characters.
The last line of the input contains the Vanya's Codehorses password. It is guaranteed that the Vanya's Codehorses password is equal to some of his n passwords.
Output
Print two integers — time (in seconds), Vanya needs to be authorized to Codehorses in the best case for him and in the worst case respectively.
Examples
Input
5 2
cba
abc
bb1
abC
ABC
abc
Output
1 15
Input
4 100
11
22
1
2
22
Output
3 4
Note
Consider the first sample case. As soon as all passwords have the same length, Vanya can enter the right password at the first try as well as at the last try. If he enters it at the first try, he spends exactly 1 second. Thus in the best case the answer is 1. If, at the other hand, he enters it at the last try, he enters another 4 passwords before. He spends 2 seconds to enter first 2 passwords, then he waits 5 seconds as soon as he made 2 wrong tries. Then he spends 2 more seconds to enter 2 wrong passwords, again waits 5 seconds and, finally, enters the correct password spending 1 more second. In summary in the worst case he is able to be authorized in 15 seconds.
Consider the second sample case. There is no way of entering passwords and get the access to the site blocked. As soon as the required password has length of 2, Vanya enters all passwords of length 1 anyway, spending 2 seconds for that. Then, in the best case, he immediately enters the correct password and the answer for the best case is 3, but in the worst case he enters wrong password of length 2 and only then the right one, spending 4 seconds at all.
Submitted Solution:
```
n, k = map(int, input().split())
lst = []
if n == 1:
s1 = 1
e1 = 1
else:
for i in range(n):
x = input()
lst.append(x)
p = input()
d = {}
lst.sort()
for i in lst:
if len(i) in d:
d[len(i)]+=1
else:
d[len(i)]=1
l = len(p)
s = 1
e = 0
for key in d.keys():
if key < l:
s += d[key]
if key <= l:
e += d[key]
s1 = s+((s//k)*5)
e1 = e+((e//k)*5)
if k == 1 and s == 1:
s1 = 1
if k == 1:
e1 = e+(((e-1)//k)*5)
print(s1, e1)
```
No
| 24,354 | [
0.62158203125,
0.06524658203125,
0.22265625,
0.1754150390625,
-0.24853515625,
-0.130859375,
0.1383056640625,
0.40087890625,
-0.140869140625,
0.66015625,
0.332275390625,
0.257568359375,
0.000576019287109375,
-0.71240234375,
-0.2298583984375,
-0.22705078125,
-0.62890625,
-0.753417968... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vanya is managed to enter his favourite site Codehorses. Vanya uses n distinct passwords for sites at all, however he can't remember which one exactly he specified during Codehorses registration.
Vanya will enter passwords in order of non-decreasing their lengths, and he will enter passwords of same length in arbitrary order. Just when Vanya will have entered the correct password, he is immediately authorized on the site. Vanya will not enter any password twice.
Entering any passwords takes one second for Vanya. But if Vanya will enter wrong password k times, then he is able to make the next try only 5 seconds after that. Vanya makes each try immediately, that is, at each moment when Vanya is able to enter password, he is doing that.
Determine how many seconds will Vanya need to enter Codehorses in the best case for him (if he spends minimum possible number of second) and in the worst case (if he spends maximum possible amount of seconds).
Input
The first line of the input contains two integers n and k (1 ≤ n, k ≤ 100) — the number of Vanya's passwords and the number of failed tries, after which the access to the site is blocked for 5 seconds.
The next n lines contains passwords, one per line — pairwise distinct non-empty strings consisting of latin letters and digits. Each password length does not exceed 100 characters.
The last line of the input contains the Vanya's Codehorses password. It is guaranteed that the Vanya's Codehorses password is equal to some of his n passwords.
Output
Print two integers — time (in seconds), Vanya needs to be authorized to Codehorses in the best case for him and in the worst case respectively.
Examples
Input
5 2
cba
abc
bb1
abC
ABC
abc
Output
1 15
Input
4 100
11
22
1
2
22
Output
3 4
Note
Consider the first sample case. As soon as all passwords have the same length, Vanya can enter the right password at the first try as well as at the last try. If he enters it at the first try, he spends exactly 1 second. Thus in the best case the answer is 1. If, at the other hand, he enters it at the last try, he enters another 4 passwords before. He spends 2 seconds to enter first 2 passwords, then he waits 5 seconds as soon as he made 2 wrong tries. Then he spends 2 more seconds to enter 2 wrong passwords, again waits 5 seconds and, finally, enters the correct password spending 1 more second. In summary in the worst case he is able to be authorized in 15 seconds.
Consider the second sample case. There is no way of entering passwords and get the access to the site blocked. As soon as the required password has length of 2, Vanya enters all passwords of length 1 anyway, spending 2 seconds for that. Then, in the best case, he immediately enters the correct password and the answer for the best case is 3, but in the worst case he enters wrong password of length 2 and only then the right one, spending 4 seconds at all.
Submitted Solution:
```
from collections import Counter
n, k = map(int, input().split())
words = list()
for i in range(n):
words.append(input())
real = input()
# Get only lengths of the passwords.
words = [len(i) for i in words if len(i) <= len(real)]
# Get all lenths of all passwords and their quantity.
c = Counter(words)
sorted_c = sorted(c) # Sort by key
# Assign a quantity of passwords with the same length as real's,
# i.e. retrieve the specific value from the dictionary.
real_value = c[len(real)]
# Get the quantity of passwords with a length less than real's
all_but_real = 0
for i in range(len(sorted_c) - 1):
all_but_real += c[sorted_c[i]]
tmin = 1 + all_but_real + (all_but_real // k) * 5
if real_value == 1:
tmax = tmin
if (real_value + all_but_real) % 2 != 0:
tmax = (real_value
+ all_but_real
+ ((real_value + all_but_real) // k) * 5)
print("ODD")
else:
tmax = (real_value
+ all_but_real
+ (((real_value + all_but_real) // k) - 1) * 5)
print("EVEN")
print(tmin, tmax)
```
No
| 24,355 | [
0.62158203125,
0.06524658203125,
0.22265625,
0.1754150390625,
-0.24853515625,
-0.130859375,
0.1383056640625,
0.40087890625,
-0.140869140625,
0.66015625,
0.332275390625,
0.257568359375,
0.000576019287109375,
-0.71240234375,
-0.2298583984375,
-0.22705078125,
-0.62890625,
-0.753417968... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vanya is managed to enter his favourite site Codehorses. Vanya uses n distinct passwords for sites at all, however he can't remember which one exactly he specified during Codehorses registration.
Vanya will enter passwords in order of non-decreasing their lengths, and he will enter passwords of same length in arbitrary order. Just when Vanya will have entered the correct password, he is immediately authorized on the site. Vanya will not enter any password twice.
Entering any passwords takes one second for Vanya. But if Vanya will enter wrong password k times, then he is able to make the next try only 5 seconds after that. Vanya makes each try immediately, that is, at each moment when Vanya is able to enter password, he is doing that.
Determine how many seconds will Vanya need to enter Codehorses in the best case for him (if he spends minimum possible number of second) and in the worst case (if he spends maximum possible amount of seconds).
Input
The first line of the input contains two integers n and k (1 ≤ n, k ≤ 100) — the number of Vanya's passwords and the number of failed tries, after which the access to the site is blocked for 5 seconds.
The next n lines contains passwords, one per line — pairwise distinct non-empty strings consisting of latin letters and digits. Each password length does not exceed 100 characters.
The last line of the input contains the Vanya's Codehorses password. It is guaranteed that the Vanya's Codehorses password is equal to some of his n passwords.
Output
Print two integers — time (in seconds), Vanya needs to be authorized to Codehorses in the best case for him and in the worst case respectively.
Examples
Input
5 2
cba
abc
bb1
abC
ABC
abc
Output
1 15
Input
4 100
11
22
1
2
22
Output
3 4
Note
Consider the first sample case. As soon as all passwords have the same length, Vanya can enter the right password at the first try as well as at the last try. If he enters it at the first try, he spends exactly 1 second. Thus in the best case the answer is 1. If, at the other hand, he enters it at the last try, he enters another 4 passwords before. He spends 2 seconds to enter first 2 passwords, then he waits 5 seconds as soon as he made 2 wrong tries. Then he spends 2 more seconds to enter 2 wrong passwords, again waits 5 seconds and, finally, enters the correct password spending 1 more second. In summary in the worst case he is able to be authorized in 15 seconds.
Consider the second sample case. There is no way of entering passwords and get the access to the site blocked. As soon as the required password has length of 2, Vanya enters all passwords of length 1 anyway, spending 2 seconds for that. Then, in the best case, he immediately enters the correct password and the answer for the best case is 3, but in the worst case he enters wrong password of length 2 and only then the right one, spending 4 seconds at all.
Submitted Solution:
```
# cook your dish here
#import sys
#sys.setrecursionlimit(10**9)
ll=lambda:map(int,input().split())
t=lambda:int(input())
ss=lambda:input()
lx=lambda x:map(int,input().split(x))
yy=lambda:print("Yes")
nn=lambda:print("No")
from math import log10 ,log2,ceil,factorial as fac,gcd,inf,sqrt,log
#from itertools import combinations_with_replacement as cs
#from functools import reduce
from bisect import bisect_right as br,bisect_left as bl
from collections import Counter
#from math import inf
mod=10**9+7
#for _ in range(t()):
def f():
n,k=ll()
d={}
q=[]
for i in range(n):
s=ss()
if len(s) not in d:
d[len(s)]=0
d[len(s)]+=1
q.append(s)
p=ss()
x,y=0,0
for i in sorted(d.keys()):
if i>len(p):
break
if i!=len(p):
x+=d[i]
y+=d[i]
x+=1
x=x+((x//k)*5 if x>k else 0)
y=y-q.count(p)+1
y=y+((y//k)*5 if y>k else 0)
print(x,y)
f()
'''
baca
bac
1 2 3
baaccca
abbaccccaba
'''
```
No
| 24,356 | [
0.62158203125,
0.06524658203125,
0.22265625,
0.1754150390625,
-0.24853515625,
-0.130859375,
0.1383056640625,
0.40087890625,
-0.140869140625,
0.66015625,
0.332275390625,
0.257568359375,
0.000576019287109375,
-0.71240234375,
-0.2298583984375,
-0.22705078125,
-0.62890625,
-0.753417968... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vanya is managed to enter his favourite site Codehorses. Vanya uses n distinct passwords for sites at all, however he can't remember which one exactly he specified during Codehorses registration.
Vanya will enter passwords in order of non-decreasing their lengths, and he will enter passwords of same length in arbitrary order. Just when Vanya will have entered the correct password, he is immediately authorized on the site. Vanya will not enter any password twice.
Entering any passwords takes one second for Vanya. But if Vanya will enter wrong password k times, then he is able to make the next try only 5 seconds after that. Vanya makes each try immediately, that is, at each moment when Vanya is able to enter password, he is doing that.
Determine how many seconds will Vanya need to enter Codehorses in the best case for him (if he spends minimum possible number of second) and in the worst case (if he spends maximum possible amount of seconds).
Input
The first line of the input contains two integers n and k (1 ≤ n, k ≤ 100) — the number of Vanya's passwords and the number of failed tries, after which the access to the site is blocked for 5 seconds.
The next n lines contains passwords, one per line — pairwise distinct non-empty strings consisting of latin letters and digits. Each password length does not exceed 100 characters.
The last line of the input contains the Vanya's Codehorses password. It is guaranteed that the Vanya's Codehorses password is equal to some of his n passwords.
Output
Print two integers — time (in seconds), Vanya needs to be authorized to Codehorses in the best case for him and in the worst case respectively.
Examples
Input
5 2
cba
abc
bb1
abC
ABC
abc
Output
1 15
Input
4 100
11
22
1
2
22
Output
3 4
Note
Consider the first sample case. As soon as all passwords have the same length, Vanya can enter the right password at the first try as well as at the last try. If he enters it at the first try, he spends exactly 1 second. Thus in the best case the answer is 1. If, at the other hand, he enters it at the last try, he enters another 4 passwords before. He spends 2 seconds to enter first 2 passwords, then he waits 5 seconds as soon as he made 2 wrong tries. Then he spends 2 more seconds to enter 2 wrong passwords, again waits 5 seconds and, finally, enters the correct password spending 1 more second. In summary in the worst case he is able to be authorized in 15 seconds.
Consider the second sample case. There is no way of entering passwords and get the access to the site blocked. As soon as the required password has length of 2, Vanya enters all passwords of length 1 anyway, spending 2 seconds for that. Then, in the best case, he immediately enters the correct password and the answer for the best case is 3, but in the worst case he enters wrong password of length 2 and only then the right one, spending 4 seconds at all.
Submitted Solution:
```
n,k=map(int,input().split())
pas=[]
for i in range(n):
pas.append(input())
cp=input(); les=0; eq=0
for item in pas:
if len(item)<len(cp): les+=1
elif len(item)==len(cp): eq+=1
add=les//k*5
add2=(eq-1)//k*5
print(les+add+1,les+eq+add2)
```
No
| 24,357 | [
0.62158203125,
0.06524658203125,
0.22265625,
0.1754150390625,
-0.24853515625,
-0.130859375,
0.1383056640625,
0.40087890625,
-0.140869140625,
0.66015625,
0.332275390625,
0.257568359375,
0.000576019287109375,
-0.71240234375,
-0.2298583984375,
-0.22705078125,
-0.62890625,
-0.753417968... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sitting in a station waiting room, Joisino is gazing at her train ticket.
The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).
In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds.
The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
Constraints
* 0≤A,B,C,D≤9
* All input values are integers.
* It is guaranteed that there is a solution.
Input
Input is given from Standard Input in the following format:
ABCD
Output
Print the formula you made, including the part `=7`.
Use the signs `+` and `-`.
Do not print a space between a digit and a sign.
Examples
Input
1222
Output
1+2+2+2=7
Input
0290
Output
0-2+9+0=7
Input
3242
Output
3+2+4-2=7
Submitted Solution:
```
# -*- coding: utf-8 -*-
import types
#import copy
# Input
abcd = int(input())
n = len(str(abcd)) - 1 # 閾の数
# Print
for i in range( 2**n ):
op = n * ["-"]
# Create operation list
# example: ['+', '-', '+']
for j in range(n):
if ( i >> j ) & 1:
op[n-1 -j] = "+"
formula = ""
for p_n, p_o in zip(str(abcd), op+[""]):
formula += (p_n + p_o)
if eval(formula) == 7:
print(formula + "=7")
break
```
No
| 24,601 | [
0.198486328125,
-0.121826171875,
0.08349609375,
-0.04193115234375,
-0.30322265625,
-0.386474609375,
0.375,
0.258056640625,
0.0596923828125,
0.5302734375,
0.5654296875,
0.0877685546875,
-0.05755615234375,
-0.449462890625,
-0.5263671875,
-0.0301666259765625,
-0.329345703125,
-0.51611... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well.
However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
Constraints
* All input values are integers.
* 1 ≤ N ≤ 100
* 1 ≤ s_i ≤ 100
Input
Input is given from Standard Input in the following format:
N
s_1
s_2
:
s_N
Output
Print the maximum value that can be displayed as your grade.
Examples
Input
3
5
10
15
Output
25
Input
3
10
10
15
Output
35
Input
3
10
20
30
Output
0
Submitted Solution:
```
n = int(input())
s = sorted([int(input()) for _ in range(n)])
s = [0]+s
x = sum(s)
for i in range(n):
if (x-s[i]) % 10:
print(x-s[i])
exit()
print(0)
```
Yes
| 24,613 | [
0.421142578125,
-0.1378173828125,
-0.1251220703125,
0.021392822265625,
-0.650390625,
-0.2232666015625,
0.28369140625,
0.312255859375,
-0.053802490234375,
0.908203125,
0.375,
0.09100341796875,
0.4970703125,
-0.5341796875,
-0.359375,
-0.11199951171875,
-0.8056640625,
-0.80322265625,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well.
However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
Constraints
* All input values are integers.
* 1 ≤ N ≤ 100
* 1 ≤ s_i ≤ 100
Input
Input is given from Standard Input in the following format:
N
s_1
s_2
:
s_N
Output
Print the maximum value that can be displayed as your grade.
Examples
Input
3
5
10
15
Output
25
Input
3
10
10
15
Output
35
Input
3
10
20
30
Output
0
Submitted Solution:
```
n=int(input())
s=[int(input()) for _ in range(n)]
x=sum(s)
if x%10:
print(x)
else:
a=[]
for i in s:
if i%10:
a.append(i)
if a:
print(x-min(a))
else:
print(0)
```
Yes
| 24,614 | [
0.426513671875,
-0.06964111328125,
-0.11212158203125,
0.0251007080078125,
-0.65625,
-0.253173828125,
0.286376953125,
0.2109375,
-0.07733154296875,
0.9111328125,
0.38232421875,
0.0911865234375,
0.50439453125,
-0.5126953125,
-0.357421875,
-0.124755859375,
-0.8271484375,
-0.8037109375... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well.
However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
Constraints
* All input values are integers.
* 1 ≤ N ≤ 100
* 1 ≤ s_i ≤ 100
Input
Input is given from Standard Input in the following format:
N
s_1
s_2
:
s_N
Output
Print the maximum value that can be displayed as your grade.
Examples
Input
3
5
10
15
Output
25
Input
3
10
10
15
Output
35
Input
3
10
20
30
Output
0
Submitted Solution:
```
n=int(input())
a=[int(input()) for _ in range(n)]
sumA=sum(a)
if sumA%10>0:
print(sumA)
else:
a=sorted(a)
for b in a:
if b%10>0:
print(sumA-b)
break
else:
print(0)
```
Yes
| 24,615 | [
0.351318359375,
-0.056640625,
-0.1881103515625,
-0.031463623046875,
-0.68212890625,
-0.24365234375,
0.3779296875,
0.267333984375,
-0.07073974609375,
0.89453125,
0.2122802734375,
0.04901123046875,
0.495849609375,
-0.465576171875,
-0.40283203125,
-0.0860595703125,
-0.74560546875,
-0.... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well.
However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
Constraints
* All input values are integers.
* 1 ≤ N ≤ 100
* 1 ≤ s_i ≤ 100
Input
Input is given from Standard Input in the following format:
N
s_1
s_2
:
s_N
Output
Print the maximum value that can be displayed as your grade.
Examples
Input
3
5
10
15
Output
25
Input
3
10
10
15
Output
35
Input
3
10
20
30
Output
0
Submitted Solution:
```
n=int(input())
s=[int(input()) for _ in range(n)]
p=sum(s)
if p%10!=0:
print(p)
else:
s.sort()
d=0
for i in s:
if i%10!=0:
d=i
break
if d==0:
print(0)
else:
print(p-d)
```
Yes
| 24,616 | [
0.38916015625,
-0.089111328125,
-0.139404296875,
0.00909423828125,
-0.7109375,
-0.224365234375,
0.3720703125,
0.3359375,
-0.059295654296875,
0.86865234375,
0.31494140625,
0.07696533203125,
0.56396484375,
-0.490966796875,
-0.385986328125,
-0.1268310546875,
-0.7958984375,
-0.75292968... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well.
However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
Constraints
* All input values are integers.
* 1 ≤ N ≤ 100
* 1 ≤ s_i ≤ 100
Input
Input is given from Standard Input in the following format:
N
s_1
s_2
:
s_N
Output
Print the maximum value that can be displayed as your grade.
Examples
Input
3
5
10
15
Output
25
Input
3
10
10
15
Output
35
Input
3
10
20
30
Output
0
Submitted Solution:
```
n = int(input())
a = [int(input()) for _ in range(n)]
a.sort()
suma = sum(a)
if suma % 10 != 0:
print(suma)
else:
for i in a:
if i % 10 != 0:
print(suma - i)
```
No
| 24,617 | [
0.34228515625,
-0.0239715576171875,
-0.2047119140625,
-0.031524658203125,
-0.70068359375,
-0.2392578125,
0.34375,
0.250244140625,
-0.06793212890625,
0.86083984375,
0.2587890625,
0.068115234375,
0.479736328125,
-0.50439453125,
-0.411376953125,
-0.10791015625,
-0.767578125,
-0.765136... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well.
However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
Constraints
* All input values are integers.
* 1 ≤ N ≤ 100
* 1 ≤ s_i ≤ 100
Input
Input is given from Standard Input in the following format:
N
s_1
s_2
:
s_N
Output
Print the maximum value that can be displayed as your grade.
Examples
Input
3
5
10
15
Output
25
Input
3
10
10
15
Output
35
Input
3
10
20
30
Output
0
Submitted Solution:
```
n=int(input())
l=sorted([int(input()) for i in range(n)])
if sum(l)%10!=0:
print(sum(l))
else:
ans=sum(l)
for i in range(n):
if l[i]%10==0:
ans-=l[i]
print(ans)
quit()
print(0)
```
No
| 24,618 | [
0.40869140625,
-0.11541748046875,
-0.1588134765625,
0.01641845703125,
-0.65625,
-0.2666015625,
0.380859375,
0.32177734375,
-0.07012939453125,
0.87646484375,
0.338623046875,
0.09552001953125,
0.51904296875,
-0.5556640625,
-0.390380859375,
-0.1124267578125,
-0.7822265625,
-0.79492187... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well.
However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
Constraints
* All input values are integers.
* 1 ≤ N ≤ 100
* 1 ≤ s_i ≤ 100
Input
Input is given from Standard Input in the following format:
N
s_1
s_2
:
s_N
Output
Print the maximum value that can be displayed as your grade.
Examples
Input
3
5
10
15
Output
25
Input
3
10
10
15
Output
35
Input
3
10
20
30
Output
0
Submitted Solution:
```
n=int(input())
s=[int(input()) for i in range(n)]
#print(n,s)
max=0
t=[0]
for j in range(n):
for i in range(len(t)):
t.append(t[i]+s[j])
if max < t[i]+s[j] and (t[i]+s[j])%10 !=0:
max = t[i]+s[j]
print(max)
```
No
| 24,619 | [
0.28564453125,
-0.0286102294921875,
-0.11212158203125,
0.06854248046875,
-0.7001953125,
-0.372314453125,
0.277587890625,
0.2430419921875,
-0.077880859375,
0.94189453125,
0.21728515625,
0.1976318359375,
0.46044921875,
-0.55908203125,
-0.31982421875,
-0.154296875,
-0.80419921875,
-0.... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well.
However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
Constraints
* All input values are integers.
* 1 ≤ N ≤ 100
* 1 ≤ s_i ≤ 100
Input
Input is given from Standard Input in the following format:
N
s_1
s_2
:
s_N
Output
Print the maximum value that can be displayed as your grade.
Examples
Input
3
5
10
15
Output
25
Input
3
10
10
15
Output
35
Input
3
10
20
30
Output
0
Submitted Solution:
```
n = int(input())
s = [ int(input()) for i in range(n)]
dp = [[0 for _ in range(n+1)] for _ in range(n) ]
for i in range(1, n + 1):
dp[0][i] = s[0]
for i in range(1, n):
for j in range(n + 1):
if (i == j):
dp[i][j] = dp[i - 1][j]
else:
dp[i][j] = dp[i - 1][j] + s[i]
print(max([it for it in dp[n - 1] if (it % 10 != 0)]))
```
No
| 24,620 | [
0.191650390625,
-0.1715087890625,
-0.0660400390625,
0.107666015625,
-0.7109375,
-0.345703125,
0.28173828125,
0.155517578125,
-0.022918701171875,
0.9560546875,
0.275390625,
0.0782470703125,
0.490234375,
-0.451171875,
-0.3701171875,
-0.09942626953125,
-0.8671875,
-0.7109375,
-0.344... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
There is a sequence $A = a_0, a_1, ..., a_{n-1}$. You are given the following information and questions.
* relate$(x, y, z)$: $a_y$ is greater than $a_x$ by $z$
* diff$(x, y)$: report the difference between $a_x$ and $a_y$ $(a_y - a_x)$
Constraints
* $2 \leq n \leq 100,000$
* $1 \leq q \leq 200,000$
* $0 \leq x, y < n$
* $x \ne y$
* $0 \leq z \leq 10000$
* There are no inconsistency in the given information
Input
$n \; q$
$query_1$
$query_2$
:
$query_q$
In the first line, $n$ and $q$ are given. Then, $q$ information/questions are given in the following format.
0 $x \; y\; z$
or
1 $x \; y$
where '0' of the first digit denotes the relate information and '1' denotes the diff question.
Output
For each diff question, print the difference between $a_x$ and $a_y$ $(a_y - a_x)$.
Example
Input
5 6
0 0 2 5
0 1 2 3
1 0 1
1 1 3
0 1 4 8
1 0 4
Output
2
?
10
"Correct Solution:
```
class WUnionFind:
MAX_N = 0
PAR = []
RANK = []
DIFF_WEIGHT=[]
def __init__(self,n):
self.MAX_N = n
self.PAR = [ i for i in range(n)]
self.RANK= [ 0 ] * n
self.DIFF_WEIGHT=[ 0 ] * n
def root(self,x):
if self.PAR[x] == x:
return x
else:
r = self.root(self.PAR[x])
self.DIFF_WEIGHT[x] += self.DIFF_WEIGHT[self.PAR[x]]
self.PAR[x] = r
return r
def weight(self,x):
self.root(x)
return self.DIFF_WEIGHT[x]
def issame(self,x,y):
return self.root(x) == self.root(y)
def diff(self,x,y):
return self.weight(y)-self.weight(x)
def merge(self,x,y,w):
w += self.weight(x)
w -= self.weight(y)
x = self.root(x)
y = self.root(y)
if x == y:
return False
if self.RANK[x] < self.RANK[y]:
x,y = y,x
w = -w
if self.RANK[x] == self.RANK[y]:
self.RANK[x] += 1
self.PAR[y] = x
self.DIFF_WEIGHT[y] = w
return True
N,Q = map(int,input().split())
Ans = []
tree = WUnionFind(N+1)
for _ in range(Q):
s = list(map(int,input().split()))
if s[0] == 0:
x = s[1]
y = s[2]
w = s[3]
tree.merge(x,y,w)
else:
x = s[1]
y = s[2]
if tree.issame(x,y):
a = tree.diff(x,y)
else:
a = '?'
Ans.append(a)
for a in Ans:
print(a)
```
| 24,714 | [
0.54150390625,
0.1859130859375,
-0.0963134765625,
0.26171875,
-0.384765625,
-0.012786865234375,
-0.421142578125,
-0.01361846923828125,
0.35888671875,
1.13671875,
0.2203369140625,
-0.347412109375,
0.285400390625,
-1.1689453125,
-0.2188720703125,
0.13330078125,
-0.7138671875,
-0.6655... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
There is a sequence $A = a_0, a_1, ..., a_{n-1}$. You are given the following information and questions.
* relate$(x, y, z)$: $a_y$ is greater than $a_x$ by $z$
* diff$(x, y)$: report the difference between $a_x$ and $a_y$ $(a_y - a_x)$
Constraints
* $2 \leq n \leq 100,000$
* $1 \leq q \leq 200,000$
* $0 \leq x, y < n$
* $x \ne y$
* $0 \leq z \leq 10000$
* There are no inconsistency in the given information
Input
$n \; q$
$query_1$
$query_2$
:
$query_q$
In the first line, $n$ and $q$ are given. Then, $q$ information/questions are given in the following format.
0 $x \; y\; z$
or
1 $x \; y$
where '0' of the first digit denotes the relate information and '1' denotes the diff question.
Output
For each diff question, print the difference between $a_x$ and $a_y$ $(a_y - a_x)$.
Example
Input
5 6
0 0 2 5
0 1 2 3
1 0 1
1 1 3
0 1 4 8
1 0 4
Output
2
?
10
"Correct Solution:
```
rank = []
p = []
w = []
def makeSet(x):
p.append(x)
rank.append(0)
w.append(0)
def union(x, y):
link(findSet(x), findSet(y))
def link(x, y):
if rank[x] > rank[y]:
p[y] = x
else:
p[x] = y
if rank[x] == rank[y]:
rank[y] = rank[y] + 1
def findSet(x):
if p[x] == x:
return x
i = findSet(p[x])
w[x] += w[p[x]]
p[x] = i
return i
def same(x, y):
return findSet(x) == findSet(y)
def relate (x,y,z):
i = findSet(x)
j = findSet(y)
if rank[i] < rank[j]:
p[i] = j
w[i] = z - w[x] + w[y]
else:
p[j] = i
w[j] = -z - w[y] + w[x]
if rank[i] == rank[j]:
rank[i] += 1
n, q = map(int, input().split())
for i in range(n):
makeSet(i)
for i in range(q):
com, *cmd = map(int, input().split())
if com == 0:
relate(cmd[0], cmd[1],cmd[2])
else:
x, y = cmd
if same(x, y):
print(w[x] - w[y])
else:
print("?")
```
| 24,716 | [
0.50341796875,
0.2335205078125,
-0.0038356781005859375,
0.384521484375,
-0.27099609375,
-0.1502685546875,
-0.43994140625,
-0.235107421875,
0.412841796875,
0.98681640625,
0.038330078125,
-0.190673828125,
0.2127685546875,
-1.0400390625,
-0.1895751953125,
0.07720947265625,
-0.7255859375... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
There is a sequence $A = a_0, a_1, ..., a_{n-1}$. You are given the following information and questions.
* relate$(x, y, z)$: $a_y$ is greater than $a_x$ by $z$
* diff$(x, y)$: report the difference between $a_x$ and $a_y$ $(a_y - a_x)$
Constraints
* $2 \leq n \leq 100,000$
* $1 \leq q \leq 200,000$
* $0 \leq x, y < n$
* $x \ne y$
* $0 \leq z \leq 10000$
* There are no inconsistency in the given information
Input
$n \; q$
$query_1$
$query_2$
:
$query_q$
In the first line, $n$ and $q$ are given. Then, $q$ information/questions are given in the following format.
0 $x \; y\; z$
or
1 $x \; y$
where '0' of the first digit denotes the relate information and '1' denotes the diff question.
Output
For each diff question, print the difference between $a_x$ and $a_y$ $(a_y - a_x)$.
Example
Input
5 6
0 0 2 5
0 1 2 3
1 0 1
1 1 3
0 1 4 8
1 0 4
Output
2
?
10
"Correct Solution:
```
class UnionFind:
def __init__(self, n):
self.tree = [-1] * n
self.rank = [0] * n
self.diff_weight = [0] * n
def unite(self, a, b, w):
w += self.weight(a)
w -= self.weight(b)
a = self.root(a)
b = self.root(b)
if a == b:
return
if self.rank[a] < self.rank[b]:
a, b = b, a
w *= -1
if self.rank[a] == self.rank[b]:
self.rank[a] += 1
self.tree[b] = a
self.diff_weight[b] = w
def root(self, a):
if(self.tree[a] < 0):
return a
else:
res = self.root(self.tree[a])
self.diff_weight[a] += self.diff_weight[self.tree[a]]
self.tree[a] = res
return self.tree[a]
def same(self, a, b):
return self.root(a) == self.root(b)
def weight(self, a):
self.root(a)
return self.diff_weight[a]
def diff(self, a, b):
return self.weight(b) - self.weight(a)
import sys
stdin = sys.stdin
na = lambda: map(int, stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
def main():
n, m = na()
uf = UnionFind(n)
for _ in range(m):
t = list(na())
a, b, c = t[0], t[1], t[2]
if a == 0:
d = t[3]
uf.unite(b, c, d)
else:
if uf.same(b, c):
print(uf.diff(b, c))
else:
print("?")
main()
```
| 24,717 | [
0.53955078125,
0.04083251953125,
-0.047637939453125,
0.315185546875,
-0.245849609375,
-0.163330078125,
-0.302734375,
-0.1539306640625,
0.50439453125,
1.0341796875,
0.12939453125,
-0.316162109375,
0.28515625,
-0.9892578125,
-0.1473388671875,
0.0838623046875,
-0.72900390625,
-0.58789... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
There is a sequence $A = a_0, a_1, ..., a_{n-1}$. You are given the following information and questions.
* relate$(x, y, z)$: $a_y$ is greater than $a_x$ by $z$
* diff$(x, y)$: report the difference between $a_x$ and $a_y$ $(a_y - a_x)$
Constraints
* $2 \leq n \leq 100,000$
* $1 \leq q \leq 200,000$
* $0 \leq x, y < n$
* $x \ne y$
* $0 \leq z \leq 10000$
* There are no inconsistency in the given information
Input
$n \; q$
$query_1$
$query_2$
:
$query_q$
In the first line, $n$ and $q$ are given. Then, $q$ information/questions are given in the following format.
0 $x \; y\; z$
or
1 $x \; y$
where '0' of the first digit denotes the relate information and '1' denotes the diff question.
Output
For each diff question, print the difference between $a_x$ and $a_y$ $(a_y - a_x)$.
Example
Input
5 6
0 0 2 5
0 1 2 3
1 0 1
1 1 3
0 1 4 8
1 0 4
Output
2
?
10
"Correct Solution:
```
class WeightedUnionFind():
def __init__(self,n):
self.n = n
self.parents = [i for i in range(n)]
self.rank = [0 for _ in range(n)]
self.weight = [0 for _ in range(n)]
def find(self,x):
root = x
stack = [root]
while self.parents[root] != root:
root = self.parents[root]
stack.append(root)
while stack:
s = stack.pop()
self.weight[s] += self.weight[self.parents[s]]
while self.parents[x] != root:
parent = self.parents[x]
self.parents[x] = root
x = parent
return root
def unite(self,x,y,w):
xroot = self.find(x)
yroot = self.find(y)
if xroot == yroot:
return
xrank = self.rank[xroot]
yrank = self.rank[yroot]
if xrank < yrank:
self.parents[xroot] = yroot
self.weight[xroot] = w-self.weight[x]+self.weight[y]
else:
self.parents[yroot] = xroot
self.weight[yroot] = -w+self.weight[x]-self.weight[y]
if xrank == yrank:
self.rank[xroot] += 1
def diff(self,x,y):
return self.weight[x]-self.weight[y]
N,Q = map(int,input().split())
uf = WeightedUnionFind(N)
ans = []
for _ in range(Q):
q = list(map(int,input().split()))
if q[0] == 0:
uf.unite(q[1],q[2],q[3])
else:
if uf.find(q[1]) == uf.find(q[2]):
ans.append(uf.diff(q[1],q[2]))
else:
ans.append('?')
print('\n'.join(map(str,ans)))
```
| 24,720 | [
0.4619140625,
0.0022983551025390625,
-0.08270263671875,
0.30517578125,
-0.2900390625,
0.0016412734985351562,
-0.409423828125,
-0.11474609375,
0.546875,
1.001953125,
0.14306640625,
-0.345458984375,
0.2431640625,
-1.1025390625,
-0.2415771484375,
0.042938232421875,
-0.66015625,
-0.633... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a sequence $A = a_0, a_1, ..., a_{n-1}$. You are given the following information and questions.
* relate$(x, y, z)$: $a_y$ is greater than $a_x$ by $z$
* diff$(x, y)$: report the difference between $a_x$ and $a_y$ $(a_y - a_x)$
Constraints
* $2 \leq n \leq 100,000$
* $1 \leq q \leq 200,000$
* $0 \leq x, y < n$
* $x \ne y$
* $0 \leq z \leq 10000$
* There are no inconsistency in the given information
Input
$n \; q$
$query_1$
$query_2$
:
$query_q$
In the first line, $n$ and $q$ are given. Then, $q$ information/questions are given in the following format.
0 $x \; y\; z$
or
1 $x \; y$
where '0' of the first digit denotes the relate information and '1' denotes the diff question.
Output
For each diff question, print the difference between $a_x$ and $a_y$ $(a_y - a_x)$.
Example
Input
5 6
0 0 2 5
0 1 2 3
1 0 1
1 1 3
0 1 4 8
1 0 4
Output
2
?
10
Submitted Solution:
```
class Node:
def __init__(self, root, length, dist):
self.root = root
self.child = None
self.length = length
self.dist = dist
self.tail = root
def relate(x, y, z):
X = A[x].root
Y = A[y].root
if A[X].length > A[Y].length:
x, y, z, X, Y = y, x, -z, Y, X
T = A[Y].tail
A[T].child = X
A[Y].tail = A[X].tail
A[Y].length += A[X].length
tmp = X
xd = A[x].dist
yd = A[y].dist
for _ in range(A[X].length):
A[tmp].root = Y
A[tmp].dist += yd - z - xd
tmp = A[tmp].child
n,q = [int(i) for i in input().split()]
A = []
for i in range(n):
A.append(Node(i, 1, 0))
for _ in range(q):
c = [int(i) for i in input().split()]
if c[0] == 0 and A[c[1]].root != A[c[2]].root:
relate(c[1], c[2], c[3])
elif c[0] == 1:
if A[c[1]].root == A[c[2]].root:
print(A[c[2]].dist - A[c[1]].dist)
else:
print("?")
```
Yes
| 24,722 | [
0.47509765625,
0.1962890625,
-0.14404296875,
0.232177734375,
-0.2890625,
-0.09185791015625,
-0.28662109375,
-0.080078125,
0.35302734375,
0.9033203125,
0.1376953125,
-0.2457275390625,
0.095458984375,
-0.84619140625,
-0.266845703125,
-0.04644775390625,
-0.6015625,
-0.485595703125,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a sequence $A = a_0, a_1, ..., a_{n-1}$. You are given the following information and questions.
* relate$(x, y, z)$: $a_y$ is greater than $a_x$ by $z$
* diff$(x, y)$: report the difference between $a_x$ and $a_y$ $(a_y - a_x)$
Constraints
* $2 \leq n \leq 100,000$
* $1 \leq q \leq 200,000$
* $0 \leq x, y < n$
* $x \ne y$
* $0 \leq z \leq 10000$
* There are no inconsistency in the given information
Input
$n \; q$
$query_1$
$query_2$
:
$query_q$
In the first line, $n$ and $q$ are given. Then, $q$ information/questions are given in the following format.
0 $x \; y\; z$
or
1 $x \; y$
where '0' of the first digit denotes the relate information and '1' denotes the diff question.
Output
For each diff question, print the difference between $a_x$ and $a_y$ $(a_y - a_x)$.
Example
Input
5 6
0 0 2 5
0 1 2 3
1 0 1
1 1 3
0 1 4 8
1 0 4
Output
2
?
10
Submitted Solution:
```
class WeightedUnionFind:
def __init__(self, n):
self.par = [i for i in range(n+1)]
self.rank = [0] * (n+1)
# 根への距離を管理
self.weight = [0] * (n+1)
# 検索
def find(self, x):
if self.par[x] == x:
return x
else:
y = self.find(self.par[x])
# 親への重みを追加しながら根まで走査
self.weight[x] += self.weight[self.par[x]]
self.par[x] = y
return y
# 併合
def union(self, x, y, w):
rx = self.find(x)
ry = self.find(y)
# xの木の高さ < yの木の高さ
if self.rank[rx] < self.rank[ry]:
self.par[rx] = ry
self.weight[rx] = w - self.weight[x] + self.weight[y]
# xの木の高さ ≧ yの木の高さ
else:
self.par[ry] = rx
self.weight[ry] = -w - self.weight[y] + self.weight[x]
# 木の高さが同じだった場合の処理
if self.rank[rx] == self.rank[ry]:
self.rank[rx] += 1
# 同じ集合に属するか
def same(self, x, y):
return self.find(x) == self.find(y)
# xからyへのコスト
def diff(self, x, y):
if self.find(x) != self.find(y):
return "?"
return self.weight[x] - self.weight[y]
n, q = map(int, input().split())
tree = WeightedUnionFind(n)
for i in range(q):
query = list(map(int, input().split()))
if query[0] == 0:
x, y, z = query[1:4]
tree.union(x, y, z)
else:
x, y = query[1:3]
ans = tree.diff(x, y)
print(ans)
```
Yes
| 24,723 | [
0.437255859375,
0.050140380859375,
-0.1815185546875,
0.258056640625,
-0.348876953125,
0.0789794921875,
-0.326416015625,
-0.1566162109375,
0.403564453125,
0.94775390625,
0.2396240234375,
-0.0261383056640625,
0.142333984375,
-1.0400390625,
-0.30322265625,
-0.169921875,
-0.609375,
-0.... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a sequence $A = a_0, a_1, ..., a_{n-1}$. You are given the following information and questions.
* relate$(x, y, z)$: $a_y$ is greater than $a_x$ by $z$
* diff$(x, y)$: report the difference between $a_x$ and $a_y$ $(a_y - a_x)$
Constraints
* $2 \leq n \leq 100,000$
* $1 \leq q \leq 200,000$
* $0 \leq x, y < n$
* $x \ne y$
* $0 \leq z \leq 10000$
* There are no inconsistency in the given information
Input
$n \; q$
$query_1$
$query_2$
:
$query_q$
In the first line, $n$ and $q$ are given. Then, $q$ information/questions are given in the following format.
0 $x \; y\; z$
or
1 $x \; y$
where '0' of the first digit denotes the relate information and '1' denotes the diff question.
Output
For each diff question, print the difference between $a_x$ and $a_y$ $(a_y - a_x)$.
Example
Input
5 6
0 0 2 5
0 1 2 3
1 0 1
1 1 3
0 1 4 8
1 0 4
Output
2
?
10
Submitted Solution:
```
#! python3
# weighted_union_find_tree.py
class WeightedUnionFindTree():
def __init__(self, n):
self.par = [i for i in range(n+1)]
self.rank = [0] * (n+1)
self.weight = [0] * (n+1)
def find(self, x):
if self.par[x] == x:
return x
else:
y = self.find(self.par[x])
self.weight[x] += self.weight[self.par[x]]
self.par[x] = y
return y
def unite(self, x, y, w):
rx = self.find(x)
ry = self.find(y)
if self.rank[rx] < self.rank[ry]:
self.par[rx] = ry
self.weight[rx] = w - self.weight[x] + self.weight[y]
else:
self.par[ry] = rx
self.weight[ry] = -w - self.weight[y] + self.weight[x]
if self.rank[rx] == self.rank[ry]:
self.rank[rx] += 1
def same(self, x, y):
return self.find(x) == self.find(y)
def diff(self, x, y):
return self.weight[x] - self.weight[y]
n, q = [int(x) for x in input().split(' ')]
wuft = WeightedUnionFindTree(n-1)
for i in range(q):
query = [int(x) for x in input().split(' ')]
if query[0] == 0:
x, y, z = query[1:]
wuft.unite(x, y, z)
elif query[0] == 1:
x, y = query[1:]
if wuft.same(x, y):
print(wuft.diff(x,y))
else:
print('?')
```
Yes
| 24,724 | [
0.467041015625,
-0.045684814453125,
-0.155029296875,
0.27392578125,
-0.298828125,
0.0843505859375,
-0.389404296875,
-0.09368896484375,
0.41259765625,
0.89208984375,
0.1583251953125,
-0.2001953125,
0.16015625,
-0.90869140625,
-0.126953125,
-0.021087646484375,
-0.67626953125,
-0.5761... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a sequence $A = a_0, a_1, ..., a_{n-1}$. You are given the following information and questions.
* relate$(x, y, z)$: $a_y$ is greater than $a_x$ by $z$
* diff$(x, y)$: report the difference between $a_x$ and $a_y$ $(a_y - a_x)$
Constraints
* $2 \leq n \leq 100,000$
* $1 \leq q \leq 200,000$
* $0 \leq x, y < n$
* $x \ne y$
* $0 \leq z \leq 10000$
* There are no inconsistency in the given information
Input
$n \; q$
$query_1$
$query_2$
:
$query_q$
In the first line, $n$ and $q$ are given. Then, $q$ information/questions are given in the following format.
0 $x \; y\; z$
or
1 $x \; y$
where '0' of the first digit denotes the relate information and '1' denotes the diff question.
Output
For each diff question, print the difference between $a_x$ and $a_y$ $(a_y - a_x)$.
Example
Input
5 6
0 0 2 5
0 1 2 3
1 0 1
1 1 3
0 1 4 8
1 0 4
Output
2
?
10
Submitted Solution:
```
import sys
input = sys.stdin.readline
class WeightedUnionFind:
def __init__(self, N):
self.parent = list(range(N))
self.rank = [0] * N
self.weight = [0] * N
def find(self, x):
stack = [x]
while self.parent[x] != x:
x = self.parent[x]
stack.append(x)
r = stack[-1]
while stack:
x = stack.pop()
self.weight[x] += self.weight[self.parent[x]]
self.parent[x] = r
return r
def unite(self, x, y, w):
rx = self.find(x)
ry = self.find(y)
w += self.weight[x] - self.weight[y]
x = rx
y = ry
if x == y:
return False
if self.rank[x] < self.rank[y]:
x, y = y, x
w = -w
if self.rank[x] == self.rank[y]:
self.rank[x] += 1
self.parent[y] = x
self.weight[y] = w
return True
def same(self, x, y):
return self.find(x) == self.find(y)
def diff(self, x, y):
self.find(x)
self.find(y)
return self.weight[y] - self.weight[x]
n, q = map(int, input().split())
wuf = WeightedUnionFind(n)
for _ in range(q):
t, *data = map(int, input().split())
if t == 0:
x, y, z = data
wuf.unite(x, y, z)
else:
x, y = data
if not wuf.same(x, y):
print('?')
else:
print(wuf.diff(x, y))
```
Yes
| 24,725 | [
0.399169921875,
-0.0718994140625,
-0.173583984375,
0.349609375,
-0.44091796875,
0.154052734375,
-0.39990234375,
-0.08123779296875,
0.416259765625,
0.91259765625,
0.1666259765625,
-0.1776123046875,
0.165771484375,
-0.9716796875,
-0.291748046875,
0.016815185546875,
-0.6708984375,
-0.... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a sequence $A = a_0, a_1, ..., a_{n-1}$. You are given the following information and questions.
* relate$(x, y, z)$: $a_y$ is greater than $a_x$ by $z$
* diff$(x, y)$: report the difference between $a_x$ and $a_y$ $(a_y - a_x)$
Constraints
* $2 \leq n \leq 100,000$
* $1 \leq q \leq 200,000$
* $0 \leq x, y < n$
* $x \ne y$
* $0 \leq z \leq 10000$
* There are no inconsistency in the given information
Input
$n \; q$
$query_1$
$query_2$
:
$query_q$
In the first line, $n$ and $q$ are given. Then, $q$ information/questions are given in the following format.
0 $x \; y\; z$
or
1 $x \; y$
where '0' of the first digit denotes the relate information and '1' denotes the diff question.
Output
For each diff question, print the difference between $a_x$ and $a_y$ $(a_y - a_x)$.
Example
Input
5 6
0 0 2 5
0 1 2 3
1 0 1
1 1 3
0 1 4 8
1 0 4
Output
2
?
10
Submitted Solution:
```
n, q = map(int, input().split())
nodes = [x for x in range(n)]
weight = [0 for x in range(n)]
def unite(x, y, w) :
if nodes[x] < nodes[y] :
nodes[y] = x
weight[y] = w
else :
nodes[x] = y
weight[x] = -w
def get_root(idx) :
if nodes[idx] == idx :
return idx
else :
r = get_root(nodes[idx])
weight[idx] += weight[nodes[idx]]
nodes[idx] = r
return r
for i in range(q) :
ip = input()
# union
if ip[0] == "0" :
q, a, b, w = map(int, ip.split())
unite(a, b, w)
# evaluate
else :
q, a, b = map(int, ip.split())
if get_root(a) == get_root(b) :
print(weight[b] - weight[a])
else :
print("?")
```
No
| 24,726 | [
0.4208984375,
0.025177001953125,
-0.20654296875,
0.29736328125,
-0.260498046875,
-0.040618896484375,
-0.388916015625,
-0.1268310546875,
0.3984375,
0.8984375,
0.11114501953125,
-0.236083984375,
0.1434326171875,
-1.0380859375,
-0.2161865234375,
-0.050201416015625,
-0.7314453125,
-0.6... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a sequence $A = a_0, a_1, ..., a_{n-1}$. You are given the following information and questions.
* relate$(x, y, z)$: $a_y$ is greater than $a_x$ by $z$
* diff$(x, y)$: report the difference between $a_x$ and $a_y$ $(a_y - a_x)$
Constraints
* $2 \leq n \leq 100,000$
* $1 \leq q \leq 200,000$
* $0 \leq x, y < n$
* $x \ne y$
* $0 \leq z \leq 10000$
* There are no inconsistency in the given information
Input
$n \; q$
$query_1$
$query_2$
:
$query_q$
In the first line, $n$ and $q$ are given. Then, $q$ information/questions are given in the following format.
0 $x \; y\; z$
or
1 $x \; y$
where '0' of the first digit denotes the relate information and '1' denotes the diff question.
Output
For each diff question, print the difference between $a_x$ and $a_y$ $(a_y - a_x)$.
Example
Input
5 6
0 0 2 5
0 1 2 3
1 0 1
1 1 3
0 1 4 8
1 0 4
Output
2
?
10
Submitted Solution:
```
# Disjoint Set: Union Find Trees
[p, rank] = [[], []]
[n, q] = list(map(int, input().split()))
w = [0 for i in range(n)]
path_c = [[] for i in range(n)]
path_c_len = [0 for i in range(n)]
def makeSet(x):
global p, rank
p.append(x)
rank.append(0)
def findSet(x):
global p
if x != p[x]:
p[x] = findSet(p[x])
return p[x]
def link(x, y):
global p, rank
if rank[x] > rank[y]:
p[y] = x
else:
p[x] = y
if rank[x] == rank[y]:
rank[y] += 1
def union(x, y):
link(findSet(x), findSet(y))
def same(x, y):
if findSet(x) == findSet(y):
return 1
else:
return 0
def relate(x, y, z):
global w, path_c
path_c[y].append((x, z))
path_c_len[y] += 1
#print(w)
if w[y] == 0:
w[y] = w[x] + z
else:
update(x, y, z)
union(x, y)
def update(x, y, z):
global w, path_c
w[x] = w[y] - z
for i in range(path_c_len[x]):
update(path_c[x][i][0], x, path_c[x][i][1])
def diff(x, y):
if same(x, y) == 1:
global w
return w[y] - w[x]
#return abs(w[y] - w[x])
else:
return "?"
'''
print(p)
print(rank)
print(w)
print("\n")
'''
for i in range(n):
makeSet(i)
for i in range(q):
data = list(map(int, input().split()))
if data[0] == 0:
relate(data[1], data[2], data[3])
else:
print(diff(data[1], data[2]))
'''
print("\n")
print(p)
print(rank)
print(w)
print("\n")
'''
```
No
| 24,727 | [
0.410400390625,
0.175048828125,
-0.050048828125,
0.29736328125,
-0.3974609375,
-0.1373291015625,
-0.366943359375,
-0.138671875,
0.36083984375,
1.107421875,
0.04644775390625,
-0.068359375,
0.106689453125,
-0.888671875,
-0.1898193359375,
-0.171142578125,
-0.708984375,
-0.49658203125,... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a sequence $A = a_0, a_1, ..., a_{n-1}$. You are given the following information and questions.
* relate$(x, y, z)$: $a_y$ is greater than $a_x$ by $z$
* diff$(x, y)$: report the difference between $a_x$ and $a_y$ $(a_y - a_x)$
Constraints
* $2 \leq n \leq 100,000$
* $1 \leq q \leq 200,000$
* $0 \leq x, y < n$
* $x \ne y$
* $0 \leq z \leq 10000$
* There are no inconsistency in the given information
Input
$n \; q$
$query_1$
$query_2$
:
$query_q$
In the first line, $n$ and $q$ are given. Then, $q$ information/questions are given in the following format.
0 $x \; y\; z$
or
1 $x \; y$
where '0' of the first digit denotes the relate information and '1' denotes the diff question.
Output
For each diff question, print the difference between $a_x$ and $a_y$ $(a_y - a_x)$.
Example
Input
5 6
0 0 2 5
0 1 2 3
1 0 1
1 1 3
0 1 4 8
1 0 4
Output
2
?
10
Submitted Solution:
```
# Disjoint Set: Union Find Trees
[p, rank] = [[], []]
[n, q] = list(map(int, input().split()))
w = [0 for i in range(n)]
def makeSet(x):
global p, rank
p.append(x)
rank.append(0)
def findSet(x):
global p
if x != p[x]:
p[x] = findSet(p[x])
return p[x]
def link(x, y):
global p, rank
if rank[x] > rank[y]:
p[y] = x
else:
p[x] = y
if rank[x] == rank[y]:
rank[y] += 1
def union(x, y):
link(findSet(x), findSet(y))
def same(x, y):
if findSet(x) == findSet(y):
return 1
else:
return 0
def relate(x, y, z):
global w
#print(w)
if w[y] == 0:
w[y] = w[x] + z
else:
w[x] = w[y] - z
#print("cost:", w[y])
union(x, y)
'''
def cost(x, y, n, total):
global w, d
#time += 1
#if time > 5:
# return None
for i in range(len(w[x])):
if d[w[x][i][0]] == 0:
#print(x, w[x][i][0])
d[w[x][i][0]] = 1
if y == w[x][i][0]:
total += w[x][i][1]
return total
result = cost(w[x][i][0], y, n, total)
if result != None:
total = result + w[x][i][1]
return total
for i in range(n):
for j in range(len(w[i])):
if w[i][j][0] == x and d[i] == 0:
#print(i, x)
d[i] = 1
if y == i:
total -= w[i][j][1]
return total
result = cost(i, y, n, total)
if result != None:
total = result - w[i][j][1]
return total
'''
def diff(x, y):
if same(x, y) == 1:
global w
return w[y] - w[x]
'''
global d
total = 0
d = [0 for i in range(n)]
d[x] = 1
return cost(x, y, n, total)
'''
else:
return "?"
'''
print(p)
print(rank)
print(w)
print("\n")
'''
for i in range(n):
makeSet(i)
#w = [0 for i in range(n)]
for i in range(q):
data = list(map(int, input().split()))
if data[0] == 0:
relate(data[1], data[2], data[3])
else:
print(diff(data[1], data[2]))
'''
print("\n")
print(p)
print(rank)
print(w)
print("\n")
'''
```
No
| 24,728 | [
0.384033203125,
0.135986328125,
-0.053924560546875,
0.326416015625,
-0.3310546875,
-0.13671875,
-0.39453125,
-0.1448974609375,
0.376220703125,
1.033203125,
0.044403076171875,
-0.057037353515625,
0.1195068359375,
-0.85009765625,
-0.1566162109375,
-0.10382080078125,
-0.72900390625,
-... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a sequence $A = a_0, a_1, ..., a_{n-1}$. You are given the following information and questions.
* relate$(x, y, z)$: $a_y$ is greater than $a_x$ by $z$
* diff$(x, y)$: report the difference between $a_x$ and $a_y$ $(a_y - a_x)$
Constraints
* $2 \leq n \leq 100,000$
* $1 \leq q \leq 200,000$
* $0 \leq x, y < n$
* $x \ne y$
* $0 \leq z \leq 10000$
* There are no inconsistency in the given information
Input
$n \; q$
$query_1$
$query_2$
:
$query_q$
In the first line, $n$ and $q$ are given. Then, $q$ information/questions are given in the following format.
0 $x \; y\; z$
or
1 $x \; y$
where '0' of the first digit denotes the relate information and '1' denotes the diff question.
Output
For each diff question, print the difference between $a_x$ and $a_y$ $(a_y - a_x)$.
Example
Input
5 6
0 0 2 5
0 1 2 3
1 0 1
1 1 3
0 1 4 8
1 0 4
Output
2
?
10
Submitted Solution:
```
MAX = 10003
N, Q = (int(x) for x in input().split())
ws = [0 for i in range(MAX)]
par = [-1 for i in range(N)]
def weight(x):
root(x)
return ws[x]
def root(x):
if par[x] < 0: return x
p = root(par[x])
ws[x] = ws[x] + ws[par[x]]
par[x] = p
return par[x]
return y
def unite(y, x, z):
z = z + weight(x)
z = z - weight(y)
x = root(x)
y = root(y)
if x == y: return 0
if par[y] < par[x]:
tmp = x
x = y
y = tmp
z = -z
par[x] = par[x] + par[y]
par[y] = x
ws[y] = z
return 1
def diff(x,y):
if root(x) != root(y) :return -1
ans = ws[x] - ws[y]
return ans
for q in range(Q):
t, *cmd = (int(x) for x in input().split())
if t:
x, y = cmd
z = diff(x, y)
if z==-1:print("?")
else :print(z)
else:
x, y, z = cmd
unite(x, y, z)
```
No
| 24,729 | [
0.42724609375,
0.1697998046875,
-0.1341552734375,
0.21826171875,
-0.41748046875,
0.049163818359375,
-0.387939453125,
-0.0199737548828125,
0.31591796875,
0.95654296875,
0.166015625,
-0.1510009765625,
0.06878662109375,
-1.0263671875,
-0.278076171875,
-0.11309814453125,
-0.7509765625,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.
The participants are offered m problems on the contest. For each friend, Gena knows what problems he can solve. But Gena's friends won't agree to help Gena for nothing: the i-th friend asks Gena xi rubles for his help in solving all the problems he can. Also, the friend agreed to write a code for Gena only if Gena's computer is connected to at least ki monitors, each monitor costs b rubles.
Gena is careful with money, so he wants to spend as little money as possible to solve all the problems. Help Gena, tell him how to spend the smallest possible amount of money. Initially, there's no monitors connected to Gena's computer.
Input
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor.
The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contains three integers xi, ki and mi (1 ≤ xi ≤ 109; 1 ≤ ki ≤ 109; 1 ≤ mi ≤ m) — the desired amount of money, monitors and the number of problems the friend can solve. The (2i + 1)-th line contains mi distinct positive integers — the numbers of problems that the i-th friend can solve. The problems are numbered from 1 to m.
Output
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
Examples
Input
2 2 1
100 1 1
2
100 2 1
1
Output
202
Input
3 2 5
100 1 1
1
100 1 1
2
200 1 2
1 2
Output
205
Input
1 2 1
1 1 1
1
Output
-1
Submitted Solution:
```
def calc(zzz, mons0):
if not zzz:
return mons0*b
z = zzz.pop()
minc=10**9
for i in dct[z]:
dr=drug[i]
price2, mon2, zz2 = dr
mons=max(mon2, mons0)
cost2 = calc(zzz-set(zz2), mons)
c=cost2+price2
if c<minc:
minc = c
return minc
def input_row():
return list(map(int, input().strip().split(' ')))
if __name__=='__main__':
zzz=set()
dct={}
drug={}
xxx = input_row()
n, m, b = xxx
for i in range(n):
x,k,_ = input_row()
zz = input_row()
drug[i] = x,k, zz
for z in zz:
if z not in dct:
dct[z]=[]
dct[z].append(i)
zzz=zzz.union(zz)
if len(zzz)<m:
print (-1)
else:
solved=set()
cost=0
mons=0
cost1 =calc(zzz, mons)
print (cost+cost1)
```
No
| 25,094 | [
0.59228515625,
-0.07867431640625,
-0.048797607421875,
0.213623046875,
-0.53662109375,
-0.537109375,
0.413818359375,
0.282470703125,
-0.1636962890625,
0.5966796875,
0.276611328125,
-0.0528564453125,
0.1553955078125,
-0.490234375,
-0.375732421875,
-0.00789642333984375,
-0.8154296875,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.
The participants are offered m problems on the contest. For each friend, Gena knows what problems he can solve. But Gena's friends won't agree to help Gena for nothing: the i-th friend asks Gena xi rubles for his help in solving all the problems he can. Also, the friend agreed to write a code for Gena only if Gena's computer is connected to at least ki monitors, each monitor costs b rubles.
Gena is careful with money, so he wants to spend as little money as possible to solve all the problems. Help Gena, tell him how to spend the smallest possible amount of money. Initially, there's no monitors connected to Gena's computer.
Input
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor.
The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contains three integers xi, ki and mi (1 ≤ xi ≤ 109; 1 ≤ ki ≤ 109; 1 ≤ mi ≤ m) — the desired amount of money, monitors and the number of problems the friend can solve. The (2i + 1)-th line contains mi distinct positive integers — the numbers of problems that the i-th friend can solve. The problems are numbered from 1 to m.
Output
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
Examples
Input
2 2 1
100 1 1
2
100 2 1
1
Output
202
Input
3 2 5
100 1 1
1
100 1 1
2
200 1 2
1 2
Output
205
Input
1 2 1
1 1 1
1
Output
-1
Submitted Solution:
```
def calc(zzz, mons0):
if not zzz:
return mons0*b
z = zzz.pop()
minc=10**9
for i in dct[z]:
dr=drug[i]
price2, mon2, zz2 = dr
mons=max(mon2, mons0)
cost2 = calc(zzz-set(zz2), mons)
c=cost2+price2
if c<minc:
minc = c
return minc
def input_row():
return list(map(int, input().strip().split(' ')))
if __name__=='__main__':
zzz=set()
dct={}
drug={}
xxx = input_row()
n, m, b = xxx
for i in range(n):
x,k,_ = input_row()
zz = input_row()
drug[i] = x,k, zz
for z in zz:
if z not in dct:
dct[z]=[]
dct[z].append(i)
zzz=zzz.union(zz)
if len(zzz)<m:
print (False)
else:
solved=set()
cost=0
mons=0
cost1 =calc(zzz, mons)
print (cost+cost1)
```
No
| 25,095 | [
0.59228515625,
-0.07867431640625,
-0.048797607421875,
0.213623046875,
-0.53662109375,
-0.537109375,
0.413818359375,
0.282470703125,
-0.1636962890625,
0.5966796875,
0.276611328125,
-0.0528564453125,
0.1553955078125,
-0.490234375,
-0.375732421875,
-0.00789642333984375,
-0.8154296875,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.
The participants are offered m problems on the contest. For each friend, Gena knows what problems he can solve. But Gena's friends won't agree to help Gena for nothing: the i-th friend asks Gena xi rubles for his help in solving all the problems he can. Also, the friend agreed to write a code for Gena only if Gena's computer is connected to at least ki monitors, each monitor costs b rubles.
Gena is careful with money, so he wants to spend as little money as possible to solve all the problems. Help Gena, tell him how to spend the smallest possible amount of money. Initially, there's no monitors connected to Gena's computer.
Input
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor.
The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contains three integers xi, ki and mi (1 ≤ xi ≤ 109; 1 ≤ ki ≤ 109; 1 ≤ mi ≤ m) — the desired amount of money, monitors and the number of problems the friend can solve. The (2i + 1)-th line contains mi distinct positive integers — the numbers of problems that the i-th friend can solve. The problems are numbered from 1 to m.
Output
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
Examples
Input
2 2 1
100 1 1
2
100 2 1
1
Output
202
Input
3 2 5
100 1 1
1
100 1 1
2
200 1 2
1 2
Output
205
Input
1 2 1
1 1 1
1
Output
-1
Submitted Solution:
```
def calc(zzz, mons0):
if not zzz:
return mons0*b
z = zzz.pop()
minc=10**9
for i in dct[z]:
dr=drug[i]
price2, mon2, zz2 = dr
mons=max(mon2, mons0)
cost2 = calc(zzz-set(zz2), mons)
c=cost2+price2
if c<minc:
minc = c
return minc
def input_row():
return list(map(int, input().strip().split(' ')))
zzz=set()
dct={}
drug={}
xxx = input_row()
n, m, b = xxx
#print( list(range(1,m+1)))
for i in range(n):
x,k,_ = input_row()
zz = input_row()
drug[i] = x,k, zz
for z in zz:
if z not in dct:
dct[z]=[]
dct[z].append(i)
zzz=zzz.union(zz)
#print(sorted(dct.keys(), key=lambda x:len(dct[x])))
if len(zzz)<m:
print (False)
else:
solved=set()
cost=0
mons=0
cost1 =calc(zzz, mons)
print (cost+cost1)
```
No
| 25,096 | [
0.59228515625,
-0.07867431640625,
-0.048797607421875,
0.213623046875,
-0.53662109375,
-0.537109375,
0.413818359375,
0.282470703125,
-0.1636962890625,
0.5966796875,
0.276611328125,
-0.0528564453125,
0.1553955078125,
-0.490234375,
-0.375732421875,
-0.00789642333984375,
-0.8154296875,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The organizers of a programming contest have decided to present t-shirts to participants. There are six different t-shirts sizes in this problem: S, M, L, XL, XXL, XXXL (sizes are listed in increasing order). The t-shirts are already prepared. For each size from S to XXXL you are given the number of t-shirts of this size.
During the registration, the organizers asked each of the n participants about the t-shirt size he wants. If a participant hesitated between two sizes, he could specify two neighboring sizes — this means that any of these two sizes suits him.
Write a program that will determine whether it is possible to present a t-shirt to each participant of the competition, or not. Of course, each participant should get a t-shirt of proper size:
* the size he wanted, if he specified one size;
* any of the two neibouring sizes, if he specified two sizes.
If it is possible, the program should find any valid distribution of the t-shirts.
Input
The first line of the input contains six non-negative integers — the number of t-shirts of each size. The numbers are given for the sizes S, M, L, XL, XXL, XXXL, respectively. The total number of t-shirts doesn't exceed 100 000.
The second line contains positive integer n (1 ≤ n ≤ 100 000) — the number of participants.
The following n lines contain the sizes specified by the participants, one line per participant. The i-th line contains information provided by the i-th participant: single size or two sizes separated by comma (without any spaces). If there are two sizes, the sizes are written in increasing order. It is guaranteed that two sizes separated by comma are neighboring.
Output
If it is not possible to present a t-shirt to each participant, print «NO» (without quotes).
Otherwise, print n + 1 lines. In the first line print «YES» (without quotes). In the following n lines print the t-shirt sizes the orginizers should give to participants, one per line. The order of the participants should be the same as in the input.
If there are multiple solutions, print any of them.
Examples
Input
0 1 0 1 1 0
3
XL
S,M
XL,XXL
Output
YES
XL
M
XXL
Input
1 1 2 0 1 1
5
S
M
S,M
XXL,XXXL
XL,XXL
Output
NO
Submitted Solution:
```
cs = list(map(int, input().split(" ")))
camisas = {}
camisas['S'] = cs[0]
camisas['M'] = cs[1]
camisas['L'] = cs[2]
camisas['XL'] = cs[3]
camisas['XXL'] = cs[4]
camisas['XXXL'] = cs[5]
p = int(input())
resposta = {}
possivel = True
s = []
m = []
l = []
xl = []
xxl = []
for i in range(p):
camisa_pessoa = list(input().split(","))
if len(camisa_pessoa) == 1:
camisa = camisa_pessoa[0]
if camisas[camisa] > 0:
resposta[i] = camisa
camisas[camisa] = camisas[camisa] - 1
else:
possivel = False
else:
if camisa_pessoa[0] == 'S': s.append(i)
elif camisa_pessoa[0] == 'M': m.append(i)
elif camisa_pessoa[0] == 'L': l.append(i)
elif camisa_pessoa[0] == 'XL': xl.append(i)
elif camisa_pessoa[0] == 'XXL': xxl.append(i)
if possivel:
for i in s:
if camisas['S'] > 0:
camisas['S'] = camisas['S'] - 1
resposta[i] = 'S'
elif camisas['M'] > 0:
camisas['M'] = camisas['M'] - 1
resposta[i] = 'M'
else:
possivel = False
break
if possivel:
for i in m:
if camisas['M'] > 0:
camisas['M'] = camisas['M'] - 1
resposta[i] = 'M'
elif camisas['L'] > 0:
camisas['L'] = camisas['L'] - 1
resposta[i] = 'L'
else:
possivel = False
break
if possivel:
for i in l:
if camisas['L'] > 0:
camisas['L'] = camisas['L'] - 1
resposta[i] = 'L'
elif camisas['XL'] > 0:
camisas['XL'] = camisas['XL'] - 1
resposta[i] = 'XL'
else:
possivel = False
break
if possivel:
for i in xl:
if camisas['XL'] > 0:
camisas['XL'] = camisas['XL'] - 1
resposta[i] = 'XL'
elif camisas['XXL'] > 0:
camisas['XXL'] = camisas['XXL'] - 1
resposta[i] = 'XXL'
else:
possivel = False
break
if possivel:
for i in xxl:
if camisas['XXL'] > 0:
camisas['XXL'] = camisas['XXL'] - 1
resposta[i] = 'XXL'
elif camisas['XXXL'] > 0:
camisas['XXXL'] = camisas['XXXL'] - 1
resposta[i] = 'XXXL'
else:
possivel = False
break
if not possivel:
print('NO')
else:
print('YES')
for k in range(p):
print(resposta[k])
```
Yes
| 25,244 | [
0.31640625,
0.0477294921875,
0.2352294921875,
0.058990478515625,
-0.7373046875,
-0.335693359375,
-0.26318359375,
0.190185546875,
-0.222412109375,
0.8955078125,
0.27392578125,
-0.11126708984375,
0.30712890625,
-0.2568359375,
-0.33935546875,
0.000018417835235595703,
-0.3251953125,
-0... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The organizers of a programming contest have decided to present t-shirts to participants. There are six different t-shirts sizes in this problem: S, M, L, XL, XXL, XXXL (sizes are listed in increasing order). The t-shirts are already prepared. For each size from S to XXXL you are given the number of t-shirts of this size.
During the registration, the organizers asked each of the n participants about the t-shirt size he wants. If a participant hesitated between two sizes, he could specify two neighboring sizes — this means that any of these two sizes suits him.
Write a program that will determine whether it is possible to present a t-shirt to each participant of the competition, or not. Of course, each participant should get a t-shirt of proper size:
* the size he wanted, if he specified one size;
* any of the two neibouring sizes, if he specified two sizes.
If it is possible, the program should find any valid distribution of the t-shirts.
Input
The first line of the input contains six non-negative integers — the number of t-shirts of each size. The numbers are given for the sizes S, M, L, XL, XXL, XXXL, respectively. The total number of t-shirts doesn't exceed 100 000.
The second line contains positive integer n (1 ≤ n ≤ 100 000) — the number of participants.
The following n lines contain the sizes specified by the participants, one line per participant. The i-th line contains information provided by the i-th participant: single size or two sizes separated by comma (without any spaces). If there are two sizes, the sizes are written in increasing order. It is guaranteed that two sizes separated by comma are neighboring.
Output
If it is not possible to present a t-shirt to each participant, print «NO» (without quotes).
Otherwise, print n + 1 lines. In the first line print «YES» (without quotes). In the following n lines print the t-shirt sizes the orginizers should give to participants, one per line. The order of the participants should be the same as in the input.
If there are multiple solutions, print any of them.
Examples
Input
0 1 0 1 1 0
3
XL
S,M
XL,XXL
Output
YES
XL
M
XXL
Input
1 1 2 0 1 1
5
S
M
S,M
XXL,XXXL
XL,XXL
Output
NO
Submitted Solution:
```
import copy
sizes = list(map(int, input().split()))
participants = {}
participants_list = []
N = int(input())
for i in range(N):
s = input()
size_string = s
d = participants.get(size_string, 0)
participants[size_string] = d + 1
participants_list.append(size_string)
single_sizes = ["S", "M", "L", "XL", "XXL", "XXXL"]
multiple_sizes = [
single_sizes[i] + "," + single_sizes[i + 1]
for i in range(len(single_sizes) - 1)
]
size_to_index = {
"S": 0,
"M": 1,
"L": 2,
"XL": 3,
"XXL": 4,
"XXXL": 5,
}
# print(sizes)
# print(participants)
# print(single_sizes)
# print(multiple_sizes)
multiple_answers = {}
sizes_copy = copy.copy(sizes)
res = "YES"
for single_size in single_sizes:
nb_participants = participants.get(single_size, 0)
ind = size_to_index[single_size]
if nb_participants > sizes_copy[ind]:
res = "NO"
break
sizes_copy[ind] -= nb_participants
for multiple_size in multiple_sizes:
size_1, size_2 = multiple_size.split(",")
nb_participants = participants.get(multiple_size, 0)
ind_1 = size_to_index[size_1]
first_size = min(sizes_copy[ind_1], nb_participants)
sizes_copy[ind_1] -= first_size
nb_participants -= first_size
ind_2 = size_to_index[size_2]
if nb_participants > sizes_copy[ind_2]:
res = "NO"
break
sizes_copy[ind_2] -= nb_participants
multiple_answers[multiple_size] = first_size, nb_participants
print(res)
# print(multiple_answers)
if res == "YES":
for participant_size in participants_list:
if "," in participant_size:
size_1, size_2 = participant_size.split(",")
r1, r2 = multiple_answers.get(participant_size, 0)
if r1 > 0:
print(size_1)
r1 -= 1
else:
print(size_2)
r2 -= 1
multiple_answers[participant_size] = r1, r2
else:
print(participant_size)
```
Yes
| 25,245 | [
0.31640625,
0.0477294921875,
0.2352294921875,
0.058990478515625,
-0.7373046875,
-0.335693359375,
-0.26318359375,
0.190185546875,
-0.222412109375,
0.8955078125,
0.27392578125,
-0.11126708984375,
0.30712890625,
-0.2568359375,
-0.33935546875,
0.000018417835235595703,
-0.3251953125,
-0... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The organizers of a programming contest have decided to present t-shirts to participants. There are six different t-shirts sizes in this problem: S, M, L, XL, XXL, XXXL (sizes are listed in increasing order). The t-shirts are already prepared. For each size from S to XXXL you are given the number of t-shirts of this size.
During the registration, the organizers asked each of the n participants about the t-shirt size he wants. If a participant hesitated between two sizes, he could specify two neighboring sizes — this means that any of these two sizes suits him.
Write a program that will determine whether it is possible to present a t-shirt to each participant of the competition, or not. Of course, each participant should get a t-shirt of proper size:
* the size he wanted, if he specified one size;
* any of the two neibouring sizes, if he specified two sizes.
If it is possible, the program should find any valid distribution of the t-shirts.
Input
The first line of the input contains six non-negative integers — the number of t-shirts of each size. The numbers are given for the sizes S, M, L, XL, XXL, XXXL, respectively. The total number of t-shirts doesn't exceed 100 000.
The second line contains positive integer n (1 ≤ n ≤ 100 000) — the number of participants.
The following n lines contain the sizes specified by the participants, one line per participant. The i-th line contains information provided by the i-th participant: single size or two sizes separated by comma (without any spaces). If there are two sizes, the sizes are written in increasing order. It is guaranteed that two sizes separated by comma are neighboring.
Output
If it is not possible to present a t-shirt to each participant, print «NO» (without quotes).
Otherwise, print n + 1 lines. In the first line print «YES» (without quotes). In the following n lines print the t-shirt sizes the orginizers should give to participants, one per line. The order of the participants should be the same as in the input.
If there are multiple solutions, print any of them.
Examples
Input
0 1 0 1 1 0
3
XL
S,M
XL,XXL
Output
YES
XL
M
XXL
Input
1 1 2 0 1 1
5
S
M
S,M
XXL,XXXL
XL,XXL
Output
NO
Submitted Solution:
```
# print(list(zip(input().split(), "S M L XL XXL XXXL".split())))
SIZES = "S M L XL XXL XXXL".split()
have = {key:int(count) for count,key in zip(input().split(), SIZES)}
n = int(input())
possible = []
uses = []
for size in range(n):
possible.append(input().split(','))
if len(possible[-1]) > 1:
uses.append(None)
else:
uses.append(possible[-1][0])
have[possible[-1][0]] -= 1
if have[possible[-1][0]] < 0:
print("NO")
exit(0)
possible[-1] = None
# print(*uses)
for size in SIZES:
for i in range(2):
for index, poss in enumerate(possible):
if poss is not None:
if have[size] > 0:
if (i == 0 and size == poss[1]) or (i == 1 and size in poss):
have[size] -= 1
uses[index] = size
possible[index] = None
else:
break
# print(*uses)
if None in uses:
print("NO")
else:
print("YES")
for i in uses:
print(i)
```
Yes
| 25,246 | [
0.31640625,
0.0477294921875,
0.2352294921875,
0.058990478515625,
-0.7373046875,
-0.335693359375,
-0.26318359375,
0.190185546875,
-0.222412109375,
0.8955078125,
0.27392578125,
-0.11126708984375,
0.30712890625,
-0.2568359375,
-0.33935546875,
0.000018417835235595703,
-0.3251953125,
-0... | 11 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.