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())
a = list(map(int, input().split()))

ans = a[0]

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

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

Submission status: Accepted

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

    tmp = 0
    for aa in a:
        tmp ^= aa

    for aa in a:
        print(tmp ^ aa)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    N = int(readline())
    A = [int(i) for i in readline().split()]
    SXOR = A[0]
    for i in range(1, N):
        SXOR ^= A[i]
    for a in A:
        print(SXOR^a, end=" ")
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)

n = int(input())
a = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

su = 0

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

for i in range(n-1):
    su = su ^ a[i] ^ a[i+1]
    ans.append(su)
    
print(*ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

ans = [None]*n

acm = 0

for i in range(0,n-2,2):
  acm ^= ls[i]^ls[i+1]
  
ans[-1] = ~ls[-2]^(~acm)  

for i in range(n-1):
  ans[i] = ~ans[-1]^(~(ls[-1]^ls[i]))

s = ""
for a in ans:
  s += str(a)+" "
  
print(s)

Submission status: Accepted

Solution code:
import math
import fractions
import collections
import itertools
import pprint
N=int(input())
a=list(map(int,input().split()))
ex=a[0]
for i in range(1,N):
    ex=ex^a[i]
l=[]
for i in range(N):
    l.append(ex^a[i])
print(*l)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
comp = A[1]
for i in range(2, N):
    comp ^= A[i]
comp ^= A[0]
ans = list()
for a in A:
    ans.append(str(comp ^ a))
print(" ".join(ans))

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    ans = []
    s = 0
    for ai in a:
        s = s ^ ai
    for i in range(n):
        ans.append(s ^ (a[i]))
    print(*ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Accepted

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

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

l=[]
for i in a:
    l.append(m^i)
print(*l)

Submission status: Accepted

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

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

for i in a:
  print(criteria ^ i, end=' ')

Submission status: Accepted

Solution code:
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
totxor = reduce(lambda a, b: a^b, A, 0)
ans = []
for a in A:
    ans.append(str(totxor ^ a))
print(' '.join(ans))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

xorall = 0

for aa in a:
    xorall ^= aa

ans = []

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

print(*ans,sep=' ')

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
tot=l[0]^l[1]
for i in range(2,n):
    tot=tot^l[i]
ar=[]
for i in l:
    ar.append(tot^i)
print(*ar)

Submission status: Accepted

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

total = 0

for num in a:
    total = total ^ num

for num in a:
    print(total ^ num,end=" ")

print('')

Submission status: Accepted

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

a_bin = [[] for _ in range(N)]
len_max = 0

odd_or_even = [0 for _ in range(30)]

for i in range(N):
    a_bin[i] = format(a[i],"030b")
    for j in range(30):
        odd_or_even[j] = (odd_or_even[j]+int(a_bin[i][j]))%2

x = [[0]*30 for _ in range(N)]

for i in range(30):
    if odd_or_even[i] == 1:
        for j in range(N):
            x[j][i] = (int(a_bin[j][i])+1)%2
    else:
        for j in range(N):
            x[j][i] = int(a_bin[j][i])

for j in range(N):
    temp = 0
    for i in range(30):
        temp += x[j][i]*(2**(29-i))
    print(temp)

Submission status: Accepted

Solution code:
#                           जय श्री राम

import sys; import math; from collections import *
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, input().split())
def get_list(): return list(get_ints())
def printspx(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")

UGLYMOD = int(1e9+7); SEXYMOD = 998244353; MAXN = int(1e5)

# sys.stdin  = open("input.txt","r"); sys.stdout = open("output.txt","w")

# for _testcases_ in range(int(input())):
from functools import reduce
n = int(input())
li = get_list()
xo = reduce(lambda x, y: x ^ y, li)
for i in li:
    printsp(i ^ xo)
print()



'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS MINE @luctivud ( UDIT GUPTA )
Link may be copy-pasted here if it's taken from other source.
DO NOT PLAGIARISE.
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

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

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

    for a in A:
        print(v ^ a)

if __name__ == '__main__':
    main()

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]
for i in range(N):
    A[i] = S ^ A[i] 
print(*A)

Submission status: Accepted

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

Submission status: Accepted

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

# 全てのaのxorを算出する
all = a[0]
for i in range(1, n):
  all = all ^ a[i]

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

ANS = []
for a in A:
    ANS.append(T ^ a)

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

Submission status: Accepted

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
bit = [0]*32
for i in A:
    for ind,j in enumerate(format(i,"32b")):
        if j == "1":
            bit[ind] += 1

bit.reverse()
for i in A:
    ans = 0
    tmp = 1
    for j,k in zip(bit,format(i,"32b")[::-1]):
        if k == "1":
            j -= 1
        
        if j % 2 != 0:
            ans += tmp
        tmp *= 2
    print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
a = list(map(int, input().split()))

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

answer = [a[i]^all_xor for i in range(N)]

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

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

print(*ans)

Submission status: Accepted

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
def main():
    N = int(input())
    A = list(map(int,input().split()))
    t = 0
    for e in A:
        t ^= e
    print(*[A[k]^t for k in range(N)])
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int,input().split()))
xor = 0
for i in a:
    xor ^= i
