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. During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the n-th place participant has rating an. Then changing the rating on the Codesecrof site is calculated by the formula <image>. After the round was over, the Codesecrof management published the participants' results table. They decided that if for a participant di < k, then the round can be considered unrated for him. But imagine the management's surprise when they found out that the participants' rating table is dynamic. In other words, when some participant is removed from the rating, he is removed from the results' table and the rating is recalculated according to the new table. And of course, all applications for exclusion from the rating are considered in view of the current table. We know that among all the applications for exclusion from the rating the first application to consider is from the participant with the best rank (the rank with the minimum number), for who di < k. We also know that the applications for exclusion from rating were submitted by all participants. Now Sereja wonders, what is the number of participants to be excluded from the contest rating, and the numbers of the participants in the original table in the order of their exclusion from the rating. Pay attention to the analysis of the first test case for a better understanding of the statement. Input The first line contains two integers n, k (1 ≤ n ≤ 2·105, - 109 ≤ k ≤ 0). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — ratings of the participants in the initial table. Output Print the numbers of participants in the order in which they were removed from the table. Print the initial numbers of the participants, that is, the numbers that the participants had in the initial table. Examples Input 5 0 5 3 4 1 2 Output 2 3 4 Input 10 -10 5 5 1 7 5 1 2 4 9 2 Output 2 4 5 7 8 9 Note Consider the first test sample. 1. Initially the sequence of the contest participants' ratings equals [5, 3, 4, 1, 2]. You can use this sequence to calculate the sequence of rating changes: [0, -9, -13, 8, 14]. According to the problem statement, the application of the participant who won the second place will be considered first. 2. As soon as the second place winner is out from the ratings, the participants' rating sequence will equal [5, 4, 1, 2]. By this sequence you can count the new sequence of rating changes: [0, -8, 2, 6]. According to the problem statement, the application of the participant who won the second place will be considered. Initially this participant won third place. 3. The new rating sequence equals [5, 1, 2], the new sequence of rating changes equals [0, -1, 1]. The second place participant's application is taken into consideration, initially this participant won the fourth place. 4. The new rating sequence equals [5, 2], the new sequence of rating changes equals [0, 0]. No more applications will be considered. Thus, you should print 2, 3, 4. Submitted Solution: ``` f = lambda: map(int, input().split()) n, k = f() s = j = 0 for i, q in enumerate(f(), 1): if s - j * (n - i) * q < k: print(i) else: s += q * (i - 1) j += 1 ``` No
85,299
[ 0.1669921875, -0.1617431640625, -0.1416015625, 0.351806640625, -0.383544921875, -0.6142578125, -0.55078125, 0.218994140625, -0.25048828125, 0.73095703125, 0.62548828125, 0.10675048828125, 0.099609375, -0.939453125, -0.337890625, 0.1007080078125, -0.7333984375, -0.751953125, -0.39...
11
Provide tags and a correct Python 3 solution for this coding contest problem. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared — the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≤ n ≤ 105) — the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 — the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 — the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Tags: data structures, implementation, sortings Correct Solution: ``` a=int(input()) b=input().split() c=input().split() d=input().split() b=[int(i) for i in b] c=[int(i) for i in c] d=[int(i) for i in d] b=sum(b) c=sum(c) d=sum(d) print(b-c) print(c-d) ```
86,086
[ 0.1761474609375, -0.3388671875, 0.031463623046875, -0.0552978515625, -0.494384765625, -0.9345703125, -0.13330078125, 0.1656494140625, 0.444091796875, 0.802734375, 0.49658203125, -0.11865234375, 0.252685546875, -0.59423828125, -0.70263671875, -0.2342529296875, -0.65966796875, -0.982...
11
Provide tags and a correct Python 3 solution for this coding contest problem. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared — the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≤ n ≤ 105) — the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 — the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 — the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Tags: data structures, implementation, sortings Correct Solution: ``` input() x=list(map(int,input().split())) y=list(map(int,input().split())) z=list(map(int,input().split())) print(sum(x)-sum(y)) print(sum(y)-sum(z)) ```
86,087
[ 0.1644287109375, -0.332763671875, 0.049530029296875, -0.048736572265625, -0.486328125, -0.93212890625, -0.1474609375, 0.146728515625, 0.448486328125, 0.814453125, 0.50537109375, -0.11871337890625, 0.296875, -0.60546875, -0.69580078125, -0.2166748046875, -0.66943359375, -0.993164062...
11
Provide tags and a correct Python 3 solution for this coding contest problem. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared — the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≤ n ≤ 105) — the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 — the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 — the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Tags: data structures, implementation, sortings Correct Solution: ``` from collections import Counter a = int(input()) b = list(int(x) for x in input().split()) c = list(int(x) for x in input().split()) d = list(int(x) for x in input().split()) p = list((Counter(b) - Counter(c)).elements()) for i in p: print(i) p = list((Counter(c) - Counter(d)).elements()) for i in p: print(i) ```
86,088
[ 0.161865234375, -0.3544921875, 0.03924560546875, -0.045013427734375, -0.4853515625, -0.9248046875, -0.12396240234375, 0.1129150390625, 0.48583984375, 0.80615234375, 0.493408203125, -0.1461181640625, 0.289306640625, -0.580078125, -0.685546875, -0.2135009765625, -0.67724609375, -0.99...
11
Provide tags and a correct Python 3 solution for this coding contest problem. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared — the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≤ n ≤ 105) — the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 — the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 — the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Tags: data structures, implementation, sortings Correct Solution: ``` n=int(input()) l=list(map(int,input().split())) b=[] for i in range(2): b=list(map(int,input().split())) print(sum(l)-sum(b)) l=b.copy() ```
86,089
[ 0.17919921875, -0.34033203125, 0.031097412109375, -0.04949951171875, -0.4912109375, -0.93505859375, -0.1278076171875, 0.164794921875, 0.443115234375, 0.82373046875, 0.50634765625, -0.11712646484375, 0.26611328125, -0.5986328125, -0.69384765625, -0.2271728515625, -0.66845703125, -0....
11
Provide tags and a correct Python 3 solution for this coding contest problem. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared — the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≤ n ≤ 105) — the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 — the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 — the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Tags: data structures, implementation, sortings Correct Solution: ``` n = int(input()) a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] c = [int(i) for i in input().split()] suma = sum(a) sumb = sum(b) sumc = sum(c) print(suma-sumb) print(sumb-sumc) ```
86,090
[ 0.17919921875, -0.34033203125, 0.031097412109375, -0.04949951171875, -0.4912109375, -0.93505859375, -0.1278076171875, 0.164794921875, 0.443115234375, 0.82373046875, 0.50634765625, -0.11712646484375, 0.26611328125, -0.5986328125, -0.69384765625, -0.2271728515625, -0.66845703125, -0....
11
Provide tags and a correct Python 3 solution for this coding contest problem. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared — the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≤ n ≤ 105) — the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 — the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 — the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Tags: data structures, implementation, sortings Correct Solution: ``` n = int(input()) e = [sum(map(int, input().split())) for i in range(3)] print(e[0] - e[1]) print(e[1] - e[2]) ```
86,091
[ 0.17919921875, -0.34033203125, 0.031097412109375, -0.04949951171875, -0.4912109375, -0.93505859375, -0.1278076171875, 0.164794921875, 0.443115234375, 0.82373046875, 0.50634765625, -0.11712646484375, 0.26611328125, -0.5986328125, -0.69384765625, -0.2271728515625, -0.66845703125, -0....
11
Provide tags and a correct Python 3 solution for this coding contest problem. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared — the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≤ n ≤ 105) — the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 — the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 — the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Tags: data structures, implementation, sortings Correct Solution: ``` n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) c=list(map(int,input().split())) suma=sum(a) sumb=sum(b) sumc=sum(c) print(suma-sumb) print(sumb-sumc) ```
86,092
[ 0.17919921875, -0.34033203125, 0.031097412109375, -0.04949951171875, -0.4912109375, -0.93505859375, -0.1278076171875, 0.164794921875, 0.443115234375, 0.82373046875, 0.50634765625, -0.11712646484375, 0.26611328125, -0.5986328125, -0.69384765625, -0.2271728515625, -0.66845703125, -0....
11
Provide tags and a correct Python 3 solution for this coding contest problem. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared — the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≤ n ≤ 105) — the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 — the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 — the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Tags: data structures, implementation, sortings Correct Solution: ``` n=input() n=list(input().split()) m=list(input().split()) l=list(input().split()) n.sort() m.sort() l.sort() i=0 while i<len(n): if i==len(m): q=n[i] break elif n[i]!=m[i]: q=n[i] break i+=1 i=0 while i<len(m): if i==len(l): w=m[i] break elif m[i]!=l[i]: w=m[i] break i+=1 print(q) print(w) ```
86,093
[ 0.1920166015625, -0.32421875, 0.037750244140625, -0.045166015625, -0.489013671875, -0.91552734375, -0.1326904296875, 0.148193359375, 0.435546875, 0.8349609375, 0.52587890625, -0.1170654296875, 0.28515625, -0.61376953125, -0.6650390625, -0.2138671875, -0.646484375, -1.0048828125, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared — the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≤ n ≤ 105) — the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 — the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 — the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Submitted Solution: ``` n = int(input()) a = [num for num in input().split()] b = [num for num in input().split()] c = [num for num in input().split()] x = "x" y = "y" a.sort() b.sort() c.sort() for i in range(n-1): if a[i] != b[i]: x = a[i] break if x == "x": x = a[n-1] for i in range(n-2): if b[i] != c[i]: y = b[i] break if y =="y": y = b[n-2] print(x) print(y) ``` Yes
86,094
[ 0.209716796875, -0.284423828125, -0.0240020751953125, -0.1385498046875, -0.7001953125, -0.755859375, -0.1741943359375, 0.292236328125, 0.29443359375, 0.8544921875, 0.498779296875, -0.09600830078125, 0.1688232421875, -0.673828125, -0.58544921875, -0.285888671875, -0.72119140625, -1....
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared — the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≤ n ≤ 105) — the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 — the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 — the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Submitted Solution: ``` n=int(input()) x=-1 y=-1 a=list(map(int,input().split())) b=list(map(int,input().split())) c=list(map(int,input().split())) a.sort() b.sort() c.sort() #print("",a,'\n',b,'\n',c) for i in range(n-1): if x==-1 and a[i] != b[i]: x=a[i] if y==-1 and i<n-2 and b[i] != c[i] : y=b[i] if x==-1: x=a[n-1] if y==-1: y=b[n-2] print(x) print(y) """ 5 1 5 8 123 7 123 7 5 1 5 1 7 outputCopy 8 123 inputCopy 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 outputCopy 1 3 """ ``` Yes
86,095
[ 0.209716796875, -0.284423828125, -0.0240020751953125, -0.1385498046875, -0.7001953125, -0.755859375, -0.1741943359375, 0.292236328125, 0.29443359375, 0.8544921875, 0.498779296875, -0.09600830078125, 0.1688232421875, -0.673828125, -0.58544921875, -0.285888671875, -0.72119140625, -1....
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared — the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≤ n ≤ 105) — the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 — the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 — the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Submitted Solution: ``` n=int(input()) l=input().split(" ",n) m=input().split(" ",n-1) j=input().split(" ",n-2) sum2=0 sum1=0 sum3=0 for i in range(n): sum1 += int(l[i]); for i in range(n-1): sum2 +=int(m[i]) for i in range(n-2): sum3 +=int(j[i]) print(sum1-sum2) print(sum2-sum3) ``` Yes
86,096
[ 0.209716796875, -0.284423828125, -0.0240020751953125, -0.1385498046875, -0.7001953125, -0.755859375, -0.1741943359375, 0.292236328125, 0.29443359375, 0.8544921875, 0.498779296875, -0.09600830078125, 0.1688232421875, -0.673828125, -0.58544921875, -0.285888671875, -0.72119140625, -1....
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared — the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≤ n ≤ 105) — the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 — the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 — the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Submitted Solution: ``` input() first_compile = sum(map(int, input().split())) second_compile = sum(map(int, input().split())) third_compile = sum(map(int, input().split())) print(first_compile - second_compile, second_compile - third_compile) ``` Yes
86,097
[ 0.1976318359375, -0.222412109375, -0.02569580078125, -0.155517578125, -0.716796875, -0.75048828125, -0.1702880859375, 0.3193359375, 0.3212890625, 0.83349609375, 0.450439453125, -0.10125732421875, 0.173095703125, -0.7021484375, -0.62451171875, -0.313720703125, -0.70947265625, -0.994...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared — the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≤ n ≤ 105) — the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 — the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 — the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Submitted Solution: ``` # -*- coding: utf-8 -*- """ Created on Mon Dec 23 18:19:49 2019 @author: Tuan """ ord1 = [int(i) for i in input().split()] ord2 = [int(i) for i in input().split()] ord3 = [int(i) for i in input().split()] err1 = sum(ord1)- sum(ord2) err2 = sum(ord2)- sum(ord3) print(err1, err2, sep='\n') ``` No
86,098
[ 0.21435546875, -0.24755859375, -0.0239410400390625, -0.1162109375, -0.7255859375, -0.73681640625, -0.1766357421875, 0.32177734375, 0.293701171875, 0.857421875, 0.484619140625, -0.088623046875, 0.172119140625, -0.68896484375, -0.60546875, -0.29345703125, -0.68994140625, -1.001953125...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared — the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≤ n ≤ 105) — the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 — the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 — the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Submitted Solution: ``` n = int(input()) arr = list(map(int,input().split())) arr1 = list(map(int,input().split())) arr2 = list(map(int,input().split())) a = set(arr) - set(arr1) b = set(arr1) - set(arr2) print(a) print(b) ``` No
86,099
[ 0.209716796875, -0.284423828125, -0.0240020751953125, -0.1385498046875, -0.7001953125, -0.755859375, -0.1741943359375, 0.292236328125, 0.29443359375, 0.8544921875, 0.498779296875, -0.09600830078125, 0.1688232421875, -0.673828125, -0.58544921875, -0.285888671875, -0.72119140625, -1....
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared — the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≤ n ≤ 105) — the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 — the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 — the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Submitted Solution: ``` n = input() a = [a for a in input().split()] b = [b for b in input().split()] c = [c for c in input().split()] print(set(a).difference(b)) print(set(b).difference(c)) ``` No
86,100
[ 0.207275390625, -0.260498046875, -0.00925445556640625, -0.1466064453125, -0.71826171875, -0.74462890625, -0.1751708984375, 0.289794921875, 0.294189453125, 0.859375, 0.496826171875, -0.08795166015625, 0.1854248046875, -0.69677734375, -0.59326171875, -0.29296875, -0.71240234375, -0.9...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared — the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≤ n ≤ 105) — the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 — the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 — the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Submitted Solution: ``` n=input() a1=input() a2=input() a3=input() a1=a1.split() a2=a2.split() a3=a3.split() l=[] m=[] for i in a1: l.append(i) if l.count(i) - a2.count(i)==1: print (i) if l.count(i) - a3.count(i)==1 and i in a2: print (i) ``` No
86,101
[ 0.207275390625, -0.260498046875, -0.00925445556640625, -0.1466064453125, -0.71826171875, -0.74462890625, -0.1751708984375, 0.289794921875, 0.294189453125, 0.859375, 0.496826171875, -0.08795166015625, 0.1854248046875, -0.69677734375, -0.59326171875, -0.29296875, -0.71240234375, -0.9...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some positive integer from 1 to n, such that equality holds. Input The only line of the input contains a rebus. It's guaranteed that it contains no more than 100 question marks, integer n is positive and doesn't exceed 1 000 000, all letters and integers are separated by spaces, arithmetic operations are located only between question marks. Output The first line of the output should contain "Possible" (without quotes) if rebus has a solution and "Impossible" (without quotes) otherwise. If the answer exists, the second line should contain any valid rebus with question marks replaced by integers from 1 to n. Follow the format given in the samples. Examples Input ? + ? - ? + ? + ? = 42 Output Possible 9 + 13 - 39 + 28 + 31 = 42 Input ? - ? = 1 Output Impossible Input ? = 1000000 Output Possible 1000000 = 1000000 Submitted Solution: ``` #!/usr/bin/env python3 # 664B_rebus.py - Codeforces.com/problemset/problem/664/B by Sergey 2016 import unittest import sys import re ############################################################################### # Rebus Class (Main Program) ############################################################################### class Rebus: """ Rebus representation """ def __init__(self, test_inputs=None): """ Default constructor """ it = iter(test_inputs.split("\n")) if test_inputs else None def uinput(): return next(it) if it else sys.stdin.readline().rstrip() # Reading single elements self.str = uinput() # End value self.n = 0 m = re.search("(\d+)", self.str) if m: self.n = int(m.group(1)) # Signs self.signs = ["+"] + re.findall("\? ([+-])", self.str) def summ(self, nums, signs): result = 0 for i in range(len(self.signs)): if self.signs[i] == "+": result += nums[i] else: result -= nums[i] return result def calculate(self): """ Main calcualtion function of the class """ nums = [0] * len(self.signs) for i in range(len(self.signs)): nums[i] = 1 sum = self.summ(nums, self.signs) for i in range(len(self.signs)): if sum != self.n: if self.signs[i] == "+" and sum < self.n: nums[i] = min(self.n - sum + 1, self.n) sum -= 1 sum += nums[i] if self.signs[i] == "-" and sum > self.n: nums[i] = min(sum + 1 - self.n, self.n) sum += 1 sum -= nums[i] if sum == self.n: result = "Possible\n" for i in range(len(self.signs)): if i != 0: result += self.signs[i] + " " result += str(nums[i]) + " " result += "= " + str(self.n) else: result = "Impossible" return str(result) ############################################################################### # Unit Tests ############################################################################### class unitTests(unittest.TestCase): def test_single_test(self): """ Rebus class testing """ # Constructor test test = "? + ? - ? + ? + ? = 42" d = Rebus(test) self.assertEqual(d.str, "? + ? - ? + ? + ? = 42") self.assertEqual(d.n, 42) self.assertEqual(d.signs, ["+", "+", "-", "+", "+"]) # Sample test self.assertEqual(Rebus(test).calculate(), "Possible\n40 + 1 - 1 + 1 + 1 = 42") # Sample test test = "? - ? = 1" self.assertEqual(Rebus(test).calculate(), "Impossible") # Sample test test = "? = 1000000" self.assertEqual(Rebus(test).calculate(), "Possible\n1000000 = 1000000") test = "? + ? + ? + ? - ? = 2" self.assertEqual(Rebus(test).calculate(), "Possible\n1 + 1 + 1 + 1 - 2 = 2") # My tests test = "" # self.assertEqual(Rebus(test).calculate(), "0") # Time limit test # self.time_limit_test(5000) def time_limit_test(self, nmax): """ Timelimit testing """ import random import timeit # Random inputs test = str(nmax) + " " + str(nmax) + "\n" numnums = [str(i) + " " + str(i+1) for i in range(nmax)] test += "\n".join(numnums) + "\n" nums = [random.randint(1, 10000) for i in range(nmax)] test += " ".join(map(str, nums)) + "\n" # Run the test start = timeit.default_timer() d = Rebus(test) calc = timeit.default_timer() d.calculate() stop = timeit.default_timer() print("\nTimelimit Test: " + "{0:.3f}s (init {1:.3f}s calc {2:.3f}s)". format(stop-start, calc-start, stop-calc)) if __name__ == "__main__": # Avoiding recursion limitaions sys.setrecursionlimit(100000) if sys.argv[-1] == "-ut": unittest.main(argv=[" "]) # Print the result string sys.stdout.write(Rebus().calculate()) ``` Yes
86,162
[ 0.48779296875, -0.220458984375, -0.4287109375, 0.0902099609375, -0.57958984375, -0.515625, 0.27734375, 0.23291015625, -0.2103271484375, 0.74951171875, 0.45166015625, -0.04156494140625, 0.1884765625, -0.736328125, -0.38818359375, -0.137939453125, -0.486083984375, -1.0087890625, -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 a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some positive integer from 1 to n, such that equality holds. Input The only line of the input contains a rebus. It's guaranteed that it contains no more than 100 question marks, integer n is positive and doesn't exceed 1 000 000, all letters and integers are separated by spaces, arithmetic operations are located only between question marks. Output The first line of the output should contain "Possible" (without quotes) if rebus has a solution and "Impossible" (without quotes) otherwise. If the answer exists, the second line should contain any valid rebus with question marks replaced by integers from 1 to n. Follow the format given in the samples. Examples Input ? + ? - ? + ? + ? = 42 Output Possible 9 + 13 - 39 + 28 + 31 = 42 Input ? - ? = 1 Output Impossible Input ? = 1000000 Output Possible 1000000 = 1000000 Submitted Solution: ``` #!/usr/bin/env python3 import re try: while True: s = input() n = int(s[s.rfind(' '):]) pos = s.count('+') + 1 neg = s.count('-') if n * pos - neg < n or pos - n * neg > n: print("Impossible") else: print("Possible") need = n - (pos - neg) prev = '+' first = True for m in re.finditer(r"[+-]", s): if first: first = False else: print(prev, end=' ') if prev == '+' and need > 0: x = min(need + 1, n) need -= x - 1 elif prev == '-' and need < 0: x = min(-need + 1, n) need += x - 1 else: x = 1 print(x, end=' ') prev = m.group() if not first: print(prev, end=' ') if prev == '+' and need > 0: x = min(need + 1, n) need -= x - 1 elif prev == '-' and need < 0: x = min(-need + 1, n) need += x - 1 else: x = 1 print(x, '=', n) except EOFError: pass ``` Yes
86,163
[ 0.451904296875, -0.120849609375, -0.317626953125, 0.01407623291015625, -0.5498046875, -0.5341796875, 0.223876953125, 0.231201171875, -0.043121337890625, 0.8330078125, 0.5625, -0.089111328125, 0.1832275390625, -0.720703125, -0.35009765625, -0.0916748046875, -0.53271484375, -0.982910...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some positive integer from 1 to n, such that equality holds. Input The only line of the input contains a rebus. It's guaranteed that it contains no more than 100 question marks, integer n is positive and doesn't exceed 1 000 000, all letters and integers are separated by spaces, arithmetic operations are located only between question marks. Output The first line of the output should contain "Possible" (without quotes) if rebus has a solution and "Impossible" (without quotes) otherwise. If the answer exists, the second line should contain any valid rebus with question marks replaced by integers from 1 to n. Follow the format given in the samples. Examples Input ? + ? - ? + ? + ? = 42 Output Possible 9 + 13 - 39 + 28 + 31 = 42 Input ? - ? = 1 Output Impossible Input ? = 1000000 Output Possible 1000000 = 1000000 Submitted Solution: ``` ar, ans = input().split('=') ans = int(ans) pl = ar.count('+') + 1 mn = ar.count('-') if pl*ans - mn*1 < ans or pl*1 - mn*ans > ans: print("Impossible") exit(0) print("Possible") mat = [1]*(pl+mn) sig = ('+' + ar).replace(' ', '').split('?') del sig[-1] while True: i = 0 s = "" for ch in ar: if ch == '?': s += str(mat[i]) i += 1 else: s += ch t = eval(s) if t == ans: print("{0}= {1}".format(s, ans)) exit(0) d = ans - t for i in range(len(mat)): if sig[i] == '+' and d > 0: mat[i] = min(1 + d, ans) d -= mat[i] - 1 elif sig[i] == '-' and d < 0: mat[i] = min(1 + abs(d), ans) d += mat[i] - 1 ``` Yes
86,164
[ 0.35009765625, -0.0236968994140625, -0.323486328125, 0.1661376953125, -0.5498046875, -0.55859375, 0.21923828125, 0.207275390625, -0.05426025390625, 0.76611328125, 0.62353515625, 0.11090087890625, 0.132080078125, -0.91259765625, -0.314208984375, 0.026611328125, -0.397216796875, -1.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 a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some positive integer from 1 to n, such that equality holds. Input The only line of the input contains a rebus. It's guaranteed that it contains no more than 100 question marks, integer n is positive and doesn't exceed 1 000 000, all letters and integers are separated by spaces, arithmetic operations are located only between question marks. Output The first line of the output should contain "Possible" (without quotes) if rebus has a solution and "Impossible" (without quotes) otherwise. If the answer exists, the second line should contain any valid rebus with question marks replaced by integers from 1 to n. Follow the format given in the samples. Examples Input ? + ? - ? + ? + ? = 42 Output Possible 9 + 13 - 39 + 28 + 31 = 42 Input ? - ? = 1 Output Impossible Input ? = 1000000 Output Possible 1000000 = 1000000 Submitted Solution: ``` expr = input().split() target_number = int(expr[-1]) result_expr = None def spread(number_sum, quantity): spreaded = [] acc = number_sum remaining = quantity - 1 for i in range(quantity): next_number = min(target_number, acc - remaining) spreaded.append(next_number) acc -= next_number remaining -= 1 return spreaded plus_count = 1 + expr.count('+') minus_count = expr.count('-') if minus_count == 0: if plus_count <= target_number <= plus_count*target_number: spreaded = spread(target_number, plus_count) result_expr = "{0} = {1}".format(" + ".join(map(str, spreaded)), target_number) else: negative = minus_count if negative <= minus_count*target_number: positive = negative + target_number if plus_count <= positive <= plus_count*target_number: spreaded_positive = spread(positive, plus_count) spreaded_negative = spread(negative, minus_count) result_expr = "{0} ".format(spreaded_positive.pop()) for i in range(1, len(expr) - 2): if expr[i] == '+': result_expr += '+ {0} '.format(spreaded_positive.pop()) elif expr[i] == '-': result_expr += '- {0} '.format(spreaded_negative.pop()) result_expr += "= {0}".format(target_number) if result_expr: print("Possible") print(result_expr) else: print("Impossible") ``` No
86,165
[ 0.244140625, -0.0297393798828125, -0.2333984375, -0.0023212432861328125, -0.4697265625, -0.595703125, 0.322265625, 0.2998046875, -0.1170654296875, 0.68896484375, 0.53466796875, 0.09124755859375, 0.118896484375, -0.60693359375, -0.336669921875, -0.042877197265625, -0.63623046875, -1...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some positive integer from 1 to n, such that equality holds. Input The only line of the input contains a rebus. It's guaranteed that it contains no more than 100 question marks, integer n is positive and doesn't exceed 1 000 000, all letters and integers are separated by spaces, arithmetic operations are located only between question marks. Output The first line of the output should contain "Possible" (without quotes) if rebus has a solution and "Impossible" (without quotes) otherwise. If the answer exists, the second line should contain any valid rebus with question marks replaced by integers from 1 to n. Follow the format given in the samples. Examples Input ? + ? - ? + ? + ? = 42 Output Possible 9 + 13 - 39 + 28 + 31 = 42 Input ? - ? = 1 Output Impossible Input ? = 1000000 Output Possible 1000000 = 1000000 Submitted Solution: ``` s = input() plus = 1 minus = 0 for i in s : if i=='+': plus+=1 if i=='-': minus+=1 n= int (s[s.rfind(' '):]) if plus<=minus : print('Impossible') else: if plus>minus: ras=plus-minus znak=0 if (ras>n): print('Impossible') else: out = str(n-ras+1); for i in s[1:s.rfind(' ')]: if i=='?': out+='1' if i=='+': out+='+' if i=='-': out+='-' if i=='=': out=out+'= '+str(n) if i==' ': out+=' ' print(out) ``` No
86,168
[ 0.376708984375, -0.16552734375, -0.344970703125, -0.0033111572265625, -0.55078125, -0.62158203125, 0.2164306640625, 0.1851806640625, -0.2254638671875, 0.85205078125, 0.55810546875, 0.0546875, 0.209228515625, -0.83154296875, -0.3623046875, -0.0706787109375, -0.59326171875, -0.965332...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You and your friend are participating in a TV show "Run For Your Prize". At the start of the show n prizes are located on a straight line. i-th prize is located at position ai. Positions of all prizes are distinct. You start at position 1, your friend — at position 106 (and there is no prize in any of these two positions). You have to work as a team and collect all prizes in minimum possible time, in any order. You know that it takes exactly 1 second to move from position x to position x + 1 or x - 1, both for you and your friend. You also have trained enough to instantly pick up any prize, if its position is equal to your current position (and the same is true for your friend). Carrying prizes does not affect your speed (or your friend's speed) at all. Now you may discuss your strategy with your friend and decide who will pick up each prize. Remember that every prize must be picked up, either by you or by your friend. What is the minimum number of seconds it will take to pick up all the prizes? Input The first line contains one integer n (1 ≤ n ≤ 105) — the number of prizes. The second line contains n integers a1, a2, ..., an (2 ≤ ai ≤ 106 - 1) — the positions of the prizes. No two prizes are located at the same position. Positions are given in ascending order. Output Print one integer — the minimum number of seconds it will take to collect all prizes. Examples Input 3 2 3 9 Output 8 Input 2 2 999995 Output 5 Note In the first example you take all the prizes: take the first at 1, the second at 2 and the third at 8. In the second example you take the first prize in 1 second and your friend takes the other in 5 seconds, you do this simultaneously, so the total time is 5. Submitted Solution: ``` # -*- coding: utf-8 -*- """ Created on Fri Feb 16 21:31:15 2018 @author: Anuroop Behera """ n = int(input()) a = input().split() for i in range(len(a)): a[i] = int(a[i]) if a[n-1] <= 1000000/2: print(a[n-1]-1) elif a[0] > 1000000/2: print(1000001-a[0]-1) else: for i in range(len(a)): if a[i] > 500000: break print(max(a[i-1]-1,1000001-a[i]-1)) ``` Yes
86,273
[ 0.455322265625, 0.1839599609375, -0.0042266845703125, 0.4169921875, -0.178466796875, -0.50146484375, -0.11309814453125, 0.2490234375, -0.0175628662109375, 0.7939453125, 0.35302734375, -0.039794921875, 0.122314453125, -0.5107421875, -0.296630859375, -0.080078125, -0.658203125, -0.86...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You and your friend are participating in a TV show "Run For Your Prize". At the start of the show n prizes are located on a straight line. i-th prize is located at position ai. Positions of all prizes are distinct. You start at position 1, your friend — at position 106 (and there is no prize in any of these two positions). You have to work as a team and collect all prizes in minimum possible time, in any order. You know that it takes exactly 1 second to move from position x to position x + 1 or x - 1, both for you and your friend. You also have trained enough to instantly pick up any prize, if its position is equal to your current position (and the same is true for your friend). Carrying prizes does not affect your speed (or your friend's speed) at all. Now you may discuss your strategy with your friend and decide who will pick up each prize. Remember that every prize must be picked up, either by you or by your friend. What is the minimum number of seconds it will take to pick up all the prizes? Input The first line contains one integer n (1 ≤ n ≤ 105) — the number of prizes. The second line contains n integers a1, a2, ..., an (2 ≤ ai ≤ 106 - 1) — the positions of the prizes. No two prizes are located at the same position. Positions are given in ascending order. Output Print one integer — the minimum number of seconds it will take to collect all prizes. Examples Input 3 2 3 9 Output 8 Input 2 2 999995 Output 5 Note In the first example you take all the prizes: take the first at 1, the second at 2 and the third at 8. In the second example you take the first prize in 1 second and your friend takes the other in 5 seconds, you do this simultaneously, so the total time is 5. Submitted Solution: ``` import sys n = sys.stdin.readline() prizes = map(int, sys.stdin.readline().strip().split()) max_steps = 0 max_steps2 = 0 pos2 = int(10 ** 6) border = int(pos2 / 2) for i in prizes: if i < border: max_steps = max(max_steps, i - 1) else: print(i) max_steps2 = max(max_steps2, pos2 - i) print(max(max_steps, max_steps2)) ``` No
86,275
[ 0.35986328125, 0.27099609375, 0.048675537109375, 0.37255859375, -0.2607421875, -0.48095703125, -0.198974609375, 0.2802734375, -0.0479736328125, 0.88916015625, 0.27099609375, -0.049560546875, 0.18701171875, -0.53369140625, -0.28515625, -0.051727294921875, -0.66162109375, -0.98535156...
11
Provide a correct Python 3 solution for this coding contest problem. Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format. Constraints * 1 \leq N \leq 10^5 * S_i is `AC`, `WA`, `TLE`, or `RE`. Input Input is given from Standard Input in the following format: N S_1 \vdots S_N Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Examples Input 6 AC TLE AC AC WA TLE Output AC x 3 WA x 1 TLE x 2 RE x 0 Input 10 AC AC AC AC AC AC AC AC AC AC Output AC x 10 WA x 0 TLE x 0 RE x 0 "Correct Solution: ``` N = int(input()) lst = [input() for _ in range(N)] V=["AC","WA","TLE","RE"] for v in V: print("{} x {}".format(v, lst.count(v))) ```
86,297
[ 0.252685546875, 0.249267578125, 0.0158538818359375, 0.2176513671875, -0.68359375, -0.56982421875, -0.184814453125, -0.10723876953125, 0.1610107421875, 0.92578125, 0.3828125, -0.296630859375, 0.25341796875, -1.009765625, -0.52001953125, -0.44189453125, -0.52294921875, -0.4267578125,...
11
Provide a correct Python 3 solution for this coding contest problem. Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format. Constraints * 1 \leq N \leq 10^5 * S_i is `AC`, `WA`, `TLE`, or `RE`. Input Input is given from Standard Input in the following format: N S_1 \vdots S_N Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Examples Input 6 AC TLE AC AC WA TLE Output AC x 3 WA x 1 TLE x 2 RE x 0 Input 10 AC AC AC AC AC AC AC AC AC AC Output AC x 10 WA x 0 TLE x 0 RE x 0 "Correct Solution: ``` t = int(input()) d = {'AC':0, 'WA':0,'TLE':0, 'RE':0} while t: d[input()]+=1 t-=1 for i in d: print(i,'x',d[i]) ```
86,298
[ 0.27978515625, 0.30615234375, -0.05084228515625, 0.1781005859375, -0.76416015625, -0.57275390625, -0.180908203125, -0.1611328125, 0.0887451171875, 0.91064453125, 0.42919921875, -0.208984375, 0.24755859375, -1.0146484375, -0.482421875, -0.475341796875, -0.440185546875, -0.4118652343...
11
Provide a correct Python 3 solution for this coding contest problem. Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format. Constraints * 1 \leq N \leq 10^5 * S_i is `AC`, `WA`, `TLE`, or `RE`. Input Input is given from Standard Input in the following format: N S_1 \vdots S_N Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Examples Input 6 AC TLE AC AC WA TLE Output AC x 3 WA x 1 TLE x 2 RE x 0 Input 10 AC AC AC AC AC AC AC AC AC AC Output AC x 10 WA x 0 TLE x 0 RE x 0 "Correct Solution: ``` n=int(input()) S = [] for i in range(n): S.append(input()) for t in ["AC","WA","TLE","RE"]: print(f"{t} x {S.count(t)}") ```
86,299
[ 0.2481689453125, 0.220458984375, -0.045684814453125, 0.212890625, -0.74462890625, -0.60546875, -0.2144775390625, -0.1312255859375, 0.1591796875, 0.9267578125, 0.47900390625, -0.2880859375, 0.252685546875, -1.0595703125, -0.51953125, -0.43505859375, -0.5478515625, -0.447509765625, ...
11
Provide a correct Python 3 solution for this coding contest problem. Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format. Constraints * 1 \leq N \leq 10^5 * S_i is `AC`, `WA`, `TLE`, or `RE`. Input Input is given from Standard Input in the following format: N S_1 \vdots S_N Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Examples Input 6 AC TLE AC AC WA TLE Output AC x 3 WA x 1 TLE x 2 RE x 0 Input 10 AC AC AC AC AC AC AC AC AC AC Output AC x 10 WA x 0 TLE x 0 RE x 0 "Correct Solution: ``` import sys input() d=dict.fromkeys('AC WA TLE RE'.split(),0) for ln in sys.stdin: d[ln.strip()]+=1 for k,v in d.items(): print(k,'x',v) ```
86,300
[ 0.286865234375, 0.34521484375, -0.07196044921875, 0.1553955078125, -0.84130859375, -0.52587890625, -0.217041015625, -0.15234375, 0.10919189453125, 1.0068359375, 0.329345703125, -0.222412109375, 0.2293701171875, -1.015625, -0.568359375, -0.48779296875, -0.400390625, -0.4345703125, ...
11
Provide a correct Python 3 solution for this coding contest problem. Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format. Constraints * 1 \leq N \leq 10^5 * S_i is `AC`, `WA`, `TLE`, or `RE`. Input Input is given from Standard Input in the following format: N S_1 \vdots S_N Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Examples Input 6 AC TLE AC AC WA TLE Output AC x 3 WA x 1 TLE x 2 RE x 0 Input 10 AC AC AC AC AC AC AC AC AC AC Output AC x 10 WA x 0 TLE x 0 RE x 0 "Correct Solution: ``` N = int(input()) D = {"AC":0, "WA":0, "TLE":0, "RE":0} for _ in range(N): S = input() D[S] += 1 for i, x in D.items(): print(i+" x "+str(x)) ```
86,301
[ 0.2337646484375, 0.215087890625, -0.0325927734375, 0.228759765625, -0.7255859375, -0.58251953125, -0.1920166015625, -0.1553955078125, 0.14892578125, 0.92041015625, 0.44482421875, -0.260498046875, 0.252197265625, -1.02734375, -0.48876953125, -0.443115234375, -0.5146484375, -0.372314...
11
Provide a correct Python 3 solution for this coding contest problem. Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format. Constraints * 1 \leq N \leq 10^5 * S_i is `AC`, `WA`, `TLE`, or `RE`. Input Input is given from Standard Input in the following format: N S_1 \vdots S_N Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Examples Input 6 AC TLE AC AC WA TLE Output AC x 3 WA x 1 TLE x 2 RE x 0 Input 10 AC AC AC AC AC AC AC AC AC AC Output AC x 10 WA x 0 TLE x 0 RE x 0 "Correct Solution: ``` n,*s=open(0).read().split() for t in['AC','WA','TLE','RE']:print(f'{t} x {s.count(t)}') ```
86,302
[ 0.292724609375, 0.322021484375, -0.050689697265625, 0.170654296875, -0.73779296875, -0.55517578125, -0.2010498046875, -0.0946044921875, 0.1375732421875, 0.9775390625, 0.426025390625, -0.235107421875, 0.336181640625, -1.005859375, -0.51513671875, -0.486572265625, -0.447998046875, -0...
11
Provide a correct Python 3 solution for this coding contest problem. Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format. Constraints * 1 \leq N \leq 10^5 * S_i is `AC`, `WA`, `TLE`, or `RE`. Input Input is given from Standard Input in the following format: N S_1 \vdots S_N Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Examples Input 6 AC TLE AC AC WA TLE Output AC x 3 WA x 1 TLE x 2 RE x 0 Input 10 AC AC AC AC AC AC AC AC AC AC Output AC x 10 WA x 0 TLE x 0 RE x 0 "Correct Solution: ``` n = int(input()) s = [input() for i in range(n)] a = ["AC","WA","TLE","RE"] for i in a: print(i,'x',s.count(i)) ```
86,303
[ 0.289794921875, 0.224365234375, -0.058563232421875, 0.1890869140625, -0.72802734375, -0.5986328125, -0.1866455078125, -0.13134765625, 0.1502685546875, 0.94580078125, 0.484375, -0.27490234375, 0.2247314453125, -1.052734375, -0.5205078125, -0.433837890625, -0.51171875, -0.38525390625...
11
Provide a correct Python 3 solution for this coding contest problem. Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format. Constraints * 1 \leq N \leq 10^5 * S_i is `AC`, `WA`, `TLE`, or `RE`. Input Input is given from Standard Input in the following format: N S_1 \vdots S_N Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Examples Input 6 AC TLE AC AC WA TLE Output AC x 3 WA x 1 TLE x 2 RE x 0 Input 10 AC AC AC AC AC AC AC AC AC AC Output AC x 10 WA x 0 TLE x 0 RE x 0 "Correct Solution: ``` n=int(input()) c={} for _ in range(n): s=input() c[s]=c.get(s,0)+1 for j in ('AC','WA','TLE','RE'): print(j,'x',c.get(j,0)) ```
86,304
[ 0.27978515625, 0.260498046875, -0.04217529296875, 0.200927734375, -0.7490234375, -0.57373046875, -0.2125244140625, -0.1580810546875, 0.0982666015625, 0.9267578125, 0.4794921875, -0.260986328125, 0.2484130859375, -1.0830078125, -0.52197265625, -0.475341796875, -0.5302734375, -0.3925...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format. Constraints * 1 \leq N \leq 10^5 * S_i is `AC`, `WA`, `TLE`, or `RE`. Input Input is given from Standard Input in the following format: N S_1 \vdots S_N Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Examples Input 6 AC TLE AC AC WA TLE Output AC x 3 WA x 1 TLE x 2 RE x 0 Input 10 AC AC AC AC AC AC AC AC AC AC Output AC x 10 WA x 0 TLE x 0 RE x 0 Submitted Solution: ``` from collections import Counter ans = Counter(input() for _ in range(int(input()))) for i in ['AC', 'WA', 'TLE', 'RE']: print(f'{i} x {ans[i]}') ``` Yes
86,305
[ 0.287109375, 0.1649169921875, -0.10650634765625, 0.138671875, -0.66796875, -0.4130859375, -0.1976318359375, -0.0697021484375, 0.059295654296875, 0.98828125, 0.2222900390625, -0.169677734375, 0.237060546875, -0.95751953125, -0.60595703125, -0.44287109375, -0.416748046875, -0.5332031...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format. Constraints * 1 \leq N \leq 10^5 * S_i is `AC`, `WA`, `TLE`, or `RE`. Input Input is given from Standard Input in the following format: N S_1 \vdots S_N Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Examples Input 6 AC TLE AC AC WA TLE Output AC x 3 WA x 1 TLE x 2 RE x 0 Input 10 AC AC AC AC AC AC AC AC AC AC Output AC x 10 WA x 0 TLE x 0 RE x 0 Submitted Solution: ``` n = int(input()) C = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0} for i in range(n): C[input()] += 1 for s in C: print(f'{s} x {C[s]}') ``` Yes
86,306
[ 0.343505859375, 0.224609375, -0.06427001953125, 0.1649169921875, -0.623046875, -0.410400390625, -0.2249755859375, -0.066650390625, -0.001171112060546875, 0.974609375, 0.347412109375, -0.1434326171875, 0.212890625, -0.970703125, -0.50927734375, -0.4345703125, -0.424072265625, -0.483...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format. Constraints * 1 \leq N \leq 10^5 * S_i is `AC`, `WA`, `TLE`, or `RE`. Input Input is given from Standard Input in the following format: N S_1 \vdots S_N Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Examples Input 6 AC TLE AC AC WA TLE Output AC x 3 WA x 1 TLE x 2 RE x 0 Input 10 AC AC AC AC AC AC AC AC AC AC Output AC x 10 WA x 0 TLE x 0 RE x 0 Submitted Solution: ``` n = int(input()) di = {'AC':0, 'WA':0, 'TLE':0, 'RE':0} for _ in range(n): di[input()] += 1 for i, j in di.items(): print(i, 'x', j) ``` Yes
86,307
[ 0.290283203125, 0.1954345703125, -0.0623779296875, 0.11865234375, -0.6591796875, -0.423095703125, -0.2449951171875, -0.08685302734375, 0.051849365234375, 1.0234375, 0.27978515625, -0.123046875, 0.2022705078125, -0.95556640625, -0.50390625, -0.462158203125, -0.446044921875, -0.47241...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format. Constraints * 1 \leq N \leq 10^5 * S_i is `AC`, `WA`, `TLE`, or `RE`. Input Input is given from Standard Input in the following format: N S_1 \vdots S_N Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Examples Input 6 AC TLE AC AC WA TLE Output AC x 3 WA x 1 TLE x 2 RE x 0 Input 10 AC AC AC AC AC AC AC AC AC AC Output AC x 10 WA x 0 TLE x 0 RE x 0 Submitted Solution: ``` dict={"AC":0,"WA":0,"TLE":0,"RE":0} n,*s=map(str,open(0).read().split()) for i in s: dict[i]+=1 for k, v in dict.items(): print(k+" x "+str(v)) ``` Yes
86,308
[ 0.28662109375, 0.2548828125, -0.1597900390625, 0.1396484375, -0.63525390625, -0.335693359375, -0.2098388671875, -0.1090087890625, -0.002666473388671875, 1.05859375, 0.23095703125, -0.203857421875, 0.2890625, -0.91796875, -0.5068359375, -0.434814453125, -0.42138671875, -0.478515625,...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format. Constraints * 1 \leq N \leq 10^5 * S_i is `AC`, `WA`, `TLE`, or `RE`. Input Input is given from Standard Input in the following format: N S_1 \vdots S_N Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Examples Input 6 AC TLE AC AC WA TLE Output AC x 3 WA x 1 TLE x 2 RE x 0 Input 10 AC AC AC AC AC AC AC AC AC AC Output AC x 10 WA x 0 TLE x 0 RE x 0 Submitted Solution: ``` n = int(input()) judge = list(input() for _ in range(n)) ac, wa, tle, re = 0 for i in judge: if i == 'AC': ac = ac + 1 elif i == 'WA': wa = wa + 1 elif i == 'TLE': tle = tle + 1 elif i == 'RE': re = re + 1 print('AC x ' + str(ac)) print('WA x ' + str(wa)) print('TLE x ' + str(tle)) print('RE x ' + str(re)) ``` No
86,309
[ 0.3330078125, 0.241455078125, -0.0914306640625, 0.1273193359375, -0.67138671875, -0.493408203125, -0.224365234375, -0.064453125, -0.07098388671875, 0.90673828125, 0.379150390625, -0.261962890625, 0.214111328125, -0.9970703125, -0.552734375, -0.490478515625, -0.458984375, -0.4565429...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format. Constraints * 1 \leq N \leq 10^5 * S_i is `AC`, `WA`, `TLE`, or `RE`. Input Input is given from Standard Input in the following format: N S_1 \vdots S_N Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Examples Input 6 AC TLE AC AC WA TLE Output AC x 3 WA x 1 TLE x 2 RE x 0 Input 10 AC AC AC AC AC AC AC AC AC AC Output AC x 10 WA x 0 TLE x 0 RE x 0 Submitted Solution: ``` n = int(input()) c0, c1, c2, c3 = 0 for _ in range(n): if _ == "AC": c0 += 1 if _ == "WA": c1 += 1 if _ == "TLE": c2 += 1 if _ == "RE": c3 += 1 print("AC x", c0) print("WA x", c1) print("TLE x", c2) print("RE x", c3) ``` No
86,310
[ 0.34326171875, 0.20703125, -0.0285797119140625, 0.170166015625, -0.5859375, -0.42529296875, -0.210205078125, -0.05877685546875, -0.0014495849609375, 0.98388671875, 0.39501953125, -0.1300048828125, 0.25048828125, -1.03125, -0.51171875, -0.499755859375, -0.438720703125, -0.490234375,...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format. Constraints * 1 \leq N \leq 10^5 * S_i is `AC`, `WA`, `TLE`, or `RE`. Input Input is given from Standard Input in the following format: N S_1 \vdots S_N Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Examples Input 6 AC TLE AC AC WA TLE Output AC x 3 WA x 1 TLE x 2 RE x 0 Input 10 AC AC AC AC AC AC AC AC AC AC Output AC x 10 WA x 0 TLE x 0 RE x 0 Submitted Solution: ``` from sys import stdin, stdout import heapq import cProfile from collections import Counter, defaultdict, deque from functools import reduce import math from bisect import bisect,bisect_right,bisect_left def get_int(): return int(stdin.readline().strip()) def get_tuple(): return map(int, stdin.readline().split()) def get_list(): return list(map(int, stdin.readline().split())) n = get_int() dic = defaultdict(int) for _ in range(n): st = input() dic[st] += 1 for val in ['AC','WA','TLE','RE']: print(val+" * "+str(dic[val])) ``` No
86,311
[ 0.304443359375, 0.26220703125, -0.1761474609375, 0.139892578125, -0.7529296875, -0.386962890625, -0.1834716796875, -0.1976318359375, 0.086181640625, 1.140625, 0.23193359375, -0.2012939453125, 0.2060546875, -0.94775390625, -0.587890625, -0.479736328125, -0.39892578125, -0.6962890625...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format. Constraints * 1 \leq N \leq 10^5 * S_i is `AC`, `WA`, `TLE`, or `RE`. Input Input is given from Standard Input in the following format: N S_1 \vdots S_N Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Output Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following: AC x C_0 WA x C_1 TLE x C_2 RE x C_3 Examples Input 6 AC TLE AC AC WA TLE Output AC x 3 WA x 1 TLE x 2 RE x 0 Input 10 AC AC AC AC AC AC AC AC AC AC Output AC x 10 WA x 0 TLE x 0 RE x 0 Submitted Solution: ``` n = int(input()) j = list() for _ in range(n): string = input() j.append(string) ac = j.count("AC") wa = j.count("WA") tel = j.count("TEL") re = j.count("RE") print(f"AC x {ac}") print(f"WA x {wa}") print(f"TEL x {tel}") print(f"RE x {re}") ``` No
86,312
[ 0.324462890625, 0.203125, -0.131591796875, 0.2252197265625, -0.5732421875, -0.45166015625, -0.283203125, -0.07073974609375, 0.176025390625, 0.94970703125, 0.302734375, -0.132568359375, 0.26416015625, -0.98486328125, -0.50634765625, -0.414794921875, -0.47021484375, -0.52392578125, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Example Input 2 1 1 2 2 Output 1 Submitted Solution: ``` from collections import deque n, m = map(int, input().split()) G = [[] for i in range(n)] for i in range(m): x, y, w = map(int, input().split()) G[x-1].append((y-1, i)) if w == 2: G[y-1].append((x-1, i)) used = {(i, -1) for i in range(n)} prev = {(i, -1): [] for i in range(n)} counter = {} que = deque((i, -1) for i in range(n)) while que: v, e = source = que.popleft() counter[source] = 0 for target in G[v]: t, f = target if e == f: continue if target not in used: used.add(target) prev[target] = [] que.append(target) prev[target].append(source) counter[source] += 1 rest = len(counter) for p in counter: if counter[p] == 0: que.append(p) rest -= 1 while que: target = que.popleft() for source in prev[target]: counter[source] -= 1 if counter[source] == 0: que.append(source) rest -= 1 if rest > 0: print("Infinite") exit(0) memo = {} def dfs(source): if source in memo: return memo[source] res = 0 v, e = source for target in G[v]: t, f = target if e == f: continue res = max(res, dfs(target) + 1) memo[source] = res return res print(max(dfs((i, -1)) for i in range(n))) ``` No
86,491
[ 0.2132568359375, 0.222900390625, 0.06939697265625, 0.1505126953125, -0.79833984375, -0.1922607421875, -0.1812744140625, 0.2069091796875, 0.401611328125, 0.7734375, 0.2481689453125, -0.0826416015625, 0.16357421875, -0.66259765625, -0.45947265625, -0.095947265625, -0.46435546875, -0....
11
Provide a correct Python 3 solution for this coding contest problem. Problem statement A programming contest will be held in the Russian Federation. The contest has N questions and has M participants. Question i has a score a_i, and it is known that participant j's ability is b_j. For problem i and participant j, participant j can always solve problem i if a_i ≤ b_j and only then. The score of a participant through the contest is the sum of the scores of the problems that the person was able to solve. Participant j also sets a target score c_j for this contest. Determine if each participant can score more than the target score. input The input is given in the following format. N a_ {0} a_ {1} a_ {2}… a_ {N−1} M b_ {0} b_ {1} b_ {2}… b_ {M−1} c_ {0} c_ {1} c_ {2}… c_ {M−1} Constraint * All inputs are integers * 1 \ ≤ N \ ≤ 300 \,000 * 1 \ ≤ M \ ≤ 300 \,000 * 0 \ ≤ a_ {i} \ ≤ 1 \, 000 \,000 * 0 \ ≤ b_ {i} \ ≤ 1 \, 000 \,000 * 0 \ ≤ c_ {i} \ ≤ ∑a_k output Print the answer on line M. On the i-line, output `Yes` if the participant i-1 can get more points than the target score, and` No` if not. sample Sample input 1 6 1 2 1 3 4 5 7 1 3 4 5 3 1 0 2 4 5 3 4 5 3 Sample output 1 Yes Yes Yes Yes Yes No No The points obtained by each participant are as follows. * Participant 0: 1 + 1 = 2 * Participant 1: 1 + 2 + 1 + 3 = 7 * Participant 2: 1 + 2 + 1 + 3 + 4 = 11 * Participant 3: 1 + 2 + 1 + 3 + 4 + 5 = 16 * Participant 4: 1 + 2 + 1 + 3 = 7 * Participant 5: 1 + 1 = 2 * Participants 6: 0 Sample input 2 8 1 1 2 3 3 4 6 100 Four 1 3 4 99 1 10 15 120 Sample output 2 Yes Yes No No Example Input 6 1 2 1 3 4 5 7 1 3 4 5 3 1 0 2 4 5 3 4 5 3 Output Yes Yes Yes Yes Yes No No "Correct Solution: ``` import bisect n=int(input()) a=sorted(list(map(int,input().split()))) d=[0]*(n+1) for i in range(1,n+1):d[i]=d[i-1]+a[i-1] m=int(input()) b,c=[list(map(int,input().split())) for _ in [0,0]] [print(['Yes','No'][d[bisect.bisect_right(a,b[i])]<c[i]]) for i in range(m)] ```
87,470
[ 0.327880859375, -0.0225677490234375, -0.365478515625, 0.2744140625, -0.471923828125, -0.43701171875, -0.12042236328125, 0.3046875, 0.1923828125, 0.5625, 0.31005859375, -0.1612548828125, 0.35888671875, -0.76806640625, -0.400390625, -0.1876220703125, -0.91943359375, -0.86474609375, ...
11
Provide a correct Python 3 solution for this coding contest problem. Problem statement A programming contest will be held in the Russian Federation. The contest has N questions and has M participants. Question i has a score a_i, and it is known that participant j's ability is b_j. For problem i and participant j, participant j can always solve problem i if a_i ≤ b_j and only then. The score of a participant through the contest is the sum of the scores of the problems that the person was able to solve. Participant j also sets a target score c_j for this contest. Determine if each participant can score more than the target score. input The input is given in the following format. N a_ {0} a_ {1} a_ {2}… a_ {N−1} M b_ {0} b_ {1} b_ {2}… b_ {M−1} c_ {0} c_ {1} c_ {2}… c_ {M−1} Constraint * All inputs are integers * 1 \ ≤ N \ ≤ 300 \,000 * 1 \ ≤ M \ ≤ 300 \,000 * 0 \ ≤ a_ {i} \ ≤ 1 \, 000 \,000 * 0 \ ≤ b_ {i} \ ≤ 1 \, 000 \,000 * 0 \ ≤ c_ {i} \ ≤ ∑a_k output Print the answer on line M. On the i-line, output `Yes` if the participant i-1 can get more points than the target score, and` No` if not. sample Sample input 1 6 1 2 1 3 4 5 7 1 3 4 5 3 1 0 2 4 5 3 4 5 3 Sample output 1 Yes Yes Yes Yes Yes No No The points obtained by each participant are as follows. * Participant 0: 1 + 1 = 2 * Participant 1: 1 + 2 + 1 + 3 = 7 * Participant 2: 1 + 2 + 1 + 3 + 4 = 11 * Participant 3: 1 + 2 + 1 + 3 + 4 + 5 = 16 * Participant 4: 1 + 2 + 1 + 3 = 7 * Participant 5: 1 + 1 = 2 * Participants 6: 0 Sample input 2 8 1 1 2 3 3 4 6 100 Four 1 3 4 99 1 10 15 120 Sample output 2 Yes Yes No No Example Input 6 1 2 1 3 4 5 7 1 3 4 5 3 1 0 2 4 5 3 4 5 3 Output Yes Yes Yes Yes Yes No No "Correct Solution: ``` n = int(input()) a = list(map(int, input().split())) m = int(input()) b = list(map(int, input().split())) a.sort() import bisect c = list(map(int, input().split())) d = [0] * (n+1) for i in range(n): d[i+1] = a[i] for i in range(n): d[i+1] += d[i] for i in range(m): n = bisect.bisect_right(a,b[i]) n = d[n] if c[i] <= n: print("Yes") else: print("No") ```
87,471
[ 0.327880859375, -0.0225677490234375, -0.365478515625, 0.2744140625, -0.471923828125, -0.43701171875, -0.12042236328125, 0.3046875, 0.1923828125, 0.5625, 0.31005859375, -0.1612548828125, 0.35888671875, -0.76806640625, -0.400390625, -0.1876220703125, -0.91943359375, -0.86474609375, ...
11
Provide a correct Python 3 solution for this coding contest problem. Problem statement A programming contest will be held in the Russian Federation. The contest has N questions and has M participants. Question i has a score a_i, and it is known that participant j's ability is b_j. For problem i and participant j, participant j can always solve problem i if a_i ≤ b_j and only then. The score of a participant through the contest is the sum of the scores of the problems that the person was able to solve. Participant j also sets a target score c_j for this contest. Determine if each participant can score more than the target score. input The input is given in the following format. N a_ {0} a_ {1} a_ {2}… a_ {N−1} M b_ {0} b_ {1} b_ {2}… b_ {M−1} c_ {0} c_ {1} c_ {2}… c_ {M−1} Constraint * All inputs are integers * 1 \ ≤ N \ ≤ 300 \,000 * 1 \ ≤ M \ ≤ 300 \,000 * 0 \ ≤ a_ {i} \ ≤ 1 \, 000 \,000 * 0 \ ≤ b_ {i} \ ≤ 1 \, 000 \,000 * 0 \ ≤ c_ {i} \ ≤ ∑a_k output Print the answer on line M. On the i-line, output `Yes` if the participant i-1 can get more points than the target score, and` No` if not. sample Sample input 1 6 1 2 1 3 4 5 7 1 3 4 5 3 1 0 2 4 5 3 4 5 3 Sample output 1 Yes Yes Yes Yes Yes No No The points obtained by each participant are as follows. * Participant 0: 1 + 1 = 2 * Participant 1: 1 + 2 + 1 + 3 = 7 * Participant 2: 1 + 2 + 1 + 3 + 4 = 11 * Participant 3: 1 + 2 + 1 + 3 + 4 + 5 = 16 * Participant 4: 1 + 2 + 1 + 3 = 7 * Participant 5: 1 + 1 = 2 * Participants 6: 0 Sample input 2 8 1 1 2 3 3 4 6 100 Four 1 3 4 99 1 10 15 120 Sample output 2 Yes Yes No No Example Input 6 1 2 1 3 4 5 7 1 3 4 5 3 1 0 2 4 5 3 4 5 3 Output Yes Yes Yes Yes Yes No No "Correct Solution: ``` from itertools import accumulate from bisect import bisect_right as br n = int(input()) alst = sorted(map(int, input().split())) acc = list(accumulate(alst)) m = int(input()) blst = list(map(int, input().split())) clst = list(map(int, input().split())) for b, c in zip(blst, clst): index = br(alst, b) print(["No", "Yes"][(acc[index - 1] if index > 0 else 0) >= c]) ```
87,472
[ 0.327880859375, -0.0225677490234375, -0.365478515625, 0.2744140625, -0.471923828125, -0.43701171875, -0.12042236328125, 0.3046875, 0.1923828125, 0.5625, 0.31005859375, -0.1612548828125, 0.35888671875, -0.76806640625, -0.400390625, -0.1876220703125, -0.91943359375, -0.86474609375, ...
11
Provide a correct Python 3 solution for this coding contest problem. Problem statement A programming contest will be held in the Russian Federation. The contest has N questions and has M participants. Question i has a score a_i, and it is known that participant j's ability is b_j. For problem i and participant j, participant j can always solve problem i if a_i ≤ b_j and only then. The score of a participant through the contest is the sum of the scores of the problems that the person was able to solve. Participant j also sets a target score c_j for this contest. Determine if each participant can score more than the target score. input The input is given in the following format. N a_ {0} a_ {1} a_ {2}… a_ {N−1} M b_ {0} b_ {1} b_ {2}… b_ {M−1} c_ {0} c_ {1} c_ {2}… c_ {M−1} Constraint * All inputs are integers * 1 \ ≤ N \ ≤ 300 \,000 * 1 \ ≤ M \ ≤ 300 \,000 * 0 \ ≤ a_ {i} \ ≤ 1 \, 000 \,000 * 0 \ ≤ b_ {i} \ ≤ 1 \, 000 \,000 * 0 \ ≤ c_ {i} \ ≤ ∑a_k output Print the answer on line M. On the i-line, output `Yes` if the participant i-1 can get more points than the target score, and` No` if not. sample Sample input 1 6 1 2 1 3 4 5 7 1 3 4 5 3 1 0 2 4 5 3 4 5 3 Sample output 1 Yes Yes Yes Yes Yes No No The points obtained by each participant are as follows. * Participant 0: 1 + 1 = 2 * Participant 1: 1 + 2 + 1 + 3 = 7 * Participant 2: 1 + 2 + 1 + 3 + 4 = 11 * Participant 3: 1 + 2 + 1 + 3 + 4 + 5 = 16 * Participant 4: 1 + 2 + 1 + 3 = 7 * Participant 5: 1 + 1 = 2 * Participants 6: 0 Sample input 2 8 1 1 2 3 3 4 6 100 Four 1 3 4 99 1 10 15 120 Sample output 2 Yes Yes No No Example Input 6 1 2 1 3 4 5 7 1 3 4 5 3 1 0 2 4 5 3 4 5 3 Output Yes Yes Yes Yes Yes No No "Correct Solution: ``` import bisect n=int(input()) a=sorted(list(map(int,input().split()))) d=[0]*(n+1) for i in range(1,n+1):d[i]=d[i-1]+a[i-1] m=int(input()) b,c=[list(map(int,input().split())) for _ in [0,0]] for i in range(m): p=bisect.bisect_right(a,b[i]) print(['Yes','No'][d[p]<c[i]]) ```
87,473
[ 0.327880859375, -0.0225677490234375, -0.365478515625, 0.2744140625, -0.471923828125, -0.43701171875, -0.12042236328125, 0.3046875, 0.1923828125, 0.5625, 0.31005859375, -0.1612548828125, 0.35888671875, -0.76806640625, -0.400390625, -0.1876220703125, -0.91943359375, -0.86474609375, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Problem statement A programming contest will be held in the Russian Federation. The contest has N questions and has M participants. Question i has a score a_i, and it is known that participant j's ability is b_j. For problem i and participant j, participant j can always solve problem i if a_i ≤ b_j and only then. The score of a participant through the contest is the sum of the scores of the problems that the person was able to solve. Participant j also sets a target score c_j for this contest. Determine if each participant can score more than the target score. input The input is given in the following format. N a_ {0} a_ {1} a_ {2}… a_ {N−1} M b_ {0} b_ {1} b_ {2}… b_ {M−1} c_ {0} c_ {1} c_ {2}… c_ {M−1} Constraint * All inputs are integers * 1 \ ≤ N \ ≤ 300 \,000 * 1 \ ≤ M \ ≤ 300 \,000 * 0 \ ≤ a_ {i} \ ≤ 1 \, 000 \,000 * 0 \ ≤ b_ {i} \ ≤ 1 \, 000 \,000 * 0 \ ≤ c_ {i} \ ≤ ∑a_k output Print the answer on line M. On the i-line, output `Yes` if the participant i-1 can get more points than the target score, and` No` if not. sample Sample input 1 6 1 2 1 3 4 5 7 1 3 4 5 3 1 0 2 4 5 3 4 5 3 Sample output 1 Yes Yes Yes Yes Yes No No The points obtained by each participant are as follows. * Participant 0: 1 + 1 = 2 * Participant 1: 1 + 2 + 1 + 3 = 7 * Participant 2: 1 + 2 + 1 + 3 + 4 = 11 * Participant 3: 1 + 2 + 1 + 3 + 4 + 5 = 16 * Participant 4: 1 + 2 + 1 + 3 = 7 * Participant 5: 1 + 1 = 2 * Participants 6: 0 Sample input 2 8 1 1 2 3 3 4 6 100 Four 1 3 4 99 1 10 15 120 Sample output 2 Yes Yes No No Example Input 6 1 2 1 3 4 5 7 1 3 4 5 3 1 0 2 4 5 3 4 5 3 Output Yes Yes Yes Yes Yes No No Submitted Solution: ``` #!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright : @Huki_Hara # Created : 2015-03-14 n = int(input()) a = list(map(int, input().split())) m = int(input()) b = list(map(int, input().split())) c = list(map(int, input().split())) l = [True] * m for i in range(m): sum = 0 for j in range(n): if a[j] <= b[i]: sum += a[j] if sum < c[i]: l[i] = False for i in range(m): if l[i] : print("Yes") else: print("No") ``` No
87,474
[ 0.31494140625, -0.10992431640625, -0.33544921875, 0.2108154296875, -0.54296875, -0.431884765625, -0.1300048828125, 0.291259765625, 0.11395263671875, 0.5556640625, 0.3662109375, -0.07696533203125, 0.293212890625, -0.61474609375, -0.384521484375, -0.20654296875, -0.90673828125, -0.89...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Problem statement A programming contest will be held in the Russian Federation. The contest has N questions and has M participants. Question i has a score a_i, and it is known that participant j's ability is b_j. For problem i and participant j, participant j can always solve problem i if a_i ≤ b_j and only then. The score of a participant through the contest is the sum of the scores of the problems that the person was able to solve. Participant j also sets a target score c_j for this contest. Determine if each participant can score more than the target score. input The input is given in the following format. N a_ {0} a_ {1} a_ {2}… a_ {N−1} M b_ {0} b_ {1} b_ {2}… b_ {M−1} c_ {0} c_ {1} c_ {2}… c_ {M−1} Constraint * All inputs are integers * 1 \ ≤ N \ ≤ 300 \,000 * 1 \ ≤ M \ ≤ 300 \,000 * 0 \ ≤ a_ {i} \ ≤ 1 \, 000 \,000 * 0 \ ≤ b_ {i} \ ≤ 1 \, 000 \,000 * 0 \ ≤ c_ {i} \ ≤ ∑a_k output Print the answer on line M. On the i-line, output `Yes` if the participant i-1 can get more points than the target score, and` No` if not. sample Sample input 1 6 1 2 1 3 4 5 7 1 3 4 5 3 1 0 2 4 5 3 4 5 3 Sample output 1 Yes Yes Yes Yes Yes No No The points obtained by each participant are as follows. * Participant 0: 1 + 1 = 2 * Participant 1: 1 + 2 + 1 + 3 = 7 * Participant 2: 1 + 2 + 1 + 3 + 4 = 11 * Participant 3: 1 + 2 + 1 + 3 + 4 + 5 = 16 * Participant 4: 1 + 2 + 1 + 3 = 7 * Participant 5: 1 + 1 = 2 * Participants 6: 0 Sample input 2 8 1 1 2 3 3 4 6 100 Four 1 3 4 99 1 10 15 120 Sample output 2 Yes Yes No No Example Input 6 1 2 1 3 4 5 7 1 3 4 5 3 1 0 2 4 5 3 4 5 3 Output Yes Yes Yes Yes Yes No No Submitted Solution: ``` n = int(input()) a = list(map(int, input().split())) m = int(input()) b = list(map(int, input().split())) c = map(int, input().split()) l = [False] * m a.sort() for i in range(m): sum = 0 for j in range(n): if a[j] > b[i]: break sum += a[j] if sum >= c.__next__(): l[i] = True for i in range(m): if l[i]: print("Yes") else: print("No") ``` No
87,475
[ 0.31494140625, -0.10992431640625, -0.33544921875, 0.2108154296875, -0.54296875, -0.431884765625, -0.1300048828125, 0.291259765625, 0.11395263671875, 0.5556640625, 0.3662109375, -0.07696533203125, 0.293212890625, -0.61474609375, -0.384521484375, -0.20654296875, -0.90673828125, -0.89...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Problem statement A programming contest will be held in the Russian Federation. The contest has N questions and has M participants. Question i has a score a_i, and it is known that participant j's ability is b_j. For problem i and participant j, participant j can always solve problem i if a_i ≤ b_j and only then. The score of a participant through the contest is the sum of the scores of the problems that the person was able to solve. Participant j also sets a target score c_j for this contest. Determine if each participant can score more than the target score. input The input is given in the following format. N a_ {0} a_ {1} a_ {2}… a_ {N−1} M b_ {0} b_ {1} b_ {2}… b_ {M−1} c_ {0} c_ {1} c_ {2}… c_ {M−1} Constraint * All inputs are integers * 1 \ ≤ N \ ≤ 300 \,000 * 1 \ ≤ M \ ≤ 300 \,000 * 0 \ ≤ a_ {i} \ ≤ 1 \, 000 \,000 * 0 \ ≤ b_ {i} \ ≤ 1 \, 000 \,000 * 0 \ ≤ c_ {i} \ ≤ ∑a_k output Print the answer on line M. On the i-line, output `Yes` if the participant i-1 can get more points than the target score, and` No` if not. sample Sample input 1 6 1 2 1 3 4 5 7 1 3 4 5 3 1 0 2 4 5 3 4 5 3 Sample output 1 Yes Yes Yes Yes Yes No No The points obtained by each participant are as follows. * Participant 0: 1 + 1 = 2 * Participant 1: 1 + 2 + 1 + 3 = 7 * Participant 2: 1 + 2 + 1 + 3 + 4 = 11 * Participant 3: 1 + 2 + 1 + 3 + 4 + 5 = 16 * Participant 4: 1 + 2 + 1 + 3 = 7 * Participant 5: 1 + 1 = 2 * Participants 6: 0 Sample input 2 8 1 1 2 3 3 4 6 100 Four 1 3 4 99 1 10 15 120 Sample output 2 Yes Yes No No Example Input 6 1 2 1 3 4 5 7 1 3 4 5 3 1 0 2 4 5 3 4 5 3 Output Yes Yes Yes Yes Yes No No Submitted Solution: ``` input() a=list(map(int,input().split())) m=int(input()) b,c=[list(map(int,input().split())) for _ in [0,0]] [print(['Yes','No'][sum([j for j in a if j<=b[i]])<c[i]])for i in range(m)] ``` No
87,476
[ 0.31494140625, -0.10992431640625, -0.33544921875, 0.2108154296875, -0.54296875, -0.431884765625, -0.1300048828125, 0.291259765625, 0.11395263671875, 0.5556640625, 0.3662109375, -0.07696533203125, 0.293212890625, -0.61474609375, -0.384521484375, -0.20654296875, -0.90673828125, -0.89...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Problem statement A programming contest will be held in the Russian Federation. The contest has N questions and has M participants. Question i has a score a_i, and it is known that participant j's ability is b_j. For problem i and participant j, participant j can always solve problem i if a_i ≤ b_j and only then. The score of a participant through the contest is the sum of the scores of the problems that the person was able to solve. Participant j also sets a target score c_j for this contest. Determine if each participant can score more than the target score. input The input is given in the following format. N a_ {0} a_ {1} a_ {2}… a_ {N−1} M b_ {0} b_ {1} b_ {2}… b_ {M−1} c_ {0} c_ {1} c_ {2}… c_ {M−1} Constraint * All inputs are integers * 1 \ ≤ N \ ≤ 300 \,000 * 1 \ ≤ M \ ≤ 300 \,000 * 0 \ ≤ a_ {i} \ ≤ 1 \, 000 \,000 * 0 \ ≤ b_ {i} \ ≤ 1 \, 000 \,000 * 0 \ ≤ c_ {i} \ ≤ ∑a_k output Print the answer on line M. On the i-line, output `Yes` if the participant i-1 can get more points than the target score, and` No` if not. sample Sample input 1 6 1 2 1 3 4 5 7 1 3 4 5 3 1 0 2 4 5 3 4 5 3 Sample output 1 Yes Yes Yes Yes Yes No No The points obtained by each participant are as follows. * Participant 0: 1 + 1 = 2 * Participant 1: 1 + 2 + 1 + 3 = 7 * Participant 2: 1 + 2 + 1 + 3 + 4 = 11 * Participant 3: 1 + 2 + 1 + 3 + 4 + 5 = 16 * Participant 4: 1 + 2 + 1 + 3 = 7 * Participant 5: 1 + 1 = 2 * Participants 6: 0 Sample input 2 8 1 1 2 3 3 4 6 100 Four 1 3 4 99 1 10 15 120 Sample output 2 Yes Yes No No Example Input 6 1 2 1 3 4 5 7 1 3 4 5 3 1 0 2 4 5 3 4 5 3 Output Yes Yes Yes Yes Yes No No Submitted Solution: ``` #!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright : @Huki_Hara # Created : 2015-03-14 n = int(input()) a = list(map(int, input().split())) m = int(input()) b = list(map(int, input().split())) c = list(map(int, input().split())) l = [] i = 0 while i < m: sum = 0 j = 0 while j < n: if a[j] <= b[i]: sum += a[j] j += 1 i += 1 l.append(sum) i = 0 while i < m: if l[i] >= c[i]: print("Yes") else: print("No") i += 1 ``` No
87,477
[ 0.31494140625, -0.10992431640625, -0.33544921875, 0.2108154296875, -0.54296875, -0.431884765625, -0.1300048828125, 0.291259765625, 0.11395263671875, 0.5556640625, 0.3662109375, -0.07696533203125, 0.293212890625, -0.61474609375, -0.384521484375, -0.20654296875, -0.90673828125, -0.89...
11
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. Tags: implementation Correct Solution: ``` n, k = map(int, input().split()) a = list(map(int, input().split())) s, ans = [-2]*k, [0]*n q1 = q2 = naw = 0 while q1 < n or any(q != -1 for q in s): for q in range(k): naw += (s[q] != -1 and s[q] != -2 and s[q][1] == q2)/n if q2 == 74: q3 = 0 for q in range(k): if s[q] != -1: if s[q] == -2 and q1 < n: s[q] = [0, a[q1], q1] q1 += 1 elif s[q] == -2 or q1 == n and q2 == s[q][1]: s[q] = -1 elif q2 == s[q][1]: s[q] = [s[q][1], s[q][1]+a[q1], q1] ans[s[q][2]] |= (naw * 100+0.5)//1 == q2 - s[q][0] + 1 q1 += 1 else: ans[s[q][2]] |= (naw * 100+0.5)//1 == q2-s[q][0]+1 q2 += 1 print(ans.count(1)) ```
87,593
[ 0.1492919921875, 0.185302734375, -0.285888671875, 0.2432861328125, -0.7822265625, -0.42822265625, -0.28076171875, -0.07611083984375, 0.36572265625, 0.96875, 0.2978515625, -0.07177734375, 0.171630859375, -1.0078125, -0.289794921875, 0.2235107421875, -0.449462890625, -0.60400390625, ...
11
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. Tags: implementation Correct Solution: ``` from collections import defaultdict as dd import math import heapq def nn(): return int(input()) def li(): return list(input()) def mi(): return map(int, input().split()) def lm(): return list(map(int, input().split())) n, p=mi() l=lm() pq=[] done=0 intints=[] for i in range(min(p,n)): heapq.heappush(pq, l[i]) intints.append((0,l[i])) currtask=min(p,n) interesting=0 donetimes=[] while done<n: nextdone=heapq.heappop(pq) done+=1 currtime=nextdone donetimes.append(currtime) if currtask<len(l): heapq.heappush(pq,l[currtask]+currtime) intints.append((currtime,l[currtask]+currtime)) currtask+=1 percenttimes=[] for i in range(n): percenttimes.append((math.floor(100*(i+1)/n+1/2),donetimes[i])) #print(percenttimes) for lower, upper in intints: for j in range(1,len(percenttimes)): lowertime=percenttimes[j-1][1] uppertime=percenttimes[j][1] percent=percenttimes[j-1][0] values=upper-lower #print(values,percent) if percent in range(1,values+1): time=lower+percent-1/2 if time>lowertime and time<uppertime: interesting+=1 break print(interesting) #print(donetimes, intints) ```
87,594
[ 0.1492919921875, 0.185302734375, -0.285888671875, 0.2432861328125, -0.7822265625, -0.42822265625, -0.28076171875, -0.07611083984375, 0.36572265625, 0.96875, 0.2978515625, -0.07177734375, 0.171630859375, -1.0078125, -0.289794921875, 0.2235107421875, -0.449462890625, -0.60400390625, ...
11
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. Tags: implementation Correct Solution: ``` n,k=map(int,input().split()) li=list(map(int,input().split())) k=min(n,k) res=li[:k] pro=li[:k] for i in range(k-1,-1,-1): li.pop(i) don=[] for i in range(k): don.append(0) t=0 d=0 m=0 c=0 used=[False]*n p=list(range(k)) while li or res: t1=t pd=[] for i in don: pd.append(i) t=min(res)+t1 for i in range(len(don)): don[i]=don[i]+t-t1 for i in range(len(res)): res[i]=pro[i]-don[i] for i in range(len(don)): if pd[i]<d<=don[i] and not used[p[i]]: c+=1 used[p[i]]='True' z=0 for i in range(len(res)-1,-1,-1): if res[i]==0: z+=1 pro.pop(i) res.pop(i) don.pop(i) for j in range(i,k-1): p[j]=p[j+1] m+=z d=int(100*(m/n)+0.5) while(z): z-=1 if li: pro.append(li[0]) res.append(li[0]) don.append(0) p[k-1-z]=n-len(li) li.pop(0) print(c) ```
87,595
[ 0.1492919921875, 0.185302734375, -0.285888671875, 0.2432861328125, -0.7822265625, -0.42822265625, -0.28076171875, -0.07611083984375, 0.36572265625, 0.96875, 0.2978515625, -0.07177734375, 0.171630859375, -1.0078125, -0.289794921875, 0.2235107421875, -0.449462890625, -0.60400390625, ...
11
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. Tags: implementation Correct Solution: ``` n,k = [int(i) for i in input().split()] a = [int(i) for i in input().split()] k = min(k, n) p = a[:k];q = a[:k];r = list(range(k)) m = 0;j = k ans = 0 used = [False]*n while True: d = int(100 * m / n + 0.5) for i in range(k): if p[i]==0: continue p[i]-=1 if q[i]-p[i]==d and not used[r[i]]: ans += 1 used[r[i]] = True if p[i] == 0: m += 1 if j == n: continue p[i] = a[j];q[i] = a[j];r[i] = j j += 1 if p.count(0) == k: break print(ans) ```
87,596
[ 0.1492919921875, 0.185302734375, -0.285888671875, 0.2432861328125, -0.7822265625, -0.42822265625, -0.28076171875, -0.07611083984375, 0.36572265625, 0.96875, 0.2978515625, -0.07177734375, 0.171630859375, -1.0078125, -0.289794921875, 0.2235107421875, -0.449462890625, -0.60400390625, ...
11
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. Tags: implementation Correct Solution: ``` #!/usr/bin/env python3 import math from collections import deque n, k = map(int, input().split()) q = deque(list(map(int, input().split()))) progress = 0 d = 0 interesting = 0 jobs = [] def minpass(jobs): return list(map(lambda x: [x[0], x[1]+1, x[2]], jobs)) def rmdone(jobs): cur_jobs = list(filter(lambda x: x[0]>x[1], jobs)) done = len(jobs) - len(cur_jobs) return (cur_jobs, done) while len(jobs) > 0 or len(q) > 0: for j in range(len(jobs)): if jobs[j][1] == d and not jobs[j][2]: interesting += 1 jobs[j][2] = True jobs, done = rmdone(jobs) progress += done d = max(math.floor(100*progress/n + 0.5), 0.00001) while len(q) and len(jobs) < k: jobs.append([q.popleft(),0,False]) jobs = minpass(jobs) print(interesting) ```
87,597
[ 0.1492919921875, 0.185302734375, -0.285888671875, 0.2432861328125, -0.7822265625, -0.42822265625, -0.28076171875, -0.07611083984375, 0.36572265625, 0.96875, 0.2978515625, -0.07177734375, 0.171630859375, -1.0078125, -0.289794921875, 0.2235107421875, -0.449462890625, -0.60400390625, ...
11
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. Tags: implementation Correct Solution: ``` n, k = map(int, input().split()) a = list(map(int, input().split())) processes = [0] * k start = [None] * n finish = [None] * n for i in range(n): first_free = min(enumerate(processes), key=lambda x: x[1])[0] start[i] = processes[first_free] finish[i] = processes[first_free] + a[i] processes[first_free] = finish[i] finish.sort() finished = [0] * n * 151 j = 0 for i in range(n * 151): finished[i] = finished[i - 1] while finish[j] <= i and j < n - 1: if finish[j] == i: finished[i] += 1 j += 1 res = 0 for i in range(n): is_good = False for j in range(a[i]): time = start[i] + j m = finished[time] if j + 1 == int(100 * m / n + 0.5): res += 1 break print(res) ```
87,598
[ 0.1492919921875, 0.185302734375, -0.285888671875, 0.2432861328125, -0.7822265625, -0.42822265625, -0.28076171875, -0.07611083984375, 0.36572265625, 0.96875, 0.2978515625, -0.07177734375, 0.171630859375, -1.0078125, -0.289794921875, 0.2235107421875, -0.449462890625, -0.60400390625, ...
11
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. Tags: implementation Correct Solution: ``` nums = list(map(int, input().split())) n, k = nums[0], nums[1] solved = 0 tests = list(map(int, input().split())) res = 0 machines_remain = [] machines_now = [] machines_interes = [] for foo in range(k): machines_remain.append(0) machines_now.append(0) machines_interes.append(0) d = 0 while True: if solved < n: m = 0 while m < len(machines_remain): if machines_remain[m] == 0 and len(tests) > 0: machines_remain[m] = tests[0] machines_now[m] = 0 machines_interes[m] = 0 tests.pop(0) if machines_remain[m] > 0: machines_now[m] += 1 if (machines_now[m] == d) and (machines_interes[m]==0): machines_interes[m] = 1 res += 1 machines_remain[m] -= 1 if machines_remain[m] == 0: machines_now[m] = 0 solved += 1 m += 1 d = int(100 * solved / n + 0.5) else: print(res) break ```
87,599
[ 0.1492919921875, 0.185302734375, -0.285888671875, 0.2432861328125, -0.7822265625, -0.42822265625, -0.28076171875, -0.07611083984375, 0.36572265625, 0.96875, 0.2978515625, -0.07177734375, 0.171630859375, -1.0078125, -0.289794921875, 0.2235107421875, -0.449462890625, -0.60400390625, ...
11
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. Tags: implementation Correct Solution: ``` # https://codeforces.com/problemset/problem/1121/C import heapq n, k = map(int, input().split()) task = list(map(int, input().split())) a = [[i, x] for i, x in enumerate(task)] start_ = [0] * n end_ = [0] * n Q = [] for i in range(k): if len(a) > 0: ind, length = a.pop(0) start_[ind] = 0 end_[ind] = length heapq.heappush(Q, length) while len(Q) > 0: end_t = heapq.heappop(Q) if len(a) > 0: ind, length = a.pop(0) start_[ind] = end_t end_[ind] = end_t + length heapq.heappush(Q, end_[ind]) end_e = sorted(end_) d = {} count = 0 for i, e in enumerate(end_e): count += 1 d[e] = int(100 * count / n + 0.5) special = 0 for i in range(n): flg = False arr = [] for j, end_t in enumerate(end_e[:-1]): if end_t >= end_[i]:break if end_e[j+1] > start_[i]: arr.append(end_t) arr.append(end_[i]) if len(arr) > 1: for x, y in zip(arr[:-1], arr[1:]): if x-start_[i] < d[x] and d[x] <= y - start_[i]: flg = True break if flg == True: special += 1 print(special)#32 100 33 1 ```
87,600
[ 0.1492919921875, 0.185302734375, -0.285888671875, 0.2432861328125, -0.7822265625, -0.42822265625, -0.28076171875, -0.07611083984375, 0.36572265625, 0.96875, 0.2978515625, -0.07177734375, 0.171630859375, -1.0078125, -0.289794921875, 0.2235107421875, -0.449462890625, -0.60400390625, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. Submitted Solution: ``` import sys, os, io def rs(): return sys.stdin.readline().rstrip() def ri(): return int(sys.stdin.readline()) def ria(): return list(map(int, sys.stdin.readline().split())) def ws(s): sys.stdout.write(s + '\n') def wi(n): sys.stdout.write(str(n) + '\n') def wia(a): sys.stdout.write(' '.join([str(x) for x in a]) + '\n') import math,datetime,functools,itertools,operator,bisect,fractions,statistics from collections import deque,defaultdict,OrderedDict,Counter from fractions import Fraction from decimal import Decimal from sys import stdout from heapq import heappush, heappop, heapify ,_heapify_max,_heappop_max,nsmallest,nlargest def main(): # mod=1000000007 # InverseofNumber(mod) # InverseofFactorial(mod) # factorial(mod) starttime=datetime.datetime.now() if(os.path.exists('input.txt')): sys.stdin = open("input.txt","r") sys.stdout = open("output.txt","w") tc=1 for _ in range(tc): n,k=ria() k=min(n,k) a=ria() rn=a[:k] arn=[0]*k m=0 j=k d=0 ans=0 ignore={} sol={} prevd=0 while m<n: for i in range(k): if i not in ignore: arn[i]+=1 if arn[i]==prevd and i not in sol: # print(arn[i]) ans+=1 sol[i]=1 if arn[i]==rn[i] : m+=1 arn[i]=0 if i in sol: del sol[i] d=math.floor(((100*m)/n)+0.5) if j<n: rn[i]=a[j] j+=1 else: ignore[i]=1 prevd=d print(ans) #<--Solving Area Ends endtime=datetime.datetime.now() time=(endtime-starttime).total_seconds()*1000 if(os.path.exists('input.txt')): print("Time:",time,"ms") class FastReader(io.IOBase): newlines = 0 def __init__(self, fd, chunk_size=1024 * 8): self._fd = fd self._chunk_size = chunk_size self.buffer = io.BytesIO() def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size)) 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, size=-1): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size)) 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() class FastWriter(io.IOBase): def __init__(self, fd): self._fd = fd self.buffer = io.BytesIO() self.write = self.buffer.write def flush(self): os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class FastStdin(io.IOBase): def __init__(self, fd=0): self.buffer = FastReader(fd) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") class FastStdout(io.IOBase): def __init__(self, fd=1): self.buffer = FastWriter(fd) self.write = lambda s: self.buffer.write(s.encode("ascii")) self.flush = self.buffer.flush if __name__ == '__main__': sys.stdin = FastStdin() sys.stdout = FastStdout() main() ``` Yes
87,601
[ 0.26220703125, 0.254638671875, -0.2388916015625, 0.29443359375, -0.77978515625, -0.301513671875, -0.279541015625, -0.00140380859375, 0.2110595703125, 0.9375, 0.1474609375, -0.01401519775390625, 0.1568603515625, -1.0078125, -0.28466796875, 0.058441162109375, -0.4501953125, -0.614257...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. Submitted Solution: ``` n,k=map(int,input().split()) a=list(map(int,input().split())) j=0 p=[[0,0]]*k;sol=set();testing=set();test={} t=0;sub=0;b=False;an=0 while 1: if sub==n: break for i in range(k): if p[i][0]==0: if j<n: #continue #print(p) p[i]=[a[j],j]; testing.add(j); test[j]=1;j+=1 else: p[i][0]-=1 test[p[i][1]]+=1 if p[i][0]==0: #print(t,i) if p[i][1] not in testing: continue sub+=1 #print(testing) testing.remove(p[i][1]) test[p[i][1]]=-1 for i in range(k): if p[i][0]==0: if j<n: #continue #print(p) p[i]=[a[j],j]; testing.add(j); test[j]=1;j+=1 #print(t,testing) t+=1 if t==49: pass #print('~',csub,test[7]) for ss,g in test.items(): if int(100*sub/n+.5)==g: sol.add(ss) #print(g,csub,testing) print(len(sol)) ``` Yes
87,602
[ 0.26220703125, 0.254638671875, -0.2388916015625, 0.29443359375, -0.77978515625, -0.301513671875, -0.279541015625, -0.00140380859375, 0.2110595703125, 0.9375, 0.1474609375, -0.01401519775390625, 0.1568603515625, -1.0078125, -0.28466796875, 0.058441162109375, -0.4501953125, -0.614257...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. Submitted Solution: ``` from collections import deque n, k = map(int, input().split()) a = list(enumerate(map(int, input().split()))) orig = a for i in range(len(a)): a[i] = (a[i][1], a[i][0]) a = deque(a) testing = [] completed = 0 interesting = set() def load(): global a global testing while a and len(testing) < k: testing.append(a.popleft()) def work(): global testing global completed old = len(testing) testing = [(x[0] - 1, x[1]) for x in testing if x[0] > 1] new = len(testing) completed += (old - new) def status(): global completed global n return ((200 * completed + n) // (2 * n)) load() st = status() for remaining, i in testing: current_test = orig[i][0] - remaining + 1 if current_test == st: interesting.add(i) while a: load() work() while testing: work() print(len(interesting)) ``` Yes
87,603
[ 0.26220703125, 0.254638671875, -0.2388916015625, 0.29443359375, -0.77978515625, -0.301513671875, -0.279541015625, -0.00140380859375, 0.2110595703125, 0.9375, 0.1474609375, -0.01401519775390625, 0.1568603515625, -1.0078125, -0.28466796875, 0.058441162109375, -0.4501953125, -0.614257...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. Submitted Solution: ``` import bisect n, k = map(int, input().split()) cl = list(map(int, input().split())) ncl = list(cl) def round(x): return int(x+0.5) def argsort(seq): return sorted(range(len(seq)), key=seq.__getitem__) prea = cl[:min(k, n)] for i in range(min(k, n), n): mn = min(prea) cl[i]+=mn del prea[prea.index(mn)] prea.append(cl[i]) ind = argsort(cl) pl = sorted(cl) count = 0 for i in range(n): a = pl[i] - ncl[ind[i]] pos = bisect.bisect_left(pl[: i+1], a) r = round(pos*100/n) prea = 1 for j in range(pos, i+1): if prea<r<=pl[j]-a: count+=1 break prea = pl[j]-a r = round((j+1)*100/n) print(count) ``` Yes
87,604
[ 0.26220703125, 0.254638671875, -0.2388916015625, 0.29443359375, -0.77978515625, -0.301513671875, -0.279541015625, -0.00140380859375, 0.2110595703125, 0.9375, 0.1474609375, -0.01401519775390625, 0.1568603515625, -1.0078125, -0.28466796875, 0.058441162109375, -0.4501953125, -0.614257...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. Submitted Solution: ``` import heapq def solve(k, tests): percentage = 100 / len(tests) heap = [] result = 0 ans = 0 interesting = set() for s, test_time in enumerate(tests[:k]): heapq.heappush(heap, (test_time, 0, test_time, s)) i = k while len(heap) > 0: time, start, test_time, s = heapq.heappop(heap) result = round(result + percentage) if i < len(tests): heapq.heappush(heap, (time + tests[i], time, tests[i], i)) i += 1 if len(heap) > 0: end = heap[0][0] for _time, _start, _test_time, j in heap: test_start = time - _start + 1 test_end = end - _start + 1 if test_start <= result and test_end >= result and j not in interesting: interesting.add(j) ans += 1 return ans if __name__ == '__main__': n, k = [int(d) for d in input().split()] tests = [int(d) for d in input().split()] print(solve(k, tests)) ``` No
87,605
[ 0.26220703125, 0.254638671875, -0.2388916015625, 0.29443359375, -0.77978515625, -0.301513671875, -0.279541015625, -0.00140380859375, 0.2110595703125, 0.9375, 0.1474609375, -0.01401519775390625, 0.1568603515625, -1.0078125, -0.28466796875, 0.058441162109375, -0.4501953125, -0.614257...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. Submitted Solution: ``` n, k = map(int, input().split()) a = list(map(int, input().split())) processes = [0] * k start = [None] * n finish = [None] * n for i in range(n): first_free = min(enumerate(processes), key=lambda x: x[1])[0] start[i] = processes[first_free] finish[i] = processes[first_free] + a[i] processes[first_free] = finish[i] finish.sort() finished = [0] * n * 151 j = 0 for i in range(n * 151): finished[i] = finished[i - 1] while finish[j] <= i and j < n - 1: if finish[j] == i: finished[i] += 1 j += 1 res = 0 for i in range(n): is_good = False for j in range(a[i]): time = start[i] + j m = finished[time] if j + 1 == round(100 * (m / n)): res += 1 break print(res) ``` No
87,606
[ 0.26220703125, 0.254638671875, -0.2388916015625, 0.29443359375, -0.77978515625, -0.301513671875, -0.279541015625, -0.00140380859375, 0.2110595703125, 0.9375, 0.1474609375, -0.01401519775390625, 0.1568603515625, -1.0078125, -0.28466796875, 0.058441162109375, -0.4501953125, -0.614257...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. Submitted Solution: ``` #!/usr/bin/pypy # -*- coding: utf-8 -*- INF = float('inf') def main(): n, k = map(int, input().split()) nums = list(map(int, input().split())) mp = [0] * k ms = [0] * k ml = [0] * k task_idx = 0 for i in range(min(n, k)): mp[i] = nums[i] ml[i] = 0 task_idx += 1 comp = 0 ans = 0 pnt = -1 nt = -1 while comp < n: nst = float('inf') for j in range(k): if mp[j] > 0: nst = min(nst, mp[j] + ms[j]) for j in range(k): if mp[j] + ms[j] == nst: if ml[j] == 1 and nst - ms[j] >= pnt and pnt != 0: ans += 1 comp += 1 mp[j] = ms[j] = 0 ml[j] = 0 nt = round(float(comp) / n * 100) for i in range(k): if mp[i] != 0: if ml[i] == 1 and nst - ms[i] >= pnt and pnt != 0: ans += 1 ml[i] = 2 if nst - ms[i] < nt and ml[i] != 2: ml[i] = 1 elif mp[i] == 0 and task_idx < n: mp[i] = nums[task_idx] ms[i] = nst ml[i] = 1 task_idx += 1 pnt = nt print(ans) if __name__ == '__main__': main() ``` No
87,607
[ 0.26220703125, 0.254638671875, -0.2388916015625, 0.29443359375, -0.77978515625, -0.301513671875, -0.279541015625, -0.00140380859375, 0.2110595703125, 0.9375, 0.1474609375, -0.01401519775390625, 0.1568603515625, -1.0078125, -0.28466796875, 0.058441162109375, -0.4501953125, -0.614257...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. Submitted Solution: ``` import math x = input().split() n, k = int(x[0]), int(x[1]) tmp = input().split() ais = [] for i in tmp: ais.append(int(i)) testing = [] for i in range(n): testing.append(0) m = 0 ans = set() def int_count(num, avg): for i in range(len(num)): if num[i] == 0: return ans if num[i] == avg and num[i] != 0: ans.add(i) completed = 0 res = 0 while completed < n: tmpk = k tmp_ind = 0 tmp_completed = 0 while tmpk > 0 and tmp_ind < n: if testing[tmp_ind] + 1 == ais[tmp_ind]: tmp_completed += 1 if testing[tmp_ind] < ais[tmp_ind]: testing[tmp_ind] += 1 tmpk -= 1 tmp_ind += 1 int_count(testing, math.floor((100*(completed) /n) + 0.5)) # int_count(testing, math.floor((100 * (completed) / n) + 0.5)) completed += tmp_completed print(len(ans)) ``` No
87,608
[ 0.26220703125, 0.254638671875, -0.2388916015625, 0.29443359375, -0.77978515625, -0.301513671875, -0.279541015625, -0.00140380859375, 0.2110595703125, 0.9375, 0.1474609375, -0.01401519775390625, 0.1568603515625, -1.0078125, -0.28466796875, 0.058441162109375, -0.4501953125, -0.614257...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Jafar has n cans of cola. Each can is described by two integers: remaining volume of cola ai and can's capacity bi (ai ≤ bi). Jafar has decided to pour all remaining cola into just 2 cans, determine if he can do this or not! Input The first line of the input contains one integer n (2 ≤ n ≤ 100 000) — number of cola cans. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 109) — volume of remaining cola in cans. The third line contains n space-separated integers that b1, b2, ..., bn (ai ≤ bi ≤ 109) — capacities of the cans. Output Print "YES" (without quotes) if it is possible to pour all remaining cola in 2 cans. Otherwise print "NO" (without quotes). You can print each letter in any case (upper or lower). Examples Input 2 3 5 3 6 Output YES Input 3 6 8 9 6 10 12 Output NO Input 5 0 0 5 0 0 1 1 8 10 5 Output YES Input 4 4 1 0 3 5 2 2 3 Output YES Note In the first sample, there are already 2 cans, so the answer is "YES". Submitted Solution: ``` def main(): input() print(("NO", "YES")[sum(map(int, input().split())) <= sum(sorted(map(int, input().split()), reverse=True)[:2])]) if __name__ == '__main__': main() ``` Yes
88,076
[ 0.279296875, -0.00926971435546875, -0.04571533203125, 0.12005615234375, -0.72314453125, -0.56689453125, 0.003902435302734375, 0.6025390625, -0.062225341796875, 0.734375, 0.6474609375, 0.0268707275390625, -0.2130126953125, -0.65087890625, -0.5322265625, 0.26708984375, -0.40869140625, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Jafar has n cans of cola. Each can is described by two integers: remaining volume of cola ai and can's capacity bi (ai ≤ bi). Jafar has decided to pour all remaining cola into just 2 cans, determine if he can do this or not! Input The first line of the input contains one integer n (2 ≤ n ≤ 100 000) — number of cola cans. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 109) — volume of remaining cola in cans. The third line contains n space-separated integers that b1, b2, ..., bn (ai ≤ bi ≤ 109) — capacities of the cans. Output Print "YES" (without quotes) if it is possible to pour all remaining cola in 2 cans. Otherwise print "NO" (without quotes). You can print each letter in any case (upper or lower). Examples Input 2 3 5 3 6 Output YES Input 3 6 8 9 6 10 12 Output NO Input 5 0 0 5 0 0 1 1 8 10 5 Output YES Input 4 4 1 0 3 5 2 2 3 Output YES Note In the first sample, there are already 2 cans, so the answer is "YES". Submitted Solution: ``` input() list1=[*map(int,input().split())] list2=[*map(int,input().split())] sum=0 for a in list1: sum+=a print(sum) m2=0 m=0 for a in list2: if a>=m: m,m2=a,m elif a<=m and a>m2: m2=a print(m,m2) if sum<=m+m2: print('YES') else: print('NO') ``` No
88,080
[ 0.22900390625, 0.0226898193359375, -0.047515869140625, 0.10772705078125, -0.7099609375, -0.5908203125, 0.0251922607421875, 0.56591796875, -0.049163818359375, 0.7919921875, 0.62939453125, 0.0938720703125, -0.1968994140625, -0.685546875, -0.51953125, 0.30810546875, -0.412841796875, -...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Jafar has n cans of cola. Each can is described by two integers: remaining volume of cola ai and can's capacity bi (ai ≤ bi). Jafar has decided to pour all remaining cola into just 2 cans, determine if he can do this or not! Input The first line of the input contains one integer n (2 ≤ n ≤ 100 000) — number of cola cans. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 109) — volume of remaining cola in cans. The third line contains n space-separated integers that b1, b2, ..., bn (ai ≤ bi ≤ 109) — capacities of the cans. Output Print "YES" (without quotes) if it is possible to pour all remaining cola in 2 cans. Otherwise print "NO" (without quotes). You can print each letter in any case (upper or lower). Examples Input 2 3 5 3 6 Output YES Input 3 6 8 9 6 10 12 Output NO Input 5 0 0 5 0 0 1 1 8 10 5 Output YES Input 4 4 1 0 3 5 2 2 3 Output YES Note In the first sample, there are already 2 cans, so the answer is "YES". Submitted Solution: ``` n=int(input()) def solve(): a=[int(i) for i in input().split()] b=[int(i) for i in input().split()] v=max(b) b.remove(v) v+=max(b) if sum(a) >=v: print('yes') else: print('no') solve() ``` No
88,082
[ 0.2322998046875, 0.0170745849609375, -0.03424072265625, 0.181640625, -0.76611328125, -0.5830078125, -0.015167236328125, 0.6240234375, -0.0079193115234375, 0.7158203125, 0.6201171875, 0.03057861328125, -0.2437744140625, -0.6845703125, -0.5625, 0.328125, -0.399169921875, -0.409423828...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls? Constraints * 1 \leq K \leq N \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: N K Output Print the maximum possible difference in the number of balls received. Examples Input 3 2 Output 1 Input 3 1 Output 0 Input 8 5 Output 3 Submitted Solution: ``` N,K = map(int,input().split(" ")) if(K==1): print(0) else: print(N-K) ``` Yes
88,185
[ 0.447021484375, 0.5966796875, -0.358154296875, 0.295166015625, -0.732421875, -0.57421875, -0.1710205078125, 0.07208251953125, -0.281494140625, 1.1318359375, 0.50244140625, 0.216064453125, 0.302001953125, -0.5302734375, -0.650390625, -0.1260986328125, -1.001953125, -0.86083984375, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls? Constraints * 1 \leq K \leq N \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: N K Output Print the maximum possible difference in the number of balls received. Examples Input 3 2 Output 1 Input 3 1 Output 0 Input 8 5 Output 3 Submitted Solution: ``` n, k = map(int, input().split()) print(n-(k-1) - n // k) ``` Yes
88,186
[ 0.439208984375, 0.6201171875, -0.36279296875, 0.314208984375, -0.70361328125, -0.5751953125, -0.228271484375, 0.057281494140625, -0.263427734375, 1.162109375, 0.50390625, 0.272705078125, 0.273193359375, -0.54150390625, -0.66455078125, -0.138916015625, -0.96142578125, -0.88037109375...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls? Constraints * 1 \leq K \leq N \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: N K Output Print the maximum possible difference in the number of balls received. Examples Input 3 2 Output 1 Input 3 1 Output 0 Input 8 5 Output 3 Submitted Solution: ``` n, k = list(map(int, input().split())) if k != 1: print(n-k) else: print(0) ``` Yes
88,187
[ 0.446044921875, 0.58984375, -0.348388671875, 0.316650390625, -0.74609375, -0.57861328125, -0.183837890625, 0.080322265625, -0.265625, 1.1201171875, 0.50390625, 0.2227783203125, 0.32373046875, -0.54296875, -0.6708984375, -0.1112060546875, -1.015625, -0.8642578125, -0.31494140625, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls? Constraints * 1 \leq K \leq N \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: N K Output Print the maximum possible difference in the number of balls received. Examples Input 3 2 Output 1 Input 3 1 Output 0 Input 8 5 Output 3 Submitted Solution: ``` N,K = map(int,input().split()) if K < 2: print(0) else: print(N-K) ``` Yes
88,188
[ 0.42529296875, 0.6103515625, -0.359130859375, 0.291015625, -0.728515625, -0.578125, -0.1939697265625, 0.0924072265625, -0.258056640625, 1.1591796875, 0.50146484375, 0.2137451171875, 0.29443359375, -0.541015625, -0.63330078125, -0.11383056640625, -1.001953125, -0.88427734375, -0.2...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls? Constraints * 1 \leq K \leq N \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: N K Output Print the maximum possible difference in the number of balls received. Examples Input 3 2 Output 1 Input 3 1 Output 0 Input 8 5 Output 3 Submitted Solution: ``` N,K=map(int,input().split()) print(N-K if K!=0 else 0) ``` No
88,190
[ 0.408935546875, 0.61376953125, -0.35498046875, 0.2939453125, -0.7060546875, -0.6142578125, -0.2244873046875, 0.08935546875, -0.27734375, 1.130859375, 0.51025390625, 0.259765625, 0.267822265625, -0.548828125, -0.669921875, -0.1483154296875, -1.0087890625, -0.8798828125, -0.3037109...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls? Constraints * 1 \leq K \leq N \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: N K Output Print the maximum possible difference in the number of balls received. Examples Input 3 2 Output 1 Input 3 1 Output 0 Input 8 5 Output 3 Submitted Solution: ``` n,k = map(int, input().split()) if k == 1: print(1) else: print(n -k) ``` No
88,191
[ 0.44287109375, 0.599609375, -0.369873046875, 0.300537109375, -0.72705078125, -0.60498046875, -0.1866455078125, 0.05682373046875, -0.269775390625, 1.1328125, 0.51171875, 0.222900390625, 0.30126953125, -0.537109375, -0.64404296875, -0.127197265625, -1.013671875, -0.86962890625, -0....
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls? Constraints * 1 \leq K \leq N \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: N K Output Print the maximum possible difference in the number of balls received. Examples Input 3 2 Output 1 Input 3 1 Output 0 Input 8 5 Output 3 Submitted Solution: ``` import sys input = sys.stdin.readline def main(): N, K = map(int, input().split()) print(N-K) if __name__ == '__main__': main() ``` No
88,192
[ 0.367919921875, 0.56005859375, -0.302490234375, 0.2208251953125, -0.7197265625, -0.50830078125, -0.261474609375, 0.08837890625, -0.2442626953125, 1.064453125, 0.5126953125, 0.194580078125, 0.28173828125, -0.50732421875, -0.7119140625, -0.1678466796875, -0.9765625, -0.86669921875, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Input The input is given from Standard Input in the following format: > $N \ Q$ $a_1 \ b_1$ $a_2 \ b_2$ $ : \ : $ $a_Q \ b_Q$ Output * You have to print $N$ lines. * The $i$-th line should contain the number of dishes of sushi had eaten for customer $i (1 \le i \le N)$. Constraints * $3 \le N, Q \le 100,000$ * $1 \le a_i \le N$ * $1 \le b_i \le 10^{12}$ * Any final results do not exceed $2 \times 10^{13}$. Subtasks Subtask 1 [ $60$ points ] * $N, Q \le 100$ * $b_i = 1$ Subtask 2 [ $400$ points ] * $N, Q \le 100$ * $b_i \le 10^{12}$ Subtask 3 [ $240$ points ] * $N, Q \le 100,000$ * $b_i = 1$ Subtask 4 [ $500$ points ] * There are no additional constraints. Output * You have to print $N$ lines. * The $i$-th line should contain the number of dishes of sushi had eaten for customer $i (1 \le i \le N)$. Constraints * $3 \le N, Q \le 100,000$ * $1 \le a_i \le N$ * $1 \le b_i \le 10^{12}$ * Any final results do not exceed $2 \times 10^{13}$. Subtasks Subtask 1 [ $60$ points ] * $N, Q \le 100$ * $b_i = 1$ Subtask 2 [ $400$ points ] * $N, Q \le 100$ * $b_i \le 10^{12}$ Subtask 3 [ $240$ points ] * $N, Q \le 100,000$ * $b_i = 1$ Subtask 4 [ $500$ points ] * There are no additional constraints. Input The input is given from Standard Input in the following format: > $N \ Q$ $a_1 \ b_1$ $a_2 \ b_2$ $ : \ : $ $a_Q \ b_Q$ Examples Input 9 3 5 11 8 4 4 7 Output 4 4 4 4 2 2 1 1 0 Input 6 6 3 5 6 11 1 6 4 7 5 2 2 5 Output 10 10 5 5 4 2 Input 5 6 1 1 2 1 3 1 1 1 5 1 3 1 Output 2 2 1 1 0 Input 10 10 10 10 9 20 8 30 7 40 6 50 5 60 4 70 3 80 2 90 1 100 Output 223 123 77 50 33 21 12 7 3 1 Submitted Solution: ``` import sys import numpy as np import numba from numba import njit i8 = numba.int64 read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines @njit((i8[:], ), cache=True) def build(raw_data): bit = raw_data.copy() for i in range(len(bit)): j = i + (i & (-i)) if j < len(bit): bit[j] += bit[i] return bit @njit((i8[:], i8), cache=True) def get_sum(bit, i): s = 0 while i: s += bit[i] i -= i & -i return s @njit((i8[:], i8, i8), cache=True) def add(bit, i, x): while i < len(bit): bit[i] += x i += i & -i @njit((i8[:], i8), cache=True) def find_kth_element(bit, k): N = len(bit) x, sx = 0, 0 dx = 1 while 2 * dx < N: dx *= 2 while dx: y = x + dx if y < N: sy = sx + bit[y] if sy < k: x, sx = y, sy dx //= 2 return x + 1 @njit((i8, i8[:]), cache=True) def main(N, AB): A, B = AB[::2], AB[1::2] Q = len(A) bit = np.zeros(N + 1, np.int64) # 長方形の右上になる x 座標集合を管理 bit_raw = np.zeros(N + 1, np.int64) H = np.zeros(N + 1, np.int64) # 長方形の高さを管理 H[0] = 10**13 + 10 bit_raw[N] = 1 add(bit, N, 1) for i in range(Q): a, b = A[i], B[i] n = get_sum(bit, a - 1) h = H[find_kth_element(bit, 1 + n)] if not bit_raw[a]: bit_raw[a] = 1 add(bit, a, 1) H[a] = h r = a while b: l = 0 if n == 0 else find_kth_element(bit, n) n -= 1 area = (H[l] - H[r]) * (r - l) if area <= b: b -= area if l: bit_raw[l] = 0 add(bit, l, -1) H[l], H[r] = 0, H[l] continue k = b // (r - l) b -= k * (r - l) H[r] += k if b: m = l + b bit_raw[m] = 1 add(bit, m, 1) H[m] = H[r] + 1 b = 0 for n in range(N, 0, -1): H[n - 1] = max(H[n - 1], H[n]) return H[1:N + 1] N, Q = map(int, readline().split()) AB = np.array(read().split(), np.int64) ans = main(N, AB) print('\n'.join(map(str, ans.tolist()))) ``` No
88,262
[ 0.39599609375, 0.1959228515625, -0.337158203125, -0.118408203125, -0.7890625, -0.163818359375, -0.0028324127197265625, 0.428466796875, 0.292236328125, 0.7978515625, 0.408935546875, 0.046966552734375, 0.1336669921875, -0.71240234375, -0.63818359375, -0.236083984375, -0.642578125, -0...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In the Catowice city next weekend the cat contest will be held. However, the jury members and the contestants haven't been selected yet. There are n residents and n cats in the Catowice, and each resident has exactly one cat living in his house. The residents and cats are numbered with integers from 1 to n, where the i-th cat is living in the house of i-th resident. Each Catowice resident is in friendship with several cats, including the one living in his house. In order to conduct a contest, at least one jury member is needed and at least one cat contestant is needed. Of course, every jury member should know none of the contestants. For the contest to be successful, it's also needed that the number of jury members plus the number of contestants is equal to n. Please help Catowice residents to select the jury and the contestants for the upcoming competition, or determine that it's impossible to do. Input The first line contains an integer t (1 ≤ t ≤ 100 000), the number of test cases. Then description of t test cases follow, where each description is as follows: The first line contains integers n and m (1 ≤ n ≤ m ≤ 10^6), the number of Catowice residents and the number of friendship pairs between residents and cats. Each of the next m lines contains integers a_i and b_i (1 ≤ a_i, b_i ≤ n), denoting that a_i-th resident is acquaintances with b_i-th cat. It's guaranteed that each pair of some resident and some cat is listed at most once. It's guaranteed, that for every i there exists a pair between i-th resident and i-th cat. Different test cases are separated with an empty line. It's guaranteed, that the sum of n over all test cases is at most 10^6 and that the sum of m over all test cases is at most 10^6. Output For every test case print: * "No", if it's impossible to select the jury and contestants. * Otherwise print "Yes". In the second line print two integers j and p (1 ≤ j, 1 ≤ p, j + p = n) — the number of jury members and the number of contest participants. In the third line print j distinct integers from 1 to n, the indices of the residents forming a jury. In the fourth line print p distinct integers from 1 to n, the indices of the cats, which will participate in the contest. In case there are several correct answers, print any of them. Example Input 4 3 4 1 1 2 2 3 3 1 3 3 7 1 1 1 2 1 3 2 2 3 1 3 2 3 3 1 1 1 1 2 4 1 1 1 2 2 1 2 2 Output Yes 2 1 1 3 2 Yes 1 2 2 1 3 No No Note In the first test case, we can select the first and the third resident as a jury. Both of them are not acquaintances with a second cat, so we can select it as a contestant. In the second test case, we can select the second resident as a jury. He is not an acquaintances with a first and a third cat, so they can be selected as contestants. In the third test case, the only resident is acquaintances with the only cat, so they can't be in the contest together. So it's not possible to make a contest with at least one jury and at least one cat. In the fourth test case, each resident is acquaintances with every cat, so it's again not possible to make a contest with at least one jury and at least one cat. Submitted Solution: ``` import sys def dfs1(v): used[v] = True for u in graph[v]: if not used[u]: dfs1(u) order.append(v) def dfs2(v, c): comp[v] = c for u in transparent_graph[v]: if comp[u] is None: dfs2(u, c) """ fin = open("fin.txt", "r") fout = open("fout.txt", "w") """ fin = sys.stdin fout = sys.stdout t = int(fin.readline()) for test in range(t): n, m = map(int, fin.readline().split()) graph = [list() for i in range(n)] transparent_graph = [list() for i in range(n)] for i in range(m): w, c = map(int, fin.readline().split()) w -= 1 c -= 1 # !w or !c # it means that w => !c # or c => !w graph[w].append(c) transparent_graph[c].append(w) order = list() used = [False] * n for i in range(n): if not used[i]: dfs1(i) order.reverse() comp = [None] * n c = 1 for v in order: if comp[v] is None: dfs2(v, c) c += 1 if c == 2: print("No", file=fout) fin.readline() continue villagers = list() cats = list() for i in range(n): if comp[i] == 1: villagers.append(i + 1) else: cats.append(i + 1) if len(villagers) == 0 or len(cats) == 0: print("No", file=fout) fin.readline() continue print("Yes", file=fout) print(len(villagers), len(cats), file=fout) for i in villagers: print(i, end=" ", file=fout) print(file=fout) for i in cats: print(i, end=" ", file=fout) print(file=fout) fin.readline() ``` No
88,479
[ 0.302978515625, 0.314697265625, -0.11187744140625, 0.26318359375, -0.75634765625, -0.382080078125, -0.4130859375, 0.373779296875, 0.1739501953125, 0.86083984375, 0.60009765625, -0.15576171875, -0.2073974609375, -0.67041015625, -0.4423828125, -0.2152099609375, -0.60888671875, -0.709...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In the Catowice city next weekend the cat contest will be held. However, the jury members and the contestants haven't been selected yet. There are n residents and n cats in the Catowice, and each resident has exactly one cat living in his house. The residents and cats are numbered with integers from 1 to n, where the i-th cat is living in the house of i-th resident. Each Catowice resident is in friendship with several cats, including the one living in his house. In order to conduct a contest, at least one jury member is needed and at least one cat contestant is needed. Of course, every jury member should know none of the contestants. For the contest to be successful, it's also needed that the number of jury members plus the number of contestants is equal to n. Please help Catowice residents to select the jury and the contestants for the upcoming competition, or determine that it's impossible to do. Input The first line contains an integer t (1 ≤ t ≤ 100 000), the number of test cases. Then description of t test cases follow, where each description is as follows: The first line contains integers n and m (1 ≤ n ≤ m ≤ 10^6), the number of Catowice residents and the number of friendship pairs between residents and cats. Each of the next m lines contains integers a_i and b_i (1 ≤ a_i, b_i ≤ n), denoting that a_i-th resident is acquaintances with b_i-th cat. It's guaranteed that each pair of some resident and some cat is listed at most once. It's guaranteed, that for every i there exists a pair between i-th resident and i-th cat. Different test cases are separated with an empty line. It's guaranteed, that the sum of n over all test cases is at most 10^6 and that the sum of m over all test cases is at most 10^6. Output For every test case print: * "No", if it's impossible to select the jury and contestants. * Otherwise print "Yes". In the second line print two integers j and p (1 ≤ j, 1 ≤ p, j + p = n) — the number of jury members and the number of contest participants. In the third line print j distinct integers from 1 to n, the indices of the residents forming a jury. In the fourth line print p distinct integers from 1 to n, the indices of the cats, which will participate in the contest. In case there are several correct answers, print any of them. Example Input 4 3 4 1 1 2 2 3 3 1 3 3 7 1 1 1 2 1 3 2 2 3 1 3 2 3 3 1 1 1 1 2 4 1 1 1 2 2 1 2 2 Output Yes 2 1 1 3 2 Yes 1 2 2 1 3 No No Note In the first test case, we can select the first and the third resident as a jury. Both of them are not acquaintances with a second cat, so we can select it as a contestant. In the second test case, we can select the second resident as a jury. He is not an acquaintances with a first and a third cat, so they can be selected as contestants. In the third test case, the only resident is acquaintances with the only cat, so they can't be in the contest together. So it's not possible to make a contest with at least one jury and at least one cat. In the fourth test case, each resident is acquaintances with every cat, so it's again not possible to make a contest with at least one jury and at least one cat. Submitted Solution: ``` print('NO') ``` No
88,480
[ 0.302978515625, 0.314697265625, -0.11187744140625, 0.26318359375, -0.75634765625, -0.382080078125, -0.4130859375, 0.373779296875, 0.1739501953125, 0.86083984375, 0.60009765625, -0.15576171875, -0.2073974609375, -0.67041015625, -0.4423828125, -0.2152099609375, -0.60888671875, -0.709...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In the Catowice city next weekend the cat contest will be held. However, the jury members and the contestants haven't been selected yet. There are n residents and n cats in the Catowice, and each resident has exactly one cat living in his house. The residents and cats are numbered with integers from 1 to n, where the i-th cat is living in the house of i-th resident. Each Catowice resident is in friendship with several cats, including the one living in his house. In order to conduct a contest, at least one jury member is needed and at least one cat contestant is needed. Of course, every jury member should know none of the contestants. For the contest to be successful, it's also needed that the number of jury members plus the number of contestants is equal to n. Please help Catowice residents to select the jury and the contestants for the upcoming competition, or determine that it's impossible to do. Input The first line contains an integer t (1 ≤ t ≤ 100 000), the number of test cases. Then description of t test cases follow, where each description is as follows: The first line contains integers n and m (1 ≤ n ≤ m ≤ 10^6), the number of Catowice residents and the number of friendship pairs between residents and cats. Each of the next m lines contains integers a_i and b_i (1 ≤ a_i, b_i ≤ n), denoting that a_i-th resident is acquaintances with b_i-th cat. It's guaranteed that each pair of some resident and some cat is listed at most once. It's guaranteed, that for every i there exists a pair between i-th resident and i-th cat. Different test cases are separated with an empty line. It's guaranteed, that the sum of n over all test cases is at most 10^6 and that the sum of m over all test cases is at most 10^6. Output For every test case print: * "No", if it's impossible to select the jury and contestants. * Otherwise print "Yes". In the second line print two integers j and p (1 ≤ j, 1 ≤ p, j + p = n) — the number of jury members and the number of contest participants. In the third line print j distinct integers from 1 to n, the indices of the residents forming a jury. In the fourth line print p distinct integers from 1 to n, the indices of the cats, which will participate in the contest. In case there are several correct answers, print any of them. Example Input 4 3 4 1 1 2 2 3 3 1 3 3 7 1 1 1 2 1 3 2 2 3 1 3 2 3 3 1 1 1 1 2 4 1 1 1 2 2 1 2 2 Output Yes 2 1 1 3 2 Yes 1 2 2 1 3 No No Note In the first test case, we can select the first and the third resident as a jury. Both of them are not acquaintances with a second cat, so we can select it as a contestant. In the second test case, we can select the second resident as a jury. He is not an acquaintances with a first and a third cat, so they can be selected as contestants. In the third test case, the only resident is acquaintances with the only cat, so they can't be in the contest together. So it's not possible to make a contest with at least one jury and at least one cat. In the fourth test case, each resident is acquaintances with every cat, so it's again not possible to make a contest with at least one jury and at least one cat. Submitted Solution: ``` import sys def dfs1(v): used[v] = True for u in graph[v]: if not used[u]: dfs1(u) order.append(v) def dfs2(v, c): comp[v] = c for u in transparent_graph[v]: if comp[u] is None: dfs2(u, c) """ fin = open("fin.txt", "r") fout = open("fout.txt", "w") """ fin = sys.stdin fout = sys.stdout t = int(fin.readline()) for test in range(t): n, m = map(int, fin.readline().split()) graph = [list() for i in range(n)] transparent_graph = [list() for i in range(n)] for i in range(m): w, c = map(int, fin.readline().split()) w -= 1 c -= 1 # !w or !c # it means that w => !c # or c => !w graph[w].append(c) transparent_graph[c].append(w) order = list() used = [False] * n for i in range(n): if not used[i]: dfs1(i) order.reverse() comp = [None] * n c = 1 for v in order: if comp[v] is None: dfs2(v, c) c += 1 if c == 1: print("No", file=fout) fin.readline() continue villagers = list() cats = list() for i in range(n): if comp[i] == 1: villagers.append(i + 1) else: cats.append(i + 1) if len(villagers) == 0 or len(cats) == 0: print("No", file=fout) fin.readline() continue print("Yes", file=fout) print(len(villagers), len(cats), file=fout) for i in villagers: print(i, end=" ", file=fout) print(file=fout) for i in cats: print(i, end=" ", file=fout) print(file=fout) fin.readline() ``` No
88,481
[ 0.302978515625, 0.314697265625, -0.11187744140625, 0.26318359375, -0.75634765625, -0.382080078125, -0.4130859375, 0.373779296875, 0.1739501953125, 0.86083984375, 0.60009765625, -0.15576171875, -0.2073974609375, -0.67041015625, -0.4423828125, -0.2152099609375, -0.60888671875, -0.709...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In the Catowice city next weekend the cat contest will be held. However, the jury members and the contestants haven't been selected yet. There are n residents and n cats in the Catowice, and each resident has exactly one cat living in his house. The residents and cats are numbered with integers from 1 to n, where the i-th cat is living in the house of i-th resident. Each Catowice resident is in friendship with several cats, including the one living in his house. In order to conduct a contest, at least one jury member is needed and at least one cat contestant is needed. Of course, every jury member should know none of the contestants. For the contest to be successful, it's also needed that the number of jury members plus the number of contestants is equal to n. Please help Catowice residents to select the jury and the contestants for the upcoming competition, or determine that it's impossible to do. Input The first line contains an integer t (1 ≤ t ≤ 100 000), the number of test cases. Then description of t test cases follow, where each description is as follows: The first line contains integers n and m (1 ≤ n ≤ m ≤ 10^6), the number of Catowice residents and the number of friendship pairs between residents and cats. Each of the next m lines contains integers a_i and b_i (1 ≤ a_i, b_i ≤ n), denoting that a_i-th resident is acquaintances with b_i-th cat. It's guaranteed that each pair of some resident and some cat is listed at most once. It's guaranteed, that for every i there exists a pair between i-th resident and i-th cat. Different test cases are separated with an empty line. It's guaranteed, that the sum of n over all test cases is at most 10^6 and that the sum of m over all test cases is at most 10^6. Output For every test case print: * "No", if it's impossible to select the jury and contestants. * Otherwise print "Yes". In the second line print two integers j and p (1 ≤ j, 1 ≤ p, j + p = n) — the number of jury members and the number of contest participants. In the third line print j distinct integers from 1 to n, the indices of the residents forming a jury. In the fourth line print p distinct integers from 1 to n, the indices of the cats, which will participate in the contest. In case there are several correct answers, print any of them. Example Input 4 3 4 1 1 2 2 3 3 1 3 3 7 1 1 1 2 1 3 2 2 3 1 3 2 3 3 1 1 1 1 2 4 1 1 1 2 2 1 2 2 Output Yes 2 1 1 3 2 Yes 1 2 2 1 3 No No Note In the first test case, we can select the first and the third resident as a jury. Both of them are not acquaintances with a second cat, so we can select it as a contestant. In the second test case, we can select the second resident as a jury. He is not an acquaintances with a first and a third cat, so they can be selected as contestants. In the third test case, the only resident is acquaintances with the only cat, so they can't be in the contest together. So it's not possible to make a contest with at least one jury and at least one cat. In the fourth test case, each resident is acquaintances with every cat, so it's again not possible to make a contest with at least one jury and at least one cat. Submitted Solution: ``` from collections import deque t=int(input()) def bfs(): global check,ans ans=0 d=deque() check=[0]*(n+1) d.append(1) while(len(d)>0): for i in range(len(v[d[0]])): if check[v[d[0]][i]]==0: check[v[d[0]][i]]=1 ans+=1 d.append(v[d[0]][i]) d.pop() def bfs2(): global check2, ans2 ans2= 0 d=deque() check2=[0]*(n+1) d.append(1) while (len(d) > 0): for i in range(len(v2[d[0]])): if check2[v2[d[0]][i]]==0: check2[v2[d[0]][i]]=1 ans2+= 1 d.append(v2[d[0]][i]) d.pop() for i2 in range(t): n,m=map(int,input().split()) v=[[]for i in range(n+1)] v2=[[]for i in range(n+1)] for i in range(m): a,b=map(int,input().split()) v[a].append(b) v2[b].append(a) bfs() bfs2() if i2<t-1: s=str(input()) if 0<ans<n: print("YES") print(ans,n-ans) for i in range(1,n+1): if check[i]==1: print(i,end=" ") print("") for i in range(1,n+1): if check[i]==0: print(i,end=" ") print("") elif 0<ans2<n: print("YES") print(n-ans2,ans2) for i in range(1, n + 1): if check2[i] == 0: print(i, end=" ") print("") for i in range(1, n + 1): if check2[i] == 1: print(i, end=" ") print("") else: print("NO") ``` No
88,482
[ 0.302978515625, 0.314697265625, -0.11187744140625, 0.26318359375, -0.75634765625, -0.382080078125, -0.4130859375, 0.373779296875, 0.1739501953125, 0.86083984375, 0.60009765625, -0.15576171875, -0.2073974609375, -0.67041015625, -0.4423828125, -0.2152099609375, -0.60888671875, -0.709...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It was the third month of remote learning, Nastya got sick of staying at dormitory, so she decided to return to her hometown. In order to make her trip more entertaining, one of Nastya's friend presented her an integer array a. Several hours after starting her journey home Nastya remembered about the present. To entertain herself she decided to check, are there four different indices x, y, z, w such that a_x + a_y = a_z + a_w. Her train has already arrived the destination, but she still hasn't found the answer. Can you help her unravel the mystery? Input The first line contains the single integer n (4 ≤ n ≤ 200 000) — the size of the array. The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 2.5 ⋅ 10^6). Output Print "YES" if there are such four indices, and "NO" otherwise. If such indices exist, print these indices x, y, z and w (1 ≤ x, y, z, w ≤ n). If there are multiple answers, print any of them. Examples Input 6 2 1 5 2 7 4 Output YES 2 3 1 6 Input 5 1 3 1 9 20 Output NO Note In the first example a_2 + a_3 = 1 + 5 = 2 + 4 = a_1 + a_6. Note that there are other answer, for example, 2 3 4 6. In the second example, we can't choose four indices. The answer 1 2 2 3 is wrong, because indices should be different, despite that a_1 + a_2 = 1 + 3 = 3 + 1 = a_2 + a_3 Submitted Solution: ``` from sys import stdin input=stdin.readline def A707(): from collections import defaultdict CAP = 2500001 n=int(input()) a=list(map(int,input().split())) d=[0]*(CAP*2) i=n-2 j=n-1 found=False while i >= 0: j = i + 1 while j < n: if d[a[i]+a[j]] != 0: ID = i*n + j for k in d[a[i]+a[j]]: if not (k % n == i or k % n == j or k//n == i or k//n == j): print('YES') print(i+1,j+1,k%n+1,k//n+1) found=True break d[a[i]+a[j]].append(ID) else: d[a[i]+a[j]] = [i*n+j] j += 1 if found: break i -= 1 if found: break if not found: print('NO') A707() ``` Yes
88,647
[ 0.295654296875, 0.0106048583984375, -0.242919921875, 0.056884765625, -0.787109375, -0.346435546875, -0.20751953125, 0.1258544921875, -0.07110595703125, 1.1572265625, 0.67431640625, -0.281494140625, 0.2841796875, -1.0048828125, -0.46044921875, -0.090087890625, -0.69970703125, -0.689...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It was the third month of remote learning, Nastya got sick of staying at dormitory, so she decided to return to her hometown. In order to make her trip more entertaining, one of Nastya's friend presented her an integer array a. Several hours after starting her journey home Nastya remembered about the present. To entertain herself she decided to check, are there four different indices x, y, z, w such that a_x + a_y = a_z + a_w. Her train has already arrived the destination, but she still hasn't found the answer. Can you help her unravel the mystery? Input The first line contains the single integer n (4 ≤ n ≤ 200 000) — the size of the array. The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 2.5 ⋅ 10^6). Output Print "YES" if there are such four indices, and "NO" otherwise. If such indices exist, print these indices x, y, z and w (1 ≤ x, y, z, w ≤ n). If there are multiple answers, print any of them. Examples Input 6 2 1 5 2 7 4 Output YES 2 3 1 6 Input 5 1 3 1 9 20 Output NO Note In the first example a_2 + a_3 = 1 + 5 = 2 + 4 = a_1 + a_6. Note that there are other answer, for example, 2 3 4 6. In the second example, we can't choose four indices. The answer 1 2 2 3 is wrong, because indices should be different, despite that a_1 + a_2 = 1 + 3 = 3 + 1 = a_2 + a_3 Submitted Solution: ``` n = int(input()) arr = list(map(int, input().split())) d = {} flag = True for i1 in range(n): for j1 in range(i1): if arr[i1]+arr[j1] in d: i2, j2 = d[arr[i1]+arr[j1]] if len(set([i1, i2, j1, j2]))==4: print("YES") print(j2+1, i2+1, j1+1, i1+1) flag = False break else: d[arr[i1]+arr[j1]] = (i1, j1) if flag==False: break if flag: print("NO") ``` Yes
88,648
[ 0.37890625, -0.013916015625, -0.2666015625, 0.06842041015625, -0.73779296875, -0.40673828125, -0.1405029296875, 0.201416015625, -0.03167724609375, 1.1484375, 0.75830078125, -0.2161865234375, 0.27978515625, -1.0341796875, -0.513671875, -0.0833740234375, -0.69775390625, -0.6313476562...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It was the third month of remote learning, Nastya got sick of staying at dormitory, so she decided to return to her hometown. In order to make her trip more entertaining, one of Nastya's friend presented her an integer array a. Several hours after starting her journey home Nastya remembered about the present. To entertain herself she decided to check, are there four different indices x, y, z, w such that a_x + a_y = a_z + a_w. Her train has already arrived the destination, but she still hasn't found the answer. Can you help her unravel the mystery? Input The first line contains the single integer n (4 ≤ n ≤ 200 000) — the size of the array. The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 2.5 ⋅ 10^6). Output Print "YES" if there are such four indices, and "NO" otherwise. If such indices exist, print these indices x, y, z and w (1 ≤ x, y, z, w ≤ n). If there are multiple answers, print any of them. Examples Input 6 2 1 5 2 7 4 Output YES 2 3 1 6 Input 5 1 3 1 9 20 Output NO Note In the first example a_2 + a_3 = 1 + 5 = 2 + 4 = a_1 + a_6. Note that there are other answer, for example, 2 3 4 6. In the second example, we can't choose four indices. The answer 1 2 2 3 is wrong, because indices should be different, despite that a_1 + a_2 = 1 + 3 = 3 + 1 = a_2 + a_3 Submitted Solution: ``` from collections import Counter n=int(input()) m=[int(j) for j in input().split()] m=m new={} res=[] for i in range(len(m)): for j in range(i+1, len(m)): if m[i]+m[j] in new: if i not in new[m[i]+m[j]] and j not in new[m[i]+m[j]]: z=new[m[i]+m[j]][0] x=new[m[i]+m[j]][1] res.extend([i, j, z, x]) break else: continue else: new[m[i]+m[j]]=[i, j] else: continue break if res: print("YES") print(" ".join([str(e+1) for e in res])) else: print("NO") ``` Yes
88,650
[ 0.34765625, -0.012115478515625, -0.294677734375, 0.040069580078125, -0.763671875, -0.391845703125, -0.11090087890625, 0.1881103515625, 0.007305145263671875, 1.12890625, 0.62744140625, -0.238525390625, 0.2464599609375, -1.0302734375, -0.53759765625, -0.06732177734375, -0.7314453125, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It was the third month of remote learning, Nastya got sick of staying at dormitory, so she decided to return to her hometown. In order to make her trip more entertaining, one of Nastya's friend presented her an integer array a. Several hours after starting her journey home Nastya remembered about the present. To entertain herself she decided to check, are there four different indices x, y, z, w such that a_x + a_y = a_z + a_w. Her train has already arrived the destination, but she still hasn't found the answer. Can you help her unravel the mystery? Input The first line contains the single integer n (4 ≤ n ≤ 200 000) — the size of the array. The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 2.5 ⋅ 10^6). Output Print "YES" if there are such four indices, and "NO" otherwise. If such indices exist, print these indices x, y, z and w (1 ≤ x, y, z, w ≤ n). If there are multiple answers, print any of them. Examples Input 6 2 1 5 2 7 4 Output YES 2 3 1 6 Input 5 1 3 1 9 20 Output NO Note In the first example a_2 + a_3 = 1 + 5 = 2 + 4 = a_1 + a_6. Note that there are other answer, for example, 2 3 4 6. In the second example, we can't choose four indices. The answer 1 2 2 3 is wrong, because indices should be different, despite that a_1 + a_2 = 1 + 3 = 3 + 1 = a_2 + a_3 Submitted Solution: ``` import sys input = sys.stdin.readline ############ ---- Input Functions ---- ############ def inp(): return(int(input())) def inlt(): return(list(map(int,input().split()))) def insr(): s = input() return(list(s[:len(s) - 1])) def invr(): return(map(int,input().split())) n = inp() a = inlt() sums = dict() # With 8 numbers we must have a pair. Try all 8^4 combinations. def find_ans(p): n = len(p) for i in range(n): for j in range(i+1,n): for k in range(j+1,n): for l in range(k+1,n): if a[i]+a[j] == a[k] + a[l]: print(f"{i+1} {j+1} {k+1} {l+1}") exit() for i in range(n): for j in range(i+1,n): s = a[i]+a[j] if s in sums: pairs = sums[s] for k in range(len(pairs) // 2): pair = (pairs[2*k], pairs[2*k+1]) if i not in pair and j not in pair: print("YES") print(f"{i+1} {j+1} {pair[0]+1} {pair[1]+1}") exit() sums[s] = sums[s] + (i,j) if len(sums[s]) >= 8: find_ans(sums[s]) else: sums[s] = (i,j) print("NO") ``` No
88,651
[ 0.361083984375, 0.023223876953125, -0.290283203125, 0.0576171875, -0.86572265625, -0.337646484375, -0.259521484375, 0.238037109375, -0.0838623046875, 1.1357421875, 0.67919921875, -0.15576171875, 0.247314453125, -0.98193359375, -0.50146484375, -0.0711669921875, -0.70947265625, -0.72...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It was the third month of remote learning, Nastya got sick of staying at dormitory, so she decided to return to her hometown. In order to make her trip more entertaining, one of Nastya's friend presented her an integer array a. Several hours after starting her journey home Nastya remembered about the present. To entertain herself she decided to check, are there four different indices x, y, z, w such that a_x + a_y = a_z + a_w. Her train has already arrived the destination, but she still hasn't found the answer. Can you help her unravel the mystery? Input The first line contains the single integer n (4 ≤ n ≤ 200 000) — the size of the array. The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 2.5 ⋅ 10^6). Output Print "YES" if there are such four indices, and "NO" otherwise. If such indices exist, print these indices x, y, z and w (1 ≤ x, y, z, w ≤ n). If there are multiple answers, print any of them. Examples Input 6 2 1 5 2 7 4 Output YES 2 3 1 6 Input 5 1 3 1 9 20 Output NO Note In the first example a_2 + a_3 = 1 + 5 = 2 + 4 = a_1 + a_6. Note that there are other answer, for example, 2 3 4 6. In the second example, we can't choose four indices. The answer 1 2 2 3 is wrong, because indices should be different, despite that a_1 + a_2 = 1 + 3 = 3 + 1 = a_2 + a_3 Submitted Solution: ``` n = int(input()) l = [int(i) for i in input().split(' ')] m = {} for i in range(0,n-1): for j in range(i+1, n): sm = l[i]+l[j] if sm in m: k,l = m[sm] print(k,l) if (k != i and k != j) and (l != i and l != j): print("YES") print(i+1,j+1,k+1,l+1) quit() else: m[sm] = [i,j] print("NO") ``` No
88,653
[ 0.3837890625, -0.01190185546875, -0.2305908203125, 0.054229736328125, -0.73974609375, -0.38330078125, -0.1312255859375, 0.1685791015625, -0.0753173828125, 1.1025390625, 0.67236328125, -0.1524658203125, 0.2349853515625, -1.0341796875, -0.51611328125, -0.0244293212890625, -0.7275390625...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It was the third month of remote learning, Nastya got sick of staying at dormitory, so she decided to return to her hometown. In order to make her trip more entertaining, one of Nastya's friend presented her an integer array a. Several hours after starting her journey home Nastya remembered about the present. To entertain herself she decided to check, are there four different indices x, y, z, w such that a_x + a_y = a_z + a_w. Her train has already arrived the destination, but she still hasn't found the answer. Can you help her unravel the mystery? Input The first line contains the single integer n (4 ≤ n ≤ 200 000) — the size of the array. The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 2.5 ⋅ 10^6). Output Print "YES" if there are such four indices, and "NO" otherwise. If such indices exist, print these indices x, y, z and w (1 ≤ x, y, z, w ≤ n). If there are multiple answers, print any of them. Examples Input 6 2 1 5 2 7 4 Output YES 2 3 1 6 Input 5 1 3 1 9 20 Output NO Note In the first example a_2 + a_3 = 1 + 5 = 2 + 4 = a_1 + a_6. Note that there are other answer, for example, 2 3 4 6. In the second example, we can't choose four indices. The answer 1 2 2 3 is wrong, because indices should be different, despite that a_1 + a_2 = 1 + 3 = 3 + 1 = a_2 + a_3 Submitted Solution: ``` n = int(input()) n_array = list(map(int, input().split())) for x_index in range(n-3): for y_index in range(x_index+1, n-2): for z_index in range(y_index+1, n-1): for w_index in range(z_index+1, n): if (n_array[x_index] + n_array[y_index] == n_array[z_index] + n_array[w_index]): print(x_index+1, y_index+1, z_index+1, w_index+1, sep = " ") exit() elif (n_array[x_index] + n_array[z_index] == n_array[y_index] + n_array[w_index]): print(x_index+1, z_index+1, y_index+1, w_index+1, sep = " ") exit() elif (n_array[x_index] + n_array[w_index] == n_array[z_index] + n_array[y_index]): print(x_index+1, w_index+1, z_index+1, y_index+1, sep = " ") exit() print("NO") ``` No
88,654
[ 0.3681640625, -0.00800323486328125, -0.197509765625, 0.042755126953125, -0.7841796875, -0.397705078125, -0.1702880859375, 0.2376708984375, -0.0274810791015625, 1.1923828125, 0.6982421875, -0.21533203125, 0.2841796875, -1.001953125, -0.490478515625, -0.0560302734375, -0.69970703125, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Amr is a young coder who likes music a lot. He always wanted to learn how to play music but he was busy coding so he got an idea. Amr has n instruments, it takes ai days to learn i-th instrument. Being busy, Amr dedicated k days to learn how to play the maximum possible number of instruments. Amr asked for your help to distribute his free days between instruments so that he can achieve his goal. Input The first line contains two numbers n, k (1 ≤ n ≤ 100, 0 ≤ k ≤ 10 000), the number of instruments and number of days respectively. The second line contains n integers ai (1 ≤ ai ≤ 100), representing number of days required to learn the i-th instrument. Output In the first line output one integer m representing the maximum number of instruments Amr can learn. In the second line output m space-separated integers: the indices of instruments to be learnt. You may output indices in any order. if there are multiple optimal solutions output any. It is not necessary to use all days for studying. Examples Input 4 10 4 3 1 2 Output 4 1 2 3 4 Input 5 6 4 3 1 1 2 Output 3 1 3 4 Input 1 3 4 Output 0 Note In the first test Amr can learn all 4 instruments. In the second test other possible solutions are: {2, 3, 5} or {3, 4, 5}. In the third test Amr doesn't have enough time to learn the only presented instrument. Submitted Solution: ``` n,k=map(int,input().split()) l=list(map(int,input().split())) new=[] ans=[] s=0 for i in range(n): new.append([l[i],i+1]) new.sort() for i in range(n): s+=new[i][0] if(s<=k): ans.append(new[i][1]) else: break if(len(ans)==0): print(0) else: print(len(ans)) print(*ans) ``` Yes
88,825
[ 0.384765625, 0.407958984375, -0.426025390625, 0.10357666015625, -0.64990234375, -0.41845703125, -0.1829833984375, 0.087890625, 0.2357177734375, 1.0341796875, 0.85791015625, -0.29345703125, 0.1153564453125, -0.7470703125, -0.254150390625, 0.25048828125, -0.82421875, -1.0087890625, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Amr is a young coder who likes music a lot. He always wanted to learn how to play music but he was busy coding so he got an idea. Amr has n instruments, it takes ai days to learn i-th instrument. Being busy, Amr dedicated k days to learn how to play the maximum possible number of instruments. Amr asked for your help to distribute his free days between instruments so that he can achieve his goal. Input The first line contains two numbers n, k (1 ≤ n ≤ 100, 0 ≤ k ≤ 10 000), the number of instruments and number of days respectively. The second line contains n integers ai (1 ≤ ai ≤ 100), representing number of days required to learn the i-th instrument. Output In the first line output one integer m representing the maximum number of instruments Amr can learn. In the second line output m space-separated integers: the indices of instruments to be learnt. You may output indices in any order. if there are multiple optimal solutions output any. It is not necessary to use all days for studying. Examples Input 4 10 4 3 1 2 Output 4 1 2 3 4 Input 5 6 4 3 1 1 2 Output 3 1 3 4 Input 1 3 4 Output 0 Note In the first test Amr can learn all 4 instruments. In the second test other possible solutions are: {2, 3, 5} or {3, 4, 5}. In the third test Amr doesn't have enough time to learn the only presented instrument. Submitted Solution: ``` s=list(map(int,input().split())) l=list(map(int,input().split())) s1=sorted(l) su=0 idx={} for i in range(len(l)): try: idx[l[i]].append(i) except: idx[l[i]]=[i] x=[] for i in s1: su+=i if(su<=s[1]): x.append(idx[i][0]+1) idx[i].pop(0) print(len(x)) if(len(x)!=0): print(*x,sep=" ") ``` Yes
88,826
[ 0.383544921875, 0.390625, -0.390869140625, 0.1085205078125, -0.626953125, -0.427490234375, -0.220947265625, 0.061370849609375, 0.244384765625, 1.0458984375, 0.87646484375, -0.271484375, 0.1121826171875, -0.73828125, -0.25927734375, 0.284423828125, -0.822265625, -1, -0.53564453125...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Amr is a young coder who likes music a lot. He always wanted to learn how to play music but he was busy coding so he got an idea. Amr has n instruments, it takes ai days to learn i-th instrument. Being busy, Amr dedicated k days to learn how to play the maximum possible number of instruments. Amr asked for your help to distribute his free days between instruments so that he can achieve his goal. Input The first line contains two numbers n, k (1 ≤ n ≤ 100, 0 ≤ k ≤ 10 000), the number of instruments and number of days respectively. The second line contains n integers ai (1 ≤ ai ≤ 100), representing number of days required to learn the i-th instrument. Output In the first line output one integer m representing the maximum number of instruments Amr can learn. In the second line output m space-separated integers: the indices of instruments to be learnt. You may output indices in any order. if there are multiple optimal solutions output any. It is not necessary to use all days for studying. Examples Input 4 10 4 3 1 2 Output 4 1 2 3 4 Input 5 6 4 3 1 1 2 Output 3 1 3 4 Input 1 3 4 Output 0 Note In the first test Amr can learn all 4 instruments. In the second test other possible solutions are: {2, 3, 5} or {3, 4, 5}. In the third test Amr doesn't have enough time to learn the only presented instrument. Submitted Solution: ``` x,y = list(map(int,input().split())) arr = list(map(int,input().split())) copy = list(arr) arr = sorted(arr) count, i = 0,0 res = [] while ((count<=y) & (i<x)): if (count + arr[i] <=y): res.append(copy.index(arr[i])+1) copy[copy.index(arr[i])] = -1 count += arr[i] i+=1 else: break print (i) if (i!=0): res = map(str,res) print (" ".join(res)) ``` Yes
88,827
[ 0.403076171875, 0.432373046875, -0.40283203125, 0.08245849609375, -0.630859375, -0.42529296875, -0.216796875, 0.07952880859375, 0.29345703125, 1.0185546875, 0.89208984375, -0.294921875, 0.140869140625, -0.75830078125, -0.286865234375, 0.291015625, -0.7802734375, -0.95703125, -0.5...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Amr is a young coder who likes music a lot. He always wanted to learn how to play music but he was busy coding so he got an idea. Amr has n instruments, it takes ai days to learn i-th instrument. Being busy, Amr dedicated k days to learn how to play the maximum possible number of instruments. Amr asked for your help to distribute his free days between instruments so that he can achieve his goal. Input The first line contains two numbers n, k (1 ≤ n ≤ 100, 0 ≤ k ≤ 10 000), the number of instruments and number of days respectively. The second line contains n integers ai (1 ≤ ai ≤ 100), representing number of days required to learn the i-th instrument. Output In the first line output one integer m representing the maximum number of instruments Amr can learn. In the second line output m space-separated integers: the indices of instruments to be learnt. You may output indices in any order. if there are multiple optimal solutions output any. It is not necessary to use all days for studying. Examples Input 4 10 4 3 1 2 Output 4 1 2 3 4 Input 5 6 4 3 1 1 2 Output 3 1 3 4 Input 1 3 4 Output 0 Note In the first test Amr can learn all 4 instruments. In the second test other possible solutions are: {2, 3, 5} or {3, 4, 5}. In the third test Amr doesn't have enough time to learn the only presented instrument. Submitted Solution: ``` n,k = map(int,input().split()) a = list(map(int,input().split())) b = a.copy();d=1 l=list([0]);vis=[0]*n sumo,cnt,j=0,0,0 a.sort() for i in range(n): if sumo+a[i]<=k: sumo+=a[i]; for j in range(n): if a[i]==b[j] and vis[j]==0: vis[j]=1;l.append(j+1);break print(len(l)-1) for i in l[1:]: print(i,end=" ") ``` Yes
88,828
[ 0.382080078125, 0.427734375, -0.398193359375, 0.1209716796875, -0.56884765625, -0.387451171875, -0.205322265625, 0.04150390625, 0.30126953125, 1.029296875, 0.8935546875, -0.25244140625, 0.1065673828125, -0.7802734375, -0.240966796875, 0.251708984375, -0.76953125, -0.994140625, -0...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Amr is a young coder who likes music a lot. He always wanted to learn how to play music but he was busy coding so he got an idea. Amr has n instruments, it takes ai days to learn i-th instrument. Being busy, Amr dedicated k days to learn how to play the maximum possible number of instruments. Amr asked for your help to distribute his free days between instruments so that he can achieve his goal. Input The first line contains two numbers n, k (1 ≤ n ≤ 100, 0 ≤ k ≤ 10 000), the number of instruments and number of days respectively. The second line contains n integers ai (1 ≤ ai ≤ 100), representing number of days required to learn the i-th instrument. Output In the first line output one integer m representing the maximum number of instruments Amr can learn. In the second line output m space-separated integers: the indices of instruments to be learnt. You may output indices in any order. if there are multiple optimal solutions output any. It is not necessary to use all days for studying. Examples Input 4 10 4 3 1 2 Output 4 1 2 3 4 Input 5 6 4 3 1 1 2 Output 3 1 3 4 Input 1 3 4 Output 0 Note In the first test Amr can learn all 4 instruments. In the second test other possible solutions are: {2, 3, 5} or {3, 4, 5}. In the third test Amr doesn't have enough time to learn the only presented instrument. Submitted Solution: ``` n, k = map(int, input().split()) k_1 = list(map(int, input().split())) summ = 0 index = [] for i in range(len(k_1)): if (summ + k_1[i]) <= k: summ += k_1[i] index.append(i+1) if len(index) == 0: print(0) else: print(len(index)) for i in index: print(i, end=" ") ``` No
88,829
[ 0.3603515625, 0.411865234375, -0.393310546875, 0.1075439453125, -0.64794921875, -0.413330078125, -0.1766357421875, 0.08123779296875, 0.25341796875, 1.0283203125, 0.86572265625, -0.279541015625, 0.1063232421875, -0.75830078125, -0.279541015625, 0.30078125, -0.8291015625, -1.01953125...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Amr is a young coder who likes music a lot. He always wanted to learn how to play music but he was busy coding so he got an idea. Amr has n instruments, it takes ai days to learn i-th instrument. Being busy, Amr dedicated k days to learn how to play the maximum possible number of instruments. Amr asked for your help to distribute his free days between instruments so that he can achieve his goal. Input The first line contains two numbers n, k (1 ≤ n ≤ 100, 0 ≤ k ≤ 10 000), the number of instruments and number of days respectively. The second line contains n integers ai (1 ≤ ai ≤ 100), representing number of days required to learn the i-th instrument. Output In the first line output one integer m representing the maximum number of instruments Amr can learn. In the second line output m space-separated integers: the indices of instruments to be learnt. You may output indices in any order. if there are multiple optimal solutions output any. It is not necessary to use all days for studying. Examples Input 4 10 4 3 1 2 Output 4 1 2 3 4 Input 5 6 4 3 1 1 2 Output 3 1 3 4 Input 1 3 4 Output 0 Note In the first test Amr can learn all 4 instruments. In the second test other possible solutions are: {2, 3, 5} or {3, 4, 5}. In the third test Amr doesn't have enough time to learn the only presented instrument. Submitted Solution: ``` n,k=map(int,input().split(" ")) a=[int(i) for i in input().split(" ")] a=list(set(a)) z=sorted(a) i=0 while(k!=0) and i<n: if z[i]>k: print(0) break else: k=k-z[i] print(z[i],end=" ") i=i+1 ``` No
88,830
[ 0.380126953125, 0.38671875, -0.43310546875, 0.09893798828125, -0.66650390625, -0.4169921875, -0.215576171875, 0.099609375, 0.2415771484375, 1.0107421875, 0.849609375, -0.2685546875, 0.11383056640625, -0.77587890625, -0.277587890625, 0.295166015625, -0.8232421875, -1.0205078125, -...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Amr is a young coder who likes music a lot. He always wanted to learn how to play music but he was busy coding so he got an idea. Amr has n instruments, it takes ai days to learn i-th instrument. Being busy, Amr dedicated k days to learn how to play the maximum possible number of instruments. Amr asked for your help to distribute his free days between instruments so that he can achieve his goal. Input The first line contains two numbers n, k (1 ≤ n ≤ 100, 0 ≤ k ≤ 10 000), the number of instruments and number of days respectively. The second line contains n integers ai (1 ≤ ai ≤ 100), representing number of days required to learn the i-th instrument. Output In the first line output one integer m representing the maximum number of instruments Amr can learn. In the second line output m space-separated integers: the indices of instruments to be learnt. You may output indices in any order. if there are multiple optimal solutions output any. It is not necessary to use all days for studying. Examples Input 4 10 4 3 1 2 Output 4 1 2 3 4 Input 5 6 4 3 1 1 2 Output 3 1 3 4 Input 1 3 4 Output 0 Note In the first test Amr can learn all 4 instruments. In the second test other possible solutions are: {2, 3, 5} or {3, 4, 5}. In the third test Amr doesn't have enough time to learn the only presented instrument. Submitted Solution: ``` instr, days = (int(x) for x in input().split()) # print (instr, days) arr = [(int(y), x + 1) for x, y in enumerate(input().split())] arr.sort() if arr[0][0] > days: print(0) else: result = [] for hard in arr: days -= hard[0] if days >= 0: result.append(str(hard[1])) else: break print (" ".join(result)) ``` No
88,831
[ 0.391357421875, 0.44580078125, -0.452392578125, 0.08782958984375, -0.62451171875, -0.3564453125, -0.220458984375, 0.08294677734375, 0.2861328125, 1.03515625, 0.92041015625, -0.294189453125, 0.103759765625, -0.85791015625, -0.33056640625, 0.2373046875, -0.80322265625, -0.97607421875...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score is reset and a new set begins. Across all the sets Misha scored a points in total, and Vanya scored b points. Given this information, determine the maximum number of sets they could have played, or that the situation is impossible. Note that the game consisted of several complete sets. Input The first line contains three space-separated integers k, a and b (1 ≤ k ≤ 109, 0 ≤ a, b ≤ 109, a + b > 0). Output If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets. Examples Input 11 11 5 Output 1 Input 11 2 3 Output -1 Note Note that the rules of the game in this problem differ from the real table tennis game, for example, the rule of "balance" (the winning player has to be at least two points ahead to win a set) has no power within the present problem. Submitted Solution: ``` # http://codeforces.com/contest/765/problem/A # http://codeforces.com/contest/765/problem/B # http://codeforces.com/contest/765/problem/C def Neverending_competitions(): n = int(input()) home = input() for i in range(n): new = input() if n % 2 == 0: return "home" else: return "contest" #print(Neverending_competitions()) def Code_obfuscation(): s = input() a = [0] * 26 okay = True for i in s: for j in range(ord(i)-97): if not a[j]: okay = False break if okay: a[ord(i) - 97] = 1 else: break if okay: print("YES") else: print("NO") #Code_obfuscation() def Table_Tennis_Game_2(): n = input().split() k = int(n[0]) a = int(n[1]) b = int(n[2]) if a >= k and b>=k: return int(a/k) + int(b/k) elif a % k == 0: return int(a/k) elif b % k == 0: return int(b/k) else: return -1 print(Table_Tennis_Game_2()) ``` No
88,904
[ 0.157470703125, 0.06195068359375, -0.039581298828125, 0.49658203125, -0.51953125, -0.72900390625, -0.41064453125, 0.283935546875, -0.2454833984375, 0.5517578125, 0.36572265625, 0.0168914794921875, 0.08880615234375, -0.78369140625, -0.3662109375, 0.1435546875, -0.83056640625, -0.779...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0. Constraints * 1≦N≦10^5 * 0≦A_i≦N-1 Input The input is given from Standard Input in the following format: N A_1 A_2 ... A_N Output Print the number of the possible orders in which they were standing, modulo 10^9+7. Examples Input 5 2 4 4 0 2 Output 4 Input 7 6 4 0 2 4 0 2 Output 0 Input 8 7 5 1 1 7 3 5 3 Output 16 Submitted Solution: ``` n = int(input()) A = list(map(int, input().split())) mod = 10 ** 9 + 7 flag = True if n%2 == 0: if 0 in A or len(set(A))!=n//2: flag = False else: if A.count(0)!=1 or len(set(A))!=n//2+1: flag = False if flag: print(2**(n//2) % mod) else: print(0) ``` Yes
89,118
[ 0.448974609375, -0.1578369140625, -0.4228515625, 0.257080078125, -0.4072265625, -0.52392578125, 0.11590576171875, 0.129638671875, 0.3662109375, 1.01953125, 0.45703125, -0.151123046875, 0.136474609375, -0.6318359375, -0.5166015625, -0.20556640625, -0.59521484375, -0.56787109375, -...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0. Constraints * 1≦N≦10^5 * 0≦A_i≦N-1 Input The input is given from Standard Input in the following format: N A_1 A_2 ... A_N Output Print the number of the possible orders in which they were standing, modulo 10^9+7. Examples Input 5 2 4 4 0 2 Output 4 Input 7 6 4 0 2 4 0 2 Output 0 Input 8 7 5 1 1 7 3 5 3 Output 16 Submitted Solution: ``` n=int(input()) A=sorted((map(int,input().split()))) G=sorted([2*(i+1) for i in range(n//2)]*2+[0]) K=sorted([(2*i+1) for i in range(n//2)]*2) if n%2: if A!=G: print(0) exit() else: if A!=K: print(0) exit() print(2**(n//2)%(10**9+7)) ``` Yes
89,119
[ 0.474853515625, -0.06951904296875, -0.441162109375, 0.262939453125, -0.40673828125, -0.454345703125, 0.07379150390625, 0.1959228515625, 0.3505859375, 0.96240234375, 0.46240234375, -0.2154541015625, 0.05615234375, -0.70361328125, -0.5908203125, -0.2060546875, -0.59033203125, -0.5859...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0. Constraints * 1≦N≦10^5 * 0≦A_i≦N-1 Input The input is given from Standard Input in the following format: N A_1 A_2 ... A_N Output Print the number of the possible orders in which they were standing, modulo 10^9+7. Examples Input 5 2 4 4 0 2 Output 4 Input 7 6 4 0 2 4 0 2 Output 0 Input 8 7 5 1 1 7 3 5 3 Output 16 Submitted Solution: ``` N = int(input()) A = [int(x) for x in input().split()] from collections import Counter def f(): cnt = Counter(A) m = N - 1 for k, v in cnt.items(): if k == 0 and v == 1: continue if v != 2 or k > m: return 0 return pow(2, N//2, 10**9 + 7) print(f()) ``` Yes
89,120
[ 0.449951171875, -0.0172271728515625, -0.465087890625, 0.29150390625, -0.432373046875, -0.363525390625, 0.046356201171875, 0.1173095703125, 0.396240234375, 0.935546875, 0.4765625, -0.17236328125, 0.0221710205078125, -0.603515625, -0.6123046875, -0.1788330078125, -0.638671875, -0.621...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0. Constraints * 1≦N≦10^5 * 0≦A_i≦N-1 Input The input is given from Standard Input in the following format: N A_1 A_2 ... A_N Output Print the number of the possible orders in which they were standing, modulo 10^9+7. Examples Input 5 2 4 4 0 2 Output 4 Input 7 6 4 0 2 4 0 2 Output 0 Input 8 7 5 1 1 7 3 5 3 Output 16 Submitted Solution: ``` from collections import Counter N, *A = map(int, open(0).read().split()) l = [v for _, v in sorted(Counter(A).items())] if all(v == 2 for v in l[N % 2:]) and (N % 2 == 0 or l[0] == 1): print(2 ** (N // 2) % (10 ** 9 + 7)) else: print(0) ``` Yes
89,121
[ 0.4375, -0.01168060302734375, -0.469970703125, 0.265380859375, -0.3740234375, -0.4375, 0.0921630859375, 0.1251220703125, 0.379150390625, 1.0029296875, 0.406005859375, -0.1942138671875, 0.10906982421875, -0.59228515625, -0.63671875, -0.25244140625, -0.61572265625, -0.57275390625, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0. Constraints * 1≦N≦10^5 * 0≦A_i≦N-1 Input The input is given from Standard Input in the following format: N A_1 A_2 ... A_N Output Print the number of the possible orders in which they were standing, modulo 10^9+7. Examples Input 5 2 4 4 0 2 Output 4 Input 7 6 4 0 2 4 0 2 Output 0 Input 8 7 5 1 1 7 3 5 3 Output 16 Submitted Solution: ``` n=int(input()) a=list(map(int, input().split())) from collections import Counter c=Counter(a) cnt_lst=[0]*n for key in c: cnt_lst[key]+=c[key] flag=True if n%2==1: if cnt_lst[0]==1: cnt_lst.pop(0) for i in range(n-1): if (i%2==1 and cnt_lst[i]!=2) or (i%2==0 and cnt_lst[i]!=0): flag=False else: for i in range(n): if (i%2==1 and cnt_lst[i]!=2) or (i%2==0 and cnt_lst[i]!=0): flag=False print(2**(n//2) if flag else 0) ``` No
89,123
[ 0.394775390625, -0.11639404296875, -0.31884765625, 0.256103515625, -0.333740234375, -0.44873046875, 0.08135986328125, 0.08270263671875, 0.363037109375, 1.0751953125, 0.406982421875, -0.1939697265625, 0.052520751953125, -0.662109375, -0.6005859375, -0.258056640625, -0.68798828125, -...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0. Constraints * 1≦N≦10^5 * 0≦A_i≦N-1 Input The input is given from Standard Input in the following format: N A_1 A_2 ... A_N Output Print the number of the possible orders in which they were standing, modulo 10^9+7. Examples Input 5 2 4 4 0 2 Output 4 Input 7 6 4 0 2 4 0 2 Output 0 Input 8 7 5 1 1 7 3 5 3 Output 16 Submitted Solution: ``` t = int(input()) m = list(map(int,input().split())) q={} z=False cnt0=0 for i in range(t): d=m[i] a=(t-1-d)//2 if d==0: cnt0+=1 if (a,a+d) not in q: q[(a,a+d)]=0 q[(a,a+d)]+=1 if q[(a,a+d)]>2: z=True break if z or cnt0>1: print(0) elif cnt0==1 and t%2==0: print(0) else: res=1 for i in q: if i[0]==i[1]: res=res*1 else: res=res*2 print(res) ``` No
89,124
[ 0.3818359375, -0.03900146484375, -0.354248046875, 0.287109375, -0.409423828125, -0.483642578125, 0.06494140625, 0.116943359375, 0.322021484375, 1.0712890625, 0.396240234375, -0.0970458984375, 0.050811767578125, -0.56689453125, -0.62451171875, -0.2401123046875, -0.642578125, -0.4831...
11