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 sys
import bisect
input = sys.stdin.readline

#+++++

def search(l,v, p):
	left=bisect.bisect_left(l, v)
	if l[left] != v:
		return -1
	
	while True:	
		if p[left] == -1:
			return left
		else:
			left+=1
		if left >= range(l) or l[left] != v:
			return -1
		
		
def main():
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	
	init=l[0]

	for i, vi in enumerate(l[1:],1):
		ll=[-1 for _ in l]
		
		ll[0]==1
		ll[i]==1
		
		pre_v = l[i]
		pre_i = i
		next_v = init ^ vi
		next_i = search(l, next_v, ll)
		ff=0
		for k in range(n-2):
			if next_i < 0:
				ff=1
				break
				
			ll[next_i]=1
			#print(next_v,pre_v)
			t=next_v^pre_v
			pre_v = next_v
			pre_i = next_i
			next_v=t
			next_i = search(l, next_v, ll)
		
		if ff ==0:
			if next_v == l[0]:
				return 'Yes'
			
	return 'No'
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int,input().split()))
a.sort()
flag = True
if len(set(a)) == 1 and a[0] == 0:
    #print('Yes')
    pass
elif N % 3 == 0:
    if len(set(a)) == 3:
        b = set(a)
        c = []
        for i in list(b):
            c.append(a.count(i))
        if a[0] != 0 and c[0] == c[1] and  c[1] == c[2] and c[2] == N//3 and b[0]^b[1]^b[2] == 0:
            #print('Yes')
            pass
        else:
            #print('No')
            flag = False
    elif len(set(a)) == 2:
        if a[0] == 0 and a.count(a[0])*2 == a.count(a[N-1]) and a.count(a[N-1]) == N//3*2:
            #print('Yes')
            pass
        else:
            #print('No')
            flag = False
    else:
        #print('No')
        flag = False
else:
    #print('No')
    flag = False
if flag:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
import copy
N=int(input())
a_list=list(map(int,input().split()))
a=set(a_list)
a=list(a)
if 0 in a:
        if len(a) ==2:
            if a_list.count(0)==len(a_list)//3 ora_list.count(0)==len(a_list)//2:
                    print("Yes")
            else:
                    print("No")
        else:
                print("No")
else:
        if len(a)==3:
            a1=a[0]
            a2=a[1]
            a3=a[2]
            if a1 ^ a2 ==a3 and a1^a3==a2 and a2^a3==a1:
                if a_list.count(a1) == a_list.count(a2) == a_list.count(a3):
                        print("Yes")
                else:
                        print("No")
            else:
                print("No")
        else:
            print("No")

Submission status: Runtime Error

Solution code:
# 1.Nが三の倍数でない場合、全てが0でなければならない.(a_i=Σa_k∧a_(i-1)+a_(i+1)=a_iとなるのはa_i=0のみ)
# 2.Nが3の倍数の場合、a,b,a+bを満たす三種類以下の数字で構成されていなければならず、かつそれであればよい。

N = int(input())
string = "No"
input_dict = {}
for i in map(int, input().split()):
    if(i in input_dict):
        input_dict[i] += 1
    else:
        input_dict[i] = 1
