Buggy python submission (verdict: Time Limit Exceeded):
def heap_localsort(Array, i):
    lsub, rsub = 2*i+1, 2*i+2
    maxIndex = i
    if lsub <= len(Array)-1 and Array[lsub] > Array[maxIndex]:
        maxIndex = lsub
    if rsub <= len(Array)-1 and Array[rsub] > Array[maxIndex]:
        maxIndex = rsub
    Array[i], Array[maxIndex] = Array[maxIndex], Array[i]
    return(Array)

def heap_sort(Array):
    for i in reversed(range(int(len(Array)/2))):
        heap_localsort(Array, i)
    return(Array)

def heap_push(Array, addElem):
    Array.append(addElem)
    return(heap_sort(Array))

def heap_pop(Array):
    init = A[0]
    Array[0], Array[len(Array)-1] = Array[len(Array)-1], Array[0]
    Array.pop(len(Array)-1)
    heap_sort(A)
    return(init)
 
def function(A, M):
    heap_sort(A)
    for i in range(M):
        max = heap_pop(A)
        heap_push(A, int(max / 2))
    return sum(A)

N = list(map(int, (input().split(' '))))
A = list(map(int, (input().split(' '))))
print(function(A, N[1]))

Fixed submission:
import heapq

N = list(map(int, (input().split(' '))))
A = list(map(lambda x: x*(-1), map(int, (input().split(' ')))))

heapq.heapify(A)
for i in range(N[1]):
    heapq.heappush(A, int(heapq.heappop(A) / 2))

print(-sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
def heap_localsort(Array, i):
    lsub, rsub = 2*i+1, 2*i+2
    maxIndex = i
    if lsub <= len(Array)-1 and Array[lsub] > Array[maxIndex]:
        maxIndex = lsub
    if rsub <= len(Array)-1 and Array[rsub] > Array[maxIndex]:
        maxIndex = rsub
    Array[i], Array[maxIndex] = Array[maxIndex], Array[i]
    return(Array)

def heap_sort(Array):
    for i in reversed(range(int(len(Array)/2))):
        heap_localsort(Array, i)
    return(Array)

def heap_push(Array, addElem):
    Array.append(addElem)
    return(heap_sort(Array))

def heap_pop(Array):
    init = A[0]
    Array.pop(0)
    heap_sort(A)
    return(init)
 
def function(A, M):
    heap_sort(A)
    for i in range(M):
        max = heap_pop(A)
        heap_push(A, int(max / 2))
    return sum(A)

N = list(map(int, (input().split(' '))))
A = list(map(int, (input().split(' '))))
print(function(A, N[1]))

Fixed submission:
import heapq

N = list(map(int, (input().split(' '))))
A = list(map(lambda x: x*(-1), map(int, (input().split(' ')))))

heapq.heapify(A)
for i in range(N[1]):
    heapq.heappush(A, int(heapq.heappop(A) / 2))

print(-sum(A))

Buggy python submission (verdict: Runtime Error):
import heapq
 
def FUNCTION(A, M):
    heapq.heapify(A)
    for i in range(M):
        heapq.heappush(A, int(heapq.heappop(A) / 2))
        print (A)
    return -sum(A)

N = list(map(int, (input().split(' '))))
A = list(map(lambda x: x*(-1), map(int, (input().split(' ')))))
print(FUNCTION(A, N[1]))

Fixed submission:
import heapq

N = list(map(int, (input().split(' '))))
A = list(map(lambda x: x*(-1), map(int, (input().split(' ')))))

heapq.heapify(A)
for i in range(N[1]):
    heapq.heappush(A, int(heapq.heappop(A) / 2))

print(-sum(A))

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

for i in range(N[1]):
    for Index, Kakaku in enumerate(A):
        if Kakaku == max(A):
            A[Index] = int(Kakaku / 2)
            break

print(sum(A))


Fixed submission:
import heapq

N = list(map(int, (input().split(' '))))
A = list(map(lambda x: x*(-1), map(int, (input().split(' ')))))

heapq.heapify(A)
for i in range(N[1]):
    heapq.heappush(A, int(heapq.heappop(A) / 2))

print(-sum(A))

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

for i in range(N[1]):
    A[A.index(max(A))] = int(max(A) / 2)

print(sum(A))

Fixed submission:
import heapq

N = list(map(int, (input().split(' '))))
A = list(map(lambda x: x*(-1), map(int, (input().split(' ')))))

heapq.heapify(A)
for i in range(N[1]):
    heapq.heappush(A, int(heapq.heappop(A) / 2))

print(-sum(A))