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 solve():
    N = int(input())
    a = [int(s) for s in input().split() if s]
    sum = 0
    for i in range(N):
        sum ^= a[i]
    print('Yes' if sum == 0 else 'No')
    
solve()

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

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

for i in range(N):
    temp = temp ^ a[i]

if temp^temp == temp:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
A = list(map(int,input().split()))
l = [[0,0],[0,0],[0,0]]
flag = 0
for i in range(n):
  x = A[i]
  for j in range(3):
    if l[j] == [0,0]:
      l[j] = [x,1]
      break
    if x == l[j][0]:
      l[j][1] += 1
      break
  else:
    break
a = l[0][1]
b = l[1][1]
c = l[2][1]
aa = l[0][0]
bb = l[1][0]
cc = l[2][0]
if n % 3 == 0:
  m = n // 3
  if a == m:
    if b == m and c == m:
      if aa ^ bb ^ cc == 0:
        flag = 1
  if a == 2 * m and b == m:
    if bb == 0:
      flag = 1
  if a == m and b == 2 * m:
    if aa == 0:
      flag = 1
if a == n and aa == 0:
  flag = 1
if flag == 1:
  print('Yes')
else:
  print('No')

Solution (Python):
from collections import defaultdict

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

dic = defaultdict(int)



if N % 3 == 0:
    
    for a in A:
        dic[a] += 1

    n_kind = len(dic.keys())
    values = list(dic.keys())
    cnts = list(dic.values())
        
    
    if n_kind == 3:
        is_xor = False    
        
        for i in range(n_kind-2):
            for j in range(i+1, n_kind-1):
                for k in range(j+1, n_kind):
                    if values[i] ^ values[j] ^ values[k] == 0:
                        is_xor = True

        
        
        is_n_valid = True
        for cnt in cnts:
            if cnt != N/3:
                is_n_valid = False

            
        if is_xor and is_n_valid:
            print('Yes')
        else:
            print('No')
    
    elif n_kind == 2:
        
        
        is_n_valid = True
        if 0 in values:
            for k, v in dic.items():
                if k == 0:
                    if v != N/3:
                        is_n_valid = False
                else:
                    if v != N * (2/3):
                        is_n_valid = False
        else:
            is_n_valid = False

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


    elif n_kind == 1:
        all_zero = True
        for a in A:
            if a != 0:
                all_zero = False

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

    else:
        print('No')


else:
    all_zero = True
    for a in A:
        if a != 0:
            all_zero = False

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

Solution (Python):
from sys import stdin


def main():
    _ = int(input())
    a_lists = [int(x) for x in stdin.readline().rstrip().split()]
    z = 0

    for a in a_lists:
        z ^= a

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


if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
arr=list(map(int,input().split()))
dic={}
for val in arr:
  if val not in dic:
    dic[val]=1
  else:
    dic[val]+=1
l=len(dic)
if l==1:
  if 0 in dic:
    print('Yes')
  else:
    print('No')
elif l==2:
  if n%3==0:
    if 0 in dic:
      if dic[0]==n//3:
        print('Yes')
      else:
        print('No')
    else:
      print('No')
  else:
      print('No')
elif l==3:
  if n%3==0:
    arr2=list(dic.keys())
    arr3=list(dic.values())
    if (arr2[0]^arr2[1]^arr2[2])==0:
      if dic[arr2[0]]==n//3 and dic[arr2[1]]==n//3 and dic[arr2[2]]==n//3:
        print('Yes')
      else:
        print('No')
    else:
      print('No')
  else:
    print('No')
else:
  print('No')

Solution (Python):
import collections
n = int(input())
a = [int(i) for i in input().split()]
b = collections.Counter(a)
ans = "No"
if (len(b) == 3):
    if (list(b.keys())[0] ^ list(b.keys())[1] ^ list(b.keys())[2]) == 0:
        if ((list(b.values())[0] == list(b.values())[1]) & (list(b.values())[0] == list(b.values())[2])):
            ans = "Yes"