for i in range(N):
    if i != (N - 1):
        print(xor ^ a[i],end = " ")
    else: print(xor ^ a[i])

Submission status: Accepted

Solution code:
from sys import stdin
from collections import defaultdict as dd
from collections import deque as dq
import itertools as it
from math import sqrt, log, log2
from fractions import Fraction

n = int(input())
xors = list(map(int, stdin.readline().split()))
nums = []
a1 = 0
for i in xors[1:]:
    a1^= i
nums.append(a1)
for i in xors[1:]:
    nums.append(xors[0]^a1^i)

print(*nums)

Submission status: Accepted

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

total = 0
for num in nums:
    total ^= num
ans = []
for i in range(n):
    ans.append(nums[i] ^ total)
print(' '.join(map(str, ans)))

Submission status: Accepted

Solution code:
N=input()
lst=list(map(int,input().split()))
s=0
for i in lst:
    s^=i
for i in lst:
    print(s^i,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.append(ALL ^ a)

print(*ans)

Submission status: Accepted

Solution code:
from functools import reduce

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

all_xor = reduce(lambda x,y:x^y, a)
ans = [str(x ^ all_xor) for x in a]
print(" ".join(ans))

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = list(map(int, readline().split()))

    s = a[0]

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

    res = [0] * n
    for i, x in enumerate(a):
        res[i] = s ^ x

    print(*res)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
arr = list(map(int, input().split()))
total = 0
for i in arr:
  total ^= i
for i in arr:
  print(total ^ 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]

ans=[]
for i in range(N):
	ans.append(S^a[i])

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

Submission status: Accepted

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

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

ans=[]
for i in range(n):
    temp=A[i]^all
    ans.append(temp)

print(*ans)

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))
total = 0
for num in A:
    total ^= num
#print(total)

ans = []
for num in A:
    ans.append(total^num)
print(*ans, sep=" ")

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import copy
def main():

    N = int(input())
    A =list(map(int, input().split()))
    AD = copy.copy(A)
    AAA = []

    while len(AD) > 1:
        if len(AD)%2==1:
            AD.append(0)
        for i in range(0,len(AD),2):
            AAA.append(AD[i]^AD[i+1])
        AD = copy.copy(AAA)
        AAA.clear()
    
    for i in range(N):
        A[i] = AD[0] ^ A[i]
    
    print(*A)





if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
a_list = list(map(int, input().split()))

first_num = 0
for i in range(1, N):
    first_num ^= a_list[i]

ans_list = [first_num]
now_num = first_num
for i in range(1, N):
    now_num ^= a_list[i - 1] ^ a_list[i]
    ans_list.append(now_num)

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

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
bina=['0'*30+bin(ai)[2:] for ai in a]
maxa=max(a)
m=len(bin(maxa))-2
ans=[0]*n
for i in range(m):
  j=-i-1
  tmp=0
  for k in range(n):
    tmp+=int(bina[k][j])
  for k in range(n):
    if tmp%2==0 and bina[k][j]=='1':
      ans[k]+=pow(2,i)
    elif tmp%2==1 and bina[k][j]=='0':
      ans[k]+=pow(2,i)
print(' '.join(map(str,ans)))

Submission status: Accepted

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

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

ans = [str(p)]
for i in range(1, N):
    t = A[i-1] ^ A[i]
    p = p ^ t
    ans.append(str(p))
print(" ".join(ans))

Submission status: Accepted

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

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

ans = [str(allxor ^ a[i]) for i in range(0,N,1)]

print(" ".join(ans))

Submission status: Accepted

Solution code:
N = int(input())
l = [int(x) for x in input().split()]
t = 0
for i in l:
    t = t ^ i
for i in range(N-1):
    print(t ^ l[i], end=' ')
