Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
s = input().split()
n = s[0]
m = s[1]
if (1<=n && n<=100 && 0<=m && m<=n):
  if (isinstance(n, int) && isinstance(m, int)):
    print(Yes)
  else:
    print(No)
else:
  print(No)

Fixed submission:
s = input().split()
n = int(s[0])
m = int(s[1])
if(n==m):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n,m = input().split(' ')

ncount = 0 if n < 2 else n*(n-1)/2
mcount = 0 if m < 2 else m*(m-1)/2

print(str(ncount + mcount))

Fixed submission:
inp = input().split(' ')

n = int(inp[0])
m = int(inp[1])

ncount = 0 if n < 2 else n*(n-1)//2
mcount = 0 if m < 2 else m*(m-1)//2

print(str(ncount + mcount))
Buggy python submission (verdict: Runtime Error):
from math import factorial


def main():
    MOD = 1000000007
    inp = input().split()
    n = int(inp[0])
    k = int(inp[1])
    r = n - k
    for i in range(1, k + 1):
        if r + 1 < i:
            return
        else:
            rr = cmb(r + 1, i)

        if i == 1:
            bb = 1
        elif i == k:
            bb = 1
        else:
            bb = cmb(k - 1, i - 1)
        print((rr % MOD) * (bb % MOD) % MOD)


def cmb(n, r):
    return factorial(n) / (factorial(r) * factorial(n - r))


if __name__ == '__main__':
    main()


Fixed submission:
from math import factorial


def main():
    MOD = 1000000007
    inp = input().split()
    n = int(inp[0])
    k = int(inp[1])
    r = n - k
    for i in range(1, k + 1):
        if r + 1 < i:
            print(0)
            continue
        elif r + 1 == i:
            rr = 1
        else:
            rr = cmb(r + 1, i)

        if i == 1:
            bb = 1
        elif i == k:
            bb = 1
        else:
            bb = cmb(k - 1, i - 1)
        print(((rr % MOD) * (bb % MOD)) % MOD)


def cmb(n, r):
    return factorial(n) // (factorial(r) * factorial(n - r))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import itertools
from operator import mul
from functools import reduce


def main():
    MOD = 1000000007
    inp = input().split()
    n = int(inp[0])
    k = int(inp[1])
    r = n - k
    for i in range(1, k + 1):
        rr = cmb(r + 1, i)
        if i == 1:
            bb = 1
        elif i == k:
            bb = 1
        else:
            bb = cmb(k - 1, i - 1)
        print((rr % MOD) * (bb % MOD) % MOD)


def cmb(n, r):
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


if __name__ == '__main__':
    main()


Fixed submission:
from math import factorial


def main():
    MOD = 1000000007
    inp = input().split()
    n = int(inp[0])
    k = int(inp[1])
    r = n - k
    for i in range(1, k + 1):
        if r + 1 < i:
            print(0)
            continue
        elif r + 1 == i:
            rr = 1
        else:
            rr = cmb(r + 1, i)

        if i == 1:
            bb = 1
        elif i == k:
            bb = 1
        else:
            bb = cmb(k - 1, i - 1)
        print(((rr % MOD) * (bb % MOD)) % MOD)


def cmb(n, r):
    return factorial(n) // (factorial(r) * factorial(n - r))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
nums = list(map(int,input().split(" ")))

c = Counter(nums)

for num in nums:
    c[num]-=1
    curr = 0
    for k,v in c.items():
        if v >=2:
            curr+= v*(v-1)//2
    print(curr)
    c[num]+=1
    

Fixed submission:
from collections import Counter
n = int(input())
nums = list(map(int,input().split(" ")))

c = Counter(nums)
a = 0
for k,v in c.items():
    if v >=2:
        a+=(v-1)*v//2

for num in nums:
    curr = -1
    if c[num] >= 2:
        curr = a - (c[num]-1)
    else:
        curr = a
    print(curr)
Buggy python submission (verdict: Runtime Error):
import math
a,b,c = map(int,input())
left = math.sqrt(a) + math.sqrt(b)
right = math.sqrt(c)
if left < right:
    print("Yes")
else:
    print("No")

