#include <stdio.h>
#include <string.h>
#define ISBITSET(x, i) (( x[i>>3] & (1<<(i&7)) ) != 0)
#define SETBIT(x, i) x[i>>3] |= (1<<(i&7));
#define CLEARBIT(x, i) x[i>>3] &= (1<<(i&7)) ^ 0xFF;
long long sumPrimes(int n) {
char b[n/8+1];
long long i, p;
long long s = 0;
for (p=2; p<n; p++) {
if (ISBITSET(b,p)) {
//printf("%d\n", p);
s += p;
for (i=p*p; i<n; i+=p) {
CLEARBIT(b, i); }}}
return s; }
int main(void) {
printf("%lld\n", sumPrimes
(2000000)); return 0; }
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KCiNkZWZpbmUgSVNCSVRTRVQoeCwgaSkgKCggeFtpPj4zXSAmICgxPDwoaSY3KSkgKSAhPSAwKQojZGVmaW5lIFNFVEJJVCh4LCBpKSB4W2k+PjNdIHw9ICgxPDwoaSY3KSk7CiNkZWZpbmUgQ0xFQVJCSVQoeCwgaSkgeFtpPj4zXSAmPSAoMTw8KGkmNykpIF4gMHhGRjsKCmxvbmcgbG9uZyBzdW1QcmltZXMoaW50IG4pIHsKICAgIGNoYXIgYltuLzgrMV07CiAgICBsb25nIGxvbmcgaSwgcDsKICAgIGxvbmcgbG9uZyBzID0gMDsKICAgIAogICAgbWVtc2V0KGIsIDI1NSwgc2l6ZW9mKGIpKTsKICAgIGZvciAocD0yOyBwPG47IHArKykgewogICAgICAgIGlmIChJU0JJVFNFVChiLHApKSB7CiAgICAgICAgICAgIC8vcHJpbnRmKCIlZFxuIiwgcCk7CiAgICAgICAgICAgIHMgKz0gcDsKICAgICAgICAgICAgZm9yIChpPXAqcDsgaTxuOyBpKz1wKSB7CiAgICAgICAgICAgICAgICBDTEVBUkJJVChiLCBpKTsgfX19CiAgICByZXR1cm4gczsgfQoKaW50IG1haW4odm9pZCkgewogICAgcHJpbnRmKCIlbGxkXG4iLCBzdW1QcmltZXMoMjAwMDAwMCkpOwogICAgcmV0dXJuIDA7IH0=