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

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

import heapq
def min_heapsort(iter):
    h = []
    for value in iter:
        heapq.heappush(h, value)
    return [heapq.heappop(h) for i in range(len(h))]

def max_heapsort(iter):
    for i in reversed(range(len(iter)//2)):
        max_heapify(iter,i)

def max_heapify(array,i):
    left = 2*i+1
    right = 2*i+2
    length = len(array) - 1
    biggest = i

    if left <= length and array[i] < array[left]:
        biggest = left
    if right <= length and array[biggest] < array[right]:
        biggest = right
    if biggest != i:
        array[i], array[biggest] = array[biggest], array[i]
        max_heapify(array, biggest)

def waribiki(X,Y):
    return X//(2**Y)

if len(A)==1:
    while M>0:
        A[0] = waribiki(A[0],1)
        M -= 1
else:
    while M>0:
        #A.sort(reverse=True)
        max_heapsort(A)
        
        m=1
        #while M>0 and waribiki(A[0],m)>A[1]:
        #    m+=1
        A[0] = waribiki(A[0],m)
        M -= m
       

print(sum(A))


Fixed submission:
N, M = map(int,input().split())

def intm(x):
    return int(x)*-1
A = list(map(intm, input().split()))

import heapq

heapq.heapify(A)
while M>0:
    a = -heapq.heappop(A) // 2
    heapq.heappush(A,-a)
    M -= 1
   

print(-sum(A))

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

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

import heapq
def heapsort(iter):
    h = []
    for value in iter:
        heappush(h, value)
    return [heappop(h) for i in range(len(h))]

def waribiki(X,Y):
    return X//(2**Y)

if len(A)==1:
    while M>0:
        A[0] = waribiki(A[0],1)
        M -= 1
else:
    while M>0:
        #A.sort(reverse=True)
        A = heapsort(A)
        
        m=1
        #while M>0 and waribiki(A[0],m)>A[1]:
        #    m+=1
        A[0] = waribiki(A[0],m)
        M -= m
       

print(sum(A))


Fixed submission:
N, M = map(int,input().split())

def intm(x):
    return int(x)*-1
A = list(map(intm, input().split()))

import heapq

heapq.heapify(A)
while M>0:
    a = -heapq.heappop(A) // 2
    heapq.heappush(A,-a)
    M -= 1
   

print(-sum(A))

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

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

def waribiki(X,Y):
    return X//(2**Y)

if len(A)==1:
    while M>0:
        A[0] = waribiki(A[0],1)
        M -= 1
else:
    while M>0:
        A.sort(reverse=True)
        m=1
        while M>0 and waribiki(A[0],m)>A[1]:
            m+=1
        A[0] = waribiki(A[0],m)
        M -= m
       

print(sum(A))


Fixed submission:
N, M = map(int,input().split())

def intm(x):
    return int(x)*-1
A = list(map(intm, input().split()))

import heapq

heapq.heapify(A)
while M>0:
    a = -heapq.heappop(A) // 2
    heapq.heappush(A,-a)
    M -= 1
   

print(-sum(A))

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

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

def waribiki(X,Y):
    return X//(2**Y)

while M>0:
    maxIdx = A.index(max(A))
    A[maxIdx] = waribiki(A[maxIdx],1)
    M -= 1
    

print(sum(A))


Fixed submission:
N, M = map(int,input().split())

def intm(x):
    return int(x)*-1
A = list(map(intm, input().split()))

import heapq

heapq.heapify(A)
while M>0:
    a = -heapq.heappop(A) // 2
    heapq.heappush(A,-a)
    M -= 1
   

print(-sum(A))

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

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

def waribiki(X,Y):
    return X//(2**Y)

if len(A)==1:
    while M>0:
        A.sort(reverse=True)
        A[0] = waribiki(A[0],1)
        M -= 1
    
else:
    while M>0:
        A.sort(reverse=True)
        m=1
        while waribiki(A[0],m) > A[1]:
            m+=1
        else:
            A[0] = waribiki(A[0],m)
        M -= m

print(sum(A))


Fixed submission:
N, M = map(int,input().split())

def intm(x):
    return int(x)*-1
A = list(map(intm, input().split()))

import heapq

heapq.heapify(A)
while M>0:
    a = -heapq.heappop(A) // 2
    heapq.heappush(A,-a)
    M -= 1
   

print(-sum(A))

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

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

def waribiki(X,Y):
    return X//(2**Y)

A.sort(reverse=True)
while M>0:
    A[0] = waribiki(A[0],1)
    M -= 1
    if len(A)>1:
        if A[0] < A[1]:
            i=0
            while A[i] < A[i+1]:
                tmp = A[i+1]
                A[i+1]=A[i]
                A[i]=tmp
                i+=1

print(sum(A))


Fixed submission:
N, M = map(int,input().split())

def intm(x):
    return int(x)*-1
A = list(map(intm, input().split()))

import heapq

heapq.heapify(A)
while M>0:
    a = -heapq.heappop(A) // 2
    heapq.heappush(A,-a)
    M -= 1
   

print(-sum(A))

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

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

def waribiki(X,Y):
    return X//(2**Y)

while M>0:
    A.sort(reverse=True)
    A[0] = waribiki(A[0],1)
    M -= 1

print(sum(A))


Fixed submission:
N, M = map(int,input().split())

def intm(x):
    return int(x)*-1
A = list(map(intm, input().split()))

import heapq

heapq.heapify(A)
while M>0:
    a = -heapq.heappop(A) // 2
    heapq.heappush(A,-a)
    M -= 1
   

print(-sum(A))