Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#coding: utf-8
def factorial(n):
	output = 1
	for i in range(1,n+1):
		output = output*i
	return output

def diff(w, sign, N):
	diff = 0
	for i in range(N):
		diff = diff + w[i]*sign[i]
	return abs(diff)

def target(sign, cnt, N, factwo):
	num = cnt
	for i in reversed(range(N)):
		temp = num - factwo[i]
		if(temp >= 0):
			sign[i] = 1
		else:
			sign[i] = -1
		num = temp

N = int(input())
#N = 8
line = input()
#line = '27 23 76 2 3 5 62 52'
w = []
sign = []
factwo = []
for i in range(N):
	factwo.append(2**i)

for i in range(N):
	w.append(int(line.split()[i]))
	sign.append(1)

cnt = 0
temp = diff(w, sign, N)

while(cnt<factorial(N)):
	target(sign, cnt, N, factwo)
	x = diff(w, sign, N)
	if(temp > x):
		temp = x
	cnt = cnt + 1
	if(diff == 0):
		break

print(temp)

Fixed submission:
#coding: utf-8

line = input()
arr = []
for i in range(3):
	arr.append(int(line.split()[i]))
ans = sum(arr) - max(arr)
print(ans)

Buggy python submission (verdict: Runtime Error):
#coding: utf-8

line = input()
for i in range(3):
	arr.append(int(line.split()[i]))
ans = sum(arr) - max(arr)
print(ans)



Fixed submission:
#coding: utf-8

line = input()
arr = []
for i in range(3):
	arr.append(int(line.split()[i]))
ans = sum(arr) - max(arr)
print(ans)
Buggy python submission (verdict: Runtime Error):
if int(input()) == 1:
 print 'Hello World'
else:
 A = int(input())
 B = int(input())
 C = A + B
 print C

Fixed submission:
#coding: utf-8

if int(input()) == 1:
    print ('Hello World')
else:
    A = int(input())
    B = int(input())
    print (A+B)

Buggy python submission (verdict: Runtime Error):
#coding: utf-8

if int(input()) == 1:
 print 'Hello World'
else:
 A = int(input)
 B = int(input)
 C = A + B
 print C

Fixed submission:
#coding: utf-8

if int(input()) == 1:
    print ('Hello World')
else:
    A = int(input())
    B = int(input())
    print (A+B)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in n:
    ans += 1 / i
print(1 / ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    ans += 1 / a[i]
print(1 / ans)
Buggy python submission (verdict: Runtime Error):
import math
a, b, c, d = map(int, input().split())
lc = int (c * d / math.gcd(c, d))
def num(x):
    return x - x // c - x // d + x // lc
print(int(num(b) - num(a - 1)))


Fixed submission:
from fractions import gcd
a, b, c, d = map(int, input().split())
lc = int (c * d / gcd(c, d))
def num(x):
    return x - x // c - x // d + x // lc
print(int(num(b) - num(a - 1)))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))

score = 1
for a in A[:K]:
    score *= a

for i in range(K, N):
    tmp = score
    tmp //= A[i-K]
    tmp *= A[i]
    
    if tmp > score:
        print('Yes')
    else:
        print('No')

    score = tmp

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

for i in range(N-K):
    if A[i+K] > A[i]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
from itertools import (
    accumulate,  # 累積和のイテレータ
    groupby,  # 値をkey,同じ値の集まりをgroup
    permutations,  # 順列
    combinations,  # 組み合わせ
    product,  # 重複あり順列（直積, 深いネストにも使える）
    combinations_with_replacement,  # 重複あり組み合わせ
)

N = int(input())

ans = [0] * (10**9)

for i, j, k in product(list(range(1, 101)), repeat=3):
    tmp = i**2 + j**2 + k**2 + i*j + j*k + k*i
    ans[tmp] += 1

for i in range(1, N+1):
    print(ans[i])


Fixed submission:
from itertools import (
    accumulate,  # 累積和のイテレータ
    groupby,  # 値をkey,同じ値の集まりをgroup
    permutations,  # 順列
    combinations,  # 組み合わせ
    product,  # 重複あり順列（直積, 深いネストにも使える）
    combinations_with_replacement,  # 重複あり組み合わせ
)

