Problem:
 Score : 500 points    Problem Statement You are given two integer sequences, each of length N : a_1, ..., a_N and b_1, ..., b_N .  There are N^2 ways to choose two integers i and j such that 1 \leq i, j \leq N . For each of these N^2 pairs, we will compute a_i + b_j and write it on a sheet of paper.
That is, we will write N^2 integers in total.  Compute the XOR of these N^2 integers.   Definition of XOR  The XOR of integers c_1, c_2, ..., c_m is defined as follows:   Let the XOR be X . In the binary representation of X , the digit in the 2^k 's place ( 0 \leq k ; k is an integer) is 1 if there are an odd number of integers among c_1, c_2, ...c_m whose binary representation has 1 in the 2^k 's place, and 0 if that number is even.   For example, let us compute the XOR of 3 and 5 . The binary representation of 3 is 011 , and the binary representation of 5 is 101 , thus the XOR has the binary representation 110 , that is, the XOR is 6 .

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007


def A():
    a, b, c = LI()
    if a + b >= c:
        print("Yes")
    else:
        print("No")
    return


def B():
    n = II()
    s = SR(n)
    m = II()
    t = SR(m)
    ans = 0
    for si in s:
        ans = max(ans, s.count(si) - t.count(si))
    print(ans)
    return


def C():
    n = II()
    ab = LIR(n)
    cd = LIR(n)
    ab.sort()
    cd.sort()
    check = [0 for i in range(n)]
    ans = 0
    for _, c in enumerate(cd):
        d = c[1]
        c = c[0]
        maxy = -1
        x = -1
        for k, a in enumerate(ab):
            b = a[1]
            a = a[0]
            if maxy < b and c > a and check[k] == 0 and d > b:
                maxy = b
                x = k
        if x != -1:
            ans += 1
            check[x] += 1
    print(ans)


    return


def D():
    N = II()
    a = LI()
    b = LI()
    ans = 0
    t = 1
    for i in range(29):
        a2 = [A & ((t << 1) - 1) for A in a]
        b2 = [B & ((t << 1) - 1) for B in b]
        a2.sort(reverse=True)
        b2.sort()
        ansb = 0
        r1 = r2 = r3 = 0
        for A in a2:
            while r1 < N and A + b2[r1] < t:
                r1 += 1
            while r2 < N and A + b2[r2] < 2*t:
                r2 += 1
            while r3 < N and A + b2[r3] < 3*t:
                r3 += 1
            ansb += r2 ^ r1 ^ N ^ r3
            ansb = ansb & 1
        ans += (ansb << i)
        t = t << 1
    print(ans)
    return


if __name__ == '__main__':
    D()

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007


def A():
    a, b, c = LI()
    if a + b >= c:
        print("Yes")
    else:
        print("No")
    return


def B():
    n = II()
    s = SR(n)
    m = II()
    t = SR(m)
    ans = 0
    for si in s:
        ans = max(ans, s.count(si) - t.count(si))
    print(ans)
    return


def C():
    n = II()
    ab = LIR(n)
    cd = LIR(n)
    ab.sort()
    cd.sort()
    check = [0 for i in range(n)]
    ans = 0
    for _, c in enumerate(cd):
        d = c[1]
        c = c[0]
        maxy = -1
        x = -1
        for k, a in enumerate(ab):
            b = a[1]
            a = a[0]
            if maxy < b and c > a and check[k] == 0 and d > b:
                maxy = b
                x = k
        if x != -1:
            ans += 1
            check[x] += 1
    print(ans)


    return


