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.



Sample input:
4
20 11 9 24


Sample output:
26 5 7 22

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:


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()
    solve(N,A)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, *a = map(int, open(0).read().split())
s = 0
for A in a:s^=A
print(*[s^B for B in a])

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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=" ")

Submission status: Accepted

Solution code:
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=" ")

Submission status: Accepted

Solution code:
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())

Submission status: Accepted

Solution code:
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=" ")

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))))

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


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
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from math import gcd

N = read_a_int()
A = read_ints()

# わかっているのは自分以外のXORの演算
# Aiをすべて合計したら必ず
S = 0
for a in A:
    S ^= a

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

Submission status: Accepted

Solution code:
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))))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
# coding: utf-8
import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
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()

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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="")

Submission status: Accepted

Solution code:
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))))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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]

Submission status: Accepted

Solution code:
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
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)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

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)))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

#nは偶数

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

print(" ".join(ans))

Submission status: Accepted

Solution code:
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))))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)
"""

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)))

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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=' ')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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
    # print(bin(x), x)

res = []
for a in A:
    res.append(x^a)
# print(res)
print(" ".join(map(str, res)))

Submission status: Accepted

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
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


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


# n*(n-1)*...*(l+1)*l
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=' ')

Submission status: Accepted

Solution code:
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)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()
A = li()

wa = 0
for num in A:
    wa ^= num
    #print(wa)

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

print()

Submission status: Accepted

Solution code:
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))))

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
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)

Submission status: Accepted

Solution code:
# Template 1.0
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)

Submission status: Accepted

Solution code:
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)))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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=' ')

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
#!python3

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()

Submission status: Accepted

Solution code:
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=" ")

Submission status: Accepted

Solution code:
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=' ')

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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))))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)))

Submission status: Accepted

Solution code:
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)])

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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]))

Submission status: Accepted

Solution code:
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=" ")

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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()