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

# 入力
n = int(sdin())
a = list(map(int, sdin().split()))
b = list(map(int, sdin().split()))

ans = 0

# k-th bitについて
for k in range(29):
    base = 2**k
    a_k = [ai % 2**(k+1) for ai in a]
    b_k = [bj % 2**(k+1) for bj in b]
    b_k.sort()
    
    one = 0
    for ai in a_k:
        first = bisect_left(b_k, 2*base - ai) - bisect_left(b_k, 1*base - ai)
        second =  bisect_left(b_k, 4*base - ai) - bisect_left(b_k, 3*base - ai)
        
        one += (first + second)
        
    if one % 2 == 1:
        ans += 2**k
        
print(ans)

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


# 入力
n = int(sdin())
a = list(map(int, sdin().split()))
b = list(map(int, sdin().split()))

ans = 0

# バケットソートする
for k in range(29):
    a_nex = [[],[]]
    b_nex = [[],[]]
    for ai in a:
        a_nex[(ai & (1<<k)) >> k].append(ai)
            
    for bj in b:
        b_nex[(bj & (1<<k)) >> k].append(bj)
    

    a = []
    b = []
    for i in range(2):
        a = a + a_nex[i]
        b = b + b_nex[i]
        
    mask = pow(2,k+1) - 1
    a_mask = [ai & mask for ai in a]
    b_mask = [bj & mask for bj in b]
    
    base = pow(2,k)
    itr = [n]*4
    count = 0
    for ai in a_mask:
        border = [
                base - ai,
                2*base - ai,
                3*base - ai,
                4*base - ai
        ]
        
        for i in range(4):
            while 0 < itr[i] and border[i] <= b_mask[itr[i] - 1]:
                itr[i] -= 1
            
            
        count += ((itr[1] - itr[0]) + (itr[3]) - itr[2])
    
    if count & 1:
        ans += base
    
    
print(ans)

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

# 入力
n = int(sdin())
a = list(map(int, sdin().split()))
b = list(map(int, sdin().split()))

ans = 0

# k-th bitについて
for k in range(29):
    base = 2**k
    a_k = [ai % 2**(k+1) for ai in a]
    b_k = [bj % 2**(k+1) for bj in b]
    b_k.sort()
    
    one = 0
    for ai in a_k:
        first = bisect_left(b_k, 2*base - ai) - bisect_left(b_k, 1*base - ai)
        second =  bisect_left(b_k, 4*base - ai) - bisect_left(b_k, 3*base - ai)
        
        one += (first + second)
        
    if one % 2 == 1:
        ans += 2**k
        
print(ans)

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


# 入力
n = int(sdin())
a = list(map(int, sdin().split()))
b = list(map(int, sdin().split()))

ans = 0

# バケットソートする
for k in range(29):
    a_nex = [[],[]]
    b_nex = [[],[]]
    for ai in a:
        a_nex[(ai & (1<<k)) >> k].append(ai)
            
    for bj in b:
        b_nex[(bj & (1<<k)) >> k].append(bj)
    

    a = []
    b = []
    for i in range(2):
        a = a + a_nex[i]
        b = b + b_nex[i]
        
    mask = pow(2,k+1) - 1
    a_mask = [ai & mask for ai in a]
    b_mask = [bj & mask for bj in b]
    
    base = pow(2,k)
    itr = [n]*4
    count = 0
    for ai in a_mask:
        border = [
                base - ai,
                2*base - ai,
                3*base - ai,
                4*base - ai
        ]
        
        for i in range(4):
            while 0 < itr[i] and border[i] <= b_mask[itr[i] - 1]:
                itr[i] -= 1
            
            
        count += ((itr[1] - itr[0]) + (itr[3]) - itr[2])
    
    if count & 1:
        ans += base
    
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a_list = [int(i) for i in input().split()]
b_list = [int(i) for i in input().split()]
 
sum_xor = 0
for a in a_list:
    for b in b_list:
        sum_xor ^= a + b
 
print(sum_xor)    

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


# 入力
n = int(sdin())
a = list(map(int, sdin().split()))
b = list(map(int, sdin().split()))