elif (len(b) == 1):
    if list(b.keys())[0] == 0:
        ans = "Yes"
elif (len(b) == 2):
    if (n % 3 == 0):
        dd = list(b.keys())
        dd.sort()
        if (dd[0] == 0) & ((b[0] * 2) == (b[dd[1]])):
            ans = "Yes"
print(ans)

Solution (Python):
import numpy as np
import sys

N = int(input())
A = input().split(' ')

an = np.array(A, dtype=np.int64)

chk = 0
for i in range(0,N):
   chk = chk ^ an[i] 

if(chk == 0):
   print('Yes')
else:
   print('No')

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
count = [0] * 30

for j in range(n):
    t = bin(a[j])[2:].zfill(30)
    for k in range(30):
        count[k] += int(t[29-k])
        count[k] = count[k] % 2

if 1 in count:
    print("No")
else:
    print("Yes")

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

if A.count(0) == N:
    print('Yes')
    exit()

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

if len(set(A)) == 3:
    F = list(set(A))
    x, y, z = F
    if not (((x ^ y) == z) or ((y ^ z) == x) or ((z ^ x) == y)):
        print('No')
        exit()

    if (A.count(x) == N // 3) and (A.count(y) == N // 3) and (A.count(z) == N // 3):
        print('Yes')
    else:
        print('No')
    exit()

if len(set(A)) == 2:
    if A.count(0) == N // 3:
        print('Yes')
    else:
        print('No')
    exit()

print('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 = list(map(int, input().split()))

res = a_list[0]
for i in range(1, len(a_list)):
    res ^= a_list[i]

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

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a_set = set(a)
if len(a_set) == 1:
    if a_set == {0}:
        print('Yes')
    else:
        print('No')
elif len(a_set) == 2:
    a_set = list(a_set)
    a0 = a.count(a_set[0])
    a1 = a.count(a_set[1])
    if N % 3 == 0 and a1 == 2 * a0 and a_set[0] == 0:
        print('Yes')
    else:
        print('No')
elif len(a_set) == 3:
    a_set = list(a_set)
    flag = 0
    if a.count(a_set[0]) == a.count(a_set[1]) and a.count(a_set[0]) == a.count(a_set[2]):
        flag = 1
    if N % 3 == 0 and flag == 1 and a_set[0] ^ a_set[1] == a_set[2]:
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

x = a[0]

for i in range(1,n):
    x = x ^ a[i]
    

if x>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 a_set == {0}:
        print('Yes')
    else:
        print('No')
elif len(a_set) == 2:
    a_set = list(a_set)
    a0 = a.count(a_set[0])
    a1 = a.count(a_set[1])
    if N % 3 == 0 and (a0 == 2 * a1 or a1 == 2 * a0) and 0 in a_set:
        print('Yes')
    else:
        print('No')
elif len(a_set) == 3:
    a_set = list(a_set)
    flag = 0
    if a.count(a_set[0]) == a.count(a_set[1]) and a.count(a_set[0]) == a.count(a_set[2]):
        flag = 1
    if N % 3 == 0 and flag == 1 and a_set[0] ^ a_set[1] == a_set[2]:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Solution (Python):
from collections import Counter

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

def solve():

    if N % 3 != 0:
        return all(a == 0 for a in A)



    counts, vals = zip(*sorted((c,v) for v,c in Counter(A).items()))

    if len(counts) == 1:
        return vals[0] == 0
    elif len(counts) == 2:
        return counts[0]*2 == counts[1] and vals[0] == 0
    elif len(counts) == 3:
        return counts[0] == counts[2] and (vals[0]^vals[1]^vals[2])==0
    else:
        return False

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

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

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

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

Solution (Python):
import sys,heapq,math,resource
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def setrlim():
  sys.setrecursionlimit(250000)
  soft,hard = resource.getrlimit(RLIMIT_STACK)
  
  

n = inn()
a = inl()
h = {} 
ddprint(n)
ddprint(a)
for x in a:
    h[x] = (1 if x not in h else h[x]+1)
b = list(h.keys())
x = a[0] if a[0]!=0 else a[1]
if len(h.keys()) == 3 and h[b[0]] == h[b[1]] and h[b[2]] == h[b[1]] and (b[0]^b[1])==b[2]:
    print('Yes')
elif len(h.keys()) == 2 and (b[0]==0 or b[1]==0) and h[0]*2 == h[x]:
    print('Yes')
elif len(h.keys()) == 1 and b[0]==0:
    print('Yes')
else:
    print('No')

Solution (Python):
import collections

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

c = collections.Counter(a)

out = "No"
flag = False
keys = list(c.keys())

if len(keys) == 3 and n %3 == 0:
    if keys[0]^keys[1]==keys[2] and c[keys[0]] == n//3 and c[keys[1]] == n//3 and c[keys[2]] == n//3:
        flag = True
        
elif len(keys) == 2 and n %3 == 0:
    if c[0] == n//3 and (c[keys[0]] == n//3*2 or c[keys[1]] == n//3*2):
        flag = True
        
elif len(keys) == 1:
    if c[0] == n:
        flag = True
        
if flag:
    out = "Yes"
    
print(out)

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

from collections import Counter

def solve(N, A):
    cs = Counter(A)
    k = list(cs.keys())
    v = list(cs.values())
    
    if len(k) == 1 and A[0] == 0:
        return True
    if len(k) == 3 and k[0] ^ k[1] ^ k[2] == 0 and v[0] == v[1] == v[2]:
        return True
    if len(k) == 2 and k[0] == 0 and v[0] * 2 == v[1]:
        return True
    if len(k) == 2 and k[1] == 0 and v[1] * 2 == v[0]:
        return True
    return False

if solve(N, A):
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
N=int(input())
a=list(map(int,input().split()))
b,c,d=0,1,0
while True:
    while True:
        if a[b]%(2**c)>=2**(c-1):
            d+=1
        b+=1
        if b==N:
            if d%2==1:
                print('No')
                sys.exit()
            else:
                break
    b,d=0,0
    c+=1
    if c==27:
        break
print('Yes')

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

tmp = 0
for data in a:
    tmp = tmp ^ data

if tmp == 0:
    print('Yes')
else:
    print('No')

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

Solution (Python):
from collections import Counter
import sys
from functools import reduce
N = int(input())
A = [int(_) for _ in input().split()]

if set(A) == {0}:
    print('Yes')
    sys.exit()

counter = Counter(A)

if len(counter) and len(set(counter.values())) == 1:
    if reduce(lambda x, y: x ^ y, counter.keys()) == 0:
        print('Yes')
        sys.exit()

if len(counter) == 2:  
    if 0 in counter.keys():
        if counter[0] == len(A) // 3:
            print('Yes')
            sys.exit()
print('No')

Solution (Python):
from operator import xor

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

D = {}

for a in A :
    if not a in D :
        D[a] = 1
    else :
        D[a] += 1

if len(D) == 1 :
    if D.get(0, 0) == N :
        ans = "Yes"
    else :
        ans = "No"
elif len(D) == 2 :
    if D.get(0, 0) * 3 == N :
        ans = "Yes"
    else :
        ans = "No"
elif len(D) == 3 :
    K = list(D.keys())
    V = list(D.values())
    
    if (xor(xor(K[0], K[1]), K[2]) == 0) and (V[0] == V[1] == V[2]) :
        ans = "Yes"
    else :
        ans = "No"
else :
    ans = "No"

print(ans)

Solution (Python):
_,a=open('/dev/fd/0');print'YNeos'[reduce(lambda x,y:x^y,map(int,a.split()))>0::2]

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


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


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ac = Counter(A)

    if len(ac) == 1 and 0 in ac:
        return 'Yes'

    if N % 3 == 0 and len(ac) == 2 and 0 in ac and ac[0] == N//3:
        return 'Yes'

    if N % 3 == 0 and len(ac) == 3:
        for v in ac.values():
            if v != N//3:
                break
        else:
            a = list(ac.keys())
            if a[0] ^ a[1] ^ a[2] ==  0:
                return 'Yes'

    return 'No'


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()

Solution (Python):

import sys

STDIN = 1
number = 1
elements = [[0]]

sample = """
3
1 2 3
"""

example = """
3
1 1 4
5 1 4
8 1 0
"""

if bool(sample.strip().splitlines()) or bool(STDIN):
    if bool(STDIN):
        number = int(sys.stdin.readline().strip())


        def pick():
            return sys.stdin.readline().strip()

    else:
        stack = sample.strip().splitlines()[::-1]
        number = int(stack.pop().strip())


        def pick():
            return stack.pop().strip()

    elements = list(map(int, pick().split()))

elif bool(number):
    i = 0
    for amp in (sample, example):
        i, j = i + 1, 0
        for p in (amp, amp.strip()):
            j += 1
            print("{}-{} = {}".format(i, j, repr(p)))
            print(p.split())
            print(p.splitlines())



numbers = tuple(elements)
kinds = set(numbers)


def yes():
    print("Yes")
    sys.exit()


if kinds == {0}:
    yes()

elif len(kinds) == 2:
    if 0 in kinds:
        if numbers.count(0) * 3 == number:
            yes()

elif len(kinds) == 3:
    a, b, c = tuple(kinds)
    if a ^ b == c:
        if (numbers.count(a) == numbers.count(b)) and (numbers.count(b) == numbers.count(c)):
            yes()

print("No")

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

unq = list(set(nums))


if len(unq) > 3:
  print("No")

if len(unq) == 3:
    
    a,b,c = unq
    if a ^ b ^ c == 0:
      if nums.count(a) == nums.count(b) == nums.count(c):
        print("Yes")
      else:
        print("No")
    else:
      print("No")

if len(unq) == 2:
    a,b = sorted(unq)
    if a == 0:
      if nums.count(a) * 2 == nums.count(b):
        print("Yes")
      else:
        print("No")
    else:
      print("No")

if len(unq) == 1:
    a = unq[0]
    if a != 0:
      print("No")
    else:
      print("Yes")

Solution (Python):
n=int(input())
al=list(map(int,input().split()))
s=set(al)
s=sorted(s)
if len(s)==1 and s[0]==0:
    print('Yes')
    exit()
if len(al)%3>0 or len(s)>3 or len(s)==1:
    print('No')
    exit()
if len(s)==2 and s[0]==0:
    if al.count(0)==n//3:
        print('Yes')
        exit()
if len(s)==3 and (s[0]^s[1]^s[2])==0:
    if al.count(s[0])==n//3 and al.count(s[1])==n//3:
        print('Yes')
        exit()
print('No')

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

from collections import Counter
C = Counter(A)
if len(C) > 3:
    print('No')
    exit()

if len(C) == 1:
    print('Yes' if A[0]==0 else 'No')
    exit()
if N%3:
    print('No')
    exit()

if len(C) == 2:
    if C[0] != N//3:
        print('No')
    else:
        print('Yes')
else:
    if any(v!=N//3 for v in C.values()):
        print('No')
    else:
        a,b,c = list(C)
        print('Yes' if a^b == c else 'No')

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

b = list(set(a))
c = [0]*len(b)

if len(b)>3:
    print('No')
    exit()

if n%3!=0:
    if len(b)==1 and b[0]==0:
        print('Yes')
        exit()
    else:
        print('No')
        exit()

for i in range(n):
    for j in range(len(b)):
        if a[i]==b[j]:
            c[j]+=1
            break


if len(b)==1:
    if b[0]==0:
        print('Yes')
        exit()
elif len(b)==2:
    if c[0]==n*2//3:
        if b[1]==0:
            print('Yes')
            exit()
    elif c[1]==n*2//3:
        if b[0]==0:
            print('Yes')
            exit()
elif len(b)==3:
    if c[0]==c[1]==c[2]:
        if b[0]^b[1]==b[2] and b[1]^b[2]==b[0] and b[2]^b[0]==b[1]:
            print('Yes')
            exit()

print('No')

Solution (Python):
from collections import Counter

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

C=Counter(A)

if len(C)==1:
	if C.keys()==[0]:
		print "Yes"
		quit()
elif len(C)==3:
	a,b,c=C.keys()
	na,nb,nc=C.values()
	if a^b==c and na==nb==nc:
		print "Yes"
		quit()
elif len(C)==2:
	if N%3==0:
		L=C.items()
		L.sort()
		a,b=L[0][0],L[1][0]
		na,nb=L[0][1],L[1][1]
		if a==0 and na==N/3:
			print"Yes"
			quit()

else:
	print "No"
	quit()


print "No"

Solution (Python):
from collections import Counter

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

for i,x in enumerate(A):
	if i==0:
		t=x
	else:
		t^=x

if t==0:
	print "Yes"
else:
	print "No"

Solution (Python):
from itertools import permutations

def check(xs):
    if xs[0] != xs[-1] ^ xs[1]:
        return False
    for i in range(1, len(xs)-1):
        if xs[i] != xs[i-1] ^ xs[i+1]:
            return False
    if xs[-1] != xs[-2] ^ xs[0]:
        return False
    return True

def solve0(A):
    for xs in permutations(A):
        if check(xs):
            return "Yes"
    return "No"

def solve(A):
    """
    N <= 10**5
    A <= 10**9
    a[i] == a[i-1] xor a[i+1]
    """
    x = 0
    for a in A:
        x ^= a

    return "Yes" if x == 0 else "No"

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

if 0==1:
    from random import randint
    N = 7
    for j in range(1, 100):
        A = [randint(0, 999999999) for i in range(N)]
        answer0 = solve0(A)
        answer = solve(A)
        if answer != answer0:
            print(answer, answer0)
            exit(1)

main()

Solution (Python):



def main():
    from collections import Counter

    n = int(input())
    a = Counter(map(int, input().split()))
    key_count = len(a.keys())
    keys_values = a.most_common()

    if key_count == 1:
        if keys_values[0][0] == 0:
            print('Yes')
        else:
            print('No')
    elif key_count == 2:
        if keys_values[0][0] == 0 or keys_values[1][0] == 0:
            if n % 3 == 0:
                if keys_values[1][0] == 0:
                    if keys_values[0][1] // keys_values[1][1] == 2 and keys_values[0][1] % keys_values[1][1] == 0:
                        print('Yes')
                    else:
                        print('No')
                elif keys_values[0][0] == 0:
                    if keys_values[1][1] // keys_values[0][1] == 2 and keys_values[1][1] % keys_values[0][1] == 0:
                        print('Yes')
                    else:
                        print('No')
                else:
                    print('No')
            else:
                print('No')
        else:
            print('No')
    elif key_count == 3:
        if keys_values[0][1] == keys_values[1][1] == keys_values[2][1]:
            xors = keys_values[0][0] ^ keys_values[1][0] ^ keys_values[2][0]

            if xors == 0:
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')


if __name__ == '__main__':
    main()

Solution (Python):

from fractions import gcd

from math import factorial as f

from math import ceil

from sys import exit

from copy import deepcopy

def main():


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

    if len(aunique) == 1:
        if a[0] == 0:
            print("Yes")
        else:
            print("No")
    elif len(aunique) is 2:
        if n%3 or not 0 in aunique:
            print("No")
        else:
            l = []
            l.append(a.count(aunique[0]))
            l.append(a.count(aunique[1]))
            if aunique[0] == 0:
                if not l[0] == n//3:
                    print("No")
                else:
                    print("Yes")
            else:
                if not l[1] == n//3:
                    print("No")
                else:
                    print("Yes")
    elif len(aunique) is 3 and not n%3:
        l = []
        l.append(a.count(aunique[0]))
        l.append(a.count(aunique[1]))
        l.append(a.count(aunique[2]))

        if not l[0] == l[1] or not l[1] == l[2]:
            print("No")
        else:
            if (aunique[0] ^ aunique[1]) ^ aunique[2] ==0:
                print("Yes")
            else:
                print("No")
    else:
        print("No")



main()

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

XOR=a[0]^a[1]
for i in range(2,N):
    XOR=XOR^a[i]
if XOR==0:
    print('Yes')
else:
    print('No')

Solution (Python):
import collections

YES="Yes"
NO="No"

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

c = collections.Counter(a)
l_c = len(c)
if l_c == 1:
    if c[0] == N:
        print(YES)
    else:
        print(NO)
elif l_c == 2:
    v = list(c.values())
    if min(v) * 2 == max(v):
        k = list(c.keys())
        k_few = k[v.index(min(v))]
        k_many = k[v.index(max(v))]
        if k_few ^ k_many == k_many:
            print(YES)
        else:
            print(NO)
    else:
        print(NO)
elif l_c == 3:
    v = list(c.values())
    if v[0] == v[1] == v[2]:
        k = list(c.keys())
        if k[0] == k[1] ^ k[2]:
            print(YES)
        else:
            print(NO)
    else:
        print(NO)
else:
    print(NO)

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

Solution (Python):
import numpy as np
n = int(input())
li = np.array(list(map(int, input().split())))

if np.count_nonzero(li) == 0:
    print("Yes")
elif len(li)%3 != 0:
    print("No")
else:
    li = sorted(li)
    li0 = li[:n//3]
    li1 = li[n//3:n//3*2]
    li2 = li[n//3*2:]
    if (li0 == li0[0]).all() and (li1 == li1[0]).all() and (li2 == li2[0]).all() and ((li0[0]^li1[0]) == li2[0] or (li0[0]^li1[0]) == li2[0] or (li0[0]^li1[0]) == li2[0]):
        print("Yes")
    else:
        print("No")

Solution (Python):
import sys
import collections


input = sys.stdin.readline


def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    c = collections.Counter(a)
    s = list(c.keys())
    v = list(c.values())
    if (len(c) == 3) and (s[0] == s[1] ^ s[2]) and (v[0] == v[1] == v[2]):
        print("Yes")
    elif len(c) == 1 and s[0] == 0:
        print("Yes")
    elif len(c) == 2 and 0 in s and (c[0] == n/3):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Solution (Python):
from collections import Counter


def solve(n, aaa):
    if all(a == 0 for a in aaa):
        return True

    if n % 3 != 0:
        return False

    cnt = Counter(aaa)
    if len(cnt) == 2:
        (a1, c1), (a2, c2) = cnt.most_common()
        if c1 != n * 2 // 3 or c2 != n // 3:
            return False
        return a2 == 0

    if len(cnt) == 3:
        if any(c != n // 3 for c in cnt.values()):
            return False
        a1, a2, a3 = cnt.keys()
        return a1 ^ a2 == a3

    return False


n = int(input())
aaa = list(map(int, input().split()))
print('Yes' if solve(n, aaa) else 'No')

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

res = "No"
a_set = list(set(a))

if len(a_set) == 3:
    if a_set[0] ^ a_set[1] == a_set[2]:
        if a.count(a_set[0]) == a.count(a_set[1]) and a.count(a_set[0]) == a.count(a_set[2]):
            res = "Yes"

if len(a_set) == 1:
    if a_set[0] == 0:
        res = "Yes"
if len(a_set) == 2:
    if 0 in a_set:
        if n%3 == 0 and a.count(0) == n/3:
            res = "Yes"
print(res)

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
a.sort()
a_kin=list(set(a))
if len(a_kin)==1 and a_kin[0]==0:
  print("Yes")
elif N%3!=0:
  print("No")
elif len(a_kin)==2 and a_kin[0]==0 and a[int(N/3)-1]==0 and a[int(N/3)]!=0:
  print("Yes")
elif len(a_kin)==3:
  if a_kin[0]^a_kin[1]^a_kin[2]==0:
    if a[0]==a[int(N/3)-1] and a[int(N/3)-1]!=a[int(N/3)] and a[int(N/3)]==a[int(2*N/3)-1] and a[int(2*N/3)-1]!=a[int(2*N/3)]:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  print("No")

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

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

ok = 1
if N % 3 != 0:
    if C.get(0, 0) != N:
        ok = 0
else:
    p = []
    K = N // 3
    for k, v in C.items():
        if v % K != 0:
            ok = 0
        for i in range(v // K):
            p.append(k)
    if ok:
        a, b, c = p
        if a ^ b != c:
            ok = 0
print("Yes" if ok else "No")

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

Solution (Python):
from collections import defaultdict
import sys

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N = read_int()[0]
a = read_int()
a.sort()

def solve():
    counts = defaultdict(lambda: int())
    keys = []
    for i in range(N):
        if counts[a[i]] == 0:
            keys.append(a[i])
        counts[a[i]] += 1
    if len(counts) == 1 and keys[0] == 0:
        return 'Yes'
    if len(counts) == 2:
        if counts[keys[0]] * 2 == counts[keys[1]] and check_xor(keys[1], keys[0], keys[1]):
            return "Yes"
        elif counts[keys[1]] * 2 == counts[keys[0]] and check_xor(keys[0], keys[1], keys[0]):
            return "Yes"
    if len(counts) == 3:
        if counts[keys[0]] == counts[keys[1]] == counts[keys[2]] and check_xor(*keys):
            return "Yes"
    return "No"

def check_xor(a, b, c):
    return a^c == b

if __name__ == "__main__":
    print(solve())

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

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
 
res = "No"
a_set = list(set(a))
 

 
if len(a_set) == 3:
    if a_set[0] ^ a_set[1] == a_set[2]:
        if a.count(a_set[0]) == a.count(a_set[1]) and a.count(a_set[0]) == a.count(a_set[2]):
            res = "Yes"
if len(a_set) == 1:
    if a_set[0] == 0:
        res = "Yes"
if len(a_set) == 2:
    if 0 in a_set:
        if N%3 == 0 and a.count(0) == N/3:
            res = "Yes"
print(res)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
b = set(a)
c = sorted(list(b))
if len(b)==1 and c[0]==0:
  print("Yes")
  exit()
elif n%3!=0:
  print("No")
  exit()
elif len(b)==2:
  if c[0]==0 and a.count(c[0])==n//3 and a.count(c[1])==(n//3)*2:
    print("Yes")
    exit()
elif len(b)==3:
  p, q, r = c[0], c[1], c[2]
  if p^q==r or q^r==p or r^p==q:
    if a.count(c[0])==n//3 and a.count(c[1])==n//3 and a.count(c[2])==n//3:
      print("Yes")
      exit()
print("No")

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

Solution (Python):
N=int(input())
a = list(map(int,input().split()))
s = set(a)
sl = list(s)
if len(s)==1:
    if sl[0]==0:
        print('Yes')
    else:
        print('No')
elif len(s)==2:
    if N%3==0:
        if sl[0]==0 or sl[1]==0:
            if a.count(0)==N/3:
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')
elif len(s)==3:
    if N%3==0:
        if sl[0]^sl[1]^sl[2]==0:
            if a.count(sl[0])==N/3 and a.count(sl[1])==N/3:
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Solution (Python):
n=int(input())
A=[int(i) for i in input().split()]
A.sort()
if n%3==0:
    n=int(n/3)
    if A[0]==A[n-1] and A[n]==A[2*n-1] and A[2*n]==A[3*n-1] and A[0]^A[n]^A[2*n]==0:
        ans=1
    else:
        ans=0
else:
    if(A[n-1]==0):
        ans=1
    else:
        ans=0
print("Yes" if ans==1 else "No")