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 count;
int com[5][3478761];
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;
			}
		}
	}
}


			   // 実際に組合せを生成する
			   // comb: 生成された組合せ配列
			   // step: n桁目までが生成されていることを示す。
			   // init: その桁始まりの数を示す。
void makeCombination(vector<int> 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<int> 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: In function 'void makeCombination(std::vector<int>, int, int, int, int)':
a.cc:38:32: error: reference to 'count' is ambiguous
   38 |                         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,
                 from a.cc:1:
/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:11:5: note:                 'int count'
   11 | int count;
      |     ^~~~~
a.cc:40:19: error: reference to 'count' is ambiguous
   40 |                 ++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:11:5: note:                 'int count'
   11 | int count;
      |     ^~~~~
a.cc: In function 'bool check(int)':
a.cc:61:14: error: 'i' was not declared in this scope
   61 |         for (i, count) {
      |              ^
a.cc:61:17: error: reference to 'count' is ambiguous
   61 |         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:11:5: note:                 'int count'
   11 | int count;
      |     ^~~~~
a.cc:64:9: error: expected primary-expression before 'return'
   64 |         return true;
      |         ^~~~~~
a.cc:63:10: error: expected ';' before 'return'
   63 |         }
      |          ^
      |          ;
   64 |         return true;
      |         ~~~~~~
a.cc:64:9: error: expected primary-expression before 'return'
   64 |         return true;
      |         ^~~~~~
a.cc:63:10: error: expected ')' before 'return'
   63 |         }
      |          ^
      |          )
   64 |         return true;
      |         ~~~~~~
a.cc:61:13: note: to match this '('
   61 |         for (i, count) {
      |             ^
a.cc:65:1: warning: control reaches end of non-void function [-Wreturn-type]
   65 | }
      | ^