Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
 
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)
 
A, B = map(int, input().split(" "))
if A >= B:
  C = gcd(A,B)
else:
  C = gcd(B,A)

c = math.ceil(math.sqrt(C)) + 1
l = [1]
f = [1] + [0]*c

for i in range(2,c+1):
  if f[i-1] == 0:
    f[i-1] = 1
    if C % i == 0:
      l.append(i)
      while C % i == 0:
        C //= i
    for j in range(i+i, c+1, i):
      f[j-1] = 1
      
if C > 1:
  l.appned(C)

print(len(l))

Fixed submission:
import math
 
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)

A, B = map(int, input().split(" "))
if A >= B:
  C = gcd(A,B)
else:
  C = gcd(B,A)

c = math.ceil(math.sqrt(C)) + 1
l = [1]
f = [1] + [0]*c

for i in range(2,c+1):
  if f[i-1] == 0:
    f[i-1] = 1
    if C % i == 0:
      l.append(i)
      while C % i == 0:
        C //= i
    for j in range(i+i, c+1, i):
      f[j-1] = 1

if C > 1:
  l.append(C)

print(len(l))

Buggy python submission (verdict: Runtime Error):
import math
 
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)

A, B = map(int, input().split(" "))
if A >= B:
  C = gcd(A,B)
else:
  C = gcd(B,A)

#c = math.ceil(math.sqrt(C)) + 1
l = [1]
f = [0]*C
ans = 0
 
for i in range(2,C+1):
  if f[i-1] == 0:
    f[i-1] = 1
    if C % i == 0:
      l.append(i)
    for j in range(i+i, C+1, i):
      f[j-1] = 1

print(len(l))

Fixed submission:
import math
 
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)

A, B = map(int, input().split(" "))
if A >= B:
  C = gcd(A,B)
else:
  C = gcd(B,A)

c = math.ceil(math.sqrt(C)) + 1
l = [1]
f = [1] + [0]*c

for i in range(2,c+1):
  if f[i-1] == 0:
    f[i-1] = 1
    if C % i == 0:
      l.append(i)
      while C % i == 0:
        C //= i
    for j in range(i+i, c+1, i):
      f[j-1] = 1

if C > 1:
  l.append(C)

print(len(l))

Buggy python submission (verdict: Runtime Error):
import math
 
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)

A, B = map(int, input().split(" "))
if A >= B:
  C = gcd(A,B)
else:
  C = gcd(B,A)

#c = math.ceil(math.sqrt(C)) + 1
l = [1]
f = [0]*C
ans = 0
 
for i in range(2,C+1):
  if f[i-1] == 0:
    f[i-1] = 1
    l.append(i)
    for j in range(i+i, C+1, i):
      f[j-1] = 1

for i in l:
  if C % i == 0:
    ans += 1

print(ans)

Fixed submission:
import math
 
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)

A, B = map(int, input().split(" "))
if A >= B:
  C = gcd(A,B)
else:
  C = gcd(B,A)

c = math.ceil(math.sqrt(C)) + 1
l = [1]
f = [1] + [0]*c

for i in range(2,c+1):
  if f[i-1] == 0:
    f[i-1] = 1
    if C % i == 0:
      l.append(i)
      while C % i == 0:
        C //= i
    for j in range(i+i, c+1, i):
      f[j-1] = 1

if C > 1:
  l.append(C)

print(len(l))
Buggy python submission (verdict: Runtime Error):
from collections import deque
import bisect

N, M = map(int, input().split(" "))
As = [0]+list(map(int, input().split(" ")))
As = sorted(As)
cnt = 0
cnt2 = 1
for _ in range(M):
  i = As[-1-cnt]  
  i = i//(2**cnt2)
  if i < As[-1-cnt-1]:
    cnt += 1
    cnt2 = 1
    bisect.insort_left(As,i)
  else:
    cnt2 += 1

print(sum(As[:-cnt]))


Fixed submission:
n = input()
weather = {0:"Sunny", 1:"Cloudy", 2:"Rainy"}

           
for k, v in weather.items():
  if v == n:
    nk = k
    break

nk = (nk+1) % 3

print(weather[nk])

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

def input():
  return sys.stdin.readline()

weather = {0:"Sunny", 1:"Cloudy", 2:"Rainy"}
n = input()
           