print(t ^ l[N-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
#map(int,input().split())
#int(x) for x in input().split()
#for _ in range(int(input())):
n=int(input())
l=[int(x) for x in input().split()]
p=[l[0]]
s=[l[-1]]
for i in range(1,len(l)):
	p.append(p[-1]^l[i])
for i in range(len(l)-2,-1,-1):
	s.append(s[-1]^l[i])
s=s[::-1]
ans=[s[1]]
for i in range(1,len(l)-1):
	ans.append(p[i-1]^s[i+1])
ans.append(p[-2])
print(*ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
N_arr = [int(v) for v in input().split()]  

total_ans = 0
for Ni in N_arr:
  total_ans ^= Ni
for i in range(N):
  ans = total_ans ^ N_arr[i]
  print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
sumA = A[0]
for i in range(1,N):
    sumA = (sumA^A[i])
    ans = []
for i in range(N):
    ans.append(str(sumA^A[i]))
print(" ".join(ans))

Submission status: Accepted

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

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

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

print(' '.join(map(str, 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 range(N):
    ans.append(s ^ a[i])
print(' '.join(list(map(str, ans))))

Submission status: Accepted

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

cnt = A[0]
for i in A[1:]:
    cnt ^= i

lst = []
for i in A:
    lst.append(i^cnt)
print(*lst)

Submission status: Accepted

Solution code:
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
ans=[[0]*35 for i in range(n)]

#print(ans)
#sys.exit()
for i in range(35):
    bits=[0 for j in range(n)]
    for k in range(n):
        bits[k]=(lis[k]>>i) %2
    #print(bits)
    ans[0][i]=sum(bits[1:])%2
    sm=sum(bits[1:])%2+bits[0]%2
    for k in range(1,n):
        ans[k][i]=(bits[k]-sm)%2
#print(ans)
answer=[0 for i in range(n)]
for i in range(n):
    for j in range(35):
        answer[i]+=ans[i][j]*(2**j)
print(*answer)

Submission status: Accepted

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

total=0
for i in a_list:
  total^=i

#print(total)

for i in a_list:
  print(total^i,end=" ")

Submission status: Accepted

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
X = 0
for a in A:
    X ^= a
ans = [str(X ^ a) for a in A]
print(' '.join(ans))

Submission status: Accepted

Solution code:
from functools import reduce
from operator import xor

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

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

Submission status: Accepted

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

cnt = 0
for i in a:
    cnt ^= i
for i in a:
    print(cnt ^ i)

Submission status: Accepted

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

ans=[]
for j in range(N):
    ans.append(a[j]^s)
print(*ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N):
  #x = bin(A[i])[2:]
  if i == 0:
    ans = A[i]
  else:
    ans = ans ^ A[i]
    
for i in range(N):
  print(ans ^ A[i], end = " ")

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(" ".join(ans))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from functools import reduce

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

all = reduce(lambda i, j: int(i) ^ int(j), a)

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

Submission status: Accepted

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

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


ans = []
for i in range(N):
    p = a[i]
    ans.append(p^XOR_all)

print(*ans)

Submission status: Accepted

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

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

  
print(*B)

Submission status: Accepted

Solution code:
# 2020/06/21
# AtCoder Beginner Contest 171 - E

# Input
n = int(input())
a = list(map(int,input().split()))
nans = [''] * n

# Calc
axor = 0
for i in range(n):
    axor = axor ^ a[i]

for i in range(n):
    nans[i] = str(axor ^ a[i])

# Output
print(' '.join(nans))

Submission status: Accepted

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

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


#############
# Main Code #
#############

N = getN()
A = getList()

lista = [[0, 0] for i in range(61)]
# bitの各桁が１か０かをlistaに収納
def splitbit(n):
    for i in range(61):
        if n & (1 << i):
            lista[i][0] += 1
        else:
            lista[i][1] += 1

for i in range(N):
    splitbit(A[i])

bi_int = 0
for i in range(61):
    if lista[i][0] % 2 == 1:
        bi_int += 2 ** i

ans = []
for i in range(N):
    ans.append(bi_int ^ A[i])
print(*ans)

Submission status: Accepted

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

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

print(*ans)

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
from sys import stdin,setrecursionlimit
import heapq,bisect,math,itertools,string,queue,datetime,copy
setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, stdin.readline().split()))

N = int(input())
Als = inpl()
sm = 0
for item in Als:
    sm = sm^item

anls = []
for item2 in Als:
    anls.append(str(sm^item2))

print(' '.join(anls))

Submission status: Accepted

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

totalH = 0
for a in listA:
    totalH = a ^ totalH

answerL = []
for a in listA:
    ans = a ^ totalH
    answerL.append(str(ans))

print(" ".join(answerL))

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,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())
l=list(map(int, input().split()))
x=0
for i in l:
    x=x^i
for i in l:
    print(x^i,end=" ")
print()

Submission status: Accepted

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

Submission status: Accepted

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

xor_a=0
for i in range(len(a)):
    xor_a=xor_a^a[i]
#print(xor_a)

b = [xor_a^a[i] for i in range(len(a))]
print(" ".join(map(str, b)))

Submission status: Accepted

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
a=lnii()

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

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

print(*ans)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
all=0
for num in a:
    all^=num
b=[str(all^i) for i in a]
print(' '.join(b))

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))
table = [0] * 32
for a in A:
    for i in range(32):
        if a>>i & 1:
            table[31-i] += 1
arr = [0] * 32
ans = 0
for i, v in enumerate(table):
    if v % 2 == 1:
        arr[i] = 1
for i, a in enumerate(arr):
    ans += a * (2**(31-i))
for a in A:
    print(ans^a, end=" ")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections,sys
input=sys.stdin.readline
n=int(input())
l=list(map(int,input().split()))
z=len(format(max(l),'b'))
x=[0]*z
for i in range(n):
  l[i]=format(l[i],'b')
  l[i]='0'*(z-len(l[i]))+l[i]
  for j,y in enumerate(l[i]):
    if y=='0':
      x[j]+=1
for j in range(z):
  x[j]=str(x[j]%2)
x=int(''.join(x),2)
for i in range(n):
  l[i]=int(l[i],2)
  l[i]=l[i]^x
print(*l)

Submission status: Accepted

Solution code:
n = int(input())
arr = [int(x) for x in input().split()]
ans = []
xor = 0
for i, x in enumerate(arr):
    xor = xor ^ x
for i, x in enumerate(arr):
    temp = xor ^ x

    ans.append(temp)
for x in ans:
    print(x, end=" ")

Submission status: Accepted

Solution code:
def two(x):
    lis=[]
    for i in range(50):
        lis.append(x%2)
        x=x//2
    return lis

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

tl=[]
for i in range(50):
    tl.append(2**i)

lis=[0 for i in range(50)]

for ai in a:
    twoi=two(ai)
    for j in range(50):
        lis[j]=(lis[j]+twoi[j])%2

ans=[]
for ai in a:
    ansi=0
    twoi=two(ai)
    for j in range(50):
        if twoi[j]!=lis[j]:
            ansi+=tl[j]
    ans.append(ansi)

print(*ans)

Submission status: Accepted

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
 
def do():
    n=INT()
    a=LIST()
    temp=0
    for i in a:
        temp=temp^i
    
    b=[0]*n
    for i in range(n):
        b[i]=a[i]^temp
    print(*b)
    
        
    
if __name__ == '__main__':
    do()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)


