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: Wrong Answer

Solution code:
def main():
    N, M, *A = map(int, open(0).read().split())
    
    A = sorted(A)
    lA = len(A)

    for i in range(M):
        A[-1] = A[-1]//2
        
        j = 1
        while (j == (len(A) - 1)) and (A[-j] >= A[-(j+1)]):
            j += 1
        A.insert(j, A.pop(-1))

    print(sum(A))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

ans=0
def cheap(x,y):
    x=int(x/(2**y))
    return x

i=0
while(i<M):
    sorted(A)
    A[0]=cheap(A[0],1)
    i+=1

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

print(ans)

Submission status: Wrong Answer

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

for i in range(ticket):
    j =len(tab) -1
    while (j > 0 and tab[j] < tab[j-1]):
        j-=1
    tab[j] = ((tab[j]/2))
    if (j < len(tab)/2):
        tab =sorted(tab)

for i in range(len(tab)):
    tab[i] = round(tab[i] - 0.01)

print(sum(tab))

Submission status: Wrong Answer

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

for i in range(M):
  if i>0:
    x=0
    for j in range(N-1):
      if a[0]<a[j+1]:
        x+=1
      elif x>0:
        a0=a[0]
        for k in range(x+1):
          a[k]=a[k+1]
        #b=a[1:x+1]
        #a[:x]=b
        a[x+1]=a0
        break
  a[0]=a[0]/2
  
sum=0
for i in range(N):
  sum+=int(a[i])
print(sum)

Submission status: Wrong Answer

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

for i in range(M):
  if i>0:
    x=0
    for j in range(N-1):
      if a[0]<a[j+1]:
        x+=1
      elif x>0:
        a0=a[0]
        b=a[1:x+1]
        a[:x]=b
        a[x+1]=a0
        break
  a[0]=a[0]/2
  
sum=0
for i in range(N):
  sum+=int(a[i])
print(sum)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
inf=10*9+7
for _ in range(inf):
    mm=max(a)
    ii=a.index(mm)
    if m>0:
        a[ii]//=2
        m-=1
    else:
        break
print(sum(a))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
inf=10*9+7
cnt=m
for i in range(inf):
    mm=max(a)
    ii=a.index(mm)
    if cnt>0:
        a[ii]//=2
        cnt-=1
    else:
        break
print(sum(a))

Submission status: Wrong Answer

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

print(-sum(A))

import heapq

Submission status: Wrong Answer

Solution code:
a = [2,3,4]
b = max(a)
b = b/2

print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(m):
    a[-1] //= 2
    a.sort()

print(sum(a))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
def calc_minus(n):
  return n*(-1)
A=list(map(int,input().split()))
for i in range(N):
  calc_minus(A[i])
import heapq
heapq.heapify(A)
t=0
import math
for i in range(M):
  maxi=heapq.heappop(A)
  maxi=math.ceil(maxi/2)
  heapq.heappush(A,maxi)
  
amount=sum(A)
print(amount)

Submission status: Wrong Answer

Solution code:
import queue
MAXIMUM = 10 ** 10
q = queue.PriorityQueue()
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
for a in A:
  q.put((-a, a))

