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:
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def main():
    n = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    a = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    xor = 0
    for i in a:
        xor ^= i

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




main()

Submission status: Accepted

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

for i in range(n):
    ans.append(tmp ^ a[i])

print(*ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

allxor = 0

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

anslist = []

for i in range(N):
    anslist.append(allxor ^ a[i])

print(*anslist, sep=' ')

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
a_list = list(map(int, input().split()))
y = 0
for a in a_list:
    y = y ^ a
for a in a_list:
    x = y ^ a
    print(x, end=" ")

Submission status: Accepted

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

resolve()

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
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()))

A = []
total = 0
for i in range(N):
    n = a[i]
    total = bin(total ^ n)
    total = int(total, 0)
    A.append(n)

result = []

for i in range(N):
    tmp = bin(total ^ A[i])
    m = int(tmp, 0)
    result.append(m)

print(*result)

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))
s = 0
ans = []
for i in a:
  s ^= i
for i in a:
  ans.append(str(s^i))
print(' '.join(ans))

Submission status: Accepted

Solution code:
N = int(input())
List = list(map(int, input().split()))
S=0
for i in List:
    S=int(bin(S^i),2)
for i in List:
    print(int(bin(S^i),2))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int, a: "List[int]"):
    t = 0
    ans = []
    for i in range(N):
        t ^= a[i]

    for i in range(N):
        ans.append(str(t^a[i]))

    print(' '.join(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()))
s = 0
for x in a:
    s ^= x
ans = [x^s for x in a]
print(" ".join(map(str, ans)))

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())
a = list(map(int,input().split()))
now = 0
for i in a:
    now ^= i
li = []
for i in a:
    li.append(i^now)

print(*li)

Submission status: Accepted

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

result = ['' for _ in range(N)]
s = A[0]
for i in range(1,N):
    s = s ^ A[i]

for i in range(N):
    result[i] = str(s ^ A[i])

print(' '.join(result))

Submission status: Accepted

Solution code:
N = int(input())
lis = list(map(int, input().split()))
def calc(vals):
    val, *vals = vals
    for v in vals:
        val ^= v
    return val
ans = []
total = calc(lis)
for val in lis:
    ans.append(total ^ val)
print(*ans)

Submission status: Accepted

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

b = 0

for i in a:
    b ^= i

ans = []

for i in a:
    ans.append(i^b)