def D():
    N = II()
    a = LI()
    b = LI()
    ans = 0
    for i in range(29):
        t = 1 << i
        a2 = [A & ((t << 1) - 1) for A in a]
        b2 = [B & ((t << 1) - 1) for B in b]
        a2.sort()
        b2.sort()
        ansb = 0
        r1 = r2 = r3 = 0
        for A in reversed(a2):
            while r1 < N and A + b2[r1] < t:
                r1 += 1
            while r2 < N and A + b2[r2] < 2*t:
                r2 += 1
            while r3 < N and A + b2[r3] < 3*t:
                r3 += 1
            ansb += r2 ^ r1 ^ N ^ r3
            ansb = ansb & 1
        ans += (ansb << i)
    print(ans)
    return


if __name__ == '__main__':
    D()

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007


def A():
    a, b, c = LI()
    if a + b >= c:
        print("Yes")
    else:
        print("No")
    return


def B():
    n = II()
    s = SR(n)
    m = II()
    t = SR(m)
    ans = 0
    for si in s:
        ans = max(ans, s.count(si) - t.count(si))
    print(ans)
    return


def C():
    n = II()
    ab = LIR(n)
    cd = LIR(n)
    ab.sort()
    cd.sort()
    check = [0 for i in range(n)]
    ans = 0
    for _, c in enumerate(cd):
        d = c[1]
        c = c[0]
        maxy = -1
        x = -1
        for k, a in enumerate(ab):
            b = a[1]
            a = a[0]
            if maxy < b and c > a and check[k] == 0 and d > b:
                maxy = b
                x = k
        if x != -1:
            ans += 1
            check[x] += 1
    print(ans)


    return


def D():
    N = II()
    a = LI()
    b = LI()
    ans = 0
    for i in range(29):
        t = 1 << i
        a2 = [A & ((t << 1) - 1) for A in a]
        b2 = [B & ((t << 1) - 1) for B in b]
        a2.sort()
        b2.sort()
        ansb = 0
        r1 = r2 = r3 = 0
        for A in reversed(a2):
            while r1 < N and A + b2[r1] < t:
                r1 += 1
            while r2 < N and A + b2[r2] < 2*t:
                r2 += 1
            while r3 < N and A + b2[r3] < 3*t:
                r3 += 1
            ansb += (r2 - r1) + (N - r3)
        ans += ((ansb & 1) << i)
    print(ans)
    return


if __name__ == '__main__':
    D()

Solution (Python):
import numpy as np
N = int(input())
A = np.array(input().split(), dtype = np.int32)
B = np.array(input().split(), dtype = np.int32)

bit = 1 << 28
mask = 2 * bit - 1

ans = 0
while bit:
    A &= mask
    B &= mask
    A.sort()
    B.sort()
    x1, x2, x3 = (np.searchsorted(B, v - A).sum() for v in [bit, 2 * bit, 3 * bit])
    zero_cnt = x1 + (x3 - x2)
    if (N - zero_cnt) % 2:
        ans += bit
    bit >>= 1
    mask >>= 1

print (ans)

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *
from copy import *

N = int(input())
a, b = list(map(int, input().split())), list(map(int, input().split()))
m, ans = 2**29, 0
for i in range(1, 30)[::-1]:
    a = [x % m for x in a]
    b = [y % m for y in b]
    m //= 2
    a.sort(reverse = 1)
    b.sort()
    f, l1, r1, l2 = 0, 0, 0, 0
    for x in a:
        while l1 < N and x+b[l1] < m:
            l1 += 1
        while r1 < N and x+b[r1] < 2*m:
            r1 += 1
        while l2 < N and x+b[l2] < 3*m:
            l2 += 1
        f += N-l2+r1-l1
    ans += m*(f&1)
print(ans)

Solution (Python):
from bisect import bisect_left


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    mask = 1
    target = 1
    ans = 0
    for _ in range(29):
        AA = sorted([a & mask for a in A], reverse=True)
        BB = sorted([b & mask for b in B])
        cnt = 0
        idx1 = 0  
        idx2 = 0  
        idx3 = 0  
        for a in AA:
            while idx1 < N and a+BB[idx1] < target*1:
                idx1 += 1
            while idx2 < N and a+BB[idx2] < target*2:
                idx2 += 1
            while idx3 < N and a+BB[idx3] < target*3:
                idx3 += 1
            cnt += (N - idx3) + (idx2 - idx1)
        ans += target * (cnt % 2)
        mask <<= 1
        mask |= 1
        target <<= 1
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np

