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: Time Limit Exceeded

Solution code:
import sys
input=sys.stdin.readline

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

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

A.sort(reverse=True)
cnt = 1
A[0]=A[0]//2

if N==1:
    while A[0]>0 and cnt<M:
        cnt+=1
        A[0]=A[0]//2
else:
    while cnt<M:
        while A[0]>=A[1] and cnt<M:
            cnt+=1
            A[0]=A[0]//2
          
        b=A[0]
        for i in range(1,N):
            if A[i]>b:A[i-1]=A[i]
            else:
                A[i-1]=b
                break
    
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
import sys


def main():
    N, M = map(int, input().split())
    arr = np.array(input().split(), dtype='int64')
    for i in range(M):
        arr[np.argmax(arr)] /= 2
    print(np.sum(arr))





if __name__ =='__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

for i in range(m):
        atop = a.pop()
        bisect.insort_left(a,atop/2)

print(sum([int(i) for i in a]))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
prices = [int(p) for p in input().split()]
for _ in range(m):
    j, p = max(enumerate(prices), key=lambda x: x[1])
    prices[j] //= 2
print(sum(prices))

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
A = list(map(int,input().split()))
for i in range(M):
    MAX = max(A)
    A[A.index(MAX)] = MAX//2
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import bisect


def main():
    N, M = map(int, input().split())
    As = [0]
    As.extend([int(i) for i in input().split()])

    As.sort()
    checkt_used = 0
    used = [0]
    while checkt_used < M:
        checkt_used += 1
        if not (N == 1 and used == [0]):
            if As:
                takai = As[-1]
                if used:
                    takakatta = used[-1]
                    if takai > takakatta:
                        takai = As.pop()
                    else:
                        takai = used.pop()
                else:
                    takai = As.pop()
                takai //= 2
                b_takai = max(As[-1],used[-1])
                while checkt_used < M and b_takai < takai:
                   takai //= 2
                   checkt_used += 1

                bisect.insort_left(used, takai)
            else:
                takai = used.pop()
                takai //= 2
                b_takai = max(As[-1],used[-1])
                while checkt_used < M and b_takai < takai:
                    takai //= 2
                    checkt_used += 1
                bisect.insort_left(used, takai)
        else:
            As[1] //= 2
        # print(used)

    print(sum(As) + sum(used))

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
j=0
for i in range(M):
    A[A.index(max(A[:j+1]))]=A[A.index(max(A[:j+1]))]//2
    j=j+1
    if j==200:
        A.sort(reverse=True)    
        j=0
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
N, M= map(int,input().split())
A = [int(i) for i in input().split()]
for i in range(M):
    B = A.index(max(A))
    A[B] = A[B] // 2
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math
n, m = map(int, input().split())
a = list(map(float, input().split()))
a.sort(reverse = True)
#print(a)
if n == 1:
    for _ in range(m):
        a[0] /= 2
else:
    for _ in range(m):
        a[0]/=2
        a.sort(reverse=True)

sum = 0
for i in range(n):
     sum += int(math.floor(a[i]))
print(sum)

Submission status: Time Limit Exceeded

Solution code:
import sys
N , M = map(int,sys.stdin.readline().split())
A = list(map(int,sys.stdin.readline().split()))
A.sort(reverse=True)
for _ in range(M):
	A[0] = int(A[0] / 2)
	A.sort(reverse=True)

print(sum(A))

Submission status: Time Limit Exceeded

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

for k in range(M):
    A[0] //= 2
    A.sort(reverse=True)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline
# n = int(input())
n, m = map(int, input().split())
a = input()
a_list = [int(x.strip()) for x in a.split()]
a_list.sort(reverse = True)
for i in range(m):
  new = a_list[0] // 2
  for j in range(n):
    if j == n-1:
      a_list[j] = new
    elif new >= a_list[j+1]:
      a_list[j] = new
      break
    else:
      a_list[j] = a_list[j+1]
  

print(sum(a_list))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict

