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: Wrong Answer

Solution code:
def examA():
    N = I()
    ans = 0
    print(ans)
    return

def examB():
    def is_prime(n):
        if n == 1: return False

        for k in range(2, int(math.sqrt(n)) + 1):
            if n % k == 0:
                return False

        return True
    N = I()
    ans = [(i+1)for i in range(N)]
    sumA = sum(ans)-N
    cur = N
    while(True):
        if is_prime(sumA+cur):
            break
        cur +=1
    ans[-1] = cur
    print(" ".join(map(str,ans)))
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LFI(): return list(map(float,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examB()

"""

"""

Submission status: Wrong Answer

Solution code:
N = int(input())
if N==3:
    print(2,3,25)
elif N%3==1:
    k = N//3
    A = [2*i for i in range(1,3*(k-1)+3)]
    A += [3,9]
    print(*A)
elif N%3==2:
    k = N//3
    A = [2*i for i in range(1,3*k+1)]
    A += [3,9]
    print(*A)
else:
    k = N//3
    A = [2*i for i in range(1,3*k-3)]
    A += [3,9,15,21]
    print(*A)

Submission status: Wrong Answer

Solution code:
N = int(input())
if N==3:
    print(2,3,9)
elif N%3==1:
    k = N//3
    A = [2*i for i in range(1,3*(k-1)+3)]
    A += [3,9]
    print(*A)
elif N%3==2:
    k = N//3
    A = [2*i for i in range(1,3*k+1)]
    A += [3,9]
    print(*A)
else:
    k = N//3
    A = [2*i for i in range(1,3*k-3)]
    A += [3,9,15,21]
    print(*A)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
if N == 3:
    print('2 5 63')
    exit()
l = np.array([3, 9, 2, 10, 4, 8, 6, 12]).astype('int32')
l2 = np.array([6, 3, 9, 2, 10, 4, 8, 12]).astype('int32')
time = N // 12
answer = np.array([])
for i in range(time):
    answer = np.append(answer, l + 12 * i)
remain = N % 12
if remain%2 == 0:
    answer = np.append(answer, l[:remain] + 12 * time)
else:
    answer = np.append(answer, l2[:remain] + 12 * time)

answer = [int(x) for x in answer]
print(*answer)
# 48

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
#sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
if N == 3:
    print('2 5 63')
    exit()
l = np.array([3, 9, 2, 10, 4, 8, 6, 12]).astype('int32')
l2 = np.array([6, 3, 9, 2, 10, 4, 8,12]).astype('int32')
time = N // 12
answer = np.array([])
for i in range(time):
    answer = np.append(answer, l + 12 * i)
remain = N % 12
if remain%2 == 0:
    answer = np.append(answer, l[:remain] + 12 * time)
else:
    answer = np.append(answer, l2[:remain] + 12 * time)

answer = [int(x) for x in answer]
print(*answer)
# 48

Submission status: Wrong Answer

Solution code:
n=int(input())
if n==3:
    print("2 5 63")
elif n==6:
    print("3 4 6 8 9 10")
elif n==7:
    print("2 3 4 6 8 10 15")
else:
    res=[]
    count = 0
    for i in range(1,50000):
        if i % 2 == 0 or i % 3 == 0:
            res.append(i)
            count += 1
        if count == n-1:
            break

    s=sum(res)
    t=res[-1]
    f1 = s%2
    f2 = s%3
    if f1==0 and f2 == 0:
        flag = 0
    elif f1==0 and f2==1:
        flag = 2
    elif f1==0 and f2==2:
        flag = 4
    if f1==1 and f2 == 0:
        flag = 3
    elif f1==1 and f2==1:
        flag = 5
    elif f1==1 and f2==2:
        flag = 1

    if flag == 5 or flag ==1:
        res.pop(1)
        f=0
        for i in range(t+1,t+10):
            if i % 2==0:
                res.append(i)
                f+=1
            if f==2:
                break

    else:
        for i in range(t+1,t+10):
            if i % 6 == flag:
                res.append(i)
                break

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

Submission status: Wrong Answer

Solution code:
n=int(input())
if n==3:
    print("2 5 63")
elif n==7:
    print("2 3 4 6 8 10 15")
else:
    res=[]
    count = 0
    for i in range(1,50000):
        if i % 2 == 0 or i % 3 == 0:
            res.append(i)
            count += 1
        if count == n-1:
            break

    s=sum(res)
    t=res[-1]
    f1 = s%2
    f2 = s%3
    if f1==0 and f2 == 0:
        flag = 0
    elif f1==0 and f2==1:
        flag = 2
    elif f1==0 and f2==2:
        flag = 4
    if f1==1 and f2 == 0:
        flag = 3
    elif f1==1 and f2==1:
        flag = 5
    elif f1==1 and f2==2:
        flag = 1

    if flag == 5 or flag ==1:
        res.pop(1)
        f=0
        for i in range(t+1,t+10):
            if i % 2==0:
                res.append(i)
                f+=1
            if f==2:
                break

    else:
        for i in range(t+1,t+10):
            if i % 6 == flag:
                res.append(i)
                break

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

Submission status: Wrong Answer

Solution code:
n=int(input())
res=[]
count = 0
for i in range(1,50000):
    if i % 2 == 0 or i % 3 == 0:
        res.append(i)
        count += 1
    if count == n-1:
        break

s=sum(res)
t=res[-1]
f1 = s%2
f2 = s%3
if f1==0 and f2 == 0:
    flag = 0
elif f1==0 and f2==1:
    flag = 2
elif f1==0 and f2==2:
    flag = 4
if f1==1 and f2 == 0:
    flag = 3
elif f1==1 and f2==1:
    flag = 5
elif f1==1 and f2==2:
    flag = 1

for i in range(t+1,t+10):
    if i % 6 == flag:
        res.append(i)
        break

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

Submission status: Wrong Answer

Solution code:
n=int(input())
res=[]
count = 0
for i in range(1,50000):
    if i % 2 == 0 or i % 3 == 0:
        res.append(i)
        count += 1
    if count == n-1:
        break

s=sum(res)
print(s)
t=res[-1]
f1 = s%2
f2 = s%3
if f1==0 and f2 == 0:
    flag = 0
elif f1==0 and f2==1:
    flag = 2
elif f1==0 and f2==2:
    flag = 4
if f1==1 and f2 == 0:
    flag = 3
elif f1==1 and f2==1:
    flag = 5
elif f1==1 and f2==2:
    flag = 1

for i in range(t+1,t+10):
    if i % 6 == flag:
        res.append(i)
        print(s+i)
        break

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

Submission status: Wrong Answer

Solution code:
from random import sample
n=int(input())
if n==3:a=[2,3,63]
else:
  l=[i for i in range(6,30001)if i%2==0 or i%3==0]
  while True:
    a=[2,3,4];a+=sample(l,n-3)
    if sum(a)%6==0:break
print(*a)

Submission status: Wrong Answer

Solution code:
A6 = []
A2 = []
A3 = []
for i in range(2, 30001):
    if i % 6 == 0:
        A6.append(i)
    elif i % 2 == 0:
        A2.append(i)
    elif i % 3 == 0:
        A3.append(i)

N = int(input())
if N <= 4:
    print(*[[2, 5, 63], [2, 5, 20, 63]][N-3])
else:
    S = A2[:2] + A3[:2]
    A2, A3 = A2[2:], A3[2:]
    N -= 4
    while N >= 2:
        if len(A2) >= 2:
            S.append(A2.pop())
            S.append(A2.pop())
            N -= 2
        elif len(A3) >= 2:
            S.append(A3.pop())
            S.append(A3.pop())
            N -= 2
        else:
            S.append(A6.pop())
            N -= 2
    print(*S)

Submission status: Wrong Answer

Solution code:

"""
2,3の倍数で構成
すべての和が6の倍数ならok

2,3,4,6 = 15
8,9,10,12 で繰り返し
"""

N = int(input())
q = []

i = 1
while len(q) < (N // 8) * 8:

    if i % 2 == 0 or i % 3 == 0:
        q.append(i)

    i += 1

i -= 1
if N - len(q) >= 2:
    q.append(i+3)
    q.append(i+9)

if N - len(q) >= 2:
    q.append(i+2)
    q.append(i+4)

if N - len(q) >= 2:
    q.append(i+8)
    q.append(i+10)

if N - len(q) >= 1:
    q.append(i+6)

if N - len(q) >= 1:
    q.append(i+12)

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

Submission status: Wrong Answer

Solution code:
n=int(input())
if n==3:
  print(22,3,5)
  exit()
if n==4:
  print(2,3,4,9)
  exit()
if n==5:
  print(2,3,4,6,9)
  exit()
a=n//4
b=n%4
ans=[]
for i in range(a//2*2):
  ans.extend((6*i+2,6*i+3,6*i+4,6*i+6))
if a%2==0:
  if b==1:
    ans.append(6*a+6)
  if b==2:
    ans.extend((6*a+2,6*a+4))
  if b==3:
    ans.extend((6*a+2,6*a+4,6*a+6))
else:
  if b==0:
    del ans[-1]
    ans.append(6*a+3)
  if b==1:
    ans.append(6*a+3)
  if b==2:
    ans.extend((6*a+3,6*a+6))
  if b==3:
    ans.extend((6*a+2,6*a+3,6*a+4))
print(*ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
if n%2:
  print(2, 3, 25, *[15]*(n-3))
else:
  print(2, 8, *[5]*(n-2))

Submission status: Wrong Answer

Solution code:
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

n=int(input())
ans=[0]*n
k=0
i=2
while k<n-1:
    if i%2==0 or i%3==0:
        ans[k]=i
        k+=1
    i+=1
x=sum(ans)
ans[-1]=30000-6+(x+5)//6*6-x
while gcd(ans[-1],x)==1:
    ans[-1]-=6
print(*ans)

Submission status: Wrong Answer

Solution code:
import math
def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
n=int(input())
ans=[i+1 for i in range(n)]
k=(n+1)*n//2
while not is_prime(k):
    k+=1
ans[-1]=k-(n-1)*n//2
print(*ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
cnt=0
ans=""
s=0
if n>=6:
    for j in range(2,30000):
        if j%6==0 or j%6==2 or j%6==3 or j%6==4:
            a.append(j)
            cnt+=1
            s+=j
            if cnt==n:
                if s%6==0:
                    for i in range(n-1):
                        ans+=str(a[i])+" "
                    ans+=str(a[-1])
                    print(ans)
                elif s%6==2:
                    a[4]=30000
                    for i in range(n-1):
                        ans+=str(a[i])+" "
                    ans+=str(a[-1])
                    print(ans)
                elif s%6==3:
                    a[5]=30000
                    for i in range(n-1):
                        ans+=str(a[i])+" "
                    ans+=str(a[-1])
                    print(ans)
                else:
                    a[5]=29998
                    for i in range(n-1):
                        ans+=str(a[i])+" "
                    ans+=str(a[-1])
                    print(ans)
elif n==3:
    print(str(2)+" "+str(5)+" "+str(63))
elif n==4:
    print(str(2)+" "+str(5)+" "+str(20)+" "+str(63))
else:
    print(str(2)+" "+str(5)+" "+str(20)+" "+str(30)+" "+str(63))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
cnt=0
ans=""
if n>=6:
    for j in range(2,30000):
        if j%6==0 or j%6==2 or j%6==3 or j%6==4:
            a.append(j)
            cnt+=1
            if cnt==n:
                if a[-1]%6==0:
                    for i in range(n-1):
                        ans+=str(a[i])+" "
                    ans+=str(a[-1])
                    print(ans)
                elif a[-1]%6==2:
                    a[4]=30000
                    for i in range(n-1):
                        ans+=str(a[i])+" "
                    ans+=str(a[-1])
                    print(ans)
                elif a[-1]%6==3:
                    a[5]=29998
                    for i in range(n-1):
                        ans+=str(a[i])+" "
                    ans+=str(a[-1])
                    print(ans)
                else:
                    a[5]=30000
                    for i in range(n-1):
                        ans+=str(a[i])+" "
                    ans+=str(a[-1])
                    print(ans)
elif n==3:
    print(str(2)+" "+str(5)+" "+str(63))
elif n==4:
    print(str(2)+" "+str(5)+" "+str(20)+" "+str(63))
else:
    print(str(2)+" "+str(5)+" "+str(20)+" "+str(30)+" "+str(63))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
cnt=0
ans=""
if n>=6:
    while cnt<n:
        for i in range(6,120000):
            if i%6==0 or i%6==2 or i%6==3 or i%6==4:
                a.append(i)
                cnt+=1
    if a[-1]%6==0:
        for i in range(n-1):
            ans+=str(a[i])+" "
        ans+=str(a[-1])
        print(ans)
    elif a[-1]%6==2:
        a[-1]=30000
        for i in range(n-1):
            ans+=str(a[i])+" "
        ans+=str(a[-1])
        print(ans)
    elif a[-1]%6==3:
        a[-1]=29998
        for i in range(n-1):
            ans+=str(a[i])+" "
        ans+=str(a[-1])
        print(ans)
    else:
        a[-1]=29995
        for i in range(n-1):
            ans+=str(a[i])+" "
        ans+=str(a[-1])
        print(ans)
elif n==3:
    print(str(2)+" "+str(5)+" "+str(63))
elif n==4:
    print(str(2)+" "+str(5)+" "+str(20)+" "+str(63))
else:
    print(str(2)+" "+str(5)+" "+str(20)+" "+str(30)+" "+str(63))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
s=0
cnt=0
ans=""
if n>=6:
    while cnt<=n:
        for i in range(6,120000):
            if i%6==0 or i%6==2 or i%6==3 or i%6==4:
                a.append(i)
                s+=i
                cnt+=1
    if s%6==0:
        for i in range(n-1):
            ans+=str(a[i])+" "
        ans+=str(a[-1])
        print(ans)
    elif s%6==2:
        a[-1]=19998
        for i in range(n-1):
            ans+=str(a[i])+" "
        ans+=str(a[-1])
        print(ans)
    elif s%6==5:
        a[-1]=19996
        for i in range(n-1):
            ans+=str(a[i])+" "
        ans+=str(a[-1])
        print(ans)
    else:
        a[-1]=19999
        for i in range(n-1):
            ans+=str(a[i])+" "
        ans+=str(a[-1])
        print(ans)
elif n==3:
    print(str(2)+" "+str(5)+" "+str(63))
elif n==4:
    print(str(2)+" "+str(5)+" "+str(20)+" "+str(63))
else:
    print(str(2)+" "+str(5)+" "+str(20)+" "+str(30)+" "+str(63))

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
N = int(input()) - 3

L = [2, 3, 25]
A = L[:]
i = 2
while N >= 2:
    if i not in L and any(i % l == 0 for l in L):
        A += (3000 - i, i)
        N -= 2
    i += 1

if N == 1:
    A.append(30000)

print(*A)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = []
n = N//2
if N == 3:
    ans = [2,3,63]
elif 4 <= N <= 15000:
    for i in range(1,n):
        ans.append(2*i)
        x = 30000 - 2*i
        ans.append(x)
    if N % 2 == 1:
        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-1):
        y = 6*j + 3
        ans.append(y)
    if x % 2 == 1:
        ans.append(30000)
    else:
        ans.append(6*x - 3)
print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = []
n = N//2
if N == 3:
    ans = [2,3,63]
elif 4 <= 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-1):
        y = 6*j + 3
    if x % 2 == 1:
        ans.append(30000)
    else:
        ans.append(6*x - 3)
print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = []
n = N//2
if N == 3:
    ans = [2,3,63]
elif 4 <= 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: Wrong Answer

Solution code:
import random
import fractions
from functools import reduce

def main():
    N = int(input().strip())

    S3not2 = []
    S2not3 = []
    S2and3 = []
    for i in range(2, 30000+1):
        if i % 3 == 0 and i % 2 != 0:
            S3not2.append(i)
        elif i % 2 == 0 and i %3 != 0:
            S2not3.append(i)
        elif i % 6 == 0:
            S2and3.append(i)

    if N == 3:
        return '2 5 63'


    S = S2not3[:2] + S3not2[:2]
    S2not3 = S2not3[2:]
    S3not2 = S3not2[2:]
    N -= 4

    if N < len(S2not3):
        if N % 2 == 0:
            S += S2not3[:N]
        else:
            S += S2not3[:N-1]
            S.append(S2and3[0])
    elif N < len(S2not3) + len(S3not2):
        if N % 2 == 0:
            S += S2not3 + S3not2[:N-len(S2not3)]
        else:
            S += S2not3 + S3not2[:N-len(S2not3)-1]
            S.append(S2and3[0])
    else:
        S = S2not3 + S3not2
        S += S2and3[:N-len(S)]

    return ' '.join(map(str, S))


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

Submission status: Wrong Answer

Solution code:
import random
import fractions
from functools import reduce

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.choice(cand) for _ in range(N)]
        if sum(S) % 6 == 0 and reduce(fractions.gcd, S) == 1:
            break
    return ' '.join(map(str, S))


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

Submission status: Wrong Answer

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.choice(cand) for _ in range(N)]
        if sum(S) % 6 == 0:
            break
    return ' '.join(map(str, S))


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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    if(n==3):
        print(2,5,63)
        return
    if(n==4):
        print(2,5,20,63)
        return

    q=n//8
    r=n%8
    ans=list(i for i in range(1,12*q+1) if(i%2==0 or i%3==0))
    x=12*q
    if(r==1):
        ans+=[x+6]
    elif(r==2):
        ans+=[x+2,x+4]
    elif(r==3):
        ans+=[x+2,x+4,x+6]
    elif(r==4):
        ans+=[x+2,x+4,x+6,x+12]
    elif(r==5):
        ans+=[x+2,x+3,x+4,x+6,x+9]
    elif(r==6):
        ans+=[x+2,x+3,x+4,x+6,x+9,x+12]
    elif(r==7):
        ans+=[x+2,x+3,x+4,x+6,x+8,x+9,x+10]
    print(max(ans))
    print(n,len(ans))
    print(sum(ans)%6)
resolve()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    if(n==3):
        print(2,5,63)
        return
    if(n==4):
        print(2,5,20,63)
        return

    q=n//8
    r=n%8
    ans=list(i for i in range(1,12*q+1) if(i%2==0 or i%3==0))
    x=12*q
    if(r==1):
        ans+=[x+6]
    elif(r==2):
        ans+=[x+2,x+4]
    elif(r==3):
        ans+=[x+2,x+4,x+6]
    elif(r==4):
        ans+=[x+2,x+4,x+6,x+12]
    elif(r==5):
        ans+=[x+2,x+3,x+4,x+6,x+12]
    elif(r==6):
        ans+=[x+2,x+3,x+4,x+6,x+9,x+12]
    elif(r==7):
        ans+=[x+2,x+3,x+4,x+6,x+8,x+9,x+10]
    print(*ans)
resolve()

Submission status: Wrong Answer

Solution code:
n = int(input())
if n == 3:
	print(2, 3, 25)
	exit()
if n == 4:
	print(2, 3, 4, 9)
	exit()
ans = [2, 4, 6, 3, 9]
c = 5
M = 4
while c + 1 < n and M < 30000:
	c += 2
	ans += [M + 4, M + 6]
	M += 6
c = len(ans)
M = 9
while c + 1 < n and M < 30000:
	c += 2
	ans += [M + 6, M + 12]
	M += 12
ans += [x * 6 for x in range(2, n - c + 2)]
print(*ans)

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    if n == 3:
        l = [2,5,63]
    elif n == 4:
        l = [2,5,20,63]
    elif n == 5:
        l = [2,3,4,6,9]
    else:
        l = []
        while len(l) < n:
            for k in range(30000):
                for i in [2,3,4,6]:
                    l.append(6*k+i)
                    if len(l) == n:
                        break
                else:
                    continue
                break
        s = sum(l)%6
        if s == 2:
            l[4] = 30000
        elif s == 3:
            l[5] = 30000
        elif s == 4:
            l[6] = 30000
        elif s == 5:
            l[4] = 29994
            l[5] = 30000
    s = sum(l)%6
    print(*l)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
def main():
    n=int(input())
    if n==3:
        print(2,5,63)
        return 0
    ans=[2,3]
    cnt=0
    i=10
    while cnt<n-4:
        if i%2==0 or i%3==0:
            ans.append(i)
            cnt+=1
        i+=1
    a=sum(ans)
    if n==20000:
        ans.pop()
        ans.pop()
        ans.append(8)
        ans.append(9)
    elif n==19999:
        ans.pop()
        ans.append(8)
    elif a%6==0:
        ans.append(4)
        ans.append(8)
    elif a%6==1:
        ans.append(8)
        ans.append(9)
    elif a%6==2:
        ans.append(4)
        ans.append(6)
    elif a%6==3:
        ans.append(6)
        ans.append(9)
    elif a%6==4:
        ans.append(8)
        ans.append(6)
    elif a%6==5:
        ans.append(9)
        ans.append(4)
    print(*ans)
main()

Submission status: Wrong Answer

Solution code:
def main():
    n=int(input())
    if n==3:
        print(2,5,63)
        return 0
    elif n==4:
        print(2,5,20,63)
        return 0
    ans=[2,3]
    cnt=0
    i=10
    while cnt<n-4:
        if i%2==0 or i%3==0:
            ans.append(i)
            cnt+=1
        i+=1
    a=sum(ans)
    if a%6==0:
        ans.append(4)
        ans.append(8)
    elif a%6==1:
        ans.append(8)
        ans.append(9)
    elif a%6==2:
        ans.append(4)
        ans.append(6)
    elif a%6==3:
        ans.append(6)
        ans.append(9)
    elif a%6==4:
        ans.append(8)
        ans.append(6)
    elif a%6==5:
        ans.append(9)
        ans.append(4)
    print(*ans)
main()

Submission status: Wrong Answer

Solution code:
def main():
    n=int(input())
    ans=[]
    cnt=0
    i=14
    while cnt<n-2:
        if i%2==0 or i%3==0:
            ans.append(i)
            cnt+=1
        i+=1
    a=sum(ans)
    if a%6==0:
        ans.append(6)
        ans.append(12)
    elif a%6==1:
        ans.append(8)
        ans.append(9)
    elif a%6==2:
        ans.append(4)
        ans.append(6)
    elif a%6==3:
        ans.append(3)
        ans.append(9)
    elif a%6==4:
        ans.append(2)
        ans.append(8)
    elif a%6==5:
        ans.append(3)
        ans.append(10)
    print(*ans)
main()

Submission status: Wrong Answer

Solution code:
def main():
    from fractions import gcd
    n=int(input())
    ans=[]
    cnt=0
    i=8
    while cnt<n-1:
        if i%2==0 or i%3==0:
            ans.append(i)
            cnt+=1
        i+=1
    a=sum(ans)
    if a%6==0:
        ans.append(6)
    elif a%6==2:
        ans.append(4)
    elif a%6==3:
        ans.append(3)
    elif a%6==4:
        ans.append(2)
    print(*ans)
main()

Submission status: Wrong Answer

Solution code:
def main():
    from fractions import gcd
    n=int(input())
    for i in range(n-2):
        n_2=n-2-i
        n_3=i+1
        wa=n_2*2+n_3*3
        print(n_2,n_3,wa)
        for j in range(1,30000):
            if (n_3*3+j)%2==0 and (n_2*2+j)%3==0 and gcd(wa,j)>=2:
                print(*([2]*n_2+[3]*n_3+[j]))
                return 0
main()

Submission status: Wrong Answer

Solution code:
N = int(input())

if N == 3 :
    print(2, 5, 63)
    
else :
    ret = [2, 4, 6]
    
    i = 3
    while N - len(ret) >= 2 and i + 6 <= 30000 :
        ret.append(i)
        ret.append(i + 6)
        i += 12

    i = 8
    while N - len(ret) >= 3 and i + 4 <= 30000 :
        ret.append(i)
        ret.append(i + 2)
        ret.append(i + 4)
        i += 6
        
    if N - len(ret) == 2 :
        ret.append(29996)
        ret.append(29998)
        
    elif N - len(ret) == 1 :
        ret.append(30000)
            
    print(*ret)

Submission status: Wrong Answer

Solution code:
N = int(input())

if N == 3 :
    print(2, 5, 63)
    
else :
    ret = [2, 4]
    i = 3
    while N - len(ret) >= 2 and i + 6 <= 30000 :
        ret.append(i)
        ret.append(i + 6)
        i += 12
    
    i = 6
    while N - len(ret) >= 2 and i + 2 <= 30000 :
        ret.append(i)
        ret.append(i + 2)
        i += 4
        
    if N != len(ret) :
        ret.append(30000)
        
    print(*ret)

Submission status: Wrong Answer

Solution code:
N = int(input())
if N == 3:
    print(2,5,63)
    exit()
if N == 4:
    print(2,5,20,63)
    exit()
if N == 6:
    print(2,4,6,3,9,24)
    exit()
for a in range(3,15001,3):
    b = N-a
    if 1 < b <= 5000 and b%2 == 0:
        break

for i in range(a):
    print(2*i+2,end=" ")

for i in range(b):
    print(6*i+3,end=" ")

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = []
if N <= 5:
    for i in range(N):
        print([2,5,63,20,70][i],end = " ")
    exit()
for i in range(2,30001):
    if i % 2 == 0 or i % 3 == 0:
        ans.append(i)
ans = ans[:N]
sumans = sum(ans)
if sumans % 6 == 2:
    ans[5] = (ans[-1]//6)*6+6
if sumans % 6 == 3:
    ans[2] = (ans[-1]//6)*6+6
if sumans % 6 == 5:
    ans[4] = (ans[-1]//6)*6+6
for i in ans:
    print(i,end=" ")

Submission status: Wrong Answer

Solution code:
N = int(input())
a,b = 0,0
if N == 3:
    print(2,5,63)
    exit()
if N == 4:
    print(2,5,20,63)
    exit()
if N == 6:
    print(2,4,6,3,9,24)
    exit()
for i in range(1,5001):
    a = 3*i
    b = N-a
    if 1 < b <= 5000 and b%2 == 0:
        break

for i in range(a):
    print(2*i+2,end=" ")

for i in range(b):
    print(6*i+3,end=" ")

Submission status: Wrong Answer

Solution code:
N = int(input())
a,b = 0,0
for i in range(1,5001):
    a = 3*i
    b = N-a
    if b <= 5000 and b%2 == 0:
        break
for i in range(a):
    print(2*i+2,end=" ")

for i in range(b):
    print(6*i+3,end=" ")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))

def main():
    n = int(input())
    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:
        sz = 0
        ans = set()
        anss = 0
        i = 0
        while True:
            if sz < n:
                ans.add(6 * i + 2)
                anss += 6 * i + 2
                sz += 1
            else:
                break
            if sz < n:
                ans.add(6 * i + 3)
                anss += 6 * i + 3
                sz += 1
            else:
                break
            if sz < n:
                ans.add(6 * i + 4)
                anss += 6 * i + 4
                sz += 1
            else:
                break
            if sz < n:
                ans.add(6 * i + 6)
                anss += 6 * i + 6
                sz += 1
            else:
                break
            i += 1
        if anss % 6 == 2:
            ans.remove(8)
            ans.add(6 * i + 6)
        elif anss % 6 == 3:
            ans.remove(9)
            ans.add(6 * i + 6)
        elif anss % 6 == 5:
            ans.remove(9)
            ans.add(6 * i + 10)
        for s in ans:
            print(s)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
s = set()
s.add(2)
s.add(5)
s.add(63)
s.add(20)
s.add(30)
cs = 120
if N == 3:
  print("2 5 63")
  exit(0)
if N == 4:
  print("2 5 20 63")
  exit(0)
if N == 5:
  print("2 5 20 30 63")
  exit(0)
s6 = []
for i in range(2, 30001):
  if i % 2 == 0 or i % 3 == 0:
    s6.append(i)

for i in range(N - 3):
  for x in s6:
    if (cs + x) % 6 == 0:
      if x in s:
        continue
      s.add(x)
      cs += x
      break
print(*sorted(s))

Submission status: Wrong Answer

Solution code:
import sys
from random import randint
input = sys.stdin.readline
N = int(input())
s = set()
s.add(2)
s.add(3)
cs = 5
for i in range(N - 2):
  x = randint(4, 30000)
  while (cs + x) % 6 == 0 or x in s:
    x = randint(4, 30000)
  s.add(x)
print(*sorted(s))

Submission status: Wrong Answer

Solution code:
import sys
from random import randint
input = sys.stdin.readline
N = int(input())
s = set()
s.add(2)
s.add(3)
cs = 5
for i in range(N - 2):
  x = randint(4, 30000)
  while (cs + x) % 6 and x in s:
    x = randint(4, 30000)
  s.add(x)
print(*sorted(s))

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd
input = sys.stdin.readline
N = int(input())
s = set()
s.add(2)
s.add(5)
s.add(63)
cs = 2 + 5 + 63
csgcd = gcd(gcd(2, 5), 63)
for i in range(N - 3):
  for x in range(2, 30000):
    if x in s: continue
    if i % 2 != x % 2: continue
    if gcd(csgcd, x) == 1 and gcd(cs, x) != 1:
      s.add(x)
      cs += x
      csgcd = gcd(csgcd, x)
      break
print(*sorted(s))