TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
import math
a,b = list(map(int,input().split()))
cf=[1]
ccf=[1]
for i in range(2,min(a,b)+1):
  if a % i == 0 and b % i == 0:
    cf.append(i)
for ii in range (len(cf)):
  q=0
  if cf[ii] == 1: 
    q =1
  for k in range(2, int(math.sqrt(cf[ii])) + 1):
    if cf[ii] % k == 0:
      q=1
  if q ==0:
    ccf.append(cf[ii])
print(len(ccf))

import heapq
n,m = list(map(int,input().split()))
l = sorted([(int(a)*-1) for a in input().split()])
for i in range (m):
  high = heapq.heappop(l)
  heapq.heappush(l,high//2)
print(abs(sum(l)))

import heapq
n,m = list(map(int,input().split()))
l = sorted([(int(a)*-1) for a in input().split()])
for i in range (m):
  high = heapq.heappop(l)
  heapq.heappush(l,-(-high//2))
print(abs(sum(l)))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
from heapq import heappush, heappop

N,M = map(int, input().split())
a = [int(i) for i in input().split()]

hq = heapq.heapify(a)

for i in range(N):
    heappush(hq, -a[i])

for i in range(M):
    tmp = -heappop(hq) // 2
    heappush(hq, -tmp)

print(-sum(hq)) 

from heapq import heappush, heappop, heapify

def main():
    N,M = map(int, input().split())
    hq = [-int(i) for i in input().split()]

    heapify(hq)

    for i in range(M):
        tmp = -heappop(hq) // 2
        heappush(hq, -tmp)

    print(-sum(hq))    

if __name__ == "__main__":
    main()
    

Verdicts: Runtime Error

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
N, M = map(int, input().split())
li = list(map(int, input().split()))
for i in range(M):
  li.append((max(li))/2)
  li.remove(max(li))
for j in range(N):
  li[j] = li[j]//1
print(sum(li))

N, M = map(int, input().split())
li = list(map(int, input().split()))
for i in range(M):
  a = max(li)
  li.remove(a)
  li.append(a/2)
for j in range(N):
  li[j] = li[j]//1
print(sum(li))
  

import heapq
n, m = map(int, input().split())
li = [-int(x) for x in input().split()]
heapq.heapify(li)
for i in range(m):
  a = heapq.heappop(li)
  heapq.heappush(li, a/2)
print(-sum(int(x) for x in li))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
n,m = map(int,input().split())
a = list(map(int,input().split()))
a = a.sort()
for i in range(m):
  a[-1] = a[-1]*0.5
  a = a.sort()
sum( i//1 for i in a)

def main():
  import heapq
  n,m = map(int,input().split())
  a =sorted(list(map(lambda x: int(x)*(-1),input().split())))
  heapq.heapify(a)
  for _ in range(m):
    x=heapq.heappop(a)/2
    heapq.heappush(a,x) 
  print(int(sum((-1)*i//1 for i in a)))
if __name__=='__main__':
  main()

Verdicts: Runtime Error

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
import heapq
n, m = map(int, input().split())
lis = list(map(int,input().split()))
for i in range(n):
  lis[i] *= -1
print(lis)
lis.sort(reverse=True)
heapq.heapify(lis)
for m in range(m):
  a = -(-heapq.heappop(lis) // 2)
  heapq.heappush(lis, a)
print(-sum(lis))

import heapq
n, m = map(int, input().split())
lis = list(map(int,input().split()))
for num in lis:
  num *= (-1)
lis.sort(reverse=True)
heapq.heapify(lis)
for m in range(m):
  a = -(-heapq.heappop(lis) // 2)
  heapq.heappush(lis, a)
print(-sum(lis))

n,m = map(int,input().split())
lis = [[] for i in range(31)]
li = list(map(int,input().split()))
li.sort()
num = 0
for i in range(n):
  while 2**num < li[i]:
    num += 1
  lis[30-num].append(li[i])

for i in range(30):
  lis[i].sort(reverse=True)
  for nu in lis[i]:
    if m:
      p = lis[i].pop(0)
      lis[i+1].append(p//2)
      m -= 1
print(sum([sum(lis[i]) for i in range(30)]))

import heapq
n, m = map(int, input().split())
lis = list(map(int,input().split()))
for i in range(n):
  lis[i] *= -1
lis.sort(reverse=True)
heapq.heapify(lis)
for m in range(m):
  a = -(-heapq.heappop(lis) // 2)
  heapq.heappush(lis, a)
print(-sum(lis))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
import math
n,m=map(int, input().split())
a=sorted(list(map(int, input().split())),reverse=True)
tot=0
rate=[0]*n
p=[0]*n

for i in range(n-1):
  rate[i]=math.log2(a[i]/a[i+1])
  
cur=0
while m>0:
  if rate[cur]>0:
    p[cur]+=1
    rate[cur]-=1
    m-=1
    if cur>0:
      rate[cur-1]+=1
      cur-=1
  else:
    if cur+1<n
      cur+=1
    else:
      p[cur+1]+=1
      rate[cur+1]-=1
      rate[cur]+=1
      cur-=1
  
for i in range(n):
  tot+=int(a[i]/(2**p[i]))
print(tot)

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

for i in range(n):
    a[i]*=-1

heapq.heapify(a)
for _ in range(m):
    x=heapq.heappop(a)*(-1)
    x=x//2
    heapq.heappush(a,-x)

print(sum(a)*(-1))

Verdicts: Runtime Error

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
import bisect
import copy

N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
A2 = copy.deepcopy(A[N-M:])

for _ in range(M):
  tmp_a = int(A2[-1]/2)
  del A2[-1]
  if A2 <= tmp_a: A2.append(tmp_a)
  else: A2.insert(bisect.bisect_left(A2,tmp_a),tmp_a)
print(sum(A[:N-M])+sum(A2))

import bisect
import copy

N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
A2 = copy.deepcopy(A[N-M:])

for _ in range(M):
  tmp_a = int(A2[-1]/2)
  del A2[-1]
  idx = bisect.bisect_left(A2,tmp_a)
  A2 = A2[:idx] + [tmp_a] + A2[idx+1:]
print(sum(A[:N-M])+sum(A2))


import heapq
import math

N, M = map(int, input().split())
A = []
for a in map(int, input().split()):
    heapq.heappush(A, -a)

for _ in range(M):
    neg_a = heapq.heappop(A)
    heapq.heappush(A, -math.floor(-neg_a/2))

print(-sum(A))

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
import bisect
import math

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

A.sort()
if len(A) < 2:
    ans = int(A[0] / (2**M))
else:
    fst = A[-1]
    scd = A[-2]

    while M > 0:
        if fst == scd:
            Y = 1
        else:
            Y = math.ceil(math.log2(fst/scd))
        print(Y)
        largest = A.pop(-1)
        largest = int(largest / (2**Y))
        print(largest)
        M = M - Y
        bisect.insort(A, largest)
        fst = A[-1]
        scd = A[-2]
        print(A)
    ans = sum(A)

print(ans)

import heapq

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

A = [-1 * i for i in A]
heapq.heapify(A)

for i in range(M):
    fst = heapq.heappop(A)
    fst = int(fst / 2)
    heapq.heappush(A, fst)
    
ans = -1 * sum(A)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
import heapq

N, M = map(int, input().split())

A = list(map(int, input().split()))
A = list(map(lambda x:x*(-1), A))

heapq.heapify(A)

for i in range(M):
    x = (heapq.heappop(A))*(-1)
    heapq.heappush(A, -(x//2))

print(A)
print(sum(A)*(-1))

import heapq

N, M = map(int, input().split())

A = list(map(int, input().split()))
A = list(map(lambda x:x*(-1), A))

heapq.heapify(A)

for i in range(M):
    x = heapq.heappop(A)
    heapq.heappush(A, x//2)

print(sum(A)*(-1))

import heapq

N, M = map(int, input().split())

A = list(map(int, input().split()))
A = list(map(lambda x:x*(-1), A))

heapq.heapify(A)

for i in range(M):
    x = (heapq.heappop(A))*(-1)
    heapq.heappush(A, -(x//2))

print(sum(A)*(-1))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
import heapq

n, m = list(map(int, input().split()))
a = list(map(lambda x: -float(x), input().split()))

heap = heapq.heapify(a)
for t in range(m):
  discount = heapq.heappop(heap) / 2.
  heapq.heappush(heap, discount)
    
print(sum(map(lambda x: int(-x), heap)))

import heapq

n, m = list(map(int, input().split()))
a = list(map(lambda x: -float(x), input().split()))

heapq.heapify(a)
for t in range(m):
  discount = heapq.heappop(a) / 2.
  heapq.heappush(a, discount)
    
print(sum(map(lambda x: int(-x), a)))

Verdicts: Runtime Error

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
val = list(map(int,input().split()))
my_index = val.index
for _in range(m):
  val[my_index(max(val))] = max(val)//2
print(sum(val))

import heapq
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
for i in range(n):
  a[i] *= -1

heapq.heapify(a)
for i in range(m):
    heapq.heapreplace(a, int(a[0] / 2))

print(sum(a)*-1)

Verdicts: Runtime Error

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
import numpy as np

N, M = map(int, input().split())
a = np.array(list(map(int, input().split())))

if N == 1:
    for i in range(M):
        a //= 2
    print(a[0])
    exit()

a.sort()
cur = M - 1
for i in range(M):
    if i == 0:
        a[-1] //= 2
    else:
        if (a[cur-1] > a[cur]):
            cur -= 1
            a[a[cur:].argmax()] //= 2
        else:
            a[-1] //= 2
print(sum(a))

import heapq

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

q = []
for i in range(N):
    
    heapq.heappush(q, -a[i])
for i in range(M):
    l = heapq.heappop(q)
    heapq.heappush(q, -(-l//2))
print(-sum(q))

Verdicts: Runtime Error

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
import heapq

K = input()
a = LI()

a = list(map(lambda x: x*(-1), a))  

heapq.heapify(a)

for i in range(
print(heapq.heappop(a)*(-1))  
print(a)

import heapq
import math

def LI():
  return [int(s) for s in input().split()]

N,M = LI()
a = LI()
a = list(map(lambda x: x*(-1), a))  

heapq.heapify(a)

for i in range(M):
    x = (-1)*(abs(heapq.heappop(a))//2)
    print(x)
    heapq.heappush(a,x)

cost = 0
for i in range(N):
  x = heapq.heappop(a)
  cost+=abs(x)
  
print(cost)

import heapq

def LI():
  return [int(s) for s in input().split()]

N,M = LI()
a = LI()
a = list(map(lambda x: x*(-1), a))  

heapq.heapify(a)

for i in range(M):
    x = heapq.heappop(a)//2
    heapq.heappush(a,x)

cost = 0
for i in range(N):
  x = heapq.heappop(a)
  cost+=abs(x)
  
print(cost)

import heapq
import math
 
def LI():
  return [int(s) for s in input().split()]
 
N,M = LI()
a = LI()
a = list(map(lambda x: x*(-1), a))  
 
heapq.heapify(a)
 
for i in range(M):
    x = (-1)*(abs(heapq.heappop(a))//2)
    heapq.heappush(a,x)

cost = 0
for i in range(N):
  x = heapq.heappop(a)
  cost+=abs(x)
  
print(cost)

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
# https://juppy.hatenablog.com/entry/2019/04/05/%E8%9F%BB%E6%9C%AC_Python_%E3%83%97%E3%83%A9%E3%82%A4%E3%82%AA%E3%83%AA%E3%83%86%E3%82%A3%E3%82%AD%E3%83%A5%E3%83%BC_2_heapq_%E7%AB%B6%E6%8A%80%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3
import heapq

n,m,*a = map(int, open(0).read().split())

# a = [1,7,3,5,4]

# #heapify

hq = heapq._heapify_max(a)
# print(a) #[7, 5, 3, 1, 4]

# #heappop

# print(_heappop_max(a)) #7
# print(a) #[5, 4, 3, 1]

# #heappush

# _heappush_max(a,2)
# print(a) #[5, 4, 3, 1, 2]


# print(_heappop_max(a)) #5
s = sum(a)
d = 0
for i in range(m):
  t = heapq._heappop_max(a)
  d += t-t//2
  heapq._heapreplace_max(a, t//2)
  # print(a)

print(s-d)

import heapq
def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappop_max(heap):
    lastelt = heap.pop()
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt

n,m,*a = map(int, open(0).read().split())

heapq._heapify_max(a)
s = sum(a)
d = 0
for i in range(m):
  t = _heappop_max(a)
  d += t-t//2
  _heappush_max(a, t//2)

print(s-d)

Verdicts: Runtime Error

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
import sys
from io import StringIO
import unittest
import heapq

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,m=map(int, readline().rstrip().split())
    arr=list(map(int, readline().rstrip().split()))
    heapq.heapify(arr)
    for i in range(n):
        arr[i]*=-1
    for _ in range(m):
        x=(heapq.heappop(arr)*-1)//2
        heapq.heappush(arr, -x)
    ans=0
    for i in range(n):
        ans+=(arr[i]*-1)
    print(ans)
    #n=int(readline())
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()


import sys
from io import StringIO
import unittest
import heapq

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,m=map(int, readline().rstrip().split())
    arr=list(map(int, readline().rstrip().split()))
    for i in range(n):
        arr[i]*=-1
    heapq.heapify(arr)
    for _ in range(m):
        x=(heapq.heappop(arr)*-1)//2
        heapq.heappush(arr, -x)
    ans=0
    for i in range(n):
        ans+=(arr[i]*-1)
    print(ans)
    #n=int(readline())
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

Verdicts: Wrong Answer

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
import numpy as np
n,m = map(int,input().split())
a_array = np.array([map(int,input().split())])
for i in range(m):

  a_array[np.argmax(a_array)] = a_array[np.argmax(a_array)]//2
   
print(np.sum(a_array))


n,m = map(int,input().split())
import math
a_list = list(map(int,input().split()))
for i in range(n):
  a_list[i] = -1 * a_list[i]
import heapq
heapq.heapify(a_list)
for j in range(m):
  
  a = heapq.heappop(a_list)
  a = math.ceil(a/2)
  heapq.heappush(a_list,a)


print(-1 * sum(a_list))

Verdicts: Runtime Error

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
import heapq
n, m = map(int, input().split(' '))
a = []
for i in list(map(int, input().split(' '))):
    heapq.heappush(a,-i)

for _ in range(m):
    p = heapq.heappop(a)
    heapq.heappush(a, p//2)

print(-sum(a))

import heapq
n, m = map(int, input().split(' '))
a = []
for i in list(map(int, input().split(' '))):
    heapq.heappush(a,-i)
if n == 1:
    ans = a[0]//(2**m)
    print(ans)

else:
    for _ in range(m):
        p = heapq.heappop(a)
        heapq.heappush(a, p//2)

    print(-sum(a))

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

for _ in range(m):
    p = heapq.heappop(a)
    heapq.heappush(a, int(p/2))

print(-sum(a))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
from math import log2
from bisect import bisect_right
n, m = map(int, input().split())
a = [int(ai) for ai in input().split()]
a.sort()
b = [log2(ai) for ai in a]
ma = int(b[-1])
c = 0
tmp = 0
for t in range(ma)[::-1]:
  i = bisect_right(b, t)
  d = n - i
  if c + d <= m:
    c += d
    for j in range(i, n):
      a[j] = a[j] / 2.0
  else:
    a.sort(reverse=True)
    for j in range(m-c):
      a[j] = a[j] / 2.0
print(sum([int(ai) for ai in a]))

from math import log2
from bisect import bisect_right
n, m = map(int, input().split())
a = [int(ai) for ai in input().split()]
a.sort()
b = [log2(ai) for ai in a]
ma = int(b[-1])
c = 0
tmp = 0
for t in range(-1, ma+1)[::-1]:
  i = bisect_right(b, t)
  d = n - i
  if c + d <= m:
    c += d
    for j in range(i, n):
      a[j] = a[j] / 2.0
  else:
    a.sort(reverse=True)
    for j in range(m-c):
      a[j] = a[j] / 2.0
    break
print(sum([int(ai) for ai in a]))


Verdicts: Wrong Answer

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
N,M = map(int,input()split())
lis = list(map(lambda x: -int(x),input().split()))

import heapq
heapq.heapify(lis)
for _ in range(M):
    tmp = -heapq.heappop(lis)
    tmp //= 2
    heapq.heappush(lis,-tmp)

print(-sum(lis))


N,M = map(int,input().split())
lis = list(map(lambda x: -int(x),input().split()))

import heapq
heapq.heapify(lis)
for _ in range(M):
    tmp = -heapq.heappop(lis)
    tmp //= 2
    heapq.heappush(lis,-tmp)

print(-sum(lis))


Verdicts: Runtime Error

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(m):
    heapq.heapify(a)
    a[n-1]=a[n-1]//2
ans=0
for i in range(n):
    ans+=a[i]
print(ans)


import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))
lis=[]
for i in range(n):
    heapq.heappush(lis,-a[i])
for i in range(m):
    b=(heapq.heappop(lis)*(-1)//2)*(-1)
    heapq.heappush(lis,b)
    #print(lis)
ans=0
#print(lis)
for i in range(n):
    ans+=lis[i]
print(-ans)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
import sys
import math
pos=input()
pos=pos.split()
N=int(pos[0])
M=int(pos[1])

item=input()
item=item.split()
item=[float(d) for d in item]
for i in range(1,M+1):
    print(max(item))
    item[item.index(max(item))]=math.floor(max(item)/(2.0))
    
print(int(sum(item)))


import math
import numpy as np
pos=input()
pos=pos.split()
N=int(pos[0])
M=int(pos[1])

item=input()
item=item.split()
item=[float(d) for d in item]
npitem=np.array(item)
for i in np.arange(1,M+1):
  print(np.max(npitem))
  npitem[np.argmax(npitem)]=np.max(npitem)/2.0
    
print(int(np.floor(np.sum(npitem))))





import sys
import math
import numpy as np
from heapq import heappush, heappop
pos=input()
pos=pos.split()
N=int(pos[0])
M=int(pos[1])
sum=0

item=input()
item=item.split()
item=list(map(float,item))

hq=[]
for i in item:
  heappush(hq,-i)
  
for j in range(1,M+1):
  temp=heappop(hq)
  heappush(hq,math.ceil(temp/2.0))
  
for k in range(0,N):
  sum-=heappop(hq)
print(int(sum))





Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
from heapq import heappush, heappop

def main():
    N, M = map(int, input().split())
    A = []
    
    for a in list(map(int, input().split())): heappush(A, -a)
    
    if not N-1:
        A[0] = (-A[0]) // 2 ** M
    else:
        while M:
            a = heappop(A)
            b = heappop(A)
    
            while a >= b and M:
                a = int(a//2)
                M -= 1
                
            heappush(A, a)
            heappush(A, b)
            
    print(-sum(A))

if __name__ == '__main__':
    main()

from heapq import heappush, heappop, heapify

N, M = list(map(int, input().split()))
A = [-a for a in list(map(int, input().split()))]
heapify(A)

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

print(-sum(list(map(int, A))))

Verdicts: Wrong Answer

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
from bisect import insort
N,M = map(int,input().split())
A = (list(map(int,input().split())))
A.sort()
for i in range(M):
  mx = A.pop()
  insert_index = bisect.bisect_left(A,mx//2)
  A.insert(insert_index,mx//2)
print(sum(A))
  

N,M = map(int,input().split())
A = list(map(lambda x: int(x)*(-1),input().split()))
import heapq
heapq.heapify(A)
for i in range(M):
  B = heapq.heappop(A)
  heapq.heappush(A,-1*((-B)//2))
print(-sum(A))
  

Verdicts: Runtime Error

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
def main():
  from heapq import heapify,heappush,heappop
  n,m,*a=[-int(i)for i in open(0).read().split()]
  heapify(a)
  for _ in range(m):heappush(a,0--heappop(a)//2)
  print(-sum(a))
main()

from heapq import*;n,m,*a=eval(',-'.join(open(0).read().split()));a.sort();exec('heappush(a,-~heappop(a)//2);'*-m);print(-sum(a))

Verdicts: Wrong Answer

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
i = 0
while i < m:
    a[n-1] = a[n-1] // 2
    i+=1
    if i == m:
        break
    j = 0
    while True:
        if a[n-j-2] > a[n-1] and i+j <= m:
            a[n-j-2] = a[n-j-2] // 2
            j+=1
        else:
            break
    if i+j <= m:
        break
    i += j
    a.sort()

print(sum(a))


n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
i = 0
while i < m:
    a[n-1] = a[n-1] // 2
    i+=1
    if i == m:
        break
    j = 0
    while a[n-j-2] > a[n-1] and i+j < m:
        a[n-j-2] = a[n-j-2] // 2
        j+=1
    if i+j <= m:
        break
    i += j
    a.sort()

print(sum(a))


n, m = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
    for i in range(m):
        a[0] = a[0] // 2
    print(sum(a))
    exit()

a.sort()
i = 0
while i < m:
    a[n-1] = a[n-1] // 2
    i+=1
    if i == m:
        break
    j = 0
    while a[n-j-2] > a[n-1] and i+j < m:
        a[n-j-2] = a[n-j-2] // 2
        j+=1
    if i+j <= m:
        break
    i += j
    a.sort()

print(sum(a))


n, m = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
    for i in range(m):
        a[0] = a[0] // 2
    print(sum(a))
    exit()

a.sort()
i = 0
while i < m:
    a[n-1] = a[n-1] // 2
    i+=1
    num = len([1 for x in a[:n-1] if x > a[n-1]])
    hoge = min(m-i, num)
    for j in range(hoge):
        a[n-2-j] = a[n-2-j] // 2
    i += hoge
    a.sort()

print(sum(a))


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
N, M = map(int, input().split())
A = list(map(int, input().split()))

A = sorted(A)[::-1]
a = 0
for i in range(M):
    x = A[a]
    A[a] = A[a] // 2
    if a+1 <= len(A)-1:
        if A[a] < A[a+1]:
            a += 1

print(sum(A))

import heapq

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

for a in A:
    a = a * (-1)

heapq.heapify(A)
for _ in range(M):
    x = heapq.heappop(A)
    heapq.heappush(A, (-x//2)*(-1))

print(-sum(A))

import heapq

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

for i in range(len(A)):
    A[i] *= -1

heapq.heapify(A)
for _ in range(M):
    x = heapq.heappop(A)
    heapq.heappush(A, (-x//2)*(-1))

print(-sum(A))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
from heapq import heapify,heappop,heappush
n,m=map(int,input().split())
a=[-int(_) for _ in input().split()]
a=heapify(a)
for i in range(m):
	heappush(a,heappop//2)
print(sum(a)*-1)

from heapq import heapify,heappop,heappush
n,m=map(int,input().split())
a=[-int(_) for _ in input().split()]
heapify(a)
for i in range(m):
	heappush(a,heappop(a)//2)
print(sum(a)*-1)

from heapq import heapify,heappop,heappush
n,m=map(int,input().split())
a=[-int(_) for _ in input().split()]
heapify(a)
for i in range(m):
	num=heappop(a)*-1
	heappush(a,(num//2)*-1)
print(sum(a)*-1)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
import sys
n,m = map(int,input().split())
lst_a = list(map(int,input().split()))
temp = 0
cnt = 0
fin = 0
loop = 0
debug = 0
temp2 = 0
if n == 1:
    for i in range(m):
        lst_a[0] //= 2
    print(lst_a[0])
    sys.exit()
while debug < 10:
    loop = 0
    #temp2 = temp
    temp = 0
    lst_a.sort(reverse=True)
    while loop < n-1:
        lst_a[loop] //= 2
        cnt += 1
        temp = max(temp,lst_a[loop])
        if cnt == m:
            print(lst_a)
            print(sum(lst_a))
            sys.exit()
        if temp > max(lst_a[loop],lst_a[loop + 1]):
            break
        if lst_a[loop + 1] > lst_a[loop]:
            loop += 1
        
        
        
"""        if lst_a[loop] >= max(lst_a[loop + 1],temp):
            lst_a[loop] //= 2
            temp = max(lst_a[loop],lst_a[loop+1])
            cnt += 1
            if cnt == m:
                print(sum(lst_a))
                sys.exit()
            if temp > lst_a[loop + 1]:
                break
            
            
        loop += 1
    
    #debug += 1
print(lst_a[99999])
# print(temp)
# print(cnt)
# print(lst_a)
# print(sum(lst_a))
"""

import heapq
n,m = map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
    a[i] = -a[i]
a.sort()
heapq.heapify(a)
for i in range(m):    
    p=heapq.heappop(a)
    heapq.heappush(a,(p+1)//2)
print(sum(a)*(-1))

Verdicts: Wrong Answer

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
program D
    implicit none
    integer::n,m,i
    real(8)::ans
    real(8),allocatable::a(:)
    read*,n,m
    allocate(a(n))
    read*,a
    if ( n == 1) then
        ans = a(0) * (0.5) ** m
    else
        do i = 0 , m
            a(maxloc(a,1)) = a(maxloc(a,1)) * 0.5
        end do
        ans = sum(a)
    end if
    print*,ans
end program D

import heapq
n,m = map(int,input().split())
a = list(map(int,input().split()))
a = [ -i for i in a ]
heapq.heapify(a)

for i in range(m):
    tmp_min = heapq.heappop(a)
    heapq.heappush(a, (-1)*(-tmp_min//2))
print(-sum(a))


Verdicts: Runtime Error

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):

import heapq

N,M = map(int,input().split())
A = list(map(lambda x:(-1)*int(x),input().split()))

heapq.heapify(A)

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

print(-sum(A))

import heapq

n,m = map(int,input().split())
a = list(map(int,input().split()))
a = list(map(lambda x: -x, a))
heapq.heapify(a)

#print(a)

for i in range(m):
    x = heapq.heappop(a)
    x = (-x)//2
    heapq.heappush(a,-x)
print(-sum(a))


Verdicts: Wrong Answer

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
def main():
    n, m = list(map(int, input().split()))
    t = list(map(int, input().split()))
    while m > 0:
        idx = 0
        t.sort(reverse=True)
        # print(t)
        t[0] //= 2
        m -= 1
        if m != 0:
            if t[0] > t[1]:
                t[0] //= 2
            else:
                t[1] //= 2
            m -= 1

    print(sum(t))

def main():
    n, m = list(map(int, input().split()))
    t = list(map(int, input().split()))
    t = list(map(lambda x: x*(-1), t))
    heapq.heapify(t)
    while m > 0:
        v = heapq.heappop(t) * -1
        heapq.heappush(t, (v // 2)* -1)
        m -= 1

    print(sum(t)*-1)


if __name__ == '__main__':
    main()

import heapq
def main():
    n, m = list(map(int, input().split()))
    t = list(map(int, input().split()))
    t = list(map(lambda x: x*(-1), t))
    heapq.heapify(t)
    while m > 0:
        v = heapq.heappop(t) * -1
        heapq.heappush(t, (v // 2)* -1)
        m -= 1

    print(sum(t)*-1)


if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
import sys
import numpy as np
def input():
    return sys.stdin.readline()[:-1]

N, M = map(int, input().split())

A = list(map(int, input().split()))

for _ in range(M):
    max_index = np.argmax(A)
    print(max_index)
    A[max_index] = int(A[max_index] / 2)

print(sum(A))

import sys
import numpy as np
import math
import heapq
def input():
    return sys.stdin.readline()[:-1]

N, M = map(int, input().split())
A = list(map(lambda a: int(a)*(-1), input().split()))
heapq.heapify(A)

for _ in range(M):
    heapq.heappush(A, math.trunc(heapq.heappop(A) / 2))

print(sum(A)*(-1))

Verdicts: Wrong Answer

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
class Node:
    def __init__(self,data):
        self.data = data
        self.left = None
        self.right = None
        self.same = 1

class BST:
    def __init__(self):
        self.root = None
    
    def insert(self,data):
        n = self.root
        if n == None:
            self.root = Node(data)
            return
        else:
            while True:
                if n.data > data:
                    if n.left is None:
                        n.left = Node(data)
                        return
                    n = n.left
                elif n.data < data:
                    if n.right is None:
                        n.right = Node(data)
                        return
                    n = n.right
                elif n.data == data:
                    n.same += 1
                    return
    
    def delete_max(self):
        n = self.root
        while True:
            if n.right == None:
                break
            else:
                n = n.right
        tmp = n.data//2
        if n.same > 1:
            n.same -= 1
        else:
            if n.left == None:
                n = None
            else:
                n.data = n.left.data
                n.left = None

        self.insert(tmp)
    
    def sum_bst(self,node):
        if node.left == None and node.right == None:
            return node.data*node.same
        else:
            s = node.data*node.same
            if node.left != None:
                s += self.sum_bst(node.left)
            if node.right != None:
                s += self.sum_bst(node.right)
            return s

N,M = map(int,input().split())

bst = BST()
for a in list(map(int,input().split())):
    bst.insert(a)
print(bst.sum_bst(bst.root))
for i in range(M):
    bst.delete_max()
print(bst.sum_bst(bst.root))

import heapq

N,M = map(int,input().split())
A = list(map(int,input().split()))
A = list(map(lambda x:x*(-1), A))

heapq.heapify(A)

for _ in range(M):
    A_max = heapq.heappop(A)*(-1)
    heapq.heappush(A, (A_max//2)*(-1))

print(sum(A)*(-1))

Verdicts: Wrong Answer

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
import numpy as np
N,M=map(int, input().split())
A=np.array(list(map(int, input().split())))
for i in range(M):
    A[A.argmax()]=A[A.argmax()]//2
sum(A)

import heapq

N,M = map(int, input().split())
A = list(-int(i) for i in input().split()) 

heapq.heapify(A)

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

print(-sum(A))



Verdicts: Wrong Answer

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
import math

n, m = map(int, input().split())
item_price = list(map(int, input().split()))
# n, m = (4, 4)
# item_price = [1, 9, 3, 5]
item_price.sort(reverse=True)
devided_two_price = [math.ceil(math.log2(i)) for i in item_price]
use_ticket_list = [0] * n
print(devided_two_price)
sum = 0

x = 0
for i in range(m):
    if devided_two_price[x] == 2:
        x += 1
        use_ticket_list[x] += 1
        devided_two_price[x] -= 1
    elif devided_two_price[x] >= devided_two_price[x+1]:
        use_ticket_list[x] += 1
        devided_two_price[x] -= 1
    else:
        x += 1
        use_ticket_list[x] += 1
        devided_two_price[x] -= 1

print(devided_two_price)
print(use_ticket_list)

for i in range(n):
    sum += item_price[i] // (2**use_ticket_list[i])

print(sum)

import heapq
import numpy as np
from math import ceil

n, m = map(int, input().split())
a = np.array(list(map(int, input().split())))
a = a * (-1)
a = list(a)
heapq.heapify(a)

for i in range(m):
    num = heapq.heappop(a)
    num = ceil(num / 2)
    heapq.heappush(a, num)

print(-1*sum(a))


Verdicts: Runtime Error

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
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)

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)

#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)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
import heapq
N, M = map(int, input().split(' '))
prices = list(map(lambda x: x * (-1), map(int, input().split(' '))))


heapq.heapify(prices)

for i in range(M):
    
    heapq.heappush(prices, heapq.heappop(prices) // 2)

print(sum(prices) * -1)


import heapq
N, M = map(int, input().split(' '))
prices = list(map(lambda x: x * (-1), map(int, input().split(' '))))


heapq.heapify(prices)

for i in range(M):
    
    heapq.heappush(prices, ((heapq.heappop(prices) * (-1)) // 2) * -1)

print(sum(prices) * -1)


Verdicts: Wrong Answer

Accepted
Problem: Takahashi is going to buy N items one by one.  The price of the i-th item he buys is A_i yen (the currency of Japan).  He has M discount tickets, and he can use any number of them when buying an item.  If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.  What is the minimum amount of money required to buy all the items?

Submission attempts (in order):
import math
import heapq

N,M = map(int,input().split())
Price_List = list(map(lambda x:x*(-1),map(int,input().split())))
heapq.heapify(Price_List)
for i in range(M):
    heapq.heapify(Price_List)
    val = heapq.heappop(Price_List)* -1 // 2 * -1
    heapq.heappush(Price_List,val)
    print(Price_List)
print(-sum(Price_List))

import heapq
 
N,M = map(int,input().split())
Price_List = list(map(lambda x:x*(-1),map(int,input().split())))
heapq.heapify(Price_List)
for i in range(M):
    val = heapq.heappop(Price_List)* -1 // 2 * -1
    heapq.heappush(Price_List,val)
print(-sum(Price_List))


Verdicts: Runtime Error

Accepted