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:
# Your code here!
N = input()
num = input().split(" ")
ichi = int(-1)
ni = int(-1)
san = int(-1)
unko = str()
for i in range(int(N)):
  if int(num[i]) == ichi:
    pass
  else:
    if int(num[i]) == ni:
      pass
    else:
      if int(num[i]) == san:
        pass
      else:
        if ichi == -1:
          ichi = int(num[i])
        elif ni == -1:
          ni = int(num[i])
        elif san == -1:
          san = int(num[i])
        else:
          unko = "unko"
          break

if int(N) % 3 != 0:
    unko = "unko"
else:
    pass

if unko != "unko":
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N = input()
num = input().split(" ")
ichi = int(-1)
ni = int(-1)
san = int(-1)
unko = str()
for i in range(int(N)):
  if int(num[i]) == ichi:
    pass
  else:
    if int(num[i]) == ni:
      pass
    else:
      if int(num[i]) == san:
        pass
      else:
        if ichi == -1:
          ichi = int(num[i])
        elif ni == -1:
          ni = int(num[i])
        elif san == -1:
          san = int(num[i])
        else:
          print("No")
          unko = "unko"
          break

if unko != "unko":
  print("Yes")
else:
  pass

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
*a, = map(int, input().split())
c = Counter(a)
used = set(c.keys())
size = len(used)

if 0 in used and size==1:
    print("Yes")
elif 0 in used and size==2 and c[0]==N//2:
    print("Yes")
elif size==3:
    s, t, u = used.pop(), used.pop(), used.pop()
    if s^t^u==0 and c[s]==c[t]==c[u]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
