Problem:
 Score : 400 points    Problem Statement Let f(A, B) be the exclusive OR of A, A+1, ..., B . Find f(A, B) .   What is exclusive OR?  The bitwise exclusive OR of integers c_1, c_2, ..., c_n (let us call it y ) is defined as follows:   When y is written in base two, the digit in the 2^k 's place ( k \geq 0 ) is 1 if, the number of integers among c_1, c_2, ...c_m whose binary representations have 1 in the 2^k 's place, is odd, and 0 if that count is even.   For example, the exclusive OR of 3 and 5 is 6 . (When written in base two: the exclusive OR of 011 and 101 is 110 .)

Solution (Python):

import sys
def input():
	return sys.stdin.readline().strip()

A, B = list(map(int, input().split()))

keta = 0
B2 = B
while B2 > 0:
	B2 = B2 // 2
	keta += 1

total = 0
for bit in range(keta):
	if bit == 0:
		A_mod = A % 4
		B_mod = B % 4
		B_mod += 4
		num = 0
		for i in range(A_mod, B_mod + 1):
			num += i%2
		
		total += num%2
		
		continue

	A_mod = A % (2**(bit+1))
	B_mod = B % (2**(bit+1))
	if B_mod <= A_mod:
		B_mod += 2**(bit+1)

	

	if A_mod < 2**bit and B_mod < 2**bit:
		num = 0
		
	elif A_mod < 2**bit and B_mod < 2**(bit+1):
		num = B_mod - 2**bit + 1
		
	elif A_mod < 2**bit:
		num = 2**bit
		
	elif A_mod < 2**(bit+1) and B_mod < 2**(bit+1):
		num = B_mod - A_mod + 1
		
	elif A_mod < 2**(bit+1) and B_mod < 3*(2**bit):
		num = 2**(bit+1) - A_mod
		
	else:
		num = B_mod - A_mod - 2**bit + 1
		

	num = num % 2
	total += num*(2**bit)
	
print(total)

