alexjercan/bugnet huggingface dataset:
Problem p02811 (Python) — buggy submission, verdict: Runtime Error

if __name__ == "__main__":
    m, n = map(int, input().split())
    if m * 500 >= n:
        print("Yes")
    else:
        print("No")


Error: ValueError: invalid literal for int() with base 10: '2 900'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02811/Python/s384378340.py", line 2, in <module>
    x = int(input())
ValueError: invalid literal for int() with base 10: '2 900'


Fixed submission:

if __name__ == "__main__":
    x = int(input())
    m, n = map(int, input().split())
    if m * 500 >= n:
        print("Yes")
    else:
        print("No")
Problem p02812 (Python) — buggy submission, verdict: Runtime Error

n = int(input())
s = input()
ans = 0
for i in range(n):
    if s[i : i + 3] == "ABC":
        ans += 1
print(ans)


Error: 0

Fixed submission:

n = int(input())
s = input()
ans = 0
for i in range(n):
    if s[i] == "A" and s[i + 1] == "B" and s[i + 2] == "C":
        ans += 1
print(ans)
Problem p02812 (Python) — buggy submission, verdict: Runtime Error

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

ans = 0
for i in range(N):
    if S[i : i + 3] == "ABC":
        ans += 1

print(ans)


Error: 0

Fixed submission:

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

ans = 0
i = 0
while i < N:
    if S[i] == "A":
        i += 1
        if S[i] == "B":
            i += 1
            if S[i] == "C":
                ans += 1
            else:
                i += 1
        else:
            i += 1
    else:
        i += 1

print(ans)
Problem p02812 (Python) — buggy submission, verdict: Runtime Error

N = int(input())
S = input()
count = 0
for i in range(N):
    try:
        if S[i] == "A" and S[i + 1] == "B" and S[i + 2] == "C":
            count += 1
    except IndexError:
        break
print(count)


Error: 0

Fixed submission:

N = int(input())
S = input()
count = 0
for i in range(N):
    if S[i] == "A" and S[i + 1] == "B" and S[i + 2] == "C":
        count += 1
print(count)
Problem p02813 (Python) — buggy submission, verdict: Runtime Error

# ABC150C - Count Order
from itertools import permutations


def main():
    N = int(input())
    P = tuple(map(int, input().split()))
    Q = tuple(map(int, input().split()))
    perms = list(permutations(range(1, N + 1)))
    ans = abs(perms.index(P) - perms.index(Q))
    print(ans)


if __name__ == "__main__":
    main()


Error: ValueError: [1, 3, 2] is not in list
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02813/Python/s593478625.py", line 14, in <module>
    main()
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02813/Python/s593478625.py", line 9, in main
    ans = abs(perms.index(P) - perms.index(Q))
ValueError: [1, 3, 2] is not in list


Fixed submission:

# ABC150C - Count Order
from itertools import permutations


def main():
    N, *PQ = map(int, open(0).read().split())
    P, Q = PQ[:N], PQ[N:]
    perms = list(permutations(range(1, N + 1), N))
    ans = abs(perms.index(P) - perms.index(Q))
    print(ans)


if __name__ == "__main__":
    main()
Problem p02813 (Python) — buggy submission, verdict: Runtime Error

import math

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
per = math.factorial(n - 1)
r = 0
r2 = 0
for k in range(1, n)[::-1]:
    t = p[0]
    c = sum([t > x for x in p])
    r += per * c
    p.remove(t)
    t = q[0]
    c = sum([t > x for x in q])
    r2 += per * c
    q.remove(t)
    per = int(per / k)

print(int(abs(r - r2)))


Error: ModuleNotFoundError: No module named 'scipy'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02813/Python/s340291207.py", line 1, in <module>
    from scipy.special import perm
ModuleNotFoundError: No module named 'scipy'


Fixed submission:

from scipy.special import perm

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
per = perm(n - 1, n - 1, exact=True)
r = 0
r2 = 0
for k in range(1, n)[::-1]:
    t = p[0]
    c = sum([t > x for x in p])
    r += per * c
    p.remove(t)
    t = q[0]
    c = sum([t > x for x in q])
    r2 += per * c
    q.remove(t)
    per = int(per / k)