N = int(input())

ans = [0] * (10**5)

for i, j, k in product(list(range(1, 101)), repeat=3):
    tmp = i**2 + j**2 + k**2 + i*j + j*k + k*i
    ans[tmp] += 1

for i in range(1, N+1):
    print(ans[i])

Buggy python submission (verdict: Runtime Error):
from itertools import (
    accumulate,  # 累積和のイテレータ
    groupby,  # 値をkey,同じ値の集まりをgroup
    permutations,  # 順列
    combinations,  # 組み合わせ
    product,  # 重複あり順列（直積, 深いネストにも使える）
    combinations_with_replacement,  # 重複あり組み合わせ
)

N = int(input())

ans = [0] * (10**9)

for i, j, k in product(range(1, 101), repeat=3):
    tmp = i**2 + j**2 + k**2 + i*j + j*k + k*i
    ans[tmp] += 1

for i in range(1, N+1):
    print(ans[i])


Fixed submission:
from itertools import (
    accumulate,  # 累積和のイテレータ
    groupby,  # 値をkey,同じ値の集まりをgroup
    permutations,  # 順列
    combinations,  # 組み合わせ
    product,  # 重複あり順列（直積, 深いネストにも使える）
    combinations_with_replacement,  # 重複あり組み合わせ
)

N = int(input())

ans = [0] * (10**5)

for i, j, k in product(list(range(1, 101)), repeat=3):
    tmp = i**2 + j**2 + k**2 + i*j + j*k + k*i
    ans[tmp] += 1

for i in range(1, N+1):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

if sum(A) <= K:
    a_max = N
    ans = N

else:
    a_total = 0
    for i in range(N):
        a_total += A[i]
        if a_total > K:
            break
    a_max = i
    ans = a_max


for i in range(a_max+1)[::-1]:
    total = sum(A[:i])
    #print('b total: ', total)
    if total + sum(B) <= K:
        ans = max(ans, i + M)
    else:
        for j in range(M):
            total += B[j]
            #print('a total: ', total)
            if total > K:
                flag = True
                break
        ans = max(ans, i + j)
    #print('ans: ', ans)
    #print()

print(ans)

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

a, b = [0]*N, [0]*M

total = 0
for i in range(N):
    total += A[i]
    a[i] = total

a = [0] + a

total = 0
for i in range(M):
    total += B[i]
    b[i] = total

b = [0] + b

ans, j = 0, M
for i in range(N+1):
    if a[i] > K:
        break
    while b[j] + a[i] > K:
        j -= 1
    #print(a[i], b[j], i, j)
    ans = max(ans, i + j)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

flag = False
a_total = 0
for i in range(N):
    a_total += A[i]
    if a_total > K:
        flag = True
        break

if flag:
    a_max = i
    ans = a_max
else:
    a_max = N
    ans = N

for i in range(a_max+1)[::-1]:
    total = sum(A[:i])
    #print('b total: ', total)
    flag = False
    for j in range(M):
        total += B[j]
        #print('a total: ', total)
        if total > K:
            flag = True
            break
    if flag:
        ans = max(ans, i + j)
    else:
        ans = max(ans, i + j + 1)
    #print('ans: ', ans)
    #print()

print(ans)

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

a, b = [0]*N, [0]*M

total = 0
for i in range(N):
    total += A[i]
    a[i] = total

a = [0] + a

total = 0
for i in range(M):
    total += B[i]
    b[i] = total

b = [0] + b

ans, j = 0, M
for i in range(N+1):
    if a[i] > K:
        break
    while b[j] + a[i] > K:
        j -= 1
    #print(a[i], b[j], i, j)
    ans = max(ans, i + j)

print(ans)
Buggy python submission (verdict: Runtime Error):
X = int(input())
rad = 90
cnt = 0

while True:
    cnt += 1
    if rad==360:
        break
    else:
        rad += X
        rad = rad if rad < 360 else rad = 360

print(cnt)

Fixed submission:
X = int(input())

eikaku = X if X < 180 else X - 180
cnt = 0

ans = 0
while True:
    ans += 1
    cnt += eikaku
    if cnt % 360 == 0:
        print(ans)
        break
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

