Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))
#print([bin(val) for val in A])

A.sort()
#print(A)

def binsearch(threshold, lst):
    left, right = -1, len(lst)
    while right - left > 1:
        mid = (right + left) // 2
        if lst[mid] >= threshold:
            right = mid
        else:
            left = mid
    return right

if N > 1:
    cnt = 0
    while cnt < M:
        while A[-1] >= A[-2] and cnt < M:
            A[-1] //= 2
            cnt += 1
        indx = binsearch(A[-1], A)
        A.insert(indx, A.pop(-1))
        #print(cnt, A)
    print(sum(A))
else:
    print(A[0] // 2**M)



Fixed submission:
import heapq

N, M = map(int, input().split())
A = list(map(lambda x:-int(x), input().split()))
#print([bin(val) for val in A])

heapq.heapify(A)
#print(A)

for _ in range(M):
    temp = -heapq.heappop(A) // 2
    heapq.heappush(A, -temp)
    #print(A)
print(-sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))
#print([bin(val) for val in A])

A.sort()
#print(A)

def binsearch(threshold, lst):
    left, right = -1, len(lst)
    while right - left > 1:
        mid = (right + left) // 2
        if lst[mid] >= threshold:
            right = mid
        else:
            left = mid
    return right
for i in range(M):
    temp = A.pop(-1) // 2
    indx = binsearch(temp, A)
    #print(indx)
    if indx == N:
        A.append(temp)
    else:
        A.insert(indx, temp)
    #print(A)
print(sum(A))


Fixed submission:
import heapq

N, M = map(int, input().split())
A = list(map(lambda x:-int(x), input().split()))
#print([bin(val) for val in A])

heapq.heapify(A)
#print(A)

for _ in range(M):
    temp = -heapq.heappop(A) // 2
    heapq.heappush(A, -temp)
    #print(A)
print(-sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))
#print([bin(val) for val in A])

A.sort()
#print(A)

def binsearch(threshold, lst):
    left, right = -1, len(lst)
    while right - left > 1:
        mid = (right + left) // 2
        if lst[mid] >= threshold:
            right = mid
        else:
            left = mid
    return right
for i in range(M):
    temp = A.pop(-1) // 2
    indx = binsearch(temp, A)
    #print(indx)
    if indx == N:
        A.append(temp)
    else:
        A.insert(indx, temp)
    #print(A)
print(sum(A))


Fixed submission:
import heapq

N, M = map(int, input().split())
A = list(map(lambda x:-int(x), input().split()))
#print([bin(val) for val in A])

heapq.heapify(A)
#print(A)

for _ in range(M):
    temp = -heapq.heappop(A) // 2
    heapq.heappush(A, -temp)
    #print(A)
print(-sum(A))

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

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

for i in range(M):
    mx=max(A)
    A.remove(mx)
    A.append(mx/2)

A=list(map(math.floor, A))
print(sum(A))


Fixed submission:
import heapq

N, M = map(int, input().split())
A = list(map(lambda x:-int(x), input().split()))
#print([bin(val) for val in A])

heapq.heapify(A)
#print(A)

for _ in range(M):
    temp = -heapq.heappop(A) // 2
    heapq.heappush(A, -temp)
    #print(A)
print(-sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N, M=map(int, input().split())
A=list(map(int, input().split()))
def discount(lst):
    M=max(lst)
    A[A.index(M)]=M/2
    return lst
#print(A)
for i in range(M):

    A=discount(A)
    #print(A)
answer=list(map(int, A))
print(sum(answer))

Fixed submission:
import heapq

N, M = map(int, input().split())
A = list(map(lambda x:-int(x), input().split()))
#print([bin(val) for val in A])

heapq.heapify(A)
#print(A)

for _ in range(M):
    temp = -heapq.heappop(A) // 2
    heapq.heappush(A, -temp)
    #print(A)
print(-sum(A))