Problem:
 Score : 500 points    Problem Statement There are N Snuke Cats numbered 1, 2, \ldots, N , where N is even .  Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.  Recently, they learned the operation called xor (exclusive OR).   What is xor?  For n non-negative integers x_1, x_2, \ldots, x_n , their xor, x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is defined as follows:  When x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is written in base two, the digit in the 2^k 's place ( k \geq 0 ) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k 's place is odd, and 0 if that count is even.  For example, 3~\textrm{xor}~5 = 6 .   They wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.  We know that the xor calculated by Snuke Cat i , that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i .
Using this information, restore the integer written on the scarf of each Snuke Cat.      Constraints  All values in input are integers.  2 \leq N \leq 200000  N is even .  0 \leq a_i \leq 10^9  There exists a combination of integers on the scarfs that is consistent with the given information.         Input Input is given from Standard Input in the following format:  N  a_1  a_2  \ldots  a_N       Output Print a line containing N integers separated with space.  The i -th of the integers from the left should represent the integer written on the scarf of Snuke Cat i .  If there are multiple possible solutions, you may print any of them.        Sample Input 1 4
20 11 9 24      Sample Output 1 26 5 7 22   5~\textrm{xor}~7~\textrm{xor}~22 = 20  26~\textrm{xor}~7~\textrm{xor}~22 = 11  26~\textrm{xor}~5~\textrm{xor}~22 = 9  26~\textrm{xor}~5~\textrm{xor}~7 = 24   Thus, this output is consistent with the given information.

Solution (Python):
n = int(input())
a_list = list(map(int,input().split()))

tmp = a_list[0]
for i in range(1,len(a_list)):
    tmp = tmp ^ a_list[i]
    
ans_list = []
for i in a_list:
    ans_list.append(i ^ tmp)
print(*ans_list)

Solution (Python):
n = int(input())
l = list(map(int,input().split()))
x = 0
for i in l:
    x = x ^ i

for i in range(n):
    if i != n-1:
        print(l[i]^x, end = ' ')
    else:
        print(l[i]^x)

Solution (Python):


import sys
import math
import itertools
import collections

def solve(N,A) -> None:
    total = 0
    for a in A:
        total ^= a
    for a in A:
        print(total ^ a,end=" ")
    print()

def main():
    N = int(input())
    A = list(map(int,input().split()))
    
    solve(N,A)

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
A = list(map(int, input().split()))

xor = 0
for a in A:
  xor ^= a

ans = [a ^ xor for a in A]

print(*ans)

Solution (Python):
from functools import reduce

N = int(input())
*A, = map(int, input().split())
S = reduce(lambda x, y: x^y, A)
ans = [S ^ a for a in A]
print(*ans)

Solution (Python):

n, *a = map(int, open(0).read().split())
s = 0
for A in a:s^=A
print(*[s^B for B in a])

Solution (Python):
def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    from functools import reduce
    s = reduce(lambda x, y: x ^ y, A, 0)
    X = [s^a for a in A]
    print(" ".join(map(str, X)))
 
 
if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10000)
    main()

Solution (Python):
N=int(input())
a=list(map(int,input().split()))

tmp=a[0]
for i in range(1,N):
    tmp=tmp^a[i]

for i in range(N):
    print(tmp^a[i],end=" ")

Solution (Python):
n=int(input())
A=list(map(int,input().split()))

t=0
for a in A:
    t=t^a
for a in A:
    print(t^a,end=" ")

Solution (Python):
def e_red_scarf():
    N = int(input())
    A = [int(i) for i in input().split()]

    total = 0
    for a in A:
        total ^= a
    ans = [a ^ total for a in A]
    return ' '.join(map(str, ans))

print(e_red_scarf())

Solution (Python):
x=int(input())
l=list(map(int,input().split()))
a=l[0]
for i in range(1,x):
	a=a^l[i]
for i in l:
	print(a^i,end=" ")

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]

W = 0
for a in A:
    W = W ^ a

ans = []
for a in A:
    ans.append(W ^ a)
print(*ans)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))

if N == 2:
    print(*a[::-1])
