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 .

Solution (Python):
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

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

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  n = int(input())
  a = input_list()
  ans = 0
  for i in a:
    ans ^= i
  if ans == 0:
    print('Yes')
  else:
    print('No')
    
import math
import fractions
import collections
import itertools
from functools import reduce
main()

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

a_set = set(a)

if len(a_set) > 3:
    print("No")
elif len(a_set) == 3:
    x, y, z = a_set
    if a.count(x) == a.count(y) == a.count(z):
        if x ^ y ^ z == 0:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
elif len(a_set) == 2:
    x, y = sorted(a_set)
    if x == 0:
        if a.count(x) * 3 == N:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    if sum(a_set) == 0:
        print("Yes")
    else:
        print("No")

Solution (Python):
x=int(input())
t=0
a=list(map(int, input().split()))
for i in range(x):
	t=t^a[i]
if t==0:
	print('Yes')
else:
	print('No')

Solution (Python):
def main():
    hats = int(input())
    number = list(map(int, input().split()))
    count = {}
    for n in number:
        if n in count:
            count[n] += 1
        else:
            count[n] = 1
    answer = False
    key = list(count.keys())
    val = list(count.values())
    if len(key) == 1 and key == [0]:
        answer = True
    elif len(key) == 2 and hats % 3 == 0:
        if (key[1] == 0 and val[0] == 2 * hats // 3 and val[1] == hats // 3) or \
                (key[0] == 0 and val[1] == 2 * hats // 3 and val[0] == hats // 3):
            answer = True
    elif len(key) == 3 and hats % 3 == 0:
        if key[0] ^ key[1] ^ key[2] == 0 and val[1] == val[2] == val[0] == hats // 3:
            answer = True
    print("Yes" if answer else "No")


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = sorted([int(i) for i in input().split()], reverse=True)
allzero = True
element = {}
for i in a:
    if i != 0:
        allzero = False
    if i not in element.keys():
        element[i] = 0
    element[i] += 1
if allzero:
    print('Yes')
else:
    if n % 3 != 0:
        print('No')
    elif len(element) == 2:
        if 0 in element.keys() and element[0] == n//3:
            print('Yes')
        else:
            print('No')
    elif len(element) == 3:
        judge = 0
        for k, v in element.items():
            judge ^= k
            if v != n//3:
                print('No')
                break
        else:
            if judge == 0:
                print('Yes')
            else:
                print('No')
    else:
        print('No')

Solution (Python):
n = int(input())
L = list(map(int,input().split()))
ans = L[0]
for i in range(1,n):
    ans ^= L[i]
if ans == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N):
  ans ^= A[i]
if ans == 0:
  print("Yes")
else:
  print("No")

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    ans = 0
    for a in A:
        ans ^= a

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


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
L=list(map(int,input().split()))
LL=list(set(L))
ans="No"
if LL==[0]:
    ans="Yes"
elif len(LL)==2:
    if L.count(LL[0])==2*L.count(LL[1]) or L.count(LL[1])==2*L.count(LL[0]):
        ans="Yes"
elif len(LL)==3:
    if L.count(LL[0])==L.count(LL[1]) and L.count(LL[1])==L.count(LL[2]):
        if LL[0]^LL[1]^LL[2]==0:
            ans="Yes"
print(ans)

Solution (Python):
from sys import stdin


def main():
    N = int(input())
    a_list = [int(x) for x in stdin.readline().rstrip().split()]
    a_set = set(a_list)

    if len(a_set) == 1:
        if sum(a_set) == 0:
            print("Yes")
        else:
            print("No")

    elif len(a_set) == 2:
        a_1, _2 = sorted(a_set)
        if a_1 == 0:
            if a_list.count(a_1) * 3 == N:
                print("Yes")
            else:
                print("No")
        else:
            print("No")

    elif len(a_set) == 3:
        a_1, a_2, a_3 = a_set
        if a_list.count(a_1) == a_list.count(a_2) and a_list.count(a_2) == a_list.count(a_3):
            if a_1 ^ a_2 == a_3:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    else:
        print("No")


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
def xored(a, b):
  y = 0
  base = 1
  while a != 0 or b != 0:
    y += ((a + b) % 2) * base
    base *= 2
    a //= 2
    b //= 2
  return y

if max(A) == 0:
  print("Yes")
else:
  if N % 3 != 0:
    print("No")
  else:
    D = {}
    for i in A:
      if i in D:
        D[i] += 1
      else:
        D[i] = 1
    if len(D) > 3:
      print("No")
    else:
      if len(D) == 3 and min(D[i] for i in D) == max(D[i] for i in D):
        L = [i for i in D]
        if xored(L[0], L[1]) == L[2]:
          print("Yes")
        else:
          print("No")
      elif len(D) == 2:
        if 0 not in D:
          print("No")
        else:
          if D[0] >= N // 3:
            print("Yes")
          else:
            print("No")
      else:
        print("No")

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
x=set(a)
if len(x)==1:
    if 0 in x:
        ans=1
    else:
        ans=0
elif len(x)==2:
    if 0 in x:
        count0=0
        count1=0
        for i in range(len(a)):
            if a[i]==0:
                count0+=1
            else:
                count1+=1
        if count0*2==count1:
            ans=1
        else:
            ans=0
    else:
        ans=0
elif len(x)==3:
    y=list(x)
    t=y[0]^y[1]^y[2]
    if t==0:
        count0=0
        count1=0
        count2=0
        for i in range(len(a)):
            if a[i]==y[0]:
                count0+=1
            elif a[i]==y[1]:
                count1+=1
            else:
                count2+=1
        if count0==count1:
            if count1==count2:
                ans=1
            else:
                ans=0
        else:
            ans=0
    else:
        ans=0
else:
    ans=0
if ans:
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
s=[int(i) for i in input().split()]
a=1
for l in s:
    a^=l
if a==1:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
X = set(A)
if len(X) == 1:
    if 0 in X:
        ans = 1
    else:
        ans = 0
elif len(X) == 2:
    if 0 in X:
        Y = list(X)
        if A.count(Y[0]) * 2 == A.count(Y[1]):
            ans = 1
        else:
            ans = 0
    else:
        ans = 0
elif len(X) == 3:
    Y = list(X)
    if A.count(Y[0]) == A.count(Y[1]) == A.count(Y[2]):
        ans = 1
        for i in range(40):
            Z = list(map(lambda x: x % 2,Y))
            Y = list(map(lambda x: x // 2,Y))
            Z.sort()
            
            if Z != [0,1,1] and Z != [0,0,0]:
                ans = 0
                break
    else:
        ans = 0
elif len(X) >= 4:
    ans = 0
if ans == 0:
    print('No')
else:
    print('Yes')

Solution (Python):
def examA():
    N = I()
    A = LI()
    cur = 0
    for a in A:
        cur ^= a
    if cur==0:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)
    return

def examB():
    N, M = LI()
    V = [[]for _ in range(N)]
    for _ in range(M):
        a, b = LI()
        a -= 1; b -= 1
        V[a].append(b)
        V[b].append(a)
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examA()

"""

"""

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
x='No'
p=len(set(a))
if p==1:
  if a[0]==0:
    x='Yes'
elif p==2:
  if n%3==0:
    if a.count(0)==n//3:
      x='Yes'
elif p==3:
  if n%3==0:
    b=set(a)
    t=0
    f=1
    for i in b:
      t=t^i
      if a.count(i)!=n//3:
        f=0
    if t==0 and f:
      x='Yes'
print(x)

Solution (Python):
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    A.sort()
    from collections import Counter
    c = Counter(A)
    if 0 in c.keys() and c[0] == N:
        return print("Yes")
    elif N % 3 == 0 and 0 in c.keys() and c[0] == N//3 and\
            len(c.keys()) == 2:
        return print("Yes")
    elif N % 3 == 0 and len(c.keys()) == 3 and \
            all(N//3 == v for v in c.values()):
        ans = 0
        for k in c.keys():
            ans ^= k
        if ans != 0:
            return print("No")
        else:
            return print("Yes")
    else:
        return print("No")


if __name__ == '__main__':
    main()

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

    d = {}
    for aa in a:
        d[aa] = d.get(aa, 0) + 1

    if d.get(0, 0) == n:
        print("Yes")
        return 0
    L = sorted(list(d.items()))
    if n % 3 == 0 and len(L) == 2 and (L[0][0] == 0 and L[0][1] == n//3) and L[1][1] == n//3*2:
        print("Yes")
        return 0
    
    if n % 3 == 0 and len(L) == 3 and L[0][1] == n//3 and L[1][1] == n//3 and L[2][1] == n//3 and L[0][0]^L[1][0]^L[2][0] == 0:
        print("Yes")
        return 0

    print("No")

main()

Solution (Python):
from collections import Counter
n = int(input())
*a, = map(int, input().split())

if sum(a) == 0:
    print("Yes")
elif n % 3 != 0:
    print("No")
else:
    can_put_on = False
    c = Counter(a)
    if c[0] == n//3 and len(c) == 2:
        can_put_on = True
    if len(c) == 3:
        s = 0
        for k in c.keys():
            s ^= k
        if s == 0 and all(v == n//3 for v in c.values()):
            can_put_on = True

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

Solution (Python):


N=int(input())
A=list(map(int,input().split()))
B=list(set(A))

if len(B)==3:
    if B[0]^B[1]==B[2]:
        if A.count(B[0])==A.count(B[1]) and A.count(B[1])==A.count(B[2]):
            print("Yes")
            exit()
elif len(B)==2:
    if 2*A.count(B[0])==A.count(B[1]):
        print("Yes")
        exit()
elif len(B)==1:
    if B[0]==0:
        print("Yes")
        exit()

print("No")

Solution (Python):
from sys import stdin
from collections import Counter
def main():
    
    readline=stdin.readline
    N=int(readline())
    a=list(map(int,readline().split()))

    c=Counter(a)
    c=sorted(c.items())
    if N%3!=0:  
        if len(c)==1 and c[0][0]==0:
            print("Yes")
        else:
            print("No")

    elif N%3==0:  
        if len(c)==1 and c[0][0]==0:
            print("Yes")
        elif len(c)==2 and c[0][0]==0 and c[0][1]==N//3:
            print("Yes")
        elif len(c)==3 and c[0][1]==N//3 and c[1][1]==N//3 and c[2][1]==N//3 and c[0][0]^c[1][0]^c[2][0]==0:
            print("Yes")
        else:
            print("No")

if __name__=="__main__":
    main()

Solution (Python):
from collections import Counter

N = int(input())
a = [int(i) for i in input().split()]
c = Counter(a)
b = len(c.keys())

def check():
    if 0 in c.keys():
        if b==1 or (b==2 and c[0]==N//3):
            return True
    elif b==3:
        s, t, u = c.keys()
        if c[s]//3==c[t]//3==c[u]//3 and s^t^u==0:
            return True
    return False

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

Solution (Python):
from collections import Counter

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

def check():
    if 0 in c.keys():
        if b==1 or (b==2 and c[0]==N//3):
            return True
    elif b==3:
        s, t, u = c.keys()
        if s^t^u==0 and c[s]==c[t]==c[u]:
            return True
    return False

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

Solution (Python):
from collections import Counter

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

def check():
    if 0 in used:
        if size==1 or (size==2 and c[0]==N//3):
            return True
    elif size==3:
        s, t, u = used
        if s^t^u==0 and c[s]==c[t]==c[u]:
            return True
    return False

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

Solution (Python):
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//3:
    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")

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
s = 0
for i in range(n):
  s ^= a[i]

if s == 0:
  ans = 'Yes'
else:
  ans = 'No'

print(ans)

Solution (Python):
import collections
def main():
    n = int(input())
    a = list(map(int,input().split()))
    cnt = collections.Counter(a)
    num = len(set(a))
    aset=set(a)

    if sum(a) == 0:
        print('Yes')
        return
    
        
        
    if len(cnt.most_common()) == 3:
        a1, a2, a3 = aset
        if cnt.most_common()[0][1] == cnt.most_common()[1][1] == cnt.most_common()[2][1]  and a1 ^ a2 == a3:
            
            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()

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
s = 0
for i in range(n):
  s ^= a[i]

if s == 0:
  ans = 'Yes'
else:
  ans = 'No'

print(ans)

Solution (Python):
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])
elif len(C)==2:
    (k1,v1),(k2,v2)=C.most_common(2)
    print("YNeos"[not(v2*2==v1 and k1^k1^k2==0)::2])
else:
    print("YNeos"[not(len(C)==3 and reduce(xor, C.keys())==0 and len(set(C.values()))==1)::2])

Solution (Python):
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')
  elif len(c) == 1 and c.get(0) == n:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Solution (Python):

















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)
if len(dis)==2:
  if a.count(0)==n//3 and n%3==0:
    print("Yes")
    exit(0)
print("No")

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
ret=a[0]
for x in range(1,n):
    ret=a[x]^ret
if ret==0:
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
a=[int(x) for x in map(int,input().split()[:n])]
ret=a[0]
for x in range(1,n):
    ret= a[x] ^ ret
if ret==0:
    print("Yes")
else:
    print("No")

Solution (Python):
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:
            if data[0][0]^data[1][0]^data[2][0]!=0:
                print('No')
            else:
                print('Yes')

Solution (Python):
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(x) * 3 == n:
            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')

Solution (Python):
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(x) * 3 == n:
            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')

Solution (Python):
def solve(n, a):
    p = 0
    for x in a:
        p ^= x
    return "Yes" if p == 0 else "No"

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

Solution (Python):
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
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]





n=ii()
arr=limii()
chk=arr[0]
for i in range(1,n):
    chk = chk^arr[i]    

arr.sort()
a0=arr.count(arr[0])
a1=arr.count(arr[-1])

if (len(list(set(arr)))==1 and list(set(arr))[0]==0) or chk==0 or (arr[0]==0 and a0==n//3 and a1==2*n//3):
    print("Yes")
else:
    print("No")

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

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


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


if len(A_set)==2 and A_lst.count(0)==1 and len(A)%3==0:
    cnt=0
    for i in range(N):
        if A[i]==0:
            cnt+=1
    if cnt==N//3:
        print('Yes')
    else:
        print('No')
    exit()


if len(A_set)==3 and A_lst[0]^A_lst[1]^A_lst[2]==0 and len(A)%3==0:
    cnt_x,cnt_y,cnt_z=0,0,0
    x,y,z=A_lst[0],A_lst[1],A_lst[2]
    for i in range(N):
        if A[i]==x:
            cnt_x+=1
            continue
        if A[i]==y:
            cnt_y+=1
            continue
        if A[i]==z:
            cnt_z+=1
    if cnt_x==cnt_y==cnt_z:
        print('Yes')
    else:
        print('No')
    exit()


print('No')

Solution (Python):
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
c = Counter(a)
flag = False

if c[0] == n:
    flag = True
elif c[0] == n/3 and len(c) == 2:
    flag = True
else:
    s = 0
    for num in c:
        s ^= num
        if c[num] != n/3: break
    else:
        if s == 0: flag = True

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

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
a.append(a[0])
s = 0
for i in a: s ^= i
ans = "Yes" if s == a[0] else "No"
print(ans)

Solution (Python):
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:
            print('Yes' if 0 in ctr else 'No')
            return

        elif len(ctr) == 2:
            print('Yes' if ctr[0] == n // 3 else 'No')
            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()

Solution (Python):

import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def calc(N):
    return sum(int(x) for x in str(N))


def main():
    
    N = Scanner.int()
    A = Scanner.map_int()
    X = A[1]
    for i in range(2, N):
        X = X ^ A[i]
    print("YNeos "[X != A[0]::2])
    return


if __name__ == "__main__":
    main()

Solution (Python):
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] == 1 * 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")

Solution (Python):
from sys import stdin
from itertools import groupby
n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
li.sort()
lin = []
for key, value in groupby(li):
    lin.append((key,len(list(value))))
if len(lin) == 1 and lin[0][1] == n and lin[0][0] == 0:
    print("Yes")
elif n%3 != 0:
    print("No")
elif len(lin) == 2:
    lin.sort()
    if lin[0][1] == n//3:
        print("Yes")
    else:
        print("No")
elif len(lin) == 3:
    if lin[0][1] == lin[1][1] == lin[2][1] and lin[0][0]^lin[1][0]^lin[2][0] == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

res=0
a_set=set(a)

res=0
for i in range(n):
    res = res ^ a[i]

if n % 3 ==0:
    if res==0:
        print("Yes")
        exit()
else:
    if len(a_set) ==1:
        print("Yes")
        exit()
print("No")

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

b = list(set(a))

if a.count(0) == n:
    print("Yes")
elif len(b) == 2 and a.count(0) == n / 3:
    print("Yes")
elif len(b) == 3 and b[0] ^ b[1] ^ b[2] == 0 and a.count(b[0]) == n / 3 and a.count(b[0]) == n / 3:
    print("Yes")
else:
    print("No")

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

setA = set(A)

if A.count(0) == N:
    print('Yes')
elif len(setA) == 2 and A.count(0) == N / 3:
    print('Yes')
elif len(setA) == 3:
    setA = list(setA)
    x = setA[0]
    y = setA[1]
    z = setA[2]
    if x ^ y ^ z == 0 and A.count(x) == N / 3 and A.count(y) == N / 3:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Solution (Python):
n = int(input())
lst = list(map(int,input().split()))
l_unique = sorted(list(set(lst)))

flg = False
if len(l_unique)==1:
    x = l_unique[0]
    if x==0:
        flg = True
elif len(l_unique) == 2:
    x,y = l_unique[0], l_unique[1]
    if x==0 and n%3==0:
        num = n//3
        if lst.count(x)==num and lst.count(y)==2*num:
            flg = True
elif len(l_unique) == 3:
    x,y,z = l_unique[0], l_unique[1], l_unique[2]
    if n%3 == 0:
        num = n//3
        if lst.count(x)==num and lst.count(y)==num and lst.count(z)==num:
            if (x^y^z)==0:
                flg = True
print('Yes' if flg else 'No')

Solution (Python):
from collections import Counter
N = int(input())
A = list(map(int, input().split()))


def xor_circle(N, A):
    if sum(A) == 0:
        return "Yes"
    if N % 3 != 0:
        return "No"

    B = Counter(A)
    if len(B) == 3:
        a, b, c = B.keys()
        Na, Nb, Nc = B.values()
        if a ^ b ^ c == 0 and Na == Nb == Nc:
            return "Yes"
        else:
            return "No"
    elif len(B) == 2:
        a, b = B.keys()
        Na, Nb = B.values()
        if a == 0 and 2*Na == Nb:
            return "Yes"
        elif b == 0 and Na == 2*Nb:
            return "Yes"
        else:
            return "No"
    else:
        return "No"


ans = xor_circle(N, A)
print(ans)

Solution (Python):

from collections import Counter as ct
n=int(input())
a=list(map(int,input().split()))

c=ct(a)
 
if c[0]==n:
    print("Yes")
elif len(c)==2 and c[0]*3==n:
    print("Yes")
elif len(c)==3 and len(set(c.values()))==1:
    a,b,c = c.keys()
    if (a^b^c)==0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
N = int(input())
alist = list(map(int, input().split()))

ans = alist[0] ^ alist[1]
for a in alist[2:]:
    ans ^= a
if ans == 0:
    print("Yes")
else:
    print("No")

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








b = list(set(a))
kind = len(b)
if kind == 1 and a[0] == 0:
    print('Yes')
    exit()
elif kind == 2 and a.count(0) == n//3 and n % 3 == 0:
    print('Yes')
    exit()
elif kind == 3:
    if a.count(b[0]) == a.count(b[1]) == a.count(b[2]) == n/3 and b[0] ^ b[1] ^ b[2] == 0:
        print('Yes')
        exit()
print('No')

Solution (Python):
n=int(input())
s=list(map(int,input().split()))
ans=s[0]
for i in range(1,n):
  ans^=s[i]
if ans!=0:
  print('No')
else:
  print('Yes')