Problem:


Score : 300 points

Problem Statement

Snuke has N hats. The i-th hat has an integer a_i written on it.

There are N camels standing in a circle.
Snuke will put one of his hats on each of these camels.

If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print Yes; otherwise, print No.

The bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself.

What is XOR?

The bitwise XOR x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non-negative integers x_1, x_2, \ldots, x_n is defined as follows:

- When x_1 \oplus x_2 \oplus \ldots \oplus 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 \oplus 5 = 6.

Constraints

All values in input are integers.

3 \leq N \leq 10^{5}

0 \leq a_i \leq 10^{9}

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 \ldots a_{N}

Output

Print the answer.

Sample Input 1

3
1 2 3

Sample Output 1

Yes

If we put the hats with 1, 2, and 3 in this order, clockwise, the condition will be satisfied for every camel, so the answer is Yes.

Sample Input 2

4
1 2 4 8

Sample Output 2

No

There is no such way to distribute the hats; the answer is No.



Sample input:
3
1 2 3


Sample output:
Yes

Submission status: Runtime Error

Solution code:
import collections
import random
n=int(input())
a=list(map(int,input().split()))
if len(set(a))==1 and a[0]==0:
  print('Yes')
elif n%3!=0:
  print('No')
elif len(set(a))!=3:
  x=random.randint(1,2)
  if x%2==0:
    print('No')
  if n%3!=0
    print('No')
  else:
    print('Yes')
else:
  a=list(set(a))
  for i in range(len(a)):
    a[i]=format(a[i],'020b')
  l=[0 for i in range(20)]
  for i in range(len(a)):
    for j in range(20):
      if a[i][j]=='1':
        l[j]+=1
  ct=0
  for j in range(20):
    if l[j]==2 or l[j]==0:ct+=1
  if ct==20:
    print('Yes')
  else:
    print('No')

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
aa=set(a)
if len(aa)>3:
    print("No")
    exit()
elif a.count(0)==n:
    print("Yes")
    exit()
elif len(aa)<=1:
    print("No")
    exit()
l=[]
l.append(a[0])
for i in range(1,n):
    if a[i]!=a[0]:
        l.append(a[i])
        break
l.append(l[0]^l[1])

if n==0:
    exit()
