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):
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	n = I()
	a_list = LI()
	a_xor = a_list[0]
	for a in a_list[1:]:
		a_xor = a ^ a_xor
	for a in a_list:
		print(a_xor ^ a)



if __name__ == '__main__':
    main()

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

for i in range(N):
    if i == 0:
        X = int(a[i])
    else:
        X = X ^ int(a[i])

ans = []

for i in a:
    ans.append(str(X ^ int(i)))

print(' '.join(ans))

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

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

ans1 = [str(a) for a in ans]
print(" ".join(ans1))

Solution (Python):
import numpy as np

n=int(input())
a = np.array(list(map(int, input().split())))
ans = np.array([0]*n)
c=0
while (a>0).any():
    ama = a%2
    a=(a-ama)//2

    if sum(ama)%2==1:
        ama = (ama+1)%2
    ans += ama*(2**c)
    c+=1

ans=ans.tolist()    
print(*ans)

Solution (Python):
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    xor = 0
    for i in range(n):
        xor =a[i] ^xor
    ans = []
    for i in range(n):
        ans.append(xor ^a[i])

    print(*ans)

resolve()

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

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




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

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

s = 0

for a in a_s:
    s = s ^ a

print(' '.join([ str(s ^ a) for a in a_s ]))

Solution (Python):
from functools import reduce

def problem():
  N = int(input())
  xs = [int(x) for x in input().split()]
  t = reduce(lambda acc, elem: acc ^ elem, xs)

  for i in range(N):
    yield (t ^ xs[i])

print(*problem())

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

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



tot = 0

for a in aa:
    tot ^= a



print(*[tot^a for a in aa])

Solution (Python):
import sys
from typing import Callable, List, NoReturn

import numpy as np


def main() -> NoReturn:
    readline: Callable[[], str] = sys.stdin.readline
    n: int = int(readline().rstrip())
    a: np.ndarray = np.array(tuple(int(_) for _ in readline().rstrip().split()))

    xor_all: int = 0
    for a_n in a:
        xor_all ^= a_n

    values = np.bitwise_xor(a, xor_all)
    print(" ".join(tuple(str(v) for v in  values)))


if __name__ == '__main__':
    main()

Solution (Python):
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

def main():
    n = int(input())
    alis = list(map(int, input().split()))
    a = alis[0] ^ alis[1]
    for i in range(2, len(alis)):
        a = a^alis[i]
    ans = []
    for num in alis:
        ans.append(str(a^num))
    print(' '.join(ans))

    
    
if __name__ == "__main__":
    main()

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

max_digit = 0
for i in range(N):
    a[i] = bin(a[i])[2:][::-1]
    max_digit = max(max_digit, len(a[i]))
    
for i in range(N):
    l = '0'*(max_digit-len(a[i]))
    a[i] += l
    a[i] = a[i][::-1]

digits = [0]*max_digit    
for i in range(max_digit):
    for j in range(N):
        if a[j][i] == '1':
            digits[i] += 1
    digits[i] %= 2

ans = ['']*N
for i in range(N):
    num = a[i]
    for j in range(max_digit):
        ans[i] += str((int(num[j]) + digits[j]) % 2)
    ans[i] = str(int(ans[i],2))
        
ans = ' '.join(ans)

print(ans)

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

maxA = max(A)
maxl = len(bin(maxA)[2:])
binary_c = [0 for _ in range(maxl)]
A_binary = [bin(a)[2:].zfill(maxl) for a in A]
for a in A_binary:
    for i, n in enumerate(a):
        if n == "1":
            binary_c[i] += 1
is_inv = []
for bc in binary_c:
    if bc % 2 == 0:
        is_inv.append(False)
    else:
        is_inv.append(True)

for a in A_binary:
    l = []
    for i, n in enumerate(a):
        if is_inv[i]:
            if n == "0":
                l.append("1")
            else:
                l.append("0")
        else:
            l.append(n)
    print(int("".join(l), 2))

Solution (Python):
import math  
from typing import Dict, List, Optional, Tuple, Union  


def sum_xor(A: List[int]) -> int:
    sum_ = 0
    for a in A:
        sum_ ^= a
    return sum_


