Buggy python submission (verdict: Time Limit Exceeded):
def factors(n):
    return [i for i in range(2, n) if n % i == 0]


X = int(input())

prime_l = factors(X)
while True:
    for i in prime_l:
        if X % i == 0:
            break
    prime_l.append(X)
    X += 1
print(X)


Fixed submission:
import random


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

    # n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1) >> 1
    while d & 1 == 0:
        d >>= 1

    # 判定をk回繰り返す
    for i in range(k):
        a = random.randint(1, q-1)
        t = d
        y = pow(a, t, q)
        # [0,s-1]の範囲すべてをチェック
        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


X = int(input())

while not is_prime3(X):
    X += 1

print(X)

Buggy python submission (verdict: Time Limit Exceeded):
def is_prime(n):
    if n < 2 or n&1 == 0:
        return False
    for i in range(2, n):
        if i*i > n or n % i == 0:
            return False
    return True


X = int(input())

while not is_prime(X):
    X += 1
print(X)


Fixed submission:
import random


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

    # n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1) >> 1
    while d & 1 == 0:
        d >>= 1

    # 判定をk回繰り返す
    for i in range(k):
        a = random.randint(1, q-1)
        t = d
        y = pow(a, t, q)
        # [0,s-1]の範囲すべてをチェック
        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


X = int(input())

while not is_prime3(X):
    X += 1

print(X)

Buggy python submission (verdict: Time Limit Exceeded):
def get_prime_list(n):
    data = [i for i in range(2, n+100)]
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    return data


X = int(input())

data2 = get_prime_list(X)
for y in data2:
    if y >= X:
        print(y)
        break


Fixed submission:
import random


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

    # n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1) >> 1
    while d & 1 == 0:
        d >>= 1

    # 判定をk回繰り返す
    for i in range(k):
        a = random.randint(1, q-1)
        t = d
        y = pow(a, t, q)
        # [0,s-1]の範囲すべてをチェック
        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


X = int(input())

while not is_prime3(X):
    X += 1

print(X)

Buggy python submission (verdict: Runtime Error):
def is_prime(n, k=100):
    n = abs(n)
    if n == 2:
        return True
    if n < 2 or n&1 == 0:
        return False
    for i in xrange(3, k):
        x, y = n, i
        while y:
            x, y = y, x%y
        if x != 1:
            continue
        if pow(2, n-1, n) != 1:
            return False
    return True


X = int(input())

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


Fixed submission:
import random


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

    # n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1) >> 1
    while d & 1 == 0:
        d >>= 1

    # 判定をk回繰り返す
    for i in range(k):
        a = random.randint(1, q-1)
        t = d
        y = pow(a, t, q)
        # [0,s-1]の範囲すべてをチェック
        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


X = int(input())

while not is_prime3(X):
    X += 1

print(X)