Buggy python submission (verdict: Time Limit Exceeded):
import sys
import bisect
input=sys.stdin.readline

n,m=map(int, input().split())
a=list(map(int, input().split()))
a.sort()

for _ in range(m):
    val=a.pop()//2
    bisect.insort(a, val)

print(sum(a))


Fixed submission:
import sys
import heapq
import numpy as np
input=sys.stdin.readline

n,m=map(int, input().split())
a=list(map(int, input().split()))
h=[]
for val in a:
    heapq.heappush(h, -val)

for _ in range(m):
    val=(-heapq.heappop(h))//2
    heapq.heappush(h, -val)

print(-sum(h))

Buggy python submission (verdict: Runtime Error):
import sys
import bisect
input=sys.stdin.readline

n,m=map(int, input().split())
a=list(map(int, input().split()))

a.sort()

e=a[:n-m-1]
d=a[n-m-1:]
f=0

for _ in range(m):
    val=d.pop()//2
    if val > d[0]:
        bisect.insort(d, val)
    else:
        f+=val

print(sum(e)+sum(d)+f)


Fixed submission:
import sys
import heapq
import numpy as np
input=sys.stdin.readline

n,m=map(int, input().split())
a=list(map(int, input().split()))
h=[]
for val in a:
    heapq.heappush(h, -val)

for _ in range(m):
    val=(-heapq.heappop(h))//2
    heapq.heappush(h, -val)

print(-sum(h))

Buggy python submission (verdict: Runtime Error):
import sys
import bisect
input=sys.stdin.readline

n,m=map(int, input().split())
a=list(map(int, input().split()))

a.sort()

e=a[:n-m]
d=a[n-m:]
f=[0]

for _ in range(m):
    val=d.pop()//2
    if val > d[0]:
        bisect.insort(d, val)
    else:
        f.append(val)

print(sum(e)+sum(d)+sum(f))


Fixed submission:
import sys
import heapq
import numpy as np
input=sys.stdin.readline

n,m=map(int, input().split())
a=list(map(int, input().split()))
h=[]
for val in a:
    heapq.heappush(h, -val)

for _ in range(m):
    val=(-heapq.heappop(h))//2
    heapq.heappush(h, -val)

print(-sum(h))

Buggy python submission (verdict: Runtime Error):
import sys
import bisect
input=sys.stdin.readline

n,m=map(int, input().split())
a=list(map(int, input().split()))

a.sort()

e=a[:n-m]
d=a[n-m:]

for _ in range(m):
    val=d.pop()//2
    if val > d[0]:
        bisect.insort(d, val)
    else:
        e.append(val)

print(sum(e)+sum(d))


Fixed submission:
import sys
import heapq
import numpy as np
input=sys.stdin.readline

n,m=map(int, input().split())
a=list(map(int, input().split()))
h=[]
for val in a:
    heapq.heappush(h, -val)

for _ in range(m):
    val=(-heapq.heappop(h))//2
    heapq.heappush(h, -val)

print(-sum(h))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import bisect
input=sys.stdin.readline

n,m=map(int, input().split())
a=list(map(int, input().split()))

a.sort()

e=a[:n-m]
d=a[n-m:]

for _ in range(m):
    val=d.pop()//2
    bisect.insort(d, val)

print(sum(e)+sum(d))


Fixed submission:
import sys
import heapq
import numpy as np
input=sys.stdin.readline

n,m=map(int, input().split())
a=list(map(int, input().split()))
h=[]
for val in a:
    heapq.heappush(h, -val)

for _ in range(m):
    val=(-heapq.heappop(h))//2
    heapq.heappush(h, -val)

print(-sum(h))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import bisect
input=sys.stdin.readline

n,m=map(int, input().split())
a=list(map(int, input().split()))

a.sort()

for _ in range(m):
    val=a.pop()//2
    bisect.insort(a, val)

print(sum(a))


Fixed submission:
import sys
import heapq
import numpy as np
input=sys.stdin.readline

n,m=map(int, input().split())
a=list(map(int, input().split()))
h=[]
for val in a:
    heapq.heappush(h, -val)

for _ in range(m):
    val=(-heapq.heappop(h))//2
    heapq.heappush(h, -val)

print(-sum(h))