A = sorted(A)
maxi = 2*(10**5)+1
dp = [0] * maxi

for i in range(N):
    tmp = A[i]
    if dp[tmp] != 0:
        dp[tmp] = 2
        continue
    else:
        for j in range(tmp, maxi, tmp):
            dp[j] += 1

ans = 0
for i in range(N):
    tmp = A[i]
    if dp[tmp] == 1:
        ans += 1

print(ans)

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

A = sorted(A)
maxi = 10**6+1
dp = [0] * maxi

for i in range(N):
    tmp = A[i]
    if dp[tmp] != 0:
        dp[tmp] = 2
        continue
    else:
        for j in range(tmp, maxi, tmp):
            dp[j] += 1

ans = 0
for i in range(N):
    tmp = A[i]
    if dp[tmp] == 1:
        ans += 1

print(ans)

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

A = sorted(A, key=lambda x: x[0])
maxi = 2*(10**5)+1
dp = [0] * maxi

for i in range(N):
    tmp = A[i]
    if dp[tmp] != 0:
        dp[tmp] = 2
        continue
    else:
        for j in range(tmp, maxi, tmp):
            dp[j] += 1

ans = 0
for i in range(N):
    tmp = A[i]
    if dp[tmp] == 1:
        ans += 1

print(ans)

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

A = sorted(A)
maxi = 10**6+1
dp = [0] * maxi

for i in range(N):
    tmp = A[i]
    if dp[tmp] != 0:
        dp[tmp] = 2
        continue
    else:
        for j in range(tmp, maxi, tmp):
            dp[j] += 1

ans = 0
for i in range(N):
    tmp = A[i]
    if dp[tmp] == 1:
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
from numba import jit
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))

@jit   # 高速化
def imo(a, n):
    imos = np.zeros(n+1)
    for i in range(n):
        imos[max(0, i-a[i])] += 1
        imos[min(n, i+a[i])+1] -= 1

    # 累計和はnumpyの方が高速
    immo = np.zeros(n+1)
    immo = np.cumsum(imos)

    return immo[:n]


for _ in range(min[K, 41]):
    A = imo(A, N)

print(*A)

Fixed submission:
import numpy as np
from numba import jit
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())), dtype=np.int64)

# 高速化
@jit
def imo(a, n):
    imos = np.zeros(n+1, dtype=np.int64)
    for i in range(n):
        imos[max(0, i-a[i])] += 1
        imos[min(n, i+a[i])+1] -= 1

    # 累計和はnumpyの方が高速
    immo = np.zeros(n+1, dtype=np.int64)
    immo = np.cumsum(imos)

    return immo[:n]


for _ in range(min(K, 41)):
    A = imo(A, N)

print(*A)
Buggy python submission (verdict: Runtime Error):
from math import ceil, floor
from decimal import Decimal

A, B = input().split()
A = int(A)
B = float(B)
B1 = int(B)
B2 = int(str(B)[-2:])

ans1 = Decimal(A) * Decimal(B1)
ans2 = Decimal(A) * Decimal(B2) // 100

ans = ans1 + ans2
print(ans)

Fixed submission:
from math import ceil, floor, modf

A, B = input().split()
A = int(A)

B1 = int(B[:-3])
B2 = int(str(B)[-2:])

ans1 = A * B1
ans2 = A * B2 // 100

ans = ans1 + ans2
print(floor(ans))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import (
    accumulate,  # 累積和のイテレータ
    groupby,  # 値をkey,同じ値の集まりをgroup
    permutations,  # 順列
    combinations,  # 組み合わせ
    product,  # 重複あり順列（直積, 深いネストにも使える）
    combinations_with_replacement,  # 重複あり組み合わせ
)

N, M, X = map(int, input().split())
book = [list(map(int, input().split())) for _ in range(N)]

def check(tisiki):
    cnt = 0
    for t in tisiki:
        if t<X:
            return False
    return True

ans = 10**9
for v in permutations(list(range(N))):
    tisiki = [0] * M
    cost = 0
    for i in v:
        b = book[i]
        cost += b[0]
        for t in range(M):
            tisiki[t] += b[t+1]
        
        if check(tisiki):
            ans = min(ans, cost)
            break

