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):
N, *A = map(int, open(0).read().split())
A_set = set(A)

if len(A_set) == 1:
    print("Yes") if sum(A) == 0 else print("No")
elif len(A_set) == 2:
    a1, a2 = sorted(A_set)
    print("Yes") if a1 == 0 and A.count(a1) * 3 == N else print("No")
elif len(A_set) == 3:
    a1, a2, a3 = list(A_set)
    if a1 ^ a2 ^ a3 == 0 and A.count(a1) == A.count(a2) == A.count(a3):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
C = {}
for i in range(N):
    if A[i] not in C:
        C[A[i]] = 0
    C[A[i]] += 1
if len(C)>3:
    print("No")
else:
    if N%3==0:
        if 0 in C:
            if len(C)==1:
                print("Yes")
            elif len(C)==2:
                if C[0]==N//3:
                    print("Yes")
                else:
                    print("No")
            else:
                print("No")
        else:
            if len(C)!=3:
                print("No")
            else:
                flag = 0
                for a in C:
                    if C[a]!=N//3:
                        flag = 1
                        break
                if flag==0:
                    C = list(C.keys())
                    if C[0]^C[1]==C[2]:
                        print("Yes")
                    else:
                        print("No")
                else:
                    print("No")
    else:
        if len(C)==1 and 0 in C:
            print("Yes")
        else:
            print("No")

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate, product 

from collections import deque,defaultdict,Counter
import decimal
import re












import sys
sys.setrecursionlimit(10000000)


mod = 998244353
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
li = list(map(int,input().split()))
se = set(li)
if len(se) == 1:
    if sum(se) == 0:
        print('Yes')
    else:
        print('No')
elif len(se) == 2:
    a,b = sorted(se)
    if a == 0:
        if li.count(a) * 3 == n:
            print('Yes') 
        else:
            print('No')
    else:
        print('No')
elif len(se) == 3:
    a,b,c = se
    if li.count(a) == li.count(b) == li.count(c):
        if a^b == c:
            print('Yes')
        else:
            print('No') 
    else:
        print('No')
else:
    print('No')

Solution (Python):
n = int(input())
a = sorted(list(map(int, input().split())))
c0 = a.count(0)

ans = "No"
if c0==n: ans = "Yes"
elif len(set(a)) == 2:
    c = a.count(a[-1])
    if c == (2*n)//3 and c0 == n//3: ans = "Yes"
elif len(set(a)) == 3:
    x,y,z = list(set(a))
    if a.count(x) == a.count(y) == a.count(z):
        if int(bin(x ^ y ^ z),2) == 0: ans = "Yes"
print(ans)

Solution (Python):
from collections import Counter

def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    
    c = Counter(A).most_common()
    
    if c[0][0] == 0 and c[0][1] == N:
        print("Yes")
    elif len(c) == 2 and c[0][1] == 2*N//3 and c[1][0] == 0 and c[1][1] == N//3:
        print("Yes")
    elif len(c) == 3 and int(c[0][0])^int(c[1][0]) == int(c[2][0]) and c[0][1] == c[1][1] and c[1][1] == c[2][1]:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Solution (Python):
