Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import collections as cole


n = int(input())
v = list(map(int, input().split()))

v1 = v[::2]   #odd
v2 = v[1::2]  #even

d1 = cole.Counter(v1)
d2 = cole.Counter(v2)

values1, counts1 = zip(*d1.most_common())
values2, counts2 = zip(*d2.most_common())

max1 = values1[0]
max2 = values2[0]

if max1 == max2:
    if len(counts1) != 1 and counts1[0] == counts1[1]:
        max1 = values[1]
    elif len(counts2) != 1 and counts2[0] == counts[1]:
        max2 = values[1]
    elif len(counts1) != 1 and len(counts2) != 1:
        if counts1[1] > counts2[1]:
            max1 = values1[1]
        else:
            max2 = values2[1]
    elif len(counts1) != 1:
        max1 = values1[1]
    elif len(counts2) != 1:
        max2 = values2[1]

print(max1, max2)
count = 0
if max1 != max2:
    count += len([x for x in v1 if x != max1])
    count += len([y for y in v2 if y != max2])

else:
    count += len(v1)


print(count)


Fixed submission:
import collections as cole


n = int(input())
v = list(map(int, input().split()))

v1 = v[::2]   #odd
v2 = v[1::2]  #even

d1 = cole.Counter(v1)
d2 = cole.Counter(v2)

values1, counts1 = zip(*d1.most_common())
values2, counts2 = zip(*d2.most_common())

max1 = values1[0]
max2 = values2[0]

if max1 == max2:
    if len(counts1) != 1 and counts1[0] == counts1[1]:
        max1 = values1[1]
    elif len(counts2) != 1 and counts2[0] == counts2[1]:
        max2 = values2[1]
    elif len(counts1) != 1 and len(counts2) != 1:
        if counts1[1] > counts2[1]:
            max1 = values1[1]
        else:
            max2 = values2[1]
    elif len(counts1) != 1:
        max1 = values1[1]
    elif len(counts2) != 1:
        max2 = values2[1]


count = 0
if max1 != max2:
    count += len([x for x in v1 if x != max1])
    count += len([y for y in v2 if y != max2])

else:
    count += len(v1)


print(count)
Buggy python submission (verdict: Runtime Error):
A, B, C = list(map(int, input().split()))
li = [A,B,C].sort()
ans = sum(li[:2]) + li[2] * 10

print(ans)

Fixed submission:
A, B, C = list(map(int, input().split()))

ans = A + B + C + 9 * max(A, B, C)

print(ans)
Buggy python submission (verdict: Runtime Error):
from collctions import Counter

S = list(input())
T = list(input())

Scount = Counter(S).values()
Tcount = Counter(T).values()



if sorted(Scount) == sorted(Tcount):
    ans = 'Yes' 
else:
    ans = 'No'

print(ans)

Fixed submission:
from collections import Counter

S = list(input())
T = list(input())

Scount = Counter(S).values()
Tcount = Counter(T).values()



if sorted(Scount) == sorted(Tcount):
    ans = 'Yes' 
else:
    ans = 'No'

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())


A = []
for i in range(N):
  if S[i] == "W":
    A.append(1)
  elif S[i] == "E":
    A.append(-1)
    
saidai = 0
for i in range(N):
  if saidai < sum(A[i+1:]) - sum(A[:i]):
    
    saidai = sum(A[i+1:]) - sum(A[:i])
    flag = i
    
ans = A[:flag].count(1) + A[flag+1:].count(-1)

print(ans)
  



Fixed submission:
N = int(input())
S = list(input())


A = []
for i in range(N):
  if S[i] == "W":
    A.append(1)
  elif S[i] == "E":
    A.append(-1)
    
R = [A[0]]
for i in range(1,N):
  R.append(R[-1] + A[i])


saidai = 0
for i in range(N):
  if i == 0:
    if saidai < R[N-1] - R[0]:
      saidai = R[N-1] - R[0]
      flag = i
  elif i == N-1:
    if saidai < -R[N-2]:
        saidai = -R[N-2]
        flag = i
  else:
    if saidai < (R[N-1] - R[i]) - R[i-1]:
        saidai = (R[N-1] - R[i]) - R[i-1]
        flag = i  
    
ans = A[:flag].count(1) + A[flag+1:].count(-1)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())

def han(X):
  i = 1
  while 1:
    i += 1
    if X**(1/i) == int(X**(1/i)):
      return True
    if X**(1/i) < 1:
      return False
    
