#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) {
int m = (n-1) / 2;
char b[m/8+1];
int i = 0;
int p = 3;
long long s = 2;
int j;
while (p*p < n) {
if (ISBITSET(b,i)) {
s += p;
j = (p*p - 3) / 2;
while (j < m) {
CLEARBIT(b, j);
j += p; } }
i += 1; p += 2; }
while (i < m) {
if (ISBITSET(b,i)) {
s += p; }
i += 1; p += 2; }
return s; }
int main(void) {
printf("%lld\n", sumPrimes
(2000000)); return 0; }
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KCiNkZWZpbmUgSVNCSVRTRVQoeCwgaSkgKCggeFtpPj4zXSAmICgxPDwoaSY3KSkgKSAhPSAwKQojZGVmaW5lIFNFVEJJVCh4LCBpKSB4W2k+PjNdIHw9ICgxPDwoaSY3KSk7CiNkZWZpbmUgQ0xFQVJCSVQoeCwgaSkgeFtpPj4zXSAmPSAoMTw8KGkmNykpIF4gMHhGRjsKCmxvbmcgbG9uZyBzdW1QcmltZXMoaW50IG4pIHsKICAgIGludCBtID0gKG4tMSkgLyAyOwogICAgY2hhciBiW20vOCsxXTsKICAgIGludCBpID0gMDsKICAgIGludCBwID0gMzsKICAgIGxvbmcgbG9uZyBzID0gMjsKICAgIGludCBqOwogICAgCiAgICBtZW1zZXQoYiwgMjU1LCBzaXplb2YoYikpOwoKICAgIHdoaWxlIChwKnAgPCBuKSB7CiAgICAgICAgaWYgKElTQklUU0VUKGIsaSkpIHsKICAgICAgICAgICAgcyArPSBwOwogICAgICAgICAgICBqID0gKHAqcCAtIDMpIC8gMjsKICAgICAgICAgICAgd2hpbGUgKGogPCBtKSB7CiAgICAgICAgICAgICAgICBDTEVBUkJJVChiLCBqKTsKICAgICAgICAgICAgICAgIGogKz0gcDsgfSB9CiAgICAgICAgaSArPSAxOyBwICs9IDI7IH0KCiAgICB3aGlsZSAoaSA8IG0pIHsKICAgICAgICBpZiAoSVNCSVRTRVQoYixpKSkgewogICAgICAgICAgICBzICs9IHA7IH0KICAgICAgICBpICs9IDE7IHAgKz0gMjsgfQoKICAgIHJldHVybiBzOyB9CgppbnQgbWFpbih2b2lkKSB7CiAgICBwcmludGYoIiVsbGRcbiIsIHN1bVByaW1lcygyMDAwMDAwKSk7CiAgICByZXR1cm4gMDsgfQ==