[AGC015D] A or...or B Problem
#include <bits/stdc++.h>
typedef long long ll;
ll l,r,mid;
int t;
int main(){
scanf("%lld%lld",&l,&r);
if (l==r){
puts("1");
return 0;
}
for (int i=60;i>=0;i--)
if ((l&(1ll<<i))==(r&(1ll<<i)))
l-=(l&(1ll<<i)),r-=(r&(1ll<<i));
else {
mid=1ll<<i;
t=-1;
for (int j=i-1;j>=0;j--)
if (r&(1ll<<j)){
t=j;
break;
}
break;
}
ll l1=l,r1=(t==-1)?mid:mid+(1ll<<t+1)-1;
ll l2=mid|l,r2=2*mid-1;
if (l2<=r1) printf("%lld\n",r2-l1+1);
else printf("%lld\n",r1-l1+1+r2-l2+1);
}
* 生而自由 爱而无畏 *