Problem:
 Score: 400 points    Problem Statement  Print a sequence a_1, a_2, ..., a_N whose length is N that satisfies the following conditions:   a_i  (1 \leq i \leq N) is a prime number at most 55  555 .  The values of a_1, a_2, ..., a_N are all different.  In every choice of five different integers from a_1, a_2, ..., a_N , the sum of those integers is a composite number.   If there are multiple such sequences, printing any of them is accepted.      Notes  An integer N not less than 2 is called a prime number if it cannot be divided evenly by any integers except 1 and N , and called a composite number otherwise.      Constraints   N is an integer between 5 and 55 (inclusive).         Input  Input is given from Standard Input in the following format:  N       Output  Print N numbers a_1, a_2, a_3, ..., a_N in a line, with spaces in between.        Sample Input 1 5      Sample Output 1 3 5 7 11 31  Let us see if this output actually satisfies the conditions. First, 3 , 5 , 7 , 11 and 31 are all different, and all of them are prime numbers. The only way to choose five among them is to choose all of them, whose sum is a_1+a_2+a_3+a_4+a_5=57 , which is a composite number. There are also other possible outputs, such as 2 3 5 7 13 , 11 13 17 19 31 and 7 11 5 31 3 .       Sample Input 2 6      Sample Output 2 2 3 5 7 11 13   2 , 3 , 5 , 7 , 11 , 13 are all different prime numbers.  2+3+5+7+11=28 is a composite number.  2+3+5+7+13=30 is a composite number.  2+3+5+11+13=34 is a composite number.  2+3+7+11+13=36 is a composite number.  2+5+7+11+13=38 is a composite number.  3+5+7+11+13=39 is a composite number.   Thus, the sequence 2 3 5 7 11 13 satisfies the conditions.       Sample Input 3 8      Sample Output 3 2 5 7 13 19 37 67 79

Solution (Python):

from itertools import combinations
def hurui(n):
    """n以下の素数のリストを返す
    """
    l = list(range(2,n))
    p = 2
    i = 0
    while True:
        l = [item for item in l if item==p or item%p!=0]
        i += 1
        p = l[i]

        if p*p>n:
            break
    return l

n = int(input())
ps = hurui(55555*5)
is_prime = [False] * 55555*5
for item in ps:
    is_prime[item] = True
l = []
for p in ps:
    if p%5==2:
        l.append(p)
    if len(l)==n:
        break
print(*l)

Solution (Python):
import math
N=int(input())

def primelist(x):
  limit=math.sqrt(x)
  
  prime=[]
  search=list(range(2,x+1))
  
  while 1:
    if search[0]>limit:
      return prime+search
     
    else:
      head_num = search.pop(0)
      prime.append(head_num)
      
      search = [num for num in search if num % head_num != 0]
      
prime=primelist(55555)

i=0
for p in prime:
  if p%5==1:
    print(p,end=" ")
    i+=1
    if i==N:
      exit()

Solution (Python):
N = int(input())
ans = list()
flag = [0] * 55556
flag[1] = 1
for i in range(1, 55556):
  if(flag[i] == 0):
    if(i%5 == 1):
      ans.append(i)
    p = i
    while(p <= 55555):
      flag[p] = 1
      p += i
print(*ans[:N])

Solution (Python):
import math
import random

def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 

    
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]
n=int(input())
P=primes(55555)
P=[int(i) for i in P if i%5==1]
print(*P[:n])

Solution (Python):
N = int(input())

def find_prime(n):
    prime_list = []
    find_list = list(range(2,n+1))
    while True:
        if find_list[0] > n**(1/2):
            prime_list.extend(find_list)
            break
        else:
            head = find_list[0]
            prime_list.append(head)
            find_list.pop(0)
            find_list = [num for num in find_list if num % head != 0]
    return prime_list

prime = find_prime(5555)
five = []
for num in prime:
    if num%5 == 1:
        five.append(num)

ans = []
for num in range(N):
    ans.append(five[num])

print(*ans)

