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

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
a_list = list(map(int, input().split()))
ans = "No"
a_list.insert(0, a_list[-1])
a_list.append(a_list[1])
for i in range(1, N + 1):
    if (a_list[i-1] ^ a_list[i+1]) != a_list[i]:
        break
else:
    ans = "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
 
import sys
 
n= int(sys.stdin.readline())
ai = [ int(x) for x in sys.stdin.readline().split() ]

a = list(set(ai))
na= len(a)
ans= "No"
if na==1 and a[0]==0: ans="Yes"
elif na==2 and 0 in a:
    x= a[0]
    if x==0: x= a[1]
    if ai.count(x)==ai.count(0): ans= "Yes"
elif na==3:
    x,y,z= a
    if x^y^z: pass
    else:
        n,l,m= [ ai.count(i) for i in a ]
        if n==l==m: ans="Yes"
#
print( ans )

Submission status: Wrong Answer

Solution code:

import collections as col
N=int(input())
A=[ai for ai in map(int,input().split())]
Ans=False
if len(A)%3==0:
    CA=col.Counter(A)
    if len(CA)==3:
        K=list(CA.keys())
        if (K[0]^K[1]==K[2]) and (CA[K[0]]==CA[K[1]]==CA[K[2]]):
            Ans=True
    elif len(CA)==2:
        K=list(sorted(CA.keys()))
        if CA[K[0]]*2==CA[K[1]]:
            Ans=True
    elif len(CA)==1 and 0 in CA:
        Ans=True

print("Yes" if Ans==True else "No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
 
import sys
 
n= int(sys.stdin.readline())
ai = [ int(x) for x in sys.stdin.readline().split() ]

a = list(set(ai))
na= len(a)
ans= "No"
if na==1 and a[0]==0: ans="Yes"
elif na==2 and 0 in a:
    x= a[0]
    if x==0: x= a[1]
    if ai.count(x)==ai.count(0): ans= "Yes"
elif na==3:
    x,y,z= [ ai.count(i) for i in a ]
    if x==y==z: ans="Yes"
#
print( ans )

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int, input().split())))
frag=False
if n > 3 and (not sum(a)==0): frag=False
else:
    if (a[1]==a[2]) and a[0] == 0: frag=True
    if (a[2]-a[1])==a[0]:
      if a[1]%n != 0:
        frag=True
      else:
        if (a[1]//n)%2==0:
          frag=True
        if sum(a)==0: frag=True
        if (a[2]-a[1])==(a[1]-a[0])==1: frag=True

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

Submission status: Wrong Answer

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

a_i_set = list(set(a_i))

if len(a_i_set) == 3:
    if(a_i_set[0] ^ a_i_set[1] ^ a_i_set[2] == 0 and \
       a_i.count(a_i_set[0]) == a_i.count(a_i_set[1]) == a_i.count(a_i_set[2])):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:

import collections as col
N=int(input())
A=[ai for ai in map(int,input().split())]
Ans=False
if len(A)%3==0:
    CA=col.Counter(A)
    if len(CA)==3:
        K=list(CA.keys())
        if (K[0]^K[1]==K[2]) and (CA[K[0]]==CA[K[1]]==CA[K[2]]):
            Ans=True
    elif len(CA)==2:
        K=list(sorted(CA.keys()))
        if CA[K[0]]*2==CA[K[1]]:
            Ans=True

print("Yes" if Ans==True else "No")

Submission status: Wrong Answer

Solution code:
# A
N = int(input())
a = list(map(int, input().split()))
flag = True
if max(a) == 0:
    print('Yes')
else:
    if N % 3 != 0:
        print('No')
    elif 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)
        t = []
        for i in range(3):
            tmp_list = a[n * i : n * (i + 1)]
            t.append(a[n * i])
            if i == n:
                if min(tmp_list) == max(tmp_list):
                    if t[0] == t[1] ^ t[2] and t[1] == t[2] ^ t[0] and t[2] == t[0] ^ t[1]:
                        pass
                    else:
                        flag = False
                elif t[0] == 0 and t[1] == t[2]:
                    pass
                else:
                    flag = False
        if flag:
            print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

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

