Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import datetime
import string
import re
import math

K=int(input())
if K % 2 == 0 or K % 5 == 0:
    print("-1")
else:
    s = 7
    count = 1
    while True:
        if s % K == 0:
            print(count)
            break
        else:
            count += 1
            s = 10*s + 7

Fixed submission:
import datetime
import string
import re
import math

K=int(input())
if K % 2 == 0 or K % 5 == 0:
    print("-1")
else:
    s = 7
    count = 1
    while True:
        if s % K == 0:
            print(count)
            break
        else:
            count += 1
            s = (s % K)*10 + 7
Buggy python submission (verdict: Runtime Error):
import datetime
import string
import re
import math

N=int(input())
input = input()
str = []
for i in range(N):
    str.append(input[i])

count = 0
begin = 0
end = len(str) - 1
while True:
    if begin < len(str):
        while str[begin] == 'W':
            begin += 1
            if begin == len(str):
                break

    if end >= 0:
        while str[end] == 'R':
            end -= 1
            if end == -1:
                break

    if begin < end:
        str[begin] = 'R'
        str[end] = 'W'
        begin += 1
        end -= 1
        count += 1
    elif begin == len(str) and end != -1:
        if str[end + 1] == 'R':
            str[end] = 'W'
            end -= 1
            count += 1
        else:
            end -= 1
    elif begin != len(str) and end == -1:
        if str[begin - 1] == 'W':
            str[begin] = 'R'
            begin += 1
            count += 1
        else:
            begin += 1
    else:
        print(count)
        break

Fixed submission:
import datetime
import string
import re
import math

N=int(input())
input = input()
str = []
for i in range(N):
    str.append(input[i])
str.reverse()

count = 0
begin = 0
end = len(str) - 1
while True:
    if begin < len(str):
        while str[begin] == 'W':
            begin += 1
            if begin == len(str):
                break

    if end >= 0:
        while str[end] == 'R':
            end -= 1
            if end == -1:
                break

    if begin < end:
        str[begin] = 'R'
        str[end] = 'W'
        begin += 1
        end -= 1
        count += 1
    elif begin >= len(str) and end > -1:
        if end != len(str) - 1:
            if str[end + 1] == 'R':
                str[end] = 'W'
                end -= 1
                count += 1
            else:
                end -= 1
        else:
            end -= 1
    elif begin < len(str) and end <= -1:
        if begin != 0:
            if str[begin - 1] == 'W':
                str[begin] = 'R'
                begin += 1
                count += 1
            else:
                begin += 1
        else:
            begin += 1
    else:
        print(count)
        break
Buggy python submission (verdict: Runtime Error):
import datetime
import string
import re
import math

aDic = {'ac': 0, 'wa': 0, 'tle': 0, 're': 0}

N = int(input())
for i in range(N):
    aDic[input()] += 1

for page in aDic:
    print(page + ' x ' + str(aDic[page]))


Fixed submission:
import datetime
import string
import re
import math

aDic = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}

N = int(input())
for i in range(N):
    aDic[input()] += 1

for page in aDic:
    print(page + ' x ' + str(aDic[page]))
Buggy python submission (verdict: Runtime Error):
x = int(input())
def ans(x):
    for a in range(0, 1000)[::-1]:
        for b in range(-1000, 1000)[::-1]:
            if a**5 - b**5 == x:
                return a, b
a,b = ans(x)
print(a,b)

Fixed submission:
import bisect
N = int(input())
alist = list(map(int, input().split()))
alist = [0] + alist
sumlist = []
# (j, wj)のリストを作る
for i in range(1,N+1):
    sumlist.append(i+alist[i])
sumlist.sort()
ans = 0
# 差と一致するものを探す
for i in range(1, N+1):
    diff = i - alist[i]
    if diff <= 0:
        continue
    i = bisect.bisect_left(sumlist, diff)
    j = bisect.bisect_right(sumlist, diff)
    ans += j - i
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S= input()
Q = int(input())
rev_cnt = 0

a = "0"
a_rev_cnt = 0
b = "0"
b_rev_cnt = 0

for _ in range(Q):
    query = input()
    if query[0]=="1":
        t = 1
        rev_cnt  = -1*rev_cnt+1
        a,b = b,a

    else:
        t,f,c = query.split()
        if f=="1":
            if rev_cnt ==0:
                a = c+a
            else:
                a = a+c

        elif f=="2":
            if rev_cnt ==0:
                b = b+c
            else:
                b = c+b
