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:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline
from decimal import Decimal

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

from heapq import heappush, heappop, heapify

heapify(a)
for i in range(m):
    tmp_min = heappop(a)/2
    heappush(a,tmp_min)

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline
from decimal import Decimal

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

trans = lambda x : Decimal(x) * (-1)

a = list(map(trans,a))

from heapq import heappush, heappop, heapify

heapify(a)
for i in range(m):
    j = heappop(a)/2
    heappush(a,j)

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

Submission status: Time Limit Exceeded

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

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

    print(sum(a_list))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    n, m = map(int, input().split())
    a_list = list(map(int, input().split()))
    sorted_a_list = sorted(a_list, reverse=True)

    for _ in range(m):
        sorted_a_list[0] = int(sorted_a_list[0]/2)
        sorted_a_list = sorted(sorted_a_list, reverse=True)

    print(sum(sorted_a_list))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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


for i in range(m):
    j = a.index(max(a))
    a[j] = int(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[-1] = int(max(a)/2)
        a.sort()

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect_right

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

for i in range(m):
  tmp = aa[-1]//2
  aa.pop()
  pos = bisect_right(aa,tmp)
  aa.insert(pos,tmp)
  
print(sum(aa))

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(A)
    y=A.index(max(A))
    A[y]=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()


import bisect
import math

for i in range(m):
  maxx=math.floor(a[-1]/2)
  a.pop(-1)
  a.insert(bisect.bisect_left(a,maxx),maxx)

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()
for i in range(m):
    nex_num = a[-1] // 2
    del a[-1]
    a.insert(bisect.bisect_left(a, nex_num), nex_num)
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_max = max(a)
    del a[a.index(tmp_max)]
    a.append(tmp_max // 2)
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(m):
    tmp_max = heapq.nlargest(1, a)[0]
    del a[a.index(tmp_max)]
    a.append(tmp_max // 2)
print(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):
    A.sort()
    A[-1] /= 2

print(sum(list(map(math.floor, A))))

Submission status: Time Limit Exceeded

Solution code:
import bisect
n,m = map(int,input().split())
A = [-int(i)for i in input().split()]
A.sort()
for _ in range(m):
    a = -((-A.pop(0)) //2)
    A.insert(bisect.bisect_left(A,a),a)
print(-sum(A))

Submission status: Time Limit Exceeded

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

list_a = list(A)
list_a.sort()
list_a.reverse()
# print(list_a)

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

print(sum(list_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(1)][0]
A.sort(reverse=True)
high = A[0:M]
low = A[M:]

while M != 0:
    high[0] = high[0] // 2
    high.sort(reverse=True)
    M -= 1

print(sum(high) + sum(low))

Submission status: Time Limit Exceeded

Solution code:
import bisect
N , M = map(int,input().split())
A = [int(i) for i in input().split()]
A.sort()
for _ in range(M):
    a = A.pop(-1) >> 1
    A.insert(bisect.bisect_left(A,a),a)
print(sum(A))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print(yen)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = list(map(float, input().split()))
for i in range(M):
    A = sorted(A)
    A[-1] /= 2
yen = 0
for i in range(N):
    yen += int(A[i])

print(yen)

Submission status: Time Limit Exceeded

Solution code:
import bisect
from collections import deque
import math 
n,m = map(int,input().split())
a = sorted(deque(map(int, input().split())))
for i in range(m):
    p = a.pop()
    p = math.floor(p/2)
    index = bisect.bisect_left(a,p)
    a.insert(index,p)
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import math

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

for _ in range(M):
  max_i = 0
  max_a = 0
  for i,a in enumerate(A):
    if max_a <= a:
      max_i = i
      max_a = a
  A[max_i] /= 2
print(sum(math.floor(a) for a in A))

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect_left

n,m = map(lambda x: int(x), input().split())
a = sorted(map(lambda x: int(x),input().split()))

for i in range(m):
    a.insert(bisect_left(a,a[n-1] // 2),a[n-1] // 2)
    a.pop(n)
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect_left

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

for i in range(m):
    x = bisect_left(a,a[n-1] // 2)
    a.insert(x,a[n-1] // 2)
    a.pop(n)
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
def main():
    import bisect
    import math
    import sys

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    import bisect
    import math
    import sys

    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    a.sort()
    for i in range(m):
        tmp=a[n-1]//2
        a.insert(bisect.bisect_left(a,tmp),tmp)
        a.pop(n)
    print(sum(a))

if __name__ == '__main__':
    main()

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()))
for i in range(M):
    A = sorted(A,reverse=True)
    A[0] //= 2
print(sum(A))

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

Submission status: Time Limit Exceeded

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

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

for _ in range(M):
    maximum = A.pop()
    insort_left(A, maximum>>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):
  A=sorted(A)
  A[len(A)-1]=A[len(A)-1]//2
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np
sys.setrecursionlimit(10**6)
def MAP(): return [int(s) for s in input().split()]

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

N, M = MAP()
A = MAP()

while M > 0:
	A[np.argmax(A)] = A[np.argmax(A)] // 2
	M -= 1

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

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

# 複数個の数値を、intの配列として取得
A = list(map(int, input().split()))
A.sort()

for i in range(M):
    d = A.pop(-1)/2
    bisect.insort_left(A,d)

ans=0
for i in range(N):
    ans+=math.floor(A[i])

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import bisect

n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
for i in range(m):
    x = a.pop()
    bisect.insort(a, x // 2)
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import math


def main():
    n, m = map(int, input().split())
    a_list = list(map(int, input().split()))

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

    ans = 0
    for a in a_list:
        ans += math.floor(a)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
A = list(map(int,input().split()))
for i in range(m):
    k = A.index(max(A))
    A[k] //= 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()))

nA = np.array(A)
nA = np.sort(nA)

for i in range(M):
    a = nA[-1]//2
    nA = np.delete(nA, -1)
    idx = np.searchsorted(nA, a)
    nA = np.insert(nA, idx, a)

print(np.sum(nA))

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect_right

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

A.sort()

for i in range(M):
    a = A.pop()//2
    idx = bisect_right(A, a)
    A.insert(idx, a)

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[0] = A[0]//2
    if N>1 and A[0]<A[1]:
        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()))

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 = map(int, input().split())
A = list(map(int, input().split()))

A.sort(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:
N, M = map(int, input().split())
A = list(map(int, input().split()))

A.sort(reverse=True)

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

ans = 0
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()))

A.sort(reverse=True)

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math
import sys
n,m = map(int, input().split())
a = np.array(list(map(int, input().split())))
if m > sum(np.ceil(np.log2(a))):
  print(0)
  sys.exit()
used = 0
while used < m:
  i = a.argmax()
  a[i] = a[i]//2
  used +=1
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math
n,m = map(int, input().split())
a = np.array(list(map(int, input().split())))
used = 0
zero = np.zeros(a.shape)
while used < m:
  i = a.argmax()
  a[i] = a[i]//2
  used +=1
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math
n,m = map(int, input().split())
a = np.array(list(map(int, input().split())))
used = 0
zero = np.zeros(a.shape)
while used < m and not np.all(a==0):
  i = a.argmax()
  a[i] = a[i]//2
  used +=1
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import sys
input = sys.stdin.readline
n,m = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
for i in range(m):
    k = np.argmax(a)
    if a[k] == 0:
        break
    a[k] = int(a[k]/2)
ans = sum(a)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n,m = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
for i in range(m):
    k = np.argmax(a)
    if a[k] == 0:
        break
    a[k] = int(a[k]/2)
ans = sum(a)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

while cnt < M:
    a = max(A)
    A[A.index(a)] = a//2
    cnt += 1

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
A = list(map(int,input().split()))
L = [0]*M

for i in A:
    cnt = 0
    while i!=0 or cnt<M:
        d = i-i//2
        if min(L)<d: 
            L[L.index(min(L))] = d
            i//=2
            cnt+=1
        else:
            break

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

Submission status: Time Limit Exceeded

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

for i in A:
    cnt = 0
    while i!=0 or cnt<M:
        L.append(i-i//2)
        i//=2
        cnt+=1

L.sort(reverse=True)
print(sum(A)-sum(L[:M]))

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 i in range(M):
    t=A[-1]//2
    index=bisect.bisect_right(A,t)
    A=A[0:len(A)-1]
    A.insert(index,t)
    

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a = [int(_) for _ in input().split()]

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
idx=1
for i in range(M):
    value=0

    for m in range(idx):
        if A[m]>value:
            value=A[m]
            nidx=m
    if nidx+1==idx:
        idx+=1
        idx=min(idx,N)
    A[nidx]/=2

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

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
idx=1
for i in range(M):
    nidx=A[:idx].index(max(A[:idx]))
    if nidx+1==idx:
        idx+=1
    A[nidx]/=2

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
# 2019-11-18 17:34:23(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect_left as bi_l, bisect_right as bi_r, insort_left as in_l
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 


def main():
    n, m, *a = [int(x) for x in sys.stdin.read().split()]
    a.sort()

    for _ in range(m):
        highest = a.pop()
        in_l(a, highest // 2)
    
    print(sum(a))
    
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
# 2019-11-18 17:34:23(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 


def main():
    n, m, *a = [int(x) for x in sys.stdin.read().split()]

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


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
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]=int(A[i])
print(sum(A))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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()))
while m>0 and sum(a)>0:
  a[a.index(max(a))]=int(max(a)//2)
  m=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 and sum(a)>=0:
  a[a.index(max(a))]=int(max(a)//2)
  m=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:
  a[a.index(max(a))]=int(max(a)//2)
  m=m-1
print(sum(a))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

while M != 0:
  A.sort(reverse=True)
  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()))

for i in range(m):
  a.sort(reverse=True)
  a[0]=int((a[0]/2)//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):
  a[a.index(max(a))]=int((max(a)/2)//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()))

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

Submission status: Time Limit Exceeded

Solution code:
# 毎回ソートしても別にいいんじゃないの -> ダメでした

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

while m > 0:
    arr = list(sorted(arr))
    arr[-1] = arr[-1] // 2
    m -= 1

print(sum(arr))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
# 毎回ソートしても別にいいんじゃないの
n, m = map(int, input().split())
arr = list(map(int, input().split()))

while m > 0:
    arr = list(sorted(arr))[::-1]
    arr[0] = arr[0] // 2
    m -= 1

print(sum(arr))

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

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

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

sum = sum(s)
print(sum)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

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

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

sum = sum(s)
print(sum)

Submission status: Time Limit Exceeded

Solution code:
#powerful discount tickets
import bisect
n,m=map(int,input().split())
lists=list(map(int,input().split()))
lists=sorted(lists)
for _ in range(m):
    #m回この作業を繰り返す
    maxi=lists[-1]
    lists.remove(maxi)
    bisect.insort(lists,maxi/2)
ans=0
import math
for some in lists:
    ans+=math.floor(some)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
AS = list(map(int, input().split()))
for i in range(M):
    hi = max(range(N), key = lambda n : AS[n])
    AS[hi]//=2
print(sum(AS))

Submission status: Time Limit Exceeded

Solution code:
import math
import bisect

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

while M > 0:
  A.insert(bisect.bisect_left(A, A[-1]/2, hi=len(A)-1), A[-1]/2)
  A.pop(-1)
  M -= 1
  
A = list(map(math.floor, A))
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(reverse = True)

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

A = list(map(math.floor, A))
print(sum(A))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n,m =map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
before_discount = sum(a)
discount = 0
for _ in range(m):
    a_old =  a[0]
    a_new = a[0]//2
    a[0] = a_new
    discount = discount + (a_old-a_new)
    a.sort(reverse=True)
price = before_discount- discount
print(price)

Submission status: Time Limit Exceeded

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

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):
  idx = A.index(max(A))
  A[idx] = A[idx]//2

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math

def find_index(l, x, default=-1):
    return l.index(x) if x in l else default


def main():
    n,m = map(int, input().split())
    A = list(map(int, input().split()))
    for i in range(m):
        maximum = max(A)
        index = find_index(A,maximum)
        A[index] = int(math.floor(maximum/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()))
h=0
for i in range(m):
  a.sort()
  a[n-1]=a[n-1]/2
for j in range(n):
  h+=math.floor(a[j])
  
print(h)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
import numpy as np
def print_ans(N, M, input_line):
    """Test Case
    >>> print_ans(3, 3, "2 13 8")
    9
    >>> print_ans(4, 4, "1 9 3 5")
    6
    >>> print_ans(1, 100000, "1000000000")
    0
    >>> print_ans(10 ,1, "1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000")
    9500000000
    """
    ar = np.array(list(map(float, input_line.split())))
    for _ in range(M):
        max_tmp_arg = np.argmax(ar)
        ar[max_tmp_arg] = ar[max_tmp_arg] // 2
    print(int(np.sum(ar)))

if __name__ == '__main__':
    N, M = map(int, input().rstrip().split())
    input_line = input().rstrip()
    print_ans(N, M, input_line)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
while M > 0:
    M -= 1
    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)
while M > 0:
    M -= 1
    A[0] //= 2
    A.sort(reverse = True)
print(sum(A))

Submission status: Time Limit Exceeded

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

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

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

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
li_a = list(map(int, input().split()))
li_w = li_a
for i in range(m):
    li_w = sorted(li_w, reverse=True)
    li_w[0] = li_w[0] // 2

print(sum(li_w))

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
def main():
    N,M=map(int,input().split())
    A=sorted(list(map(int,input().split())))
    for i in range(M):
        A[N-1]=int(A[N-1]/2)
        A.sort()
    print(sum(A))
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from bisect import insort

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

for i in range(m):
	new_amax = a_s[-1] // 2
	a_s = a_s[:-1]
	insort(a_s, new_amax)

res = sum(a_s)
print(res)

Submission status: Time Limit Exceeded

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

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

res = sum(a_s)
print(res)

Submission status: Time Limit Exceeded

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

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

res = sum(a_s)
print(res)

Submission status: Time Limit Exceeded

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