Problem:


Score : 600 points

Problem Statement

Nagase is a top student in high school. One day, she's analyzing some properties of special sets of positive integers.  

She thinks that a set S = \{a_{1}, a_{2}, ..., a_{N}\} of distinct positive integers is called special if for all 1 \leq i \leq N, the gcd (greatest common divisor) of a_{i} and the sum of the remaining elements of S is not 1.

Nagase wants to find a special set of size N. However, this task is too easy, so she decided to ramp up the difficulty. Nagase challenges you to find a special set of size N such that the gcd of all elements are 1 and the elements of the set does not exceed 30000.

Constraints

3 \leq N \leq 20000

Input

Input is given from Standard Input in the following format:

N

Output

Output N space-separated integers, denoting the elements of the set S. S must satisfy the following conditions :

The elements must be distinct positive integers not exceeding 30000.

The gcd of all elements of S is 1, i.e. there does not exist an integer d > 1 that divides all elements of S.

S is a special set.

If there are multiple solutions, you may output any of them. The elements of S may be printed in any order. It is guaranteed that at least one solution exist under the given contraints.

Sample Input 1

3

Sample Output 1

2 5 63

\{2, 5, 63\} is special because gcd(2, 5 + 63) = 2, gcd(5, 2 + 63) = 5, gcd(63, 2 + 5) = 7. Also, gcd(2, 5, 63) = 1. Thus, this set satisfies all the criteria.

Note that \{2, 4, 6\} is not a valid solution because gcd(2, 4, 6) = 2 > 1.

Sample Input 2

4

Sample Output 2

2 5 20 63

\{2, 5, 20, 63\} is special because gcd(2, 5 + 20 + 63) = 2, gcd(5, 2 + 20 + 63) = 5, gcd(20, 2 + 5 + 63) = 10, gcd(63, 2 + 5 + 20) = 9. Also, gcd(2, 5, 20, 63) = 1. Thus, this set satisfies all the criteria.



Sample input:
3


Sample output:
2 5 63

Submission status: Runtime Error

Solution code:
N = int(input())

if N == 3:
  print "2 5 63"
elif N == 4:
  print "2 5 20 63"
else
  print "2 2 2 3 3" + " 6" * (N-5)

Submission status: Runtime Error

Solution code:
# 12/25 AC日記
# GCDについて,2,3を追加しておくと全体のgcdは必ず1
# つまり残りは2の倍数または3の倍数を入れることにする?
# 2,3,a ではaは素数ではない.また3,(2+a)=3なのでa = 4?と思うが(3+a)は偶数なので7とする?
# 2,3,7に加えるとしたら？->この方法だと20000個数も取れないでしょ
# ちょっと難しいので休憩

# 12/27 再開
# 素因数は必ず2種類あるべきなのではないか
# それを2,3とする
# 0(mod2) ∧ !0(mod3) -> 総和は3の倍数
# 全部入れると丁度2万個なのでこれが想定されていそう
n = int(input())
nn = n
if n == 3:
    print("2 5 63")
else:
    res = [2, 4, 3, 9]
    n -= 4
    for i in range(2, 5001):
        if n < 2:
            break
        else:
            n -= 2
            res.append(6 * i - 4)
            res.append(6 * i - 2)
    for i in range(3, 5000, 2):
        if n < 2:
            break
        else:
            n -= 2
            res.append(6 * i - 3)
            res.append(6 * i + 3)
    for i in range(1, 5001):
        if n == 0:
            break
        else:
            n -= 1
            res.append(6 * i)

for i in range(len(res)):
    print(str(res[i]) + " ", end="")

Submission status: Runtime Error

Solution code:
N = int(input())
ans = []
n = N//2
if N <= 15000:
    for i in range(1,n):
        ans.append(2*i)
        x = 30000 - 2*i
        ans.append(x)
    if N % 2 == 0:
        ans.append(30000)
    ans.append(3)
    ans.append(9)
else:
    for i in range(1,15000):
        ans.append(2*i)
    x = N - 14999
    for j in range(x):
        y = 6*x + 3
        if y <= 30000:
            ans.append(y)
    if N = 20000:
        ans.append(30000)
print(*ans)

Submission status: Runtime Error

Solution code:
import random

