Buggy python submission (verdict: Runtime Error):
from bisect import insort_left

def main():
  N, M = map(int, input().split())
  A = sorted(list(map(int, input().split())))

  if M < N: 
    ans = sum(A[:N-M])
    A = A[N-M:]
  else: ans = 0

  if not len(A)-1: A[0] //= 2 ** M
  else:
    while M:
        a = A.pop(N-1)

        while a >= A[-1] and M:
            a //= 2
            M -= 1

        insort_left(A, a)

  print(ans + sum(A))

if __name__ == '__main__':
  main()

Fixed submission:
from heapq import heappush, heappop, heapify

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

  if N == 1: A[0] = A[0] // 2 ** M
  else:
    for i in range(N): A[i] *= -1

    heapify(A)

    for i in range(M):
      a = heappop(A)
      heappush(A, -(-a//2))

  print(-sum(A))  
  
if __name__ == '__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):

from bisect import insort_left

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

if not N-1:
  A[0] //= 2 ** M
		
else:
  while M:
	  a = A.pop(N-1)
	
	  while a >= A[-1] and M:
		  a //= 2
		  M -= 1
		
	  insort_left(A, a)
	
print(sum(A))

Fixed submission:
from heapq import heappush, heappop, heapify

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

  if N == 1: A[0] = A[0] // 2 ** M
  else:
    for i in range(N): A[i] *= -1

    heapify(A)

    for i in range(M):
      a = heappop(A)
      heappush(A, -(-a//2))

  print(-sum(A))  
  
if __name__ == '__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import insort_left

def main():
  N, M = map(int, input().split())
  A = sorted(list(map(int, input().split())))

  for i in range(M):
    a = A.pop(N-1)  
    insort_left(A, a//2)

  print(sum(A))  	
  
if __name__ == '__main__':
  main()
  

Fixed submission:
from heapq import heappush, heappop, heapify

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

  if N == 1: A[0] = A[0] // 2 ** M
  else:
    for i in range(N): A[i] *= -1

    heapify(A)

    for i in range(M):
      a = heappop(A)
      heappush(A, -(-a//2))

  print(-sum(A))  
  
if __name__ == '__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import insort_left

def main():
  N, M = map(int, input().split())
  A = sorted(list(map(int, input().split())))

  for i in range(M):
    a = A.pop(N-1)  
    insort_left(A, a//2)

  print(sum(list(map(int, A))))  	
  
if __name__ == '__main__':
  main()

Fixed submission:
from heapq import heappush, heappop, heapify

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

  if N == 1: A[0] = A[0] // 2 ** M
  else:
    for i in range(N): A[i] *= -1

    heapify(A)

    for i in range(M):
      a = heappop(A)
      heappush(A, -(-a//2))

  print(-sum(A))  
  
if __name__ == '__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import insort_left

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

for i in range(M):
  a = A.pop(N-1)  
  insort_left(A, a/2)
  
print(sum(list(map(int, A))))  

Fixed submission:
from heapq import heappush, heappop, heapify

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

  if N == 1: A[0] = A[0] // 2 ** M
  else:
    for i in range(N): A[i] *= -1

    heapify(A)

    for i in range(M):
      a = heappop(A)
      heappush(A, -(-a//2))

  print(-sum(A))  
  
if __name__ == '__main__':
  main()