Fixed submission:
a,b,c = map(int,input().split(" "))
right = c- a- b
if right > 0 and right ** 2 > 4 * a* b:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
rev = 1
for _ in range(Q):
    op = input().split(" ")
    if int(op[0]) == 1:
        rev *= -1
    else:
        f, ch = op[1:]
        if rev == 1:
            if f == "1":
                S = ch + S
            else:
                S = S + ch
        else:
            if f == "1":
                S = S + ch
            else:
                S = ch + S
if rev == -1:
    S = S[::-1]
print(S)

Fixed submission:
from collections import  deque
S = input()
Q = int(input())
rev = 1
q = deque(list(S))
for _ in range(Q):
    op = input().split(" ")
    if int(op[0]) == 1:
        rev *= -1
    else:
        f, ch = op[1:]
        if rev == 1:
            if f == "1":
                q.appendleft(ch)
            else:
                q.append(ch)
        else:
            if f == "1":
                q.append(ch)
            else:
                q.appendleft(ch)
S = "".join(q)
if rev == -1:
    S = S[::-1]
print(S)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())

for _ in range(Q):
    op = input().split(" ")
    if int(op[0]) == 1:
        S = S[::-1]
    else:
        f, ch = op[1:]
        if f == "1":
            S = ch + S
        else:
            S = S + ch

print(S)

Fixed submission:
from collections import  deque
S = input()
Q = int(input())
rev = 1
q = deque(list(S))
for _ in range(Q):
    op = input().split(" ")
    if int(op[0]) == 1:
        rev *= -1
    else:
        f, ch = op[1:]
        if rev == 1:
            if f == "1":
                q.appendleft(ch)
            else:
                q.append(ch)
        else:
            if f == "1":
                q.append(ch)
            else:
                q.appendleft(ch)
S = "".join(q)
if rev == -1:
    S = S[::-1]
