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 = int(input())
A = list(map(int,input().split()))
B = set(A)
C = list(B)
k = len(C)
if N%3==0:
    if k==3 and C[0]^C[1]==C[2] and A.count(C[0])==A.count(C[1]) and A.count(C[0])==A.count(C[2]):
        print("Yes")
    elif k==2:
        C = sorted(C)
        if C[0]==0 and A.count(C[0])==N//3:
            print("Yes")
        else:
            print("No")
    elif k==1 and C[0] == 0:
        print("Yes")
    else:
        print("No")
else:
    if k==1 and C[0] ==0:
        print("Yes")
    else:
        print("No")

Solution (Python):
from collections import  Counter

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

tmp=Counter(a)
if len(tmp)>3:
    print("No")
elif len(tmp)==1:
    if not 0 in a:
        print("No")
    else:
        print("Yes")
elif len(tmp)==2:
    if tmp[0]==n//3 :
        print("Yes")
    else:
        print("No")
else:
    values, counts=zip(*tmp.most_common())
    if counts[0]==counts[1]==counts[2] and values[0]^values[1]^values[2]==0:
        print("Yes")
    else:
        print("No")

Solution (Python):

from collections import Counter

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

if max(al)==0:
    print("Yes")
    exit()

d = Counter(al)
keys = sorted(d.keys())
if len(keys)==2:
    if n%3==0 and keys[0]==0 and d[keys[0]]*2==d[keys[1]]:
        print("Yes")
        exit()

if len(keys)==3:
    if n%3==0 and keys[0]^keys[1]^keys[2]==0 and d[keys[0]]==d[keys[1]]==d[keys[2]]:
        print("Yes")
        exit()

print("No")

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
flag = False
x = len(set(A))
if x == 1 and A[0] == 0:
  flag = True
elif x == 2 and A.count(0) == N // 3:
  flag = True
elif x == 3:
  X = A[0]
  Y = -1
  Z = -1
  i = 1
  while i < N:
    if A[i] != X:
      Y = A[i]
      break
    i += 1
  while i < N:
    if A[i] != X and A[i] != Y:
      Z = A[i]
    i += 1
  if X ^ Y ^ Z == 0 and A.count(X)  == N // 3 and A.count(Y)  == N // 3:
    flag = True
print("Yes" if flag else "No")

Solution (Python):
from collections import Counter

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

c = Counter(A)
if len(c) == 3:
    x, y, z = c.keys()
    ans = (c[x] == c[y] == c[z]) and (x ^ y == z)
elif len(c) == 2:
    ans = (0 in c) and (c[0] * 3 == N)
elif len(c) == 1:
    ans = 0 in c
else:
    ans = False
print('Yes' if ans else 'No')

Solution (Python):
import collections

n = int(input())
a_list = list(map(int,input().split()))

c = collections.Counter(a_list)
c_set = set(a_list)
check = -1
check_list = []

if len(c) == 1:
    if c[0] != 0:
        print("Yes")
        exit()
elif len(c) == 2:
    if c[0] == n//3:
        print("Yes")
        exit()
elif len(c) == 3:
    for i in c_set:
        check_list.append(i)
        if check == -1:
            check = c[i]
        else:
            if check != c[i]:
                print("No")
                exit()
    else:
        res = check_list[0] ^ check_list[1] ^ check_list[2]
        if res == 0:
            print("Yes")
            exit()
        
print("No")

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


S = {}
for ai in a:
    if ai in S:
        S[ai]+=1
    else:
        S[ai] = 1
A = list(S.keys())




if len(S) ==3:
    if A[0]==A[1]^A[2] and S[A[0]]==S[A[1]] and S[A[1]] == S[A[2]]:
        print("Yes")
    else:
        print("No")


elif len(S)==2:
    if A[0]==0 and S[A[1]] == 2*S[A[0]]:
        print("Yes")
    elif A[1]==0 and S[A[0]] == 2*S[A[1]]:
        print("Yes")
    else:
        print("No")


elif len(S)==1:
    if list(S.keys())==[0]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):