if a[0]=="0":
    a = a[::-1]
a = a[:-1]
if b[-1]=="0":
    b = b[::-1]
b = b[1:]


if rev_cnt%2==0:
    ans = a+S+b
else:
    ans = a+S[::-1]+b
print(ans)

Fixed submission:
S= input()
Q = int(input())
rev_cnt = 0

a = "0"
a_rev_cnt = 0
b = "0"
b_rev_cnt = 0

for _ in range(Q):
    query = input()
    if query[0]=="1":
        t = 1
        rev_cnt  = -1*rev_cnt+1
        a,b = b,a

    else:
        t,f,c = query.split()
        if f=="1":
            if rev_cnt ==0:
                a = c+a
            else:
                a = a+c

        elif f=="2":
            if rev_cnt ==0:
                b = b+c
            else:
                b = c+b
if a[0]=="0":
    a = a[::-1]
a = a[:-1]
if b[-1]=="0":
    b = b[::-1]
b = b[1:]


if rev_cnt%2==0:
    ans = a+S+b
else:
    ans = a+S[::-1]+b
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S= input()
Q = int(input())
rev_cnt = 0

a = ""
b = ""

for _ in range(Q):
    query = input()
    if query[0]=="1":
        t = 1
        rev_cnt +=1
        a,b = b[::-1],a[::-1]
    else:
        t,f,c = query.split()
        if f=="1":
            a = c+a
        elif f=="2":
            b = b+c
if rev_cnt%2==0:
    ans = a+S+b
else:
    ans = a+S[::-1]+b
print(ans)

Fixed submission:
S= input()
Q = int(input())
rev_cnt = 0

a = "0"
a_rev_cnt = 0
b = "0"
b_rev_cnt = 0

for _ in range(Q):
    query = input()
    if query[0]=="1":
        t = 1
        rev_cnt  = -1*rev_cnt+1
        a,b = b,a

    else:
        t,f,c = query.split()
        if f=="1":
            if rev_cnt ==0:
                a = c+a
            else:
                a = a+c

        elif f=="2":
            if rev_cnt ==0:
                b = b+c
            else:
                b = c+b
if a[0]=="0":
    a = a[::-1]
a = a[:-1]
if b[-1]=="0":
    b = b[::-1]
b = b[1:]


if rev_cnt%2==0:
    ans = a+S+b
else:
    ans = a+S[::-1]+b
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
K=int(input())

M = len(str(N)) # 桁数

def solve_1(n,m):
    ans = 0
    ans += 9*(m-1)
    x = n//(10**(m-1))
    ans += x
    return ans

def solve_2(n,m):
    ans=0
    if m<1:
        return ans
    elif m>2:
        ans+= (9**2)*int((m-2)*(m-1)/2) 

    x = n//(10**(m-1))
    ans+= (x-1)*(m-1)*9
    ans+= int(str(n)[1])+9*(m-2)
    return ans

def solve_3(n,m):
    ans=0
    if m<2:
        return ans
    elif m>3:
        ans+=int((9**3)*(1/6)*(m-1)*(m-2)*(m-3))
    
    x = n//(10**(m-1))
    ans+=int((x-1)*(m-1)*(m-2)/2*81)
    ans+=solve_2(int(str(n)[1:]),m-1)
    return ans

if K==1:
    ans = solve_1(N,M)
if K==2:
    ans = solve_2(N,M)
if K==3:
    ans = solve_3(N,M)

print(ans)

Fixed submission:
N=int(input())
K=int(input())

M = len(str(N)) # 桁数

def solve_1(n,m):
    ans = 0
    ans += 9*(m-1)
    x = n//(10**(m-1))
    ans += x
    return ans

def solve_2(n,m):
    ans=0
    if m<2:
        return ans
    elif m>2:
        ans+= (9**2)*int((m-2)*(m-1)/2) 

    x = n//(10**(m-1))
    ans+= (x-1)*(m-1)*9

    y=int(str(n)[1:])
    ans+=solve_1(y,len(str(y)))
    # ans+= int(str(n)[1])+9*(m-2)
    return ans

def solve_3(n,m):
    ans=0
    if m<3:
        return ans
    elif m>3:
        ans+=int((9**3)*(1/6)*(m-1)*(m-2)*(m-3))
    
    x = n//(10**(m-1))
    ans+=int((x-1)*(m-1)*(m-2)/2*81)
    
    y= int(str(n)[1:])

    ans+=solve_2(y,len(str(y)))
    return ans

