Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def convert_X(x,index):
	if index == 0:
		return x[1:]
	if index == len(x)-1:
		return x[:-1]
	return x[:index] + x[index+1:]

N = int(input())
X = [int(d) for d in input().split()]

for index in range(N):
	d_x = convert_X(X,index)
	d_x.sort()
	print(d_x[int( (len(d_x)+1)/2 ) -1])


Fixed submission:
N = int(input())
X = [int(d) for d in input().split()]

sort_x = X.copy()
sort_x.sort()

nn = N//2
low_ = sort_x[nn-1]
high_ = sort_x[nn]

for x in X:
	if x < high_:
		print(high_)
	else:
		print(low_)

Buggy python submission (verdict: Time Limit Exceeded):
def convert_X(x,index):
	if index == 0:
		return x[1:]
	if index == len(x)-1:
		return x[:-1]
	return x[:index] + x[index+1:]

N = int(input())
X = [int(d) for d in input().split()]

for index in range(N):
	#print(index,convert_X(X,index))
	d_x = convert_X(X,index)
	d_x.sort()
	#print(d_x)
	#print(d_x[center-1])
	print(d_x[int( (len(d_x)+1)/2 ) -1])


Fixed submission:
N = int(input())
X = [int(d) for d in input().split()]

sort_x = X.copy()
sort_x.sort()

nn = N//2
low_ = sort_x[nn-1]
high_ = sort_x[nn]

for x in X:
	if x < high_:
		print(high_)
	else:
		print(low_)
Buggy python submission (verdict: Runtime Error):
def comb1(n, r):
    if n == 0 or r == 0: return 1
    return comb1(n, r-1) * (n-r+1) / r 


N = int(input())
X = [int(d) for d in input().split()]

max_ = 0
comb_ = []

X.sort(reverse=True)
for i,v in enumerate(X):
	for h in range(1,len(X)-i):
		#print(v,X[i+h])
		comb_value = comb1(v,X[i+h])
		if max_<comb_value:
			max_ = comb_value
			comb_ = [v,X[i+h]]


print(comb_[0],comb_[1])

Fixed submission:
N = int(input())
X = [int(d) for d in input().split()]

max_ = max(X)
X.remove(max_)

center = max_/2
abs_ = float('inf')
t_index = None


for i in range(N-1):
	if abs(center - X[i]) < abs_:
		abs_ = abs(center - X[i])
		t_index = i

print(max_,X[t_index])
Buggy python submission (verdict: Runtime Error):
from collections import Counter

n = int(input())
s = []
for i in range(n):
    s.append(input())

m = int(input())
t = []
for i in range(m):
    t.append(input())

ls = Counter(s)
lt = Counter(t)

c = 0
for k in ls.keys():
    c_temp = ls[k] - lt[k]
    if c < c_temp:
        c = c_temp

print(c)


Fixed submission:
a, b, c = [int(x) for x in input().split(' ')]

if a + b >= c:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N=input()
cnt=0
last=-1
while N>0:
  N,n=divmod(N,10)
  if last == n:
    cnt+=1
    if cnt>=3:
      break
  else:
    cnt=1
  last=n
if cnt>=3:
  print('yes')
else:
  print('no')

Fixed submission:
N=int(input())
cnt=0
last=-1
while N>0:
  N,n=divmod(N,10)
  if last == n:
    cnt+=1
    if cnt>=3:
      break
  else:
    cnt=1
  last=n
