Problem:
 Score : 400 points    Problem Statement 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?      Constraints  All values in input are integers.  1 \leq N, M \leq 10^5  1 \leq A_i \leq 10^9         Input Input is given from Standard Input in the following format:  N  M  A_1  A_2  ...  A_N       Output Print the minimum amount of money required to buy all the items.        Sample Input 1 3 3
2 13 8      Sample Output 1 9  We can buy all the items for 9 yen, as follows:   Buy the 1 -st item for 2 yen without tickets.  Buy the 2 -nd item for 3 yen with 2 tickets.  Buy the 3 -rd item for 4 yen with 1 ticket.        Sample Input 2 4 4
1 9 3 5      Sample Output 2 6       Sample Input 3 1 100000
1000000000      Sample Output 3 0  We can buy the item priced 1000000000 yen for 0 yen with 100000 tickets.       Sample Input 4 10 1
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000      Sample Output 4 9500000000

Solution (Python):
from queue import PriorityQueue

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

for a in A:
    queue.put(-a)

for i in range(M):
    a = -queue.get()
    a /= 2
    queue.put(-a)

ans = 0
for i in range(N):
    ans += int(-queue.get())
print(ans)

Solution (Python):
import heapq

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

heapq.heapify(A)

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

print(-sum(A))

Solution (Python):
N,M=map(int,input().split())
A=list(map(int,input().split()))
for i in range(len(A)):
  A[i]=A[i]*(-1)

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

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

Solution (Python):
N, M = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(1)][0]
A = [-1*x for x in A]

import heapq
heapq.heapify(A)

while M != 0:
    x = heapq.heappop(A)
    y = -x // 2
    heapq.heappush(A, -y)
    M -= 1

A = [-1*x for x in A]
print(sum(A))

Solution (Python):
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))

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

[N,M] = inpl()
Alist = inpl()

