Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math


def median(array):
    if N % 2:
        return array[N // 2]
    else:
        return sum(array[N // 2 - 1: N // 2 + 1]) / 2


N = int(input())
A, B = [], []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
x = median(A)
y = median(B)
if N % 2:
    print(y - x + 1)
else:
    temp = math.ceil(y) - math.floor(x)
    print(2 * temp + 1))


Fixed submission:
import math


def median(array):
    if N % 2:
        return array[N // 2]
    else:
        return sum(array[N // 2 - 1: N // 2 + 1])


N = int(input())
A, B = [], []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
x = median(A)
y = median(B)
print(y - x + 1)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
graph = [set() for i in range(N)]
for i, a in enumerate(A):
    graph[i].add(a - 1)

stack = [0]
seen = {0}
path = []
dist = [-1] * N
while stack:
    cur = stack.pop()
    if dist[cur] != -1:
        break
    dist[cur] = len(path)
    path.append(cur)
    for nei in graph[cur]:
        if nei not in seen:
            stack.append(nei)
            seen.add(nei)

not_loop = graph[cur].pop()
loop = len(path) - not_loop
if K < not_loop:
    print(path[K] + 1)
else:
    K -= not_loop
    K %= loop
    print(path[not_loop + K - 1] + 1)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
graph = [set() for i in range(N)]
for i, a in enumerate(A):
    graph[i].add(a - 1)

queue = [0]
seen = {0}
path = []
while queue:
    new = []
    for cur in queue:
        path.append(cur)
        for nei in graph[cur]:
            if nei not in seen:
                new.append(nei)
                seen.add(nei)
    queue = new

if 0 in graph[path[-1]]:
    rest = K % len(path)
    print(path[rest] + 1)
else:
    if K < len(path):
        print(path[K] + 1)
    else:
        start = graph[path[-1]].pop()
        index = path.index(start)
        rest = (K - len(path[:index])) % len(path[index:])
        print(path[index:][rest] + 1)
Buggy python submission (verdict: Runtime Error):
from decimal import *


def target(x):
    x = Decimal(x)
    return (A * x).divmod(B) - A * (x.divmod(B))


A, B, N = map(int, input().split())
A = Decimal(A)
B = Decimal(B)

left = 1
right = N

while right - left > 1:
    mid = left + (right - left) // 2
    y = target(mid)
    prv = target(mid - 1)
    nxt = target(mid + 1)
    if prv <= y <= nxt:
        left = mid
    else:
        right = mid


print(target(right))


Fixed submission:
def target(x):
    return (A * x) // B - A * (x // B)


A, B, N = map(int, input().split())
print(target(min(B - 1, N)))

Buggy python submission (verdict: Runtime Error):
from decimal import *


def target(x):
    x = Decimal(x)
    return (A * x).divmod(B) - A * (x.divmod(B))


A, B, N = map(int, input().split())
A = Decimal(A)
B = Decimal(B)

left = 1
right = N

while right - left > 1:
    mid = left + (right - left) // 2
    y = target(mid)
    prv = target(mid - 1)
    nxt = target(mid + 1)
    if prv <= y <= nxt:
        left = mid
    else:
        right = mid


print(target(right))


Fixed submission:
def target(x):
    return (A * x) // B - A * (x // B)


A, B, N = map(int, input().split())
print(target(min(B - 1, N)))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
pairs = []
for i, c1 in enumerate(S):
    for j, c2 in enumerate(S[i + 1:], start=i + 1):
        if c1 != c2:
            pairs.append((i, j))
res = 0
for i, j in pairs:
    for k, c3 in enumerate(S[j + 1:], start=j + 1):
        if j - i == k - j:
            continue
        elif S[j] == c3 or S[i] == c3:
            continue
        else:
            res += 1
print(res)

Fixed submission:
N = int(input())
S = list(input())
n = len(S)
pairs = []
for i, c1 in enumerate(S):
    for j, c2 in enumerate(S[i + 1:], start=i + 1):
        if c1 != c2:
            pairs.append((i, j))
prefix = [[0] * 3 for _ in range(len(S) + 1)]
for i, c in enumerate(S, start=1):
    if c == 'R':
        prefix[i][0] += prefix[i - 1][0] + 1
        prefix[i][1] += prefix[i - 1][1]
        prefix[i][2] += prefix[i - 1][2]
    elif c == 'G':
        prefix[i][1] += prefix[i - 1][1] + 1
        prefix[i][0] += prefix[i - 1][0]
        prefix[i][2] += prefix[i - 1][2]
    else:
        prefix[i][2] += prefix[i - 1][2] + 1
        prefix[i][0] += prefix[i - 1][0]
        prefix[i][1] += prefix[i - 1][1]
res = 0
for i, j in pairs:
    if {S[i], S[j]} == {'R', 'G'}:
        res += prefix[-1][2] - prefix[j + 1][2]
        if 2 * j - i < n and S[2 * j - i] == 'B':
            res -= 1
    elif {S[i], S[j]} == {'R', 'B'}:
        res += prefix[-1][1] - prefix[j + 1][1]
        if 2 * j - i < n and S[2 * j - i] == 'G':
            res -= 1
    elif {S[i], S[j]} == {'B', 'G'}:
        res += prefix[-1][0] - prefix[j + 1][0]
        if 2 * j - i < n and S[2 * j - i] == 'R':
            res -= 1
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
N, X, Y = map(int, input().split())
graph = [set() for _ in range(N)]
graph[X - 1].add(Y - 1)
graph[Y - 1].add(X - 1)
for i in range(N - 1):
    graph[i].add(i + 1)
    graph[i + 1].add(i)


dist = [[10 ** 9] * N for _ in range(N)]
for i in range(N):
    queue = [i]
    seen = {i}
    dist[i][i] = 0
    while queue:
        new = []
        for cur in queue:
            for nei in graph[cur]:
                dist[i][nei] = min(dist[i][nei], dist[i][cur] + 1)
                if nei not in seen:
                    new.append(nei)
                    seen.add(nei)
        queue = new
count = [0] * N
for i in range(N):
    for j in range(i + 1, N):
        count[dist[i][j]] += 1

for c in count[1:]:
    print(c)

Fixed submission:
N, X, Y = map(int, input().split())
graph = [set() for _ in range(N)]
graph[X - 1].add(Y - 1)
graph[Y - 1].add(X - 1)
for i in range(N - 1):
    graph[i].add(i + 1)
    graph[i + 1].add(i)


dist = [[10 ** 9] * N for _ in range(N)]
for i in range(N):
    queue = [i]
    seen = {i}
    dist[i][i] = 0
    while queue:
        new = []
        for cur in queue:
            for nei in graph[cur]:
                dist[i][nei] = min(dist[i][nei], dist[i][cur] + 1)
                if nei not in seen:
                    new.append(nei)
                    seen.add(nei)
        queue = new
count = [0] * N
for i in range(N):
    for j in range(i + 1, N):
        count[dist[i][j]] += 1

for c in count[1:]:
    print(c)
Buggy python submission (verdict: Time Limit Exceeded):
import math
import collections


f = math.factorial


def comb(n, r, memo):
    if (n, r) in memo:
        return memo[n, r]
    elif n < r:
        memo[n, r] = 0
        return 0
    else:
        res = memo[n, r] = f(n) // f(r) // f(n - r)
        return res


N = int(input())
A = list(map(int, input().split()))
memo = {}
counts = collections.Counter(A)
for a in A:
    res = 0
    for val, count in counts.items():
        if val == a:
            count -= 1
        res += comb(count, 2, memo)
    print(res)

Fixed submission:
import math
import collections


f = math.factorial


def comb(n, r, memo):
    if (n, r) in memo:
        return memo[n, r]
    elif n < r:
        memo[n, r] = 0
        return 0
    else:
        res = memo[n, r] = f(n) // f(r) // f(n - r)
        return res


N = int(input())
A = list(map(int, input().split()))
memo = {}
counts = collections.Counter(A)
total = sum(comb(count, 2, memo) for count in counts.values())
for a in A:
    count = counts[a] - 1
    diff = count * (counts[a] - count + 1) // 2
    print(total - diff)
Buggy python submission (verdict: Runtime Error):
import math


a, b, c = map(int, input().split())
if math.log2(a + b + 2 * ((a * b) ** .5)) < math.log2(c):
    print('Yes')
else:
    print('No')

Fixed submission:
from decimal import Decimal, getcontext

getcontext().prec = 100

a, b, c = map(Decimal, input().split())
if a + b + Decimal(2) * (a * b).sqrt() < c:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque


S = deque(list(input()))
Q = int(input())
queries = []
for _ in range(Q):
    query = input().split()
    if len(query) == 3:
        queries.append([int(x) for x in query[:2]] + [query[2]])
    else:
        if len(queries[-1]) == 1:
            queries.pop()
        else:
            queries.append([int(x) for x in query])

for query in queries:
    if len(query) == 3:
        if query[1] == 1:
            S.appendleft(query[2])
        else:
            S.append(query[2])
    else:
        S.reverse()
print(''.join(S))

Fixed submission:
from collections import deque


S = deque(list(input()))
Q = int(input())
queries = []
for _ in range(Q):
    query = input().split()
    if len(query) == 3:
        queries.append([int(x) for x in query[:2]] + [query[2]])
    else:
        if len(queries[-1]) == 1:
            queries.pop()
        else:
            queries.append([int(x) for x in query])
p = True
count = 0
for query in queries:
    if len(query) == 3:
        if p:
            if query[1] == 1:
                S.appendleft(query[2])
            else:
                S.append(query[2])
        else:
            if query[1] == 1:
                S.append(query[2])
            else:
                S.appendleft(query[2])
    else:
        p = not p
        count += 1

if count % 2:
    S.reverse()
print(''.join(S))

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


S = deque(list(input()))
Q = int(input())
queries = []
for _ in range(Q):
    query = input().split()
    if len(query) == 3:
        queries.append([int(x) for x in query[:2]] + [query[2]])
    else:
        if len(queries[-1]) == 1:
            queries.pop()
        else:
            queries.append([int(x) for x in query])

for query in queries:
    if len(query) == 3:
        if query[1] == 1:
            S.appendleft(query[2])
        else:
            S.append(query[2])
    else:
        S.reverse()
print(''.join(S))

Fixed submission:
from collections import deque


S = deque(list(input()))
Q = int(input())
queries = []
for _ in range(Q):
    query = input().split()
    if len(query) == 3:
        queries.append([int(x) for x in query[:2]] + [query[2]])
    else:
        if len(queries[-1]) == 1:
            queries.pop()
        else:
            queries.append([int(x) for x in query])
p = True
count = 0
for query in queries:
    if len(query) == 3:
        if p:
            if query[1] == 1:
                S.appendleft(query[2])
            else:
                S.append(query[2])
        else:
            if query[1] == 1:
                S.append(query[2])
            else:
                S.appendleft(query[2])
    else:
        p = not p
        count += 1

if count % 2:
    S.reverse()
print(''.join(S))
Buggy python submission (verdict: Runtime Error):
H, N = map(int, input().split())
AB = [[int(x) for x in input().split()] for _ in range(N)]
dp = [float('inf')] * (H + 1)
dp[0] = 0
for h in range(H + 1):
    for a, b in AB:
        h_new = min(h + a, H)
        dp[h_new] = min(dp[h] + b, dp[h_new])
print(dp[-1])

Fixed submission:
import math

H, A = map(int, input().split())
print(math.ceil(H / A))
Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
AB = [[int(x) for x in input().split()] for _ in range(N)]
dp = [float('inf')] * (H + 1)
dp[0] = 0
for h in range(H + 1):
    for a, b in AB:
        h_new = min(h + a, H)
        dp[h_new] = min(dp[h] + b, dp[h_new])
print(dp[-1])

Fixed submission:
H, N = map(int, input().split())
AB = [[int(x) for x in input().split()] for _ in range(N)]
dp = [float('inf')] * (H + 1)
dp[0] = 0
for h in range(H + 1):
    for a, b in AB:
        h_new = min(h + a, H)
        dp[h_new] = min(dp[h] + b, dp[h_new])
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10 ** 6)


def dp(H, memo):
    if H in memo:
        return memo[H]
    if H <= 0:
        return 0
    res = min(dp(H - a, memo) + b for a, b in AB)
    memo[H] = res
    return res

H, N = map(int, input().split())
AB = []
for _ in range(N):
    a, b = map(int, input().split())
    AB.append((a, b))
memo = {}
print(dp(H, memo))

Fixed submission:
H, N = map(int, input().split())
AB = [[int(x) for x in input().split()] for _ in range(N)]
dp = [float('inf')] * (H + 1)
dp[0] = 0
for h in range(H + 1):
    for a, b in AB:
        h_new = min(h + a, H)
        dp[h_new] = min(dp[h] + b, dp[h_new])
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10 ** 6)


def dp(H, memo={}):
    if H <= 0:
        return 0
    elif H in memo:
        return memo[H]
    res = min(dp(H - a, memo) + b for a, b in zip(A, B))
    memo[H] = res
    return res

H, N = map(int, input().split())
A, B = [], []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

print(dp(H))

Fixed submission:
H, N = map(int, input().split())
AB = [[int(x) for x in input().split()] for _ in range(N)]
dp = [float('inf')] * (H + 1)
dp[0] = 0
for h in range(H + 1):
    for a, b in AB:
        h_new = min(h + a, H)
        dp[h_new] = min(dp[h] + b, dp[h_new])
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
N, K, S = map(int, input().split())
arr = [1 if S > N else S + 1] * N
for i in range(K):
    arr[i] = S
print(arr)

Fixed submission:
W = int(input())
H = int(input())
N = int(input())
longer = max(W, H)
res = cur = 0
while cur < N:
    cur += longer
    res += 1
print(res)
Buggy python submission (verdict: Runtime Error):
k, x = map(int, input())
if 500 * k >= x:
  print('Yes')
else:
  print('No')

Fixed submission:
k, x = map(int, input().split())
if 500 * k >= x:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
import math

A, B = map(int, input().split())
print(A * B // math.gcd(A, B))

Fixed submission:
def gcd(x, y):
    while y > 0:
        x, y = y, x % y
    return x


A, B = map(int, input().split())
print(A * B // gcd(A, B))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations


_ = input()
s = input()
seen = set()
for x in combinations(s, 3):
    if x not in seen:
        seen.add(x)

print(len(seen))

Fixed submission:
N = int(input())
S = input()
 
ans = 0
for i in range(1000):
    s = str(i).zfill(3)
 
    index = 0
    for j in range(N):
        if s[index] == S[j]:
            index += 1
        if index == 3:
            ans += 1
            break
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from itertools import combinations, permutations

def dist(x1, y1, x2, y2):
    return ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** .5


n = int(input())
xy = [[int(i) for i in input().split()] for _ in range(n)]
edges = list(range(n))
memo = {}
res = 0
for p in permutations(edges):
    for i, a in enumerate(p[1:], start=1):
        b = p[i - 1]
        if (a, b) in memo:
            res += memo[a, b]
        else:
            d = dist(*xy[a], *xy[b])
            memo[a, b] = d
            memo[b, a] = d
            res += d
print(res / math.factorial(n))

Fixed submission:
import math
from itertools import combinations, permutations

def dist(x1, y1, x2, y2):
    return ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** .5


n = int(input())
xy = [[int(i) for i in input().split()] for _ in range(n)]
edges = list(range(n))
memo = {}
res = 0
for p in permutations(edges):
    for i, a in enumerate(p[1:], start=1):
        b = p[i - 1]
        if (a, b) in memo:
            res += memo[a, b]
        else:
            d = dist(xy[a][0], xy[a][1], xy[b][0], xy[b][1])
            memo[a, b] = d
            memo[b, a] = d
            res += d
print(res / math.factorial(n))

Buggy python submission (verdict: Runtime Error):
import math
from itertools import combinations, permutations

def dist(x1, y1, x2, y2):
    return ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** .5


n = int(input())
xy = [[int(i) for i in input().split()] for _ in range(n)]
edges = list(range(n))
memo = {}
res = 0
for p in permutations(edges):
    for i, a in enumerate(p[1:], start=1):
        b = p[i - 1]
        if (a, b) in memo:
            res += memo[a, b]
        else:
            d = dist(*xy[a], *xy[b])
            memo[a, b] = d
            memo[b, a] = d
            res += d
print(res / math.factorial(n))

Fixed submission:
import math
from itertools import combinations, permutations

def dist(x1, y1, x2, y2):
    return ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** .5


n = int(input())
xy = [[int(i) for i in input().split()] for _ in range(n)]
edges = list(range(n))
memo = {}
res = 0
for p in permutations(edges):
    for i, a in enumerate(p[1:], start=1):
        b = p[i - 1]
        if (a, b) in memo:
            res += memo[a, b]
        else:
            d = dist(xy[a][0], xy[a][1], xy[b][0], xy[b][1])
            memo[a, b] = d
            memo[b, a] = d
            res += d
print(res / math.factorial(n))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10 ** 8)


def dp(i, j, memo={}):
    if (i, j) in memo:
        return memo[i, j]
    elif i < 0 or j < 0:
        return 0
    elif i == 0 and j == 0:
        return 1
    res = dp(i - 1, j - 2, memo) + dp(i - 2, j - 1, memo)
    memo[i, j] = res
    return res


x, y = map(int, input().split())
print(dp(x, y) % (10 ** 9 + 7))

Fixed submission:
import math
MOD = 1000000000+7
X, Y = map(int, input().split())
 
if ((2*Y-X)%3 != 0) or ((2*X-Y)%3 != 0) or (2*Y-X) < 0 or (2*X-Y) < 0:
    print(0)
elif 2 *Y == X or 2 * X == Y:
    print(1)
else:
    x = (2*Y-X) // 3
    y = (2*X-Y) // 3
    fac_list = [None for _ in range(x+y+2)]
    inv_fac_list = [None for _ in range(x+y+2)]
 
    fac_list[0] = 1
    for i in range(1, x+y+2):
        fac_list[i] = i * fac_list[i-1] % MOD
 
    inv_fac_list[x+y+1] = pow(fac_list[x+y+1],(MOD - 2), MOD)
    for i in range(x+y, 0, -1):
        inv_fac_list[i] = inv_fac_list[i+1] * (i+1) % MOD
 
    print((fac_list[x+y] * inv_fac_list[x] * inv_fac_list[y]) % MOD)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N,M,L = map(int,input().split())
ABC = [list(map(int,input().split())) for _ in [0]*M]
Q = int(input())
ST = [list(map(int,input().split())) for _ in [0]*Q]


INF = (L+1)*N
d = [[INF]*N for _ in [0]*N]
for i in range(N):
    d[i][i] = 0
for a,b,c in ABC:
    a-=1;b-=1
    d[a][b] = c
    d[b][a] = c

def Warshall_Floyd(d,N=None):
    if N==None : N = len(d)
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j],d[i][k]+d[k][j])

Warshall_Floyd(d,N)

d2 = [None]*N
for i,row in enumerate(d):
    d2[i] = [1 if e<=L else INF for e in row]
    d2[i][i] = 0

Warshall_Floyd(d2,N)

for s,t in ST:
    s-=1;t-=1
    ans = (d2[s][t]%INF)-1
    print(ans)

Fixed submission:
A, B = map(int, input().split())
diff = A - 2 * B
if diff > 0:
  print(diff)
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
N, M, L = map(int,input().split())
ABC = [list(map(int, input().split())) for _ in [0] * M]
Q = int(input())
ST = [list(map(int, input().split())) for _ in [0] * Q]


INF = (L + 1) * N
d = [[INF] * N for _ in [0] * N]
for i in range(N):
    d[i][i] = 0
for a, b, c in ABC:
    a -= 1
    b -= 1
    d[a][b] = c
    d[b][a] = c

def Warshall_Floyd(d, N=None):
    if N is None:
      N = len(d)
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])

