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: Wrong Answer

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

for i in range(N):
    ans = 0
    for j in range(60):
        x = 0
        for k in range(N):
            if i == k:
                continue
            if A[k] >> j & 1:
                x += 1
        if x % 2 == 1:
            ans += 2**i
    print(ans)

Submission status: Wrong Answer

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

total=0
for i in range(n):
  total=total^a[i]
  
result=[]
for i in range(n):
  result.append(total^a[i])
print(result)

Submission status: Wrong Answer

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

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

b = [0]*32
for i in range(N):
    a = A[i]
    for j in range(32):
        b[j] += a % 2
        b[j] %= 2
        a >>= 1
        if a <= 0:
            break

for i in range(N):
    ans = 0
    k = 1
    a = A[i]
    for j in range(32):
        m = a % 2
        ans += k * ((b[j] + m)%2)
        k *= 2
        a >>= 1
        if a <= 0:
            break
    print(ans, end=' ')
print()

Submission status: Wrong Answer

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):
            ans[j]+=((a[j]>>i)&1)*pow(2,i)
    else:
        for j in range(n):
            if (a[j]>>i)&0==0:
                ans[j]+=pow(2,i)

print(*ans)

Submission status: Wrong Answer

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

    ANS = []
    B = [False] * 32

    for i in range(1, n):
        s = format(A[i], '032b')
        for ci, c in enumerate(s):
            if c == '1':
                B[ci] = not B[ci]

        sa = ''
        for b in B:
            if b:
                sa += '1'
            else:
                sa += '0'

        ANS.append(int(sa, 2))

    ANS.append(A[0])

    print(*ANS)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    a = list(map(int, input().split()))
    # 自分以外全体のxorがわかっている状態
    ans = a
    for i in range(10):
        c0,c1 = 0,0
        for j in range(N):
            if (a[j]>>i)&1:
                c1+=1
        if c1%2==0:
            ans[j] += (a[j]>>i)*pow(2,i)
    print(*ans)

main()

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
cnt = 0
cntcnt = 0
new = []
for i in range(N):
  num = 0
  l = list(range(N))
  l.remove(l[i])
  for j in l:
    if cntcnt == 0:
      num = a[j]
    else:
      num = a[j]^num
    cntcnt += 1
  new.append(num)
  cnt += 1
print(new)

Submission status: Wrong Answer

Solution code:
N = input()
strs = input().split(" ")
nums = list(map(int,strs ))
all = []
ma = max(nums)

print(ma)
ma_l = len(format(ma,"b"))
all_nums = [0] * ma_l



for num in nums:
    bins = format(num,"b")
    
    bins = bins[::-1]
    for i,c in enumerate(bins):
        if c == "1":
            all_nums[i] += 1

all_nums.reverse()
anss = []
for num in nums:
    s = num
    bins = format(num,"b")
    bins = bins[::-1]
    ans = 0
    jo  = 1
    for i in range(ma_l):
        
        if len(bins) - 1 < i:
            hoge = 0
        else:
            c = bins[i]
            hoge = int(c ) 
        if (all_nums[i] - hoge) % 2 == 1:
            ans += jo 
        jo *= 2
    anss.append(ans)
print(*anss)

Submission status: Wrong Answer

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

ans = "0"

for i in range(1, n):
    a = l[i] ^ l[0]
    ans += " {}".format(a)

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
s = [0] * 30
t = [1] * 30
for i in range(29):
    t[i + 1] = t[i] * 2
for i in range(N):
    aa = a[i]
    for j in range(30):
        if aa == 0:
            break
        s[j] = (s[j] + aa)%2
        aa = aa//2
for i in range(N):
    ans = a[i]
    b = a[i]
    for j in range(30):
        if b == 0:
            break
        ans1 = b%2
        b = b//2
        if s[j] == 1:
            if ans1 == 1:
                ans -= t[j] 
            else:
                ans += t[j]
    print(ans,end = " ")
print()

Submission status: Wrong Answer

Solution code:
N=int(input())
a_list=list(map(int,input().split()))
a_list.sort(reverse=True)
c_list=[None]*N

c_list[0]=2**(len(bin(a_list[0])[2:]))
b=a_list[0]

for i,a in enumerate(a_list[1:]):
    c_list[1+i]=b^a^c_list[i]
    b=a

ans=" ".join(list(map(str,c_list)))
print(ans)

