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:
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]

####

from collections import defaultdict as ddic

def solve(N, A):
    X = 0
    for x in A: X^=x
    return [X^x for x in A]


ans = solve(rri(), rrm())
print " ".join(map(str, ans))

Submission status: Accepted

Solution code:
def main():
    n=int(input())
    A=list(map(int,input().split()))
    acc=0
    for a in A:
        acc^=a
    Ans=[0]*n
    for i,a in enumerate(A):
        Ans[i]=acc^a
    print(*Ans)
    
if __name__=='__main__':
    main()

Submission status: Accepted

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

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: Runtime Error

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

x = reduce(lambda x, y: x ^ y, A)
print(*[x ^ a for a in A])

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int, input().split()))
S=A[0]
for i in range(N-1):
  S=S^A[i+1]
L=[0]*N
for i in range(N):
  L[i]=A[i]^S
print(*L)

Submission status: Runtime Error

Solution code:
from math import log2
N = int(input())
a = list(map(int, input().split()))
Maxa = max(a)
J = int(log2(Maxa)) + 1
A = [format(x, 'b').zfill(J) for x in a]
S = [0] * J
for j in range(J):
  for i in range(N):
    S[j] += int(A[i][j])
  S[j] %= 2
  
X = [""] * N
for i in range(N):
  for j in range(J):
    X[i] += str(int((int(A[i][j]) != S[j])))
  print(int(X[i], 2), end = " ")

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

N = int(input())
A = array.array("L", map(int, input().split()))

Q = array.array("L", [0]) * N

array.array("L", (A[n] for n in range(N) if n!=i))

R = reduce(xor, A)
for i in range(N):
    print(R^A[i])

Submission status: Runtime Error

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

N = int(input())
A = array.array("L", map(int, input().split()))

Q = array.array("L", [0]) * N

array.array((A[n] for n in range(N) if n!=i))

R = reduce(xor, A)
for i in range(N):
    print(R^A[i])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
a = list(map(int, input().split()))
all_xor = 0
for _a in a:
    all_xor = all_xor ^ _a
for _a in a:
    print(all_xor ^ _a)

Submission status: Runtime Error

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

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

pop=0 #xorのpopにする
while(xor >> pop >=1):
    pop += 1

sum_xor=0 #各猫の排他的論理和
if N%2==1:
    for i in range(pop):
        sum_xor += 2 **i
else:
    sum_xor=xor

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

Submission status: Runtime Error

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

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

pop=0 #xorのpopにする
while(xor >> pop >=1):
    pop += 1

sum_xor=0 #各猫の排他的論理和
if N%2==1:
    for i in range(pop):
        sum_xor += 2 **i
else:
    sum_xor=xor

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

num_list = []
sum = 0
for i in range(n):
  num = numbers[i]
  num_str = ''
  while num != 0:
    p = num % 2
    num_str = str(p) + num_str
    num = num // 2
  #print(num_str)
  num = int(num_str)
  sum += num
  num_list.append(num)
#print(sum)
#print(num_list)
ans = []
for i in range(n):
  num = sum - num_list[i]
  num = str(num)
  l = len(num)
  m = 0
  for j in range(len(num)):
    k = num[j]
    k = int(k) % 2
    m += k * 2 ** (l - 1)
    l -= 1
  ans.append(str(m))
print(' '.join(ans))

Submission status: Runtime Error

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 ^ i,ende="")

Submission status: Runtime Error

Solution code:
n=int(input(""))
a=[]
ans=[1]
ain=input("").split(" ")
for i in range(n):
    a+=[int(ain[i])]
s=a[1]
for i in range(n-2):
    s^=a[i+2]
ans[0]=s
for i in range(n-1):
    s=s^a[i]
    s^=a[i+1]
    ans+=s
print(" ".join(ans))

Submission status: Runtime Error

Solution code:
n = int(input())
a = input().split(" ")

s = a[0]

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

ans = [0]*n

for i, num in enumerate(a):
	ans[i] = s^num

