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:
n, m = map(int, input().split())
lst = [int(i) for i in input().split()]
for x in range(m):
    lst.sort()
    lst[-1] //= 2
print(sum(lst))

Submission status: Time Limit Exceeded

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

As=sorted(A, reverse=True)

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

print(sum(As))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

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

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

for _ in range(M):
    waribiki_item = A.pop(-1)
    bisect.insort(A, waribiki_item//2)
    
print(sum(A))

Submission status: Time Limit Exceeded

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

a=sorted(a)
if n==1:
  for i in range(m):
    a[0]=a[0]/2
else:
  for i in range(m):
    if a[n-2]>a[n-1]:
      a=sorted(a)
    a[n-1]=a[n-1]/2

ans=0
for j in range(n):
  ans=ans+int(a[j])
  
print(ans)

Submission status: Time Limit Exceeded

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

def main():
    n, m = map(int, input().split())
    a = [int(i) for i in input().split()]
    a.sort()

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

    print(sum(a))

main()

Submission status: Time Limit Exceeded

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

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

print(sum(a))

Submission status: Time Limit Exceeded

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

As = input().split()
A = [0]*N

for n in range(N): 
  A[n] = float(int(As[n]))
A.sort()

for m in range(M):
  
  midx = 0
  mval = 0
  for n in range(N):
    if mval<A[n]:
      mval = A[n]
      midx = n
  A[midx]=A[midx]/2.0
  
Asum = 0
for n in range(N):
  Asum += int(A[n])
print(Asum)

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 = [i for i in map(int,input().split())]

for i in range(M):
    max_idx = A.index(max(A))
    A[max_idx] = A[max_idx]/2
    
ans = 0
for i in map(int,A):
    ans+=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):
    A[A.index(max(A))] //= 2

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import  bisect

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

for i in range(M):
  a = pri[-1] // 2
  pri.pop()
  bisect.insort(pri,a)

ans = sum(pri)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

# In[19]:


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


# In[20]:


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


# In[ ]:

Submission status: Time Limit Exceeded

Solution code:
import bisect
n, m = map(int, input().split())
a = list(map(int, input().split()))
l = len(a)
a.sort()

for i in range(m):
    x = a.pop(l-1)
    x = x / 2
    bisect.insort(a, x)



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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
n, m = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
sorted_a = sorted(a, reverse=True)
for i in range(m):
    sorted_a[0] = math.floor(sorted_a[0]/2)
    new_a = sorted(sorted_a, reverse=True)
    sorted_a = new_a
print(sum(sorted_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):
    saidai = a.pop()
    sounyu = saidai // 2
    bisect.insort(a, sounyu)

print(sum(a))

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)

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

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):
  if A[N-1] == 0:
    break
  A[N-1] >>= 1
  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()))  # 品物の値段
list.sort(A)
for _ in range(M):
    tmp = max(A)
    A[A.index(tmp)] = tmp // 2
print(str(sum(A)))

Submission status: Time Limit Exceeded

Solution code:
num ,m =map(int,input().split())
arr = list(map(int,input().split()))

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


print(sum(arr))

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[-1] = A[-1] // 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] //= 2
    for j in range(1, n):
        if a[-j] > a[-j - 1]:
            break
        a[-j], a[-j - 1] = a[-j - 1], a[-j]
print(sum(a))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import math
n_m_str = input()
n_m = n_m_str.split(" ")
N = int(n_m[0])
M = int(n_m[1])

a_str = input()
a_s = a_str.split(" ")
a_list = []
for a in a_s:
    a_list.append(int(a))
for i in range(M):
    a_list.sort(reverse=True)
    a_list[0] /= 2
sum = 0
for i in a_list:
    sum += math.floor(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):
    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()))
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:
import bisect

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

for i in range(m):
    x = a[-1]
    a.remove(x)
    x //= 2
    insert_index = bisect.bisect_left(a, x)
    a.insert(insert_index, x)
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[-1] = a[-1] // 2
    a = sorted(a)
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import math


def max_index(list):
    r = -1
    max = 0
    for i in range(len(list)):
        v = list[i]
        if v > max:
            max = v
            r = i
    return r


def use_coupon(a):
    index = max_index(a)
    a[index] /= 2


def sum(a):
    s = 0
    for v in a:
        s += math.floor(v)
    return s


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

for i in range(m):
    use_coupon(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):
    maxA = max(A)
    A.remove(maxA)
    maxA = maxA // 2
    A.append(maxA)

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()
tmp = A.pop(-1)
index = 0
for _ in range(M):
  tmp //= 2
  index = bisect.bisect_left(A,tmp)
  if index < N - 1:
    A.insert(index, tmp)
    tmp = A.pop(-1)
A.append(tmp)

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[n-1] = a[n-1] // 2
    a.sort()
print(sum(a))

Submission status: Time Limit Exceeded

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

