Buggy python submission (verdict: Time Limit Exceeded):
import sys,bisect
input = sys.stdin.readline


def main():
    n = int(input())
    a = tuple(map(int,input().split()))
    b = tuple(map(int,input().split()))


    res = 0
    p = 0

    for i in range(1,30):
        p += 1<<(i-1)
        tank = []
        for eb in b:
            tank.append(eb&p)
        tank.sort()

        cnt = 0
        
        
        q2 = p+1
        q1 = q2>>1
        q3 = q2<<1

        for elt in a:
            e = elt&p

            cnt += bisect.bisect_left(tank, q2-e ) - bisect.bisect_left(tank, q1-e)
            cnt += bisect.bisect_left(tank, q3-e ) - bisect.bisect_left(tank, 3*q1-e)
        
        if cnt%2 != 0:
            res += 1<<(i-1)

    print(res)


if __name__ == "__main__":
    main()

Fixed submission:
import sys,bisect
input = sys.stdin.readline


def main():
    n = int(input())
    a = tuple(map(int,input().split()))
    b = tuple(map(int,input().split()))


    res = 0
    p = 0

    for i in range(1,30):
        p += 1<<(i-1)
        A = []
        B = []

        for j in range(n):
            A.append(a[j]&p)
            B.append(b[j]&p)
        A.sort()
        B.sort()

        cnt = 0

        q2 = p+1
        q1 = q2>>1
        q3 = q2<<1

        k1,k2,k3,k4 = 0,0,0,0

        for j in range(n-1,-1,-1):
            while k1 < n and A[j]+B[k1] < q1:
                k1 += 1
            while k2 < n and A[j]+B[k2] < q2:
                k2 += 1
            while k3 < n and A[j]+B[k3] < 3*q1:
                k3 += 1
            while k4 < n and A[j]+B[k4] < q3:
                k4 += 1
            cnt += k4 + k2 - k1 - k3

        
        if cnt%2 != 0:
            res += 1<<(i-1)

    print(res)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys,bisect
input = sys.stdin.readline


def main():
    n = int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))


    res = 0

    for i in range(1,30):
        tank = []
        for eb in b:
            tank.append(eb - ((eb>>i)<<i))
        tank.sort()

        cnt = 0

        for elt in a:
            e = elt - ((elt >> i) << i)

            cnt += bisect.bisect_left(tank, (1<<i)-e ) - bisect.bisect_left(tank, (1<<(i-1))-e)
            cnt += bisect.bisect_left(tank, (1<<(i+1))-e ) - bisect.bisect_left(tank, 3*pow(2,i-1)-e)
        
        if cnt%2 != 0:
            res += 1<<(i-1)

    print(res)


if __name__ == "__main__":
    main()

Fixed submission:
import sys,bisect
input = sys.stdin.readline


def main():
    n = int(input())
    a = tuple(map(int,input().split()))
    b = tuple(map(int,input().split()))


    res = 0
    p = 0

    for i in range(1,30):
        p += 1<<(i-1)
        A = []
        B = []

        for j in range(n):
            A.append(a[j]&p)
            B.append(b[j]&p)
        A.sort()
        B.sort()

        cnt = 0

        q2 = p+1
        q1 = q2>>1
        q3 = q2<<1

        k1,k2,k3,k4 = 0,0,0,0

        for j in range(n-1,-1,-1):
            while k1 < n and A[j]+B[k1] < q1:
                k1 += 1
            while k2 < n and A[j]+B[k2] < q2:
                k2 += 1
            while k3 < n and A[j]+B[k3] < 3*q1:
                k3 += 1
            while k4 < n and A[j]+B[k4] < q3:
                k4 += 1
            cnt += k4 + k2 - k1 - k3

        
        if cnt%2 != 0:
            res += 1<<(i-1)

    print(res)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys,bisect
input = sys.stdin.readline

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


res = 0

for i in range(1,30):
    tank = []
    for eb in b:
        tank.append(eb - ((eb>>i)<<i))
    tank.sort()

    cnt = 0

    for elt in a:
        e = elt - ((elt >> i) << i)

        cnt += bisect.bisect_left(tank, (1<<i)-e ) - bisect.bisect_left(tank, (1<<(i-1))-e)
        cnt += bisect.bisect_left(tank, (1<<(i+1))-e ) - bisect.bisect_left(tank, 3*pow(2,i-1)-e)
    
    if cnt%2 != 0:
        res += 1<<(i-1)

print(res)


Fixed submission:
import sys,bisect
input = sys.stdin.readline


def main():
    n = int(input())
    a = tuple(map(int,input().split()))
    b = tuple(map(int,input().split()))


    res = 0
    p = 0

    for i in range(1,30):
        p += 1<<(i-1)
        A = []
        B = []

        for j in range(n):
            A.append(a[j]&p)
            B.append(b[j]&p)
        A.sort()
        B.sort()

        cnt = 0

        q2 = p+1
        q1 = q2>>1
        q3 = q2<<1

        k1,k2,k3,k4 = 0,0,0,0

        for j in range(n-1,-1,-1):
            while k1 < n and A[j]+B[k1] < q1:
                k1 += 1
            while k2 < n and A[j]+B[k2] < q2:
                k2 += 1
            while k3 < n and A[j]+B[k3] < 3*q1:
                k3 += 1
            while k4 < n and A[j]+B[k4] < q3:
                k4 += 1
            cnt += k4 + k2 - k1 - k3

        
        if cnt%2 != 0:
            res += 1<<(i-1)

    print(res)


if __name__ == "__main__":
    main()