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 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <stdio.h>

#define lln long long int

int main(){
	lln A, B, C, D, E;
	scanf("%lld%lld", &A, &B);
	for(C = 1; ; C <<= 1){
		if(C >= B){
			C >>= 1;
			if(C >= A){
				D = B - C;
				break;
			}
			else{
				A -= C;
				B -= C;
				C = 1;
			}
		}
	}
	for(E = 1; ; E <<= 1){
		if(E > D){
			E--;
			break;
		}
	}/*
	printf("C:%lld\n", C);
	printf("D:%lld\n", D);
	printf("E:%lld\n", E);*/
	if(E >= A){
		printf("%lld\n", 2 * C - A);
	}
	else{
		printf("%lld\n", 2 * (C - A) + E + 1);
	}
	return 0;
}