while 1:
  if X == 1000:
    print(X)
    break  
  elif han(X):
    print(X)
    break
  X -= 1

Fixed submission:
l = [1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 128, 144, 169, 196, 216, 225, 243, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000]
X = int(input())
while 1:
  if X in l:
    print(X)
    break
  X -= 1
Buggy python submission (verdict: Runtime Error):
A, B, C = list(map(int, input()))
K = int(input())

ans = max(A, B, C) * (2 ** K)

print(ans)

Fixed submission:
A, B, C = list(map(int, input().split()))
K = int(input())

ans = max([A, B, C]) * (2 ** K) - max([A, B, C])

print(ans + A + B + C)

Buggy python submission (verdict: Runtime Error):
A, B, C = list(map(int, input()))
K = int(input())

ans = max(A, B, C) * (2 ** K)

Fixed submission:
A, B, C = list(map(int, input().split()))
K = int(input())

ans = max([A, B, C]) * (2 ** K) - max([A, B, C])

print(ans + A + B + C)
Buggy python submission (verdict: Time Limit Exceeded):
def mid(n):
    return int((n + 1) / 2)

N = int(input())
X = list(map(int, input().split()))
save = X[:]
for i in range(N):
    X = save[:]
    del X[i]
    X.sort()
    print(X[mid(N - 1) - 1])



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

save = X[:]

save.sort()

midL = save[int(N / 2 - 1)]
midR = save[int(N / 2)]

for i in X:
    if i <= midL:
        print(midR)
    else:
        print(midL)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

a.sort()

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
  

sMAX = 1
memo=[a[1],a[0]]
memo2=[a[1],a[0]]
for i in range(n):
  MAX = 1
  for j in range(0, i):
    temp = cmb(a[i], a[j])
            
    if MAX <= temp:
      MAX = temp
      memo = [a[i], a[j]]
    else:
      break
      
  if sMAX < MAX:
    sMAX = MAX
    memo2 = memo
    
for i in range(2):
  print(memo2[i], end=" ")

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()

left = a[-1]
sa = 199999999999999999999999999
for i in range(n):
  if sa > abs((left/2) -a[i]):
    right = a[i]
    sa = abs((left/2) - a[i])
    
print(left, right)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().list()))

a.sort(reverse=True)
ans1 = a[0]
count = 0

if ans1 % 2 == 0:
    mid = int(ans1 / 2)
    if mid in a:
        j = mid

    elif:
        while 1:
            count += 1
            if (mid + count) in a:
                j = mid + count
                break
            elif:
                (mid - count) in a:
                j = mid + count
                break

else:
    while 1:
        count += 1
        if (mid + count) in a:
            j = mid + count
            break
        elif:
            (mid - count) in a:
            j = mid + count
            break

print(ans1, j)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()

left = a[-1]
sa = 199999999999999999999999999
for i in range(n):
  if sa > abs((left/2) -a[i]):
    right = a[i]
    sa = abs((left/2) - a[i])
    
print(left, right)
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if A + B*2 >= C:
    print('Yes')
else:
    print(No)


Fixed submission:
A, B, C = map(int, input().split())
if A + B >= C:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
a = []
for i in range(3):
    a.append(list(input().split()))


answer = ""
for i in range(3):
    answer += str(a[i][i])
print(answer)


Fixed submission:
a = [input() for i in range(3)]

answer = ""
for i in range(3):
    answer += a[i][i]
print(answer)

Buggy python submission (verdict: Runtime Error):
a = []
for i in range(3):
    a.append(list(map(int, input().split())))


answer = ""
for i in range(3):
    answer += str(a[i][i])
print(answer)


Fixed submission:
a = [input() for i in range(3)]

answer = ""
for i in range(3):
    answer += a[i][i]
print(answer)
Buggy python submission (verdict: Runtime Error):
N = int(ipnut())

ans = N // 3
print(ans)


Fixed submission:
N = int(input())

ans = N // 3
print(ans)
Buggy python submission (verdict: Runtime Error):
s = list(map(int, input().split()))
ans = 0
for i in range(3):
    if s[i] == 1:
        ans += 1

print(ans)


Fixed submission:
s = list(input())
ans = 0
for i in range(3):
    if s[i] == '1':
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
N, A, B = list(map(int, input().split()))
ans = max(A * T, B)