print(*ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

sm = 0
for a in A:
    sm ^= a
for a in A:
    print(sm^a, end=' ')
print()

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

n = ni()
a = nl()
for i,j in enumerate(a):
    if i == 0:
        t = j
        continue
    t = t ^ j
for k in a:
    print(t ^ k)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

ans = []
for i in alist:
    ans.append(s ^ i)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(31):
    x=0
    for j in range(n):
        if (a[j]>>i)&1:
            x+=1
    if x%2==0:
        for j in range(n):
            if (a[j]>>i)&1:
                ans[j]+=pow(2,i)
    else:
        for j in range(n):
            if not (a[j]>>i)&1:
                ans[j]+=pow(2,i)

print(*ans)

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
res = 0
for a in A:
    res ^= a
ans = [-1] * N
for i, a in enumerate(A):
    ans[i] = res ^ a
print(*ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
s = 0
for i in a:
    s = s ^ i
ans = []
for i in a:
    ans.append(s ^ i)
print(*ans, sep=' ')

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1,n):
  ans = ans ^ a[i]
ans_l = [ans ^ ai for ai in a]
print(' '.join(map(str, ans_l)))

Submission status: Accepted

Solution code:
#import sys
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np
from collections import defaultdict

def main():
	n=II()
	A=LI()

	a=0

	ans=[]

	for i in A:
		a^=i

	for i in A:
		ans.append(a^i)

	print(*ans)












if __name__ == "__main__":
	main()

Submission status: Accepted

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

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

for a in A:
    print(xor^a, '',end='')
print()

Submission status: Accepted

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

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

ans = [SUM ^ a for a in A]

print(*ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = []
origin = A[0]

for i in range(1, N):
  origin ^= A[i]
  
for j in range(N):
  ans.append(origin^A[j])

for k in range(len(ans)-1):
  print("{} ".format(ans[k]), end="")
print(ans[len(ans)-1])

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
p=[]
for j in range(30):
  p.append(pow(2,j))
t=0
for i in range(n):
  t=t^a[i]
for i in range(n):
  ans=0
  for j in range(30):
    ans=ans+p[j]*(((a[i]^t)//p[j])%2)
  print(ans,end=" ")

Submission status: Accepted

Solution code:
#aが最大で10**9ということは、各整数も10**9以下と仮定していい。二進数になおしたときの桁数は、30くらい
N = int(input())
A = list(map(int,input().split()))

digit = "0"+str(30)+"b"
memo = [None]*(N)

#総和からAiを引くと、A番目の数がもとまる
#どうやって総XORを求める？

#まず、aを二進数に直せばよさそう
a = A[0]
for i in range(1,N):
    a = a^A[i]

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

Submission status: Accepted

Solution code:
from functools import reduce
import sys
from operator import xor


def _i(): return int(sys.stdin.readline().strip())


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    _ = _i()
    a = list(_ia())
    s = reduce(xor, a, 0)
    return " ".join(map(str, map(lambda x: s ^ x, a)))


if __name__ == "__main__":
    print(main())

Submission status: Accepted

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

tmp = int(0)
for t in a:
    tmp ^= t

ans = [0] * n
for i in range(n):
    ans[i] = tmp ^ a[i]

print(*ans)

Submission status: Accepted

Solution code:
n = int(input())
A=[int(i) for i in input().split()]
k = A[0]
for i in range(n-1):
    k ^= A[i+1]
res = []

for i in A:
    res.append(i^k)
for i in res:
    print(i, end=" ")

Submission status: Accepted

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

s = 0
for i in range(N):
  s ^= A[i]
for i in range(N):
  si = s
  si ^= A[i]
  print(si)

Submission status: Accepted

Solution code:
from functools import reduce

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

print(*[t ^ x for x in xs])

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())
a = input().split()
np_a=np.array(a, dtype=int)

ans=np.zeros(n, dtype=int)

all=np_a[0]
for i in range(1,n):
  all=all ^ np_a[i]
  

for i in range(0,n):
  ans[i]=all ^ np_a[i]
  
print (*ans)

Submission status: Accepted

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

allh=alist[0]^alist[1]
for i in range(n-2):
    allh = allh ^ alist[i+2]

outlist=[]
for a in alist:
    outlist.append(str(allh ^ a))
    outlist.append(" ")
outlist.pop()
print("".join(outlist))

Submission status: Accepted

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

  X = A[0]

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

  B = []

  for v in A:
    B.append(X ^ v)
  
  print(" ".join(map(str, B)))

if __name__ == "__main__":
  main()

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int,input().split()))
b=0
for a in A:
  b ^= a 

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

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=[]
bn=[]
xo=0
for i in a:
  xo^=i
  
for i in a:
  ans.append(xo^i)
for i in ans:
  print(i,end=" ")

Submission status: Accepted

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

# m = bin(10**9)[2:]
# print(int('11010', 2))
# print(17^19^2)
# print(26^19^2)
# print(26^17^2)
# print(26^17^19)

first = 0
tmp = 0

for (i, a) in enumerate(A):
    if i == 0:
        first = a
        continue
    else:
        xor = first^a
        tmp = tmp^xor

f = tmp^first
print(f)
for (i, a) in enumerate(A):
    if i == 0:
        continue
    else:
        print(first^f^a)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    N = int(input().strip())
    a_l = [int(i) for i in input().strip().split()]
    ans = [None] * N
    base = 0
    for a in a_l:
        base ^= a
    for i in range(N):
        ans[i] = str(base ^ a_l[i])
    print(" ".join(ans))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

res =[]

r = None

for i in range(len(alphas)):
	if r is None:
		r = alphas[i]
	else:
		r ^= alphas[i]

for i in range(len(alphas)):
	res.append(r^alphas[i])
print(*res)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    N = int(input())
    A_lsit = list(map(int, input().split()))
    A_binstr_lsit = [bin(a)[2:].zfill(30) for a in A_lsit]

    is_odd_list = [
        bool(sum([
                int(A_binstr_lsit[j][i])
                for j in range(N)
            ])%2)
        for i in range(30)
    ]

    #print(A_lsit)
    #print(A_binstr_lsit)
    #print(is_odd_list)

    answer_list = []

    for i in range(N):
        A_bin = A_binstr_lsit[i]
        answer = ""
        for j in range(30):
            if is_odd_list[j]:
                if A_bin[j] == "1":
                    answer += "0"
                else:
                    answer += "1"
            else:
                answer += A_bin[j]
        answer_list.append(str(int(answer, 2)))
    print(" ".join(answer_list))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict, deque
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

n=r()
a=rl()
all=a[0]^a[1]
for i in range(2,n):
    all^=a[i]
b=[]
for j in range(n):
    b.append(all^a[j])
print(*b)

Submission status: Accepted

Solution code:
def solve():
	N = int(input())
	arr = list(map(int, input().split()))
	xor = arr[0]
	for i in range(1, N):
		xor ^= arr[i]
	for x in arr:
		print(x ^ xor, end = " ")
	print()

def main():
	# for _ in range(int(input())):
	solve()


if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
import sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n=ri()
a=rl()
t=0
for i in a:
    t^=i
t=bin(t)[2:]
max_len=max(len(bin(max(a)))-2,len(t))

if len(t)<max_len:t="0"*(max_len-len(t))+t
try:
    a=list(map(lambda x : bin(x)[2:],a))
except:
    sys.exit()
    
try:
    for i in range(n):
        if len(a[i])<max_len:
            a[i]="0"*(max_len-len(a[i]))+a[i]
except:
    sys.exit()


ans=[[] for i in range(n)]
for i in range(max_len):
    for j in range(n):  
            if a[j][i]==t[i]:
                ans[j].append("0")
            else:
                ans[j].append("1")

for i in ans:
    print(int("".join(i), 2))

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
suml=0
for i in l:
    suml=suml^i
ll=[]
for i in l:
    ll.append(suml^i)
print(*ll)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
A = [list(map(int, list('{:031b}'.format(x)))) for x in A]
total = []
for B in zip(*A):
    total.append(sum(B))

ans = []
for a in A:
    tmp = []
    for i in range(31):
        tmp.append(str((total[i]-a[i])%2))
    ans.append(int(''.join(tmp), 2))
print(*ans)

Submission status: Accepted

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


ans = []
alld = 0

for aa in a:
    alld = alld ^ aa

for  aa in a:
    ans.append(alld ^ aa)

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

Submission status: Accepted

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

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

ans = []
for i in a:
    ans.append(a_xor^i)

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

Submission status: Accepted

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

b = a[:]

dig_m = 30
cnt_dig = [1]*30
for i in range(dig_m):
    cnt = 0
    for j in range(n):
        if b[j] % 2 == 0:
            cnt += 1
        b[j] //= 2
    if cnt % 2 == 0:
        cnt_dig[i] = 0
cnt_dig.reverse()
cnt_dig = int(''.join(map(str, cnt_dig)), 2)

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

Submission status: Accepted

Solution code:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

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

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

n = I()
a = RI()

s = 0
for i in a:
    s ^= i
# print(s)

l = []
for i in a:
    b = i^s
    l.append(b)
myoutput(l,True)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(s) for s in input().split()]

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

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