N = int(input())
A = np.array(input().split(), dtype=np.int32)
B = np.array(input().split(), dtype=np.int32)

ans = 0
pow = 1
for digit in range(30) :
    mask = pow*2 - 1
    maskedA = A & mask
    maskedB = B & mask

    maskedA.sort()
    maskedB.sort()

    sum1, sum2, sum3 = (np.searchsorted(maskedB, bound - maskedA).sum() for bound in [pow, pow*2, pow*3])
    count = sum1 + (sum3 - sum2)

    if (N - count) % 2 == 1 :
        ans += pow
    pow *= 2

print(ans)

Solution (Python):
import numpy as np
N = int(input())
A = np.array(input().split(), dtype=np.int32)
B = np.array(input().split(), dtype=np.int32)
	
bit = 1 << 28
mask = 2 * bit - 1

answer = 0
while bit:
  A &= mask
  B &= mask
  A.sort()
  B.sort()

  x1,x2,x3 = (np.searchsorted(B, v-A).sum() for v in [bit, 2*bit, 3*bit])
  zero_cnt = x1 + (x3-x2)
  if (N-zero_cnt)%2:
    answer += bit
  bit >>= 1
  mask >>= 1

print(answer)

Solution (Python):
import numpy as np
N = int(input())
A = np.array(input().split(), dtype=np.int32)
B = np.array(input().split(), dtype=np.int32)
	
def f(t,A,B):
  power = 1<<t
  mask = (power<<1)-1
  AA = A & mask
  BB = B & mask
  AA.sort()
  BB.sort()

  x1,x2,x3 = (np.searchsorted(BB, v-AA).sum() for v in [power, 2*power, 3*power])
  zero_cnt = x1 + (x3-x2)
  return (N-zero_cnt)%2
  
answer = sum(f(t,A,B) << t for t in range(29))
print(answer)

Solution (Python):
import numpy as np
N = int(input())
A = np.array(input().split(), dtype=np.int32)
B = np.array(input().split(), dtype=np.int32)
	
def f(t,A,B):
  power = 1<<t
  mask = (power<<1)-1
  AA = A & mask
  BB = B & mask
  AA.sort()
  BB.sort()

  x1,x2,x3 = (np.searchsorted(BB, v-AA).sum() for v in [power, 2*power, 3*power])
  zero_cnt = x1 + (x3-x2)
  return (N-zero_cnt)%2
  
answer = sum(f(t,A,B) << t for t in range(30))
print(answer)

Solution (Python):
import numpy as np
N = int(input())
A = np.array(input().split(), dtype=np.int32)
B = np.array(input().split(), dtype=np.int32)
	
def f(t,A,B):
  power = 1<<t
  mask = (power<<1)-1
  AA = A & mask
  BB = B & mask
  AA.sort()

  x1,x2,x3 = (np.searchsorted(AA, v-BB).sum() for v in [power, 2*power, 3*power])
  zero_cnt = x1 + (x3-x2)
  return (N-zero_cnt)%2
  
answer = 0
for t in range(30):
	x = f(t,A,B)
	if x == 1:
		answer += 1<<t

print(answer)

Solution (Python):
from subprocess import*
call(('python3','-c',"""
import numpy as np
bisect_left = np.searchsorted
input()
a = np.int32(input().split())
b = np.int32(input().split())
ans = 0
for k in range(28, -1, -1):
    low = pow(2, k)
    high = pow(2, k + 1)
    a %= high
    b %= high
    b.sort()
    y = np.hstack((b - high, b))
    left = bisect_left(y, low - a)
    right = bisect_left(y, high - a)
    if np.sum(right - left) % 2:
        ans += low
print(ans)
"""))

