Problem:
Score : 900 points

Problem Statement

Nukes has an integer that can be represented as the bitwise OR of one or more integers between A and B (inclusive).
How many possible candidates of the value of Nukes's integer there are?

Constraints

1 ≤ A ≤ B < 2^{60}

A and B are integers.

Input

The input is given from Standard Input in the following format:

A
B

Output

Print the number of possible candidates of the value of Nukes's integer.

Sample Input 1

7
9

Sample Output 1

4

In this case, A=7 and B=9. There are four integers that can be represented as the bitwise OR of a non-empty subset of {7, 8, 9}: 7, 8, 9 and 15.

Sample Input 2

65
98

Sample Output 2

63

Sample Input 3

271828182845904523
314159265358979323

Sample Output 3

68833183630578410

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<cstdio>
#include<cstring>
#include<algorithm>
#define MN 2100
#define ll long long
using namespace std;

int read_p,read_ca;
inline int read(){
	read_p=0;read_ca=getchar();
	while(read_ca<'0'||read_ca>'9') read_ca=getchar();
	while(read_ca>='0'&&read_ca<='9') read_p=read_p*10+read_ca-48,read_ca=getchar();
	return read_p;
}
long long l,r,mmh;
inline ll max(ll a,ll b){return a>b?a:b;}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll work(ll l,ll r,ll up){
	if (l>r) swap(l,r);
	int i;
	if (l==r) return 0;
	for (i=60;;i--) if (((r>>i)&1)&&(!((l>>i)&1))) break;
	//printf("%lld %lld %lld %lld %lld\n",l,r,mmh,up,1ll<<i);
	r&=(1ll<<(i+1))-1;l&=(1ll<<(i+1))-1;r^=1ll<<i;
	if (r+1>=l) return min(1ll<<i,up)-r-1;
	ll mmh=work(0,r,min(up,l));
	mmh+=min((1ll<<i),up)-l;
	return mmh;
}
int main(){
	int i,j;
	scanf("%lld%lld",&l,&r);
	if (l==r) return puts("1"),0;
	printf("%lld\n",work(l,r,1ll<<62)+r-l+1);
}