if cnt>=3:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
l=[int(x) for x in list(input())]
if l[0]+l[1]+l[2]+l[3]==7: print('{}+{}+{}+{}=7'.format(l[0],l[1],l[2],l[3])
elif l[0]+l[1]+l[2]-l[3]==7: print('{}+{}+{}-{}=7'.format(l[0],l[1],l[2],l[3])
elif l[0]+l[1]-l[2]+l[3]==7: print('{}+{}-{}+{}=7'.format(l[0],l[1],l[2],l[3])
elif l[0]+l[1]-l[2]-l[3]==7: print('{}+{}-{}-{}=7'.format(l[0],l[1],l[2],l[3])
elif l[0]-l[1]+l[2]+l[3]==7: print('{}-{}+{}+{}=7'.format(l[0],l[1],l[2],l[3])
elif l[0]-l[1]+l[2]-l[3]==7: print('{}-{}+{}-{}=7'.format(l[0],l[1],l[2],l[3])
elif l[0]-l[1]-l[2]+l[3]==7: print('{}-{}-{}+{}=7'.format(l[0],l[1],l[2],l[3])
elif l[0]-l[1]-l[2]-l[3]==7: print('{}-{}-{}-{}=7'.format(l[0],l[1],l[2],l[3])


Fixed submission:
l=[int(x) for x in list(input())]
if l[0]+l[1]+l[2]+l[3]==7: print('{}+{}+{}+{}=7'.format(l[0],l[1],l[2],l[3]))
elif l[0]+l[1]+l[2]-l[3]==7: print('{}+{}+{}-{}=7'.format(l[0],l[1],l[2],l[3]))
elif l[0]+l[1]-l[2]+l[3]==7: print('{}+{}-{}+{}=7'.format(l[0],l[1],l[2],l[3]))
elif l[0]+l[1]-l[2]-l[3]==7: print('{}+{}-{}-{}=7'.format(l[0],l[1],l[2],l[3]))
elif l[0]-l[1]+l[2]+l[3]==7: print('{}-{}+{}+{}=7'.format(l[0],l[1],l[2],l[3]))
elif l[0]-l[1]+l[2]-l[3]==7: print('{}-{}+{}-{}=7'.format(l[0],l[1],l[2],l[3]))
elif l[0]-l[1]-l[2]+l[3]==7: print('{}-{}-{}+{}=7'.format(l[0],l[1],l[2],l[3]))
elif l[0]-l[1]-l[2]-l[3]==7: print('{}-{}-{}-{}=7'.format(l[0],l[1],l[2],l[3]))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
X = list(map(int, input().split()))

for i in range(len(X)):
    print(int(np.median(X[:i] + X[i+1:])))

Fixed submission:
import numpy as np

N = int(input())
X = list(map(int, input().split()))

M = np.median(X)

Y = sorted(X)
a = Y[int(len(Y)/2 - 1)]
b = Y[int(len(Y)/2)]

for x in X:
    if x <= a:
        print(b)
    else:
        print(a)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
inp=list(map(int, input().strip().split(' ')))

med = int(N/2)
for i in range(N):
  X=[]
  for j in range(N):
    if i!=j:
      X.append(inp[j])
  Xsort = sorted(X)
  print(Xsort[med-1])


Fixed submission:
N=int(input())
inp=list(map(int, input().strip().split(' ')))
Xsort=sorted(inp)
med = int(N/2)
for i in range(N):
  if Xsort[med-1] >= inp[i] :
    print(Xsort[med])
  else:
    print(Xsort[med-1])
Buggy python submission (verdict: Runtime Error):
N = input()
list=[]
flg = 0 
for i in range(N):
    list.append(map(int, raw_input().split()))
if N == 1:
	rem = abs(list[0][1]) + abs(list[0][2])
	if rem == 1:
		print("Yes")
	else:
		print("No")
else:
	for i in range(N-1):
		rem = abs(list[i][1]-list[i+1][1]) + abs(list[i][2]-list[i+1][2])
		time = list[i][0]-list[i+1][0]
		if (time-rem) <= 0:
			flg = 1
			break
		elif (time-rem) % 2 ==1:
			flg = 1
		            break
	if flg == 0:
		print("Yes")
	else:
		print("No")

Fixed submission:
N = input()
list=[]
flg = 0 
for i in range(N):
    list.append(map(int, raw_input().split()))
if N == 1:
	rem = abs(list[0][1]) + abs(list[0][2])
	if rem == 1:
		print("Yes")
	else:
		print("No")
else:
	for i in range(N-1):
		rem = abs(list[i][1]-list[i+1][1]) + abs(list[i][2]-list[i+1][2])
		time = list[i+1][0]-list[i][0]
		if (time-rem) < 0:
			    flg = 1
		            break
		elif (time-rem) % 2 ==1:
			    flg = 1
		            break
		            
	if flg == 0:
		print("Yes")
	else:
		print("No")
Buggy python submission (verdict: Runtime Error):
import math
N,A,B=[int(i) for i in raw_input().split()]
if B-A % 2 ==0:
     print("Alice")
else:
     print("Borys")

Fixed submission:
import math
N,A,B=[int(i) for i in raw_input().split()]
C=B-A
if C % 2 ==0:
     print("Alice")
else:
     print("Borys")
Buggy python submission (verdict: Runtime Error):
N = int(input())
b = input().split(" ")

for i in range(N):
    X = b
    X.pop(i)
    X.sort()
    print(X[len(X)//2])

Fixed submission:
N = int(input())
b = [int(i) for i in input().split()]
c = sorted(b[:])
s = c[(N-1)//2]
l = c[N//2]

for i in b:
    if i > s:
       print(s)
    else:
       print(l)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from collections import Counter


N = int(input())
p = {}

for _ in range(N):
    s = input()
    if s not in p.keys():
        p[s] = 1
    else:
        p[s] += 1

M = int(input())

for _ in range(M):
    t = input()
    if t not in p.keys():
        p[t] = -1
    else:
        p[t] -= 1

print(max(max(p.values()), 0))


Fixed submission:
# -*- coding: utf-8 -*-

A, B, C = map(int, input().split(" "))

if A + B >= C:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

N, K = map(int, input().split(" "))
c = 0
 
if K != 0:
    for b in range(K+1, N+1):
        s = N % b
        t = N - s
        p = t // b * (b - K)
        q = max(0, s - (K - 1))
        c += (p + q)
        
else:
    c = N ** 2

print(c)

Fixed submission:
# -*- coding: utf-8 -*-

c = []
for i in range(3):
    c.append(input())
print(c[0][0] + c[1][1] + c[2][2])
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

N, K = map(int, input().split(" "))
c = 0

if K == 0:
    print(N*N)
else:
    for b in range(K+1, N+1):
        for a in range(K, b):
            n = (N-a)//b + 1
            c += n
            
    print(c)

Fixed submission:
# -*- coding: utf-8 -*-

N, K = map(int, input().split(" "))
c = 0
 
if K != 0:
    for b in range(K+1, N+1):
        s = N % b
        t = N - s
        p = t // b * (b - K)
        q = max(0, s - (K - 1))
        c += (p + q)
        
else:
    c = N ** 2

print(c)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from IPython import embed
H, W = [int(s) for s in input().split(" ")]

maze = [list(input()) for _ in range(H)]

distance = [[float("inf") for i in range(W)] for j in range(H)]

def bfs():
    queue = []
    sx = 0
    sy = 0
    gx = H-1
    gy = W-1

    queue.insert(0, (sx, sy))

    distance[sx][sy] = 0

    while len(queue):
        x, y = queue.pop()

        if x == gx and y == gy:
            break

        for i in range(0, 4):
            nx, ny = x + [1, 0, -1, 0][i], y + [0, 1, 0, -1][i]
            
            if (0 <= nx < H and 0 <= ny < W):
                if maze[nx][ny] != '#' and distance[nx][ny] == float("inf"):
                    queue.insert(0, (nx, ny))
                    distance[nx][ny] = distance[x][y] + 1

    return distance[gx][gy]

d = bfs()
cnt = 0
for i in range(H):
    for j in range(W):
        if maze[i][j] == ".":
            cnt += 1
if  d == float("inf"):
    print(-1)
else:
    print(cnt - d - 1)


Fixed submission:
# -*- coding: utf-8 -*-
H, W = [int(s) for s in input().split(" ")]

maze = [list(input()) for _ in range(H)]

distance = [[float("inf") for i in range(W)] for j in range(H)]

def bfs():
    queue = []
    sx = 0
    sy = 0
    gx = H-1
    gy = W-1

    queue.insert(0, (sx, sy))

    distance[sx][sy] = 0

    while len(queue):
        x, y = queue.pop()

        if x == gx and y == gy:
            break

        for i in range(0, 4):
            nx, ny = x + [1, 0, -1, 0][i], y + [0, 1, 0, -1][i]
            
            if (0 <= nx < H and 0 <= ny < W):
                if maze[nx][ny] != '#' and distance[nx][ny] == float("inf"):
                    queue.insert(0, (nx, ny))
                    distance[nx][ny] = distance[x][y] + 1

    return distance[gx][gy]

d = bfs()
cnt = 0
for i in range(H):
    for j in range(W):
        if maze[i][j] == ".":
            cnt += 1
if  d == float("inf"):
    print(-1)
else:
    print(cnt - d - 1)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import itertools
import sys

ships = []
N, M = [int(x) for x in input().split()]
for i in range(M):
    ships.append([int(x) for x in input().split()])

from_1 = set([ship[1] for ship in ships if ship[0] == 1])
to_N = set([ship[0] for ship in ships if ship[1] == N])

if from_1 & to_N:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Fixed submission:
# -*- coding: utf-8 -*-

N = int(input())
print('ABC' + str(N))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import itertools
import sys

ships = []
N, M = [int(x) for x in input().split()]
for i in range(M):
    ships.append([int(x) for x in input().split()])

from_1 = [ship[1] for ship in ships if ship[0] == 1]
to_N = [ship[0] for ship in ships if ship[1] == N]

for land in from_1:
    if land in to_N:
        print("POSSIBLE")
        sys.exit()

print("IMPOSSIBLE")

Fixed submission:
# -*- coding: utf-8 -*-

ships = []
N, M = [int(x) for x in input().split()]
for i in range(M):
    ships.append([int(x) for x in input().split()])

from_1 = set([ship[1] for ship in ships if ship[0] == 1])
to_N = set([ship[0] for ship in ships if ship[1] == N])

if from_1.intersection(to_N):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

N, K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]

l.sort(reverse=True)
print(sum(l[:K]))

Fixed submission:
# -*- coding: utf-8 -*-

A, B = [int(x) for x in input().split()]

if A % 3 == 0:
    print ("Possible")
elif B % 3 == 0:
    print("Possible")
elif (A + B) % 3 == 0:
    print("Possible")
else:
    print("Impossible")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = input()
a = [int(x) for x in input().split()]

ans = 1e16
for s in (1, -1):
    res, cumsum = 0, 0
    for j in range(n):
        cumsum += a[j]
        if cumsum * s <= 0:
            res += abs(cumsum-s)
            cumsum = s
        s *= -1
    ans = min(ans, res)

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())
a = [int(x) for x in input().split()]

ans = 1e16
for s in (1, -1):
    res, cumsum = 0, 0
    for j in range(n):
        cumsum += a[j]
        if cumsum * s <= 0:
            res += abs(cumsum-s)
            cumsum = s
        s *= -1
    ans = min(ans, res)

print(ans)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,raw_input().split())
arr = [1]*n
x = [False]*n
x[0] = True
counter = 0
for i in xrange(m) :
    a,b = map(int,raw_input().split())
    if x[a-1] :
        x[b-1] = True
    arr[a-1] -= 1
    arr[b-1] += 1
    if arr[a-1] == 0 :
        x[a-1] = False
for j in x :
    if j  :
        counter += 1
print counter


Fixed submission:
a,b = map(int,raw_input().split())
if a > 0 and b > 0 :
    print 'Positive'
elif (a <= 0 and b >=0) :
    print 'Zero'
else :
    if b == 0 :
        print 'Zero'
    else :
        if (b-a+1)%2 == 0 :
            print 'Positive'
        else :
            print 'Negative'
Buggy python submission (verdict: Runtime Error):
n,l = map(int,raw_input().split())
s = []
for i in xrange(n) :
    s.append(raw_input())
s.sort()
t = ''
for j in xrange(n) :
    t += s[j]
print t    


Fixed submission:
a,b,c = map(int,raw_input().split())
if max(a,b,c) == 7 and min(a,b,c) == 5 and a+b+c == 17 :
    print 'YES'
else :
    print 'NO'
Buggy python submission (verdict: Runtime Error):
n,x = map(int,raw_input().split())
print '%d' %(n + ((n/x) - 1)*2*x + 3*(n%x))


Fixed submission:
n = int(raw_input())
a = map(int,raw_input().split())
a.sort()
s_l = 0
for i in xrange(0,2*n,2) :
    s_l += a[i]
print s_l

Buggy python submission (verdict: Runtime Error):
n,x = map(int,raw_input().split())
if n > 2*x :
    print '%d' %(n + (n/x - 1)*2*x + 3*(n-(n/x)*x))
else :
    print '%d' %(n + x)


Fixed submission:
n = int(raw_input())
a = map(int,raw_input().split())
a.sort()
s_l = 0
for i in xrange(0,2*n,2) :
    s_l += a[i]
print s_l
Buggy python submission (verdict: Time Limit Exceeded):
def run(lst, i):
    lst = [0]+lst+[0]
    cost = 0
    a = lst[:i]+lst[i+1:]
    for a,b in zip(a,a[1:]):
        cost+=abs(b-a)
    return cost

N = int(input())
l = list(map(int,input().split()))
for i in range(1,N+1):
    print(run(l,i))


Fixed submission:
N = int(input())
l = list(map(int,input().split()))
l = [0]+l+[0]
cost = 0
for a,b in zip(l,l[1:]):
    cost += abs(b-a)
for i in range(1,N+1):
    n = cost
    n-=abs(l[i-1]-l[i])
    n-=abs(l[i]-l[i+1])
    n+=abs(l[i-1]-l[i+1])
    print(n)
Buggy python submission (verdict: Runtime Error):
from math import log2
from decimal import Decimal

x, y = map(int, input().split())
dx = Decimal(log2(x))
dy = Decimal(log2(y))
print(1 + int(log2(dy) - log2(dx)))

Fixed submission:
x, y = map(int, input().split())

ans = 0
while x <= y:
    x *= 2
    ans += 1
else:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter as C

_, k = map(int, input().split())
a = [int(i) for i in input().split()]

ans = 0
c = sorted(C(a).values())
while k < len(c):
    ans += c.pop(0)
else:
    print(ans)

Fixed submission:
from collections import Counter, deque

_, k = map(int, input().split())
a = [int(i) for i in input().split()]

ans = 0
d = deque(sorted(Counter(a).values()))
while k < len(d):
    ans += d.popleft()
else:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

p = []
for _ in range(n):
    a = input()
    if a in p:
        p.remove(a)
    else:
        p.append(a)
else:
    print(len(p))

Fixed submission:
from collections import Counter as C

n = int(input())
a = C([input() for _ in range(n)])

print(sum([1 for v in a.values() if v % 2]))
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = [int(x) for x in input().split()]

cnt = 0
for i in range(n):
    if p[i] == i + 1:
        cnt += 1
        if i != n:
            p[i], p[i+1] = p[i+1], p[i]
else:
    print(cnt)

Fixed submission:
n = int(input())
p = [int(x) for x in input().split()]

cnt = 0
for i in range(n):
    if p[i] == i + 1:
        cnt += 1
        if i != n - 1:
            p[i], p[i+1] = p[i+1], p[i]
else:
    print(cnt)

Buggy python submission (verdict: Runtime Error):
_ = input()
p = [int(x) for x in input().split()]

lenp = len(p)
cnt = 0
for i in range(lenp):
    if p[i] == i + 1:
        cnt += 1
        if i != lenp:
            p[i], p[i+1] = p[i+1], p[i]
else:
    print(cnt)

Fixed submission:
n = int(input())
p = [int(x) for x in input().split()]

cnt = 0
for i in range(n):
    if p[i] == i + 1:
        cnt += 1
        if i != n - 1:
            p[i], p[i+1] = p[i+1], p[i]
else:
    print(cnt)

Buggy python submission (verdict: Runtime Error):
_ = input()
p = [int(x) for x in input().split()]

cnt = 0
for i in range(len(p)):
    if p[i] == i + 1:
        p[i], p[i+1] = p[i+1], p[i]
        cnt += 1
else:
    print(cnt)

Fixed submission:
n = int(input())
p = [int(x) for x in input().split()]

cnt = 0
for i in range(n):
    if p[i] == i + 1:
        cnt += 1
        if i != n - 1:
            p[i], p[i+1] = p[i+1], p[i]
else:
    print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
_ = input()
a = [int(x) for x in input().split()]

b = sorted(set(x for x in a if 2 <= a.count(x)))
if b:
    maxb = b[-1]
    if 4 <= a.count(maxb):
        print(maxb ** 2)
    elif 2 <= len(b):
        print(maxb * b[-2])
    else:
        print(0)
else:
    print(0)

Fixed submission:
from collections import Counter as C

_ = input()
a = C(map(int, input().split()))

b = []
for k, v in a.items():
    b.extend([k] * (v // 2))
else:
    if 2 <= len(b):
        b.sort()
        print(b[-1] * b[-2])
    else:
        print(0)

Buggy python submission (verdict: Time Limit Exceeded):
_ = input()
a = [int(x) for x in input().split()]

b = [0] * 2
for i in set(a):
    c = a.count(i)
    if 4 <= c:
        b.extend([i] * 2)
    elif 2 <= c:
        b.append(i)
else:
    b.sort()
    print(b[-1] * b[-2])

Fixed submission:
from collections import Counter as C

_ = input()
a = C(map(int, input().split()))

b = []
for k, v in a.items():
    b.extend([k] * (v // 2))
else:
    if 2 <= len(b):
        b.sort()
        print(b[-1] * b[-2])
    else:
        print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = input().split()
b = ""
for i in range(n):
    if i % 2 != n % 2:
        b = a[i] + " " + b
    else:
        b += a[i] + " "
else:
    print(b[:-1])

Fixed submission:
from collections import deque

n = int(input())
a = input().split()
b = deque()

for i in range(n):
    if i % 2 != n % 2:
        b.appendleft(a[i])
    else:
        b.append(a[i])
else:
    print(*b)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = input().split()
b = []
for i in range(n):
    if i % 2 != n % 2:
        b.insert(0, a[i])
    else:
        b += a[i]
else:
    print(" ".join(b))

Fixed submission:
from collections import deque

n = int(input())
a = input().split()
b = deque()

for i in range(n):
    if i % 2 != n % 2:
        b.appendleft(a[i])
    else:
        b.append(a[i])
else:
    print(*b)

Buggy python submission (verdict: Time Limit Exceeded):
_ = input()
b = []
for i in input().split():
    b.append(i)
    b.reverse()
else:
    print(" ".join(b))

Fixed submission:
from collections import deque

n = int(input())
a = input().split()
b = deque()

for i in range(n):
    if i % 2 != n % 2:
        b.appendleft(a[i])
    else:
        b.append(a[i])
else:
    print(*b)

Buggy python submission (verdict: Time Limit Exceeded):
_ = input()
b = []
for i in [x for x in input().split()]:
    b.append(i)
    b.reverse()
else:
    print(" ".join(b))

Fixed submission:
from collections import deque

n = int(input())
a = input().split()
b = deque()

for i in range(n):
    if i % 2 != n % 2:
        b.appendleft(a[i])
    else:
        b.append(a[i])
else:
    print(*b)

Buggy python submission (verdict: Time Limit Exceeded):
_ = input()
a = [x for x in input().split()]
b = []
for i in a:
    b.append(i)
    b.reverse()
else:
    print(" ".join(b))

Fixed submission:
from collections import deque

n = int(input())
a = input().split()
b = deque()

for i in range(n):
    if i % 2 != n % 2:
        b.appendleft(a[i])
    else:
        b.append(a[i])
else:
    print(*b)
Buggy python submission (verdict: Runtime Error):
from math import factorial as f

n, m = map(int(), input().split())

if n == m:
    print((f(n) ** 2 * 2) % (10 ** 9 + 7))
elif abs(n - m) == 1:
    print((f(n) * f(m)) % (10 ** 9 + 7)) 
else:
    print(0)

Fixed submission:
from math import factorial as f

n, m = map(int, input().split())

if n == m:
    print((f(n) ** 2 * 2) % (10 ** 9 + 7))
elif abs(n - m) == 1:
    print((f(n) * f(m)) % (10 ** 9 + 7)) 
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
n = input()
a = [int(x) for x in input().split() if x < 3200]
c = len(set([x // 400 for x in a]))
print(max(c, 1), c + n - len(a))

Fixed submission:
_ = input()
a = [int(x) for x in input().split()]

p = [False] * 8
q = 0
for i in a:
    if 3199 < i:
        q += 1
    else:
        for j in range(8):
            if 400 * j <= i < 400 * (j + 1):
                p[j] = True
else:
    s = sum(p)
    print(max(s, 1), s + q)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().aplit())
if b - a == c - b:
    print("YES")
else:
    print("NO")

Fixed submission:
a, b, c = map(int, input().split())
if b - a == c - b:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
o = input()
e = input()

pw = ""
for i in range(len(o)):
    pw += o[i] + e[i]
else:
    print(pw)

Fixed submission:
o = input()
e = input()

pw = ""
lene = len(e)
for i in range(lene):
    pw += o[i] + e[i]
else:
    if lene < len(o):
        pw += o[-1]
    print(pw)
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
ans = 0
for x in range(min(s, k) + 1):
    for y in range(min(s-x, k) + 1):
        for z in range(min(s-x-y, k) + 1):
            if x + y + z == s:
                ans += 1
else:
    print(ans)

Fixed submission:
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if 0 <= z <= k:
            ans += 1
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x + y + z == s:
                ans += 1
else:
    print(ans)

Fixed submission:
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if 0 <= z <= k:
            ans += 1
else:
    print(ans)