Solution (Python):
import numpy as np
N = int(input())
A = np.array(input().split(), dtype=np.int32)
B = np.array(input().split(), dtype=np.int32)
	
def f(t,A,B):
  power = 1<<t
  mask = (power<<1)-1
  AA = A & mask
  BB = B & mask
  AA.sort()
  BB.sort()

  x1,x2,x3 = (np.searchsorted(BB, v-AA).sum() for v in [power, 2*power, 3*power])
  zero_cnt = x1 + (x3-x2)
  return (N-zero_cnt)%2
  
answer = 0
for t in range(30):
	x = f(t,A,B)
	if x == 1:
		answer += 1<<t

print(answer)

Solution (Python):
import numpy as np
N = int(input())
A = np.int32(input().split())
B = np.int32(input().split())

ans = 0
for k in range(29):
    a = np.sort(A%(2**(k+1)))
    b = B%(2**(k+1))
    ans += (np.sum(np.searchsorted(a,2**(k+1)-b)-np.searchsorted(a,2**k-b)+N-np.searchsorted(a-2**(k+1),2**k-b)))%2*2**k

print(ans)

Solution (Python):
import numpy as np
N = int(input())
A = np.int32(input().split())
B = np.int32(input().split())

ans = 0
for k in range(29):
    a = np.sort(np.hstack((A%(2**(k+1)),A%(2**(k+1))-2**(k+1))))
    b = B%(2**(k+1))
    ans += (np.sum(np.searchsorted(a,2**(k+1)-b)-np.searchsorted(a,2**k-b)))%2*2**k

print(ans)

Solution (Python):
import numpy as np
N = int(input())
A = np.int32(input().split())
B = np.int32(input().split())

ans_arr = np.zeros(29,int)
for k in range(29):
    a = np.sort(A%(2**(k+1)))
    b = B%(2**(k+1))
    ans_arr[k] += np.sum(np.searchsorted(a,2**(k+1)-1-b,side='right')-np.searchsorted(a,2**k-b))
    ans_arr[k] += np.sum(N-np.searchsorted(a,3*2**k-b))
    ans_arr[k] %= 2

ans = 0
for k in range(29):
    ans += ans_arr[k]*2**k

print(ans)

Solution (Python):
def main():
  N=int(input())
  A=list(map(int,input().split()))
  B=list(map(int,input().split()))
  ans=[]
  for i in range(29):
    T=2**i
    B_=list(B)
    A_=list(A)
    t=0
    for j in range(N):
      B_[j]%=2*T
      A_[j]%=2*T
    A_.sort()
    B_.sort()
    p=q=r=0
    for a in A_[::-1]:
      while p<N and a+B_[p]<T:
        p+=1
      while q<N and a+B_[q]<2*T:
        q+=1
      while r<N and a+B_[r]<3*T:
        r+=1
      t+=(q-p)+(N-r)
    ans.append(t%2)
  a=0
  for i in range(29):
    a+=2**i*ans[i]
  print(a)
if __name__=='__main__':
  main()

Solution (Python):


from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


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


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


class UnionFind:

    def __init__(self, n):
        self.parent = [i for i in range(n)]

    def root(self, i):
        if self.parent[i] == i:
            return i
        self.parent[i] = self.root(self.parent[i])
        return self.parent[i]

    def unite(self, i, j):
        rooti = self.root(i)
        rootj = self.root(j)
        if rooti == rootj:
            return
        if rooti < rootj:
            self.parent[rootj] = rooti
        else:
            self.parent[rooti] = rootj

    def same(self, i, j):
        return self.root(i) == self.root(j)