while M > 0:
  item = q.get()
  if item[1] == 0:
    break
  q.put((-item[1]//2, item[1]//2))
  M -= 1

result = 0
while not q.empty():
  result += q.get()[1]
print(result)

Submission status: Wrong Answer

Solution code:
import heapq

def receive_shopping_plan():
    num_commodity, num_coupon = input().split(' ')
    num_commodity, num_coupon = int(num_commodity), int(num_coupon)
    return num_commodity, num_coupon

def calc_minimized_sum(num_commodity, num_coupon):
    prices = list(map(lambda x: int(x) * -1 , input().split(' ')))
    heapq.heapify(prices)
    for _ in range(num_coupon):
        max_price = heapq.heappop(prices) // 2
        heapq.heappush(prices, max_price)

    print(sum(prices)*-1)

if __name__ == '__main__':
    num_commodity, num_coupon = receive_shopping_plan()
    calc_minimized_sum(num_commodity, num_coupon)

Submission status: Wrong Answer

Solution code:
from fractions import gcd as bltin_gcd


def coprime2(a, b):
    return bltin_gcd(a, b) == 1


def cf(x1,x2):
    cf = [1]
    for i in range(2, min(x1, x2) + 1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf


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

# 公約数
divisor_list = cf(A, B)

# print(divisor_list)

counts = []
for i in divisor_list:
    if i == 1:
        continue

    other_list = list(filter(lambda x: x != i, divisor_list))

    count = 0
    nums = []
    for j in other_list:
        if coprime2(i, j):
            for n in nums:
                if not coprime2(j, n):
                    break
            else:
                nums.append(j)
                count = count + 1

    counts.append(count)

if not counts:
    print(1)
else:
    print(max(counts) + 1)

Submission status: Wrong Answer

Solution code:
import math
a,b = list(map(int,input().split()))
cf=[1]
ccf=[1]
for i in range(2,min(a,b)+1):
  if a % i == 0 and b % i == 0:
    cf.append(i)
for ii in range (len(cf)):
  q=0
  if cf[ii] == 1: 
    q =1
  for k in range(2, int(math.sqrt(cf[ii])) + 1):
    if cf[ii] % k == 0:
      q=1
  if q ==0:
    ccf.append(cf[ii])
print(len(ccf))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().rstrip().split())
S = list(map(int, input().rstrip().split()))
S = [-x for x in S]
import heapq
heapq.heapify(S)

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

Submission status: Wrong Answer

Solution code:
import numpy as np

def receive_shopping_plan():
    num_commodity, num_coupon = input().split(' ')
    num_commodity, num_coupon = int(num_commodity), int(num_coupon)
    return num_commodity, num_coupon

def calc_minimized_sum(num_commodity, num_coupon):
    prices = np.array(input().split(' '), dtype='f')
    for _ in range(num_coupon):
        prices[prices.argmax()] //= 2
    print(int(prices.sum()))

if __name__ == '__main__':
    num_commodity, num_coupon = receive_shopping_plan()
    calc_minimized_sum(num_commodity, num_coupon)

Submission status: Wrong Answer

Solution code:
import numpy as np

def receive_shopping_plan():
    num_commodity, num_coupon = input().split(' ')
    num_commodity, num_coupon = int(num_commodity), int(num_coupon)
    return num_commodity, num_coupon

def calc_minimized_sum(num_commodity, num_coupon):
    prices = np.array(input().split(' '), dtype='i')
    for _ in range(num_coupon):
        prices[prices.argmax()] //= 2
    print(prices)

if __name__ == '__main__':
    num_commodity, num_coupon = receive_shopping_plan()
    calc_minimized_sum(num_commodity, num_coupon)

Submission status: Wrong Answer

Solution code:
import numpy as np

def receive_shopping_plan():
    num_commodity, num_coupon = input().split(' ')
    num_commodity, num_coupon = int(num_commodity), int(num_coupon)
    return num_commodity, num_coupon

def calc_minimized_sum(num_commodity, num_coupon):
    prices = np.array(input().split(' '), dtype='f')
    for _ in range(num_coupon):
        prices[prices.argmax()] //= 2.
    print((prices//1).sum().astype('i'))

if __name__ == '__main__':
    num_commodity, num_coupon = receive_shopping_plan()
    calc_minimized_sum(num_commodity, num_coupon)

Submission status: Wrong Answer

Solution code:
import numpy as np

def receive_shopping_plan():
    num_commodity, num_coupon = input().split(' ')
    num_commodity, num_coupon = int(num_commodity), int(num_coupon)
    return num_commodity, num_coupon

def calc_minimized_sum(num_commodity, num_coupon):
    prices = np.array(input().split(' '), dtype='f')
    for _ in range(num_coupon):
        prices[prices.argmax()] /= 2.
    print((prices//1).sum().astype('i'))

if __name__ == '__main__':
    num_commodity, num_coupon = receive_shopping_plan()
    calc_minimized_sum(num_commodity, num_coupon)

Submission status: Wrong Answer

Solution code:
import numpy as np

def receive_shopping_plan():
    num_commodity, num_coupon = input().split(' ')
    num_commodity, num_coupon = int(num_commodity), int(num_coupon)
    return num_commodity, num_coupon

def calc_minimized_sum(num_commodity, num_coupon):
    prices = np.array(input().split(' '), dtype='f')
    for _ in range(num_coupon):
        prices[prices.argmax()] /= 2.
    print((prices//1).sum())

if __name__ == '__main__':
    num_commodity, num_coupon = receive_shopping_plan()
    calc_minimized_sum(num_commodity, num_coupon)

Submission status: Wrong Answer

Solution code:
import numpy as np

def receive_shopping_plan():
    num_commodity, num_coupon = input().split(' ')
    num_commodity, num_coupon = int(num_commodity), int(num_coupon)
    return num_commodity, num_coupon

def calc_minimized_sum(num_commodity, num_coupon):
    princes = np.array(input().split(' '), dtype='i')
    for i in range(num_coupon):
        princes[princes.argmax()] //= (2**2)
    print(princes.sum())

if __name__ == '__main__':
    num_commodity, num_coupon = receive_shopping_plan()
    calc_minimized_sum(num_commodity, num_coupon)

Submission status: Wrong Answer

Solution code:
import heapq

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

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

heapq.heapify(nums)

for _ in range(N):
    tmp = heapq.heappop(nums)
    heapq.heappush(nums, (-1)*(-tmp//2))

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

Submission status: Wrong Answer

Solution code:
import heapq

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

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

Submission status: Wrong Answer

Solution code:
import heapq

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

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

print(-int(sum(A)))

Submission status: Wrong Answer

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

a.sort()

for _ in range(0, M):
    a[N-1] = a[N-1] // 2
    i = N - 2
    while a[N-1] < a[i]:
        i -= 1
    tmp = a[N-1]
    a[N-1] = a[i]
    a[i] = tmp
        
#    a.sort()

print(sum(a))

Submission status: Wrong Answer

Solution code:
import heapq
X = list(map(int, input().split()))
A = list(map(int, input().split()))
heapq.heapify(A)

for i in range(X[1]):
  x = heapq.heappop(A) * (-1)
  heapq.heappush(A, int(x/2) * (-1))

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

print(ans)

Submission status: Wrong Answer

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


A = Aorg
"""
A.sort(reverse=True)
A = A[:M]
print(A)
"""

sumA = sum(Aorg)

for m in range(M):
  #print(A.index(max(A)))
  sumA = int(sumA - max(A)/2)
  #A[A.index(max(A))] = int(A[A.index(max(A))] - max(A)/2)

print(sum(A))

Submission status: Wrong Answer

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


A = Aorg
A.sort(reverse=True)
A = A[:M]
#print(A)

sumA = sum(Aorg)

for m in range(M):
  #print(A.index(max(A)))
  sumA = int(sumA - max(A)/2)
  A[A.index(max(A))] = int(A[A.index(max(A))] - max(A)/2)

print(sum(A))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    d = {"Sunny":1 , "Cloudy":2, "Rainy":0}
    a = ["Sunny", "Cloudy", "Rainy"]
    print(a[d[input().rstrip()]])
    return

#B
def B():
    s = S()
    for i, si in enumerate(s):
        if i % 2:
            if si == "R":
                print("No")
                return
        else:
            if si == "L":
                print("No")
                return
    print("Yes")
    return

#C
def C():
    n, k, q = LI()
    d = [0] * n
    for _ in range(q):
        a = II() - 1
        d[a] += 1
    for a in d:
        if k - (q - a) > 0:
            print("Yes")
        else:
            print("No")
    return

#D
def D():
    n,m = LI()
    a = LI()
    q = []
    for ai in a:
        heappush(q, ai)
    for _ in range(m):
        heappush(q, heappop(q) / 2)
    ans = 0
    while q:
        ans += int(heappop(q))
    print(ans)
    return

#E
def E():
    return

#F
def F():
    return

#Solve
if __name__ == '__main__':
    D()

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
t=0
while True:
  maxi=A[0]
  if len(A)>1 :
    maxi_2=A[1]
    t+=1
    maxi=maxi//2
    if t==M :
      A[0]=maxi
      break
    elif maxi_2>maxi :
      A[0]=maxi
      A.sort(reverse=True)
      continue
    else:
      continue
  else :
    maxi=maxi//(2**M)
    A[0]=maxi
    break

amount=sum(A)
print(amount)

Submission status: Wrong Answer

Solution code:
# -*- coding utf-8 -*-
import heapq

MOD = 10 ** 9 + 7

N, M = map(int, input().split())
AN = map(int, input().split())
hq = []
for an in AN:
    heapq.heappush(hq, -an)
print(hq)

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

ans = - sum(hq)

print(ans)

Submission status: Wrong Answer

Solution code:
import heapq

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

for a in A:
    a = a * (-1)

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

print(-sum(A))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

goods = np.array(list(map(int, input().split())))

for i in range(M):
    max_value = max(goods)
    max_index = np.where(goods == max_value)[0]
    goods[max_index] = goods[max_index]//2
    
sum_value = sum(goods)

print(sum_value)

Submission status: Wrong Answer

Solution code:
import heapq
import math

n, m = map(int, input().split())
goods = list(map(lambda x: int(x) * -1, input().split()))
heapq.heapify(goods)
for i in range(n):
    the_most_expensive = heapq.heappop(goods)
    heapq.heappush(goods, math.ceil(the_most_expensive / 2))

print(sum(goods) * -1)

Submission status: Wrong Answer

Solution code:
import math
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(m):
    a.sort(reverse=True)
    a[0] = (a[0]/2)
print(math.floor(sum(a)))

Submission status: Wrong Answer

Solution code:
import math
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(m):
    a.sort(reverse=True)
    a[0] = round(a[0]/2)
print(math.floor(sum(a)))

Submission status: Wrong Answer

Solution code:
import sys
n,m = map(int,input().split())
lst_a = list(map(int,input().split()))
temp = 0
cnt = 0
fin = 0
loop = 0
debug = 0
temp2 = 0
if n == 1:
    for i in range(m):
        lst_a[0] //= 2
    print(lst_a[0])
    sys.exit()
while debug < 10:
    loop = 0
    #temp2 = temp
    temp = 0
    lst_a.sort(reverse=True)
    while loop < n-1:
        lst_a[loop] //= 2
        cnt += 1
        temp = max(temp,lst_a[loop])
        if cnt == m:
            print(lst_a)
            print(sum(lst_a))
            sys.exit()
        if temp > max(lst_a[loop],lst_a[loop + 1]):
            break
        if lst_a[loop + 1] > lst_a[loop]:
            loop += 1
        
        
        
"""        if lst_a[loop] >= max(lst_a[loop + 1],temp):
            lst_a[loop] //= 2
            temp = max(lst_a[loop],lst_a[loop+1])
            cnt += 1
            if cnt == m:
                print(sum(lst_a))
                sys.exit()
            if temp > lst_a[loop + 1]:
                break
            
            
        loop += 1
    
    #debug += 1
print(lst_a[99999])
# print(temp)
# print(cnt)
# print(lst_a)
# print(sum(lst_a))
"""

Submission status: Wrong Answer

Solution code:
import sys
n,m = map(int,input().split())
lst_a = list(map(int,input().split()))
temp = 0
cnt = 0
fin = 0
loop = 0
debug = 0
temp2 = 0
if n == 1:
    for i in range(m):
        lst_a[0] //= 2
    print(lst_a[0])
    sys.exit()
while debug < 10:
    loop = 0
    lst_a.sort(reverse=True)
    while loop < n-1:
        if lst_a[loop] >= max(lst_a[loop + 1],temp):
            lst_a[loop] //= 2
            temp = max(lst_a[loop],lst_a[loop+1])
            cnt += 1
            if cnt == m:
                print(sum(lst_a))
                sys.exit()
            if temp > lst_a[loop + 1]:
                break
            
            
        loop += 1
    
    #debug += 1
print(lst_a[99999])
# print(temp)
# print(cnt)
# print(lst_a)
# print(sum(lst_a))

Submission status: Wrong Answer

Solution code:
import sys
n,m = map(int,input().split())
lst_a = list(map(int,input().split()))
temp = 0
cnt = 0
fin = 0
loop = 0
debug = 0
temp2 = 0
if n == 1:
    for i in range(m):
        lst_a[0] //= 2
    print(lst_a[0])
    sys.exit()
while debug < 10:
    lst_a.sort(reverse=True)
    while loop < n-1:
        if lst_a[loop] >= max(lst_a[loop + 1],temp):
            lst_a[loop] //= 2
            temp = max(lst_a[loop],lst_a[loop+1])
            cnt += 1
            if cnt == m:
                print(sum(lst_a))
                sys.exit()
            if temp > lst_a[loop + 1]:
                break
            
            
        loop += 1
    loop = 0
    #debug += 1
print(lst_a[99999])
# print(temp)
# print(cnt)
# print(lst_a)
# print(sum(lst_a))

Submission status: Wrong Answer

Solution code:
import sys
n,m = map(int,input().split())
lst_a = list(map(int,input().split()))
temp = 0
cnt = 0
fin = 0
loop = 0
debug = 0
if n == 1:
    for i in range(m):
        lst_a[0] //= 2
    print(lst_a[0])
    sys.exit()
while debug < 10:
    lst_a.sort(reverse=True)
    while loop < n-1:
        if lst_a[loop] >= max(lst_a[loop+1],temp):
            lst_a[loop] //= 2
            temp = lst_a[loop+1]
            cnt += 1
            if cnt == m:
                print(sum(lst_a))
                sys.exit()
        loop += 1
    loop = 0
    #debug += 1
print(lst_a[99999])
# print(temp)
# print(cnt)
# print(lst_a)
# print(sum(lst_a))

Submission status: Wrong Answer

Solution code:
import sys
n,m = map(int,input().split())
lst_a = list(map(int,input().split()))
temp = 0
cnt = 0
fin = 0
loop = 0
debug = 0
if n == 1:
    for i in range(m):
        lst_a[0] //= 2
    print(lst_a[0])
    sys.exit()
while debug < 10:
    lst_a.sort(reverse=True)
    while loop < n-1:
        if lst_a[loop] >= max(lst_a[loop+1],temp):
            lst_a[loop] //= 2
            temp = lst_a[loop+1]
            cnt += 1
            if cnt == m:
                print(sum(lst_a))
                sys.exit()
        loop += 1
    loop = 0
    #debug += 1
print(temp)
print(cnt)
print(lst_a)
print(sum(lst_a))
"""
for i in range(m):
    if lst_a[0] >= lst_a[1]:
        lst_a[0] //= 2
    elif lst_a[1] >= lst_a[2]:
        lst_a[1] //= 2
        lst_a.sort(reverse=True)
        """

Submission status: Wrong Answer

Solution code:
import heapq
import math

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

heapq.heapify(b)
for i in range(m):
    h = heapq.heappop(b)
    heapq.heappush(b, math.floor(h / 2))

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

Submission status: Wrong Answer

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

for m_num in range(m):
    max_index = a.index(max(a))
    a[max_index] = a[max_index] / 2

print(sum(a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m, *a = map(int, open(0).read().split())
new_a = sorted(a, key=lambda x: -x)
sum = 0
for _ in range(m):
    new_a[0] /= 2
    new_a.sort(key=lambda x: -x)
for price in new_a:
    sum += int(price)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import heapq

num_product, num_coupon = [int(s) for s in input().split()]
price_list = []
for s in input().split():
  heapq.heappush(price_list, int(s)*-1)

for i in range(num_coupon):
  min = price_list[0]
  heapq.heapreplace(price_list, min//2)

sum = 0
for price in price_list:
  sum -= price

print(sum)

Submission status: Wrong Answer

Solution code:
import sys
import os
import math
import heapq

N, M = map(int,input().split())
A = list(map(int,input().split()))
#大きいものから取り出したいので-1倍してqueueに入れる
if len(A) == 1:
    print(A[0]//(2**M))
    sys.exit()

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


first = 1000000000
second = 0

for i in range(M):
    first = -heapq.heappop(Q)
    second = -heapq.heappop(Q)
    while first >= second and i >= 0:
        first = first//2
        i -= 1
    heapq.heappush(Q,-first)
    heapq.heappush(Q,-second)

print(-sum(Q))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# D - Powerful Discount Tickets
n,m= map(int, input().split())

list = [int(s) for s in input().split()]
list.sort(reverse=True)
i = 0
while (m != 0):
    list[i] = (int)(list[i] / 2)
    m = m - 1
    if len(list) == 1:
        continue
    elif len(list) > 1 and list[i] < list[i + 1]:
        list.sort(reverse=True)
    else:
        i = i + 1
print(sum(list))

Submission status: Wrong Answer

Solution code:
import heapq
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

heapq.heapify(A)

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

print(-1*sum(A))

Submission status: Wrong Answer

Solution code:
import heapq
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

heapq.heapify(A)

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

print(-1*sum(A))

Submission status: Wrong Answer

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

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

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

print(sum(prices) * -1)

Submission status: Wrong Answer

Solution code:
import heapq

n,m = map(int,input().split())
s = list(map(lambda x: int(x) * -1, input().split()))
#print(type(s))
heapq.heapify(s)
for _ in range(m):
    heapq.heappush(s,heapq.heappop(s)//2)
sum = sum(s)*-1
print(sum)

Submission status: Wrong Answer

Solution code:
import sys
import heapq
sys.setrecursionlimit(100002)
input=sys.stdin.readline
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in a:
  i=-i
heapq.heapify(a)
for i in range(m):
  heapq.heappushpop(a,-1*(-a[0]//2))
print(-sum(a))

Submission status: Wrong Answer

Solution code:
#coding:utf-8
N,Y=map(int,input().split())
a=[int(x) for x in input().split()]
for b in range(N):
  a[a.index(max(a))]=a[a.index(max(a))]//2
print(sum(a))

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop
N, K = list(map(int, input().split()))

Alist = [int(i) for i in input().split(' ')]
import math

Blist=Alist
#print(Alist)
my_list = [9,8,7,4,7,1,3]

#Alist=sorted(Alist, reverse=True)
heap = []
 
for i in Alist:
    heappush(heap, i)
Alist=heap
def insert_list(list, value):
	start=0
	end=len(list)-1

	if value<list[len(list)-1]:
		list.insert(len(list), value)
		return list
	if value>list[0]:
		list.insert(0, value)
		return list
	while True:
		mid_point=int((start+end)/2)
		if value>list[mid_point]:
			if (end-start)<2:
				list.insert(start, value)
				return list
			else:
				end=mid_point
		else:
			if (end-start)<2:
				list.insert(end, value)
				return list
			else:
				start=mid_point

for i in range(K):
   Alist[0]=Alist[0]/2
   
   if len(Alist)>1:
      value=Alist.pop(0)
      Alist=insert_list(Alist,value)
sum=0

for i in Alist:
   sum+=math.floor(i) 
print(int(sum))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop
N, K = list(map(int, input().split()))

Alist = [int(i) for i in input().split(' ')]
import math

Blist=Alist
#print(Alist)
#my_list = [9,8,7,4,7,1,3]

#Alist=sorted(Alist, reverse=True)
heap = []
 
for i in Alist:
    heappush(heap, -i)
Alist=heap
def insert_list(list, value):
	start=0
	end=len(list)-1

	if value<list[len(list)-1]:
		list.insert(len(list), value)
		return list
	if value>list[0]:
		list.insert(0, value)
		return list
	while True:
		mid_point=int((start+end)/2)
		if value>list[mid_point]:
			if (end-start)<2:
				list.insert(start, value)
				return list
			else:
				end=mid_point
		else:
			if (end-start)<2:
				list.insert(end, value)
				return list
			else:
				start=mid_point

for i in range(K):
   Alist[0]=Alist[0]/2
   
   if len(Alist)>1:
      value=Alist.pop(0)
      Alist=insert_list(Alist,value)
sum=0

for i in Alist:
   sum+=math.floor(i) 
print(int(sum))

Submission status: Wrong Answer

Solution code:
def get_answer(input_list):
    c_list = [int(v) for v in input_list[0].split(" ")]
    a = [int(v) for v in input_list[1].split(" ")]
    a = sorted(a, reverse=True)
    n = c_list[0]
    m = c_list[1]

    """
    for i in range(m):
        index = a.index(max(a))
        v = int(a[index] / 2)
        a[index] = v
        m -= 1
    """
    # 9 3 = 2*2*2+1 2+1
    # 10 2
    # 100 4
    # 1000 8
    # 10000 16

    # 13 8 2 : 23 : 9
    # 2*2*2 +5 + 2*2*2 + 2
    # 2*(2*2 + 2*2 + 1) + 5
    # 2*(2*(1+1) + 1) + 5

    #  1101 13  0011 3
    #  1000 8   0100 4
    #  0010 2   0010 2
    # 10111 23  1001 9



    # 2*2*2 = 8

    # 3 3 1
    # total=7
    # cou=3
    #
    #ab = [0] * n
    #for i in range(n):
    #    ab[i] = len(bin(a[i])[2:]) - 1
    a.append(0)

    while m > 0:
        for j in range(n):
            if a[j] >= a[j+1]:
                a[j] = a[j]>>1
                m-=1
                break

    return str(sum(a))



if __name__ == "__main__":
    input_list = []
    while True:
        try:
            input1 = input()
            if not input1:
                break
            if len(input1) == 0:
                break
            input_list.append(input1)
        except EOFError:
            break
    print(get_answer(input_list))

Submission status: Wrong Answer

Solution code:
def get_answer(input_list):
    c_list = [int(v) for v in input_list[0].split(" ")]
    a = [int(v) for v in input_list[1].split(" ")]
    a = sorted(a, reverse=True)
    n = c_list[0]
    m = c_list[1]

    """
    for i in range(m):
        index = a.index(max(a))
        v = int(a[index] / 2)
        a[index] = v
        m -= 1
    """
    # 9 3 = 2*2*2+1 2+1
    # 10 2
    # 100 4
    # 1000 8
    # 10000 16

    # 3 3 1
    # total=7
    # cou=3
    #
    ab = [0] * n
    for i in range(n):
        ab[i] = len(bin(a[i])[2:]) - 1

    while m > 0:
        for j in range(n):
            if ab[j] > 0:
                if j < n - 1:
                    d = ab[j] - ab[j + 1] - 1
                    if d > 0:
                        ab[j] -= d
                        m -= d
                        break
                elif ab[j] > 0:
                    ab[j] -= ab[j]
                    m -= ab[j]
                    break

    return str(sum(ab))



if __name__ == "__main__":
    input_list = []
    while True:
        try:
            input1 = input()
            if not input1:
                break
            if len(input1) == 0:
                break
            input_list.append(input1)
        except EOFError:
            break
    print(get_answer(input_list))