Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
Q=int(input())

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

AllSum=sum(A)

for a in A:
  NumList[a]+=1

for i in range(Q):
  B,C=map(int,input().split())
  AllSum=AllSum + (C-B)*NumList[B]
  NumList[C]+=NumList[B]
  NumList[B]=0
  
  print(AllSum)

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

NumList=[0]*(10**5+1)

AllSum=sum(A)

for a in A:
  NumList[a]+=1

for i in range(Q):
  B,C=map(int,input().split())
  AllSum=AllSum + (C-B)*NumList[B]
  NumList[C]+=NumList[B]
  NumList[B]=0
  
  print(AllSum)

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

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

AllSum=sum(A)

for a in A:
  NumList[a]+=1

for i in range(Q):
  B,C=map(int,input().split())
  AllSum=AllSum + (C-B)*NumList[B]
  NumList[C]+=NumList[B]
  NumList[B]=0
  print(AllSum)


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

NumList=[0]*(10**5+1)

AllSum=sum(A)

for a in A:
  NumList[a]+=1

for i in range(Q):
  B,C=map(int,input().split())
  AllSum=AllSum + (C-B)*NumList[B]
  NumList[C]+=NumList[B]
  NumList[B]=0
  
  print(AllSum)
Buggy python submission (verdict: Time Limit Exceeded):
INPUT = list(map(int, input().split()))

import time
B=INPUT[1]
Number=(INPUT[0]*INPUT[1]+1)
time.sleep(2)

print(Number)

Fixed submission:
INPUT = list(map(int, input().split()))
print(INPUT[0]*INPUT[1])

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

import time
B=INPUT[1]
Number=(INPUT[0]*INPUT[1])
time.sleep(2)

print(Number)

Fixed submission:
INPUT = list(map(int, input().split()))
print(INPUT[0]*INPUT[1])
Buggy python submission (verdict: Time Limit Exceeded):
N=input()
Alist=list(map(int, input().split()))

MultipliedNum=1
index=0

for i in Alist:
    MultipliedNum*=i
    

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

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

MultipliedNum=1
index=0

if min(Alist)==0:
    print(0)
    index=1

else:
    for i in Alist:
        MultipliedNum*=i

        if MultipliedNum>10**18:
            print(-1)
            index=1
            break
            
if index==0:
    print(MultipliedNum)
Buggy python submission (verdict: Runtime Error):
S,T=input().split()S,T=input().split()
print(T+S)

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

print('{}{}'.format(a[1],a[0]))
Buggy python submission (verdict: Runtime Error):
A,B,K=map(int,input().split())

if A-K=>0:
  print(A-K,B)
elif (A+B)<=K:
  print(0,0)
else:
  print(0,A+B-K)

Fixed submission:
A,B,K=map(int,input().split())
 
if A-K>=0:
  print(A-K,B)
elif (A+B)<=K:
  print(0,0)
else:
  print(0,A+B-K)
Buggy python submission (verdict: Runtime Error):
N,A,B=map(int,input().split())

Alltotal=0
for i in range(1,N+1):
  partTotal=0
  while i!=0:
    partTotal+=i%10
    i=i//10
  if A<=partTotal and partTotal<=b:
    Alltotal+=partTotal



Fixed submission:
N,A,B=map(int,input().split())
 
Alltotal=0
for i in range(1,N+1):
  partTotal=0
  temp=i
  while temp!=0:
    partTotal+=temp%10
    temp=temp//10
    
  if A<=partTotal and partTotal<=B:
    Alltotal+=i
    #print(i)
print(Alltotal)
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())

if b<=c or d<=a:
  print(0)
else:
  print(min(d,b)-max(a-c))

Fixed submission:
a,b,c,d=map(int,input().split())
 
if b<=c or d<=a:
  print(0)
else:
  print(min(d,b)-max(a,c))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())

res=1
for i in range(1,N+1):
  res=res*i

print(res%(10**9+7))

Fixed submission:
N=int(input())

res=1
for i in range(1,N+1):
  res=res*i
  res=res%(10**9+7)

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())

res=1
for i in range(1,N+1):
  res=res*i

print(res%(10**9+7))

Fixed submission:
N=int(input())

res=1
for i in range(1,N+1):
  res=res*i
  res=res%(10**9+7)

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
S = []
for j in range(K):
    LRj = list(map(int, input().split()))
    for s in range(LRj[0], LRj[1] + 1):
        S.append(s)

m =  998244353

# print(S)

dp = [0] * N
dp[0] = 1
for i in range(1, N):
    for s in S:
        if s <= i:
            # print(i, i-s)
            dp[i] += dp[i - s] % m
            dp[i] %= m

