Language: C++

#include<bits/stdc++.h>
#define FOR(i,n,m) for(int i = m;i<n;i++)
#define rep(i,n) FOR(i,n,0)
#define ll long long
#define INF (1e9)
#define PI (acos(-1))
int dy[] = { 0, 0, 1, -1 };
int dx[] = { 1, -1, 0, 0 };
using namespace std;
int n;
int ans[55];
bool sosuu[10000000];
void Eratosthenes() {
	for (int i = 0; i < 10000000; i++) {
		sosuu[i] = true;
	}
	sosuu[0] = sosuu[1] = false;
	for (int i = 2; i < sqrt(10000000); i++) {
		if (sosuu[i]) {
			for (int j = 0; i * (j + 2) < 10000000; j++) {
				sosuu[i *(j + 2)] = false;
			}
		}
	}
}]int com[5][3478761];
int count = 0; // 組合せの総数

			   // 実際に組合せを生成する
			   // comb: 生成された組合せ配列
			   // step: n桁目までが生成されていることを示す。
			   // init: その桁始まりの数を示す。
void makeCombination(vector comb, int n, int r, int step, int init) {
	// r桁すべてが生成された
	if (step == r) {
		for (int j = 0; j < r; ++j) {
			com[j][count] = comb[j];
		}
		++count;
		return;
	}

	// 全桁生成されていない
	for (int i = init; i <= n - r + step; ++i) {
		comb.push_back(i);
		makeCombination(comb, n, r, step + 1, i + 1);
		// ここで配列から一つ排除しないと困ったことになる
		comb.pop_back();
	}
}

// makeCombinationに値を渡すためだけの関数
// n個の中からr個選択する
void combination(int n, int r) {
	vector comb;
	makeCombination(comb, n, r, 0, 0);
}
bool check(int num) {
	combination(num, 5);
	for (i, count) {
		if (sosuu[ans[com[0][count]] + ans[com[1][count]] + ans[com[2][count]] + ans[com[3][count]] + ans[com[4][count]] == true)return false;
	}
	return true;
}



int main() {
	Eratosthenes();
	int nowpos = 0;
	cin >> n;
	rep(i, 10000000){
		if (sosuu[i]) {
			ans[nowpos] = i;
			nowpos++;
			sosuu[i] = false;
		}
		if (nowpos == 4)break;
	}
	rep(i, 10000000) {
		if (sosuu[i]) {
			ans[nowpos] = i;
			if (check(nowpos) ){
				ans[nowpos] = i;
				nowpos++;
			}
			if (nowpos == n)break;
		}
	}
	rep(i, n - 1)cout << ans[i] << " ";
	cout << ans[n - 1] << endl;
	return 0;
}


Compiler output:
a.cc:25:2: error: expected unqualified-id before ']' token
   25 | }]int com[5][3478761];
      |  ^
a.cc:32:22: error: missing template argument list after 'std::vector'; template placeholder not permitted in parameter
   32 | void makeCombination(vector comb, int n, int r, int step, int init) {
      |                      ^~~~~~
      |                            <>
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:428:11: note: 'template<class _Tp, class _Alloc> class std::vector' declared here
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
a.cc: In function 'void makeCombination(...)':
a.cc:36:25: error: 'com' was not declared in this scope; did you mean 'cos'?
   36 |                         com[j][count] = comb[j];
      |                         ^~~
      |                         cos
a.cc:36:32: error: reference to 'count' is ambiguous
   36 |                         com[j][count] = comb[j];
      |                                ^~~~~
In file included from /usr/include/c++/14/algorithm:86,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:4025:5: note:                 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4025 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
a.cc:26:5: note:                 'int count'
   26 | int count = 0; // 組合せの総数
      |     ^~~~~
a.cc:36:41: error: 'comb' was not declared in this scope; did you mean 'wctomb'?
   36 |                         com[j][count] = comb[j];
      |                                         ^~~~
      |                                         wctomb
a.cc:38:19: error: reference to 'count' is ambiguous
   38 |                 ++count;
      |                   ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note:                 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4025 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
a.cc:26:5: note:                 'int count'
   26 | int count = 0; // 組合せの総数
      |     ^~~~~
a.cc:44:17: error: 'comb' was not declared in this scope; did you mean 'wctomb'?
   44 |                 comb.push_back(i);
      |                 ^~~~
      |                 wctomb
a.cc: In function 'void combination(int, int)':
a.cc:54:16: error: class template argument deduction failed:
   54 |         vector comb;
      |                ^~~~
a.cc:54:16: error: no matching function for call to 'vector()'
/usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate: 'template<class _Tp, class _Alloc, class _InputIterator, class> vector(_InputIterator, _InputIterator, const _Alloc&)-> std::vector<_Tp, _Alloc>'
  707 |         vector(_InputIterator __first, _InputIterator __last,
      |         ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:707:9: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::initializer_list<_Tp>, const _Alloc&)-> std::vector<_Tp, _Alloc>'
  678 |       vector(initializer_list<value_type> __l,
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:678:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, std::__type_identity_t<_Alloc>&)-> std::vector<_Tp, _Alloc>'
  659 |       vector(vector&& __rv, const __type_identity_t<allocator_type>& __m)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:659:7: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, const _Alloc&, std::false_type)-> std::vector<_Tp, _Alloc>'
  640 |       vector(vector&& __rv, const allocator_type& __m, false_type)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:640:7: note:   candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, const _Alloc&, std::true_type)-> std::vector<_Tp, _Alloc>'
  635 |       vector(vector&& __rv, const allocator_type& __m, true_type) noexcept
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:635:7: note:   candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&)-> std::vector<_Tp, _Alloc>'
  624 |       vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:624:7: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&)-> std::vector<_Tp, _Alloc>'
  620 |       vector(vector&&) noexcept = default;
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:620:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const std::vector<_Tp, _Alloc>&)-> std::vector<_Tp, _Alloc>'
  601 |       vector(const vector& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:601:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::size_t, const _Tp&, const _Alloc&)-> std::vector<_Tp, _Alloc>'
  569 |       vector(size_type __n, const value_type& __value,
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:569:7: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::size_t, const _Alloc&)-> std::vector<_Tp, _Alloc>'
  556 |       vector(size_type __n, const allocator_type& __a = allocator_type())
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:556:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const _Alloc&)-> std::vector<_Tp, _Alloc>'
  542 |       vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:542:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate: 'template<class _Tp, class _Alloc> vector()-> std::vector<_Tp, _Alloc>'
  531 |       vector() = default;
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:531:7: note:   template argument deduction/substitution failed:
a.cc:54:16: note:   couldn't deduce template parameter '_Tp'
   54 |         vector comb;
      |                ^~~~
/usr/include/c++/14/bits/stl_vector.h:428:11: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>)-> std::vector<_Tp, _Alloc>'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:2033:5: note: candidate: 'template<class _InputIterator, class _ValT, class _Allocator, class, class> std::vector(_InputIterator, _InputIterator, _Allocator)-> vector<_ValT, _Allocator>'
 2033 |     vector(_InputIterator, _InputIterator, _Allocator = _Allocator())
      |     ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:2033:5: note:   candidate expects 2 arguments, 0 provided
a.cc: In function 'bool check(int)':
a.cc:59:14: error: 'i' was not declared in this scope
   59 |         for (i, count) {
      |              ^
a.cc:59:17: error: reference to 'count' is ambiguous
   59 |         for (i, count) {
      |                 ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note:                 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4025 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
a.cc:26:5: note:                 'int count'
   26 | int count