Solution (Python):
N = int(input())
P = []

def is_prime(n: int):
    if n == 2:
        return True
    if n == 1 or n % 2 == 0:
        return False
    for p in range(3, int(n**0.5)+1, 2):
        if n % p == 0:
            return False
    return True

for i in range(5, 55555+1):
    
    
    if is_prime(i) and i % 5 == 1:
        P.append(i)

print(*P[:N])

Solution (Python):
import sys,queue,math,copy,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

N = NI()
p = []
for i in range(7,55555,10):
    for j in range(3,int(math.sqrt(i))+1):
        if i % j == 0: break
    else:
        p.append(i)

print(*p[:N])

Solution (Python):
def isprime(x):
    if x <= 1:
        return False
    for i in range(2, int(x**0.5) + 1):
        if x % i == 0:
            return False
    return True


n = int(input())

A = []
count = 0
for a in range(55556):
    if a % 5 != 1:
        continue
    if isprime(a):
        A.append(a)
        count += 1
    if count == n:
        break

print(*A)

Solution (Python):
import math
from collections import deque

N = int(input())

def prime(n):
    if(n == 1):
        return False
    for i in range(2, int(math.sqrt(n))+1):
        if(n % i == 0):
            return False
        
    return True
A = []
cnt = 0
for i in range(2, 55556):
    if(prime(i)):
        if(i % 5 == 1):
            A.append(i)
            cnt += 1
            if(cnt == N):
                break
                
for i in range(N):
    print(A[i], end=' ')

Solution (Python):
def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    
    return table

n = int(input())
table = sieve(55555)
table2 = []
for i in table:
    if i % 5 == 1:
        table2.append(i)

for i in range(n):
    print(table2[i], end = ' ')

Solution (Python):
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

N = int(input())
P = primes(55555)
ans = []
for p in P:
    if len(ans) == N:
        break
    if p % 5 == 1:
        ans.append(p)

print(*ans)

Solution (Python):
N = int(input())
prime = [2]
ansans = []
flag = True
counter = 0
now = 3
ans = ""
while len(ansans) != N:
  counter = 0
  flag = True
  while prime[counter] ** 2 <= now:
    if now % prime[counter] == 0:
      flag = False
      break
    counter += 1
  if flag:
    prime.append(now)
    if now % 5 == 1:
      ansans.append(now)
  now += 1
for i in range(N):
  ans += str(ansans[i])
  if i != N - 1:ans += " "
print(ans)

Solution (Python):
n = int(input())
l = [11,31,41,61,71]
if n == 5:
    print(*l)
    exit()
for i in range(81,60000,10):
    check = True
    for j in range(3,int(i**0.5)+1):
        if i % j == 0:
            check = False
    if check:
        l.append(i)
    if len(l) == n:
        print(*l)
        exit()

Solution (Python):
n = int(input())

def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    return table
  
table = sieve(55555)  
print(*[t for t in table if t%5==1][:n])

Solution (Python):
N = int(input())

n = 55555

prime = []
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, n + 1):
    if is_prime[i]:
        if i % 5 == 1:
            prime.append(i)

        for j in range(2 * i, n + 1, i):
            is_prime[j] = False

print(*prime[:N])

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    def is_prime(x):
        for i in range(2,int(x**0.5)+1):
            if x%i==0:
                return False
        return True
    N=int(input())
    ans=[]
    tmp=1
    while len(ans)<N:
        tmp+=10
        if is_prime(tmp):
            ans.append(tmp)
    print(*ans)
    

if __name__ == '__main__':
    main()

Solution (Python):






def prime_set(limit=10**5):
    """
    2020/04/10
    https://atcoder.jp/contests/abc084/tasks/abc084_d
    """

    ret = [2]
    for x in range(3, limit+1, 2):
        is_prime = True
        sqrtx = int(pow(x, 0.5))

        for p in ret:
            if p > sqrtx:
                break

            if x % p == 0:
                is_prime = False
                break

        if is_prime:
            ret.append(x)

    return ret


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

    primes = prime_set(55555)
    
    ans = [None] * N
    i = 0
    for p in primes:
        if p % 5 == 2:
            ans[i] = p
            if i == N-1:
                break
            i += 1

    for a in ans:
        print(a, end=" ")