lists=list(map(int,input().split()))
import collections
d=dict(collections.Counter(lists))
if n%3==0:

    if True:
        if len(d)==3:
            a,b,c=tuple([some for some in d.keys()])
            x,y,z=tuple([some for some in d.values()])
            if a^b^c==0 and x==y==z==n//3:
                print("Yes")
            else:
                print("No")
        
        
        elif len(d)==2:
            a,b=tuple([some for some in d.keys()])
            x,y=tuple([some for some in d.values()])
            if a!=0 and b!=0:
                print("No")
            else:
                if a==0:
                    if d[a]==n//3 and d[b]==2*n//3:
                        print("Yes")
                    else:
                        print("No")
                elif b==0:
                    if d[b]==n//3 and d[a]==2*n//3:
                        print("Yes")
                    else:
                        print("No")
            
        
        elif len(d)==1:
            if lists[0]==0:
                print("Yes")
            else:
                print("No")
            
        elif len(d)>3:
            print("No")
            
    
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
lists=list(map(int,input().split()))
import collections
d=dict(collections.Counter(lists))
if n%3==0:
    if min(lists)==-1:
        print("Yes")
    else:
        if len(d)==3:
            a,b,c=tuple([some for some in d.keys()])
            x,y,z=tuple([some for some in d.values()])
            if a^b^c==0 and x==y==z==n//3:
                print("Yes")
            else:
                print("No")
        
        
        elif len(d)==2:
            a,b=tuple([some for some in d.keys()])
            x,y=tuple([some for some in d.values()])
            if a!=0 and b!=0:
                print("No")
            else:
                if a==0:
                    if d[a]==n//3 and d[b]==2*n//3:
                        print("Yes")
                    else:
                        print("No")
                if b==0:
                    if d[b]==n//3 and d[a]==2*n//3:
                        print("Yes")
                    else:
                        print("No")
            
        
        elif len(d)==1:
            if lists[0]==0:
                print("Yes")
            else:
                print("No")
            
        else:
            print("No")
            
    
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
lists=list(map(int,input().split()))
import collections
d=dict(collections.Counter(lists))
if n%3==0:
    if min(lists)==0:
        print("Yes")
    else:
        if len(d)==3:
            a,b,c=tuple([some for some in d.keys()])
            x,y,z=tuple([some for some in d.values()])
            if a^b^c==0 and x==y==z==n//3:
                print("Yes")
            else:
                print("No")
        
        
        elif len(d)==2:
            a,b=tuple([some for some in d.keys()])
            x,y=tuple([some for some in d.values()])
            if a!=0 and b!=0:
                print("No")
            else:
                if a==0:
                    if d[a]==n//3 and d[b]==2*n//3:
                        print("Yes")
                    else:
                        print("No")
                if b==0:
                    if d[b]==n//3 and d[a]==2*n//3:
                        print("Yes")
                    else:
                        print("No")
            
        
        else:
            print("No")
    
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#Xor circle
n=int(input())
lists=list(map(int,input().split()))
import collections
d=dict(collections.Counter(lists))
if len(d)==3:
    sub=[]
    for some in d.values():
        sub.append(some)
    sub=sorted(sub)
    a,b,c=tuple([some for some in d.keys()])
    judge=False
    if a^b^c==0:
        judge=True
    if n%3==0:
        if sub==[n//3,n//3,n//3] and judge:
            print("Yes")
        else:
            print("No")
    elif n%3==1:
        if sub==[n//3,n//3,n-2*n//3] and judge:
            print("Yes")
        else:
            print("No")
    elif n%3==2:
        if sub==[n//3+1,n//3+1,n-n//3*2-2] and judge:
            print("Yes")
        else:
            print("No")
            
    
elif len(d)==2:
    sub=[]
    for some in d.values():
        sub.append(some)
    sub=sorted(sub) 
    if n%3==0:
        if sub==[n//3*2,n//3]:
            print("Yes")
        else:
            print("No")
    elif n%3==1:
        if sub==[n//3*2,n-n//3*2] or sub==[n//3*2+1,n-1-2*n//3]:
            print("Yes")
        else:
            print("No")
    elif n%3==2:
        if sub==[n//3*2+1,n//3+1] or sub==[n//3*2+2,n//3]:
            print("Yes")
        else:
            print("No")
    
    
elif len(d)==1:
    print("No")

else:
    print("No")

Submission status: Wrong Answer

Solution code:
#Xor circle
n=int(input())
lists=list(map(int,input().split()))
import collections
d=dict(collections.Counter(lists))
if len(d)==3:
    sub=[]
    for some in d.values():
        sub.append(some)
    sub=sorted(sub)
    a,b,c=tuple([some for some in d.keys()])
    judge=False
    if a^b^c==0:
        judge=True
    if n%3==0:
        if sub==[n//3,n//3,n//3] and judge:
            print("Yes")
        else:
            print("No")
    elif n%3==1:
        if sub==[n//3,n//3,n-2*n//3] and judge:
            print("Yes")
        else:
            print("No")
    elif n%3==2:
        if sub==[n//3+1,n//3+1,n-n//3*2-2] and judge:
            print("Yes")
        else:
            print("No")
            
    
elif len(d)==2:
    sub=[]
    for some in d.values():
        sub.append(some)
    sub=sorted(sub) 
    if n%3==0:
        if sub==[n//3*2,n//3]:
            print("Yes")
        else:
            print("No")
    elif n%3==1:
        if sub==[n//3*2,n-n//3*2] or sub==[n//3*2+1,n-1-2*n//3]:
            print("Yes")
        else:
            print("No")
    elif n%3==2:
        if sub==[n//3*2+1,n//3+1] or sub==[n//3*2+2,n//3]:
            print("Yes")
        else:
            print("No")
    
    
elif len(d)==1:
    print("Yes")

else:
    print("No")

Submission status: Wrong Answer

Solution code:
#Xor circle
n=int(input())
lists=list(map(int,input().split()))
import collections
d=dict(collections.Counter(lists))
if len(d)==3:
    sub=[]
    for some in d.values():
        sub.append(some)
    sub=sorted(sub)
    if n%3==0:
        if sub==[n//3,n//3,n//3]:
            print("Yes")
        else:
            print("No")
    elif n%3==1:
        if sub==[n//3,n//3,n-2*n//3]:
            print("Yes")
        else:
            print("No")
    elif n%3==2:
        if sub==[n//3+1,n//3+1,n-n//3*2-2]:
            print("Yes")
        else:
            print("No")
            
    
elif len(d)==2:
    sub=[]
    for some in d.values():
        sub.append(some)
    sub=sorted(sub) 
    if n%3==0:
        if sub==[n//3*2,n//3]:
            print("Yes")
        else:
            print("No")
    elif n%3==1:
        if sub==[n//3*2,n-n//3*2] or sub==[n//3*2+1,n-1-2*n//3]:
            print("Yes")
        else:
            print("No")
    elif n%3==2:
        if sub==[n//3*2+1,n//3+1] or sub==[n//3*2+2,n//3]:
            print("Yes")
        else:
            print("No")
    
    
elif len(d)==1:
    print("Yes")

else:
    print("No")

Submission status: Wrong Answer

Solution code:
#Xor circle
n=int(input())
lists=list(map(int,input().split()))
import collections
d=dict(collections.Counter(lists))
if len(d)<=3:
    flag=True
    for key,value in d.items():
        if value<n//3:
            flag=False
            break
    if flag:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#Xor circle
n=int(input())
lists=list(map(int,input().split()))
if all(lists[i-1]^lists[i+1]==lists[i] for i in range(n-1)) and lists[-2]^lists[0]==lists[-1]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#Xor circle
n=int(input())
lists=list(map(int,input().split()))
lists.append(lists[0])
flag=True
for i in range(1,n):
    if lists[i-1]^lists[i+1]!=lists[i]:
        flag=False
        break
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import collections
def main():
    n = int(input())
    a = list(map(int,input().split()))
    cnt = collections.Counter(a)
    num = len(set(a))
    if sum(a) == 0:
        print('Yes')
        return
    # if n % 3 != 0:
        # print('No')
        # return
    if len(cnt.most_common()) == 3:
        if cnt.most_common()[0][1] == cnt.most_common()[1][1] == cnt.most_common()[2][1]  :
            # print(cnt.most_common())
            print('Yes')
            return

    if len(cnt.most_common()) == 2:

        tmp_min = cnt.most_common()[1][1]
        tmp_max = cnt.most_common()[0][1]
        if 3 * tmp_min == n and int(cnt.most_common()[1][0]) == 0:
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import collections
def main():
    n = int(input())
    a = list(map(int,input().split()))
    cnt = collections.Counter(a)
    num = len(set(a))
    if sum(a) == 0:
        print('Yes')
        return
    # if n % 3 != 0:
        # print('No')
        # return
    if len(cnt.most_common()) == 3:
        if cnt.most_common()[0][1] == cnt.most_common()[1][1] == cnt.most_common()[2][1]  :
            print(cnt.most_common())
            print('Yes')
            return

    if len(cnt.most_common()) == 2:

        tmp_min = cnt.most_common()[1][1]
        tmp_max = cnt.most_common()[0][1]
        if 3 * tmp_min == n and int(cnt.most_common()[1][0]) == 0:
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import collections
def main():
    n = int(input())
    a = list(map(int,input().split()))
    cnt = collections.Counter(a)
    num = len(set(a))
    if sum(a) == 0:
        print('Yes')
        return
    # if n % 3 != 0:
        # print('No')
        # return
    if len(cnt.most_common()) == 3:
        if cnt.most_common()[0][1] == cnt.most_common()[1][1] == cnt.most_common()[2][1]  :
            print(cnt.most_common())
            print('Yes')
            return

    if len(cnt.most_common()) == 2:

        tmp_min = cnt.most_common()[1][1]
        tmp_max = cnt.most_common()[0][1]
        if 3 * tmp_min == n and int(cnt.most_common()[1][0]) == 0:
            print('Yes1')
            return
    print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import collections
def main():
    n = int(input())
    a = list(map(int,input().split()))
    cnt = collections.Counter(a)
    num = len(set(a))
    if sum(a) == 0:
        print('Yes')
        return
    # if n % 3 != 0:
        # print('No')
        # return
    if len(cnt.most_common()) == 3:
        if cnt.most_common()[0][1] == cnt.most_common()[1][1] and cnt.most_common()[2][1] == cnt.most_common()[1][1] :
            print('Yes')
            return

    if len(cnt.most_common()) == 2:

        tmp_min = cnt.most_common()[1][1]
        tmp_max = cnt.most_common()[0][1]
        if 3 * tmp_min == n and int(cnt.most_common()[1][0]) == 0:
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import collections
def main():
    n = int(input())
    a = list(map(int,input().split()))
    cnt = collections.Counter(a)
    num = len(set(a))
    if sum(a) == 0:
        print('Yes')
        return
    # if n % 3 != 0:
        # print('No')
        # return
    if len(cnt.most_common()) == 3:
        if cnt.most_common()[0][1] == cnt.most_common()[1][1] and cnt.most_common()[2][1] == cnt.most_common()[1][1] :
            print('Yes')
            return

    if len(cnt.most_common()) == 2:

        tmp_min = cnt.most_common()[1][1]
        tmp_max = cnt.most_common()[0][1]
        if 3 * tmp_min == n and cnt.most_common()[1][0] == str(0):
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import collections
def main():
    n = int(input())
    a = list(map(int,input().split()))
    cnt = collections.Counter(a)
    num = len(set(a))
    if sum(a) == 0:
        print('Yes')
        return
    if n % 3 != 0:
        print('No')
        return
    if len(cnt.most_common()) == 3:
        if cnt.most_common()[0][1] == cnt.most_common()[1][1] and cnt.most_common()[2][1] == cnt.most_common()[1][1] :
            print('Yes')
            return

    if len(cnt.most_common()) == 2:

        tmp_min = cnt.most_common()[1][1]
        tmp_max = cnt.most_common()[0][1]
        if tmp_max // tmp_min == 2 and cnt.most_common()[1][0] == str(0):
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import collections
def main():
    n = int(input())
    a = list(map(int,input().split()))
    cnt = collections.Counter(a)
    num = len(set(a))
    if sum(a) == 0:
        print('Yes')
        return
    if n % 3 != 0:
        print('No')
        return
    if len(cnt.most_common()) == 3:
        if cnt.most_common()[0][1] == cnt.most_common()[1][1] and cnt.most_common()[2][1] == cnt.most_common()[1][1] :
            print('Yes')
            return

    if len(cnt.most_common()) == 2:
        tmp_min = min(cnt.most_common()[0][1],cnt.most_common()[1][1])
        tmp_max = max(cnt.most_common()[0][1],cnt.most_common()[1][1])
        if tmp_max // tmp_min == 2:
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import collections
def main():
    n = int(input())
    a = list(map(int,input().split()))
    cnt = collections.Counter(a)
    num = len(set(a))
    if n % 3 != 0:
        print('No')
        return
    if len(cnt.most_common()) == 3:
        
        if cnt.most_common()[0][1] == cnt.most_common()[1][1] and cnt.most_common()[2][1] == cnt.most_common()[1][1] :
            print('Yes')
            return
    if sum(a) == 0:
        print('Yes')
        return
    if len(cnt.most_common()) == 2:
        tmp_min = min(cnt.most_common()[0][1],cnt.most_common()[1][1])
        tmp_max = max(cnt.most_common()[0][1],cnt.most_common()[1][1])
        if tmp_max // tmp_min == 2:
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import collections
def main():
    n = int(input())
    a = list(map(int,input().split()))
    cnt = collections.Counter(a)
    num = len(set(a))
    if n % 3 != 0:
        print('No')
        return
    if num != 3 and cnt.most_common()[0][1] !=3 and cnt.most_common()[-1][1] != 3:
        print('No')
        return
    print('Yes')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import collections
def main():
    n = int(input())
    a = list(map(int,input().split()))
    # cnt = collections.Counter(a)
    num = len(set(a))
    if n % 3 != 0:
        print('No')
        return
    if num != 3:
        print('No')
        return
    print('Yes')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from functools import reduce
from operator import xor
from collections import Counter
N=int(input())
A=list(map(int, input().split()))
C=Counter(A)
if len(C)==1:
    k=list(C.keys())[0]
    print("YNeos"[k!=0::2])
else:
    print("YNeos"[not(len(C)==3 and reduce(xor, C.keys())==0)::2])

Submission status: Wrong Answer

Solution code:
from functools import reduce
from operator import xor
from collections import Counter
N=int(input())
A=list(map(int, input().split()))
C=Counter(A)
if len(C)==1:
    print("Yes")
else:
    print("YNeos"[not(len(C)==3 and reduce(xor, C.keys())==0)::2])

Submission status: Wrong Answer

Solution code:
from functools import reduce
from operator import xor
from collections import Counter
N=int(input())
A=list(map(int, input().split()))
C=Counter(A)
print("YNeos"[not(len(C)==3 and reduce(xor, C.keys())==0)::2])

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
a = A[0]
for i in range(1, n):
  a ^= A[i]
c = Counter(A)
if a == 0:
  if len(c) == 3 and all(v == n // 3 for v in c.values()):
    print('Yes')
  elif len(c) == 2 and c.get(0) > 0 and n - c[0] == 2 * c[0]: 
    print('Yes')
  else:
    print('No')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
a = A[0]
for i in range(1, n):
  a ^= A[i]
c = Counter(A)
if a == 0 and len(c) == 3 and all(v == n // 3 for v in c.values()):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
a = A[0]
for i in range(1, n):
  a ^= A[i]
if a == 0 and len(Counter(A)) == 3:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
# 1,2,3
# 01
# 10
# 11

# 両隣のXORと一致->両隣と自分をXORすると0になる
# 連続した3つのXORが0になる
# a,b,c,dでaとdは同じになる

# 円環になるには、
# a,b,c,a,b,cというセットになり、
# 且つa,b,cのXORが0であればよい
# もしくは全部0

n=int(input())
a=list(map(int,input().split()))
dis=set(a)
if a[0]==0 and len(dis)==1:
  print("Yes")
  exit(0)
if len(dis)==3:
  xor=0
  cur=0
  for c in dis:
    xor^=c
    cnt=a.count(c)
    if cur==0:
      cur=cnt
    else:
      if cnt!=cur:
        print("No")
        exit(0)
  if xor==0:
    print("Yes")
    exit(0)
print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
if n%3!=0:
  if a.count(0)==n:
    print("Yes")
  else:
    print("No")
  exit()

for i in range(2,n):
  if (i+1)%3==0:
    if a[i]!=a[i-2]^a[i-1]:
      print("No")
      exit()
  elif (i+1)%3==1:
    if a[i]!=a[0]:
      print("No")
  elif (i+1)%3==2:
    if a[i]!=a[1]:
      print("No")

print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
if n%3!=0:
  if a.count(0)==n:
    print("Yes")
  else:
    print("No")
  exit()

for i in range(2,n):
  if (i+1)%3==0:
    if a[i]!=a[i-2]^a[i-1]:
      print("No")
      exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
if n%3!=0:
  if a.count(0)==n:
    print("Yes")
  else:
    print("No")
  exit()

for i in range(2,n):
  if i%2==0:
    if a[i]!=a[i-2]^a[i-1]:
      print("No")
      exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
from itertools import groupby

N=int(input())
A=list(map(int,input().split()))
A.sort()
X=groupby(A)
data=[]
for key,group in X:
    g=len(list(group))
    data.append([key,g])
if len(data)==1 and data[0][0]==0:
    print('Yes')
elif N%3!=0:
    print('No')
else:
    if len(data)>3:
        print('No')
    elif len(data)==1:
        if data[0][0]==0:
            print('Yes')
        else:
            print('No')
    elif len(data)==2:
        if data[0][0]==0 and data[0][1]==N//3:
            print('Yes')
        else:
            print('No')
    else:
        if data[0][1]!=N//3 or data[1][1]!=N//3 or data[2][1]!=N//3:
            print('No')
        else:
            print('Yes')

Submission status: Wrong Answer

Solution code:
from itertools import groupby

N=int(input())
A=list(map(int,input().split()))
A.sort()
X=groupby(A)
data=[]
for key,group in X:
    g=len(list(group))
    data.append([key,g])
if N%3!=0:
    print('No')
else:
    if len(data)>3:
        print('No')
    elif len(data)==1:
        if data[0][0]==0:
            print('Yes')
        else:
            print('No')
    elif len(data)==2:
        if data[0][0]==0 and data[0][1]==N//3:
            print('Yes')
        else:
            print('No')
    else:
        if data[0][1]!=N//3 or data[1][1]!=N//3 or data[2][1]!=N//3:
            print('No')
        else:
            print('Yes')

Submission status: Wrong Answer

Solution code:
from itertools import groupby

N=int(input())
A=list(map(int,input().split()))
A.sort()
if N%3!=0:
    print('No')
else:
    X=groupby(A)
    data=[]
    for key,group in X:
        g=len(list(group))
        data.append([key,g])
    if len(data)!=3:
        print('No')
    else:
        if data[0][1]!=N//3 or data[1][1]!=N//3 or data[2][1]!=N//3:
            print('No')
        else:
            print('Yes')

Submission status: Wrong Answer

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

a_set = set(a)

if len(a_set) == 1:
    if sum(a_set) == 0:
        print('Yes')
    else:
        print('No')
elif len(a_set) == 2:
    x, y = sorted(a_set)
    if x == 0:
        if a.count(y) == n//3:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
elif len(a_set) == 3:
    x, y, z = a_set
    if a.count(x) == a.count(y) and a.count(y) == a.count(z):
        if x ^ y == z:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

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

a_set = set(a)

if len(a_set) == 1:
    if sum(a_set) == 0:
        print('Yes')
    else:
        print('No')
elif len(a_set) == 2:
    x, y = sorted(a_set)
    if x == 0:
        if a.count(y) == n//3:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
elif len(a_set) == 3:
    x, y, z = a_set
    if a.count(x) == a.count(y) and a.count(y) == a.count(z):
        if x ^ y == z:
            print('Yes')
        else:
            print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()

arr.sort()
if arr==[1,2,3] or len(list(set(arr)))==1 or (len(list(set(arr)))==2 and sorted(arr)[0]==0):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()

arr.sort()
if arr==[1,2,3] or len(list(set(arr)))==1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

A_set=set(A)
A_lst=list(A_set)

# すべてが0のとき
if sum(A_set)==0 and len(A_set)==1:
    print('Yes')
    exit()

# x…2N/3,0…N/3
if len(A_set)==2 and A_lst.count(0)==1 and A_lst.count(sum(A_set)//2)==2 and len(A)%3==0:
    print('Yes')
    exit()

# x^y^z==0
if len(A_set)==3 and A_lst[0]^A_lst[1]^A_lst[2]==0 and len(A)%3==0:
    print('Yes')
    exit()

# それ以外
print('No')

Submission status: Wrong Answer

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

if N<3:
    print('No')
    exit()

A_set=set(A)
A_lst=list(A_set)

if len(A_set)==1 and sum(A_set)==0:
    print('Yes')
    exit()

if len(A_set)==3 and len(A)%3==0 and A_lst[0]^A_lst[1]^A_lst[2]==0:
    print('Yes')
    exit()

if len(A_set)==2 and len(A)%3==0 and sum(A_lst)^sum(A_lst)^0==0 and 0 in A_lst:
    print('Yes')
    exit()


print('No')

Submission status: Wrong Answer

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

if N<3:
    print('No')
    exit()

A_set=set(A)
A_lst=list(A_set)

if len(A_set)==0 and sum(A_set):
    print('Yes')
    exit()

if len(A_set)==3 and len(A)%3==0 and A_lst[0]^A_lst[1]^A_lst[2]==0:
    print('Yes')
    exit()

if len(A_set)==2 and len(A)%3==0 and sum(A_lst)^sum(A_lst)^0==0 and 0 in A_lst:
    print('Yes')
    exit()

print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
a.append(a[0])
a.append(a[1])
ans = "Yes"

for i in range(1,n+1):
    if a[i] != a[i-1]^a[i+1]:
        ans = "No"
        break

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    from collections import Counter

    n = int(input())
    *a, = map(int, input().split())

    if n % 3 == 0:
        ctr = Counter(a)
        if (len(ctr) == 1) and (0 in ctr):
            print('Yes')
            return
        elif len(ctr) == 3:
            x = 0
            p = None
            for k, v in ctr.items():
                if p is None:
                    p = v
                elif p != v:
                    print('No')
                    return
                x ^= k

            print('Yes' if x == 0 else 'No')
            return
        else:
            print('No')
            return
    else:
        print('Yes' if all(map(lambda x: x == 0, a)) else 'No')
        return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    from collections import Counter

    n = int(input())
    *a, = map(int, input().split())

    if n % 3 == 0:
        ctr = Counter(a)
        if (len(ctr) == 1) and (0 in ctr):
            print('Yes')
            return
        elif len(ctr) == 3:
            it = iter(ctr.keys())
            x = next(it)
            y = next(it)
            z = next(it)
            print('Yes' if x ^ y == z else 'No')
            return
        else:
            print('No')
            return
    else:
        print('Yes' if all(map(lambda x: x == 0, a)) else 'No')
        return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


from collections import defaultdict
dic = {}

for a in al:
    if a not in dic:
        dic[a] = 0
    dic[a] += 1
if 0 in dic:
    if dic[0] == n:
        print("Yes")
        exit()
if 0 in dic:
    if n % 3 == 0:
        if dic[0] == 2 * n // 3:
            print("Yes")
            exit()
if n % 3 != 0:
    print("No")
    exit()
else:
    if len(dic) == 3:
        if max(dic.values()) == n // 3:
            a = 0
            for i in dic:
                a ^= i
            if a == 0:
                print("Yes")
                exit()
print("No")