def main(input, print):
    n = int(input())
    a = list(map(int, input().split()))
    total = 0
    ans = ['']*n
    for x in a:
        total ^= x
    for i in range(n):
        ans[i] = total ^ a[i]
    print(*ans)


if __name__ == '__main__':
    main(sys.stdin.readline, print)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
result = [0]*n
xor_sum = 0
for ai in a:
    xor_sum = xor_sum ^ ai
    # print(str(xor_sum) + " : " + str(bin(xor_sum)))

for i in range(n):
    result[i] = str(xor_sum ^ a[i])
    # print(str(result[i]) + " : " )

print(" ".join(result))

Submission status: Accepted

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


def solve(N: int, a: "List[int]"):
    from functools import reduce
    assert N % 2 == 0
    b = reduce(lambda a, b: a ^ b, a)
    return [aa ^ b for aa in a]

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
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]"
    print(*solve(N, a))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()

Submission status: Accepted

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

Submission status: Accepted

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


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

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

    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:
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    n=int(input())
    A=list(map(int,input().split()))
    ans=0
    for i in A:
        ans^=i
    
    for i in A:
        ans2=ans
        print(ans2^i, end=' ')
    
resolve()

Submission status: Accepted

Solution code:
import sys
imput = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
ans = A[0]
for i in A[1:]:
    ans ^=i
for i in A:
    print(ans^i)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

for a in A:
    print(S ^ a)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    t = 0
    for v in a:
        t = (t ^ v)
    for v in a:
        print(v ^ t, end=" ")

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
from functools import reduce
read = sys.stdin.read

n, *lst = map(int, read().split())
lst_xor = reduce(lambda x, y: x ^ y, lst)
print(*[lst_xor ^ i for i in lst])

Submission status: Accepted

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

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