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:
N = int(input())
if N == 3: print(" ".join(map(str, [2, 3, 63])))
elif N == 4: print(" ".join(map(str, [2, 3, 20, 63])))
elif N == 5: print(" ".join(map(str, [2, 3, 20, 30, 63])))
else:
    Ans = [None] * N
    for i in range(N):
        if i % 4 == 0:
            Ans[i] = 6 * (i//4) + 2
        elif i % 4 == 1:
            Ans[i] = 6 * (i//4) + 3
        elif i % 4 == 2:
            Ans[i] = 6 * (i//4) + 4
        else: Ans[i] = 6 * (i//4) + 6
    total = sum(Ans) % 6
    if total == 2: 
        if 6 * (N//4 + 1) <= 30000: Ans[4] = 6 * (N//4 + 1)
        else: Ans[4] = 6 * (N//4)
    elif total == 3: 
        if 6 * (N//4 + 1) <= 30000: Ans[5] = 6 * (N//4 + 1)
        else: Ans[5] = 6 * (N//4)
    elif total == 5: 
        if 6 * (N//4 + 1) + 4 <= 30000: Ans[5] = 6 * (N//4 + 1) + 4 
        else: Ans[5] = 6 * (N//4) + 4
    print(" ".join(map(str, Ans)))

Submission status: Wrong Answer

Solution code:
N = int(input())
if N == 3: print(" ".join(map(str, [2, 3, 63])))
elif N == 4: print(" ".join(map(str, [2, 3, 20, 63])))
elif N == 5: print(" ".join(map(str, [2, 3, 20, 30, 63])))
else:
    Ans = [None] * N
    for i in range(N):
        if i % 4 == 0:
            Ans[i] = 6 * (i//4) + 2
        elif i % 4 == 1:
            Ans[i] = 6 * (i//4) + 3
        elif i % 4 == 2:
            Ans[i] = 6 * (i//4) + 4
        else: Ans[i] = 6 * (i//4) + 6
    total = sum(Ans) % 6
    if total == 2: Ans[4] = (6 * (N//4 + 1) if N % 4 > 0 else 6 * (N//4))
    elif total == 3: Ans[5] = (6 * (N//4 + 1) if N % 4 > 0 else 6 * (N//4))
    elif total == 5: Ans[5] = (6 * (N//4 + 1) + 4 if N % 4 > 2 else 6 * (N//4) + 4)
    print(" ".join(map(str, Ans)))

Submission status: Wrong Answer

Solution code:
N = int(input())
if N == 3: print(" ".join(map(str, [2, 3, 63])))
elif N == 4: print(" ".join(map(str, [2, 3, 20, 63])))
elif N == 5: print(" ".join(map(str, [2, 3, 20, 30, 63])))
else:
    Ans = [None] * N
    for i in range(N):
        if i % 4 == 0:
            Ans[i] = 6 * (i//4) + 2
        elif i % 4 == 1:
            Ans[i] = 6 * (i//4) + 3
        elif i % 4 == 2:
            Ans[i] = 6 * (i//4) + 4
        else: Ans[i] = 6 * (i//4) + 6
    total = sum(Ans) % 6
    if total == 2: Ans[4] = 6 * (N//4 + 1)
    elif total == 3: Ans[5] = 6 * (N//4 + 1)
    elif total == 5: Ans[5] = 6 * (N//4 + 1) + 4
    print(" ".join(map(str, Ans)))

Submission status: Wrong Answer

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()
S=[]
L=[0,2,3,4]
for i in range(1,30001):
    j=i%6
    if j in L:
        S.append(i)
    if len(S)==N-1:
        break
s=sum(S)
def f(L):
    return print(' '.join(map(str,L)))
if s%6==0:
    f(S+[30000])
elif s%6==2:
    f(S+[29998])
elif s%6==3:
    f(S+[29997])
elif s%6==2:
    f(S[1:]+[29997,30000])
#print(len(S),s%6)

Submission status: Wrong Answer

Solution code:
def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

n = int(input())
if n >= 15002:
  if n % 2 == 0:
    a = [i*2 for i in range(1,15001)] + [i*6 + 3 for i in range(n - 15000)]
  else:
    a = [i*2 for i in range(1,15000)] + [i*6 + 3 for i in range(n - 14999)]
  print(*a)
elif n == 3:
  print(*[2,5,63])
else:
  b = prime_factors((n-1)*(n-2)) + prime_factors((n-2)*(n-3))
  b.sort()
  c = 0
  for i in b:
    if i >= 3:
      c = i
      break
  d = [i*2 for i in range(1,n-1)] + [c,c*3]
  print(*d)

Submission status: Wrong Answer

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])
else:
    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: Wrong Answer

Solution code:
data=[2,3,25]
for i in range(1,30001):
    if (i%2==0 or i%3==0 or i%25==0) and (i!=2 and i!=3 and i!=25):
        data.append(i)
print(data[:int(input())])

Submission status: Wrong Answer

Solution code:
N = int(input())
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
    L = [str(a) for a in L]
    print(" ".join(L))

Submission status: Wrong Answer

Solution code:
N = int(input())
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 63")
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 != (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
    L = [str(a) for a in L]
    print(" ".join(L))

Submission status: Wrong Answer

Solution code:
N = int(input())
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 5")
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 != (1, 7, 11, 13, 17, 19, 23, 29):
                L += [base,base + 30 - su%30]
            else:
                k, l = p[su%30]
                L += [base+k,base+l]
            break
    L = [str(a) for a in L]
    print(" ".join(L))

Submission status: Wrong Answer

Solution code:
N = int(input())
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 5")
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 != (1, 7, 11, 13, 17, 19, 23, 29):
                L += [base,base + 30 - su%30]
            else:
                k, l = p[su%30]
                L += [base+k,base+l]
            break
    print(sum(L))
    L = [str(a) for a in L]
    print(" ".join(L))

Submission status: Wrong Answer

Solution code:
n = int(input())
if n == 3:
    res = [2, 5, 63]
elif n == 4:
    res = [2, 5, 20, 63]
elif n == 5:
    res = [2, 5, 20, 30, 63]
else:
    res = [i for i in range(1, 30001)
           if i % 6 not in (1, 5)][:n]
    s = sum(res)
    if s % 6 == 2:
        res.pop(res.index(2))
        res.append(30000)
    elif s % 6 == 3:
        res.pop(res.index(3))
        res.append(30000)
    elif s % 6 == 5:
        res.pop(res.index(3))
        res.append(29998)

    print(*res)

Submission status: Wrong Answer

Solution code:
N=int(input())
k=0
a=[]
S=0
for i in range(2,30001):
  if k<N-2:
    if i%2==0 or i%3==0 or i%5==0:
      a.append(str(i))
      k+=1
      S+=i
  elif k==N-2:
    if S%2==0:
      if i%2==0:
        a.append(str(i))
        k+=1
        S+=i
        break
    elif S%2==1:
      if i%2==1:
        if i%3==0 or i%5==0:
          a.append(str(i))
          k+=1
          S+=i
          break
a.append(str(30000-S%30))
print(" ".join(a))

Submission status: Wrong Answer

Solution code:
N = int(input())
N1 = N
candi22 = [20 + 6*i for i in range(4997)]
candi24 = [4 + 6*i for i in range(5000)]
candi3 =  [15 + 6*i for i in range(4998)]
candi6 =  [6 + 6*i for i in range(5000)]
if N == 3:
    print(2, 5, 63)
elif N == 4:
    print(2, 5, 20, 63)
elif N >= 15000:
    ans = [2, 8, 14, 3, 9]
    ans += candi22 + candi24 + candi3 + candi6[:N-15000]
    print(ans)
else:
    ans = [2, 8, 14, 3, 9]
    N -= 5
    c22 = min(4995, N//3*3)
    N -= c22
    c24 = min(4998, N//3*3)
    N -= c24
    c3 = min(4998, N//2*2)
    N -= c3
    c6 = N
    ans += candi22[:c22] + candi24[:c24] + candi3[:c3] + candi6[:c6]
    print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin

d_in = lambda: int(stdin.readline())  # N = d_in()


MAX = 30000
N = d_in()

base = [3, 25, 2]
cand = []
for i in range(4, MAX // 2, 2):
    cand.append(i)
    cand.append(MAX - i)
cand.append(MAX // 2)
cand.append(MAX)

for i in range(9, MAX // 2, 6):
    cand.append(i)
    cand.append(MAX - i)

ans = []
if N % 2 == 1:
    ans.extend(base)
    ans.extend(cand[:N-3])
else:
    ans.extend(base)
    ans.append(MAX)
    ans.extend(cand[:N-4])
print(*ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin

d_in = lambda: int(stdin.readline())  # N = d_in()


MAX = 30000
N = d_in()

base = [3, 25, 2, MAX-2]
cand = []
for i in range(4, MAX // 2, 2):
    cand.append(i)
    cand.append(MAX - i)
cand.append(MAX // 2)
cand.append(MAX)

for i in range(9, MAX // 2, 6):
    cand.append(i)
    cand.append(MAX - i)

ans = []
if N % 2 == 1:
    ans.extend(base[:3])
    ans.extend(cand[:N-3])
else:
    ans.extend(base)
    ans.extend(cand[:N-4])
print(*ans)

Submission status: Wrong Answer

Solution code:
n=input()
for i in range(n/8):
	print i*12+2, i*12+3, i*12+4, i*12+6, i*12+8, i*12+9, i*12+10, i*12+12,
if n%8==1:
	print n/8*12+6,
if n%8==2:
	print n/8*12+2, n/8*12+4,
if n%8==3:
	print n/8*12+2, n/8*12+4, n/8*12+6,
if n%8==4:
	print n/8*12+2, n/8*12+4, n/8*12+6, n/8*12+12,
if n%8==5:
	print n/8*12+2, n/8*12+3, n/8*12+4, n/8*12+6, n/8*12+9, 
if n%8==6:
	print n/8*12+2, n/8*12+3, n/8*12+4, n/8*12+8, n/8*12+9, n/8*12+10,
if n%8==7:
	print n/8*12+2, n/8*12+3, n/8*12+4, n/8*12+6, n/8*12+8, n/8*12+9, n/8*12+10,
print

Submission status: Wrong Answer

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())
ans3 = [3*(i*2+1) for i in range(5000)]
ans2 = [2*(i+1) for i in range(15000)]

if N == 3:
    print(2,5,63)
elif N == 4:
    print(2,5,20,63)
elif N == 6:
    print(3,6,9,12,2,4)
elif N == 19999:
    assert True, 'nya-n'
else:
    for x in range(1,2501):
        if (N-x*2)%3 == 0:
            y = (N-x*2)//3
            if 1 <= y <= 5000:
                ans = ans3[:x*2]+ans2[:y*3]
                break
    print(' '.join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())
ans3 = [3*(i*2+1) for i in range(5000)]
ans2 = [2*(i+1) for i in range(15000)]

if N == 3:
    print(2,5,63)
elif N == 4:
    print(2,5,20,63)
elif N == 6:
    print(3,6,9,12,2,4)
elif N == 19999:
    print('nya-n')
    print(ans2[:14999]+ans3)
else:
    for x in range(1,2501):
        if (N-x*2)%3 == 0:
            y = (N-x*2)//3
            if 1 <= y <= 5000:
                ans = ans3[:x*2]+ans2[:y*3]
                break
    print(' '.join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())
ans3 = [3*(i*2+1) for i in range(5000)]
ans2 = [2*(i+1) for i in range(15000)]

if N == 3:
    print(2,5,63)
elif N == 4:
    print(2,5,20,63)
elif N == 6:
    print(3,6,9,12,2,4)
elif N == 19999:
    print(ans2[:14999]+ans3)
else:
    for x in range(1,2501):
        if (N-x*2)%3 == 0:
            y = (N-x*2)//3
            if 1 <= y <= 5000:
                ans = ans3[:x*2]+ans2[:y*3]
                break
    print(' '.join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())
ans3 = [3*(i*2+1) for i in range(5000)]
ans2 = [2*(i+1) for i in range(15000)]

if N == 3:
    print(2,5,63)
elif N == 4:
    print(2,5,20,63)
elif N == 6:
    print('nya-n')
elif N == 19999:
    print(ans2[:14999]+ans3)
else:
    for x in range(1,2501):
        if (N-x*2)%3 == 0:
            y = (N-x*2)//3
            if 1 <= y <= 5000:
                ans = ans3[:x*2]+ans2[:y*3]
                break
    print(' '.join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
from random import sample
def gcd(x, y):
    if x < y:# x >= y とする
        x, y = y, x
    r = x % y
    res = y if r == 0 else gcd(y, r)
    return res

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 = tl[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: Wrong Answer

Solution code:
n = int(input())

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

ans = [8,9,2,3,4,10,6] + [0 for _ in range(n)]
k = 12
i = 7
while i < n:
    ans[i] = k
    ans[i + 1] = k + 2
    ans[i + 2] = k + 3
    ans[i + 3] = k + 4
    i += 4
    k += 6

ans = ans[:n]

temp = sum(ans) % 6

if temp == 2:
    ans[0] = k
elif temp == 3:
    ans[1] = k
elif temp == 5:
    ans[0] = k
    ans[1] = k + 6

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

Submission status: Wrong Answer

Solution code:
n = int(input())
if n == 3:
    print("2 5 63")
elif n == 4:
    print("2 5 20 63")
elif n == 5:
    print("3 4 6 8 9")
elif n == 6:
    print("2 3 4 8 9 10")
elif n == 7:
    print("2 3 4 6 8 9 10 12")
else:
    ans = []
    for i in range(n // 8):
        ans += [12 * i + 2, 12 * i + 3, 12 * i + 4, 12 * i + 6, 12 * i + 8, 12 * i + 9, 12 * i + 10, 12 * i + 12]
    if n % 8 == 1:
        ans += [ans[-1] + 6]
    elif n % 8 == 2:
        ans += [ans[-1] + 4, ans[-1] + 8]
    elif n % 8 == 3:
        ans += [ans[-1] + 4, ans[-1] + 6, ans[-1] + 8]
    elif n % 8 == 4:
        ans += [ans[-1] + 2, ans[-1] + 4, ans[-1] + 8, ans[-1] + 10]
    elif n % 8 == 5:
        ans += [ans[-1] + 3, ans[-1] + 4, ans[-1] + 6, ans[-1] + 8, ans[-1] + 9]
    elif n % 8 == 6:
        ans += [ans[-1] + 2, ans[-1] + 3, ans[-1] + 4, ans[-1] + 8, ans[-1] + 9, ans[-1] + 10]
    elif n % 8 == 7:
        ans += [ans[-1] + 2, ans[-1] + 3, ans[-1] + 4, ans[-1] + 6, ans[-1] + 8, ans[-1] + 9, ans[-1] + 10]

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

Submission status: Wrong Answer

Solution code:
N=int(input())

ans=[]
for i in range(3,30001):
  if len(ans)==N-1:
    break
  if i%2==0 or i%3==0 or i%5==0:
    ans.append(i)

s=sum(ans)

if s%2==1:
  ans[0]=2
  s=sum(ans)

ans.append(30000 - s%30)

print(*ans)

Submission status: Wrong Answer

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
  if res == 0:
    return ans
  
  rep=cnt_fact
  for i in range(cnt_fact,30001):
    if (i%2==0 or i%3==0) and (i%6)+res==6:
      rep=i
      break

  ans[3]=rep
  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: Wrong Answer

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

  cnt_fact-=1  
  res = cnt_sum % 6
  if cnt_fact %6 != 0:
    cnt_fact=(cnt_fact+5)//6*6
  
  if res==0:
    return ans
  elif res==1:
    ans[2]=cnt_fact+3
    return ans
  elif res==2:
    ans[2]=cnt_fact+2
    return ans
  elif res==3:
    ans[3]=cnt_fact+3
    return ans
  elif res==4:
    ans[4]=cnt_fact+4
    return ans
  else:
    ans[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: Wrong Answer

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

  cnt_fact-=1  
  res = cnt_sum % 6
  if cnt_fact %6 != 0:
    cnt_fact=(cnt_fact+5)//6*6
  
  if res==0:
    return ans
  elif res==1:
    ans[2]=cnt_fact+3
    return ans
  elif res==2:
    ans[2]=cnt_fact+2
    return ans
  elif res==3:
    ans[3]=cnt_fact+3
    return ans
  elif res==4:
    ans[4]=cnt_fact+4
    return ans
  else:
    ans[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[-1])
  print(*A)

Submission status: Wrong Answer

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+5)//6)*6
  
  if res==0:
    return ans
  elif res==1:
    ans[2]=cnt_fact+3
    return ans
  elif res==2:
    ans[2]=cnt_fact+2
    return ans
  elif res==3:
    ans[3]=cnt_fact+3
    return ans
  elif res==4:
    ans[4]=cnt_fact+4
    return ans
  else:
    ans[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: Wrong Answer

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+1)//6)*6
  
  if res==0:
    return ans
  elif res==1:
    ans[2]=cnt_fact+3
    return ans
  elif res==2:
    ans[2]=cnt_fact+2
    return ans
  elif res==3:
    ans[3]=cnt_fact+3
    return ans
  elif res==4:
    ans[4]=cnt_fact+4
    return ans
  else:
    ans[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: Wrong Answer

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)*6
  
  if res==0:
    return ans
  elif res==1:
    ans[2]=cnt_fact+3
    return ans
  elif res==2:
    ans[2]=cnt_fact+2
    return ans
  elif res==3:
    ans[3]=cnt_fact+3
    return ans
  elif res==4:
    ans[4]=cnt_fact+4
    return ans
  else:
    ans[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: Wrong Answer

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[2]=cnt_fact+2
    return ans
  elif res==3:
    ans[3]=cnt_fact+3
    return ans
  elif res==4:
    ans[4]=cnt_fact+4
    return ans
  else:
    ans[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: Wrong Answer

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) + 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)])

pret.sort()
print(pret)
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)
    if not 6* (it_count - 1) + 4 in ret:
        ret.append(6* (it_count - 1) + 4)
    else:
        ret.append(6* (it_count) + 4)


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

Submission status: Wrong Answer

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) + 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)])

pret.sort()
print(pret)
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 - 1) + 4)


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

Submission status: Wrong Answer

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) + 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)])

pret.sort()
print(pret)
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:
    print("hoge")
    ret.append(6* (it_count - 1) + 4)


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

Submission status: Wrong Answer

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) + 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)])

pret.sort()
print(pret)
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 == 5:
    ret.remove(9)
    ret.append(6* (it_count-1) + 4)


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

Submission status: Wrong Answer

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) + 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)])

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

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) + 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)])

pret.sort()
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 == 5:
    ret.remove(9)
    ret.append(6* (it_count+1) + 4)


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

Submission status: Wrong Answer

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)])

pret.sort()
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 == 5:
    ret.remove(9)
    ret.append(6* (it_count+1) + 4)


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

Submission status: Wrong Answer

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)])

sorted(pret)
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 == 5:
    ret.remove(9)
    ret.append(6* (it_count+1) + 4)


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

Submission status: Wrong Answer

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 == 5:
    ret.remove(9)
    ret.append(6* (it_count+1) + 4)


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

Submission status: Wrong Answer

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(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+1) + 6))
    elif S%6 == 3:
        retList.remove('9')
        S -= 9
        S += 6*(Q+1) + 6
        retList.append(str(6*(Q+1) + 6))
    elif S%6 == 5:
        retList.remove('9')
        S -= 9
        S += 6*(Q+1) + 4
        retList.append(str(6*(Q+1) + 4))
    print(' '.join(retList))