Buggy python submission (verdict: Time Limit Exceeded):

def examD():
    N = I()
    a = LI();  b = LI()
    cura = [0]*N; curb=[0]*N
    ansC = [0]*29
    for i in range(29):
        T = (2 ** i)
        for j in range(N):
            curb[j] = b[j]%(2**(i+1))
        curb.sort()
        for j in range(N):
            cura[j] = a[j]%(2**(i+1))
            loc1 = T - cura[j]
            loc3 = 2 * T - cura[j]
            loc2 = 3 * T - cura[j]
            cur = (bisect.bisect_left(curb, loc1)-bisect.bisect_left(curb, loc2)\
                + bisect.bisect_left(curb, loc3))+N
            ansC[i] = (ansC[i]+cur)%2
#    print(ansC)
    ans = 0
    for i in range(29):
        ans += ansC[i]*(2**i)
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()


Fixed submission:
def examD():
    N = I()
    a = LI();  b = LI()
    cura = [0]*N; curb=[0]*N
    ans = 0
    for i in range(28,-1,-1):
        T = (2 ** i)
        for j in range(N):
            cura[j] = a[j]%(2**(i+1))
            curb[j] = b[j]%(2**(i+1))
        curb.sort()
        cura.sort(reverse=1)
        f, l1, r1, l2 = 0, 0, 0, 0
        for x in cura:
            while l1 < N and x + curb[l1] < T:
                l1 += 1
            while r1 < N and x + curb[r1] < 2 * T:
                r1 += 1
            while l2 < N and x + curb[l2] < 3 * T:
                l2 += 1
            f += N - l2 + r1 - l1
        ans += T * (f & 1)
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()

Buggy python submission (verdict: Time Limit Exceeded):
def examD():
    N = I()
    a = LI();  b = LI()
    cura = [0]*N; curb = [0]*N
    ansC = [0]*29
    for i in range(29):
        T = (2 ** i)
        for j in range(N):
            curb[j] = b[j]%(2**(i+1))
        curb.sort()
        for j in range(N):
            cura[j] = a[j]%(2**(i+1))
            loc1 = T - cura[j]
            loc3 = 2 * T - cura[j]
            loc2 = 3 * T - cura[j]
            cur = (bisect.bisect_left(curb, loc1)-bisect.bisect_left(curb, loc2)\
                + bisect.bisect_left(curb, loc3))+N
            ansC[i] = (ansC[i]+cur)%2
#    print(ansC)
    ans = 0
    for i in range(29):
        ans += ansC[i]*(2**i)
    print(ans)



import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()


Fixed submission:
def examD():
    N = I()
    a = LI();  b = LI()
    cura = [0]*N; curb=[0]*N
    ans = 0
    for i in range(28,-1,-1):
        T = (2 ** i)
        for j in range(N):
            cura[j] = a[j]%(2**(i+1))
            curb[j] = b[j]%(2**(i+1))
        curb.sort()
        cura.sort(reverse=1)
        f, l1, r1, l2 = 0, 0, 0, 0
        for x in cura:
            while l1 < N and x + curb[l1] < T:
                l1 += 1
            while r1 < N and x + curb[r1] < 2 * T:
                r1 += 1
            while l2 < N and x + curb[l2] < 3 * T:
                l2 += 1
            f += N - l2 + r1 - l1
        ans += T * (f & 1)
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()

Buggy python submission (verdict: Time Limit Exceeded):
#2つの長さNの非負整数列a1,,,aNが与えられます。１<=i,j<=Nとなるように整数i,jを選ぶ方法はN~2通りありますが、
#このN~2通りのi,jそれぞれについて、ai+biを計算し、紙に書きだします。
#つまり紙にN~2個の整数を書きます。この整数のxorを計算してください。
#
import bisect

N = int(input())

a = [0]*N
b = [0]*N
ax = [0]*N
bx = [0]*N
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = [0]*30
n = int(0)

for K in range(30):
    for i in range(N):
        ax[i] = a[i]%(2**(K+1))
        bx[i] = b[i]%(2**(K+1))
    bx.sort()
    num = int(0)
    for i in range(N):
        loc1 = 2**K-ax[i]
        loc3 = 2*2**K-ax[i]
        loc2 = 3*2**K-ax[i]
        num += N - bisect.bisect_left(bx, loc1)
        num += N - bisect.bisect_left(bx, loc2)
        num -= N - bisect.bisect_left(bx, loc3)
    if num%2==1:
        ans[K]=1
#    print(bisect.bisect_left(bx, loc2))

#print(ans)

for i in range(30):
    n += (2**i)*ans[i]

print(n)

Fixed submission:
def examD():
    N = I()
    a = LI();  b = LI()
    cura = [0]*N; curb=[0]*N
    ans = 0
    for i in range(28,-1,-1):
        T = (2 ** i)
        for j in range(N):
            cura[j] = a[j]%(2**(i+1))
            curb[j] = b[j]%(2**(i+1))
        curb.sort()
        cura.sort(reverse=1)
        f, l1, r1, l2 = 0, 0, 0, 0
        for x in cura:
            while l1 < N and x + curb[l1] < T:
                l1 += 1
            while r1 < N and x + curb[r1] < 2 * T:
                r1 += 1
            while l2 < N and x + curb[l2] < 3 * T:
                l2 += 1
            f += N - l2 + r1 - l1
        ans += T * (f & 1)
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()