print(*ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = input().split(" ")

s = a[0]

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

ans = [0]*n

for i, num in enumerate(a):
	ans[i] = s^num

print(*ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
L=len(A)
S=sum(A)

for i in range(Q):
    ans=0
    B,C=map(int,input().split())
    for j in range(L):
        if A[j]==B:
            A[j]=C
            S+=(C-B)
    ans=S
    print(ans)

Submission status: Runtime Error

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

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

d = []
for i in range(1, math.floor(math.log(N)) + 2):
    a_i = (N - 2 ** (N + 1) + 1) % i
    is1_i = (a_i % 2) == 1 and a_i <= 2 ** (i - 1) - 1
    d.append(1 if is1_i else 0)

sum_2 = d[::-1]

for a in A:
    num = 0
    ai_2 = ''
    while a > 0:
        ai_2 += str(a % 2)
        a //= 2
    
    ai_2 = ai_2[::-1]
    
    for i in range(len(sum_2)):
        num *= 10
        if ai_2[i] != sum_2[i]:
            num += 1
    
    ans = 0
    for i in range(len(sum_2)):
        ans += (2 ** i) * (num % 2)
        num //= 10
    
    print(ans, end=' ', flush=True)

Submission status: Runtime Error

Solution code:
        n = int(input())
        xor_arr = list(map(int, input().split()))
        xor_of_xor = 0
        for elm in xor_arr:
            xor_of_xor = xor_of_xor ^ elm
        scarf_val = [xor_of_xor ^ elm for elm in xor_arr]
        print(" ".join(str(x) for x in scarf_val))

Submission status: Runtime Error

Solution code:
    n = int(input())
    xor_arr = list(map(int, input().split()))
    xor_of_xor = 0
    for elm in xor_arr:
        xor_of_xor = xor_of_xor ^ elm
    scarf_val = [xor_of_xor ^ elm for elm in xor_arr]
     
    print(" ".join(str(x) for x in scarf_val))

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
l = [0] * 30
b = []
for i in range(n):
  x = a[i]
  t = ''
  j = 29
  while j >= 0:
    if x < 2**j:
      t += '0'
    else:
      x -= 2**j
      t += '1'
      l[j] += 1
    j -= 1
  b.append(t)
ans = []
for i in range(n):
  t = b[i]
  for j in range(30):
    k = l[j]
    if t[j] == '1':
      k += 1
    k %= 2
    d += k * 2**j
  ans.append(d)
print(*ans)

Submission status: Runtime Error

Solution code:
n = int(input())
arr = list(map(int,input().split()))
xors = 0
for val in arr:
  xors^=val
ans = []
for i in range(n):
  ans.append(xros^arr[i])
  
print(*ans)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
A = A + A
ans = [0] * N
a = 0
for i in range(N-1):
    a ^= A[i]
ans[N-1] = a
W = N - 1
for i in range(N-1):
    remove = A[i]
    addition = A[i+W]
    a = remove^a^addition
    ans[i] = a

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

Submission status: Runtime Error

Solution code:
import copy

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

target = A[0] ^ A[1] ^ A[2] ^ A[3]

results = [''] * n

for i in range(n):
    results[i] = str(target ^ A[i])

print(" ".join(results))

Submission status: Runtime Error

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

def all_xor(l):
    while len(l) != 1:
        l[0] ^= l[1]
        l.pop(1)
    return l[0]

s = []
for i in range(len(a)):
    s.append(all_xor(a[0:i] + a[i+1:]))

print(' '.join(s))

Submission status: Runtime Error

Solution code:
n=int(input())
a=(int(i) for i input().split())
b=0
for i in a:b^=i
print(*(i^b for i in a))

Submission status: Runtime Error

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

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

print(*b)

Submission status: Runtime Error

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

def mi(): return map(int,input().split())
def lmi(): return list(map(int,input().split()))
def ii(): return int(input())
def isp(): return input().split()



n=ii()
a=lmi()
S=0
for i in a:
  S=S^i

b=[]
for i in a:
  a_=S^i
  b.append(a_)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def main():
    _ = int(input())
    a = tuple(map(int, input().split()))

    res = 0
    for i in a:
        res ^= i
    ans = [res ^ j for j in a]
    for k in ans:
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import numpy as np
n=int(input())
*a,=map(int, input().split())
x=0
for ai in a:
    x^=ai

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

Submission status: Runtime Error

Solution code:
n=int(input())
A=list(map(int,input().split()))
B=reduce(lambda a,b:a^b,A)
ans=map(lambda x:x^B,A)
print(*ans)

Submission status: Runtime Error

Solution code:
def main():
  N=int(input())
  a=list(map(int,input().split()))
  p=max(a)
  m=len(bin(p))-2
  for i in range(N):
    b=len(bin(a[i]))-2
    ans=0
    for j in range(b):
      if a[i]>>j&1==1:
        if j==m-1 or j==0:
          ans+=pow(2,j)
      else:
        if j==m-1 or j==0:
          continue
        ans+=pow(2,j)
    print(ans,end=' ')
if __name__=='__main__':

Submission status: Runtime Error

Solution code:
for i in a:=[*map(int,[*open(x:=0)][1].split())]:x^=i
for i in a:print(x^i)

Submission status: Runtime Error

Solution code:
import numpy as np
import math
import collections
import bisect
import itertools
from collections import Counter

suf_xor_dict = {}
pre_xor_dict = {}


def suf_xor(N, p):
    # print(p)
    global xor_dict
    if N - len(p) + 1 in suf_xor_dict:
        return suf_xor_dict[N - len(p) + 1]

    if len(p) == 0:
        return 0
    if len(p) == 1:
        suf_xor_dict[N] = p[0]
        return p[0]
    if len(p) == 2:
        suf_xor_dict[N] = p[1]
        suf_xor_dict[N - 1] = p[0] ^ p[1]
        return(p[0] ^ p[1])
    else:
        ret = p[0] ^ suf_xor(N, p[1:])
        suf_xor_dict[N - len(p) + 1] = ret
        return ret


def pre_xor(N, p):
    global pre_xor_dict
    if len(p) in pre_xor_dict:
        return pre_xor_dict[len(p)]

    if len(p) == 0:
        return 0
    if len(p) == 1:
        pre_xor_dict[1] = p[0]
        return p[0]
    if len(p) == 2:
        pre_xor_dict[1] = p[0]
        pre_xor_dict[2] = p[0] ^ p[1]
        return(p[0] ^ p[1])
    else:
        ret = p[-1] ^ pre_xor(N, p[:-1])
        pre_xor_dict[len(p)] = ret
        return ret


def main():
    N = int(input())
    a = list(map(int, input().split()))
    ans = []
    last = pre_xor(N, a[:N - 1]) ^ suf_xor(N, a[N:])
    for i in range(N - 1):
        ans.append(pre_xor(N, a[:i]) ^ suf_xor(N, a[i + 1:]))

    ans.append(last)
    for item in ans:
        print(item, end=' ')
    print('')


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N=int(input())
arr = list(map(int,list(input().split())))
ds = set(arr)
############################################

allxor=0
for i in range(N):
	allxor=allxor ^ ds.pop()

for i in range(N):
	if i==0 :
		s=str(allxor ^ arr[i])
	else:
		s=s + ' ' + str((allxor ^ arr[i]))

print(s)

Submission status: Runtime Error

Solution code:
import copy

n = int(input())
A = list(map(int, input().split()))
B = copy.deepcopy(A)
results = [''] * n
maxvalue = max(A)
maxvalue2 = max(A)
targetValue = ''
while maxvalue > 0:
    mod = 0
    maxvalue = maxvalue >> 1
    for idx, a in enumerate(A):
        mod += a % 2
        A[idx] = a >> 1
    targetValue = str(mod % 2) + targetValue
for i in range(n):
    maxvalue2 = max(B)
    tmpValue = int(targetValue, 2)
    while maxvalue2 > 0:
        results[i] = str((tmpValue % 2 + B[i] % 2) % 2) + results[i]
        tmpValue = tmpValue >> 1
        B[i] = B[i] >> 1
        maxvalue2 = maxvalue2 >> 1
answers = [''] * n
for idx, res in enumerate(results):
    answers[idx] = str(int(res, 2))
print(" ".join(answers))

Submission status: Runtime Error

Solution code:
import numpy as np
import math
import collections
import bisect
import itertools
from collections import Counter

suf_xor_dict = {}
pre_xor_dict = {}


def suf_xor(N, p):
    # print(p)
    global xor_dict
    if N - len(p) + 1 in suf_xor_dict:
        # print("memo")
        return suf_xor_dict[N - len(p) + 1]
    if len(p) == 0:
        return 0
    if len(p) == 1:
        return p[0]
    if len(p) == 2:
        suf_xor_dict[N - 1] = p[0] ^ p[1]
        return(p[0] ^ p[1])
    else:
        ret = p[0] ^ suf_xor(N, p[1:])
        suf_xor_dict[N - len(p) + 1] = ret
        return ret


def pre_xor(N, p):
    global pre_xor_dict
    if N - len(p) + 1 in pre_xor_dict:
        # print("memo")
        return pre_xor_dict[N - len(p) + 1]
    if len(p) == 0:
        return 0
    if len(p) == 1:
        return p[0]
    if len(p) == 2:
        pre_xor_dict[N - 1] = p[0] ^ p[1]
        return(p[0] ^ p[1])
    else:
        ret = p[-1] ^ pre_xor(N, p[:-1])
        pre_xor_dict[N - len(p) + 1] = ret
        return ret


def main():
    N = int(input())
    a = list(map(int, input().split()))
    ans = []
    last = pre_xor(N, a[:N - 1]) ^ suf_xor(N, a[N:])
    for i in range(N - 1):
        ans.append(pre_xor(N, a[:i]) ^ suf_xor(N, a[i + 1:]))

    ans.append(last)
    for item in ans:
        print(item, end=' ')
    print('')


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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])
L=' '.join(result)
print(L)