else:
    product = a[0]
    for i in range(N):
        if i == 0:
            product = a[i]
        else:
            product = product ^ a[i]
    ans = []
    for i in range(N):
        product = product ^ a[i]
        ans.append(product)
        product = product ^ a[i]
    print(*ans)

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()
b = 0
for i in a:
    b ^= i

for i in range(n):
    a[i] ^= b

print(*a)

Solution (Python):
n=int(input())
a=[int(j)for j in input().split()]
x=0
for i in a:x^=i
print(*[x^i for i in a])

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
SUM = [0 for _ in range(32)]
for i in range(N):
    for j in range(32):
        SUM[j] += ((A[i] >> j) & 1)
for i in range(32):
    SUM[i] %= 2
res = [0 for _ in range(N)]
for i in range(N):
    for j in range(32):
        res[i] += ((((A[i] >> j) & 1) ^ SUM[j]) << j)
for i in range(N):
    print(res[i], end = ' '*(i!=(N-1)))
print()

Solution (Python):
N,*a = map(int, open(0).read().split())
m = N % 4
xs = 0
for x in a:
    xs ^= x
ans = []
for y in a:
    ans.append(xs^y)
print(*ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
xor = A[0]
for i in range(1, len(A)):
    xor = xor^A[i]
ans = []
for ai in A:
    ans += [xor^ai]
print(' '.join(list(map(str, ans))))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

master = a[0]

for i in range(1, n):
    master ^= a[i]

for i in a:
    print(i ^ master, end=" ")
print()

Solution (Python):
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()
A = rl()

s = 0
for a in A:
	s ^= a
ans = []
for a in A:
	ans.append(s^a)
print(*ans)

Solution (Python):
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))



def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) 
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    


MOD = 10**9 + 7
INF = 2**31  

from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  
from math import gcd

N = read_a_int()
A = read_ints()



S = 0
for a in A:
    S ^= a

ans = []
for a in A:
    ans.append(S ^ a)
print(*ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
total = [0] * 31
for i in a:
    for j in range(31):
        if i >> j & 1:
            total[j] += 1

for i in a:
    ans = 0
    for j in range(31):
        if total[j] % 2 != (i >> j & 1):
            ans += 2 ** j
    print(ans, end=" ")
print()

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
x = A[0]
for a in A[1:]:
  x ^= a
  
ans = [0] * N
for i in range(N):
  ans[i] = x ^ A[i]
  
print(' '.join(list(map(str, ans))))

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  
def LS2(): return list(sys.stdin.readline().rstrip())  

N = I()
a = LI()

x = 0
for i in range(N):
    x = x ^ a[i]
ANS = [0]*N
for i in range(N):
    ANS[i] = a[i] ^ x

print(*ANS)

Solution (Python):
import sys

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().strip().split()))

all_xor = 0
for a_i in A:
    all_xor ^= a_i

ans = []
for a_i in A:
    ans.append(all_xor ^ a_i)

print(*ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

rec = [0] * n

def check(k):
    off = []
    on = []
    flag = 0
    for i in range(n):
        if (a[i]>>k)&1:
            flag += 1
            on.append(i)
        else:
            off.append(i)

    if flag%2 == 0:
        for i in on:
            rec[i] += pow(2, k)
    else:
        for i in off:
            rec[i] += pow(2, k)

for i in range(31):
    check(i)
print(*rec)

Solution (Python):
N = int(input())
A = [int(a) for a in input().split()]
xor_sum = 0
for a in A:
    xor_sum ^= a

ans = [0] * N
for i, a in enumerate(A):
    ans[i] = xor_sum ^ a

print(" ".join(str(a) for a in ans))

Solution (Python):
from functools import reduce

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

c = []
for i in range(0, n, 2):
    diff = a[i] ^ a[i+1]
    c.append(diff)
all_xor = reduce(lambda x, y: x^y, c)
ans = []
for i in a:
    current = all_xor^i
    ans.append(current)
print(*ans)

Solution (Python):

import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip() 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))