def main(N: int, A: List[int]):
    sum_ = sum_xor(A)
    for a in A:
        print(a ^ sum_, end=" ")
    print()


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    main(N, A)

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

sum = As[0]
for i in range(1,N):
    sum = sum ^ As[i]



for i in range(N):
    v = sum ^ As[i]
    print(v, end = ' ')

Solution (Python):
n = int(input())
a = list(map(int , input().split()))
b = []
for ai in a:
    b.append('{:0=30b}'.format(ai))

cnt = []
for j in range(30):
    tmp = 0
    for i in range(n):
        tmp += int(b[i][j])
    cnt.append(tmp)
ans = []
for bi in b:
    tmp = 0
    for i in range(30):
        idx = 29 + (-i)
        
        x = int(bi[i])
        if cnt[i] == 0:
            continue
        if cnt[i] % 2 == 0:
            tmp += x << idx
        else:
            if x == 0:
                tmp += 1 << idx
    ans.append(tmp)



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

"""
0000010100
0000001011
0000001001
0000011000

0000011010
0000000101
0000000111
0000010110
"""

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

    total = 0
    for i in a:
        total ^= i
    
    ans = ""
    for i in a:
        ans += "{} ".format(total ^ i)
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
ans=[]
b=a.copy()
del b[0]
a1=0
a2=a[0]
for i in b:
    a1=a1^i
ans.append(a1)
for i in b:
    ansii=a1^i
    ansi=a2^ansii
    ans.append(ansi)

for i in range(n):
    print(ans[i],end=' ')

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))

def resolve():
    N,=pin()
    A=lispin()
    
    left=[0]*N
    left[-2]=A[-1]    

    temp=0
    for i in A:
        temp=temp^i
    left[-1]=temp
    

    left[0]=A[0]^left[-1]
    



    for i in range(1,N-2):
        left[i]=A[i]^left[-1]^left[i-1]
    
    ans=[left[0]]
    for i in range(1,N):
        ans.append(left[i]^left[i-1])
    print(*ans)

resolve()

Solution (Python):
def main():
    n = int(input())
    lst_a = [int(v) for v in input().split()]
    s = 0
    for a in lst_a:
        s ^= a
    lst_b = []
    for a in lst_a:
        lst_b.append(s ^ a)
    for i, b in enumerate(lst_b):
        if i > 0:
            print(' ', end='')
        print(b, end='')
    print()


if __name__ == '__main__':
    main()

Solution (Python):
import collections


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

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

for i in a:
    print(i^A)

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    a = list(map(int, rl().split()))
    
    n = a[0]
    for i in range(1, N):
        n ^= a[i]
    for i in range(N):
        a[i] ^= n
    print(*a)


if __name__ == '__main__':
    solve()

Solution (Python):
n=int(input())
A=list(map(int,input().split()))
ans=[]
sum=0
for a in A:
    sum=sum^a
for a in A:
    ans.append(sum^a)
ans=' '.join(map(str,ans))
print(ans)

Solution (Python):


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

    s = a_lst[0]
    for a in a_lst[1:]:
        s = s ^ a

    ret = []
    for a in a_lst:
        ret.append(s ^ a)

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

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
from functools import reduce
axor = reduce(lambda x,y: x^y, l)
res = []
for i in l:
    res.append(axor^i)
print(' '.join(map(str,res)))

Solution (Python):
import math

n=int(input())
seq=list(map(int,input().split()))
ans=seq[0]
d=[]
for i in range(1,n):
    ans=ans^seq[i]
for i in range(n):
    d.append(seq[i]^ans)
print(*d)

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

s = 0

for i in range(n):
    s = s ^ l[i]

print(*[s^i for i in l])

Solution (Python):
import numpy as np
n = int(input())
a = np.array([int(a) for a in input().split()])






totalxor = a[0]
for i in range(1, len(a)):
  totalxor = totalxor^a[i]

print(' '.join([str(i^totalxor) for i in a]))

Solution (Python):
n = int(input())
alist = list(map(int,input().split()))
asum = 0
for i in range(n):
    asum ^= alist[i]