Submission status: Wrong Answer

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"+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):
        try:
            
            if a[j][i]==t[i]:
                ans[j].append("0")
            else:
                ans[j].append("1")
        
        except:
            sys.exit()

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
a = list(map(int, input().split()))
a = [format(i, '019b') for i in a]
ans = [''] * N
for i in range(19):
    tmp = [int(t[i]) for t in a]
    if Counter(tmp)[0] % 2 == 0:
        for j in range(N):
            ans[j] += str(tmp[j])
    else:
        for j in range(N):
            if tmp[j]:
                ans[j] += str(0)
            else:
                ans[j] += str(1)
for tp in ans:
    print(int('0b'+tp, 0))

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
x=[0]*32
saka=[2**i for i in range(32)]
b=[[] for i in range(len(A))]
for i,a in enumerate(A):
  j=0
  while a>0:
    _=a%2
    b[i].append(_)
    x[j]=(x[j]+_)%2
    a=a>>1
    j+=1
ans=[]
for i in range(N):
  j=0
  _=0
  while j<len(b[i]):
    _+=abs(x[j]-b[i][j])*saka[j]
    j+=1
  ans.append(_)
print(*ans)

Submission status: Wrong Answer

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

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

if bit == a[0]:
    print(' '.join(map(str, ans)))
else:
    index = 0
    for i in range(1, 10 ** 6 + 1):
        bit = bit ^ (i - 1) ^ i
        if bit == a[0]:
            index = i
            break

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

ans = []

for i in range(N - 1):
    ans.append(a[i] & a[i + 1])

ans.append(a[0] & a[N - 1])

print(*ans)

Submission status: Wrong Answer

Solution code:
n = (int)(input())
a = list(map(int, input().split(" ")))
xor = []
ans = 0
for i in range(1, 2 * (10 ** 5 + 1)):
    xor = []
    test = 1
    for j in range(n):
        xor.append(a[0] ^ i)
    for j in range(n - 1):
        test *= xor[j]
    if test == xor[-1]:
        ans = i
        break
#print(ans)
txt = ""
for i in range(n):
    txt += (str)(a[i] ^ ans)
    if i != n - 1:
        txt += " "
print(txt)

Submission status: Wrong Answer

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)
print(ans, end="")

Submission status: Wrong Answer

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"+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"+a[i]
except:
    sys.exit()


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

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

Submission status: Wrong Answer

Solution code:
n = int(input())

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

ans = []
for i in range(int(n/2)):
  tmp = bin(a_list[2*i]^a_list[2*i+1])
  a_1 = 0
  a_2 = 0
  k = len(tmp[2:])
  for j in range(len(tmp[2:])):
    if tmp[2:][j] == '1':
      a_1 += 2**(k-1-j)
  ans.append(a_1)
  ans.append(a_2)

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

Submission status: Wrong Answer

Solution code:
N=int(input())
a_list=list(map(int,input().split()))
a_list.sort(reverse=True)
c_list=[None]*N

c_list[0]=2**(len(bin(a_list[0])[2:])-1)
b=a_list[0]

for i,a in enumerate(a_list[1:]):
    c_list[1+i]=b^a^c_list[i]
    b=a

ans=" ".join(list(map(str,c_list)))
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
x=[0]*35
b=[[] for i in range(len(A))]
for i,a in enumerate(A):
  j=0
  while a>0:
    _=a%2
    b[i].append(_)
    x[j]=(x[j]+_)%2
    a=a>>1
    j+=1
ans=[]
for i in range(N):
  j=0
  _=0
  while j<len(b[i]):
    _+=abs(x[j]-b[i][j])*2**j
    j+=1
  ans.append(_)
print(*ans)

Submission status: Wrong Answer

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

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

ans = []

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

ans.append(a[0] ^ a[N - 1])