for k, v in weather.items():
  if v == n:
    nk = k
    break

nk = (nk+1) % 3

print(weather[nk])

Fixed submission:
n = input()
weather = {0:"Sunny", 1:"Cloudy", 2:"Rainy"}

           
for k, v in weather.items():
  if v == n:
    nk = k
    break

nk = (nk+1) % 3

print(weather[nk])

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

def input():
  return sys.stdin.readline()

weather = {0:"Sunny", 1:"Cloudy", 2:"Rainy"}
n = input()
           
for k, v in weather.items():
  if v == n:
    nk = k
    break

nk = (nk+1) % 3

print(weather[nk])

Fixed submission:
n = input()
weather = {0:"Sunny", 1:"Cloudy", 2:"Rainy"}

           
for k, v in weather.items():
  if v == n:
    nk = k
    break

nk = (nk+1) % 3

print(weather[nk])

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

def input():
  return sys.stdin.readline()

weather = {0:"Sunny", 1:"Cloudy", 2:"Rainy"}
n = input()
           
for k, v in weather.items():
  if v == n:
    nk = k
    break

nk = (nk+1) % 3

print(weather[nk])


Fixed submission:
n = input()
weather = {0:"Sunny", 1:"Cloudy", 2:"Rainy"}

           
for k, v in weather.items():
  if v == n:
    nk = k
    break

nk = (nk+1) % 3

print(weather[nk])
Buggy python submission (verdict: Runtime Error):
import bisect

n = int(input())
P = list(map(int, input().split(" ")))
sp = sorted(P, reverse=True)
bi = []
bisect.insort(bi,P.index(sp[0]))
C = 0
lc = 0
rc = 0
C1 = 0
for j in sp[1:]:
  i = P.index(j)
  #bisect.insort(bi,i)
  l = bisect.bisect_left(bi,i)
  if l == 0:
    lc = i + 1
    if len(bi) == 1:
      rc = n - bi[0]
    else:
      rc = bi[l+1] - bi[l]
    C1 = lc*rc
  elif l == len(bi):
    if len(bi) == 1:
      lc = bi[0] + 1
    else:
      lc = bi[l-1] - bi[l-2]
    rc = n - i
    C1 = lc*rc
  else: 
    if len(bi) == 2:
      lc = bi[0] + 1
      rc = bi[1] - i
      C1 = lc*rc
      lc = i - bi[0]
      rc = n - bi[1]
      C1 += lc*rc
    elif l == 1:
      lc = bi[0] + 1
      rc = bi[1] - i
      C1 = lc*rc
      lc = i - bi[0]
      rc = bi[2] - bi[1]
      C1 += lc*rc
    elif l == len(bi) - 1:
      lc = bi[l-1] - bi[l-2]
      rc = bi[l] - i
      C1 = lc*rc
      lc = i - bi[l-1]
      rc = n - bi[l]
      C1 += lc*rc
    else:
      lc = bi[l-1] - bi[l-2]
      rc = bi[l] - i
      C1 = lc*rc
      lc = i - bi[l-1]
      rc = bi[l+1] - bi[l]
      C1 += lc*rc
  C += (P[i]*C1)
  bisect.insort(bi,i)
  
print(C)

Fixed submission:
n = int(input())
print(n**3)
Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split(" "))
 
ns= [list(map(int, input().split(" ")))  for _ in range(N-1)]
 
flags = [False]*N
dic = [[] for _ in range(N)]
rlt = [0]*N
 
for i in range(N-1):
  dic[ns[i][1]-1] += [ns[i][0]-1]
  dic[ns[i][0]-1] += [ns[i][1]-1]
  
for p, x in (map(int, input().split()) for _ in range(Q)):
  rlt[p - 1] += x
 
que = [0]
while len(que):
  a = que.pop(0)
  flags[a] = True
  for e in dic[a]:
    if flags[e]:
      continue
    else:
      rlt[e] += rlt[a]
      que.append(e)
    
print(" ".join(map(str, rlt)))

Fixed submission:
a = int(input())
s = input()

if a < 3200:
  print('red')
else:
  print(s)
Buggy python submission (verdict: Runtime Error):
import math

S = int(input())
t = math.sqrt(S)
a = b = math.ceil(t)

if a*(b-1) >= S:
  b -= 1