print(ans)


Fixed submission:
N, A, B = list(map(int, input().split()))
ans = min(A * N, B)

print(ans)
Buggy python submission (verdict: Runtime Error):
X, Y = list(map(int, input().split()))

X = int(X, 16)
Y = int(Y, 16)

if X < Y:
    ans = '<'

elif X > Y:
    ans = '>'

else:
    print('=')


Fixed submission:
X, Y = list(input().split())


X = int(X, 16)
Y = int(Y, 16)

if X < Y:
    ans = '<'

elif X > Y:
    ans = '>'

else:
    ans = '='

print(ans)
Buggy python submission (verdict: Runtime Error):
C1 = list(input().split())
C2 = list(input().split())

ans = 'Yes'

for i in range(3):
    if C1[i] == C2[-i-1]:
        continue
    else:
        ans = 'No'
print(ans)


Fixed submission:
C1 = list(input())
C2 = list(input())

ans = 'YES'

for i in range(3):
    if C1[i] == C2[-i-1]:
        continue
    else:
        ans = 'NO'
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(iput())
if N < 100:
    ans = '0' + str(N) + 'ABC'
else:
    ans = str(N) + 'ABC'
print(ans)


Fixed submission:
N = int(input())
if N < 100:
    ans = 'ABC' + '0' + str(N)
else:
    ans = 'ABC' + str(N)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
    
A = 0
B = sum(a)

min = B

for i in range(N-1):
     A += a[i]
     B -= a[i]
     
   if min > abs(A - B):
        min = abs(A - B)
    

print(ans)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
    
A = a[0]
B = sum(a[1:])

min = abs(A - B)

for i in range(N-2):
    A += a[i+1]
    B -= a[i+1]

    if min > abs(A - B):
        min = abs(A - B)


print(min)
Buggy python submission (verdict: Runtime Error):
X, A, B = list(map(int, input().split()))

if A > B:
    ans = 'delicious'
elif B - A <= X:
    ans = 'safe'
else:
    'dangerous'

print(ans)


Fixed submission:
X, A, B = list(map(int, input().split()))

if A >= B:
    ans = 'delicious'
elif B - A <= X:
    ans = 'safe'
else:
    ans = 'dangerous'

print(ans)
Buggy python submission (verdict: Runtime Error):
A. B = list(map(int, input().split()))
if A == B:
    ans = 'Draw'
elif A == 1:
    ans = 'Alice'
elif B == 1:
    ans = 'Bob'
else:
    ans = 'Alice' if A > B else 'Bob'

print(ans)


Fixed submission:
A, B = list(map(int, input().split()))
if A == B:
    ans = 'Draw'
elif A == 1:
    ans = 'Alice'
elif B == 1:
    ans = 'Bob'
else:
    ans = 'Alice' if A > B else 'Bob'

print(ans)
Buggy python submission (verdict: Runtime Error):
x = int(input())
ans = 'ABC' if x < 1200 else 'ARC'
prit(ans)


Fixed submission:
x = int(input())
ans = 'ABC' if x < 1200 else 'ARC'
print(ans)
Buggy python submission (verdict: Runtime Error):
if input() in ['a','e','i','o','u'] print('vowel') else print('constant')


Fixed submission:
if input() in ['a','e','i','o','u']:
    print('vowel')
else:
    print('consonant')
Buggy python submission (verdict: Runtime Error):
a, b, c =  list(map(int, input().split()))

ans = (a!=b) + (b!=c) + (c!=a)

ans = 1 if ans == 0

print(ans) 


Fixed submission:
a, b, c =  list(map(int, input().split()))

ans = (a!=b) + (b!=c) + (c!=a)

ans = 1 if ans == 0 else ans

print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c = list(map(int, input().split()))

if (a + b + c == 17) && (a * b * c == 5 * 5 * 7):
    print("YES")
else:
    print("NO")

Fixed submission:
a, b, c = list(map(int, input().split()))

if (a + b + c == 17) and (a * b * c == 5 * 5 * 7):
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
a, b, c = list(map(int, input().split()))

if a + b + c == 17 && a * b * c == 5 * 5 * 7:
    print("YES")
else:
    print("NO")

Fixed submission:
a, b, c = list(map(int, input().split()))

if (a + b + c == 17) and (a * b * c == 5 * 5 * 7):
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())

if a + b + c == 17 && a * b * c == 5 * 5 * 7:
    print("YES")