def main():
    n = ni()
    a = na()
    s = a[0]
    for i in range(1,n):
        s = s^a[i]
    print(' '.join(list(map(str,[s^a[i] for i in range(n)]))))
    return


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
li_a = list(map(int, input().split()))
sum_ = 0
for i in li_a:
    sum_ = sum_ ^ i
for i in li_a:
    k = sum_ ^ i
    print(k)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

t = 0
for i in range(1, n):
    t ^= a[i]

ans = [0 for _ in range(n)]
ans[0] = t
for i in range(1, n):
    ans[i] = ans[i-1]^a[i-1]^a[i]

print(*ans)

Solution (Python):
from functools import reduce
N = int(input())
a = [int(x) for x in input().split()]
s = reduce(lambda x, y : x ^ y, a)
ans = [str(s ^ a[i]) for i in range(N)]
print(" ".join(ans))

Solution (Python):
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    N = II()
    A = LMIIS()
    allxor = A[0]
    for i in range(1,N):
        allxor ^= A[i]
    ans = [0] * N
    for i in range(N):
        ans[i] = allxor ^ A[i]
    print(*ans)

    
main()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = a[0]


for i in range(1, n):
    ans ^= a[i]

for i in range(n):
    print(ans^a[i], end="")
    print(" ", end="")

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

b = 0
for i in range(n):
    b^=a[i]

ans = [a[i]^b for i in range(n)]
print(' '.join(list(map(str, ans))))

Solution (Python):
n = int(input().strip())
A = list(map(int, input().strip().split()))
total=0
for a in A:
    total^=a

for a in A:
    print(total^a)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
x = 0
for a in A:
    x ^= a
ans = [x^a for a in A]
print(*ans)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
x=A[0]
for i in range(1,N):
    x=x^A[i]
for i in range(N):
    x=x^A[i]
    print(x)
    x=x^A[i]

Solution (Python):

import sys
def main(N, A):
    L = [0] * N
    R = [0] * N
    for i in range(1, N):
        L[i] = L[i - 1] ^ A[i - 1]
    for i in range(N - 2, -1, -1):
        R[i] = R[i + 1] ^ A[i + 1]
    ans = [L[i] ^ R[i] for i in range(N)]
    print(*ans)

if __name__ == '__main__':
    input = sys.stdin.readline
    N = int(input())
    *A, = map(int, input().split())
    main(N, A)

Solution (Python):


N = int(input())
A = list(map(int, input().split()))

s = A[0]

for a in A[1:]:
    s ^= a

ret = []

for a in A:
    ret.append(s^a)

print(' '.join(map(str, ret)))

Solution (Python):
import functools

n = int(input())
a = [int(i) for i in input().split()]

xorAll = functools.reduce(lambda x, y: x ^ y, a)
for i in a:
    print(i ^ xorAll)

Solution (Python):
import sys
from collections import deque
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    all = 0
    for a in A: all ^= a

    ans = [all ^ a for a in A]
    print(" ".join(map(str, ans)))



if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

all = A[0]
for a in A[1:]:
    all = all ^ a

list_a = [all ^ a for a in A]
print(*list_a)

Solution (Python):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    
    xor_all = A[0]
    for a in A[1:]:
        xor_all ^= a

    print()
    for a in A:
        print(a ^ xor_all)

main()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))



suma=0
for aa in a:
    suma=suma^aa
    
ans=[]
for aa in a:
    ans.append(str(suma^aa))

print(" ".join(ans))

Solution (Python):
n = int(input())

ans = 0
a = list(map(int, input().split()))
for i in a:
    ans ^= i
final = []
for i in a:
    final.append(ans ^ i)
print(" ".join(list(map(str, final))))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

al = 0
for i in range(N):
  al = al ^ A[i]
  


for i in range(N):
  print(al ^ A[i])

Solution (Python):
n=int(input())
a=[0]*n
a=list(map(int,input().split()))
ans=[0]*n
check=0
for i in range(n):
    check=check^a[i]
for i in range(n):
    ans[i]=check^a[i]
    
ans=[str(a) for a in ans]
ans=" ".join(ans)
print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    ans ^= a[i]
for i in range(n):
    print(ans^a[i], end=' ')
