#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
const int NMAX = (int)1e8;
std::bitset<NMAX> bits;
int main() {
bits.set();
bits[0] = bits[1] = 0;
for (int i = 2; i * i <= NMAX; i++) {
if (bits[i]) {
for (int j = i * i; j <= NMAX; j += i) bits[j] = 0;
}
}
//iterate over primes
int64_t sum(0);
int cnt(0);
for (int p = bits._Find_first(); p < bits.size(); p = bits._Find_next(p)) {
sum += p;
cnt++;
}
assert(bits.count() == cnt);
std::cout << "sum = " << sum << std::endl;
std::cout << "cnt = " << cnt << std::endl;
return 0;
}
I3ByYWdtYSBHQ0Mgb3B0aW1pemUoIk9mYXN0IikKI3ByYWdtYSBHQ0MgdGFyZ2V0KCJhdngiKQojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KY29uc3QgaW50IE5NQVggPSAoaW50KTFlODsKc3RkOjpiaXRzZXQ8Tk1BWD4gYml0czsKaW50IG1haW4oKSB7CgliaXRzLnNldCgpOwoJYml0c1swXSA9IGJpdHNbMV0gPSAwOwoJZm9yIChpbnQgaSA9IDI7IGkgKiBpIDw9IE5NQVg7IGkrKykgewoJCWlmIChiaXRzW2ldKSB7CgkJCWZvciAoaW50IGogPSBpICogaTsgaiA8PSBOTUFYOyBqICs9IGkpIGJpdHNbal0gPSAwOwoJCX0KCX0KCS8vaXRlcmF0ZSBvdmVyIHByaW1lcwoJaW50NjRfdCBzdW0oMCk7CglpbnQgY250KDApOwoJZm9yIChpbnQgcCA9IGJpdHMuX0ZpbmRfZmlyc3QoKTsgcCA8IGJpdHMuc2l6ZSgpOyBwID0gYml0cy5fRmluZF9uZXh0KHApKSB7CgkJc3VtICs9IHA7CgkJY250Kys7Cgl9CiAgICBhc3NlcnQoYml0cy5jb3VudCgpID09IGNudCk7CglzdGQ6OmNvdXQgPDwgInN1bSA9ICIgPDwgc3VtIDw8IHN0ZDo6ZW5kbDsKCXN0ZDo6Y291dCA8PCAiY250ID0gIiA8PCBjbnQgPDwgc3RkOjplbmRsOwoJcmV0dXJuIDA7Cn0=