a_i_set = list(set(a_i))

if len(a_i_set) == 3:
    if(a_i_set[0] ^ a_i_set[1] == a_i_set[2] and \
       a_i_set[1] ^ a_i_set[2] == a_i_set[0] and \
       a_i.count(a_i_set[0]) == a_i.count(a_i_set[1]) == a_i.count(a_i_set[2])):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

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

ans = set(A)
if len(ans) <= 3:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from operator import xor
from functools import reduce

n = int(input())
hats = list(map(int, input().split(' ')))

if reduce(xor, hats) == 0:
    uni = list(set(hats))

    if len(uni) == 3:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from operator import xor
from functools import reduce

n = int(input())
hats = list(map(int, input().split(' ')))

if reduce(xor, hats) == 0:
    uni = list(set(hats))

    if len(uni) in [2, 3]:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
_,a=open(0);a,*b=map(int,a.split())
for b in b:a^=b
print('YNeos'[b>0::2])

Submission status: Wrong Answer

Solution code:
N = int(input())
d = list(map(int,input().split()))
d_unique = list(set(d))

if len(d_unique) == 1:
    if d_unique[0] == 0:
        print('Yes')
    else:
        print('No')

else:
    if N%3 != 0 :
        print('No')

    else :
        if len(d_unique) == 2 :
            i1 = d_unique[0]
            i2 = d_unique[1]
            len_i1 = d.count(i1)
            len_i2 = d.count(i2)
            if len_i1 ==  N/3 and i1 == 0 :
                print('Yes')
            elif len_i2 ==  N/3 and i2 == 0 :
                print('Yes')                
            else :
                print('No')

        elif len(d_unique) == 3 :
            i1 = d_unique[0]
            i2 = d_unique[1]
            i3 = d_unique[2]
            len_i1 = d.count(i1)
            len_i2 = d.count(i2)
            len_i3 = d.count(i3)
            if i1 & i2 & i3 != 0:
                print('No')     
            else:
                if len_i1 ==  N/3 and len_i2 == N/3 :
                    print('Yes')
                else :
                    print('No')

Submission status: Wrong Answer

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 or n==m|l or m==n|l :ans=1
if len(set(A))==1:
	if A[0]==0:ans=1
if len(set(A))==2:
	if P%3==0:
		if A.count(0)==P//3:ans=1

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

Submission status: Wrong Answer

Solution code:
_ = input()
input_num = [int(i) for i in input().split(" ")]
input_size = len(input_num)-1


if sum(input_num)==0:
  print("Yes")
else:
    for i in range(len(input_num)):
        left = i-1
        right = i+1
        if left < 0:
            left = input_size
        if right > input_size:
          right = 0
    #     print(input_num[left])
    #     print(input_num[right])
        if (input_num[left]^input_num[right]) == input_num[i]:
            continue
        else:
            print("No")
            break
    else:
        print("Yes")

Submission status: Wrong Answer

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 or n==m|l or m==n|l :ans=1
if len(set(A))==1:
	if A[0]==0:ans=1
if len(set(A))==2:
	if P%2==0:
		if A.count(0)==P//3:ans=1

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

Submission status: Wrong Answer

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 and first[0] == 0:
        print("Yes")
    else:
        print("No")
elif N % 3 == 0 and N != 3 and second[1] == N // 3 and third[1] == N * 2 // 3:
    a_lst = [ a_lst[0], a_lst[second[1]], a_lst[third[1]] ]
elif N % 3 == 0 and N != 3 and second[1] == N // 3 and third[1] == N * 2 // -1:
    a_lst = [ a_lst[0], a_lst[second[1]], a_lst[third[1]] ]

if not done:
    if len(a_lst) == 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: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
if N % 3:
  print('No')