print()
"""
for i in range(n):
    ans = 0
    for j in range(n):
        if i != j:
            ans ^= a[j]
    print(ans)
"""

Solution (Python):
N=int(input())
ls=[int(s) for s in input().split()]
x=0
for e in ls:
  x=x^e
ans=[0 for _ in range(N)]
for i in range(N):
  ans[i]=x^ls[i]
print(*ans)

Solution (Python):
n = int(input())
a = [int(e) for e in input().split()]

total_xor = 0
for e in a:
    total_xor ^= e

for i in range(n):
    a[i] ^= total_xor

print(' '.join(map(str, a)))

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
tot = l[0]
for i in range(1,n):
    tot ^= l[i]
for i in range(n):
    print(tot^l[i], end = ' ')
print()

Solution (Python):
N = int(input())
l = list(map(int, input().split()))

b = 0
for v in l:
    b = b ^ v
ans = []
for v in l:
    ans.append(v^b)
print(*ans)

Solution (Python):
n=int(input())
nums=[int(x) for x in input().split()]

s=0
for i in nums:
  s=s^i

for i in nums:
    print(s^i,end=' ')

Solution (Python):
n=int(input())
A=list(map(int,input().split()))
x=0
for a in A:
    x^=a
print(*[x^a for a in A])

Solution (Python):
import re
def main():
    n = int(input())
    A = list(map(int,input().split()))
    xor = A[0]
    for a in A[1:]:
        xor = xor^a
    Ans = []
    for a in A:
        Ans.append(a^xor)
    print(*Ans, sep=" ")
    return 

if __name__ == "__main__":
    main()

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
cum=[0]*(N+1)
for i in range(N):
    cum[i+1]=cum[i]^a[i]

ans=[]
for i in range(N):
    r=cum[N]^cum[i]
    l=cum[i]
    ans.append(r^l^a[i])
print(*ans)

Solution (Python):
n=int(input())
arr = list(map(int,input().split()))
t=0
for i in range(int(n/2)):
    t^=arr[i]^arr[n-i-1]
    
for i in range(n):
    t2 = t^arr[i]
    print(t2,end=" ")
print()

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
xor = 0
for a in A:
    xor ^= a
for a in A:
    print(xor ^ a)

Solution (Python):
n = int(input())
arr = [int(x) for x in input().split()]

xor = 0

for x in arr:
    xor = xor ^ x

result = []

for i in range(n):
    result.append(str(xor ^ arr[i]))

print(" ".join(result))

Solution (Python):
from math import *
from collections import *
from itertools import *
from bisect import *
from heapq import *
from operator import *
from sys import *
setrecursionlimit(100000000)


n=int(input())
l=list(map(int,input().split()))
x=0
for i in l:
   x^=i
ans=[x^y for y in l]
print(*ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

def to_bit(n):
    print(bin(n))

x = 0
for a in A:
    x = x^a
    

res = []
for a in A:
    res.append(x^a)

print(" ".join(map(str, res)))

Solution (Python):





import math
import fractions
import sys
import bisect
import heapq  
import collections
from collections import Counter
from collections import deque
import pprint

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr



def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod



def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
a = lr()
dp = [0 for i in range(32)]
for num in a:
    for j in range(32):
        if ((num >> j) & 1):
            dp[j]+=1
ans = []
for num in a:
    judge = []
    for j in range(32):
        if ((num >> j) & 1):
            judge.append((dp[j]+1)%2)
        else:
            judge.append((dp[j]) % 2)
    tmp = 0
    for i,num in enumerate(judge):
        if num == 1:
            tmp+=power(2,i,mod)
    ans.append(tmp)
print(*ans,sep=' ')

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]





N = ii()
A = li()

wa = 0
for num in A:
    wa ^= num
    

for num in A:
    print(wa^num, end = '')
    print(' ', end = '')

print()

Solution (Python):
n = int(input())

arr = list(map(int, input().split()))

all_xor = arr[0]

for i in range(1, n):
	all_xor ^= arr[i]

res = [0 for i in range(n)]

for i in range(n):
	res[i] = all_xor ^ arr[i]

print(" ".join(list(map(str, res))))

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter











