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 <= 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 + 10
        retList.append(str(6*Q + 2))
        retList.append(str(6*Q + 3))
        retList.append(str(6*Q + 5))

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

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

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 + 12
        retList.append(str(6*Q + 2))
        retList.append(str(6*Q + 3))
        retList.append(str(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: Wrong Answer

Solution code:
n = int(input())
k = n%8
t = n//8
ans = [[2,3,4,6,8,9,10,12],[6],[3,9],[2,3,9],[2,3,9,10],[2,3,6,9,10],[2,3,4,8,9,10],[2,3,4,6,8,9,10]][k]
if k == 0:
  for i in range(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 range(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: Wrong Answer

Solution code:
n = int(input())
k = n%8
t = n//8
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 range(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 range(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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = []
b = []
c = []
ans = []
n = (int)(input())
for i in range(10,30001):
	if i % 2 != 0 and i % 3 == 0:
		a.append(i);
for i in range(10,30001):
	if i % 2 == 0 and i % 3 != 0:
		b.append(i);
for i in range(10,30001):
	if i % 6 == 0:
		c.append(i);
if n >= 5:
	n -= 5
	ans = [2,4,3,9,6]
elif n == 4:
	n = 0
	ans = [2,5,20,63]
elif n == 3:
	n = 0
	ans = [2,5,63]
k = (int)(len(b) / 2)
for i in range(0,k):
	if n >= 2:
		ans.append(b[i * 2])
		ans.append(b[i * 2 + 1])
		n -= 2
k = (int)(len(a) / 2)
for i in range(0,k):
	if n >= 2:
		ans.append(a[i * 2])
		ans.append(a[i * 2 + 1])
		n -= 2
k = len(c)
for i in range(0,k):
	if n >= 1:
		ans.append(c[i])
		n -= 1
print(*ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10000)
def gcd(a,b):
	if b > 0:
		return gcd(b,a % b)
	else:
		return a
a = []
b = []
c = []
ans = []
n = (int)(input())
for i in range(10,30001):
	if i % 2 != 0 and i % 3 == 0:
		c.append(i);
for i in range(10,30001):
	if i % 2 == 0 and i % 3 != 0:
		a.append(i);
for i in range(10,30001):
	if gcd(i,6) % 6 == 0:
		b.append(i);
if n >= 5:
	n -= 5
	ans = [2,4,3,9,6]
if n == 4:
	n = 0
	ans = [2,5,20,63]
if n == 3:
	n = 0
	ans = [2,5,63]
k = (int)(len(b) / 2)
for i in range(0,k):
	if n >= 2:
		ans.append(b[i * 2])
		ans.append(b[i * 2 + 1])
		n -= 2
k = (int)(len(a) / 2)
for i in range(0,k):
	if n >= 2:
		ans.append(a[i * 2])
		ans.append(a[i * 2 + 1])
		n -= 2
k = len(c)
for i in range(0,k):
	if n >= 1:
		ans.append(c[i])
		n -= 1
print(*ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10000)
def gcd(a,b):
	if b > 0:
		return gcd(b,a % b)
	else:
		return a
a = []
b = []
c = []
ans = []
n = (int)(input())
for i in range(1,30001):
	if i % 2 != 0 and i % 3 == 0:
		c.append(i);
for i in range(1,30001):
	if i % 2 == 0 and i % 3 != 0:
		a.append(i);
for i in range(1,30001):
	if gcd(i,6) % 6 == 0:
		b.append(i);
k = (int)(len(b) / 2)
for i in range(0,k):
	if n >= 2:
		ans.append(b[i * 2])
		ans.append(b[i * 2 + 1])
		n -= 2
k = (int)(len(a) / 2)
for i in range(0,k):
	if n >= 2:
		ans.append(a[i * 2])
		ans.append(a[i * 2 + 1])
		n -= 2
k = len(c)
for i in range(0,k):
	if n >= 1:
		ans.append(c[i])
		n -= 1
print(*ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

def check(A):
    g = reduce(gcd, A)
    if g != 1:
        return False
    s = sum(A)
    for a in A:
        if gcd(a, s - a) == 1:
            print a, s - a, gcd(a, s - a)

N = input()
M = 30000

if N == 3:
    print "2 5 63"
elif N == 4:
    print "2 5 20 63"
elif N == 5:
    print "2 3 4 9 12"
else:
    ans = [2, 4, 3, 9]
    a = 8
    b = 6
    c = 15
    while len(ans) < N:
        if N - len(ans) == 1:
            ans.append(b)
        elif a + 2 <= M:
            ans.append(a)
            ans.append(a+2)
            a += 6
        elif c + 6 <= M:
            ans.append(c)
            ans.append(c+6)
            c += 12
        else:
            ans.append(b)
            b += 3
    print ' '.join(map(str, ans))

Submission status: Wrong Answer

Solution code:
N = input()
M = 30000

if N == 3:
    print "2 5 63"
elif N == 4:
    print "2 5 20 63"
elif N == 5:
    print "2 3 4 9 12"
else:
    ans = range(2, N+2)[:N/6*6]
    if sum(a % 2 for a in ans) % 2 == 1:
        ans[-1] += 3
    n = N + 2
    cnt = N/6*6
    while cnt < N:
        if n % 6 == 0:
            ans.append(n)
            n += 6
            cnt += 1
        n += 1
    print ' '.join(map(str, ans))

Submission status: Wrong Answer

Solution code:
def gca(a,b):
    while 1:
        a = a%b
        if a == 0:
            return b
        b = b%a
        if b == 0:
            return a
            
def searchAns(nums):
    cnt = 0
    max_num = sum(nums)
    while cnt < 100000:
        isNotProper = False
        cnt += 1
        last_num = max_num*cnt
        num_list = nums + [last_num]
        sum_others = [sum(num_list) - i for i in num_list]
        for num, sum_of_others in zip(num_list, sum_others):
            flag = gca(num, sum_of_others)
            if flag == 1:
                isNotProper = True
                break          
        
        if isNotProper:
            continue
        
        return last_num
    return None

def main():
    #1. input
    n = int(input())
    
    #2. choose numbers
    nums = []
    for i in range(2,n+1):
        nums.append(i)
    
    #3. search a proper last number
    max_num = searchAns(nums)
    print(nums + [max_num])
    


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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.append(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: Wrong Answer

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 b==0:
	pass
elif b==1:
	S.append(6*(x+1))
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)

for i in S:
	print i,

Submission status: Wrong Answer

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 b==0:
	pass
elif b==1:
	S.append(6*(x+1))
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)+2)
	S.append(6*(x+1)+6)

for i in S:
	print i,

Submission status: Wrong Answer

Solution code:
n=input()
ans=[3,5]
for i in xrange(n - 3):
 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([str(x) for x in ans])
  exit()

Submission status: Wrong Answer

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([str(x) for x in ans])
  exit()

Submission status: Wrong Answer

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([str(x) for x in ans])
  exit()

Submission status: Wrong Answer

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

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

numbers = []

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

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


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

Submission status: Wrong Answer

Solution code:
N = int(input())
l = N // 4
ans = []

if N == 3:
	print("2 5 63")
	exit(0)
elif N == 4:
	print("2 5 20 63")
	exit(0)
elif N == 5:
	print("6 8 9 10 15")
	exit(0)
elif N == 6:
	print("6 8 9 10 12 15")
	exit(0)

for i in range(l):
	ans.extend([6*i+2,6*i+3,6*i+4,6*i+6])

add = [6*(l)+2,6*(l)+3,6*(l)+4,6*(l+1)]
ans.extend(add[:N%4])
s = sum(ans)
flg = s % 6

if flg == 1:
	ans[1] = 6*(l+1)+2
elif flg == 2:
	ans[0] = 6*(l+2)
elif flg == 3:
	ans[1] = 6*(l+2)
elif flg == 4:
	ans[2] = 6*(l+2)
elif flg == 5:
	ans[1] = 6*(l+1) + 4

print(*ans,end=' ')

Submission status: Wrong Answer

Solution code:
N = int(input())
l = N // 4
ans = []

if N == 3:
	print("2 5 63")
	exit(0)
elif N == 4:
	print("2 5 20 63")
	exit(0)
elif N == 5:
	print("6 8 9 10 15")
	exit(0)
elif N == 6:
	print("6 8 9 10 12 15")
	exit(0)

for i in range(l):
	ans.extend([6*i+2,6*i+3,6*i+4,6*i+6])

add = [6*(l)+2,6*(l)+3,6*(l)+4,6*(l+1)]
ans.extend(add[:N%4])
s = sum(ans)
flg = s % 6

if flg == 1:
	ans[2] = 6*(l+1)+2
elif flg == 2:
	ans[1] = 6*(l+2)
elif flg == 3:
	ans[2] = 6*(l+2)
elif flg == 4:
	ans[3] = 6*(l+2)
elif flg == 5:
	ans[2] = 6*(l+1) + 4

print(*ans,end=' ')

Submission status: Wrong Answer

Solution code:
N = int(input())
l = N // 4
ans = []

if N == 3:
	print("2 5 63")
	exit(0)
elif N == 4:
	print("2 5 20 63")
	exit(0)
elif N == 5:
	print("6 8 9 10 15")
	exit(0)
elif N == 6:
	print("6 8 9 10 12 15")
	exit(0)

for i in range(1,l+1):
	ans.extend([6*i,6*i+2,6*i+3,6*i+4])

add = [6*(l+1),6*(l+1)+2,6*(l+1)+3,6*(l+1)+4]
ans.extend(add[:N%4])
s = sum(ans)
flg = s % 6

if flg == 1:
	ans[2] = 6*(l+2)+2
elif flg == 2:
	ans[1] = 6*(l+2)
elif flg == 3:
	ans[2] = 6*(l+2)
elif flg == 4:
	ans[3] = 6*(l+2)
elif flg == 5:
	ans[2] = 6*(l+2) + 4

print(*ans,end=' ')

Submission status: Wrong Answer

Solution code:
from sys import stdin 
a = []
b = []
c = [] 
d = []
cur = 2
hi = 30000
while cur <= hi:
    a.append(cur)
    cur = cur + 2 
cur = 3
while cur <= hi:
    b.append(cur)
    cur = cur + 6 
cur = 3
ans = [2,5,63]
cur = 630
while cur <=hi:
    ans.append(cur)
    cur = cur + 630
c = [] 
d = [] 
cur = 3
while cur <= hi:
    c.append(cur)
    cur = cur + 3 
cur = 2 
while cur <= hi:
    d.append(cur)
    d.append(cur+2)
    cur += 6 
print len(c),len(d)
n = int(stdin.readline())
if n <= 10:
    ans = ans[:n]
else:
    if n!=19999:
        for x in xrange(1,len(a)+1):
            y = n - x 
            if x > 0 and y > 0 and x <= len(a) and y <= len(b) and x%3==0 and y%2==0:
                break 
        ans = a[:x] + b[:y]
    else:
        for x in xrange(1,len(d)+1):
            y = n - x 
            if x > 0 and y > 0 and x <= len(d) and y <= len(c) and x%3==0 and y%2==0:
                break 
        ans = c[:x] + d[:y]
for i in ans:
    print i,

Submission status: Wrong Answer

Solution code:
from sys import stdin 
a = []
b = []
c = [] 
d = []
cur = 2
hi = 30000
while cur <= hi:
    a.append(cur)
    cur = cur + 2 
cur = 3
while cur <= hi:
    b.append(cur)
    cur = cur + 6 
cur = 3
ans = [2,5,63]
cur = 630
while cur <=hi:
    ans.append(cur)
    cur = cur + 630

n = int(stdin.readline())
if n <= 10:
    a = ans[:n]
    for i in a:
        print i,
else:
    for x in xrange(1,len(a)+1):
        y = n - x 
        if x > 0 and y > 0 and x <= len(a) and y <= len(b) and x%3==0 and y%2==0:
            break 
    ans = a[:x] + b[:y]
    for i in ans:
        print i,

Submission status: Wrong Answer

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

sm = sum(ans)
for j in range(i+1, 30001):
    for k in range(j+1, 30001):
        if (sm + j + k) % (2*3*5) == 0 and\
           (j % 2 == 0 or j % 3 == 0 or j % 5 == 0) and\
           (k % 2 == 0 or k % 3 == 0 or k % 5 == 0):
            ans.append(j)
            ans.append(k)
            break
    else:
        continue
    break
print(' '.join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    if n == 3:
        return '2 5 63'
    if n == 4:
        return '2 5 20 63'
    a = []
    c = 1
    for i in range(n):
        while c%2 > 0 and c%3 > 0 and c%5 > 0:
            c += 1
        a.append(c)
        c += 1
    a[-3] += 30 - (a[-3] % 30)
    a[-2] += 60 - (a[-2] % 30)
    a[-1] += 90 - (a[-1] % 30)
    t = sum(a)
    while t % 2 == 1:
        a[-3] += 3
        t += 3
    while t % 3 > 0:
        a[-2] += 5
        t += 5
    while t % 5 > 0:
        a[-1] += 6
        t += 6

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


print(main())

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())

    if N == 3:
        ans = [2, 5, 63]
    else:
        ans = []
        apnd = ans.append
        n = -(-N // 12)
        if N % 2:
            num = (6, 2, 10, 3, 9, 4, 8, 12)
        else:
            num = (2, 10, 3, 9, 4, 8, 6, 12)
        for i in range(n):
            for j in num:
                apnd(j + 12 * i)
                N -= 1
                if not N:
                    break

    print(*ans, sep=' ')

main()

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

if N == 5:
    print('2 3 6 4 9')
    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: 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()

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

S = '2 3 6 4 9'

N -= 5

print(S, end='')

if N == 1:
    print(' 30000')
    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(' 30000')
        sys.exit()
        
for i in range(5001):
    
    Tmp1 = 6 * i + 15
    Tmp2 = 6 * i + 21
    if Tmp2 > 30000:
        break
    
    print(' %d %d' %(Tmp1, Tmp2), end='')
    N -= 2
    if N == 0:
        print()
        sys.exit()
    elif N == 1:
        print(' 30000')
        sys.exit()   

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


print()

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

if N == 5:
    print('2 3 6 4 9')
    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 = 6 * i + 9
    Tmp2 = 6 * i + 15
    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: 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()

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

S = '2 3 6 4 9'

N -= 5

print(S, end='')

if N == 1:
    print(' 30000')
    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(' 30000')
        sys.exit()
        
for i in range(5001):
    
    Tmp1 = 6 * i + 9
    Tmp2 = 6 * i + 15
    if Tmp2 > 30000:
        break
    
    print(' %d %d' %(Tmp1, Tmp2), end='')
    N -= 2
    if N == 0:
        print()
        sys.exit()
    elif N == 1:
        print(' 30000')
        sys.exit()   

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


print()

Submission status: Wrong Answer

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

MX = 30000
sieve = [0]*MX
for i in xrange(2,MX):
    if sieve[i]==0:
        for j in xrange(i,MX,i):
            sieve[j] = i
N = input()
if(N==3):
    print "2 5 63"
else:
    ls = filter(lambda x: x%2==0 or x%3==0,range(1,MX+1))[:N]
    sm = sum(ls)
    ls[N-1]+=6-(sm%6)
    fsm = sum(ls[:-1])
    for i in xrange(4,MX):
        if fsm%i==0 and i%6==0:
            ls[N-1]+=i
            print i
            break
    print " ".join(map(str,ls))

Submission status: Wrong Answer

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 )]
    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
ans = map(str,ans)
print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
seq = [2,5]
mar = [5,2]
N = int(input())
sumval = 7
for i in range(2,N-1):
	seq.append(sumval)
	mar = list(map(lambda x: x+sumval,mar))
	mar.append(sumval)
	sumval += seq[-1]

val = sumval
while val <= 30000:
	flg = True
	for i in range(N-1):
		if ((val + mar[i]) % seq[i]) != 0:
			flg = False
			break

	if flg:
		seq.append(val)
		break
	else:
		val += sumval

for num in seq:
	print(num,end=' ')
print()

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

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

elif total%6 == 2:
    i = N - 1
    while ans[i]%2 > 0:
        i -= 1
    ans[i] += 4

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

elif total%6 == 4:
    i = N - 1
    while ans[i]%2 > 0:
        i -= 1
    ans[i] += 2

elif total%6 == 5:
    i = N - 1
    while ans[i]%3 > 0:
        i -= 1
    ans[i] += 3
    i = N - 1
    while ans[i]%2 > 0:
        i -= 1
    ans[i] += 4

ctr = Counter(ans)
mo = ctr.most_common()
if mo[0][1] == 2:
    k = mo[0][0]
    tmp = []
    for i,a in enumerate(ans):
        if a != k: continue
        tmp.append(i)
    ans[tmp[0]] = 5
    ans[tmp[1]] = 25

print(*ans)

Submission status: Wrong Answer

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

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

elif total%6 == 2:
    i = N - 1
    while ans[i]%2 > 0:
        i -= 1
    ans[i] += 4

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

elif total%6 == 4:
    i = N - 1
    while ans[i]%2 > 0:
        i -= 1
    ans[i] += 2

elif total%6 == 5:
    i = N - 1
    while ans[i]%3 > 0:
        i -= 1
    ans[i] += 3
    i = N - 1
    while ans[i]%2 > 0:
        i -= 1
    ans[i] += 4

print(*ans)

Submission status: Wrong Answer

Solution code:
seq = [2,5]
N = int(input())
for i in range(2,N):
	seq.append(sum(seq))

for num in seq:
	print(num,end=' ')

Submission status: Wrong Answer

Solution code:
import fractions

def verify(seq):
    sm = sum(seq)
    print(all([fractions.gcd(2, sm-2) != 1 for s in seq]))

n = int(input())
cnt = 0
ans = []
for i in range(2, 30001):
    if cnt == n - 1:
        break
    if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 or i % 7 == 0 or i % 11 == 0:
        ans.append(i)
        cnt += 1

sm = sum(ans)
for j in range(i, 30001):
    if ((sm + j) % (2*3*5*7*11)) == 0:
        if j % 2 == 0 or j % 3 == 0 or j % 5 == 0 or j % 7 == 0 or j % 11 == 0:
            ans.append(j)
            break
print(' '.join(map(str, ans)))

Submission status: Wrong Answer

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 - 5000 )]
    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
ans = map(str,ans)
print(" ".join(ans))

Submission status: Wrong Answer

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

if N == 19999:
    ans[-1] = 5
elif N == 20000:
    ans[-1] = 5
else:
    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)

Submission status: Wrong Answer

Solution code:
import sys,collections;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
l =[]
for i in range(1,n+1,1):
    l.append(str(i))
print(" ".join(l))