def main():
  n, m = map(int, input().split())
  prices = map(int, input().split())
  
  priceMap = defaultdict(lambda : 0)
  
  for price in prices:
    priceMap[price] += 1
  
  for _ in range(m):
    keys = priceMap.keys()
    maxPrice = max(keys)
    priceMap[maxPrice] -= 1
    if priceMap[maxPrice] == 0:
      del(priceMap[maxPrice])
    newPrice = maxPrice // 2
    priceMap[newPrice] += 1
  
  total = 0
  for price, num in priceMap.items():
  	total += price * num
  print(total)
  
if __name__ == "__main__":
  main()

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
goods = list(map(int,input().split()))
for i in range(m):
  idx = goods.index(max(goods))
  goods[idx] = goods[idx] // 2
print(sum(goods))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# from collections import deque
import bisect

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

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

ans += sum(A_list)
print(ans)

Submission status: Time Limit Exceeded

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

count = 0

if n == 1:
    for i in range(m):
        a_list[0] = a_list[0] // 2
else:
    while m>count:
      a_list.sort(reverse=True)
      a_list[0] = a_list[0] // 2
      count += 1
      if a_list[0] >= a_list[1]:
        a_list[0] = a_list[0] // 2
        count += 1
print(sum(a_list))

Submission status: Time Limit Exceeded

Solution code:
import math
import numpy as np

def where(x):
  return np.array(np.where(x))

n, m = map(int, input().split())
a = np.array(list(map(int, input().split())))
a = np.sort(a)
b = np.log2(a)
b = np.array(list(map(int, b)))
mx = np.max(b)

while m != 0:
  mask = where(b == mx).flatten()
  if len(mask) == 0:
      continue
  if len(mask) <= m:
    b[mask] = b[mask] - 1
    a[mask] = a[mask] / 2
    m -= len(mask)
    mx -= 1
  else:
    while m != 0:
      a = np.sort(a)
      a[n-1] /= 2
      m -= 1

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, M = map(int, input().split())
items = np.array(list(map(int, input().split())))
for i in range(M):
    items[items.argmax()]/=2
    if np.max(items)<0.5:
        break
print(round(np.sum(items)))

Submission status: Time Limit Exceeded

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

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N,M=map(int, input().split())
A=np.array(list(map(int, input().split())))
for i in range(M):
    x=np.argmax(A)
    A[x]=A[x]//2
print(sum(A))

Submission status: Time Limit Exceeded

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

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

print(sum(A))

Submission status: Time Limit Exceeded

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

for i in range(d):
    t = a.index(max(a))
    a[t] = max(a)//2
    if max(a) == 0:
        break
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
from copy import copy

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

A = list(map(int, input().split(" ")))
A = np.array(A)
A = np.sort(A)[::-1]

B = np.array([0.0] * N)
i = M
j = 0
C = copy(A)

ind = 0
while i > 0:
    # print(C)
    # print(B)
    # print(A)
    B[0] += 1
    C[0] = A[0] / (2 ** B[0])
    i -= 1
    ind = np.argsort(C)[::-1]
    C = C[ind]
    B = B[ind]
    A = A[ind]
    # for ind in range(N-1):
    #     if C[0] < C[ind]:
    #         C[ind] = C[ind+1]
    #         B[ind] = B[ind+1]
    #         A[ind] = A[ind+1]
    #     else:
    #         if ind < N:
    #             C[ind] = tmp
    #             B[ind] = tmp_B
    #             A[ind] = tmp_A
    #         break

for i in range(N):
    C[i] = A[i] // (2 ** B[i])
print(sum(C))
# print(B)

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect_left
import sys

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

if N == 1:
    for i in range(M):
        A[0] = A[0] // 2
    print(sum(A))
    sys.exit()

A.sort(reverse=True)
for i in range(M):
    index = A.index(max(A))
    A[index] = A[index] // 2

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math
import bisect

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

for i in range(M):
    n = A.pop() / 2
    bisect.insort(A, n)

print(sum(math.floor(A[j]) for j in range(N)))

Submission status: Time Limit Exceeded

Solution code:
from numpy import array, sum, argmax

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

for i in range(M):
  #print(A)
  idx = argmax(A)
  A[idx] //= 2

print(sum(A))

Submission status: Time Limit Exceeded

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

test = [0]*N

for i in range(M):
    A.sort()
    A[-1] = A[-1] // 2
    if A == test:
        break

total = sum(A)
print(total)