d = a*b - S
if d == 0:
  c = 0
print("0 0 {} {} {} {}".format(a, c, d, b))

Fixed submission:
import math

S = int(input())
t = math.sqrt(S)
a = b = math.ceil(t)

if a*(b-1) >= S:
  b -= 1

d = a*b - S
if d == 0:
  c = 0
else:
  c = 1
print("0 0 {} {} {} {}".format(a, c, d, b))
Buggy python submission (verdict: Runtime Error):
from collections import Counter

N = int(input())
S = input()
P = 10**9 + 7

dic = Counter(S)
rlt = 1

for k in dic:
  rlt = rlr*(dic[k]+1) % P
  
print(rlt-1)

Fixed submission:
from collections import Counter

N = int(input())
S = input()
P = 10**9 + 7

dic = Counter(S)
rlt = 1

for k in dic:
  rlt = rlt*(dic[k]+1) % P
  
print(rlt-1)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = 10**5
Q = int(input())

lst1 = [2]
for L in range(3, N, 2):
    if all(L % L2 != 0 for L2 in lst1):
        lst1.append(L)

lst1 = set(lst1) 
lst2 = [i for i in lst1 if (i+1)//2 in lst1]

lst2.sort()

for _ in range(Q):
  l, r = map(int, input().split())
  a = bisect.bisect_left(lst2, l)
  b = bisect.bisect_right(lst2, r)
  print(b-a)

Fixed submission:
import bisect, math
N = 10**5
Q = int(input())

lst1 = [2]
for L in range(3, N, 2):
  f = 0
  for d in range(3, math.floor(math.sqrt(L))+1, 2):
    if L % d == 0:
      f = 1
      break
  if f == 0:
    lst1.append(L)

lst1 = set(lst1) 
lst2 = [i for i in lst1 if (i+1)//2 in lst1]

lst2.sort()

for _ in range(Q):
  l, r = map(int, input().split())
  a = bisect.bisect_left(lst2, l)
  b = bisect.bisect_right(lst2, r)
  print(b-a)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = 10**5
Q = int(input())

lst1 = [2]
for L in range(3, N, 2):
    if all(L % L2 != 0 for L2 in lst1):
        lst1.append(L)

lst2 = [i for i in lst1 if (i+1)//2 in lst1]

lst2.sort()

for _ in range(Q):
  l, r = map(int, input().split())
  a = bisect.bisect_left(lst2, l)
  b = bisect.bisect_right(lst2, r)
  print(b-a)

Fixed submission:
import bisect, math
N = 10**5
Q = int(input())

lst1 = [2]
for L in range(3, N, 2):
  f = 0
  for d in range(3, math.floor(math.sqrt(L))+1, 2):
    if L % d == 0:
      f = 1
      break
  if f == 0:
    lst1.append(L)

lst1 = set(lst1) 
lst2 = [i for i in lst1 if (i+1)//2 in lst1]

lst2.sort()

for _ in range(Q):
  l, r = map(int, input().split())
  a = bisect.bisect_left(lst2, l)
  b = bisect.bisect_right(lst2, r)
  print(b-a)
Buggy python submission (verdict: Time Limit Exceeded):
import math

N = int(input())

T,A = map(int, input().split())
rlt = T+A
for _ in range(N-1):
  t,a = map(int, input().split())
  i = math.ceil(rlt/(t+a))
  while i*t < T or i*a < A:
    i += 1
  T = i*t
  A = i*a
  
print(T+A) 

Fixed submission:
import math

N = int(input())

T,A = map(int, input().split())
for _ in range(N-1):
  t,a = map(int, input().split())
  if T % t == 0:
    i = T // t
  else:
    i = T // t + 1
  if A % a == 0:
    j = A // a
  else:
    j = A // a + 1
  k = max(i,j)
  T = k*t
  A = k*a
  
print(T+A)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections
import bisect

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    n = int(input())

    ans = 0
    for i in range(1,n):
        if len(make_divisors(n-i)) != 0:
            num = len(make_divisors(n-i))
            ans += num
    print(ans)



if __name__ == '__main__':
    main()


Fixed submission:
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections
import bisect

def main():
    n = int(input())
    ans = 0
    for i in range(1, n):
        ans += (n-1)//i
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    n,k = map(int, input().split())
    A = list(map(int, input().split()))

    before = 1
    for i in range(k):
        before *= A[k-1-i]
    for i in range(k,n):
        after = (before//A[i-k])*A[i]
        if before < after:
            print('Yes')
        else:
            print('No')
        before = after


if __name__ == '__main__':
    main()


Fixed submission:
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    n,k = map(int, input().split())
    A = list(map(int, input().split()))

    for i in range(k,n):
        if A[i-k]<A[i]:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    n,k = map(int, input().split())
    A = list(map(int, input().split()))

    array = [0]*n
    before = 1
    for i in range(k):
        before *= A[k-1-i]
    for i in range(k,n):
        tmp = 1
        after = (before//A[i-k])*A[i]
        if before < after:
            print('Yes')
        else:
            print('No')
        before = after


if __name__ == '__main__':
    main()


Fixed submission:
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    n,k = map(int, input().split())
    A = list(map(int, input().split()))

    for i in range(k,n):
        if A[i-k]<A[i]:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    n,k = map(int, input().split())
    A = list(map(int, input().split()))

    array = [0]*n
    for i in range(k-1,n):
        tmp = 1
        for j in range(k):
            tmp *= A[i-j]
        array[i] = tmp

    for i in range(k-1, n-1):
        if array[i] < array[i+1]:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()


Fixed submission:
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    n,k = map(int, input().split())
    A = list(map(int, input().split()))

    for i in range(k,n):
        if A[i-k]<A[i]:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9
import fractions

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

    A.sort()
    ans = len(A)
    if n == 1:
        print(1)
        return
    for i in range(n):
        for j in range(n):
            ri = -i-1
            r = A[ri]
            l = A[j]

            if (ri!=-n and r == A[ri-1]) or (j!=n-1 and r == A[ri+1]):
                ans -= 1
                break
            if n+ri == j:
                break
            if r % l == 0:
                ans -= 1
                break
            if l >= r**(1/2):
                break
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9
import fractions

def main():
    X = list(map(int, input().split()))

    ans = 0
    for i in range(5):
        if X[i]==0:
            if i==4:
                ans = X[i-1]+1
                print(ans)
                return
            ans = X[i+1]-1
            print(ans)
            return



if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9
import fractions

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

    A.sort()
    ans = len(A)
    if n == 1:
        print(1)
        return
    for i in range(n):
        for j in range(n):
            ri = -i-1
            r = A[ri]
            l = A[j]
            if (ri!=-n and r == A[ri-1]) or (i!=n-1 and r == A[ri+1]):
                ans -= 1
                break
            if n+ri == j:
                break
            if r % l == 0:
                ans -= 1
                break
            if l >= r**(1/2):
                break
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9
import fractions

def main():
    x,n = map(int, input().split())
    P = list(map(int, input().split()))

    ans = INF
    array = set(range(x-n-1,x+n+1))
    array = array - set(P)
    array = list(array)
    for i in range(len(array)):
        ans = min(ans, abs(array[i]-x))
    if (x-ans) in P:
        print(x+ans)
    else:
        print(x-ans)




if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    n,m = map(int, input().split())
    H = list(map(int,input().split()))
    # array = [list(map(int,input().split())) for _ in range(m)]
    pool = set(range(1, n+1))

    for i in range(m):
        a,b = map(int,input().split())
        # a,b = array[i]
        if H[a-1] < H[b-1]:
            pool = pool - set([a])
        else:
            pool = pool - set([b])

    print(len(pool))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    S = input()

    if S=='ABC':
        print('ARC')
    else:
        print('ABC')


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
import fractions

def main():
    import math
    k = int(input())
    ans = 0

    for i in range(1,k+1):
        for j in range(1,k+1):
            for l in range(1,k+1):
                ans += reduce(lambda a,b: fractions.gcd(a, b), [i,j,l])
    print(ans)


if __name__ == '__main__':
    main()

Fixed submission:
from functools import reduce
import fractions

def main():
    import math
    k = int(input())
    ans = 0

    for i in range(1,k+1):
        for j in range(1,k+1):
            for l in range(1,k+1):
                ans += reduce(lambda a,b: math.gcd(a,b), [i,j,l])
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    A = list(map(int, input().split()))

    for i in range(n):
        a = A.pop()
        if a in A:
            print('NO')
            return
    print('YES')


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    A = list(map(int, input().split()))

    A_set = set(A)
    if len(A) == len(A_set):
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import math

def main():
    h = int(input())
    n = math.floor(math.log2(h))
    print(2**(n+1)-1)


if __name__ == '__main__':
    main()


Fixed submission:
import math

def main():
    h = int(input())
    n = math.floor(math.log(h,2))
    print(2**(n+1)-1)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

def main():
    n,m = map(int, input().split())
    wa = 0
    ac = 0
    used = {}
    wa_tmp = {}
    for _ in range(m):
        p,s = map(str, input().split())
        if used.get(p):
            continue
        if s == 'WA':
            if not wa_tmp.get(p):
                wa_tmp[p] = 0
            wa_tmp[p] += 1
        if s == 'AC':
            ac += 1
            used[p] = True
            wa += wa_tmp[p]
    print(ac, wa)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

def main():
    n,m = map(int, input().split())
    wa = 0
    ac = 0
    used = {}
    wa_tmp = {}
    for _ in range(m):
        p,s = map(str, input().split())
        if used.get(p):
            continue
        if s == 'WA':
            if not wa_tmp.get(p):
                wa_tmp[p] = 0
            wa_tmp[p] += 1
        if s == 'AC':
            ac += 1
            used[p] = True
            if wa_tmp.get(p):
                wa += wa_tmp[p]
    print(ac, wa)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

def main():
    a,b = map(int, input().split())

    print(a*b//math.gcd(a, b))


if __name__ == '__main__':
    main()


Fixed submission:
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9
import fractions

def main():
    a,b = map(int, input().split())

    print(a*b//fractions.gcd(a, b))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

def main():
    a,b = map(int, input().split())

    print(a*b//math.gcd(a, b))


if __name__ == '__main__':
    main()


Fixed submission:
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9
import fractions

def main():
    a,b = map(int, input().split())

    print(a*b//fractions.gcd(a, b))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

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

    if sum(A) => 22:
        print('bust')
    else:
        print('win')


if __name__ == '__main__':
    main()


Fixed submission:
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

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

    if sum(A) >= 22:
        print('bust')
    else:
        print('win')


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = [int(x) for x in input().split()]

    array = []
    for i in range(n):
        array.append(str(a.index(i+1)+1))
    print(' '.join(array))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    a = [int(x) for x in input().split()]

    array = ['']*n
    for i in range(n):
        array[a[i]-1] = str(i+1)
    print(' '.join(array))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import math

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


def main():
    n,m = map(int, input().split())
    A = list(map(int, input().split()))
    for i in range(m):
        maximum = max(A)
        index = find_index(A,maximum)
        A[index] = int(math.floor(maximum/2))
    print(sum(A))


if __name__ == '__main__':
    main()


Fixed submission:
import heapq

def main():
    n,m = map(int, input().split())
    A = list(map(lambda x: -int(x), input().split()))

    heapq.heapify(A)
    for i in range(m):
        temp_min = heapq.heappop(A)
        heapq.heappush(A, (-1)*(-temp_min//2))
    print(-sum(A))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = [int(input()) for i in range(N)]

    temp = 0
    minimum = -1
    for i in range(N):
        temp = A[i]
        A[i] = minimum
        print(max(A))
        A[i] = temp


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    A_sorted = sorted(A)

    for i in range(N):
        if A_sorted[-1] == A[i]:
            print(A_sorted[-2])
        else:
            print(A_sorted[-1])


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = [int(input()) for i in range(N)]

    temp = 0
    minimum = -1
    for i in range(N):
        temp = A[i]
        A[i] = minimum
        print(max(A))
        A[i] = temp


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    A_sorted = sorted(A)

    for i in range(N):
        if A_sorted[-1] == A[i]:
            print(A_sorted[-2])
        else:
            print(A_sorted[-1])


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = [int(input()) for i in range(N)]
    temp = 0
    minimum = min(A)
    for i in range(N):
        temp = A[i]
        A[i] = minimum
        print(max(A))
        A[i] = temp


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    A_sorted = sorted(A)

    for i in range(N):
        if A_sorted[-1] == A[i]:
            print(A_sorted[-2])
        else:
            print(A_sorted[-1])


if __name__ == '__main__':
    main()