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):
A, B = map(int, input().split())

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

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

def hoge(x: int):
    ans = []
    t = 1
    while x >= t:
        temp = t * (x//(t * 2)) + max(x%(t * 2) - (t - 1), 0)
        ans.append(temp)
        t *= 2
    return ans
ans=0
t=1
for i, j in itertools.zip_longest(hoge(b) , hoge(a-1), fillvalue = 0):
    if (i - j) % 2 == 1:
        ans += t
    t *= 2
print(ans)

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

def solve(A):
    ret=0
    res=1
    if A%4==1 or A%4==2:
        ret+=res
    dig=A%2
    res<<=1
    A>>=1
    while A>0:
        if dig==0 and A%2==1:
            ret+=res
        res<<=1
        A>>=1
    return ret

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

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

Solution (Python):
a, b = map(int, input().split())
if a == b:
    print(a)
else:
    bits = []
    for i in range(b.bit_length()):
        k = pow(2, i+1)
        nb, rb = divmod(b, k)
        na, ra = divmod(max(0,a-1), k)

        bb = nb*(k//2) + max(0, rb - k//2 + 1)
        aa = na*(k//2) + max(0, ra - k//2 + 1)
        bits.append((bb-aa)%2)
    
    print(int(''.join(map(str, bits[::-1])), 2))

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

def xor(n):
    m = n % 4
    if m == 0:
        return n
    elif m == 1:
        return 1
    elif m == 2:
        return n+1
    else:
        return 0

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

Solution (Python):
A, B = map(int, input().split())
n = 2
answer = ((B+1)//2-A//2)%2
A -= 1
while n <= B:
  cnt_b = 0
  if (B//n)%2 != 0:
    cnt_b += B%n
  cnt_b += B//n
  cnt_a = 0
  if (A//n)%2 != 0:
    cnt_a += A%n
  cnt_a += A//n
  if (cnt_b-cnt_a)%2 != 0:
    answer += n
  n *= 2
print(answer)

Solution (Python):
a, b = (int(_) for _ in input().split())

def xor(n):
    m = 0
    if (n % 4 == 0):
        m = n
    elif (n % 4 == 1):
        m = 1
    elif (n % 4 == 2):
        m = n + 1
    return (m)

A = xor(a - 1)
B = xor(b)
print(A ^ B)

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

Solution (Python):
import sys



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


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


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


def main():
    a, b = input_int_list()
    
    

    if a == 0:
        print(f(b))
        return
    else:
        print(f(b) ^ f(a - 1))
    return


if __name__ == "__main__":
    main()

Solution (Python):
def sol(x):
    mod=x&3
    if mod==0:
        return x
    if mod==1:
        return 1
    if mod==2:
        return x+1
    if mod==3:
        return 0


a,b=input().split()
aa=sol(int(a)-1)
bb=sol(int(b))
ans =aa^bb
print(ans)

Solution (Python):

import sys

sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math








INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7

def mapline(t = int):
    return map(t, sysread().split())
def mapread(t = int):
    return map(t, read().split())

def counts(A):
    L = A.bit_length()
    ans = 0
    for l in range(L):
        if l == 0:
            s = A // 2
            s = s % 2
            if A % 2:
                ans = s ^ 1
            else:
                ans = s
        else:
            if (A >> l) & 1:
                v = A - ((A >> l) << l) + 1
                if v % 2:
                    ans |= 1 << l
    return ans

def run():
    A, B = mapline()
    a = counts(A-1)
    b = counts(B)

    print(a ^ b)
if __name__ == "__main__":
    run()

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

if B - A<=1000:
    ans=A
    for i in range(A+1, B+1):
        ans=ans^i
    print(ans)
else:
    lis=[]
    for i in range(A, B+1):
        if i%4==0:
            break
        else:
            lis.append(i)
    for j in range(B, A-1, -1):
        if j%4==0:
            lis.append(j)
            break
        else:
            lis.append(j)
    for i in range(len(lis)):
        if i==0:
            ans=lis[i]
        else:
            ans=ans^lis[i]
    print(ans)

Solution (Python):
def main():
    A,B = map(int,input().split())
    if A == B:
        return A
    elif A%2 == 0 and B%2 == 0:
        tmp = int((B-A)/2)
        if tmp%2 == 0:
            return 0^B
        else:
            return 1^B
    elif A%2 == 0 and B%2 == 1:
        tmp = int((B-A+1)/2)
        if tmp%2 == 0:
            return 0
        else:
            return 1
    elif A%2 == 1 and B%2 == 0:
        tmp = int((B-A-1)/2)
        if tmp%2 == 0:
            return 0^B^A
        else:
            return 1^B^A
    elif A%2 == 1 and B%2 == 1:
        tmp = int((B-A)/2)
        if tmp%2 == 0:
            return 0^A
        else:
            return 1^A

print(main())

Solution (Python):
A,B = map(int,input().split())
A2 = bin(A)[2:]
B2 = bin(B)[2:]
N = len(B2)
A2 = "0"*(N-len(A2))+A2
C = [0 for _ in range(N)]
T = B-A
for k in range(N):
    ind = A%(2**(k+1))
    if k==0:
        t = T%(2**(k+2))
        s = "01010101"
        c1 = 0
        for i in range(ind,ind+t+1):
            if s[i]=="1":
                c1 += 1
    else:
        t = T%(2**(k+1))
        if ind<2**k:
            if ind+t<2**k:
                c1 = 0
            elif ind+t<2**(k+1):
                c1 = ind+t-(2**k-1)
            else:
                c1 = 2**k
        else:
            if ind+t<2**(k+1):
                c1 = t+1
            elif ind+t<3*(2**k):
                c1 = 2**(k+1)-ind
            else:
                c1 = t-2**k+1
    C[N-1-k] = c1%2
a = 0
for i in range(N):
    a = 2*a+C[i]
print(a)

Solution (Python):
A,B = map(int,input().split())
dif = B-A+1
MAX = 45
ans = 0
for i in range(1,MAX):
  base = pow(2,i)
  if (B+1)%base <= base//2:
    up = ((B+1)//base)*(base//2)
  else:
    up = ((B+1)//base)*(base//2) + (B+1)%base - base//2
  if A%base <= base//2:
    down = (A//base)*(base//2)
  else:
    down = (A//base)*(base//2) + A%base - base//2
  ans += (up-down)%2*(base//2)
print(ans)

Solution (Python):
A, B = map(int, input().split())
ans = 0
X = (4 - A % 4) % 4
for i in range(X):
    ans ^= (A + i)

Y = B % 4
for i in range(Y + 1):
    ans ^= (B - i)

print(ans)

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



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

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

Solution (Python):
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))



def f(n):
    ans=0
    for i in range(n,n-n%4-1,-1):
        ans^=i
    return ans

A,B=mint()
print(f(A-1)^f(B))

Solution (Python):
def main():
    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))

main()

Solution (Python):

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

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

    
    
    

    ans = f(B) ^ f(A - 1)
    print(ans)


if __name__ == "__main__":
    resolve()

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

    
    
    b += 1
    ans = 0
    unit = 1
    for i in range(b.bit_length()):
        new_unit = unit << 1
        cnt = min(new_unit - a % new_unit, unit) % 2
        cnt += max(0, b % new_unit - unit) % 2
        cnt %= 2
        if cnt:
            ans += unit

        unit = new_unit

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

    print(ans)

main()

Solution (Python):
A,B=list(map(int, input().split()))
if A==B:
  print(A)
  exit()
a=A//4
b=B//4

def xorsum(L):
  if len(L)==1:
    return L[0]
  a=L[0]
  for i in range(1,len(L)):
    a^=L[i]
  return a

if a==b:
  L=[A+i for i in range(B-A+1)]
  print(xorsum(L))
  exit()
c=[a*4+i for i in range(4) if i>=A%4]
d=[b*4+i for i in range(4) if i<=B%4]
print(xorsum(c)^xorsum(d))

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




num = B - A + 1
ans = 0

if A % 2 == 0:
	ones = num // 2
	
	if ones % 2 == 1:
		ans = 1
	else:
		ans = 0
		
	if num % 2 == 1:
		ans = ans ^ B
		
if A % 2 == 1:
	num -= 1
	
	ones = num // 2
	
	if ones % 2 == 1:
		ans = 1
	else:
		ans = 0
	
	if num % 2 == 1:
		ans = ans ^ B
		
	ans = ans ^ A
	
print(ans)

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

ones = [0] * 101
def calcones(end, pow):
	start = pow // 2
	if end < pow // 2:
		return 0
	
	n = (end - start + 1) // pow
	n *= pow // 2
	
	if 0 < (end - start + 1) % pow <= pow // 2:
		n += (end - start + 1) % pow
		
	return n

pow = 2
for i in range(1, 101):
	ones[i] = calcones(B, pow) - calcones(A-1, pow)
	pow *= 2
	

		
ans = 0
pow = 1
for i in range(1, 101):
	ans += (ones[i] % 2) * pow
	pow *= 2
	
print(ans)

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B = map(int, readline().split())

    def f(x):
        r = (x + 1) % 4
        ans = 0
        for n in range(x, x - r, -1):
            ans ^= n
        return ans

    if A == 0:
        print(f(B))
    else:
        print(f(B) ^ f(A - 1))

    return


if __name__ == '__main__':
    main()

Solution (Python):
a,b=map(int, input().split())
  
a1 = a
b1 = b
if(a1%2 == 1) : a1 = a1+1
if(b1%2 == 0) : b1 = b1-1

c = (b1-a1+1)//2 % 2

ans = 0
if(a%2 == 1):ans = ans^a
if(b%2 == 0):ans = ans^b
print(ans^c)

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

Solution (Python):
def f(n):  
    if n % 2 == 0:
        if (n // 2) % 2 == 0:
            return n
        else:
            return 1 ^ n
    else:
        if (n // 2) % 2 == 0:
            return 1
        else:
            return 0


def main():
    a, b = map(int, input().split())
    print(f(a - 1) ^ f(b))


if __name__ == "__main__":
    main()

Solution (Python):
a,b=map(int,input().split());print(-(a^b)>>1&1^~b%2*b^a%2*a)

Solution (Python):
a,b=map(int,input().split())
print((-a^b)>>1&1^[b,1][b&1]^(a&1)*a)

Solution (Python):
a,b=map(int,input().split());a-=1
print((a^b)>>1&1^[b,1][b&1]^[a,1][a&1])

Solution (Python):
a,b=map(int,input().split());a-=1
print(a>>1&1 ^ b>>1&1^[b,1][b&1]^[a,1][a&1])

Solution (Python):
a,b = map(int,input().split())
c,d = map(lambda x:(x//2)%2^1 if x%2 else x^(x//2)%2,[a-1,b])
print(c^d)

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

m = len(format(B, "b"))

a = A
b = B
AA = 0
BB = 0

if A % 2 == 1:
    a = A + 1
    AA = A
if B % 2 == 0:
    b = B - 1
    BB = B
b += 1

t = (b - a) // 2

if t % 2 == 0:
    print(AA ^ BB)
else:
    print(AA ^ BB ^ 1)

Solution (Python):
A, B = [int(_) for _ in input().split()]

def g(n):
    ans = 0
    v = (n // 4) * 4
    for x in range(v, n+1):
        ans ^= x
    return ans 

va = g(A-1)
vb = g(B)

print(va ^ vb)

Solution (Python):
A,B = map(int,input().split())
a = A%2>0
b = B%2<1
print((A*a)^(((B-b)-(A-1^a))//2%2)^(B*b))

Solution (Python):
def main():
	A, B = [int(n) for n in input().split(" ")]
	d = B - A
	if d == 0:
		print(A)
		return 0
	if d == 1:
		print(A ^ B)
		return 0
	begin = A + A % 2
	end = B + B % 2 - 1
	pair = int((end - begin + 1) / 2)
	print((A * (A % 2)) ^ pair % 2 ^ (B * (1 - B % 2)))

main()

Solution (Python):
A,B=list(map(int,input().split()))
C,D,s=0,0,B-A+1
C=0 if A%2==0 else A
D=0 if B%2==1 else B
if ((s-(0 if C==0 else 1)-(0 if D==0 else 1))//2)%2==0:
   E=0
else:
   E=1
print(C^D^E)

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

def xor(n):
  z=n%4
  if z==0:
      return n
  elif z==1:
      return 1
  elif z==2:
      return n+1
  else:
      return 0


xxx=xor(b)^xor(a-1)

print(xxx)

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

Solution (Python):
a,b = map(int,input().split())
l = []
if a % 4 != 0:
    for i in range(a-1,-6,-1):
        l.append(i)
        if i % 4 == 0:
            break
if b % 4 != 3:
    for i in range(b+1,10**12+5):
        l.append(i)
        if i % 4 == 3:
            break

ans = 0
for i in l:
    ans = ans ^ i
print(ans)

Solution (Python):
A,B=map(int,input().split())
ans=0
while True:
    ans=ans^A
    
    if A%4==3:
        break
    A=A+1

while True:
    ans=ans^B
    
    if B%4==0:
        break
    B=B-1
print(ans)

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

def xor_sum(A): 
  ans = 0
  if A % 2 == 0:
    ans += A
  if ((A+1) // 2) % 2 == 1: 
    ans += 1
  return ans
  
print(xor_sum(B) ^ xor_sum(A-1))

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


ans=0

ans+=((b+1)//2-a//2)%2

for i in range(1,50):
  if a//(2**(i+1))==b//(2**(i+1)):
    ci=max(0,b%(2**(i+1))-max(a%(2**(i+1)),2**i)+1)
  else:
    ci=min(2**(i+1)-a%(2**(i+1)),2**i)+max(b%(2**(i+1))-2**i+1,0)
  if ci%2==1:
    ans+=2**i
  
print(ans)

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

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

if __name__ == "__main__":
    main()

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

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

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

Solution (Python):
A,B=map(int,input().split())
if A%2:
    s1=((A+1)//2)%2
else:
    s1=((A//2)%2)^A
if B%2:
    s2=((B+1)//2)%2
else:
    s2=((B//2)%2)^B
print(s1^s2^A)

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

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

i_num=100

def get_one(N,i_num=i_num):
    n_list=[0]*i_num

    for i in range(i_num):
        N_ = N
        if 2**i > N_:
            break
        if (N_//2**i) % 2 == 0:
            N_ = (2**i)*(N//2**i)-1

        n_list[i] = (((N_//(2**i))-1)//2)*2**i + N_%(2**i)+1
    return(n_list)

B_=get_one(B)
A_=get_one(A-1)

ans_ = [0]*i_num
for i in range(i_num):
    if (B_[i] - A_[i]) % 2 != 0:
        ans_[i] = 1
        
ans_.reverse()
ans=''.join(map(str,ans_))

print(int(ans,2))

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

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


def F(a:int):
    if a%2==1:
        if a%4==1:
            return 1
        else:
            return 0
    else:
        return F(a+1)^(a+1)
ans=F(a-1)^F(b)
print(ans)

Solution (Python):

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


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


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

Solution (Python):
def g(N):
    if N%4==0:
        return N
    elif N%4==1:
        return 1
    elif N%4==2:
        return N+1
    else:
        return 0

def f(A,B):
    if A==0:
        return g(B)
    else:
        return g(A-1)^g(B)

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

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

def calc(x):
    l = len(format(x,'b'))
    s = '1' if x%4==1 or x%4==2 else '0'
    for i in range(1,l):
        x_ = x
        x_ -= 2**i-1
        mod = x_ % (2**(i+1))
        if mod >= 2**i:
            s += '0'
        else:
            if mod%2==0:
                s += '0'
            else:
                s += '1'
    s = s[::-1]
    return s

suma = int(calc(a-1),2)
sumb = int(calc(b),2)
print(int(suma^sumb))

Solution (Python):

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





def xor(a,b):
    x=a
    for i in range(a+1,b+1):
        x=x^i
    print("xor:",x)

ia=len(bin(a))-2
ib=len(bin(b))-2

def px(b,ib):
    bbr=[]
    ip=1
    for i in range(ib):
        ip*=2
        bc=(b//ip)*(ip//2)
        bc+=max((b%ip+1)-(ip//2),0)
        bbr.append(bc)
    return bbr

aar=px(a-1,ib)
bbr=px(b,ib)

c=[0]*ib
ip=1
for i in range(ib):
    ip*=2
    ci=bbr[i]-aar[i]
    c[i]=ci%2

ip=1
csum=0
for i in range(ib):
    csum+=c[i]*ip
    ip*=2
    
print(csum)

Solution (Python):
a,b = map(int, input().split())
bis = [0] * 50
"""
- F(A,B) = F(0,B) ^ F(0,A-1)
- 2m ^ 2m+1 = 1
"""
def F(a):
    if a % 2 == 0:
        x = (a-1)//2
        return (x%2)^a
    else:
        x = a//2
        return x%2
    
ans = F(b)^F(a-1)

print((ans))

Solution (Python):
from math import ceil
A, B = map(int, input().split())
res = 0
if B-A+1<=20:
    for a in range(A,B+1):
        res^=a
    print(res)
    exit()
for a in range(A,ceil(A/4)*4):
    res ^= a
for b in range((B//4)*4,B+1):
    res ^= b
print(res)

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

print(ans)

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B = map(int, readline().split())

    def f(x):
        r = (x + 1) % 4
        ans = 0
        for i in range(x, x - r, -1):
            ans ^= i

        return ans

    if A == 0:
        print(f(B))
    else:
        print(f(B) ^ f(A - 1))
    return


if __name__ == '__main__':
    main()

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B = map(int, readline().split())

    def rec(x):
        if x < 4:
            ans = 0
            for i in range(1, x + 1):
                ans ^= i
            return ans

        p = 0
        y = 1
        while y << 1 <= x:
            y <<= 1
            p += 1

        return (1 << p) * ((x - y + 1) % 2) + rec(x & ~(1 << p))

    if A == 0:
        print(rec(B))
    else:
        print(rec(B) ^ rec(A - 1))
    return


if __name__ == '__main__':
    main()

Solution (Python):
from functools import reduce
a,b = map(int,input().split())
a -= 1
print(reduce(lambda x,y:x^y,list(range(a-a%4,a+1))+list(range(b-b%4,b+1))))

Solution (Python):
def r(n):
    t=n%4
    if t==0:
        return n
    if t==1:
        return 1
    if t==2:
        return n+1
    if t==3:
        return 0
a,b=map(int,input().split())
print(r(a-1)^r(b))

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

A, B = mapint()

def cal(N):
    bits = [0]*50
    for i in range(1, 50):
        b = 2**i
        bits[i-1] = ((N//b*(b//2))+max(0, N%b-b//2))
    return bits

a_bits = cal(A)
b_bits = cal(B+1)
ans = 0
for i, (a, b) in enumerate(zip(a_bits, b_bits)):
    ans += 2**i*((a+b)%2)
print(ans)

Solution (Python):
import sys
import math
import itertools
import collections
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    A,B = NMI()
    
    xA , xB = 0,0
    
    if A == 0 or A == 1:
        xA = 0
    else:
        if A % 4 == 1:
            xA = A - 1
        elif A % 4 == 2:
            xA = 1
        elif A % 4 == 3:
            xA = A
        else:
            xA = 0
    
    if B == 0:
        xB = 0
    else:
        if B % 4 == 1:
            xB = 1
        elif B % 4 == 2:
            xB = B + 1
        elif B % 4 == 3:
            xB = 0
        else:
            xB = B
           
    A_bin = format(xA, '040b')
    B_bin = format(xB, '040b')
    
    ans = ['0' for _ in range(40)]
    
    for i in range(39,-1,-1):
        if int(A_bin[i])+int(B_bin[i])==1:
            ans[i] = '1'
    
    print(int("".join(ans),2))
        
    

if __name__ == '__main__':
    main()

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

def xor_sum(n):
    if n % 4 == 1:
        return 1
    elif n % 4 == 2:
        return n+1
    elif n % 4 == 3:
        return 0
    else:
        return n

if a == 0:
    print(xor_sum(b))
else:
    print(xor_sum(a-1) ^ xor_sum(b))

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

def ff(n):
    tmp = (n + 1) // 2
    tmp %= 2
    if n % 2 == 1:
        return tmp
    else:
        return n ^ tmp
    
ans = ff(a - 1) ^ ff(b)
print(ans)

Solution (Python):
import sys

input = sys.stdin.readline


def g(N):
    if N == -1:
        return 0
    r = N % 4
    if r == 0:
        return N
    elif r == 1:
        return 1
    elif r == 2:
        return N + 1
    else:
        return 0


def main():
    A, B = map(int, input().split())
    ans = g(A - 1) ^ g(B)
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
from collections import Counter as cc
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())


def main():
    a, b = mi()
    def sxor(x):
        ret = ((x+1)//2)%2
        if x%2 == 0:
            ret ^= x
        return ret
    ans = sxor(b)^sxor(a-1)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def abc121_d():
    a, b = map(int, input().split())
    ans = 0
    if b - a < 8:
        for k in range(a, b+1):
            ans ^= k
    else:
        low = (a + 3) // 4
        up = b // 4
        for k in range(a, 4*low):
            ans ^= k
        for k in range(4*up, b+1):
            ans ^= k
    print(ans)

if __name__ == '__main__':
    abc121_d()

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

def allx(n):
    ans=0
    for i in range(40):
        if i==0:
            if n%4==2 or n%4==1:
                ans+=1
                continue
        c= pow(2,i+1)
        k=n% c
        
        if k>=c//2 and k%2==0:
          ans+=pow(2,i)
    return ans

print(allx(b)^allx(a))

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

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


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

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

def f(X):
  a, b = divmod(X+1, 2)
  return (a%2)^(X*b)

print(f(max(0, A-1))^f(B))

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

def f(X):
  a = 1
  temp = 2
  ret = []
  while a > 0:
    a, b = divmod(X+1, temp)
    if temp == 2:
      ret.append(a%2)
    else:
      ret.append(max(b-(temp//2), 0)%2)
    temp *= 2
  return "".join(map(str, reversed(ret)))

print(int(f(max(0, A-1)), 2)^int(f(B), 2))

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

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

    
    def f(x):
        rem = x % 4
        if rem == 0:
            return x
        elif rem == 1:
            return 1
        elif rem == 2:
            return x + 1
        elif rem == 3:
            return 0

    ans = f(B) ^ f(A - 1)
    print(ans)

if __name__ == '__main__':
    resolve()

Solution (Python):
A,B = map(int,input().split())
xor = []
if B-A<=8:
    ans = 0
    for i in range(A,B+1):
        ans^=i
else:
    while True:
        if A%4 == 0:
            break
        else:
            xor.append(A)
        A+=1

    while True:
        if B%4 == 3:
            break
        else:
            xor.append(B)
        B-=1

    ans = 0
    while xor:
        ans^=xor.pop()
print(ans)

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

def f(x):
    res = 0
    while x % 4 != 3:
        res ^= x
        x -= 1
    
    return res

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

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

if A == 0:
  print(B)
  exit()
  
a = A - 1
rlt = ((B+1)//2 - (a+1)//2) % 2

for i in range(1, 40):
  pw1 = 2**i
  pw2 = pw1*2
  cnta = max(a % pw2 - pw1 + 1, 0)
  cntB = max(B % pw2 - pw1 + 1, 0)
  rlt += ((cntB - cnta) % 2)*pw1
  
print(rlt)

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

cnt = b - a + 1
cnt -= (a % 2 == 1) + (b % 2 == 0)
a, b = a * (a % 2 == 1), b * (b % 2 == 0)
print((cnt // 2 % 2) ^ a ^ b)

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

answer = 0
X = A - 1
Y = B
answer = 0
for i in range(1,41):
    cycle = 2 ** i
    qX = X // cycle
    qY = Y // cycle
    rX = X % cycle
    rY = Y % cycle
    oneX = qX * cycle // 2
    oneY = qY * cycle // 2
    if rX >= cycle // 2:
        oneX += rX - cycle // 2 + 1
    if rY >= cycle // 2:
        oneY += rY - cycle // 2 + 1
    one = oneY - oneX

    if one % 2 == 1 :
        answer += 2 ** (i - 1)
    
print(answer)

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

fa = (a - 1) * ((a - 1) % 2 == 0) ^ a // 2 % 2
fb = b * (b % 2 == 0) ^ (b + 1) // 2 % 2
print(fa ^ fb)

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

if a == b:
    print(a)
    exit()
cnt = b - a + 1
cnt -= (a % 2 == 1) + (b % 2 == 0)
a, b = a * (a % 2 == 1), b * (b % 2 == 0)
print((cnt // 2 % 2) ^ a ^ b)

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

if a == b:
    print(a)
    exit()
cnt = b - a + 1
cnt -= (a % 2 == 1) + (b % 2 == 0)
a, b = a * (a % 2 == 1), b * (b % 2 == 0)
if cnt // 2 % 2 == 0:
    print(0 ^ a ^ b)
elif cnt // 2 % 2 == 1:
    print(1 ^ a ^ b)

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






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

f1 = xor_func(A - 1)
f2 = xor_func(B)
ans = f1 ^ f2
print(ans)

Solution (Python):
def xor_from_zero(to):
    fr = 0
    to_copy = to
    b = 2 ** (len(format(to, 'b'))-1)
    while b > 2:
        if to_copy // b > 0:
            fr += b
            to_copy -= b

        b = b // 2

    res = 0
    for a in range(fr, to+1):
        res = res ^ a

    return res

A, B = map(int, input().split())
print(xor_from_zero(A-1)^xor_from_zero(B))