Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
def binary_search(list,target): 

	result = -1
	left = 0
	right = len(list) - 1

	while left <= right:
		center = (left + right)//2
		if list[center] == target:
			result = center
			break
		elif list[center] < target:
			right = center - 1
		elif list[center] > target:
			left = center + 1
	if result == -1:
		return left
	else:
		return result

if N>1:
  for i in range(M):
    A[0]=A[0]//2
    if A[0]<A[1]:
      j=binary_search(A[1:],A[0])
      A=A[1:j+1]+[A[0]]+A[j+1:]
else:
  A[0]=A[0]//(2**M)
print(sum(A))

Fixed submission:
from collections import deque
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
q1=deque(A)
q2=deque([])
for i in range(M):
  if len(q1)!=0 and (len(q2)==0 or q1[0]>=q2[0]):
    x=q1.popleft()
  else:
    x=q2.popleft()
  q2.append(x//2)
print(int(sum(q1)+sum(q2)))

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

if N>1:
  for i in range(M):
    A[0]=A[0]//2
    if A[0]<A[1]:
      j=1
      while j<N:
        if A[0]>A[j]:
          A=A[1:j]+[A[0]]+A[j:]
          break
        else:
          j+=1
      if j==N:
        A=A[1:]+[A[0]]
else:
  A[0]=A[0]//(2**M)
print(sum(A))

Fixed submission:
from collections import deque
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
q1=deque(A)
q2=deque([])
for i in range(M):
  if len(q1)!=0 and (len(q2)==0 or q1[0]>=q2[0]):
    x=q1.popleft()
  else:
    x=q2.popleft()
  q2.append(x//2)
print(int(sum(q1)+sum(q2)))

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int, input().split())
ls = list(map(int, input().split()))
ls.sort()
def half(l):
  a=l.index(max(l))
  l[a]=l[a]//2
  return(l)
for i in range(M):
  half(ls)
print(sum(ls))

Fixed submission:
from collections import deque
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
q1=deque(A)
q2=deque([])
for i in range(M):
  if len(q1)!=0 and (len(q2)==0 or q1[0]>=q2[0]):
    x=q1.popleft()
  else:
    x=q2.popleft()
  q2.append(x//2)
print(int(sum(q1)+sum(q2)))

Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())
ls = list(map(int, input().split()))
for i in range(M)
  a=ls.index(max(ls))
  l[a]=l[a]//2
print(sum(ls))

Fixed submission:
from collections import deque
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
q1=deque(A)
q2=deque([])
for i in range(M):
  if len(q1)!=0 and (len(q2)==0 or q1[0]>=q2[0]):
    x=q1.popleft()
  else:
    x=q2.popleft()
  q2.append(x//2)
print(int(sum(q1)+sum(q2)))

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int, input().split())
ls = list(map(int, input().split()))
 
def half(l):
  a=l.index(max(l))
  l[a]=l[a]//2
  return(l)
for i in range(M):
  half(ls)
print(sum(ls))

Fixed submission:
from collections import deque
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
q1=deque(A)
q2=deque([])
for i in range(M):
  if len(q1)!=0 and (len(q2)==0 or q1[0]>=q2[0]):
    x=q1.popleft()
  else:
    x=q2.popleft()
  q2.append(x//2)
print(int(sum(q1)+sum(q2)))

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

def half(l):
  a=-1
  for i in range(len(l)):
    if l[i]==max(l):
      a=i
  l[a]=l[a]//2
  return(l)
for i in range(M):
  half(ls)
print(sum(ls))

Fixed submission:
from collections import deque
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
q1=deque(A)
q2=deque([])
for i in range(M):
  if len(q1)!=0 and (len(q2)==0 or q1[0]>=q2[0]):
    x=q1.popleft()
  else:
    x=q2.popleft()
  q2.append(x//2)
print(int(sum(q1)+sum(q2)))

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

def half(l):
  a=-1
  for i in range(len(l)):
    if l[i]==max(l):
      a=i
  l[a]=l[a]//2
  return(l)
for i in range(M):
  half(ls)
print(sum(ls))

Fixed submission:
from collections import deque
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
q1=deque(A)
q2=deque([])
for i in range(M):
  if len(q1)!=0 and (len(q2)==0 or q1[0]>=q2[0]):
    x=q1.popleft()
  else:
    x=q2.popleft()
  q2.append(x//2)
print(int(sum(q1)+sum(q2)))