print(*ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a = list(map(int,input().split()))
matrix = [[0 for j in range(19)] for i in range(n)]
total = [0 for j in range(19)]

for j in range(n):
  target = a[j]
  for i in range(19):
    matrix[j][18-i] = a[j]//(2**(18-i))
    total[18-i] += a[j]//(2**(18-i))
    a[j] = a[j]%(2**(18-i))

for k in range(19):
  total[k] = total[k]%2
#print(total)

for l in range(n):
  judge = [0 for j in range(19)]
  answer = 0
  for m in range(19):
    judge[m] = (matrix[l][m]+total[m])%2
    answer += (2**m)*((matrix[l][m]+total[m])%2)
  #print(judge)
  print(answer,end=" ")

Submission status: Wrong Answer

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: Wrong Answer

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

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

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(f^a)

Submission status: Wrong Answer

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

k = len(bin(max(a))) - 2

for i in range(n):
    a[i] = format(a[i], '031b')
    print(int(a[i][-k]+a[i][-k+1:-1].replace('0', '2').replace('1', '0').replace('2', '1')+a[i][-1], 2), end=' ')

Submission status: Wrong Answer

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: Wrong Answer

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"+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"+a[i]
except:
    sys.exit()


try:
    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")
except:
    sys.exit()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = 0
ans_list = []
for i in a:
  s = str(bin(i))
  s = s[2:]
  ans_list.append(int(s))
  ans += int(s)
z = []
for i in ans_list:
  z.append(ans - i)
f = []
for i in z:
  e = []
  for j in str(i):
    if int(j) % 2 == 0:
      j = 0
    if int(j) % 2 == 1:
      j = 1
    e.append(str(j))
  f.append(''.join(e))
h = []
for i in f:
  h.append(int(i, 2))
print(*h)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=[]
b=a.copy()
del b[0]
a1=0
a2=a[1]
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: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = 0
ans_list = []
for i in a:
  s = str(bin(i))
  s = s[2:]
  ans_list.append(int(s))
  ans += int(s)
z = []
for i in ans_list:
  z.append(ans - i)
f = []
for i in z:
  e = []
  for j in str(i):
    if int(j) % 2 == 0:
      j = 0
    if int(j) % 2 == 1:
      j = 1
    e.append(str(j))
  f.append(''.join(e))
h = []
for i in f:
  h.append(int(i, 2))
print(h)

Submission status: Wrong Answer

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

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

first = 0
tmp = 0

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

#A_bin = [bin(x)[2:] for x in A]
#A_bin = [bin(x) for x in A]
#maxlen = max([len(x) for x in A_bin])
#A_bin = [x.zfill(maxlen) for x in A_bin]

ans = ["" for _ in range(N)]
ans[0] = str(0)
A0 = A[0]
for i in range(1,N):
    xor = bin(A0 ^ A[i])
    ans[i] = str(int(xor,0))
print(" ".join(ans))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from math import factorial, sqrt, ceil, gcd
from functools import lru_cache, reduce
from decimal import Decimal
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
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

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定
def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True


# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
n = int(input())
a = list(map(int, input().split()))
total = 10 ** 9
ans = [total^i for i in a]
print(*ans)

Submission status: Wrong Answer

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

def solver(l, idx):
    l.pop(idx)
    ret = l.pop()
    for el in l:
        ret = ret ^ el
    return ret

ans = []
for i in range(n):
    ans.append(solver(a.copy(), i))
print(ans)

Submission status: Wrong Answer

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

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

print(result)

Submission status: Wrong Answer

Solution code:
n=int(input())
a = list(map(int,input().split()))
matrix = [[0 for j in range(19)] for i in range(n)]
total = [0 for j in range(19)]

for j in range(n):
  target = a[j]
  for i in range(19):
    matrix[j][18-i] = a[j]//2**(18-i)
    total[18-i] += a[j]//2**(18-i)
    a[j] = a[j]%2**(18-i)

for k in range(19):
  total[k] = total[k]%2
#print(total)

for l in range(n):
  judge = [0 for j in range(19)]
  answer = 0
  for m in range(19):
    judge[m] = (matrix[l][m]+total[m])%2
    answer += (2**m)*((matrix[l][m]+total[m])%2)
  #print(judge)
  print(answer,end=" ")

Submission status: Wrong Answer

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

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

print(result)

Submission status: Wrong Answer

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

    ANS = []
    B = [False] * 32
    for a in A:
        s = format(a, '032b')
        for ci, c in enumerate(s):
            if c == '1':
                B[ci] = not B[ci]

        sa = ''
        for b in B:
            if b:
                sa += '1'
            else:
                sa += '0'

        ANS.append(int(sa, 2))

    print(*ANS)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
a_list = list(map(int, input().split()))

x_list = [1]
for i in range(1, n):
    x_list.append(a_list[0] ^ a_list[i] ^ x_list[0])

for i in range(0, n):
    print(x_list[i], end=" ")

Submission status: Wrong Answer

Solution code:
import numpy as np


def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    k = max(a).bit_length()
    c = np.zeros(n, dtype=np.int)
    for i in range(k):
        b = np.array([ai // 2**i % 2 for ai in a], dtype=np.int)
        if b.sum() % 2:
            b = 1 - b
        print(b)
        c += b * 2**i
    print(*c)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
ls = list(map(int,input().split()))
di= [0]*n
for i in range(n):
    di[i] = int(bin(ls[i])[2:])
s = sum(di)
fi = list(str(s))
for j in range(len(str(s))):
    if int(fi[j]) % 2 == 0:
        fi[j] = 0
    else:
        fi[j] = 1
fi = list(map(str,fi))
ss = int("".join(fi))
pi = []
for k in di:
    a = ss+k
    b = list(str(a))
    for j in range(len(str(a))):
        if int(b[j]) % 2 == 0:
            b[j] = 0
        else:
            b[j] = 1
    c = list(map(str,b))
    pi.append(int("".join(c),2))
print(*pi)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
lis = []
for i in range(n-1):
    lis.append(a[i]^a[i+1])
ans = [26]
for i in range(n-1):
    ans.append(ans[i]^lis[i])
for i in range(len(ans)):
    ans[i] = str(ans[i])
print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
def resolve():
    n=int(input())
    a = list(map(int, input().split()))
    c = [str(x) for x in a]
    L = " ".join(c)
    print(L)
resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools

n=int(input())

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

ans = []

for v in itertools.combinations(t, n-1):
    memo = v[0]
    for i in range(1,len(v)):
        memo = memo ^ v[i]
    ans.append(memo)
print(*ans)

Submission status: Wrong Answer

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

A = []
total = 0
for i in range(N):
    n = int(format(a[i], 'b'))
    A.append(n)
    total += n

total = str(total)
Total = ''

for i in range(len(total)):
    if int(total[i]) % 2 == 0:
        Total = Total + '0'
    else:
        Total = Total + '1'

Total = int(Total)
result = []

for i in range(N):
    tmp = Total + A[i]
    tmp = str(tmp)
    m = ''
    for i in range(len(tmp)):
        if int(tmp[i]) % 2 == 0:
            m = m + '0'
        else:
            m = m + '1'
    m = int(m, 2)
    result.append(m)

print(*result)

Submission status: Wrong Answer

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


def calc_total(A):
    total = []
    for x, y in zip(A, A[1:]):
        total.append(x ^ y)
    return total


total = A
while len(total) != 1:
    total = calc_total(total)
total = total[0]
ans = []
for a in A:
    ans.append(total ^ a)
print(*ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
ls = list(map(int,input().split()))
di= [0]*n
#10進数→n進数への書き換え(nは1<=n<=10を満たす自然数)
def n_base(v,n): #1<=n<=10でお願いします
    if v == 0:
        return 0
    k = 0
    ls = []
    while v - n**k >= 0:
        k += 1
    k -= 1
    for i in range(k+1):
        l = k-i
        a = v // n**l
        v = v % n**l
        ls.append(str(a))
    return int("".join(ls))
for i in range(n):
    di[i] = n_base(ls[i],2)
s = sum(di)
fi = list(str(s))
for j in range(len(str(s))):
    if int(fi[j]) % 2 == 0:
        fi[j] = 0
    else:
        fi[j] = 1
fi = list(map(str,fi))
ss = int("".join(fi))
pi = []
for k in di:
    a = ss+k
    b = list(str(a))
    for j in range(len(str(a))):
        if int(b[j]) % 2 == 0:
            b[j] = 0
        else:
            b[j] = 1
    c = list(map(str,b))
    pi.append(int("".join(c),2))
print(*pi)

Submission status: Wrong Answer

Solution code:
# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


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

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

    oore = dict()
    for k, v in digits.items():
        oore[k] = v % 2

    nums = [0] * N

    # for i, a in enumerate(As):
    #     for d in range(30):
    #         nums[i] += ((a >> d & 1) ^ (oore[d])) << d

    return nums


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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

i=29

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

    s=sum(curbit)

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



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

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

Submission status: Wrong Answer

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

print(blist)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
ans = []
for x in a:
    s = '1'*(len(str(x)))
    ans.append(x^int(s))
print(*ans)

Submission status: Wrong Answer

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

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

A = 0

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

print(b)

Submission status: Wrong Answer

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

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