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 itertools
# import math
# import sys

# import numpy as np
from collections import deque

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
N, M = map(int, input().split())
A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

A = sorted(A, reverse=True)
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)


#     for l in tree[s]:


#             dfs(tree, l[0])
# dfs(tree, 1)


#     arr = []
#     temp = n

#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#     if temp!=1:
#         arr.append([temp, 1])
#     if arr==[]:
#         arr.append([n, 1])
#     return arr


queue_A = deque(A)
queue_B = deque()

for i in range(M):
    if len(queue_B) > 0 and queue_B[0] >= queue_A[0]:
        queue_A.appendleft(queue_B.popleft())
    queue_A[0] //= 2
    if len(queue_A) > 1 and queue_A[0] < queue_A[1]:
        queue_B.append(queue_A.popleft())

print(queue_A)

print(queue_B)
print(sum(queue_A) + sum(queue_B))

# import itertools
# import math
# import sys

# import numpy as np
# from collections import deque
import heapq

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
N, M = map(int, input().split())
A = list(map(lambda x: int(x)*(-1), input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()


# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)


#     for l in tree[s]:


#             dfs(tree, l[0])
# dfs(tree, 1)


#     arr = []
#     temp = n

#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#     if temp!=1:
#         arr.append([temp, 1])
#     if arr==[]:
#         arr.append([n, 1])
#     return arr

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

A = map(lambda x: x*(-1), A)
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 numpy as np
n, m = map(int, input().split())
a = list(map(int, input().split()))
l = np.array(a)
for i in range(m):
    idx = l.argmax()
    print(idx)
    l[idx] = l[idx]//2
print(sum(l))

import heapq
n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)
for _ in range(m):
    t = heapq.heappop(a)
    heapq.heappush(a, (-1)*(-t//2))
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 = map(int, input().split())
    a = [int(x)*-1 for x in input().split()]
    ans = sum(a)*-1
    diff = 0
    
    heapify(a)
    for _ in range(1, m+1):
        _h_a = heappop(a) * -1
        diff += _h_a - _h_a // 2
        heappush(a, (_h_a // 2)*-1)
    ans -= diff
    print(ans)
    
if __name__ == '__main__':
    main()

from heapq import heapify, heappush, heappop

def main():
    n, m = map(int, input().split())
    a = [int(x)*-1 for x in input().split()]
    ans = sum(a)*-1
    diff = 0
    
    heapify(a)
    for _ in range(1, m+1):
        _h_a = heappop(a) * -1
        diff += _h_a - _h_a // 2
        heappush(a, (_h_a // 2)*-1)
    ans -= diff
    print(ans)
    
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 math
import bisect

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

def XX(A, M):
  if M <= 0:
    return
  A[0] = A[0]/2
  M -= 1
  for i in range(1, len(A)):
    if A[i] > A[0] and M > 0:
      A[i] = A[i]/2
      M -= 1
    else:
      break
  A.sort(reverse = True)
  XX(A, M)
  
A = list(map(math.floor, A))
XX(A, M)
print(sum(A))
  
           

A = list(map(math.floor, A))

import math
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse = True)

while M > 0:
  A[0] = A[0]/2
  #A.sort(reverse = True)
  M -= 1

A = list(map(math.floor, A))
print(sum(A))

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

def insertHeap(array, val):
    array.append(val)
    n = len(array)-1
    while n != 0:
        parent = int((n - 1) / 2)
        if array[n] > array[parent]:
            tmp = array[n]
            array[n] = array[parent]
            array[parent] = tmp
            n = parent
        else:
            break
    return array

def desertHeap(array):
    if array == []:
      return None
    array[0], array[-1] = array[-1], array[0]
    res = array.pop(-1)
    n = len(array)
    if n == 0 or n == 1:
      return res
    parent = 0
    while True:
        child = 2 * parent + 1
        if child >= n: break
        if (child + 1 < n) and array[child] < array[child + 1]:
            child += 1
        if array[parent] < array[child]:
            array[child], array[parent] = array[parent], array[child]
            parent = child;
        else:
            break
    return res
 

li = []
a.sort()
for aa in a:
  li = insertHeap(li, aa)

for i in range(m):
  val = desertHeap(li)
  li = insertHeap(li, val//2)

print(sum(li))
  

Verdicts: Runtime Error

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):
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
top, bottom = 0, M-1

if len(A) == 1:
    for _ in range(M):
        A[0] //= 2
else:
    for _ in range(M):
        A[top] //= 2
        print(top, bottom)
        if A[top] >= A[bottom]:
            bottom -= 1
            continue
        else:
            top += 1
print(sum(A))

import heapq
N, M = map(int, input().split())
heap = [-i for i in list(map(int, input().split()))]
heapq.heapify(heap)
for i in range(M):
    heapq.heappush(heap, -(-heapq.heappop(heap)//2))
print(-sum(heap))

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())
aaa = list(map(int, input().split()))
aaa.sort()

if n > 1:
  for i in range(m):
    a = heapq.heappop(aaa) // 2
    heapq.heappush(aaa, a)
else:
  print(aaa[0] // (2 ** m))
  
print(sum(aaa))

import bisect

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

for i in range(m):
  a = aaa.pop(-1)
  a = a // 2
  insert_index = bisect.bisect_left(aaa, a)
  aaa.insert(insert_index, a)
  
print(aaa)
print(sum(aaa))

import bisect

n, m = map(int, input().split())
aaa = list(map(int, input().split()))
aaa.sort(reverse = True)

for i in range(m):
  a = aaa.pop(0)
  a = a // 2
  insert_index = bisect.bisect_right(aaa, a)
  aaa.insert(insert_index, a)
  
print(sum(aaa))

import bisect

n, m = map(int, input().split())
aaa = list(map(int, input().split()))
aaa.sort(reverse = True)

for i in range(m):
  a = aaa.pop(0)
  a = a // 2
  insert_index = bisect.bisect_left(aaa, a)
  aaa.insert(insert_index, a)
  
print(aaa)
print(sum(aaa))

import heapq

n, m = map(int, input().split())
aaa = [-1 * int(a) for a in input().split()]
heapq.heapify(aaa)

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

Verdicts: Wrong Answer

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=int(input())
print(n*(n-1)//2)


import heapq

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

import heapq

n,m=map(int,input().split())
a=list(map(int,input().split()))
a=list(map(lambda x: int(x)*(-1) , a))
heapq.heapify(a)
for i in range(m):
  x=heapq.heappop(a)*(-1)
  heapq.heappush(a,-1*(x//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):
def main():
    n, m = map(int, input().split())
    a_list = list(map(int, input().split()))

    for _ in range(m):
        a_list[a_list.index(max(a_list))] /= 2

    print(sum(a_list))


if __name__ == '__main__':
    main()


import heapq


def main():
    n, m = map(int, input().split())
    a_list = list(map(lambda x: -int(x), input().split()))

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

    print(-sum(a_list))


if __name__ == '__main__':
    main()


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()))
sub = [0]
a.sort()
for i in range (m):
    if (len(a) != 0):
        if (a[-1] >= sub[-1]):
            x =a.pop()
            sub.insert(1,x//2)
    else:
        x =sub.pop()
        sub.insert(1,x//2)
print(sum(a)+sum(sub))
        

from collections import deque
n,m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
p = a.pop()
sub = deque([p//2])
for i in range (m-1):
    if (len(a) != 0):
        if (a[-1] >= sub[-1]):
            x =a.pop()
            sub.appendleft(x//2)
        else:
            x =sub.pop()
            sub.appendleft(x//2)
    else:
        x =sub.pop()
        sub.appendleft(x//2)
print(sum(a)+sum(sub))
        

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 heapq

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

heapq.heapify(A)
for _ in range(M):
    a = heapq.heappop(A) >> 1
    heapq.heappush(A,a)
print(-sum(A))


import heapq

N , M = map(int,input().split())
A = [-int(i) for i in input().split()]
heapq.heapify(A)
for _ in range(M):
    a = -heapq.heappop(A) >> 1
    heapq.heappush(A,-a)
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 heapq

n, m = map(int, input().split())
goods = map(lambda x: int(x) * -1, input().split())
heapq.heapify(goods)
for i in range(n):
    the_most_expensive = heapq.heappop(goods)
    heapq.heappush(the_most_expensive / 2)

print(sum(goods) * -1)


import heapq

n, m = map(int, input().split())
goods = map(lambda x: int(x) * -1, input().split())
heapq.heapify(goods)
for i in range(m):
    the_most_expensive = heapq.heappop(goods)
    heapq.heappush(the_most_expensive / 2)

print(sum(goods) * -1)


import heapq

n, m = map(int, input().split())
goods = map(lambda x: int(x) * -1, input().split())
heapq.heapify(goods)
for i in range(m):
    the_most_expensive = heapq.heappop(goods)
    heapq.heappush(the_most_expensive / 2)

print(sum(goods) * -1)

import heapq
import math

n, m = map(int, input().split())
goods = list(map(lambda x: int(x) * -1, input().split()))
heapq.heapify(goods)
for i in range(m):
    the_most_expensive = heapq.heappop(goods)
    heapq.heappush(goods, math.ceil(the_most_expensive / 2))

print(sum(goods) * -1)


Verdicts: Runtime Error

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())
value = list(map(int,input().split()))
value = list(map(lambda x: x*(-1), value))

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

print(sum(list(map(lambda x: x*(-1), value))))


import heapq

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

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

print(sum(list(map(lambda x: x*(-1), value))))


import heapq

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

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

print(sum(list(map(lambda x: x*(-1), value))))


import heapq

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

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

print(sum(list(map(lambda x: x*(-1), value))))


Verdicts: Wrong Answer

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):
N, M = map(int, input().split())
A = [int(a) for a in input().split()]
q = []
for a in A:
    heapq.heappush(q, -a)
    
for _ in range(M):
    tmp = -heapq.heappop(q)
    heapq.heappush(q, -(tmp//2))
print(-sum(q))

import heapq

N, M = map(int, input().split())
A = [int(a) for a in input().split()]
q = []
for a in A:
    heapq.heappush(q, -a)
    
for _ in range(M):
    tmp = -heapq.heappop(q)
    heapq.heappush(q, -(tmp//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):
N,M = map(int, input().split())
A = list(map(int, input().split()))

A = A.sort(reverse=True)
l = len(A)

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

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

l = len(A)
A.sort(reverse=True)

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

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

l = len(A)

if N>=2:
  while M>=1:
    A.sort(reverse=True)
    div = A[0]//2
    
    for i in range(l):
      if A[i]>=div:
        if M>=1:
          A[i] = A[i]//2
          M -= 1
        else:
          break
      else:
        break
 
  print(sum(A))
else:
    i=1
    while 2**(i+1)<=A[0]:
      i+=1
    if M>=i:
      print(0)
    else:
      print(A[0]//2**M)

Verdicts: Runtime Error

Time Limit Exceeded

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


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


if __name__ == '__main__':
    main()


import heapq

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

heapq.heapify(A)
for i in range(m):
    item = heapq.heappop(A)
    heapq.heappush(A, (-1) * (-item // 2))

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):
from heapq import heappush, heappop, heapify

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

A.sort()
heap = heapify(A)
for i in range(M):
  heappush(heap, heappop()//2)
print(sum(heap))


from heapq import heappush, heappop, heapify
import math

N, M = map(int, input().strip().split())
A = list(map(int, input().strip().split()))
A = [-x for x in A]
A.sort()
for i in range(M):
  heappush(A, math.ceil(heappop(A)/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):
from heapq import heapify, heappop, heappush
import sys

input = sys.stdin.readline

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

BC = [tuple(map(int, input().split())) for _ in range(m)]

for b, c in BC:
    for _ in range(b):
        A.append(c)

A = list(map(lambda x: -x, A))
heapify(A)

answer = 0
for _ in range(n):
    answer += heappop(A)

print(-answer)


import heapq

n, m = map(int, input().split())
A = list(map(lambda x: -int(x), input().split()))
heapq.heapify(A)
for _ in range(m):
    max_price = -heapq.heappop(A) // 2
    heapq.heappush(A, -max_price)
total = -sum(A)
print(total)


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):
class Heap:
    
    def maintain_heapify(self,A,i):
        l=2*i+1
        r=2*i+2
        if self.name=='max':
            if l<len(A) and A[l]>A[i]:
                largest=l
            else:
                largest=i
            
            if r<len(A) and A[r]>A[largest]:
                largest=r
            
            if largest!=i:
                A[largest],A[i]=A[i],A[largest]
                self.maintain_heapify(A,largest)

        elif self.name=='min':
            if l<len(A) and A[l]<A[i]:
                smallest=l
            else:
                smallest=i
            if r<len(A) and A[r]<A[smallest]:
                smallest=r
            if smallest!=i:
                A[smallest],A[i]=A[i],A[smallest]
                self.maintain_heapify(A,smallest)

    def build_heap(self,A):
        i=len(A)//2
        while i>=0:
            self.maintain_heapify(A,i)
            i-=1

    def __init__(self,A,name='max'):
        self.name=name
        self.build_heap(A)
        self.heap=A

    def insert(self,v):
        self.heap.append(v)
        self.build_heap(self.heap)

    def deleteroot(self):
        root=self.heap[:1]
        tmp=self.heap[1:len(self.heap)-1]
        self.heap=self.heap[len(self.heap)-1:]+tmp
        self.build_heap(self.heap)
        return root[0]

    def get_root(self):
        return self.heap[0]
    def get_sum(self):
      	for i in range(len(self.heap)):
          self.heap[i] = int(self.heap[i])
        return sum(self.heap)


def main():
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    heap = Heap(A)
    tmp = 0
    for cnt in range(M):
        first = heap.deleteroot()
        plus = first / 2
        heap.insert(plus)
    print(heap.get_sum())
    return
main()


def minus(a:str):
    return int(a)*-1

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

import heapq as hq

def main():
    hq.heapify(A)
    for _ in range(M):
        target = hq.heappop(A)
        target = -1*((-1*target) // 2)
        hq.heappush(A,target)
    print(sum(A)*-1)
    return 

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
 
itemCount, ticketCount = map(int, input().split(' '))
prices = map(int, input().split(' '))
 
h = []
for price in prices:
    heapq._heappush_max(h, price)
 
for i in range(ticketCount):
    price = _heappop_max(h)
    heapq._heappush_max(h, price // 2)
total = 0
for price in h:
    total += price
 
print(total)

import heapq


def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap) - 1)


def _heappop_max(heap):
    """Maxheap version of a heappop."""
    lastelt = heap.pop()    # raises appropriate IndexError if heap is empty
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt


itemCount, ticketCount = map(int, input().split(' '))
prices = map(int, input().split(' '))

h = []
for price in prices:
    _heappush_max(h, price)

for i in range(ticketCount):
    price = _heappop_max(h)
    _heappush_max(h, price // 2)
total = 0
for price in h:
    total += price

print(total)

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 = int(input())
a = list(map(int,input().split()))
aabs = [i if i>=0 else i*(-1) for i in a]
MIN = min(aabs)
ans = 0
mcount = 0

for i in range(n):
  if a[i] < 0:
    mcount += 1
    
if mcount%2 == 0:
  for i in a:
    ans += abs(i)
    print(ans)
else:
  for i in a:
    ans += abs(i)
  print(ans - 2*MIN)
  

import heapq

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

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

heapq.heapify(a)

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

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

for i in range(m):
  b = a[-1]
  a.remove(b)
  b = int(b/2)
  bisect.insort_left(a,b)
  
print(sum(a))

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):
  tmp = heapq.heappop(a)
  heapq.heappush(a,(-tmp//2)*(-1))
  
print(-sum(a))

Verdicts: Runtime Error

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):
N, M = map(int,input().split())

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

import heapq
def heapsort(iter):
    h = []
    for value in iter:
        heappush(h, value)
    return [heappop(h) for i in range(len(h))]

def waribiki(X,Y):
    return X//(2**Y)

if len(A)==1:
    while M>0:
        A[0] = waribiki(A[0],1)
        M -= 1
else:
    while M>0:
        #A.sort(reverse=True)
        A = heapsort(A)
        
        m=1
        #while M>0 and waribiki(A[0],m)>A[1]:
        #    m+=1
        A[0] = waribiki(A[0],m)
        M -= m
       

print(sum(A))


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

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

import heapq

heapq.heapify(A)
while M>0:
    a = -heapq.heappop(A) // 2
    heapq.heappush(A,-a)
    M -= 1
   

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
X = list(map(int, input().split()))
A = list(map(int, input().split()))
heapq.heapify(A)

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

ans = 0
for i in range(X[0]):
  ans += A[i]

print(ans)

import heapq
X = list(map(int, input().split()))
# A = list(map(int, input().split()))
A = list(map(lambda x: int(x)*(-1), input().split())) 
heapq.heapify(A)

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

ans = 0
for i in range(X[0]):
  ans -= A[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):
N, M = map(int, input().split())
A = [-1*int(i) for i in input().split()]

# import heapq
# print(A)
heapq.heapify(A)
# print(A)
for _ in range(M):
    a = heapq.heappop(A)
#     print( "aaa",a)
    heapq.heappush(A,-1*((-1*a)//2))
#     print("AAA",A)
    
# print("list",A)

print(-1*sum(A))


N, M = map(int, input().split())
A = [-1*int(i) for i in input().split()]

import heapq
# print(A)
heapq.heapify(A)
# print(A)
for _ in range(M):
    a = heapq.heappop(A)
#     print( "aaa",a)
    heapq.heappush(A,-1*((-1*a)//2))
#     print("AAA",A)
    
# print("list",A)

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

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)

while m != 0:
    
    price = heapq.heappop(a)
    
    price //= 2
    m -= 1
    
    heapq.heappush(a, price)

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)

while m != 0:
    
    price = heapq.heappop(a) * (-1)
    
    price //= 2
    m -= 1
    
    heapq.heappush(a, (-1) * price)

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

def solution():
    n, m = map(int, input().split())
    a = [int(aa) for aa in input().split()]
    a.sort(reverse=True)
    for i in range(m):
        a[0] = a[0] // 2
        numpy.np.sort(a)[::-1]
    print(sum(a))

solution()


import numpy

def solution():
    n, m = map(int, input().split())
    a = [int(aa) for aa in input().split()]
    a.sort(reverse=True)
    for i in range(m):
        a[0] = a[0] // 2
        numpy.np.sort(a)[::-1]
    print(sum(a))

solution()


import heapq as hp
def solution():
    n, m = map(int, input().split())
    a = [int(aa) * -1 for aa in input().split()]
    hp.heapify(a)
    for i in range(m):
        hp.heappush(a, (hp.heappop(a)*-1 // 2) * -1)
    print(abs(sum(a)))

solution()


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 numpy as np
import math
n, m = map(int, input().split())
#a = list(map(int, input().split()))
a = list(map(lambda x: int(x) * (-1), input().split()))
heapq.heapify(a)  

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

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

#import numpy as np
#import math
import heapq

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

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

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

#import numpy as np
#import math
import heapq

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

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

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

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())
A = list(map(lambda x: int(x)*-1, input().split()))
heapq.heapify(A)
for i in range(M):
    tmp = heapq.heappop(A)
    heapq.heappush(A, (tmp) // 2)
print(str(-sum(A)))

import heapq

n,m = map(int,input().split())
a = list(map(int,input().split()))
a = [-x for x in a]
heapq.heapify(a) 
ans =0
for i in range(m):
  b = a[0]
  c = (-1)*b //2
  heapq.heappop(a) 
  heapq.heappush(a, c*(-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 os
import heapq
import math

N, M = (int(x) for x in input().split())
cost = [-a for a in map(int, input().split())]
heapq.heapify(cost)

for _ in range(0,M):
    x = heapq.heappop(cost)
    heapq.heappush(cost, math.floor(x/2))

res = 0
for i in range(0, N):
    res += (cost[i]*-1)

print(res)

import os
import heapq
import math

N, M = (int(x) for x in input().split())
cost = [-a for a in map(int, input().split())]
heapq.heapify(cost)

for _ in range(0,M):
    x = heapq.heappop(cost)
    heapq.heappush(cost, x/2)
res = 0
for i in range(0, N):
    res += math.floor(cost[i]*-1)

print(res)

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 heapq
def main():
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    for i,aa in enumerate(a):
        a[i] = -1 * aa
    heapq.heapify(a)
    for i in range(m):
        tmp = heapq.heappop(a) // 2
        heapq.heappush(a,tmp)
    print(sum(a) * (-1))
if __name__=='__main__':
    main()


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


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())
As = list(map(int, input().split()))

mvals = list(np.array(As) * (-1))
import heapq
heapq.heapify(mvals)

for _ in range(M):
    price = heapq.heappop(mvals)
    heapq.heappush(mvals, price / 2)

res = (np.array(mvals) * (-1)).astype(int).sum()
print(res)

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

import heapq
heapq.heapify(mvals)

for _ in range(M):
    price = heapq.heappop(mvals)
    heapq.heappush(mvals, price / 2)

res = sum(map(lambda x:int(-x), mvals))
print(res)

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())
List=list(map(-int,input().split()))

heapq.heapify(List)

for i in range(M):
  a = (-heapq.heappop(List)) // 2
  heapq.heappush(List, -a)
  
print(int(sum(List)))

import heapq

N,M = map(int, input().split())
List1=list(map(int,input().split()))
List=[]

for i in range(N):
  a = List1[i]
  List.append(-a)

heapq.heapify(List)

for i in range(M):
  a = (-heapq.heappop(List)) // 2
  heapq.heappush(List, -a)
  
print(int(-sum(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


class MaxHeap(object):
    def __init__(self, x):
        self.heap = [-e for e in x]
        heapq.heapify(self.heap)

    def push(self, value):
        heapq.heappush(self.heap, -value)

    def pop(self):
        return -heapq.heappop(self.heap)

N, M = list(map(lambda x:int(x), input().split(' ')))
l = list(map(lambda x:int(x), input().split(' ')))

print(N, M)
print(l)

maxheap = MaxHeap(l)

WARI = 0.5
for _ in range(0, M):
    v = int(maxheap.pop() * WARI)
    maxheap.push(v)

print(SUM)

import heapq
 
 
class MaxHeap(object):
    def __init__(self, x):
        self.heap = [-e for e in x]
        heapq.heapify(self.heap)
 
    def push(self, value):
        heapq.heappush(self.heap, -value)
 
    def pop(self):
        return -heapq.heappop(self.heap)
 
N, M = list(map(lambda x:int(x), input().split(' ')))
l = list(map(lambda x:int(x), input().split(' ')))

maxheap = MaxHeap(l)
 
WARI = 0.5
for _ in range(0, M):


import heapq


class MaxHeap(object):
    def __init__(self, x):
        self.heap = [-e for e in x]
        heapq.heapify(self.heap)

    def push(self, value):
        heapq.heappush(self.heap, -value)

    def pop(self):
        return -heapq.heappop(self.heap)

N, M = list(map(lambda x:int(x), input().split(' ')))
l = list(map(lambda x:int(x), input().split(' ')))

maxheap = MaxHeap(l)

WARI = 0.5
for _ in range(0, M):
    v = int(maxheap.pop() * WARI)
    maxheap.push(v)

SUM = 0
for _ in range(0, N):
    SUM += maxheap.pop()

print(SUM)

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):
N,M=[int(thing) for thing in input().split(" ")]
A_list=[int(thing) for thing in input().split(" ")]

A_list.sort(reverse=True)
for aaaaa in range(M):
    A_list[0]=A_list[0]*0.5
    A_list.sort(reverse=True)
print(sum([thing//1 for thing in A_list]))


import heapq
N,M=[int(thing) for thing in input().split(" ")]
A_list=[int(thing)*(-1) for thing in input().split(" ")]
heapq.heapify(A_list)
for aaaaa in range(M):
    thing =heapq.heappop(A_list)/2
    heapq.heappush(A_list,thing)
print(sum([thing*-1//1 for thing in A_list]))


N,M=[int(thing) for thing in input().split(" ")]
A_list=[int(thing) for thing in input().split(" ")]
A_list.sort(reverse=True)
for aaaaa in range(M):
    com=A_list.pop(0)/2
    for i in range(len(A_list)):
        if A_list[i]<=com:
            A_list.insert(i,com)
            break
    else:A_list.append(com)

print(sum([thing//1 for thing in A_list]))


N,M=[int(thing) for thing in input().split(" ")]
A_list=[int(thing) for thing in input().split(" ")]
sogaku=sum(A_list)
A_list.sort(reverse=True)
i=0
for aaaaa in range(M):
    exp=max(A_list)
    ind=A_list.index(exp)
    A_list[ind]=A_list[ind]*0.5
print(sum([thing//1 for thing in A_list]))


import heapq
N,M=[int(thing) for thing in input().split(" ")]
A_list=[int(thing)*(-1) for thing in input().split(" ")]
heapq.heapify(A_list)
for aaaaa in range(M):
    thing =heapq.heappop(A_list)/2
    heapq.heappush(A_list,thing)
print(int(sum([thing*-1//1 for thing in A_list])))


Verdicts: Wrong Answer

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):
# -*- coding utf-8 -*-
import heapq

MOD = 10 ** 9 + 7

N, M = map(int, input().split())
AN = map(int, input().split())
hq = []
for an in AN:
    heapq.heappush(hq, -an)
print(hq)

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

ans = - sum(hq)

print(ans)


# -*- coding utf-8 -*-
import heapq

MOD = 10 ** 9 + 7

N, M = map(int, input().split())
AN = map(int, input().split())
hq = []
for an in AN:
    heapq.heappush(hq, -an)

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

ans = - sum(hq)

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):
from heapq import heapify, heapreplace

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

for _ in range(m):
    heapreplace(aaa, aaa[0] // 2)

print(sum(aaa))


from heapq import heapify, heapreplace

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

for _ in range(m):
    heapreplace(aaa, aaa[0] // 2 + aaa[0] % 2)

print(-sum(aaa))


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 heapq
N,M=map(int,input().split())
A=list(map(lambda x:-int(x),input().split()))
heapq.heapify(A)


for _ in range(M):
  ma=heapq.heappop(A)
  heapq.heappush(A,-((-ma)//2))
  
print(sum(A))

import heapq
N,M=map(int,input().split())
A=list(map(lambda x:-int(x),input().split()))
heapq.heapify(A)


for _ in range(M):
  ma=heapq.heappop(A)
  heapq.heappush(A,-((-ma)//2))
  
print(-sum(A))

Verdicts: Wrong Answer

Accepted