if K==1:
    ans = solve_1(N,M)
if K==2:
    ans = solve_2(N,M)
if K==3:
    ans = solve_3(N,M)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
import numpy as np
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


N = int(input())
A_list = list(map(int,input().split()))
temp_max= 0
for i in range(N):
        temp_list = A_list.copy()
        temp_list.pop(i)
        gcd_temp = gcd(*temp_list)
        if type(gcd_temp)== int:
                gcd_temp = [gcd_temp] 
        if max(gcd_temp)>temp_max:
                temp_max = max(gcd_temp)

print(temp_max)

Fixed submission:
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))

l=[0]*N
r=[0]*N
l[0]=A[0]
r[0]=A[N-1]
for i in range(1,N-1):
   l[i]=gcd(l[i-1],A[i])
   r[i]=gcd(r[i-1],A[N-1-i])
gcdlist = [1,l[N-2],r[N-2]]
for i in range(N-2):
   gcdlist.append(gcd(l[i],r[N-3-i]))

print(max(gcdlist))

Buggy python submission (verdict: Runtime Error):
import math
import numpy as np
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)


N = int(input())
A_list = list(map(int,input().split()))
temp_max= 0
for i in range(N):
        temp_list = A_list.copy()
        temp_list.pop(i)
        gcd_temp = gcd(*temp_list)
        if type(gcd_temp)== int:
                gcd_temp = [gcd_temp] 
        if max(gcd_temp)>temp_max:
                temp_max = max(gcd_temp)

print(temp_max)





Fixed submission:
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))

l=[0]*N
r=[0]*N
l[0]=A[0]
r[0]=A[N-1]
for i in range(1,N-1):
   l[i]=gcd(l[i-1],A[i])
   r[i]=gcd(r[i-1],A[N-1-i])
gcdlist = [1,l[N-2],r[N-2]]
for i in range(N-2):
   gcdlist.append(gcd(l[i],r[N-3-i]))

print(max(gcdlist))
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A_list = list(map(int,input().split()))
neg_num = len([x for x in A_list if x<0])
zero_num = len([x for x in A_list if x==0])
abs_list = [abs(x) for x in A_list]

ans = np.sum(abs_list)
if neg_num%2==0 or zero_num>0:
    ans = ans
elif n%2!=0:
    ans = ans - min(abs_list)
print(ans)

Fixed submission:
import numpy as np
N = int(input())
A_list = list(map(int,input().split()))
neg_num = len([x for x in A_list if x<0])
zero_num = len([x for x in A_list if x==0])
abs_list = [abs(x) for x in A_list]

ans = np.sum(abs_list)
if neg_num%2==0 or zero_num>0:
    ans = ans
elif neg_num%2!=0:
    ans = ans - 2*min([x for x in abs_list if x!=0])
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
listA = list(map(int, input().split()))
c = [0,2,5,5,4,5,6,3,7,6]
dp = [-1]*N
dp[0] = 0
for j in range(1, N+1):
	for a in listA:
		if j-c[a] >= 0:
			dp[j] = max(dp[j], dp[j-c[a]]*10+a)
print(dp[N])

Fixed submission:
N, M = map(int, input().split())
listA = list(map(int, input().split()))
c = [0,2,5,5,4,5,6,3,7,6]
dp = [-1]*10010
dp[0] = 0
for j in range(1, N+1):
	for a in listA:
		if j-c[a] >= 0:
			dp[j] = max(dp[j], dp[j-c[a]]*10+a)
print(dp[N])
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = list(map(int,input().split())) #準備度
B = list(map(int,input().split())) #試験

A = np.array(A)
B = np.array(B)


sumA = sum(A)
sumB = sum(B)

if sumA < sumB:
    print(-1)
else:
    gap = A - B
    minus = gap[gap<0]
    numminus = len(gap[gap<0])
    if numminus == 0:
        print(0)
    else:
        needs = - minus.sum()
        sortgap = np.sort(gap)[::-1]
        s = 0
        for i in range(N):
            s += sortgap[i]
            if s >= needs:
                changedplus = i+1
                break
        print(changedplus + numminus)

Fixed submission:
nums = list(map(int,input().split()))
flag1 = 1 in nums and 9 in nums and 7 in nums and 4 in nums
if flag1 == True:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
nums = list(map(int,input().split()))
flag1 = 1 in nums and 9 in nums and 7 in nums and 4 in nums
if flag1 == True:
   print(“YES”)
else:
   print(“NO”)

