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
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
# list(map(int, input().split()))

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

ans = [0] * n

# l = [0] * (n + 1)
# for i in range(1, n + 1):
#     l[i] = l[i - 1] ^ A[i - 1] 

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

for i in range(n):
    ans[i] = total ^ A[i]
print(*ans)

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]
l = []
for i in range(n):
    l.append(s ^ a[i])
print(" ".join(map(str,l)))

Submission status: Accepted

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

Submission status: Accepted

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

total = 0

for item in a:
    total = total ^ item

ret = []

for item in a:
    ret.append(total ^ item)

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

Submission status: Accepted

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

Submission status: Accepted

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

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    A = ZZ()
    x = 0
    for a in A: x ^= a
    ans = []
    for a in A:
        ans.append(a ^ x)
    print(*ans)


    return

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from functools import reduce

N, *A = map(int, open(0).read().split())

S = reduce(lambda a, b: a ^ b, A)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

A_all = 0
for i, Ai in enumerate(A):
    A_all ^= Ai

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

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

Submission status: Accepted

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

all_xor = 0
for a in a_list:
    all_xor ^= a
ans = []
for a in a_list:
    ans.append(all_xor ^ a)
    
print(" ".join([str(el) for el in ans]))

Submission status: Accepted

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

all = 0
for v in a:
    all ^= v
nums = []
for v in a:
    nums.append(str(all ^ v))
print(" ".join(nums))

Submission status: Accepted

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

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

ans = []
for _a in a:
  ans.append(str(x ^ _a))

print(" ".join(ans))

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
a = list(map(int,readline().split()))
x = 0
for i in a:
  x ^= i
aa = []
for i in a:
  aa.append(x^i)
print(*aa)

Submission status: Accepted

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

s = 0
for k in a:
    s ^= k

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

Submission status: Accepted

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

xor_all = 0

for ai in a:
    xor_all ^= ai

ans = [xor_all^ai for ai in a]
print(*ans)

Submission status: Accepted

Solution code:
import sys

N = int(sys.stdin.readline())
A = [int(x) for x in sys.stdin.readline().split()]

tmp = 0

for a in A:
    tmp ^= a

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

print(" ".join([str(x) for x in ANS]))

Submission status: Accepted

Solution code:
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft



def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = [[] for i in range(n)]
    for i in range(60):
        c = 0
        for x in a:
            if (x >> i) & 1:
                c ^= 1
        for j in range(n):
            x = (a[j] >> i) & 1
            b[j].append(x ^ c)

    for x in b:
        print(int("".join(str(i) for i in x[::-1]), 2))
main()

Submission status: Accepted

Solution code:
n = int(input())
A = tuple(map(int, input().split()))
from functools import reduce
AXOR = reduce(lambda x, y: x^y, A)

xor = []
for a in A:
    xor.append(str(AXOR^a))
print(' '.join(xor))

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
l=[0]*35
for i in range(n):
    for j in range(35):
        if (a[i]>>j)%2==1:
            if l[j]==0:
                l[j]=1
            else:
                l[j]=0
ans=[]
for i in range(n):
    temp=0
    for j in range(35):
        if (a[i]>>j)%2==1:
            if l[j]==0:
                temp+=2**j
        else:
            if l[j]==1:
                temp+=2**j
    ans.append(temp)

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

Submission status: Accepted

Solution code:
n=int(input())
A=list(map(int,input().split()))
L = []
x=0
for a in A:
    x ^= a
    L.append(x)
R = []
x=0
for a in reversed(A):
    x ^= a
    R.append(x)
for i in range(n):
    x = 0
    if i>0:
        x^=L[i-1]
    if i<n-1:
        x^=R[n-1-(i+1)]
    print(x, end="")
    if i==n-1:
        print("")
    else:
        print(" ",end="")

Submission status: Accepted

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

aa = 0

for i in range(1,len(List)):
  a = List[i]
  aa = aa ^ a
  

bb = List[0]
arr = [aa]
for i in range(1,len(List)):
  a = List[i]
  b = bb ^ a
  c = b ^ aa
  arr.append(c)
  
print(*arr)

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))
t = 0
for i in range(N):
    t = t ^ a[i]
b = []
for i in range(N):
    b.append(t ^ a[i])
print(*b, sep=' ')

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
now = 0
for x in a:
  now ^= x