def main():
    n = intin()
    alist = intina()
    blist = intina()

    ans = 0

    for i in range(29):
        mod = 1 << (i + 1)
        mask = mod - 1

        aalist = [a & mask for a in alist]
        bblist = [b & mask for b in blist]
        aalist.sort(reverse=True)
        bblist.sort()
        bblist.append(float('inf'))

        count = 0
        cache = {}
        idx1 = idx2 = idx3 = 0
        for a in aalist:
            while bblist[idx1] < (mod >> 1) - a:
                idx1 += 1
            while bblist[idx2] < mod - a:
                idx2 += 1
            while bblist[idx3] < (mod >> 1) + mod - a:
                idx3 += 1

            count += idx2 - idx1
            count += n - idx3

        ans += (mod >> 1) if count & 1 else 0

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
	N = int(input())
	A = list(map(int,input().split()))
	B = list(map(int,input().split()))
	ans = 0
	p = 1
	for k in range(29):
		a_m = sorted([i & (2*p-1) for i in A], reverse=True)
		b_m = sorted([i & (2*p-1) for i in B])
		s = 0
		l1 = 0
		r1 = 0
		l2 = 0
		r2 = 0
		for a in a_m:
			while l1 < N and a + b_m[l1] < p:
				l1 += 1
			while r1 < N and a + b_m[r1] < 2*p:
				r1 += 1
			while l2 < N and a + b_m[l2] < 3*p:
				l2 += 1
			while r2 < N and a + b_m[r2] < 4*p:
				r2 += 1
			s += r2 - l2 + r1 - l1
		if s&1 == 1:
			ans += p
		p *= 2

	print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import math
import numpy as np
bl = np.searchsorted

N=int(input())
a=np.int32(input().split())
b=np.int32(input().split())
b.sort()
q=max(a+[b[-1]])
if q==0: print(0),sys.exit()

p=math.ceil( math.log(q,2) )+1


ans=0
for i in range(p,-1,-1):
    low=2**i
    ai=a % (2*low)
    bi=b % (2*low)
    bi.sort()
    bi = np.hstack((bi - 2*low, bi))
    tmp=0
    left1 = bl(bi, low - ai)
    right1 = bl(bi, 2*low - ai)   
    if np.sum(-left1 + right1) % 2: ans+=low

print(ans)

Solution (Python):
import sys
import math
import numpy as np
bl = np.searchsorted

N=int(input())
a=np.int32(input().split())
b=np.int32(input().split())
b.sort()
q=max(a+[b[-1]])
if q==0: print(0),sys.exit()

p=math.ceil( math.log(q,2) )+1


ans=0
for i in range(p,-1,-1):
    T=2**i
    ai=a % (2*T)
    bi=b % (2*T)
    bi.sort()

    tmp=0
    left1 = bl(bi, T - ai)
    right1 = bl(bi, 2*T - ai)
    left2 = bl(bi, 3*T - ai)
    right2 = bl(bi, 4*T - ai)    
    if np.sum(-left1 + right1 -left2 +right2) % 2: ans+=T

print(ans)

Solution (Python):
import numpy as np
bisect_left = np.searchsorted
N = input()
a = np.int32(input().split())
b = np.int32(input().split())
ans = 0
for k in range(29):
    low = pow(2, k)
    high = pow(2, k + 1)
    x = a % high
    y = b % high
    y.sort()
    y = np.hstack((y - high, y))  
    left = bisect_left(y, low - x)
    right = bisect_left(y, high - x)
    if np.sum(right - left) % 2:
        ans += low
print(ans)

Solution (Python):
n = int(input())
a = [int(i) for i in input().split(" ")]
b = [int(i) for i in input().split(" ")]






p = 1
x = 0
for k in range(0, 29):
    b_m = sorted([i % (p * 2) for i in b])
    a_m = sorted([i % (p * 2) for i in a], reverse=True)
    s = 0
    l1 = 0
    r1 = 0
    l2 = 0
    r2 = 0
    for a_mi in a_m:
        while l1 < n and a_mi + b_m[l1] < p:
            l1 += 1
        while r1 < n and a_mi + b_m[r1] < 2 * p:
            r1 += 1
        while l2 < n and a_mi + b_m[l2] < 3 * p:
            l2 += 1
        while r2 < n and a_mi + b_m[r2] < 4 * p:
            r2 += 1
        s += r2 - l2 + r1 - l1
    if s % 2 == 1:
        x += p
    p *= 2

