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

heapq.heapify(A)

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

cost = 0
for a in A:
    cost -= a
print(cost)

Solution (Python):
import heapq

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

heapq.heapify(A)

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

print sum(A)*(-1)

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

for i in range(M):
    ll=heapq.heappop(la)/2
    heapq.heappush(la,ll)
ans=0
for i in range(N):
    ans+=int(-heapq.heappop(la))
print(ans)

Solution (Python):
import sys
import math
import numpy as np
import copy
import heapq
import queue



def main():
    n, m = [int(t) for t in input().split()]
    a = [int(t) for t in input().split()]
    b = [-x for x in a]
    heapq.heapify(b)
    for i in range(m):
        x = heapq.heappop(b) * -1
        heapq.heappush(b, (x // 2) * -1)
    print(-1 * sum(b))
    return 0

if __name__ == '__main__':
    sys.exit(main())

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

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

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

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

Solution (Python):
import heapq


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


A2 = [-a for a in A]
heapq.heapify(A2)

for i in range(M):
    temp_min = A2[0] + 1
    heapq.heappushpop(A2, temp_min//2)

print(-sum(A2))

Solution (Python):

from heapq import heapify, heapreplace


def main():
    N, M, *A = map(int, open(0).read().split())
    H = [-i for i in A]
    heapify(H)
    for _ in range(M):
        x = H[0]
        heapreplace(H, x // 2 + x % 2)
    ans = -sum(H)
    print(ans)


if __name__ == "__main__":
    main()

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

Solution (Python):
import heapq

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

while M > 0:
    maxPrice = -heapq.heappop(priceList)
    maxPrice = maxPrice // 2
    M -= 1
    heapq.heappush(priceList, -maxPrice)

sum = 0
for i in range(N):
    sum += priceList[i]

print(-sum)

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(int, input().split())
a = list(map(int, input().split()))
a = [-x for x in a]

heapq.heapify(a)

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

Solution (Python):
import heapq

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

heapq.heapify(price_list)
for n in range(M):
    max_price = heapq.heappop(price_list)*(-1)
    devided_price = max_price // 2
    heapq.heappush(price_list, (-1)*devided_price)

print((-1)*sum(price_list))

Solution (Python):
import heapq
 
N, M = [int(item) for item in input().rstrip().split()]
hp = [-1 * int(item) for item in input().rstrip().split()]
heapq.heapify(hp)

for i in range(M):
    _t = heapq.heappop(hp)
    heapq.heappush(hp, -1 * (-1 * _t // 2))
    
_sum = sum([-1 * int(item) for item in hp])
print(_sum)

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

Solution (Python):
import heapq
from functools import reduce

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

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

print(-reduce(lambda a, b: a+b, h))

Solution (Python):
import heapq
n,m = map(int,input().split())
a_list=[-int(s) for s in input().split()]
heapq.heapify(a_list)

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

print(-sum(a_list))

Solution (Python):
import heapq
N,M=map(int,input().split())
kakaku=list(map(int,input().split()))
han=[]
for i in range(N):
  han.append(-kakaku[i])
  
heapq.heapify(han)
for _ in range(M):
  k=heapq.heappop(han)
  k=k/2
  heapq.heappush(han,k)

sum=0
for j in range(N):
  sum+=int(-han[j])
print(sum)

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)
    sum = 0

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

    for i in range(n):
        sum += a[i]

    print(-sum)

if __name__ == "__main__":
    main()

Solution (Python):


import heapq
import math
import sys


DEBUG = False


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


def solve(N, M, A):
    hq = [-a for a in A]
    heapq.heapify(hq)
    for _ in range(M):
        v = -hq[0]
        if v < 1:
            break
        v //= 2
        heapq.heapreplace(hq, -v)

    return sum([math.floor(-v) for v in hq])


def main():
    N, M = [int(e) for e in input().split()]
    A = [int(e) for e in input().split()]
    print(solve(N, M, A))


if __name__ == '__main__':
    main()

Solution (Python):
import heapq

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

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

Solution (Python):
import heapq

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

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

ans=0
for i in range(n[0]):
  ans+=-m[i]

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)

while M:
  m = heapq.heappop(A) * (-1)
  heapq.heappush(A, (-1) * (m // 2))
  M -= 1
print (sum(A) * (-1))

Solution (Python):
import math
import heapq

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


while m >0:
    heru = math.ceil((heapq.heappop(h))/2)
    heapq.heappush(h,heru)
    m = m-1
print((-1)*sum(h))

Solution (Python):



def main():
    from heapq import heappush, heappop

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

    for ai in a:
        heappush(b, -ai)

    for i in range(m):
        bi = -heappop(b)
        bi //= 2
        heappush(b, -bi)

    print(-sum(b))


if __name__ == '__main__':
    main()

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 i in range(m):
    x=-(-heapq.heappop(a)//2)
    heapq.heappush(a,x)

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

print(sum(a))

Solution (Python):
import heapq

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

def minus_int(x):
  return -1 * int(x)

a = list(map(minus_int, input().split()))
heapq.heapify(a)

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

Solution (Python):
import sys
import math
from fractions import gcd





def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""


 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())


 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""
from heapq import heappop, heappush, heapify
n,m =  map(int, sys.stdin.readline().split())
a =  list(map(int, sys.stdin.readline().split()))
q = []

for x in a:
        heappush(q,-x)
for _ in range(m):
        l = heappop(q)
        heappush(q, -((-l)//2))
print(-sum(q))

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

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

heapify(A)
for i in range(M):
    heappush(A, int(heappop(A) / 2))

print(-1 * sum(A))

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

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

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

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

Solution (Python):
import heapq

NM =input().split(" ")
A_LIST = input().split(" ")
N = int(NM[0])
M = int(NM[1])

A = []
for i in A_LIST:
    heapq.heappush(A, -1 * int(i))
    
for i in range(0, M):
    m = heapq.heappop(A)
    m = -1 * m
    m = m // 2
    heapq.heappush(A, -1 * m)

S = 0    
for i in A:
    S += (-1 * i)

print(S)

Solution (Python):
import heapq

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

heapq.heapify(price)

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

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]*(-1)
heapq.heapify(a)
for i in range(m):
    b = heapq.heappop(a)
    if b % 2 == 0:
        b = b //2
    else:
        b = b//2 + 1
    
    heapq.heappush(a,b)
ans = 0
for i in range(n):
    ans += (heapq.heappop(a))*(-1)
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 _ in range(m):
    y = heapq.heappop(a)
    heapq.heappush(a, (-1)*(-y//2))

print(-sum(a))

Solution (Python):
import heapq


N,M = [int(i) for i in input().split()]
data = [int(i) for i in input().split()]
data = list(map(lambda x: x*(-1), data))
heapq.heapify(data)

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

Solution (Python):
def main():
    from heapq import heappush,heappop,heapify
    N, M = (int(i) for i in input().split())
    A = [-int(i) for i in input().split()]
    heapify(A)
    for divcnt in range(M):
        tmp = -heappop(A)
        tmp //= 2
        heappush(A,-tmp)
    print(-sum(A))
if __name__ == "__main__":
    main()

Solution (Python):
from heapq import heappush,heappop,heapify
from math import ceil
def main():
    N, M = (int(i) for i in input().split())
    A = [-int(i) for i in input().split()]
    heapify(A)
    for divcnt in range(M):
        tmp = ceil(heappop(A)/2)
        heappush(A,tmp)
    print(-sum(A))
if __name__ == "__main__":
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *
INF = 10**10

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

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

print(-sum(A))

Solution (Python):
import heapq


def main():
    n, m = map(int, input().split(' '))
    a_s = list(sorted(map(lambda x: -1 * int(x), input().split(' '))))

    heapq.heapify(a_s)
    for _ in range(m):
        e = heapq.heappop(a_s)
        heapq.heappush(a_s, int(e/2))
    print(-1*sum(a_s))
    
    

if __name__ == '__main__':
    main()

Solution (Python):
import sys
import heapq

input = sys.stdin.readline

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

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

minus = lambda x:-x

data = list(map(minus,data))


heapq.heapify(data)


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

print(-sum(data))

Solution (Python):
import heapq

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

heapq.heapify(A)

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

print(-sum(A))

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

import heapq

h = []
for i in range(N):
    heapq.heappush(h, A[i]*(-1))
    
for i in range(M):
    temp = heapq.heappop(h)
    temp *= (-1)
    temp //= 2
    temp *= (-1)
    heapq.heappush(h, temp)
    
print(sum(h)*(-1))

Solution (Python):
import heapq
N,M=map(int,input().split())
A=[int(i) for i in input().split()]
q=[]
for i in range(N):
    heapq.heappush(q,-A[i])
for i in range(M):
    K=-heapq.heappop(q)
    L=K//2
    heapq.heappush(q,-L)
ans=0
for i in range(N):
    ans-=heapq.heappop(q)
print(ans)

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

Solution (Python):
import heapq
 
def FUNCTION(A, M):
    heapq.heapify(A)
    for i in range(M):
        heapq.heappush(A, int(heapq.heappop(A) / 2))
    return -sum(A)

N = list(map(int, (input().split(' '))))
A = list(map(lambda x: x*(-1), map(int, (input().split(' ')))))
print(FUNCTION(A, N[1]))

Solution (Python):
import heapq

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

ans = 0
for _ in range(m):
    tmp_max = -(-1 * heapq.heappop(A) // 2)
    heapq.heappush(A, tmp_max)

for i in range(n):
    ans += heapq.heappop(A) * (-1)

print(ans)

Solution (Python):
def solve(string):
    n, m, *a = map(int, string.split())
    while m > 0:
        a.sort(reverse=True)
        if a[0] == 0:
            break
        b = a[0] // 2
        for i, _a in enumerate(a):
            if m == 0 or _a <= b:
                break
            a[i] //= 2
            m -= 1
    return str(sum(a))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Solution (Python):
from heapq import heappush, heappop


def solve(string):
    n, m, *a = map(int, string.split())
    while m > 0:
        a.sort(reverse=True)
        if a[0] == 0:
            break
        b = a[0] // 2
        for i, _a in enumerate(a):
            if m == 0 or _a <= b:
                break
            a[i] //= 2
            m -= 1
    return str(sum(a))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

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

ans = 0
for i in a:
    ans += int(i)

print(-ans)

Solution (Python):
n,m = map(int,input().split())
arr = list(map(int,input().split()))
l = len(arr)

while m != 0 :
    arr.sort(reverse=True)
    j = arr[0] // 2
    for i in range(l):
            if arr[i] > j:
                if m != 0:
                    m -= 1
                else:
                    break
                arr[i] //= 2
            else:
                break
    if arr[0] == 0:
        break
            

print(sum(arr))

Solution (Python):
import heapq

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

lst = [-int(x) for x in input().split()]

heapq.heapify(lst)
 
for i in range(M):
    lstmin = heapq.heappop(lst)
    b = (-(lstmin) // 2)
    heapq.heappush(lst,-b)
    
print (-sum(lst))

Solution (Python):
from heapq import heappush, heappop


def solve(string):
    n, m, *a = map(int, string.split())
    h = []
    for _a in a:
        heappush(h, -_a)
    for _ in range(m):
        heappush(h, -(-heappop(h) // 2))
    return str(-sum(h))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Solution (Python):




import heapq

def main():
  n, m = map(int, input().split())
  a = list(map(int, input().split()))
  pq = to_priorityqueue(a)
  pq = use_ticket(pq, m)
  print(-sum(pq))






def to_priorityqueue(list):
  rtn = []
  for el in list:
    heapq.heappush(rtn, -el)
  return rtn




def use_ticket(pq, t_num):
  while t_num and pq:
    el = -(heapq.heappop(pq))
    el //= 2
    heapq.heappush(pq, -el)
    t_num -= 1
  return pq

if __name__ == "__main__":
  main()

Solution (Python):
import heapq

N, M  = [int(x) for x in input().split()]
l = [-int(x) for x in input().split()]
heapq.heapify(l)
for i in range(M):
  h = heapq.heappop(l)
  h = -h // 2
  heapq.heappush(l, -h)
print(-sum(l))

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 j in range(M):
    a = heapq.heappop(A)
    b = -1*((-a) // 2)
    heapq.heappush(A,b)

print(-sum(A))

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

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


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



print(sum(map(lambda n: int (-n), heap)))

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

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


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



print(sum(map(lambda n: int (-n), heap)))

Solution (Python):
n, m = map(int, input().split())
a = [int(x) for x in input().split() ]

while m > 0 and a[0] > 0:
    a.sort(reverse=True)
    tmp = a[0] // 2
    for i in range(n):
        if a[i] > tmp and m > 0:
            a[i] //= 2
            m -= 1
        else:
            break

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 _ in range(m):
    tmp = int(heapq.heappop(a)/2)
    
    heapq.heappush(a,tmp)

print(-sum(a))

Solution (Python):
import sys
import heapq

n, m = map(int, sys.stdin.readline().split())

a = list(map(int, sys.stdin.readline().split()))

pq = []

for ele in a:
	heapq.heappush(pq, -ele)

while m and pq:
	ele = -(heapq.heappop(pq))
	ele = ele//2
	if ele:
		heapq.heappush(pq, -ele)
	m -= 1
print(-sum(pq))

Solution (Python):
import heapq
n,m=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
heap=[]
for i in a:
    heapq.heappush(heap,10**5-i)

for i in range(m):
    tmp=heapq.heappop(heap)
    tmp=(10**5-tmp)//2
    heapq.heappush(heap,10**5-tmp)

ans=0
for i in range(n):
    ans+=10**5-heap[i]
print(ans)

Solution (Python):
'use strict'
import heapq

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

heapq.heapify(goods_price_list)

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

print(-sum(goods_price_list))

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

A = [-a for a in A]

from heapq import heapify, heappop, heappush

heapify(A)

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

Solution (Python):
from queue import PriorityQueue

N, M = map(int, input().split())
A = list(map(int, input().split()))
queue = PriorityQueue()
for a in A:
    queue.put(-a)
for _ in range(M):
    v = -queue.get()
    queue.put(-(v // 2))

total = 0
while not queue.empty():
    total += -(queue.get())
print(total)

Solution (Python):
import heapq

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

def pop():
    return -heapq.heappop(a)

def push(x):
    return heapq.heappush(a, -x)

for _ in range(m):
    tmp = pop()
    push(tmp//2)

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

print(-sum(a))

Solution (Python):
import heapq

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

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

print(-sum(a))

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

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

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

Solution (Python):
import heapq
def f(s):
  return -int(s)
N,M = map(int,input().split())
A = list(map(f,input().split()))

h = []
for a in A:
  heapq.heappush(h,a)

for i in range(M):
  a = heapq.heappop(h)
  heapq.heappush(h,a/2)
ans=0
for a in h:
  ans += int(-a)
print(ans)

Solution (Python):
import heapq

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

heapq.heapify(A)
for i in range(N[1]):
    heapq.heappush(A, int(heapq.heappop(A) / 2))

print(-sum(A))

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
from queue import PriorityQueue
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

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

pq = PriorityQueue()
for a in A:
    pq.put((-a, a))

for i in range(M):
    val = pq.get()[1]
    val = math.floor(val/2)
    pq.put((-val, val))

ans = 0
while not pq.empty():
    ans += pq.get()[1]
print(ans)

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

import heapq

heapq.heapify(a)

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

Solution (Python):
import heapq

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

heapq.heapify(A)

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

Solution (Python):
import heapq,math
n, m = map(int, input().split())
a =[int(i) *(-1) for i in input().split()]
heapq.heapify(a)
for _ in range(m):
    amin = heapq.heappop(a)
    heapq.heappush(a, amin/2)
ans = 0
for _a in a:
    ans += math.floor(_a * (-1))
print(ans)

Solution (Python):
import heapq

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

heapq.heapify(A)

for m in range(M):
    heapq.heapreplace(A, -(-A[0] // 2))

print(-sum(A))

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

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

Solution (Python):


from fractions import Fraction
import heapq
import math
import sys


DEBUG = False


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


def solve(N, M, A):
    hq = [-a for a in A]
    heapq.heapify(hq)
    for _ in range(M):
        v = -hq[0]
        if v < 1:
            break
        v = Fraction(v, 2)
        heapq.heapreplace(hq, -v)

    return sum([math.floor(-v) for v in hq])


def main():
    N, M = [int(e) for e in input().split()]
    A = [int(e) for e in input().split()]
    print(solve(N, M, A))


if __name__ == '__main__':
    main()

Solution (Python):
import heapq
n,m = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
h = []
for i in l:
    i = -1*i
    heapq.heappush(h,i)
    
for _ in range(m):
    v = -heapq.heappop(h)
    heapq.heappush(h,-1*(v//2))
    
print(-sum(h))

Solution (Python):
import heapq as hp

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

Solution (Python):
import heapq

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

A =[-a for a in A]

heapq.heapify(A)

for w in range(M):
    max=heapq.heappop(A)
    heapq.heappush(A,max/2)
   
B=list(map(int, A))

print(sum(B)*-1)

Solution (Python):
import heapq as hq

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

A = []
for a in [int(_) for _ in input().split()]:
    hq.heappush(A, -a)

for _ in range(m):
    t = hq.heappop(A)
    hq.heappush(A, t / 2)
print(-sum([int(a) for a in A]))

Solution (Python):
import sys
sys.setrecursionlimit(int(1e6))

import heapq

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

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

prices = [- heapq.heappop(h_A) for _ in range(N)]
print(sum(prices))

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

hq.heapify(A)
for i in range(M):
    m = A[0]
    hq.heappushpop(A, -((-m)//2))
print(-sum(A))

Solution (Python):
import heapq

def solve(n, m, a):
    v = []
    for i in range(n):
        heapq.heappush(v, -a[i])
    for i in range(m):
        x = heapq.heappop(v)
        x /= 2
        heapq.heappush(v, x)
    res = sum([int(-heapq.heappop(v)) for i in range(n)])
    return int(res)

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

Solution (Python):
import sys
import heapq

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

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

Solution (Python):
import heapq

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

heapq.heapify(A)

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

A = [-val for val in A]

print(sum(A))

Solution (Python):
import heapq

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

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

print(-sum(queue))

Solution (Python):
import heapq

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

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

Solution (Python):
import heapq
N,M=[int(s) for s in input().split()]
ls=input().split()
h = []
for e in ls:
  heapq.heappush(h, -int(e))
for i in range(M):
  x=heapq.heappop(h)
  y=(-x)//2
  heapq.heappush(h,-y)
print(-sum(h))

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

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

Solution (Python):
import heapq

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

heap = [-Ai for Ai in A]
heapq.heapify(heap)
for _ in range(M):
    heapq.heapreplace(heap, heap[0]/2)
A = [int(-p) for p in heap]
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):
  temp=(-1)*heapq.heappop(A)>>1
  heapq.heappush(A, temp*(-1))
print(-sum(A))

Solution (Python):
import heapq
import math

q = []
N, M = map(int, input().split())
A = list(map(int, input().split()))
for i in A:
    heapq.heappush(q, -i)
for j in range(M):
    x = heapq.heappop(q)
    heapq.heappush(q, math.ceil(x/2))
print(-sum(q))

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