ans = dp[N - 1]

print(ans)

Fixed submission:
N, K = map(int, input().split())
S = []
for j in range(K):
    S.append(list(map(int, input().split())))

m =  998244353

# print(S)

dp = [0] * N
dp[0] = 1
sum_of_region = [0] * K
for i in range(1, N):
    for j in range(K):
        if i - S[j][0] >= 0:
            sum_of_region[j] += dp[i - S[j][0]]
        if i - S[j][1] - 1 >= 0:
            sum_of_region[j] -= dp[i - S[j][1] - 1]
        dp[i] += sum_of_region[j] % m
        dp[i] %= m
    # print(i, dp, sum_of_region)

ans = dp[N - 1]
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = []  # 累積和テーブル B[i] = sum(A[:i])
mod = 10**9 + 7
ans = 0

for i in range(N):
    B[i+1] = B[i] + A[i]  # 累積和

for i in range(N):
    sum = (B[N] - B[i+1]) % mod
    ans += A[i] * sum
    ans %= mod

print(ans)


Fixed submission:
import numpy as np
N = int(input())
A = list(map(int, input().split()))
B = [0] * (N+1)  # 累積和テーブル B[i] = sum(A[:i])
mod = 10**9 + 7
ans = 0

for i in range(N):
    B[i+1] = B[i] + A[i]  # 累積和

for i in range(N):
    sum = (B[N] - B[i+1]) % mod
    ans += A[i] * sum
    ans %= mod

print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
# https://atcoder.jp/contests/abc177/submissions/16358885

N = int(input())
A = list(map(int, input().split()))
B = []  # 累積和テーブル B[i] = sum(A[:i])
mod = 10**9 + 7
ans = 0

for i in range(N+1):
    B.append(sum(A[:i]))  # 累積和

for i in range(N):
    sum = (B[N] - B[i+1]) % mod
    ans += A[i] * sum
    ans %= mod

print(ans)


Fixed submission:
import numpy as np
N = int(input())
A = list(map(int, input().split()))
B = [0] * (N+1)  # 累積和テーブル B[i] = sum(A[:i])
mod = 10**9 + 7
ans = 0

for i in range(N):
    B[i+1] = B[i] + A[i]  # 累積和

for i in range(N):
    sum = (B[N] - B[i+1]) % mod
    ans += A[i] * sum
    ans %= mod

print(int(ans))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split())
B = []  # 累積和テーブル B[i] = sum(A[:i])
mod = 10**9 + 7
ans = 0

for i in range(N+1):
    B.append(sum(A[:i]))  # 累積和

for i in range(N):
    sum = (B[N] - B[i+1]) % mod
    ans += A[i] * sum
    ans %= mod

print(ans)

Fixed submission:
import numpy as np
N = int(input())
A = list(map(int, input().split()))
B = [0] * (N+1)  # 累積和テーブル B[i] = sum(A[:i])
mod = 10**9 + 7
ans = 0

for i in range(N):
    B[i+1] = B[i] + A[i]  # 累積和

for i in range(N):
    sum = (B[N] - B[i+1]) % mod
    ans += A[i] * sum
    ans %= mod

print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nums_list = list(map(int, list(input().split())))  # 各数字はint

sum = 0
for i, numi in enumerate(nums_list):
    for j, numj in enumerate(nums_list):
        if i < j:
            product = numi * numj
            amari = product % (10**9 + 7)
            sum += amari

ans = sum % (10**9 + 7)

print(ans)

Fixed submission:
import numpy as np
N = int(input())
A = list(map(int, input().split()))
B = [0] * (N+1)  # 累積和テーブル B[i] = sum(A[:i])
mod = 10**9 + 7
ans = 0

for i in range(N):
    B[i+1] = B[i] + A[i]  # 累積和

for i in range(N):
    sum = (B[N] - B[i+1]) % mod
    ans += A[i] * sum
    ans %= mod

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

integers = [i for i in range(1, 101)]
for i in list:
    integers.remove(i)

ans = integers[0]
minabs = abs(integers[0] - x)
for i in integers:
    if abs(i - x) < minabs:
        minabs = abs(i - x)
        ans = i
        break

print(ans)

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

ans = 300
for i in range(-200, 201):
    if i not in list:
        if abs(x-i) < abs(x-ans):
            ans = i

print(ans)

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

integers = [i for i in range(1, 101)]  # この中の整数をxと比較
for i in list:
    integers.remove(i)