minusA = [-x for x in Alist]
heapq.heapify(minusA)
for i in range(M):
    temp = heapq.heappop(minusA)
    heapq.heappush(minusA,-(-temp//2))

ans = - sum(minusA)
print(ans)

Solution (Python):
import sys
input = sys.stdin.buffer.readline
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
ind=[0]*N
import bisect
t=A[-1]
k=0
while(1):
  if k==M:
    break
  t=t/2
  a=bisect.bisect_right(A,t)
  b=N-a
  if b+k>M:
    break
  for j in range(b):
    j1=j+1
    ind[-j1]+=1
  k+=b
if k!=M:
  S=0
  for i in range(N):
    A[i]=(A[i]/(2**ind[i]))
  A.sort()
  ind2=[0]*N
  for j in range(M-k):
    ind2[-1-j]=1
  for i in range(N):
    S+=(A[i]//(2**ind2[i]))
  print(int(S))
else:
  S=0
  for i in range(N):
    S+=(A[i]//(2**ind[i]))
  print(S)

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

Solution (Python):
import heapq

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

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

print(-sum(a))

Solution (Python):
import heapq

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

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

print(sum([-int(i) for i in a]))

Solution (Python):



import math
import heapq

n, m = map(int, input().split())
a = [0] * n
a = list(map(int, input().split()))

a = list(map(lambda x: x*(-1), a))
heapq.heapify(a)
for _ in range(m):
    tmp = heapq.heappop(a) * (-1)
    tmp = math.floor(tmp / 2) * (-1)
    heapq.heappush(a, tmp)

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

Solution (Python):
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))

Solution (Python):
n, m = map(int, input().split())
l_ = list(map(int, input().split()))
l = [(-1)*l_[i] for i in range(n)]

import heapq
heapq.heapify(l)

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

print(sum(l)*(-1))

Solution (Python):
n, m = map(int, input().split())
l_ = list(map(int, input().split()))
l = [(-1)*l_[i] for i in range(n)]

import heapq
heapq.heapify(l)

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

print(sum(l)*(-1))

Solution (Python):
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):
	tmp_min = heapq.heappop(a)
	heapq.heappush(a, (-1)*(-tmp_min//2))

print(-sum(a))

Solution (Python):
import heapq
n,m = map(lambda x: int(x), 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(-sum(a))

Solution (Python):
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = []
for a in A:
    B.append(-a)


import heapq
heapq.heapify(B)
for i in range(M):
    b = heapq.heappop(B)
    b = -b // 2
    b = -b
    heapq.heappush(B, b)

res = -sum(B)
print(res)

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

Solution (Python):
import heapq
n,m=map(int,input().split())
x=list(map(int,input().split()))
for k in range(n):
    x[k]-=2*x[k]
heapq.heapify(x)
ans=0
for i in range(m):
    maxvalue=heapq.heappop(x)*(-1)
    heapq.heappush(x,(maxvalue//2)*(-1))
ans=-1*sum(x)
print(ans)

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

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

Solution (Python):
def main():
    import bisect
    import math
    import sys
    import heapq
    def f(s):
        return -int(s)

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

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

    print(-sum(a))
    

if __name__ == '__main__':
    main()

Solution (Python):
import heapq
N,M = map(int,input().split())
A=[-int(i) for i in input().split()]
heapq.heapify(A)
for _ in range(M):
    s = heapq.heappop(A)
    if s % 2 == 0:
        heapq.heappush(A, s//2)
    else:
        heapq.heappush(A, s//2 + 1)
print(-sum(A))

Solution (Python):
import heapq
N,M = map(int,input().split())
A=[-int(i) for i in input().split()]
heapq.heapify(A)
for _ in range(M):
    s = heapq.heappop(A)
    if s % 2 == 0:
        heapq.heappush(A, s//2)
    else:
        heapq.heappush(A, s//2 + 1)
print(-sum(A))

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

while M>0:
    A.sort(reverse=True)
    if A[0]==0:
        break
    judge=A[0]//2
    for i in range(len(A)):
        if A[i]>judge and M>0:
            A[i]=A[i]//2
            M-=1
        else:
            break
print(sum(A))

Solution (Python):
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))

Solution (Python):
import heapq

class PriorytyQueue(object):

    def __init__(self, arr, target='min'):
        self.arr = arr
        self.target = target
        self._heapify()
    
    def _heapify(self):
        if self.target == 'max':
            self.arr = list(map(lambda x:x*(-1), self.arr))
        heapq.heapify(self.arr)
    
    def push(self, x):
        if self.target == 'max':
            x *= -1
        heapq.heappush(self.arr, x)

    def pop(self):
        res = heapq.heappop(self.arr)
        if self.target == 'max':
            return res*(-1)
        else:
            return res
    
    def get_arr(self):
        if self.target == 'max':
            return list(map(lambda x:x*(-1), self.arr))
        else:
            return self.arr

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

A = PriorytyQueue(A, target='max')

for i in range(M):
    max_A = A.pop()
    A.push(max_A//2)

print(sum(A.get_arr()))

Solution (Python):
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):
    max = heapq.heappop(A)*(-1)
    heapq.heappush(A, (max // 2) * -1)

print(sum(A) * -1)

Solution (Python):
import sys
input = sys.stdin.readline
import heapq

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

for _ in range(M):
    tmp = heapq.heappop(A)
    
    heapq.heappush(A, (-1)*(-tmp >> 1))

print(-sum(A))

Solution (Python):
import heapq

n, m = map(int, (input().split()))
hp = [-int(v) for v in input().split()]

heapq.heapify(hp)

for i in range(m):
    tmp = heapq.heappop(hp)
    heapq.heappush(hp, int(tmp / 2))

print(-sum(hp))

Solution (Python):
import sys
import heapq
input = sys.stdin.readline

N, M = list(map(int, input().strip().split()))
A = [-int(x) for x in input().strip().split()]
heapq.heapify(A)
for m in range(M):
    a = heapq.heappop(A)
    heapq.heappush(A, a / 2)
print(sum([int(-a) for a in A]))

Solution (Python):
N, M = map(int, input().split())
nums = map(int, input().split())

import heapq

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

print(-sum(pq))

Solution (Python):


import heapq

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

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

Solution (Python):
import heapq
N,M =map(int,input().split())
A=[-int(x) for x in input().split()]

heapq.heapify(A)

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

Solution (Python):
import sys
import heapq
sys.setrecursionlimit(10**6)
def MAP(): return [int(s) for s in input().split()]

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

N, M = MAP()

A = [int(s)*-1 for s in input().split()]


heapq.heapify(A)

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

print(sum(A)*-1)

Solution (Python):
import heapq

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

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

print(-1 * sum(A))

Solution (Python):
import heapq

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

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

Solution (Python):
import heapq
N, M = [int(i) for i in input().split()]
A = [-int(i) for i in input().split()]

heapq.heapify(A)

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

print(-sum(A))

Solution (Python):

import math
import heapq
import bisect

MOD = 10**9+7

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)

ans=0
for a in A:
    ans+=math.floor(-a)

print(ans)

Solution (Python):


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 i in range(m):  
    t=heapq.heappop(a)
    t*=-1
    t//=2
    t*=-1
    heapq.heappush(a,t)
    
ans=0
for i in range(n):
    ans-=a[i]
print(ans)

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

Solution (Python):
import heapq

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

Solution (Python):
import heapq

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

Solution (Python):
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):
    x=heapq.heappop(A)
    heapq.heappush(A,(x+1)//2)
    

ans=-sum(A)

print(ans)

Solution (Python):
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_min = heapq.heappop(A)
    heapq.heappush(A, (-1)*(-tmp_min//2))
print(-sum(A))

Solution (Python):
import heapq

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

heapq.heapify(A)

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

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

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

Solution (Python):

import sys
import heapq 
input = sys.stdin.readline
n,m = (int(i) for i in input().split())
a = [int(i)*(-1) for i in input().split()] 
heapq.heapify(a)
for i in range(m):
    """
    k = np.argmax(a)
    if a[k] == 0:
        break
    a[k] = int(a[k]/2)
    """
    tmp = heapq.heappop(a) 
    heapq.heappush(a, (-1)*(-tmp//2)) 
ans = -sum(a)
print(ans)

Solution (Python):
import heapq

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

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

    print(-sum(A))
    


if __name__ == "__main__":
    main()

Solution (Python):
import heapq
import math

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):
    max = heapq.heappop(a)
    heapq.heappush(a, math.ceil(max/2))

print(-sum(a))

Solution (Python):
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 i in range(m):
  heapq.heappush(a,(heapq.heappop(a)+1)//2)
print(-sum(a))

Solution (Python):
import heapq

n, m = map(int,input().split())
price = list(map(int, input().split()))
price = list(map(lambda x: x*(-1), price))
heapq.heapify(price)
while m != 0:
    maxv = heapq.heappop(price)
    heapq.heappush(price, (maxv+1) // 2)
    m -= 1
print(sum(price) * (-1))

Solution (Python):
import heapq

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

que = []
for a in A:
  heapq.heappush(que, -1*a)
 
for a in range(M):
  maxvalue = -1 * heapq.heappop(que)
  maxvalue /= 2
  heapq.heappush(que, -1*maxvalue)
 
print(sum([int(-1*a) for a in que]))

Solution (Python):
import heapq

n, m = map(int, input().split())
a = [int(_) for _ in input().split()]
que = []
for _ in a:
  heapq.heappush(que, -1*_)

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

print(sum([int(-1*_) for _ in que]))

Solution (Python):
import heapq
n, m = map(int, input().split())
al = list(map(lambda x: (-1) * int(x), input().split()))
heapq.heapify(al)

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

print(-sum(al))

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
 



 




 


 





 


 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,M = inputMap()
    A = inputList()
    
    AA = []
    heapq.heapify(AA)
    for val in A:
        heapq.heappush(AA, val * (-1))
    
    for i in range(M):
        tmp = heapq.heappop(AA) * (-1)
        tmp = tmp // 2
        heapq.heappush(AA, tmp * (-1))
        
    ans = 0
    for i in range(N):
        tmp = heapq.heappop(AA) * (-1)
        ans += tmp
        
    print(ans)
    
    
if __name__ == "__main__":
	main()

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

Solution (Python):
import heapq
import math

n, m = map(int, input().split())
a = list(map(int, input().split()))
q = []
heapq.heapify(q)

for i in range(n):
    heapq.heappush(q, -a[i])

for _ in range(m):
    b = heapq.heappop(q) / 2
    heapq.heappush(q, math.ceil(b))

print(sum(q) * -1)

Solution (Python):
import heapq

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

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

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

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

Solution (Python):
import heapq

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

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

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



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

Solution (Python):

import sys








import heapq





def main():
    n, m = [int(x) for x in sys.stdin.readline().split()]
    a = [-int(x) for x in sys.stdin.readline().split()]

    heapq.heapify(a)
    for _ in range(m):
        highest = - heapq.heappop(a)
        heapq.heappush(a, -(highest // 2))
    
    print(-sum(a))
    
if __name__ == "__main__":
    main()

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

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

Solution (Python):
import heapq
import math

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

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

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

print(sum(A))

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

Solution (Python):
import heapq


def int_and_reverse(num):
    return int(num) * -1


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

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

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

print(-(sum(a)))

Solution (Python):
N,M = map(int,input().split())
A =list(map(int,input().split()))
A.sort(reverse=True)
A_len =len(A)
count =0
if A_len ==1:
    for l in range(0,M):
        A[0]=A[0]/2
else:
    for l in range(0,M):
        comp = A[0]/2
        for i in range(0,A_len-1,1):
            if count >= M:
                break
            if A[i+1]<comp:
                break
            while True:
                count +=1
                if A[i]/2 > A[i+1]:
                    A[i] = A[i]/2
                else:
                    A[i] = A[i]/2
                    break
        A.sort(reverse=True)
        if count>=M:
            break
A = [int(i) for i in A]
sumN =sum(A)
print(sumN)

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

print(-sum(a))

Solution (Python):
import heapq
N, M = map(int, input().split())
A = [int(_)*(-1) for _ in input().split()]
heapq.heapify(A)

while M != 0:
  max_ = -heapq.heappop(A) // 2
  heapq.heappush(A, -max_)
  M -= 1
  
print(-sum(A))

Solution (Python):

import heapq

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

for i in range(m):
  maxi = heapq.heappop(s)
  heapq.heappush(s, -(-maxi // 2))

print(-sum(s))

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

Solution (Python):

import heapq

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

print(-sum(L))

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

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

ans = 0
for i in ar:
    ans += math.floor(-i)

print(ans)

Solution (Python):

n,m=map(int,input().split())
lists=list(map(int,input().split()))
uselist=[0 for i in range(n)]
for j in range(n):
    uselist[j]=lists[j]*(-1)
import heapq
heapq.heapify(uselist)
for _ in range(m):
    
    mini=heapq.heappop(uselist)
    heapq.heappush(uselist,mini/2) 

ans=0
import math
for some in uselist:
    ans+=math.floor(-some)
print(ans)

Solution (Python):
N, M = map(int, input().split())
AS = list(map(int, input().split()))

import math

buckets = [[] for i in range(31)]
count = [0 for i in range(31)]
for num in AS:
    buckets[math.floor(math.log(num)/math.log(2))].append(num)
    
for lst in buckets: lst.sort(reverse=True)

hi = 30
while buckets[hi-1] == []: hi -= 1
found = 0
while True:
    try:
        if M > found:
            for i in range(hi, 31):
                count[i] += 1
            hi -= 1
            M -= found
            found += len(buckets[hi])
        else:
            total = 0
            for i in range(hi):
                total += sum(buckets[i])
                
            lst = []
            for i in range(hi, 30):
                for item in buckets[i]:
                    lst.append(item // pow(2, count[i]))
             
            lst.sort(reverse=True)
            
            for i in range(M):
                lst[i] //= 2

            total += sum(lst)

            print(total)
            break
    except:
        print(0)
        break

Solution (Python):
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 or A[0]<1:
    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)
  
XX(A, M)
A = list(map(math.floor, A))
print(sum(A))

Solution (Python):
def main():
    import heapq
    import sys

    input = sys.stdin.readline

    n,m = map(int,input().split())
    def int2(x):
        a = -int(x)
        return a
    s = list(map(int2,input().split()))
    heapq.heapify(s)

    for i in range(m):
        mi = heapq.heappop(s)
        if mi % 2 == 1:
            mi = (mi // 2) + 1
        else:
            mi = mi // 2
        heapq.heappush(s,mi)
    
    s1 = -(sum(s))
    print(s1)

if __name__ == "__main__":
    main()

Solution (Python):
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):
  heapq.heappush(A,((heapq.heappop(A)*-1)//2)*-1)

print(sum(A)*-1)

Solution (Python):
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))

Solution (Python):
import heapq

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

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


if __name__ == '__main__':
    main()

Solution (Python):
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(len(a)):
  a[i]*=(-1)

import heapq
heapq.heapify(a)

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

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

Solution (Python):
import sys
input = sys.stdin.readline
import heapq as hq
def print_ans(N, M, input_line):
    """Test Case
    >>> print_ans(3, 3, "2 13 8")
    9
    >>> print_ans(4, 4, "1 9 3 5")
    6
    >>> print_ans(1, 100000, "1000000000")
    0
    >>> print_ans(10 ,1, "1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000")
    9500000000
    """
    ar = [-int(i) for i in input_line.split()]
    hq.heapify(ar)
    for _ in range(M):
        hq.heappush(ar, -(-hq.heappop(ar) // 2))
    
    print(-sum(ar))

if __name__ == '__main__':
    N, M = map(int, input().rstrip().split())
    input_line = input().rstrip()
    print_ans(N, M, input_line)

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

Solution (Python):
import heapq
n,m = list(map(int,input().split()))
a = list(map(lambda s: (-1)*int(s),input().split()))

heapq.heapify(a)

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


print(-1 * sum(a))

Solution (Python):
import heapq
import math

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


for i in range(m):
    w = heapq.heappop(li_a)
    heapq.heappush(li_a, math.ceil(w / 2))

print(sum(li_a) * -1)

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

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

Solution (Python):
import heapq
n,m = list(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(-sum(a))

Solution (Python):
import sys
import heapq


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, input().rstrip('\n').split()))
    a = [-v for v in list(map(int, input().rstrip('\n').split()))]
    heapq.heapify(a)
    for i in range(m):
        t = -heapq.heappop(a)
        heapq.heappush(a, -(t // 2))
    print(-sum(a))


if __name__ == '__main__':
    solve()

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

Solution (Python):
import heapq
N,M=map(int,input().split())
A =  [-int(x) for x in input().split()]
A.sort()
for i in range(M):
    rem=A[0]
    heapq.heappush(A,int(rem/2))
    heapq.heappop(A)
    
print(-sum(A))

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from heapq import heapify,heappop,heappush
    n,m=map(int,input().split())
    A=[-a for a in map(int,input().split())]
    heapify(A)
    for _ in range(m):
        x=-heappop(A)
        heappush(A,-(x//2))
    print(-sum(A))
resolve()

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from heapq import heapify,heappop,heappush
    n,m=map(int,input().split())
    A=[-a for a in map(int,input().split())]
    heapify(A)
    for _ in range(m):
        x=-heappop(A)
        heappush(A,-(x//2))
    print(-sum(A))
resolve()

Solution (Python):
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))