Fixed submission:
nums = list(map(int,input().split()))
flag1 = 1 in nums and 9 in nums and 7 in nums and 4 in nums
if flag1 == True:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
from skimage import measure

Fixed submission:
n = int(input())
h = int(input())
w = int(input())
print((n-h+1)*(n-w+1))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a, b = map(int,input().split())
listP=list(map(int,input().split()))
num0 = sum(listP<=a)
num1 = sum(listP<=b) - num0
num2 = sum(listP>b)
print(min([num0,num1,num2]))

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

a = listAB[0]
b = listAB[1]

num0 = sum([1 for p in listP if p <=a])
num2 = sum([1 for p in listP if p > b])
num1 = n - num0 -num2
print(min([num0,num1,num2]))
Buggy python submission (verdict: Time Limit Exceeded):
N, K  = map(int,input().split())
h_list = list(map(int,input().split()))

INF = 100001010000100
dp = [INF]*N
dp[0] = 0

for i in range(1,N):
    start = max(0,i-K)
    dp[i] = min([dp[j]+abs(h_list[i]-h_list[j]) for j in range(start,i)])

print(dp[N-1])

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

INF = 100001010000100
dp = [INF]*N
dp[0] = 0

for i in range(1,N):
    start = max(0,i-K)
    dp[i] = min([dp[j]+abs(h_list[i]-h_list[j]) for j in range(start,i)])

print(dp[N-1])
Buggy python submission (verdict: Runtime Error):
N = int(input())

happiness = list(map(int,input().split()))
dp = happiness # dp: i日目にa~cそれぞれの活動をしたときの幸福度の最大値

for i in range(1,N):
    happiness = list(map(int,input().split()))
    dp_pre = dp.copy()

    dp[0] = max(dp_pre[1],dp_pre[2])+happiness[0] # i日目にaをする場合
    dp[1] = max(dp_pre[0],dp_pre[2])+happiness[1] # i日目にbをする場合
    dp[2] = max(dp_pre[1],dp_pre[0])+happiness[2] # i日目にcをする場合
     
print(max(dp))


Fixed submission:
N = int(input())

happiness = list(map(int,input().split()))
dp = happiness # dp: i日目にa~cそれぞれの活動をしたときの幸福度の最大値

for i in range(1,N):
    happiness = list(map(int,input().split()))
    dp_pre = dp.copy()

    dp[0] = max(dp_pre[1],dp_pre[2])+happiness[0] # i日目にaをする場合
    dp[1] = max(dp_pre[0],dp_pre[2])+happiness[1] # i日目にbをする場合
    dp[2] = max(dp_pre[1],dp_pre[0])+happiness[2] # i日目にcをする場合
     
print(max(dp))

Buggy python submission (verdict: Runtime Error):
N = int(input())

happiness = list(map(int,input().split()))
dp = happiness # dp: i日目にa~cそれぞれの活動をしたときの幸福度の最大値

for i in range(1,N):
    happiness = list(map(int,input().split()))
    dp_pre = dp.copy()

    dp[0] = max(dp_pre[1],dp_pre[2])+happiness[0] # i日目にaをする場合
    dp[1] = max(dp_pre[0],dp_pre[2])+happiness[1] # i日目にbをする場合
    dp[2] = max(dp_pre[1],dp_pre[0])+happiness[2] # i日目にcをする場合
     
print(max(dp))


Fixed submission:
N = int(input())

happiness = list(map(int,input().split()))
dp = happiness # dp: i日目にa~cそれぞれの活動をしたときの幸福度の最大値

for i in range(1,N):
    happiness = list(map(int,input().split()))
    dp_pre = dp.copy()

    dp[0] = max(dp_pre[1],dp_pre[2])+happiness[0] # i日目にaをする場合
    dp[1] = max(dp_pre[0],dp_pre[2])+happiness[1] # i日目にbをする場合
    dp[2] = max(dp_pre[1],dp_pre[0])+happiness[2] # i日目にcをする場合
     
print(max(dp))
Buggy python submission (verdict: Time Limit Exceeded):
### LCS 
# dp[i][j]: s[i],t[j]までの最長部分文字列の長さ
# s[i]==t[j]だったらs[i-1][j-1]+1,
# それ以外の場合はmax(s[i-1][j],s[i][j-1])

s= input()
t= input()

dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]
for i, si in enumerate(s):
    for j, tj in enumerate(t):
        if si==tj:
            dp[i+1][j+1]=dp[i][j]+1
        else:
            dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])

