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
import math
import numpy as np
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

N,M = map(int, sys.stdin.readline().split())
list_A = list(map(int, sys.stdin.readline().split()))
list_A.sort(reverse=True)

list_A_np = np.array(list_A)

for i in range(M):
    # list_A.sort(reverse=True)
    # idx_max = list_A.index(max(list_A))
    # list_A[idx_max] = int(list_A[idx_max]/2)

    # if(list_A[0] > list_A[1]):
    #     list_A[0] = int(list_A[0]/2)
    # else:
    #     list_A.sort(reverse=True)
    #     list_A[0] = int(list_A[0]/2)

    idx_max = list_A_np.argmax()
    list_A_np[idx_max] = int(list_A_np[idx_max]/2)

ans = 0

for i in range(N):
    # ans += list_A[i]
    ans += list_A_np[i]

print(ans)

Submission status: Time Limit Exceeded

Solution code:
s = input().split()
n = int(s[0])
m = int(s[1])
a_i = input().split()
a_i = [int(i) for i in a_i]
a_i.sort(reverse=True)
cnt = 1
if len(a_i) == 1:
  for j in range(m):
    a_i[0] = int(a_i[0] / 2)
else:
  while(cnt <= m):
    discount = int(a_i[0] / 2)
    while(discount > a_i[1]):
      discount = int(discount / 2)
      cnt += 1
    a_i[0] = discount
    cnt += 1
    a_i.sort(reverse=True)
print(sum(a_i))

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(n):
    while m > 0:
        a[i] = a[i] // 2
        a.sort(reverse = True)
        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 = sorted(a)
ans = 0

while True:
    if m <= 0:
        break
    a[-1] = a[-1] // 2
    if len(a) > 1 and a[-1] < a[-2]:
        a = sorted(a)
    m -= 1

ans = sum(a)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, m = list(map(int, input().split()))
lisA = [int(i) for i in input().split()]
#print(n, m)
#print(lisA)

lisA.sort()
half0 = lisA[n-1]
count = n-1
for i in range(m):
	if (count < 0):
		count = n-1
	if (lisA[count] < half0):
		lisA.sort()
		half0 = lisA[n-1]
		count = n-1
	lisA[count] /= 2
	count -= 1
answer = 0
for i in range(n):
	answer += int(lisA[i])
print(answer)

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int, input().split())
A = list(map(int, input().split()))
value = sum(A)
A.append(-10**9)

cards = M

for i in range(M):
    A = sorted(A,reverse=True)
    p = 0
    while A[p] == max(A) and cards >= 1:
        A[p] //= 2
        p += 1
        cards -= 1
    if cards == 0 or max(A) == 0:
        break

A.pop()
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import copy
def xx(x,y):
    return int(x/(2**y))
N,M = map(int, input().split())
A = list(map(int, input().split()))
AA = copy.deepcopy(A)
ti = list()
for n in range(N):
    ti.append(int(0))

for m in range(M):
    max = -1
    maxn = -1
    for n in range(N):
        if max < AA[n]:
            max = AA[n]
            maxn = n
    ti[maxn] += 1
    AA[maxn] = xx(A[maxn], ti[maxn])

s = 0
for a in AA:
    s += a

print(s)

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect
n,m,*a=map(int,open(0).read().split())
a.sort()
for i in range(m):
    tmp = a.pop()>>1
    if tmp >0:
        tmp_index = bisect(a,tmp)
        a.insert(tmp_index,tmp)
    elif a==[]:
        break
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

for i in range(M):
  c = A[N]/2
  insert_index = bisect.bisect_left(A,c)
  del A[N]
  A.insert(insert_index,c)

print(sum(map(int, A)))

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[69]:


#import copy
import numpy as np

N, M = map(int, input().split())
As = np.sort(np.array(list(map(int, input().split()))))[::-1]
"""
3 3
2 13 8

4 4
1 9 3 5
"""


# In[70]:


As


# In[71]:


#As[0] = As[0] // 2
#arg = 0
As[0] = As[0] // 2
for i in range(1, M):
    arg = np.argmax(As[:i+1])
    #print(arg)
    As[arg] = As[arg] // 2
    #As[:i+1] = np.sort(As[:i+1])[::-1]
    #As[0] = As[0] // 2


# In[72]:


