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: Time Limit Exceeded

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(61)]
li = []
for i in a:
    c = np.array([((i>>j)&1) for j in range(61)],dtype=np.int64)
    d = b-c
    point = 0
    for i in range(61):
        if d[i]%2 == 1:
            point += 2**(i)
    li.append(point)

print(*li)

Submission status: Time Limit Exceeded

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

g = 0
for i in range(n):
    if i != 0:
        g = 0
    for j in range(n):
        if j != i:
            g = g ^ a[j]
    print(g, end=' ')

Submission status: Time Limit Exceeded

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

res =[]
for i in range(len(alphas)):
	
	r = None
	for j in range(len(alphas)):
		if j != i:
			if r is None:
				r = alphas[j]
			else:
				r ^= alphas[j]
	res.append(r)
print(*res)

Submission status: Time Limit Exceeded

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)
for i in range(N):
  if(i!=N-1):
    print(ans[i], end=" ")
  else:
    print(ans[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))
tmp = -1
ans = []
for i in range(N):
  for j in range(N):
    if i == j:
      continue
    else:
      if tmp == -1:
        tmp = A[j]
      else:
        tmp = tmp^A[j]
  ans.append(tmp)
  tmp = -1

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

Submission status: Time Limit Exceeded

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

for i in range(1, 10**9):
    x_list = [i]
    k = 0
    for i in range(1, n):
        x = a_list[0] ^ a_list[i] ^ x_list[0]
        x_list.append(x)
        k = k ^ x
    if a_list[0] == k:
        for i in range(0, n):
            print(x_list[i], end=" ")
        break

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

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

for i in range(0,n):
  loop=list(range(0,n))
  loop.pop(i)
  for j in loop:
    if (j == loop[0]): 
      atai=np_a[j]
    else:
      atai=atai ^ np_a[j]
  ans[i]=atai
  
print (*ans)

Submission status: Time Limit Exceeded

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

def biconv( x ):
    bi_x = []
    while len( bi_x ) <= 30:
        bi_x.append( x % 2 )
        x = x // 2
    return bi_x

def xor( x, y ):
    ans = []
    for i in range( len( x ) ):
        if x[ i ] + y[ i ] == 1:
            ans.append( 1 )
        else:
            ans.append( 0 )
    return ans

bi_a = []
for a_i in a:
    bi_a.append( biconv( a_i ) )

sum_x = [ 0 for _ in range( 31 ) ]
for a_i in bi_a:
    sum_x = xor( sum_x, a_i )

ans = []
for a_i in bi_a:
    x = xor( a_i, sum_x )
    ans_i = 0
    for i in range( 31 ):
        ans_i += ( 2 ** i ) * x[ i ]
    ans.append( ans_i )

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

Submission status: Time Limit Exceeded

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):
        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):
        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: Time Limit Exceeded

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 ** 9 + 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: Time Limit Exceeded

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(str(solver(a.copy(), i)))
print(" ".join(ans))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [bin(int(i)) for i in input().split(" ")]
max_len = len(str(max(a))[2:])

a = [str(i)[2:].zfill(max_len) for i in a]
#print(a)

answer_list = []
for k in range(n):
    answer_string = ""
    b = [one for i, one in enumerate(a) if i!=k]
    for y in range(max_len):
        string_num = 0
        for one in b:
            string_num = string_num ^ int(one[y])
        answer_string+=str(string_num)
    answer_list.append(str(int("0b" + answer_string, 0)))
print(" ".join(answer_list))

Submission status: Time Limit Exceeded

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

max_digit = 0
for i in range(N):
    a[i] = bin(a[i])[2:][::-1]
    max_digit = max(max_digit, len(a[i]))
    
for i in range(N):
    l = '0'*(max_digit-len(a[i]))
    a[i] += l
    a[i] = a[i][::-1]

digits = [0]*max_digit    
for i in range(max_digit):
    for j in range(N):
        if a[j][i] == '1':
            digits[i] += 1
    digits[i] %= 2

