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):
import heapq
N,M=map(int,input().split())
arr=list(map(int,input().split()))
hq=[]
for i in arr:
    heapq.heappush(hq,-i)

while M>0:
    a=heapq.heappop(hq)    
    heapq.heappush(hq,a/2)
    M-=1
    
ans=0
for i in hq:    
    ans+=int(-i)
    
print(ans)

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

Solution (Python):
[N,M] = list(map(int,input().split()))
A = list(map(int,input().split()))
out=sum(A)
import heapq
a = list(map(lambda x: x*(-1), A))  
heapq.heapify(a)


for i in range(M):
    
    saidai = heapq.heappop(a)*(-1)
    out-=saidai
    out+=saidai//2
    
    heapq.heappush(a, (saidai//2)*(-1))
    

print(out)

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

Solution (Python):
import math        
import heapq





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

price = [-i for i in price]

heapq.heapify(price)

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

price = [-i for i in price]

print(sum(price))

Solution (Python):
import sys
stdin = sys.stdin

n,m = map(int, stdin.readline().split())
an = [i*(-1) for i in map(int, stdin.readline().split())]



import heapq
heapq.heapify(an)

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


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

Solution (Python):
import sys
import heapq


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

while m > 0:
    max_a = heapq.heappop(a_list)
    heapq.heappush(a_list, (-1)*(-max_a//2))
    m -= 1

print(-sum(a_list))

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    import heapq
    mod=10**9+7
    N,M=MI()
    A=LI()
    for i in range(N):
        A[i]*=-1
    heapq.heapify(A)
    
    for i in range(M):
        a=heapq.heappop(A)
        heapq.heappush(A,a/2)
        
    ans=0
    for i in range(N):
        a=heapq.heappop(A) * -1
        ans+=int(a)
        
    print(ans)
        

main()

Solution (Python):
import heapq
class Heapq:
    def __init__(self, arr, desc=False):
        if desc:
            arr = [-a for a in arr]
        self.sign = -1 if desc else 1
        self.hq = arr
        heapq.heapify(self.hq)
 
    def pop(self):
        return heapq.heappop(self.hq) * self.sign
 
    def push(self, a):
        heapq.heappush(self.hq, a * self.sign)
 
    def top(self):
        return self.hq[0] * self.sign
        
N,M=map(int,input().split())
A=list(map(int,input().split()))

q = Heapq(A, True)
    
for i in range(M):
    x=q.pop()
    q.push(x//2)

print(sum([q.pop() for _ in range(N)]))

Solution (Python):

import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N, M = zz()
A = zz()
A = [-a for a in A]
heapq.heapify(A)

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

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

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

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

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):
    number=heapq.heappop(a)  
    if number%2==0:
        number=number//2
    else:
        number=number//2+1
    heapq.heappush(a, number)  
print(-sum(a))

Solution (Python):
import sys
import heapq


def main():
    input = sys.stdin.buffer.readline
    n, m = map(int, input().split())
    a = list(map(lambda x: -int(x), input().split()))
    heapq.heapify(a)
    for _ in range(m):
        price = heapq.heappop(a)
        heapq.heappush(a, -((-price) // 2))
    print(-sum(a))


if __name__ == "__main__":
    main()

Solution (Python):
n,m=map(int,input().split())
import heapq

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 = [int(_) for _ in input().split()]
A = [int(_) * -1 for _ in input().split()]

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

Solution (Python):
import math
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))

lis = []
for i in a:
    lis.append(-1*i)

heapq.heapify(lis)

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

print(-sum(lis))

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

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

Solution (Python):
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [i*-1 for i in a]
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(x) for x in input().split()]
A = [-int(x) for x in input().split()]

heapq.heapify(A)

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

ans = -sum(A)

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 _ in range(M):
    p = -heapq.heappop(A)
    tmp = p // 2
    heapq.heappush(A, -tmp)

print(-sum(A))

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m = list(map(int, input().split()))
a = list(map(int, input().split()))
from heapq import heappop as hpp, heappush as hp
h = []
for num in a:
    hp(h, -num)
for _ in range(m):
    val = hpp(h)
    val *= -1
    hp(h, -(val//2))
ans = -sum(h)
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(0,M):
    a=heapq.heappop(A)
    heapq.heappush(A,(-1)*(-a//2))
print(-sum(A))

Solution (Python):
import heapq
from collections import deque
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):
    x=heapq.heappop(A)
    if x%2==0:
        x//=2
    else:
        x=x//2 +1
    heapq.heappush(A,x)

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

Solution (Python):
import heapq

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

heapq.heapify(A)

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

Solution (Python):
from heapq import *
n,m = map(int,input().split())
a = list(map(int,input().split()))

heap = []
for i in a:
    heappush(heap,-i)

for _ in range(m):
    tmp = heappop(heap)
    heappush(heap,-(-tmp//2))

ans = 0
for a in heap:
    ans += -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):
    ref = heapq.heappop(a)*-1
    ref //= 2
    heapq.heappush(a, -ref)

print(sum(a)*-1)

Solution (Python):
import heapq

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

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

Solution (Python):


import sys
from heapq import heapify, heappop, heappush
from math import ceil
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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

heapify(A)

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

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

print(-sum(a))

Solution (Python):
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy


import heapq
sys.setrecursionlimit(10**6)

INF = 10**18
import bisect
import statistics
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):
    a = heapq.heappop(A)
    a = ((-1) * a // 2) * (-1)
    heapq.heappush(A, a)

print(-sum(A))

Solution (Python):
from heapq import heapify, heappop, heappush
N, M = map(int, input().split())
A = list(map(int, input().split()))
q = []
for a in A:
    q.append((a//2-a, a, 1))
heapify(q)
ans = sum(A)
for _ in range(M):
    discount, a, n = heappop(q)
    ans += discount
    if ans==0:
        break
    heappush(q, (a//2**(n+1)-a//2**n, a, n+1))
print(ans)

Solution (Python):
import sys
import math
import itertools
import collections
from collections import deque
import heapq 

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():

    N, M = NMI()
    A = NLI()
    
    A = list(map(lambda x: x*(-1), A))
    
    heapq.heapify(A)
    
    for m in range(M):
        highest = (heapq.heappop(A)*(-1))
        discounted = math.floor(highest/2) * -1
        heapq.heappush(A, discounted)

        
    print(sum(A)*-1)


if __name__ == '__main__':
    main()

Solution (Python):

import heapq


def solve(n,m,a):
  a = [-x for x in a]
  heapq.heapify(a)
  for _ in range(m):
    x = heapq.heappop(a)
    heapq.heappush(a,-(abs(x)//2))
  return abs(sum(a))


def main():
  N,M = map(int,input().split())
  a = list(sorted(map(int,input().split())))
  print(solve(N,M,a))
  pass

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 * (-1), a))

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

print(-sum(a))

Solution (Python):
import heapq

from typing import List


def main():
    n, m = map(int, input().split())
    v = map(int, input().split())
    print(pdt(v, m))


def pdt(v: List[int], m: int) -> int:
    vv = [-a for a in v]
    heapq.heapify(vv)

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

    return -sum(vv)


if __name__ == '__main__':
    main()

Solution (Python):
import heapq as hp

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

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

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

print(-sum(a))

Solution (Python):
from heapq import heapify, heappop, heappush

def resolve():
  N, M = map(int, input().split(" "))
  A = [(-1)*int(x) for x in input().split(" ")]
  heapify(A)

  for _ in range(M):
    max_A = (-1)*heappop(A)
    heappush(A, (-1)*(max_A//2))
  
  print((-1)*sum(A))

if __name__ == "__main__":
  resolve()

Solution (Python):

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

Solution (Python):
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,m=mp()
a=lmp()
l=[]
heapq.heapify(l)
for i in a:
    heapq.heappush(l,(-1)*i)
for i in range(m):
    j=heapq.heappop(l)
    heapq.heappush(l,-(-j//2))
print(-sum(l))

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

Solution (Python):
from heapq import heappop,heappush

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

h=[]
for l in a:
    heappush(h,-l) 
    
for i in range(m):
    amax=heappop(h)
    l=(-amax)//2
    heappush(h,-l)
    
print(-sum(h))

Solution (Python):
import heapq

n, m = map(int, input().split())
aL = list(map(lambda x: int(x) * (-1), input().split(" ")))

heapq.heapify(aL)

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

print(int(sum(aL) * -1))

Solution (Python):

import heapq

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



heapq.heapify(A)

for i in range(M):
    heapq.heappush(A,-(-heapq.heappop(A)//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] = -A[i]
heapq.heapify(A)
for _ in range(M):
  a = -heapq.heappop(A)
  a = (a//2) * -1
  heapq.heappush(A, a)
print(sum(A)*-1)

Solution (Python):
import heapq

I = input().split()
N = int(I[0])
M = int(I[1])



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

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

heapq.heapify(A)
for i in range(M):
    M -= 1
    pri = heapq.heappop(A)

    pri *= -1
    pri //= 2
    pri *= -1

    heapq.heappush( A , pri )

Fi_pri = 0
for i in range(N):
    Fi_pri += A[i]

print( -1 * Fi_pri )

Solution (Python):
def bin_tree( pri , li_pri , len_li ):
    
    
    
    lo = 0
    hi = len_li - 1
    while hi - lo > 1:
        mid = lo + (hi - lo) // 2
        guess = li_pri[mid]
        if guess >= pri:
            hi = mid
        else:
            lo = mid
    return lo

I = input().split()
N = int(I[0])
M = int(I[1])



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

while M > 0:
    M -= 1
    pri = A.pop( N - 1 )
    pri = pri // 2
    if len(A) == 0:
        ans = 0
    elif (pri < A[0] ):
        ans = 0
    else:
        ans = bin_tree( pri , A , N - 1 ) + 1
    
    A[ans:ans] = [pri]    

F_pri = 0
for i in range(N):
    F_pri += A[i]
print(F_pri)

Solution (Python):

import sys
import heapq


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    n, m = MI()
    a = LI()
    heap = []
    for i in range(n):
        heapq.heappush(heap, a[i] * -1)

    while m > 0:
        min_ = heapq.heappop(heap) * -1
        min_ = (min_ // 2) * -1
        heapq.heappush(heap, min_)
        m -= 1
    print(sum(heap) * -1)


main()

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

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

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

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

if __name__ == "__main__":
    main()

Solution (Python):
from heapq import heapify,heappush,heappop

def main():
    N,M = map(int,input().split())
    A = [ -x for x in map(int,input().split()) ]
    heapify(A)

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


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

    ans = abs(ans)
    return ans

print(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 i in range(m):
    tmp = heapq.heappop(A)*(-1)
    heapq.heappush(A, (-1)*(tmp//2))
print(sum(A)*(-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 i in range(M) :
    a = heapq.heappop(A)
    a = int(a/2)
    heapq.heappush(A,a)

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

Solution (Python):
import heapq

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

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

Solution (Python):
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math
INT_MIN=-10**13
import bisect as B

n,m=INPUT()
A=INPUT()
A.sort()
for _ in range(m):
    B.insort(A,A.pop()//2)
print(sum(A))

Solution (Python):
import heapq
from fractions import Fraction

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

a = list(map(lambda x: Fraction(1, int(x)), input().split()))

heapq.heapify(a)

for i in range(m):
    x = heapq.heappop(a)
    y = Fraction(x.numerator * 2, x.denominator)
    if y.numerator < y.denominator:
        heapq.heappush(a, y)
    elif len(a) == 0:
        break

s = 0


for j in range(len(a)):
    s += int(Fraction(a[j].denominator, a[j].numerator))

print(s)

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

discount_list = []
for a in A:
    while a > 0:
        discount = a//2
        discount_list.append(a-discount)
        a = discount
        
discount_list.sort(reverse=True)


print(sum(A)-sum(discount_list[:M]))

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

while M > 0:
    x = heapq.heappop(heap)
    heapq.heappush(heap, int(x/2))
    M -= 1
print(sum(heap)*(-1))

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

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

for _ in range(M):
    a=-heapq.heappop(A)
    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)
for _ in range(m):
  b=heapq.heappop(a)
  heapq.heappush(a,-(-b//2))
print(-sum(a))

Solution (Python):
from collections import deque


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

coupon = M
while coupon:
    try:
        if B:
            if A[-1] >= B[-1]:
                B.appendleft(A.pop() // 2)
            else:
                B.appendleft(B.pop() // 2)
        else:
            B.append(A.pop() // 2)
        coupon -= 1
    except IndexError:
        A, B = B, A


ans = sum(int(i) for i in A) + sum(int(i) for i in B)
print(ans)

Solution (Python):
import heapq
N, M = map(int, input().split())
A = [-a for a in map(int, input().split())]
heapq.heapify(A)
for _ in range(M):
    x = -heapq.heappop(A)
    heapq.heappush(A, -(x // 2))
ans = -sum(A)
print(ans)

Solution (Python):
import bisect
N, M = map(int, input().split())
A = sorted(map(int, input().split()))
for _ in range(M):
    x = A.pop()
    y = x // 2
    i = bisect.bisect_left(A, y)
    A.insert(i, y)
ans = sum(A)
print(ans)

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

Solution (Python):
N,M = map(int,input().split())
A = list(map(int,input().split()))
su = sum(A)
l = []

for i in range(N):
    for j in range(30):
        l += -(-A[i]//2),
        A[i] //= 2

l.sort(reverse=True)

print(su - sum(l[:M]))

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

while M:
    A[-1]//=2
    M-=1
    i=-2
    while M and (-N<=i and A[i]>=A[-1]):
        A[i]//=2
        M-=1
        i-=1
    A.sort()

print(sum(A))

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

print(-sum(a))

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

Solution (Python):
inp=list(map(int,input().split()))
m=inp[1]
inp=list(map(int,input().split()))
ans=0
inp=[-1*item for item in inp]
import heapq
heapq.heapify(inp)
while m>0:
    a=heapq.heappop(inp)
    a*=-1
    x=a//2
    heapq.heappush(inp,-1*x)
    m-=1
print (-1*sum(inp))

Solution (Python):


import heapq

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

a = [*map(lambda x: -x, a)]
heapq.heapify(a)
for _ in range(m):
    heapq.heappush(a, -(-heapq.heappop(a) >> 1))
print(-sum(a))

Solution (Python):


import heapq

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

a = [*map(lambda x: -x, a)]
heapq.heapify(a)
for _ in range(m):
    heapq.heappush(a, -(-heapq.heappop(a) >> 1))
print(-sum(a))

Solution (Python):


from bisect import insort_right

n, m, *a = map(int, open(0).read().split())
a.sort()
for _ in range(m):
    insort_right(a, a.pop() >> 1)
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 i in range(m):
    tmp_min=heapq.heappop(a)
    if tmp_min%2==0:
        push=tmp_min/2
    else:
        push=tmp_min//2+1
    heapq.heappush(a,push)
print(int(-sum(a)))

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

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

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,string
from collections import defaultdict as D
from functools import reduce
from heapq import heappop,heappush,heapify
import numpy as np
import sys
import os
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


N, M = LI()
A = LI()

A_minus = [-x for x in A]

heapify(A_minus)

pop = lambda: -heappop(A_minus)
push = lambda x: heappush(A_minus,-x)

for _ in range(M):
    
    x = pop()
    push(x//2)
 
answer = -sum(A_minus)
print(answer)

Solution (Python):
from collections import deque

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

A = deque(sorted(A,reverse=True))
B = deque([])
n = 0
for m in range(M):
    if A:
        if B:
            if (A[0] > B[0]):
                B.append(A.popleft()//2)
                continue
        else:
            B.append(A.popleft()//2)
            continue
    
    n += 1
    b = B.popleft()
    B.append(b//2)

print(sum(A)+sum(B))

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M = mapint()
As = list(mapint())
Q = []
from heapq import heappop, heappush
for a in As:
    heappush(Q, -a)
for i in range(M):
    v = heappop(Q)
    heappush(Q, v/2)
lis = [-int(x) for x in Q]
print(sum(lis))

Solution (Python):
import heapq

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

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

a = [-1*i for i in a]

heapq.heapify(a)

count = 0

while count < m:
    item = heapq.heappop(a)
    item= abs(item)
    discount_item = item//2
    heapq.heappush(a,-1*discount_item)
    count += 1

print(abs(sum(a)))

Solution (Python):
import heapq

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

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

a = [-1*i for i in a]

heapq.heapify(a)

count = 0

while count < m:
    item = heapq.heappop(a)
    item= abs(item)
    discount_item = item//2
    heapq.heappush(a,-1*discount_item)
    count += 1

result_prime = [-1*i for i in a]

print(sum(result_prime))

Solution (Python):
N, M = list(map(int,input().split()))
A = sorted(list(map(int,input().split())), reverse=True)
b = []

b.append(A.pop(0)//2)
for i in range(1,M):
    if A == []:
        b.append(b.pop(0)//2)
    else:
        if A[0] > b[0]:
            b.append(A.pop(0)//2)
        else:
            b.append(b.pop(0)//2)

print(sum(A)+sum(b))

Solution (Python):
from heapq import *
N, M = map(int, input().split())
A = []
for a in map(int, input().split()):
    heappush(A, -a)
for _ in range(M):
    x = -heappop(A)
    x //= 2
    heappush(A, -x)
print(-sum(A))

Solution (Python):
import heapq

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

Solution (Python):

from heapq import heappop, heappush

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

pq = []
for v in X:
    heappush(pq, -v)

for _ in range(M):
    u = heappop(pq)
    heappush(pq, -(-u // 2))

print(-sum(pq))

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))
ticket_num = m
heapq.heapify(a)

if n > 1:
    for i in range(m):
        MAX = heapq.heappop(a)
        MAX = math.ceil(MAX / 2)
        heapq.heappush(a,MAX)
        
else:
    MAX = heapq.heappop(a)
    MAX = math.ceil(MAX / (2**m))
    heapq.heappush(a,MAX)

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

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

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):
    a = heapq.heappop(A)
    heapq.heappush(A, a/2)
print(sum([-int(a) for a in A]))

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

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

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