ans = 0

# バケットソートする
for k in range(29):
    a_nex = [[],[]]
    b_nex = [[],[]]
    for ai in a:
        a_nex[(ai & (1<<k)) >> k].append(ai)
            
    for bj in b:
        b_nex[(bj & (1<<k)) >> k].append(bj)
    

    a = []
    b = []
    for i in range(2):
        a = a + a_nex[i]
        b = b + b_nex[i]
        
    mask = pow(2,k+1) - 1
    a_mask = [ai & mask for ai in a]
    b_mask = [bj & mask for bj in b]
    
    base = pow(2,k)
    itr = [n]*4
    count = 0
    for ai in a_mask:
        border = [
                base - ai,
                2*base - ai,
                3*base - ai,
                4*base - ai
        ]
        
        for i in range(4):
            while 0 < itr[i] and border[i] <= b_mask[itr[i] - 1]:
                itr[i] -= 1
            
            
        count += ((itr[1] - itr[0]) + (itr[3]) - itr[2])
    
    if count & 1:
        ans += base
    
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

def xor(a,b):
    return a^b

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

#2. conduct a+b
sum_list = []
for a_i in a:
    for b_j in b:
        sum_list.append(a_i+b_j)

#3. calculate xor
ans = reduce(xor, sum_list)
print(ans)

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


# 入力
n = int(sdin())
a = list(map(int, sdin().split()))
b = list(map(int, sdin().split()))

ans = 0

# バケットソートする
for k in range(29):
    a_nex = [[],[]]
    b_nex = [[],[]]
    for ai in a:
        a_nex[(ai & (1<<k)) >> k].append(ai)
            
    for bj in b:
        b_nex[(bj & (1<<k)) >> k].append(bj)
    

    a = []
    b = []
    for i in range(2):
        a = a + a_nex[i]
        b = b + b_nex[i]
        
    mask = pow(2,k+1) - 1
    a_mask = [ai & mask for ai in a]
    b_mask = [bj & mask for bj in b]
    
    base = pow(2,k)
    itr = [n]*4
    count = 0
    for ai in a_mask:
        border = [
                base - ai,
                2*base - ai,
                3*base - ai,
                4*base - ai
        ]
        
        for i in range(4):
            while 0 < itr[i] and border[i] <= b_mask[itr[i] - 1]:
                itr[i] -= 1
            
            
        count += ((itr[1] - itr[0]) + (itr[3]) - itr[2])
    
    if count & 1:
        ans += base
    
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

def xor(a,b):
    return a^b


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

#2. conduct a+b
sum_list = []
for a_i in a:
    for b_j in b:
        sum_list.append(a_i+b_j)

#3. convert decimal into binary
sum_list_bin = [bin(sum_list_dec) for sum_list_dec in sum_list]

#4. calculate xor
ans = reduce(xor, sum_list)
print(ans)

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


# 入力
n = int(sdin())
a = list(map(int, sdin().split()))
b = list(map(int, sdin().split()))

ans = 0

# バケットソートする
for k in range(29):
    a_nex = [[],[]]
    b_nex = [[],[]]
    for ai in a:
        a_nex[(ai & (1<<k)) >> k].append(ai)
            
    for bj in b:
        b_nex[(bj & (1<<k)) >> k].append(bj)
    

    a = []
    b = []
    for i in range(2):
        a = a + a_nex[i]
        b = b + b_nex[i]
        
    mask = pow(2,k+1) - 1
    a_mask = [ai & mask for ai in a]
    b_mask = [bj & mask for bj in b]
    
    base = pow(2,k)
    itr = [n]*4
    count = 0
    for ai in a_mask:
        border = [
                base - ai,
                2*base - ai,
                3*base - ai,
                4*base - ai
        ]
        
        for i in range(4):
            while 0 < itr[i] and border[i] <= b_mask[itr[i] - 1]:
                itr[i] -= 1
            
            
        count += ((itr[1] - itr[0]) + (itr[3]) - itr[2])
    
    if count & 1:
        ans += base
    
    
print(ans)