ans = ['']*N
for i in range(N):
    num = a[i]
    for j in range(max_digit):
        ans[i] += str((int(num[j]) + digits[j]) % 2)
    ans[i] = str(int(ans[i],2))
        
ans = ' '.join(ans)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int , input().split()))
b = []
for ai in a:
    b.append('{:0=30b}'.format(ai))

cnt = []
for j in range(30):
    tmp = 0
    for i in range(n):
        tmp += int(b[i][j])
    cnt.append(tmp)
ans = []
for bi in b:
    tmp = 0
    for i in range(30):
        idx = 29 + (-i)
        #print(idx)
        x = int(bi[i])
        if cnt[i] == 0:
            continue
        if cnt[i] % 2 == 0:
            tmp += x << idx
        else:
            if x == 0:
                tmp += 1 << idx
    ans.append(tmp)


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

"""
0000010100
0000001011
0000001001
0000011000

0000011010
0000000101
0000000111
0000010110
"""

Submission status: Time Limit Exceeded

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


ans = []
for i in range(n):
    temp = 0
    for j, aa in enumerate(a):
        if j == i:
            continue
        temp = temp ^ aa
    ans.append(temp)

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

Submission status: Time Limit Exceeded

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))
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: Time Limit Exceeded

Solution code:
def xor(x):
    for i in range(len(x)-1):
        x[i+1]=x[i]^x[i+1]
    return x[len(x)-1]
N=int(input())
a=list(map(int,input().split()))
for i in range(N):
    A=a.copy()
    del A[i]
    print(xor(A),end=" ")

Submission status: Time Limit Exceeded

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

result = ['' for _ in range(N)]

for i in range(N//2):
    if i < N -2:
        s_1 = A[2*i+1]
        s_2 = A[2*i]
        for j in range(2*i+2, N):
            s_1 = s_1 ^ A[j]
            s_2 = s_2 ^ A[j]
        result[2*i] = str(s_1)
        result[2*i+1] = str(s_2)
        m = s_1^s_2
        for j in range(2*i+2, N):
            A[j] = m^A[j]
 
    else:
        result.append(str(A[N-1]))
        result.append(str(A[N-2]))
        break

print(' '.join(result))

Submission status: Time Limit Exceeded

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

m = len(bin(max(a))[2:])
t = [0] * (m)

for i in range(n):
    bin_str_i = [int(s) for s in list(bin(a[i])[2:])]
    l = len(bin_str_i)
    for j in range(l):
        t[m - j - 1] += bin_str_i[l - j - 1]
x = ''
for j in range(m):
    if t[j] % 2 == 0:
        x += '0'
    else:
        x += '1'

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

Submission status: Time Limit Exceeded

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

maxA = max(A)
maxl = len(bin(maxA)[2:])
binary_c = [0 for _ in range(maxl)]
for a in A:
    for i, n in enumerate(bin(a)[2:].zfill(maxl)):
        if n == "1":
            binary_c[i] += 1
is_inv = []
for bc in binary_c:
    if bc % 2 == 0:
        is_inv.append(False)
    else:
        is_inv.append(True)

for a in A:
    l = []
    for i, n in enumerate(bin(a)[2:].zfill(maxl)):
        if is_inv[i]:
            if n == "0":
                l.append("1")
            else:
                l.append("0")
        else:
            l.append(n)
    print(int("".join(l), 2))

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict
def main():
    n = int(input())
    A = list(map(int, input().split()))
    d = defaultdict(int)
    for a in A:
        B = list(f'{a:030b}')
        for i, b in enumerate(B):
            if b == '1':
                d[i] += 1
    ANS = []
    for a in A:
        B = list(f'{a:030b}')
        ans = 0
        for i, b in enumerate(B):
            if b == '1':
                k = d[i] - 1
            else:
                k = d[i]
            if k % 2 == 1:
                ans += pow(2, 29 - i)
        ANS.append(str(ans))
    print(' '.join(ANS))





if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

allxor=0
for i in range(len(arr)):
	allxor=allxor ^ arr[i]


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

print(s)

Submission status: Time Limit Exceeded

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
        c += b * 2**i
    print(*c)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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


m = max(a)
for i in range(100):
    if 2**i>m:
        n = i
        break


mat = []
for j in a:
    b=[1 if j >> i &1 else 0 for i in reversed(range(n))] 
    mat.append(b)


for i in range(n):
    f = [part[i] for part in mat]
    if sum(f)%2==0:
        ans = f
#         print(ans)
    else:
        ans = [1 if j==0 else 0 for j in f]
#         print(ans)
    for j in range(len(ans)):
        mat[j][i] = ans[j]
res = []
for m in mat:
    ans = 0
    for i in range(len(m)):
        ans += 2**i*m[-i-1]
    
    res.append(ans)
print(" ".join(map(str,res)))

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    a = list(map(int,input().split()))
    l = len(format(max(a),'b'))
    a = [format(a[i],'0{}b'.format(l)) for i in range(n)]
    ans = [[] for i in range(n)]
    for i in range(l):
        t = []
        for j in range(n):
            t.append(int(a[j][i]))
        s = sum(t)
        b = []
        if s%2==0:
            b = t
        else:
            b = [(t[i]+1)%2 for i in range(n)]

        for j in range(n):
            ans[j].append(str(b[j]))
    for i in range(n):
        ans[i] = ''.join(ans[i])
        ans[i] = str(int(ans[i],2))
    print(' '.join(ans))

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

ans = [0] * N

for i in range(10 ** 9 + 1):
    ans[0] = i
    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]:
        break

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
AList = list(map(int, input().split()))
RList = []