import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

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

n = I()
A = readInts()
ans = []
SUM = 0
for i in range(n):
    SUM ^=A[i]
for i in range(n):
    ans.append(SUM^A[i])
print(*ans)

Solution (Python):

import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()

a = LIST()

xorTot = 0
for el in a:
    xorTot^=el

ans = []

for el in a:
    ans.append(el^xorTot)
print(*ans)

Solution (Python):
N = int(input())
As = list(map(int, input().split()))

al = 0
for a in As:
  al ^= a
  
rlt = []
for a in As:
  tmp = al ^ a
  rlt.append(tmp)

print(" ".join(map(str, rlt)))

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
S = A[0]
for i in range(1,N):
    S = S^A[i]
out = []
for i in range(N):
    out.append(S^A[i])
print(*out)

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
"""
全員が自分以外の全員のxorを把握しているので、全員の値を求めよ
nは偶数

"""
n = int(readline())
lst1 = list(map(int,readline().split()))
limit = 33
ans = []
parity = [0]*limit
for i in lst1:
    for j in range(limit):
        parity[j] += i>>j

for i in range(limit):
    parity[i] %= 2

for i in lst1:
    res = 0
    for j in range(limit):
        p = i>>j&1
        if parity[j]== 0 and p== 1:
            res += 1<<j
        elif parity[j] == 1 and p == 0:
            res += 1<<j
    ans.append(res)
