Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left as bl
from bisect import bisect_right as br
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    l = [[] for i in range(30)]
    b.sort()
    for i in range(29):
        mod = 2**(i+1)
        for j in b:
            l[i].append(j%mod)
        l[i].sort()

    ans = 0
    for i in range(29):
        al = []
        count = 0
        mod = 2**i
        for j in a:
            al.append(j%(2*mod))
        al.sort(reverse = True)
        r1 = r2 = r3 = 0
        for j in al:
            while r1 < n and l[i][r1]+j < mod:
                r1 += 1
            while r2 < n and l[i][r2]+j < 2*mod:
                r2 += 1
            while r3 < n and l[i][r3]+j < 3*mod:
                r3 += 1
            count += n-r3+r2-r1
        ans += (count%2) << i
    print(ans)

if __name__ =="__main__":
    main()

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


n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
l = [[] for i in range(29)]
for i in range(29):
    mod = 2**(i+1)
    for j in b:
        l[i].append(j%mod)
    l[i].sort()

ans = 0
for i in range(29):
    al = []
    count = 0
    mod = 2**i
    for j in a:
        al.append(j%(2*mod))
    al.sort(reverse = True)
    r1 = r2 = r3 = 0
    for j in al:
        while r1 < n and l[i][r1]+j < mod:
            r1 += 1
        while r2 < n and l[i][r2]+j < 2*mod:
            r2 += 1
        while r3 < n and l[i][r3]+j < 3*mod:
            r3 += 1
        count += n-r3+r2-r1
    ans += (count%2) << i
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left as bl
from bisect import bisect_right as br
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    l = [[] for i in range(30)]
    b.sort()
    for i in range(29):
        mod = 2**(i+1)
        for j in b:
            l[i].append(j%mod)
        l[i].sort()

    ans = [0]*30

    for i in a:
        
        for j in range(29):
            mod = pow(2,j)
            x = i%(mod*2)
            ans[j] += br(l[j],2*mod-x-1)-bl(l[j],mod-x)+n-bl(l[j],3*mod-x)
            
    count = 0
    for i in range(30):
        count += pow(2,i)*(ans[i]%2)
    print(count)

if __name__ =="__main__":
    main()

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


n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
l = [[] for i in range(29)]
for i in range(29):
    mod = 2**(i+1)
    for j in b:
        l[i].append(j%mod)
    l[i].sort()

ans = 0
for i in range(29):
    al = []
    count = 0
    mod = 2**i
    for j in a:
        al.append(j%(2*mod))
    al.sort(reverse = True)
    r1 = r2 = r3 = 0
    for j in al:
        while r1 < n and l[i][r1]+j < mod:
            r1 += 1
        while r2 < n and l[i][r2]+j < 2*mod:
            r2 += 1
        while r3 < n and l[i][r3]+j < 3*mod:
            r3 += 1
        count += n-r3+r2-r1
    ans += (count%2) << i
print(ans)

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

def main():
    n = int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    l = [[] for i in range(31)]
    b.sort()
    for i in range(30):
        mod = 2**(i+1)
        for j in b:
            l[i].append(j%mod)
        l[i].sort()

    ans = [0]*31

    for i in a:
        
        for j in range(30):
            mod = pow(2,j)
            x = i%(mod*2)
            count = bisect.bisect_right(l[j],2*mod-x-1)-bisect.bisect_left(l[j],mod-x)
            count += bisect.bisect_right(l[j],4*mod-x-1)-bisect.bisect_left(l[j],3*mod-x)
            ans[j] += count
    count = 0
    for i in range(31):
        count += pow(2,i)*(ans[i]%2)
    print(count)

if __name__ =="__main__":
    main()

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


n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
l = [[] for i in range(29)]
for i in range(29):
    mod = 2**(i+1)
    for j in b:
        l[i].append(j%mod)
    l[i].sort()

ans = 0
for i in range(29):
    al = []
    count = 0
    mod = 2**i
    for j in a:
        al.append(j%(2*mod))
    al.sort(reverse = True)
    r1 = r2 = r3 = 0
    for j in al:
        while r1 < n and l[i][r1]+j < mod:
            r1 += 1
        while r2 < n and l[i][r2]+j < 2*mod:
            r2 += 1
        while r3 < n and l[i][r3]+j < 3*mod:
            r3 += 1
        count += n-r3+r2-r1
    ans += (count%2) << i
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
l = [[] for i in range(31)]
b.sort()
for i in range(30):
    mod = 2**(i+1)
    for j in b:
        l[i].append(j%mod)
    l[i].sort()

ans = [0]*31

for i in a:
    
    for j in range(30):
        mod = pow(2,j)
        x = i%(mod*2)
        count = bisect.bisect_right(l[j],2*mod-x-1)-bisect.bisect_left(l[j],mod-x)
        count += bisect.bisect_right(l[j],4*mod-x-1)-bisect.bisect_left(l[j],3*mod-x)
        ans[j] += count
count = 0
for i in range(31):
    count += pow(2,i)*(ans[i]%2)
print(count)

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


n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
l = [[] for i in range(29)]
for i in range(29):
    mod = 2**(i+1)
    for j in b:
        l[i].append(j%mod)
    l[i].sort()

ans = 0
for i in range(29):
    al = []
    count = 0
    mod = 2**i
    for j in a:
        al.append(j%(2*mod))
    al.sort(reverse = True)
    r1 = r2 = r3 = 0
    for j in al:
        while r1 < n and l[i][r1]+j < mod:
            r1 += 1
        while r2 < n and l[i][r2]+j < 2*mod:
            r2 += 1
        while r3 < n and l[i][r3]+j < 3*mod:
            r3 += 1
        count += n-r3+r2-r1
    ans += (count%2) << i
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
l = [[] for i in range(31)]
b.sort()
for i in range(30):
    mod = 2**(i+1)
    for j in b:
        l[i].append(j%mod)
    l[i].sort()

ans = [0]*31

for i in a:
    
    for j in range(30):
        mod = pow(2,j)
        x = i%(mod*2)
        count = bisect.bisect_right(l[j],2*mod-x-1)-bisect.bisect_left(l[j],mod-x)
        count += bisect.bisect_right(l[j],4*mod-x-1)-bisect.bisect_left(l[j],3*mod-x)
        ans[j] += count
count = 0
for i in range(31):
    count += pow(2,i)*(ans[i]%2)
print(count)

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


n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
l = [[] for i in range(29)]
for i in range(29):
    mod = 2**(i+1)
    for j in b:
        l[i].append(j%mod)
    l[i].sort()

ans = 0
for i in range(29):
    al = []
    count = 0
    mod = 2**i
    for j in a:
        al.append(j%(2*mod))
    al.sort(reverse = True)
    r1 = r2 = r3 = 0
    for j in al:
        while r1 < n and l[i][r1]+j < mod:
            r1 += 1
        while r2 < n and l[i][r2]+j < 2*mod:
            r2 += 1
        while r3 < n and l[i][r3]+j < 3*mod:
            r3 += 1
        count += n-r3+r2-r1
    ans += (count%2) << i
print(ans)