Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import deque

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

edges = [[] for j in range(N+1)]
for p in path:
    x, y = p
    edges[x].append(y)
    edges[y].append(x)

que = deque([])
dic = {1: 0}
def bfs(now):
    e = edges[now]
    for q in e:
        if not q in dic:
            dic[q] = now
            que.append(q)
    try:
        n = que.popleft()
        bfs(n)
    except IndexError:
        pass

bfs(1)

if len(dic) != N:
    print("No")
else:
    print('Yes')
    dic_sort = sorted(dic.items())
    for elem in dic_sort:
        if elem[0] != 1:
            print(elem[1])



Fixed submission:
from collections import deque
import sys
sys.setrecursionlimit(10 ** 9)

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

edges = [[] for j in range(N+1)]
for p in path:
    x, y = p
    edges[x].append(y)
    edges[y].append(x)

que = deque([])
dic = {1: 0}
def bfs(now):
    e = edges[now]
    for q in e:
        if not q in dic:
            dic[q] = now
            que.append(q)
    try:
        n = que.popleft()
        bfs(n)
    except IndexError:
        pass

bfs(1)

if len(dic) != N:
    print("No")
else:
    print('Yes')
    dic_sort = sorted(dic.items())
    for elem in dic_sort:
        if elem[0] != 1:
            print(elem[1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys

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

alr = []
now = 1
i = 0
while not now in alr:
    alr.append(now)
    now = A[now-1]
    i += 1
    if i == K:
        print(now)
        sys.exit()

place = alr.index(now)
circle = len(alr) - place
rem = (K - place) % circle
print(alr[place + rem])

Fixed submission:
import sys

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

alr = {}
now = 1
i = 0
while not now in alr.keys():
    alr[now] = i
    now = A[now-1]
    i += 1
    if i == K:
        print(now)
        sys.exit()

place = alr[now]
circle = len(alr) - place
rem = (K - place) % circle
for k, v in alr.items():
    if v == place + rem:
        print(k)
        break
Buggy python submission (verdict: Runtime Error):
import collections
import numpy as np

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

n1, n2 = np.meshgrid(np.arange(1,N+1),np.arange(1,N+1))
t1, t2 = np.meshgrid(np.array(A), np.array(A))
ans = (np.abs(n2-n1)==t1 + t2)

print(np.count_nonzero(ans)//2)

Fixed submission:
import collections

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

P = [i+A[i] for i in range(N)]
Q = [j-A[j] for j in range(N)]

Q_dict = collections.Counter(Q)

cnt = 0
for i in range(N-1):
    Q_dict[Q[i]] -= 1
    cnt += Q_dict[P[i]]

print(cnt)

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

P = [i+A[i] for i in range(N)]
Q = [j-A[j] for j in range(N)]

cnt = 0
for i in range(N-1):
    cnt += Q[i+1:].count(P[i])

print(cnt)

Fixed submission:
import collections

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

P = [i+A[i] for i in range(N)]
Q = [j-A[j] for j in range(N)]

Q_dict = collections.Counter(Q)

cnt = 0
for i in range(N-1):
    Q_dict[Q[i]] -= 1
    cnt += Q_dict[P[i]]

print(cnt)

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

cnt = 0
for i in range(N-1):
    height_A = A[i]
    start = i + height_A
    if start < N - 1:
        for j in range(start,N):
            height_B = A[j]
            if j - i == height_A + height_B:
                cnt += 1

print(cnt)


Fixed submission:
import collections

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

P = [i+A[i] for i in range(N)]
Q = [j-A[j] for j in range(N)]

Q_dict = collections.Counter(Q)

cnt = 0
for i in range(N-1):
    Q_dict[Q[i]] -= 1
    cnt += Q_dict[P[i]]

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
 
N = len(S)

mod_list = []
for i in range(N-1, -1, -1):
    if i == N-1:
        num = int(S[i])
    else:
        num += int(S[i]) * (10 ** (N-1-i))
    mod_list.append(num % 2019)

mod_list.sort()

cnt = 0
ans = 0
for i in range(len(mod_list)-1):
    if mod_list[i] == 0:
        ans += 1
    if mod_list[i+1] == mod_list[i]:
        cnt += 1
    else:
        ans += cnt
        cnt = 0
        
print(ans)

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

mod = 2019
d = [0 for i in range(2019)]
d[0] = 1
t = 1
rem = 0

for i in reversed(S):
    rem += int(i) * t
    rem %= mod
    t *= 10
    t %= mod
    d[rem] += 1

print(int(sum([i * (i-1) / 2 for i in d])))

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
 
N = len(S)

mod_list = []
for i in range(N-1, -1, -1):
    num = int(S[i:])
    mod_list.append(num % 2019)

mod_list.sort()

cnt = 0
ans = 0
for i in range(len(mod_list)-1):
    if mod_list[i] == 0:
        ans += 1
    if mod_list[i+1] == mod_list[i]:
        cnt += 1
    else:
        ans += cnt
        cnt = 0
        
print(ans)

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

mod = 2019
d = [0 for i in range(2019)]
d[0] = 1
t = 1
rem = 0

for i in reversed(S):
    rem += int(i) * t
    rem %= mod
    t *= 10
    t %= mod
    d[rem] += 1

print(int(sum([i * (i-1) / 2 for i in d])))

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
 
N = len(S)
 
cnt = 0
alr = []
for i in range(N-4):
    if not i in alr:
        cnt_i = 1
        for j in range(i+4,N):
            S_int = int(S[i:(j+1)])
            if S_int % 2019 == 0:
                cnt += cnt_i
                cnt_i += 1
                alr.append(j+1)
print(cnt)
        


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

mod = 2019
d = [0 for i in range(2019)]
d[0] = 1
t = 1
rem = 0

for i in reversed(S):
    rem += int(i) * t
    rem %= mod
    t *= 10
    t %= mod
    d[rem] += 1

print(int(sum([i * (i-1) / 2 for i in d])))

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
 
N = len(S)
 
cnt = 0
alr = []
for i in range(N-3):
    if i in alr:
        continue
    else:
        cnt_i = 1
        for j in range(i+3,N):
            S_int = int(S[i:(j+1)])
            if S_int % 2019 == 0:
                cnt += cnt_i
                cnt_i += 1
                alr.append(j+1)
print(cnt)

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

mod = 2019
d = [0 for i in range(2019)]
d[0] = 1
t = 1
rem = 0

for i in reversed(S):
    rem += int(i) * t
    rem %= mod
    t *= 10
    t %= mod
    d[rem] += 1

print(int(sum([i * (i-1) / 2 for i in d])))

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

N = len(S)

cnt = 0
for i in range(N-3):
    for j in range(i+3,N):
        S_int = int(S[i:(j+1)])
        if S_int % 2019 == 0:
            cnt += 1
print(cnt)

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

mod = 2019
d = [0 for i in range(2019)]
d[0] = 1
t = 1
rem = 0

for i in reversed(S):
    rem += int(i) * t
    rem %= mod
    t *= 10
    t %= mod
    d[rem] += 1

print(int(sum([i * (i-1) / 2 for i in d])))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

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

RGB = {"R":[0]*N, "G":[0]*N, "B":[0]*N}
for i in range(N):
    if S[i] == "R":
        RGB["R"][i] = 1
    elif S[i] == "G":
        RGB["G"][i] = 1
    else:
        RGB["B"][i] = 1

for k in RGB.keys():
    RGB[k] = list(itertools.accumulate(RGB[k]))

ans = 0
for i in range(N-2):
    l_i = S[i]
    for j in range(i+1, N-1):
        l_j = S[j]
        d = {"R", "G", "B"}
        if l_i != l_j:
            d.remove(l_i)
            d.remove(l_j)
            l_k = d.pop()
            ans += RGB[l_k][N-1] - RGB[l_k][j]
            if j*2 - i <= N-1:
                if S[j*2 - i] == l_k:
                    ans -= 1

print(ans)




Fixed submission:
import itertools

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

RGB = {"R":[0]*N, "G":[0]*N, "B":[0]*N}
for i in range(N):
    if S[i] == "R":
        RGB["R"][i] = 1
    elif S[i] == "G":
        RGB["G"][i] = 1
    else:
        RGB["B"][i] = 1

for k in RGB.keys():
    RGB[k] = list(itertools.accumulate(RGB[k]))

ans = 0
for i in range(N-2):
    l_i = S[i]
    for j in range(i+1, N-1):
        l_j = S[j]
        d = {"R", "G", "B"}
        if l_i != l_j:
            d.remove(l_i)
            d.remove(l_j)
            l_k = d.pop()
            ans += RGB[l_k][N-1] - RGB[l_k][j]
            if j*2 - i <= N-1:
                if S[j*2 - i] == l_k:
                    ans -= 1

print(ans)

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

count = 0
for i in range(0, N-2):
    S_i = S[i]
    for j in range(i+1, N-1):
        S_j = S[j]
        if S_i != S_j:
            for k in range(j+1, N):
                S_k = S[k]
                if S_j != S_k and S_k != S_i and j-i != k-j:
                    count += 1
print(count)

Fixed submission:
import itertools

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

RGB = {"R":[0]*N, "G":[0]*N, "B":[0]*N}
for i in range(N):
    if S[i] == "R":
        RGB["R"][i] = 1
    elif S[i] == "G":
        RGB["G"][i] = 1
    else:
        RGB["B"][i] = 1

for k in RGB.keys():
    RGB[k] = list(itertools.accumulate(RGB[k]))

ans = 0
for i in range(N-2):
    l_i = S[i]
    for j in range(i+1, N-1):
        l_j = S[j]
        d = {"R", "G", "B"}
        if l_i != l_j:
            d.remove(l_i)
            d.remove(l_j)
            l_k = d.pop()
            ans += RGB[l_k][N-1] - RGB[l_k][j]
            if j*2 - i <= N-1:
                if S[j*2 - i] == l_k:
                    ans -= 1

print(ans)
Buggy python submission (verdict: Runtime Error):
x. y, z = map(int, input().split())

print(z, x, y)

Fixed submission:
x, y, z = map(int, input().split())

print(z, x, y)
Buggy python submission (verdict: Runtime Error):
if s == s[::-1]:
  #前半部分の回文チェック
  p = int((n-1)/2)
  f = s[:p]
  if f == f[::-1]:
    #後半部分の回文チェック
    q = int((n+3)/2)
    l = s[q-1:]
    if l == l[::-1]:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  print("No")

Fixed submission:
s = input()
n = len(s)

if s == s[::-1]:
  #前半部分の回文チェック
  p = int((n-1)/2)
  f = s[:p]
  if f == f[::-1]:
    #後半部分の回文チェック
    q = int((n+3)/2)
    l = s[q-1:]
    if l == l[::-1]:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import math

def combinations_count(n):
    return (n * (n - 1)) // 2

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

dic = Counter(A)

for i in range(N):
    a = A[i]
    dic[a] -= 1
    ans = 0
    for v in dic.values():
        if v >= 2:
            ans += combinations_count(v)
    dic[a] += 1
    print(ans)


Fixed submission:
from collections import Counter
import math

def combinations_count(n):
    return (n * (n - 1)) // 2

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

combs = {}
dic = Counter(A)
for k, v in dic.items():
    combs[k] = combinations_count(v)
ans = sum(combs.values())

for i in range(N):
    a = A[i]
    ans_i = ans
    if combs[a] < 2:
        ans_i -= combs[a]
        print(ans_i)
    else:
        ans_i -= dic[a] - 1
        print(ans_i)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

dic = Counter(A)

for i in range(N):
    a = A[i]
    dic[a] -= 1
    ans = 0
    for v in dic.values():
        if v >= 2:
            ans += combinations_count(v, 2)
    dic[a] += 1
    print(ans)


Fixed submission:
from collections import Counter
import math

def combinations_count(n):
    return (n * (n - 1)) // 2

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

combs = {}
dic = Counter(A)
for k, v in dic.items():
    combs[k] = combinations_count(v)
ans = sum(combs.values())

for i in range(N):
    a = A[i]
    ans_i = ans
    if combs[a] < 2:
        ans_i -= combs[a]
        print(ans_i)
    else:
        ans_i -= dic[a] - 1
        print(ans_i)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))


for i in range(n):
  b = a[:]
  b.pop(i)
  r = 0
  for j in range(n):
    c = b.count(j)
    if c > 1:
      r += c * (c-1) / 2
    else:
      pass
  print(int(r))

Fixed submission:
from collections import Counter
import math

def combinations_count(n):
    return (n * (n - 1)) // 2

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

combs = {}
dic = Counter(A)
for k, v in dic.items():
    combs[k] = combinations_count(v)
ans = sum(combs.values())

for i in range(N):
    a = A[i]
    ans_i = ans
    if combs[a] < 2:
        ans_i -= combs[a]
        print(ans_i)
    else:
        ans_i -= dic[a] - 1
        print(ans_i)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [input() for i in range(N)]

count = {}
for i in range(N):
    if not S[i] in count:
        count[S[i]] = 1
    else:
        count[S[i]] += 1
max_k_list = [kv[0] for kv in count.items() if kv[1] == max(count.values())]
max_k_list.sort()
for i in range(len(max_k_list)):
    print(max_k_list[i])


Fixed submission:
from collections import Counter

N = int(input())
S = [input() for i in range(N)]

C = Counter(S)

C = sorted(C.items(), key=lambda x:x[1], reverse=True)


cnt_max = C[0][1]
ans = []
for i in range(len(C)):
    if cnt_max > C[i][1]:
        break
    else:
        ans.append(C[i][0])

ans.sort()

for w in ans:
    print(w)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
P = list(map(int, input().split()))

def exp_k(n):
    exp_list = []
    for i in range(n):
        exp = (P[i] * (P[i] + 1) / 2) / P[i]
        exp_list.append(exp)
    return exp_list

exp_max = 0
a = exp_k(n)
for i in range(n-k+1):
    exp_sum = sum(a[i:(i+k)])
    if exp_max < exp_sum:
        exp_max = exp_sum
        
print(exp_max)

Fixed submission:
import itertools
N, K = map(int, input().split())
p = list(map(int, input().split()))

pos = [(p[i]+1)/2 for i in range(N)]

pos_acum = list(itertools.accumulate(pos))

ans = pos_acum[K-1]
for i in range(N-K):
    ans = max(ans, pos_acum[K+i]-pos_acum[i])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
P = list(map(int, input().split()))

def exp_k(s, k):
    exp_sum = 0
    for i in range(s, s+k):
        exp = (P[i] * (P[i] + 1) / 2) / P[i]
        exp_sum += exp
    return exp_sum

exp_max = 0
for i in range(n-k+1):
    a = exp_k(i, k)
    if a > exp_max:
        exp_max = a
print(exp_max)

Fixed submission:
import itertools
N, K = map(int, input().split())
p = list(map(int, input().split()))

pos = [(p[i]+1)/2 for i in range(N)]

pos_acum = list(itertools.accumulate(pos))

ans = pos_acum[K-1]
for i in range(N-K):
    ans = max(ans, pos_acum[K+i]-pos_acum[i])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
P = list(map(int, input().split()))

def exp_k(s, k):
    exp_sum = 0
    for i in range(s, s+k):
        exp = (P[i] * (P[i] + 1) / 2) / P[i]
        exp_sum += exp
    return exp_sum

exp_max = 0
for i in range(n-k+1):
    a = exp_k(i, k)
    if a > exp_max:
        exp_max = a
print(exp_max)

Fixed submission:
import itertools
N, K = map(int, input().split())
p = list(map(int, input().split()))

pos = [(p[i]+1)/2 for i in range(N)]

pos_acum = list(itertools.accumulate(pos))

ans = pos_acum[K-1]
for i in range(N-K):
    ans = max(ans, pos_acum[K+i]-pos_acum[i])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
import sys

input = sys.stdin.readline

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

    def lcm_base(x, y):
        return (x * y) // math.gcd(x, y)

    def lcm(*numbers):
        return reduce(lcm_base, numbers, 1)

    LCM = lcm(*A)
    MOD = 10 ** 9 + 7
    ans = 0
    for i in range(N):
        ans = (ans + LCM // A[i]) % MOD
    print(ans)

if __name__ == '__main__':
    main()




Fixed submission:
import math
from functools import reduce
from collections import defaultdict

#素因数分解O(√n)
def primeFactor(n):
    res = defaultdict(lambda: 0)
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            res[i] += 1
            n = n // i
    if n != 1:
        res[n] += 1
    return res

    

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

def gcd(*numbers):
    return reduce(math.gcd, numbers)

MOD = 10**9+7
GCD = gcd(*A)

P = defaultdict(lambda: 0)

for i in range(N):
    factors = primeFactor(A[i])
    for k, v in factors.items():
        if v > P[k]:
            P[k] = v


P_mod = 1
for k in P.keys():
    P_mod = P_mod*(k**P[k])%MOD

ans = 0
for i in range(N):
    b = A[i]
    mod_inv = pow(b, MOD-2, MOD)
    ans = (ans + P_mod * mod_inv) % MOD

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

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

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

LCM = lcm(*A)
MOD = 10 ** 9 + 7
ans = 0
for i in range(N):
    ans = (ans + LCM // A[i]) % MOD
print(ans)




Fixed submission:
import math
from functools import reduce
from collections import defaultdict

#素因数分解O(√n)
def primeFactor(n):
    res = defaultdict(lambda: 0)
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            res[i] += 1
            n = n // i
    if n != 1:
        res[n] += 1
    return res

    

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

def gcd(*numbers):
    return reduce(math.gcd, numbers)

MOD = 10**9+7
GCD = gcd(*A)

P = defaultdict(lambda: 0)

for i in range(N):
    factors = primeFactor(A[i])
    for k, v in factors.items():
        if v > P[k]:
            P[k] = v


P_mod = 1
for k in P.keys():
    P_mod = P_mod*(k**P[k])%MOD

ans = 0
for i in range(N):
    b = A[i]
    mod_inv = pow(b, MOD-2, MOD)
    ans = (ans + P_mod * mod_inv) % MOD

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())

import math

if N % 2 == 1:
    print(0)
else:
    half = N // 2
    m = math.floor(math.log(half, 5))
    cnt = 0
    for i in range(m):
        cnt += half // (5 ** (i+1))
    print(cnt)

Fixed submission:
N = int(input())

import math

if N % 2 == 1:
    print(0)
elif N == 0:
    print(0)
else:
    half = N // 2
    m = math.floor(math.log(half, 5))
    cnt = 0
    for i in range(m):
        cnt += half // (5 ** (i+1))
    print(cnt)
Buggy python submission (verdict: Runtime Error):
import math
import sys

X, Y = map(int, input().split())

#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

if (X + Y) % 3 != 0:
    print(0)
    sys.exit()

x = X - ((X + Y) // 3)
y = Y - ((X + Y) // 3)

mod = 10 ** 9 + 7

numerater = math.factorial(x + y) % mod
denominator_x = math.factorial(x) % mod
denominator_y = math.factorial(x) % mod
denominator = (denominator_x * denominator_y) % mod

res = (numerater * mod_inv(denominator, mod)) % mod

print(res)

Fixed submission:
import math
import sys

X, Y = map(int, input().split())

#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

if (X + Y) % 3 != 0:
    print(0)
    sys.exit()

if X / 2 > Y or Y > X * 2:
    print(0)
    sys.exit()

x = X - ((X + Y) // 3)
y = Y - ((X + Y) // 3)

mod = 10 ** 9 + 7

numerater = 1
for i in range(1, x+y+1):
    numerater =  (numerater * i) % mod

denominator_x = 1
for i in range(1, x+1):
    denominator_x = (mod_inv(i, mod) * denominator_x) % mod

denominator_y = 1
for i in range(1, y+1):
    denominator_y = (mod_inv(i, mod) * denominator_y) % mod

res = (numerater * denominator_x * denominator_y) % mod

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq

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

A_heap = A[:]
heapq.heapify(A_heap)

ans = []
for i in range(N):
    ans.append(A.index(heapq.heappop(A_heap)) + 1)
print(*ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

ans = [0] * N
for i in range(N):
    ans[A[i]-1] = i+1
print(*ans)
Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

gcd = math.gcd(A, B)
divisors = make_divisors(gcd)

def is_prime(n):
    if n == 1: return True

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

    return True

count = 0
for i in range(len(divisors)):
    if is_prime(divisors[i]):
        count += 1

print(count)

Fixed submission:
from fractions import gcd
import math
A, B = map(int, input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

gcd = gcd(A, B)
divisors = make_divisors(gcd)

def is_prime(n):
    if n == 1: return True

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

    return True

count = 0
for i in range(len(divisors)):
    if is_prime(divisors[i]):
        count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import math

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


total = sum(A)
for i in range(M):
    max_index = np.argmax(A)
    total -= math.ceil(A[max_index] / 2)
    A[max_index] = A[max_index] // 2

print(total)
    

Fixed submission:
import heapq
import math

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

B = [-A[i] for i in range(N)]
heapq.heapify(B)
while M:
    p = heapq.heappop(B)
    p /= 2
    heapq.heappush(B, p)
    M -= 1

ans = 0
for i in range(N):
    ans += math.floor(-B[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())

if B == 1:
    print(0)
else:
    C = A
    cnt = 1
    while C < B:
        C += A - 1
        cnt += 1

print(cnt)


Fixed submission:
A, B = map(int, input().split())

if B == 1:
    print(0)
else:
    C = A
    cnt = 1
    while C < B:
        C += A - 1
        cnt += 1
    print(cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))

res = []
cnt = 0
for i in range(N-1):
    if H[i+1] <= H[i]:
        cnt += 1
        if i == N - 2:
            res.append(cnt)
    else:
        res.append(cnt)
        cnt = 0
print(max(res))

Fixed submission:
N = int(input())
H = list(map(int, input().split()))

res = []
cnt = 0
for i in range(N-1):
    if H[i+1] <= H[i]:
        cnt += 1
        if i == N - 2:
            res.append(cnt)
    else:
        res.append(cnt)
        cnt = 0
if res == []:
    print(0)
else:
    print(max(res))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
for i in range(N):
  A.append(int(input()))
for i in range(N):
  B = A[:]
  del B[i]
  print(max(B))

Fixed submission:
N = int(input())
A = []
for i in range(N):
  A.append(int(input()))
A_max = max(A)
i = A.index(A_max)
del A[i]
B_max = max(A)
for j in range(N):
  if j == i:
    print(B_max)
  else:
    print(A_max)