Warshall_Floyd(d, N)

d2 = [None] * N
for i, row in enumerate(d):
    d2[i] = [1 if e <= L else INF for e in row]
    d2[i][i] = 0

Warshall_Floyd(d2, N)

for s, t in ST:
    s -= 1
    t -= 1
    ans = (d2[s][t] % INF) - 1
    print(ans)

Fixed submission:
A, B = map(int, input().split())
diff = A - 2 * B
if diff > 0:
  print(diff)
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left, bisect_right


def count(i, j):
    l1, l2 = L[i], L[j]
    low = l2 - l1
    high = l2 + l1
    arr = L[j + 1:]
    start = bisect_right(arr, low)
    end = bisect_left(arr, high)
    return end - start


if __name__ == '__main__':
    input()
    L = [int(x) for x in input().split()]
    L.sort()
    total = 0
    for i in range(len(L)):
        for j in range(i + 1, len(L)):
            total += count(i, j)
    print(total)

Fixed submission:
from bisect import bisect_left, bisect_right


def count(i, j):
    l1, l2 = L[i], L[j]
    low = l2 - l1
    high = l2 + l1
    start = bisect_right(L, low, j + 1)
    end = bisect_left(L, high, j + 1)
    return end - start


if __name__ == '__main__':
    input()
    L = [int(x) for x in input().split()]
    L.sort()
    total = 0
    for i in range(len(L)):
        for j in range(i + 1, len(L)):
            total += count(i, j)
    print(total)

