#include #include #include #include #include #include #include #include #include #include #include #include #include #define p(s) cout<<(s)<=n;i--) #define CK(n,a,b) ((a)<=(n)&&(n)<(b)) #define F first #define S second typedef long long ll; using namespace std; const int inf = 1e9+7; int K; bool isPrime_v[1000010]; // 処理用のメモリ確保 vector hurui_v(int n) { vector v; //bool *isPrime_v; // 初期化 isPrime_v[0] = isPrime_v[1] = false; for (int i = 2; i < n + 1; i++) isPrime_v[i] = true; // isPrime[0~n]で素数のものだけtrueにする for (int i = 2; i*i <= n; i++) { for (int j = i * 2; j < n + 1; j += i) { isPrime_v[j] = false; } } // 素数のみ追加 for (int i = 0; i < n + 1; i++) { if (isPrime_v[i]) v.push_back(i); } //delete[] isPrime_v; //メモリ解放 return v; } int one, sosu, rest; int main(){ cin>>K; if(K==0){ cout<<2< prime = hurui_v(1000000); int mn = inf; REP(i, 1, 251) { REP(j, 0, 251 - i) { if (i * (i - 1) / 2 + i * j < K && K - (i * (i - 1) / 2 + i * j) + i + j < mn) { one = i; sosu = j; rest = K - (i * (i - 1) / 2 + i * j); mn = one + sosu + rest; } } } //cout << K << endl; cout << mn+1 << endl; REP(i, 0, one) { cout << "1 "; } REP(i, 0, sosu) { cout << "2 "; } cout << "8 "; int cnt=1000; REP(i, 4, 1000) { if (rest <= 1){ cnt=i; break; } if (!isPrime_v[prime[i] - 7] && !isPrime_v[prime[i] - 6]) { cout << prime[i] - 8 << " "; rest--; } } REP(i, cnt, 1000) { if (!isPrime_v[prime[i] - 7] && !isPrime_v[prime[i] - 6]) { cout << prime[i] - 8 <