Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
import bisect
import itertools


def solve(N: int, L: "List[int]"):
    L.sort()
    ans = 0
    ans = sum([bisect.bisect_left(L[j+1:], a+b)
               for i, a in enumerate(L[:-1], 1) for j, b in enumerate(L[i:], i)])
    print(ans)
    return


def main():
    def iterate_tokens():
        for sent in sys.stdin:
            for token in sent.split():
                yield token
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, L)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import bisect
import itertools


def solve(N: int, L: "List[int]"):
    L.sort()
    L = tuple(L)
    ans = 0
    ans = sum([bisect.bisect_left(L, a+L[j]) - j - 1
               for i, a in enumerate(L[:-1], 1) for j in range(i, N)])
    print(ans)
    return


def main():
    def iterate_tokens():
        for sent in sys.stdin:
            for token in sent.split():
                yield token
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, L)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
import bisect
import itertools


def solve(N: int, L: "List[int]"):
    L.sort()
    ans = 0
    for i, l in enumerate(L[2:]):
        way2 = sorted([sum(x) for x in itertools.combinations(L[: 2 + i], 2)])
        ans += len(way2) - bisect.bisect_right(way2, l)
    print(ans)
    return


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
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, L)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import bisect
import itertools


def solve(N: int, L: "List[int]"):
    L.sort()
    L = tuple(L)
    ans = 0
    ans = sum([bisect.bisect_left(L, a+L[j]) - j - 1
               for i, a in enumerate(L[:-1], 1) for j in range(i, N)])
    print(ans)
    return


def main():
    def iterate_tokens():
        for sent in sys.stdin:
            for token in sent.split():
                yield token
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, L)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


def solve(A: int, B: int):
    while A % B:
        tmp = B
        B = A % B
        A = tmp
    if B == 1:
        print(1)
    else:
        ans = factorization(B)
        print(len(ans)+1)
    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()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
# %%

import sys


def solve(N: int):
    return (N+1)//2/N


# %%

# 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
    print(solve(N))


if __name__ == '__main__':
    main()


# %%
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def era(N: int):
    N1 = N+1
    prim = [0]*N1
    i = 2
    while i**2 < N1:
        if prim[i] == 0:
            for j in range(i**2, N1, i):
                if prim[j] == 0:
                    prim[j] = i
        i += 1
    ans = []
    p = N
    n = prim[p]
    while n != 0:
        ans.append(n)
        p = p // n
        n = prim[p]
    ans.append(n)
    return ans


def solve(A: int, B: int):

    while A % B:
        tmp = B
        B = A % B
        A = tmp
    ans = set(era(B))
    print(len(ans)+1)
    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()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


def solve(A: int, B: int):
    while A % B:
        tmp = B
        B = A % B
        A = tmp
    if B == 1:
        print(1)
    else:
        ans = factorization(B)
        print(len(ans)+1)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def sort(A):
    for i in range(1, len(A)):
        insert(A, i)


def insert(A, i):
    temp = A[i]
    for j in range(i - 1, -1, -1):
        if temp < A[j]:
            A[j + 1] = A[j]
        else:
            A[j + 1] = temp
            break
    else:
        A[0] = temp