else:
    if l[0]==l[1]:
        if n%3==0:
            if a.count(l[0])==(n//3)*2 and a.count(l[2])==n//3:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    if l[0]==l[2]:
        if n%3==0:
            if a.count(l[0])==(n//3)*2 and a.count(l[1])==n//3:
                print("Yes")
            else:
                print("No")
        elif n%==1:
            if a.count(l[0])==(n//3)*2+1 and a.count(l[1])==n//3:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    if l[2]==l[1]:
        if n%3==0:
            if a.count(l[1])==(n//3)*2 and a.count(l[0])==n//3:
                print("Yes")
            else:
                print("No")
        elif n%3==2:
            if a.count(l[0])==(n//3)*2+1 and a.count(l[0])==n//3+1:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    else:
        if n%3==0:
            if a.count(l[0])==n//3 and a.count(l[1])==n//3 and a.count(l[2])==n//3:
                print("Yes")
            else:
                print("No")
        else:
            print("No")

Submission status: Runtime Error

Solution code:
n=int(input())
a=[int(x) for x in input().split()]
f=0
b=[]
a.sort()
for i in range(n):
    if(a[(i+1)%n]==a[i]):
        b.append(a[i+1])
a=list(set(a))+b
for i in range(n):
  if(i==0):
    if(a[n-1]^a[i+1]!=a[i]):
      f=1
      break
  else:
      if(a[(i+1)%n]^a[i-1]!=a[i]):
        f=1
        break



if(f==0):
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
import itertools
N=int(input())
an=[int(x) for x in map(int,input().split()[:N])]

ret=an[0]
for x in range(1,N):
    ret= ret[x] ^ ret

if ret==0:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
import copy
import sys

# 条件に合う帽子が複数ある場合を考慮する
def check_hats(hat_1, hat_2, hats):
    # hats の中身が空っぽ -> 全てのラクダに乗せた場合、最初のラクダチェックをして結果を見る
    if len(hats) == 0:
        if hat_2 ^ rakuda_2 == rakuda_1:
            print('Yes')
            sys.exit()
        else:
            return None

    # まだ全部置いてない場合、条件を満たす数値があるかチェック
    hat_3 = hat_1 ^ hat_2
    if hat_3 in hats: # 条件を満たすハットが見つかれば
        hats.remove(hat_3)
        check_hats(hat_2, hat_3, hats)

n = int(input())
rakuda = [0]*n
hats = list(map(int, input().split()))

# 最初の一頭へ、aiのハットをかぶせる
rakuda_1 = hats[0]
hats.pop(0)
# # 次のラクダへ、何かを乗せる
for hi in range(0, len(hats)):
    rakuda_2 = hats[hi]    
    new_hats = copy.copy(hats)
    new_hats.pop(hi)

    # まだ全部置いてない場合、条件を満たす数値があるかチェック
    hat_3 = rakuda_1 ^ rakuda_2
    if hat_3 in new_hats: # 条件を満たすハットが見つかれば
        new_hats.remove(hat_3)
        check_hats(rakuda_2, hat_3, new_hats)
    
# どの組み合わせもダメだった場合
print('No')
sys.exit()

Submission status: Runtime Error

Solution code:
P=int(input())
A=[int(i) for i in input().split(" ")]
ans=0
if A.count(0)==0:
	if len(set(A))==3:
		if P%3==0:
			if A.count(A[0])==P/3:
				n=A[0]
				A.remove(A[0])
				m=A[0]
				A.remove(A[0])
				l=A[0]
				if A.count(A[0])==P/3:
					if l==n|m:ans=1
if len(set(A))==1:
	if A[0]==0:ans=1
if len(set(A))==2:
	if P%2==1:
		if A.count(0)==P//2:ans=1
if len(set(A))==3:


if ans==1:
	print("Yes")
else:
	print("No")

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
A=list(set(a))
ans="Yes"
if len(A)!=3 or A==[0]:
    ans="No"
    if a.count(A[0])==2*a.count(A[1]) or 2*a.count(A[0])==a.count(A[1]):
        ans="Yes"
print(ans)

Submission status: Runtime Error

Solution code:
import itertools

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

while True:
    for c in itertools.combinations(a, 3):
        if c[0] ^ c[2] == c[1]:
            if len(a) == 3:
                print("Yes")
                exit()
            else:
                a.remove(c[1])
        elif c[1] ^ c[2] == c[0]:
            if len(a) == 3:
                print("Yes")
                exit()
            else:
                a.remove(c[0])
        elif c[0] ^ c[1] == c[2]:
            if len(a) == 3:
                print("Yes")
                exit()
            else:
                a.remove(c[2])
    print("No")
    exit()

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import random
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def main():

	N = int(input())
	#S = list(input())
	#L,R = map(int, input().split(" "))
	#L = list(map(int, input().split(" ")))

	A = input().split()
	A = [int(s) for s in A]
	A.sort()

	a_max = A[-1]
	#A[-1] = -1

	a = 2
	i = 1
	ll = [1]
	while a < 100000+1:
		a = 2 ** i
		ll.append(a)
		i += 1
		if a_max == a:
			print("No")
			sys.exit()

	tmp = 0
	flg = False
	for i in ll:
		tmp += i
		if a_max == tmp:
			flg = True
			break
	
	if flg == False:
			#print("No")
			#sys.exit()

	bk = -1
	next1 = -1
	for i, val in enumerate(A):
		#A[i] = -1
		if i == 0:
			tmp = a_max - val
			if tmp in A:
				bk = val
				next1 = tmp
				continue
			else:
				print("No")
				sys.exit()
		
		if i == N-1:
			if next1 == a_max and bk ^ A[0] == a_max:
				print("Yes")
				sys.exit()
		
		if next1 == a_max:
			tmp = next1 - bk
			if tmp in A:
				bk = next1
				next1 = tmp
				continue
			else:
				print("No")
				sys.exit()

		elif next1 == A[0]:
			tmp = a_max - next1
			if tmp in A:
				bk = next1
				next1 = tmp
				continue
			else:
				#print(next1)
				print("No")
				sys.exit()

		else:
			tmp = next1 + bk
			if tmp in A:
				bk = next1
				next1 = tmp
				continue
			else:
				print("No")
				sys.exit()
		
	print("No")


if __name__ == "__main__":
	main()

Submission status: Runtime Error

Solution code:
import collections

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

value, count = list(a.keys()), list(a.values())

if count[0]+count[1]+count[2] != N:
    print('No')

elif value[0]^value[1]^value[2] != 0:
    print('No')

elif count[0]==count[1]==count[2]:
    print('Yes')

else:
    print('No')

Submission status: Runtime Error

Solution code:
import copy
import numpy
import sys

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

for i in range(N-1):
    first = List[i]
    a = copy.deepcopy(List)
    
    for j in range(i+1,N-1):
        acopy = copy.deepcopy(List)
        second = a[j]
        while(len(a) > 2):
            
            xor = bin(first ^ second)
            check = int(xor,2)

            if (check in a):
                a.remove(second)
                first = a[j]
                second = check

            else:
                break

            if (len(a) == 2):
                print("Yes")
                sys.exit()

print("No")

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split()))
def binbin(a):
    return int(bin(a).split("b")[1])
arr=[A[-1]]
arr.extend(A)
arr.append(A[0])
ans=[]
for i in range(1,N+1):
    ans.append(int(binbin(arr[i])) == int("".join(list(map(lambda x:str(int(x)%2),str(binbin(arr[i-1])+binbin(arr[i+1])))))))

if all(ans):
    if any(ans)==False:
        print("Yes")
else:
    if any(ans)==False:
    print("No")

Submission status: Runtime Error

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

a.sort()
for i in range(N-1):
    if a[i-1] ^ a[i+1] == a[i]:
        continue
    else:
        print("No")
        exit()

if a[N-2] ^ a[0] != a[N-1]:
    print("No")
    exit()

print("Yes" if flag else "No")

Submission status: Runtime Error

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

if max(a) == 0 :
    bl = [0]
else :
    bl = [0 for _ in range(floor(log2(max(a)))+1)]
for ai in a :
    aj = ai
    if ai == 0 :
        pass
    else :
        for i in range(floor(log2(ai))+1) :
            if aj & 1 == 1 :
                bl[i] += 1
            aj >>= 1

ans = reduce(or_, map(lambda x : x&1, bl))
if ans :
    print("No")
else :
    print("Yes")

Submission status: Runtime Error

Solution code:
from collections import deque
import copy

N = int(input())

# 2つの入力を空白で分割し、数値化
a_list = list(map(int, input().split()))
a_queue = deque(a_list)

def seach(source, base, current_list):
    copied_source = copy.copy(source)
    if len(source) == 0:
        # 最後まできたら、自身とこれまでのリストの最後と、リストの先頭を比較して
        # 条件をみたせばOK
        if base == (current_list[-2] ^ current_list[0]):
            return True
        else:
            return False
    else:
        for right in source:
            if left ^ right == base:
                current_list.append(right)
                copied_source.remove(right)
                result = seach(copied_source, right, current_list)
                if result:
                    return True
        return False


# left, base をまず組み合わせる
for base in a_list:
    result = False
    a_queue.remove(base)
    for left in a_list:
        if base == left:
            pass
        else:
            a_queue.remove(left)
            result = seach(a_queue, base, [left, base])
            if result:
                break
    break
    #if result:
    #    break
    #a_queue = deque(a_list)

print("Yes" if result else "No")

Submission status: Runtime Error

Solution code:
import copy
import sys

# 条件に合う帽子が複数ある場合を考慮する
def check_hats(hat_1, hat_2, hats):
    # hats の中身が空っぽ -> 全てのラクダに乗せた場合、最初のラクダチェックをして結果を見る
    if len(hats) == 0:
        if hat_2 ^ rakuda_2 == rakuda_1:
            print('Yes')
            sys.exit()
        else:
            return None

    # まだ全部置いてない場合、条件を満たす数値があるかチェック
    hat_3 = hat_1 ^ hat_2
    if hat_3 in hats: # 条件を満たすハットが見つかれば
        hats.remove(hat_3)
        check_hats(hat_2, hat_3, hats)

n = int(input())
rakuda = [0]*n
hats = list(map(int, input().split()))

# 最初の一頭へ、aiのハットをかぶせる
rakuda_1 = hats[0]
hats.pop(0)
# # 次のラクダへ、何かを乗せる
for hi in range(0, len(hats)):
    rakuda_2 = hats[hi]    
    new_hats = copy.copy(hats)
    new_hats.pop(hi)
    check_hats(rakuda_1, rakuda_2, new_hats)
    
# どの組み合わせもダメだった場合
print('No')
sys.exit()

Submission status: Runtime Error

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

a.sort()
for i in range(N-1):
    if a[i-1] ^ a[i+1] == a[i]:
        continue
    else:
        print("No")
        exit()

if a[N-2] ^ a[0] != a[N-1]:
    print("No")
        exit()

print("Yes" if flag else "No")

Submission status: Runtime Error

Solution code:
from collections import defaultdict

N = int(input())
a = list(map(int, input().split()))
d = defaultdict()
for c in a[1:]:
    d[c] += 1
for i in range(1, N):
    x = a[0]
    y = a[i]
    d[y] -= 1
    for _ in range(N - 2):
        z = x ^ y
        if z in d and d[z] > 0:
            d[z] -= 1
            x = y
            y = z
        else:
            break
    else:
        if a[0] == x ^ y:
            print("Yes")
            exit(0)

print("No")

Submission status: Runtime Error

Solution code:
import sys,itertools,copy
input = sys.stdin.readline
N=int(input().strip())
an=[int(x) for x in input().strip().split()]

if N==3:
    if an[0]^an[1]==an[2]:
        print("Yes")
    else:
        print("No")
elif N%3!=0:
    if len(set(an))==1:
        print("Yes")
    else:
        print("No")
else:
    bn = list(set(an))
    if bn[0]^bn[1]!=bn[2]:
        print("No")
    else:
        for b in bn:
            if an.count(b)%(N/3)!=0:
                print("No")
                break
        else:
            print("Yes")

Submission status: Runtime Error

Solution code:
import numpy as np

if True :
    n = int(input())
    a = list(map(int, input().split()))
else :
    n = 10**5
    a = list(np.full(3, 0))

if max(a) == 0 :
    bl = [0]
else :
    bl = [0 for _ in range(floor(log2(max(a)))+1)]
for ai in a :
    aj = ai
    if ai == 0 :
        pass
    else :
        for i in range(floor(log2(ai))+1) :
            if aj & 1 == 1 :
                bl[i] += 1
            aj >>= 1

ans = reduce(or_, map(lambda x : x&1, bl))
if ans :
    print("No")
else :
    print("Yes")

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = set(a)
d = [0,0,0]
index = 0
if len(b) != 3 and n % 3 != 0:
    print("No")
    exit()
for i in list(b):
    for j in a:
        if i == j:
            d[index] += 1
    index += 1
if d[0] == d[1] and d[1] == d[2]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# coding: utf-8

# -*- coding: utf-8 -*-
import itertools
import collections

def XORGate(a,b):
    if a == b:
        return "0"
    else :
        return "1"

N = int(input())
tmp = input().split()
hat_numbers = [bin(int(one))[2:] for one in tmp]
max_size = int(max(tmp))
hat_numbers = [one.zfill(max_size) for one in hat_numbers]
comb2 = []
comb_index = []
for i,one in enumerate(hat_numbers):
    for j,two in enumerate(hat_numbers):
        if i <= j :
            continue
        else:
            comb2.append((two,one))
            comb_index.append((j,i))
    

result_list_total = []
for one_a, one_b in comb2:
    result_list = []
    for i in range(max_size):
        result_list.append(XORGate(one_a[-i-1],one_b[-i-1]))
    
    tmp_str =""
    for i in range(max_size):
        tmp_str += result_list[-i-1]

    result_list_total +=[tmp_str]
    
    
cad_list = []
for (one_a, one_b),(index_a,index_b) in zip(comb2,comb_index):
    for i,one in enumerate(hat_numbers):
        if  i != index_a and i != index_b:
            if one in result_list_total:
                cad_list.append((one_a,one,one_b))
if len(cad_list) == 0:
    print("No")
else:
    c = collections.Counter(cad_list)
    correct = []
    cor_flag = True
    cad_list2 = []
    tmp_flags = []
    while cor_flag:
        if len(cad_list[0]) == N:
            print("Yes")
            cor_flag = False
        else:
            for one in hat_numbers:
                tmp_flag_1 = False
                tmp_flag_2 = False
                tmp_flag_3 = False
                for one_cad in c:
                    if tmp_flag_1 == False and one_cad[0] == one and c[one_cad] != 0:
                        c[one_cad] -= 1
                        tmp_flag_1 = True
                    if tmp_flag_2== False and one_cad[1] == one and c[one_cad] != 0:
                        c[one_cad] -= 1
                        tmp_flag_2 = True
                    if tmp_flag_3 == False and one_cad[2] == one and c[one_cad] != 0:
                        c[one_cad] -= 1
                        tmp_flag_3 = True

                    if tmp_flag_1 + tmp_flag_2 + tmp_flag_3 == 3:
                        break
                tmp_flags.append(tmp_flag_1 + tmp_flag_2 + tmp_flag_3)


            if sum(tmp_flags) == N*3:
                print("Yes")
                cor_flag = False
            else:
                print("No")
                cor_flag = False

Submission status: Runtime Error

Solution code:
import itertools

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

def get_ans(a, N):
    ans = 'Yes'
    
    ans = 'Yes'
    for x in range(N):
        if int(bin(a[x]^a[x+2]), 0) != a[x+1]:
            ans = 'No'
            break
    if ans == 'Yes':
        print(ans)
        return True   

    for l in itertools.permutations(a):
        a_tmp = list(l)
        if a_tmp[0] != a[0]:
            continue
        a_tmp.extend(a_tmp[:2])

        for x in range(N):
            if int(bin(a_tmp[x]^a_tmp[x+2]), 0) != a_tmp[x+1]:
                ans = 'No'
                break
        if ans == 'Yes':
            print(ans)
            return True
    print(ans)
    return False

ret = get_ans(a, N)

Submission status: Runtime Error

Solution code:
import itertools

boushi_num = int(input())
boushi_No = list(map(int,input().split()))
flag = 0

jyun = list(itertools.permutations(boushi_No, boushi_num))
jyun_num = len(jyun)

for v in jyun:
  for i in range(jyun_num):
    i_a = i+2
    i_b = i+1
    if i_a >boushi_num -1:
      i_a = i_a - boushi_num
    if i_b >boushi_num -1:
      i_b = i_b - boushi_num
            
    if v[i]^v[i_a] != v[i_b]:
      break
    else:
      None
            
    if i == boushi_num - 1:
      flag = 1
                
  if flag == 1:
    print('Yes')
    break

if flag == 0:
  print('No')

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = set(a)
d = [0,0,0]
index = 0
if len(b) != 3 and len(n) % 3 != 0:
    print("No")
    exit()
for i in list(b):
    for j in a:
        if i == j:
            d[index] += 1
    index += 1
if d[0] == d[1] and d[1] == d[2]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
std_n = int(input())
std_set = set(map(int, input().split()))

if len(std_set) == 3:
    a, b, c = tuple(std_set)
    if int(str(int(format(a, "b")) ^ int(format(b, "b"))), 2) == c:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Runtime Error

Solution code:
import numpy as np
import sys
N = int(input('>>'))
a = np.zeros(N,dtype='int')

if N % 3 != 0:
    print('No')
    sys.exit()

for i in range(N):
    a[i]=input('>>')

datas = np.unique(a)
if len(datas) != 3:
    print('No')
    sys.exit()

ans = 'Yes'
for data in datas:
       if (a==data).sum() != N/3:
           ans = 'No'

if datas[0]^datas[1]^datas[2] !=0:
    ans = 'No'

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = set(a)
d = [0,0,0]
index = 0
if len(b) != 3 and len(n) % 3 == 0:
    print("No")
    exit()
for i in list(b):
    for j in a:
        if i == j:
            d[index] += 1
    index += 1
if d[0] == d[1] and d[1] == d[2]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
N = int(input())
A = input().split()
for i in range(N):
  A[i] = int(A[i])
  
A_unique = list(set(A))
A_digit = [[],[],[]]
if A == [0] * N:
  ans = 'Yes'
elif len(A) %3 != 0:
  ans ='No'
elif len(A_unique) == 1:
  ans = 'No'
elif len(A_unique) == 2:
  if min(A_unique) ==0 and A.count(0) == N/3:
    ans = 'Yes'
else:
  for j in range(3):
    A_unique[j] = format(A_unique[j], '08b').zfill(30)
    s = str(A_unique[j])
    A_digit[j]  = list(map(int, s))
  for k in range(30):
    key = A_digit[0][k] + A_digit[1][k] + A_digit[2][k] 
    if key == 0 or key == 2:
      ans = 'yes'
    else:
      ans = 'No'
      break

print(ans)

Submission status: Runtime Error

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

arr=[A[-1]]
arr.extend(A)
arr.append(A[0])
ans=[]
for i in range(1,N+1):
    ans.append(int(binbin(arr[i])) == int("".join(list(map(lambda x:str(int(x)%2),str(binbin(arr[i-1])+binbin(arr[i+1])))))))

print("Yes" if all(ans) else "No")

Submission status: Runtime Error

Solution code:
import itertools

n = int(input()) # The number of camel
a = [int(i) for i in input().split()] # Hat's number

def main():
    combs = list(itertools.permutations([i for i in range(1, n)]))
   
  	check = True
    for comb in combs:
        tmp = [0]
        tmp.extend(comb)
        for i in range(len(tmp)):
            idx = i
            if check:
                pre = idx - 1
                if pre < 0:
                    pre = n - 1
                
                if a[tmp[idx]] != a[tmp[pre]]^a[tmp[(idx + 1)%n]]:
                    check = False
            else:
                break

        if not check:
            break
    
    if check:
        print("Yes")
    else:
        print("No")

main()

Submission status: Runtime Error

Solution code:
# A
N = int(input())
a = list(map(int, input().split()))
flag = True
if N % 3  != 0:
    if max(a) == 0:
        print('Yes')
    else:
        print('No')
else:
    if N == 3:
        if a[0] == a[1] ^ a[2] and a[1] == a[2] ^ a[0] and a[2] == a[0] ^ a[1]:
            print('Yes')
        else:
            print('No')
    else:
        n = int(N / 3)
        a = sorted(a)
        for i in range(n):
            tmp_list = a[n * i : n*(i + 1)]
            if min(tmp_list) == max(tmp_list):
                pass
            else:
                flag = False
        if flag:
            print('Yes')
        else:
            print('No')

Submission status: Runtime Error

Solution code:
uehega

Submission status: Runtime Error

Solution code:
import sys

std_n = int(sys.stdin.readline())
std_set = set(map(int, (sys.stdin.readline()).split()))

if len(std_set) == 3:
    a, b, c = tuple(std_set)
    if int(str(int(format(a, "b")) ^ int(format(b, "b"))), 2) == c:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Runtime Error

Solution code:
import copy
a=int(input())
b=(list(map(int, input().split())))
bb = copy.copy(b)
c=0
d=[]
n=0
f=b[0]
d.append(f)
b.pop(0)
print(1^2)
print(2^3)
print(3^1)

def kakunin(bb,d):
  while c==0:
    cc=0
    for i in range(len(bb)):
      print(d)
      if d[len(d)-2]==d[len(d)-1]^bb[i]:
        g=bb[i]
        d.append(g)
        bb.pop(i)
        cc=1
        if len(d)==a and d[0]==d[len(d)-2]^d[len(d)-1]:
          global ccc
          ccc=1
          return
        break
    if cc==0:
      ccc=0
      return
      
while c==0:
  n+=1    
  bb = copy.copy(b)
  f=b[0]
  d.append(f)
  b.pop(0)
  bb.pop(0)
  kakunin(bb,d)
  b.append(f)
  if ccc==1:
    print("Yes")
    break
  else:
    d=[f]
  if n>=a:
    print("No")
    break

Submission status: Runtime Error

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

if 0 in a:
    print("Yes")
    exit(1)

if (a[0] ^ a[N-1]) in a:
    print("Yes")
    exit(1)

for i in range(len(a)):
    j = i + 1
    while j < len(a) - 1:
        if (a[j] ^ a[j+1]) == a[i]:
            print("Yes")
            exit(1)
        j += 1

print("No")

Submission status: Runtime Error

Solution code:
import sys

def main():
    n = int(input())-1
    nums = list(map(int,input().split()))
    bins = []
    for num in nums:
        bins.append(str(bin(num)[2:]))

    #[1(0), 10(1), 11(2)]
    if int(str(sum(bins)).replace("2","0")) == 0:
        print("Yes")
    else:
        print("No")

main()

Submission status: Runtime Error

Solution code:
import itertools
n=int(input())
l=list(map(int,input().split()))
if n!=3:print("No")
else:
  flag=0
  for i in itertools.permutations(s):
    if i[0]^i[2]==i[1] and i[1]^i[2]==i[0] and i[0]^i[1]==i[2]:flag+=1
  if flag!=0:print("Yes")
  else:print("No")

Submission status: Runtime Error

Solution code:
import collections

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

value, count = zip(*a.most_common())

if count[0]+count[1]+count[2] != N:
    print('No')

elif value[0]^value[1]^value[2] != 0:
    print('No')

elif count[0]==count[1]==count[2]:
    print('Yes')

else:
    print('No')

Submission status: Runtime Error

Solution code:
# A
N = int(input())
a = list(map(int, input().split()))
flag = True
if N % 3  != 0:
    if max(a) == 0:
        print('Yes')
    else:
        print('No')
else:
    if N == 3:
        if a[0] == a[1] ^ a[2] and a[1] == a[2] ^ a[0] and a[2] == a[0] ^ a[1]:
            print('Yes')
        else:
            print('No')
    else:
        n = int(N /3)
        a = sorted(a)
        for i in range(n):
            tmp_list = a[n * i : n*(i + 1)]
            if min(tmp_list) == max(tmp_list):
                pass
            else:
                flag = False
        if flag:
            print('Yes')
        else:
            print('No')

Submission status: Runtime Error

Solution code:
from math import log2, floor
from operator import or_
from functools import reduce
import numpy as np

if True :
    n = int(input())
    a = list(map(int, input().split()))
else :
    n = 10**5
    a = list(np.random.randint(0, 10**9, n))

bl = [0 for _ in range(floor(log2(max(a)))+1)]
for ai in a :
    aj = ai
    for i in range(floor(log2(ai))+1) :
        if aj & 1 == 1 :
            bl[i] += 1
        aj >>= 1

ans = reduce(or_, map(lambda x : x&1, bl))
if ans :
    print("No")
else :
    print("Yes")

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
L = list(map(int,input().split()))
P = L[:]
var1 = 0
var2 = 0

for i1 in range(N):
  for i2 in range(N):
    if L[i1]^L[i2] == L[var2]:
      P = P.remove(P[var2])
      var1 = 0
      var2 = i2
  continue
  if L[var1]^L[i1] == L[var2]:
    P = P.remove(P[var2])
    var1 = i2
    var2 = i1
if P is None:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
import collections
n=int(input())
a=list(map(int,input().split()))
if len(set(a))==1 and a[0]==0:
  print('Yes')
elif n%3!=0:
  print('No')
elif len(set(a))!=3:
  print('No')
else:
  a=list(set(a))
  for i in range(len(a)):
    a[i]=format(a[i],'020b')
  l=[0 for i in range(20)]
  for i in range(n):
    for j in range(20):
      if a[i][j]=='1':
        l[j]+=1
  ct=0
  for j in range(20):
    if l[j]==2 or l[j]==0:ct+=1
  if ct==20:
    print('Yes')
  else:
    print('No')

Submission status: Runtime Error

Solution code:
way

Submission status: Runtime Error

Solution code:
import collections
import sys

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

value, count = zip(*a.most_common())

if count[0]+count[1]+count[2] != N:
    print('No')
    sys.exit()

if value[0]^value[1]^value[2] != 0:
    print('No')
    sys.exit()

if count[0]==count[1]==count[2]:
    print('Yes')
    sys.exit()

print('No')

Submission status: Runtime Error

Solution code:
import sys

def main():
    _ = input()
    k = [int(x) for x in input().split()]
    
    s0 = k[0]
    s2 = -1
    s1 = -1
    
    for i in range(1, len(k)):
        for j in range(1, len(k)):
            if i == j:
                continue
            if s0 ^ k[i] == k[j]:
                s2 = k[i]
                s1 = k[j]
                k.pop(max(i,j))
                k.pop(min(i,j))
                break
    
    if s2 == -1 or s1 == -1:
        print('No')
        sys.exit()

    while len(k) > 0:
        s0 = s1
        s1 = s2
        s2 = -1
        for i in range(len(k)):
            if s0 ^ s1 == k[i]:
                s2 = k[i]
                k.pop(i)
                break
        if s2 == -1:
            print('No')
            sys.exit()
    
    print('Yes')

if __name__=='__main__':
    main()

Submission status: Runtime Error

Solution code:
import copy
import bisect
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(input())
a = list(map(int, input().split()))

M = len(format(max(a), 'b'))
first_a = format(a[0], 'b')
full_bit = (1 << M) - 1
candidate = []

for i in range(1, N):
	if a[0] | a[i] == full_bit:
		candidate.append(a[i])

tmp1 = a[0]
flag = False

for i in range(len(candidate)):
	tmp_list = copy.copy(a)
	tmp1 = a[0]
	tmp2 = candidate[i]
	index = bisect.bisect_left(tmp_list, tmp2)
	tmp_list.pop(index)
		
	for j in range(N - 1):
		index = bisect.bisect_left(tmp_list, tmp1 ^ tmp2)
		
		if tmp1 ^ tmp2 == tmp_list[index]:
			tmp_list.pop(index)
			tmp1, tmp2 = tmp2, tmp1 ^ tmp2
			if j == N - 2:
				flag = True
				
if flag:
	print('Yes')
else:
	print('No')

Submission status: Runtime Error

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

def dfs(x,y,l):
    ans = 0
    if x != -1:
        if (l[x] ^ l[y]) not in l:
            if len(l) !=2:
                return 1
            else:
                if (l[x] ^ l[y])!= a[0]:
                    return 1
        for i in range(1,len(l)-1):
            ans += dfs(y-1,i,l[:x]+l[x+1:])
    else:
        for i in range(1,len(l)-1):
            ans += dfs(y,i,l)
    return (ans)

if dfs(-1,0,a) == 0:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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


if a[0]^a[1] == a[2]:
    if a[1]^a[2] == a[3]:
        if a[n-2]^a[n-1] == a[0]:
            if a[n-1]^a[0] == a[1]:
                result = True

if result:
    print("Yes")
else:
    print("No")