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 math import ceil
from heapq import *

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

for _ in range(m):
	amax = -heappop(a_s)
	heappush(a_s, -(amax // 2))

res = -sum(a_s)
print(res)

Solution (Python):
from math import ceil
from heapq import *

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

for _ in range(m):
	amax = heappop(a_s)
	heappush(a_s, ceil(amax / 2))

res = sum([-heappop(a_s) for _ in range(n)])
print(res)

Solution (Python):
import heapq

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

heapq.heapify(li)

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

print(-sum(li))

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

Solution (Python):
import sys
from collections import defaultdict, deque
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


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


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]



def A():
    s = input()
    if s == "Sunny":
        print("Cloudy")
    elif s == "Cloudy":
        print("Rainy")
    else:
        print("Sunny")
    return



def B():
    s = S()
    for i in range(len(s)):
        if i % 2:
            if s[i] not in ["L", "U", "D"]:
                print("No")
                return
        else:
            if s[i] not in ["R", "U", "D"]:
                print("No")
                return
    print("Yes")
    return



def C():
    n, k, q = LI()
    a = IR(q)
    sc = [0] * n
    for i in a:
        sc[i - 1] += 1
    for i in sc:
        print("Yes" if i > q - k else "No")
    return



def D():
    n, m = LI()
    a = LI()
    q = []
    for i in range(n):
        heappush(q, -a[i])
    for i in range(m):
        x = heappop(q)
        x *= -1
        x >>= 1
        heappush(q, -x)
    print(-sum(q))
    return



def E():
    return



def F():
    return



def resolve():
    D()
    return



if __name__ == "__main__":
    D()

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

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

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

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

    print(sum(A)*-1)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
mlmis = lambda: [-int(x) for x in input().split()]
INF = float('inf')


def main():
    N,M = mis()
    A = mlmis()
    import heapq
    heapq.heapify(A)
    for _ in range(M):
        a = heapq.heappop(A)
        heapq.heappush(A, a/2)
    print(sum(-int(a) for a in A))



main()

Solution (Python):
import heapq

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

heapq.heapify(l)

while m>0:
    a=heapq.heappop(l)
    if a//2==a/2:
        heapq.heappush(l,a//2)

    else:
        heapq.heappush(l,a//2+1)
    m=m-1

print(-sum(l))

Solution (Python):
import heapq
N,M=map(int,input().split())
l=list(map(int,input().split()))
l=[-n for n in l]
heapq.heapify(l)
while M>0:
  a=-heapq.heappop(l)
  a=a//2
  heapq.heappush(l,-a)
  M-=1
print(-sum(l))

Solution (Python):
import heapq

if __name__ == "__main__":
    n, m = list(map(int, input().split(" ")))
    a = list(map(lambda x: (-1) * int(x), input().split(" ")))

    heapq.heapify(a)

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

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

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

import heapq
a = [-i for i in a]

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

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

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

  if N == 1: A[0] = A[0] // 2 ** M
  else:
    for i in range(N): A[i] *= -1

    heapify(A)

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

  print(-sum(A))  
  
if __name__ == '__main__':
  main()

Solution (Python):
import heapq as hq

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

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

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

Solution (Python):
import heapq
import math

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

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

print(-sum(a))

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

Solution (Python):
from sys import stdin
import heapq

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = list(map(int,stdin.readline().rstrip().split()))

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

heapq.heapify(li)

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

li.sort()
print(sum(li)*(-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 i in range(M):

    num = heapq.heappop(A)
    num *= -1
    num //= 2
    num *= -1
    heapq.heappush(A, num)


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

Solution (Python):
import heapq
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')

N, M = LI()
A = LI()
ans = int(0)

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

for _ in range(M):
    cur = heapq.heappop(A)

    heapq.heappush(A, ((cur+1)//2))


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
    ham = A[0] // 2
    for i, a in enumerate(A):
        if ham < a and M > 0:
            A[i] = A[i] // 2
            M -= 1
        else:
            break
print(sum(A))

Solution (Python):
import sys
from io import StringIO
import unittest
import heapq


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

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


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 3
2 13 8"""
        output = """9"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4 4
1 9 3 5"""
        output = """6"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1 100000
1000000000"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """10 1
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000"""
        output = """9500000000"""
        self.assertIO(input, output)


if __name__ == "__main__":
    
    resolve()

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

Solution (Python):
from enum import Enum
from queue import Queue

import numpy as np

import collections
import bisect
import sys
import math
import heapq

from scipy.sparse.csgraph import floyd_warshall

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())
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())
prices = list(map(int,input().split()))
for i in range(len(prices)):
  prices[i] *= -1

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

print(sum(prices)*-1)

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

Solution (Python):
import heapq
import math

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

now=[]

for i in range(N):   
    heapq.heappush(now,-A[i])

for j in range(M):  
    MIN=heapq.heappop(now)
    MIN/=2
    heapq.heappush(now,MIN)

for k in range(N):  
    now[k]=math.floor(-now[k])

print(sum(now))

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

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

N=int(N)
M=int(M)

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

a=[]
for n in range(N):
    a.append(int(A[n]) * (-1))

import heapq
import math

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

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

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

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

for i in range(M):

    max = heapq.heappop(A_q) * (-1) // 2
    heapq.heappush(A_q, -max)



result = 0
A_q = list(map(lambda x:x*(-1),A_q))

for i in range(N):
    result += A_q[i]

print(result)

Solution (Python):

import heapq


def solve(*args: str) -> str:
    n, m = map(int, args[0].split())
    A = list(map(lambda _: -int(_), args[1].split()))
    heapq.heapify(A)

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

    return str(-sum(A))


if __name__ == "__main__":
    print(solve(*[input() for _ in range(2)]))

Solution (Python):

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

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

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

for _ in range(m):
    highest = -heappop(q)
    heappush(q, -(highest // 2))

cost = -sum(q)

print(cost)

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

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

print(-sum(A))

Solution (Python):
import heapq

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

Solution (Python):
import heapq
import math

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

for i in a:
    heapq.heappush(h, -i)


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


print(-1*sum(h))

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

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

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

heapify(A)

for i in range(M): 
    x = heappop(A)
    heappush(A, x/2)
    
    
print(sum([-int(a) for a in A]))

Solution (Python):

from heapq import heappush, heappop

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

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

print(-sum(A))

Solution (Python):
import sys
from heapq import heappush, heappop
input = sys.stdin.readline
N,M = map(int, input().split())
A = []
for a in input().split():
  heappush(A,-int(a))

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

print(-sum(A))

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

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

print(-sum(a_list))

Solution (Python):
import heapq

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

heapq.heapify(A_lis)

def discount(A_lis):
    popped = heapq.heappop(A_lis)
    heapq.heappush(A_lis,popped/2)
    return A_lis

for i in range(M):
    A_lis = discount(A_lis)
ans = 0
for i in A_lis:
    ans += int(i)
print(ans*(-1))

Solution (Python):
n,m=list(map(int, input().split()))
a=list(map(int, input().split()))
a.sort(reverse=True)
while m>0:
  a[0] //= 2
  m = m - 1
  for i in range(n-1):
    if a[0] < a[i+1] and m > 0:
      a[i+1] //= 2
      m = m - 1
    else:
      a.sort(reverse=True)
      break
print(sum(a))

Solution (Python):
import heapq

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

a = [-int(a) for a in input().split()]
heapq.heapify(a)

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

print(sum(a) * -1)

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

Solution (Python):
def funcD():
    import heapq
    N, M = map(int, input().split())
    A = list(map(lambda x: -1 * int(x), input().split()))
    A.sort(reverse=True)
    heapq.heapify(A)
    for m in range(M):
        a = -(-heapq.heappop(A) // 2)
        heapq.heappush(A, a)
    print(-sum(A))


funcD()

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

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

total_m = 0

def discount(price_list, ticket_num):
    total_ticket =0
    hp.heapify(price_list)

    while total_ticket < ticket_num:
        temp = hp.heappop(price_list)
        hp.heappush(price_list, -1* (-1*temp//2))
        total_ticket += 1

    return price_list

res = discount(price_list, M)
print(-1 * sum(res))

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

Solution (Python):
from heapq import heappush, heappop

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

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

print(-sum(hq))

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

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

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

print(-sum(A))

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

Solution (Python):
import heapq
if __name__ == '__main__':
    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, -(-tmp // 2))
    print(-sum(A))

Solution (Python):
import heapq

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

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

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

res = 0
for i in range(n):
    res += int(-que[i])

print(res)

Solution (Python):
from heapq import heappush, heappop
def main():
	(N, M) = map(int, input().split())
	hq =  list(map(lambda x:-x, map(int, input().split())))
	hq.sort()
	for i in range(M):
		b = - heappop(hq) // 2
		heappush(hq, -b)
	print(-sum(hq))
main()

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):
    heapq.heappush(a, int(heapq.heappop(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_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()))
cost = []
heapq.heapify(cost)
for i in range(n):
    heapq.heappush(cost, -A[i])
for i in range(m):
    target = heapq.heappop(cost) / 2
    heapq.heappush(cost, target)
ans = [int(i) for i in cost]
print(-sum(ans))

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

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

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

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

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

import heapq
import math


heapq.heapify(a)



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

res=0
for i in range(N):
        a[i] = -a[i]
        res += math.floor(a[i])

print(res)

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):
    heapq.heappush(a, int(heapq.heappop(a)/2))

print(-sum(a))

Solution (Python):
import heapq

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

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

print(sum(A)*-1)

Solution (Python):
import heapq

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


def solve():
    AA = [[-x, x] for x in A]

    heapq.heapify(AA)

    for i in range(M):
        x, y = heapq.heappop(AA)
        heapq.heappush(AA, [-(y//2), y//2])

    AAA = [x[1] for x in AA]
    return sum(AAA)


print(solve())

Solution (Python):
import heapq

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


def solve():
    AA = [[-x, x] for x in A]

    heapq.heapify(AA)

    for i in range(M):
        x, y = heapq.heappop(AA)
        heapq.heappush(AA, [-(y//2), y//2])

    AAA = [x[1] for x in AA]
    return sum(AAA)


print(solve())

Solution (Python):
from collections import deque
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
q1=deque(A)
q2=deque([])
for i in range(M):
  if len(q1)!=0 and (len(q2)==0 or q1[0]>=q2[0]):
    x=q1.popleft()
  else:
    x=q2.popleft()
  q2.append(x//2)
print(int(sum(q1)+sum(q2)))

Solution (Python):
def resolve():
    import heapq
    _,M = map(int,input().split())
    A = list(map(lambda x:(-1)*int(x),input().split()))
    heapq.heapify(A)
    for _ in range(M):
        heapq.heapreplace(A,(A[0]*(-1) // 2)*(-1))
    print((-1) * sum(A))    
resolve()

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

Solution (Python):
import heapq

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

heapq.heapify(a_L)




for val in range(0,m):
    a_min = heapq.heappop(a_L)
    a_min = (-1 * a_min)//2 * -1
    heapq.heappush(a_L,a_min)

print(-sum(a_L))

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

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

Solution (Python):

import heapq

N, M = list(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)

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

ans = -sum(a_list)
print(ans)

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

Solution (Python):
import heapq
class PriorityQueue:
	def __init__(self,num_list=None,reverse=False):
		self.reverse = reverse
		self.heap = []
		if num_list != None :
			for num in num_list:
				self.push(num)

	def push(self,num):
		heapq.heappush(self.heap,-num if self.reverse else num)

	def pop(self):
		num = heapq.heappop(self.heap)
		return -num if self.reverse else num
	
	def get_heap(self):
		return list(map(lambda x: x*(-1),self.heap))

n,m = map(int,input().split())
items = list(map(int,input().split()))
pq = PriorityQueue(num_list=items,reverse=True)

while m>0:
	item = pq.pop()
	pq.push(int(item/2))
	m -= 1
print(sum(pq.get_heap()))

Solution (Python):
import heapq
class PriorityQueue:
	def __init__(self,num_list=None,reverse=False):
		self.reverse = reverse
		self.heap = []
		if num_list != None :
			for num in num_list:
				self.push(num)

	def push(self,num):
		heapq.heappush(self.heap,-num if self.reverse else num)

	def pop(self):
		num = heapq.heappop(self.heap)
		return -num if self.reverse else num
	
	def get_heap(self):
		return map(lambda x: x*(-1),self.heap)

n,m = map(int,input().split())
items = list(map(int,input().split()))
pq = PriorityQueue(num_list=items,reverse=True)

while m>0:
	item = pq.pop()
	pq.push(int(item/2))
	m -= 1
print(sum(pq.get_heap()))

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


que = []

for v in a:
    heappush(que, -v)

for i in range(m):
    heappush(que, heappop(que) / 2)

print(-sum(int(v) for v in que))

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)

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

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

print(-1*sum(A))

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

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

Solution (Python):
import heapq as hq

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

hq.heapify(h)

for _ in range(m):
    M = hq.heappop(h)
    hq.heappush(h, (M + 1) // 2)

print(-sum(h))

Solution (Python):
import heapq

def func(x):
    return -x

def main():
    N, M = map(int, input().split())
    A = list(map(func, map(int, input().split())))
    heapq.heapify(A)

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

    print(-sum(A))



if __name__ == "__main__":
    main()

Solution (Python):
import heapq
N,M = map(int,input().split())
l_a = list(map(int,input().split()))
l_a = [(-x,x) for x in l_a]
heapq.heapify(l_a)
for m in range(M):
    if l_a[0][1]%2==1:
        heapq.heappush(l_a,(l_a[0][0]//2+1,l_a[0][1]//2))
    else:
        heapq.heappush(l_a,(l_a[0][0]//2,l_a[0][1]//2))
    heapq.heappop(l_a)
a = 0
for i in range(N):
    a += l_a[i][1]
print(a)

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

for _ in range(m):
	a_min = heapq.heappop(a)
	heapq.heappush(a,(-(-a_min//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):
    tmin = heapq.heappop(A)
    heapq.heappush(A, (-1)*(-tmin//2))

print(-sum(A))

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

heapq.heapify(a)

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

print(-sum(a))

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

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

heapq.heapify(l)
for i in range(m):
  new = heapq.heappop(l)
  heapq.heappush(l,-((-new)//2))

print(-sum(l))

Solution (Python):
import heapq
import math

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

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

heapq.heapify(a)

for i in range(m):
    
    maximum = heapq.heappop(a)
    
    add = math.trunc(maximum/2)
    
    heapq.heappush(a,add)


print(-1 * sum(a))