ans = []
for x in a:
  ans.append(now^x)
#print(ans)
print(' '.join(list(map(str,ans))))

Submission status: Accepted

Solution code:
import sys


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 = 0
    for ai in a:
        s ^= ai

    return " ".join(map(str, map(lambda x: s^x, a)))


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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

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=[0]*n
for i in range(n):
    ans[i]=a[i]^b
print(" ".join(map(str,ans)))

Submission status: Accepted

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

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

for x in a:
    print(full_arr ^ x, end=' ')

print()

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
k = 0
for num in a:
  k = k^num
ans = []
for num2 in a:
  ans.append(str(k^num2))
print(' '.join(ans))

Submission status: Accepted

Solution code:
import sys
import math
def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

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

def SI():
	return sys.stdin.readline().strip()
n = II()
a = LI()
s = a[0]
for i in a[1:]:
	s^=i
ans = []
for i in range(n):
	ans.append(s^a[i])
print(*ans)

Submission status: Accepted

Solution code:
n = int(input())
A = list(int(x) for x in input().split())
tmp = 0
for a in A:
    tmp ^= a

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

print(" ".join(ANS))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
p = 0
t = []
for i in range(n):
    p ^= a[i]
for i in range(n):
    t.append(p^a[i])
s = [str(x) for x in t]
print(' '.join(s))

Submission status: Accepted

Solution code:
from functools import reduce

def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    b = reduce(lambda x,y: x^y, a)
    print(*list(map(lambda x: a[x]^b, range(n))))

if __name__ == "__main__":
    resolve()

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

Submission status: Accepted

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

Submission status: Accepted

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

allXOR = 0
for a in As:
    allXOR ^= a

ans = []
for a in As:
    ans.append(allXOR ^ a)
print(' '.join(map(str, ans)))

Submission status: Accepted

Solution code:
# E - Red Scarf
N = int(input())
a = list(map(int,input().split()))
ans = 0
for x in a:
    ans = ans^x
for i in range(N):
    print(ans^a[i],end=' ')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')
AZ = "abcdefghijklmnopqrstuvwxyz"

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  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

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
N = I()
A = IL()

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

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

Submission status: Accepted

Solution code:
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
n=int(input())
a=list(map(int,stdin.readline().split()))
total=0
for i in a:
    total=total^i 
for i in range(n):
    a[i]=total^a[i]
print(*a)

Submission status: Accepted

Solution code:
import sys

n, *aaa = map(int, sys.stdin.buffer.read().split())
all_xor = 0
for a in aaa:
    all_xor ^= a

buf = []

for a in aaa:
    buf.append(all_xor ^ a)

print(*buf)

Submission status: Accepted

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

al = 0

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

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

print(*ans)

Submission status: Accepted

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

kotae = []

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

for i in range(n):
    kotae.append(str(total ^ a[i]))


kotae = " ".join(kotae)
print(kotae)

Submission status: Accepted

Solution code:
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


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


sys.setrecursionlimit(1000000)


def main():
    N = I()
    A = LI()

    sumxor = 0
    for ai in A:
        sumxor ^= ai

    for ai in A:
        print(sumxor ^ ai, end=" ")


main()

Submission status: Accepted

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

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

b = []
for i in range(N - 1) :
  b.append(a[i] ^ a[(i + 1) % N])

x = 0
for i in range(0, N - 1, 2) :
  x ^= b[i]

ret = [a[-1] ^ x]
for c in b[::-1] :
  ret.append(c ^ ret[-1])

ret = ret[::-1]
print(*ret)

Submission status: Accepted

Solution code:
from sys import stdin,stdout
input = stdin.readline
print = stdout.write
from functools import reduce
n = int(input())
a = list(map(int,input().split()))
xor = reduce(lambda x,y: x^y,a)
for i in a:
    print(str(xor^i)+" ")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    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)
    return ans
print(*solve())

Submission status: Accepted

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


resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    xorA = 0
    for a in A:
        xorA ^= a
    ans = [xorA ^ a for a in A]
    print(*ans, sep=' ')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
a=list(map(int,input().split()))
s=0
for x in a:
    s^=x
for x in a:
    print(s^x)

Submission status: Accepted

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

def xor(x, y):
  return x^y

from functools import reduce
s = reduce(xor, a)
ans = []
for i in range(n):
  ans.append(str(xor(s, a[i])))
