Buggy python submission (verdict: Time Limit Exceeded):
import math
def binary_search(arr, val, start, end):
    if start == end: 
        if arr[start] > val: 
            return start 
        else: 
            return start+1
  
    if start > end: 
    	return start 
  
    mid = (start+end)//2
    if arr[mid] < val: 
        return binary_search(arr, val, mid+1, end) 
    elif arr[mid] > val: 
        return binary_search(arr, val, start, mid-1) 
    else: 
        return mid 
n,m=[int(x) for x in input().split()]
s,v=0,[]
for x in input().split():
	x=int(x)
	s+=x
	v.append(x)
v.sort()
while (m>0):
	if (v[-1]==0):
		break
	k=v[-1]/2
	s-=math.ceil(k)
	del v[-1]
	l=binary_search(v, math.floor(k), 0, len(v)-1)
	v=v[:l]+[math.floor(k)]+v[l:]
	m-=1
print(s)

Fixed submission:
#coding:utf-8
 
import heapq
 
N, M = map(int, input().split())
invA = []
for a in map(int, input().split()):
    heapq.heappush(invA, -1*a)
for m in range(M):
    heapq.heappush(invA, heapq.heappop(invA)/2)
total = -1*sum(map(int, invA))
 
print(total)

Buggy python submission (verdict: Time Limit Exceeded):
import math
def insert(list, n): 
	j=0
	for j in range(len(list)): 
		if list[j] > n: 
			break
      
	list = list[:j] + [n] + list[j:] 
	return list
n,m=[int(x) for x in input().split()]
s,v=0,[]
for x in input().split():
	x=int(x)
	s+=x
	v.append(x)
v.sort()
while (m>0):
	if (v[-1]==0):
		break
	k=v[-1]/2
	s-=math.ceil(k)
	del v[-1]
	v=insert(v,math.floor(k))
	m-=1
print(s)

Fixed submission:
#coding:utf-8
 
import heapq
 
N, M = map(int, input().split())
invA = []
for a in map(int, input().split()):
    heapq.heappush(invA, -1*a)
for m in range(M):
    heapq.heappush(invA, heapq.heappop(invA)/2)
total = -1*sum(map(int, invA))
 
print(total)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=[int(x) for x in input().split()]
v=[int(x) for x in input().split()]
def insert(list, n): 
	j=0
	for j in range(len(list)): 
		if list[j] > n: 
			break
      
	list = list[:j] + [n] + list[j:] 
	return list
v.sort()
while (m>0):
	if (v[-1]==0):
		break
	k=v[-1]/2
	del v[-1]
	v=insert(v,k)
	m-=1
i,sum=0,0
while(i<n):
	sum+=int(v[i])
	i+=1
print(sum)

Fixed submission:
#coding:utf-8
 
import heapq
 
N, M = map(int, input().split())
invA = []
for a in map(int, input().split()):
    heapq.heappush(invA, -1*a)
for m in range(M):
    heapq.heappush(invA, heapq.heappop(invA)/2)
total = -1*sum(map(int, invA))
 
print(total)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=[int(x) for x in input().split()]
v=[int(x) for x in input().split()]
def insert(list, n): 
	j=0
	for j in range(len(list)): 
		if list[j] > n: 
			break
      
	list = list[:j] + [n] + list[j:] 
	return list
v.sort()
while (m>0):
	k=v[-1]/2
	del v[-1]
	v=insert(v,k)
	m-=1
i,sum=0,0
while(i<n):
	sum+=int(v[i])
	i+=1
print(sum)

Fixed submission:
#coding:utf-8
 
import heapq
 
N, M = map(int, input().split())
invA = []
for a in map(int, input().split()):
    heapq.heappush(invA, -1*a)
for m in range(M):
    heapq.heappush(invA, heapq.heappop(invA)/2)
total = -1*sum(map(int, invA))
 
print(total)

Buggy python submission (verdict: Runtime Error):
n,m=[int(x) for x in input().split()]
v=[int(x) for x in input().split()]
def insert(list, n): 
      
    for i in range(len(list)): 
        if list[i] > n: 
            break
      
    list = list[:i] + [n] + list[i:] 
    return list
v.sort()
while (m>0):
	k=v[-1]/2
	del v[-1]
	v=insert(v,k)
	m-=1
i,sum=0,0
print(v)
while(i<n):
	sum+=int(v[i])
	i+=1
print(sum)

Fixed submission:
#coding:utf-8
 
import heapq
 
N, M = map(int, input().split())
invA = []
for a in map(int, input().split()):
    heapq.heappush(invA, -1*a)
for m in range(M):
    heapq.heappush(invA, heapq.heappop(invA)/2)
total = -1*sum(map(int, invA))
 
print(total)

Buggy python submission (verdict: Runtime Error):
n,m=[int(x) for x in input().split()]
v=[int(x) for x in input().split()]
def insert(list, n): 
      
    for i in range(len(list)): 
        if list[i] > n: 
            break
      
    list = list[:i] + [n] + list[i:] 
    return list
v.sort()
while (m>0):
	k=v[0]/2
	del v[0]
	v=insert(v,k)
	m-=1
i,sum=0,0
while(i<n):
	sum+=int(v[i])
	i+=1
print(sum)

Fixed submission:
#coding:utf-8
 
import heapq
 
N, M = map(int, input().split())
invA = []
for a in map(int, input().split()):
    heapq.heappush(invA, -1*a)
for m in range(M):
    heapq.heappush(invA, heapq.heappop(invA)/2)
total = -1*sum(map(int, invA))
 
print(total)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=[int(x) for x in input().split()]
v=[int(x) for x in input().split()]
v.sort(reverse=True)
while (m>0):
	v[0]=v[0]/2
	v.sort(reverse=True)
	m-=1
i,sum=0,0
while(i<n):
	sum+=int(v[i])
	i+=1
print(sum)

Fixed submission:
#coding:utf-8
 
import heapq
 
N, M = map(int, input().split())
invA = []
for a in map(int, input().split()):
    heapq.heappush(invA, -1*a)
for m in range(M):
    heapq.heappush(invA, heapq.heappop(invA)/2)
total = -1*sum(map(int, invA))
 
print(total)