def solve(N: int, M: int, A: "List[int]"):
    sort(A)
    for i in range(M):
        MD = A[-1]
        A[-1] = MD // 2
        sort(A)
        if A[-1] == 0:
            break
    print(sum(A))
    return


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


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, A: "List[int]"):
    while M > 0:
        A = sorted(A, reverse=True)
        MD = A[0] // 2
        for i, ai in enumerate(A):
            if ai > MD and M > 0:
                A[i] = ai//2
                M -= 1
            else:
                break
        if A[i] == 0:
            break
    print(sum(A))
    return


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

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, A: "List[int]"):
    A = sorted(A)
    for i in range(M):
        MD = A[-1]
        A[-1] = MD // 2
        A = sorted(A)
        if A[-1] == 0:
            break
    print(sum(A))
    return


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


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, A: "List[int]"):
    while M > 0:
        A = sorted(A, reverse=True)
        MD = A[0] // 2
        for i, ai in enumerate(A):
            if ai > MD and M > 0:
                A[i] = ai//2
                M -= 1
            else:
                break
        if A[i] == 0:
            break
    print(sum(A))
    return


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()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def z_algo(S):
    N = len(S)
    A = [0]*N
    i = 1
    j = 0
    A[0] = len_s = len(S)
    while i < len_s:
        while i+j < len_s and S[j] == S[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while len_s-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k
        j -= k
    return A


def solve(N: int, S: str):
    ans = 0
    for i in range(N-1):
        ans = max(z_algo(S[i:])[(N-i+1)//2:] + [ans])
    print(ans)
    return


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
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def z_algo(N, S):
    end = 1
    start = 0
    max_length = 0

    while start < N:
        while end-start > N-end:
            break
        subword = S[start:end]
        if subword in S[end:]:
            max_length = max(max_length, len(subword))
            end += 1
        else:
            start += 1
            if start == end:
                end += 1
    return max_length


def solve(N: int, S: str):
    print(z_algo(N, S))
    return


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
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
s=input()
if (int(s[0])*int(s[-1]))%2 == 1:
  print("Odd")
 else:
  print("Even")

Fixed submission:
s=input().split()
if (int(s[0])*int(s[-1]))%2 == 1:
  print("Odd")
else:
  print("Even")
Buggy python submission (verdict: Runtime Error):
num_list=int(input())
a=[int(x) for x in input().split()]
for i in range(num_list):
  b=[int(x) for x in input().split()]
  if (abs(b[1]-a[1])+abs(b[2]-a[2]))<=(b[0]-a[0]) and (abs(b[1]-a[1])+abs(b[2]-a[2])) != 0:
    if i+2 == num_list:
      print("Yes")
      break
    a=b
    continue
  else:
    print("No")
    break

Fixed submission:
num_list=int(input())
a=[0,0,0]
for i in range(num_list):
  b=[int(x) for x in input().split()]
  dt=(b[0]-a[0])
  d=(abs(b[1]-a[1])+abs(b[2]-a[2]))
  if d<=dt and dt%2==d%2:
    if i == num_list-1:
      print("Yes")
      break
    a=b
  else:
    print("No")
    break

Buggy python submission (verdict: Runtime Error):
num_list=int(input())
a=[int(x) for x in input().split()]
for i in range(num_list):
  b=[int(x) for x in input().split()]
  if (abs(b[1]-a[1])+abs(b[2]-a[2]))<=(b[0]-a[0]):
    if i+2 == num_list:
      print("Yes")
      break
    a=b
    continue
  else:
    print("No")
    break

Fixed submission:
num_list=int(input())
a=[0,0,0]
for i in range(num_list):
  b=[int(x) for x in input().split()]
  dt=(b[0]-a[0])
  d=(abs(b[1]-a[1])+abs(b[2]-a[2]))
  if d<=dt and dt%2==d%2:
    if i == num_list-1:
      print("Yes")
      break
    a=b
  else:
    print("No")
    break

Buggy python submission (verdict: Runtime Error):
num_list=int(input())
a=[int(x) for x in input().split()]
print(a)
for i in range(num_list):
  b=[int(x) for x in input().split()]
  print(b)
  if (abs(b[1]-a[1])+abs(b[2]-a[2]))<=(b[0]-a[0]):
    if i+2 == num_list:
      print("Yes")
      break
    a=b
    continue
  else:
    print("No")
    break

Fixed submission:
num_list=int(input())
a=[0,0,0]
for i in range(num_list):
  b=[int(x) for x in input().split()]
  dt=(b[0]-a[0])
  d=(abs(b[1]-a[1])+abs(b[2]-a[2]))
  if d<=dt and dt%2==d%2:
    if i == num_list-1:
      print("Yes")
      break
    a=b
  else:
    print("No")
    break
Buggy python submission (verdict: Runtime Error):
import collections

N,K,Q = map(int,input().split())
lst =[int(input()) for i in range (Q)]

if K > Q :
    for i in range(N):
        print('Yes')
    exit(0)
else:
    x = Q - K

#s = set(lst)
c = collections.Counter(lst)

values, counts = zip(*c.most_common(x))

if len(values) == 0 :
    for i in range(N):
        print('No')
    exit(0)
    

#print(values)
#print(type(values))
newlist = sorted(values)
j = 0
l = len(values)
for i in range(N):
    if l-1 >= j :
        if i +1 == values[j] :
            print('Yes')
            j += 1
        else:
            print('No')
    else:
        print('No')



Fixed submission:
N,K,Q = map(int,input().split())

lst = [0] * N

for i in range(Q):
    lst[int(input())-1] += 1

x = Q - K 

for i in range(len(lst)):
    if lst[i] - x > 0 :
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Runtime Error):
import collections

N,K,Q = map(int,input().split())
lst =[int(input()) for i in range (Q)]

if K > Q :
    for i in range(N):
        print('Yes')
    exit(0)
else:
    x = Q - K

#s = set(lst)
c = collections.Counter(lst)

values, counts = zip(*c.most_common(x))

if len(values) == 0 :
    for i in range(N):
        print('No')
        exit(0)

#print(values)
#print(type(values))
#values.sort()
j = 0
l = len(values)
for i in range(N):
    if l-1 >= j :
        if i +1 == values[j] :
            print('Yes')
            j += 1
        else:
            print('No')
    else:
        print('No')


Fixed submission:
N,K,Q = map(int,input().split())

lst = [0] * N

for i in range(Q):
    lst[int(input())-1] += 1

x = Q - K 

for i in range(len(lst)):
    if lst[i] - x > 0 :
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
lst = list(map(int,input().split()))

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

print (sum(lst))



Fixed submission:
import heapq

N,M = map(int,input().split())
#lst = list(map(int,input().split()))
lst = [-int(x) for x in input().split()]

heapq.heapify(lst)
 
for i in range(M):
    lstmin = heapq.heappop(lst)
    b = (-(lstmin) // 2)
    heapq.heappush(lst,-b)
    
print (-sum(lst))

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
lst = list(map(int,input().split()))

lst.sort(reverse=True)

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

print (sum(lst))



Fixed submission:
import heapq

N,M = map(int,input().split())
#lst = list(map(int,input().split()))
lst = [-int(x) for x in input().split()]

heapq.heapify(lst)
 
for i in range(M):
    lstmin = heapq.heappop(lst)
    b = (-(lstmin) // 2)
    heapq.heappush(lst,-b)
    
print (-sum(lst))
Buggy python submission (verdict: Runtime Error):
N = int(input())
cnt = 0
for i in range(1,N+1):
    if len(str(i)) % 2 != 0:
        cnt += 1
print (cnt)


Fixed submission:
a, b, c = map(int, input().split())

if c - ( a - b) >= 0  :
    print( c - ( a - b))
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
N = int(input())

lst = []
for i in range(N):
    lst.append(int(input()))

for i in range(N):
    lstAns = copy.copy(lst)
    a = lstAns.pop(i)
    print(max(lstAns))


Fixed submission:
N = int(input())

lst = []
for i in range(N):
    lst.append(int(input()))

lstA = sorted(lst,reverse=True)

for i in range(N):
    if lst[i] == lstA[0]:
        print(lstA[1])
    else:
        print(lstA[0])
Buggy python submission (verdict: Runtime Error):
D = int(input())

if ( D == 25 )
	print('Christmas')
elif (D == 24)
	print('Christmas Eve')
elif (D == 23)
	print('Christmas Eve Eve')
elif (D == 22)
	print('Christmas Eve Eve Eve')


Fixed submission:
D = int(input())
 
if ( D == 25 ):
	print('Christmas')
elif (D == 24):
	print('Christmas Eve')
elif (D == 23):
	print('Christmas Eve Eve')
elif (D == 22):
	print('Christmas Eve Eve Eve')
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n == 1:
  print('Hello World')
else:
  a,b = map(int,input().split())
  print( a + b )
  

Fixed submission:
n = int(input())
if n == 1:
  print('Hello World')
else:
  a = int(input())
  b = int(input())
  print( a + b )
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N = int(input())

lst = []
# listにN個の数値を格納
for i in range(N):
    lst.append(int(input()))

l_sum = sum(lst)

p_list = []

if l_sum % 10 == 0:
    
    # enumerate()関数を使うと、forループの中でリスト（配列）インデックス番号（カウント、順番）を取得できる
    # i にインデックス番号が入る

    for i, _ in enumerate(lst, 1):
        # permutations()を使うと 第2引数分の全パターンを取得できる
        for j in itertools.permutations(lst, r=i):  # rには1、2、3と渡される
            p_list.append(j)

    q_list = sorted(set(list(map(sum, p_list))),reverse=True)
    x = 0
    for i, item in enumerate(q_list, 1):
        if item % 10 != 0 :
            print(item)
            exit(0)
    
    if x == 0:
        print(0)

else:
    print (l_sum)




Fixed submission:
N = int(input())

lst = []
# listにN個の数値を格納
for i in range(N):
    lst.append(int(input()))

lst.sort()
lstsum = sum(lst)
p_list = [ i / 10 for i in lst if i % 10 != 0 ]

if len(p_list) == 0:
    print(0)
elif lstsum % 10 != 0:
    print(lstsum)
else:
    for i in range(N):
        ans = lstsum - lst[i]
        if ans % 10 != 0:
            print(ans)
            exit(0)

Buggy python submission (verdict: Runtime Error):
import itertools

N = int(input())

lst = []
# listにN個の数値を格納
for i in range(N):
    lst.append(int(input()))

l_sum = sum(lst)

p_list = []

if l_sum % 10 == 0:
    
    # enumerate()関数を使うと、forループの中でリスト（配列）インデックス番号（カウント、順番）を取得できる
    # i にインデックス番号が入る

    for i, _ in enumerate(lst, 1):
        # permutations()を使うと 第2引数分の全パターンを取得できる
        for j in itertools.permutations(lst, r=i):  # rには1、2、3と渡される
            p_list.append(j)
    
    q_list = sorted(set(list(map(sum, p_list))),reverse=True)
    
    x = 0
    for i, item in enumerate(q_list, 1):
        if item % 10 != 0 :
            print(item)
            x = 1
            break
    
    if x = 0:
        print(0)

else:
    print (l_sum)




Fixed submission:
N = int(input())

lst = []
# listにN個の数値を格納
for i in range(N):
    lst.append(int(input()))

lst.sort()
lstsum = sum(lst)
p_list = [ i / 10 for i in lst if i % 10 != 0 ]

if len(p_list) == 0:
    print(0)
elif lstsum % 10 != 0:
    print(lstsum)
else:
    for i in range(N):
        ans = lstsum - lst[i]
        if ans % 10 != 0:
            print(ans)
            exit(0)
Buggy python submission (verdict: Runtime Error):
import math

a, b, x = map(int, input().split())

if b >= a:
    theta = 0.5 * math.asin((4*x)/(b*b*a))
    print(90 - math.degrees(theta))
else:
    theta = math.atan((2*(a*a*b-x))/(a*a*a))
    print(math.degrees(theta))


Fixed submission:
import math

a, b, x = map(int, input().split())

if a*a*b/2 > x:
    theta = math.atan((2*x)/(b*b*a))
    print(90 - math.degrees(theta))
else:
    theta = math.atan((2*(a*a*b-x))/(a*a*a))
    print(math.degrees(theta))

Buggy python submission (verdict: Runtime Error):
import math

a, b, x = map(int, input().split())

if b >= a:
    theta = 0.5 * math.asin((4*x)/(b*b*a))
    print(90 - math.degrees(theta))
else:
    theta = math.atan((2*(a*a*b-x))/(a*a*a))
    print(math.degrees(theta))


Fixed submission:
import math

a, b, x = map(int, input().split())

if a*a*b/2 > x:
    theta = math.atan((2*x)/(b*b*a))
    print(90 - math.degrees(theta))
else:
    theta = math.atan((2*(a*a*b-x))/(a*a*a))
    print(math.degrees(theta))
Buggy python submission (verdict: Runtime Error):
from scipy.sparse.csgraph import floyd_warshall

N, M, L = map(int, input().split())
edges = [[0] * N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    edges[a - 1][b - 1] = c
    edges[b - 1][a - 1] = c

Q = int(input())
st = []
for _ in range(Q):
    st.append([int(j) - 1 for j in input().split()])

edges = floyd_warshall(edges)

for i in range(N):
    for j in range(N):
        if edges[i][j] <= L:
            edges[i][j] = 1
        else:
            edges[i][j] = 0

edges = floyd_warshall(edges)

for i, j in st:
    if edges[i][j] == float("inf"):
        print(-1)
    else:
        print(int(edges[i][j]) - 1)


Fixed submission:
from scipy.sparse.csgraph import floyd_warshall

N, M, L = map(int, input().split())
edges = [[0] * N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    edges[a - 1][b - 1] = c
    edges[b - 1][a - 1] = c

Q = int(input())
st = []
for _ in range(Q):
    st.append([int(j) - 1 for j in input().split()])

edges = floyd_warshall(edges)

for i in range(N):
    for j in range(N):
        if edges[i][j] <= L:
            edges[i][j] = 1
        else:
            edges[i][j] = 0

edges = floyd_warshall(edges)

for i, j in st:
    if edges[i][j] == float("inf"):
        print(-1)
    else:
        print(int(edges[i][j]) - 1)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import sys

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

for i in range(M):
    x = A.pop(N-1)
    if x == 0:
        break
    x = x // 2
    A.insert(bisect.bisect_left(A, x), x)
print(sum(A))


Fixed submission:
import heapq

N, M = map(int, input().split())
A = [-int(x) for x in input().split()]
heapq.heapify(A)
for i in range(M):
    x = heapq.heappop(A)
    x = int(x / 2)
    heapq.heappush(A, x)  # pop minimum
print(-sum(A))

Buggy python submission (verdict: Runtime Error):
import bisect
import sys

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

for i in range(M):
    x = A.pop(N-1)
    if x == 0:
        break
    x = x // 2
    A.insert(bisect.bisect_left(A, x), x)
print(sum(A)

Fixed submission:
import heapq

N, M = map(int, input().split())
A = [-int(x) for x in input().split()]
heapq.heapify(A)
for i in range(M):
    x = heapq.heappop(A)
    x = int(x / 2)
    heapq.heappush(A, x)  # pop minimum
print(-sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
import copy

N = int(input())
S = input()

c = []
find = []
for i in range(N//2+1):
    new_c = copy.deepcopy(c)
    for k in c:
        v = k+S[i]
        if v in S[i+1:]:
            find.append(len(v))
        new_c.append(v)
    if S[i] not in c:
        if S[i] in S[i+1:]:
            find.append(1)
        new_c.append(S[i])
    c = new_c
if len(find)>0:
    print(max(find))
else:
    print(0)

Fixed submission:
N = int(input())
S = input()

r=0
i=j=0
while j < N:
    t = S[i:j]
    if t in S[j:]:
        r = max(r, j-i)
        j += 1
    else:
        i += 1
print(r)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
if N == 1:
    print(0)
    exit()

M = 1
for i in range(2, N):
    m = i % (i+1)
    M += m
print(M)

Fixed submission:
N = int(input())
N = N-1
if N % 2 == 0:
    print((N+1) * (N//2))
else:
    n = N-1
    print((n+1) * (n//2) + N)