Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
input= sys.stdin.readline
N, M = map(int,input().split())
 
A= list(map(int,input().split()))
 
A.sort(reverse=True)
cnt = 1
A[0]=A[0]//2
 
if N==1:
    while A[0]>0 and cnt<M:
        cnt+=1
        A[0]=A[0]//2
else:
    while cnt<M:
        c=min(M-cnt,int(math.log2(A[0]/A[1])+1))
        cnt+=c
        A[0]=A[0]//(2**c)
          
        b=A[0]
        A.sort(reverse=True)
    
print(sum(A))

Fixed submission:
import heapq

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

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

heapq.heapify(a)

num = 0
hq = 1

while num < M and hq != 0:
    hq = -heapq.heappop(a)
    hq2 = hq // 2
    heapq.heappush(a, -hq2)
    num += 1

print(-sum(a))

Buggy python submission (verdict: Runtime Error):
import sys
input= sys.stdin.readline
N, M = map(int,input().split())
 
A= list(map(int,input().split()))
 
A.sort(reverse=True)
cnt = 1
A[0]=A[0]//2
 
if N==1:
    while A[0]>0 and cnt<M:
        cnt+=1
        A[0]=A[0]//2
else:
    while cnt<M:
        c=min(M-cnt,int(math.log2(A[0]/A[1])+1))
        cnt+=c
        A[0]=A[0]//(2**c)
          
        b=A[0]
        A.sort(reverse=True)
    
print(sum(A))

Fixed submission:
import heapq

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

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

heapq.heapify(a)

num = 0
hq = 1

while num < M and hq != 0:
    hq = -heapq.heappop(a)
    hq2 = hq // 2
    heapq.heappush(a, -hq2)
    num += 1

print(-sum(a))

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

input= sys.stdin.readline
N, M = map(int,input().split())

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

A.sort(reverse=True)
cnt = 1
A[0]=A[0]//2

if N==1:
    while A[0]>0 and cnt<M:
        cnt+=1
        A[0]=A[0]//2
else:
    while cnt<M:
        c=min(M-cnt,int(math.log2(A[0]/A[1])+1))
        cnt+=c
        A[0]=A[0]//(2**c)
        
        b=A[0]
        A[0]=A[1]
        for i in range(2,N):
            if A[i]>b:A[i-1]=A[i]
            else:
                A[i-1]=b
                break

print(sum(A))
    
        

Fixed submission:
import heapq

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

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

heapq.heapify(a)

num = 0
hq = 1

while num < M and hq != 0:
    hq = -heapq.heappop(a)
    hq2 = hq // 2
    heapq.heappush(a, -hq2)
    num += 1

print(-sum(a))

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

input= sys.stdin.readline
N, M = map(int,input().split())

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

A.sort(reverse=True)
cnt = 1
A[0]=A[0]//2

if N==1:
    while A[0]>0 and cnt<M:
        cnt+=1
        A[0]=A[0]//2
else:
    while cnt<M:
        c=int(math.log2(A[0]/A[1])+1)
        cnt+=c
        A[0]=A[0]//(2**c)
        A.sort(reverse=True)
    
print(sum(A))
    
        

Fixed submission:
import heapq

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

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

heapq.heapify(a)

num = 0
hq = 1

while num < M and hq != 0:
    hq = -heapq.heappop(a)
    hq2 = hq // 2
    heapq.heappush(a, -hq2)
    num += 1

print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input= sys.stdin.readline
N, M = map(int,input().split())

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

A.sort(reverse=True)
cnt = 1
A[0]=A[0]//2

if N==1:
    while A[0]>0 and cnt<M:
        cnt+=1
        A[0]=A[0]//2
else:
    while cnt<M:
        while A[0]>=A[1] and cnt<M:
            cnt+=1
            A[0]=A[0]//2
          
        b=A[0]
        A.sort(reverse=True)
    
print(sum(A))
    
        

Fixed submission:
import heapq

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

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

heapq.heapify(a)

num = 0
hq = 1

while num < M and hq != 0:
    hq = -heapq.heappop(a)
    hq2 = hq // 2
    heapq.heappush(a, -hq2)
    num += 1

print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline

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

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

A.sort(reverse=True)
cnt = 1
A[0]=A[0]//2

if N==1:
    while A[0]>0 and cnt<M:
        cnt+=1
        A[0]=A[0]//2
else:
    while cnt<M:
        while A[0]>=A[1] and cnt<M:
            cnt+=1
            A[0]=A[0]//2
        if cnt==M:break
        else:
            b=A[0]
            for i in range(1,N):
                if A[i]>b:A[i-1]=A[i]
                else:
                    A[i-1]=b
                    break
    
print(sum(A))
    
        

Fixed submission:
import heapq

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

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

heapq.heapify(a)

num = 0
hq = 1

while num < M and hq != 0:
    hq = -heapq.heappop(a)
    hq2 = hq // 2
    heapq.heappush(a, -hq2)
    num += 1

print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline

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

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

A.sort(reverse=True)
cnt = 1
A[0]=A[0]//2

if N==1:
    while A[0]>0 and cnt<M:
        cnt+=1
        A[0]=A[0]//2
else:
    while cnt<M:
        while A[0]>=A[1] and cnt<M:
            cnt+=1
            A[0]=A[0]//2
          
        b=A[0]
        for i in range(1,N):
            if A[i]>b:A[i-1]=A[i]
            else:
                A[i-1]=b
                break
    
print(sum(A))

Fixed submission:
import heapq

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

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

heapq.heapify(a)

num = 0
hq = 1

while num < M and hq != 0:
    hq = -heapq.heappop(a)
    hq2 = hq // 2
    heapq.heappush(a, -hq2)
    num += 1

print(-sum(a))