else:
    print("NO")

Fixed submission:
a, b, c = list(map(int, input().split()))

if (a + b + c == 17) and (a * b * c == 5 * 5 * 7):
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math
N = int(input())

n_max = int(math.sqrt(N))
l = [i for i in range(1, n_max)]
cand = []
score = []
for c in itertools.combinations_with_replacement(l, 3):
  cand.append(c[0]**2 + c[1]**2 + c[2]**2 + c[0]*c[1] + c[0]*c[2] + c[1]*c[2])
  if len(set(c)) == 3:
    score.append(6)
  elif len(set(c)) == 2:
    score.append(3)
  else:
    score.append(1)

for n in range(1, N+1):
  ans = 0
  if n in cand:
    ans += score[cand.index(n)]
  print(ans)

Fixed submission:
import itertools
import math
import numpy as np

N = int(input())

n_max = int(math.sqrt(N))
l = [i for i in range(1, n_max)]
score = np.zeros([10000]).astype(np.uint8)
for c in itertools.combinations_with_replacement(l, 3):
  sum = c[0]**2 + c[1]**2 + c[2]**2 + c[0]*c[1] + c[0]*c[2] + c[1]*c[2]
  if sum <= 10000:
    if len(set(c)) == 3:
      score[sum-1] += 6
    elif len(set(c)) == 2:
      score[sum-1] += 3
    else:
      score[sum-1] += 1
    