anslist = []
for i in range(n):
    asum ^= alist[i]
    anslist.append(asum)
    asum ^= alist[i]
for ans in anslist:
    print(ans ,end = ' ')

Solution (Python):
from collections import defaultdict
def main():
    n = int(input())
    A = list(map(int, input().split()))
    d = defaultdict(int)
    for a in A:
        B = list(f'{a:030b}')
        for i, b in enumerate(B):
            if b == '1':
                d[i] += 1
    ANS = []
    for a in A:
        B = list(f'{a:030b}')
        ans = 0
        for i, b in enumerate(B):
            if b == '1':
                k = d[i] - 1
            else:
                k = d[i]
            if k % 2 == 1:
                ans += pow(2, 29 - i)
        ANS.append(str(ans))
    print(' '.join(ANS))





if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
aa = a[0]
for n in a[1:]:
    aa = aa^n
    
for one in a:
    print(aa^one)

Solution (Python):
import numpy as np
n=int(input())
a=np.array(list(map(int,input().split())))
s=np.bitwise_xor.reduce(a)

b=np.bitwise_xor(a,s)
print(" ".join((str(x) for x in b)))

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
k=a[0]
ans=[]
for i in range(1,n):
    k=k^a[i]
for i in range(n):
    ans.append(k^a[i])
print(*ans)

Solution (Python):
import numpy as np
n=int(input())
A=list(map(int,input().split()))
C=A
A=np.array(A)
length=len(format(max(A),"b"))

B=""
for i in range(length):
    cnt=np.count_nonzero(A&1)
    if cnt%2==0:B +="0"
    else:B +="1"
    A >>=1

B=int(B[::-1],2)
D=[]
for i in C:
    D.append(B^i)
print(*D)

Solution (Python):
n = int(input())
a=list(map(int,input().split()))
forward = []
back = []
result = ''
t = 0
for i in range(n):
    t ^= a[i]
    forward.append(t)
t = 0
for i in range(n-1, -1, -1):
    t ^= a[i]
    back.append(t)

for i in range(n):
    if i == 0:
        t = back[n-2]
    elif i == n-1:
        t = forward[n-2]
    else:
        t = forward[i-1] ^ back[n-2-i]
    result += str(t) + ' '

print(result)

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

p = A[0]
for i in range(1, n):
    p ^= A[i]

for i in range(n):
    print(p^A[i])

Solution (Python):
from functools import reduce
n = int(input())
al = list(map(int, input().split()))
ansl = [0]*n
test_list = al
  


  


res = reduce(lambda x, y: x ^ y, test_list) 
  

sum = res
for i in range(n):
    ansl[i] = res^al[i]

"""
for i,youso in enumerate(al):
    for j in range(n):
        if i == j:
            continue
        else:
            ansl[j] ^= youso 

"""
print(' '.join(map(str, ansl)))