ans = integers[0]
minabs = abs(integers[0] - x)
for i in integers:
    if abs(i - x) < minabs:
        minabs = abs(i - x)
        ans = i

print(ans)

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

ans = 300
for i in range(-200, 201):
    if i not in list:
        if abs(x-i) < abs(x-ans):
            ans = i

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
xy = [list(map(int,input().split())) for i in range(N)]
xy.sort()
xy = [list(x) for x in zip(*xy)]
ans = 0
for i in range(N-1):
    a = xy[1][i]
    x = xy[0][i+1:]
    y = list(map(lambda y: abs(y-a),xy[1][i+1:]))
    z = [i+j for i,j in zip(x,y)]
    ans = max(ans,max(z)-xy[0][i])
print(ans)

Fixed submission:
N = int(input())
xy = [list(map(int,input().split())) for i in range(N)]
xy = [list(x) for x in zip(*xy)]
a = [i+j for i,j in zip(xy[0],xy[1])]
b = [i-j for i,j in zip(xy[0],xy[1])]
aa = max(a) - min(a)
ba = max(b) - min(b)
print(max(aa,ba))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
xy = [list(map(int,input().split())) for i in range(N)]
xy.sort()
xy = [list(x) for x in zip(*xy)]
import copy
ans = 0
for i in range(N-1):
    w = xy.copy()
    x = list(map(lambda x: abs(x-xy[0][i]),w[0]))
    y = list(map(lambda y: abs(y-xy[1][i]),w[1]))
    z = [i+j for i,j in zip(x,y)]
    ans = max(ans,max(z))
print(ans)

Fixed submission:
N = int(input())
xy = [list(map(int,input().split())) for i in range(N)]
xy = [list(x) for x in zip(*xy)]
a = [i+j for i,j in zip(xy[0],xy[1])]
b = [i-j for i,j in zip(xy[0],xy[1])]
aa = max(a) - min(a)
ba = max(b) - min(b)
print(max(aa,ba))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    for j in range(i+1,N):
        ans += A[i] * A[j]
    ans = ans % 1000000007
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
a = 0
b = 0
mod = 10**9 + 7
for i in range(N):
    a += A[i]
    b += A[i]**2
    a = a 
    b = b 
a = a ** 2 
ans = (a - b) // 2 % mod
if ans < 0:
    ans += mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    for j in range(i+1,N):
        ans += A[i] * A[j]
        ans = ans % 1000000007
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
a = 0
b = 0
mod = 10**9 + 7
for i in range(N):
    a += A[i]
    b += A[i]**2
    a = a 
    b = b 
a = a ** 2 
ans = (a - b) // 2 % mod
if ans < 0:
    ans += mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    a = A[i] % 1000000007
    for j in range(i+1,N):
        b = A[j] % 1000000007
        ans += a*b
        ans = ans % 1000000007
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
a = 0
b = 0
mod = 10**9 + 7
for i in range(N):
    a += A[i]
    b += A[i]**2
    a = a 
    b = b 
a = a ** 2 
ans = (a - b) // 2 % mod
if ans < 0:
    ans += mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    for j in range(i+1,N):
        ans += A[i] * A[j] % 1000000007
        ans = ans % 1000000007
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
a = 0
b = 0
mod = 10**9 + 7
for i in range(N):
    a += A[i]
    b += A[i]**2
    a = a 
    b = b 
a = a ** 2 
ans = (a - b) // 2 % mod
if ans < 0:
    ans += mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    for j in range(i+1,N):
        ans += A[i] * A[j] % 1000000007
        ans = ans % 1000000007
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
a = 0
b = 0
mod = 10**9 + 7
for i in range(N):
    a += A[i]
    b += A[i]**2
    a = a 
    b = b 
a = a ** 2 
ans = (a - b) // 2 % mod
if ans < 0:
    ans += mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
H,W,M=map(int,input().split())
h=[0]*M
w=[0]*M
for i in range(M):
    h[i],w[i]=map(int,input().split())
t=[0]*H
y=[0]*W
for i in range(H):
    a = 0
    for j in range(M):
        if h[j] == i+1:
            a = a+1
        t[i] = a
for i in range(W):
    a = 0
    for j in range(M):
        if w[j] == i+1:
            a = a+1
        y[i] = a       
maxt = max(t)
maxy = max(y)
lt=[]
ly=[]
for i in range(len(t)):
    if t[i] == maxt:
        lt.append(i+1)
for i in range(len(y)):
    if y[i] == maxy:
        ly.append(i+1)
b = 0
for i in range(M):
    if h[i] in lt and w[i] in ly:
        b = b + 1