#print(As)
print(sum(As))


# In[ ]:

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math

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]

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

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.pop(N-1)
        bisect.insort(A,a)

    A[N-1] //=2


print(sum(A))

Submission status: Time Limit Exceeded

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

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

print(sum(A))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = list(map(int,input().split()))
if N == 1:
  a = A[0]
  for j in range(M):
    a = a//2
  print(a)
elif N > 1:  
  for i in range(M):
    aa = A.index(max(A))
    A[aa] = A[aa]//2
  print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import  copy

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

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

Alist_B = copy.copy(Alist)
Alist_C = [1]*N

for i in range(0,M):
    temp = Alist_B.index(max(Alist_B))
    Alist_B[temp] = Alist[temp] // (2 ** Alist_C[temp])
    Alist_C[temp] +=1

ans = 0
for j in Alist_B:
    ans +=j

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 = sorted(a, reverse=True)
    a[0] = a[0] // 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))] /= 2
ans = list(map(int, A))
print(int(sum(ans)))

Submission status: Time Limit Exceeded

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

while m > 0:
    max_index = a.index(max(a))
    a[max_index] = math.floor(a[max_index] /2)
    m -=1

print(int(sum(a)))

Submission status: Time Limit Exceeded

Solution code:
import numpy

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

for _ in range(M):
    # i = A.index(max(A))
    i = A2.argmax()
    a=A2[i]>>1
    A2[i]=a

print(sum(A2))

Submission status: Time Limit Exceeded

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

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
master = list(map(int, input().split()))
merchandises = list(map(int, input().split()))

if (len(merchandises) == 1):
    merchandises.append(0)
else:
    merchandises.sort(reverse = True)

tmp = 0
for dc in range(master[1]):
    tmp = int(merchandises[0] / 2)
    merchandises[0] = tmp
    idx = 1
    exchange = False
    while(tmp < merchandises[idx]):
        merchandises[idx - 1] = merchandises[idx]
        idx += 1
        exchange = True
        if (idx == master[0]):
            break
    if (exchange):
        merchandises[idx - 1] = tmp

fullPrice = 0
for p in merchandises:
    fullPrice += p

print(fullPrice)

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):
  A.sort()
  A[N-1]=int(A[N-1]/2)
  
sum=0
for j in range(N):
  sum=sum+A[j]
  
print(sum)

Submission status: Time Limit Exceeded

Solution code:
import sys

A = [int(x) for x in input().split()]
#print(AB)
N = A[0]
M = A[1]
#print(N)
#print(M)
B = [int(x) for x in input().split()]
#print(B)

for i in range(M):
    max_index = B.index(max(B))
    B[max_index] = int(B[max_index] / 2)
    if sum(B) == 0:
        print(0)
        sys.exit()
    #print(B)
print(sum(B))

Submission status: Time Limit Exceeded

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

n, m = map(int, input().split())
l = [int(n) for n in input().split()]
arr = np.asarray(l)

for j in range(m):
    i = np.argmax(l)
    l[i] = int(l[i]/2)
    if l[i] <= 0:
        l.remove(l[i])
        if len(l) == 0:
            break

print(sum(l))

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):
    tem = a.index(max(a))
    a[tem] = math.floor(a[tem]/2)

print(sum(a))

Submission status: Time Limit Exceeded

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

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

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