tmp = 0
for p in range(len(AList)):
    tmp = 0
    for q in range(len(AList)):
        if p == q:
            continue
        else:
            tmp = tmp ^ AList[q]
    
    RList.append(tmp)
    

for i in range(len(RList)):
    print(RList[i], end=' ')

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

def problem():
  N = int(input())
  xs = [int(x) for x in input().split()]

  for i in range(N):
    t = (x for j, x in enumerate(xs) if i != j)
    yield reduce(lambda acc, elem: acc ^ elem, t)

print(*problem())

Submission status: Time Limit Exceeded

Solution code:
#Red Scarf
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
output = ''

def binary(A, p):
    if not np.all(A==0) :
        return binary( (A-A%2)/2 , p+1 ) + ((A%2).sum())%2 * 2**p
    return ((A%2).sum())%2 * 2**p

for i in range(N):
    ken = (np.delete(A,i))
    output += str(int(binary(ken,0)))
    if i != N-1:
        output += ' '

print(output)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
result = [0] * n
for i in range(n):
  tmp = 0
  for j in range(n):
    if i == j:
      continue
    else:
      tmp = tmp ^ a[j]
  result[i] = tmp
for e in result:
  print(e, end=' ')

Submission status: Time Limit Exceeded

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):
        s[j] = (s[j] + aa)%2
        aa = aa//2
for i in range(N):
    ans = a[i]
    for j in range(30):
        ans1 = a[i]%2
        a[i] = a[i]//2
        if s[j] == 1:
            if ans1 == 1:
                ans -= t[j] 
            else:
                ans += t[j]
    print(ans,end = " ")
print()

Submission status: Time Limit Exceeded

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

for i,youso in enumerate(al):
    for j in range(n):
        if i == j:
            continue
        else:
            ansl[j] ^= youso 


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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

N = int(input().strip())
A = [int(x) for x in input().strip().split(" ")]

# def calc(A, i):

values = [
    str(reduce(lambda x, y: x ^ y, map(lambda v: v[1], filter(lambda v: v[0] != i, enumerate(A)))))
    # calc(A, i)
    for i in range(len(A))
]
print(" ".join(values))

Submission status: Time Limit Exceeded

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

c = format(c,'b').zfill(30)

