Buggy python submission (verdict: Runtime Error):
import sys
import heapq

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

if len(A) == 1:
    A[0] //= (2 ** M)
    print(sum(A))
    sys.exit()

h = [(1/a, a) for a in A]
heapq.heapify(h)

for m in range(M):
    x = heapq.heappop(h)
    _, a = x

    a //= 2

    heapq.heappush(h, (1/a, a))

print(sum([a for _, a in h]))


Fixed submission:
import sys
import heapq

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

if len(A) == 1:
    A[0] //= (2 ** M)
    print(sum(A))
    sys.exit()

h = [(1/a, a) for a in A]
heapq.heapify(h)

for m in range(M):
    x = heapq.heappop(h)
    _, a = x

    a //= 2

    heapq.heappush(h, (1/a if a > 0 else float('inf'), a))

print(sum([a for _, a in h]))

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

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

A.sort()

if len(A) == 1:
    A[0] //= (2 ** M)
    print(sum(A))
    sys.exit()

for m in range(M):
    a = A[-1]
    A = A[:-1]

    a //= 2

    for i, x in enumerate(reversed(A)):
        j = len(A) - i - 1
        if x < a:
            A.insert(j+1, a)
            break
    else:
        A = [a] + A

print(sum(A))


Fixed submission:
import sys
import heapq

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

if len(A) == 1:
    A[0] //= (2 ** M)
    print(sum(A))
    sys.exit()

h = [(1/a, a) for a in A]
heapq.heapify(h)

for m in range(M):
    x = heapq.heappop(h)
    _, a = x

    a //= 2

    heapq.heappush(h, (1/a if a > 0 else float('inf'), a))

print(sum([a for _, a in h]))

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

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

A.sort()

if len(A) == 1:
    A[0] //= (2 ** M)
    print(sum(A))
    sys.exit()

for m in range(M):
    *A, a = A

    a //= 2

    for i, x in enumerate(reversed(A)):
        j = len(A) - i - 1
        if x < a:
            A.insert(j+1, a)
            break
    else:
        A = [a] + A

print(sum(A))


Fixed submission:
import sys
import heapq

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

if len(A) == 1:
    A[0] //= (2 ** M)
    print(sum(A))
    sys.exit()

h = [(1/a, a) for a in A]
heapq.heapify(h)

for m in range(M):
    x = heapq.heappop(h)
    _, a = x

    a //= 2

    heapq.heappush(h, (1/a if a > 0 else float('inf'), a))

print(sum([a for _, a in h]))

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

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

A.sort()

if len(A) == 1:
    A[0] //= (2 ** M)
    print(sum(A))
    sys.exit()

for m in range(M):
    *A, a = A

    a //= 2

    for i, x in reversed(list(enumerate(A))):
        if x < a:
            A.insert(i+1, a)
            break
    else:
        A = [a] + A

print(sum(A))


Fixed submission:
import sys
import heapq

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

if len(A) == 1:
    A[0] //= (2 ** M)
    print(sum(A))
    sys.exit()

h = [(1/a, a) for a in A]
heapq.heapify(h)

for m in range(M):
    x = heapq.heappop(h)
    _, a = x

    a //= 2

    heapq.heappush(h, (1/a if a > 0 else float('inf'), a))

print(sum([a for _, a in h]))

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

A.sort()

for m in range(M):
    if len(A) == 1:
        A[0] //= 2
        continue

    *A, a = A

    a //= 2

    for i, x in reversed(list(enumerate(A))):
        if x < a:
            A.insert(i+1, a)
            break
    else:
        A = [a] + A

print(sum(A))


Fixed submission:
import sys
import heapq

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

if len(A) == 1:
    A[0] //= (2 ** M)
    print(sum(A))
    sys.exit()

h = [(1/a, a) for a in A]
heapq.heapify(h)

for m in range(M):
    x = heapq.heappop(h)
    _, a = x

    a //= 2

    heapq.heappush(h, (1/a if a > 0 else float('inf'), a))

print(sum([a for _, a in h]))