A little girl loves problems on bitwise operations very much. Here's one of them.

You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones.

Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor».


-----Input-----

The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18).

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.


-----Output-----

In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r).


-----Examples-----
Input
1 2

Output
3

Input
8 16

Output
31

Input
1 1

Output
0

Difficulty: interview

Starter code:

Solutions:
import sys
l,r=map(int,(sys.stdin.readline().split()))
i=64
while i>=0:
    if ((1<<i)&l!=0 and (1<<i)&r!=0) or ((1<<i)&l==0 and (1<<i)&r==0):i-=1
    else:break
print((1<<(i+1))-1)

l,r=map(int,(input().split()))
for i in range(64,-2,-1):
    if(i<0 or ((1<<i)&l)!=((1<<i)&r)): break
print((1<<(i+1))-1)

# miracle!!
# cannot believe!!

(l, r) = list(map(int, input().split()))

bl = (r-l).bit_length()

print((((r^l)>>bl)+1<<bl)-1)


l, r = map(int, input().split())
i = 0
if l == r: print(0)
else:
    l, r = format(l, 'b'), format(r, 'b')
    if len(l) == len(r):
        while l[i] == r[i]: i += 1
    print((1 << len(r) - i) - 1)

import sys

l, r = tuple(int(x) for x in sys.stdin.readline().split())
maximum = -1
cur_pow = 1

while cur_pow <= r:
    if cur_pow - 1 >= l:
        cur_result = cur_pow ^ (cur_pow - 1)
        maximum = max(maximum, cur_result)
    cur_pow *= 2

if maximum < 0:
    n_ones = len(bin(l))
    str1, str2 = bin(l), bin(r)
    index = 0
    while index < len(str1) and index < len(str2) and str1[index] == str2[index]:
        index += 1
        n_ones -= 1
    if n_ones == 0:
        maximum = 0
    else:
        maximum = int('1' * n_ones, 2)

print(maximum)


# your code goes here
import sys
l, r = tuple(int(x) for x in sys.stdin.readline().split())
l = bin(l)
r = bin(r)
l = l[2:]
r = r[2:]
l = l.zfill(len(r))
#print (l)
#print (r)
i = 0
while l[i] == r[i]:
	if i == len(l)-1:
		print (0)
		return
	i+=1
i=len(l)-i
print(2**i-1)		

l,r=list(map(int,input().split()))
res=0
for it in range(62,-1,-1):
    if ((l>>it)&1) != ((r>>it)&1):
        res=(1<<it+1)-1
        break
print (res)


def main():
    l, r = (format(int(s), 'b') for s in input().split())
    le = len(r)
    if len(l) == le:
        for i in range(le):
            if l[i] != r[i]:
                print(int('1' * (le - i), 2))
                break
        else:
            print(0)
    else:
        print(int('1' * le, 2))


def __starting_point():
    main()

__starting_point()

#in the name of god
#Mr_Rubick
l,r=list(map(int, input().split()))
i=0
if l==r:
    if l==1 and r==1:print(0)
    else:print(1)
else:
    l,r=format(l,'b'),format(r,'b')
    if len(l)==len(r):
        while l[i]==r[i]:
            i+=1
    print((1 << len(r)-i)-1)


import math

l, r = map(int, input().split())

if l==r:
    print("0")
else:
    msb = int(math.log2(r))
    for i in range(msb, -1, -1):
        if (l & (1 << i)) != (r & (1 << i)):
            break

    print(2*(1<<i)-1)

def maximum(l,r):

    r = bin(r)[2:]
    l = bin(l)[2:].zfill(len(r))

    if r[0] == "1" and l[0] == "0":
        return int("1"*len(l), base=2)
    else:
        #print(l,r)

        if l[1:] != "":

            l =int(l[1:],base=2)
            r = int(r[1:], base=2)

        else:
            return 0

        return maximum(l,r)


inp = input()
l, r = inp.split(" ")
print(maximum(int(l),int(r)))

l = [int(x) for x in input().split()]
l.sort()
b, a = l

s1 = list(bin(a)[2:])
s2 = list(bin(b)[2:])

if s1 == s2:
    print(0)

elif len(s1) == len(s2):
    cont = 0
    while s1[cont] == s2[cont]:
        s1[cont] = "0"
        cont+=1
    for i in range(cont , len(s1)):
        s1[i] = "1"
    print(int("".join(s1), 2))

else:
    for i in range(len(s1)):
        s1[i] = "1"
    print(int("".join(s1), 2))




l = [int(x) for x in input().split()]
l.sort()
b, a = l

s1 = list(bin(a)[2:])
s2 = list(bin(b)[2:])

if s1 == s2:
    print(0)

elif len(s1) == len(s2):
    cont = 0
    while s1[cont] == s2[cont]:
        s1[cont] = "0"
        cont+=1
    for i in range(cont , len(s1)):
        s1[i] = "1"
    print(int("".join(s1), 2))