print(int(abs(r - r2)))
Problem p02813 (Python) — buggy submission, verdict: Runtime Error

# ABC150C - Count Order
from itertools import permutations


def main():
    N = int(input())
    P = tuple(map(int, input().split()))
    Q = tuple(map(int, input().split()))
    perms = tuple(permutations(range(1, N + 1)))
    ans = abs(perms.index(P) - perms.index(Q))
    print(ans)


if __name__ == "__main__":
    main()


Error: ValueError: [1, 3, 2] is not in list
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02813/Python/s713702771.py", line 14, in <module>
    main()
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02813/Python/s713702771.py", line 9, in main
    ans = abs(perms.index(P) - perms.index(Q))
ValueError: [1, 3, 2] is not in list


Fixed submission:

# ABC150C - Count Order
from itertools import permutations


def main():
    N, *PQ = map(int, open(0).read().split())
    P, Q = PQ[:N], PQ[N:]
    perms = list(permutations(range(1, N + 1)))
    ans = abs(perms.index(P) - perms.index(Q))
    print(ans)


if __name__ == "__main__":
    main()
Problem p02814 (Python) — buggy submission, verdict: Time Limit Exceeded

def GCD(a: int, b: int) -> int:
    return a if b == 0 else GCD(b, a % b)


def LCM(a: int, b: int) -> int:
    return a * b // GCD(a, b)