if b == len(lt)*len(ly):
    print(maxt+maxy-1)
else:
    print(maxt+maxy)

Fixed submission:
H,W,M=map(int,input().split())
bomb=[]
h=[0]*H
w=[0]*W
for i in range(M):
    hi,wi=map(int,input().split())
    h[hi-1] += 1
    w[wi-1] += 1
    bomb.append([hi,wi])    
maxh = max(h)
maxw = max(w)
ans = maxh +  maxw
lh=[]
lw=[]
for i in range(len(h)):
    if h[i] == maxh:
        lh.append(i+1)
for i in range(len(w)):
    if w[i] == maxw:
        lw.append(i+1)
a = 0
for i in range(M):
    if ans == h[bomb[i][0]-1]+w[bomb[i][1]-1]:
        a += 1
if a == len(lh)*len(lw):
    print(ans-1)
else:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A = list(map(int,input().split()))
count = 0
now = 1
city = [1]
while count < K:
    count +=  1
    now = A[now-1]
    if now in city:
        break
    else:
        city.append(now)
if count == K:
    print(now)
else:
    n = city.index(now)
    K -= n
    count -= n
    K %= count
    print(city[n+K])

Fixed submission:
N,K=map(int,input().split())
A = list(map(int,input().split()))
count = 0
now = 1
city = [1]
city2 = {1}
while count < K:
    count +=  1
    now = A[now-1]
    if now in city2:
        break
    else:
        city.append(now)
        city2.add(now)
if count == K:
    print(now)
else:
    n = city.index(now)
    K -= n
    count -= n
    K %= count
    print(city[n+K])