if ans < 10**9:
    print(ans)
else:
    print(-1)

Fixed submission:
import numpy as np

N, M, X = map(int, input().split())
book = [list(map(int, input().split())) for _ in range(N)]

ans = 10**9

for i in range(1<<N):
    cost = 0
    tisiki = np.array([0]*M)
    cond = [0]*N
    for j in range(N):
        if 1&(i>>j):  # 右シフトして論理積（bit全探索）
            cond[j] = 1
    
    for k in range(N):
        if cond[k]==1:
            b = book[k]
            cost += b[0]
            tisiki += np.array(b[1:])
    
    if np.all(tisiki>=X):
        ans = min(ans, cost)

if ans < 10**9:
    print(ans)
else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import (
    accumulate,  # 累積和のイテレータ
    groupby,  # 値をkey,同じ値の集まりをgroup
    permutations,  # 順列
    combinations,  # 組み合わせ
    product,  # 重複あり順列（直積, 深いネストにも使える）
    combinations_with_replacement,  # 重複あり組み合わせ
)

N, M, X = map(int, input().split())
book = [list(map(int, input().split())) for _ in range(N)]

def check(tisiki):
    cnt = 0
    for t in tisiki:
        if t<X:
            return False
    return True

ans = 10**9
for v in permutations(list(range(N))):
    tisiki = [0] * M
    cost = 0
    for i in v:
        b = book[i]
        cost += b[0]
        for t in range(M):
            tisiki[t] += b[t+1]
        
        if check(tisiki):
            ans = min(ans, cost)

if ans < 10**9:
    print(ans)
else:
    print(-1)

Fixed submission:
import numpy as np

N, M, X = map(int, input().split())
book = [list(map(int, input().split())) for _ in range(N)]

ans = 10**9

for i in range(1<<N):
    cost = 0
    tisiki = np.array([0]*M)
    cond = [0]*N
    for j in range(N):
        if 1&(i>>j):  # 右シフトして論理積（bit全探索）
            cond[j] = 1
    
    for k in range(N):
        if cond[k]==1:
            b = book[k]
            cost += b[0]
            tisiki += np.array(b[1:])
    
    if np.all(tisiki>=X):
        ans = min(ans, cost)

if ans < 10**9:
    print(ans)
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**9)

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

log = []

def func(x, iter):
    x = A[x-1]

    if iter+1 == K:
        return x
    if x in log:
        ix = log.index(x)
        loop = log[ix:]
        tmp = (K-iter-1)%len(loop)
        return loop[tmp]
    else:
        log.append(x)
        iter += 1
        return func(x, iter)

print(func(1, 0))

Fixed submission:
import sys
sys.setrecursionlimit(10**9)

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

log = []
check = [False]*N

def func(x, iter):
    x = A[x-1]

    if iter+1 == K:
        return x
    if check[x-1]:
        ix = log.index(x)
        loop = log[ix:]
        tmp = (K-iter-1)%len(loop)
        return loop[tmp]
    else:
        log.append(x)
        check[x-1] = True
        iter += 1
        return func(x, iter)

print(func(1, 0))

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)

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

log = []

def func(x, iter):
    x = A[x-1]

    if iter+1 == K:
        return x
    if x in log:
        tmp = K%(iter+1)
        return log[tmp]
    else:
        log.append(x)
        iter += 1
        return func(x, iter)

print(func(1, 0))

Fixed submission:
import sys
sys.setrecursionlimit(10**9)

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

log = []
check = [False]*N

def func(x, iter):
    x = A[x-1]

    if iter+1 == K:
        return x
    if check[x-1]:
        ix = log.index(x)
        loop = log[ix:]
        tmp = (K-iter-1)%len(loop)
        return loop[tmp]
    else:
        log.append(x)
        check[x-1] = True
        iter += 1
        return func(x, iter)

print(func(1, 0))
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
SWITCH = False

for i in range(Q):
    v = list(input().split())
    if v[0] == '1':
        if SWITCH:
            SWITCH = False
        else:
            SWITCH = True

    else:
        if v[1] == '1':
            if SWITCH==False:
                S = v[2] + S
            else:
                S = S + v[2]
        else:
            if SWITCH==False:
                S = S + v[2]
            else:
                S = v[2] + S

