Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

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

if N == 1:
    MAX = A[0]//2**M 
    print(MAX)
    exit()

while M > 0:
    MAX = max(A)
    A.remove(MAX)
    A.append(MAX//2)

    M -= 1

print(sum(A))


Fixed submission:
#!/usr/bin/env python3
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x: x*(-1), A))  # 各要素を-1倍

heapq.heapify(A)

if N == 1:
    MAX = heapq.heappop(A)//2**M 
    if MAX < 0:
        print(0)
    else:
        print(MAX)
    exit()

cnt = 0
while M > 0:
    MAX = heapq.heappop(A)
    if MAX % 2 == 0:
        heapq.heappush(A, MAX//2)
    else:
        heapq.heappush(A, MAX//2+1)

    M -= 1

print(-sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))[::-1]

if N == 1:
    print(A[0]//2**M)
    exit()

cnt = 0
while M > 0:
    m = 1
    while True:
        if A[0]//2**m < A[1]:
            break
        else:
            m += 1
    if M-m >= 0:
        A.append(A[0]//2**m)
        M -= m
        cnt += m
    else:
        A.append(A[0]//2**M)
        M = 0
        cnt += M
    A.pop(0)
    A = sorted(A)[::-1]

print(sum(A))


Fixed submission:
#!/usr/bin/env python3
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x: x*(-1), A))  # 各要素を-1倍

heapq.heapify(A)

if N == 1:
    MAX = heapq.heappop(A)//2**M 
    if MAX < 0:
        print(0)
    else:
        print(MAX)
    exit()

cnt = 0
while M > 0:
    MAX = heapq.heappop(A)
    if MAX % 2 == 0:
        heapq.heappush(A, MAX//2)
    else:
        heapq.heappush(A, MAX//2+1)

    M -= 1

print(-sum(A))

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

A = sorted(A)[::-1]

waribiki = 0
index = 0

if len(A)==1:
    print(A[0]//pow(2,M))
    exit()

while waribiki < M:
    if index==0 and A[index] < 3: break
    if A[index]>2 and A[index+1]>2:
        x = A[index] // A[index+1]
        if x+waribiki>M: x = M-waribiki

    if A[index] > 2:
        A[index] = A[index]//pow(2, x)
        waribiki+=x

    index += 1
    if index==N:
        index=0



if waribiki < M:
    index = 0
    while waribiki < M:
        A[index] = A[index] // 2
        waribiki += 1

        index += 1
        if index==N: index=0

        if sum(A)==0:break


print(sum(A))


Fixed submission:
#!/usr/bin/env python3
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x: x*(-1), A))  # 各要素を-1倍

heapq.heapify(A)

if N == 1:
    MAX = heapq.heappop(A)//2**M 
    if MAX < 0:
        print(0)
    else:
        print(MAX)
    exit()

cnt = 0
while M > 0:
    MAX = heapq.heappop(A)
    if MAX % 2 == 0:
        heapq.heappush(A, MAX//2)
    else:
        heapq.heappush(A, MAX//2+1)

    M -= 1

print(-sum(A))

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

A = sorted(A)[::-1]

waribiki = 0
index = 0

if len(A)==1:
    print(A[0]//pow(2,M))
    exit()

while waribiki < M:
    if index==0 and A[index] < 3: break
    if A[index]>2 and A[index+1]>2:
        x = A[index] // A[index+1]
        if x+waribiki>M: x = M-waribiki

    if A[index] > 2:
        A[index] = A[index]//pow(2, x)
        waribiki+=x

    index += 1
    if index==N:
        index=0



if waribiki < M:
    index = 0
    while waribiki < M:
        A[index] = A[index] // 2

        index += 1
        if index==N: index=0

        if sum(A)==0:break


print(sum(A))


Fixed submission:
#!/usr/bin/env python3
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x: x*(-1), A))  # 各要素を-1倍

heapq.heapify(A)

if N == 1:
    MAX = heapq.heappop(A)//2**M 
    if MAX < 0:
        print(0)
    else:
        print(MAX)
    exit()

cnt = 0
while M > 0:
    MAX = heapq.heappop(A)
    if MAX % 2 == 0:
        heapq.heappush(A, MAX//2)
    else:
        heapq.heappush(A, MAX//2+1)

    M -= 1

print(-sum(A))

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

A = sorted(A)[::-1]

waribiki = 0
index = 0

if len(A)==1:
    print(A[0]//pow(2,M))
    exit()

while waribiki < M:
    if index < N and A[index]>2 and A[index+1]>2:
        x = A[index] // A[index+1]
        if x+waribiki>M: x = M-waribiki
    else: x = 1

    if A[index] > 2:
        A[index] = A[index]//pow(2, x)
        waribiki+=x

    index += 1
    if index==N: index=0

print(sum(A))


Fixed submission:
#!/usr/bin/env python3
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x: x*(-1), A))  # 各要素を-1倍

heapq.heapify(A)

if N == 1:
    MAX = heapq.heappop(A)//2**M 
    if MAX < 0:
        print(0)
    else:
        print(MAX)
    exit()

cnt = 0
while M > 0:
    MAX = heapq.heappop(A)
    if MAX % 2 == 0:
        heapq.heappush(A, MAX//2)
    else:
        heapq.heappush(A, MAX//2+1)

    M -= 1

print(-sum(A))