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 sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


from heapq import heapify, heappop, heappush, heappushpop


class PriorityQueue:
    def __init__(self, heap):
        '''
        heap ... list
        '''
        self.heap = heap
        heapify(self.heap)

    def push(self, item):
        heappush(self.heap, item)

    def pop(self):
        return heappop(self.heap)

    def pushpop(self, item):
        return heappushpop(self.heap, item)

    def __call__(self):
        return self.heap

    def __len__(self):
        return len(self.heap)


N, M = read_ints()
A = read_ints()
que = PriorityQueue([-a for a in A])
for _ in range(M):
    x = -que.pop()
    x //= 2
    que.push(-x)

print(-sum(que.heap))

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)
    cnt = 0
    while cnt < M:
        cnt += 1
        tmp = -heapq.heappop(A)
        heapq.heappush(A,-(tmp//2))
    
    print(-sum(A))

if __name__ == "__main__":
    main()

Solution (Python):
import heapq

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

arr = [-int(s) for s in S.split(" ")]

heapq.heapify(arr)

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

print(-sum(arr))

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

heapq.heapify(a)
for _ in range(m):
    tmp=heapq.heappop(a)
    cal=math.ceil(tmp/2)
    heapq.heappush(a,cal)
    
print(sum(a)*-1)

Solution (Python):
import heapq

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

heap = []
heapq.heapify(heap)
for a in A:
    heapq.heappush(heap, -1*a)

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

ans = 0
for y in heap:
    y = -1 * y
    ans += y // 1

print(int(ans))

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

Solution (Python):
import heapq


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

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


if __name__ == '__main__':
    main()

Solution (Python):
import heapq


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

    for _ in range(M):
        x = heapq.heappop(heap)
        x = -x
        x = x // 2
        x = -x
        heapq.heappush(heap, x)
    print(sum(map(lambda x: -x, heap)))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 
input=lambda:sys.stdin.readline().rstrip()

class Heap(object):
    def __init__(self, A):
        self._heap = A[:]
        
        for i in range((len(A))//2-1,-1,-1): self._descend(i)

    def __len__(self):
        return len(self._heap)

    def __bool__(self):
        return bool(self._heap)

    def _descend(self, i):
        heap = self._heap
        now = i
        
        while(1):
            if now*2+1 >= len(self): break 
            
            if now*2+1 == len(self)-1:
                if heap[now] > heap[now*2+1]:
                    heap[now], heap[now*2+1] = heap[now*2+1], heap[now]
                break
            
            else:
                
                if min(heap[now], heap[2*now+1], heap[2*now+2]) == heap[now]: break
                
                next = min((heap[2*now+1],2*now+1), (heap[2*now+2],2*now+2))[1]
                heap[now], heap[next] = heap[next], heap[now]
                now = next

    def front(self):
        assert self
        return self._heap[0]

    def append(self, x):
        self._heap.append(x)
        now = len(self)-1
        heap = self._heap
        
        while now!=0 and heap[now] < heap[(now-1)//2]:
            heap[now], heap[(now-1)//2] = heap[(now-1)//2], heap[now]
            now = (now-1)//2

    def pop(self):
        assert self
        if len(self)==1: return self._heap.pop()
        res, self._heap[0] = self._heap[0], self._heap.pop()
        self._descend(0)
        return res

def resolve():
    n, m = map(int,input().split())
    A = list(map(lambda x:-int(x),input().split()))
    heap = Heap(A)
    for _ in range(m):
        x = -heap.pop()
        x //= 2
        heap.append(-x)

    print(-sum(heap._heap))
resolve()

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 
input=lambda:sys.stdin.readline().rstrip()

class Heap(object):
    def __init__(self, A):
        self._heap = A[:]
        for i in range((len(A))//2-1,-1,-1): 
            self._descend(i)

    def __len__(self):
        return len(self._heap)

    def __bool__(self):
        return bool(self._heap)

    def _descend(self, i):
        heap = self._heap
        
        while(1):
            if i*2+1 >= len(self): break 
            
            if i*2+1 == len(self)-1:
                if heap[i] > heap[i*2+1]:
                    heap[i], heap[i*2+1] = heap[i*2+1], heap[i]
                break
            
            else:
                
                if min(heap[i], heap[2*i+1], heap[2*i+2]) == heap[i]: break
                
                next = min((heap[2*i+1],2*i+1), (heap[2*i+2],2*i+2))[1]
                heap[i], heap[next] = heap[next], heap[i]
                i = next

    def front(self):
        assert self
        return self._heap[0]

    def append(self, x):
        self._heap.append(x)
        now = len(self)-1
        heap = self._heap
        
        while now!=0 and heap[now] < heap[(now-1)//2]:
            heap[now], heap[(now-1)//2] = heap[(now-1)//2], heap[now]
            now = (now-1)//2

    def pop(self):
        assert self
        if len(self)==1: return self._heap.pop()
        res, self._heap[0] = self._heap[0], self._heap.pop()
        self._descend(0)
        return res

def resolve():
    n, m = map(int,input().split())
    A = list(map(lambda x:-int(x),input().split()))
    heap = Heap(A)
    for _ in range(m):
        x = -heap.pop()
        x //= 2
        heap.append(-x)

    print(-sum(heap._heap))
resolve()

Solution (Python):
import heapq

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

heapq.heapify(a_list)
for _ in range(m):
  min_n = heapq.heappop(a_list)
  heapq.heappush(a_list, (min_n//2 if min_n%2 == 0 else min_n//2+1))
print(sum(a_list) * (-1))

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 
input=lambda:sys.stdin.readline().rstrip()

class Heap(object):
    def __init__(self, A):
        self._heap = []
        
        
        for a in A:
            self.append(a)

    def __len__(self):
        return len(self._heap)

    def __bool__(self):
        return bool(self._heap)

    def front(self):
        assert self
        return self._heap[0]

    def append(self, x):
        self._heap.append(x)
        now = len(self)-1
        heap = self._heap
        
        while now!=0 and heap[now] < heap[(now-1)//2]:
            heap[now], heap[(now-1)//2] = heap[(now-1)//2], heap[now]
            now = (now-1)//2

    def pop(self):
        assert self
        if len(self)==1:
            return self._heap.pop()

        heap = self._heap
        res, heap[0] = heap[0], heap.pop()
        
        now = 0
        while(1):
            if now*2+1 >= len(self): break 
            
            if now*2+1 == len(self)-1:
                if heap[now] > heap[now*2+1]:
                    heap[now], heap[now*2+1] = heap[now*2+1], heap[now]
                break
            
            else:
                
                if min(heap[now], heap[2*now+1], heap[2*now+2]) == heap[now]: break
                
                next = min((heap[2*now+1],2*now+1), (heap[2*now+2],2*now+2))[1]
                heap[now], heap[next] = heap[next], heap[now]
                now = next

        return res

    def sort(self):
        return [self.pop() for _ in range(len(self))]

def resolve():
    n, m = map(int,input().split())
    A = list(map(lambda x:-int(x),input().split()))
    heap = Heap(A)
    for _ in range(m):
        x = -heap.pop()
        x //= 2
        heap.append(-x)

    print(-sum(heap._heap))
resolve()

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

class PriorityQueue:
    def __init__(self, heap):
        '''
        heap ... list
        '''
        self.heap = heap
        heapify(self.heap)

    def push(self, item):
        heappush(self.heap, item)

    def pop(self):
        return heappop(self.heap)

    def pushpop(self, item):
        return heappushpop(self.heap, item)

    def __call__(self):
        return self.heap

    def __len__(self):
        return len(self.heap)
      
N,M=map(int,input().split())
L = list(map(lambda s:int(s) * -1,input().split()))

pq = PriorityQueue(L)
import math
for _ in range(M):
  m = pq.pop()
  
  pq.push(math.ceil(m / 2))
ANS=0
for _ in range(N):
  k = pq.pop()
  
  ANS += k
print(ANS * -1)

Solution (Python):
import heapq

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

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

Solution (Python):
import heapq

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

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

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

heapq.heapify(price)
for _ in range(m):
    max_price = -heapq.heappop(price)
    heapq.heappush(price, -(max_price//2))

ans = -sum(price)
print(ans)

Solution (Python):
import math
import heapq

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

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

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

a = list(map(lambda x:x*(-1),a))
a = list(map(math.floor,a))

print(sum(a))

Solution (Python):
import heapq

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

def func():
   n=-heapq.heappop(A)
   n//=2
   heapq.heappush(A,-n)

for i in range(M):
   func()

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

Solution (Python):
import heapq

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

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

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

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

print(-sum(q))

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

print(main())

Solution (Python):
import heapq

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

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

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

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

for _ in range(M):
    _max = heappop(A)*(-1)
    x = _max / 2
    heappush(A, floor(_max/2)*(-1))

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

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

print(-sum(a))

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

import heapq  
heapq.heapify(a_list)  

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

print(sum(a_list) * -1)

Solution (Python):
import heapq

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

heapq.heapify(A)

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

print(-sum(A))

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

import heapq

heapq.heapify(A)

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

print(-sum(A))

Solution (Python):
import heapq

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

nums = [n * -1 for n in nums]
heapq.heapify(nums)

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

print(-sum(nums))

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

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

nums = [-n for n in nums]
print(sum(nums))

Solution (Python):
import heapq
import math
import sys
from functools import reduce
input = sys.stdin.readline

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

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

    print(reduce(lambda total, x: math.floor(-x) + total, A, 0))

main()

Solution (Python):
import heapq

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

Solution (Python):
import heapq

N,M = map(int, input().split())
List1=list(map(int,input().split()))
List=[]

for i in range(N):
  a = List1[i]
  List.append(-a)

heapq.heapify(List)

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

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):
    
    tem_num=heapq.heappop(a)*(-1)
    
    heapq.heappush(a,(-1)*(tem_num//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 _ in range(m):
    heapq.heappushpop(a, -(-a[0] // 2))
print(-sum(a))

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

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

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

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

Solution (Python):
import heapq

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    A = list(map(lambda x: x*(-1), A)) 
    heapq.heapify(A)
    ans = 0
    while M > 0:
        heapq.heappush(A, (heapq.heappop(A)*-1) // 2 * -1)
        M -= 1
    for i in range(N):
        ans += -A[i]
    print(ans)

if __name__ == '__main__':
    main()

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

for m in range(M):
  tmp1=heapq.heappop(A)
  tmp2=(-1)*(math.floor((-1)*tmp1/2))
  heapq.heappush(A,tmp2)
  
print((-1)*sum(A))

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


import heapq
heapq.heapify(A)

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

ans = -sum(int(a) for a in A)
print(ans)

Solution (Python):

import sys
import heapq

def solve(N: int, M: int, A: "List[int]"):

    while True:
        tmp = heapq.heappop(A) * -1
        heapq.heappush(A,tmp // 2 * -1)
        M -= 1
        if M == 0:
            break
    
    print(sum(A) * -1)

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    A = []
    heapq.heapify(A)
    for i in range(N):
        heapq.heappush(A,int(next(tokens)) * -1)

    solve(N, M, A)

if __name__ == '__main__':
    main()

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

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

print(-sum(A))

Solution (Python):
N = int(2e5+3)
heap_arr, heap_size = [0] * N, 0

def heap_push(x):
    global heap_size
    heap_arr[heap_size] = x
    i = heap_size
    while i > 0 and heap_arr[i] > heap_arr[(i-1)//2]:
        heap_arr[i], heap_arr[(i-1)//2] = heap_arr[(i-1)//2], heap_arr[i]
        i = (i-1)//2
    heap_size += 1

def get_max():
    global heap_size
    if heap_size == 0:
        return -2e9
    return heap_arr[0]

def heap_pop():
    global heap_size
    if heap_size == 0:
        return
    heap_size -= 1
    heap_arr[0], heap_arr[heap_size] = heap_arr[heap_size], heap_arr[0]
    i, j = 0, -1
    while i != j:
      j = i
      l = 2*i+1
      r = 2*i+2
      if l < heap_size and heap_arr[l] > heap_arr[i]:
          i = l
      if r < heap_size and heap_arr[r] > heap_arr[i]:
          i = r
      heap_arr[i], heap_arr[j] = heap_arr[j], heap_arr[i]

n, m = map(int, input().split())
arr = list(map(int, input().split()))
for i in arr:
    heap_push(i)
while m >= 1:
    x = get_max() // 2
    heap_pop()
    heap_push(x)
    m -= 1    
print(sum(heap_arr))

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

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

print(-sum(a))

Solution (Python):
N = int(2e5+3)
heap_arr, heap_size = [0] * N, 0

def heap_push(x):
    global heap_size
    heap_arr[heap_size] = x
    i = heap_size
    while i > 0 and heap_arr[i] > heap_arr[(i-1)//2]:
        heap_arr[i], heap_arr[(i-1)//2] = heap_arr[(i-1)//2], heap_arr[i]
        i = (i-1)//2
    heap_size += 1

def get_max():
    global heap_size
    if heap_size == 0:
        return -2e9
    return heap_arr[0]

def heap_pop():
    global heap_size
    if heap_size == 0:
        return
    heap_size -= 1
    heap_arr[0], heap_arr[heap_size] = heap_arr[heap_size], heap_arr[0]
    i, j = 0, -1
    while i != j:
      j = i
      l = 2*i+1
      r = 2*i+2
      if l < heap_size and heap_arr[l] > heap_arr[i]:
          i = l
      if r < heap_size and heap_arr[r] > heap_arr[i]:
          i = r
      heap_arr[i], heap_arr[j] = heap_arr[j], heap_arr[i]

n, m = map(int, input().split())
arr = list(map(int, input().split()))
for i in arr:
    heap_push(i)
while m >= 1:
    x = get_max() // 2
    heap_pop()
    heap_push(x)
    m -= 1    
print(sum(heap_arr))

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())
price = list(map(lambda x: -x, map(int, input().split())))
heapq.heapify(price)

while m >= 1:
    a = (heapq.heappop(price) + 1) // 2
    heapq.heappush(price, a)
    m -= 1
    
print(sum(price) * (-1))

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

print(-sum(A))


"""

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


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

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

items = list(map(lambda x:int(x)*(-1), input().split()))
heapq.heapify(items)
             
for i in range(m):
    pop = heapq.heappop(items)*(-1)//2
    heapq.heappush(items, pop*(-1))

print(-1*sum(items))

Solution (Python):
import heapq

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

heapq.heapify(heap)

for i in range(m):
    highest = heap[0]
    heapq.heapreplace(heap, highest / 2.0)

ans = -sum(map(int, heap))
print(ans)

Solution (Python):
import heapq


def main():
    n, m = map(int, input().split())
    alist = map(int, input().split())
    heap = []
    for a in alist:
        heapq.heappush(heap, a * -1)
    for _ in range(m):
        v = heapq.heappop(heap)
        heapq.heappush(heap, int(v / 2))
    print(int(-1 * sum(heap)))


main()

Solution (Python):
import heapq
import math
 
def LI():
  return [int(s) for s in input().split()]
 
N,M = LI()
a = LI()
a = list(map(lambda x: x*(-1), a))  
 
heapq.heapify(a)
 
for i in range(M):
    x = (-1)*(abs(heapq.heappop(a))//2)
    heapq.heappush(a,x)

cost = 0
for i in range(N):
  x = heapq.heappop(a)
  cost+=abs(x)
  
print(cost)

Solution (Python):
import heapq

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

A = list((-1)*(int(x)) for x in input().split())
heapq.heapify(A)

sum = 0

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

for i in range(len(A)):
    sum += -A[i]

print(sum)

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

Solution (Python):

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

from heapq import heappush, heappop

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

for i in range(M):
  x = -heappop(queue)
  heappush(queue, -(x // 2))

print(-sum(queue))

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

import heapq
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())
Alist = list(map(int,input().split()))
newA = list(map(lambda x: x*(-1),Alist))
heapq.heapify(newA)
for i in range(M):
    current = -heapq.heappop(newA)
    heapq.heappush(newA,-(current//2))
cost = 0
print(-sum(newA))

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

Solution (Python):
import heapq
import math

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

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

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

print(-sum(A))

Solution (Python):
def minus(a:str):
    return int(a)*-1

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

import heapq as hq

def main():
    hq.heapify(A)
    for _ in range(M):
        target = hq.heappop(A)
        target = -1*((-1*target) // 2)
        hq.heappush(A,target)
    print(sum(A)*-1)
    return 

if __name__ == "__main__":
    main()

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

Solution (Python):
import bisect
import heapq
import numpy as np
N, M = map(int,input().split())
a = list(map(int,input().split()))
a = list((np.array(a))*(-1))
heapq.heapify(a)
for m in range(M):
    tgt = -heapq.heappop(a)
    heapq.heappush(a,-(tgt//2))
res = 0
for n in range(N):
    res += int(heapq.heappop(a))
print(-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 k in range(m):
    a=heapq.heappop(A)
    heapq.heappush(A, -1*(-a//2))
print((sum(A))*-1)

Solution (Python):
import heapq


nm = list(map(int, input().split()))
n, m = nm[0], nm[1]

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

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

heapq.heapify(prices)

while m > 0:
    top = heapq.heappop(prices)
    discounted = ((top * -1) // 2) * -1
    heapq.heappush(prices, discounted)
    m -= 1


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

Solution (Python):
import heapq

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

input_list = [-x for x in input_list]

heapq.heapify(input_list)
discount_element = heapq.heappop(input_list)


i = 0
while i < m:
    discount_element = -(-(discount_element) // 2)
    heapq.heappush(input_list, discount_element)
    discount_element = heapq.heappop(input_list)
    i += 1

heapq.heappush(input_list, discount_element)

print(-(sum(input_list)))

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 _ in range(m):
    pop = heapq.heappop(a)
    p = -(pop*-1//2)
    
    heapq.heappush( a, p)
print(sum(list(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):
    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 = list(map(lambda x: x*(-1), a))

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

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

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

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

import numpy as np
l = list(map(int, input().split()))
l = list(map(lambda x: -1 * x, l))

import heapq

heapq.heapify(l)

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

print(-1 * sum(l))

Solution (Python):
import heapq as hq

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

print(-sum(b))

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

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

print(sum(a)*-1)

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

for i in range(m):
    heapq.heappush(a,ceil(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):
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
while m>0:
  a[0]//=2
  for i in range(1, m):
    if i<n and a[i] >= a[0]:
      a[i]//=2
    else:
      a.sort(reverse=True)
      m-=i
      break
  else:
    break
print(sum(a))