while(M > 0):
    A.sort(reverse=True)
    k = min((A[0] // A[1]), M)
    A[0] = A[0] // (2 ** k)
    M -= k

print(sum(A))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
ans = 0
minV = 10**15
cnt = 0

while True:
    if m <= 0:
        break
    a[-1] = a[-1] // 2
    a = sorted(a)
    m -= 1

ans = sum(a)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():
     n,m=map(int,input().split())
     a=list(map(int,input().split()))
     firstone=a[0]
     dp=[firstone//(2**i) for i in range(m+1)]
     dpp=dp
     for i in a[1:]:
          tmp=[i//(2**j) for j in range(0,m+1)]
          dp=[_ + tmp[0] for _ in dp]
          for j in range(m+1):
               tmp2=[dpp[k]+tmp[j-k] for k in range(j+1)]
               dp[j]=min([dp[j]]+tmp2)
          dpp=dp
     print(min(dp))
     
if __name__=='__main__':
     main()

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
A = list(map(int, input().split()))
i=0
while i<m:
  i+=1
  t=A.index(max(A))
  A[t]=A[t]//2
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import bisect
n, m = map(int, input().split())
a = sorted([int(i) for i in input().split()])

for i in range(m):
    tmp = a.pop() // 2
    idx = bisect.bisect_left(a, tmp)
    a.insert(idx, tmp)

print(sum(a))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,K=[int(i) for i in input().split()]
A = list(map(int,input().split()))
A.sort(reverse=1)

for i in range(K) :
    A[0] = int(A[0]/2)
    A.sort(reverse=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()
while m>0:
    a[n-1]=a[n-1]//2
    if a[n-1]<a[n-2] and a[n-1]>=a[n-3]:
        a[n-1],a[n-2]=a[n-2],a[n-1]
    if a[n-1]<a[n-2] and a[n-1]<a[n-3]:
        a.sort()
    m=m-1
print(sum(a))

Submission status: Time Limit Exceeded

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

for i in range (m):
    cost=sorted(cost)
    cost[-1]=cost[-1]//2

print(sum(cost))

Submission status: Time Limit Exceeded

Solution code:
import bisect
n,m=map(int,input().split())
A=sorted(list(map(int,input().split())))
for i in range(m):
    b=A.pop(n-1)//2
    bisect.insort_left(A, b)
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==1000:
        A.sort(reverse=True)    
        j=0
print(sum(A))

Submission status: Time Limit Exceeded

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

for n in range(M):
    next_keep=[]
    max_price=que.pop(-1)
    half_price=max_price/2
    
    while  len(que)!=0 and que[-1]>half_price:
        next_keep.insert(0,que.pop(-1))
               
    que.append(half_price)
    if len(next_keep)!=0:
        que[len(que):len(que)]=next_keep
        
ans=0
for k in range(N):
    ans+=int(que[k])
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/python
# coding: UTF-8


#import scipy.optimize
import math

    
##################################################################

if __name__ == "__main__":

    Input = [input() for i in range(2)]
    N,M = list(map(int,Input[0].split()))
    A = list(map(int,Input[1].split()))
    A.sort(reverse=True)

    if N==1:
        Money = math.floor(A[0]/(2**M))
        print(Money)
    else:      
        Use = 0
        while Use < M:
            if A[0] == A[1]:
                Usenow = 1
                Use += Usenow
            else:
                Usenow = math.ceil(math.log2(A[0])-math.log2(A[1]))
                Use += Usenow
                if Use > M:
                    Usenow -= Use - M
                    Use = M
            temp = math.floor(A[0]/(2**Usenow))
            if temp >= A[1]:
                A[0] = temp
            else:
                for i in range(2,N):
                    if temp >= A[i]:
                        A[0:i-1] = A[1:i]
                        A[i-1] = temp
                        break
                    elif i == N-1:
                        A[0:N-1] = A[1:N]
                        A[N-1] = temp                        
                    else:
                        continue
        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)
    A[index] = A[index] * 0.5
A = np.floor(A)
print(int(A.sum()))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
list.sort(A, reverse=True)

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import sys
import bisect
inputs = sys.stdin.readlines()

N, M = map(int, inputs[0].split())
A = sorted(list(map(int, inputs[1].split())))

for _ in range(M):
    tmp = A.pop() // 2
    A.insert(bisect.bisect_left(A, tmp), tmp)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
if n == 1:
    a[0] //= 2**m
else:
    while m > 0:
        a[a.index(max(a))] //= 2
        m -= 1
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)
y = 1

if n == 1:
    print(a[0]//(2**m))
else:
    for i in range(m):
        if m < 1:
            a[0] = a[0]//(2**y)
            break
        if a[0]-a[0]//(2**y) > a[1]-a[1]//(2**y):
            a[0] = a[0]//(2**y)
            i -= 1
            m -= 1
        else:
            a[0] = a[0]//(2**y)
        a = sorted(a,reverse=True)
    
    print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import bisect
N,M=map(int,input().split())
l=list(map(int,input().split()))
sl=sorted(l)
for i in range(M):
	sl[len(sl)-1]=sl[len(sl)-1]//2
	tmp=sl.pop(len(sl)-1)
	bisect.insort(sl, tmp) 
else:
	print(sum(sl))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
if len(a) == 1:
    ans = a[0] * (0.5) ** m
    print(int(ans))
    exit()
while m > 0:
    a.sort(reverse=True)
    #print(m)
    plus = a[0] - a[0]//2
    ngtv = a[1] - a[1]//2
    if plus > ngtv:
        m -= 1
        a[0] = a[0]//2
    else:
        m -= 1
        a[1] = a[1]//2
    #print(a)
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import math
import sys

nm = list(map(int,input().split(" ")))
N = nm[0]
M = nm[1]

A = list(map(int,input().split(" ")))
A.sort(reverse=True)
hmax = math.floor(A[0]/2)
index = 0
while M > 0:
    if index != len(A):
        if A[index] >= hmax:
            A[index] = math.floor(A[index]/2)
            M = M -1
            index = index + 1
        else:
            index = 0
            A.sort(reverse=True)
            hmax = math.floor(A[0])
    else:
        index = 0
    if hmax == 0:
        print(0)
        sys.exit()
print(sum(A))

Submission status: Time Limit Exceeded

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



for j in range(M):
    idx = L.index(max(L))
    L[idx] = L[idx]//  2
    
print(sum(L))

Submission status: Time Limit Exceeded

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

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

print(sum(A))

Submission status: Time Limit Exceeded

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


if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

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

items = sorted(items)

for i in range(M):
    items[-1] = items[-1] // 2
    items = sorted(items)

print(sum(items))

Submission status: Time Limit Exceeded

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

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

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
n, m = tuple(map(int, input().split()))
a = sorted(list(map(int, input().split())))
for _ in range(m):
    a[-1] = int(a[-1]/2)
    a.sort()
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)
    
for j in range(N):
    A[j] = math.floor(A[j])

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n, m = map(int, input().split())
a = np.array(list([int(x) for x in input().split()]))

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

Submission status: Time Limit Exceeded

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

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import bisect
n,m = [int(i) for i in input().split()]
l = sorted([int(i) for i in input().split()])
[bisect.insort(l,l[n-1]//2) for _ in range(m)]
    
print(sum(l[0:n]))

Submission status: Time Limit Exceeded

Solution code:
import bisect

def irekae(lis):
    last=lis[-1]
    lis.pop(-1)
    index=bisect.bisect_left(lis,last)
    lis=lis[:index]+[last]+lis[index:]
    return lis


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

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

print(sum(a))

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
    index = bisect.bisect_left(a,a_tmp)
    a.insert(index,a_tmp)


print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n, m = map(int, input().split())
a = np.array([int(i) for i in input().split()])

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

print(a.sum())

Submission status: Time Limit Exceeded

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

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

Alist = [int(A) for A in Alist]
print(sum(Alist))

Submission status: Time Limit Exceeded

Solution code:
import sys
n,m=map(int,sys.stdin.readline().split())
a=sorted(list(map(int,sys.stdin.readline().split())))
for i in range(m):
    a[n-1]=a[n-1]//2
    for i in range(n-1):
        if a[-1-i]>a[-2-i]:
            break
        else:
            a[-1-i],a[-2-i]=a[-2-i],a[-1-i]
print(sum(a))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math

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]

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

Submission status: Time Limit Exceeded

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

print(sum(map(int, A)))

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:
n,m=map(int,input().split())

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

i=m
while i>0:
    ma=max(c)
    ind=c.index(ma)
    c[ind]=ma//2
    
    i-=1
    
print(sum(c))

Submission status: Time Limit Exceeded

Solution code:
import sys
n,m=map(int,sys.stdin.readline().split())
a=sorted(list(map(int,sys.stdin.readline().split())))
for i in range(m):
    a[n-1]=a[n-1]//2
    for i in range(n-1):
        if a[-1-i]>a[-2-i]:
            break
        else:
            a[-1-i],a[-2-i]=a[-2-i],a[-1-i]
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import bisect as bl
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
for i in range(M):
  tmp=A.pop(-1)
  tmp=tmp//2
  bl.insort(A,tmp)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
(_, M) = map(int, input().split())
A = list(map(int, input().split()))
for _ in range(M):
  i = A.index(max(A))
  A[i] = A[i]//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[-1] = a[-1] // 2
    a.sort()
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
n,m=list(map(int,input().split()))
a=list(map(int,input().split()))
for i in range(m):
  max_j=-1
  max=0
  for j in range(n):
    if(max<a[j]):
      max=a[j]
      max_j=j
  a[max_j]=a[max_j]//2
count=0
for i in range(n):
  count=count+a[i]
print(count)

Submission status: Time Limit Exceeded

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

A.sort(reverse=True)
#print(A)

B=A[0:min(N,M)]

for i in range(M):
    idx = B.index(max(B))

    B[idx] = int(B[idx] / 2.0)
#    A.sort(reverse=True)

ans = 0
for i in range(N):
    if i < len(B):
        ans+=B[i]
    else:
        ans += A[i]

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import bisect

N,M=map(int,input().split())
A=[int(_) for _ in input().split()]
A.sort()
for m in range(M):
    a=A.pop(-1)//2
    insert_index = bisect.bisect_right(A,a)
    A[insert_index:insert_index]=[a]
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math
n, m = input().split()
N = int(n)
M = int(m)

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

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

s = input().split()
N = int(s[0])
M = int(s[1])
A = np.array(list(map(int, input().split())))
# A = list(map(int, input().split()))

for i in range(M):
    # j = A.index(max(A))
    # j = A.argmax()
    A[A.argmax()] //= 2
    # A.sort()
    # A[N-1] //= 2

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

print(sum)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
L = list(map(int, input().split()))
L.sort(reverse=True)
for i in range(m):
  i = L.index(max(L))
  L[i] = int(L[i]*0.5)
print(sum(L))

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[-1] = A[-1]//2
  for j in range(N-1):
    if A[N-1-j] >= A[N-1-j-1]:
      continue
    else:
      temp = A[N-1-j]
      A[N-1-j] = A[N-1-j-1]
      A[N-1-j-1] = temp
      if A[N-1-j-1] <= A[N-1-j]:
        continue
      
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math

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

alog0=math.log2(alist[0])
alist_log=[]
diff_list=[]
for i in range(N):
  a=alist[i]
  alogi=math.log2(a)  
  alist_log.append(alogi)

#print(alist)
#print(alist_log)

tlist=[0]*N
while(M>0):
  max_value=max(alist_log)
  max_index=alist_log.index(max_value)
  
  alist_log[max_index]-=1
  tlist[max_index]+=1
  M-=1
#print(tlist)

answer=0
for i in range(N):
  answer+=alist[i]//(2**tlist[i])

print(answer)

Submission status: Time Limit Exceeded

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

a_list.sort(reverse=True)
swapped = False
while m > 0:
    a_list[0] = a_list[0] // 2
    m -= 1
    if (n > 1) and (a_list[0] < a_list[1]) and not swapped:
        temp = a_list[0]
        a_list[0] = a_list[1]
        a_list[1] = temp
        swapped = True
    else:
        a_list.sort(reverse=True)
        swapped = False

cost_sum = 0
for a in a_list:
    cost_sum += a

print(cost_sum)

Submission status: Time Limit Exceeded

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

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

print(sum(Alist))

Submission status: Time Limit Exceeded

Solution code:
N, M= map(int,input().split())
A = [int(i) for i in input().split()]
while M != 0:
    A[A.index(max(A))] = A[A.index(max(A))] // 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()))
while m > 0:
    m -= 1
    i = a.index(max(a))
    a[i] = a[i] // 2
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import sys
from bisect import bisect_left,bisect

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
n,m=map(int,input().split())

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

for i in range(m):
	A.insert(bisect_left(A,max(A)//2),max(A)//2)
	del A[n]
	
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
get1 = list(map(int, input().split()))
get2 = list(map(int, input().split()))
 
N = get1[0]
M = get1[1]
 
get2.sort()
 
for i in range(M):
 
  get2[N -1] = get2[N -1] // 2
  if get2[N -1] < max(get2):
    get2.sort()
  
print(sum(get2))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N,M=np.array(list(map(int, input().split())))
A=np.array(list(map(int, input().split())))
A=np.sort(A)[::-1]

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


print(np.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] = a[0] // 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()))
a.sort(reverse = True)
A = a[:m]
for i in range(m):
    A.sort(reverse = True)
    A[0] = A[0]//2
print(sum(A)+sum(a[m:]))