print(x)

Solution (Python):
import numpy as np
bisect_left = np.searchsorted
input()
a = np.int32(input().split())
b = np.int32(input().split())
ans = 0
for k in range(29):
    low = pow(2, k)
    high = pow(2, k + 1)
    x = a % high
    y = b % high
    y.sort()
    y = np.hstack((y - high, y))
    left = bisect_left(y, low - x)
    right = bisect_left(y, high - x)
    if np.sum(right - left) % 2:
        ans += low
print(ans)

Solution (Python):
import numpy as np
bisect_left = np.searchsorted
input()
a = np.int32(input().split())
b = np.int32(input().split())
ans = 0
for k in range(28, -1, -1):
    low = pow(2, k)
    high = pow(2, k + 1)
    a %= high
    b %= high
    b.sort()
    y = np.hstack((b - high, b))
    left = bisect_left(y, low - a)
    right = bisect_left(y, high - a)
    if np.sum(right - left) % 2:
        ans += low
print(ans)

Solution (Python):
import numpy as np
bisect_left = np.searchsorted
input()
a = np.array(input().split(), 'int32')
b = np.array(input().split(), 'int32')
ans = 0
for k in range(28, -1, -1):
    low = pow(2, k)
    high = pow(2, k + 1)
    a %= high
    b %= high
    b.sort()
    y = np.hstack((b - high, b))
    left = bisect_left(y, low - a)
    right = bisect_left(y, high - a)
    if np.sum(right - left) % 2:
        ans += low
print(ans)

Solution (Python):
def main():
    from numpy import array,searchsorted,sum,hstack
    n,*t=map(int,open(0).read().split())
    a,b=array(t[:n],'i4'),array(t[n:],'i4')
    c=0
    for k in range(28,-1,-1):
        l,h=pow(2,k),pow(2,k+1)
        a%=h
        b%=h
        b.sort()
        y=hstack((b-h,b))
        i=searchsorted(y,l-a)
        j=searchsorted(y,h-a)
        m=sum(j-i)
        c+=m%2*l
    print(c)
if __name__=='__main__':
    main()

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007


def A():
    return


def B():
    return


def C():
    def bfs(a,b):
        bfs_map = [-1 for i in range(2*n+2)]
        q = [a]
        bfs_map[a] = 0
        while q:
            x = q.pop(0)
            for y in out[x]:
                if bfs_map[y] == -1:
                    q.append(y)
                    bfs_map[y] = bfs_map[x]+1
        if bfs_map[b] == -1:return 0
        d = bfs_map[b]
        path = [b]
        y = b
        while d > 0:
            for x in ent[y]:
                if bfs_map[x] == d-1:
                    path.insert(0,x)
                    y = x
                    d -= 1
                    break
        return path

    def ford_fulkerson(a,b,c):
        ans = 0
        while 1:
            path = bfs(a,b)
            if not path:break
            for i in range(len(path)-1):
                out[path[i]].remove(path[i+1])
                ent[path[i+1]].remove(path[i])
                if not c[path[i+1]][path[i]]:
                    c[path[i+1]][path[i]] = 1
                    out[path[i+1]].append(path[i])
                    ent[path[i]].append(path[i+1])
            ans += 1
        return ans
    n = I()
    r = LIR(n)
    b = LIR(n)
    c = [[0 for i in range(2*n+2)] for i in range(2*n+2)]
    out = [[] for i in range(2*n+2)]
    ent = [[] for i in range(2*n+2)]
    for i in range(n):
        c[0][i+1] = 1
        out[0].append(i+1)
        ent[i+1].append(0)
        for j in range(n):
            if r[i][0] < b[j][0] and r[i][1] < b[j][1]:
                c[i+1][n+j+1] = 1
                out[i+1].append(n+j+1)
                ent[n+j+1].append(i+1)
    for j in range(n):
        c[n+j+1][2*n+1] = 1
        out[n+j+1].append(2*n+1)
        ent[2*n+1].append(n+j+1)
    print(ford_fulkerson(0,2*n+1,c))