if((N % 3) == 0):
    num_count = len(input_dict.keys())
    if(num_count == 3 ):
        input_list = list(input_dict.keys())
        if(input_list[0] ^ input_list[1] == input_list[2] and input_dict[input_list[0] == N//3 and input_dict[input_list[1]]] == N//3):
            string = "Yes"
    elif(num_count == 2):
        if(0 in input_dict and input_dict[0] == N//3):
            string = "Yes"
    elif(num_count == 1):
        if(0 in input_dict):
            string = "Yes"
else:
    if(0 in input_dict and input_dict[0] == N):
        string = "Yes"
print(string)

Submission status: Runtime Error

Solution code:
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    a_list = [int(i) for i in input().split()]
    kind = set(a_list)
    if len(kind) not in (1, 2, 3):
        print("No")
        return
    # 1 0 1
    # 1 2 3
    if len(kind) == 1 and kind[0] == 0:
        print("Yes")
        return
    elif len(kind) == 3:
        if n % 3 != 0 or len(set([a_list.count(k) for k in kind])) != 1:
            print("No")
            return
        kind = list(kind)
    else:
        a, b = kind
        a_c, b_c = a_list.count(a), a_list.count(b)
        if 0 not in kind or abs(a_c - b_c) > 1:
            print("No")
            return
        if a == 0:
            if a_c > b_c:
                print("No")
                return
            kind = [b, a, b]
        else:
            if b_c > a_c:
                print("No")
                return
            kind = [a, b, a]
    kind.extend([kind[0], kind[-1]])
    for i in range(3):
        if kind[i] != kind[i - 1] ^ kind[i + 1]:
            print("No")
            return
    print("Yes")


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

def xor(a,b):
    x = 0
    ma = max(len(str(a)),len(str(b)))
    for i in range(ma):
        a = str(a).rjust(ma,"0")
        b = str(b).rjust(ma,"0")     
        if a[-i-1] != b[-i-1]:
            x+= 10**i
        else:
            pass
    return x

bin_l = []
for i in lists:
    a = bin(i)
    b = int(a[2:])
    bin_l.append(b)

zero = bin_l.count(0)

if zero <=len(bin_l)//3:
    if 0 in bin_l :
        k = bin_l.remove(0)
        if len(k) == 2:
        
            if k[0] == k[1]:
                print("Yes")
            else:
                print("No")
        elif len(k)%3 ==0 and len(set(k)) == 3:
            l = list(set(k))
    
    
            if l[0] == xor(l[1],l[2]) and l[1] == xor(l[0],l[2]) and l[2] == xor(l[0],l[1]):
                print("Yes")
            else:
                print("No")
        else:
            pass
    else:
        if len(bin_l)%3 ==0 and len(set(bin_l)) == 3:
            l = list(set(bin_l))
    
    
            if l[0] == xor(l[1],l[2]) and l[1] == xor(l[0],l[2]) and l[2] == xor(l[0],l[1]):
                print("Yes")
            else:
                print("No")   
        else:
            print("No")     

else:
    print("No")

Submission status: Runtime Error

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

if std_set == {0}:
    print("Yes")
elif len(std_set) == 2:
    if 0 in std_set:
        if std_tuple.count(0) * 3 == std_n:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
elif len(std_set) == 3:
    a, b, c = tuple(std_set)
    if (std_tuple.count(a) == std_tuple.count(b)) and (std_tuple.count(b) == std_tuple.count(c)):
        if int(str(int(format(a, "b")) ^ int(format(b, "b"))), 2) == c:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")

Submission status: Runtime Error

Solution code:

import numpy as np 

def make_bit(A):
    arr = np.zeros(31)
    i = 30
    while A:
        arr[i] = A % 2
        A = A // 2
        i -= 1

    return arr

def return_first_second_third(a_lst):
    first = [a_lst[0], 0]
    second = [-1, -1]
    third = [-1, -1]
    i = 0
    while i < len(a_lst) - 1:
        if a_lst[i] != a_lst[i+1]:
            second[0] = a_lst[i+1]
            second[1] = i+1
            i += 1
            break
        else:
            i += 1
    while i < len(a_lst) - 1:
        if a_lst[i] != a_lst[i+1]:
            third[0] = a_lst[i+1]
            third[1] = i+1
            i += 1
            break
        else:
            i += 1
    
    return first, second, third


N = int(input())

a_lst = list(map(int, input().split()))
a_lst.sort()
first, second, third = return_first_second_third(a_lst)
a_lst.reverse()

done = False
if second[0] == -1: # 全ての数が同じとき
    done = True
    if first[0] == 0: # 全ての数がゼロの時
        print("Yes")
    else:
        print("No")
elif third[0] == -1:    # 数が2種類だけの時
    done = True
    if N % 2 == 0 and second[1] == N // 2:
        print("Yes")
    else:
        print("No")
elif N % 3 == 0 and second[1] == N // 3 and third[1] == N * 2 // 3:
    a_lst = [ a_lst[0] + a_lst[second[1]] + a_lst[third[1]] ]


if not done:
    if N == 3:

        a1 = make_bit(a_lst[0])
        a2 = make_bit(a_lst[1])
        a3 = make_bit(a_lst[2])
        bits_arr = np.array([a1, a2, a3])

        judge = True
        for i in range(31):
            if bits_arr[0][i] == bits_arr[1][i] and bits_arr[2][i] == 1:
                judge = False
                break

            elif bits_arr[0][i] != bits_arr[1][i] and bits_arr[2][i] == 0:
                judge = False
                break
                
        if judge:
            print("Yes")
        else:
            print("No")


    else:
        print("No")

Submission status: Runtime Error

Solution code:

import numpy as np 

def make_bit(A):
    arr = np.zeros(31)
    i = 30
    while A:
        arr[i] = A % 2
        A = A // 2
        i -= 1

    return arr

def return_first_second_third(a_lst):
    first = [a_lst[0], 0]
    second = [-1, -1]
    third = [-1, -1]
    i = 0
    while i < len(a_lst) - 1:
        if a_lst[i] != a_lst[i+1]:
            second[0] = a_lst[i+1]
            second[1] = i+1
            i += 1
            break
        else:
            i += 1
    while i < len(a_lst) - 1:
        if a_lst[i] != a_lst[i+1]:
            third[0] = a_lst[i+1]
            third[1] = i+1
            i += 1
            break
        else:
            i += 1
    
    return first, second, third


N = int(input())

a_lst = list(map(int, input().split()))
a_lst.sort()
first, second, third = return_first_second_third(a_lst)
a_lst.reverse()

done = False
if second[0] == -1: # 全ての数が同じとき
    done = True
    if first[0] == 0: # 全ての数がゼロの時
        print("Yes")
    else:
        print("No")
elif third[0] == -1:    # 数が2種類だけの時
    done = True
    if N % 2 == 0 and second[1] == N // 2:
        print("Yes")
    else:
        print("No")
elif N % 3 == 0 and second[1] == N // 3 and third[1] == N * 2 // 3:
    a_lst = [ a_lst[0] + a_lst[second[0]] + a_lst[third[0]] ]


if not done:
    if N == 3:

        a1 = make_bit(a_lst[0])
        a2 = make_bit(a_lst[1])
        a3 = make_bit(a_lst[2])
        bits_arr = np.array([a1, a2, a3])

        judge = True
        for i in range(31):
            if bits_arr[0][i] == bits_arr[1][i] and bits_arr[2][i] == 1:
                judge = False
                break

            elif bits_arr[0][i] != bits_arr[1][i] and bits_arr[2][i] == 0:
                judge = False
                break
                
        if judge:
            print("Yes")
        else:
            print("No")


    else:
        print("No")

Submission status: Runtime Error

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

hats = A[:]
d = {}
for h in hats:
    d[h] = True

h1 = hats[0]

import sys

sys.setrecursionlimit(20000)
 
def search(now1, now2, count):
    now1, now2 = now2, now1^now2
    if now2 in d:
        if now2 == h1:
            if count == N:
                return True
            if count > N:
                return False
            else:
                return search(now1, now2, count+1)
        else:
            return search(now1, now2, count+1)
    else:
        return False
    

ans = False
for h2 in hats[1:]:
    if search(h1, h2, 2):
        ans = True

if ans:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

# %%
# N = 4
# a = [1, 2, 4, 8] 

# N = 3
# a = [1, 2, 3] 

def func(flg, bef, nokori):
    xor = [bef^x for x in nokori]
    curr_flg = []
    for j, curr in enumerate(nokori):
        if curr in xor:
            curr_flg.append(True)
            func(flg, curr, nokori[0:j]+nokori[j+1:])
        curr_flg.append(False)
        # print(curr_flg)
    flg = True in curr_flg

flg = True

for i, bef in enumerate(a):
    nokori = a[0:i] + a[i+1:]
    func(flg, bef, nokori)

if flg:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

def xor(a,b):
    x = 0
    ma = max(len(str(a)),len(str(b)))
    for i in range(ma):
        a = str(a).rjust(ma,"0")
        b = str(b).rjust(ma,"0")     
        if a[-i-1] != b[-i-1]:
            x+= 10**i
        else:
            pass
    return x

bin_l = []
for i in lists:
    a = bin(i)
    b = int(a[2:])
    bin_l.append(b)

zero = bin_l.count(0)

if zero <=len(bin_l)//2:
    if 0 in bin_l :
        k = bin_l.remove(0)
        if len(k) == 2:
        
            if k[0] == k[1]:
                print("Yes")
            else:
                print("No")
        elif len(k)%3 ==0 and len(set(k)) == 3:
            l = list(set(k))
    
    
            if l[0] == xor(l[1],l[2]) and l[1] == xor(l[0],l[2]) and l[2] == xor(l[0],l[1]):
                print("Yes")
            else:
                print("No")
        else:
            pass
    else:
        if len(bin_l)%3 ==0 and len(set(bin_l)) == 3:
            l = list(set(bin_l))
    
    
            if l[0] == xor(l[1],l[2]) and l[1] == xor(l[0],l[2]) and l[2] == xor(l[0],l[1]):
                print("Yes")
            else:
                print("No")   
        else:
            print("No")     

else:
    print("No")

Submission status: Runtime Error

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

hats = A[:]
d = {}
for h in hats:
    d[h] = True

h1 = hats[0]
 
def search(now1, now2, count):
    now1, now2 = now2, now1^now2
    if now2 in d:
        if now2 == h1:
            if count == N:
                return True
            if count > N:
                return False
            else:
                return search(now1, now2, count+1)
        else:
            return search(now1, now2, count+1)
    else:
        return False
    

ans = False
for h2 in hats[1:]:
    if search(h1, h2, 2):
        ans = True

if ans:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
a_2=[]
for i in range(len(a)):
    a_2.append(bin(a[i]))
import collections
c = collections.Counter(a_2)
b=[]
out=0
for i in c.values():
    b.append(i)
if a.count(0)==0:#0がない場合
    if len(b)!=3:
        out=1
    if b[0]!=b[1] or b[1]!=b[2]:
        out=1
    else:
        pass
else:#0あり
    if len(b)>2:
        out=1
    elif len(b)==1:
        pass
    elif len(b)==2:
        if a.count(0)*3==len(a):
            pass
        else:
            out=1
if out==0:
    print('Yes')
elif out==1:
    print('No')

Submission status: Runtime Error

Solution code:

import numpy as np 

def make_bit(A):
    arr = np.zeros(31)
    i = 30
    while A:
        arr[i] = A % 2
        A = A // 2
        i -= 1

    return arr

def return_first_second_third(a_lst):
    first = [a_lst[0], 0]
    second = [-1, -1]
    third = [-1, -1]
    i = 0
    while i < len(a_lst) - 1:
        if a_lst[i] != a_lst[i+1]:
            second[0] = a_lst[i+1]
            second[1] = i+1
            i += 1
            break
        else:
            i += 1
    while i < len(a_lst) - 1:
        if a_lst[i] != a_lst[i+1]:
            third[0] = a_lst[i+1]
            third[1] = i+1
            i += 1
            break
        else:
            i += 1
    
    return first, second, third


N = int(input())

a_lst = list(map(int, input().split()))
a_lst.sort()
first, second, third = return_first_second_third(a_lst)
a_lst.reverse()

done = False
if second[0] == -1: # 全ての数が同じとき
    done = True
    if first[1] == 0: # 全ての数がゼロの時
        print("Yes")
    else:
        print("No")
elif third[0] == -1:    # 数が2種類だけの時
    done = True
    if N % 2 == 0 and second[1] == N // 2:
        print("Yes")
    else:
        print("No")
elif N % 3 == 0 and second[1] == N // 3 and third[1] == N * 2 // 3:
    a_lst = [ a_lst[0] + a_lst[second[0]] + a_lst[third[0]] ]


if not done:
    if N == 3:

        a1 = make_bit(a_lst[0])
        a2 = make_bit(a_lst[1])
        a3 = make_bit(a_lst[2])
        bits_arr = np.array([a1, a2, a3])

        judge = True
        for i in range(31):
            if bits_arr[0][i] == bits_arr[1][i] and bits_arr[2][i] == 1:
                judge = False
                break

            elif bits_arr[0][i] != bits_arr[1][i] and bits_arr[2][i] == 0:
                judge = False
                break
                
        if judge:
            print("Yes")
        else:
            print("No")


    else:
        print("No")

Submission status: Runtime Error

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

hats = A[:]
d = {}
for h in hats:
    d[h] = True

h1 = hats[0]
 
def search(now1, now2, count):
    now1, now2 = now2, now1^now2
    if now2 in d:
        if now2 == h1:
            if count == N:
                return True
            if count > N:
                return True
            else:
                return search(now1, now2, count+1)
        else:
            return search(now1, now2, count+1)
    else:
        return False
    

ans = False
for h2 in hats[1:]:
    if search(h1, h2, 2):
        ans = True

if ans:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
a_2=[]
for i in range(len(a)):
    a_2.append(bin(a[i]))
import collections
c = collections.Counter(a_2)
b=[]
out=0
for i in c.values():
    b.append(i)
if a.count(0)==0:#0がない場合
    if len(b)!=3:
        out=1
    if b[0]!=b[1] or b[1]!=b[2]:
        out=1
        break
    else:
        pass
else:#0あり
    if len(b)>2:
        out=1
    elif len(b)==1:
        pass
    elif len(b)==2:
        if a.count(0)*3==len(a):
            pass
        else:
            out=1
if out==0:
    print('Yes')
elif out==1:
    print('No')

Submission status: Runtime Error

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

def xor(a,b):
    x = 0
    ma = max(len(str(a)),len(str(b)))
    for i in range(ma):
        a = str(a).rjust(ma,"0")
        b = str(b).rjust(ma,"0")     
        if a[-i-1] != b[-i-1]:
            x+= 10**i
        else:
            pass
    return x

bin_l = []
for i in lists:
    a = bin(i)
    b = int(a[2:])
    bin_l.append(b)

zero = bin_l.count(0)

if zero <=len(bin_l)//2:
    if 0 in bin_l:
        k = bin_l.remove(0)
        if len(k) == 2:
        
            if k[0] == k[1]:
                print("Yes")
            else:
                print("No")
        elif len(k)%3 ==0 and len(set(k)) == 3:
            l = list(set(k))
    
    
            if l[0] == xor(l[1],l[2]) and l[1] == xor(l[0],l[2]) and l[2] == xor(l[0],l[1]):
                print("Yes")
            else:
                print("No")
        else:
            pass
    else:
        if len(bin_l)%3 ==0 and len(set(bin_l)) == 3:
            l = list(set(bin_l))
    
    
            if l[0] == xor(l[1],l[2]) and l[1] == xor(l[0],l[2]) and l[2] == xor(l[0],l[1]):
                print("Yes")
            else:
                print("No")   
        else:
            print("No")     

else:
    print("No")

Submission status: Runtime Error

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

hats = A[:]
d = {}
for h in hats:
    d[h] = True

h1 = hats[0]
 
def search(now1, now2, count):
    now1, now2 = now2, now1^now2
    if now2 in d:
        if now2 == h1:
            if count == N:
                return True
            else:
                return search(now1, now2, count+1)
        else:
            return search(now1, now2, count+1)
    else:
        return False
    

ans = False
for h2 in hats[1:]:
    if search(h1, h2, 2):
        ans = True

if ans:
    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 = list(a.keys()), list(a.values())

if len(value)<3:
    if len(value)==1
        if sum(a)==0:
            print('Yes')
        else:
            print('No')

    if len(value)==2
        if 0 in value:
            if count[0]==N/3 or count[1]==N/3:
                print('Yes')
            else:
                print('No')

        else:
            print('No')

if len(value)>=3:
    if count[0]+count[1]+count[2] == N:
        if value[0]^value[1]^value[2] == 0:
            if count[0]==count[1]==count[2]:
                print('Yes')
            else:
                print('No')

    else:
        print('No')

Submission status: Runtime Error

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

if std_set == {0}:
    print("Yes")
elif len(std_set) == 2:
    if 0 in std_set:
        if std_tuple.count(0) * 3 == std_n:
            print("Yes")
        elif std_tuple.count(0) * 3 == std_n * 2:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
elif len(std_set) == 3:
    a, b, c = tuple(std_set)
    if std_tuple.count(a) == std_tuple.count(b) == std_tuple.count(c):
        if int(str(int(format(a, "b")) ^ int(format(b, "b"))), 2) == c:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=[A[0]]
A.remove(A[0])
for i in B:
        if i==N:
                if B[0]^B[N-2]==B[N-1]:
                        print('Yes')
                        break
                else:
                        print("No")
                        break
        for j in A:
                if i^j in A:
                        A.remove(j)
                        A.remove(i^j)
                        B.append(i^j)
                        B.append(j)
                        break
                elif j==A[len(A)]:
                        print("No")
                        break
                break

Submission status: Runtime Error

Solution code:
from functools import reduce 
n=int(input())
a=list(map(int, input().rstrip().split(' ')))
def check(x):
  return reduce(lambda x,y:x^y, x) == 0
if check(a):
  print('Yes')
  break
else:
  print('No')

Submission status: Runtime Error

Solution code:
N = input()
ai = [int(x) for x in input().split()]
bi = sum([int(bin(x)[2:]) for x in ai])
if list(set(str(bi)))[0] == "2":
  print("Yes")
else:
  if list(set(str(bi)))[0] == "0":
    print("Yes")
  else
    print("No")

Submission status: Runtime Error

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

def xor(a,b):
    x = 0
    ma = max(len(str(a)),len(str(b)))
    for i in range(ma):
        a = str(a).rjust(ma,"0")
        b = str(b).rjust(ma,"0")     
        if a[-i-1] != b[-i-1]:
            x+= 10**i
        else:
            pass
    return x

bin_l = []
for i in lists:
    a = bin(i)
    b = int(a[2:])
    bin_l.append(b)

zero = bin_l.count(0)

if zero <=len(bin_l)//2:
    if 0 in bin_l :
        k = bin_l.remove(0)
        if len(k) == 2:
        
            if k[0] == k[1]:
                print("Yes")
            else:
                print("No")
        elif len(k)%3 ==0 and len(set(k)) == 3:
            l = list(set(k))
    
    
            if l[0] == xor(l[1],l[2]) and l[1] == xor(l[0],l[2]) and l[2] == xor(l[0],l[1]):
                print("Yes")
            else:
                print("No")
        else:
            pass
    else:
        if len(bin_l)%3 ==0 and len(set(bin_l)) == 3:
            l = list(set(bin_l))
    
    
            if l[0] == xor(l[1],l[2]) and l[1] == xor(l[0],l[2]) and l[2] == xor(l[0],l[1]):
                print("Yes")
            else:
                print("No")   
        else:
            print("No")     

else:
    print("No")

Submission status: Runtime Error

Solution code:
import collections 

n = int(input())
input_list = [int(i) for i in input().split(' ')]

counter = collections.Counter(input_list)


unique_list = list(counter.keys())
counts = list(counter.values())

if (all(num == 0 for num in unique_list)):
    print('Yes')
else:
    if n % 3 == 0:
        zero_count = counter[0] 
        if zero_count == n / 3 and len(unique_list) == 2:
            print('Yes')
        else: 
            if len(unique_list) != 3:
                print('No')
            else if (unique_list[0] ^ unique_list[1] == unique_list[2]):
                if (all(counts[0] == num for num in counts)):
                    print('Yes')
                else:
                    print('No')
            else:
                print('No')
    else:
        print('No')

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
a_uni = list(set(a))
if len(a_uni) == 1:
	if a[0] == 0:
		print("Yes")
	else
		print("No")
elif n%3 != 0:
	print("No")
elif len(a_uni) == 2:
	if a.count(0) == n/3:
		print("Yes")	
	else:
		print("No")	
elif len(a_uni) == 3:
	if a_uni[0]^a_uni[1]!=a_uni[2]:
		print("No")
	elif a.count(a_uni[0])==n/3 and a.count(a_uni[1])==n/3:
		print("Yes")
	else:
		print("No")
else:
	print("No")

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
    default_queue = deque(a_list)
    default_queue.remove(base)
    for left in a_list:
        if base == left:
            pass
        else:
            q = copy.copy(default_queue)
            q.remove(left)
            result = seach(q, base, [left, base])
            if result:
                break
            else:
                pass

    break

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

Submission status: Runtime Error

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

def xor(a,b):
    x = 0
    ma = max(len(str(a)),len(str(b)))
    for i in range(ma):
        a = str(a).rjust(ma,"0")
        b = str(b).rjust(ma,"0")     
        if a[-i-1] != b[-i-1]:
            x+= 10**i
        else:
            pass
    return x

bin_l = []
for i in lists:
    a = bin(i)
    b = int(a[2:])
    bin_l.append(b)

zero = bin_l.count(0)

if zero <=len(bin_l)//2:
    if 0 in bin_l :
        k = bin_l.remove(0)
        if len(k) == 2:
        
            if k[0] == k[1]:
                print("Yes")
            else:
                print("No")
        elif len(k)%3 ==0 and len(set(k)) == 3:
            l = list(set(k))
    
    
            if l[0] == xor(l[1],l[2]) and l[1] == xor(l[0],l[2]) and l[2] == xor(l[0],l[1]):
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    else:
        if len(bin_l)%3 ==0 and len(set(bin_l)) == 3:
            l = list(set(bin_l))
    
    
            if l[0] == xor(l[1],l[2]) and l[1] == xor(l[0],l[2]) and l[2] == xor(l[0],l[1]):
                print("Yes")
            else:
                print("No")   
        else:
            print("No")     

else:
    print("No")

Submission status: Runtime Error

Solution code:
import collections 

n = int(input())
input_list = [int(i) for i in input().split(' ')]

counter = collections.Counter(input_list)


unique_list = list(counter.keys())
counts = list(counter.values())

if (all(num == 0 for num in unique_list)):
    print('Yes')
else:
    if n % 3 == 0:
        zero_count = counter[0] 
        if zero_count == n / 3 and len(unique_list) == 2:
            print('Yes')
        else: 
            if len(unique_list) != 3:
                print('No')
            if (unique_list[0] ^ unique_list[1] == unique_list[2]):
                if (all(counts[0] == num for num in counts)):
                    print('Yes')
                else:
                    print('No')
            else:
                print('No')
    else:
        print('No')

Submission status: Runtime Error

Solution code:
た　す　け　て

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):
    print(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
    default_queue = deque(a_list)
    default_queue.remove(base)
    for left in a_list:
        if base == left:
            pass
        else:
            q = copy.copy(default_queue)
            q.remove(left)
            result = seach(q, base, [left, base])
            if result:
                break
            else:
                pass

    break

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