Buggy python submission (verdict: Time Limit Exceeded):
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
import bisect
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	A = getlist()
	B = getlist()
	ans = 0
	for i in range(29):
		mul = 2 ** (i + 1)
		mul2 = 2 ** i
		Aex = [A[j] % mul for j in range(N)]
		Bex = [B[j] % mul for j in range(N)]
		Bex.sort()
		cnt = 0
		for j in range(N):
			var = Aex[j]
			if var <= 2 ** i:
				cnt += bisect.bisect_left(Bex, mul - var) - (bisect.bisect_left(Bex, mul2 - var))
			else:
				cnt += bisect.bisect_left(Bex, mul - var)
				cnt += N - bisect.bisect_left(Bex, mul + mul2 - var)
		# print(Aex)
		# print(Bex)
		# print(cnt)
		if cnt % 2 != 0:
			ans += 2 ** i

	print(ans)

if __name__ == '__main__':
	main()

Fixed submission:
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
import bisect
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	A = getlist()
	B = getlist()
	ans = 0
	for i in range(29):
		mul = 2 ** (i + 1)
		mul2 = 2 ** i
		Aex = [A[j] % mul for j in range(N)]
		Bex = [B[j] % mul for j in range(N)]
		Aex.sort()
		Bex.sort()
		cnt = 0
		p, q, r = N - 1, N - 1, N - 1
		for j in range(N):
			var = Aex[j]
			while p >= 0 and mul2 - var <= Bex[p]:
				p -= 1
			while q >= 0 and mul - var <= Bex[q]:
				q -= 1
			while r != 0 and mul + mul2 - var <= Bex[r]:
				r -= 1
			cnt += q - p
			cnt += N - 1 - r
			
			# if var <= 2 ** i:
			# 	cnt += bisect.bisect_left(Bex, mul - var) - (bisect.bisect_left(Bex, mul2 - var))
			# else:
			# 	cnt += bisect.bisect_left(Bex, mul - var)
			# 	cnt += N - bisect.bisect_left(Bex, mul + mul2 - var)
		# print(Aex)
		# print(Bex)
		# print(cnt)
		if cnt % 2 != 0:
			ans += 2 ** i

	print(ans)

if __name__ == '__main__':
	main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
import bisect
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	A = getlist()
	B = getlist()
	ans = 0
	for i in range(30):
		Aex = [A[j] % (2 ** (i + 1)) for j in range(N)]
		Bex = [B[j] % (2 ** (i + 1)) for j in range(N)]
		Bex.sort()
		cnt = 0
		for j in range(N):
			var = Aex[j]
			if var <= 2 ** i:
				cnt += bisect.bisect_left(Bex, 2 ** (i + 1) - var) - (bisect.bisect_left(Bex, 2 ** i - var))
			else:
				cnt += bisect.bisect_left(Bex, 2 ** (i + 1) - var)
				cnt += N - bisect.bisect_left(Bex, 2 ** (i + 1) + 2 ** i - var)
		# print(Aex)
		# print(Bex)
		# print(cnt)
		if cnt % 2 != 0:
			ans += 2 ** i

	print(ans)

if __name__ == '__main__':
	main()

Fixed submission:
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
import bisect
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	A = getlist()
	B = getlist()
	ans = 0
	for i in range(29):
		mul = 2 ** (i + 1)
		mul2 = 2 ** i
		Aex = [A[j] % mul for j in range(N)]
		Bex = [B[j] % mul for j in range(N)]
		Aex.sort()
		Bex.sort()
		cnt = 0
		p, q, r = N - 1, N - 1, N - 1
		for j in range(N):
			var = Aex[j]
			while p >= 0 and mul2 - var <= Bex[p]:
				p -= 1
			while q >= 0 and mul - var <= Bex[q]:
				q -= 1
			while r != 0 and mul + mul2 - var <= Bex[r]:
				r -= 1
			cnt += q - p
			cnt += N - 1 - r
			
			# if var <= 2 ** i:
			# 	cnt += bisect.bisect_left(Bex, mul - var) - (bisect.bisect_left(Bex, mul2 - var))
			# else:
			# 	cnt += bisect.bisect_left(Bex, mul - var)
			# 	cnt += N - bisect.bisect_left(Bex, mul + mul2 - var)
		# print(Aex)
		# print(Bex)
		# print(cnt)
		if cnt % 2 != 0:
			ans += 2 ** i

	print(ans)

if __name__ == '__main__':
	main()