#pragma GCC optimize("Ofast") #pragma GCC target("avx2") char*mmap(); char wbuf[1<<25]; #define rd_skip_line() while(*rp++!=10) #define rd(v) long v=0;{long _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;} #define WTHI(v) {long _z=v,_n=0,_d=0;while(++_n,_d=_d<<8|0x30|_z%10,_z/=10);*(long*)wp=_d;wp+=_n;} #define WTLO(v) {long _z=v,_n=8,_d=0;while(_d=_d<<8|0x30|_z%10,_z/=10,--_n);*(long*)wp=_d;wp+=8;} #define wt(v) {WTHI(v);} char a[500000/8+8]; main(){ char*rp=mmap(0l,1l<<25,1,2,0,0ll); char*wp=wbuf; long z=0; rd_skip_line(); while(*rp){ rd(l); rd(r); int*p=(int*)(a+(l>>3)); int m=(1<<(r-=l-1))-1<<(l&7); int x=*p; x^=m; *p=x; x&=m; z+=__builtin_popcount(x)*2-r; wt(z); *wp++='\n'; } write(1,wbuf,wp-wbuf); _exit(0); }