Buggy python submission (verdict: Time Limit Exceeded):
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())
A = list(map(int, input().split()))
B = sorted(list(map(int, input().split())))

from bisect import bisect_left, bisect_right
from copy import copy

ans = 0
for k in range(38):
    mod = 2**(k+1)
    T = 2**k
    B_sub = [ [], [] ]
    for b in B:
        B_sub[ (b & (1<<k))>>k].append(b)

    B = sum(B_sub, [])
    # print(B)
    # Bcopy = copy(B)
    Bcopy = list(map(lambda x: x%mod, B))

    count = 0
    for a in A:
        a = a % mod
        i1 = bisect_left(Bcopy, T-a)
        i2 = bisect_right(Bcopy, 2*T-a-1 )
        i3, i4 = bisect_left(Bcopy, 3*T-a), \
                 bisect_right(Bcopy, 4*T-a-1)
        count += i2 - i1 + i4 - i3
        # print("T: {}, a: {} , i1,i2,i3,i4: {}, Bcopycopy: {}, T-a: {}, 2*T-a: {}".format(T,a, [i1,i2,i3,i4], Bcopy,
        #          T-a, 2*T-a))
    if not count % 2 == 0:
        ans |= 1<<k
print(ans)
        


Fixed submission:
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())
A = list(map(int, input().split()))
B = sorted(list(map(int, input().split())))

from bisect import bisect_left, bisect_right
from copy import copy

ans = 0
for k in range(38):
    mod = 2**(k+1)
    T = 2**k
    A_sub = [ [], [] ]
    B_sub = [ [], [] ]
    for a in A:
        A_sub[ (a & (1<<k))>>k].append(a)
    for b in B:
        B_sub[ (b & (1<<k))>>k].append(b)

    A = sum(A_sub, [])
    B = sum(B_sub, [])

    itr = [N]*4
    count = 0
    mask = 2**(k+1)-1
    amask = [ai & mask for ai in A]
    bmask = [bi & mask for bi in B]
    for ai in amask:
        border = [
                T - ai,
                2*T - ai,
                3*T - ai,
                4*T - ai]
        for i in range(4):
            while 0 < itr[i]  and border[i] <= bmask[itr[i]-1]:
                itr[i] -= 1
        count += (itr[1] - itr[0]) + (itr[3]) - (itr[2])


    # Bcopy = list(map(lambda x: x%mod, B))

    # count = 0
    # for a in A:
    #     a = a % mod
    #     i1 = bisect_left(Bcopy, T-a)
    #     i2 = bisect_right(Bcopy, 2*T-a-1 )
    #     i3, i4 = bisect_left(Bcopy, 3*T-a), \
    #              bisect_right(Bcopy, 4*T-a-1)
    #     count += i2 - i1 + i4 - i3
    #     # print("T: {}, a: {} , i1,i2,i3,i4: {}, Bcopycopy: {}, T-a: {}, 2*T-a: {}".format(T,a, [i1,i2,i3,i4], Bcopy,
    #     #          T-a, 2*T-a))
    if not count % 2 == 0:
        ans |= 1<<k
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())
A = list(map(int, input().split()))
B = sorted(list(map(int, input().split())))

from bisect import bisect_left, bisect_right

ans = 0
for k in range(38):
    mod = 2**(k+1)
    T = 2**k
    Bcopy = sorted(list(map(lambda x:x%mod, B)))
    count = 0
    for a in A:
        a = a % mod
        i1 = bisect_left(Bcopy, T-a)
        i2 = bisect_right(Bcopy, 2*T-a-1 )
        i3, i4 = bisect_left(Bcopy, 3*T-a), \
                 bisect_right(Bcopy, 4*T-a-1)
        count += i2 -i1 + i4 - i3
        # print("T: {}, a: {} , i1,i2,i3,i4: {}, Bcopy: {}, T-a: {}, 2*T-a: {}".format(T,a, [i1,i2,i3,i4], Bcopy,
        #          T-a, 2*T-a))
    if not count % 2 == 0:
        ans |= 1<<k
print(ans)
        


Fixed submission:
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())
A = list(map(int, input().split()))
B = sorted(list(map(int, input().split())))

from bisect import bisect_left, bisect_right
from copy import copy

ans = 0
for k in range(38):
    mod = 2**(k+1)
    T = 2**k
    A_sub = [ [], [] ]
    B_sub = [ [], [] ]
    for a in A:
        A_sub[ (a & (1<<k))>>k].append(a)
    for b in B:
        B_sub[ (b & (1<<k))>>k].append(b)

    A = sum(A_sub, [])
    B = sum(B_sub, [])

    itr = [N]*4
    count = 0
    mask = 2**(k+1)-1
    amask = [ai & mask for ai in A]
    bmask = [bi & mask for bi in B]
    for ai in amask:
        border = [
                T - ai,
                2*T - ai,
                3*T - ai,
                4*T - ai]
        for i in range(4):
            while 0 < itr[i]  and border[i] <= bmask[itr[i]-1]:
                itr[i] -= 1
        count += (itr[1] - itr[0]) + (itr[3]) - (itr[2])


    # Bcopy = list(map(lambda x: x%mod, B))

    # count = 0
    # for a in A:
    #     a = a % mod
    #     i1 = bisect_left(Bcopy, T-a)
    #     i2 = bisect_right(Bcopy, 2*T-a-1 )
    #     i3, i4 = bisect_left(Bcopy, 3*T-a), \
    #              bisect_right(Bcopy, 4*T-a-1)
    #     count += i2 - i1 + i4 - i3
    #     # print("T: {}, a: {} , i1,i2,i3,i4: {}, Bcopycopy: {}, T-a: {}, 2*T-a: {}".format(T,a, [i1,i2,i3,i4], Bcopy,
    #     #          T-a, 2*T-a))
    if not count % 2 == 0:
        ans |= 1<<k
print(ans)