Buggy python submission (verdict: Time Limit Exceeded):
import bisect
 
N, M = map(int, input().split(" "))
As = [0]+list(map(int, input().split(" ")))
As.sort()
cnt = 0
cnt2 = 1
for j in range(M):
  i = As[-1-cnt]  
  i = i//(2**cnt2)
  if j == M-1 or i < As[-1-cnt-1]:
    cnt += 1
    cnt2 = 1
    bisect.insort_left(As,i)
  else:
    cnt2 += 1
 
print(sum(As[:-cnt]))

Fixed submission:
import heapq
 
N, M = map(int, input().split(" "))
As = [-i for i in map(int, input().split(" "))]
As.sort()
heapq.heapify(As)

for _ in range(M):
  i = - heapq.heappop(As)
  i = i >> 1
  heapq.heappush(As,-i)

print(-sum(As))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
 
N, M = map(int, input().split(" "))
As = [0]+list(map(int, input().split(" ")))
As.sort()
cnt = 0
cnt2 = 1
for j in range(M):
  i = As[-1-cnt]  
  i = i>>cnt2
  if j == M-1 or i < As[-1-cnt-1]:
    cnt += 1
    cnt2 = 1
    bisect.insort_left(As,i)
  else:
    cnt2 += 1
 
print(sum(As[:-cnt]))

Fixed submission:
import heapq
 
N, M = map(int, input().split(" "))
As = [-i for i in map(int, input().split(" "))]
As.sort()
heapq.heapify(As)

for _ in range(M):
  i = - heapq.heappop(As)
  i = i >> 1
  heapq.heappush(As,-i)

print(-sum(As))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
 
N, M = map(int, input().split(" "))
As = [0]+list(map(int, input().split(" ")))
As.sort()
cnt = 0
cnt2 = 1
for _ in range(M):
  i = As[-1-cnt]  
  i = i>>cnt2
  if i < As[-1-cnt-1]:
    cnt += 1
    cnt2 = 1
    bisect.insort_left(As,i)
  else:
    cnt2 += 1
 
print(sum(As[:-cnt]))

Fixed submission:
import heapq
 
N, M = map(int, input().split(" "))
As = [-i for i in map(int, input().split(" "))]
As.sort()
heapq.heapify(As)

for _ in range(M):
  i = - heapq.heappop(As)
  i = i >> 1
  heapq.heappush(As,-i)

print(-sum(As))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
 
N, M = map(int, input().split(" "))
As = [0]+list(map(int, input().split(" ")))
As = sorted(As)
cnt = 0
cnt2 = 1
for _ in range(M):
  i = As[-1-cnt]  
  i = i>>cnt2
  if i < As[-1-cnt-1]:
    cnt += 1
    cnt2 = 1
    bisect.insort_left(As,i)
  else:
    cnt2 += 1
 
print(sum(As[:-cnt]))

Fixed submission:
import heapq
 
N, M = map(int, input().split(" "))
As = [-i for i in map(int, input().split(" "))]
As.sort()
heapq.heapify(As)

for _ in range(M):
  i = - heapq.heappop(As)
  i = i >> 1
  heapq.heappush(As,-i)

print(-sum(As))

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

N, M = map(int, input().split(" "))
As = [0]+list(map(int, input().split(" ")))
As = sorted(As)
cnt = 0
cnt2 = 1
for _ in range(M):
  i = As[-1-cnt]  
  i = i//(2>>cnt2)
  if i < As[-1-cnt-1]:
    cnt += 1
    cnt2 = 1
    bisect.insort_left(As,i)
  else:
    cnt2 += 1

print(sum(As[:-cnt]))

Fixed submission:
import heapq
 
N, M = map(int, input().split(" "))
As = [-i for i in map(int, input().split(" "))]
As.sort()
heapq.heapify(As)

for _ in range(M):
  i = - heapq.heappop(As)
  i = i >> 1
  heapq.heappush(As,-i)

print(-sum(As))

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

N, M = map(int, input().split(" "))
As = list(map(int, input().split(" ")))
As = sorted(As)
cnt = 0
j = 0
for _ in range(M):
  if j >= As[-1-cnt]:
    i = j>>1
  else:
    i = As[-1-cnt]>>1
    
  j = i
  
  if i < As[-1-cnt-1]:
    cnt += 1
    bisect.insort_left(As,i)

if j > As[-1-cnt-1]:
  bisect.insort_left(As,j)
  cnt += 1

print(sum(As[:-cnt]))

Fixed submission:
import heapq
 
N, M = map(int, input().split(" "))
As = [-i for i in map(int, input().split(" "))]
As.sort()
heapq.heapify(As)

for _ in range(M):
  i = - heapq.heappop(As)
  i = i >> 1
  heapq.heappush(As,-i)

print(-sum(As))

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

N, M = map(int, input().split(" "))
As = list(map(int, input().split(" ")))
As = sorted(As)
cnt = 0
j = 0
for _ in range(M):
  if j >= As[-1-cnt]:
    i = j>>1
  else:
    i = As[-1-cnt]>>1
    
  j = i
  
  if i < As[-1-cnt-1]:
    cnt += 1
    bisect.insort_left(As,i)

if j > As[-1-cnt-1]:
  bisect.insort_left(As,j)

print(sum(As[:-cnt]))

Fixed submission:
import heapq
 
N, M = map(int, input().split(" "))
As = [-i for i in map(int, input().split(" "))]
As.sort()
heapq.heapify(As)

for _ in range(M):
  i = - heapq.heappop(As)
  i = i >> 1
  heapq.heappush(As,-i)

print(-sum(As))

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

N, M = map(int, input().split(" "))
As = [0]+list(map(int, input().split(" ")))
As = sorted(As)
cnt = 0
cnt2 = 1
for _ in range(M):
  i = As[-1-cnt]  
  i = i//(2**cnt2)
  if i < As[-1-cnt-1]:
    cnt += 1
    cnt2 = 1
    bisect.insort_left(As,i)
  else:
    cnt2 += 1

print(sum(As[:-cnt]))

Fixed submission:
import heapq
 
N, M = map(int, input().split(" "))
As = [-i for i in map(int, input().split(" "))]
As.sort()
heapq.heapify(As)

for _ in range(M):
  i = - heapq.heappop(As)
  i = i >> 1
  heapq.heappush(As,-i)

print(-sum(As))

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

N, M = map(int, input().split(" "))
As = [0]+list(map(int, input().split(" ")))
As = sorted(As)
cnt = 0
cnt2 = 1
for _ in range(M):
  i = As[-1-cnt]  
  i = i//(2**cnt2)
  if i < As[-1-cnt-1]:
    cnt += 1
    cnt2 = 1
    bisect.insort_left(As,i)
  else:
    cnt2 += 1

print(sum(As[:-cnt]))

Fixed submission:
import heapq
 
N, M = map(int, input().split(" "))
As = [-i for i in map(int, input().split(" "))]
As.sort()
heapq.heapify(As)

for _ in range(M):
  i = - heapq.heappop(As)
  i = i >> 1
  heapq.heappush(As,-i)

print(-sum(As))

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

for _ in range(M):
  i = As.index(max(As))
  As[i] = As[i]//2

print(sum(As))

Fixed submission:
import heapq
 
N, M = map(int, input().split(" "))
As = [-i for i in map(int, input().split(" "))]
As.sort()
heapq.heapify(As)

for _ in range(M):
  i = - heapq.heappop(As)
  i = i >> 1
  heapq.heappush(As,-i)

print(-sum(As))