ans =""
n = dp[-1][-1]
i = len(s)
j =len(t)
while n >0:
    if dp[i][j]==dp[i-1][j]:
        i-= 1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    elif dp[i][j]==dp[i-1][j-1]+1:
        ans = s[i-1]+ans
        n-=1
        i-=1
        j-=1

print(ans)



Fixed submission:
### LCS 
# dp[i][j]: s[i],t[j]までの最長部分文字列の長さ
# s[i]==t[j]だったらs[i-1][j-1]+1,
# それ以外の場合はmax(s[i-1][j],s[i][j-1])

s= input()
t= input()

dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]
for i, si in enumerate(s):
    for j, tj in enumerate(t):
        if si==tj:
            dp[i+1][j+1]=dp[i][j]+1
        else:
            dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])

ans =""
n = dp[-1][-1]
i = len(s)
j =len(t)
while n >0:
    if dp[i][j]==dp[i-1][j]:
        i-= 1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    elif dp[i][j]==dp[i-1][j-1]+1:
        ans = s[i-1]+ans
        n-=1
        i-=1
        j-=1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
input()
nums = list(map(int,input().split()))

if nums.count(0):
    print(0)
    exit(0)

result=1
for i in nums:
    result *= i

if result > (10**18):
    print(-1)
else:
    print(result)

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

if nums.count(0):
    print(0)
    exit(0)

result=1
for i in nums:
    result *= i
    if result > (10**18):
        print(-1)
        exit(0)
print(result)

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

if 0 in nums:
    print(0)
    exit 0

result=1
for i in nums:
    result *= i

if result > (10**18):
    print(-1)
else:
    print(result)

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

if nums.count(0):
    print(0)
    exit(0)

result=1
for i in nums:
    result *= i
    if result > (10**18):
        print(-1)
        exit(0)
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
input()
nums = map(int,input().split())

result=1
for i in nums:
    result *= i

if result > (10**18):
    print(-1)
else:
    print(result)

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

if nums.count(0):
    print(0)
    exit(0)

result=1
for i in nums:
    result *= i
    if result > (10**18):
        print(-1)
        exit(0)
print(result)
Buggy python submission (verdict: Runtime Error):
import math
import sys

antenas = []
for i in range(5):
    antenas.append(int(input()))
k = int(input())

for f in antenas:
    for d in antenas:
        if abs(f-d) > k:
            print(":(")
            sys.exit(-1)

print("Yay!")

Fixed submission:
import math
import sys

antenas = []
for i in range(5):
    antenas.append(int(input()))
k = int(input())

for f in antenas:
    for d in antenas:
        if abs(f-d) > k:
            print(":(")
            sys.exit(0)

print("Yay!")
Buggy python submission (verdict: Runtime Error):
A, B, K = [int(x) for x in input().split(" ")]

warikiru = []
for i in range(1, min([A,B])):
    if A % i == 0 and B % i == 0:
        warikiru.append(i)

if warikiru == []:
    print(1)
else:
    print(warikiru[-1::-1][K-1])

Fixed submission:
A, B, K = [int(x) for x in input().split(" ")]

warikiru = []
for i in range(1, min([A,B])+1):
    if A % i == 0 and B % i == 0:
        warikiru.append(i)

warikiru.reverse()
print(warikiru[K-1])

Buggy python submission (verdict: Runtime Error):
A, B, K = [int(x) for x in input().split(" ")]

warikiru = []
for i in range(1, max([A,B])):
    if A % i == 0 and B % i == 0:
        warikiru.append(i)

if warikiru == []:
    print(1)
else:
    print(warikiru[-1::-1][K-1])

Fixed submission:
A, B, K = [int(x) for x in input().split(" ")]

warikiru = []
for i in range(1, min([A,B])+1):
    if A % i == 0 and B % i == 0:
        warikiru.append(i)