print(*ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

N = int(input())
A = list(map(int,input().split()))

total = 0
for a in A:
    total ^= a

ans = []
for a in A:
    ret = total ^ a
    ans.append(ret)
print(*ans)

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n = int(input())
a = [int(x) for x in input().split()]
total = 0
for i in a:
    total ^= i
ans = []
for i in a:
    ans.append(total^i)
print(*ans)

Solution (Python):
n=int(input())
arr=[int(i) for i in input().split()]
xor=0 
for x in arr:
    xor^=x 
for x in arr:
    curr=xor^x 
    print(curr,end=' ')

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
all = 0
for a in A:
    all ^= a

ans = ""

for a in A:
    ans += str(a^all) + " "

print(ans)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(0,n,2):
  b.append(a[i]^a[i+1])
bs = 0
for i in range(len(b)):
  bs ^= b[i]

ans = []
for i in range(n//2):
  bt = bs^b[i]
  ans.append(a[i*2+1]^bt)
  ans.append(a[i*2]^bt)
print(*ans)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
B = []
k = 0
for i in range(1, N):
    k ^= A[i]
B.append(k)
for i in range(1, N):
    B.append(B[-1] ^ A[i] ^ A[i-1])

print(*B)

Solution (Python):


import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
from operator import xor
from functools import reduce

def resolve():
    it = map(int, sys.stdin.read().split())
    N = next(it)
    A = list(it)
    x1 = reduce(xor, A)

    print(*map(lambda x: x ^ x1, A))


if __name__ == "__main__":
    resolve()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
s=0
res=list()
for i in range(n):
    s^=a[i]
for i in range(n):
    res.append(s^a[i])
for i in range(n):
    print(res[i],end=" ")

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
key=0
for i in a:
  key=key^i
for i in a:
  print(key^i,end=' ')

Solution (Python):
N = int(input())
a = list(map(int, input().split()))

S = 0
for i in range(N):
  S = S^a[i]

for j in range(N):
  print(S^a[j])

Solution (Python):
from functools import reduce

N = int(input())
a = list(map(int, input().split()))

X = reduce(lambda x, y: x ^ y, a)
ans = [ai ^ X for ai in a]
print(' '.join(list(map(str, ans))))

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
import math
import bisect
from collections import deque
def input():
    return sys.stdin.readline()[:-1]

n = int(input())
a = list(map(int,input().split()))
su = a[0]
for i in range(1,n):
    su = su^a[i]

lis = []

for i in range(n):
    lis.append(su^a[i])

print(*lis)

Solution (Python):
n,*a=map(int,open(0).read().split())
b=0
for i in a:
    b^=i
c=[b^i for i in a]  
print(*c)

Solution (Python):
import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
n=N()
l=L()
sx=0
for i in l:
    sx^=i
ans=[]
for i in l:
    ans.append(sx^i)
print(" ".join(map(str,ans)))

Solution (Python):
from functools import reduce


N = int(input())
A = list(map(int, input().split()))
base = reduce(lambda x, y: x ^ y, A)
print(*[base ^ A[i] for i in range(N)])

Solution (Python):
N = int(input())
arr = list(map(int, input().split()))
ans = arr[-1]
for i in range(1,N):
    ans ^= arr[N-1-i]
ans_arr = [0]*N
for i in range(N):
    ans_arr[i] = ans^arr[i]
print(*ans_arr)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    ans = A[0]
    for a in A[1:]:
        ans ^= a

    for a in A:
        print(a ^ ans, end=" ")


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

x = [0]*30
for a in A:
    for i in range(30):
        if (a>>i) & 1:
            x[i] += 1

f = 0
for i in range(30):
    if x[i]%2 == 1:
        f ^= (1<<i)

for i in range(N):
    A[i] ^= f

print(" ".join([str(a) for a in A]))

Solution (Python):
N=int(input())
A=list(map(int, input().split()))
"""
20 10100 11010
11 01011 00101
9  01001 00111
24 11000 10110
"""
for i in range(N):
    if i==0:
        now=A[0]
    else:
        now=now^A[i]
for i in range(N):
    ans=now^A[i]
    print(ans, end=" ")

Solution (Python):
n = int(input())
dat = list(map(int, input().split()))
res = []
x = 0
for i in range(n):
    x = x ^ dat[i]
for i in range(n):
    res.append(str(x^dat[i]))
print(" ".join(res))

Solution (Python):

import sys


def solve(N: int, a: "List[int]"):
    all_a = a[0]
    for ai in a[1:]:
        all_a = all_a ^ ai
    ans = []
    for ai in a:
        ans.append(all_a^ai)
    print(*ans)
    
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    a = [int(next(tokens)) for _ in range(N)]  
    solve(N, a)

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
tmp = A[0]

for i in range(1, len(A)):
    tmp = tmp ^ A[i]
    
for i in A:
    print(tmp ^ i, end=' ')
print()

Solution (Python):
N = int(input())
A = [int(hoge) for hoge in input().split()]
cur = A[0]
for n,a in enumerate(A):
    if n:
        cur = cur ^ a
ans = []
for a in A:
    ans.append(cur ^ a)
print(*ans)

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    total = 0
    for a in A:
        total ^= a

    ans = [0] * N

    for i,a in enumerate(A):
        ans[i] = total^a

    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()

Solution (Python):

import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def fact(N):
        res = {}
        tmp = N
        for i in range(2, int(N ** 0.5 + 1) + 1):
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if cnt > 0:
                res[i] = cnt
        if tmp != 1:
            res[tmp] = 1
        if res == {}:
            res[N] = 1
        return res


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N = Scanner.int()
    A = Scanner.map_int()
    S = 0
    for a in A:
        S ^= a
    B = [0 for _ in range(N)]
    for i in range(N):
        B[i] = S ^ A[i]
    print(*B)


def main():
    
    
    
    
    
    solve()


if __name__ == "__main__":
    main()

Solution (Python):
from functools import reduce

N = int(input())
arr = list(map(int, input().split()))

tot_xor = reduce(lambda x, y: x ^ y, arr)
print(" ".join(list(map(str, [tot_xor ^ i for i in arr]))))

Solution (Python):
def main():
    N = int(input())
    a_list = list(map(int, input().split()))
    BITS = 30
    sum_bit = [0] * BITS
    a_bits = []

    for a in a_list:
        bits = [a>> j & 1 for j in range(BITS)]
        for i, bit in enumerate(bits):
            sum_bit[i] += bit
        a_bits.append(bits)

    for a_bit in a_bits:
        
        res = 0
        cur = 1
        for i in range(BITS):
            res += cur if (a_bit[i] + sum_bit[i])%2 == 1 else 0
            cur *= 2
        print(res, end=" ")

if __name__ == "__main__":
    main()