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<bits/stdc++.h>
#define ll long long
using namespace std;
ll get(ll A,ll B){
    int i,a,b;ll t;
    if(A==B) return 1;
    for(a=0;A>=(1ll<<a);a++);
    for(b=0;B>=(1ll<<b);b++);
    if(a>b+1) return (1ll<<a)-B;
    else if(a>b){
        for(i=a-2;i>=0;i--)
            if(A&(1ll<<i)) break;
        t=i==-1?0:(1ll<<(i+1))-1;
        if(B<=t+1) return (1ll<<a)-B;
        return ((1ll<<(a-1))|t)-B+1+(1ll<<(a-1))-B;
    }
    else return get(A^(1ll<<(a-1)),B^(1ll<<(b-1)));
}
int main()
{
    ll A,B;
    cin>>B>>A;
    cout<<get(A,B);
    return 0;
}