warikiru.reverse()
print(warikiru[K-1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
tmp = input()
an = []
for t in tmp.split():
    an.append(int(t))

while True:
    # 最小値を抽出する
    # 最小値以外の要素に対し、int(tmp/min)*minを引く
    min_tmp = 0
    for i in range(len(an)):
        if(an[i] < an[min_tmp] and an[i] > 0):
            min_tmp = i

    # i_min = an.index(min(an))
    i_min = min_tmp
    for i in range(len(an)):
        if i == i_min:
            continue
        an[i] = an[i] - int(an[i]/an[i_min]) * an[i_min]

    flag = True
    for i in range(len(an)):
        if(an[i] > 0 and not i == i_min):
            flag = False
    if flag:
        break

print(an[i_min])

Fixed submission:
a,b = [int(x) for x in input().split()]
if b % a == 0:
    print(a+b)
else:
    print(b-a)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split()]
count = 0
judge = False

#奇数
odd = []
#偶数
even = []

# 奇数と偶数に分ける
for i_a in range(len(a)):
    if(a[i_a] % 2 == 0):
        even.append(a[i_a])
    else:
        odd.append(a[i_a])
# もし偶数がいない場合は操作不可能
if(even == []):
    print(0)
    exit()

# 偶数を一つ取り出し、2で割る。次で割れなくなるなら削除
max_odd = max(odd)
while True:
    count += 1
    even[0] /= 2
    if(even[0] % 2 != 0):
        even.pop(0)
    if(even == []):
        break
        

print(count)


# while True:
#     for i_a in range(len(a)):
#         judge = False
#         if(a[i_a] % 2 == 0):
#             a[i_a] /= 2
#             count += 1
#             judge = True
#             break
#         else:
#             a[i_a] *= 3
        
#     if(not judge):
#         print(count)
#         print(a)
#         exit()


# while True:
#     for i_a in range(len(a)):
#         judge = False
#         if(a[i_a] % 2 == 0):
#             a[i_a] /= 2
#             judge = True
#             break
#         else:
#             a[i_a] *= 3
        
#     if(not judge):
#         print(count)
#         exit()
#     else:
#         count += 1

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
count = 0
judge = False

#奇数
odd = []
#偶数
even = []

# 奇数と偶数に分ける
for i_a in range(len(a)):
    if(a[i_a] % 2 == 0):
        even.append(a[i_a])
    else:
        odd.append(a[i_a])
# もし偶数がいない場合は操作不可能
if(even == []):
    print(0)
    exit()

# 偶数を一つ取り出し、2で割る。次で割れなくなるなら削除
while True:
    count += 1
    even[0] /= 2
    if(even[0] % 2 != 0):
        even.pop(0)
    if(even == []):
        break
        

print(count)


# while True:
#     for i_a in range(len(a)):
#         judge = False
#         if(a[i_a] % 2 == 0):
#             a[i_a] /= 2
#             count += 1
#             judge = True
#             break
#         else:
#             a[i_a] *= 3
        
#     if(not judge):
#         print(count)
#         print(a)
#         exit()


# while True:
#     for i_a in range(len(a)):
#         judge = False
#         if(a[i_a] % 2 == 0):
#             a[i_a] /= 2
#             judge = True
#             break
#         else:
#             a[i_a] *= 3
        
#     if(not judge):
#         print(count)
#         exit()
#     else:
#         count += 1
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
if a != 0 and a != 50:
    a = a+1
if b != 0 and b != 50:
    b = b+1
if c != 0 and c != 50:
    c = c+1
for i_a in range(a):
    for j_b in range(b):
        for k_c in range(c):
            if(i_a * 500 + j_b * 100 + k_c * 50 == x):
                count = count + 1
if a == b == c == 0:
    count = count + 1
print(count)


Fixed submission:
x = int(input())
a = int(input())
b = int(input())

print((x-a) - (x-a)//b*b)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = list(map(int, input().split(' ')))
ans = 1
for i in range(0, len(lst)):
  ans *= lst[i]
if ans > 1000000000000000000:
  print("-1")
else:
  print(ans)

Fixed submission:
import sys

if __name__ == "__main__":
    a = int(input())
    n = list(map(int, input().strip().split(' ')))
    ans = 1
    n.sort()
    for i in n:
      ans *= i
      if ans > 10**18:
          break
    if ans > 10**18:
        print(-1)
    else:
        print(ans)
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split(' '))
lst = []
for i in range(n):
  lst.append(int(input()))
  lst.sort()
  minn = 999999999999
  for i in range(0, n-x+1):
    if lst[i+x]-lst[i] < minn:
      minn = lst[i+x] - lst[i]
  print(minn)

Fixed submission:
n, m = map(int, input().split(' '))
lst = [int(input()) for i in range(n)]
lst.sort()
print(min(lst[i+m-1]-lst[i] for i in range(n-m+1)))
Buggy python submission (verdict: Runtime Error):
    ans = 0
    for i in input():
        if i == '1':
            ans += 1
    print(ans)

Fixed submission:
ans = 0
for i in input():
    if i == '1':
        ans += 1
print(ans)