Submission status: Runtime Error

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(' '.join(map(str, new)))

Submission status: Runtime Error

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

l = [0]*(2**max(A))
ll = []
for a in A:
  pattern = bin(a)[2:].zfill(N)
  for i in range(len(pattern)):
    if pattern[i] == '1':
      l[i] += 1

for a in A:
  ans = ''
  pattern = bin(a)[2:].zfill(N)
  for i in range(len(pattern)):
    if pattern[i] == '1' and int(l[i])%2 == 0:
      ans += '1'
    elif pattern[i] == '0' and int(l[i])%2 != 0:
      ans += '1'
    else:
      ans += '0'
  ll.append(int(ans,2))
print(*ll)

Submission status: Runtime Error

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

lis = []
for a in A:
    stra = str(a)
    S = '0b'
    i = 0
    for s in stra:
        s = 0 | (a >> i)
        if i%2 == 0:
            S = s + S
        else:
            if s == '0':
                S = '1' + S
            else:
                S = '0' + S
        i += 1
    lis.append(int(S))
print(*S)

Submission status: Runtime Error

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *

N = INT()
a = LIST()



n = ceil(log2(max(a)))

A = ["{:b}".format(x).zfill(n) for x in a]


b = a[0]
for i in range(1, N):
	b ^= a[i]