def main():
    N,M=map(int,input().split())
    A = list(map(int, input().split()))
    A.sort()
    while M>0:
        a = A.pop()
        a //= 2
        M -= 1
        bisect.insort(A, a)
    print(sum(A))

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] //= 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 _ in range(M):
    A[0]=int(A[0]//2)
    buf=A[0]
    if N>2:
        i=1
        while buf<A[i]:
            A[i-1]=A[i]
            i+=1
            if i==N:
                break
        A[i-1]=buf
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math

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

A_list.sort()
while M > 0:
    A_list[-1] = math.floor(A_list[-1] / 2)
    if len(A_list) > 1 and A_list[-1] < A_list[-2]:
        A_list.sort()
    M -= 1

print(sum(A_list))

Submission status: Time Limit Exceeded

Solution code:
def main():
    n, m = (int(i) for i in input().split(' '))

    objs = [int(i) for i in input().split(' ')]

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

    print(sum(objs))


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

a.sort()

for i in range(m):
    div_a = a.pop(-1)
    div_a = div_a // 2
    insert_index = bisect.bisect_left(a, div_a)
    a.insert(insert_index, div_a)

ans = sum(a)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = [int(a) for a in input().split()]
A = sorted(A)
for _ in range(M):
    A[-1] = int(A[-1] * 0.5)
    A = sorted(A)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
la=list(map(int,input().split()))
#la.sort()
for i in range(M):
    la.sort()
    la[N-1]/=2
ans=0
for i in range(N):
    ans+=int(la[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 _ in range(m):
    tgt = a.pop(-1)
    tgt //= 2
    bisect.insort(a, tgt, lo=max(0, (n-m)))

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect_left

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

for i in range(M):
    x = A.pop(-1)
    x //= 2
    A.insert(bisect_left(A, x), x)

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:
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import bisect
import sys
input = sys.stdin.readline

setrecursionlimit(1000000)


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

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

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

print(sum(A))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
A_sorted = sorted(A, reverse=True)
for i in range(M):
    A_sorted[0] = (A_sorted[0])/2
    A_sorted = sorted(A_sorted, reverse=True)

ans = 0
for i in range(N):
    ans += A_sorted[i]//1
    
print(int(ans))

Submission status: Time Limit Exceeded

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

import numpy as np
A=np.array(a_list)
counts=[0]*N
for i in range(M):
    max_id=np.argmax(A)
    A[max_id] /=2
    counts[max_id]+=1

    money=0
for x,y in zip(a_list,counts):
    money+=int(x/2**y)
print(money)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
for j in range(m):
  a[0] //= 2
  a.sort(reverse=True)
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()))
C = np.array(A)
for i in range(M):
  p = np.argmax(C)
  C[p] = int(C[p]/2)
print(sum(C))

Submission status: Time Limit Exceeded

Solution code:
import bisect
n,m = input().split(' ')
n = int(n)
m = int(m)
a = [0]*n
for i,x in enumerate(input().split(' ')):
    a[i] = int(x)
a = sorted(a)
for i in range(m):
    a[-1]//=2
    index = bisect.bisect_left(a[:-1],a[-1])
    ngo = a[-1]
    a = a[:-1]
    a.insert(index,ngo)
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
##############################

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

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import bisect
n,m=map(int,input().split())
A=list(map(int,input().split()))
for _ 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):
  s = a.index(max(a))
  a[s] = int(a[s] / 2)

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()]

A = sorted(A,reverse=True)
#print(A)

for i in range(M):
    A[0] //= 2
    for i in range(N-1):
        if A[i] < A[i+1]:
            x = A[i]
            A[i] = A[i+1]
            A[i+1] = x
            
        else:
            break

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

print(ans)

Submission status: Time Limit Exceeded

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

# N: 品物の数、M: 割引券の枚数
# A: 品物の値段のリスト。

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

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

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)

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

b = list(map(math.floor, a))
print(sum(b))

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())  # 品物の数、割引券の枚数
A = list(map(int, input().split()))  # 品物の値段
list.sort(A, reverse=True)
for _ in range(M):
    tmp = max(A)
    A[A.index(tmp)] = tmp // 2