Solution (Python):
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    k = max(a).bit_length()
    c = [0] * n
    for i in range(k):
        b = [ai // 2**i % 2 for ai in a]
        if sum(b) % 2:
            b = [1 - bi for bi in b]
        for j in range(n):
            c[j] += b[j] * 2**i
    print(*c)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
AList = list(map(int, input().split()))
RList = []
tmp = 0
tmppoint = 0
for i in range(1, len(AList)):
    tmp = tmp ^ AList[i]

RList.append(tmp)
for p in range(1, len(AList)):
    tmp = tmp ^ AList[tmppoint]
    tmp = tmp ^ AList[p]
    tmppoint = p
    
    RList.append(tmp)

for i in range(len(RList)):
    print(RList[i], end=' ')

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

S = A[0]
for i in range(1, N):
    S = S ^ A[i]





S = [str(S ^ a) for a in A]
print(' '.join(S))

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


m = max(a)
for i in range(100):
    if 2**i>m:
        n = i
        break


mat = []
for j in a:
    b=[1 if j >> i &1 else 0 for i in reversed(range(n))] 
    mat.append(b)


for i in range(n):
    f = [part[i] for part in mat]
    if sum(f)%2==0:
        ans = f

    else:
        ans = [1 if j==0 else 0 for j in f]

    for j in range(len(ans)):
        mat[j][i] = ans[j]
res = []
for m in mat:
    ans = 0
    for i in range(len(m)):
        ans += 2**i*m[-i-1]
    
    res.append(ans)
print(" ".join(map(str,res)))

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

a_xor = a[0]
for i in range(1, N):
    a_xor = a_xor ^ a[i]
    
ans = []
for i in range(N):
    ans.append(a_xor ^ a[i])
print(*ans)

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

res = bin(0)
for i in range(n):
    res = bin(int(res,2)^al[i])

resu=[]
for j in range(n):
    ress = bin(int(res,2)^al[j])
    resu.append(int(ress,2))

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
al = a[0]
ans = []
for i in range(1, n):
    al ^= a[i]
for i in range(n):
    ans.append(al^a[i])
print(*ans)

Solution (Python):
N = int(input())
A = [int(a) for a in input().split()]
ALL = 0b0
for i in range(N):
    ALL = ALL ^ A[i]
for i in range(N):
    print(ALL ^ A[i])

Solution (Python):
def main():
    n = int(input())
    a = [int(v) for v in input().split()]
    x = 0
    for i in range(n):
        x ^= a[i]
    for i in range(n):
        print(x ^ a[i])

main()

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

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
key=0
for i in A:
    key=int(bin(key^i),2)
for i in A:
    print(int(bin(key^i),2), end=" ")

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

def xor(num_list):
  result = 0
  for num in num_list:
    result ^= num
  return result

xor_a = xor(A)

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

Solution (Python):
n=int(input())
A=list(map(int,input().split()))
dic={tl:0 for tl in range(n)}

l=1
while max(A)>0:
  Q=[a%2 for a in A]
  A=[a//2 for a in A]
  s=sum(Q)
  if s%2==1:
    for i in range(n):
      if Q[i]==0:
       dic[i]+=l
  else:
    for i in range(n):
      if Q[i]==1:
       dic[i]+=l
  l*=2

for i in range(n):
  print(dic[i])

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

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

Solution (Python):
import sys

N = int(input())
A = list(map(int, sys.stdin.readline().rsplit()))

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

for a in A:
    print(t ^ a)

Solution (Python):
import numpy as np
from numba import jit, njit
import copy

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





base = 0
for _a in a:
    base = base ^ _a




xors = []
for i in range(n):
    xors.append(base ^ a[i])

xors = [str(x) for x in xors]


print(' '.join(xors))

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
xor = 0
for i in x:
    xor ^= i
ans = []
for i in x:
    ans.append(xor^i)
print(*ans)

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

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


answers = []
for i in range(N):
    
    
    answers.append(X^a[i])
    
    
    
    

    
print(*answers)

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

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

tmp=[]

for i in range(n):
    if i%2==1:
        continue
    x=a[i]^a[i+1]
    tmp.append(x)

S=0
for j in range(len(tmp)):
    S = S^tmp[j]

ans=[]

for k in range(n):
    p = a[k]^S
    ans.append(p)

print(*ans)

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

ans = [0] * N
for i in range(N):
    ans[i] = al ^ A[i]
print(" ".join(map(str, ans)))

Solution (Python):
from sys import stdin, stdout
from collections import Counter
for _ in range(1):
    n=int(stdin.readline())
    a=list(map(int, stdin.readline().split()))
    xor=0
    for v in a:xor^=v
    ans=[]
    for v in a:
        ans+=[v^xor]
    print(*ans)

Solution (Python):








import sys

N = int(sys.stdin.readline())
a = tuple(map(int,sys.stdin.readline().split())) 

left = [0]*(N+1)
for i in range(N):
    left[i+1] = left[i]^a[i]

right = [0]*(N+1)
for i in range(N)[::-1]:
    right[i] = right[i+1]^a[i]



ret = []
for i in range(N):
    
    ret.append(left[max(0,i)]^right[i+1])

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

Solution (Python):
from functools import reduce

N = int(input().strip())
A = [int(x) for x in input().strip().split(" ")]
xor = reduce(lambda x, y: x ^ y, A)

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

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

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

Solution (Python):
from sys import stdin




def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def si(): return stdin.readline().rstrip()
def lsi(): return list(si())

res=['Yes', 'No']



test_case=1
while test_case:
    test_case-=1

    n=ii()
    a=li()
    x=a[0]
    for i in a[1:]:
        x^=i
    
    ans=[]
    for i in a:
        ans.append(i^x)
    print(*ans)

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

buf = []
for i in a:
    buf.append(c^i)
    
print(*buf)

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

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

A_max = max(A)






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


ans = []
for a in A:
    ans.append(a ^ mask)

print(*ans)

Solution (Python):



import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline




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

res = 0
for a_ in a:
    res = a_ ^ res

for a_ in a:
    print(a_ ^ res, end=' ')
print()

Solution (Python):
def main():
    n = int(input())
    a = list(map(int,input().split()))
    s = 0
    for i, aa in enumerate(a):
        if i == 0:
            s = aa
        else:
            s ^= aa
        

    ans = []
    if n % 2 == 0:
        for i, aa in enumerate(a):

            ans.append(s^aa)
    else:
        
        for i, aa in enumerate(a):

            ans.append(s^aa)
            
    print(' '.join(map(str,ans)))

if __name__=='__main__':
    main()

Solution (Python):
N = int(input())
A_list = list(map(int,input().split()))
ans = []
total_xor = 0
for i in A_list:
  total_xor = int(str(bin(total_xor^i)),2)
total_xor = int(str(bin(total_xor^0)),2)
for i in A_list:
  print(int(str(bin(total_xor^i)),2),end=" ")

Solution (Python):



def cal_xor(xor_list):
    ans = None
    for xi in xor_list:
        if ans is not None:
            ans = ans^xi
        else:
            ans = xi
    return ans

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

ans_str = ''

if N==2:
    print("{} {}".format(a[1], a[0]))
else:

    xors = []
    for i in range(N//2):
        xors.append(a[2*i]^a[2*i+1])

    sum_xor = cal_xor(xors)
    for i, ai in enumerate(a):
        tmp_xor = sum_xor^xors[i//2]
        if i%2==0:
            ind = i+1
        else:
            ind = i-1

        ans = tmp_xor^a[ind]
        ans_str += str(ans)+' '
    print(ans_str[:-1])

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

for i in l:
    print(i,end=" ")

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

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

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

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

B=[0]*N
for i in range(N):
    B[i]=s^A[i]

L=[str(a) for a in B]
L=" ".join(L)
print(L)

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

for i in l:
    print(i,end=" ")

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

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

a = arr[0]

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

ans = []
for i in range(n):
    ans.append(a ^ arr[i])
    
print(*ans)

Solution (Python):
from functools import reduce
from operator import xor
n = int(input())
A = list(map(int, input().split()))


total = []
it = iter(A)
for x, y in zip(it, it):
    total.append(x ^ y)

total = reduce(xor, total)

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

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

base = A[0]
for i in range(1, len(A)):
    base = base ^ A[i]

ans = [0] * N
for i, v in enumerate(A):
    ans[i] = str(base ^ v)

print(" ".join(ans))

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
ans=[[0]*30 for _ in range(N)]

if sum(a)==0:
    print(' '.join(['0']*N))
    exit(0)

i=29

while i>=0:
    curbit=[aa%2 for aa in a]

    s=sum(curbit)

    if s%2==0:
        for j in range(N):
            ans[j][i]=curbit[j]
    else:
        for j in range(N):
            ans[j][i]=0 if curbit[j] else 1



    a=[aa//2 for aa in a]
    
    i-=1

print(' '.join([str(int(''.join([str(aaa) for aaa in aa]),2)) for aa in ans]))

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

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

for i in range(n):
    print(l[i]^a)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
ans = [0] * N
a_max = max(a)
max_iter = len(bin(a_max)) - 2
i = 0
for i in range(max_iter+1):
    pow2 = 2 ** i
    count_1 = 0
    count_0 = 0
    for j in range(N):
        if a[j]>>i & 1:
            count_1 += 1
        else:
            count_0 += 1
            
    if count_1 % 2 == 0:
        
        for j in range(N):
            if a[j]>>i & 1:
                ans[j] += 1 * pow2
    else:
        
        for j in range(N):
            if not a[j]>>i & 1:
                ans[j] += 1 * pow2
print(*ans)

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

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

c = []
for i in range(n):
    num = samu^a[i]
    c.append(num)

print(*c)

Solution (Python):


import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	n = int(sys.stdin.readline())
	a = list(map(int, sys.stdin.readline().split()))
	
	
	
	
	
	
	
	
	
	
	
	
	
	sumxor = a[0]
	for i in range(1, n):
		sumxor ^= a[i]
	ans = []
	for i in range(n):
		ans.append(sumxor ^ a[i])
	print(*ans)

	


main()

Solution (Python):
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
import bisect as bs
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
def adj(n): return [[] for _ in range(n)]

n = iinput()
a = iarr()
tmp = a[0]

for i in range(1,n): tmp = tmp^a[i]
anss = []
for i in range(n): anss.append(tmp^a[i])
print(*anss)

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

ans=[]
for i in a:
    ans.append(res^i)
print(*ans)

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

Solution (Python):









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

    digits = dict()
    for d in range(30):
        digits[d] = 0
        for a in As:
            digits[d] += a >> d & 1

    oore = 0
    for k, v in digits.items():
        oore += (v % 2) << k

    nums = [0] * N

    for i, a in enumerate(As):
        nums[i] = a ^ oore

    return nums


def main():
    print(*solve())


if __name__ == "__main__":
    main()

Solution (Python):
from operator import mul

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

MAX_VAL = 10 ** 9

ans = []

for idx, a in enumerate(A[1:]):
    if idx == 0:
        xor = a
    else:
        xor ^= a

ans = [xor]

l_xor = None
r_xor = xor
for i in range(1, N):
    if i == 1:
        l_xor = A[i - 1]
        r_xor = A[i] ^ r_xor
        ans.append(l_xor ^ r_xor)
    elif i == N:
        l_xor = l_xor ^ A[i - 1]
        ans.append(l_xor)
    else:
        l_xor = l_xor ^ A[i - 1]
        r_xor = A[i] ^ r_xor
        ans.append(l_xor ^ r_xor)

print(*ans)

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

B=bin(a[0])
for i in range(1,n):
    B=bin(int(str(B)[2:],2)^a[i])
for j in range(n):
    x=bin(int(str(B)[2:],2)^a[j])
    print(int(str(x)[2:],2))

Solution (Python):
input()
input_list = list(map(int,input().split()))
total = 0
for num in input_list:
    total = total ^ num
str_list = [str(num ^ total) for num in input_list]
print(" ".join(str_list))

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
x = [0 for _ in range(31)]
for ai in a:
  i = 0
  while ai > 0:
    if ai%2 == 1:
      x[i] += 1
    ai = ai//2
    i += 1
for i in range(31):
  x[i] = x[i]%2
for ai in a:
  s = 0
  for i in range(31):
    if ai%2 == 1:
      if x[i] == 0:
        s += 2**i
    else:
      if x[i] == 1:
        s += 2**i
    ai = ai//2
  print(s)

Solution (Python):
def resolve():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    for i in range(n):
        ans=ans^a[i]
    for i in range(n):
        print(ans^a[i])

if __name__ == '__main__':
    resolve()

Solution (Python):
N = int(input())
SUM = 0
A = []
O = []
for i in input().split():
  i = int(i)
  SUM ^= i
  A.append(i)

for a in A:
  O.append(SUM ^ a)

print(' '.join([str(s) for s in O]))

Solution (Python):
def main():
    n = int(input())
    hoge = [int(i) for i in input().split()]
    tmp = 0 
    for h in hoge:
        tmp = tmp ^ h
    res = [str(tmp ^ h) for h in hoge]
    print(' '.join(res))

if __name__ == '__main__':
    main()

Solution (Python):
from collections import deque
def calcXor(nums):
  x=0
  for n in nums:
    x=x^n
  return x

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

ans=deque()
for a in A:
  ans.append(A_xor^a) 


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

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

for i in range(N):
  print(L^a[i])