Buggy python submission (verdict: Time Limit Exceeded):
def backtrack(i, j, memo):
    if (i, j) in memo:
        return 0
    memo[i, j] = True
    l1, l2 = L[i], L[j]
    count = 0
    for l3 in L[j + 1:]:
        if l3 < l1 + l2 and l2 < l1 + l3 and l1 < l2 + l3:
            count += 1
        else:
            break
    return count


if __name__ == '__main__':
    input()
    L = [int(x) for x in input().split()]
    L.sort()
    total = 0
    memo = {}
    for i in range(len(L)):
        for j in range(i + 1, len(L)):
            total += backtrack(i, j, memo)
    print(total)

Fixed submission:
from bisect import bisect_left, bisect_right


def count(i, j):
    l1, l2 = L[i], L[j]
    low = l2 - l1
    high = l2 + l1
    start = bisect_right(L, low, j + 1)
    end = bisect_left(L, high, j + 1)
    return end - start


if __name__ == '__main__':
    input()
    L = [int(x) for x in input().split()]
    L.sort()
    total = 0
    for i in range(len(L)):
        for j in range(i + 1, len(L)):
            total += count(i, j)
    print(total)
Buggy python submission (verdict: Runtime Error):
import math


def sieve_of_eratosthenes(n):
    candidate = [i for i in range(2, n+1)]
    prime = []
    limit = math.sqrt(n) + 1

    while True:
        p = min(candidate)
        if limit <= p:
            prime.extend(candidate)
            break
        prime.append(p)

        candidate = [i for i in candidate if i % p != 0]
    return prime