Solution (Python):
def xor(x):
    if x%2==1:
        if ((x+1)//2)%2==0:
            return 0
        else:
            return 1
    else:
        if (x//2)%2==0:
            return x
        else:
            return x^1 

def main():
    a,b = map(int,input().split())
    ans = xor(b)^xor(a-1)
    print(ans)
if __name__ == "__main__":
    main()

Solution (Python):
A, B = map(int, input().split())



def xorsum(n):
  k = n // 2 + n % 2
  l = n % 2
  if l == 1:
    if k % 2 == 0:
      return 0
    else:
      return 1
  else:
    if k % 2 == 0:
      return n
    else:
      return 1 ^ n

print(xorsum(max(A - 1, 0)) ^ xorsum(B)) if A != B else print(A)
"""
def ddddd(n):
  res = 0
  for i in range(1, n + 1):
    res = res ^ i
  return res
print(ddddd(A - 1) ^ ddddd(B), ddddd(A - 1), ddddd(B))
"""

Solution (Python):
def xor(a, b):
  return a^b
from functools import reduce
flag = False

a, b = map(int, input().split())
if b - a < 100:
  print(reduce(xor, [i for i in range(a, b+1)]))
else:
  l = []
  for i in range(a, b):
    if i % 4 != 0:
      l.append(i)
    else:
      break
  for i in range(b, a, -1):
    if i % 4 != 0:
      l.append(i)
    else:
      l.append(i)
      break
  print(reduce(xor, l))

Solution (Python):
a,b = map(int,input().split())
def xor(X):
  if X%2== 0:
    i = 0 if (X//2)%2==0 else 1
    return X ^ i
  else:
    i = 0 if ((X+1)//2)%2==0 else 1
    return i
A = xor(a-1)
B = xor(b)
print(A ^ B)

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main_prev(): 
    A, B = LI()

    if A == B:
        print(A)
        return
    if B - A < 20:
        xor = B
        for i in range(A, B):
            xor ^= i
        print(xor)
        return

    to_xor = []
    while A%4 != 0:
        to_xor.append(A)
        A += 1
    while B%4 != 3:
        to_xor.append(B)
        B -= 1
    xor = 0
    for i in to_xor:
        xor ^= i
    print(xor)

def xor_to(a):
    evens = a//2 - 1 if a%2 == 0 else a//2
    evens_xor = 0 if evens%2 == 0 else 1
    return evens_xor^a if a%2 == 0 else evens_xor

def main():
    A, B = LI()
    print(xor_to(A-1)^xor_to(B))


main()

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    A, B = LI()

    if A == B:
        print(A)
        return
    if B - A < 20:
        xor = B
        for i in range(A, B):
            xor ^= i
        print(xor)
        return

    to_xor = []
    while A%4 != 0:
        to_xor.append(A)
        A += 1
    while B%4 != 3:
        to_xor.append(B)
        B -= 1
    xor = 0
    for i in to_xor:
        xor ^= i
    print(xor)


main()

Solution (Python):
def XORSUM(n):
    if n%4==0:return n
    elif n%4==1:return 1
    elif n%4==2:return n^1
    else:return 0
a,b=map(int,input().split())
print(XORSUM(b)^XORSUM(a-1))

Solution (Python):
a,b = map(int,input().split())
n = 0
while 2**n < b:
    n += 1
ans = 0
for i in range(1,n):
    k = 2**i
    if a >= k:
        x = a - (k-1)
        y = b - (k-1)
        x1 = x%(k*2)
        y1 = y%(k*2)
        if x1 == 0 or x1 > k:
            if y1 <= k and y1 % 2 == 1:
                ans += k
        else:
            if x1 % 2 == 0:
                if y1 % 2 == 0 or y1 > k:
                    ans += k
            else:
                if y1 % 2 == 1 and y1 <= k:
                    ans += k
    else:
        y = b - (k-1)
        y1 = y % (k*2)
        if y1 < k and y1 % 2 == 1:
            ans += k
if b == 2**n and n > 0:
    ans += 2**n
if a % 4 == 0 or a % 4 == 1:
    if b % 4 == 1 or b % 4 == 2:
        ans += 1
else:
    if b % 4 == 0 or b % 4 == 3:
        ans += 1
print(ans)

Solution (Python):
from functools import reduce
from operator import xor

A, B = map(int,input().split())


def calc(A):
    A = A+1
    cnt = 0
    ans = 0
    for i in range(0,50):
        
        
        loop = pow(2,i+1)

        
        
        
        cnt = (A//loop)*pow(2,i)

        
        
        
        if((A%loop - loop//2) > 0):
            cnt = cnt + (A%loop - loop//2)

        
        if(cnt%2 == 1):
            ans = ans + pow(2,i)

    return ans



def main():
    return calc(A-1)^calc(B)

print(main())

Solution (Python):
def MAP(): return list(map(int,input().split()))
def f(x):
    tmp = (x+1)%4
    if tmp==0:
        return 0
    elif tmp==1:
        return x
    elif tmp==2:
        return 1
    else:
        return 1^x
A,B = MAP()
print(f(A-1)^f(B))

Solution (Python):
A, B = map(int, input().split())

def test(A):
	if A % 2 == 1:
		if (A+1)/2 % 2 == 1:
			tmp_A = 1
		else:
			tmp_A = 0
	else:
		if A/2 % 2 == 1:
			tmp_A = 1 ^ A
		else:
			tmp_A = 0 ^ A
	return tmp_A

print(test(A-1)^test(B))

Solution (Python):
def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]

A, B = map(int, input().split())

def checker(n): 
    s = format(n, 'b')
    l = len(s)
    res = [0]*l
    for i in range(l):
        if i == l - 1:
            hoge = n // 4
            if n == hoge * 4 + 1 or n == hoge * 4 + 2:
                res[i] = 1
        else:
            if s[i] == "1":
                res[i] = (int(s[i+1:], 2) + 1) % 2
    return res

a = checker(A-1) if A > 0 else [0]
b = checker(B)

if len(a) < len(b):
    tmp = a
    a = b
    b = tmp

b = [0 for _ in range(len(a) - len(b))] + b

ans = ""
for i in range(len(a)):
    ans += str(a[i] ^ b[i])
ans = int(ans, 2)
print(ans)

Solution (Python):

import sys
import math
from collections import defaultdict


sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]


mod = 10**9 + 7


def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))



A,B = II()

b = format(B,'b')
n = len(b)
a = format(A,'b').zfill(n)
num = B-A+1

ans = str()
for i in range(n):
    if i==0:
        q,m = divmod(num,2)
        if q%2==0:
            if m==1:
                ans += a[n-i-1]
            else:
                ans += '0'
        else:
            if m==1:
                if a[n-i-1]=='0':
                    ans += '1'
                else:
                    ans += '0'
            else:
                ans += '1'
        continue       
    if a[n-i-1]=='0':
        temp = (1<<i)-int(a[-i:],2)
        if temp >= num:
            ans += '0'
        else:
            val = num-temp
            q,m = divmod(val,2**i)
            if q%2==1:
                ans += '0'
            else:
                if m%2==1:
                    ans += '1'
                else:
                    ans += '0'
    else:
        temp = (1<<(i+1))-int(a[-(i+1):],2)
        if temp >= num:
            if num%2==0:
                ans += '0'
            else:
                ans += '1'
        else:
            val = num-temp
            q,m = divmod(val,2**i)
            if q%2==1:
                if m%2==1:
                    if temp%2==0:
                        ans += '1'
                    else:
                        ans += '0'
                else:
                    if temp%2==0:
                        ans += '0'
                    else:
                        ans += '1'
            else:
                if temp%2==0:
                    ans += '0'
                else:
                    ans += '1'

ans = ans[::-1]
print(int(ans,2))

Solution (Python):
a, b = map(int, input().split())

def f(x):
    tmp = (x + 1) % 4
    if tmp == 0:
        return 0
    elif tmp == 1:
        return x
    elif tmp == 2:
        return 1
    else:
        return 1 ^ x

print(f(a-1) ^ f(b))

Solution (Python):
a,b = map(int,input().split())
if a > 0:
  a -= 1
if a % 4 == 0:
  ans = a
elif a % 4 == 1:
  ans = 1
elif a % 4 == 2:
  ans = a + 1
else:
  ans = 0
if b % 4 == 0:
  print(ans^b)
elif b % 4 == 1:
  print(ans^1)
elif b % 4 == 2:
  print(ans^b^1)
else:
  print(ans)

Solution (Python):
a, b = map(int, input().split())
def trans(x):
    if x%2 == 0:
        if x%4 == 0:
            return 0^x
        else:
            return 1^x
    else:         
        if (x+1)%4 == 0:
            return 0
        else:
            return 1
print(trans(a-1)^trans(b))

Solution (Python):
A, B = map(int, input().split())
if A%2==0:
  if B%2==0:
    if (B-A)%4==0:
      print(0^B)
    else:
      print(1^B)
  else:
    if (B-A+1)%4==0:
      print(0)
    else:
      print(1)
else:
  if B%2==0:
    if (B-A-1)%4==0:
      print(A^0^B)
    else:
      print(A^1^B)
  else:
    if (B-A)%4==0:
      print(A^0)
    else:
      print(A^1)

Solution (Python):
def main():
    
    
    A,B = map(int, input().split())
    m = B-A
    a = A%2
    b = B%2
    
    if a == 0:
        if b ==0:
            ans =B^(m//2%2)
        else:
            ans = (m+1)//2%2
    else:
        if b ==0:
            ans = A^((m-1)//2%2)^B
        else:
            ans = A^(m//2%2)
    
    print(ans)
    
    
main()

Solution (Python):
def main():
    
    
    A,B = map(int, input().split())
    m = B-A
    A2 = []
    B2 = []
    Atmp = A
    Btmp = B
    i = 2
    while i//2 < B+1:
        B2.append(int((B+1)//i*i/2 + max((B+1)%i - i/2,0)))
        i *= 2
    j = 2
    while j//2 < A:
        A2.append(int(A//j*j/2 + max(A%j - j/2,0)))
        j *= 2
    
    for _ in range(len(B2)-len(A2)):
        A2.append(0)
    
    ans = 0
    tmp = 1
    for i in range(len(B2)):
        ans += tmp * ((B2[i] - A2[i])%2)
        tmp *= 2
    print(ans)
    
    
    
main()

Solution (Python):
a, b = list(map(int, input().split()))


def f(x):
    rem = [x, x ^ (x - 1), x ^ (x - 1) ^ (x - 2), 0]
    return rem[x % 4]


print(f(b) ^ f(a - 1))

Solution (Python):
import math

def cnt1(a, i):
    return (a//(2**i)) * 2**(i-1) + max(0, a%(2**i) - 2**(i-1))

A, B = [int(i) for i in input().split()]
if B == 0:
    ans = '0'
else:
    top = int(math.log2(B))+1


    ans = ''
    for i in range(1, top+1):
        cntB = cnt1(B+1, i)
        cntA = cnt1(A, i)
        ans += str((cntB-cntA)%2)

    ans = ans[::-1]
print(int(ans, 2))

Solution (Python):
a, b = map(int, input().split())

x1, y1 = (a-1)//4, (a-1) % 4
x2, y2 = b//4, b % 4

A = 0
for i in range(4*x1, 4*x1+y1+1):
    A ^= i

B = 0
for i in range(4*x2, 4*x2+y2+1):
    B ^= i

ans = A ^ B
print(ans)

Solution (Python):
a,b = map(int,input().split())
ans = 0
if b-a <= 8:
  for i in range(a,b+1):
    ans^=i
  print(ans)
  exit()

stop = a - (a%8) + 8
start = b - (b%8)
for i in range(a,stop):
  ans ^= i
for i in range(start,b+1):
  ans ^= i
print(ans)

Solution (Python):
a, b = (int(i) for i in input().split())
def f0(x):
    xx = (x + 1) % 4
    if xx == 0:
        return 0
    elif xx == 1:
        return x
    elif xx == 2:
        return 1
    else:
        return x^1
a = f0(a-1)
b = f0(b)
print(a^b)

Solution (Python):
import sys
input = sys.stdin.readline

A,B = map(int,input().split())

def xor(x,length):
    if x < 0: return 0
    x+=1
    ans = 0
    for i in range(length):
        loop = 2**(i+1)
        cnt = x//loop*loop//2
        cnt += max(0,x%loop - loop//2)
        if cnt%2==1:
            ans+=(1<<i)

    return ans
a=format(A,"b")
b=format(B,"b")
a=list(a)
b=list(b)
alength = len(a)
blength = len(b)
print(xor(B,blength)^xor(A-1,alength))

Solution (Python):

A,B = map(int,input().split())
def f(n):
    if n%2 == 0:
        if (n//2)%2 == 0:
            return n
        else:
            return n+1
    else:
        if ((n-1)//2)%2 == 0:
            return 1
        else:
            return 0
        
FB = f(B)
FA = f(A-1)
print(FB^FA)

Solution (Python):
def main():
    A, B = map(int, input().split())
    
    onesA = countOne(A)
    onesB = countOne(B)
    onesA += [0]*(len(onesB) - len(onesA))
    onesA = onesA
    onesB = onesB
    onesTot = [onesB[i]-onesA[i] for i in range(len(onesA))]
    b = format(A, "b")
    for i in range(len(b)):
        onesTot[i] += (b[len(b)-1-i] == "1")
    for i in range(len(onesTot)):
        onesTot[i] = str(onesTot[i] % 2)
    bfinal = "".join(onesTot[::-1])
    return int(bfinal, 2)

def countOne(n):
    
    n = n + 1
    p = 2
    res = []
    while n >= p//2:
        d = n // p
        r = n % p
        res.append(d*(p//2)+max(0,(r-p//2)))
        p *= 2
    return res

if __name__ == '__main__':
    print(main())

Solution (Python):
A, B = map(int, input().split())


def xor(x):
    if x % 4 == 0:
        return x
    elif x % 4 == 1:
        return 1
    elif x % 4 == 2:
        return 1 ^ x
    else:
        return 0


print(xor(A-1) ^ xor(B))

Solution (Python):
A, B = map(int,input().split())
def f(x):
   if x%4==3:
       return 0
   elif x%4==2:
       return 1^x
   elif x%4==1:
       return 1
   else:
       return x
print (f(A-1)^f(B))

Solution (Python):
def f(x,y):
  if(y-x)%4:return y^f(x,y-1)
  if x%2:return x
  return y
print(f(*map(int,input().split())))

Solution (Python):
a, b = map(int, input().split())
b += 1
s, p, q = (a//2%2)^(b//2%2), 4, 2
while b > q:
    c, d = (a%p//q)&(a%p%q), (b%p//q)&(b%p%q)
    s += (c^d)*q
    p, q = p*2, q*2
print(s)

Solution (Python):
a,b = map(int,input().split())

def f(n):
    if n%2 == 1:
        return ((n+1)//2)%2
    else:
        return ((n//2)%2)^n

print(f(b)^f(a-1))

Solution (Python):
A,B = map(int,input().split())
if A % 2 == 0:
    n = (B-A+1) % 4
    if n == 0:
        ans = 0
    elif n == 1:
        ans = B
    elif n == 2:
        ans = (B-1)^B
    else:
        ans = (B-2)^(B-1)^B
else:
    n = (B-A+1-1) % 4 
    if n == 0:
        ans = A 
    elif n == 1:
        ans = A^B
    elif n == 2:
        ans = A^(B-1)^B
    else:
        ans = A^(B-2)^(B-1)^B

print(ans)

Solution (Python):

A,B = map(int,input().split())



keta = 0
ans = 0

while B >= 2 ** keta:

    nowsum = 0

    fblock = A // (2 ** (keta+1))
    eblock = B // (2 ** (keta+1))

    if fblock != eblock:
        nowsum += (eblock - fblock - 1) * (2 ** keta)

        nowsum += min( 2 ** keta , (2 ** (keta + 1)) * (fblock + 1) - A )
        nowsum += max( 0 , B - (((2 ** (keta + 1)) * eblock - 1) + (2 ** keta)) )

    elif ( B // (2 ** keta) ) % 2 == 1 and ( A // (2 ** keta) ) % 2 == 1:

        nowsum += B - A + 1

    elif ( B // (2 ** keta) ) % 2 == 1:

        nowsum += B -  (B // (2 ** keta)) * (2 ** keta) + 1
        
    ans += ( 2 ** keta ) * ( nowsum % 2 )
    keta += 1
    
print (ans)

Solution (Python):
a,b=map(int,input().split())

if a%2==0:
  if b%2==1:
    if (b-a+1)%4==0:
      print('0')
    else:
      print('1')
  else:
    if (b-a)%4==0:
      print(b)
    else:
      print(b^1)
else:
  if b%2==1:
    if (b-a)%4==0:
      print(a)
    else:
      print(a^1)
  else:
    if (b-a-1)%4==0:
      print(a^b)
    else:
      print(a^b^1)

Solution (Python):
a, b = map(int, input().split())
c = b - a + 1
if c % 2 == 0:
    if a % 2 == 0:
        print(c // 2 % 2)
    else:
        print((c - 2) // 2 % 2 ^ a ^ b)
else:
    if a % 2 == 0:
        print((c - 1) // 2 % 2 ^ b)
    else:
        print((c - 1) // 2 % 2 ^ a)

Solution (Python):
A,B= map(int,input().split())

Bb = format(B,"b")
l = len(Bb)


ans = []
for i in range(l-1,0,-1):
  d = 2**(i)
  
  
  
  if (B//d%2 == 0)&(A//d%2 == 0):
    ans.append('0')
  elif (B//d%2 == 0)&(A//d%2 != 0):
    if A%d%2 == 0:
      ans.append('0')
    else:
       ans.append('1')
  elif (B//d%2 != 0)&(A//d%2 == 0):
    if B%d%2 == 0:
       ans.append('1')
    else:
       ans.append('0')
  elif (B//d%2 != 0)&(A//d%2 != 0):
    if B%d%2 == A%d%2:
       ans.append('1')
    else:
       ans.append('0')
if (B-(A-1))%4 ==0:
  ans.append("0")
elif (B-(A-1))%4 ==2:
  ans.append("1")
elif (B-(A-1))%4 ==3:
  if A%2==0:
    ans.append("1")
  else:
    ans.append("0")
else:
  if A%2==0:
    ans.append("0")
  else:
    ans.append("1")
             
print(int('0b'+''.join(ans),2))

Solution (Python):
a,b = map( int, input().split() )
 
def f_xor( num ):
    if num % 4 == 0:
        return num
    elif num % 4 == 1:
        return 1
    elif num % 4 == 2:
        return num ^ 1
    elif num % 4 == 3:
        return 0

print(f_xor(a-1) ^ f_xor(b))

Solution (Python):
a,b=map(int,input().split())

def f(x):
    if x%2==0:
        if x%4==0:
            return x
        else:
            return x^1
    else:
        if (x+1)%4==0:
            return 0
        else:
            return 1

print(f(a-1)^f(b))

Solution (Python):
import os,re,sys,operator
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations,groupby
from sys import stdin,setrecursionlimit
from copy import deepcopy
import heapq

setrecursionlimit(10**6)
def xor(n):
    if n%2==1:
        if (n//2+1)%2==0:
            return 0
        return 1
    else:
        return xor(n-1)^n
a,b=map(int,stdin.readline().rstrip().split())
if a==0:
    print(xor(b))
else:
    print(xor(a-1)^xor(b))

Solution (Python):
A, B = map(int, input().split())

ans = 0
if B - A <= 8:
  for i in range(A, B + 1):
    ans = ans ^ i
else:
  for i in range(A, A + 4 - (A % 4)):
    ans = ans ^ i
  for i in range(B - (B % 4), B + 1):
    ans = ans ^ i
print(ans)

Solution (Python):
a,b = map(int,input().split())

if b - a == 0:
    answer = a
else:
    answer = 0
    if a % 2 == 0:
        first_odd = a
    else:
        first_odd = a+1
    if b % 2 == 0:
        last_even = b-1
    else:
        last_even = b
    odd_even = int((last_even - first_odd + 1) // 2)
    if a % 2 == 1 and b % 2 == 0:
        answer += (odd_even + 1) % 2
        b2 = []
        while b > 0:
            b2.append(b % 2)
            b = int((b-b%2)//2)
        a2 = []
        for i in range(len(b2)):
            a2.append(a % 2)
            a = int((a-a%2)//2)
        for i in range(1,len(b2)):
            if a2[i]+b2[i] == 1:
                answer += 2**i
    elif a % 2 == 1:
        answer += (odd_even + 1) % 2 + a - 1
    elif b % 2 == 0:
        answer += odd_even % 2 + b
    else:
        answer += odd_even % 2

print(answer)

Solution (Python):
import sys
input = sys.stdin.readline
import heapq
import fractions
a,b=map(int,input().split())

if a%2==0 and b%2==1:
        if (b-a+1)%4==0:
                print(0)
        else:
                print(1)
elif a%2==0 and b%2==0:
        if (b-1-a+1)%4==0:
                print(b)
        else:
                print(1^b)
elif a%2==1 and b%2==1:
        if (b-1-a+1)%4==0:
                print(a)
        else:
                print(1^a)
elif a%2==1 and b%2==0:
        if (b-1-a)%4==0:
                print(a^b)
        else:
                print(a^b^1)

Solution (Python):
A,B = map(int,input().split())
ans = 0
l = (A//4)*4
for i in range((A//4)*4,A):
    ans ^= i
for i in range((B//4)*4,B+1):
    ans ^= i
print(ans)

Solution (Python):
from functools import reduce

A,B= (int(i) for i in input().split()) 

def XOR(x):
	if x%2==1:
		if ((x+1)//2)%2==0:
			return 0
		else:
			return 1
	else:
		if (x//2)%2==0:
			return int(format(x,"b"))
		else:
			return int(format(x,"b"))+1

ans = int(str(XOR(A-1)), 2) ^ int(str(XOR(B)), 2)
print(ans)

Solution (Python):
A, B = map(int, input().split())


def count1(A, B, i):
    
    under = 2**(i+1) - A % (2**(i+1))
    if under > 2**i:
        under = 0

    upper = max(0, B % (2**(i+1))-2**i+1)

    
    return (under+upper) % 2


ans = ((B+1)//2 - A//2) % 2  
for i in range(1, len(format(B, 'b'))):
    ans += count1(A, B, i)*2**i

print(ans)

Solution (Python):


def f(x):
    if x % 2 == 0:
        if ((x-1) // 2) % 2 == 0:
            return 0 ^ x
        else:
            return 1 ^ x
    else:
        if (x // 2) % 2 == 0:
            return 0
        else:
            return 1

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

result = f(a-1) ^ f(b)
print(result)

Solution (Python):
A, B = map(int, input().split())

n = A // 2
m = B // 2
if (m-n)%2 == 0:
    c = 0
else:
    c = 1
if B % 2 == 0:
    c = c^B
else:
    c = c^1
if A % 2 == 1:
    c = c^(A-1)
print(c)

Solution (Python):


from collections import deque


def calc(x):
    if x == 0:
        return 0
    num_numbers = x+1
    num1 = (num_numbers) // 2
    tmp = 0
    if num1 % 2 == 1:
        tmp = 1

    if num_numbers % 2 == 0:
        return tmp
    else:
        return tmp + x

def resolve():
    a, b = map(int, input().split())
    ans = calc(a-1) ^ calc(b)
    print(ans)

if __name__ == "__main__":
    resolve()

Solution (Python):
a, b = list(map(int, input().split()))

def f0n(n):
    if n % 2 == 0:
        return (n // 2) % 2 ^ n
    else:
        return 0 if ((n + 1) / 2) % 2 == 0 else 1

print(int(f0n(a-1)) ^ int(f0n(b)))

Solution (Python):
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
Mod = 1000000007



def main(): 
    A,B = map(int,input().split())
    def modfour(i):
        return i % 4
    ans = 0
    if A % 2 == 0:
        for i in range(modfour(B-A+1)):
            ans ^= B-i
        print(ans)
    else:
        ans = A
        for i in range(modfour(B-A+1)+3):
            ans ^= B-i
        print(ans)
if __name__ == "__main__":
    main() 




def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n < 2 is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))):
        if prime[i] == 1:
            for j in range(2*i,n):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n):
        if prime[i] == 1:
            res.append(i)
    return res

class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py

    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

Solution (Python):

def get_numbers():
    return map(int, input().split())


def xor(n):
    if n % 4 == 3:
        return 0
    if n % 4 == 0:
        return n
    if n % 4 == 1:
        return 1
    if n % 4 == 2:
        return 1 ^ n


a, b = get_numbers()
print(xor(a - 1) ^ xor(b))

Solution (Python):
A,B = map(int,input().split())

if A%2 == 0 and B%2 == 1:
	if (B-A-1)%4 == 0:
		print("1")
	else:
		print("0")
elif A%2 == 0 and B%2 == 0:
	if (B-A)%4 == 0:
		print(B)
	else:
		print(B^1)
elif A%2 == 1 and B%2 == 1:
	if (B-A)%4 == 0:
		print(A)
	else:
		print(A^1)
else:
	if (B-A-1)%4 == 0:
		print(A^B)
	else:
		print(A^B^1)

Solution (Python):
A,B = map(int,input().split())
keta = 0
tmp = B
twos = []
base = 1
while tmp > 0:
    tmp /= 2
    keta += 1
    base *= 2
    twos.append(base)

def func(n):
    if n%2 == 0:
        tmp = (n-1)//2
        ans = tmp%2 ^ n
    else:
        tmp = (n-1)//2 
        ans = tmp%2
    return ans
    
print(func(B)^func(A-1))

Solution (Python):
import sys

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

if b - a < 100:
    for i in range(a, b + 1):
        ans ^= i
    print(ans)
    sys.exit()

while a % 4 > 0:
    ans ^= a
    a += 1
while b % 4 < 3:
    ans ^= b
    b -= 1
print(ans)

Solution (Python):
a, b = map(int, input().split())

def f(x):
    r = x % 4
    if r == 0:
        return x
    elif r == 1:
        return 1
    elif r == 2:
        return 1^x
    else:
        return 0

print(f(a-1)^f(b))

Solution (Python):
A, B = map(int, input().split())

def z_to_xor(a):
	if a % 2 == 1:
		return ((a + 1) // 2 % 2)
	else:
		return ((a // 2 % 2) ^ a)

print(z_to_xor(A - 1) ^ z_to_xor(B))

Solution (Python):
a,b=map(int,input().split())
t=b-a+1
if a==b:
  print(a)
elif t%2:
  if a%2:
    print(((t-1)//2)%2^a)
  else:
    print(((t-1)//2)%2^b)
else:
  if a%2:
    print((t//2-1)%2^a^b)
  else:
    print((t//2)%2)

Solution (Python):
def xor_func(x):
    res = [x, 1, x+1, 0]
    return res[x%4]


a, b = map(int, input().split())
print(xor_func(b)^xor_func(a-1))

Solution (Python):
A, B = map(int, input().split())
sub = B - A + 1

if A % 2 == 0:
  if sub % 4 == 0:
    print(0)
  elif sub % 4 == 2:
    print(1)
  elif sub % 4 == 1:
    print(B)
  else:
    print(B + 1)
else:
  if sub % 4 == 1:
    print(A)
  elif sub % 4 == 3:
    print(A - 1)
  elif sub % 4 == 2:
    print(A ^ B)
  else:
    print((A-1) ^ B)

Solution (Python):
a,b = map(int, input().split())
a = a-1

def calc(input):
  if(input%4 == 1):
    return 1
  elif(input%4 == 2):
    return 1^input
  elif(input%4 == 3):
    return 0
  else:
    return input
  
print(calc(a)^calc(b))

Solution (Python):
a, b = map(int, input().split())
c = a - b + 1
if c % 2 == 1:
    if a % 2 == 0:
        print((abs(b - a) // 2) % 2 ^ b)
    else:
        print((abs(b - a) // 2) % 2 ^ a)
else:
    if a % 2 == 0:
        print((abs(b - a + 1) // 2) % 2)
    else:
        print((abs(b - a - 1) // 2) % 2 ^ a ^ b)

Solution (Python):
A, B = map(int, input().split())

def func(x):
    ans = 0 if (x + 1) // 2 % 2 == 0 else 1
    ans ^= x if x % 2 == 0 else 0
    return ans

print(func(B)^func(A - 1))

Solution (Python):
a, b = map(int, input().split())

def func(x):
    if x <= 1:
        return x
    elif x == 2:
        return 3
    elif x == 3:
        return 0

    y = 1
    while y*2 <= x:
        y *= 2

    if (x - y + 1) % 2 == 1:
        return y + func(x - y)
    else:
        return func(x - y)

if a == 0:
    ans = func(b)
else:
    c, d =  func(a - 1), func(b)
    
    x = 0
    ans = 0
    while (1<<x) <= c or (1<<x) <= d:
        y, z = (c>>x)&1, (d>>x)&1
        if y ^ z == 1:
            ans += 1<<x
        x += 1

print(ans)

Solution (Python):
a,b = map(int, input().split())
get = lambda x:[x,1,x+1,0][x%4]
print(get(a-1)^get(b))

Solution (Python):
def F(x): 
    if x % 2 == 1:
        if (x + 1)  % 4 == 0:
            return 0
        else:
            return 1
    else:
        return F(x-1) ^ x


A,B = list(map(int,input().split(" ")))
print(F(A - 1) ^ F(B))

Solution (Python):
import numpy as np

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


flag = True
div = 2
bxor = []
while flag:
    q = b//div
    r = b-q*div
    if q == 0:
        flag = False
        if r > div//2:
            temp = r-(div//2)
            temp = temp%2
            bxor.append(temp)
        else:
            bxor.append(0)
    else:
        sup = q*div//2
        sup = sup%2
        temp = r - (div // 2)
        if temp > 0:
            temp = temp%2
            sup += temp
            bxor.append(sup)
        else:
            bxor.append(sup)
    div *= 2

axor = [0 for i in range(len(bxor))]
ind = 0

flag = True
div = 2
while flag:
    q = a//div
    r = a-q*div
    if q == 0:
        flag = False
        if r > div//2:
            temp = r-(div//2)
            temp = temp%2
            axor[ind]=(temp)
        else:
            axor[ind]=(0)
    else:
        sup = q*div//2
        sup = sup%2
        temp = r - (div // 2)
        if temp > 0:
            temp = temp%2
            sup += temp
            axor[ind]=(sup)
        else:
            axor[ind]=(sup)
    div*=2
    ind += 1

ans = 0
for i in range(len(axor)):
    temp = axor[i]+bxor[i]
    if temp%2 == 0:
        continue
    else:
        ans += 2**i



print(ans)

Solution (Python):
a, b = map(int, input().split())
even_a = a%2 == 0
even_b = b%2 == 0
if even_a and even_b:
    print((((b - a)//2)%2)^b)
elif even_a:
    print(((b+1 - a)//2)%2)
elif even_b:
    print((((b - (a+1))//2)%2)^a^b)
else:
    print((((b - a)//2)%2)^a)

Solution (Python):
a, b = map(int, input().split())

if (b-a+1) % 2 == 0:
    if a % 2 == 0:
        print((b-a+1) // 2 % 2)
    else:
        print(((b - a + 1 - 2) // 2 % 2) ^ a ^ b)
else:
    if a % 2 == 0:
        print(((b - a + 1 - 1) // 2 % 2) ^ b)
    else:
        print(((b - a + 1 - 1) // 2 % 2) ^ a)

Solution (Python):
a,b = map(int,input().split())
def f(x):
    if x%4 == 0:
        return x
    elif x%4==1:
        return 1
    elif x%4==2:
        return x+1
    else:
        return 0
print(f(a-1)^f(b))

Solution (Python):
a,b=map(int,input().split())



def f(x):
    if x==1:
        return 1
    elif (x+1)%2==0:
        if ((x+1)//2)%2==0:
            return 0
        else:
            return 1
    else:
        if (x//2)%2==0:
            return 0^x
        else:
            return 1^x
print(f(a-1)^f(b))

Solution (Python):
A, B = list(map(int, input().split()))

def g(X):
    r = 1 if X&1 else X
    return r^1 if X&2 else r

print(g(A-1)^g(B))

Solution (Python):
A, B = map(int, input().split())

def func(n):
    
    ret = (n + 1) // 2 % 2
    if n % 2 == 0:
        ret ^= n
    return ret

print(func(A - 1) ^ func(B))

Solution (Python):
A,B=map(int,input().split())
ans=0
b=((B-1)//4)*4
for i in range(b,B+1):
    ans^=i
A-=1
a=((A-1)//4)*4
for i in range(a,A+1):
    ans^=i
print(ans)

Solution (Python):
def g(x):
    if x == 0:
        return 0
    if x % 2 == 1:
        if x % 4 == 1:
            return 1
        else:
            return 0
    else:
        return g(x-1) ^ x

a, b = map(int, input().split())
if a == 0:
    print(g(b))
else:
    print(g(b) ^ g(a-1))

Solution (Python):
A, B = map(int, input().split())
def f(a):
    if a%4 == 0:
        return a
    elif a%4 == 1:
        return 1
    elif a%4 == 2:
        return a+1
    else:
        return 0
print(f(B)^f(A-1))