Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
from collections import Counter
import functools
import operator


def resolve(in_):
    N, M = map(int, next(in_).split())
    A = tuple(map(lambda x: int(x) // 2, next(in_).split()))

    max_a = max(A)
    temp = [0] * (max_a + 1)
    temp[1] = 1

    for i in range(2, max_a + 1):
        if temp[i]:
            continue

        j = i
        while j < max_a + 1:
            if not temp[j]:
                temp[j] = i
            j += i

    B = Counter()
    for a in A:
        C = Counter()
        while a > 1:
            C.update((temp[a],))
            a = a // temp[a]
        B |= C
    
    lcm = functools.reduce(operator.mul, (k * v for k, v in B.items()), 1)
    lcm2 = lcm + lcm

    answer = sum(1 for _ in range(lcm, M, lcm2))
    return answer


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
import functools
from math import gcd


def lcm2(x, y):
    return x * y // gcd(x, y)


def lcm(x):
    return functools.reduce(lcm2, x)


def resolve(in_):
    N, M = map(int, next(in_).split())
    A = tuple(map(lambda x: int(x) // 2, next(in_).split()))

    a0 = A[0]
    x = 0
    while True:
        a0, b = divmod(a0, 2)
        if b:
            break
        x += 1
    x = 2 ** x
    for a in A[1:]:
        d, m = divmod(a, x)
        if m != 0 or not d % 2:
            return 0 

    l = lcm(A)
    l2 = l + l

    answer = len(range(l, M + 1, l2))

    return answer


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
A, B, K= map(int, next(sys.stdin.buffer))
x = min(A, B, K)
print(A - x, B - x)

Fixed submission:
import sys
A, B, K= map(int, next(sys.stdin.buffer).split())
if K > A:
  a = 0
  b = max(0, B - (K - A))
else:
  a = A - K
  b = B

print(a, b)

Buggy python submission (verdict: Runtime Error):
import sys
A, B, K= map(int, sys.stdin.buffer)
x = min(A, B, K)
print(A - x, B - x)

Fixed submission:
import sys
A, B, K= map(int, next(sys.stdin.buffer).split())
if K > A:
  a = 0
  b = max(0, B - (K - A))
else:
  a = A - K
  b = B

print(a, b)
Buggy python submission (verdict: Runtime Error):
5 2 3

Fixed submission:
import sys
n, a, b = map(int, sys.stdin.readline().split())
c = b - a
if c % 2:
  d = min(a - 1, n - b)
  e = 1
  f = (b - a - 1) // 2
  print(d + e + f)
else:
  print(c // 2)
Buggy python submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self, n):
        self.p = list(range(n))
    
    def find(self, x):
        if self.p[x] == x:  return x
        self.p[x] = self.find(self.p[x])
        return self.p[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x != y:  self.p[x] = y

N,M = map(int, input().split())
uf = UnionFind(N)
for i in range(M):
    a,b = map(int, input().split())
    uf.unite(a-1, b-1)

ans = 0
for i in range(1, N):
    if uf.find(0) != uf.find(i):
        uf.unite(0, i)
        ans += 1

print(ans)


Fixed submission:
import sys
sys.setrecursionlimit(int(1e9))

class UnionFind():
    def __init__(self, n):
        self.p = list(range(n))
    
    def find(self, x):
        if self.p[x] == x:  return x
        self.p[x] = self.find(self.p[x])
        return self.p[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x != y:  self.p[x] = y

N,M = map(int, input().split())
uf = UnionFind(N)
for i in range(M):
    a,b = map(int, input().split())
    uf.unite(a-1, b-1)

ans = 0
for i in range(1, N):
    if uf.find(0) != uf.find(i):
        uf.unite(0, i)
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
ans = 10**8
for i in range(len(s)):
    cnt = 0
    for j in range(len(t)):
        if s[i+j] != t[j]: cnt += 1
    ans = min(ans, cnt)

print(ans)


Fixed submission:
s = input()
t = input()
ans = 10**8
for i in range(len(s)-len(t)+1):
    cnt = 0
    for j in range(len(t)):
        if s[i+j] != t[j]: cnt += 1
    ans = min(ans, cnt)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans, m = 0, int(1e9+7)
for i in range(n-1):
    ans = (ans + a[i]*sum(a[i+1:])) % m
print(ans)


Fixed submission:
n = int(input())
a = [0] + list(map(int, input().split()))
for i in range(1, n+1):  a[i] += a[i-1]
ans, m = 0, int(1e9+7)
for i in range(1, n):
    ans = (ans + (a[i]-a[i-1])*(a[n]-a[i])) % m

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys 
S = input()
A = []
for i,s in enumerate(S):
    if s != 'x':  A.append(i)
for i in range(len(A)//2):
    if S[A[i]] != S[A[-i-1]]:
        print(-1)
        sys.exit()
ans = abs((len(S)-1-A[-1])-A[0])
for i in range(len(A)//2):
    cnt = abs(A[i+1]-A[i] - (A[-1-i]-A[-2-i]))
    ans += cnt
print(ans)


Fixed submission:
import sys 
S = input()
A = []
for i,s in enumerate(S):
    if s != 'x':  A.append(i)
if not A:
    print(0)
    sys.exit()
for i in range(len(A)//2):
    if S[A[i]] != S[A[-i-1]]:
        print(-1)
        sys.exit()
ans = abs((len(S)-1-A[-1])-A[0])
for i in range(len(A)//2):
    cnt = abs(A[i+1]-A[i] - (A[-1-i]-A[-2-i]))
    ans += cnt
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


class Combination:
    def __init__(self, n: int, mod: int):
        self.mod = mod
        self.fact = [0] * (n + 1)
        self.factinv = [0] * (n + 1)
        self.inv = [0] * (n + 1)
        
        self.fact[0] = self.fact[1] = 1
        self.factinv[0] = self.factinv[1] = 1
        self.inv[1] = 1
        for i in range(2, n + 1):
            self.fact[i] = (self.fact[i - 1] * i) % mod
            self.inv[i] = (-self.inv[mod % i] * (mod // i)) % mod
            self.factinv[i] = (self.factinv[i - 1] * self.inv[i]) % mod
    
    def ncr(self, n: int, r: int):
        if r < 0 or n < r:
            return 0
        r = min(r, n - r)
        return self.fact[n] * self.factinv[r] % self.mod * self.factinv[n - r] % self.mod
    
    def nhr(self, n: int, r: int):
        return self.ncr(n + r - 1, r)
    
    def npr(self, n: int, r: int):
        if r < 0 or n < r:
            return 0
        return self.fact[n] * self.factinv[n - r] % self.mod


def solve():
    K = int(rl())
    S = rl().rstrip()
    MOD = 10 ** 9 + 7
    
    com = Combination(2 * 10 ** 5 + 10, MOD)
    n = len(S)
    m = n + K
    ans = 0
    for i in range(n, m + 1):
        j = m - i
        ans += com.ncr(n + K - j - 1, n - 1) * pow(25, K - j, MOD) * pow(26, j, MOD)
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    solve()


Fixed submission:
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


class Combination:
    def __init__(self, n: int, mod: int):
        self.mod = mod
        self.fact = [0] * (n + 1)
        self.factinv = [0] * (n + 1)
        self.inv = [0] * (n + 1)
        
        self.fact[0] = self.fact[1] = 1
        self.factinv[0] = self.factinv[1] = 1
        self.inv[1] = 1
        for i in range(2, n + 1):
            self.fact[i] = (self.fact[i - 1] * i) % mod
            self.inv[i] = (-self.inv[mod % i] * (mod // i)) % mod
            self.factinv[i] = (self.factinv[i - 1] * self.inv[i]) % mod
    
    def ncr(self, n: int, r: int):
        if r < 0 or n < r:
            return 0
        r = min(r, n - r)
        return self.fact[n] * self.factinv[r] % self.mod * self.factinv[n - r] % self.mod
    
    def nhr(self, n: int, r: int):
        return self.ncr(n + r - 1, r)
    
    def npr(self, n: int, r: int):
        if r < 0 or n < r:
            return 0
        return self.fact[n] * self.factinv[n - r] % self.mod


def solve():
    K = int(rl())
    S = rl().rstrip()
    MOD = 10 ** 9 + 7
    
    com = Combination(2 * 10 ** 6, MOD)
    n = len(S)
    m = n + K
    ans = 0
    for i in range(n, m + 1):
        j = m - i
        ans += com.ncr(n + K - j - 1, n - 1) * pow(25, K - j, MOD) * pow(26, j, MOD)
        ans %= MOD
    print(ans)


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

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


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)
    return divisors


def solve():
    N = int(rl())
    A = list(map(int, rl().split()))
    
    a_set = set()
    memo = set()
    for ai in A:
        if ai in a_set:
            memo.add(ai)
            if ai == 1:
                print(0)
                return
        else:
            a_set.add(ai)
    if 1 in a_set:
        print(1)
        return
    
    se = set()
    A.sort()
    ans = 0
    for ai in A:
        flg = True
        divs = make_divisors(ai)
        for div in divs:
            if div in se:
                flg = False
                break
        if ai in memo:
            flg = False
        se.add(ai)
        ans += flg
    print(ans)


if __name__ == '__main__':
    solve()


Fixed submission:
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


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)
    return divisors


def solve():
    _ = int(rl())
    A = list(map(int, rl().split()))
    
    a_set = set()
    memo = set()
    for ai in A:
        if ai in a_set:
            memo.add(ai)
            if ai == 1:
                print(0)
                return
        else:
            a_set.add(ai)
    if 1 in a_set:
        print(1)
        return
    
    counter = [0] * (10 ** 6 + 1)
    for ai in A:
        for m in range(ai, 10 ** 6 + 1, ai):
            counter[m] += 1
    
    ans = 0
    for ai in A:
        if counter[ai] == 1:
            ans += 1
    print(ans)


if __name__ == '__main__':
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    H, W, K = map(int, rl().split())
    sy, sx, gy, gx = map(lambda n: int(n) - 1, rl().split())
    c = [rl().rstrip() for _ in range(H)]
    
    INF = 10 ** 10
    cost = [[INF] * W for _ in range(H)]
    cost[sy][sx] = 0
    que = deque([(sy, sx)])
    while que:
        cy, cx = que.popleft()
        for dy, dx in ((-1, 0), (0, 1), (1, 0), (0, -1)):
            for k in range(1, K + 1):
                ny, nx = cy + k * dy, cx + k * dx
                if 0 <= ny < H and 0 <= nx < W:
                    if c[ny][nx] == '@':
                        break
                    if cost[ny][nx] <= cost[cy][cx]:
                        break
                    cost[ny][nx] = cost[cy][cx] + 1
                    que.append((ny, nx))
    print(cost[gy][gx] if cost[gy][gx] != INF else -1)


if __name__ == '__main__':
    solve()


Fixed submission:
import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    H, W, K = map(int, rl().split())
    sy, sx, gy, gx = map(lambda n: int(n) - 1, rl().split())
    c = [rl().rstrip() for _ in range(H)]
    
    INF = 10 ** 10
    cost = [[INF] * W for _ in range(H)]
    cost[sy][sx] = 0
    que = deque([(sy, sx)])
    while que:
        cy, cx = que.popleft()
        for dy, dx in ((-1, 0), (0, 1), (1, 0), (0, -1)):
            for k in range(1, K + 1):
                ny, nx = cy + k * dy, cx + k * dx
                if 0 <= ny < H and 0 <= nx < W:
                    if c[ny][nx] == '@':
                        break
                    if cost[ny][nx] <= cost[cy][cx]:
                        break
                    ncost = cost[cy][cx] + 1
                    if ncost < cost[ny][nx]:
                        cost[ny][nx] = ncost
                        que.append((ny, nx))
    print(cost[gy][gx] if cost[gy][gx] != INF else -1)


if __name__ == '__main__':
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from operator import add

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


class DualSegmentTree:
    def __init__(self, size: int, segfunc, lazy_ide_ele=0):
        self.lazy_ide_ele = lazy_ide_ele
        self.segfunc = segfunc
        self.N0 = 1 << (size - 1).bit_length()
        self.lazy = [self.lazy_ide_ele] * (2 * self.N0)
    
    def gindex(self, left, right):
        L = left + self.N0
        R = right + self.N0
        lm = (L // (L & -L)) >> 1
        rm = (R // (R & -R)) >> 1
        while L < R:
            if R <= rm:
                yield R
            if L <= lm:
                yield L
            L >>= 1
            R >>= 1
        while L:
            yield L
            L >>= 1
    
    def propagates(self, *ids):
        for i in reversed(ids):
            idx = i - 1
            v = self.lazy[idx]
            if v == self.lazy_ide_ele:
                continue
            self.lazy[2 * idx + 1] = self.segfunc(self.lazy[2 * idx + 1], v)
            self.lazy[2 * idx + 2] = self.segfunc(self.lazy[2 * idx + 2], v)
            self.lazy[idx] = self.lazy_ide_ele
    
    def update(self, left: int, right: int, x):
        L = self.N0 + left
        R = self.N0 + right
        
        while L < R:
            if R & 1:
                R -= 1
                self.lazy[R - 1] = self.segfunc(self.lazy[R - 1], x)
            if L & 1:
                self.lazy[L - 1] = self.segfunc(self.lazy[L - 1], x)
                L += 1
            L >>= 1
            R >>= 1
    
    def query(self, k: int):
        self.propagates(*self.gindex(k, k + 1))
        return self.lazy[k + self.N0 - 1]


def solve():
    N, K = map(int, rl().split())
    A = list(map(int, rl().split()))
    
    for _ in range(min(K, 41)):
        dual_seg_tree = DualSegmentTree(N, add)
        for i in range(N):
            left = max(0, i - A[i])
            right = min(N - 1, i + A[i])
            dual_seg_tree.update(left, right + 1, 1)
        for i in range(N):
            A[i] = dual_seg_tree.query(i)
    print(*A)


if __name__ == '__main__':
    solve()


Fixed submission:
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, K = map(int, rl().split())
    A = list(map(int, rl().split()))
    
    for _ in range(min(K, 100)):
        imos = [0] * N
        for i in range(N):
            left = max(0, i - A[i])
            right = min(N - 1, i + A[i])
            imos[left] += 1
            if right < N - 1:
                imos[right + 1] -= 1
        for i in range(1, N):
            imos[i] += imos[i - 1]
        A = imos[:]
    print(*A)


if __name__ == '__main__':
    solve()
Buggy python submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, K = map(int, rl().split())
    if N == 0 or K == 1:
        print(0)
        exit()
    """
    if N < abs(N - K):
        print(N)
        exit()
    """
    print(min(abs(N % (N - K)), abs(N - (N - K) * (N // K + 1))))


if __name__ == '__main__':
    solve()


Fixed submission:
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, K = map(int, rl().split())
    if N % K == 0:
        print(0)
        exit()

    print(min(N % K, abs(N - K * (N // K + 1))))


if __name__ == '__main__':
    solve()
Buggy python submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    H, W = map(int, rl().split())
    s = [list(input()) for _ in range(H)]
    
    dp = [[0] * W for _ in range(H)]
    dp[0][0] = s[0][0] == '#'
    for i in range(1, W):
        dp[0][i] = dp[0][i - 1] + (s[0][i] == '#')
        dp[i][0] = dp[i - 1][0] + (s[i][0] == '#')
    
    for i in range(1, H):
        for j in range(1, W):
            dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + (s[i][j] == '#')
    print(dp[-1][-1])


if __name__ == '__main__':
    solve()


Fixed submission:
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    H, W = map(int, rl().split())
    s = [list(input()) for _ in range(H)]
    
    dp = [[0] * W for _ in range(H)]
    dp[0][0] = s[0][0] == '#'
    for i in range(1, W):
        dp[0][i] = dp[0][i - 1] + (s[0][i - 1] == '.' and s[0][i] == '#')
    for i in range(1, H):
        dp[i][0] = dp[i - 1][0] + (s[i - 1][0] == '.' and s[i][0] == '#')
    
    for i in range(1, H):
        for j in range(1, W):
            dy = s[i - 1][j] == '.' and s[i][j] == '#'
            dx = s[i][j - 1] == '.' and s[i][j] == '#'
            dp[i][j] = min(dp[i - 1][j] + dy, dp[i][j - 1] + dx)
    print(dp[-1][-1])


if __name__ == '__main__':
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque


def solve():
    S = deque(list(input()))
    Q = int(input())
    for _ in range(Q):
        query = list(input().split())
        if int(query[0]) == 1:
            S.reverse()
        else:
            if int(query[1]) == 1:
                S.appendleft(query[2])
            else:
                S.append(query[2])
    print(''.join(S))


if __name__ == '__main__':
    solve()


Fixed submission:
from collections import deque


def solve():
    S = deque(list(input()))
    Q = int(input())
    state = 0
    for _ in range(Q):
        query = list(input().split())
        if int(query[0]) == 1:
            state = 1 if state == 0 else 0
        else:
            if (state + int(query[1])) % 2 == 1:
                S.appendleft(query[2])
            else:
                S.append(query[2])
    if state == 0:
        print(''.join(S))
    else:
        S.reverse()
        print(''.join(S))


if __name__ == '__main__':
    solve()
Buggy python submission (verdict: Runtime Error):
def solve():
    S, T, A, B, U = map(int, open(0).read().split())
    if S == U:
        print(A - 1, B)
    else:
        print(A, B - 1)


if __name__ == '__main__':
    solve()


Fixed submission:
def solve():
    S, T = map(str, input().split())
    A, B = map(int, input().split())
    U = input()
    if S == U:
        print(A - 1, B)
    else:
        print(A, B - 1)


if __name__ == '__main__':
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from fractions import Fraction
from math import factorial

rl = sys.stdin.readline


def solve():
    N = int(rl())
    x = list(map(int, rl().split()))
    MOD = 10 ** 9 + 7
    
    acc = [Fraction(0)] * N
    for i in range(1, N):
        acc[i] = acc[i - 1] + Fraction(1, i)
    
    ans = 0
    for i in range(N - 1):
        ans = ans + (x[i + 1] - x[i]) * acc[i + 1] % MOD
    
    ans = int(ans * factorial(N - 1) % MOD)
    print(ans)


if __name__ == '__main__':
    solve()


Fixed submission:
import sys
from math import factorial

rl = sys.stdin.readline


def mod_div(x, y, mod=10 ** 9 + 7):
    return x * pow(y, mod - 2, mod) % mod


def solve():
    N = int(rl())
    x = list(map(int, rl().split()))
    MOD = 10 ** 9 + 7
    
    acc = [0] * N
    k = factorial(N - 1)
    for i in range(1, N):
        acc[i] = (acc[i - 1] + k) % MOD
        k = k * mod_div(i, i + 1) % MOD
    
    ans = 0
    for i in range(N - 1):
        ans = (ans + (x[i + 1] - x[i]) * acc[i + 1]) % MOD
    print(ans)


if __name__ == '__main__':
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from fractions import Fraction
from math import factorial

rl = sys.stdin.readline


def solve():
    N = int(rl())
    x = list(map(int, rl().split()))
    MOD = 10 ** 9 + 7
    
    acc = [Fraction(0)] * N
    for i in range(1, N):
        acc[i] = acc[i - 1] + Fraction(1, i)
    
    ans = 0
    for i in range(N - 1):
        ans = ans + (x[i + 1] - x[i]) * acc[i + 1] % MOD
    
    ans = int(ans * factorial(N - 1) % MOD)
    print(ans)


if __name__ == '__main__':
    solve()


Fixed submission:
import sys
from math import factorial

rl = sys.stdin.readline


def mod_div(x, y, mod=10 ** 9 + 7):
    return x * pow(y, mod - 2, mod) % mod


def solve():
    N = int(rl())
    x = list(map(int, rl().split()))
    MOD = 10 ** 9 + 7
    
    acc = [0] * N
    k = factorial(N - 1)
    for i in range(1, N):
        acc[i] = (acc[i - 1] + k) % MOD
        k = k * mod_div(i, i + 1) % MOD
    
    ans = 0
    for i in range(N - 1):
        ans = (ans + (x[i + 1] - x[i]) * acc[i + 1]) % MOD
    print(ans)


if __name__ == '__main__':
    solve()
Buggy python submission (verdict: Runtime Error):
from fractions import gcd


def solve():
    N, M, *a = map(int, open(0).read().split())
    
    a_lcm = a[0]
    for i in range(1, N):
        a_lcm = (a_lcm * a[i]) // gcd(a_lcm, a[i])
    ans = 1 + (M - a_lcm / 2) // a_lcm
    if M < a_lcm / 2:
        ans = 0
    print(int(ans))


if __name__ == '__main__':
    solve()


Fixed submission:
from fractions import gcd
from functools import reduce


def lcm(x, y):
    res = (x * y) // gcd(x, y)
    if 10 ** 9 < res:
        res = 0
    return res


def solve():
    N, M, *a = map(int, open(0).read().split())
    
    half_a = [ai // 2 for ai in a]
    half_lcm = reduce(lcm, half_a)
    
    for ai in half_a:
        if (half_lcm // ai) % 2 == 0:
            print(0)
            exit()
    
    if half_lcm == 0:
        ans = 0
    else:
        ans = (M // half_lcm) - (M // (2 * half_lcm))
    print(ans)


if __name__ == '__main__':
    solve()
Buggy python submission (verdict: Runtime Error):
def solve():
    A, B, K = map(int, input().split())
    if K <= A:
        print(A-K, B)
    elif A+B <= K:
        print(0, 0)
    else:
        print(0, B-(K-A))


if __name__ == '__main__':
    solve()


Fixed submission:
def solve():
    S, T = map(str, input().split())
    print(T+S)


if __name__ == '__main__':
    solve()
Buggy python submission (verdict: Runtime Error):
import math
from bisect import bisect_left
from random import random


def eratosthenes(n):
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


def is_prime(q, k=50):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q & 1 == 0: return False

    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True


def solve():
    X = int(input())
    if is_prime(X):
        print(X)
    else:
        primes = eratosthenes(100010)
        index = bisect_left(primes, X)
        print(primes[index])


if __name__ == '__main__':
    solve()


Fixed submission:
import math
from bisect import bisect_left


def eratosthenes(n):
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


def solve():
    X = int(input())
    primes = eratosthenes(100010)
    index = bisect_left(primes, X)
    print(primes[index])


if __name__ == '__main__':
    solve()
Buggy python submission (verdict: Runtime Error):
import sys


def solve():
    MOD = 998244353
    N, *d_l = map(int, open(0).read().split())
    ans = 1
    
    if d_l[0] != 0:
        print(0)
        sys.exit()
    
    d_max = max(d_l)
    count_l = [d_l.count(1)]
    for i in range(2, d_max+1):
        count_l.append(d_l.count(i))
        ans *= count_l[i-2] ** count_l[i-1]
    print(ans%MOD)


if __name__ == '__main__':
    solve()

Fixed submission:
def solve():
    N = int(input())
    ans = 0
    if N % 2 == 0:
        ans = N // 2 - 1
    else:
        ans = N // 2
    print(ans)


if __name__ == '__main__':
    solve()