print(*B)

Submission status: Accepted

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

if N % 2 == 0:
    s = A[0]
    for i in range(1,N):
        s = s^A[i]
    
    for i in range(N):
        print(s^A[i],end=" ")
    print()
else:
    print()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])
#print(ans)
ans1 = [str(a) for a in ans]
print(" ".join(ans1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

x = 0
for i in range(n):
    x = x ^ a[i]
#print(bin(c))


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

Submission status: Accepted

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

# 00 ^ 05 ^ 07 ^ 22 | 20
# 26 ^ 00 ^ 07 ^ 22 | 11
# 26 ^ 05 ^ 00 ^ 22 | 09
# 26 ^ 05 ^ 07 ^ 00 | 24

# 26 ^ 05 ^ 07 ^ 22 | 14

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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



tot = 0

for a in aa:
    tot ^= a



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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math  # noqa: F401
from typing import Dict, List, Optional, Tuple, Union  # noqa: F401


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)

Submission status: Accepted

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

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

# print(sum)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
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))
#%%code
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
    #print(left)

    left[0]=A[0]^left[-1]
    #print(left)

#    left[1]=11^left[-1]^left[0]
#    print(left)
    for i in range(1,N-2):
        left[i]=A[i]^left[-1]^left[i-1]
    #output
    ans=[left[0]]
    for i in range(1,N):
        ans.append(left[i]^left[i-1])
    print(*ans)
#%%submit!
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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