if SWITCH:
    print(S[::-1])
else:
    print(S)

Fixed submission:
from collections import deque

S = deque(input())
Q = int(input())
SWITCH = False

for i in range(Q):
    v = list(input().split())
    if v[0] == '1':
        SWITCH = not SWITCH

    else:
        if v[1] == '1':
            if SWITCH==False:
                S.appendleft(v[2])
            else:
                S.append(v[2])
        else:
            if SWITCH==False:
                S.append(v[2])
            else:
                S.appendleft(v[2])

S = ''.join(S)

if SWITCH:
    print(S[::-1])
else:
    print(S)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
query = [list(input().split()) for _ in range(Q)]

for i in range(Q):
    v = query[i]
    if v[0] == '1':
        S = S[::-1]
    else:
        if v[1] == '1':
            S = v[2] + S
        else:
            S = S + v[2]

print(S)

Fixed submission:
from collections import deque

S = deque(input())
Q = int(input())
SWITCH = False

for i in range(Q):
    v = list(input().split())
    if v[0] == '1':
        SWITCH = not SWITCH

    else:
        if v[1] == '1':
            if SWITCH==False:
                S.appendleft(v[2])
            else:
                S.append(v[2])
        else:
            if SWITCH==False:
                S.append(v[2])
            else:
                S.appendleft(v[2])

S = ''.join(S)

if SWITCH:
    print(S[::-1])
else:
    print(S)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
st = {}

maxi = 0

for _ in range(n):
    s = input()

    if s in st:
        st[s] += 1
    else:
        st[s] = 1

    if st[s] > maxi:
        maxi = st[s]

max_k = sorted([kv[0] for kv in st.items() if kv[1] == max(st.values())])

for k in max_k:
    print(k)

Fixed submission:
n = int(input())
st = {}

maxi = 0

for _ in range(n):
    s = input()

    if s in st:
        st[s] += 1
    else:
        st[s] = 1

    if st[s] > maxi:
        maxi = st[s]

ans = []
for k, v in st.items():
    if v==maxi:
        ans.append(k)

ans = sorted(ans)
for a in ans:
    print(a)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = list(map(int, input().split()))

p_mean = [(i+1)/2 for i in p]

p_ruikei = [0] * n
p_ruikei[0] =  p_mean[0]

for i in range(1, n):
    p_ruikei[i] = p_ruikei[i-1] + p_mean[i]

maxx = 0
for i in range(i-k+1):

    if i==0:
        mean = p_ruikei[i+k-1]
    else:
        mean = p_ruikei[i+k-1] - p_ruikei[i-1]

    if mean > maxx:
        maxx = mean

print(maxx)

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

p_mean = [(i+1)/2 for i in p]

p_ruikei = [0] * n
p_ruikei[0] =  p_mean[0]

for i in range(1, n):
    p_ruikei[i] = p_ruikei[i-1] + p_mean[i]

maxx = p_ruikei[k-1]
for i in range(1, n-k+1):
    mean = p_ruikei[i+k-1] - p_ruikei[i-1]

    if mean > maxx:
        maxx = mean

print(maxx)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
s = input()
ans = 0

for i in range(1000):
    i = str(i).zfill(3)
    
    cnt = 0
    for ss in s:
        if cnt == 0:
            if ss==i[0]:
                cnt += 1
                continue
        elif cnt == 1:
            if ss==i[1]:
                cnt += 1
                continue
        else:
            if ss==i[2]:
                ans += 1
                break

print(ans)

Fixed submission:
n = int(input())
s = input()
ans = 0

for i in range(1000):
    i = str(i).zfill(3)

    first = s.find(i[0])
    if first == -1:
        continue

    second = s.find(i[1], first+1)
    if second == -1:
        continue

    third = s.find(i[2], second+1)

    if third != -1:
        ans += 1

print(ans)

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

n = int(input())
s = input()
s = [i for i in s]

set_ = set(itertools.combinations(s, 3))

print(len(set_))

Fixed submission:
n = int(input())
s = input()
ans = 0