print(S)
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n % 2 == 0:
    print(n//2)
else:
    print(n//2)+1

Fixed submission:
n = int(input())
if n % 2 == 0:
    print(n//2)
else:
    print(n//2+1)
Buggy python submission (verdict: Time Limit Exceeded):
def getCount(num, i,j):
    cnt = 0
    for n in range(1,num+1):
        s = str(n)
        if s[0] == str(i) and s[-1] == str(j):
            cnt+=1
    return cnt        

n = int(input())

res = 0
for i in range(0,10):
    for j in range(0,10):
        res += getCount(n,i,j) * getCount(n,j,i)
print(res)




Fixed submission:
from collections import defaultdict
def getLeft(num):
    while num >= 10:
        num = int(num / 10)
    return num

def getRight(num):
    return num % 10

n = int(input())
a = defaultdict(int)
for number in range(1,n+1):
    left = getLeft(number)
    right = getRight(number)
    a[(left,right)] += 1


res = 0
for i in range(0,10):
    for j in range(0,10):
        res += a[(i,j)] * a[(j,i)]
print(res)
Buggy python submission (verdict: Runtime Error):
from collections import deque
w,h = list(map(int,input().split(" ")))
path = [input() for _ in range(w)]

def bfs(sw,sh):
    res = 0
    dw = [-1,1,0,0]
    dh = [0,0,1,-1]
    dist = [[-1 for _ in range(w)] for _ in range(h)]
    dist[sw][sh] = 0
    queue = deque()
    queue.append((sw,sh))
    while len(queue) != 0:
        cw,ch = queue.popleft()
        for i in range(4):
            nw,nh = cw + dw[i], ch + dh[i]
            if not (0<= nw < w and 0 <= nh < h): continue
            if path[nw][nh] == "#": continue
            if dist[nw][nh] != -1: continue
            dist[nw][nh] = dist[cw][ch] + 1
            queue.append((nw,nh))
            res = max(res, dist[nw][nh])
    return res

ans = 0
for i in range(w):
    for j in range(h):
        if path[i][j] == "#":
            continue
        ans = max(ans, bfs(i,j))
print(ans)

Fixed submission:
from collections import deque
w,h = list(map(int,input().split(" ")))
path = [input() for _ in range(w)]

def bfs(sw,sh):
    res = 0
    dw = [-1,1,0,0]
    dh = [0,0,1,-1]
    dist = [[-1 for _ in range(h)] for _ in range(w)]
    dist[sw][sh] = 0
    queue = deque()
    queue.append((sw,sh))
    while len(queue) != 0:
        cw,ch = queue.popleft()
        for i in range(4):
            nw,nh = cw + dw[i], ch + dh[i]
            if not (0<= nw < w and 0 <= nh < h): continue
            if path[nw][nh] == "#": continue
            if dist[nw][nh] != -1: continue
            dist[nw][nh] = dist[cw][ch] + 1
            queue.append((nw,nh))
            res = max(res, dist[nw][nh])
    return res

ans = 0
for i in range(w):
    for j in range(h):
        if path[i][j] == "#":
            continue
        ans = max(ans, bfs(i,j))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math

n,k = list(map(int, input().split(" ")))
nums  = list(map(int, input().split(" ")))
nums.sort()

mod = 10**9 + 7
f = [1]
for i in range(1,10**5+1):
    f.append(f[-1] * i)

def nCr(n,r):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod

minSum = 0
maxSum = 0

for i in range(n-k+1):
    minSum += nums[i] * nCr(n-1-i, k-1)
    maxSum += nums[-i-1] * nCr(n-1-i,k-1)

print((maxSum - minSum + mod) % mod)

Fixed submission:
import math

n,k = list(map(int, input().split(" ")))
nums  = list(map(int, input().split(" ")))
nums.sort()

mod = 10**9 + 7
f = [1]
for i in range(1,10**5+1):
    f.append(f[-1] * i % mod)

def nCr(n,r):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod

minSum = 0
maxSum = 0

for i in range(n-k+1):
    minSum += nums[i] * nCr(n-1-i, k-1)
    maxSum += nums[-i-1] * nCr(n-1-i,k-1)

print((maxSum - minSum + mod) % mod)
Buggy python submission (verdict: Runtime Error):
a,b,k = list(map(int,input().split(" ")))

if a > k:
    a -= k
    print(str(a) + " " + b)
else:
    left = k - a
    b -= left
    print(str(0) + " " + b)

Fixed submission:
a,b,k = list(map(int,input().split(" ")))

if a > k:
    a -= k
    print(str(a) + " " + str(b))
else:
    left = k - a
    b -= left
    if b < 0:
        b = 0
    print(str(0) + " " + str(b))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nums = list(map(int,input().split(" ")))
nums.sort()
total = 0
for i in range(n):
    for j in range(i+1,n):
        k = j+1
        while k < n and nums[k] < nums[i] + nums[j]:
            k+=1    
        total += k-j -1 
print(total)

Fixed submission:
n = int(input())
nums = list(map(int,input().split(" ")))
nums.sort()
total = 0
for i in range(n-1,-1,-1):
    l = 0
    r = i-1
    while l < r:
        if nums[l] + nums[r] > nums[i]:
            total += r - l
            r -= 1
        else:
            l += 1
print(total)
Buggy python submission (verdict: Runtime Error):
nums = list(map(int,input().split(" ")))
res = [0 for _ in range(len(nums))]
for i in range(len(nums)):
    index = i+1
    cnt = nums[i]
    res[cnt-1] = index
print(res)


Fixed submission:
n = int(input())
nums = list(map(int,input().split(" ")))
res = [0 for _ in range(len(nums))]
for i in range(len(nums)):
    index = i+1
    cnt = nums[i]
    res[cnt-1] = index
print(*res,sep=" ")
Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q = map(int,input().split(" "))
score = [0]
for _ in range(N):
    score.append(K)

for _ in range(Q):
    ans = int(input())
    for i in range(1,N+1):
        if i != ans:
            score[i]-=1

for i in range(1,N+1):
    if score[i] > 0:
        print("Yes")
    else:
        print("No")

Fixed submission:
N,K,Q = map(int,input().split(" "))
score = [0]
for _ in range(N):
    score.append(K)

for _ in range(Q):
    ans = int(input())
    score[ans] +=1

for i in range(1,N+1):
    if score[i] > Q:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
import collections
import math
def calculateProb(counts):
    ways = 0
    for key in counts.keys():
        if counts[key] < 2:
            continue
        if counts[key] in cache:
            ways += cache[counts[key]]
        else:
            val = counts[key]
            cache[val] = math.factorial(val)/math.factorial(2)/math.factorial(val - 2)
            ways += cache[val]
    return ways

def getfact(val):
    if val < 2:
        return 0
    return math.factorial(val)/math.factorial(2)/math.factorial(val - 2)


n = int(input())

values = list(map(int, input().split(' ')))
counts = collections.Counter(values)

cache = {}
ways = calculateProb(counts)
for k in range(n):
    curVal = values[k]
    count = counts[curVal]
    temp = ways
    ways = ways - getfact(count)  + getfact(count - 1)
    print(int(ways))
    ways = temp

Fixed submission:
import collections
import math
def calculateProb(counts):
    ways = 0
    for key in counts.keys():
        if counts[key] < 2:
            continue
        else:
            val = counts[key]
            ret = val*(val-1)/2
            ways += ret
    return ways

def getfact(val):
    if val < 2:
        return 0
    return val*(val-1)/2


n = int(input())

values = list(map(int, input().split(' ')))
counts = collections.Counter(values)

ways = calculateProb(counts)
for k in range(n):
    curVal = values[k]
    count = counts[curVal]
    temp = ways
    ways = ways - getfact(count)  + getfact(count - 1)
    print(int(ways))
    ways = temp

Buggy python submission (verdict: Runtime Error):
import collections
import math
def calculateProb(counts):
    ways = 0
    for key in counts.keys():
        if counts[key] < 2:
            continue
        if counts[key] in cache:
            ways += cache[counts[key]]
        else:
            val = counts[key]
            cache[val] = math.factorial(val)/math.factorial(2)/math.factorial(val - 2)
            ways += cache[val]
    return ways

        


n = int(input())

values = list(map(int, input().split(' ')))
counts = collections.Counter(values)

cache = {}

for k in range(n):
    curVal = values[k]
    counts[curVal] -= 1
    print(int(calculateProb(counts)))
    counts[curVal] += 1

Fixed submission:
import collections
import math
def calculateProb(counts):
    ways = 0
    for key in counts.keys():
        if counts[key] < 2:
            continue
        else:
            val = counts[key]
            ret = val*(val-1)/2
            ways += ret
    return ways

def getfact(val):
    if val < 2:
        return 0
    return val*(val-1)/2


n = int(input())

values = list(map(int, input().split(' ')))
counts = collections.Counter(values)

ways = calculateProb(counts)
for k in range(n):
    curVal = values[k]
    count = counts[curVal]
    temp = ways
    ways = ways - getfact(count)  + getfact(count - 1)
    print(int(ways))
    ways = temp
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
2 ans = N // (A + B) * A
3 rem = N % (A + B)
4 ans += min(rem, A)
5 print(ans)


Fixed submission:
N, A, B = map(int, input().split())
ans = N // (A + B) * A
rem = N % (A + B)
ans += min(rem, A)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy
 
N,K=map(int,input().split())
p=list(map(int,input().split()))
ans = 0
tmp = [0]*(N-K+1)

for i in range(K):
  tmp[0] = tmp[0]+p[i]

for i in range(1,N-K+1):
  tmp[i]=tmp[i-1]-p[i-1]+p[i+K-1]

max_index=numpy.argmax(tmp)
for i in range(max_index,max_index+K):
  for j in range(1,p[i]+1):
    ans=ans+float(j*(1/p[i]))
print(ans)

Fixed submission:
import numpy
 
N,K=map(int,input().split())
p=list(map(int,input().split()))
ans = 0
tmp = [0]*(N-K+1)

for i in range(K):
  tmp[0] = tmp[0]+p[i]

for i in range(1,N-K+1):
  tmp[i]=tmp[i-1]-p[i-1]+p[i+K-1]

max_index=numpy.argmax(tmp)
for i in range(max_index,max_index+K):
  ans=ans+float(((p[i]*(p[i]+1))/2)*1/p[i])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy
 
N,K=map(int,input().split())
p=list(map(int,input().split()))
ans = 0
tmp = [0]*(N-K+1)
 
for i in range(N-K+1):
  for j in range(i,i+K):
    tmp[i]=tmp[i]+p[j]

max_index=numpy.argmax(tmp)
for i in range(max_index,max_index+K):
  for j in range(1,p[i]+1):
    ans=ans+float(j*(1/p[i]))
print(ans)

Fixed submission:
import numpy
 
N,K=map(int,input().split())
p=list(map(int,input().split()))
ans = 0
tmp = [0]*(N-K+1)

for i in range(K):
  tmp[0] = tmp[0]+p[i]

for i in range(1,N-K+1):
  tmp[i]=tmp[i-1]-p[i-1]+p[i+K-1]

max_index=numpy.argmax(tmp)
for i in range(max_index,max_index+K):
  ans=ans+float(((p[i]*(p[i]+1))/2)*1/p[i])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy

N,K=map(int,input().split())
p=list(map(int,input().split()))
ans = 0
tmp = [0]*N
tmp2 = 0

for i in range(N):
  if len(p)<i+K:
    break
  for j in range(i,i+K):
    tmp[i]=tmp[i]+p[j]

max_index=numpy.argmax(tmp)
for i in range(max_index,max_index+K):
  for j in range(1,p[i]+1):
    ans=ans+float(j*(1/p[i]))
print(ans)

Fixed submission:
import numpy
 
N,K=map(int,input().split())
p=list(map(int,input().split()))
ans = 0
tmp = [0]*(N-K+1)

for i in range(K):
  tmp[0] = tmp[0]+p[i]

for i in range(1,N-K+1):
  tmp[i]=tmp[i-1]-p[i-1]+p[i+K-1]

max_index=numpy.argmax(tmp)
for i in range(max_index,max_index+K):
  ans=ans+float(((p[i]*(p[i]+1))/2)*1/p[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
H,A=map(int,raw_input().split())
ans=0
for i in range(1,10000):
  H = H-A
  ans += 1
  if H=<0:
    break
print ans

Fixed submission:
H,A=map(int,raw_input().split())
ans=0
for i in range(1,100000):
  H = H-A
  ans += 1
  if H<=0:
    break
print ans
Buggy python submission (verdict: Runtime Error):
K,X=map(int,raw_input().split())
if K*500>=X:
  print "Yes"
else:
  print "No"

Fixed submission:
K,X=map(int,raw_input().split())
if K*500>=X:
  print "Yes"
else:
  print "No"

Buggy python submission (verdict: Runtime Error):
K,X=map(int,raw_input().split())
if K*500>=X:
  print "Yes"
else:
  print "No"

Fixed submission:
K,X=map(int,raw_input().split())
if K*500>=X:
  print "Yes"
else:
  print "No"
Buggy python submission (verdict: Time Limit Exceeded):
N = int(raw_input())
a = map(int,raw_input().split())
con = 0
i = 0
while i <= N:
  if len(a)==0:
    con = -1
    print con
    break
  elif len(a)==con:
    print N-con
    break
  elif a[con] == con+1:
    con = con + 1
  else:
    a.pop(con)
  i= i+1

Fixed submission:
N = int(raw_input())
a = map(int,raw_input().split())
con = 1
ans = 0
for i in range(0,N):
  if a[i] == con:
    con = con + 1
    continue
  else:
    ans = ans + 1
if ans == N:
  print -1
else:
  print ans

Buggy python submission (verdict: Time Limit Exceeded):
N = int(raw_input())
a = map(int,raw_input().split())
con = 0
i = 0
while i <= N:
  if len(a)==0:
    con = -1
    print con
    break
  elif len(a)==con:
    print N-con
    break
  if a[con] == con+1:
    con = con + 1
  else:
    a.pop(con)
  i= i+1

Fixed submission:
N = int(raw_input())
a = map(int,raw_input().split())
con = 1
ans = 0
for i in range(0,N):
  if a[i] == con:
    con = con + 1
    continue
  else:
    ans = ans + 1
if ans == N:
  print -1
else:
  print ans
Buggy python submission (verdict: Runtime Error):
A.B.C=map(int,input().split())
if A+B+C>=22:
  print("bust")
else:
  print("win")

Fixed submission:
A,B,C=map(int,input().split())
if A+B+C>=22:
  print("bust")
else:
  print("win")
Buggy python submission (verdict: Runtime Error):
import math
N = int(raw_input())
(float)avg = ((float)math.ceil(N/2)/N
print avg

Fixed submission:
import math

N = float(raw_input())
print math.ceil(N/2)/N
Buggy python submission (verdict: Time Limit Exceeded):
N = int(raw_input())
A = list(map(int,raw_input().split()))
ans = []
for i in range(0,N):
  print A.index(i+1)+1,
  

Fixed submission:
N = int(raw_input())
A = list(map(int,raw_input().split()))
ans = [0]*N
for (index,con) in enumerate(A):
  ans[con-1] = index+1
for i in ans:
  print i,

Buggy python submission (verdict: Time Limit Exceeded):
N = int(raw_input())
A = list(map(int,raw_input().split()))
ans = []
for i in range(0,N):
  ans.append(A.index(i+1)+1)
for i in ans:
  print i, 


Fixed submission:
N = int(raw_input())
A = list(map(int,raw_input().split()))
ans = [0]*N
for (index,con) in enumerate(A):
  ans[con-1] = index+1
for i in ans:
  print i,
Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q = map(int, raw_input().split())
A = []
 
for i in range(0,Q):
  A.append(int(raw_input()))
B = K-Q
for i in range(1,N+1):
  con = A.count(i)
  if (B + con) > 0:
    print "Yes"
  else:
    print "No"

Fixed submission:
N,K,Q = map(int, raw_input().split())
K_list = [Q-K]*N
for i in range(0,Q):
  index = int(raw_input())
  K_list[index-1] = K_list[index-1] -1

for i in K_list:
  if i < 0:
    print "Yes"
  else:
    print "No"

Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q = map(int, raw_input().split())
A = []
 
for i in range(0,Q):
  A.append(int(raw_input()))
for i in range(1,N+1):
  con = A.count(i)
  if K - (Q - con) > 0:
    print "Yes"
  elif K - (Q - con) <= 0:
    print "No"
    


Fixed submission:
N,K,Q = map(int, raw_input().split())
K_list = [Q-K]*N
for i in range(0,Q):
  index = int(raw_input())
  K_list[index-1] = K_list[index-1] -1

for i in K_list:
  if i < 0:
    print "Yes"
  else:
    print "No"
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int, raw_input().split())
A = list(map(int,raw_input().split()))	
ans = 0
for i in range(0,M):
  max_A_index = A.index(max(A))
  A[max_A_index] = A[max_A_index]/2
print sum(A)

Fixed submission:
import heapq

N,M = map(int, raw_input().split())
A = list(map(lambda x: int(x)*(-1), raw_input().split()))

heapq.heapify(A)

for i in range(0,M):
  max_A = heapq.heappop(A)*(-1) / 2*(-1)
  heapq.heappush(A,max_A)

print sum(A)*(-1)

Buggy python submission (verdict: Runtime Error):
N,M = map(int, raw_input().split())
A = list(map(int,raw_input().split()))	
ans = 0
for i in range(0,M):
  max_A_index = A.index(max(A))
  A[max_A_index] = max_A/2
print sum(A)

Fixed submission:
import heapq

N,M = map(int, raw_input().split())
A = list(map(lambda x: int(x)*(-1), raw_input().split()))

heapq.heapify(A)

for i in range(0,M):
  max_A = heapq.heappop(A)*(-1) / 2*(-1)
  heapq.heappush(A,max_A)

print sum(A)*(-1)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int, raw_input().split())
A = list(map(int,raw_input().split()))	
ans = 0
for i in range(0,M):
  max_A = max(A)
  max_A_index = A.index(max(A))
  max_A = max_A / 2
  A[max_A_index] = max_A  
print sum(A)

Fixed submission:
import heapq

N,M = map(int, raw_input().split())
A = list(map(lambda x: int(x)*(-1), raw_input().split()))

heapq.heapify(A)

for i in range(0,M):
  max_A = heapq.heappop(A)*(-1) / 2*(-1)
  heapq.heappush(A,max_A)

print sum(A)*(-1)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int, raw_input().split())
A = list(map(int,raw_input().split()))	
A=sorted(A)
ans = 0
for i in range(0,M):
  max_A = A[N-1]
  max_A = max_A / 2
  A[N-1] = max_A
  A = sorted(A)
for i in A:
  ans = ans+i
  
print ans

Fixed submission:
import heapq

N,M = map(int, raw_input().split())
A = list(map(lambda x: int(x)*(-1), raw_input().split()))

heapq.heapify(A)

for i in range(0,M):
  max_A = heapq.heappop(A)*(-1) / 2*(-1)
  heapq.heappush(A,max_A)

print sum(A)*(-1)