Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python
# coding: UTF-8


#import scipy.optimize
import math

    
##################################################################

if __name__ == "__main__":

    Input = [input() for i in range(2)]
    N,M = list(map(int,Input[0].split()))
    A = list(map(int,Input[1].split()))
    A.sort(reverse=True)

    if N==1:
        Money = math.floor(A[0]/(2**M))
        print(Money)
    else:      
        Use = 0
        while Use < M:
            if A[0] == A[1]:
                Usenow = 1
                Use += Usenow
            else:
                Usenow = math.ceil(math.log2(A[0])-math.log2(A[1]))
                Use += Usenow
                if Use > M:
                    Usenow -= Use - M
                    Use = M
            temp = math.floor(A[0]/(2**Usenow))
            if temp >= A[1]:
                A[0] = temp
            else:
                for i in range(2,N):
                    if temp >= A[i]:
                        A[0:i-1] = A[1:i]
                        A[i-1] = temp
                        break
                    elif i == N-1:
                        A[0:N-1] = A[1:N]
                        A[N-1] = temp                        
                    else:
                        continue
        print(sum(A))                            


Fixed submission:
# coding: UTF-8

#import scipy.optimize
from math import ceil,floor
from heapq import heappush, heappop, heapify
    
##################################################################

if __name__ == "__main__":

    Input = [input() for i in range(2)]
    N,M = list(map(int,Input[0].split()))
    A = list(map(int,Input[1].split()))
    A = [-a for a in A]
    heapify(A)
    Use = 0
    while Use < M:
        temp = -1*heappop(A)
        temp = floor(temp/2)
        heappush(A, -temp)
        Use += 1
    print(sum(A)*-1)

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python
# coding: UTF-8


#import scipy.optimize
import math

    
##################################################################

if __name__ == "__main__":

    Input = [input() for i in range(2)]
    N,M = list(map(int,Input[0].split()))
    A = list(map(int,Input[1].split()))
    A.sort(reverse=True)

    if N==1:
        Money = math.floor(A[0]/(2**M))
        print(Money)
    else:      
        Use = 0
        while Use < M:
            if A[0] == A[1]:
                Usenow = 1
                Use += Usenow
            else:
                Usenow = math.ceil(math.log2(A[0])-math.log2(A[1]))
                Use += Usenow
                if Use > M:
                    Usenow -= Use - M
                    Use = M
            temp = math.floor(A[0]/(2**Usenow))
            for i in range(1,N):
                if temp < A[i]:
                    A[0:i] = A[1:i+1]
                    A[i] = temp
                    break
                else:
                    continue
        print(sum(A))                            


Fixed submission:
# coding: UTF-8

#import scipy.optimize
from math import ceil,floor
from heapq import heappush, heappop, heapify
    
##################################################################

if __name__ == "__main__":

    Input = [input() for i in range(2)]
    N,M = list(map(int,Input[0].split()))
    A = list(map(int,Input[1].split()))
    A = [-a for a in A]
    heapify(A)
    Use = 0
    while Use < M:
        temp = -1*heappop(A)
        temp = floor(temp/2)
        heappush(A, -temp)
        Use += 1
    print(sum(A)*-1)

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python
# coding: UTF-8


#import scipy.optimize
import math

    
##################################################################

if __name__ == "__main__":

    Input = [input() for i in range(2)]
    N,M = list(map(int,Input[0].split()))
    A = list(map(int,Input[1].split()))
    A.sort(reverse=True)

    if N==1:
        Money = math.floor(A[0]/(2**M))
        print(Money)
    else:      
        Use = 0
        while Use < M:
            if A[0] == A[1]:
                Usenow = 1
            else:
                Usenow = math.ceil(math.log2(A[0])-math.log2(A[1]))
            Use += Usenow
            if Use > M:
                Usenow -= Use - M
            temp = math.floor(A[0]/(2**Usenow))
            for i in range(1,N):
                if temp < A[i]:
                    A[0:i] = A[1:i+1]
                    A[i] = temp
                    break
                else:
                    continue
        print(sum(A))                            


Fixed submission:
# coding: UTF-8

#import scipy.optimize
from math import ceil,floor
from heapq import heappush, heappop, heapify
    
##################################################################

if __name__ == "__main__":

    Input = [input() for i in range(2)]
    N,M = list(map(int,Input[0].split()))
    A = list(map(int,Input[1].split()))
    A = [-a for a in A]
    heapify(A)
    Use = 0
    while Use < M:
        temp = -1*heappop(A)
        temp = floor(temp/2)
        heappush(A, -temp)
        Use += 1
    print(sum(A)*-1)