def D():
    n = I()
    a = LI()
    b = LI()
    ans = 0
    p = 1
    for k in range(30):
        s = 0
        c = [b[i]%(p*2) for i in range(n)]
        a_ = [a[i]%(p*2) for i in range(n)]
        c.sort()
        a_.sort()
        l1,l2,l3 = 0,0,0
        y = float("inf")
        for x in a_[::-1]:
            if x != y:
                while l1 < n and c[l1] < p-x:l1 += 1
                while l2 < n and c[l2] < 2*p-x:l2 += 1
                while l3 < n and c[l3] < 3*p-x:l3 += 1
            s += n-l2-l1-l3
            y = x
        ans += (s%2)*p
        p *= 2
    print(ans)

def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == "__main__":
    D()

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007


def A():
    return


def B():
    return


def C():
    n = II()
    ab = LIR(n)
    cd = LIR(n)
    ab.sort()
    cd.sort()
    check = [0 for i in range(n)]
    ans = 0
    
    for i, c in enumerate(cd):
        d = c[1]
        c = c[0]
        maxy = -1
        x = -1
        for k, a in enumerate(ab):
            b = a[1]
            a = a[0]
            if maxy < b and c > a and check[k] == 0 and d > b:
                maxy = b
                x = k
                
        if x != -1:
            ans += 1
            check[x] += 1
    print(ans)


    return


def D():
    N = II()
    a = LI()
    b = LI()
    ans = 0
    for i in range(29):
        t = 2 ** i
        a2 = [A % (2 * t) for A in a]
        b2 = [B % (2 * t) for B in b]
        a2.sort()
        b2.sort()
        ansb = 0
        r1 = r2 = r3 = 0
        for A in reversed(a2):
            while r1 < N and A + b2[r1] < t:
                r1 += 1
            while r2 < N and A + b2[r2] < 2*t:
                r2 += 1
            while r3 < N and A + b2[r3] < 3*t:
                r3 += 1
            ansb += (r2 - r1) + (N - r3)
        ans += ((ansb %2 ) << i)
    print(ans)
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == '__main__':
    D()

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007


def A():
    return


def B():
    return


def C():
    n = II()
    ab = LIR(n)
    cd = LIR(n)
    ab.sort()
    cd.sort()
    check = [0 for i in range(n)]
    ans = 0
    
    for i, c in enumerate(cd):
        d = c[1]
        c = c[0]
        maxy = -1
        x = -1
        for k, a in enumerate(ab):
            b = a[1]
            a = a[0]
            if maxy < b and c > a and check[k] == 0 and d > b:
                maxy = b
                x = k
                
        if x != -1:
            ans += 1
            check[x] += 1
    print(ans)


    return


def D():
    N = II()
    a = LI()
    b = LI()
    ans = 0
    for i in range(29):
        t = 2 ** i
        a2 = [A % (2 * t) for A in a]
        b2 = [B % (2 * t) for B in b]
        a2.sort()
        b2.sort()
        ansb = 0
        r1 = r2 = r3 = 0
        for A in reversed(a2):
            while r1 < N and A + b2[r1] < t:
                r1 += 1
            while r2 < N and A + b2[r2] < 2*t:
                r2 += 1
            while r3 < N and A + b2[r3] < 3*t:
                r3 += 1
            ansb += (r2 - r1) + (N - r3)
        ans += ((ansb %2 ) << i)
    print(ans)
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == '__main__':
    D()