def main():
    N = int(input().strip())
    cand = []
    for i in range(30000 // 6):
        cand.append(6 * i + 2)
        cand.append(6 * i + 3)
        cand.append(6 * i + 4)
        cand.append(6 * i + 6)

    while True:
        S = random.choices(cand, k=N)
        if sum(S) % 6 == 0:
            break
    return ' '.join(map(str, S))


if __name__ == '__main__':
    print(main())

Submission status: Runtime Error

Solution code:
a=0
b=0
lists=[]
n=int(input())
if n>=7and n!=19999:
    lists2=[2*j for j in range(1,15001)]
    lists3 =[3+6*k for k in range(0,5000)]
    for q in range(1,2501):
        if (n-2*q)%3==0 and 1<=(n-2*q)<=15000:
            a=(n-2*q)
            b=q
            print(a,2*b)
    lists=lists2[:a]+lists3[:2*b]
    print(*lists)
elif n==3:
    lists=[2,5,63]
    print(*lists)
elif n==4:
    lists=[2 ,5 ,20, 63]
    print(*lists)  
elif n==5:
    lists=[2,4,6,3,9]
    print(*lists)
elif n==6:
    lists=[2,5,20,63,70,140]
    print(*lists)
elif n==19999:
    lists=lists2[:14999]+lists3[:4988]
    lists.append(229)
    print(*lists)

Submission status: Runtime Error

Solution code:
a=0
b=0
lists=[]
n=int(input())
if n>=7 and n!=19999:
    lists2=[2*j for j in range(1,15001)]
    lists3 =[3+6*k for k in range(0,5000)]
    for q in range(1,2501):
        if (n-2*q)%3==0 and 1<=(n-2*q)<=15000:
            a=(n-2*q)
            b=q
    lists=lists2[:a]+lists3[:2*b]
    print(*lists)
elif n==3:
    lists=[2,5,63]
    print(*lists)
elif n==4:
    lists=[2 ,5 ,20, 63]
    print(*lists)  
elif n==5:
    lists=[2,4,6,3,9]
    print(*lists)
elif n==6:
    lists=[2,5,20,63,70,140]
    print(*lists)
elif n==19999:
    lists2=[2*j for j in range(1,15001)]
    lists3 =[3+6*k for k in range(0,5000)]
    lists=lists2[:14999]+lists3[:4999]
lists.append(229)
    print(*lists)

Submission status: Runtime Error

Solution code:
n=int(input())
lists2=[2*j for j in range(1,15001)]
lists3 =[3+6*k for k in range(0,5000)]
for q in range(1,5001):
    if (n-2*q)%3==0 and 1<=n-2*q<=15000:
        p=(n-2*q)
        break
lists=lists2[:p]+lists3[:2*q]
print(*lists)

Submission status: Runtime Error

Solution code:
n = int(input())
if n == 3:
    ans = [2, 5, 63]
elif n == 4:
    ans = [2, 5, 20, 63]
else:
    even = odd = None
    for i in range(1, 5001):
        a = n-3*i
        if a % 2 == 0 and 0 < a//2 <= 2500:
            even = 3*i
            odd = a
            break
    assert(even+odd == n)
    assert(0 < even <= 15000)
    assert(0 < odd <= 5000)
    evens = [i for i in range(1, 30001) if i%2 == 0]
    odds = [i for i in range(1, 30001) if i%3 == 0 and i%2 == 1]
    ans = evens[:even] + odds[:odd]
print(*ans)

Submission status: Runtime Error

Solution code:
from math import gcd
def f(x):
    return x%2==0 or x%3==0 or x%5==0

prd = list(filter(lambda x: f(x[0]) and f(x[1]), [(i, 30 - i) for i in range(1, 14)]))

pairs = []
for i in range(1, 1000):
    for j in prd:
        pairs += [i * 30 + j[0], i * 30 + j[1]]
for i in range(0, 500):
    pairs += [i * 30 + 15, (999 - i) * 30 + 15]
pairs += [4, 26, 6, 24, 8, 22, 9, 21, 10, 20, 12, 18, 14, 16]
N = int(input())
if N == 4:
    print(2, 3, 25, 30)
    exit(0)

a = [2, 3, 25]
aiv = [28, 27, 5]
if (N - len(a)) % 2 == 1: a += aiv

a += pairs
for i in range(1, 1001): a.append(i * 30)
print(" ".join(map(str, a[:N])))

Submission status: Runtime Error

Solution code:
from heapq import heappop, heappush, heapify

N = int(input())

ans = []

que = [6, 10, 15]
heapify(que)

while N > 0:
    a = heappop(que)
    ans.append(a)
    N -= 1
    for p in [2, 3, 5]:
        if a % p != 0:
            heappush(que, a * p)

print(*ans)

Submission status: Runtime Error

Solution code:
n = int(input())

div, mod = divmod(n, 4)
ans = []
for i in range(div):
    ans.append(6*i + 2)
    ans.append(6*i + 3)
    ans.append(6*i + 4)
    ans.append(6*i + 6)

if mod == 1:
    ans.append(6*(i+1) + 6)
if mod == 2:
    ans.append(6*(i+1) + 2)
    ans.append(6*(i+1) + 4)
if mod == 3:
    ans.append(6*(i+1) + 2)
    ans.append(6*(i+1) + 4)
    ans.append(6*(i+1) + 6)

print(*ans)

Submission status: Runtime Error

Solution code:
data=[]
for i in range(1,30001):
    if i%2==0 or i%3==0:
        data.append(i)
k=int(input())
if k==3:
    print(*[2,5,63])
elif k==4:
    print(*[2,5,20,63])
elif k==5:
    print(*[2,5,20,63,6])
ans=data[:k]
sm=sum(ans)
if sm%6==2:
    ans[4]=30000
elif sm%6==3:
    ans[5]=30000
elif sm%6==5:
    ans[5]=29998
print(*ans)

Submission status: Runtime Error

Solution code:
N = int(input())
def main(N):
    L = [2,3,5]
    su = 10
    n = 3
    p = [0] * 30
    p[1] = (15,16)
    p[7] = (3, 4)
    p[11] = (5, 6)
    p[13] = (3, 10)
    p[17] = (8, 9)
    p[19] = (9, 10)
    p[23] = (9, 14)
    p[29] = (2, 27) 
    if N == 3:
        print("2 3 65")
    elif N == 4:
        print("2 3 5 20")
    elif N == 5:
        print("2 3 5 10 20")
    else:
        cc = 6
        while True:
            if cc%2==0 or cc%3==0 or cc%5==0:
                L.append(cc)
                su += cc
                n += 1
            cc += 1
            if n == N-2:
                base = (cc//30 + 1) *30
                if su%30 not in (1, 7, 11, 13, 17, 19, 23, 29):
                    L += [base,base + 30 - su%30]
                else:
                    k, l = p[30-su%30]
                    L += [base+k,base+l]
                break
        return L

L = main(N)
L = [str(a) for a in L]
print(" ".join(L))

Submission status: Runtime Error

Solution code:
from random import sample
from math import gcd

n = int(input())

nl = []
for j in range(1, 30000 + 1):
    if (j % 2 == 0 or j % 3 == 0 or j % 5 == 0):
        nl.append(j)
len_nl = len(nl)

while True:
    tl = sample(nl, len_nl)
    g = 0
    total = 0
    for j in range(n):
        g = gcd(g, tl[j])
        total += tl[j]
    if total % 30 == 0:
        continue
    if g != 1:
        continue
    break
print(*tl[:n])

Submission status: Runtime Error

Solution code:
N=int(input())

def solve(n):
  cnt_len=0
  cnt_fact=2
  cnt_sum=0
  ans=[]

  while cnt_len < n:
    if cnt_fact%2==0 or cnt_fact%3==0:
      ans.append(cnt_fact)
      cnt_len+=1
      cnt_sum+=cnt_fact
    cnt_fact+=1
    
  res = cnt_sum % 6
  cnt_fact=((cnt_fact)//6+1)*6
  
  if res==0:
    return ans
  elif res==1:
    ans[2]=cnt_fact+3
    return ans
  elif res==2:
    ans[4]=cnt_fact
    return ans
  elif res==3:
    ans[3]=cnt_fact+3
    return ans
  elif res==4:
    ans[4]=cnt_fact+4
    return ans
  else:
    cnt[4]=cnt_fact+3
    return ans
  
if N==3:
  print(2,5,63)
elif N==4:
  print(2,5,20,63)
elif N==5:
  print(2,3,4,6,9)
else:
  A=solve(N)
  print(*A)

Submission status: Runtime Error

Solution code:
n = int(input())
h = 30000

if n == 3:
    print("2 5 63")
    exit()
if n == 4:
    print("2 5 20 63")
    exit()
if n == 5:
    print("2 5 20 30 63")
    exit()


pret = [2, 3, 4]
it_count = int(n/4)
pret.extend([6*i for i in range(1, it_count)])
pret.extend( [6*i + 2 for i in range(1, it_count)])
pret.extend([6*i +3 for i in range(1, it_count)])
pret.extend(  [6*i + 4 for i in range(1, it_count)])

pret.sort()
ret = pret[:n]


sum_of_ret = sum(ret) % 6
if sum_of_ret == 2:
    ret.remove(8)
    ret.append(6* (it_count))
if sum_of_ret == 3:
    ret.remove(9)
    ret.append(6* (it_count))
if sum_of_ret == 5:
    ret.remove(9)
    ret.append(6* (it_count) + 4)


print(" ".join(list(map(str,ret))))

Submission status: Runtime Error

Solution code:
n = int(input())

h = 30000

if n == 3:
    print("2 5 63")
    exit()
if n == 4:
    print("2 5 20 63")
    exit()
if n == 5:
    print("2 5 63 20 30")
    exit()


pret = [2, 3, 4]
it_count = int(n/4) + 1
pret.extend([6*i for i in range(1, it_count)])
pret.extend( [6*i + 2 for i in range(1, it_count)])
pret.extend([6*i +3 for i in range(1, it_count)])
pret.extend(  [6*i + 4 for i in range(1, it_count)])

ret = pret[:n]


sum_of_ret = sum(ret) % 6
if sum_of_ret == 2:
    ret.remove(8)
    ret.append(6* (it_count+1))
if sum_of_ret == 3:
    ret.remove(9)
    ret.append(6* (it_count+1))
if sum_of_ret == 4:
    ret.remove(10)
    ret.append(6* (it_count+1))
if sum_of_ret == 5:
    ret.remove(9)
    ret.append(6* (it_count+1) + 4)


print(" ".join(ret))

Submission status: Runtime Error

Solution code:

n = int(input())

h = 30000

if n == 3:
    print("2 5 63")
    exit()
if n == 4:
    print("2 5 20 63")
    exit()
if n == 5:
    print("2 5 63 20 30")
    exit()


pret = [2, 3, 4]
it_count = int(n/4) + 1
pret.extend([6*i for i in range(1, it_count)])
pret.extend( [6*i + 2 for i in range(1, it_count)])
pret.extend([6*i +3 for i in range(1, it_count)])
pret.extend(  [6*i + 4 for i in range(1, it_count)])

ret = pret[:n]


sum_of_ret = sum(ret) % 6
if sum_of_ret == 2:
    ret.remove(8)
    ret.append(6* (it_count+1))
if sum_of_ret == 3:
    ret.remove(9)
    ret.append(6* (it_count+1))
if sum_of_ret == 4:
    ret.remove(10)
    ret.append(6* (it_count+1))
if sum_of_ret == 5:
    ret.remove(9)
    ret.append(6* (it_count+1) + 4)


print(" ".join(ret))

Submission status: Runtime Error

Solution code:
"""
和の最大公倍数1ではない
2n 3n

素数2つを含む
6n, 6n+2,6n+3 6n+4

"""



n = int(input())

h = 30000

if n == 3:
    print("2 5 63")
    exit()
if n == 4:
    print("2 5 20 63")
    exit()
if n == 5:
    print("2 5 63 20 30")
    exit()


pret = [2, 3, 4]
it_count = int(n/4) + 1
pret.extend([6*i for i in range(1, it_count)])
pret.extend( [6*i + 2 for i in range(1, it_count)])
pret.extend([6*i +3 for i in range(1, it_count)])
pret.extend(  [6*i + 4 for i in range(1, it_count)])

ret = pret[:n]


sum_of_ret = sum(ret) % 6
if sum_of_ret == 2:
    ret.remove(8)
    ret.append(6* (it_count+1))
if sum_of_ret == 3:
    ret.remove(9)
    ret.append(6* (it_count+1))
if sum_of_ret == 4:
    ret.remove(10)
    ret.append(6* (it_count+1))
if sum_of_ret == 5:
    ret.remove(9)
    ret.append(6* (it_count+1) + 4)


print(" ".join(ret))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

N = int(input())
if N <= 5:
    if N == 3: print('2 5 63')
    elif N == 4: print('2 5 20 63')
    elif N == 5: print('2 5 20 30 63')
else:
    flag = 0
    S = 0
    k = 0
    retList = list()
    Q = N // 4
    R = N % 4
    for q in range(Q):
        S += 4*6*q + 15
        retList.append(str(6*q+2))
        retList.append(str(6*q+3))
        retList.append(str(6*q+4))
        retList.append(str(6*q+6))
    if R == 0:
        pass
    elif R == 1:
        S += 6*Q + 2
        retList.append(str(6*Q + 2))
    elif R == 2:
        S += 2*6*Q + 5
        retList.append(str(6*Q + 2))
        retList.append(str(6*Q + 3))
    elif R == 3:
        S += 3*6*Q + 9
        retList.append(str(6*Q + 2))
        retList.append(str(6*Q + 3))
        retList.append(str(6*Q + 4))

    if S%6 == 0:
        pass
    elif S%6 == 2:
        retList.remove('8')
        S -= 8
        S += 6*(Q+1) + 6
        retList.append(str(6*Q + 6))
    elif S%6 == 3:
        retList.remove('9')
        S -= 9
        S += 6*(Q+1) + 6
        if 6*
        retList.append(str(6*Q + 6))
    elif S%6 == 5:
        retList.remove('9')
        S -= 9
        S += 6*(Q+1) + 4
        retList.append(str(6*Q + 4))
    # print(S%6)
    # print(len(retList))
    # retIntList = list(map(int, retList))
    # for a in retIntList:
    #     if gcd(S, a) <= 1:
    #         print(S)
    #         print(a)
    print(' '.join(retList))
    # print(gcd(*retIntList))

Submission status: Runtime Error

Solution code:
N = int(input())
if N <= 5:
    if N == 3: print('2 5 63')
    elif N == 4: print('2 5 20 63')
    elif N == 5: print('2 5 20 30 63')
else:
    flag = 0
    S = 0
    k = 0
    retList = list()
    Q = N // 4
    R = N % 4
    for q in range(Q):
        S += 4*6*q + 15
        retList.append(str(6*q+2))
        retList.append(str(6*q+3))
        retList.append(str(6*q+4))
        retList.append(str(6*q+6))
    if R == 0:
        pass
    elif R == 1:
        S += 6*Q + 2
        retList.append(6*Q + 2)
    elif R == 2:
        S += 2*6*Q + 5
        retList.append(6*Q + 2)
        retList.append(6*Q + 3)
    elif R == 3:
        S += 3*6*Q + 12
        retList.append(6*Q + 2)
        retList.append(6*Q + 3)
        retList.append(6*Q + 5)

    # for i in range(len(N)):
    #     if flag%4 == 0: 
    #         S += 6*k + 2
    #         retList.append(str(6*k + 2))
    #     elif flag%4 == 1:
    #         S += 6*k + 3
    #         retList.append(str(6*k + 3))
    #     elif flag%4 == 2: 
    #         S += 6*k + 4
    #         retList.append(str(6*k + 4))
    #     elif flag%4 == 3: 
    #         S += 6*k + 6
    #         retList.append(str(6*k + 6))
    #         k += 1
        
    #     if flag == 4: flag = 0
    #     else: flag += 1

    if S%6 == 0:
        pass
    elif S%6 == 2:
        retList.remove('8')
        retList.append(str(6*k + 6))
    elif S%6 == 3:
        retList.remove('9')
        retList.append(str(6*(k+1) + 6))
    elif S%6 == 5:
        retList.remove('9')
        retList.append(str(6*(k+1) + 4))
    print(' '.join(retList))

Submission status: Runtime Error

Solution code:
N = int(input())
if N <= 5:
    if N == 3: print('2 5 63')
    elif N == 4: print('2 5 20 63')
    elif N == 5: print('2 5 20 30 63')
else:
    flag = 0
    S = 0
    k = 0
    retList = list()
    Q = N // 4
    R = N % 4
    for q in range(len(Q)):
        S += 4*6*q + 15
        retList.append(str(6*q+2))
        retList.append(str(6*q+3))
        retList.append(str(6*q+4))
        retList.append(str(6*q+6))
    if R == 0:
        pass
    elif R == 1:
        S += 6*Q + 2
        retList.append(6*Q + 2)
    elif R == 2:
        S += 2*6*Q + 5
        retList.append(6*Q + 2)
        retList.append(6*Q + 3)
    elif R == 3:
        S += 3*6*Q + 12
        retList.append(6*Q + 2)
        retList.append(6*Q + 3)
        retList.append(6*Q + 5)

    # for i in range(len(N)):
    #     if flag%4 == 0: 
    #         S += 6*k + 2
    #         retList.append(str(6*k + 2))
    #     elif flag%4 == 1:
    #         S += 6*k + 3
    #         retList.append(str(6*k + 3))
    #     elif flag%4 == 2: 
    #         S += 6*k + 4
    #         retList.append(str(6*k + 4))
    #     elif flag%4 == 3: 
    #         S += 6*k + 6
    #         retList.append(str(6*k + 6))
    #         k += 1
        
    #     if flag == 4: flag = 0
    #     else: flag += 1

    if S%6 == 0:
        pass
    elif S%6 == 2:
        retList.remove('8')
        retList.append(str(6*k + 6))
    elif S%6 == 3:
        retList.remove('9')
        retList.append(str(6*(k+1) + 6))
    elif S%6 == 5:
        retList.remove('9')
        retList.append(str(6*(k+1) + 4))
    print(' '.join(retList))

Submission status: Runtime Error

Solution code:
N = int(input())
if N <= 5:
    if N == 3: print('2 5 63')
    elif N == 4: print('2 5 20 63')
    elif N == 5: print('2 5 20 30 63')
else:
    flag = 0
    S = 0
    k = 0
    retList = list()
    for i in range(len(N)):
        if flag%4 == 0: 
            S += 6*k + 2
            retList.append(str(6*k + 2))
        elif flag%4 == 1:
            S += 6*k + 3
            retList.append(str(6*k + 3))
        elif flag%4 == 2: 
            S += 6*k + 4
            retList.append(str(6*k + 4))
        elif flag%4 == 3: 
            S += 6*k + 6
            retList.append(str(6*k + 6))
            k += 1
        
        if flag == 4: flag = 0
        else: flag += 1

    if S%6 == 0:
        pass
    elif S%6 == 2:
        retList.remove('8')
        retList.append(str(6*k + 6))
    elif S%6 == 3:
        retList.remove('9')
        retList.append(str(6*(k+1) + 6))
    elif S%6 == 5:
        retList.remove('9')
        retList.append(str(6*(k+1) + 4))
    print(' '.join(retList))

Submission status: Runtime Error

Solution code:
n = int(input())
k = n%8
t = n//k
ans = [[2,3,4,6,8,9,10,12],[6],[6,12],[2,6,12],[2,4,8,10],[2,4,6,8,10],[2,3,4,8,9,10],[2,3,4,6,8,9,10]][k]
if k == 0:
  for i in ranke(1,t):
    ans.append(i * 12 + 2)
    ans.append(i * 12 + 3)
    ans.append(i * 12 + 4)
    ans.append(i * 12 + 6)
    ans.append(i * 12 + 8)
    ans.append(i * 12 + 9)
    ans.append(i * 12 + 10)
    ans.append(i * 12 + 12)
else:
  for i in ranke(1,t+1):
    ans.append(i * 12 + 2)
    ans.append(i * 12 + 3)
    ans.append(i * 12 + 4)
    ans.append(i * 12 + 6)
    ans.append(i * 12 + 8)
    ans.append(i * 12 + 9)
    ans.append(i * 12 + 10)
    ans.append(i * 12 + 12)
print(*ans)

Submission status: Runtime Error

Solution code:
n=int(input())
ret=[2,3,4] if n>=6 else [2,3,25] if n==3 else [2,3,5,30] if n==4 else [2,3,5,30,60]
if n>=6:
    def getnext(a):
        if a%6==0:
            return a+2
        elif a%6==2:
            return a+1
        elif a%6==3:
            return a+1
        elif a%6==4:
            return a+2
    while len(ret)<n:
        ret.append(getnext(ret[-1]))
    if sum(ret)%6==5:
        ret[-1]=getnext(ret[-1])
    elif sum(ret)%6!=0:
        ret.remove((sum(ret)%6)+6)
        ret.append(getnext(ret[-1]))
        while sum(ret)%6!=0:
            ret[-1]=getnext(ret[-1])
    print(" ".join(map(str,ret)))
else:
    print(" ".join(ret))

Submission status: Runtime Error

Solution code:
import random,math,functools

n = input()
N = int(n)
list = []

while len(list) < N :
    while len(list) < N :
        randomNumber = random.randint(2,30000)
        if randomNumber not in list :
            list.append(randomNumber)
    for i in range(N):
        if i == 0 and (math.gcd(list[0], sum(list[1:])) > 1):
            pass
        elif 0 < i < N-1 and math.gcd(list[i], sum(list)-list[i]) > 1 :
            pass
        elif i == N-1 and (math.gcd(sum(list) - sum(list[:N-2]), sum(list[:N-2])) > 1):
            if functools.reduce(math.gcd, list) == 1:
                print (" ".join(str(list[i]) for i in range(N)))
            else:
                list.clear()
                break
        else:
            list.clear()
            break

Submission status: Runtime Error

Solution code:
N=input()

if N==3:
	print "2 5 63"
	quit()
elif N==4:
	print "2 5 20 63"
	quit()

#N>=5
#For 2 and 3
S=[2,3,4]
N-=3


x=N/4	# N=4x+b
b=N%4

for i in range(1,x+1):
	S.append(6*i)
	S.append(6*i+2)
	S.append(6*i+3)
	S.append(6*i+4)

if x%2==0:
	if b==0:
		pass
	elif b==1:
		S.append(6*(x+1)+3)
	elif b==2:
		S.append(6*(x+1))
		S.append(6*(x+1)+3)
	elif b==3:
		S.append(6*(x+1))
		S.append(6*(x+1)+3)
		S.append(6*(x+1)+6)
else:
	if b==0:
		S.remove(6*x+3)
		S.remove(6*x+6)
	elif b==1:
		S.append(6*(x+1))
	elif b==2:
		S.append(6*(x+1)+2)
		S.append(6*(x+1)+4)
	elif b==3:
		S.append(6*(x+1))
		S.append(6*(x+1)+2)
		S.append(6*(x+1)+4)	

for i in S:
	print i,

Submission status: Runtime Error

Solution code:
n=input()
ans=[3,5]
for i in xrange(n - 2):
    ans.append(i * 2 + 2)
s = sum(ans)
for i in xrange(30000, 0, -2):
    if (s + i) % 15 == 0:
        ans.append(i)
        ans.sort()
        print ' '.join(ans)
        exit()

Submission status: Runtime Error

Solution code:
n=input()
ans=[3,5]
for i in xrange(n - 2):
 ans.append(i * 2 + 2)
s = sum(ans)
for i in xrange(30000, 0, -2):
 if (s + i) % 15 == 0:
  ans.sort()
  print ' '.join(ans)
  exit()

Submission status: Runtime Error

Solution code:
N = int(input())

if N == 3:
    print("2 3 25")
    exit()

MAX = 30000
v2, v3, v6 = [], [], []

for x in range(2, MAX+1):
    if x%6 == 0:
        v6.append(x)
    elif x%3 == 0:
        v3.append(x)
    elif x%2 == 0:
        v2.append(x)

ans = []
j = 0

while j < len(v2) and N > 3:
    ans.append(v2[j*2])
    ans.append(v2[j*2+1])
    j += 1
    N -= 2

j = 0
while j < len(v3) and N > 1:
    ans.append(v3[j*2])
    ans.append(v3[j*2+1])
    j += 1
    N -= 2

if N == 1:
    ans.append(6)

print(" ".join(map(str, ans)))

Submission status: Runtime Error

Solution code:
import sys
N = int(input())

if N == 3:
    print('2 5 63')
    sys.exit()
if N == 4:
    print('2 5 20 63')
    sys.exit()

if N == 5:
    print('2 3 6 4 9')
    sys.exit()

if N = 20000:
    for i in range(5000):
        Tmp1 = 6 * i + 2
        Tmp2 = 6 * i + 3
        Tmp3 = 6 * i + 4
        Tmp4 = 6 * (i + 1)
        print('%d %d %d %d' %(Tmp1,Tmp2,Tmp3,Tmp4), end='')
        if Tmp4 == 30000:
            break
        else:
            print(' ', end='')
    
    print()
    sys.exit()


S = '2 3 6 4 9'

N -= 5

print(S, end='')

if N == 1:
    print(' 12')
    sys.exit()

for i in range(5001):
    
    Tmp1 = 6 * i + 8
    Tmp2 = 6 * i + 10
    if Tmp2 > 30000:
        break
    
    print(' %d %d' %(Tmp1, Tmp2) , end='')
    N -= 2
    if N == 0:
        print()
        sys.exit()
    elif N == 1:
        print(' 12')
        sys.exit()
        
for i in range(5001):
    
    Tmp1 = 12 * i + 15
    Tmp2 = 12 * i + 21
    if Tmp2 > 30000:
        break
    
    print(' %d %d' %(Tmp1, Tmp2), end='')
    N -= 2
    if N == 0:
        print()
        sys.exit()
    elif N == 1:
        print(' 12')
        sys.exit()   

for i in range(N):
    
    Tmp1 = 6 * (i + 3)
    if Tmp1 > 30000:
        break
    
    print(' %d' %(Tmp1) , end='')


print()

Submission status: Runtime Error

Solution code:
N = int(input())
if N < 5002:
    if N % 2  == 0:
        sans = [6 * i  + 3 for i in range(N-2)]
        ans = sans + [2,4]
    if N % 2 == 1:
        sans = [6 * i  + 3 for i in range(N-3)]
        ans = sans + [2,4,6]
    if N == 3:
        ans = [2,3,25]
else:
    sans = [6 * i  + 3 for i in range(5000)]
    nis = [2 * i + 2 for i in range(N - 5000 )]
    else:
        if (len(nis) * (nis[0] + nis[-1]) //2) % 3 == 1:
            nis[-1] += 2
        elif    (len(nis) * (nis[0] + nis[-1]) //2) % 3 == 2:
            nis[-1] += 2
            nis[-2] += 2
    ans = sans + nis
ans = map(str,ans)
print(" ".join(ans))

Submission status: Runtime Error

Solution code:
n = int(input())

a = [-1 for i in range(n)]

a[0] = 1
a[1] = 3
a[2] = 2

if n <= 10000:
    for i in range(3, n):
        a[i] = (i-1) * 3
    print(*a)
else:
    if n<20000:
        for i in range(3, 10000):
            a[i] = (i - 1) * 3
        if n % 2 == 0:
            for i in range((n - 10000) // 2):
                a[10000 + 2 * i] = i * 6 + 4
                a[10000 + 2 * i + 1] = i * 6 + 8
        if n % 2 == 1:
            for i in range((n - 10000) // 2):
                a[10000 + 2 * i] = i * 6 + 4
                a[10000 + 2 * i + 1] = i * 6 + 8
            a[10000 + 2 * (((n - 10000) // 2) + 1)] = (((n - 10000) // 2) + 1) * 6 + 4
            a[3] = (((n - 10000) // 2) + 1) * 6 + 8
    else:
        for i in range(3, 10000):
            a[i] = (i - 1) * 3
        if n % 2 == 0:
            for i in range((n - 10000) // 2-1):
                a[10000 + 2 * i] = i * 6 + 4
                a[10000 + 2 * i + 1] = i * 6 + 8
            a[n-2] = 5
            a[n-1] = 7
    print(*a)

Submission status: Runtime Error

Solution code:
# -*- 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

Submission status: Runtime Error

Solution code:
# -*- 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

Submission status: Runtime Error

Solution code:
N = int(input())
if N < 5002:
    if N % 2  == 0:
        sans = [6 * i  + 3 for i in range(N-2)]
        ans = sans + [2,4]
    if N % 2 == 1:
        sans = [6 * i  + 3 for i in range(N-3)]
        ans = sans + [2,4,6]
    if N == 3:
        ans = [2,3,25]
else:
    sans = [6 * i  + 3 for i in range(4999)]
    nis = [2 * i + 2 for i in range(N - 50000 )]
    if N == 20000:
        nis[-1] = 5
    else:
        if (len(nis) * (nis[0] + nis[-1]) //2) % 3 == 1:
            nis[-1] += 2
        elif    (len(nis) * (nis[0] + nis[-1]) //2) % 3 == 2:
            nis[-1] += 2
            nis[-2] += 2
    ans = sans + nis
print(ans)

Submission status: Runtime Error

Solution code:
import functools
import math
from itertools import combinations
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    ham = combinations(range(1, 30001), 100)
    for x in ham:
        x = list(x)
        if functools.reduce(math.gcd, x) == 1:
            for y in x:
                xx = x[:]
                xx.remove(y)
                if functools.reduce(math.gcd, [y, sum(xx)]) != 1:
                    break
            else:
                print(' '.join([str(i) for i in x]))
                return


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import functools
import math
from itertools import combinations
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    ham = combinations(range(1, 30001), 2)
    for x in ham:
        if functools.reduce(math.gcd, x) == 1:
            for y in x:
                xx = list(x)
                xx.remove(y)
                if functools.reduce(math.gcd, [y, sum(xx)]) != 1:
                    break
            else:
                print(' '.join([str(i) for i in x]))
                return


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
ans = []
total = 0
for n in range(30001):
    if (n%2 == 0) ^ (n%3 == 0):
        ans.append(n)
        total += n
    if len(ans) == N: break

if total%2 == 0:
    i = N - 1
    while ans[i]%3 > 0:
        i -= 1
    ans[i] += 3

if total%3 == 0:
    i = N - 1
    while ans[i]%2 > 0:
        i -= 1
    ans[i] += 2

print(*ans)