import sys, math
from functools import lru_cache
from collections import defaultdict
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    a = list(mi())
    s = 0
    for i in range(N):
        s ^= a[i]

    if s != 0:
        print('No')
        return

    if N%3 == 0:
        d = {}
        for i in range(N):
            if not a[i] in d:
                d[a[i]] = 0
            d[a[i]] += 1

        if (len(d) == 1 and 0 in d) or (2 <= len(d) <= 3 and all(v%(N//3) == 0 for v in d.values())):
            print('Yes')
        else:
            print('No')

    else:
        if all(a[i] == 0 for i in range(N)):
            print('Yes')
        else:
            print('No')



if __name__ == '__main__':
    main()

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

if n == 3:
    if a[0] == a[1]^a[2]:
        print("Yes")
    else:
        print("No")
elif sum(a) == 0:
    print("Yes")
else:
    vals = []
    cnts = []

    for i in range(n):
        if a[i] in vals:
            cnts[vals.index(a[i])] += 1
        else:
            if len(vals) == 3:
                print("No")
                exit()

            vals.append(a[i])
            cnts.append(1)

    if len(vals) == 3 and (vals[0] == vals[1]^vals[2]) and (cnts[0] == cnts[1] and cnts[1] == cnts[2]):
        print("Yes")
    elif len(vals) == 2 and (vals[0] == 0 or vals[1] == 0):
        if vals[0] == 0 and  2*cnts[0] == cnts[1]:
            print("Yes")
        elif vals[1] == 0 and cnts[0] == 2*cnts[1]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

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

T={}
for a in A:
    if a in T:
        T[a]+=1
    else:
        T[a]=1

F=True
for x in T:
    F&=(3*T[x]%N==0)

if not F:
    print("No")
    exit()

M=max(T,key=lambda x:T[x])
if 3*T[M]==N:
    x,y,z=list(T.keys())
elif 3*T[M]==2*N:
    x=y=M
    del T[M]
    z=tuple(T.keys())[0]
else:
    x=y=z=M

if x^y==z:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
if N % 3 != 0:
    if any(a):
        print('No')
    else:
        print('Yes')
else:
    a.sort()
    a1 = set(a[:N//3])
    a2 = set(a[N//3:2*N//3])
    a3 = set(a[2*N//3:])
    if len(a1) == 1 and len(a2) == 1 and len(a3) == 1:
        if a1.pop()^a2.pop()^a3.pop() == 0:
            print('Yes')
        else:
            print('No')
    else:
        print('No')

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

a.sort()

if n % 3 != 0:
    if all((a[i] == 0 for i in range(n))):
        print('Yes')
    else:
        print('No')
else:
    a1 = a[:n//3]
    a2 = a[n//3:n*2//3]
    a3 = a[n*2//3:]
    if all((a1[i] == 0 for i in range(n//3))) and all((a2[i] == a2[0] for i in range(n//3))) and all((a3[i] == a3[0] for i in range(n//3))):
        print('Yes')
    elif all((a1[i] == a1[0] for i in range(n//3))) and all((a2[i] == a2[0] for i in range(n//3))) and all((a3[i] == a3[0] for i in range(n//3))) and a1[0] ^ a2[0] ^ a3[0] == 0:
        print('Yes')
    else:
        print('No')

Solution (Python):

from collections import Counter





def solve(n,a):
  d = Counter(a)

  if d[0] == n:
    return True
  if n % 3 != 0:
    return False
  if len(d) == 2 and d[0] == n // 3:
    return True
  if len(d) == 3:
    if not all(v == n//3 for v in d.values()):
      return False
    x,y,z = d.keys()
    if x ^ y ^ z == 0:
      return True
  return False





def main():
  N = int(input())
  
  a = list(map(int,input().split()))
  print("Yes" if solve(N,a) else "No")
  return

if __name__ == '__main__':
  main()

Solution (Python):
import collections
n=int(input())
a=list(map(int,input().split()))
b=0
for i in a:
  b^=i
c=collections.Counter(a)
if len(c)>3:
  print('No')
elif len(c)==1:
  if a[0]==0:
    print('Yes')
  else:
    print('No')
elif b==0:
  print('Yes')
else:
  print('No')

Solution (Python):
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
if a.count(0) == n:
    print("Yes")
    exit()

if n%3 != 0:
    print("No")
    exit()

c = Counter(a)
if len(c) == 2:
    if 0 not in c.keys():
        print("No")
        exit()
    if c[0] != n//3:
        print("No")
    else:
        print("Yes")
elif len(c) == 3:
    x = 0
    for i,j in c.items():
        if j != n//3:
            print("No")
            exit()
        x ^= i
    if x:
        print("No")
    else:
        print("Yes")

else:
    print("No")

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
l = list(set(a))
n = len(l)
if n == 3:
    if l[0] ^ l[1] ^ l[2] == 0:
        x = a.count(l[0])
        y = a.count(l[1])
        z = a.count(l[2])
        if x == y == z:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
elif n == 2:
    z = -1
    if l[0] == 0:
        x = 1
        z = 0
    if l[1] == 0:
        x = 0
        z = 1
    if z != -1:
        x = a.count(l[x])
        z = a.count(l[z])
        if x == z + z:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
elif n == 1:
    if l[0] == 0:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Solution (Python):
from collections import Counter

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

cnt = Counter(A)

try:
    if cnt[0] == N:
        print("Yes")
    else:
        if N % 3 != 0:
            print("No")
        else:
            if cnt.most_common(1)[0][1] == N*2//3 and cnt[0] == N//3:
                print("Yes")
            else:
                x = cnt.most_common(3)
                if x[0][1] == x[1][1] == x[2][1] == N//3:
                    if x[0][0]^x[1][0]^x[2][0] == 0:
                        print("Yes")
                    else:
                        print("No")
                else:
                    print("No")
except:
    print("No")

Solution (Python):
from collections import Counter
def check():
  N = int(input())
  A = list(map(int, input().split()))
  if N%3 in [1,2]:
    if A!=[0]*N:
      return 'No'
    return 'Yes'
  c = Counter(A)
  if len(c)==1:
    if c[0]==0:
      return 'No'
    return 'Yes'
  if len(c)==2:
    if c[0]!=N//3:
      return 'No'
    return 'Yes'
  if len(c)==3:
    lis = []
    for k,v in c.items():
      if v!=N//3:
        return 'No'
      lis.append(k)
    if lis[0]^lis[1]==lis[2]:
      return 'Yes'
  return 'No'
print(check())

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

if a.count(0) == n:
    print('Yes')
elif n%3 != 0:
    print('No')
elif a.count(max(a)) == 2*n//3 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]) == a.count(b[1]) == a.count(b[2]):
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
a_counter = Counter(a)
k = list(a_counter.keys())
v = list(a_counter.values())

if len(a_counter) == 3 and k[0]^k[1]^k[2] == 0 and v[0] == v[1] == v[2]:
    print("Yes")
elif len(a_counter) == 2 and 0 in k and (v[0] == v[1]*2 or v[1] == v[0]*2):
    print("Yes")
elif len(a_counter) == 1 and 0 in k:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
a_counter = Counter(a)
a_counter_li = list(a_counter)
if sum(a) == 0:
    print("Yes")
elif len(a)%3 != 0:
    print("No")
elif len(a_counter) > 3 or len(a_counter) <= 1:
    print("No")
elif len(a_counter) == 3:
    if a_counter[a_counter_li[0]] == n // 3 and a_counter[a_counter_li[1]] == n // 3 and a_counter[a_counter_li[2]] == n // 3:
        if a_counter_li[0]^a_counter_li[1]^a_counter_li[2] == 0:
            print("Yes")
        else:
            print('No')
    else:
        print("No")
else:
    a_counter_li.sort()
    if a_counter_li[0] == 0 and a_counter[a_counter_li[0]] == n // 3:
        print("Yes")
    else:
        print("No")

Solution (Python):
import collections

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

B = collections.Counter(a)
k = list(B.keys())
v = list(B.values())

if len(B) == 3 and k[0]^k[1]^k[2] == 0 and v[0] == v[1] == v[2]:
    print("Yes")
elif len(B) == 2 and 0 in k and (v[0] == 2*v[1] or v[1] == 2*v[0]):
    print("Yes")
elif len(B) == 1 and 0 in k:
    print("Yes")
else: print("No")

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
max_a = max(a)
if max_a == 0:
    print('Yes')
    exit()

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

if a.count(max_a) == 2 * N // 3 and a.count(0) == N // 3:
    print('Yes')
    exit()

set_a = list(set(a))
if len(set_a) == 3 and set_a[0] ^ set_a[1] ^ set_a[2] == 0:
    if a.count(set_a[0]) == a.count(set_a[1]) == a.count(set_a[2]):
        print('Yes')
        exit()

print('No')

Solution (Python):
import collections
N = int(input())
a = list(map(int,input().split()))
B = collections.Counter(a)
k = list(B.keys())
v = list(B.values())

if len(B) == 3 and k[0]^k[1]^k[2] == 0 and v[0] == v[1] == v[2]:
    print("Yes")
elif len(B) == 2 and 0 in k and (v[0] == 2*v[1] or v[1] == 2*v[0]):
    print("Yes")
elif len(B) == 1 and 0 in k:
    print("Yes")
else: print("No")

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
if len(set(a)) == 1 and a[0] == 0:
    print("Yes")
    exit()
if N%3 != 0:
    print("No")
    exit()

import collections
sa = list(set(a))
sa.sort()
B = collections.Counter(a)

if len(sa) == 2 and 0 in sa:
    if B[0] == N//3 and B[sa[1]] == N*2//3:
        print("Yes")
    else: print("No")
    exit()
if len(sa) != 3:
    print("No")
    exit()

if B[sa[0]] == B[sa[1]] == B[sa[2]]:
    print("Yes" if sa[0] ^ sa[1] == sa[2] else "No")
else:
    print("No")

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]

d = dict()
for i in range(N):
    d[A[i]] = d.get(A[i], 0) + 1

if len(d) > 3:
    print('No')

else:
    k = list(d.keys())
    v = list(d.values())
    
    
    if len(d) == 3 and k[0]^k[1]^k[2] == 0 and v[0]==v[1]==v[2]:
        print('Yes')
    
    
    elif len(d) == 2 and ((k[0] == 0 and v[1] == 2*v[0]) or (k[1] == 0 and v[0] == 2*v[1])):
        print('Yes')
    
    
    elif len(d) == 1 and k[0] == 0:
        print('Yes')
    
    else:
        print('No')

Solution (Python):
from collections import Counter

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

d = Counter(A)

if len(d) > 3:
    print('No')

else:
    k = list(d.keys())
    v = list(d.values())
    
    
    if len(d) == 3 and k[0]^k[1]^k[2] == 0 and v[0]==v[1]==v[2]:
        print('Yes')
    
    
    elif len(d) == 2 and ((k[0] == 0 and v[1] == 2*v[0]) or (k[1] == 0 and v[0] == 2*v[1])):
        print('Yes')
    
    
    elif len(d) == 1 and k[0] == 0:
        print('Yes')
    
    else:
        print('No')

Solution (Python):
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()
c = Counter(a).most_common()

if len(c) == 3 and c[0][1] == c[1][1] == c[2][1]:
    x = c[0][0]
    y = c[1][0]
    z = c[2][0]
    if x^y^z == 0:
        ans = "Yes"
    else:
        ans = "No"
elif len(c) == 2 and c[0][1] == 2*c[1][1]:
    x = c[0][0]
    y = c[1][0]
    if x^x^y == 0:
        ans = "Yes"
    else:
        ans = "No"
elif len(c) == 1 and c[0][0] == 0:
    ans = "Yes"
else:
    ans = "No"

print(ans)

Solution (Python):
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()
c = Counter(a).most_common()

if len(c) == 3 and c[0][1] == c[1][1] == c[2][1]:
    x = c[0][0]
    y = c[1][0]
    z = c[2][0]
    if x^y == z and y^z == x and z^x == y:
        ans = "Yes"
    else:
        ans = "No"
elif len(c) == 2 and c[0][1] == 2*c[1][1]:
    x = c[0][0]
    y = c[1][0]
    if x^x == y and x^y == x:
        ans = "Yes"
    else:
        ans = "No"
elif len(c) == 1 and c[0][0] == 0:
    ans = "Yes"
else:
    ans = "No"

print(ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
num=a[0]
for i in range(1,n):
    num=num^a[i]
if max(a)==(2**(n-3))+(2**(n-4)):
    print("No")
elif max(a)==min(a) and a[0]!=0:
    print("No")
elif num<=1:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())

if sum(As)==0:
    print('Yes')
elif N%3!=0:
    print('No')
else:
    from collections import Counter
    d = N//3
    c = Counter(As)
    if len(set(As))>3:
        print('No')
    elif len(set(As))==3:
        items = list(set(As))
        a = 0
        for item in items:
            a ^= item
            if not c[item]==d:
                print('No')
                break
        else:
            if a!=0:
                print('No')
            else:
                print('Yes')
    else:
        if c[0]==d:
            print('Yes')
        else:
            print('No')

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

c=Counter(a)
bl=True
if n%3==0:
    if len(c.keys())==3:
        l=[]
        for i,j in c.items():
            if j!=n//3:
                bl=False
            l.append(i)
        if 0 in l:
            bl=False
        if l[0]^l[1]!=l[2]:
            bl=False
    elif len(c.keys())==2:
        if c[0]!=n//3:
            bl=False
    else:
        bl=False
else:
    bl=False
if c[0]==n:
    bl=True

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

Solution (Python):

from collections import Counter

n = int(input())
(*a, ) = map(int, input().split())
c = Counter(a)
b = 0
for i in c.keys():
    b ^= i
if sum(a) == 0 or (b == 0 and all(i * 3 == n for i in c.values())):
    print("Yes")
elif len(c) == 2 and c.most_common()[0][1] * 3 == 2 * n and c.most_common(
)[1][0] == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n = I()
a = LI()





c = Counter(a)
n_uniq = len(c)

if n_uniq > 3:
    print('No')


elif n_uniq == 3:
    a_1, a_2, a_3 = c.keys()
    if a_1 ^ a_2 ^ a_3 == 0 and c[a_1] == c[a_2] == c[a_3]:
        print('Yes')
    else:
        print('No')

elif n_uniq == 2:
    a_1, a_2 = sorted(set(a))
    if a_1 == 0 and 3 * c[a_1] == n:
        print('Yes')
    else:
        print('No')

else:
    if sum(a) == 0:
        print('Yes')
    else:
        print('No')

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
if sum(a)==0:
  print("Yes")
else:
  t=list(set(a))
  if len(t)==3 and n%3==0:
    if t[0]^t[1]==t[2] and a.count(t[0])==n//3 and a.count(t[1])==n//3:
      print("Yes")
    else:
      print("No")
  elif len(t)==2 and a.count(0)==n//3 and n%3==0:
    print("Yes")
  else:
    print("No")

Solution (Python):
N = int(input())
A_LIST = list(map(int, input().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:
    a1, a2 = sorted(A_SET)
    if a1 == 0 and A_LIST.count(a1) * 3 == N:
        print('Yes')
    else:
        print('No')
elif len(A_SET) == 3:
    a1, a2, a3 = A_SET
    if a1 ^ a2 == a3 and A_LIST.count(a1) ==  A_LIST.count(a2) and A_LIST.count(a2) == A_LIST.count(a3):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Solution (Python):
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
s = set(a)
l = len(s)
c = Counter(a)
if l == 1:
    if sum(a) == 0:
        print("Yes")
    else:
        print("No")
elif l == 2:
    x, y = min(a), max(a)
    if x == 0 and c[0] == n / 3:
        print("Yes")
    else:
        print("No")
elif l == 3:
    x, y, z = s
    if x ^ y ^ z == 0 and c[x] == c[y] == c[z]:
        print("Yes")
    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) == 0:
        ans = "Yes"
    else:
        ans = "No"
elif len(a_set) == 2:
    a1,a2 = sorted(a_set)
    if a1 == 0 and N == a.count(a1)*3:
        ans = "Yes"
    else:
        ans = "No"
elif len(a_set) == 3:
    a1,a2,a3 = a_set
    if (a1^a2^a3 == 0) and (a.count(a1)==a.count(a2)==a.count(a3)):
        ans = "Yes"
    else:
        ans = "No"
else:
    ans = "No"
    
print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 

from decimal import *



N = INT()
A = LIST()
c = Counter(A)

a = list(c.keys())
n = len(a)

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

Solution (Python):
import sys
from collections import Counter
N = int(input())
C = Counter(list(map(int, input().split())))
if len(C) == 1 and C[0] == N:
    print('Yes')
elif len(C) == 2 and N % 3 == 0 and C[0] == N // 3 and N - C[0] == 2 * N // 3:
    print('Yes')
elif len(C) == 3 and N % 3 == 0:
    b = 0
    for c in C.most_common():
        if c[1] != N // 3:
            print('No')
            sys.exit()
        b ^= c[0]
    if b == 0:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = list(map(int, readline().split()))

    if a.count(0) == n:
        print("Yes")
    else:
        if n % 3 == 0:
            s = list(set(a))
            if len(s) == 3:
                if s[0] ^ s[2] == s[1] and s[1] ^ s[0] == s[2] and s[2] ^ s[1] == s[0]:
                    if a.count(s[0]) == a.count(s[1]) == a.count(s[2]):
                        print("Yes")
                    else:
                        print("No")
                else:
                    print("No")
            elif len(s) == 2:
                if a.count(0) == n // 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()))


setA = set(A)
if len(setA) == 1:
    if sum(A) == 0:
        ans = 'Yes'
    else:
        ans = 'No'

elif len(setA) == 2:
    a1, a2 = sorted(setA)
    if (a1 == 0) and (A.count(a1) * 3 == n):
        ans = 'Yes'
    else:
        ans = 'No'

elif len(setA) == 3:
    a1, a2, a3 = setA
    if (a1 ^ a2 ^ a3 == 0) and (A.count(a1) == A.count(a2) == A.count(a3)):
        ans = 'Yes'
    else:
        ans = 'No'
else:
    ans = 'No'

print(ans)

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
u = list(set(l))
if len(u)==1 and u[0]==0:
  print("Yes")
elif n%3==0:
  if len(u)==2:
    x = l.count(u[0])
    y = l.count(u[1])
    if (x==2*n/3 and y==n/3 and u[1]==0) or (y==2*n/3 and x==n/3 and u[0]==0):
      print("Yes")
    else:
      print("No")
  elif len(u)==3:
    x = l.count(u[0])
    y = l.count(u[1])
    z = l.count(u[2])
    if x==n/3 and y==n/3 and z==n/3 and ((u[0]^u[1])^u[2])==0:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  print("No")

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

    cnt=Counter(A)

    if cnt[0]==N:
        print("Yes")
        return
    t=0
    for a in A:
        t^=a

    if N%3==0:
        if cnt[0]==int(N//3) and len(cnt)==2:
            print("Yes")
        elif len(cnt)==3 and t==0:
            print("Yes")
        else:
            print("No")
    else:
        print("No")


    
if __name__ == "__main__":
     solve()

Solution (Python):





import math
import fractions
import sys
import bisect
import heapq  
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr



def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod



def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
a = lr()
flag = False
dic = collections.Counter(a)
if len(dic) == 1:
    if 0 in dic:
        print('Yes')
    else:
        print('No')
elif len(dic) == 2:
    if 0 in dic:
        if dic[0] == n/3:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
elif len(dic) == 3:
    pre = 0
    for k,v in dic.items():
        if v != n/3:
            print('No')
            sys.exit()
        pre = pre^k
    if pre == 0:
        print('Yes')
    else:
        print('No')
else:
    print('No')