message stringlengths 2 44.5k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 42 109k | cluster float64 5 5 | __index_level_0__ int64 84 217k |
|---|---|---|---|---|---|
Provide a correct Python 3 solution for this coding contest problem.
There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.
You can perform the following operation on this integer sequence any number of times:
Operation: Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.
Let B_1, B_2, ..., B_N be the integer sequence after your operations.
Find the maximum possible value of B_1 + B_2 + ... + B_N.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* -10^9 \leq A_i \leq 10^9
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
Output
Print the maximum possible value of B_1 + B_2 + ... + B_N.
Examples
Input
3
-10 5 -4
Output
19
Input
5
10 -4 -8 -11 3
Output
30
Input
11
-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000
Output
10000000000 | instruction | 0 | 75,693 | 5 | 151,386 |
"Correct Solution:
```
N,*A=map(int,open(0).read().split())
x,y=0,-1e10
for a in A:x,y=max(x+a,y-a),max(x-a,y+a)
print(x)
``` | output | 1 | 75,693 | 5 | 151,387 |
Provide a correct Python 3 solution for this coding contest problem.
There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.
You can perform the following operation on this integer sequence any number of times:
Operation: Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.
Let B_1, B_2, ..., B_N be the integer sequence after your operations.
Find the maximum possible value of B_1 + B_2 + ... + B_N.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* -10^9 \leq A_i \leq 10^9
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
Output
Print the maximum possible value of B_1 + B_2 + ... + B_N.
Examples
Input
3
-10 5 -4
Output
19
Input
5
10 -4 -8 -11 3
Output
30
Input
11
-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000
Output
10000000000 | instruction | 0 | 75,694 | 5 | 151,388 |
"Correct Solution:
```
n = int(input())
a = list(map(int, input().split()))
ab = list(map(abs, a[:]))
s = sum(ab[:])
m = len([i for i in a if i < 0])
if m % 2 == 0:
print(s)
else:
print(s - 2 * min(ab))
``` | output | 1 | 75,694 | 5 | 151,389 |
Provide a correct Python 3 solution for this coding contest problem.
There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.
You can perform the following operation on this integer sequence any number of times:
Operation: Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.
Let B_1, B_2, ..., B_N be the integer sequence after your operations.
Find the maximum possible value of B_1 + B_2 + ... + B_N.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* -10^9 \leq A_i \leq 10^9
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
Output
Print the maximum possible value of B_1 + B_2 + ... + B_N.
Examples
Input
3
-10 5 -4
Output
19
Input
5
10 -4 -8 -11 3
Output
30
Input
11
-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000
Output
10000000000 | instruction | 0 | 75,695 | 5 | 151,390 |
"Correct Solution:
```
n = int(input())
a = list(map(int, input().split()))
p = sum(ai < 0 for ai in a)
ans = sum(map(abs, a))
if p & 1:
ans -= 2 * min(abs(ai) for ai in a)
print(ans)
``` | output | 1 | 75,695 | 5 | 151,391 |
Provide a correct Python 3 solution for this coding contest problem.
There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.
You can perform the following operation on this integer sequence any number of times:
Operation: Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.
Let B_1, B_2, ..., B_N be the integer sequence after your operations.
Find the maximum possible value of B_1 + B_2 + ... + B_N.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* -10^9 \leq A_i \leq 10^9
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
Output
Print the maximum possible value of B_1 + B_2 + ... + B_N.
Examples
Input
3
-10 5 -4
Output
19
Input
5
10 -4 -8 -11 3
Output
30
Input
11
-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000
Output
10000000000 | instruction | 0 | 75,696 | 5 | 151,392 |
"Correct Solution:
```
n = int(input())
A = list(map(int,input().split()))
B = [abs(a) for a in A]
ans=sum(B)
c=sum(1 for a in A if a<0)
if c%2 :
ans-=min(B)*2
print(ans)
``` | output | 1 | 75,696 | 5 | 151,393 |
Provide a correct Python 3 solution for this coding contest problem.
There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.
You can perform the following operation on this integer sequence any number of times:
Operation: Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.
Let B_1, B_2, ..., B_N be the integer sequence after your operations.
Find the maximum possible value of B_1 + B_2 + ... + B_N.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* -10^9 \leq A_i \leq 10^9
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
Output
Print the maximum possible value of B_1 + B_2 + ... + B_N.
Examples
Input
3
-10 5 -4
Output
19
Input
5
10 -4 -8 -11 3
Output
30
Input
11
-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000
Output
10000000000 | instruction | 0 | 75,697 | 5 | 151,394 |
"Correct Solution:
```
n = int(input())
a = list(map(int, input().split()))
b = [abs(i) for i in a]
if sum([i <= 0 for i in a]) % 2 == 0:
print(sum(b))
else:
print(sum(b) - min(b) * 2)
``` | output | 1 | 75,697 | 5 | 151,395 |
Provide a correct Python 3 solution for this coding contest problem.
There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.
You can perform the following operation on this integer sequence any number of times:
Operation: Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.
Let B_1, B_2, ..., B_N be the integer sequence after your operations.
Find the maximum possible value of B_1 + B_2 + ... + B_N.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* -10^9 \leq A_i \leq 10^9
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
Output
Print the maximum possible value of B_1 + B_2 + ... + B_N.
Examples
Input
3
-10 5 -4
Output
19
Input
5
10 -4 -8 -11 3
Output
30
Input
11
-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000
Output
10000000000 | instruction | 0 | 75,698 | 5 | 151,396 |
"Correct Solution:
```
n=input()
a=list(map(int,input().split()))
n=sum(x<0 for x in a)
a=list(map(lambda x: abs(x),a))
m=min(a)
s=sum(a) if n%2==0 else sum(a)-m *2
print(s)
``` | output | 1 | 75,698 | 5 | 151,397 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.
You can perform the following operation on this integer sequence any number of times:
Operation: Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.
Let B_1, B_2, ..., B_N be the integer sequence after your operations.
Find the maximum possible value of B_1 + B_2 + ... + B_N.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* -10^9 \leq A_i \leq 10^9
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
Output
Print the maximum possible value of B_1 + B_2 + ... + B_N.
Examples
Input
3
-10 5 -4
Output
19
Input
5
10 -4 -8 -11 3
Output
30
Input
11
-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000
Output
10000000000
Submitted Solution:
```
N=int(input())
A=list(map(int,input().split()))
S=sum(map(abs,A))
sign=1
for i in range(N):
if A[i]<0:
sign*=-1
print (S if sign>0 or 0 in A else S-2*min(map(abs,A)))
``` | instruction | 0 | 75,699 | 5 | 151,398 |
Yes | output | 1 | 75,699 | 5 | 151,399 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.
You can perform the following operation on this integer sequence any number of times:
Operation: Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.
Let B_1, B_2, ..., B_N be the integer sequence after your operations.
Find the maximum possible value of B_1 + B_2 + ... + B_N.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* -10^9 \leq A_i \leq 10^9
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
Output
Print the maximum possible value of B_1 + B_2 + ... + B_N.
Examples
Input
3
-10 5 -4
Output
19
Input
5
10 -4 -8 -11 3
Output
30
Input
11
-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000
Output
10000000000
Submitted Solution:
```
n=int(input());a=list(map(int,input().split()));m=0
for i in range(n):
if a[i]<0:m+=1
a=list(map(abs,a))
a.sort()
print(sum(a) if m%2 ==0 else sum(a) - 2*a[0])
``` | instruction | 0 | 75,700 | 5 | 151,400 |
Yes | output | 1 | 75,700 | 5 | 151,401 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.
You can perform the following operation on this integer sequence any number of times:
Operation: Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.
Let B_1, B_2, ..., B_N be the integer sequence after your operations.
Find the maximum possible value of B_1 + B_2 + ... + B_N.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* -10^9 \leq A_i \leq 10^9
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
Output
Print the maximum possible value of B_1 + B_2 + ... + B_N.
Examples
Input
3
-10 5 -4
Output
19
Input
5
10 -4 -8 -11 3
Output
30
Input
11
-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000
Output
10000000000
Submitted Solution:
```
n=int(input())
a=list(map(int,input().split()))
sm=sum(map(abs,a))
f=1
for i in range(n-1):
f= 1 if a[i]*f>=0 else -1
print (sm if f*a[n-1]>0 or 0 in a else sm-2*min(map(abs,a)))
``` | instruction | 0 | 75,701 | 5 | 151,402 |
Yes | output | 1 | 75,701 | 5 | 151,403 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.
You can perform the following operation on this integer sequence any number of times:
Operation: Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.
Let B_1, B_2, ..., B_N be the integer sequence after your operations.
Find the maximum possible value of B_1 + B_2 + ... + B_N.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* -10^9 \leq A_i \leq 10^9
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
Output
Print the maximum possible value of B_1 + B_2 + ... + B_N.
Examples
Input
3
-10 5 -4
Output
19
Input
5
10 -4 -8 -11 3
Output
30
Input
11
-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000
Output
10000000000
Submitted Solution:
```
N = int(input())
A = list(map(int, input().split()))
m = 1
for i in range(N):
if A[i] < 0:
m *= -1
A[i] = (-1) * A[i]
print(sum(A) + (m - 1) * min(A))
``` | instruction | 0 | 75,702 | 5 | 151,404 |
Yes | output | 1 | 75,702 | 5 | 151,405 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.
You can perform the following operation on this integer sequence any number of times:
Operation: Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.
Let B_1, B_2, ..., B_N be the integer sequence after your operations.
Find the maximum possible value of B_1 + B_2 + ... + B_N.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* -10^9 \leq A_i \leq 10^9
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
Output
Print the maximum possible value of B_1 + B_2 + ... + B_N.
Examples
Input
3
-10 5 -4
Output
19
Input
5
10 -4 -8 -11 3
Output
30
Input
11
-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000
Output
10000000000
Submitted Solution:
```
n = int(input())
n_list = [int(i) for i in input().split()]
minus_count = 0
plus_list = []
for x in n_list:
if x < 0:
minus_count += 1
plus_list.append(abs(x))
if x % 2 == 0: #even
print(sum(plus_list))
else:
print(sum(plus_list) - 2 * min(plus_list))
``` | instruction | 0 | 75,703 | 5 | 151,406 |
No | output | 1 | 75,703 | 5 | 151,407 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.
You can perform the following operation on this integer sequence any number of times:
Operation: Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.
Let B_1, B_2, ..., B_N be the integer sequence after your operations.
Find the maximum possible value of B_1 + B_2 + ... + B_N.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* -10^9 \leq A_i \leq 10^9
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
Output
Print the maximum possible value of B_1 + B_2 + ... + B_N.
Examples
Input
3
-10 5 -4
Output
19
Input
5
10 -4 -8 -11 3
Output
30
Input
11
-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000
Output
10000000000
Submitted Solution:
```
n = int(input())
a = list(map(int, input().split()))
zeroFlag = False
kosuu = 0
ans = 0
for i in range(n):
if(a[i]<0):
kosuu += 1
elif(a[i]==0):
zeroFlag = True
ans += abs(a[i])
if(zeroFlag):
print(ans)
else:
if(kosuu%2==0):
print(ans)
else:
ans -= 2*abs(a[n-1])
print(ans)
``` | instruction | 0 | 75,704 | 5 | 151,408 |
No | output | 1 | 75,704 | 5 | 151,409 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.
You can perform the following operation on this integer sequence any number of times:
Operation: Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.
Let B_1, B_2, ..., B_N be the integer sequence after your operations.
Find the maximum possible value of B_1 + B_2 + ... + B_N.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* -10^9 \leq A_i \leq 10^9
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
Output
Print the maximum possible value of B_1 + B_2 + ... + B_N.
Examples
Input
3
-10 5 -4
Output
19
Input
5
10 -4 -8 -11 3
Output
30
Input
11
-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000
Output
10000000000
Submitted Solution:
```
N = int(input())
a =list(map(int, input().split()))
ret = 0
for i in range(len(a)-1):
if a[i] < 0:
a[i] *= -1
a[i+1] *= -1
ret += a[i]
#print(a[i], ret)
ret += a[-1]
print(ret)
``` | instruction | 0 | 75,705 | 5 | 151,410 |
No | output | 1 | 75,705 | 5 | 151,411 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.
You can perform the following operation on this integer sequence any number of times:
Operation: Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.
Let B_1, B_2, ..., B_N be the integer sequence after your operations.
Find the maximum possible value of B_1 + B_2 + ... + B_N.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* -10^9 \leq A_i \leq 10^9
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
Output
Print the maximum possible value of B_1 + B_2 + ... + B_N.
Examples
Input
3
-10 5 -4
Output
19
Input
5
10 -4 -8 -11 3
Output
30
Input
11
-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000
Output
10000000000
Submitted Solution:
```
#conding utf-8
N = int(input())
A = input().split()
ans = 0
t = 0
for i in range(N):
A[i] = int(A[i])
for i in range(N):
if A[i] == 0:
for j in range(N):
if A[j]<0:
A[j] = -A[j]
ans = sum(A)
for j in range(N):
if A[j]<0:
t +=1
if t%2 == 0:
for j in range(N):
if A[j]<0:
A[j] = -A[j]
ans = sum(A)
else:
for j in range(N):
if A[j]<0:
A[j] = -A[j]
A[A.index(min(A))] = -A[A.index(min(A))]
ans = sum(A)
print(ans)
``` | instruction | 0 | 75,706 | 5 | 151,412 |
No | output | 1 | 75,706 | 5 | 151,413 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In some other world, today is December D-th.
Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22.
Constraints
* 22 \leq D \leq 25
* D is an integer.
Input
Input is given from Standard Input in the following format:
D
Output
Print the specified string (case-sensitive).
Examples
Input
25
Output
Christmas
Input
22
Output
Christmas Eve Eve Eve
Submitted Solution:
```
N = int(input())
p=[int(input()) for _ in range(N)]
#print(p)
p.sort()
_sum=sum(p)-int(p[-1]/2)
print(_sum)
``` | instruction | 0 | 75,719 | 5 | 151,438 |
No | output | 1 | 75,719 | 5 | 151,439 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b.
The i-th operation is as follows:
1. Append a_i to the end of b.
2. Reverse the order of the elements in b.
Find the sequence b obtained after these n operations.
Constraints
* 1 \leq n \leq 2\times 10^5
* 0 \leq a_i \leq 10^9
* n and a_i are integers.
Input
Input is given from Standard Input in the following format:
n
a_1 a_2 ... a_n
Output
Print n integers in a line with spaces in between. The i-th integer should be b_i.
Examples
Input
4
1 2 3 4
Output
4 2 1 3
Input
3
1 2 3
Output
3 1 2
Input
1
1000000000
Output
1000000000
Input
6
0 6 7 6 7 0
Output
0 6 6 0 7 7 | instruction | 0 | 75,739 | 5 | 151,478 |
"Correct Solution:
```
n = int(input())
a = list(map(int, input().split()))
b_1 = []
b_2 = []
b = []
for i in reversed(range(len(a))):
if i % 2 != 0:
b_1.append(a[i])
else:
b_2.append(a[i])
if len(a) % 2 == 0:
b_2.reverse()
b.extend(b_1)
b.extend(b_2)
else:
b_1.reverse()
b.extend(b_2)
b.extend(b_1)
for b_num in b:
print(b_num, end = ' ')
``` | output | 1 | 75,739 | 5 | 151,479 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b.
The i-th operation is as follows:
1. Append a_i to the end of b.
2. Reverse the order of the elements in b.
Find the sequence b obtained after these n operations.
Constraints
* 1 \leq n \leq 2\times 10^5
* 0 \leq a_i \leq 10^9
* n and a_i are integers.
Input
Input is given from Standard Input in the following format:
n
a_1 a_2 ... a_n
Output
Print n integers in a line with spaces in between. The i-th integer should be b_i.
Examples
Input
4
1 2 3 4
Output
4 2 1 3
Input
3
1 2 3
Output
3 1 2
Input
1
1000000000
Output
1000000000
Input
6
0 6 7 6 7 0
Output
0 6 6 0 7 7 | instruction | 0 | 75,740 | 5 | 151,480 |
"Correct Solution:
```
from collections import deque
n=int(input())
a=list(map(str,input().split()))
d=deque()
for i in range(n):
if i%2==0:
d.appendleft(a[i])
else:
d.append(a[i])
d=list(d)
if n%2==0:
d=d[::-1]
print(" ".join(d))
``` | output | 1 | 75,740 | 5 | 151,481 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b.
The i-th operation is as follows:
1. Append a_i to the end of b.
2. Reverse the order of the elements in b.
Find the sequence b obtained after these n operations.
Constraints
* 1 \leq n \leq 2\times 10^5
* 0 \leq a_i \leq 10^9
* n and a_i are integers.
Input
Input is given from Standard Input in the following format:
n
a_1 a_2 ... a_n
Output
Print n integers in a line with spaces in between. The i-th integer should be b_i.
Examples
Input
4
1 2 3 4
Output
4 2 1 3
Input
3
1 2 3
Output
3 1 2
Input
1
1000000000
Output
1000000000
Input
6
0 6 7 6 7 0
Output
0 6 6 0 7 7 | instruction | 0 | 75,741 | 5 | 151,482 |
"Correct Solution:
```
N=int(input())
A=list(map(int,input().split()))
B=[]
C=[]
for i in range(N):
if(N%2==0):
if(i%2==0):
B.append(A[i])
else:
C.append(A[i])
else:
if(i%2==0):
C.append(A[i])
else:
B.append(A[i])
C.reverse()
for i in range(len(B)):
C.append(B[i])
for i in range(N):
print(C[i] if i==0 else " "+str(C[i]),end="")
print()
``` | output | 1 | 75,741 | 5 | 151,483 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b.
The i-th operation is as follows:
1. Append a_i to the end of b.
2. Reverse the order of the elements in b.
Find the sequence b obtained after these n operations.
Constraints
* 1 \leq n \leq 2\times 10^5
* 0 \leq a_i \leq 10^9
* n and a_i are integers.
Input
Input is given from Standard Input in the following format:
n
a_1 a_2 ... a_n
Output
Print n integers in a line with spaces in between. The i-th integer should be b_i.
Examples
Input
4
1 2 3 4
Output
4 2 1 3
Input
3
1 2 3
Output
3 1 2
Input
1
1000000000
Output
1000000000
Input
6
0 6 7 6 7 0
Output
0 6 6 0 7 7 | instruction | 0 | 75,742 | 5 | 151,484 |
"Correct Solution:
```
n = int(input())
a = list(map(int,input().split()))
if n % 2 == 1:
b = a[::2]
c = a[1::2]
b.reverse()
d = b+c
print(' '.join(map(str,d)))
else:
b = a[::2]
c = a[1::2]
c.reverse()
d = c+b
print(' '.join(map(str,d)))
``` | output | 1 | 75,742 | 5 | 151,485 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b.
The i-th operation is as follows:
1. Append a_i to the end of b.
2. Reverse the order of the elements in b.
Find the sequence b obtained after these n operations.
Constraints
* 1 \leq n \leq 2\times 10^5
* 0 \leq a_i \leq 10^9
* n and a_i are integers.
Input
Input is given from Standard Input in the following format:
n
a_1 a_2 ... a_n
Output
Print n integers in a line with spaces in between. The i-th integer should be b_i.
Examples
Input
4
1 2 3 4
Output
4 2 1 3
Input
3
1 2 3
Output
3 1 2
Input
1
1000000000
Output
1000000000
Input
6
0 6 7 6 7 0
Output
0 6 6 0 7 7 | instruction | 0 | 75,743 | 5 | 151,486 |
"Correct Solution:
```
n=int(input())
a=list(map(int,input().split()))
ans=[]
v=[]
ans=a[-1::-2]
if n%2==0:
for i in range(0,n,2):
v.append(a[i])
else:
for i in range(1,n,2):
v.append(a[i])
ans.extend(v)
moji=" ".join(map(str,ans))
print(moji)
``` | output | 1 | 75,743 | 5 | 151,487 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b.
The i-th operation is as follows:
1. Append a_i to the end of b.
2. Reverse the order of the elements in b.
Find the sequence b obtained after these n operations.
Constraints
* 1 \leq n \leq 2\times 10^5
* 0 \leq a_i \leq 10^9
* n and a_i are integers.
Input
Input is given from Standard Input in the following format:
n
a_1 a_2 ... a_n
Output
Print n integers in a line with spaces in between. The i-th integer should be b_i.
Examples
Input
4
1 2 3 4
Output
4 2 1 3
Input
3
1 2 3
Output
3 1 2
Input
1
1000000000
Output
1000000000
Input
6
0 6 7 6 7 0
Output
0 6 6 0 7 7 | instruction | 0 | 75,744 | 5 | 151,488 |
"Correct Solution:
```
def slove():
import sys
input = sys.stdin.readline
n = int(input().rstrip('\n'))
a = list(map(int, input().rstrip('\n').split()))
ls = []
for i in range(n-1, -1, -2):
ls.append(a[i])
for i in range(0 if n % 2 == 0 else 1, n, 2):
ls.append(a[i])
print(*ls)
if __name__ == '__main__':
slove()
``` | output | 1 | 75,744 | 5 | 151,489 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b.
The i-th operation is as follows:
1. Append a_i to the end of b.
2. Reverse the order of the elements in b.
Find the sequence b obtained after these n operations.
Constraints
* 1 \leq n \leq 2\times 10^5
* 0 \leq a_i \leq 10^9
* n and a_i are integers.
Input
Input is given from Standard Input in the following format:
n
a_1 a_2 ... a_n
Output
Print n integers in a line with spaces in between. The i-th integer should be b_i.
Examples
Input
4
1 2 3 4
Output
4 2 1 3
Input
3
1 2 3
Output
3 1 2
Input
1
1000000000
Output
1000000000
Input
6
0 6 7 6 7 0
Output
0 6 6 0 7 7 | instruction | 0 | 75,745 | 5 | 151,490 |
"Correct Solution:
```
n = int(input())
a = list(map(int,input().split()))
even = []
odd = []
for i in range(0,n):
if i % 2 == 0:
odd.append(a[i])
else:
even.append(a[i])
res = []
if n % 2 == 0:
even = reversed(even)
res.extend(even)
res.extend(odd)
else:
odd = reversed(odd)
res.extend(odd)
res.extend(even)
print(" ".join(map(str,res)))
``` | output | 1 | 75,745 | 5 | 151,491 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b.
The i-th operation is as follows:
1. Append a_i to the end of b.
2. Reverse the order of the elements in b.
Find the sequence b obtained after these n operations.
Constraints
* 1 \leq n \leq 2\times 10^5
* 0 \leq a_i \leq 10^9
* n and a_i are integers.
Input
Input is given from Standard Input in the following format:
n
a_1 a_2 ... a_n
Output
Print n integers in a line with spaces in between. The i-th integer should be b_i.
Examples
Input
4
1 2 3 4
Output
4 2 1 3
Input
3
1 2 3
Output
3 1 2
Input
1
1000000000
Output
1000000000
Input
6
0 6 7 6 7 0
Output
0 6 6 0 7 7 | instruction | 0 | 75,746 | 5 | 151,492 |
"Correct Solution:
```
from collections import deque
n = int(input())
a = list(input().split())
b = deque()
for i in range(n):
if i % 2 == 0:
b.append(a[i])
else:
b.appendleft(a[i])
if n % 2 == 1:
b.reverse()
print(' '.join(b))
``` | output | 1 | 75,746 | 5 | 151,493 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b.
The i-th operation is as follows:
1. Append a_i to the end of b.
2. Reverse the order of the elements in b.
Find the sequence b obtained after these n operations.
Constraints
* 1 \leq n \leq 2\times 10^5
* 0 \leq a_i \leq 10^9
* n and a_i are integers.
Input
Input is given from Standard Input in the following format:
n
a_1 a_2 ... a_n
Output
Print n integers in a line with spaces in between. The i-th integer should be b_i.
Examples
Input
4
1 2 3 4
Output
4 2 1 3
Input
3
1 2 3
Output
3 1 2
Input
1
1000000000
Output
1000000000
Input
6
0 6 7 6 7 0
Output
0 6 6 0 7 7
Submitted Solution:
```
N = int(input())
a = input().split()
b = [""] * N
b1 = [a[i] for i in range(len(a)) if i % 2 == 1][::-1]
b2 = [a[i] for i in range(len(a)) if i % 2 == 0]
b = b1 + b2
if N % 2 == 1:
b = b[::-1]
line = " ".join(b)
print(line)
``` | instruction | 0 | 75,747 | 5 | 151,494 |
Yes | output | 1 | 75,747 | 5 | 151,495 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b.
The i-th operation is as follows:
1. Append a_i to the end of b.
2. Reverse the order of the elements in b.
Find the sequence b obtained after these n operations.
Constraints
* 1 \leq n \leq 2\times 10^5
* 0 \leq a_i \leq 10^9
* n and a_i are integers.
Input
Input is given from Standard Input in the following format:
n
a_1 a_2 ... a_n
Output
Print n integers in a line with spaces in between. The i-th integer should be b_i.
Examples
Input
4
1 2 3 4
Output
4 2 1 3
Input
3
1 2 3
Output
3 1 2
Input
1
1000000000
Output
1000000000
Input
6
0 6 7 6 7 0
Output
0 6 6 0 7 7
Submitted Solution:
```
n = int(input())
A = list(input().split())
even = [A[i] for i in range(n) if i % 2 == 0]
odd = [A[i] for i in range(n) if i % 2 == 1]
if n % 2 == 0:
print(' '.join(list(reversed(odd)) + even))
else:
print(' '.join(list(reversed(even)) + odd))
``` | instruction | 0 | 75,748 | 5 | 151,496 |
Yes | output | 1 | 75,748 | 5 | 151,497 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b.
The i-th operation is as follows:
1. Append a_i to the end of b.
2. Reverse the order of the elements in b.
Find the sequence b obtained after these n operations.
Constraints
* 1 \leq n \leq 2\times 10^5
* 0 \leq a_i \leq 10^9
* n and a_i are integers.
Input
Input is given from Standard Input in the following format:
n
a_1 a_2 ... a_n
Output
Print n integers in a line with spaces in between. The i-th integer should be b_i.
Examples
Input
4
1 2 3 4
Output
4 2 1 3
Input
3
1 2 3
Output
3 1 2
Input
1
1000000000
Output
1000000000
Input
6
0 6 7 6 7 0
Output
0 6 6 0 7 7
Submitted Solution:
```
from collections import deque
que = deque()
n = int(input())
seq = list(map(int, input().split()))
for i in range(n):
if i%2 == 0:
que.append(seq[i])
else:
que.appendleft(seq[i])
if n%2 != 0:
que.reverse()
print(*que)
``` | instruction | 0 | 75,749 | 5 | 151,498 |
Yes | output | 1 | 75,749 | 5 | 151,499 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b.
The i-th operation is as follows:
1. Append a_i to the end of b.
2. Reverse the order of the elements in b.
Find the sequence b obtained after these n operations.
Constraints
* 1 \leq n \leq 2\times 10^5
* 0 \leq a_i \leq 10^9
* n and a_i are integers.
Input
Input is given from Standard Input in the following format:
n
a_1 a_2 ... a_n
Output
Print n integers in a line with spaces in between. The i-th integer should be b_i.
Examples
Input
4
1 2 3 4
Output
4 2 1 3
Input
3
1 2 3
Output
3 1 2
Input
1
1000000000
Output
1000000000
Input
6
0 6 7 6 7 0
Output
0 6 6 0 7 7
Submitted Solution:
```
N = int(input())
A = list(input().split())
if N==1:
print(A[0])
else:
side1 = A[0::2]
side2 = A[1::2]
if N%2==0:
print(" ".join(side2[::-1]+side1))
else:
print(" ".join(side1[::-1]+side2))
``` | instruction | 0 | 75,750 | 5 | 151,500 |
Yes | output | 1 | 75,750 | 5 | 151,501 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b.
The i-th operation is as follows:
1. Append a_i to the end of b.
2. Reverse the order of the elements in b.
Find the sequence b obtained after these n operations.
Constraints
* 1 \leq n \leq 2\times 10^5
* 0 \leq a_i \leq 10^9
* n and a_i are integers.
Input
Input is given from Standard Input in the following format:
n
a_1 a_2 ... a_n
Output
Print n integers in a line with spaces in between. The i-th integer should be b_i.
Examples
Input
4
1 2 3 4
Output
4 2 1 3
Input
3
1 2 3
Output
3 1 2
Input
1
1000000000
Output
1000000000
Input
6
0 6 7 6 7 0
Output
0 6 6 0 7 7
Submitted Solution:
```
n = int(input())
a = list(map(int, input().split()))
b = []
for aa in a:
b.append(aa)
b.reverse()
ans = ''
for bb in b:
ans += bb + ' '
print(ans[:-1])
``` | instruction | 0 | 75,751 | 5 | 151,502 |
No | output | 1 | 75,751 | 5 | 151,503 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b.
The i-th operation is as follows:
1. Append a_i to the end of b.
2. Reverse the order of the elements in b.
Find the sequence b obtained after these n operations.
Constraints
* 1 \leq n \leq 2\times 10^5
* 0 \leq a_i \leq 10^9
* n and a_i are integers.
Input
Input is given from Standard Input in the following format:
n
a_1 a_2 ... a_n
Output
Print n integers in a line with spaces in between. The i-th integer should be b_i.
Examples
Input
4
1 2 3 4
Output
4 2 1 3
Input
3
1 2 3
Output
3 1 2
Input
1
1000000000
Output
1000000000
Input
6
0 6 7 6 7 0
Output
0 6 6 0 7 7
Submitted Solution:
```
import collections
n = int(input())
a = list(map(int, input().split()))
b = collections.deque(list)
if n % 2 == 0:
for i, ele in enumerate(a):
if i % 2 == 0:
b.append(ele)
else:
b.appendleft(ele)
else:
for i, ele in enumerate(a):
if i % 2 == 0:
b.appendleft(ele)
else:
b.append(ele)
print(" ".join(b))
``` | instruction | 0 | 75,752 | 5 | 151,504 |
No | output | 1 | 75,752 | 5 | 151,505 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b.
The i-th operation is as follows:
1. Append a_i to the end of b.
2. Reverse the order of the elements in b.
Find the sequence b obtained after these n operations.
Constraints
* 1 \leq n \leq 2\times 10^5
* 0 \leq a_i \leq 10^9
* n and a_i are integers.
Input
Input is given from Standard Input in the following format:
n
a_1 a_2 ... a_n
Output
Print n integers in a line with spaces in between. The i-th integer should be b_i.
Examples
Input
4
1 2 3 4
Output
4 2 1 3
Input
3
1 2 3
Output
3 1 2
Input
1
1000000000
Output
1000000000
Input
6
0 6 7 6 7 0
Output
0 6 6 0 7 7
Submitted Solution:
```
n = int(input())
A = input().split()
b = []
for (i, a) in enumerate(A):
if i % 2 == 0:
b.append(a)
else:
b.insert(0, a)
if n % 2 == 1:
b = list(reversed(b))
print(' '.join(b))
``` | instruction | 0 | 75,753 | 5 | 151,506 |
No | output | 1 | 75,753 | 5 | 151,507 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b.
The i-th operation is as follows:
1. Append a_i to the end of b.
2. Reverse the order of the elements in b.
Find the sequence b obtained after these n operations.
Constraints
* 1 \leq n \leq 2\times 10^5
* 0 \leq a_i \leq 10^9
* n and a_i are integers.
Input
Input is given from Standard Input in the following format:
n
a_1 a_2 ... a_n
Output
Print n integers in a line with spaces in between. The i-th integer should be b_i.
Examples
Input
4
1 2 3 4
Output
4 2 1 3
Input
3
1 2 3
Output
3 1 2
Input
1
1000000000
Output
1000000000
Input
6
0 6 7 6 7 0
Output
0 6 6 0 7 7
Submitted Solution:
```
N = int(input())
a = list(map(int,input().split()))
check = N%2==0
for i,j in enumerate(a[1:]):
if(check):
if(i%2==0):
ans.insert(0,j)
else:
ans.append(j)
else:
if(i%2==1):
ans.insert(0,j)
else:
ans.append(j)
print(" ".join(map(str,ans)))
``` | instruction | 0 | 75,754 | 5 | 151,508 |
No | output | 1 | 75,754 | 5 | 151,509 |
Provide a correct Python 3 solution for this coding contest problem.
For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.
* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.
* find($x$): Report the number of $x$ in $S$ (0 or 1).
* delete($x$): Delete $x$ from $S$.
Constraints
* $1 \leq q \leq 200,000$
* $0 \leq x \leq 1,000,000,000$
Input
The input is given in the following format.
$q$
$query_1$
$query_2$
:
$query_q$
Each query $query_i$ is given by
0 $x$
or
1 $x$
or
2 $x$
where the first digits 0, 1 and 2 represent insert, find and delete operations respectively.
Output
For each insert operation, print the number of elements in $S$.
For each find operation, print the number of specified elements in $S$.
Example
Input
8
0 1
0 2
0 3
2 2
1 1
1 2
1 3
0 2
Output
1
2
3
1
0
1
3 | instruction | 0 | 75,874 | 5 | 151,748 |
"Correct Solution:
```
q = int(input())
S = set([])
for i in range(q):
query, x = list(map(int, input().split()))
# insert
if query == 0:
S.add(x)
print(len(S))
# find
elif query == 1:
if x in S:
print(1)
else:
print(0)
# delete
else:
if x in S:
S.remove(x)
``` | output | 1 | 75,874 | 5 | 151,749 |
Provide a correct Python 3 solution for this coding contest problem.
For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.
* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.
* find($x$): Report the number of $x$ in $S$ (0 or 1).
* delete($x$): Delete $x$ from $S$.
Constraints
* $1 \leq q \leq 200,000$
* $0 \leq x \leq 1,000,000,000$
Input
The input is given in the following format.
$q$
$query_1$
$query_2$
:
$query_q$
Each query $query_i$ is given by
0 $x$
or
1 $x$
or
2 $x$
where the first digits 0, 1 and 2 represent insert, find and delete operations respectively.
Output
For each insert operation, print the number of elements in $S$.
For each find operation, print the number of specified elements in $S$.
Example
Input
8
0 1
0 2
0 3
2 2
1 1
1 2
1 3
0 2
Output
1
2
3
1
0
1
3 | instruction | 0 | 75,875 | 5 | 151,750 |
"Correct Solution:
```
if __name__ == '__main__':
n = int(input())
S = set()
for _ in range(n):
x,y = map(int,input().split())
if x == 0:
S.add(y)
print(len(S))
elif x == 1:
if y in S:
print("1")
else:
print("0")
else:
S.discard(y)
``` | output | 1 | 75,875 | 5 | 151,751 |
Provide a correct Python 3 solution for this coding contest problem.
For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.
* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.
* find($x$): Report the number of $x$ in $S$ (0 or 1).
* delete($x$): Delete $x$ from $S$.
Constraints
* $1 \leq q \leq 200,000$
* $0 \leq x \leq 1,000,000,000$
Input
The input is given in the following format.
$q$
$query_1$
$query_2$
:
$query_q$
Each query $query_i$ is given by
0 $x$
or
1 $x$
or
2 $x$
where the first digits 0, 1 and 2 represent insert, find and delete operations respectively.
Output
For each insert operation, print the number of elements in $S$.
For each find operation, print the number of specified elements in $S$.
Example
Input
8
0 1
0 2
0 3
2 2
1 1
1 2
1 3
0 2
Output
1
2
3
1
0
1
3 | instruction | 0 | 75,876 | 5 | 151,752 |
"Correct Solution:
```
s = set()
for _ in range(int(input())):
q,x = map(int, input().split())
if q==0:
s.add(x)
print(len(s))
elif q==2:
s.discard(x)
else:
print("1" if x in s else "0")
``` | output | 1 | 75,876 | 5 | 151,753 |
Provide a correct Python 3 solution for this coding contest problem.
For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.
* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.
* find($x$): Report the number of $x$ in $S$ (0 or 1).
* delete($x$): Delete $x$ from $S$.
Constraints
* $1 \leq q \leq 200,000$
* $0 \leq x \leq 1,000,000,000$
Input
The input is given in the following format.
$q$
$query_1$
$query_2$
:
$query_q$
Each query $query_i$ is given by
0 $x$
or
1 $x$
or
2 $x$
where the first digits 0, 1 and 2 represent insert, find and delete operations respectively.
Output
For each insert operation, print the number of elements in $S$.
For each find operation, print the number of specified elements in $S$.
Example
Input
8
0 1
0 2
0 3
2 2
1 1
1 2
1 3
0 2
Output
1
2
3
1
0
1
3 | instruction | 0 | 75,877 | 5 | 151,754 |
"Correct Solution:
```
from typing import Set
if __name__ == "__main__":
int_set: Set[int] = set()
num_query = int(input())
for _ in range(num_query):
op, v = map(lambda x: int(x), input().split())
if (0 == op):
int_set.add(v)
print(len(int_set))
elif (1 == op):
if (v in int_set):
print(1)
else:
print(0)
else:
if (v in int_set):
int_set.remove(v)
``` | output | 1 | 75,877 | 5 | 151,755 |
Provide a correct Python 3 solution for this coding contest problem.
For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.
* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.
* find($x$): Report the number of $x$ in $S$ (0 or 1).
* delete($x$): Delete $x$ from $S$.
Constraints
* $1 \leq q \leq 200,000$
* $0 \leq x \leq 1,000,000,000$
Input
The input is given in the following format.
$q$
$query_1$
$query_2$
:
$query_q$
Each query $query_i$ is given by
0 $x$
or
1 $x$
or
2 $x$
where the first digits 0, 1 and 2 represent insert, find and delete operations respectively.
Output
For each insert operation, print the number of elements in $S$.
For each find operation, print the number of specified elements in $S$.
Example
Input
8
0 1
0 2
0 3
2 2
1 1
1 2
1 3
0 2
Output
1
2
3
1
0
1
3 | instruction | 0 | 75,878 | 5 | 151,756 |
"Correct Solution:
```
readline = open(0).readline
writelines = open(1, 'w').writelines
s = set()
def insert(x):
s.add(x)
ans.append("%d\n" % len(s))
def find(x):
ans.append("%d\n" % (x in s))
C = [insert, find, s.discard].__getitem__
Q = int(readline())
ans = []
for _ in range(Q):
t, x = map(int, readline().split())
C(t)(x)
writelines(ans)
``` | output | 1 | 75,878 | 5 | 151,757 |
Provide a correct Python 3 solution for this coding contest problem.
For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.
* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.
* find($x$): Report the number of $x$ in $S$ (0 or 1).
* delete($x$): Delete $x$ from $S$.
Constraints
* $1 \leq q \leq 200,000$
* $0 \leq x \leq 1,000,000,000$
Input
The input is given in the following format.
$q$
$query_1$
$query_2$
:
$query_q$
Each query $query_i$ is given by
0 $x$
or
1 $x$
or
2 $x$
where the first digits 0, 1 and 2 represent insert, find and delete operations respectively.
Output
For each insert operation, print the number of elements in $S$.
For each find operation, print the number of specified elements in $S$.
Example
Input
8
0 1
0 2
0 3
2 2
1 1
1 2
1 3
0 2
Output
1
2
3
1
0
1
3 | instruction | 0 | 75,879 | 5 | 151,758 |
"Correct Solution:
```
q = int(input())
se = set()
while q:
q -= 1
op, x = map(int, input().split())
if op == 1:
print(+(x in se))
elif op == 0:
se.add(x)
print(len(se))
else:
se.discard(x)
``` | output | 1 | 75,879 | 5 | 151,759 |
Provide a correct Python 3 solution for this coding contest problem.
For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.
* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.
* find($x$): Report the number of $x$ in $S$ (0 or 1).
* delete($x$): Delete $x$ from $S$.
Constraints
* $1 \leq q \leq 200,000$
* $0 \leq x \leq 1,000,000,000$
Input
The input is given in the following format.
$q$
$query_1$
$query_2$
:
$query_q$
Each query $query_i$ is given by
0 $x$
or
1 $x$
or
2 $x$
where the first digits 0, 1 and 2 represent insert, find and delete operations respectively.
Output
For each insert operation, print the number of elements in $S$.
For each find operation, print the number of specified elements in $S$.
Example
Input
8
0 1
0 2
0 3
2 2
1 1
1 2
1 3
0 2
Output
1
2
3
1
0
1
3 | instruction | 0 | 75,880 | 5 | 151,760 |
"Correct Solution:
```
def main():
m = int(input())
s = set()
for _ in range(m):
a,b = map(int,input().split())
if a == 0:
s.add(b)
print (len(s))
elif a == 1:
if b in s:print (1)
else :print (0)
elif b in s:s.remove(b)
if __name__ == '__main__':
main()
``` | output | 1 | 75,880 | 5 | 151,761 |
Provide a correct Python 3 solution for this coding contest problem.
For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.
* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.
* find($x$): Report the number of $x$ in $S$ (0 or 1).
* delete($x$): Delete $x$ from $S$.
Constraints
* $1 \leq q \leq 200,000$
* $0 \leq x \leq 1,000,000,000$
Input
The input is given in the following format.
$q$
$query_1$
$query_2$
:
$query_q$
Each query $query_i$ is given by
0 $x$
or
1 $x$
or
2 $x$
where the first digits 0, 1 and 2 represent insert, find and delete operations respectively.
Output
For each insert operation, print the number of elements in $S$.
For each find operation, print the number of specified elements in $S$.
Example
Input
8
0 1
0 2
0 3
2 2
1 1
1 2
1 3
0 2
Output
1
2
3
1
0
1
3 | instruction | 0 | 75,881 | 5 | 151,762 |
"Correct Solution:
```
readline = open(0).readline
writeline = open(1, 'w').writelines
s = set()
def insert(x):
s.add(x)
ans.append("%d\n" % len(s))
def find(x):
ans.append("%d\n" % (x in s))
C = [insert, find, s.discard].__getitem__
Q = int(readline())
ans = []
for _ in range(Q):
t, x = map(int, readline().split())
C(t)(x)
writeline(ans)
``` | output | 1 | 75,881 | 5 | 151,763 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.
* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.
* find($x$): Report the number of $x$ in $S$ (0 or 1).
* delete($x$): Delete $x$ from $S$.
Constraints
* $1 \leq q \leq 200,000$
* $0 \leq x \leq 1,000,000,000$
Input
The input is given in the following format.
$q$
$query_1$
$query_2$
:
$query_q$
Each query $query_i$ is given by
0 $x$
or
1 $x$
or
2 $x$
where the first digits 0, 1 and 2 represent insert, find and delete operations respectively.
Output
For each insert operation, print the number of elements in $S$.
For each find operation, print the number of specified elements in $S$.
Example
Input
8
0 1
0 2
0 3
2 2
1 1
1 2
1 3
0 2
Output
1
2
3
1
0
1
3
Submitted Solution:
```
S = set()
q = int(input())
for _ in range(q):
command, *list_num = input().split()
x = int(list_num[0])
if command == "0":
# insert(x)
S.add(x)
print(len(S))
elif command == "1":
# find(x)
if x in S:
print(1)
else:
print(0)
elif command == "2":
if x in S:
S.remove(x)
else:
raise
``` | instruction | 0 | 75,882 | 5 | 151,764 |
Yes | output | 1 | 75,882 | 5 | 151,765 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.
* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.
* find($x$): Report the number of $x$ in $S$ (0 or 1).
* delete($x$): Delete $x$ from $S$.
Constraints
* $1 \leq q \leq 200,000$
* $0 \leq x \leq 1,000,000,000$
Input
The input is given in the following format.
$q$
$query_1$
$query_2$
:
$query_q$
Each query $query_i$ is given by
0 $x$
or
1 $x$
or
2 $x$
where the first digits 0, 1 and 2 represent insert, find and delete operations respectively.
Output
For each insert operation, print the number of elements in $S$.
For each find operation, print the number of specified elements in $S$.
Example
Input
8
0 1
0 2
0 3
2 2
1 1
1 2
1 3
0 2
Output
1
2
3
1
0
1
3
Submitted Solution:
```
import sys
input = sys.stdin.buffer.readline
from random import randrange
q = int(input())
queries = [list(map(int, input().split())) for i in range(q)]
set_ = set()
for category, x in queries:
if category == 0:
set_.add(x)
print(len(set_))
elif category == 1:
print(int(x in set_))
else:
if x in set_:
set_.remove(x)
``` | instruction | 0 | 75,883 | 5 | 151,766 |
Yes | output | 1 | 75,883 | 5 | 151,767 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.
* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.
* find($x$): Report the number of $x$ in $S$ (0 or 1).
* delete($x$): Delete $x$ from $S$.
Constraints
* $1 \leq q \leq 200,000$
* $0 \leq x \leq 1,000,000,000$
Input
The input is given in the following format.
$q$
$query_1$
$query_2$
:
$query_q$
Each query $query_i$ is given by
0 $x$
or
1 $x$
or
2 $x$
where the first digits 0, 1 and 2 represent insert, find and delete operations respectively.
Output
For each insert operation, print the number of elements in $S$.
For each find operation, print the number of specified elements in $S$.
Example
Input
8
0 1
0 2
0 3
2 2
1 1
1 2
1 3
0 2
Output
1
2
3
1
0
1
3
Submitted Solution:
```
S=set()
q=int(input())
for _ in range(q):
query=[int(i) for i in input().split(" ")]
if query[0]==0:
S.add(query[1])
print(len(S))
elif query[0]==1:
if query[1] in S:
print(1)
else:
print(0)
else:
if query[1] in S:
S.remove(query[1])
``` | instruction | 0 | 75,884 | 5 | 151,768 |
Yes | output | 1 | 75,884 | 5 | 151,769 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.
* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.
* find($x$): Report the number of $x$ in $S$ (0 or 1).
* delete($x$): Delete $x$ from $S$.
Constraints
* $1 \leq q \leq 200,000$
* $0 \leq x \leq 1,000,000,000$
Input
The input is given in the following format.
$q$
$query_1$
$query_2$
:
$query_q$
Each query $query_i$ is given by
0 $x$
or
1 $x$
or
2 $x$
where the first digits 0, 1 and 2 represent insert, find and delete operations respectively.
Output
For each insert operation, print the number of elements in $S$.
For each find operation, print the number of specified elements in $S$.
Example
Input
8
0 1
0 2
0 3
2 2
1 1
1 2
1 3
0 2
Output
1
2
3
1
0
1
3
Submitted Solution:
```
import sys
nq = int(input())
lines = sys.stdin.readlines()
ans = [None] * nq
s = {}
for i in range(nq):
q, x = lines[i].split()
if q == '0': # insert x
s[x] = ''
ans[i] = str(len(s))
elif q == '1': # find x
ans[i] = str(int(x in s))
else: # delete x
if x in s:
del s[x]
[print(x) for x in ans if x]
``` | instruction | 0 | 75,885 | 5 | 151,770 |
Yes | output | 1 | 75,885 | 5 | 151,771 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.
* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.
* find($x$): Report the number of $x$ in $S$ (0 or 1).
* delete($x$): Delete $x$ from $S$.
Constraints
* $1 \leq q \leq 200,000$
* $0 \leq x \leq 1,000,000,000$
Input
The input is given in the following format.
$q$
$query_1$
$query_2$
:
$query_q$
Each query $query_i$ is given by
0 $x$
or
1 $x$
or
2 $x$
where the first digits 0, 1 and 2 represent insert, find and delete operations respectively.
Output
For each insert operation, print the number of elements in $S$.
For each find operation, print the number of specified elements in $S$.
Example
Input
8
0 1
0 2
0 3
2 2
1 1
1 2
1 3
0 2
Output
1
2
3
1
0
1
3
Submitted Solution:
```
import math
class LinearProbingIntSet:
def __init__(self):
self.count = 0
self.size = 1
self.keys = [None] * self.size
def add(self, key):
i = self._hash(key)
for j in range(self.size):
k = (i + j) % self.size
if self.keys[k] is None:
self.keys[k] = key
self.count += 1
break
elif self.keys[k] == key:
break
else:
raise RuntimeError('set is full')
if self.count > self.size // 2:
size = int(2 ** (math.log2(self.size+1)+1)) - 1
self._resize(size)
def delete(self, key):
i = self._hash(key)
while self.keys[i] is not None and self.keys[i] != key:
i = (i + 1) % self.size
if self.keys[i] != key:
return
self.keys[i] = None
self.count -= 1
i = (i + 1) % self.size
while self.keys[i] is not None:
k, self.keys[i] = self.keys[i], None
self.count -= 1
self.add(k)
i = (i + 1) % self.size
if self.count <= self.size // 4:
size = max(1, int(2 ** (math.log2(self.size+1)-1)) - 1)
self._resize(size)
def __contains__(self, key):
i = self._hash(key)
for j in range(self.size):
k = (i + j) % self.size
if self.keys[k] is None:
return False
elif self.keys[k] == key:
return True
raise RuntimeError('set is full')
def _hash(self, key):
return key % self.size
def _resize(self, size):
old_keys = self.keys
self.count = 0
self.size = size
self.keys = [None] * self.size
for key in old_keys:
if key is None:
continue
self.add(key)
def run():
q = int(input())
s = LinearProbingIntSet()
for _ in range(q):
command, value = [int(x) for x in input().split()]
if command == 0:
s.add(value)
print(s.count)
elif command == 1:
if value in s:
print(1)
else:
print(0)
elif command == 2:
s.delete(value)
else:
raise ValueError('invalid command')
if __name__ == '__main__':
run()
``` | instruction | 0 | 75,886 | 5 | 151,772 |
No | output | 1 | 75,886 | 5 | 151,773 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.
* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.
* find($x$): Report the number of $x$ in $S$ (0 or 1).
* delete($x$): Delete $x$ from $S$.
Constraints
* $1 \leq q \leq 200,000$
* $0 \leq x \leq 1,000,000,000$
Input
The input is given in the following format.
$q$
$query_1$
$query_2$
:
$query_q$
Each query $query_i$ is given by
0 $x$
or
1 $x$
or
2 $x$
where the first digits 0, 1 and 2 represent insert, find and delete operations respectively.
Output
For each insert operation, print the number of elements in $S$.
For each find operation, print the number of specified elements in $S$.
Example
Input
8
0 1
0 2
0 3
2 2
1 1
1 2
1 3
0 2
Output
1
2
3
1
0
1
3
Submitted Solution:
```
numset = set([])
q = int(input())
for i in range(q):
query, x = list(map(int, input().split(' ')))
if query == 0:
numset.add(x)
print(len(numset))
elif query == 1:
if set([x]).issubset(numset):
print(1)
else:
print(0)
else:
numset.remove(x)
``` | instruction | 0 | 75,887 | 5 | 151,774 |
No | output | 1 | 75,887 | 5 | 151,775 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.
* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.
* find($x$): Report the number of $x$ in $S$ (0 or 1).
* delete($x$): Delete $x$ from $S$.
Constraints
* $1 \leq q \leq 200,000$
* $0 \leq x \leq 1,000,000,000$
Input
The input is given in the following format.
$q$
$query_1$
$query_2$
:
$query_q$
Each query $query_i$ is given by
0 $x$
or
1 $x$
or
2 $x$
where the first digits 0, 1 and 2 represent insert, find and delete operations respectively.
Output
For each insert operation, print the number of elements in $S$.
For each find operation, print the number of specified elements in $S$.
Example
Input
8
0 1
0 2
0 3
2 2
1 1
1 2
1 3
0 2
Output
1
2
3
1
0
1
3
Submitted Solution:
```
import math
class LinearProbingIntSet:
def __init__(self):
self.count = 0
self.size = 1
self.keys = [None] * self.size
def add(self, key):
i = self._hash(key)
for j in range(self.size):
k = (i + j) % self.size
if self.keys[k] is None:
self.keys[k] = key
self.count += 1
break
elif self.keys[k] == key:
break
else:
raise RuntimeError('set is full')
if self.count > self.size // 2:
size = int(2 ** (math.log2(self.size+1)+1)) - 1
self._resize(size)
def delete(self, key):
i = self._hash(key)
while self.keys[i] is not None and self.keys[i] != key:
i = (i + 1) % self.size
if self.keys[i] != key:
return
for j in range(self.size):
k1 = (i + j) % self.size
k2 = (i + j + 1) % self.size
if self.keys[k2] is None:
self.keys[k1] = None
self.count -= 1
break
elif k2 == self._hash(self.keys[k2]):
self.keys[k1] = None
self.count -= 1
break
else:
self.keys[k1] = self.keys[k2]
if self.count <= self.size // 4:
size = max(1, int(2 ** (math.log2(self.size+1)-1)) - 1)
self._resize(size)
def __contains__(self, key):
i = self._hash(key)
for j in range(self.size):
k = (i + j) % self.size
if self.keys[k] is None:
return False
elif self.keys[k] == key:
return True
raise RuntimeError('set is full')
def _hash(self, key):
return key % self.size
def _resize(self, size):
old_keys = self.keys
self.count = 0
self.size = size
self.keys = [None] * self.size
for key in old_keys:
if key is None:
continue
self.add(key)
def run():
q = int(input())
s = LinearProbingIntSet()
for _ in range(q):
command, value = [int(x) for x in input().split()]
if command == 0:
s.add(value)
print(s.count)
elif command == 1:
if value in s:
print(1)
else:
print(0)
elif command == 2:
s.delete(value)
else:
raise ValueError('invalid command')
if __name__ == '__main__':
run()
``` | instruction | 0 | 75,888 | 5 | 151,776 |
No | output | 1 | 75,888 | 5 | 151,777 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.
* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.
* find($x$): Report the number of $x$ in $S$ (0 or 1).
* delete($x$): Delete $x$ from $S$.
Constraints
* $1 \leq q \leq 200,000$
* $0 \leq x \leq 1,000,000,000$
Input
The input is given in the following format.
$q$
$query_1$
$query_2$
:
$query_q$
Each query $query_i$ is given by
0 $x$
or
1 $x$
or
2 $x$
where the first digits 0, 1 and 2 represent insert, find and delete operations respectively.
Output
For each insert operation, print the number of elements in $S$.
For each find operation, print the number of specified elements in $S$.
Example
Input
8
0 1
0 2
0 3
2 2
1 1
1 2
1 3
0 2
Output
1
2
3
1
0
1
3
Submitted Solution:
```
# coding=utf-8
Q = int(input())
S = set()
for i in range(Q):
qtype, number = map(int, input().split())
if qtype == 0:
S.add(number)
print(len(S))
elif qtype == 1:
if number in S:
print(1)
else:
print(0)
elif qtype == 2:
S.remove(number)
``` | instruction | 0 | 75,889 | 5 | 151,778 |
No | output | 1 | 75,889 | 5 | 151,779 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two integers n and m. Calculate the number of pairs of arrays (a, b) such that:
* the length of both arrays is equal to m;
* each element of each array is an integer between 1 and n (inclusive);
* a_i β€ b_i for any index i from 1 to m;
* array a is sorted in non-descending order;
* array b is sorted in non-ascending order.
As the result can be very large, you should print it modulo 10^9+7.
Input
The only line contains two integers n and m (1 β€ n β€ 1000, 1 β€ m β€ 10).
Output
Print one integer β the number of arrays a and b satisfying the conditions described above modulo 10^9+7.
Examples
Input
2 2
Output
5
Input
10 1
Output
55
Input
723 9
Output
157557417
Note
In the first test there are 5 suitable arrays:
* a = [1, 1], b = [2, 2];
* a = [1, 2], b = [2, 2];
* a = [2, 2], b = [2, 2];
* a = [1, 1], b = [2, 1];
* a = [1, 1], b = [1, 1].
Submitted Solution:
```
import sys
import math
import heapq
import collections
def inputnum():
return(int(input()))
def inputnums():
return(map(int,input().split()))
def inputlist():
return(list(map(int,input().split())))
def inputstring():
return([x for x in input()])
def inputstringnum():
return([ord(x)-ord('a') for x in input()])
def inputmatrixchar(rows):
arr2d = [[j for j in input().strip()] for i in range(rows)]
return arr2d
def inputmatrixint(rows):
arr2d = []
for _ in range(rows):
arr2d.append([int(i) for i in input().split()])
return arr2d
def nCr(n, r):
return (fact(n)//(fact(r)*fact(n - r)))
def fact(n):
res = 1
for i in range(2, n+1):
res = res * i
return res
n, m = inputnums()
mod = 1000000007
ans = nCr(n + 2*m - 1, 2*m)%mod
print(ans)
``` | instruction | 0 | 75,999 | 5 | 151,998 |
Yes | output | 1 | 75,999 | 5 | 151,999 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Jeff got 2n real numbers a1, a2, ..., a2n as a birthday present. The boy hates non-integer numbers, so he decided to slightly "adjust" the numbers he's got. Namely, Jeff consecutively executes n operations, each of them goes as follows:
* choose indexes i and j (i β j) that haven't been chosen yet;
* round element ai to the nearest integer that isn't more than ai (assign to ai: β ai β);
* round element aj to the nearest integer that isn't less than aj (assign to aj: β aj β).
Nevertheless, Jeff doesn't want to hurt the feelings of the person who gave him the sequence. That's why the boy wants to perform the operations so as to make the absolute value of the difference between the sum of elements before performing the operations and the sum of elements after performing the operations as small as possible. Help Jeff find the minimum absolute value of the difference.
Input
The first line contains integer n (1 β€ n β€ 2000). The next line contains 2n real numbers a1, a2, ..., a2n (0 β€ ai β€ 10000), given with exactly three digits after the decimal point. The numbers are separated by spaces.
Output
In a single line print a single real number β the required difference with exactly three digits after the decimal point.
Examples
Input
3
0.000 0.500 0.750 1.000 2.000 3.000
Output
0.250
Input
3
4469.000 6526.000 4864.000 9356.383 7490.000 995.896
Output
0.279
Note
In the first test case you need to perform the operations as follows: (i = 1, j = 4), (i = 2, j = 3), (i = 5, j = 6). In this case, the difference will equal |(0 + 0.5 + 0.75 + 1 + 2 + 3) - (0 + 0 + 1 + 1 + 2 + 3)| = 0.25.
Submitted Solution:
```
from sys import *
import math
def numline(f = int):
return map(f, input().split())
n = int(input())
a = list(filter(lambda x: x != 0, numline(lambda s: int(s.split('.')[1]))))
c0 = min(2 * n - len(a), len(a))
# print(' '.join(map(str, a)), file = stderr)
# print(c0, file = stderr)
s = sum(a)
ans = math.inf
for i in range(-c0 * 1000, c0 * 1000 + 1, 1000):
ans = min(ans, abs(s - i))
print('{}.{:0>3}'.format(ans // 1000, ans % 1000))
``` | instruction | 0 | 76,197 | 5 | 152,394 |
No | output | 1 | 76,197 | 5 | 152,395 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Jeff got 2n real numbers a1, a2, ..., a2n as a birthday present. The boy hates non-integer numbers, so he decided to slightly "adjust" the numbers he's got. Namely, Jeff consecutively executes n operations, each of them goes as follows:
* choose indexes i and j (i β j) that haven't been chosen yet;
* round element ai to the nearest integer that isn't more than ai (assign to ai: β ai β);
* round element aj to the nearest integer that isn't less than aj (assign to aj: β aj β).
Nevertheless, Jeff doesn't want to hurt the feelings of the person who gave him the sequence. That's why the boy wants to perform the operations so as to make the absolute value of the difference between the sum of elements before performing the operations and the sum of elements after performing the operations as small as possible. Help Jeff find the minimum absolute value of the difference.
Input
The first line contains integer n (1 β€ n β€ 2000). The next line contains 2n real numbers a1, a2, ..., a2n (0 β€ ai β€ 10000), given with exactly three digits after the decimal point. The numbers are separated by spaces.
Output
In a single line print a single real number β the required difference with exactly three digits after the decimal point.
Examples
Input
3
0.000 0.500 0.750 1.000 2.000 3.000
Output
0.250
Input
3
4469.000 6526.000 4864.000 9356.383 7490.000 995.896
Output
0.279
Note
In the first test case you need to perform the operations as follows: (i = 1, j = 4), (i = 2, j = 3), (i = 5, j = 6). In this case, the difference will equal |(0 + 0.5 + 0.75 + 1 + 2 + 3) - (0 + 0 + 1 + 1 + 2 + 3)| = 0.25.
Submitted Solution:
```
n = int(input())
As = list(map(float, input().split()))
B = list(x - int(x) for x in As if x - int(x) > 0.000)
l = len(B)
if l == 0:
print('{:.3f}'.format(0))
exit(0)
S = sum(x for x in B)
print(S)
ll = l if l % 2 == 0 else l + 1
ans = 1e10
for i in range(max(0, l - n), (n if l > n else l) + 1):
ans = min(ans, abs(i - S))
print('{:.3f}'.format(ans))
``` | instruction | 0 | 76,198 | 5 | 152,396 |
No | output | 1 | 76,198 | 5 | 152,397 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.