Submission status: Time Limit Exceeded

Solution code:
N,M = input().split()
N = int(N)
M = int(M)
price_list = input().split()
 
price_list = list(map(int, price_list))
 
for _ in range(M):
  num = max(price_list)
  price_list.remove(num)
  price_list.append(int(num/2))
print(sum(price_list))

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import Counter
import bisect
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N, M = MAP()
A = LIST()
A.sort()

for i in range(M):
    if A[N-1] < A[N-2]:
        a = A[N-1]
        A = A[:N-1]
        bisect.insort(A,a)

    A[N-1] //=2


print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n, m = list(map(int, input().split()))
A = np.array(list(map(int, input().split())))
for i in range(m):
    idx = A.argmax()
    A[idx] = A[idx] / 2.0
print(A.sum())

Submission status: Time Limit Exceeded

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

for i in range(m):
    p = max(a_list)
    a_list.remove(p)
    a_list.append(p // 2)
    
print(sum(a_list))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import sys

input = sys.stdin.readline

N,M = [int(a) for a in input().split()]
A = np.array([int(a) for a in input().split()], dtype=int)

A = np.sort(A)[::-1]

for i in range(M):
    max_idx = np.argmax(A)
    A[max_idx] //= 2

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

inputData = input().split()
N, M = [int(x) for x in inputData]
inputData = input().split()
A = np.array([float(x) for x in inputData])
for i in range(M):
    index = np.argmax(A)
    np.put(A, index, A[index] * 0.5)
    # A[index] = A[index] * 0.5
A = np.floor(A)
print(int(A.sum()))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


for j in range(M):
  i=A.index(max(A))
  A[i]=int(A[i]/2)
  
sum=0
for j in range(N):
  sum=sum+A[j]
  
print(sum)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n = list(map(int,input().split()))
a = list(map(int,input().split()))
a = np.array(a)

for i in range(n[1]):
    a[a.argmax()] = a[a.argmax()]//2 
print(np.sum(a))

Submission status: Time Limit Exceeded

Solution code:
import bisect
import sys
input = sys.stdin.readline

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

for i in range(m):
  a = aaa.pop(-1) // 2
  insert_index = bisect.bisect_right(aaa, a)
  aaa.insert(insert_index, a)
  if a == 0:
    print(0)
    break
else:
  print(sum(aaa))

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
A=list(map(int,input().split()))
ct=0
for i in range(m):
    A = sorted(A,reverse=True)
    A[0]=int(A[0]/2)
    ct+=1
print(sum(A))

Submission status: Time Limit Exceeded

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

# N: 買う品物の個数
# M: 持っている割引券の数
N, M = list(map(int, input().split()))

# X 円の品物を買う際に Y 枚の割引券を使った場合、その品物を (X/2^Y) 円(小数点以下切り捨て)で買うことができます。
# 最小で何円あれば全ての品物を買うことができるのか?

# アイディア
# 単に高い商品から順に割引券を使えればよい...
# ただ、割引券は 10^5 枚ありえるようなので、
# 普通に並び替えて最大なものに割引券を適用する...というのを繰り返しても、
# タイムアウトになるだろう。
# うーん...
#
# 単に大きい順にソートして割引券を適用して、
# そのあとは挿入ソートを使って順繰りに割引券を適用するというのはどうだろうか
# やってみようか
A = list(map(int, input().split()))
A.sort(reverse=True)

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

for i in range(M):
    # 1. 先頭を半額にする
    # 2. 挿入ソートする
    A[0] = A[0] / 2

    if 1 < N:
        idx = 0
        for j in range(1, N):
            if A[j] < A[0]:
                idx = j
                break
        if idx == 0:  # A[0] より小さい値を探せなかったとき; 単に A[0] を最後尾に回す
            pass
            A = A[1:] + [A[0]]
        else:
            A = A[1:idx] + [A[0]] + A[idx:]

print(sum([int(x) for x in A]))

Submission status: Time Limit Exceeded

Solution code:
n,m=(int(x) for x in input().split())
l = [int(i) for i in input().split()]

l.sort(reverse=True)
for i in range(m):
    l[0]=l[0]//2
    l.sort(reverse=True)
total=0
for j in range(len(l)):
    total+=l[j]

print(total)

Submission status: Time Limit Exceeded

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

for i in range(m):
	temp = int(max(p)/2)
	p.remove(max(p)) 
	p.append(temp)

ans = sum(p)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = list(map(int,input().split()))
for i in range(M):
    A[A.index(max(A))] /= 2
# print(A)
ans = 0
for x in A:
    ans += int(x)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import bisect


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

for _ in range(m):
    a_tmp = a.pop()
    a_tmp //= 2
    if(len(a)==0):a.append(a_tmp)
    else:
        if(a_tmp >= a[-1]):a.append(a_tmp)
        elif(a_tmp <= a[0]):a.insert(0,a_tmp)
        else:
            index = bisect.bisect_left(a,a_tmp)
            a.insert(index,a_tmp)


print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
from math import ceil

n,m=map(int,input().split())
a=list(map(int,input().split()))
goukei=sum(a)
sorta=sorted(a, reverse=True)
waribiki=0

for i in range(m):
  waribiki+=ceil(max(a)/2)
  ind=a.index(max(a))
  a[ind]//=2
print(goukei-waribiki)

Submission status: Time Limit Exceeded

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

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

sm = 0
for i in range(n):
    sm+=int(a[i])
print(sm)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

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

for w in range(M):
    max2=A.pop(N-1)/2
    #A[N-1]=A[N-1]/2
    #max=A[N-1]
    
    bisect.insort_left(A,max2)
    #print(A)

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

Submission status: Time Limit Exceeded

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

a = sorted(l, reverse=True)

for i in range(m):
    a[0] = a[0]//2
    a.sort(reverse=True)

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import math
goods, tickets = list(map(int, input().split()))
price = list(map(int, input().split()))

while tickets > 0:
    highest_index = price.index(max(price))
    highest = max(price)
    if not len(price) == 1:
        while highest_index == price.index(max(price)) and max(price)!=0:
            use = 1
            discount = math.floor(price[highest_index] / (2 ** use))
            if discount < highest:
                price[highest_index] = discount
                tickets -= use
            elif discount == 0:
                break
            else:
                use+=1
    else:
        discount = math.floor(price[highest_index] / (2 ** tickets))
        tickets = 0
        price[0] = discount
print(sum(price))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
*a, = sorted(map(int, input().split()), key=lambda x: -x)
for i in range(m):
    tmp = a.pop(0)
    tmp /= 2
    if len(a) == 0:
        a.append(tmp)
    for j in range(min(len(a), m-i)):
        if tmp > a[j]:
            a.insert(j, tmp)
            break
    else:
        a.append(tmp)

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

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    while m > 0:
        tmp = a.index(max(a))
        #print(tmp)
        a[tmp] = a[tmp] // 2
        m -= 1
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

a = sorted(a)

for i in range(m):
    a[n-1] = a[n-1] // 2
    temp = a.pop()
    bisect.insort_left(a, temp)

'''
    left = 0
    right = n-2
    mid = 0
    while left < right:
        mid = (left + right) // 2
        if a[mid] > temp:
            right = mid - 1
            if right == left:
                a.insert(right+1, temp)
        elif a[mid] < temp:
            left = mid + 1
            if right == left:
                a.insert(right, temp)
        else:
            a.insert(right, temp)
            break
'''
    
print(sum(a))

Submission status: Time Limit Exceeded

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

if n==1:
    for i in range(m):
        a[0]=int(a[0]/2)
    print(a[0])
    
else:
    a.sort(reverse=True)
    for i in range(m):
        a[0]=int(a[0]/2)
        if a[0]<=a[1]:
            tmp=a[1:]
            if tmp[-1]>a[0]:
                tmp.append(a[0])
                a=tmp
            else:
                for i in range(1,n-1):
                    if tmp[i]<a[0]:
                        tmp2=tmp[:i]
                        tmp2.append(a[0])
                        tmp2=tmp2+tmp[i:]
                        a=tmp2
                        break  
    print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
j=0
for i in range(M):
    A[A.index(max(A[:j+1]))]=A[A.index(max(A[:j+1]))]//2
    j=j+1
    if j==440:
        A.sort(reverse=True)    
        j=0
print(sum(A))

Submission status: Time Limit Exceeded

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

for i in range(M):
    tmp_index = A.index(max(A))
    A[tmp_index] = A[tmp_index] / 2
    
import math
B = [math.floor(A[i]) for i in range(len(A))]
print(sum(B))

Submission status: Time Limit Exceeded

Solution code:
l = list(map(int, input().split()))
prices = list(map(int, input().split()))

for i in range(l[1]):
    x = prices.index(max(prices))
    prices[x] = int(prices[x] / 2)

print(sum(prices))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

nm = input()
a = input()

nm = nm.split()
n = int(nm[0])
m = int(nm[1])
a = a.split()
a = [int(x) for x in a]


for i in range(m):
    index = np.argmax(a)
    a[index] = a[index]//2
output = sum(a)
print(output)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N,M=map(int,input().split())
A=list(map(int,input().split()))
for i in range(M):
    max_point = np.argmax(A)
    if A[max_point] == 0:
        break
    A[max_point] = int(A[max_point]/2)
print(sum(A))

Submission status: Time Limit Exceeded

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

def half(l):
  a=-1
  for i in range(len(l)):
    if l[i]==max(l):
      a=i
  l[a]=l[a]//2
  return(l)
for i in range(M):
  half(ls)
print(sum(ls))

Submission status: Time Limit Exceeded

Solution code:
'use strict'
import math
N, M = map(int, input().split())
goods_price_list = (list(map(int, input().split())))
goods_price_list.sort(reverse=True)

if len(goods_price_list) == 1:
  for i in range(M):
    goods_price_list[0] = math.floor(goods_price_list[0]/2)

else:
  for i in range(M):
    goods_price_list[0] = math.floor(goods_price_list[0]/2)
    
    if goods_price_list[0] < goods_price_list[1]:
      num = 1
      while goods_price_list[0] <= goods_price_list[num]:
        num += 1
        if num == len(goods_price_list):
          break

      goods_price_list.insert(num,goods_price_list[0])
      del goods_price_list[0]

print(sum(goods_price_list))

Submission status: Time Limit Exceeded

Solution code:
N, M= map(int,input().split())
A = [int(i) for i in input().split()]
for i in range(M):
    B = A.index(max(A))
    A[B] = A[B] // 2
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
a=input().split(' ')
b=input().split(' ')
m=int(a[1])
b=[int(x) for x in b]
while m>0:
    b[b.index(max(b))]=max(b)/2
    m-=1
print(str(sum([int(x) for x in b])))

Submission status: Time Limit Exceeded

Solution code:
n,m  =map(int,input().split())
a = [int(i) for i in input().split()]
a.sort()
ans = 0

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

for i in range(n):
	ans+=a[i]

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
#A = sorted(a,reverse=True)
ct=0
for i in range(m):
    j=a.index(max(a))
    a[j]=int(a[j]/2)
    ct+=1
print(sum(a))

Submission status: Time Limit Exceeded

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

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

def waribiki(X,Y):
    return X//(2**Y)

while M>0:
    maxIdx = A.index(max(A))
    A[maxIdx] = waribiki(A[maxIdx],1)
    M -= 1
    

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import math
def main():
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    for _ in range(M):
        A[A.index(max(A))] = math.floor(A[A.index(max(A))]-(max(A)/2))
    print(sum(A))
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def mmm(li):
    li[li.index(max(a))]//=2

n,m = map(int,input().split())
a=  list(map(int,input().split()))
[mmm(a) for i in range(m)]
print(sum(a))

Submission status: Time Limit Exceeded

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

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

print(sum)

Submission status: Time Limit Exceeded

Solution code:
I = list(map(int,input().split()))
N = I[0]
M = I[1]
A = list(map(int,input().split()))
for i in range(M):
    num = A.index(max(A))
    A[num] = A[num] / 2
ans = 0
A = list(map(int,A))
ans = sum(A)
print(ans)

Submission status: Time Limit Exceeded

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

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


for i in range(M):
    A.sort()
    mtmp = max(A)
    insert_index = bisect.bisect_left(A, mtmp)
    A[insert_index] = mtmp // 2

print(sum(A))

Submission status: Time Limit Exceeded

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

tmp = a[:m]
for _ in range(m):
    maximum = tmp.index(max(tmp))
    tmp[maximum] = tmp[maximum] // 2

print(sum(tmp + a[m:]))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

if len(X) == 1:
    X[0] //= pow(2, M)
else:
    l = np.argsort(X) [::-1][:2]
    m = np.ceil(np.log2(X[l[0]])) - np.ceil(np.log2(X[l[1]]))
    if m >= M:
        X[l[0]] //= pow(2, M)
    elif m > 0:
        X[l[0]] //= pow(2, m)
    M -= m
    while M > 0:
        m = np.argmax(X)
        X[m] //= 2
        M -= 1
print(int(sum(X)))

Submission status: Time Limit Exceeded

Solution code:
import math
N, M = map(int,input().split())
A = list(map(int,input().split()))
ans = sum(A)
A.sort()
for i in range(M):
    ans = ans - math.ceil(A[N-1]/2)
    A.append(math.floor(A[N-1]/2))
    A.remove(A[N-1])
    A.sort()
print(ans)

Submission status: Time Limit Exceeded

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

for i in range(d):
    t = a.index(max(a))
    a[t] = a[t]//2
    if max(a) == 0:
        break
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import math
import numpy as np

n, m = map(int, input().split())
prices = np.array(list(map(int, input().split())))

for _ in range(m):
    max_index = np.argmax(prices)
    prices[max_index] = prices[max_index] / 2

total = 0
for price in prices:
    total += math.floor(price)

print(total)

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect_left
import sys

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

if N == 1:
    for i in range(M):
        A[0] = A[0] // 2
    print(sum(A))
    sys.exit()

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: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
lista = [int(i) for i in input().split()]
lista.sort()

dic = {}
for i in range(31):
    dic[i] = []

i2 = 0

for i in range(len(lista)):
    while(lista[i]>=2**(i2+1)):
        i2+=1
    dic[i2].append(lista[i])
    
#print(dic)

end = False
for t in range(i2,0,-1):
    list_d = dic[t]
    list_d.sort()
    loop = len(list_d)
    for i in range(loop):
        tmp = list_d[-1]
        dic[t-1].append(tmp/2)
        list_d =  list_d[:-1]
        m = m-1
        if m==0:
            end = True
            dic[t] = list_d
            break
    
    dic[t] = list_d
    if end == True:
        break
        
        
"""print(dic)
print(m)"""
ans = 0
if m > 0:
    ans = n-m
    if ans >= 0:
        print(n-m)
    else:
        print(0)
else:
    for i in range(t+1):
        list_d = dic[i]
        #print(i,list_d)
        for l in range(len(list_d)):
            tmp = list_d[l]
            ans+=int(tmp)
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
a = list(map(int, input().split()))
ans = sum(a)
for _ in range(M):
    m = max(a)
    l = m // 2
    ans -= m - l
    if ans == 0:
        break
    if len(a) > 1:
        a.remove(m)
        a.append(l)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

for i in range(M):
  #print(A)
  idx = np.argmax(A)
  A[idx] //= 2

print(np.sum(A))

Submission status: Time Limit Exceeded

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

for i in range(M):
    A[N-1] //= 2
    A.sort()

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
ss = input().split()
N = int(ss[0])
M = int(ss[1])

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

for i in range(M):
  As[As.index(max(As))] = int(As[As.index(max(As))] / 2)
print(sum(As))

Submission status: Time Limit Exceeded

Solution code:
import math
N, M = map(int, input().split())
AA = [int(a) for a  in input().split()]

for x in range(M):
    maxind = AA.index(max(AA))
#     print("max ind: ", maxind, " value: ",max(AA), " in ", AA)
    AA[maxind] = AA[maxind]/2

goukei = 0

for Ai in AA:
    goukei += math.floor(Ai)
#     print(Ai, math.floor(Ai))

print(goukei)

Submission status: Time Limit Exceeded

Solution code:
import bisect
N, M = list(map(int, input().split(' ')))
As = list(map(int, input().split(' ')))
As = sorted(As)
trimeed = len(As) - 1
for i in range(M):
    hoge = As.pop(-1) // 2
    while As and not As[0]:
        As.pop(0)
    bisect.insort(As, hoge)
print(sum(As))