Buggy python submission (verdict: Time Limit Exceeded):
A,B,N = map(int,input().split())
ans = 0
if N >= B-1:
    for i in range(B-1,N+1,B):
        a =A*i//B
        b = A*(i//B)
        ans = max(ans,a-b)
else:
    ans = A*N//B - A*(N//B)
print(ans)


Fixed submission:
A,B,N = map(int,input().split())
if N >= B-1:
    i = B-1
    ans = A*i//B - A*(i//B)
else:
    ans = A*N//B - A*(N//B)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
A,B,N = map(int,input().split())
ans = 0
if N >= B-1:
    for i in range(B-1,N+1,B):
        a =A*i//B
        b = A*(i//B)
        ans = max(ans,a-b)
else:
    ans = A*N//B - A*(N//B)
print(ans)

Fixed submission:
A,B,N = map(int,input().split())
if N >= B-1:
    i = B-1
    ans = A*i//B - A*(i//B)
else:
    ans = A*N//B - A*(N//B)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S =  input()
ans = 0
for i in range(N-2):
    r = S[i]
    for j in range(i+1,N-1):
        g = S[j]
        if r == g:
            continue
        for k in range(j+1,N):
            if j-i != k-j and r != S[k] and g != S[k]:
                ans += 1
print(ans)

Fixed submission:
N = int(input())
S =  input()
ans = S.count("R") * S.count("G") * S.count("B")
for i in range(N-2):
    r = S[i]
    for j in range(i+1,N-1):
        g = S[j]
        if r == g:
            continue
        k = 2*j - i
        if k >= N:
            continue
        b = S[k]
        if r != b and g != b:
            ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S =  input()
ans = 0
for i in range(N-2):
    r = S[i]
    for j in range(i+1,N-1):
        g = S[j]
        if r == g:
            continue
        for k in range(j+1,N):
            if j-i != k-j and r != S[k] and g != S[k]:
                ans += 1
print(ans)

Fixed submission:
N = int(input())
S =  input()
ans = S.count("R") * S.count("G") * S.count("B")
for i in range(N-2):
    r = S[i]
    for j in range(i+1,N-1):
        g = S[j]
        if r == g:
            continue
        k = 2*j - i
        if k >= N:
            continue
        b = S[k]
        if r != b and g != b:
            ans -= 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
T = 0
for i in range(Q):
    q = list(input().split())
    if q[0] == "1":
        T = (T+1) % 2
    elif (T == 0 and q[1] == "1") or (T == 1 and q[1] == "2"):
        S = q[2] + S
    else:
        S = S + q[2]
if T == 0:
    print(S)
else:
    s = S[::-1]
    print(s)

Fixed submission:
S = input()
Q = int(input())
T = 0
s = ""
for i in range(Q):
    q = list(input().split())
    if q[0] == "1":
        T = (T+1) % 2
    elif (T == 0 and q[1] == "1") or (T == 1 and q[1] == "2"):
        s += q[2]
    else:
        S += q[2]
if T == 0:
    S = s[::-1] + S
    print(S)
else:
    S = S[::-1] + s
    print(S)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
T = 0
for i in range(Q):
    q = list(input().split())
    if q[0] == "1":
        T = (T+1) % 2
    elif (T == 0 and q[1] == "1") or (T == 1 and q[1] == "2"):
        S = q[2] + S
    else:
        S = S + q[2]
if T == 0:
    print(S)
else:
    s = S[::-1]
    print(s)

Fixed submission:
S = input()
Q = int(input())
T = 0
s = ""
for i in range(Q):
    q = list(input().split())
    if q[0] == "1":
        T = (T+1) % 2
    elif (T == 0 and q[1] == "1") or (T == 1 and q[1] == "2"):
        s += q[2]
    else:
        S += q[2]
if T == 0:
    S = s[::-1] + S
    print(S)
else:
    S = S[::-1] + s
    print(S)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
p = list(map(lambda x: (int(x)+1)/2,input().split()))
ans=[]
for i in range(N-K+1):
    ans.append(sum(p[i:i+K]))
print(max(ans))

Fixed submission:
N,K = map(int,input().split())
p = list(map(lambda x: int(x)+1,input().split()))
ans = sum(p[0:K])
s = ans
for i in range(1,N-K+1):
    s += p[i+K-1]-p[i-1]
    ans = max(ans,s)
print(ans/2)
Buggy python submission (verdict: Time Limit Exceeded):
N,D,A = map(int,input().split())
XH = [list(map(int,input().split())) for i in range(N)]
XH.sort()
from math import ceil
times = ceil(XH[0][1]/A)
ans = times
damege = [times*A]
coor = [XH[0][0]+2*D]
start = 0
end = 1
for i in range(1,N):
    while start < end and coor[start] < XH[i][0]:
        start += 1
    H = XH[i][1] - sum(damege[start:end])
    if H > 0:
        times = ceil(H/A)
        ans += times
        damege.append(times*A)
        coor.append(XH[i][0]+2*D)
        end += 1
print(ans)

Fixed submission:
N,D,A = map(int,input().split())
XH = [list(map(int,input().split())) for i in range(N)]
XH.sort()
from math import ceil
times = ceil(XH[0][1]/A)
ans = times
damege = [times*A]
coor = [XH[0][0]+2*D]
start = 0
end = 1
dam = sum(damege[start:end])
for i in range(1,N):
    st = start
    while start < end and coor[start] < XH[i][0]:
        start += 1
    dam -= sum(damege[st:start])
    H = XH[i][1] - dam
    if H > 0:
        times = ceil(H/A)
        ans += times
        damege.append(times*A)
        dam += times*A
        coor.append(XH[i][0]+2*D)
        end += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
import bisect
for i in range(M):
    bisect.insort(A,A[-1]//2)
    A.pop(-1)
print(sum(A))

Fixed submission:
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
import bisect
for i in range(M):
    bisect.insort(A,A[-1]/2)
    A.pop(-1)
for i in range(N):
    A[i] = int(A[i])
print(sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
import bisect
for i in range(M):
    bisect.insort(A,A[-1]/2)
    A.pop(-1)
for i in range(N):
    A[i] = int(A[i])
print(sum(A))

Fixed submission:
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
import bisect
for i in range(M):
    bisect.insort(A,A[-1]/2)
    A.pop(-1)
for i in range(N):
    A[i] = int(A[i])
print(sum(A))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = [int(input()) for i in range(M)]
a = b = A[0]
n = 0
c = 0
ans = [0,1]
for i in range(1,N+1):
    if  i == a:
        c = 0
        n += 1
        b = a
        if n <= M-1:
            a = A[n]
    elif i-2 == b:
        c = ans[-1]
    elif i-1 == b :
        c = ans[-2]
    else:
        c  = ans[-1] + ans[-2]
    c %= 10**9 + 7
    ans.append(c)
print(ans[-1])

Fixed submission:
N,M = map(int,input().split())
A = [int(input()) for i in range(M)]
n = 0
if M != 0:
    a = b = A[0]
else:
    a = b = -2
c = 0
ans = [0,1]
for i in range(1,N+1):
    if  i == a:
        c = 0
        n += 1
        b = a
        if n <= M-1:
            a = A[n]
    elif i-2 == b:
        c = ans[-1]
    elif i-1 == b :
        c = ans[-2]
    else:
        c  = ans[-1] + ans[-2]
    c %= 10**9 + 7
    ans.append(c)
print(ans[-1])