main()

Solution (Python):
n = 55555
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    if i not in primes:
        i += 1
    else:
        ran = range(i*2, n+1,i)
        primes.difference_update(ran)
primes = list(primes)

N = int(input())
res = []
for i in primes:
    if len(res) >= N:
        print(*res)
        exit()
    if i % 5 == 2:
        res.append(i)

Solution (Python):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    n = ni()

    def primes(n):
        is_prime = [True] * (n + 1)
        is_prime[0] = False
        is_prime[1] = False
        for i in range(2, int(n**0.5) + 1):
            if not is_prime[i]:
                continue
            for j in range(i * 2, n + 1, i):
                is_prime[j] = False
        return [i for i in range(n + 1) if is_prime[i]]

    p = primes(55555)
    ans = []
    i = 0

    for prime in p:
        if prime % 5 == 1:
            ans.append(prime)
            i += 1
        if i == n:
            break

    print(*ans)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())

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
s = []
for i in range(1,10**6):
	if is_prime(i):
		if i%5 == 1:
			s.append(i)
	if len(s) == n:
		break
print (*s)

Solution (Python):

import sys


def is_prime(n: int):
    if n == 1:
        return False
    if n % 2 == 0:
        return n == 2
    i = 3
    while i * i <= n:
        if n % i == 0:
            return False
        i += 2
    return True


def solve(N: int):
    def f():
        i = 11
        while True:
            if is_prime(i):
                yield i
            i += 10

    it = f()
    print(*(next(it) for _ in range(N)))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    solve(N)


if __name__ == '__main__':
    main()

Solution (Python):

"""
問題：
55555以下の異なる素数をN個出力せよ。
但し、N個のうちどの5つの素数を組み合わせても素数にならないように
しなければならない。
このような数列は必ず作れるものと仮定して良い。(5<=N<=55)
解法：
5で割って1余る素数の個数は55555以下のうち1408個存在する。
よってこのうち適当にN個とって出力すれば良い。
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())

import math

def eratosthenes(n): 
    if n < 2: 
        return []
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p: 
            return prime + data 
        prime.append(p)
        data = [e for e in data if e % p != 0] 

primes = eratosthenes(55555+1)


"""
res = 0
for i in primes:
    if i%5==1:
        res += 1
