CodeEff/ECCO huggingface dataset:
# Original solution
n, m = list(map(int,input().split()))
List = list(map(int,input().split()))
List.sort(reverse=True)
halves = [0]
max_halves = 0

for i in range(m):
  x = List.pop(0)
  if x >= max_halves:
    x = int(x/2)
    if len(List) == 0:
      List = [x]
    else:
      halves.append(x)
      if x >= max_halves:
        max_halves = x
  else:
    halves.remove(max_halves)
    halves.append(int(max_halves/2))
    max_halves = max(halves)
    List = [x]+ List
print((sum(List)+sum(halves)))


# Optimized solution
import heapq
n, m = list(map(int,input().split()))
List = list(map(int,input().split()))

List = list([x*(-1) for x in List])  # 各要素を-1倍

heapq.heapify(List)
for i in range(m):
  max = heapq.heappop(List)
  heapq.heappush(List, int(max/2))  # 要素の挿入
print((sum(List)*(-1)))
# Original solution
import heapq

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


# Optimized solution
import heapq

N, M = [int(n) for n in input().split()]
hq = []
[heapq.heappush(hq, v) for v in [-1*int(n) for n in input().split()]]
[heapq.heappush(hq, -1*(-1*heapq.heappop(hq)//2)) for _ in range(M)]
print((-1*sum(hq)))
# Original solution
import heapq

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

# Optimized solution
import heapq

N, M = [int(n) for n in input().split()]
A = [-int(n) for n in input().split()]
heapq.heapify(A)
[heapq.heappush(A, -(-heapq.heappop(A)//2)) for _ in range(M)]   
print((-sum(A)))
# Original solution
def main():
    N, M = list(map(int, input().split()))
    A = list(map(int, input().split()))

    sort_A = sorted(A, reverse=True)


    for _ in range(M):
        sort_A[sort_A.index(max(sort_A))] = max(sort_A) // 2

    print((sum(sort_A)))

main()

# Optimized solution
import heapq
def func(n):
    return -n

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

    heapq.heapify(A)

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

    print((-sum(A)))

main()
# Original solution
# -*- coding: utf-8 -*-

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
for i in range(M):
    ans = int(A[0] / 2)
    A[0] = ans
    A = sorted(A, reverse=True)
sum = 0
for a in A:
    sum += a
print(sum)


# Optimized solution
# -*- coding: utf-8 -*-
import heapq
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
sum = 0
l = []
for i in A:
    heapq.heappush(l, i*-1)
for i in range(M):
    c = int(heapq.heappop(l)*-1/2)
    heapq.heappush(l, c*-1)
for a in l:
    sum += a*-1
print(sum)
# Original solution
import bisect

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

for i in range(M):
    a = A.pop(-1)//2
    bisect.insort_left(A,a)

print((sum(A)))

# Optimized solution
import heapq

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

heapq.heapify(A)

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

print((sum(A)*(-1)))
# Original solution
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
A.sort(reverse=True)
for i in range(K):
  A[0] = int(A[0]/2)
  A.sort(reverse=True)

print((sum(A)))

# Optimized solution
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
import heapq
a = list([x*(-1) for x in A])  # 各要素を-1倍

heapq.heapify(a)
for i in range(K):
  num = heapq.heappop(a)*(-1)
  heapq.heappush(a, -1*(int(num/2)))
  #print(num,a)
  if num == 0:
    break
print((-sum(a)))
# Original solution
N, M = list(map(int, input().split()))
A = sorted(list(map(int, input().split())))
for i in range(M):
    A[-1] //= 2
    A = sorted(A)
print((sum(A)))


# Optimized solution
import heapq

N, M = list(map(int, input().split()))
A = [-i for i in list(map(int, input().split()))]
heapq.heapify(A)
for m in range(M):
    A_max = -heapq.heappop(A)  # Aの最大値を削除して取り出す
    heapq.heappush(A, -(A_max // 2))
print((-sum(A)))
# Original solution
N, M = list(map(int, input().split()))
A = [int(a) for a in input().split()]

for m in range(M):
    index = A.index(max(A))
    A[index] //= 2

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

print(ans)


# Optimized solution
import heapq

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

# 優先度付きキューに変換
heapq.heapify(A)

# 最小値（最大値）の値を半分にしていく
for i in range(M):
    tmp = -heapq.heappop(A) // 2
    heapq.heappush(A, -tmp)

print((-sum(A)))
# Original solution

#D
import bisect


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

a.sort()

for i in range(m):
    a[-1] //= 2
    tmp = a.pop(-1)
    k = bisect.bisect_left(a,tmp)
    a.insert(k,tmp)
        
    
print((sum(a)))

# Optimized solution
#優先度付きキュー -> 最小値をO(logN)で取り出す
import heapq

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

a = [-x for x in a]

#aを優先度付きキューに変更
heapq.heapify(a)

for _ in range(m):
   
    tmp = heapq.heappop(a)
    tmp = (-tmp // 2) * -1
    heapq.heappush(a,tmp)
        
    
print((sum(a) * -1))
# Original solution
N, M = list(map(int, input().split()))
prices = list(map(int, input().split(' ')))
for i in range(M):
    prices[prices.index(max(prices))] //= 2

print((sum(prices)))

# Optimized solution
import heapq
N, M = list(map(int, input().split(' ')))
prices = list([x * (-1) for x in list(map(int, input().split(' ')))])

# 優先度付きキューに変換
heapq.heapify(prices)

for i in range(M):
    # 最大のものを半額にしてまたキューに突っ込む
    heapq.heappush(prices, ((heapq.heappop(prices) * (-1)) // 2) * -1)

print((sum(prices) * -1))
# Original solution
import heapq
import math

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


# Optimized solution
import heapq

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

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

heapq.heapify(a)

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

print((-1 * sum(a)))
# Original solution
import heapq
 
N,M = list(map(int,input().split()))
Price_List = list([x*(-1) for x in list(map(int,input().split()))])
heapq.heapify(Price_List)
for i in range(M):
    heapq.heapify(Price_List)
    val = heapq.heappop(Price_List)* -1 // 2 * -1
    heapq.heappush(Price_List,val)
print((-sum(Price_List)))

# Optimized solution
import heapq
 
N,M = list(map(int,input().split()))
Price_List = list([x*(-1) for x in list(map(int,input().split()))])
heapq.heapify(Price_List)
for i in range(M):
    val = heapq.heappop(Price_List)* -1 // 2 * -1
    heapq.heappush(Price_List,val)
print((-sum(Price_List)))
# Original solution
n, m = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))

for _ in range(m):
    a[-1] //= 2
    a = sorted(a)

print((sum(a)))

# Optimized solution
import heapq

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

heapq.heapify(a)

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

print((-sum(a)))
# Original solution
# -*- coding: utf-8 -*-
from heapq import heappop, heappush, heapify
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

N, M = inpl()
A = inpl()
Q = [[-A[i], A[i], 0] for i in range(N)]
F = 2
heapify(Q)

for _ in range(M):
    b, a, x = heappop(Q)
    if b:
        b = a//(2**(x+1))
    heappush(Q, [-b, a, x+1])

ans = 0
for i in range(N):
    ans -= Q[i][0]

print(ans)

# Optimized solution
from heapq import heappop, heappush
def inpl(): return list(map(int, input().split()))
N, M = inpl()
A = inpl()
Q = []
for a in A:
    heappush(Q, [-a, a, 0])

for i in range(M):
    x, a, d = heappop(Q)
    if x == 0:
        break
    heappush(Q, [-(a//pow(2, d+1)), a, d+1])

print((sum([-q[0] for q in Q])))
# Original solution
N,M=list(map(int,input().split()))
A=sorted(list(map(int,input().split())),reverse=True)
idx=1
for i in range(M):
    value=0

    for m in range(idx):
        if A[m]>value:
            value=A[m]
            nidx=m
    if nidx+1==idx:
        idx+=1
        idx=min(idx,N)
    A[nidx]/=2

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


# Optimized solution
import heapq
N,M=list(map(int,input().split()))
A=list([x*-(1) for x in list(map(int,input().split()))])
heapq.heapify(A)
for i in range(M):
    num=(heapq.heappop(A)*(-1)/2)
    heapq.heappush(A, num*-1)



A=list(map(int,A))
print((-sum(A)))
# Original solution
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(m):
    a[a.index(max(a))] = max(a)//2
print((sum(a)))

# Optimized solution
import heapq
n, m = list(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)))
# Original solution
from bisect import bisect_right

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

cnt=0
while cnt<m:
    y=lists[-1]//2
    del lists[-1]
    
    indexes=bisect_right(lists,y)
    #indexesというところに新しいyの値を代入しておきたい
    lists.insert(indexes,y)

    cnt+=1
print((sum(lists)))

# Optimized solution
from bisect import bisect_right
import heapq
n,m=list(map(int,input().split()))
lists=list(map(int,input().split()))
uselists=[]
for _ in lists:
    uselists.append(-_)

heapq.heapify(uselists)

cnt=0
while cnt<m:
    y=heapq.heappop(uselists)

    z=(-y)//2
    heapq.heappush(uselists,-z)
    

    cnt+=1
anslist=[]
for j in uselists:
    anslist.append(-j)
print((sum(anslist)))
# Original solution
#powerful discount tickets
import bisect
n,m=list(map(int,input().split()))
lists=list(map(int,input().split()))
lists=sorted(lists)
for _ in range(m):
    #m回この作業を繰り返す
    maxi=lists[-1]
    lists.remove(maxi)
    bisect.insort(lists,maxi/2)
ans=0
import math
for some in lists:
    ans+=math.floor(some)
print(ans)

# Optimized solution
#powerful discount tickets
n,m=list(map(int,input().split()))
lists=list(map(int,input().split()))
uselist=[0 for i in range(n)]
for j in range(n):
    uselist[j]=lists[j]*(-1)
import heapq
heapq.heapify(uselist)
for _ in range(m):
    #m回この作業を繰り返す
    mini=heapq.heappop(uselist)
    heapq.heappush(uselist,mini/2) 
#バイナリツリーと同じ方法で保管していると考えられる
ans=0
import math
for some in uselist:
    ans+=math.floor(-some)
print(ans)
# Original solution
import sys
import bisect
inputs = sys.stdin.readlines()

N, M = list(map(int, inputs[0].split()))
A = sorted(list(map(int, inputs[1].split())))

for _ in range(M):
    tmp = A.pop() // 2
    A.insert(bisect.bisect_left(A, tmp), tmp)
print((sum(A)))

# Optimized solution
import sys
inputs = sys.stdin.readlines()

from heapq import heappush, heappop
N, M = list(map(int, inputs[0].split()))
A = list(map(int, inputs[1].split()))

queue = []
for a in A:
    heappush(queue, -a)

for _ in range(M):
    heappush(queue, -(-heappop(queue) // 2))
print((-sum(queue)))
# Original solution
from bisect import insort
def main():
	(_, M) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	A.sort()
	for i in range(M):
		b = A[-1] // 2
		insort(A, b)
		A = A[:-1]
	print((sum(A)))
main()

# Optimized solution
from heapq import heappush, heappop
def main():
	(N, M) = list(map(int, input().split()))
	hq =  list([-x for x in list(map(int, input().split()))])
	hq.sort()
	for i in range(M):
		b = - heappop(hq) // 2
		heappush(hq, -b)
	print((-sum(hq)))
main()
# Original solution
n,m = list(map(int,input().split()))
A = [int(i) for i in input().split()]
 
A.sort(reverse=True)
 
def bisect(A,x):
  lo = -1
  hi = len(A)
  while lo+1 < hi:
    idx = (lo+hi)//2
    if A[idx] > x:
      lo = idx
    else:
      hi = idx
  return lo
 
for i in range(m):
  v = A.pop(0)//2
  idx = bisect(A,v)+1
  A = A[:idx] + [v] + A[idx:]

print((sum(A)))

# Optimized solution
from heapq import heappop, heappush, heapify
n, m = list(map(int, input().split()))
a = [-int(i) for i in input().split()]

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

print((-sum(a)))
# Original solution
n, m = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
for i in range(m):
    a[a.index(max(a))] = max(a)//2
print((sum(a)))

# Optimized solution
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_min = ((a[0] * (-1)) //2) * (-1)
    heapq.heappushpop(a,tmp_min)
print((abs(sum(a))))
# Original solution
import math

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

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

for i in range(m):
    idx = a.index(max(a))
    a[idx] = a[idx] // 2
print((sum(a)))

# Optimized solution
import math
from heapq import heappush, heappop

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

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

h = []

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

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

print((-sum(h)))
# Original solution
def resolve():
    from collections import deque
    n, m = list(map(int, input().split()))
    a = deque(list(map(int, input().split())))
 
    for i in range(m):
        a = deque(sorted(a))
        maxa = a.pop()
        maxa //= 2
        a.appendleft(maxa)
    print((sum(a)))
resolve()

# Optimized solution
def resolve():
    import heapq
    n, m = list(map(int, input().split()))
    a = list([int(x)*-1 for x in input().split()])
    heapq.heapify(a)
    for i in range(m):
        maxa = heapq.heappop(a) * -1
        maxa //= 2
        heapq.heappush(a, -maxa)
    print((sum(a)*-1))
resolve()
# Original solution
n,m=list(map(int,input().split()))
a = sorted([int(i) for i in input().split()])[::-1]
ans = 0

while m > 0:
    a[0] = a[0]//2
    m-=1
    for i in range(n-1):
        if a[i] < a[i+1]: a[i],a[i+1] = a[i+1],a[i]
        else: break
print((sum(a)))

# Optimized solution
import heapq

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

while m > 0:
    t = heapq.heappop(a)*(-1)//2
    heapq.heappush(a,-t)
    m-=1
print((-sum(a)))
# Original solution
N, M = list(map(int, input().split()))
A = [int(i) for i in input().split()]

A = sorted(A, reverse=True)

for _ in range(M):
    A[0] = A[0] / 2
    A = sorted(A, reverse=True)

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

print(ans)


# Optimized solution
import heapq

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

heapq.heapify(A)

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

ans = 0
for a in A:
    ans -= int(a)

print(ans)
# Original solution
n,m = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(m):
	target = max(a)	
	a[a.index(target)] = target // 2
print((sum(a)))	

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

for i in range(m):
	target = heapq.heappop(a)
	heapq.heappush(a, (-1)*(-target//2))
	
print((-sum(a)))
# Original solution
import bisect
n,m=list(map(int,input().split()))
A=list(map(int,input().split()))
for _ in range(m):
  A[A.index(max(A))]//=2
print((sum(A)))

# Optimized solution
import heapq
n,m=list(map(int,input().split()))
A=list(map(int,input().split()))
hq=[]
for i in A:
  heapq.heappush(hq,-i)
for _ in range(m):
  m=-((-heapq.heappop(hq))//2)
  heapq.heappush(hq,m)
print((-sum(hq)))
# Original solution
def bin_tree( pri , li_pri , len_li ):
    #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])
# N: 品物の数
# M: 割引券の数
# A: 品物の値段行列
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
    # ans: pri以上となる値段のうち最小のインデックス
    A[ans:ans] = [pri]    

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

# Optimized solution
import heapq

I = input().split()
N = int(I[0])
M = int(I[1])
# N: 品物の数
# M: 割引券の数
# A: 品物の値段行列
A = list(map(int , input().split()))

A = list([x*(-1) for x in 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 ))
# Original solution
import math
import queue

mod = 1e9+7

def swap(a,b):
    return (b,a)

def gcd(a,b):
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def divisors(a):
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def main():
    n,m = list(map(int,input().split()))
    a = [x for x in map(int,input().split())]
    for i in range(m):
        id = a.index(max(a))
        a[id] //= 2
    print((sum(a)))
    return

if __name__ == '__main__':
    main()

# Optimized solution
import math
import queue
import bisect
import heapq

mod = 1e9+7

def swap(a,b):
    return (b,a)

def gcd(a,b):
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def divisors(a):
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def main():
    n,m = list(map(int,input().split()))
    a = [-x for x in map(int,input().split())]
    heapq.heapify(a)
    for i in range(m):
        x = heapq.heappop(a)
        if x%2==0:
            heapq.heappush(a,x//2)
        else:
            heapq.heappush(a,x//2+1)
    ans = 0
    for i in range(n):
        ans += heapq.heappop(a)*(-1)
    print(ans)
    return

if __name__ == '__main__':
    main()
# Original solution
from heapq import heapify,heappush,heappop

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

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


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

    ans = abs(ans)
    return ans

print((main()))


# Optimized solution
from heapq import heapify,heappush,heappop

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

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


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

    ans = abs(ans)
    return ans

print((main()))
# Original solution
#!/usr/bin/env python3
import sys


def sort(A):
    for i in range(1, len(A)):
        insert(A, i)


def insert(A, i):
    temp = A[i]
    for j in range(i - 1, -1, -1):
        if temp < A[j]:
            A[j + 1] = A[j]
        else:
            A[j + 1] = temp
            break
    else:
        A[0] = temp


def solve(N: int, M: int, A: "List[int]"):
    sort(A)
    for i in range(M):
        MD = A[-1]
        A[-1] = MD // 2
        sort(A)
        if A[-1] == 0:
            break
    print((sum(A)))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)


if __name__ == '__main__':
    main()


# Optimized solution
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, A: "List[int]"):
    while M > 0:
        A = sorted(A, reverse=True)
        MD = A[0] // 2
        for i, ai in enumerate(A):
            if ai > MD and M > 0:
                A[i] = ai//2
                M -= 1
            else:
                break
        if A[i] == 0:
            break
    print((sum(A)))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)


if __name__ == '__main__':
    main()
# Original solution
# -*- coding: utf-8 -*-
# from collections import deque
import bisect

N, M = list(map(int, input().split()))
A_list = list(map(int, input().split()))
A_list.sort()
# A_list = deque(A_list)

ans = 0
ans += sum(A_list[0:N - M])
del(A_list[0:N - M])
for i in range(M):
    max_price = A_list.pop()
    bisect.insort(A_list, max_price // 2)
    

ans += sum(A_list)
print(ans)

# Optimized solution
# D 終了後再チャレンジ
# -*- coding: utf-8 -*-
import heapq

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

for i in range(M):
    max_price = heapq.heappop(A_list) * (-1)
    heapq.heappush(A_list, max_price // 2 * (-1))
    
ans = sum(A_list) * (-1)
print(ans)
# Original solution
n,m=list(map(int, input().split()))
a=[int(x) for x in input().split()]

while m>0:
    max_value = max(a)
    max_index = a.index(max_value)
    a[max_index]=max_value/2
    m-=1
a=[int(x) for x in a]
print((sum(a)))

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

import heapq

heapq.heapify(a)

for i in range(m):
    max_value = heapq.heappop(a) #最大値の取得
    heapq.heappush(a, (max_value/2)) #半額にして-1倍してからキューに戻す

a=[-1*x for x in a]
a=[int(x) for x in a]
print((sum(a)))
# Original solution
from bisect import insort_left

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

a_list = [int(x) for x in input().split()]
a_list.sort()

for _ in range(m):
    a_list[-1] //= 2
    insort_left(a_list, a_list.pop())
print((sum(a_list)))

# Optimized solution
import heapq
from math import ceil

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

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

for _ in range(m):
    temp = ceil(heapq.heappop(a_list) / 2)
    heapq.heappush(a_list, temp)
print((-sum(a_list)))
# Original solution
n,m=list(map(int,input().split()))
a = list(map(int,input().split()))
for i in range(1,m+1):
  l = a.index(max(a))
  a[l] = a[l] // 2
print((sum(a)))



# Optimized solution
import heapq
import math
n,m=list(map(int,input().split()))
a = list(map(int,input().split()))
h = []
for _a in a:
  heapq.heappush(h,-_a)
for i in range(m):
  heapq.heappush(h,math.ceil(heapq.heappop(h) / 2))
print((sum(h)*(-1)))
# Original solution
n, m = list(map(int, input().split()))
lisA = [int(i) for i in input().split()]
#print(n, m)
#print(lisA)

lisA.sort(reverse=True)
half0 = lisA[0] / 2
count = 0
for i in range(m):
	if (count > n - 1):
		count = 0
	if (lisA[count] < half0):
		lisA.sort(reverse=True)
		half0 = lisA[0]
		count = 0
	lisA[count] //= 2
	count += 1
print((sum(lisA)))

# Optimized solution
n, m = list(map(int, input().split()))
lisA = [int(i) for i in input().split()]
#print(n, m)
#print(lisA)

lisA.sort(reverse=True)
half0 = lisA[0] // 2
count = 0
for i in range(m):
	if (count > n - 1):
		count = 0
	if (lisA[count] < half0):
		lisA.sort(reverse=True)
		half0 = lisA[0] // 2
		count = 0
	lisA[count] //= 2
	count += 1
print((sum(lisA)))