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

while True:
    if m <= 0:
        break
    a[-1] = a[-1] // 2
    if len(a) > 1 and a[-1] < a[-2]:
        a = sorted(a)
    m -= 1

ans = sum(a)
print(ans)

Fixed submission:
import heapq

n, m = map(int, input().split())
a = []
#a = list(map(int, input().split()))
#a = list(reversed(sorted(a)))
#heapq.heapify(a)
for i in input().split():
    heapq.heappush(a, -int(i))

ans = 0

for i in range(len(a)):
    while True:
        if m <= 0:
            break

        maxV = heapq.heappop(a)
#        print('maxV: ' + str(maxV))
        heapq.heappush(a, -(-maxV // 2))
        m -= 1
        # print('m: ' + str(m))
        # print('a: ' + str(a))
ans = -sum(a)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
ans = 0
minV = 10**15
cnt = 0

while True:
    if m <= 0:
        break
    a[-1] = a[-1] // 2
    a = sorted(a)
    m -= 1

ans = sum(a)
print(ans)

Fixed submission:
import heapq

n, m = map(int, input().split())
a = []
#a = list(map(int, input().split()))
#a = list(reversed(sorted(a)))
#heapq.heapify(a)
for i in input().split():
    heapq.heappush(a, -int(i))

ans = 0

for i in range(len(a)):
    while True:
        if m <= 0:
            break

        maxV = heapq.heappop(a)
#        print('maxV: ' + str(maxV))
        heapq.heappush(a, -(-maxV // 2))
        m -= 1
        # print('m: ' + str(m))
        # print('a: ' + str(a))
ans = -sum(a)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))
#a = list(reversed(sorted(a)))
ans = 0
#minV = 10**15
total = sum(a)
#print(total)

while True:
    if m <= 0:
        break
    maxV = max(a)
    idx = a.index(maxV)
#    total = total - maxV + (maxV // 2)
    a[idx] = a[idx] // 2

#    a[0] = a[0] // 2
#    a = list(reversed(sorted(a)))
    m -= 1

ans = sum(a)
print(ans)

Fixed submission:
import heapq

n, m = map(int, input().split())
a = []
#a = list(map(int, input().split()))
#a = list(reversed(sorted(a)))
#heapq.heapify(a)
for i in input().split():
    heapq.heappush(a, -int(i))

ans = 0

for i in range(len(a)):
    while True:
        if m <= 0:
            break

        maxV = heapq.heappop(a)
#        print('maxV: ' + str(maxV))
        heapq.heappush(a, -(-maxV // 2))
        m -= 1
        # print('m: ' + str(m))
        # print('a: ' + str(a))
ans = -sum(a)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = list(reversed(sorted(a)))
ans = 0
minV = 10**15
cnt = 0

while True:
    if m <= 0:
        break
    a[0] = a[0] // 2
    a = list(reversed(sorted(a)))
    m -= 1

ans = sum(a)
print(ans)

Fixed submission:
import heapq

n, m = map(int, input().split())
a = []
#a = list(map(int, input().split()))
#a = list(reversed(sorted(a)))
#heapq.heapify(a)
for i in input().split():
    heapq.heappush(a, -int(i))

ans = 0

for i in range(len(a)):
    while True:
        if m <= 0:
            break

        maxV = heapq.heappop(a)
#        print('maxV: ' + str(maxV))
        heapq.heappush(a, -(-maxV // 2))
        m -= 1
        # print('m: ' + str(m))
        # print('a: ' + str(a))
ans = -sum(a)
print(ans)