else:
    for i in range(len(s1)):
        s1[i] = "1"
    print(int("".join(s1), 2))




lr = input().split()
l,r = [int(x) for x in lr]

if l == r:
    print(0)
else:
    a,b = list(bin(l)[2:]), list(bin(r)[2:])

    if len(a) == len(b):
        i = 0
        while a[i] == b[i]:
            i+=1
        left = '1'*(len(a)-i)
        print(int(left,2))
    elif len(a) > len(b):
        left = '1'*(len(a))
        print(int(left,2))
    else:
        left = '1'*(len(b))
        print(int(left,2))

lr = input().split()
l,r = [int(x) for x in lr]

if l == r:
    print(0)
    
else:
    a,b = list(bin(l)[2:]), list(bin(r)[2:])
    if len(a) == len(b):
        i = 0
        while a[i] == b[i]:
            i+=1
        left = '1'*(len(a)-i)
        print(int(left,2))
    elif len(a) > len(b):
        left = '1'*(len(a))
        print(int(left,2))
    else:
        left = '1'*(len(b))
        print(int(left,2))

l, r = map(int, input().split())
hmm, t = l ^ r, 2 ** 60
while hmm ^ t > hmm:
  t //= 2
print(2 * t - 1 if hmm != 0 else 0)

a,b  = map(int, input().split())

print(2**(a ^ b).bit_length() -1)

l, r = ['{:061b}'.format(int(x)) for x in input().split()]

pot = 0
for i in range(61):
    if l[i] != r[i]:
        pot = 61 - i
        break

if pot == 0:
    print(0)
else:
    print((2**pot - 2) ^ 1)

from math import log2
l,r = list(map(int,input().split()))
if(l == r):print('0')
else : print((1 << int(log2(l ^ r) + 1)) - 1)


import math
l,r = list(map(int,input().strip().split()))
lr = int(math.log(r)/math.log(2))
ll = int(math.log(l)/math.log(2))

if lr > ll:
	lr+=1
	ans = 1<<lr
	ans-=1
	print(ans)
else:
	ans = 0
	fl = False
	for i in range(lr,-1,-1):
		if l&(1<<i) == r&(1<<i) and fl == False:
			continue 
		elif l&(1<<i) != r&(1<<i):
			ans = ans + (1<<i)
			fl = True
		elif fl == True:
			ans = ans + (1<<i)
				
	print(ans)
##101100101110010110010011110101101110101101111010110010011000
##100101001000010011010111110011010001111010111010011001111010


a, b = list(map(int, input().split()))
s=-1
for i in range(60, 0, -1):
    if a&(1<<i)==0 and b&(1<<i)!=0:
        print((1<<(i+1))-1)
        break
else:
    print(a^b)


import sys
l,r=list(map(int,sys.stdin.readline().split()))
binr=list(str(bin(r)))[2:]
binl=list(str(bin(l)))[2:]
lenr=len(binr)
lenl=len(binl)
for i in range(lenr-lenl):
    binl.insert(0,0)

ans=['1']
length=lenr
status=0
for i in range(0,length):
    if status==1:
        ans.append('1')
    if(binr[i]!=binl[i]):
        status=1

if(status==0):
    print(0)
else:
    strans=''.join(ans)
    print(int(strans,2))

        



a,b=list(map(int,input().split()))
s1=list(map(int,reversed(list(bin(a)[2:]))))
s2=list(map(int,reversed(list(bin(b)[2:]))))
s1+=[0]*(len(s2)-len(s1))
out=0
for i in range(len(s1)):
    if s1[i]^s2[i]:
        out=i+1

print(2**out-1)


n,m=list(map(int,input().split()))
n=str(bin(n))[2:]
m=str(bin(m))[2:]
n='0'*(len(m)-len(n))+n
f=0
for i in range(len(n)):
    if n[i]=='0' and m[i]=='1':
        print(2**(len(n)-i)-1)
        f=1
        break
if not f:
    print(f)


n=input().split()
m=int(n[1])
n=int(n[0])
if m<n:
    c=m
    m=n
    n=c
c=''
a=bin(m)[2:]
b=bin(n)[2:]
b='0'*(len(a)-len(b))+b
while a[0]==b[0] and len(a)!= 0:
    c1 = str(int(a[0])^int(b[0]))
    c+=c1
    a=a[1:]
    b=b[1:]
    if len(a)==0 or len(b)==0:
        break
    #if len(a)!=0:
     #   a=str(int(a))
    #if len(b)!=0:
     #7   b=str(int(b))
aa=max(len(b),len(a))
c=c+aa*'1'
c=int(c)
d=1
p=0
while c!=0:
    s=c%10
    p+=d*s
    d=d*2
    c=c//10
print(p)