else:
  a.sort()
  for i in range(N):
    if a[i] != a[(i//(N//3))*(N//3)]:
      print('No')
      break
  else:
    print('Yes')

Submission status: Wrong Answer

Solution code:

N = int(input())
d = list(map(int,input().split()))
d_unique = list(set(d))

if len(d_unique) == 1:
    if d_unique[0] == 0:
        print('Yes')
    else:
        print('No')

else:
    if N%3 != 0 :
        print('No')

    else :
        if len(d_unique) == 2 :
            i1 = d_unique[0]
            i2 = d_unique[1]
            len_i1 = d.count(i1)
            len_i2 = d.count(i2)
            if len_i1 ==  N/3 and i1 == 0 :
                print('Yes')
            elif len_i2 ==  N/3 and i2 == 0 :
                print('Yes')                
            else :
                print('No')

        elif len(d_unique) == 3 :
            i1 = d_unique[0]
            i2 = d_unique[1]
            i3 = d_unique[2]
            len_i1 = d.count(i1)
            len_i2 = d.count(i2)
            len_i3 = d.count(i3)
            if len_i1 ==  N/3 and len_i2 == N/3 :
                print('Yes')
            else :
                print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int, input().split())))
frag=False
if n > 3 and (not sum(a)==0): frag=False
else:
    if (a[1]==a[2]) and a[0] == 0: frag=True

    if (a[2]-a[1])==a[0]:
        if a[1]%n != 0:
            frag=True
        else:
            if (a[1]//n)%2==0:
                frag=True
    if sum(a)==0: frag=True
    if (a[2]-a[1])==(a[1]-a[0])==1 and n <= 3: frag=True

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

Submission status: Wrong Answer

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

R = {}
for i in a:
  if i in R:
    R[i] += 1
  else:
    R[i] = 1

ans = ["Yes", "No"]
if 0 in R:
  if len(R) == 1:
    print(ans[0])
  elif len(R) == 2:
    for i in R.keys():
      if i != 0:
        x = R[i]
      else:
        z = R[i]
    if x == z * 2:
      print("hoge")
    else:
      print(ans[1])
  else:
    print(ans[1])
else:
  if len(R) != 3:
    print(ans[1])
  else:
    t = -1
    for i in R.values():
      if t == -1:
        t = i
      else:
        if i != t:
          print(ans[1])
          break
    else:
      a = b = c = -1
      for i in R.keys():
        if a == -1:
          a = i
        elif b == -1:
          b = i
        else:
          c = i
      if a ^ b == c:
        print(ans[0])
      else:
        print(ans[1])

Submission status: Wrong Answer

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 and first[0] == 0:
        print("Yes")
    else:
        print("No")
elif N % 3 == 0 and N != 3 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 len(a_lst) == 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: Wrong Answer

Solution code:
from collections import defaultdict
def main():
	N = int(input())
	A = list(map(int, input().split()))

	if all(map(lambda a: a==0, A)):
		print("Yes")
		return

	ans_dict = defaultdict(int)
	for a in A:
		ans_dict[a] += 1
	if len(ans_dict) == 3:
		xor = 0
		num = [0, 0, 0]
		i = 0
		for k in ans_dict:
			num[i] = ans_dict[k]
			xor ^= k
			i += 1
		if num[0] == num[1] and num[1] == num[2] and xor == 0:
			print("Yes")
			return
	if len(ans_dict) == 2 and 0 in ans_dict:
		num = [ans_dict[0], 0]
		for k in ans_dict:
			if k == 0:
				continue
			num[1] = ans_dict[k]
		if num[1]*2 == num[0]:
			print("Yes")
			return
	print("No")


if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
A.append(A[0])
A.append(A[1])
d=0

# for i in range(0,n):
#     a=str(bin(A[i]))
#     b=str(bin(A[i+2]))
#     print(a)
#     print(b)
#     c=bin("a"^"b")
#     if int(bin(c,2))==int(A[i+1]):
#        d=d+1
for i in range(0,n):
    if bin(A[i]^A[i+2])==bin(A[i+1]):
       d=d+1
if d==n:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
if N % 3:
  print('No')
else:
  a.sort()
  for i in range(0,N,3):
    if not (a[i]==a[i+1]==a[i+2]):
      print('No')
      break
  else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
_ = input()
input_num = [int(i) for i in input().split(" ")]
input_size = len(input_num)-1


if sum(input_num)==0:
  print("Yes")
else:
    for i in range(len(input_num)):
        left = i-1
        right = i+1
        if left < 0:
            left = input_size
        if right > input_size:
          right = 0
    #     print(input_num[left])
    #     print(input_num[right])
        if input_num[left]^input_num[right] == input_num[i]:
            continue
        else:
            print("No")
            break
    else:
        print("Yes")

Submission status: Wrong Answer

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 and first[1] == 0:
        print("Yes")
    else:
        print("No")
elif N % 3 == 0 and N != 3 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 len(a_lst) == 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: Wrong Answer

Solution code:
N = int(input())
d = list(map(int,input().split()))
d_unique = list(set(d))

if len(d) == 1:
    if d_unique == 0:
        print('Yes')
    else:
        print('No')
else:
    if N%3 != 0 :
        print('No')
    else :
        if len(d) == 2 :
            i1 = d_unique[0]
            i2 = d_unique[1]
            len_i1 = d.count(i1)
            len_i2 = d.count(i2)
            if len_i1 ==  N/3 or len_i2 == N/3 :
                print('Yes')
            else :
                print('No')
        elif len(d) == 3 :
            i1 = d_unique[0]
            i2 = d_unique[1]
            i3 = d_unique[2]
            len_i1 = d.count(i1)
            len_i2 = d.count(i2)
            len_i3 = d.count(i3)
            if len_i1 ==  N/3 and len_i2 == N/3 :
                print('Yes')
            else :
                print('No')

Submission status: Wrong Answer

Solution code:
_ = input()
input_num = [int(i) for i in input().split(" ")]
input_num = [i for i in reversed(input_num)]
input_size = len(input_num)-1

if input_size < 2:
  print("No")
if sum(input_num)==0:
  print("Yes")
for i in range(len(input_num)):
    left = i-1
    right = i+1
    if left < 0:
        left = input_size
    if right > input_size:
      right = 0
#     print(input_num[left])
#     print(input_num[right])
    if input_num[left]^input_num[right] == input_num[i]:
        continue
    else:
        print("No")
        break
else:
    print("Yes")

Submission status: Wrong Answer

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 and first[1] == 0:
        print("Yes")
    else:
        print("No")
elif N % 3 == 0 and N != 3 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: Wrong Answer

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

xor = 1
for a in a_list:
    xor ^= a
    
if a == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n =int(input())
rakuda = [0] * n

rakuda = []
s = input()
rakuda = s.split(' ')
# print(rakuda)

# for i in range(n):
#     # print(i)
#     rakuda[i] = int(input())

flag = True
for i in range(n):
    left = i - 1;
    right = i + 1;
    if(left == -1): left = n - 1
    if(right == n): right = 0
    
    if((int(rakuda[left]) ^ int(rakuda[right]) ^ int(rakuda[i])) != 0):
        flag = False
        break


if(flag == False):
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int, input().split())))
frag=False
if (a[1]==a[2]) and a[0] == 0: frag=True