a, b = map(int, input().split())
if a > b:
    a, b = b, a
prime = sieve_of_eratosthenes(b)
res = 1
for p in prime:
    if a %p == b % p == 0:
        res += 1
print(res)

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

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

    if temp != 1:
        arr.add(temp)

    if not arr:
        arr.add(n)

    return arr

if a == b == 1:
    print(1)
else:
    fa = factorization(a)
    fb = factorization(b)
    res = 1
    for n in fa:
        if n in fb:
            res += 1
    print(res)

Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())
nums = [x for x in reversed(range(2, min(a, b) + 1)) if a % x == b % x == 0]
res = 1
while nums:
    x = nums.pop()
    res += 1
    nums = [y for y in nums if y % x != 0]
print(res)

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

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

    if temp != 1:
        arr.add(temp)

    if not arr:
        arr.add(n)

    return arr

if a == b == 1:
    print(1)
else:
    fa = factorization(a)
    fb = factorization(b)
    res = 1
    for n in fa:
        if n in fb:
            res += 1
    print(res)
Buggy python submission (verdict: Runtime Error):
next_weather = {'Sunny': 'Cloudy', 'Cloudy': 'Rainy', 'Rainy': 'Sunny'}
print(next_weahter[input()])

Fixed submission:
next_weather = {'Sunny': 'Cloudy', 'Cloudy': 'Rainy', 'Rainy': 'Sunny'}
print(next_weather[input()])