buf = []
for i in a:
    s = format(i,'b').zfill(30)
    ans = list(c)
    for j in range(len(s)):
        x = (int(ans[j])+int(s[j]))%2
        ans[j] = str(x)
    x = ''.join(ans)
    buf.append(int(x,2))
print(*buf)

Submission status: Time Limit Exceeded

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

c = format(c,'b').zfill(50)

buf = []
for i in a:
    s = format(i,'b').zfill(50)
    ans = list(c)
    for j in range(len(s)):
        x = (int(ans[j])+int(s[j]))%2
        ans[j] = str(x)
    x = ''.join(ans)
    buf.append(int(x,2))
print(*buf)

Submission status: Time Limit Exceeded

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

result = []

for i in range(N//2):
    if i < N -2:
        s_1 = A[2*i+1]
        s_2 = A[2*i]
        for j in range(2*i+2, N):
            s_1 = s_1 ^ A[j]
            s_2 = s_2 ^ A[j]
        result.append(str(s_1))
        result.append(str(s_2))
        for j in range(2*i+1, N):
            A[j] = int(result[-1])^int(result[-2])^A[j]
 
    else:
        result.append(str(A[N-1]))
        result.append(str(A[N-2]))
        break

print(' '.join(result))

Submission status: Time Limit Exceeded

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


def cal_xor(xor_list, rm_ind):
    ans = None
    for i, xi in enumerate(xor_list):
        if i!=rm_ind:
            if ans is not None:
                ans = ans^xi
            else:
                ans = xi
    return ans

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

ans_str = ''

if N==2:
    print("{} {}".format(a[1], a[0]))
else:

    xors = []
    for i in range(N//2):
        xors.append(a[2*i]^a[2*i+1])

    for i, ai in enumerate(a):
        sum_xor = cal_xor(xors, i//2)
        if i%2==0:
            ind = i+1
        else:
            ind = i-1

        ans = sum_xor^a[ind]
        ans_str += str(ans)+' '
    print(ans_str[:-1])

Submission status: Time Limit Exceeded

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

c = format(c,'b').zfill(30)[::-1]

buf = []
for i in a:
    s = format(i,'b')[::-1]
    ans = list(c)
    for j in range(len(s)):
        x = (int(ans[j])+int(s[j]))%2
        ans[j] = str(x)
    x = ''.join(ans)
    buf.append(int(x[::-1],2))
print(*buf)

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    a = [int(v) for v in input().split()]
    for j in range(n):
        x = 0
        for i in range(0, j):
            x ^= a[i]
        for i in range(j+1, n):
            x ^= a[i]
        print(x)

main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=[int(i) for i in input().split()]
X=0
for i in A:
	X=X^i
Y=""
for i in range(N):
	if i!=N-1:
		Y+=str(int(X^A[i]))+" "
	else:
		Y+=str(int(X^A[i]))
print(Y)

Submission status: Time Limit Exceeded

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] += aa%2
        aa = aa//2
for i in range(30):
    s[i] = s[i]%2
for i in range(N):
    ans1 = [0] * 30
    ans = a[i]
    for j in range(30):
        ans1[j] = a[i]%2
        a[i] = a[i]//2
        if s[j] == 1:
            if ans1[j] == 1:
                ans -= t[j] 
            else:
                ans += t[j]
    print(ans,end = " ")
print()

Submission status: Time Limit Exceeded

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: Time Limit Exceeded

Solution code:
n = int(input())
alist = [int(s) for s in input().split(" ")]

import copy
a_ans = []
for i in range(n):
  atmp = copy.copy(alist)
  del atmp[i]
  ans = atmp[0]
  for a in atmp[1:]:
    ans ^= a
  a_ans.append(ans)
print(" ".join([str(a) for a in a_ans]))

Submission status: Time Limit Exceeded

Solution code:
_,*a = open(0).read().split()
for n,m in enumerate(a):
    b = a + []
    del b[n]
    print(eval("^".join(b)),end=" ")

Submission status: Time Limit Exceeded

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

def set2(nu):
    name = ''
    for i in range(30):
        m = nu%2
        if(m == 0):
            name = '0' + name
        else:
            name = '1' + name
        nu  = nu // 2
    return name

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

def xor(a,b):
    if(a == '0' and b == '0'):
        return '0'
    elif(a == '1' and b == '1'):
        return '0'
    else:
        return '1'

def xor2(A,B):
    C = ''
    for i in range(30):
        C = C + xor(A[i],B[i])
    return C

samu = '0'*30
for i in range(n):
    samu = xor2(samu,b[i])

c = []
for i in range(n):
    X = xor2(samu,b[i])
    num = 0
    d = 1
    for j in range(30):
        if(X[30-j-1]=='1'):
            num += d
        d *= 2
    c.append(num)

print(*c)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=[int(i) for i in input().split()]
X=0
for i in A:
	X=X^i
ans=[]
for i in A:
	k=int(X^i)
	ans=ans+[k]
Y=""
for i in range(len(ans)):
	if i!=len(ans)-1:
		Y+=str(ans[i])+" "
	else:
		Y+=str(ans[i])
print(Y)

Submission status: Time Limit Exceeded

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

b_ls=[0]*30
c_ls=[]

import numpy as np

for i in range(N):
	b=bin(a_ls[i])[2:].zfill(30)
	c_ls+=[list(b)]
	for j in range(30):
		b_ls[j]+=int(b[j])

ans_all=""

for i in range(N):
	d_ls=np.array(b_ls)-np.array(c_ls[i]).astype(int)
	ans=0
	for i in range(30):
		ans+=(d_ls[29-i]%2)*(2**i)
	
	ans_all+=" "
	ans_all+=str(ans)

print(ans_all[1:])

# 2darray [[0] * 4 for i in range(3)]

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(input().split())
C = []

for n in range(N):
  B = A[:]
  B.pop(n)
  C.append(eval("^".join(B)))

print(*C,sep=" ")

Submission status: Time Limit Exceeded

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

result = []

for i in range(N//2):
    if i < N -2:
        s = A[2*i+1]
        for j in range(2*i+2, N):
            s = s ^ A[j]
        result.append(str(s))
        s = A[2*i]
        for j in range(2*i+2, N):
            s = s ^ A[j]
        result.append(str(s))
        
    else:
        result.append(str(A[N-1]))
        result.append(str(A[N-2]))
        break
    
    for j in range(2*i+1, N):
        A[j] = int(result[-1])^int(result[-2])^A[j]

print(' '.join(result))

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

N = int(input())
xs = [int(x) for x in input().split()]

def others_xor(l, i):
  l.pop(i)
  return reduce(lambda acc, elem: acc ^ elem, l)

print(*[others_xor(xs[::], i) for i in range(N)])

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
def calcXor(nums):
  x=0
  for n in nums:
    x=x^n
  return x

N=int(input())
A=list(map(int,input().split()))
ans=deque()
for i in range(N):
  #print(A[0:i])
  x=calcXor(A[0:i])
  #print(A[i+1:N])
  y=calcXor(A[i+1:N])
  ans.append(x^y)
print(" ".join(map(str,ans)))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
a=list(map(int,input().split()))
b=a[0]
for i in range(N-1):
  b=b^a[i+1]
ans=""
for i in range(N):
  if(i<N-1):
    ans+=str(b^a[i])+" "
  else:
    ans+=str(b^a[i])
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


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


def z():
    return int(input())


def S():
    return input()


def C(line):
    return [input() for _ in range(line)]


N = z()
a = zz()
ans = []
for i in range(N):
    tmp_ans = 0
    lis = a[:i] + a[i+1:]
    for ai in lis:
        tmp_ans ^= ai
    ans.append(tmp_ans)

print(*ans)
# i番目以外のxorの合計がai

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    n=int(input())
    a=list(map(int,input().split()))
    for i in range(n):
        ans=0
        for j in range(n):
            if j==i:
                continue
            ans=ans^a[j]
        print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a=list(map(int,input().split()))
result = ''
for i in range(n):
    t = 0
    for j in range(n):
        if j != i:
            t ^= a[j]
    result += str(t) + ' '

print(result)

Submission status: Time Limit Exceeded

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] += aa%2
        aa = aa//2
for i in range(30):
    s[i] = s[i]%2
for i in range(N):
    ans1 = [0] * 30
    for j in range(30):
        ans1[j] = a[i]%2
        a[i] = a[i]//2
        if s[j] == 1:
            ans1[j] = (ans1[j] + 1)%2
    ans = 0
    for j in range(30):
        ans += ans1[j]*t[j]
    print(ans,end = " ")
print()

Submission status: Time Limit Exceeded

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

for i in range(n):
    ans = 0
    for j in range(n):
        if i==j:
            continue
        ans = ans^ali[j]
    
    if i != (n-1):
        print(ans, end=" ")
    else:
        print(ans)

Submission status: Time Limit Exceeded

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

for i in range(n):
    ans = 0
    for j in range(n):
        if j == i:
            continue
        
        ans = ans^a[j]
        
    print(ans, end=' ')

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int,input().split()))
s = len(bin(max(a)))-2