print(str(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):
    maxa=max(a)
    maxind=a.index(maxa)
    maxa = maxa // 2
    a[maxind] = maxa
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
list_a = list(map(int,input().split()))
#b_list = list(map(int,input().split()))
#print(" ".join(map(str,c_list)))

for i in range(m):
    list_a.sort(reverse = True)
    list_a[0] = list_a[0] //2
    """
    if list_a[0] % 2 != 0:
        list_a[0] = list_a[0] // 2 - 1
    else:
        list_a[0] = list_a[0] // 2
    """
print(sum(list_a))

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
import sys, math
import numpy as np

N, M = map(int, input().split())
A_list = np.array(list(map(int, input().split())))

for i in range(M):
    #max_a = A_list.max()
    index_max_a = A_list.argmax()
    A_list[index_max_a] = math.floor(A_list[index_max_a] / 2)
    #print(A_list)
    
print(np.sum(A_list))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

for i in range(M):
    k=np.where(A==A.max())[0][0]
    A[k]=A[k]//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 i in range(M):
    max_ind = A.index(max(A))
    A[max_ind] = A[max_ind] // 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
sys.setrecursionlimit(10**6)

def solve(N, M, A, cur, remain):
  if cur == N:
    return 0
  else:
    a = A[cur]
    tmp = 10**10
    for i in range(remain+1):
      tmp = min(tmp, solve(N, M, A, cur+1, remain-i)+a//(2**i))
    return tmp
n, m = map(int, input().split())
a = list(map(int, input().split()))
print(solve(n, m, a, 0, m))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

for j in range(N):
    A[j] = math.floor(A[j])

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
n,m=map(int,input().split())
l=list(map(int,input().split()))
for i in range(m):
    l.sort(reverse=True)
    l[0]=l[0]//2
print(sum(l))

Submission status: Time Limit Exceeded

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

for _ in range(0, m):
	i      = n - 1
	xs[i] /= 2
	
	while 0 < i and xs[i] < xs[i - 1]:
		x         = xs[i]
		xs[i]     = xs[i - 1]
		xs[i - 1] = x
		i        -= 1

print(sum(int(x) for x in xs))

Submission status: Time Limit Exceeded

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

    a = sorted(a)

    ans = 0

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

    ans = sum(a)
    print(ans)

if __name__=="__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

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

print(int(np.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[N-1] >>= 1
  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()))

A.sort(reverse=True)

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

for _ in range(M):
  tmp_a = int(A[-1]/2)
  del A[-1]
  A.insert(bisect.bisect_left(A,tmp_a),tmp_a)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
value = sum(a)
used = []
import math
for i in range(m):
  if used != []:
    if a != []:
      if max(used) < a[-1]:
        value -= math.ceil(a[-1]/2)
        used.append(math.floor(a[-1]/2))
        a = a[:-1]
      else:
        use = max(used)
        value -= math.ceil(use/2)
        used[used.index(use)] //= 2
    else:
      use = max(used)
      value -= math.ceil(use/2)
      used[used.index(use)] //= 2
  else:
    value -= math.ceil(a[-1]/2)
    used.append(math.floor(a[-1]/2))
    a = a[:-1]
print(value)

Submission status: Time Limit Exceeded

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

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

list1.sort()

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
import sys, math
import numpy as np

N, M = map(int, input().split())
A_list = np.array(list(map(int, input().split())))

for i in range(M):
    max_a = A_list.max()
    index_max_a = A_list.argmax()
    A_list[index_max_a] = math.floor(A_list[index_max_a] / (2))
    #print(A_list)
    
print(np.sum(A_list))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

ans=0

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

Submission status: Time Limit Exceeded

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

import numpy as np
A = np.array(A)

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

print(np.sum(A))

Submission status: Time Limit Exceeded

Solution code:
N,M=[int(s) for s in input().split()]
ls=[int(s) for s in input().split()]
ls.sort(reverse=True)
#print(ls)
for i in range(M):
  x=ls[0]>>1
  for j in range(N-1):
    if ls[j+1]>x:
      ls[j]=ls[j+1]
    else:
      ls[j]=x
      break
#    print(ls,j,x)
  else:
    ls[N-1]=x
#  print(ls)
print(sum(ls))

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] //= 2

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()]

A = sorted(A,reverse=True)
#print(A)

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

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

print(ans)

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:
    f = True
else:
    f = False

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

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n,m = MAP()
a = MAP()

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

Submission status: Time Limit Exceeded

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

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

ans = sum(pri)
print(ans)

Submission status: Time Limit Exceeded

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

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

a.sort()

e=a[:n-m]
d=a[n-m:]

for _ in range(m):
    val=d.pop()//2
    bisect.insort(d, val)

print(sum(e)+sum(d))

Submission status: Time Limit Exceeded

Solution code:
def solve():
  import sys
  import math

  sys.setrecursionlimit(10**7)
  readline=sys.stdin.readline

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

if __name__ == '__main__':
  solve()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


def solve(N: int, M: int, A: "List[int]"):
    for m in range(M):
        max_index = A.index(max(A))
        A[max_index] = A[max_index] // 2
    print(sum(A))
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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:
import math
N, M = list(map(int, input().split()))
A = list(map(float ,input().split()))

for i in range(M):
  A = sorted(A, reverse=True)
  A[0] = A[0] / 2
  
print(sum(list(map(int, A))))

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
a=[int(x) for x in input().split()]
s=0
for c in range(m):
    b=max(a)
    a.remove(b)
    a.append(int(b/2))
for c in range(n):
    s=s+a[c]
print(s)

Submission status: Time Limit Exceeded

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