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



Sample input:
3 3
2 13 8


Sample output:
9

Submission status: Runtime Error

Solution code:
from bisect import bisect_right
from collections import deque

n,m = map(int,input().split())
aa = list(map(int,input().split()))
q = deque()
q.extend(sorted(aa))

for i in range(m):
  tmp = q.pop()//2  
  pos = bisect_right(q,tmp)
  q.insert(pos,tmp)
  
print(sum(q))

Submission status: Runtime Error

Solution code:
# 最大値を見つけ、それを２で割るをチケットがなくなるまで繰り返す
# 普通にやると、最大値の選定でO(n)、それをチケット数分だけ繰り返すのでO(n*m)。
# 間に合わないので、優先度付きキューを用いる
import math

n, m = map(int, input().split())
a = [0] * n
a = list(map(int, input().split()))

a = list(map(lambda x: x*(-1), a))
heapq.heapify(a)
for _ in range(m):
    tmp = heapq.heappop(a) * (-1)
    tmp = math.floor(tmp / 2) * (-1)
    heapq.heappush(a, tmp)

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

Submission status: Runtime Error

Solution code:
n=int(input())
print(n*(n-1)//2)

Submission status: Runtime Error

Solution code:
import heapq  # heapqライブラリのimoprt

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

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

Submission status: Runtime Error

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

A.sort(reverse=True)

for i in range(M):
    A[0] = A[0]//2
    if A[0]<A[1]:
        A.sort(reverse=True)

print(sum(A))

Submission status: Runtime Error

Solution code:
from bisect import bisect_left
N, M=map(int, input().split())
A=list(map(int, input().split()))
A.sort()
for i in range(M):
  tmp=A[-1]//2
  A.pop(N-1)
  A.insert(bisect_left(A, tmp), tmp)
  if A[-1]=0:
    break
print(sum(A))

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
A =list(map(int,input().split()))
A.sort(reverse=True)
A_len =len(A)
count =0
for l in range(0,M):
    comp = A[0]/2
    for i in range(0,A_len-1,1):
        if count => M:
            break
        if A[i+1]<comp:
            break
        while True:
            count +=1
            if A[i]/2 > A[i+1]:
                A[i] = A[i]/2
            else:
                A[i] = A[i]/2
                break
    A.sort(reverse=True)
    if count=>M:
        break
A = [int(i) for i in A]
sumN =sum(A)
print(sumN)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
A =list(map(int,input().split()))
A.sort(reverse=True)
A_len =len(A)
count =0
for l in range(0,M):
    comp = A[0]/2
    for i in range(0,A_len,1):
        if count => M:
            break
        if A[i+1]<comp:
            break
        while True:
            count +=1
            if A[i]/2 > A[i+1]:
                A[i] = A[i]/2
            else:
                A[i] = A[i]/2
                break
    A.sort(reverse=True)
    if count=>M:
        break
A = [int(i) for i in A]
sumN =sum(A)
print(sumN)

Submission status: Runtime Error

Solution code:
import heapq
n,m=map(int,input().split())
a=heapq.heapify(list(map(lambda x: int(x)*(-1),input().split())))
while m>0 and sum(a)>0:
  heapq.heappush(a,int(heapq.heappop(a)//2))
  m=m-1
a=list(map(lambda x: int(x)*(-1),a))
print(sum(a))

Submission status: Runtime Error

Solution code:
import math
n,m=map(int,input().split())
a=list(map(int,input().split()))
while m>0:
  a[index(max(a))]=int(math.foor(max(a)/2))
  m=m-1
print(sum(a))

Submission status: Runtime Error

Solution code:
import math

def getMax(arr):
    maxValue = max(list(arr))
    maxIndex = list(arr).index(maxValue)

    return maxIndex,maxValue


def getSum(arr):
    return sum(list(arr))

def calculate(arr,n):
    if n == 0:
        return getSum(arr)
    else:
        index,value = getMax(arr)
        if value == 0:
            return value
        n -= 1
        arr[index] = math.floor(value/2)
        return calculate(arr,n)

S = input().split(' ')
m = int(S[0])
n = int(S[1])

T = input().split(' ')
arr = list(map(int, list(T)))


result = calculate(arr,n)
print(result)

Submission status: Runtime Error

Solution code:
# coding: utf-8
import heepq

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

for i in range(m):
  maxi = heapq.heappop(s)
  heapq.heappush(s, maxi // 2)

print(-sum(s))

Submission status: Runtime Error

Solution code:
import math
n,m=int(input().split())
a=list(map(int,inpit().split()))
ans=0

for i in range(m):
  a=sorted(a,reverse=True)
  a[0]=math.floor(a[0]/2)
     
for j in range(n):
  ans+=a[j]
    
print(ans)

Submission status: Runtime Error

Solution code:
import math
n,m=map(int(input().split()))
a=list(map(int,inpit().split()))
ans=0

for i in range(m):
  a=sorted(a,reverse=True)
  a[0]=math.floor(a[0]/2)
     
for j in range(n):
  ans+=a[j]
    
print(ans)

Submission status: Runtime Error

Solution code:
import math
n,m=map(int(input().split()))
a=list(map(int,inpit().split()))
ans=0

for i in range(m):
    a=sorted(a,reverse=True)
    a[0]=math.floor(a[0]/2)
     
for j in range(n):
    ans+=a[j]
    
print(ans)

Submission status: Runtime Error

Solution code:
import math
import bisect

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

def XX(A, M):
  if M <= 0:
    return
  A[0] = A[0]/2
  M -= 1
  for i in range(1, len(A)):
    if A[i] > A[0] and M > 0:
      A[i] = A[i]/2
      M -= 1
    else:
      break
  A.sort(reverse = True)
  XX(A, M)
  
XX(A, M)
A = list(map(math.floor, A))
print(sum(A))

Submission status: Runtime Error

Solution code:
import math
import bisect

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

def XX(A, M):
  if M <= 0:
    return
  A[0] = A[0]/2
  M -= 1
  for i in range(1, len(A)):
    if A[i] > A[0] and M > 0:
      A[i] = A[i]/2
      M -= 1
    else:
      break
  A.sort(reverse = True)
  XX(A, M)
  
A = list(map(math.floor, A))
XX(A, M)
print(sum(A))

Submission status: Runtime Error

Solution code:
A = list(map(math.floor, A))

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)
for _ in range(M):
  A[0] //=2
  i = 1
  while i < N:
    if A[0] > A[i]:
      A[0:i] = [*A[1:i],A[0]]
      break
    if i == N-1:
      A[0:i] = [*A[1:i],A[0]]
    i +=1


print(sum(A))

Submission status: Runtime Error

Solution code:
from heapq import heappush, heappop, heapify

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

A.sort()
heap = heapify(A)
for i in range(M):
  heappush(heap, heappop()//2)
print(sum(heap))

Submission status: Runtime Error

Solution code:
n, m = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
a.sort()
for _ in range(m):
    a[-1] //= 2
    if a[-1] >= a[-2]: continue
    else:
        a.sort()
print(sum(a))

Submission status: Runtime Error

Solution code:
import sys

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

if len(a_s) == 1:
	for i in range(m):
		a_s[0] = a_s[0] // 2
	print(a_s[0])
	sys.exit()

amax1, amax2 = a_s[-1], a_s[-2]

for i in range(m):
	a_s[a_s.index(amax1)] = amax1 // 2
	if amax1 // 2 < amax2:
		a_s = sorted(a_s)
		amax1, amax2 = a_s[-1], a_s[-2]

res = sum(a_s)
print(res)

Submission status: Runtime Error

Solution code:
from bisect import insort_left

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

  if M < N: 
    ans = sum(A[:N-M])
    A = A[N-M:]
  else: ans = 0

  if not len(A)-1: A[0] //= 2 ** M
  else:
    while M:
        a = A.pop(N-1)

        while a >= A[-1] and M:
            a //= 2
            M -= 1

        insort_left(A, a)

  print(ans + sum(A))

if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
for j in range(M):
  A.sort()
  A[N-1]=A[N-1]//2
print(sum(L))

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
for j in range(M):
  L.sort()
  A[N-1]=A[N-1]//2
print(sum(L))

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
for j in range(M):
  L.sort()
  A[N-1]==A[N-1]//2
print(sum(L))

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)
i = 0
if len(A) == 1:
    A[i] = A[i]//2**m
else:
    for _ in range(m):
        tmpmax = 0
        if i == 0:
            A[i] = A[i]//2
            i +=1
        else:
            for j in range(0,i):
                if A[i] > A[j]:
                    A[i] = A[i]//2
                    i +=1
                    break
                else:
                    A[j] = A[j]//2
                    break
print(sum(A))

Submission status: Runtime Error

Solution code:
N,M = input().split()
N,M = int(N),int(M)
A = input().split()
A = [int(a) for a in A]
def dp(i,M):
    if(i==N):
        return 0
    else:
        if(M==0):
            return dp(i+1,M)+A[i]
        else:
            p = 1e+20
            for m in range(M+1):
                val = dp(i+1,M-m)+int(A[i]/(2**m))
                if(p>val):
                    p = val
                
            return p
print(dp(0,M))

Submission status: Runtime Error

Solution code:
N,M = input().split()
N,M = int(N),int(M)
A = input().split()
A = [int(a) for a in A]
def dp(i,M):
    if(i==N):
        return 0
    else:
        if(M==0):
            return dp(i+1,M)+A[i]
        else:
            p = 1e+10
            for m in range(M+1):
                val = dp(i+1,M-m)+int(A[i]/(2**m))
                if(p>val):
                    p = val
                
            return p
print(dp(0,M))

Submission status: Runtime Error

Solution code:
N,M = input().split()
N,M = int(N),int(M)
A = input().split()
A = [int(a) for a in A]
def dp(i,M):
    if(i==N):
        return 0
    else:
        if(M==0):
            return dp(i+1,M)+A[i]
        else:
            p = []
            for m in range(M+1):
                p.append(dp(i+1,M-m)+int(A[i]/(2**m)))
            return min(p)
print(dp(0,M))

Submission status: Runtime Error

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

for i in range(m)

    v=a.index(max(a))
    a[v] = a[v]/2

#a=map(int, a)
print(sum(a))

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort(reverse=True)
ans=0
a=[]
k=0
left = 0
right = len(x) - 1
for i in range(m):
    x[0]=x[0]//2
    while left <= right:
        mid = (left + right) // 2
        if  x[mid] >= x[0]>=x[mid+1]:
            x.insert(mid+1,x[0])
            x.remove(x[0])
            break               
        elif x[mid] > x[0]:
            right = mid - 1
        else:
            left = mid + 1
for j in range(n):
    ans+=x[j]
print(ans)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort(reverse=True)
ans=0
a=[]
k=0
for i in range(m):
    x[0]=x[0]//2
    if x[0]<x[1]:
        x.sort(reverse=True)
print(ans)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort(reverse=True)
ans=0
a=[]
print(x)
k=0
if n==1:
    for i in range(m):
        x[0]=x[0]//2
        if x[0]<x[1]:
            x.sort(reverse=True)
print(ans)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort(reverse=True)
ans=0
a=[]
print(x)
k=0
if n==1:
    for i in range(m):
        x[0]=x[0]//2
    ans=x[0]
else:
    for i in range(m):
        if x[0]<x[1]:
            a.append(x[0])
            x.remove(x[0])
        else:
            x[0]=x[0]//2
            continue
        if len(a)>0:
            if a[0]>x[0]:
                a[0]=a[0]//2
                a.sort(reverse=True)
            else:
                x[0]=x[0]//2
    for j in range(len(x)):
        ans+=x[j]
    for o in range(len(a)):
        ans+=a[o]
print(ans)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
prices = list(map(int,input().split()))
prices.sort(reverse=True)
big = prices[:M]
small = prices[M:]

discounted = [int(big[0]/2)]
i = 1
if N > 1 and M > 1:
  temp = big[1]
  for m in range(1,M):
    for index in range(len(discounted)):
      if discounted[index]/2 > temp/2:
        discounted[index] = int(discounted[index]/2)
        break
    else:
      discounted.append(int(temp/2))
      i += 1
      temp = big[i]
else:
  for m in range(1,M):
    discounted[0] = int(discounted[0]/2)
  
result = sum(small) + sum(big[i:]) + sum(discounted)
print(result)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
for i in range(m):
    a[-1] //= 2
    if a[-1] < a[-2]:
        a.sort()
print(sum(a))

Submission status: Runtime Error

Solution code:
program D
    implicit none
    integer::n,m,i
    real(8)::ans
    real(8),allocatable::a(:)
    read*,n,m
    allocate(a(n))
    read*,a
    if ( n == 1) then
        ans = a(0) * (0.5) ** m
    else
        do i = 0 , m
            a(maxloc(a,1)) = a(maxloc(a,1)) * 0.5
        end do
        ans = sum(a)
    end if
    print*,ans
end program D

Submission status: Runtime Error

Solution code:
N,M,*A=input().split()  

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

Submission status: Runtime Error

Solution code:
N=int(N)
M=int(M)
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))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from collections import deque
n,m=map(int,input().split())#n:num m:ticket
a=[int(_) for _ in input().split()]
a=deque(a)
for i in range(m):
	a[a.index(max(a))]=max(a)//2
print(sum(a))

Submission status: Runtime Error

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

if len(A) ==1:
  print(int(A[0]/(2**M)))
else:
  while(M>0):
    A[-1]=int(A[-1]/2)
    M -=1
    while(1)
      if A[-1] > A[-2] and M >0:
        A[-1]=int(A[-1]/2)
        M -=1
      elif A[-1] < A[-2] and M > 0:
        A[-1]=int(A[-1]/2)
        M -=1
        A.sort()
        break
      else:
        A.sort()
        break
  print(sum(A))

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
while(M>0):
  A[-1]=int(A[-1]/2)
  M -=1
  if A[-1] < A[-2]:
    A.sort()
print(sum(A))

Submission status: Runtime Error

Solution code:
N, M = [int(item) for item in input().split()]
price_list = sorted([int(item) for item in input().split()])

ticket_list = []
total_price_list = []
total_m = 0

def discount(price_list, ticket_num):
    total_ticket =0

    while total_ticket < ticket_num:
        price_list[-1] = int(price_list[-1]/2)
        temp = price_list[-2]
        price_list[-2] = price_list[-1]
        price_list[-1] =temp
        total_ticket += 1

    return price_list

res = discount(price_list, M)
print(sum(res))

Submission status: Runtime Error

Solution code:
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)
    print(hq)
    heappush(hq, -1 * (tmp // 2))

print(-sum(hq))

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
    N, M = map(int, input().split())
    A = sorted(map(int, input().split()), reverse=True)
    p = 0
    while 0 < M:
        if N == 1:
            p = 0
        elif N == 2:
            p = A.index(max(A[0], A[1]))
        else:
            p = A.index(max(A[p - 1], A[p], A[p + 1])) if p != 0 else A.index(max(A[p], A[p + 1], A[p + 2]))

        A[p] //= 2
        M -= 1

    ret = 0
    for a in A:
        ret += a
    print(ret)

Submission status: Runtime Error

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

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

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

print(-sum(a))

Submission status: Runtime Error

Solution code:
import math

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


def solve():
    sorted_list = A

    for index in range(0, M):
        sorted_list = sorted(sorted_list)
        sorted_list[-1] = math.round(sorted_list[-1] / 2)

    return sum(sorted_list)


print(solve())

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
A=[int(x) for x in input().split()]
A.sort(reverse=True)
print(A)
for i in range(0,M):
    A[0]=int(A[0]/2)
    A.sort(reverse=True)
    print(A)

print(sum(A))

Submission status: Runtime Error

Solution code:
import heapq

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

q = heapq.heapify(a_L)


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

print(-sum(q))

Submission status: Runtime Error

Solution code:
from heapq import heapify, heapreplace
n,m = map(int,input().split())
L = [  -i for i in map(int, input().split())]
heapify(L)
for _ in range(m):
    heapreplace(L,L[0]//2 + L[0]%2)
print(-sum)

Submission status: Runtime Error

Solution code:
import heapq
n,m = map(int,input().split())
L = [  -i for i in map(int, input().split())]
heapify(L)
for _ in range(m):
    heapreplace(L,L[0]//2 + L[0]%2)
print(-sum(L))

Submission status: Runtime Error

Solution code:
import heapq
n,m = map(int,input().split())
L = [  -i for i in map(int, input().split())]
heapify(L)
for _ in range(m):
    heapreplace(L,L[0]//2 + L[0]%2)
print(-sum)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m=list(map(int, input().split()))
a=list(map(int,input().split()))
for _ in range(m):
  a.sort()
  a[m-1] //= 2
print(sum(a))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

n, m = map(int, input().split())
a_i = list(map(lambda x: math.log(int(x), 2), input().split()))
for _ in range(m):
    a_i.sort(reverse=true)
    a_i[0] -= 1
print(reduce(lambda acc, x: acc + int(2 ** x), a_i, 0))

Submission status: Runtime Error

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

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

print(-sum(lis))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
a = list(map(int, input().solit()))

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

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
a = list(map(int, input().solit()))

import heapq
a = [-1*i for i in a]
a = heapq.haapify(a)
for i in range(M):
  b = heapq.heappop(a)
  b = (-1*b)//2
  heap.heappush(a, -1*b)
print(-1*sum(a))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
a = list(map(int, input().solit()))

import heapq
a = [-1*i for i in a]
a = heapq.haapify(a)
for i in range(M):
  b = heapq.heappop(a)
  b = (-1*b)//2
  heap.heap.push(a, -1*b)
print(-1*sum(a))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
a = list(map(int, input().solit()))

import heapq
a = [-1*i i for i in a]
a = heapq.haapify(a)
for i in range(M):
  b = heapq.heappop(a)
  b = (-1*b)//2
  heap.heap.push(a, -1*b)
print(-1*sum(a))

Submission status: Runtime Error

Solution code:
N,K,Q = map(int,input().split())

A = [K]*N
C = [0]*N

for r in range(Q):
  correct = int(input())
  C[correct-1] = C[correct-1] + 1

for i in range(N):
  A[i] = A[i] - Q + C[i]
  
  if A[i] > 0:
    print('Yes')
  else:
    print('No')

Submission status: Runtime Error

Solution code:
from heapq import heappop, heappush
heap = []
N, M = map(int, input().split())
for i in list(map(int,input().split())):
    heappush(heap, i*-1)
for j in range(M):
    num = -((-heappop(heap))//2)
    heappush(heap)

print(sum(heap))

Submission status: Runtime Error

Solution code:
from heapq import heappop, heappush
heap = []
N, M = map(int, input().split())
for i in map(int,input().split()):
    heappush(heap, i*-1)
for j in range(M):
    num = -((-heappop(heap))//2)
    heappush(heap)

print(sum(heap))

Submission status: Runtime Error

Solution code:
def insert_sort(list):
    m=list[0]
    for i in range(N):
        if(m >= list[i+1]):
            list.insert(i+1,m)
            del list[0]
            break

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

for i in range(M):
    if i==0:
        Alist.sort(reverse=True)
        Alist[0]=Alist[0]//2
    elif N>1 and Alist[0]<Alist[1]:
        insert_sort(Alist)
        Alist[0]=Alist[0]//2
    else:
        Alist[0]=Alist[0]//2

        
print(sum(Alist))

Submission status: Runtime Error

Solution code:
N, M =map(int,input().split())
Alist=list(map(int,input().split()))

for i in range(M):
    if i==0:
        Alist.sort(reverse=True)
        Alist[0]=Alist[0]//2
    elif Alist[0]<Alist[1]:
        Alist.sort(reverse=True)
        Alist[0]=Alist[0]//2
    else:
        Alist[0]=Alist[0]//2

        
print(sum(Alist))

Submission status: Runtime Error

Solution code:
N, M =map(int,input().split())
Alist=list(map(int,input().split()))

for i in range(M):
    if i==0:
        Alist.sort(reverse=True)
        Alist[0]=Alist[0]//2
    elif Alist[0]<Alist[1]:
        Alist.sort(reverse=True)
        Alist[0]=Alist[0]//2
    else:Alist[0]=Alist[0]//2

        
print(sum(Alist))

Submission status: Runtime Error

Solution code:
import math

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

def waribiki(s,maisu):
    return math.floor(s/(2**maisu))

for _ in range(m):
    a.append(waribiki(max(A)),1))
    a.remove(max(a))

print(sum(a))

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.buffer.readline
class SkewHeap:
  def __init__(self, init_val = None, left = None, right = None):
    self.val = init_val
    self.left = left
    self.right = right
    self.root = None
  def heapmeld(self, h1, h2):
    if h1 == None: return h2
    if h2 == None: return h1
    if h1.val > h2.val:
      h1.val, h1.left, h1.right, h2.val, h2.left, h2.right = h2.val, h2.left, h2.right, h1.val, h1.left, h1.right
    h1.right = self.heapmeld(h2, h1.right)
    return h1
  def heappop(self):
    if self.root == None:
      res = self.val
      h = self.heapmeld(self.left, self.right)
      if h == None: h = SkewHeap(None)
      self.val, self.left, self.right = h.val, h.left, h.right
      return res
    res = self.root.val
    self.root = self.heapmeld(self.root.left, self.root.right)
    return res
  def heappush(self, x):
    h = SkewHeap(x)
    self.root = self.heapmeld(self.root, h)
N, M = map(int, input().split())
a = list(map(int, input().split()))
h = SkewHeap()
res = 0
for e in a:
  h.heappush(-e)
for _ in range(M):
  h.heappush(-(-h.heappop() // 2))
for _ in range(N):
  res -= h.heappop()
print(res)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Thu Oct  3 07:43:37 2019

@author: avina
"""

import heapq

class Maxheap():
    
    def __init__(self, x):
        self.heap = [-e for e in x]
        heapq.heapify(self.heap)
    
    def push(self, value):
        heapq.heappush(self.heap, -value)
    
    def pop(self):
        return -heapq.heappop(self.heap)

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

l = list(map(int, input().split()))
a = Maxheap(l)
for i in range(l):
    b = a.pop()//2
    a.push(b)
    
sums = 0
for i in range(n):
    sums += a.pop()
print(sums)

Submission status: Runtime Error

Solution code:
def getPlace(tab, v, d, f):
    if (d >= f):
        return tab[d]
    mil = (d + f) // 2
    if (tab[mil] <= v and (mil == f or tab[mil +1] >= v)):
        return (max(f,(mil + 1)))
    if (tab[mil] > v):
        return getPlace(tab, v, d, mil -1)
    else:
        return getPlace(tab, v, mil+1, f)

size = input().split()
objet, ticket = int(size[0]),int(size[1])
data =input().split()
tab = []
for i in data:
    tab.append(int(i))
tab =sorted(tab)

for i in range(ticket):
    j =len(tab) -1
    tab[j] = ((tab[j]//2))
    k = tab.pop(len(tab)-1)
    j = getPlace(tab, k,0,len(tab)-1)
    tab.insert(j,k)
print(sum(tab))

Submission status: Runtime Error

Solution code:
def getPlace(tab, v, d, f):
    if (d >= f):
        return tab[d]
    mil = (d + f) // 2
    if (tab[mil] <= v and (mil == f or tab[mil +1] >= v)):
        return (mil + 1)
    if (tab[mil] > v):
        return getPlace(tab, v, d, mil -1)
    else:
        return getPlace(tab, v, mil+1, f)

size = input().split()
objet, ticket = int(size[0]),int(size[1])
data =input().split()
tab = []
for i in data:
    tab.append(int(i))
tab =sorted(tab)

for i in range(ticket):
    j =len(tab) -1
    tab[j] = ((tab[j]//2))
    k = tab.pop(len(tab)-1)
    j = getPlace(tab, k,0,len(tab)-1)
    tab.insert(j,k)
print(sum(tab))

Submission status: Runtime Error

Solution code:
def getPlace(tab, v, d, f):
    if (d >= f):
        return tab[d]
    mil = (d + f) // 2
    if (tab[mil] <= v and tab[mil +1] >= v):
        return (mil + 1)
    if (tab[mil] > v):
        return getPlace(tab, v, d, mil -1)
    else:
        return getPlace(tab, v, mil+1, f)

size = input().split()
objet, ticket = int(size[0]),int(size[1])
data =input().split()
tab = []
for i in data:
    tab.append(int(i))
tab =sorted(tab)

for i in range(ticket):
    j =len(tab) -1
    tab[j] = ((tab[j]//2))
    k = tab.pop(len(tab)-1)
    j = getPlace(tab, k,0,len(tab)-1)
    tab.insert(j,k)
print(sum(tab))

Submission status: Runtime Error

Solution code:
size = input().split()
objet, ticket = int(size[0]),int(size[1])
data =input().split()
tab = []
for i in data:
    tab.append(int(i))
tab =sorted(tab)

for i in range(ticket):
    j =len(tab) -1
    #print(tab)
    tab[j] = round(((tab[j]//2)))
    k = tab.pop(len(tab)-1)
    #print("remove " + str(k))
    while (k < tab[j - 1]):
        j-=1
    tab.insert(j,k)
#print(round(1.5))
print(sum(tab))

Submission status: Runtime Error

Solution code:
import heapq
 
 
class MaxHeap(object):
    def __init__(self, x):
        self.heap = [-e for e in x]
        heapq.heapify(self.heap)
 
    def push(self, value):
        heapq.heappush(self.heap, -value)
 
    def pop(self):
        return -heapq.heappop(self.heap)
 
N, M = list(map(lambda x:int(x), input().split(' ')))
l = list(map(lambda x:int(x), input().split(' ')))

maxheap = MaxHeap(l)
 
WARI = 0.5
for _ in range(0, M):

Submission status: Runtime Error

Solution code:

import heapq


class MaxHeap(object):
    def __init__(self, x):
        self.heap = [-e for e in x]
        heapq.heapify(self.heap)

    def push(self, value):
        heapq.heappush(self.heap, -value)

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

N, M = list(map(lambda x:int(x), input().split(' ')))
l = list(map(lambda x:int(x), input().split(' ')))

print(N, M)
print(l)

maxheap = MaxHeap(l)

WARI = 0.5
for _ in range(0, M):
    v = int(maxheap.pop() * WARI)
    maxheap.push(v)

print(SUM)

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
using namespace std;
int main(void){
    int n,m;
    cin >> n >> m;
    vector<int> a;
    for(int i = 0; i<n; i++){
        int temp;
        cin >> temp;
        a.push_back(temp);
    }
    sort(a.begin(),a.end());
    
    if(n==1){
        int ans;
        ans = floor(a[0]/pow(2,m));
        cout << ans << endl;
    }
    else{
        while(m>0){
            while(a[n-1] >= a[n-2]){
                a[n-1] = floor(a[n-1]/2);
                m = m-1;
            }
            int temp;
            temp = a[n-1];
            a.pop_back();
            int ind;
            ind = *lower_bound (a.begin(),a.end(),temp);
            a.insert(a.begin()+ind,temp);
        }
        int ans;
        ans = accumulate(a.begin(),a.end(),0);
        cout << ans << endl;
    }
}

Submission status: Runtime Error

Solution code:
import sys
import heapq

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

if len(A) == 1:
    A[0] //= (2 ** M)
    print(sum(A))
    sys.exit()

h = [(1/a, a) for a in A]
heapq.heapify(h)

for m in range(M):
    x = heapq.heappop(h)
    _, a = x

    a //= 2

    heapq.heappush(h, (1/a, a))

print(sum([a for _, a in h]))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
import math
import numpy as np
import heapq
from functools import lru_cache

args = sys.argv
if len(args) == 2:
  from IPython import embed
  em = True
else:
  em = False

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

sys.stdin = open('/dev/tty')

heapq.heapify(A)

#### functions
def discount(num_coupon):
  max = -heapq.heappop(A) / 2
  heapq.heappush(A, -max)

#### execution
# if em: embed()
for i in range(0, M):
  max = math.floor(-heapq.heappop(A) / 2)
  heapq.heappush(A, -max)

print(-sum(A))

Submission status: Runtime Error

Solution code:
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):
    print("mae")
    print(A)
    hoge = -heapq.heappop(A)
    hoge = hoge // 2
    print(A)
    heapq.heappush(A, -hoge)

    print(A)
    
print(-sum(A))