box = [0] * s
bbbox = [] * n
for i in range(n):
    bbbox.append(format(a[i],'b').zfill(s))
    for j in range(s):
        box[j] += int(bbbox[-1][-j-1])
        

ans = [0] * n
for i in range(s):
    for j in range(n):
        if box[i] % 2 == 0:
            if bbbox[j][-1-i] == '1':
                ans[j] += 2 ** i
        else:
            if bbbox[j][-1-i] == '0':
                ans[j] += 2 ** i
print(*ans)

Submission status: Time Limit Exceeded

Solution code:
import sys

if __name__ == '__main__':
    n = int(sys.stdin.readline())
    a = list(map(lambda x: int(x), sys.stdin.readline().split()))
    for i in range(len(a)):
        ans = 0
        for j in range(len(a)):
            if i == j:
                continue
            else:
                ans ^= a[j]
        print(ans, end=' ')
    print()

# スヌケ君dの値が知りたい：d以外の人の計算結果を全部xorする

Submission status: Time Limit Exceeded

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

for i in range(N):
  for j in range(N):
    if i == j:
      continue
    O[i] ^= A[j]

print(' '.join([str(s) for s in O]))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))
mx=len(bin(max(a)))
b=["0"*(mx-len(bin(x)))+bin(x)[2:] for x in a]