b = "{:b}".format(b).zfill(n)


ans = []

for x in A:
	tmp = 0
	for i in range(n):
		tmp += ((int(b[i])+int(x[i]))%2) * (2**(n-1-i))

	ans.append(tmp)

print(*ans)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    a = list(map(int, input().split()))
    X = max(a)
    L = len(bin(X)) - 2
    print(L)
    now = 0
    for i in range(N):
        now ^= a[i]
    print(now)
    b = list(format(now, 'b').zfill(L))
    print(b)
    ans = []
    for i in range(N):
        s = list(format(a[i], 'b').zfill(L))
        for j in b:
            if j == '0':
                continue
            if s[int(j)] == '0':
                s[int(j)] = '1'
            else:
                s[int(j)] = '0'
        ans.append("".join(s))
    print(int(*ans))
    
    
        

    # print(int(format(a[0],'b').zfill(L)))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
for i in range(n):
    ans=0
    for j in a:
        if j!=a[i]:
            ans^=j
    aa.append(a)
print("".join(aa))

Submission status: Runtime Error

Solution code:
import numpy as np

n = int(input())
a = list(map(int,input().split()))
a = np.array(a,dtype=np.int64)
b = [((a>>i)&1).sum() for i in range(21)]
li = []
for i in a:
    c = np.array([((i>>j)&1) for j in range(21)],dtype=np.int64)
    d = b-c
    point = 0
    for i in range(31):
        if d[i]%2 == 1:
            point += 2**(i)
    li.append(point)

print(*li)

Submission status: Runtime Error

Solution code:
import math
a = input()
num = int(a)
p = input().rstrip().split(" ")
k=[]
for i in p:
    k.append(int(i))
for i in range(num):
    list = k
    del list[i]
    ans = []
    while True:
        if sum(list)==0:
            break
        if sum(list) % 2 == 0:
            ans.append(0)
        else:
            ans.append(1)
        list = math.floor(list/2)
    l = 0
    for i in ans:
        l += (2*i)*ans
    print(l, end="")

Submission status: Runtime Error

Solution code:
import math

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

