Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right as br
import random
def calc1(N, A, B):
    s, t = 0, 0
    for i in range(N):
        s ^= A[i]
        t ^= B[i]
    ans = (s ^ t) * (N % 2)
    for k in range(1, 29):
        m = (1<<k) - 1
        AA = sorted([a & m for a in A])
        BB = sorted([a & m for a in B])
        ans ^= (sum([N - br(AA, (1<<k) - b - 1) for b in BB]) % 2) << k
        # print(k, sum([N - br(AA, (1<<k) - b - 1) for b in BB]))
    return ans
def calc2(N, A, B):
    s, t = 0, 0
    for i in range(N):
        s ^= A[i]
        t ^= B[i]
    ans = (s ^ t) * (N % 2)
    for k in range(1, 29):
        m = (1<<k) - 1
        AA = sorted([a & m for a in A])
        BB = sorted([a & m for a in B])[::-1]
        m += 1
        i, j = 0, 0
        while i < N and AA[i] + BB[j] < m:
            i += 1
        s = 0
        while i < N:
            while j < N and AA[i] + BB[j] >= m:
                j += 1
            s += j
            i += 1
        # print("k, s =", k, s)
        ans += (s % 2) << k
    return ans
N = int(input())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
print(calc1(N, A, B))

Fixed submission:
from bisect import bisect_right as br
N = int(input())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
s, t = 0, 0
for i in range(N):
    s ^= A[i]
    t ^= B[i]
ans = (s ^ t) * (N % 2)
for k in range(1, 29):
    m = (1<<k) - 1
    AA = sorted([a & m for a in A])
    BB = sorted([a & m for a in B])[::-1]
    m += 1
    i, j = 0, 0
    while i < N and AA[i] + BB[j] < m:
        i += 1
    s = 0
    while i < N:
        while j < N and AA[i] + BB[j] >= m:
            j += 1
        s += j
        i += 1
    ans ^= (s % 2) << k
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right as br
N = int(input())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
s, t = 0, 0
for i in range(N):
    s ^= A[i]
    t ^= B[i]
ans = (s ^ t) * (N % 2)
for k in range(1, 29):
    m = (1<<k) - 1
    AA = sorted([a & m for a in A])
    BB = sorted([a & m for a in B])
    ans ^= (sum([N - br(AA, (1<<k) - b - 1) for b in BB]) % 2) << k

print(ans)

Fixed submission:
from bisect import bisect_right as br
N = int(input())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
s, t = 0, 0
for i in range(N):
    s ^= A[i]
    t ^= B[i]
ans = (s ^ t) * (N % 2)
for k in range(1, 29):
    m = (1<<k) - 1
    AA = sorted([a & m for a in A])
    BB = sorted([a & m for a in B])[::-1]
    m += 1
    i, j = 0, 0
    while i < N and AA[i] + BB[j] < m:
        i += 1
    s = 0
    while i < N:
        while j < N and AA[i] + BB[j] >= m:
            j += 1
        s += j
        i += 1
    ans ^= (s % 2) << k
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right as br
N = int(input())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
s, t = 0, 0
for i in range(N):
    s ^= A[i]
    t ^= B[i]
ans = (s ^ t) * (N % 2)
for k in range(1, 29):
    m = (1<<k) - 1
    AA = sorted([a & m for a in A])
    BB = [a & m for a in B]
    ans ^= (sum([N - br(AA, (1<<k) - b - 1) for b in BB]) % 2) << k

print(ans)

Fixed submission:
from bisect import bisect_right as br
N = int(input())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
s, t = 0, 0
for i in range(N):
    s ^= A[i]
    t ^= B[i]
ans = (s ^ t) * (N % 2)
for k in range(1, 29):
    m = (1<<k) - 1
    AA = sorted([a & m for a in A])
    BB = sorted([a & m for a in B])[::-1]
    m += 1
    i, j = 0, 0
    while i < N and AA[i] + BB[j] < m:
        i += 1
    s = 0
    while i < N:
        while j < N and AA[i] + BB[j] >= m:
            j += 1
        s += j
        i += 1
    ans ^= (s % 2) << k
print(ans)