for i in range(1000):
    i = str(i).zfill(3)

    first = s.find(i[0])
    if first == -1:
        continue

    second = s.find(i[1], first+1)
    if second == -1:
        continue

    third = s.find(i[2], second+1)

    if third != -1:
        ans += 1

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

left, right = [], []
total = 0

while a != []:
    if total > 0:
        tmp = a.pop()
        right.append(tmp)
        total -= tmp
    else:
        tmp = a.pop(0)
        left.append(tmp)
        total += tmp

print(abs(sum(left) - sum(right)))

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

left = sum(a)
right = 0

mini = float('inf')
for i in a:
    right += i
    left -= i
    tmp = abs(right - left)

    if tmp < mini:
        mini = tmp

print(mini)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = sorted(list(map(int, input().split())), reverse=True)

ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            a1, a2, a3 = L[i], L[j], L[k]
            if a2+a3 <= a1:
                break
            else:
                ans += 1

print(ans)

Fixed submission:
from bisect import bisect_left, bisect_right  # return index

N = int(input())
L = sorted(list(map(int, input().split())))

ans = 0
for i in range(N):
    for j in range(i+1, N):
        tmp = L[i]+L[j]  # tmpはこの値より短くなくてはいけない

        ### ここから下は二分探索
        ix = bisect_left(L, tmp)
        ans += ix-(j+1)

print(ans)
Buggy python submission (verdict: Runtime Error):
from heapq import (
    heapify,  # 優先度付きキューの生成
    heappop,
    heappush,
    heappushpop,
    heapreplace
    )

N, M = map(int, input().split())

#heapqは最小値しか取り出さないので-1倍する
A = heapify([-i for i in map(int,input().split())])

for _ in range(M):
    s = -heappop(A)
    s //= 2
    heappush(A, -s)

print(-sum(A))

Fixed submission:
from heapq import (
    heapify,  # 優先度付きキューの生成
    heappop,
    heappush,
    heappushpop,
    heapreplace
    )

N, M = map(int, input().split())

#heapqは最小値しか取り出さないので-1倍する
A = [-i for i in map(int,input().split())]
heapify(A)

for _ in range(M):
    s = -heappop(A)
    s //= 2
    heappush(A, -s)

print(-sum(A))

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)

for _ in range(M):
    A[0] = int(A[0]/2)
    if A[0]<A[1]:
        A = sorted(A, reverse=True)

print(sum(A))

Fixed submission:
from heapq import (
    heapify,  # 優先度付きキューの生成
    heappop,
    heappush,
    heappushpop,
    heapreplace
    )

N, M = map(int, input().split())

#heapqは最小値しか取り出さないので-1倍する
A = [-i for i in map(int,input().split())]
heapify(A)

for _ in range(M):
    s = -heappop(A)
    s //= 2
    heappush(A, -s)

print(-sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)

for _ in range(M):
    A[0] = int(A[0]/2)
    A = sorted(A, reverse=True)

print(sum(A))

Fixed submission:
from heapq import (
    heapify,  # 優先度付きキューの生成
    heappop,
    heappush,
    heappushpop,
    heapreplace
    )

N, M = map(int, input().split())

#heapqは最小値しか取り出さないので-1倍する
A = [-i for i in map(int,input().split())]
heapify(A)

for _ in range(M):
    s = -heappop(A)
    s //= 2
    heappush(A, -s)

print(-sum(A))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans, kurikosi = 0, 0
for i in range(n+1):
    if a[i]<=kurikosi:
        ans += a[i]
        kurikosi = b[i]
    elif kurikosi < a[i] <= kurikosi+b[i]:
        ans += a[i]
        kurikosi = kurikosi+b[i] - a[i]
    else:
        ans += a[i] - (kurikosi+b[i])
        kurikosi = 0

print(ans)

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

ans, kurikosi = 0, 0
for i in range(n+1):
    if i != n:
        ans += min(a[i], kurikosi+b[i])
        if a[i]<=kurikosi:
            kurikosi = b[i]
        elif kurikosi < a[i] <= kurikosi+b[i]:
            kurikosi = kurikosi+b[i] - a[i]
        else:
            kurikosi = 0
    else:
        ans += min(kurikosi, a[i])

print(ans)