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 math
#=== swap ===
def swap(arr, i, j):
    arr[i], arr[j] = arr[j], arr[i]

#=== ヒープ（１次元のリストで表現） ===
class heap():

    #=== 初期化 ===
    def __init__(self, number_list):
        self.list = []
        for num in number_list:
            self.insert(num)

    #=== 挿入 ===
    def insert(self, num):
        self.list.append(num)

        # 上へ登りながら逆転を解消
        index = len(self.list)
        while(index!=1 and self.list[index-1]>self.list[(index//2)-1]):
            swap(self.list, index-1, (index//2)-1)
            index = index // 2

    #=== 最大値を取り出す ===
    def deletemax(self):
        if len(self.list) == 1:
            obj = self.list.pop(0)
            return obj
        obj = self.list[0] # 最小値（先頭）の取り出し
        self.list[0] = self.list.pop(-1) # 最後尾を先頭に持ってくる

        #=== 下へ辿りながら逆転を解消 ===
        index = 1
        while((len(self.list)>=index*2 and (self.list[index-1]<self.list[index*2-1]))
        or
        (len(self.list)>=index*2+1 and (self.list[index-1]<self.list[index*2]))):
        # 右側が小さい場合は右側と交換(鎮遠評価を利用)
            if (len(self.list)>=index*2+1 and self.list[index*2-1] < self.list[index*2]):
                swap(self.list, index-1, index*2)
                index = index*2+1
            else:
                swap(self.list, index-1, index*2-1)
                index = index*2
        return obj

    #=== sum ===
    def sum(self):
        sorted_list = [self.deletemax() for i in range(len(self.list))]
        sum = 0
        for i in sorted_list:
            sum += i
        return sum

N, M = tuple(map(int, input().split()))
A = list(map(int, input().split()))
heap = heap(A)
for i in range(M):
    max = heap.deletemax()
    heap.insert(math.floor(max/2))
print(heap.sum())

Submission status: Time Limit Exceeded

Solution code:
def main():
    number_of_goods,number_of_coupons = map(int,input().split())
    goods = list(map(int,input().split()))
    for i in range(number_of_coupons):
        goods = use_coupons(goods)
    print(sum(goods))

def use_coupons(goods):
    goods.sort(reverse=True)

    goods[0] = goods[0]//2
    return goods

main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N,M=map(int,input().split())
A=[int(x) for x in input().split()]
A.sort(reverse=True)

for i in range(0,M):
    A[0]=int(A[0]/2)
    flag=0
    while(flag!=1):
        for j in range(0,N-1):
            if(A[j]>A[j+1]):
                flag=1
                break
            else:
                tmp=A[j]
                A[j]=A[j+1]
                A[j+1]=tmp
        
print(sum(A))

Submission status: Time Limit Exceeded

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

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N,M=map(int,input().split())
A=[int(x) for x in input().split()]
A.sort(reverse=True)

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:

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

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

print(sum(A))

Submission status: Time Limit Exceeded

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

#a_L = list(sorted(a_L))
#max_num = a_L[0]
#a_L.append(max_num)

for val in range(0,m):
    a_L = list(sorted(a_L))
    a_L[-1] = a_L[-1] //2

print(sum(a_L))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
for m in range(M):
    A[0] = A[0] // 2
    A.sort(reverse=True)
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):
  x=a.index(max(a))
  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()))
import numpy as np

for i in range(m):
  np_a = np.array(a)
  x=np_a.argmax()
  a[x]//=2
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3

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

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

ans = sum(a_list)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3

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

for _ in range(M):
    max_diff = -float("inf")
    max_index = 0
    for i, a in enumerate(a_list):
        if a - (a // 2) > max_diff:
            max_diff = a - (a // 2)
            max_a = a // 2
            max_index = i
    a_list[max_index] = max_a

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()))
A_list.sort()
if N == 1:
    A_list[-1] = A_list[-1] // (2**M)
elif N > 1:
    while M > 0:
        A_list[-1] = A_list[-1] // 2
        if A_list[-1] < A_list[-2]:
            A_list.sort()
        M -= 1
print(sum(A_list))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(n):
    k = a[i]
    while(k):
        if(k%2==0):
            b.append(k//2)
            k = k//2
        else:
            b.append(k//2+1)
            k = k//2
        b.sort(reverse = True)
        if(len(b)>m):
            b.pop(len(b)-1)
    
    
sn = sum(b)

sna = sum(a)

print(sna-sn)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(M):
    x = max(a)
    a[a.index(x)]=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[a.index(max(a))]=max(a)//2
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
A=list(map(int,input().split()))
while(m>0):
    A=sorted(A,reverse=True)
    if n>1:
        while(A[0]>=A[1]):
            A[0]=A[0]//2
            m-=1
    else:
        A[0]=A[0]//2
        m-=1
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)
def binary_search(list,target): 

	result = -1
	left = 0
	right = len(list) - 1

	while left <= right:
		center = (left + right)//2
		if list[center] == target:
			result = center
			break
		elif list[center] < target:
			right = center - 1
		elif list[center] > target:
			left = center + 1
	if result == -1:
		return left
	else:
		return result

if N>1:
  for i in range(M):
    A[0]=A[0]//2
    if A[0]<A[1]:
      j=binary_search(A[1:],A[0])
      A=A[1:j+1]+[A[0]]+A[j+1:]
else:
  A[0]=A[0]//(2**M)
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)

if N>1:
  for i in range(M):
    A[0]=A[0]//2
    if A[0]<A[1]:
      j=1
      while j<N:
        if A[0]>A[j]:
          A=A[1:j]+[A[0]]+A[j:]
          break
        else:
          j+=1
      if j==N:
        A=A[1:]+[A[0]]
else:
  A[0]=A[0]//(2**M)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

while M > 0:
    a = A.pop()
    bisect.insort(A, a//2)
    M -= 1

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math
n,m = map(int,input().split())
a = list(map(int,input().split()))
SUM =0 
for i in range(m):#チケットの数
	a[np.argmax(a)] /= 2

for i in range(len(a)):
	a[i] = math.floor(a[i])
	SUM += a[i]
print(SUM)

Submission status: Time Limit Exceeded

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

for i in range(m):#チケットの数
	a[np.argmax(a)] /= 2

for i in range(len(a)):
	a[i] = math.floor(a[i])

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
from collections import deque

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

while M > 0:
    a = max(A)
    A.remove(a)
    A.append(a//2)
    M -= 1

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math
n,m = map(int,input().split())
a = [0]*n
a = input().split()

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

for i in range(m):#チケットの数
	a[np.argmax(a)] /= 2

for i in range(len(a)):
	a[i] = math.floor(a[i])

print(sum(a))

Submission status: Time Limit Exceeded

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

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

T = 0
for i in A:
    T += i

print(T)

Submission status: Time Limit Exceeded

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

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

T = 0
for i in A:
    T += i

print(T)

Submission status: Time Limit Exceeded

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

for i in range(M):
    max = 1
    maxj = 0
    for j in range(N):
        if max < A[j]:
            max = A[j]
            maxj = j
    A[maxj] = max // 2

T = 0
for i in A:
    T += i

print(T)

Submission status: Time Limit Exceeded

Solution code:
num_line=input().rstrip().split(" ")
times=int(num_line[0])
num=int(num_line[1])

price_line= list(map(int, input().split()))
#print(price_line)
for i in range(num):
    price_line.sort(reverse=True)
    price_line[0]//=2

summ=0
for i in range(times):
    summ+=price_line[i]
    
print(summ)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N,M=map(int,input().split()) #N個の商品、M枚の割引券
A=np.array(input().split(),dtype=int) #i番目に買う値段はA[i]円
for i in range(M):
    A[np.argmax(A)]//=2
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split()) #N個の商品、M枚の割引券
A=list(map(int,input().split())) #i番目に買う値段はA[i]円

for i in range(M):
    A[A.index(max(A))]//=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()
  a[a.index(max(a))]//=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()
for i in range(m):
  a[a.index(max(a))]//=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[a.index(max(a))]//=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)
for i in range(m):
  a[a.index(max(a))]//=2
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
"""ABC141C.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1KjTnXzjTYGekJQp4Cj4bBKVUKkYLEzG9
"""

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

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

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

print(sum(list_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[a.index(max(a))]//=2
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys


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


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


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


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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys


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


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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(M):
  A_max = A[-1]
  if A_max==0: break
  A[-1] //= 2
  A = sorted(A)
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_max = max(A)
  if A_max==0:break
  A[A.index(A_max)] = A_max//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_max = max(A)
  A[A.index(A_max)] = A_max//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()

while m:
    a[n-1] //= 2
    a.sort()
    m -= 1
    
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import sys

N, M = [int(n) for n in sys.stdin.readline().strip().split()]
ans = [int(n) for n in sys.stdin.readline().strip().split()]
ans.sort()

for _ in range(M):
  ans[-1] //= 2
  ans.sort()
  # if ans[-1]<ans[-2]:
  #   ans[-1], ans[-2] = ans[-2], ans[-1]
print(sum(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):
    max_a = max(a)
    a.append(max_a / 2)
    a.remove(max_a)

res_list = [int(_) for _ in a]
print(sum(res_list))

Submission status: Time Limit Exceeded

Solution code:
n,m=(int(x) for x in input().split())
import math as math
import numpy as np

ans = 0
A = [int(x) for x in input().split()]

for i in range(m):
    A.sort()
    A [-1] = A[-1]/2
for i in range(n):
   A[i] =  math.floor(A[i]) 
   ans += A[i]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,m=(int(x) for x in input().split())
import math as math
import numpy as np


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

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

Submission status: Time Limit Exceeded

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

import numpy as np
for i in range(M):
  A[np.argmax(np.array(A))] //= 2
print(sum(A))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(M):
    tmp = A.index(max(A))

    A[tmp]=A[tmp]//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()
    A[N-1]=A[N-1]//2

print(sum(A))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(sum(A)*-1)

Submission status: Time Limit Exceeded

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

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

ans = 0
for a in A:
  ans += a*-1
print(ans)

Submission status: Time Limit Exceeded

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

A = sorted(A, reverse=True)

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

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

print(ans)

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()
    A[-1] = A[-1] // 2
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:

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

dp = [[0]*(M+1) for _ in range(N+1)]

for product_num in range(N):
    for ticket_num in range(M+1):
        price_caditate_list = []
        for use_num in range(ticket_num+1):
            price_caditate_list.append(dp[product_num][ticket_num-use_num] + (A[product_num]>>use_num))
        dp[product_num+1][ticket_num] = min(price_caditate_list)

print(dp[N][M])

Submission status: Time Limit Exceeded

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

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

while M > 0:
    num = lis.index(max(lis))
    lis[num] = int(lis[num] / 2)
    M -= 1

sum = 0

for i in range(len(lis)):
    sum += lis[i]
print(sum)

Submission status: Time Limit Exceeded

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

for i in range(m):
    maxIndex = 0
    for j in range(n):
        if a[maxIndex] < a[j]:
            maxIndex = j
    a[maxIndex] = a[maxIndex] >> 1
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):
    maxIndex = 0
    for j in range(n):
        if a[maxIndex] < a[j]:
            maxIndex = j
    a[maxIndex] //= 2
print(sum(a))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
n, m = map(int, input().split())
price = list(map(int, input().split()))
while m > 0:
    for i in range(n):
        if price[i] == max(price):
            price[i] = math.floor(price[i]/2)
            m -= 1
            break
print(sum(price))

Submission status: Time Limit Exceeded

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

while M>0:
    max_A = max(A)
    ind = A.index(max_A)
    A[ind] = A[ind]//2
    M = M-1
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

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

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

print(sum(Alist))

Submission status: Time Limit Exceeded

Solution code:
def main():
    N, M, *A = map(int, open(0).read().split())
    
    for i in range(M):
        A = sorted(A)
        A[-1] = A[-1]//2

    print(sum(A))

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

for _ in range(m):
    p = a.pop()
    a.append(waribiki(p,1))
    a.sort()

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
def main():
    N, M, *A = map(int, open(0).read().split())
    
    for i in range(M):
        maxA = max(A)
        A[A.index(maxA)] = maxA // 2

    print(sum(A))

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
inp_list = list(map(int, input().split()))
n = inp_list[0]
m = inp_list[1]
item_list = list(map(int, input().split()))
for i in range(m):
    max_num = max(item_list)
    item_list[item_list.index(max_num)] = max_num//2

print(sum(item_list))

Submission status: Time Limit Exceeded

Solution code:
inp_list = list(map(int, input().split()))
n = inp_list[0]
m = inp_list[1]
item_list = list(map(int, input().split()))
for i in range(m):
    item_list[item_list.index(max(item_list))] = max(item_list)//2

print(sum(item_list))

Submission status: Time Limit Exceeded

Solution code:
inp_list = list(map(int, input().split()))
n = inp_list[0]
m = inp_list[1]
item_list = list(map(int, input().split()))
for i in range(m):
    item_list.sort(reverse=True)
    item_list[0] = item_list[0]//2

print(sum(item_list))

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

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(sum(a))

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
A = sorted(A)[::-1]
res = 0
for x in A:
    res += x
for m in range(M):
    tmp = sorted(A[:m+1])[::-1]
    k = tmp[0]
    tmp[0] = int(tmp[0]/2)
    l = tmp[0]
    tmp.extend(A[m+1:])
    A = tmp
    res -= k-l

print(res)

Submission status: Time Limit Exceeded

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

B = list()
for n in range(len(A)):
    B.append([n,A[n]])
B = sorted(B, key=lambda x:x[1])
for m in range(M):
    B[-1][1] = int(B[-1][1]/2)
    B = sorted(B, key=lambda x:x[1])
res = 0
for x in B:
    res += x[1]
print(res)

Submission status: Time Limit Exceeded

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

for m in range(M):
    argmax = 0
    tmp = 0
    for n in range(len(A)):
        if A[n] >= tmp:
            argmax = n
            tmp = A[n]
    A[argmax] = int(A[argmax]/2)
res = 0
for x in A:
    res += x
print(res)

Submission status: Time Limit Exceeded

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

N,M = map(int, input().split())
item = list(map(int, input().split()))
item = sorted(item, reverse=True)

for i in range(M):
    item[0]=int(item[0]/2)
    item = sorted(item, reverse=True)

print(sum(item))

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
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: Time Limit Exceeded

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):
    A.sort(reverse=True)
    A[0]=cheap(A[0],1)
    i+=1

for i in range(0,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()))
for i in range(m):
	target = max(a)	
	a[a.index(target)] = target // 2
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

N, M = map(int, stdin.readline().split())

A = list(map(int, stdin.readline().split()))

A.sort(reverse = True)

for i in range(M):
    A[0] = int(A[0]/2)

    for i in range(N-1):

        if A[i] < A[i+1]:
            temp = A[i]
            A[i] = A[i+1]
            A[i+1] = temp
        else:
            break


ans = sum(A)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

N, M = map(int, stdin.readline().split())

A = list(map(int, stdin.readline().split()))

A.sort(reverse = True)

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

ans = sum(A)
print(ans)

Submission status: Time Limit Exceeded

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
    tab[j] = round(((tab[j]//2)))
    k = tab.pop(len(tab)-1)
    while (j > 0 and k < tab[j - 1]):
        j-=1
    tab.insert(j,k)
print(sum(tab))

Submission status: Time Limit Exceeded

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):
    tab[len(tab) - 1] = ((tab[len(tab)-1]/2) )
    tab =sorted(tab)

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

print(sum(tab))

Submission status: Time Limit Exceeded

Solution code:
ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(map(int, input().split()))

import numpy as np
n,m = mi()
a = np.array(li())

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

print(np.sum(a))

Submission status: Time Limit Exceeded

Solution code:

import math

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

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

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
numbers =input().rstrip().split(" ")
prices=input().rstrip().split(" ")
noa =int(numbers[0])
noc =int(numbers[1])
for i in range(noa):
  prices[i] =int(prices[i])
prices=sorted(prices ,reverse=True)
for i in range(noc):
  prices[0]=prices[0]//2
  prices=sorted(prices ,reverse=True)
answer=0
for i in range(noa):
  answer=answer+prices[i]
print(answer)

Submission status: Time Limit Exceeded

Solution code:
numbers =input().rstrip().split(" ")
prices=input().rstrip().split(" ")
noa =int(numbers[0])
noc =int(numbers[1])
for i in range(noa):
  prices[i] =int(prices[i])
#sort max//2を求めてからsort repeat
#loop content
prices=sorted(prices ,reverse=True)
#print(prices)
for i in range(noc):
  prices[0]=prices[0]//2
  prices=sorted(prices ,reverse=True)
#print(prices)
answer=0
for i in range(noa):
  answer=answer+prices[i]
print(answer)