if (a[2]-a[1])==a[0]:
    if a[1]%n != 0:
        frag=True
    else:
        if (a[1]//n)%2==0:
            frag=True
if sum(a)==0: frag=True
if n > 3: frag=False
if (a[2]-a[1])==(a[1]-a[0])==1 and n <= 3: frag=True

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

Submission status: Wrong Answer

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

flg = 1
sum = lst[-1]
for i in range(len(lst)):
  if i == lst[-1]:
    break
  sum = sum ^ lst[i]
  if i+1 == len(lst):
    if bin(lst[i]) != bin(lst[i-1] ^ lst[0]):
      flg = 0
      #break
  elif bin(lst[i]) != bin(lst[i-1] ^ lst[i+1]):
    flg = 0
    #break
if sum == 0:
  print("Yes")
else:
  print("No")
#elif flg == 1:
#  print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import Counter

def main():
    num = int(input())
    data = list(map(int, input().split()))

    num_c = Counter(data)
    if len(num_c) > 3:
        print('No')
    else:
        if len(num_c) == 1:
            if num_c[0] == num:
                print('Yes')
            else:
                print('No')
        elif num % 3 == 0:
            if len(num_c) == 2:
                if num_c[0] == num // 3:
                    print('Yes')
                else:
                    print('No')
            else:
                ans = 0
                for ele in num_c.keys():
                    ans ^= ele
                if ans == 0:
                    print('Yes')
                else:
                    print('No')
        else:
            print('No')







if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

flg = 1
sum = lst[-1]
for i in range(len(lst)):
  sum = sum ^ lst[i]
  if i+1 == len(lst):
    if bin(lst[i]) != bin(lst[i-1] ^ lst[0]):
      flg = 0
      #break
  elif bin(lst[i]) != bin(lst[i-1] ^ lst[i+1]):
    flg = 0
    #break
if sum == 0:
  print("Yes")
else:
  print("No")
#elif flg == 1:
#  print("Yes")

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())

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

