Problem p03394 (python)

Fixed submission:
# -*- coding: utf-8 -*-
def inpl(): return tuple(map(int, input().split()))

N = int(input())
if N == 3:
    print("2 5 63")
    exit()
elif N == 4:
    print("2 5 20 63")
    exit()
elif N == 5:
    print("7 1580 9438 11373 22962")
    exit()

numbers = []

for k in range(0, 5000):
    numbers.extend([6*k+2, 6*k+3, 6*k+4, 6*k+6])

ans = numbers[:N]
S = sum(ans)


if S%6 == 0:
    pass
elif S%6 == 2:
    del ans[4]
    ans.append((ans[-1]//6 + 1)*6)
elif S%6 == 3:
    del ans[5]
    ans.append((ans[-1]//6 + 1)*6)
else:
    x, y = (ans[-1]//6)*6+4, (ans[-1]//6)*6+10
    ans.append(x if x > ans[-1] else y)
    del ans[5]
print(*ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def inpl(): return tuple(map(int, input().split()))
from math import sqrt
from itertools import combinations
import random
from math import gcd
N = int(input())
def primesd(N):
    P = [2]
    L = (N-1)//2
    searched = [False]*(L+1)
    for i in range(1, L+1):
        if searched[i]:
            continue
        j = i*2+1
        P.append(j)
        searched[i::j] = [True]*(((L-i)//j)+1)
    return P

P = primesd(int(sqrt(30000)))
S = [True]*30001
S[:2] = [False]*2

for p in P:
    i = p
    while i <= 30000:
        S[i] = False
        i *= p

for a, b in combinations(P, 2):
    S[a*b] = False

for a, b, c in combinations(P, 3):
    if a*b*c < 30000:
        S[a*b*c] = False

for a, b, c, d in combinations(P, 4):
    if a*b*c*d < 30000:
        S[a*b*c*d] = False

for a, b, c, d, e in combinations(P, 5):
    if a*b*c*d*e < 30000:
        S[a*b*c*d*e] = False

numbers = [i for i, s in enumerate(S) if s==True]

count = 0
while True:
    sample = random.sample(numbers, N-1)
    sum_ = sum(sample)
    if sum_ % 7 != 0:
        continue
    elif any([s%7!=0 for s in sample]):
        sum_ += 7
        for s in sample:
            if gcd(s, sum_-s) == 1:
                break
        else:
            sample += [7]
            print(*sample)
            break

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def inpl(): return tuple(map(int, input().split()))
from math import sqrt
from itertools import combinations
import random
from math import gcd
N = int(input())
def primesd(N):
    P = [2]
    L = (N-1)//2
    searched = [False]*(L+1)
    for i in range(1, L+1):
        if searched[i]:
            continue
        j = i*2+1
        P.append(j)
        searched[i::j] = [True]*(((L-i)//j)+1)
    return P

P = primesd(int(sqrt(30000)))
S = [True]*30001
S[:2] = [False]*2

for p in P:
    i = p
    while i <= 30000:
        S[i] = False
        i *= p

for a, b in combinations(P, 2):
    S[a*b] = False

for a, b, c in combinations(P, 3):
    if a*b*c < 30000:
        S[a*b*c] = False

for a, b, c, d in combinations(P, 4):
    if a*b*c*d < 30000:
        S[a*b*c*d] = False

for a, b, c, d, e in combinations(P, 5):
    if a*b*c*d*e < 30000:
        S[a*b*c*d*e] = False

numbers = [i for i, s in enumerate(S) if s]

count = 0
while True:
    sample = random.sample(numbers, N-1)
    sum_ = sum(sample)
    if sum_ % 11 != 0:
        continue
    elif any([s%11!=0 for s in sample]):
        sum_ += 11
        for s in sample:
            if gcd(s, sum_-s) == 1:
                print("break")
                break
        else:
            sample += [1]
            print(*sample)
            break

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def inpl(): return tuple(map(int, input().split()))

N = int(input())

if N == 3:
    print("2 5 63")
elif N == 4:
    print("2 5 63")
elif N%2 == 0:
    raise