print(res) 
"""
ans = []
for i in primes:
    if n <= 0:
        break
    if i%5==1:
        ans.append(i)
        n -= 1

print(*ans)

Solution (Python):
nim = int(input())
array = [0] * 55556
prime = []
for i in range(2, 55556):
    if array[i] == 0:
        if i % 10 == 1:
            prime.append(i)
        for j in range(i, 55556, i):
            array[j] = 1
    if len(prime) == nim:
        print (*prime)
        exit()

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

    n = int(input())
    a = [11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381, 1451, 1471, 1481, 1511, 1531, 1571, 1601, 1621, 1721, 1741, 1801, 1811, 1831, 1861, 1871, 1901, 1931, 1951, 2011, 2081, 2111, 2131, 2141, 2161, 2221, 2251, 2281, 2311, 2341, 2351, 2371, 2381, 2411, 2441, 2521, 2531, 2551, 2591, 2621, 2671, 2711, 2731, 2741, 2791, 2801, 2851, 2861, 2971, 3001, 3011, 3041, 3061, 3121, 3181, 3191, 3221, 3251, 3271, 3301, 3331, 3361, 3371, 3391, 3461, 3491, 3511, 3541, 3571, 3581, 3631, 3671, 3691, 3701, 3761, 3821, 3851, 3881, 3911, 3931, 4001, 4021, 4051, 4091, 4111, 4201, 4211, 4231, 4241, 4261, 4271, 4391, 4421, 4441, 4451, 4481, 4561, 4591, 4621, 4651, 4691, 4721, 4751, 4801, 4831, 4861, 4871, 4931, 4951, 5011, 5021, 5051, 5081, 5101, 5171, 5231, 5261, 5281, 5351, 5381, 5431, 5441, 5471, 5501, 5521, 5531, 5581, 5591, 5641, 5651, 5701, 5711, 5741, 5791, 5801, 5821, 5851, 5861, 5881, 5981, 6011, 6091, 6101, 6121, 6131, 6151, 6211, 6221, 6271, 6301, 6311, 6361, 6421, 6451, 6481, 6491, 6521, 6551, 6571, 6581, 6661, 6691, 6701, 6761, 6781, 6791, 6841, 6871, 6911, 6961, 6971, 6991, 7001, 7121, 7151, 7211, 7321, 7331, 7351, 7411, 7451, 7481, 7541, 7561, 7591, 7621, 7681, 7691, 7741, 7841, 7901, 7951, 8011, 8081, 8101, 8111, 8161, 8171, 8191, 8221, 8231, 8291, 8311, 8431, 8461, 8501, 8521, 8581, 8641, 8681, 8731, 8741, 8761, 8821, 8831, 8861, 8941, 8951, 8971, 9001, 9011, 9041, 9091, 9151, 9161, 9181, 9221, 9241, 9281, 9311, 9341, 9371, 9391, 9421, 9431, 9461, 9491, 9511, 9521, 9551, 9601, 9631, 9661, 9721, 9781, 9791, 9811, 9851, 9871, 9901, 9931, 9941, 10061, 10091, 10111, 10141, 10151, 10181, 10211, 10271, 10301, 10321, 10331, 10391, 10501, 10531, 10601, 10631, 10651, 10691, 10711, 10771, 10781, 10831, 10861, 10891, 11071, 11131, 11161, 11171, 11251, 11261, 11311, 11321, 11351, 11411, 11471, 11491, 11551, 11621, 11681, 11701, 11731, 11801, 11821, 11831, 11941, 11971, 11981, 12011, 12041, 12071, \
12101, 12161, 12211, 12241, 12251, 12281, 12301, 12391, 12401, 12421, 12451, 12491, 12511, 12541, 12601, 12611, 12641, 12671, 12721, 12781, 12791, 12821, 12841, 12911]
    print(*a[:n])

if __name__ == '__main__':
    main()

Solution (Python):

def primes(n):
    is_prime = [False] * 2 + [True] * (n - 1)
    for i in range(2, int(n ** 0.5) + 1): 
        if not is_prime[i]: continue
        for j in range(2 * i, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

N = int(input())
n = 1450  
P = primes(n)

A = []
for p in P:
    if p % 5 == 1:
        A.append(str(p))

print(" ".join(A[0:N]))

Solution (Python):
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return (i for i in range(n + 1) if is_prime[i])


N = int(input())
print(*tuple(x for x in primes(55555) if x % 5 == 1)[:N])

Solution (Python):
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
def isPrime(n):
    if n == 1: return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0: return False
    return True

def main():
    n = II()
    pp = []
    p = 1
    cnt = 0
    while cnt < n:
        p += 10
        if isPrime(p): pp.append(p); cnt += 1
    print(*pp)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

import math


def eratosthenes(limit):
    A = [i for i in range(2, limit + 1)]
    P = []

    for i in range(limit):
        prime = min(A)

        if prime > math.sqrt(limit):
            break

        P.append(prime)
        for j in range(limit):
            if j >= len(A):
                break
            if A[j] % prime == 0:
                A.pop(j)
                continue

    for a in A:
        P.append(a)

    return P


n = int(readline())
prime_list = eratosthenes(55555)
ans = []
cnt = 0
for check in prime_list:
    if check % 5 == 1 and check > 10:
        ans.append(check)
        cnt += 1
        if cnt == n:
            print(*ans)
            exit()

Solution (Python):
n = int(input())

U = 55555
is_prime = [1]*(U+1)
is_prime[0] = 0
is_prime[1] = 0
for p in range(2, int(U**.5)+1):
    if is_prime[p]:
        for q in range(2*p, U+1, p):
            is_prime[q] = 0
prime_list = [n for n, bl in enumerate(is_prime)if bl]

A = []
for p, bl in enumerate(is_prime):
    if bl and p % 5 == 1:
        A.append(p)

print(*A[:n])

Solution (Python):
import math


def is_prime(x):
    if x == 1:
        return False

    for y in range(2, math.ceil(math.sqrt(x)) + 1):
        if not x % y:
            return False
    return True


def submit():
    n = int(input())

    
    prime_cand = []
    for x in range(2, 55556):
        if is_prime(x):
            prime_cand.append(x)

    
    prime_cand = [p for p in prime_cand if p % 5 == 1]
    print(*prime_cand[:n])
        

submit()

Solution (Python):
import math
N=int(input())

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

plist=[]
p=1
while(len(plist)<N):
  p+=10
  if isPrime(p):
    plist.append(p)
    
print(*plist)

Solution (Python):
import math
N=int(input())

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

plist=[2]
p=11
while(len(plist)<N):
  if p%5==1 and isPrime(p):
    plist.append(p)
  p+=10
    
print(" ".join(map(str,plist)))

Solution (Python):
import math
N=int(input())

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

plist=[2]
p=11
while(len(plist)<N):
  if p%5==1 and isPrime(p):
    plist.append(p)
  p+=2
    
print(" ".join(map(str,plist)))

Solution (Python):
N = int(input())
import math

prime=[]
for n in range(2,55556):
    for i in range(2,math.floor(math.sqrt(n))+1):
        if n % i == 0:
            break
    else:
        if n % 5 == 1:
            prime.append(n)


print(' '.join(list(map(str, prime[:N]))))

Solution (Python):
N = int(input())
D = {i: 1 for i in range(3, 55556, 2)}
D[2] = 1
for i in range(3, 237, 2):
  if D[i] == 1:
    for j in D:
      if j % i == 0 and j != i:
        D[j] = 0
L = []
for i in D:
  if D[i] == 1:
    L.append(i)
X = [[] for i in range(5)]
for i in L:
  X[i%5].append(i)
S = []
for i in range(N):
  S.append(X[1][i])
for i in range(N):
  if i != N - 1:
    print(S[i], end = ' ')
  else:
    print(S[i])

Solution (Python):
a=[2];b=[2]
for i in range(3,100000):
    t=0
    while t<len(a):
        if i%a[t]==0:
            break
        else:t+=1
    else:
        a.append(i)
        if i%5==2:
            b.append(i)

    if len(b)==55:
        break

b.sort()
print(*b[:int(input())])

Solution (Python):
n=int(input())

a=[2]
b=[2]
for i in range(3,10000000):
    t=0
    while t<len(a):
        if i%a[t]==0:
            break
        else:t+=1
    else:
        a.append(i)
        if i%5==2:
            b.append(i)

    if len(b)==55:
        break

b.sort()
print(" ".join(list(map(str, b[:n]))))

Solution (Python):
n = int(input())

def eratosthenes(n):
    import math
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
    return data

sosu = eratosthenes(55555)
ans = [i for i in sosu if i%5==1]

print(*ans[:n],sep=' ')

Solution (Python):


def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False
    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    return is_prime, table

ps = sieve(55555)[1]
N = int(input())
cands = []
for p in ps:
  if p%5 == 1:
    cands.append(p)
    if len(cands) == N:
      break

print(*cands)

Solution (Python):
def main():
    n = int(input())
    primes = get_primes(55555)
    out = []
    num = 0
    for prime in primes:
        if prime%5 == 1:
           out.append(prime)
           num += 1
        if n == num:
            print(*out)
            return

def get_primes(x):
    if x < 2: return []
    if x == 2: return [2]
    limit = x**0.5 + 1
    nums = list(range(3, x+1, 2))
    dividers = [2]
    divider = 3
    while limit > divider:
        dividers.append(divider)
        nums = [num for num in nums if num%divider]
        divider = nums[0]
    return dividers+nums
        
if __name__ == "__main__":
    main()

Solution (Python):
def main():
    n = int(input())
    primes = get_primes(55555)
    out = []
    num = 0
    for prime in primes:
        if prime%5 == 1:
           out.append(prime)
           num += 1
        if n == num:
            print(*out)
            return

def get_primes(x):
    if x < 2:
        return []
    if x == 2:
        return [2]
    limit = x**0.5 + 1
    nums = list(range(3, x+1, 2))
    divider = 3
    dividers = []
    while limit > divider:
        dividers.append(divider)
        nums = [num for num in nums if num%divider]
        divider = nums[0]
    return dividers+nums
        
if __name__ == "__main__":
    main()

Solution (Python):
def main():
    n = int(input())
    primes = get_primes(55555)
    out = []
    num = 0
    for prime in primes:
        if prime%5 == 1:
           out.append(prime)
           num += 1
        if n == num:
            print(*out)
            return

def get_primes(x):
    if x < 2:
        return []
    if x == 2:
        return [2]
    limit = x**0.5
    nums = list(range(3, x+1, 2))
    divider = 3
    dividers = []
    while limit >= divider:
        dividers.append(divider)
        nums = [num for num in nums if num%divider]
        divider = nums[0]
    return dividers+nums
        
if __name__ == "__main__":
    main()

Solution (Python):
def main():
    n = int(input())
    primes = get_primenumber(55555)
    out = []
    num = 0
    for prime in primes:
        if prime%5 == 1:
           out.append(prime)
           num += 1
        if n == num:
            print(*out)
            return

def get_primenumber(number):
    prime_list = []
    if number < 2:
        return prime_list
    if number == 2:
        return [2]
    search_list = [2] + list(range(3, number+1, 2))
    while True:
      if search_list[0] > number**0.5:
        prime_list.extend(search_list)
        break
      else:
        head_num = search_list[0]
        prime_list.append(head_num)
        search_list.pop(0)
        search_list = [num for num in search_list if num % head_num != 0]
    return prime_list

        
if __name__ == "__main__":
    main()

Solution (Python):
def main():
    n = int(input())
    primes = get_primes_less_than(55556)
    out = []
    num = 0
    for prime in primes:
        if prime%5 == 1:
           out.append(prime)
           num += 1
        if n == num:
            print(*out)
            return

def get_primes_less_than(x):
    ans = []
    if x < 3:
        return ans
    if x == 3:
        ans.append(2)
        return ans
    else:
        for i in range(3, x, 2):
            for j in ans:
                if not i%j:
                    break
            else:
                ans.append(i)
    return ans
        
if __name__ == "__main__":
    main()

Solution (Python):
def main():
    n = int(input())
    primes = get_primes_less_than(55556)
    out = []
    num = 0
    for prime in primes:
        if prime%5 == 1:
           out.append(prime)
           num += 1
        if n == num:
            print(*out)
            return

def get_primes_less_than(x):
    ans = []
    ap = ans.append
    if x < 3:
        return ans
    if x == 3:
        ap(2)
        return ans
    else:
        for i in range(3, x, 2):
            for j in ans:
                if not i%j:
                    break
            else:
                ap(i)
    return ans
        
if __name__ == "__main__":
    main()

Solution (Python):
def main():
    n = int(input())
    primes = get_primes_less_than(55556)
    out = []
    num = 0
    for prime in primes:
        if prime%5 == 1:
           out.append(prime)
           num += 1
        if n == num:
            print(*out)
            return

def get_primes_less_than(x):
    ans = []
    if x < 3:
        return ans
    if x == 3:
        ans.append(2)
        return ans
    else:
        for i in range(3, x, 2):
            if all(i%j for j in ans):
                ans.append(i)
    return ans
        
if __name__ == "__main__":
    main()

Solution (Python):
def main():
    n = int(input())
    primes = get_primes_less_than(55556)
    out = []
    num = 0
    for prime in primes:
        if prime%5 == 1:
           out.append(prime)
           num += 1
        if n == num:
            print(*out)
            return

def get_primes_less_than(x):
    ans = []
    if x < 3:
        return ans
    if x == 3:
        ans.append(2)
        return ans
    else:
        for i in range(3, x, 2):
            flag = True
            for j in ans:
                if not i%j:
                    flag = False
                    break
            if flag:
                ans.append(i)
    return ans
        
if __name__ == "__main__":
    main()

Solution (Python):
def primes(n):
    ass = []
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2,int(n**0.5)+1):
        if not is_prime[i]:
            continue
        
        for j in range(i*2,n+1,i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

p_list = primes(55555)
ans = []
for p in p_list:
    if p%5 == 1:
        ans.append(p)

n = int(input())

print(' '.join(map(str,ans[:n])))

Solution (Python):
def check(x):
  for i in range(2,int(x**0.5)+1):
    if x%i==0:
      return False
  return True
n=int(input())
l=[]
for i in range(11,55551,10):
  if check(i):
    l.append(i)
print(*l[:n])

Solution (Python):
print(*[2, 7, 17, 37, 47, 67, 97, 107, 127, 137, 157, 167, 197, 227, 257, 277, 307, 317, 337, 347, 367, 397, 457, 467, 487, 547, 557, 577, 587, 607, 617, 647, 677, 727, 757, 787, 797, 827, 857, 877, 887, 907, 937, 947, 967, 977, 997, 1087, 1097, 1117, 1187, 1217, 1237, 1277, 1297][:int(input())])

Solution (Python):
import sys
input = sys.stdin.readline

n = int(input())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

a = []

for i in range(2, 55556):
    if is_prime(i) and i % 5 == 1:
        a.append(i)

print(*a[:n])

Solution (Python):

n = int(input())
prime_5 = []
for i in range(2, 55556):
    flg = (i % 5 == 1)
    if flg:
        for j in range(2, int(i**0.5)+1):
            if i % j == 0:
                flg = False
                break
    if flg:
        prime_5.append(i)
print(*prime_5[:n])

Solution (Python):
def prime(n):
    N=[1 for i in range(n+1)]
    N[0],N[1]=0,0
    for i in range(4,n+1,2):N[i]=0
    for i in range(3,int(n**0.5)+1):
        if N[i]==1:
            for j in range(i*2,n+1,i):
                N[j]=0
    return [i for i,j in enumerate(N) if j==1]


n=int(input())
num=prime(55555)
cnt,A=0,[]
for i in num:
    if i%5==1:
        A.append(i)
        cnt +=1
    if cnt==n:
        print(*A);exit()

Solution (Python):
n = int(input())
P, A = [2], [2]
for i in range(3, 55556, 2):
    for p in P:
        if i % p == 0: break
    else:
        P.append(i)
        if i % 5 == 2: A.append(i)
    if len(A) == n: break
print(*A)

Solution (Python):

N = int(input())


lim = 10 ** 5
candidates = [True for _ in range(lim)]
candidates[0], candidates[1] = False, False
for i in range(lim):
    if candidates[i]:
        for j in range(i*2, lim, i):
            candidates[j] = False


nums = []
for i in range(lim):
    if candidates[i]:
        if i % 5 == 1:
            nums.append(i)

print(*nums[:N])

Solution (Python):
def sieve(n):
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]:
            continue
        else:
            for j in range(i*2, n+1, i):
                is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

n = int(input())
prime_lst = sieve(55555)

res = []
for p in prime_lst:
    if p%5==1:
        res.append(p)
print(*res[:n])

Solution (Python):
x=int(input())
a=[0]*x
k=0
t=0
for i in range(11,55555,10):
	t=0
	for j in range (2,round(i**0.5)+2):
		if i%j==0:
			t=1
	if t==0 and k<x:
		a[k]=i
		k=k+1
print(*a)