for n in range(1, N+1):
  ans = 0
  print(score[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math
N = int(input())
for n in range(1, N+1):
  ans = 0
  n_max = int(math.sqrt(n))
  l = [i for i in range(1, n_max)]
  for c in itertools.combinations_with_replacement(l, 3):
    if n == c[0]**2 + c[1]**2 + c[2]**2 + c[0]*c[1] + c[0]*c[2] + c[1]*c[2]:
      if len(set(c)) == 1:
        ans += 1
      elif len(set(c)) == 2:
        ans += 3
      elif len(set(c)) == 3:
        ans += 6
  print(ans)

Fixed submission:
import itertools
import math
import numpy as np

N = int(input())

n_max = int(math.sqrt(N))
l = [i for i in range(1, n_max)]
score = np.zeros([10000]).astype(np.uint8)
for c in itertools.combinations_with_replacement(l, 3):
  sum = c[0]**2 + c[1]**2 + c[2]**2 + c[0]*c[1] + c[0]*c[2] + c[1]*c[2]
  if sum <= 10000:
    if len(set(c)) == 3:
      score[sum-1] += 6
    elif len(set(c)) == 2:
      score[sum-1] += 3
    else:
      score[sum-1] += 1
    
for n in range(1, N+1):
  ans = 0
  print(score[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math
N = int(input())
for n in range(1, N+1):
  ans = 0
  if n > 5:
    n_max = int(math.sqrt(n))
    l = [i for i in range(1, n_max)]
    for c in itertools.combinations_with_replacement(l, 3):
      if n == c[0]**2 + c[1]**2 + c[2]**2 + c[0]*c[1] + c[0]*c[2] + c[1]*c[2]:
        if len(set(c)) == 1:
          ans += 1
        elif len(set(c)) == 2:
          ans += 3
        elif len(set(c)) == 3:
          ans += 6
  print(ans)

Fixed submission:
import itertools
import math
import numpy as np

N = int(input())

n_max = int(math.sqrt(N))
l = [i for i in range(1, n_max)]
score = np.zeros([10000]).astype(np.uint8)
for c in itertools.combinations_with_replacement(l, 3):
  sum = c[0]**2 + c[1]**2 + c[2]**2 + c[0]*c[1] + c[0]*c[2] + c[1]*c[2]
  if sum <= 10000:
    if len(set(c)) == 3:
      score[sum-1] += 6
    elif len(set(c)) == 2:
      score[sum-1] += 3
    else:
      score[sum-1] += 1
    
for n in range(1, N+1):
  ans = 0
  print(score[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import numpy as np

N, M, X = map(int, input().split())
c_list = []
for _ in range(N):
  c_list.append(list(map(int, input().split())))
  
cand = []
e_list = [i for i in range(N)]
for e in itertools.combinations_with_replacement(e_list, N):
  sum_list = np.zeros(M)
  sum_maney = 0
  for i in set(e):
    sum_list += np.array(c_list[i][1:])
    sum_maney += c_list[i][0]
  flag = True
  for m in range(M):
    if not sum_list[m] >= X:
      flag = False
  if flag:
    cand.append(sum_maney)
if cand == []:
  print(-1)
else:
  print(min(cand))

Fixed submission:
import itertools
import numpy as np
 
N, M, X = map(int, input().split())
c_list = []
for _ in range(N):
  c_list.append(list(map(int, input().split())))
  
cand = []
e_list = [i for i in range(N)]
for n in range(1, N+1):
  for e in itertools.combinations(e_list, n):
    sum_list = np.zeros(M)
    sum_maney = 0
    for i in set(e):
      sum_list += np.array(c_list[i][1:])
      sum_maney += c_list[i][0]
    flag = True
    for m in range(M):
      if not sum_list[m] >= X:
        flag = False
    if flag:
      cand.append(sum_maney)
if cand == []:
  print(-1)
else:
  print(min(cand))
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
H_list = list(map(int, input().split()))
N_list = [[0] * N for _ in range(N)]
for _ in range(M):
  A, B = map(int, input().split())
  N_list[A-1][B-1] = 1
  N_list[B-1][A-1] = 1

def search(N_list, H_list, n, ans):
  w_flag = True
  for i in range(len(N_list[n])):
    if N_list[n][i] == 1:
      if H_list[n] <= H_list[i]:
        w_flag = False
        N_list[n][n] = 1
        if N_list[i][i] != 1:
          ans = search(N_list, H_list, i, ans)
      else:
        N_list[i][i] = 1
  if w_flag:
    ans += 1
    N_list[n][n] = 1
  return ans

ans = 0    
for n in range(N):
  if N_list[n][n] == 0:
    ans = search(N_list, H_list, n, ans)
print(ans)

Fixed submission:
N, M = map(int, input().split())
H_list = list(map(int, input().split()))
N_list = [0] * N
for _ in range(M):
  A, B = map(int, input().split())
  if H_list[A-1] >= H_list[B-1]:
    N_list[B-1] = 1
  if H_list[A-1] <= H_list[B-1]:
    N_list[A-1] = 1
print(N_list.count(0))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
def comb(lis, k):
    l_sum = [sum(pair) for pair in itertools.combinations(lis, k)]
    return len(set(l_sum))
    
n, k = map(int, input().split())
ans = 0
l = [i for i in range(n+1)]
for i in range(k, n+2):
    ans += comb(l, i)
    
mod = 10 ** 9 + 7
print(ans % mod)

Fixed submission:
n, k = map(int, input().split())
ans = 0
mod = 10 ** 9 + 7

n_min = sum([i for i in range(0, k-1)])
n_max = sum([n - i for i in range(0, k-1)])

for i in range(k-1, n+1):
  n_min += i
  n_max += n - i
  ans += n_max - n_min + 1
    
print(ans % mod)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = []
for i in range(0, n) :
	temp = int(input())
	A.append(temp)
flag = True
for i in range(0, n) :
	if A[i] % 2 != 0 :
		continue
	elif A[i] % 2 == 0 and (A[i]%3 == 0 or A[i]%5 == 0) :
		continue
	else :
		flag = False
		break
if flag :
	print ("APPROVED")
else :
	print ("DENIED")

Fixed submission:
n = int(input())
A = [int(x) for x in input().split()]
flag = True
for i in range(0, n) :
	if A[i] % 2 != 0 :
		continue
	elif A[i] % 2 == 0 and (A[i]%3 == 0 or A[i]%5 == 0) :
		continue
	else :
		flag = False
		break
if flag :
	print ("APPROVED")
else :
	print ("DENIED")
Buggy python submission (verdict: Time Limit Exceeded):
def solve(h, k):
    dp = [0]
    for i in range(1, len(h)):
        best = float("inf")
        for j in range(1, min(i, k)+1):
            best = min(best, dp[i - j] + abs(h[i - j] - h[i]))
        dp.append(best)
    return dp[-1]


if __name__ == "__main__":
    n, k = map(int, input().split())
    h = [int(x) for x in input().split()]
    print(solve(h, k))


Fixed submission:
def solve(h, k):
    dp = [0]
    for i in range(1, len(h)):
        best = float("inf")
        for j in range(1, min(i, k)+1):
            best = min(best, dp[i - j] + abs(h[i - j] - h[i]))
        dp.append(best)
    return dp[-1]


if __name__ == "__main__":
    n, k = map(int, input().split())
    h = [int(x) for x in input().split()]
    print(solve(h, k))
Buggy python submission (verdict: Runtime Error):
def checkCanHalf(ary):
  for item in ary:
    if(item % 2 != 0):
      return False
  return True

n = range(int(input()))
ary = map(int, input().split())
cnt = 0

while checkCanHalf(ary) == True:
  for i in range(len(ary)):
    ary[i] = ary[i]/2
  cnt += 1

print(cnt)

Fixed submission:
def checkCanHalf(ary):
  for item in ary:
    if(item % 2 != 0):
      return False
  return True

n = range(int(input()))
ary = list(map(int, input().split()))
cnt = 0

while checkCanHalf(ary) == True:
  for i in range(len(ary)):
    ary[i] = ary[i]/2
  cnt += 1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
def checkCanHalf(ary):
  for item in ary:
    if(item % 2 != 0):
      return False
  return True

n = range(int(input()))
ary = map(int, input().split())
cnt = 0

while checkCanHalf(ary) == True:
  ary = map(lambda x: x / 2, ary)
  cnt += 1

print(cnt)

Fixed submission:
def checkCanHalf(ary):
  for item in ary:
    if(item % 2 != 0):
      return False
  return True

n = range(int(input()))
ary = list(map(int, input().split()))
cnt = 0

while checkCanHalf(ary) == True:
  for i in range(len(ary)):
    ary[i] = ary[i]/2
  cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())

if n%1000 == 0:
  return n//1000
else:
  return 1000 - n%1000

Fixed submission:
n = int(input())

if n%1000 == 0:
  print(0)
else:
  print(1000 - n%1000)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = [0]*Q
C = [0]*Q

for i in range(Q):
    B[i], C[i] = map(str, input().split())

for i in range(Q):
    A = list(map(str, A))
    if B[i] in A:
        A = [a.replace(B[i], C[i]) for a in A]
    
    A = list(map(int, A))
    print(sum(A))

Fixed submission:
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
Q = int(input())

cntA = Counter(A)

ans = sum(A)

for i in range(Q):
    B, C = map(int, input().split())

    ans += cntA[B]*(C - B)
    cntA[C] += cntA[B]
    cntA[B] = 0
    
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = input()

a = list(map(int, input().split()))

total = 1

if str(a) in '0':
	total = 0
else:
	for i in a:
		total *= i

if total > 10**18:
	total = -1

print(total)


Fixed submission:
n = input()
li = list(map(int, input().split())) 

total = 1
li.sort()
for a in li:
    if a == 0:
        total = 0
        break
    total *= a
    if 10 ** 18 < total:
        total = -1
        break
print(total)

Buggy python submission (verdict: Runtime Error):
n = input()

a = list(map(int, input().split()))

total = 1

if a in 0:
	total = 0
else:
	for i in a:
		total *= i

if total > 10**18:
	total = -1

print(total)


Fixed submission:
n = input()
li = list(map(int, input().split())) 

total = 1
li.sort()
for a in li:
    if a == 0:
        total = 0
        break
    total *= a
    if 10 ** 18 < total:
        total = -1
        break
print(total)

Buggy python submission (verdict: Time Limit Exceeded):
import math

n = input()
 
a = list(map(int, input().split()))
 
total = 1
 
for i in a:
	total *= i
 
if total > math.pow(10, 18):
	total = -1
 
print(total)

Fixed submission:
n = input()
li = list(map(int, input().split())) 

total = 1
li.sort()
for a in li:
    if a == 0:
        total = 0
        break
    total *= a
    if 10 ** 18 < total:
        total = -1
        break
print(total)

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
 
a = list(map(int, input().split()))
 
total = 1
 
for i in a:
	total *= i
 
if total > 10**18:
	total = -1
 
print(int(total))

Fixed submission:
n = input()
li = list(map(int, input().split())) 

total = 1
li.sort()
for a in li:
    if a == 0:
        total = 0
        break
    total *= a
    if 10 ** 18 < total:
        total = -1
        break
print(total)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
N, K = map(int, input().split())

if K == 1:
    print(0)
    sys.exit()
while True:
    x = abs(N - K)
    if x > N:
        break
    N = min(x, N)
print(N)

Fixed submission:
N, K = map(int, input().split())

t = N % K
N = min(t, K - t)

print(N)