a_coll  = collections.Counter(a)
a_key   = list(a_coll.keys())
a_value = list(a_coll.values())

if N % 3 != 0:
    if len(a_key) == 1 and a_key[0] == 0:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

if len(a_key) == 1:
    if a_key[0] == 0:
        print("Yes")
        exit()

if len(a_key) == 2:
    if 0 in a_key:
        print("Yes")
        exit()

for key,count in zip(a_key,a_value):
    if key == 0:
        if count != int(N / 3):
            print("No")
            exit()
    else:
        if count != int(2* N / 3):
            print("No")
            exit()

if len(a_key) == 3:
    if a_key[0] ^ a_key[1] == a_key[2]:
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter

def main():
    num = int(input())
    data = list(map(int, input().split()))

    num_c = Counter(data)
    if len(num_c) > 3 or num % 3 != 0:
        print('No')
    else:
        if len(num_c) == 1:
            if num_c[0] == num:
                print('Yes')
            else:
                print('No')
        elif len(num_c) == 2:
            if num_c[0] == num // 3:
                print('Yes')
            else:
                print('No')
        else:
            ans = 0
            for ele in num_c.keys():
                ans ^= ele
            if ans == 0:
                print('Yes')
            else:
                print('No')







if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
b=set(a)
l=len(b)
if l==2:
  c=sorted([b.pop(),b.pop()])
  if c[1]^c[0]==c[1]:
    if n%2==0 and a[n//3-1]!=a[n//3]:print("Yes")
    else:print("No")
  else:print("No")
  exit()
elif l==1:
  if a[0]==0:print("Yes")
  else:print("No")
  exit()
def ecount(X):
  c,ans=1,[]
  for i in range(len(X)-1):
    if X[i]==X[i+1]:c+=1
    else:
      ans.append(c);c=1
  ans.append(c)
  return ans
for i in range(n):
  if a[i]!=0:d=ecount(a[i:]);z=i;break
if l-(0 in b)!=3:print("No");exit()
if 0 in b:b.discard(0)
for i in range(z):
  d.sort()
  d[-1]-=1
d.sort()
if d[0]>0 and b.pop()^b.pop()^b.pop()==0 and d[0]==d[2]:print("Yes")
else:print("No")

Submission status: Wrong Answer

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

flg = 1
sum = lst[-1]
for i in range(len(lst)):
  sum = sum ^ lst[i]
  if i+1 == len(lst):
    if bin(lst[i]) != bin(lst[i-1] ^ lst[0]):
      flg = 0
      #break
  elif bin(lst[i]) != bin(lst[i-1] ^ lst[i+1]):
    flg = 0
    #break
if sum == 0:
  print("Yes")
elif flg == 1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

hats = A[:]
import copy
from collections import defaultdict
d = defaultdict(lambda: 0)

for h in hats:
    d[h] += 1

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

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int, input().split())))
frag=False
if (a[1]==a[2]) and a[0] == 0: frag=True
if (a[2]-a[1])==(a[1]-a[0])==1: frag=True
if n > 3: frag=False
if (a[2]-a[1])==a[0]:
    if a[1]%n != 0:
        frag=True
    else:
        if (a[1]//n)%2==0:
            frag=True
if sum(a)==0: frag=True
print("Yes" if frag else "No")

Submission status: Wrong Answer

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

f = True

a_list.sort()

for i in range(N):
    a1 = a_list[i-1]
    a2 = a_list[i % N]
    a3 = a_list[(i + 1) % N]
    if a1 ^ a3 == a2:
        continue
    else:
        f = False

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