n, m = map(int, input().split())
a = list(map(lambda x: int(x) // 2, input().split()))

a_lcm = a[0]
for i in range(1, n):
    a_lcm = LCM(a_lcm, a[i])
    if a_lcm > m:
        break

if a_lcm <= m:
    flag = True
    for i in range(n):
        if (a_lcm // a[i]) % 2 == 0:
            flag = False
            break

    if flag:
        ans = ((m // a_lcm) + 1) // 2
    else:
        ans = 0
else:
    ans = 0
print(ans)


Error: TLE

Fixed submission:

def GCD(a: int, b: int) -> int:
    return a if b == 0 else GCD(b, a % b)


def LCM(a: int, b: int) -> int:
    return a * b // GCD(a, b)


n, m = map(int, input().split())
a = list(map(lambda x: int(x) // 2, input().split()))

a_lcm = a[0]
for i in range(1, n):
    a_lcm = LCM(a_lcm, a[i])

flag = True
for i in range(n):
    if (a_lcm // a[i]) % 2 == 0:
        flag = False
        break

if flag:
    ans = ((m // a_lcm) + 1) // 2
else:
    ans = 0
print(ans)
Problem p02814 (Python) — buggy submission, verdict: Runtime Error

import sys


def gcd(x, y):
    if x % y == 0:
        return y
    return gcd(y, x % y)


n, m = map(int, input().split())
a = list(map(int, input().split()))

cur = a[0]
for x in a[1:]:
    g = gcd(cur, x)
    if (cur // 2) % g != (x // 2) % g:
        print(0)
        sys.exit(0)
    else:
        cur = cur // g * x
    if cur > m * 2:
        print(0)
        sys.exit(0)

print((m + cur // 2) // cur)


Error: 0

Fixed submission:

import sys
import math

n, m = map(int, input().split())
a = list(map(int, input().split()))

cur = a[0]
for x in a[1:]:
    g = math.gcd(cur, x)
    if (cur // 2) % g != (x // 2) % g:
        print(0)
        sys.exit(0)
    else:
        cur = cur // g * x
    if cur > m * 2:
        print(0)
        sys.exit(0)

print((m + cur // 2) // cur)
Problem p02814 (Python) — buggy submission, verdict: Runtime Error

from fractions import gcd
from functools import reduce
import sys


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


def lcm_list(numbers, maxvalue):
    first = 1
    second = 1
    for i in numbers:
        second = i
        lcm_result = lcm_base(first, second)
        if lcm_result > max_value:
            return -1
        first = lcm_result
    return lcm_result


n, m = map(int, input().split())
A = list(map(int, input().split()))

max_value = 2 * m

lcm = lcm_list(A, 2 * m)
if lcm == -1:
    print("0")
    sys.exit(0)

if any((lcm / a) % 2 != 1 for a in A):
    print("0")
    sys.exit(0)

max_product = max_value // lcm
print((max_product + 1) // 2)


Error: ImportError: cannot import name 'gcd' from 'fractions' (/usr/lib/python3.10/fractions.py)
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02814/Python/s018417487.py", line 1, in <module>
    from fractions import gcd
ImportError: cannot import name 'gcd' from 'fractions' (/usr/lib/python3.10/fractions.py)


Fixed submission:

from fractions import gcd
from functools import reduce
import sys


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


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


n, m = map(int, input().split())
A = list(map(int, input().split()))

max_value = 2 * m

if len(A) > 1:
    lcm = lcm_list(A)
else:
    lcm = A[0]

if any((lcm / a) % 2 != 1 for a in A):
    print("0")
    sys.exit(0)

max_product = max_value // lcm
print((max_product + 1) // 2)
Problem p02814 (Python) — buggy submission, verdict: Time Limit Exceeded

from sys import stdin
import fractions

N, M = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) // 2 for x in stdin.readline().rstrip().split()]
ans = 0
g = 1

for i in range(len(A)):
    g = g * A[i] // fractions.gcd(g % A[i], A[i])
    if g > M:
        print(0)
        exit()

for i in range(len(A)):
    if (g // A[i]) % 2 == 0:
        print(0)
        exit()

ans = M // g
if ans % 2 == 0:
    print(ans // 2)
else:
    print((ans + 1) // 2)


Error: TLE

Fixed submission:

from sys import stdin
import fractions

N, M = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) // 2 for x in stdin.readline().rstrip().split()]
ans = 0
g = 1

for i in range(len(A)):
    g = g * A[i] // fractions.gcd(g % A[i], A[i])

for i in range(len(A)):
    if (g // A[i]) % 2 == 0:
        print(0)
        exit()

ans = M // g
if ans % 2 == 0:
    print(ans // 2)
else:
    print((ans + 1) // 2)
Problem p02814 (Python) — buggy submission, verdict: Runtime Error

from fractions import gcd
from functools import reduce

N, M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

A = [i >> 1 for i in A]


def applied_lcm(x, y):
    g = gcd(x, y)
    x //= g
    y //= g
    if x % 2 == 0 or y % 2 == 0:
        return 0
    n = x * y * g
    if n >> 10**9:
        return 0

    return n


p = reduce(applied_lcm, A)
if p == 0:
    ans = 0
else:
    ans = (M // p) - (M // (p + p))
print(ans)


Error: 0

Fixed submission:

import math


def f(x):
    res = 0
    while x % 2 == 0:
        x /= 2
        res += 1
    return res


def lcm(a, b):
    return a * b // math.gcd(a, b)


N, M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]


# a -> a'
for i in range(N):
    A[i] = A[i] // 2

# a' -> a''
t = f(A[0])
for i in range(N):
    if f(A[i]) != t:
        print(0)
        exit()
    A[i] >>= t  # A[i] /= 2^t
M >>= t

L = 1
for i in range(N):
    L = lcm(L, A[i])
    if L > M:
        print(0)
        exit()

M /= L
ans = math.ceil(M / 2)
print(ans)
Problem p02814 (Python) — buggy submission, verdict: Time Limit Exceeded

from fractions import gcd
from functools import reduce


def inpl():
    return list(map(int, input().split()))


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


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


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def count2(i):
    t = 2
    ret = 1
    while i % t == 0:
        t *= 2
        ret += 1
    return ret - 1


N, M = inpl()
A = inpl()
A = [a // 2 for a in A]

all_lcm = 1
c2 = count2(A[0])
for a in A:
    all_lcm = lcm(all_lcm, a)
    if count2(a) != c2:
        print(0)
        exit()

print(((M // all_lcm) + 1) // 2)


Error: TLE

Fixed submission:

from fractions import gcd
from functools import reduce


def inpl():
    return list(map(int, input().split()))


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


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


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def count2(i, t=0):
    if i % 2 == 0:
        return count2(i // 2, t + 1)
    else:
        return t


N, M = inpl()
A = inpl()
A = [a // 2 for a in A]

all_lcm = lcm_list(A)
c_2 = count2(A[0])
for a in A:
    if c_2 != count2(a):
        print(0)
        exit()

print(((M // all_lcm) + 1) // 2)
Problem p02816 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0] * n
d = [0] * (2 * n - 1)
for i in range(n - 1):
    c[i] = b[i] ^ b[i + 1]
    d[i] = a[i] ^ a[i + 1]
c[n - 1] = b[0] ^ b[-1]
d[n - 1] = a[0] ^ a[-1]
for i in range(n - 1):
    d[n + i] = d[i]
t = [0] * (n + 1)
t[0] = -1
j = -1
for i in range(n):
    while j >= 0 and c[i] != c[j]:
        j = t[j]
    j += 1
    t[i + 1] = j
m = 0
i = 0
ans = []
while m < n:
    if c[i] == d[m + i]:
        i += 1
        if i == n:
            ans.append(m)
            m += i - t[i]
            i = t[i]
    else:
        m += i - t[i]
        if i > 0:
            i = t[i]
for k in ans:
    print(k, a[k] ^ b[0])


Error: TLE

Fixed submission:

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0] * n
d = [0] * (2 * n - 1)
for i in range(n - 1):
    c[i] = b[i] ^ b[i + 1]
    d[i] = a[i] ^ a[i + 1]
c[n - 1] = b[0] ^ b[-1]
d[n - 1] = a[0] ^ a[-1]
for i in range(n - 1):
    d[n + i] = d[i]
t = [0] * (n + 1)
t[0] = -1
j = -1
for i in range(n):
    while j >= 0 and c[i] != c[j]:
        j = t[j]
    j += 1
    t[i + 1] = j
m = 0
ans = []
while m < n:
    for i in range(n):
        if c[i] != d[m + i]:
            m += i - t[i]
            if i > 0:
                i = t[i]
            break
    else:
        ans.append(m)
        m = m + n - t[n]
        i = t[n]
for k in ans:
    print(k, a[k] ^ b[0])
Problem p02817 (Python) — buggy submission, verdict: Runtime Error

S, T = input().split()
print(T + S)


Error: ValueError: invalid literal for int() with base 10: 'oder'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02817/Python/s961214447.py", line 1, in <module>
    In = list(map(int, input().split()))
ValueError: invalid literal for int() with base 10: 'oder'


Fixed submission:

In = list(map(int, input().split()))
sin = set(In)
print("Yes" if len(sin) == 2 else "No")
Problem p02817 (Python) — buggy submission, verdict: Runtime Error

s, t = input().split()
print(t + s)


Error: ValueError: invalid literal for int() with base 10: 'oder'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02817/Python/s795282831.py", line 1, in <module>
    s, t = map(int, input().split())
ValueError: invalid literal for int() with base 10: 'oder'


Fixed submission:

s, t = map(int, input().split())
print(s + t)
Problem p02817 (Python) — buggy submission, verdict: Runtime Error

s, t = input().rstrip().split()
print(t + s)


Error: AttributeError: 'list' object has no attribute 'rstrip'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02817/Python/s248204703.py", line 1, in <module>
    s, t = list(input().split().rstrip())
AttributeError: 'list' object has no attribute 'rstrip'


Fixed submission:

s, t = list(input().split().rstrip())
print(t + s)
Problem p02817 (Python) — buggy submission, verdict: Runtime Error

s, t = input().split()
ans = t + s
print(ans)


Error: EOFError: EOF when reading a line
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02817/Python/s790047642.py", line 2, in <module>
    T = input()
EOFError: EOF when reading a line


Fixed submission:

S = input()
T = input()
print(T + S)
Problem p02817 (Python) — buggy submission, verdict: Runtime Error

s, t = map(str, input().split())
print(t + s)


Error: ValueError: too many values to unpack (expected 2)
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02817/Python/s530679524.py", line 1, in <module>
    s, t = input()
ValueError: too many values to unpack (expected 2)


Fixed submission:

s, t = input()
print(s + t)
Problem p02818 (Python) — buggy submission, verdict: Time Limit Exceeded

A, B, K = map(int, input().split())

C = max(0, A - K)
K -= A - C
print(C, max(0, B - K))


Error: TLE

Fixed submission:

A, B, K = map(int, input().split())

for _ in range(K):
    if A > 0:
        A -= 1
    elif B > 0:
        B -= 1
    else:
        continue
print(A, B)
Problem p02818 (Python) — buggy submission, verdict: Runtime Error

a, b, k = (int(i) for i in input().split())
takahashi = a - k
aoki = b + takahashi if takahashi < 0 else b
print("{} {}".format(max(takahashi, 0), max(aoki, 0)))


Error: 0

Fixed submission:

a, b, k = (int(i) for i in input().split())
takahashi = a - k
aoki = b + takahashi if takahashi < 0 else b
print(f"{max(takahashi, 0)} {max(aoki, 0)}")
Problem p02818 (Python) — buggy submission, verdict: Time Limit Exceeded

a, b, k = map(int, input().split())
if k >= a:
    b -= k - a
    a = 0
else:
    a -= k
print(max(a, 0), max(b, 0))


Error: TLE

Fixed submission:

a, b, k = map(int, input().split())
for _ in range(k):
    if a >= 1:
        a -= 1
    elif b >= 1:
        b -= 1
print(a, b)
Problem p02818 (Python) — buggy submission, verdict: Time Limit Exceeded

import sys

A, B, K = [int(num) for num in input().split()]

if A + B <= K:
    A = 0
    B = 0
    print(A, B)
    sys.exit(0)

if A > K:
    A = A - K
    print(A, B)
    sys.exit(0)
else:
    K = K - A
    A = 0

if B > K:
    B = B - K
    print(A, B)
    sys.exit(0)
else:
    B = 0
    print(A, B)


Error: TLE

Fixed submission:

import sys

A, B, K = [int(num) for num in input().split()]

if A + B == K:
    print(0, 0)
    sys.exit(0)

if K > A:
    K = K - A
    A = 0

while K:
    if A > 0:
        A -= 1
        K -= 1
        continue
    if B > 0:
        B -= 1
        K -= 1
        continue
print(A, B)
Problem p02818 (Python) — buggy submission, verdict: Time Limit Exceeded

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

# TEだった
# for _ in range(k):
#     if a >= 1:
#         a -= 1
#     elif b >= 1:
#         b -= 1

ans_a = 0
ans_b = 0

if a >= k:
    ans_a = a - k
    ans_b = b
else:
    ans_a = 0
    if b >= (k - a):
        ans_b = b - (k - a)
    else:
        ans_b = 0

print(ans_a, ans_b, sep=" ")


Error: TLE

Fixed submission:

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

for _ in range(k):
    if a >= 1:
        a -= 1
    elif b >= 1:
        b -= 1

print(a, b, sep=" ")
Problem p02818 (Python) — buggy submission, verdict: Runtime Error

A, B, K = map(int, input().split())
a = max(0, A - K)
b = B
if K - A > 0:
    b = max(0, B - K + A)
print(a, b)


Error: 0

Fixed submission:

A, B, K = map(int, input().split())
a = max(0, A - K)
if K - A > 0:
    b = max(0, B - K + A)
print(a, b)
Problem p02818 (Python) — buggy submission, verdict: Runtime Error

a, b, k = map(int, input().split())
print(max(a - k, 0), max(b - max(k - a, 0), 0))


Error: TypeError: unsupported operand type(s) for -: 'str' and 'str'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02818/Python/s417489568.py", line 2, in <module>
    print(max(a - k, 0), b - max(k - a, 0))
TypeError: unsupported operand type(s) for -: 'str' and 'str'


Fixed submission:

a, b, k = input().split()
print(max(a - k, 0), b - max(k - a, 0))
Problem p02819 (Python) — buggy submission, verdict: Time Limit Exceeded

x = int(input())
while True:
    i = 2
    while i * i <= x:
        if x % i == 0:
            break
        i += 1
    else:
        print(x)
        exit()
    x += 1


Error: TLE

Fixed submission:

x = int(input())

while True:
    if x % 2 == 0:
        x += 1
        continue
    i = 1
    while i * i <= x:
        if x % i == 0:
            break
        i += 1
    else:
        print(x)
        exit()
    x += 1
Problem p02819 (Python) — buggy submission, verdict: Runtime Error

import math

x = int(input())


def is_prime(x):
    if x < 2:
        return False  # 2未満に素数はない
    if x == 2 or x == 3 or x == 5:
        return True  # 2,3,5は素数
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0:
        return False  # 2,3,5の倍数は合成数

    # ためし割り: 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0:
            return False

        prime += step
        step = 6 - step

    return True


while True:
    if is_prime(x):
        print(x)
        break
    x += 1


Error: 0

Fixed submission:

from sympy import sieve

x = int(input())

while True:
    if x in sieve:
        print(x)
        break
    x += 1
Problem p02819 (Python) — buggy submission, verdict: Runtime Error

import math

n = int(input())


def prime_checker(n):
    dest = int(math.sqrt(n))
    for i in range(2, dest):
        if n % i == 0:
            return False
    return True


while True:
    if prime_checker(n):
        print(n)
        break
    n += 1


Error: 0

Fixed submission:

import sympy

n = int(input())

if sympy.isprime(n):
    print(n)
else:
    res = sympy.nextprime(n, 1)
    print(res)
Problem p02819 (Python) — buggy submission, verdict: Time Limit Exceeded

import sys

x = int(input())
nums = [i for i in range(1, 100004, 2)]
del nums[0]
if x == 2:
    print(2)
    sys.exit()
while nums:
    primal = nums.pop(0)
    if primal >= x:
        print(primal)
        break
    nums = [num for num in nums if num % primal != 0]


Error: TLE

Fixed submission:

x = int(input())
nums = [i for i in range(2, 100004)]
while nums:
    primal = nums.pop(0)
    if primal >= x:
        print(primal)
        break
    nums = [num for num in nums if num % primal != 0]
Problem p02819 (Python) — buggy submission, verdict: Time Limit Exceeded

import math

x = int(input())

primes = []

if x == 2:
    print(2)
    exit(0)

for n in range(3, 10000000000, 2):
    f = True
    mp = math.ceil(math.sqrt(n))
    for p in primes:
        if p > mp:
            break
        if n % p == 0:
            f = False
            break
    if f:
        primes.append(n)
        if n >= x:
            print(n)
            exit(0)


Error: TLE

Fixed submission:

import math

x = int(input())

primes = []

for n in range(2, 10000000000, 2):
    f = True
    mp = math.ceil(math.sqrt(n))
    for p in primes:
        if p > mp:
            break
        if n % p == 0:
            f = False
            break
    if f:
        primes.append(n)
        if n >= x:
            print(n)
            exit(0)
Problem p02819 (Python) — buggy submission, verdict: Time Limit Exceeded

def check_primal(num):
    """素数だったら0を、違ったら1を返す"""
    for mod in range(2, int(num**0.5 + 1)):
        if num % mod == 0:
            return 1
    return 0


x = int(input())

for i in range(x, 100004):
    if check_primal(i) == 0:
        print(i)
        break


Error: TLE

Fixed submission:

import sys

x = int(input())
nums = [i for i in range(1, 100004, 2)]
del nums[0]
if x == 2:
    print(2)
    sys.exit()
while nums:
    primal = nums.pop(0)
    if primal >= x:
        print(primal)
        break
    nums = [num for num in nums if num % primal != 0]