a_max = math.log(max(a), 2)
flag = pow(2, math.floor(a_max))-2
print(*list(map(lambda x:x^flag, a)))

Submission status: Runtime Error

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+2]

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

Submission status: Runtime Error

Solution code:
import numpy as np
import math
import collections
import bisect
import itertools
from collections import Counter

suf_xor_dict = {}
pre_xor_dict = {}


def suf_xor(N, p):
    # print(p)
    global xor_dict
    if N - len(p) + 1 in suf_xor_dict:
        # print("memo")
        return suf_xor_dict[N - len(p) + 1]
    if len(p) == 0:
        return 0
    if len(p) == 1:
        return p[0]
    if len(p) == 2:
        suf_xor_dict[N - 1] = p[0] ^ p[1]
        return(p[0] ^ p[1])
    else:
        ret = p[0] ^ suf_xor(N, p[1:])
        suf_xor_dict[N - len(p) + 1] = ret
        return ret


def pre_xor(N, p):
    global pre_xor_dict
    if N - len(p) + 1 in pre_xor_dict:
        # print("memo")
        return pre_xor_dict[N - len(p) + 1]
    if len(p) == 0:
        return 0
    if len(p) == 1:
        return p[0]
    if len(p) == 2:
        pre_xor_dict[N - 1] = p[0] ^ p[1]
        return(p[0] ^ p[1])
    else:
        ret = p[-1] ^ pre_xor(N, p[:-1])
        pre_xor_dict[N - len(p) + 1] = ret
        return ret


def main():
    N = int(input())
    a = list(map(int, input().split()))
    ans = []
    for i in range(N):
        ans.append(pre_xor(N, a[:i]) ^ suf_xor(N, a[i + 1:]))
    for item in ans:
        print(item, end=' ')
    print('')


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *

N = INT()
a = LIST()

n = ceil(log2(max(a)))

A = ["{:b}".format(x).zfill(n) for x in a]


b = a[0]
for i in range(1, N):
	b ^= a[i]
b = "{:b}".format(b).zfill(n)


ans = []

for x in A:
	tmp2 = 0
	for i in range(n):
		tmp2 += ((int(b[i])+int(x[i]))%2) * (2**(n-1-i))

	ans.append(tmp2)

print(*ans)

Submission status: Runtime Error

Solution code:
import sys
from typing import Callable, List, NoReturn

import numpy as np


def main() -> NoReturn:
    readline: Callable[[], str] = sys.stdin.readline
    n: int = int(readline().rstrip())
    a: np.ndarray = np.array(tuple(int(_) for _ in readline().rstrip().split()))

    xor_all: int = 0
    for a_n in a:
        xor_all ^= a_n

    values = np.bitwise_xor(a, xor_all)
    print(" ".join(values))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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


#print(a)
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")
#print(ans)
for i in ans:
    print(int("".join(i), 2))

Submission status: Runtime Error

Solution code:
aa

Submission status: Runtime Error

Solution code:
a

Submission status: Runtime Error

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


#print(a)
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")
#print(ans)
for i in ans:
    print(int("".join(i), 2))

Submission status: Runtime Error

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

for i in range(n):
    if len(a[i])<max_len:
        a[i]="0"+a[i]
#print(a)
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")
#print(ans)
for i in ans:
    print(int("".join(i), 2))

Submission status: Runtime Error

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))
#print(max_len)
if len(t)<max_len:t="0"+t
#print(t)
a=list(map(lambda x : bin(x)[2:],a))
for i in range(n):
    if len(a[i])<max_len:
        a[i]="0"+a[i]
#print(a)
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")
#print(ans)
for i in ans:
    print(int("".join(i), 2))

Submission status: Runtime Error

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=len(bin(max(a)))-2
#print(max_len)
if len(t)<max_len:t="0"+t
#print(t)
a=list(map(lambda x : bin(x)[2:],a))
for i in range(n):
    if len(a[i])<max_len:
        a[i]="0"+a[i]
#print(a)
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")
#print(ans)
for i in ans:
    print(int("".join(i), 2))

Submission status: Runtime Error

Solution code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()
    num_list = i_list()

    sum_d = num_list[0] ^ num_list[1] ^ num_list[2] ^ num_list[3]

    ans_list = []
    for num in num_list:
        ans_list.append(sum_d ^ num)

    print(*ans_list)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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 True:
    curbit=[aa%2 for aa in a]

    s=sum(curbit)

    if s==0:
        break

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