out=["" for _ in range(n)]
ref=[0 for _ in range(mx-2)]
for j in range(n):
    work=b[j]
    for i in range(mx-2):
        ref[i]+=int(work[i])
        ref[i]%=2

for j in range(n):
    work=b[j]
    for i in range(mx-2):
        if int(work[i])==ref[i]:out[j]+="0"
        else : out[j]+="1"

c=[str(int(y,2)) for y in out]
print(" ".join(c))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=input().split()
l0=[]
sums=[1 for i in range(30)]
for i in range(n):
  newl=[]
  k=int(a[i])
  for j in range(30):
    if k%2==0:
      newl.append(0)
      k/=2
    else:
      newl.append(1)
      sums[j]*=-1
      k=(k-1)/2
  l0.append(newl)
      
for i in range(n):
  ans=0
  for j in range(30):
    if sums[j]==1:
      if l0[i][j]==1:
        ans+=2**j
    else:
      if l0[i][j]==0:
        ans+=2**j
  print(ans,end=" ")
print("")

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int,input().split()))
c = [0]*31
for i in a:
    s = format(i,'b')[::-1]
    for i in range(len(s)):
        c[i] += int(s[i])

buf = []
for i in a:
    s = format(i,'b').zfill(31)[::-1]
    ans = ''
    for i in range(31):
        ans +=  str((c[i]-int(s[i]))%2)
    ans = ans[::-1]
    buf.append(int(ans,2))

print(*buf)

Submission status: Time Limit Exceeded

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