#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int N = 1000; //Print primes number from 1 to N
vector<bool> primes(N, true);
long long count = 0;
for(int i = 3; i*i < N; i += 2){
for(int j = 3; j*i < N; j+=2){
primes[j*i] = false;
count++;
}
}
if(N >= 2) cout << "2 ";
for(int i = 3; i < N; i+=2){
count++;
if(primes[i] == true) cout << i << " ";
}
cout << "\ncnt : " << count;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CiAgICBpbnQgTiA9IDEwMDA7IC8vUHJpbnQgcHJpbWVzIG51bWJlciBmcm9tIDEgdG8gTgoJdmVjdG9yPGJvb2w+IHByaW1lcyhOLCB0cnVlKTsKICAgIGxvbmcgbG9uZyAgY291bnQgPSAwOwogICAgZm9yKGludCBpID0gMzsgaSppIDwgTjsgaSArPSAyKXsKICAgIAlmb3IoaW50IGogPSAzOyBqKmkgPCBOOyBqKz0yKXsKICAgIAkJcHJpbWVzW2oqaV0gPSBmYWxzZTsKICAgIAkJY291bnQrKzsKICAgIAl9CiAgICB9CiAgICBpZihOID49IDIpIGNvdXQgPDwgIjIgIjsKICAgIGZvcihpbnQgaSA9IDM7IGkgPCBOOyBpKz0yKXsKICAgIAljb3VudCsrOwogICAgCWlmKHByaW1lc1tpXSA9PSB0cnVlKSBjb3V0IDw8IGkgPDwgIiAiOyAKICAgIH0KCWNvdXQgPDwgIlxuY250IDogIiA8PCBjb3VudDsKCiAgICByZXR1cm4gMDsKfQ==