mod=10**9+7
def factorial(x): 
    n=1
    for i in range(x):
        n=(n*(i+1))%mod
    return n

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return((a*b)//gcd(a,b))
def div(x): 
    div=[1]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        if(x%check==0):
            div.append(check)
            while(x%check==0):
                x=x//check
        check+=1
    if x != 1:
      div.append(x)
    return div
def div2(x): 
    div2=[]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        while x%check==0:
            div2.append(check)
            x/=check
        check+=1
    if x != 1:
      div2.append(x)
    return div2

def main():
    
    
    
    
    
    
    
    
    
    
    n=int(input())
    a = list(map(int,input().split())) 
    if a==[0 for _ in range(n)]:
        print("Yes")
        exit()
    if n%3!=0:
        print("No")
        exit()
    else:
        a.sort()
        x=a[0]
        z=a[n-1]
        if n%2==0:
            y=a[n//2]
        else:
            y=a[((n+1)//2)-1]
        x0=y0=z0=0
        for i in range(n):
            if a[i]==x:
                x0+=1
            if a[i]==y:
                y0+=1
            if a[i]==z:
                z0+=1
        if x==0 and x0==n//3 and y==z:
            print("Yes")
            exit()
        if x0!=n//3 or y0!=n//3 or z0!=n//3:
            print("No")
            exit()
        cnt={}
        index=0
        while x != 0:
            if x//2>0:
                if x%2!=0:
                    if index not in cnt:
                        cnt[index]=1
                    else:
                        cnt[index]+=1
                x=x//2
                index+=1
            else:
                if index not in cnt:
                    cnt[index]=1
                else:
                    cnt[index]+=1
                x=0
        index=0
        while y != 0:
            if y//2>0:
                if y%2!=0:
                    if index not in cnt:
                        cnt[index]=1
                    else:
                        cnt[index]+=1
                y=y//2
                index+=1
            else:
                if index not in cnt:
                    cnt[index]=1
                else:
                    cnt[index]+=1
                y=0
        index=0
        while z != 0:
            if z//2>0:
                if z%2!=0:
                    if index not in cnt:
                        cnt[index]=1
                    else:
                        cnt[index]+=1
                z=z//2
                index+=1
            else:
                if index not in cnt:
                    cnt[index]=1
                else:
                    cnt[index]+=1
                z=0
        for i in cnt:
            if cnt[i]%2==1:
                print("No")
                exit()
        print("Yes")

main()

Solution (Python):
from collections import Counter

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

ak = list(a.keys())
av = list(a.values())

if N % 3 != 0:
    if a[0] == N:
        print('Yes')
    else:
        print('No')
elif len(ak) == 3:
    if ak[0] ^ ak[1] ^ ak[2] == 0 and av[0] == av[1] == av[2]:
        print('Yes')
    else:
        print('No')
elif len(ak) == 2:
    if 0 in ak:
        if a[0] == N // 3:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
elif len(ak) == 1:
    if 0 in ak:
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

if len(A)==1:
  if 0 in A:
    print("Yes")
  else:
    print("No")
elif len(A)==2:
  if A[0]==N/3:
    print("Yes")
  else:
    print("No")
elif len(A)==3:
  if list(A.values())==[N/3]*3 and list(A.keys())[0]^list(A.keys())[1]^list(A.keys())[2]==0:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Solution (Python):
cnt = [0 for i in range(31)]

n = int(input())
lis = list(map(int,input().split()))

for num in lis:
  s = format(num,'b').zfill(31)
  for i in range(31):
    cnt[i] += int(s[i])

if n % 3 == 0:
  for nu in cnt:
    if nu != 0 and nu * 3 != n * 2:
      print("No")
      exit()
  print("Yes")
else:
  for nu in cnt:
    if nu != 0:
      print("No")
      exit()
  print("Yes")

Solution (Python):
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
a = nl()

s = 0

for i in range(n):
    s ^= a[i]
if s == 0:
    print('Yes')
else:
    print('No')

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

Solution (Python):

import collections

N = int(input().split()[0])
a_list = list(map(int, input().split()))

counter = collections.Counter(a_list)


is_ok = True
if len(counter) > 4:
    is_ok = False
elif len(counter) == 3:
    v_list = list(counter.values())
    if len(set(v_list)) != 1:
        
        is_ok = False

    if is_ok:
        k_list = list(counter.keys())
        if k_list[0] ^ k_list[1] != k_list[2]:
            is_ok = False
elif len(counter) == 2:
    v_list = list(counter.values())
    if min(v_list) * 2 == max(v_list):
        a = [k for k, v in counter.items() if v == max(v_list)][0]
        b = [k for k, v in counter.items() if v == min(v_list)][0]
        if a ^ a != b:
            is_ok = False
    else:
        is_ok = False
else:
    for k in counter.keys():
        if k != 0:
            is_ok = False
            break

ans = "Yes" if is_ok else "No"

print(ans)

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

a.sort()

if a[-1]==0:
    f=True
elif N%3!=0:
    f=False
elif a[0]==a[N//3-1] and a[N//3]==a[2*N//3-1] and a[2*N//3]==a[-1] and a[0]^a[N//3]==a[-1]:
    f=True
else:
    f=False

print('Yes' if f else 'No')

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

def a():
    if n%3 > 0:
        if len(list(set(A))) == 1:
            return "Yes"
    else:
        B = list(set(A))
        if len(B) <= 3:
            c = 0
            t = 0
            for i in B:
                cou = A.count(i)
                
                if cou % (n//3) == 0:
                    c += 1
                    for j in range(cou // (n//3)):
                        
                        t ^= i
                
            if c == len(B) and t == 0:
                return "Yes"
    return "No"

print(a())

Solution (Python):
from collections import Counter

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

A = Counter(A)
V = Counter(A.values())

if list(A.keys())==[0]:
    print('Yes')

elif len(A)==2:
    p,q = A.keys()
    if min(p,q)==0 and A[0]*2==A[max(p,q)]:
        print('Yes')
    else:
        print('No')

elif len(A)==3 and len(V)==1:
    p,q,r = A.keys()
    if p^q^r == 0:
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

c = list(set(a))
c.sort()
if len(c) > 3:
    print('No')
    exit()

if len(c) == 1:
    if c[0] == 0:
        print('Yes')
    else:
        print('No')
elif len(c) == 2:
    if c[0] == 0 and a.count(0) * 2 == a.count(c[1]):
        print('Yes')
    else:
        print('No')
else:
    if c[0] ^ c[1] == c[2] and a.count(c[0]) == a.count(c[1]) and a.count(c[1]) == a.count(c[2]):
        print('Yes')
    else:
        print('No')

Solution (Python):
from collections import Counter


def main():
    N = int(input())
    lst_a = list(map(int, input().split()))

    cnt_a = Counter(lst_a)

    if len(cnt_a) > 3:
        print("No")
        exit()
    
    if len(cnt_a) == 1:
        print("Yes" if lst_a[0] == 0 else "No")
        exit()
    
    if N % 3:
        print("No")
        exit()
    
    if len(cnt_a) == 2:
        if cnt_a[0] != N//3:
            print("No")
        else:
            print("Yes")
    else:
        if any(v != N//3 for v in cnt_a.values()):
            print("No")
        else:
            x, y, z = list(cnt_a)
            print("Yes" if x ^ y ^ z == 0 else "No")


if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
p=[]
cnt=[]
zero=0
for i in range(n):
	if len(p)>=4:
		print("No")
		exit()
	if a[i]==0:
		zero+=1
	elif a[i] not in p:
		p.append(a[i])
		cnt.append(1)
	else:
		for j in range(len(p)):
			if a[i]==p[j]:
				cnt[j]+=1
if n%3!=0 and zero!=n:
	print("No")
	exit()
if len(p)>=4:
	print("No")
	exit()
if len(p)==3:
	if cnt[0]==cnt[1]==cnt[2]==n/3:
		if p[0]^p[1]^p[2]==0:
			print("Yes")
			exit()
	else:
		print("No")
		exit()
elif len(p)==1:
	if cnt[0]==n/3*2:
		print("Yes")
		exit()
elif len(p)==0:
	if sum(a)==0:
		print("Yes")
		exit()
print("No")

Solution (Python):
import collections
import itertools

n = int(input())
ls = list(map(int, input().split()))
counter = collections.Counter()
for x in ls:
    counter[x] += 1
if len(counter.keys()) > 3:
    print('No')
else:
    for a, b in itertools.combinations_with_replacement(counter.keys(), 2):
        if a == b and counter[a] == 1:
            continue
        counter2 = collections.Counter()
        x = a
        counter2[a] += 1
        counter2[b] += 1
        for _ in range(n - 2):
            a, b = b, a ^ b
            counter2[b] += 1
            if counter2[b] > counter[b]:
                break
        else:
            if a ^ b != x:
                continue
            else:
                print('Yes')
                break
    else:
        print('No')

Solution (Python):
N = int(input())
a = [int(i) for i in input().split()]
b = list(set(a))
flag = False
if len(b) == 3:
    if b[0]^b[1] == b[2] and N % 3 == 0 and a.count(b[0]) == a.count(b[1]) and a.count(b[1]) == a.count(b[2]):
        flag = True
elif len(b) == 2:
    if b[0]^b[0] == b[1]:
        if N % 3 == 0 and a.count(b[0]) == a.count(b[1]) * 2:
            flag = True
    if b[1]^b[1] == b[0]:
        if N % 3 == 0 and a.count(b[1]) == a.count(b[0]) * 2:
            flag = True
elif len(b) == 1:
    if b[0] == 0:
        flag = True
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
x = 0
for a in A:
  x ^= a
print('Yes' if x == 0 else 'No')

Solution (Python):
from collections import Counter

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

mc = Counter(a).most_common()
ln = len(mc)

def detect():
    if ln == 1 and mc[0][0] == 0:
        return True
    elif ln == 2 and mc[1][0] == 0 and mc[1][1] == n // 3:
        return True
    elif ln == 3 and mc[0][0] ^ mc[1][0] ^ mc[2][0] == 0 and mc[0][1] == mc[1][1] == mc[2][1]:
        return True
    return False

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

Solution (Python):
from collections import defaultdict as dd
n = int(input())
a = [int(i) for i in input().split()]
if sum(a):
    if n%3: f = 0
    else:
        d,x = dd(int),[]
        for i in a: d[i]+=1
        for i in d.keys(): x.append(i)
        if len(d)==2 and d[0]==n//3: f = 1
        elif len(d)==3 and x[0]^x[1]^x[2]==0 and d[x[0]]==d[x[1]]==d[x[2]]: f = 1
        else: f = 0
else: f = 1
if f: print("Yes")
else: print("No")

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
def solve(A):
  count = {}
  for x in A:
    if x not in count:
      count[x] = 0
    count[x] += 1
  if 0 in count and count[0] == N: return True
  if len(A) % 3 != 0: return False    
  xs = []
  for k, v in count.items():
    if v % (N//3) != 0: return False
    for _ in range(v // (N//3)):
      xs.append(k)
  return (xs[0] == xs[1] ^ xs[2]) or (xs[1] == xs[2] ^ xs[0]) or (xs[2] == xs[0] ^ xs[1])

print('Yes' if solve(A) else 'No')

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
flag = 0
if n % 3 != 0:
    for i in range(0, n - 1):
        if a[i] == a[i + 1]:
            flag += 1
        else:
            break
    if flag == n - 1:
        print("Yes")
    else:
        print("No")
else:
    n3 = n // 3

    if a[0] ^ a[n3 * 2] != a[n3]:
        print("No")
    else:
        for i in range(0, n - 1):
            if i == n3 - 1 or i == n3 * 2 - 1:
                continue
            if a[i] == a[i + 1]:
                flag += 1
            else:
                break
        if flag == n - 3:
            print("Yes")
        else:
            print("No")

Solution (Python):


import numpy as np

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


def solve(x):
    if (x == 0).all():
        return "Yes"
    if len(x) % 3:
        return "No"
    x.sort()
    idx = len(x)//3
    if (x[:idx] == 0).all() and (x[idx:] == x[-1]).all():
        return "Yes"
    if x[0] ^ x[idx] ^ x[2*idx] == 0 and (x[:idx] == x[0]).all() and (x[idx:2*idx] == x[idx]).all() and (x[2*idx:] == x[2*idx]).all():
        return "Yes"
    return "No"


a = np.array(a)
ans = solve(a)
print(ans)

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

d = defaultdict(int)
for i in range(n):
    d[a[i]] += 1

k = list(d.keys())
v = list(d.values())

if len(k) == 1 and k[0] == 0:
    ans = "Yes"
elif n % 3 != 0:
    ans = "No"
elif len(k) == 2 and 0 in d and d[0] == n // 3:
    ans = "Yes"
elif len(k) == 3 and v[0] == v[1] == v[2] and k[0] ^ k[1] ^ k[2] == 0:
    ans = "Yes"
else:
    ans = "No"

print(ans)

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

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

if 0 in c and c[0] == N:
    print('Yes')
elif len(c) == 2 and 0 in c and c[0] == N/3:
    print('Yes')
elif len(c) == 3 and v[0]==v[1]==v[2] and k[0]^k[1]^k[2] == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
import collections

N=int(input())
l=list(map(int,input().split()))
c=collections.Counter(l)
cv=list(c.values())
ck=list(c.keys())
if len(cv) == 3 and cv[0] == cv[1] and cv[1] == cv[2] and ck[0]==ck[1]^ck[2]:
    print("Yes")
elif len(cv) == 2 and ((cv[0] == cv[1]*2 and ck[1]==0) or (cv[1] == cv[0]*2 and ck[0]==0)):
    print("Yes")
elif len(cv) == 1 and ck[0] == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter
from functools import reduce
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
if (len(c) == 1 and c[0] == n) or (len(c) == 2 and c[0] == n//3 and c[max(c.keys())] == 2*n//3) or (len(c) == 3 and reduce(lambda x, y: x^y, c.keys()) == 0 and set(c.values()) == set([n//3])):
    print("Yes")
else:
    print("No")

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

for i in range(N):
    if a[i] not in dic:
        dic[a[i]] = 1
    else:
        dic[a[i]] += 1

values = list(dic.values())
keys = list(dic.keys())

if len(dic.keys()) == 3 and values[0] == values[1] == values[2] and keys[0] ^ keys[1] ^ keys[2] == 0:
    print('Yes')
elif len(dic.keys()) == 2 and 0 in dic and dic[0] * 3 == N:
    print('Yes')
elif len(dic.keys()) == 1 and 0 in dic:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
A = list(map(int, input().split()))
A.sort()
B = list(set(A))
if len(B) >= 4:
  print('No')
else:
  if B[-1] == 0:
    print('Yes')
  elif A.count(0) == n/3 and len(B) == 2:
    print('Yes')
  elif len(B) == 3 and B[0]^B[1]^B[2] == 0 and A.count(B[0]) == A.count(B[1]) == n/3:
    print('Yes')
  else:
    print('No')

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

A_sorted = sorted(A)
A_set = list(set(A))
A_cnt = dict()
for a in A:
    if not a in A_cnt.keys():
        A_cnt[a] = 1
    else:
        A_cnt[a] += 1

if A_cnt.get(0) == N:
    print("Yes")
    exit()

if len(A_set) > 3 or len(A_set) == 1 or N%3 != 0:
    print("No")
    exit()

B = []
B.append(A_set[0])
B.append(A_set[1])
for _ in range(N-2):
    B.append(B[-1] ^ B[-2])

B_sorted = sorted(B)
if A_sorted == B_sorted:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import defaultdict
def solve(n,A):
    S=set(A)
    l=len(S)
    if S=={0}:
        return 'Yes'
    if n%3 or l==1 or l>3:
        return 'No'
    d=defaultdict(int)
    for a in A:
        d[a]+=1
    if l==2:
        return 'Yes' if d[0]==n//3 else 'No'
    x=0
    for s in S:
        if d[s]!=n//3:
            return 'No'
        x^=s
    return 'No' if x else 'Yes'

n=int(input())
A=tuple(map(int,input().split()))
print(solve(n,A))

Solution (Python):
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    d = dict()
    for a in A: d[a] = d.get(a, 0) + 1

    if len(d) == 1:
        a = list(d.keys())[0]
        if a == 0:
            return "Yes"
    elif len(d) == 2:
        a, b = list(d.keys())
        if a == 0 and d[b] == 2*d[a]:
            return "Yes"
        if b == 0 and d[a] == 2*d[b]:
            return "Yes"
    elif len(d) == 3:
        a, b, c = list(d.keys())
        if d[a] == d[b] == d[c]:
            if (a^b == c and b^c == a and c^a == b) or (a^c == b and c^b == a and b^a == c):
                return "Yes"
    return "No"

if __name__ == '__main__':
    print(main())

Solution (Python):
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    d = dict()
    for a in A: d[a] = d.get(a, 0) + 1

    if len(d) == 1:
        a = list(d.keys())[0]
        if a == 0:
            return "Yes"
    elif len(d) == 2:
        a, b = list(d.keys())
        if a == 0 or b == 0:
            if d[a] == d[b]:
                return "Yes"
            if N % 3 == 0 and (d[a] == 2*d[b] or d[b] == 2*d[a]):
                return "Yes"    
    elif len(d) == 3:
        a, b, c = list(d.keys())
        if d[a] == d[b] == d[c]:
            if (a^b == c and b^c == a and c^a == b) or (a^c == b and c^b == a and b^a == c):
                return "Yes"
    return "No"

if __name__ == '__main__':
    print(main())

Solution (Python):

data = {}
N = int(input())
for i in input().split():
    if i not in data:
        data.update({i: 1})
    else:
        data[str(i)] += 1

ok = 0

if len(data.keys()) > 3:
    pass
elif len(data.keys()) == 1:
    if list(data.keys())[0] == "0":
        ok = 1
elif len(data.keys()) == 2:
    if "0" in data.keys() and data["0"] == N/3:
        ok = 1
else:
    sum = 0
    for i, count in data.items():
        if not count == N/3:
            ok = -1
            break
        sum = sum ^ int(i)
    if ok == 0 and sum == 0:
        ok = 1

if ok == -1:
    ok = 0
print("Yes" if ok else "No")

Solution (Python):
def main():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = collections.Counter(list(map(int, input().rstrip('\n').split()))).most_common()
    if len(a) == 3:
        if a[0][0] ^ a[1][0] ^ a[2][0] == 0 and a[0][1] == a[1][1] == a[2][1]:
            print("Yes")
            exit()
    elif len(a) == 2:
        if (a[0][0] == 0 and a[1][1] == a[0][1] * 2) or (a[1][0] == 0 and a[0][1] == a[1][1] * 2):
            print("Yes")
            exit()
    elif len(a) == 1 and a[0][0] == 0:
        print("Yes")
        exit()
    print("No")


if __name__ == '__main__':
    main()

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(N: int, a: "List[int]"):
    if all([aa == 0 for aa in a]):
        print(YES)
    elif len(set(a)) == 2 and len([aa for aa in a if aa == 0]) == N // 3:
        print(YES)
    elif len(set(a)) == 3:
        l = list(set(a))
        if l[0] ^ l[1] ^ l[2] == 0 and a.count(l[0]) == N // 3 and a.count(l[1]) == N // 3:
            print(YES)
        else:
            print(NO)
    else:
        print(NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    a = [int(next(tokens)) for _ in range(N)]  
    solve(N, a)

if __name__ == '__main__':
    main()

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

total=L[0]
for i in range(1,N):
    total^=L[i]

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

Solution (Python):



import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n = I()
a = LI()
if sum(a) == 0:
    print('Yes')
elif n % 3 != 0:
    print('No')
else:
    b = list(Counter(a).items())
    b.sort(key = itemgetter(0))
    if len(b) == 2:
        if b[0][0] == 0 and b[0][1] == n//3 and b[1][1] == n//3*2:
            print('Yes')
            quit()
    elif len(b) == 3:
        if b[0][0]^b[1][0]^b[2][0] == 0:
            if b[0][1] == n//3 and b[1][1] == n//3 and b[2][1] == n//3:
                print('Yes')
                quit()
    print('No')

Solution (Python):
from collections import Counter

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





if sum(a)  == 0:
    print("Yes")
    exit(0)

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

b = list(set(a))
if len(b) > 3:
    print("No")
    exit(0)

A = Counter(a)
if len(b) == 3:
    if A[b[0]] == A[b[1]] == A[b[2]]:
        if b[0]^b[1]^b[2] == 0:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    if A[0] == N//3:
        print("Yes")
    else:
        print("No")

Solution (Python):
def getlist():
    return list(map(int, input().split()))

N = int(input())
a = getlist()
a = sorted(a)

if N % 3 != 0:
    if a[-1] >= 1:
        print("No")
    else:
        print("Yes")
else:
    m = int(N // 3)
    if a[0] == a[m - 1] and a[m] == a[2 * m - 1] and a[2 * m] == a[3 * m - 1]:
        if a[0] ^ a[m] == a[2 * m] and a[m] ^ a[2 * m] == a[0] and a[2 * m] ^ a[0] == a[m]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Solution (Python):
import collections
n = int(input())
a = sorted(collections.Counter(list(map(int, input().split()))).most_common())
if len(a) == 3:
    if a[0][0] ^ a[1][0] ^ a[2][0] == 0 and a[0][1] == a[1][1] == a[2][1]:
        print("Yes")
    else:
        print("No")
elif len(a) == 2:
    if a[0][1] * 2 == a[1][1] and a[0][0] == 0:
        print("Yes")
    else:
        print("No")
elif len(a) == 1:
    if a[0][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()))

c = Counter(a)
k = list(c.keys())
v = list(c.values())
if k == [0]:
    able = True
elif len(c) == 2 and 0 in c and c[0] == N // 3:
    able = True
elif len(c) == 3 and k[0] ^ k[1] == k[2] and v[0] == v[1] == v[2]:
    able = True
else:
    able = False
print('Yes' if able else 'No')

Solution (Python):
n = int(input())
d = {}
for a in [int(x) for x in input().split()]:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1
ans = "No"
key = list(d.keys())
l_key = len(key)
if l_key == 1:
    if 0 in d:
        ans = "Yes"
elif l_key == 2:
    if 0 in d:
        if d[0] * 3 == n:
            ans = "Yes"
elif l_key == 3:
    flag = 0
    for v in d.values():
        if v * 3 == n:
            flag += 1

    if key[0] ^ key[1] ^ key[2] == 0 and flag == 3:
        ans = "Yes"

print(ans)

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

if len(aset) == 1:
  if all(i == 0 for i in a):
    print("Yes")
  else:
    print("No")
elif len(aset) == 2:
  a1, a2 = sorted(aset)
  if a1 == 0:
    if a.count(a1) * 3 == n:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
elif len(aset) == 3:
  a1, a2, a3 = aset
  if a.count(a1) == a.count(a2) == a.count(a3):
    if a1 ^ a2 == a3:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  print("No")

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
s = 1
for i in a:
    s ^= i
if s == 1:
    print('Yes')
else:
    print('No')

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

a = collections.Counter(a)
a_list = list(a.items())
a_list = sorted(a_list,key = lambda a_list:a_list[0])

if len(a_list) == 1:
	if a_list[0][0] == 0:
		print("Yes")
	else:
		print("No")
elif len(a_list) == 2:
	if ((a_list[0][0] == 0) and (a_list[0][1] == int(N/3)) and \
		(a_list[1][1] == int(2*N/3))):
		print("Yes")
	else:
		print("No")
elif len(a_list) == 3:
	if ((a_list[0][1] == int(N/3)) and \
		(a_list[1][1] == int(N/3)) and \
		(a_list[2][1] == int(N/3)) and \
		(a_list[0][0]^a_list[1][0]^a_list[2][0] == 0)):
		print("Yes")
	else:
		print("No")
else:
	print("No")

Solution (Python):
import sys
input=sys.stdin.readline

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

a.sort()
h = {}
for i in a:
    if i in h:
        h[i] += 1
    else:
        h[i] = 1
k = []
v = []
for i,j in h.items():
    k.append(i)
    v.append(j)

if len(h) == 1:
    if k[0] == 0:
        print("Yes")
        exit()
elif len(h) == 2:
    if k[0] == 0 and 2*v[0] == v[1]:
        print("Yes")
        exit()
elif len(h) == 3:
    if k[0] ^ k[1] == k[2] and v[0] == v[1] and v[0] == v[1]:
        print("Yes")
        exit()
print("No")

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

if len(k)==3 and k[0]^k[1]^k[2]==0 and v[0]==v[1]==v[2]:
  print("Yes")
elif len(k)==2 and k.count(0) and v[k.index(0)]==(sum(v)/3):
  print("Yes")
elif k == [0]:
  print("Yes")
else:
  print("No")

Solution (Python):
def solve():
  n = int(input())
  ans = 0
  for a in map(int, input().split()):
    ans ^=a
  print("No" if ans else "Yes")
solve()