print(' '.join(ans))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, *a = map(int, open(0).read().split())
ans = 0
for i in a:
    ans = ans ^ i
for j in a:
    print(ans ^ j)

Submission status: Accepted

Solution code:
import itertools, operator
N = int(input())
A = [int(_) for _ in input().split()]
S = list(itertools.accumulate(A, func=operator.xor))[-1]
print(*(S ^ a for a in A), sep=' ')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    N = int( input())
    A = list( map( int, input().split()))
    t = 0
    for a in A:
        t ^= a
    print( " ".join( map( str, [t^a for a in A])))
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from functools import reduce
N = int(input())
A = [int(i) for i in input().split()]
B = reduce(lambda x,y: x^y, A)
print(" ".join(map(str, [A[i]^B for i in range(N)])))

Submission status: Accepted

Solution code:
n = int(input())
A = [int(i) for i in input().split()]
total_xor = 0
for i in A:
    total_xor ^= i
ans = [i^total_xor for i in A]
print(*ans)

Submission status: Accepted

Solution code:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *                    # ll = deepcopy(l)
from heapq import *                    # heappush(hp,x)
from string import *                # alpha = ascii_lowercase
from random import *                # l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *                # bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin                # bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize                # minn = -maxsize
from operator import *                # d = sorted(d.items(), key=itemgetter(1))
from itertools import *                # pre = [0] + list(accumulate(l))
from decimal import Decimal         # a = Decimal(a)    # use this for math questions
from collections import Counter        # d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
    n = len(l)
    xor = 0
    for i in l:
        xor ^= i
    ans = []
    for i in l:
        ans.append(xor^i)
    return ans
    

N = int(stdin.readline())
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l)
print(*ans)

Submission status: Accepted

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

for i in a:
    for j in range(32):
        if i >> j & 1:
            l[j] += 1

ans = [0]*n

for i in range(32):
    if l[i]%2 == 0:
        for j in range(n):
            if a[j]>>i & 1:
                ans[j] += 1<<i
    else:
        for j in range(n):
            if not a[j] >> i & 1:
                ans[j] += 1<<i
print(*ans)

Submission status: Accepted

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

num = 0
for a in As:
  num ^= a

ans = [str(num ^ a) for a in As]

print(" ".join(ans))

Submission status: Accepted

Solution code:
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
A=[int(i) for i in input().split()]
tot=0
for a in A:
  tot^=a
T=[0]*30
for i in range(30):
  if tot&(1<<i):
    T[i]=1

Ans=[0]*n
for i in range(n):
  cur=0
  for j in range(30):
    if A[i]&(1<<j)>0 and T[j]==0:
      cur+=2**j
    elif A[i]&(1<<j)==0 and T[j]==1:
      cur+=2**j
  Ans[i]=cur
print(*Ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub, xor


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    S = reduce(xor, A, 0)
    ans = []
    for a in A:
        ans.append(S ^ a)
    return ans


def main():
    N = read_int()
    A = read_int_n()
    print(*slv(N, A))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

from collections import Counter
N = int(input())
As = list(mapint())

cum = 0
for a in As:
    cum^=a
A = []
for a in As:
    ans = cum^a
    A.append(str(ans))
print(' '.join(A))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from operator import xor
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input())
    a = [int(ai) for ai in input().split()]

    x = reduce(xor, a)

    sol = [x ^ i for i in a]
    print(*sol)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

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

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
*A, = map(int, input().split())
x = 0
for a in A:
    x ^= a
for a in A:
    print(x^a, end=" ")

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(*ans)

Submission status: Accepted

Solution code:
# import sys

# n = int(input())

# result = []
# k = 26
# i = 1

# while k < n:
# 	n -= k
# 	k *= 26
# 	i += 1

# length = i
# n -= 1

# pow26 = 1
# for i in range(length):

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

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

result = map(lambda x: str(x ^ s), a)
print(" ".join(result))

Submission status: Accepted

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

al=0
for ele in A:
    al=al^ele

for ele in A:
    print(al^ele)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    N = int(input())
    A = list(map(int,input().split()))
    tot = 0
    for a in A:
        tot ^= a
    
    ans = []
    for a in A:
        ans.append(tot^a)
    print(*ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

xor_total = 0
for sunuke in a:
    xor_total = xor_total ^ sunuke

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

Submission status: Accepted

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