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


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    s = input()
    if s == "Sunny":
        print("Cloudy")
    elif s == "Cloudy":
        print("Rainy")
    else:
        print("Sunny")
    return


# B
def B():
    s = S()
    for i in range(len(s)):
        if i % 2:
            if s[i] not in ["L", "U", "D"]:
                print("No")
                return
        else:
            if s[i] not in ["R", "U", "D"]:
                print("No")
                return
    print("Yes")
    return


# C
def C():
    n, k, q = LI()
    a = IR(q)
    sc = [0] * n
    for i in a:
        sc[i - 1] += 1
    for i in sc:
        print("Yes" if i > q - k else "No")
    return


# D
def D():
    n,m=LI()
    a=LI()
    for i in range(m):
        index = a.index(max(a))
        if a[index] > 0:
            a[index] = a[index]>>1
        else:
            break
    print(sum(a))
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    D()
    return


# Solve
if __name__ == "__main__":
    D()

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

Submission status: Time Limit Exceeded

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

for _ in range(m):
    b=a[-1]
    a.pop()
    bisect.insort(a,b/2)
print(sum( int( i//1) for i in 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 j in range(m):
    b=a[-1]
    a.pop()
    bisect.insort(a,b/2)
print(sum( int( i//1) for i in a ))

Submission status: Time Limit Exceeded

Solution code:
import bisect 

N, M = list(map(int, input().split(" ")))
A = [int(a) for a in input().split(" ")]
A.sort()

for i in range(M):
  bisect.insort_left(A, int(A.pop()/2))
  
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import bisect 

N, M = list(map(int, input().split(" ")))
A = [int(a) for a in input().split(" ")]
A.sort()

for i in range(M):
  a = int(A.pop()/2)
  bisect.insort(A, a) 
  
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import bisect 

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

for i in range(M):
  #a = int(A.pop()/2)
  #bisect.insort(A, a) 
  
  k = A.index(max(A))
  A[k] = int(A[k]/2)
  
  
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import bisect 

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

for i in range(M):
  a = int(A.pop()/2)
  bisect.insort(A, a) 
  
  
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):
  A.sort(reverse=True)
  A[0] = int(A[0]/2)
  
  
print(sum(A))

Submission status: Time Limit Exceeded

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

while m>0:
    a=l[len(l)-1]
    l.pop()
    l.append(a//2)
    l=sorted(l)
    m=m-1

print(sum(l))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
"""
high = float('inf')
low = -1

while low + 1 < high:
  mid = (low + high) // 2
  
  if min(sum(a), mid  :
    high = mid
  else:
    low = mid
print(high)
"""
for i in range(m):
  a[a.index(max(a))] = int(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()
while m:
    a[-1]//=2
    m-=1
    a.sort()

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
#ソートしてでかいやつから割引券使っていって、次に値段が高いやつよりも値段が低くなれば次にいく。
#これを繰り返せばいい。
#一周してもまだ割引券が余っていればもう一度ソートして同じことをする。
#途中で割引券がなくなれば終了して、合計を計算する。
#実際に買い物をする順番は気にしなくていい。どこで何枚使うのが最適かが分かればいい
#ということは割引券を使うたび毎回ソートする？

n,m = map(int,input().split())
A = list(map(int,input().split()))
#print(A)
A.sort(reverse=True)

while m!=0:
  M_A = max(A)
  A[0] = M_A //2
  m -= 1
  A.sort(reverse=True)
  
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:

from bisect import insort_left

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

if not N-1:
  A[0] //= 2 ** M
		
else:
  while M:
	  a = A.pop(N-1)
	
	  while a >= A[-1] and M:
		  a //= 2
		  M -= 1
		
	  insort_left(A, a)
	
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
from bisect import insort_left

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

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

  print(sum(A))  	
  
if __name__ == '__main__':
  main()

Submission status: Time Limit Exceeded

Solution code:
from bisect import insort_left

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

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

  print(sum(list(map(int, A))))  	
  
if __name__ == '__main__':
  main()

Submission status: Time Limit Exceeded

Solution code:
from bisect import insort_left

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

for i in range(M):
  a = A.pop(N-1)  
  insort_left(A, a/2)
  
print(sum(list(map(int, A))))

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
from bisect import insort
n, m = [int(x) for x in stdin.readline().rstrip().split()]
a = [int(x) for x in stdin.readline().rstrip().split()]
a.sort()
for i in range(m):
    harf = a[n-1] // 2
    a[n-1:n] = []
    insort(a, harf)
print(sum(a))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import bisect
n, m = [int(x) for x in stdin.readline().rstrip().split()]
a = [int(x) for x in stdin.readline().rstrip().split()]
a.sort()
sum = 0
for i in range(m):
    harf = a[n-1] // 2
    del a[n-1]
    bisect.insort_left(a, harf)
for i in range(n):
    sum += a[i]
print(sum)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import bisect
n, m = [int(x) for x in stdin.readline().rstrip().split()]
a = [int(x) for x in stdin.readline().rstrip().split()]
a.sort()
sum = 0
for i in range(m):
    a[n-1] = a[n-1] // 2
    a.sort()
for i in range(n):
    sum += a[i]
print(sum)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import bisect
n, m = [int(x) for x in stdin.readline().rstrip().split()]
a = [int(x) for x in stdin.readline().rstrip().split()]
a.sort()
sum = 0
for i in range(m):
    harf = a[n-1] // 2
    a.remove(a[n-1])
    bisect.insort_left(a, harf)
for i in range(n):
    sum += a[i]
print(sum)

Submission status: Time Limit Exceeded

Solution code:
import bisect as b
import math

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

for _ in range(m):
    half = a.pop(-1) / 2
    a.insert(b.bisect_left(a, half), half)

print(sum(list(map(lambda x: math.floor(x), 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):
  ind=np.argmax(a)
  a[ind] = a[ind]//2
  
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
Q = []
for i in range(N):
  Q.append(max(A))
  A.remove(max(A))
for j in range(M):
  Q[0] //= 2
  for k in range(1, N-1):
    if Q[0] <= Q[k] and Q[0] >= Q[k+1]:
      Q.insert(k+1, Q[0])
      Q.remove(Q[0])
    if Q[0] < Q[N-1]:
      Q.append(Q[0])
      Q.remove(Q[0])
S = 0
for k in range(N):
  S += Q[k]
print(S)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

def discount(n,m,prices):
    for i in range(m):
        prices.sort(reverse = True)
        prices[0] //= 2
    return sum(prices)

print (discount(n,m,prices))

Submission status: Time Limit Exceeded

Solution code:
from enum import Enum
from queue import Queue

import numpy as np

import collections
import bisect
import sys
import math

from scipy.sparse.csgraph import floyd_warshall

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(map(int,A)))

Submission status: Time Limit Exceeded

Solution code:
import sys
from io import StringIO
import unittest


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

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

    print(int(sum(A)))


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 3
2 13 8"""
        output = """9"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4 4
1 9 3 5"""
        output = """6"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1 100000
1000000000"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """10 1
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000"""
        output = """9500000000"""
        self.assertIO(input, output)


if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

Solution code:
N, M = tuple(int(elem) for elem in input().split())
Ai = [int(elem) for elem in input().split()]
Ai.sort(reverse=True)
if N == 1:
  print(Ai[0]//(2**M))
  quit()
while M > 0:
  l, r = 0, M
  while l < r:
    mid = l + (r-l) // 2
    if Ai[0]//(2**mid) >= Ai[1]:
      l = mid + 1
    else:
      r = mid
  Ai[0] = Ai[0]//(2**l)
  M = M - l
  Ai.sort(reverse=True)
print(sum(Ai))

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):

    v=np.argmax(a)
    a[v] = a[v]/2

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

Submission status: Time Limit Exceeded

Solution code:
import heapq
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort(reverse=True)
heapq.heapify(x)
ans=0
for i in range(m):
    y=heapq.nlargest(1,x)[0]
    x.remove(y)
    x.append(y//2)
for j in range(n):
    ans+=x[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):
    v=a.index(max(a))
    a[v] = a[v]/2

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

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

print(sum(list(map(int,A_n))))

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:
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
for i in range(m):
  a[-1]=int(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(" ")))

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

result = 0

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

print(result)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
import bisect


def solve(*args: str) -> str:
    n, m = map(int, args[0].split())
    A = sorted(map(int, args[1].split()))

    for _ in range(m):
        a = A[-1]
        A = A[0:-1]
        bisect.insort_left(A, int(a/2))

    return str(sum(A))


if __name__ == "__main__":
    print(solve(*[input() for _ in range(2)]))

Submission status: Time Limit Exceeded

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

big = 0

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

Submission status: Time Limit Exceeded

Solution code:
from bisect import*
n,m,*a=map(int,open(0).read().split())
a.sort()
while m:insort(a,a.pop()//2);m-=1
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
from bisect import*
n,m,*a=map(int,open(0).read().split())
a.sort()
exec('insort(a,a.pop()//2);'*m)
print(sum(a))

Submission status: Time Limit Exceeded

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

for _ in range(M):
    n = max(lst)
    idx = lst.index(n)
    lst[idx] = n // 2
print(sum(lst))

Submission status: Time Limit Exceeded

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

for i in range(M):
  max_a = max(A_n)
  A_n[A_n.index(max_a)] /= 2
  
print(sum(list(map(int,A_n))))

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())#n:num m:ticket
a=[int(_) for _ in 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()

if len(A) ==1:
  print(int(A[0]/(2**M)))
else:
  while(M>0):
    A[-1]=int(A[-1]/2)
    M -=1
    while(1):
      if A[-1] > A[-2] and M >0:
        A[-1]=int(A[-1]/2)
        M -=1
      elif A[-1] < A[-2] and M > 0:
        A[-2]=int(A[-2]/2)
        M -=1
        A.sort()
        break
      else:
        A.sort()
        break
  print(sum(A))

Submission status: Time Limit Exceeded

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

if len(A) ==1:
  print(int(A[0]/(2**M)))
else:
  while(M>0):
    A[-1]=int(A[-1]/2)
    M -=1
    if A[-1] < A[-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()))

for i in range(M):
  maxA = A.index(max(A))
  A[maxA] = int(A[maxA]/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):
  index = A.index(max(A))
  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:
N,M = map(int, input().split())
A = list(map(int, input().split()))

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

print(sum(A))

Submission status: Time Limit Exceeded

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

def sub_sort(list,num):
    for i,elem in enumerate(list):
        if num >= elem:
            list.insert(i,num)
            return list
        elif i == len(list) - 1:
            list.append(num)
            return list

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

Submission status: Time Limit Exceeded

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

def maximum(list):
    sub = []
    for i,x in enumerate(list):
        if sub == [] or x > sub[0]:
            sub = [x,i]
    return sub[0],sub[1]

for i in range(m):
    x,idx = maximum(a_list)
    a_list[idx] = x//2

print(sum(a_list))

Submission status: Time Limit Exceeded

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

def discount(B_lis,delta):
    #B_lis.sort()
    max_index = B_lis.index(max(B_lis))
    delta[max_index] += B_lis[max_index]/2
    B_lis[max_index] = B_lis[max_index]/2
    #B_lis.sort()
    return B_lis,delta

dis = [0]*N
for i in range(M):
    A_lis,dis = discount(A_lis,dis)
    #print(A_lis)
    #print(dis)

ans = 0
for i in range(len(A_lis)):
    ans+=int(A_lis[i])
print(ans)

Submission status: Time Limit Exceeded

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

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

# list内の最も大きい数字を2で割るのをm回行う
for i in range(m):
    a = sorted(a)
    a[n -1] = int(a[n -1] / 2)

print(sum(a))

Submission status: Time Limit Exceeded

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

while m != 0:
    price[0] //= 2
    for i in range(1,n):
        if price[0] > price[i]:
            price_buf = price[1:i]
            price[i-1] = price[0]
            price[0:i-1] = price_buf
            break
    m -= 1
print(sum(price))

Submission status: Time Limit Exceeded

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

while m != 0:
    price[0] //= 2
    price.sort(reverse=True)
    m -= 1
print(sum(price))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n = list(map(int, input().split()))
h = list(map(int, input().split()))
h = sorted(h, reverse = True)
i = 0
for i in range(n[1]):
    h[0] = h[0]/2
    h = sorted(h, reverse  = True)
    i = i + 1
h = np.floor(h)
print(int(sum(h)))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, M = [int(item) for item in input().split()]
price_list = sorted([int(item) for item in input().split()])

ticket_list = []
total_price_list = []
total_m = 0

def discount(price_list, ticket_num):
    total_ticket =0

    while total_ticket < ticket_num:
        price_list[-1] = int(price_list[-1]/2)
        price_list.sort()
        total_ticket += 1

    return price_list

res = discount(price_list, M)
print(sum(res))

Submission status: Time Limit Exceeded

Solution code:
N, M = [int(item) for item in input().split()]
price_list = [int(item) for item in input().split()]

ticket_list = []
total_price_list = []
total_m = 0

def discount(price_list, ticket_num):
    total_ticket =0

    while total_ticket < ticket_num:
        temp_num = int(sorted(price_list)[-1]/2)
        price_list.sort()
        price_list[-1] = temp_num 
        total_ticket += 1

    return price_list



# total_price  += int(price_list[n] / (2 ** m))
# break
res = discount(price_list, M)
# print(res)
print(sum(res))

Submission status: Time Limit Exceeded

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

a_sorted = sorted(a)

for i in range(m):
    maximum = a_sorted.pop(-1)
    bisect.insort_left(a_sorted, maximum//2)

ans = sum(a_sorted)
print(ans)

Submission status: Time Limit Exceeded

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

a_sorted = sorted(a)

while m > 0:
    maximum = a_sorted.pop(-1)
    if maximum % 2 == 0:
        bisect.insort_left(a_sorted, maximum//2)
    else:
        bisect.insort_left(a_sorted, maximum//2)
    m += -1
ans = sum(a_sorted)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

Submission status: Time Limit Exceeded

Solution code:
from bisect import insort
def main():
	(_, M) = map(int, input().split())
	A = list(map(int, input().split()))
	A.sort()
	for i in range(M):
		b = A[-1] // 2
		insort(A, b)
		A = A[:-1]
	print(sum(A))
main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def price(x):
    return x // 2


for i in range(m):
    x = a.pop()
    a.append(price(x))
    a.sort()

print(sum(a))

Submission status: Time Limit Exceeded

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


def price(x):
    return x // 2


for i in range(m):
    x = max(a)
    y = a.index(x)
    a[y] = price(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(reverse=True)
def price(x):
    return x // 2

while m > 0:
    a[0] = price(a[0])
    a.sort(reverse=True)
    m -= 1

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
def 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))

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import bisect
 
n, m = (int(x) for x in input().split())
item = sorted([int(x) for x in input().split()])
if n == 1:
    print(item[0] // (2**m))
else:
  while m > 0:
      a = item.pop()
      while a >= item[-1] and m > 0:
          a = a // 2
          m -= 1
      bisect.insort_left(item,a)
  print(sum(item))

Submission status: Time Limit Exceeded

Solution code:
import bisect
 
n, m = (int(x) for x in input().split())
item = sorted([int(x) for x in input().split()])
for _ in range(m):
    a = item.pop() // 2
    bisect.insort_left(item,a)
print(sum(item))

Submission status: Time Limit Exceeded

Solution code:
import bisect

n, m = (int(x) for x in input().split())
item = sorted([int(x) for x in input().split()])
for _ in range(m):
    a = item.pop() // 2
    bisect.insort_left(item,a)
print(sum(item))

Submission status: Time Limit Exceeded

Solution code:
NM = input().split()
N = int(NM[0])
M = int(NM[1])
array = list(map(int, input().split()))
array.sort(reverse=True)
if len(array) == 1:
  array.append(0)
if array[0] // 512 > array[1]:
  array[0] = array[0] // 1024
  M = M - 10
elif array[0] // 256 > array[1]:
  array[0] = array[0] // 512
  M = M - 9
elif array[0] // 128 > array[1]:
  array[0] = array[0] // 256
  M = M - 8
elif array[0] // 64 > array[1]:
  array[0] = array[0] // 128
  M = M - 7
elif array[0] // 32 > array[1]:
  array[0] = array[0] // 64
  M = M - 6
elif array[0] // 16 > array[1]:
  array[0] = array[0] // 32
  M = M - 5
elif array[0] // 8 > array[1]:
  array[0] = array[0] // 16
  M = M - 4
elif array[0] // 4 > array[1]:
  array[0] = array[0] // 8
  M = M - 3
elif array[0] // 2 > array[1]:
  array[0] = array[0] // 4
  M = M - 2
else:
  array[0] = array[0] // 2
  M = M - 1

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

print(sum(array))

Submission status: Time Limit Exceeded

Solution code:
NM = input().split()
N = int(NM[0])
M = int(NM[1])
array = list(map(int, input().split()))
if len(array) == 1:
  array.append(0)
num = 1

for i in range(M):
  array.sort(reverse=True)
  if num == 1:
    if array[0] // 512 > array[1]:
      array[0] = array[0] // 1024
      num = 512
    elif array[0] // 256 > array[1]:
      array[0] = array[0] // 512
      num = 256
    elif array[0] // 128 > array[1]:
      array[0] = array[0] // 256
      num = 128
    elif array[0] // 64 > array[1]:
      array[0] = array[0] // 128
      num = 64
    elif array[0] // 32 > array[1]:
      array[0] = array[0] // 64
      num = 32
    elif array[0] // 16 > array[1]:
      array[0] = array[0] // 32
      num = 16
    elif array[0] // 8 > array[1]:
      array[0] = array[0] // 16
      num = 8
    elif array[0] // 4 > array[1]:
      array[0] = array[0] // 8
      num = 4
    elif array[0] // 2 > array[1]:
      array[0] = array[0] // 4
      num = 2
    else:
      array[0] = array[0] // 2
  else:
    num = num // 2

print(sum(array))

Submission status: Time Limit Exceeded

Solution code:
NM = input().split()
N = int(NM[0])
M = int(NM[1])
array = list(map(int, input().split()))
if len(array) == 1:
  array.append(0)
num = 1

for i in range(M):
  array.sort(reverse=True)
  if num == 1:
    if array[0] // 16 > array[1]:
      array[0] = array[0] // 32
      num = 16
    elif array[0] // 8 > array[1]:
      array[0] = array[0] // 16
      num = 8
    elif array[0] // 4 > array[1]:
      array[0] = array[0] // 8
      num = 4
    elif array[0] // 2 > array[1]:
      array[0] = array[0] // 4
      num = 2
    else:
      array[0] = array[0] // 2
  else:
    num = num // 2

print(sum(array))

Submission status: Time Limit Exceeded

Solution code:
NM = input().split()
N = int(NM[0])
M = int(NM[1])
array = list(map(int, input().split()))

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

print(sum(array))

Submission status: Time Limit Exceeded

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


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


# Generated by 1.1.6 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:
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 math

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


def solve():
    sorted_list = A

    for index in range(0, M):
        sorted_list = sorted(sorted_list)
        sorted_list[-1] = math.floor(sorted_list[-1] / 2)

    return sum(sorted_list)


print(solve())

Submission status: Time Limit Exceeded

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

def use_coupons(goods):
    goods[goods.index(max(goods))] = goods[goods.index(max(goods))]//2
    return goods

main()