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):
import collections

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

value, count = list(a.keys()), list(a.values())

if len(value)<3:
    if len(value)==1:
        if sum(a)==0:
            print('Yes')
        else:
            print('No')

    if len(value)==2:
        if 0 in value:
            if count[0]==N/3 or count[1]==N/3:
                print('Yes')
            else:
                print('No')

        else:
            print('No')

if len(value)>=3:
    if count[0]+count[1]+count[2] == N:
        if value[0]^value[1]^value[2] == 0:
            if count[0]==count[1]==count[2]:
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')

Solution (Python):
import sys
inputs = sys.stdin.readlines()

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

from collections import Counter

def all_zeros(a_list):
    return sum(a_list) == 0

def check(N, a_list):
    if all_zeros(a_list):
        print('Yes')
        return
    elif N % 3 == 0:
        x = N // 3
        if not all([v % x == 0 for v in Counter(a_list).values()]):
            print('No')
            return
        while not all_zeros(a_list):
            counter = Counter([a & 1 for a in a_list])
            if counter[0] == x or counter[0] == N:
                a_list = [a >> 1 for a in a_list]
            else:
                print('No')
                return
        print('Yes')
    else:
        print('No')

check(N, a_list)

Solution (Python):
from collections import Counter

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

if len(o) >=4:
    print('No')
    exit()
if len(o) == 3:
    if o[0][1]==o[1][1] and o[1][1] == o[2][1]:
        if o[0][0]^o[1][0] == o[2][0] and o[1][0]^o[2][0] == o[0][0] and o[2][0]^o[0][0] == o[1][0]:
            print('Yes')
            exit()
    print('No')
    exit()
if len(o) == 2:
    if n%3 == 0:
        if o[1][0] == 0 and o[1][1] == n//3:
            print('Yes')
            exit()
    print('No')
    exit()

if len(o) == 1:
    if o[0][0] == 0:
        print('Yes')
        exit()
    else:
        print('No')
        exit()

Solution (Python):
from collections import Counter

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

def solve():
    C = Counter(A)
    M = len(C)
    if M == 1 and 0 in C:
        return True
    elif M == 2:
        if 0 in C:
            b = 0
            for k, v in C.items():
                if k != 0:
                    b = v
            a = C[0]
            return (b == a * 2)
        else:
            return False
    elif M == 3:
        a, b, c = C.keys()
        if a ^ b == c or b ^ c == a or c ^ a == b:
            return (C[a] == C[b] == C[c])
        else:
            return False
    else:
        return False

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

Solution (Python):
N = int(input())
*A, = map(int, input().split())
setA = set(A)
if len(setA) == 3:
    a, b, c = list(setA)
    if a ^ c == b and a ^ b == c and b ^ c == a and A.count(a) == A.count(b) == A.count(c): print('Yes')
    else: print('No')
elif len(setA) <= 2:
    maxA = max(setA)
    if A.count(0) == A.count(maxA) or 2*A.count(0) == A.count(maxA): print('Yes')
    else: print('No')
else: print('No')

Solution (Python):

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


rtn = "Yes"

t = 0

for i,ai in enumerate(a):
    t ^= ai

if (t != 0):
    rtn = "No"

print(rtn)

Solution (Python):
n = int(input())
c = list(map(int, input().split()))
c.sort()
c_set = set(c)
set_list = list(c_set)
ans = 'No'


if c.count(0) == n:
    ans = 'Yes'
elif c[0] == 0:
    if n % 3 == 0 and len(c_set) == 2 and c.count(0) == int(n / 3):
        ans = 'Yes'
elif n == 3:
    if c[0] ^ c[1] == c[2]:
        ans = 'Yes'
else:
    if n % 3 == 0 and len(c_set) == 3:
        ank = int(n / 3)
        if c.count(c[0]) == ank and c.count(c[ank]) == ank and set_list[0] ^ set_list[1] == set_list[2]:
            ans = 'Yes'

print(ans)

Solution (Python):
import collections


N = int(input())
a = list(map(int, input().split()))
C = collections.Counter(a)
L = len(C)
e = list(C.keys())
print(
    (
        ((L == 1) and (C[0] > 0))
        or ((L == 2) and (C[0] > 0) and (C[e[0]] * 2 == C[e[1]]))
        or ((L == 3) and (C[e[0]] == C[e[1]] == C[e[2]]) and ((e[0] ^ e[1]) == e[2]))
    )
    and "Yes"
    or "No"
)

Solution (Python):
import collections 

n = int(input())
input_list = [int(i) for i in input().split(' ')]

counter = collections.Counter(input_list)


unique_list = list(counter.keys())
counts = list(counter.values())

if (all(num == 0 for num in unique_list)):
    print('Yes')
else:
    if n % 3 == 0:
        zero_count = counter[0] 
        if zero_count == n / 3 and len(unique_list) == 2:
            print('Yes')
        else: 
            if len(unique_list) != 3:
                print('No')
            elif (unique_list[0] ^ unique_list[1] == unique_list[2]):
                if (all(counts[0] == num for num in counts)):
                    print('Yes')
                else:
                    print('No')
            else:
                print('No')
    else:
        print('No')

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
a_uni = list(set(a))
if len(a_uni) == 1:
	if a[0] == 0:
		print("Yes")
	else:
		print("No")
elif n%3 != 0:
	print("No")
elif len(a_uni) == 2:
	if a.count(0) == n/3:
		print("Yes")	
	else:
		print("No")	
elif len(a_uni) == 3:
	if a_uni[0]^a_uni[1]!=a_uni[2]:
		print("No")
	elif a.count(a_uni[0])==n/3 and a.count(a_uni[1])==n/3:
		print("Yes")
	else:
		print("No")
else:
	print("No")

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

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

f = True
for i in range(N):
    if a[i] == sums ^ a[i]:
        pass
    else:
        f = False

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

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = inp()
aa = inpl()
aa.sort()

def product():
    if N%3 == 0:
        ax = aa[0:N//3]
        bx = aa[N//3:N//3*2]
        cx = aa[N//3*2:]
        if len(set(ax)) != 1:
            return 'No'
        if len(set(bx)) != 1:
            return 'No'
        if len(set(cx)) != 1:
            return 'No'
        if ax[0]^bx[0] != cx[0]:
            return 'No'
        if bx[0]^cx[0] != ax[0]:
            return 'No'
        if cx[0]^ax[0] != bx[0]:
            return 'No'
        return 'Yes'

    else:
        for a in aa:
            if a != aa[0]:
                return 'No'
        return 'Yes'



print(product())

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

Solution (Python):
m=int(input())//3;a=sorted(map(int,input().split()));print('YNeos'[(a[0],a[m],a[-m])!=(a[m-1],a[-m-1],a[-1])or a[0]^a[m]!=a[-m]::2])

Solution (Python):
import collections


N = int(input())
a = list(map(int, input().split()))
C = collections.Counter(a)
L = len(C)
e = list(C.keys())
if (L == 1) and (C[0] > 0):
    print("Yes")
elif (L == 2) and (C[0] > 0) and (C[e[0]] * 2 == C[e[1]]):
    print("Yes")
elif (L == 3) and (C[e[0]] == C[e[1]] == C[e[2]]) and ((e[0] ^ e[1]) == e[2]):
    print("Yes")
else:
    print("No")

Solution (Python):

import numpy as np





N = int(input())
s = input()
a = np.asarray(s.split(), dtype=int)



d = {}
for val  in a:
    if val in d.keys():
        d[val] += 1
    else:
        d[val] = 1

keyNum = len(d.keys())
num = len(a)
keys = list(d.keys())


if len(d.keys()) == 1 and 0 in d.keys():
    print ("Yes")
elif len(a) % 3 != 0:
    print ("No")
elif keyNum == 2:
    keys.sort()
    if keys[0] != 0:
        print ("No")
    elif d[0] != num//3:
        print ("No")
    else:
        print ("Yes")











elif keyNum != 3:
    print ("No")

else:
    if d[keys[0]] != num//3:
        print ("No")
    elif d[keys[1]] != num//3:
        print ("No")
    elif d[keys[2]] != num//3:
        print ("No")
    else:
        key1 = format(keys[0],'099b')
        key2 = format(keys[1],'099b')
        key3 = format(keys[2],'099b')
        isA = True
        for k1,k2,k3 in zip(key1,key2,key3):
            kk1 = int(k1)
            kk2 = int(k2)
            kk3 = int(k3)
            goukei = kk1 + kk2 + kk3
            if not (goukei == 0 or goukei == 2):
                isA = False
                break
        
        if isA:
            print ("Yes")
        else:
            print ("No")

Solution (Python):
m=int(input())//3
a=sorted(map(int,input().split()))
print('YNeos'[(a[0],a[m],a[-m])!=(a[m-1],a[-m-1],a[-1]) or a[0]^a[m]!=a[-m]::2])

Solution (Python):
import sys,itertools,copy
input = sys.stdin.readline
N=int(input().strip())
an=[int(x) for x in input().strip().split()]

if N==3:
    if an[0]^an[1]==an[2]:
        print("Yes")
    else:
        print("No")
elif N%3!=0:
    if len(set(an))==1:
        print("Yes")
    else:
        print("No")
else:
    bn = list(set(an))
    if len(bn)>3:
        print("No")
    elif len(bn)==1:
        if bn[0]==0:
            print("Yes")
        else:
            print("No")
    elif len(bn)==2:
        if an.count(0)==(N/3):
            print("Yes")
        else:
            print("No")
    elif bn[0]^bn[1]!=bn[2]:
        print("No")
    else:
        for b in bn:
            if an.count(b)!=(N/3):
                print("No")
                break
        else:
            print("Yes")

Solution (Python):
a=int(input())
b=list(map(int, input().split()))
c=list(set(b))
t=0
d=[0 for i in range(len(c))]
if a==1:
  print("Yes")
else:
  if len(c)==1:
    if c[0]==0:
      print("Yes")
    else:
      print("No")
  elif len(c)==2:
    for i in range(len(c)):
      e=c[i]
      d[i]=b.count(e)
    if (c[0]==0 and d[0]*2==d[1])or (c[1]==0 and d[1]*2==d[0]):
      print("Yes")
    else:
      print("No")
  elif len(c)>3:
    print("No")
  else:  
    for i in range(len(c)):
      e=c[i]
      d[i]=b.count(e)
    if d[0]==d[1]and d[0]==d[2] and c[0]==c[1]^c[2]:
      print("Yes")
    else:
      print("No")

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

Solution (Python):
n=int(input())
a=sorted(map(int,input().split()))
m=n//3
print('YNeos'[(a[0],a[m],a[-m])!=(a[m-1],a[-m-1],a[-1]) or a[0]^a[m]!=a[-m]::2])

Solution (Python):
from sys import stdin
from collections import defaultdict
def main():
    n = int(stdin.readline())
    a = map(int, stdin.readline().split())
    d = defaultdict(int)
    for x in a:
        d[x] += 1
    s = d.keys()
    if len(s) == 1:
        print 'Yes' if s[0] == 0 else 'No'
    elif len(s) == 2:
        print 'Yes' if (0 in s and (d[s[0]] == d[s[1]] or n % 3 == 0 and d[0] == n / 3)) else 'No'
    elif len(s) == 3:
        print 'Yes' if (s[0] ^ s[1] ^ s[2] == 0 and d[s[0]] == d[s[1]] == d[s[2]]) else 'No'
    else:
        print 'No'
main()

Solution (Python):
from collections import Counter
from functools import reduce

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

count = Counter((a))
len_count = len(count)

if len_count >= 4:
    print("No")
elif len_count == 1:
    if a[0] == 0:
        print("Yes")
    else:
        print("No")
elif len_count == 3:
    count_count = Counter(count.values())
    if len(count_count) == 1 and reduce(lambda x, y: x ^ y, count.keys()) == 0:
        print("Yes")
    else:
        print("No")
else:
    if count[0] * 3 == len(a):
        print("Yes")
    else:
        print("No")

Solution (Python):
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
ans = "No"
Co = Counter(A)
if n % 3 != 0 : 
    if len(Co.keys()) == 1 and list(Co.keys())[0] == 0:
        ans = "Yes" 
else :
    tr = n // 3
    Va = Co.values()
    if len(Va) == 3 :
        if Co.most_common()[0][1] == Co.most_common()[1][1] == Co.most_common()[2][1] == tr:
            a,b,c = Co.most_common()[0][0],Co.most_common()[1][0],Co.most_common()[2][0]
            if a^b==c and b^c==a and c^a==b:
                ans = "Yes"
    elif len(Va) == 2 and Co.most_common()[0][1] == 2 * tr :
        a, b = Co.most_common()[0][0], Co.most_common()[1][0]
        if a^b==a and a^a==b:
            ans = "Yes"
    elif len(Va) == 1 and Co.most_common()[0][0] == 0 :
        ans = "Yes"
print(ans)

Solution (Python):
import collections

N = int(input())
a = list(map(int, input().split()))
C = collections.Counter(a)
L = len(C)
e = list(C.keys())
if (L == 1) and (C[0] > 0):
    print("Yes")
elif (L == 2) and (C[e[0]] * 2 == C[e[1]]):
    print(((e[0] ^ e[0] == e[1]) or (e[1] ^ e[1] == e[0])) and "Yes" or "No")
elif (L == 3) and (C[e[0]] == C[e[1]]) and (C[e[1]] == C[e[2]]):
    print(((e[0] ^ e[1]) == e[2]) and "Yes" or "No")
else:
    print("No")

Solution (Python):
from collections import Counter

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

c = Counter(A)
K = c.keys()

ans = "No"
if len(K)==3:
    B = []
    for k in K:
        B.append(k)
    if c[B[0]]==c[B[1]] and c[B[1]]==c[B[2]] and B[0]^B[1]==B[2]:
        ans = "Yes"
elif len(K)==2:
    B = []
    for k in K:
        B.append(k)
    if (c[B[0]]==2*c[B[1]] or c[B[1]]==2*c[B[0]]) and (B[0]==0 or B[1]==0):
        ans = "Yes"
elif sum(A)==0:
    ans = "Yes"

print(ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
aa=set(a)
if len(aa)>3:
    print("No")
    exit()
elif a.count(0)==n:
    print("Yes")
    exit()
elif len(aa)<=1:
    print("No")
    exit()
l=[]
l.append(a[0])
for i in range(1,n):
    if a[i]!=a[0]:
        l.append(a[i])
        break
l.append(l[0]^l[1])

if n==0:
    exit()
else:
    if len(aa)==2:
        if n%3==0:
            if (a.count(l[0])==(n//3)*2 and a.count(l[1])==n//3) or (a.count(l[1])==(n//3)*2 and a.count(l[0])==n//3):
                print("Yes")
            else:
                print("No")
        elif n%3==1:
            if (a.count(l[0])==(n//3)*2+1 and a.count(l[1])==n//3) or (a.count(l[1])==(n//3)*2 and a.count(l[0])==n//3+1):
                print("Yes")
            else:
                print("No")
        elif n%3==2:
            if (a.count(l[0])==(n//3)*2+1 and a.count(l[1])==n//3+1) or (a.count(l[1])==(n//3)*2+1 and a.count(l[0])==n//3+1):
                print("Yes")
            else:
                print("No")


    else:
        if n%3==0:
            if a.count(l[0])==n//3 and a.count(l[1])==n//3 and a.count(l[2])==n//3:
                print("Yes")
            else:
                print("No")
        else:
            print("No")

Solution (Python):
n=int(input())
a=sorted([int(i) for i in input().split()])
m=n//3
print('YNeos'[(a[0],a[m],a[-m])!=(a[m-1],a[-m-1],a[-1]) or a[0]^a[m]!=a[-m]::2])

Solution (Python):
import collections

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

C = collections.Counter(a)
L = len(C)
e = list(C.keys())
if (L == 1) and (C[0] > 0):
    print("Yes")
elif (L == 2) and (C[e[0]] * 2 == C[e[1]]):
    print(((e[0] ^ e[0] == e[1]) or (e[1] ^ e[1] == e[0])) and "Yes" or "No")
elif (L == 3) and (C[e[0]] == C[e[1]]) and (C[e[1]] == C[e[2]]):
    print(((e[0] ^ e[1]) == e[2]) and "Yes" or "No")
else:
    print("No")

Solution (Python):
import numpy as np

n = int(input())
arr = list(map(int,input().split()))
d = {}

for a in arr:
    if a not in d:
        d[a] = 1
    else:
        d[a] += 1


if len(d) == 1:
    if 0 in d:
        print("Yes")
    else:
        print("No")
elif len(d) == 2:
    if n%3 != 0:
        print("No")
    elif 0 in d:
        flag = True
        for key in d.keys():
            if key == 0:
                if not d[key] == n//3:
                    flag = False
            else:
                if not d[key] == 2*n//3:
                    flag=False
        if flag:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

elif len(d) != 3:
    print("No")

else:
    if n % 3 != 0:
        print("No")
    elif 0 in d:
        print("No")
    else:
        tartar = [0,0,0]
        num = [0,0,0]
        temp = 0
        for key in d.keys():
            tartar[temp] = key
            num[temp] = d[key]
            temp+=1
        if not (num[0] == num[1] and num[1] == num[2]):
            print("No")
        else:
            tar2 = [
                [tartar[0], tartar[1], tartar[2]],
                [tartar[0], tartar[2], tartar[1]],
                [tartar[1], tartar[0], tartar[2]],
                [tartar[1], tartar[2], tartar[0]],
                [tartar[2], tartar[1], tartar[0]],
                [tartar[2], tartar[0], tartar[1]],

            ]
            flag = False
            for tar in tar2:
                x1 = tar[0]^tar[2]
                x2 = tar[0]^tar[1]
                x3 = tar[1]^tar[2]

                if x1 == tar[1] and x2 == tar[2] and x3 == tar[0]:
                    flag = True
            if flag:
                print("Yes")
            else:
                print("No")

Solution (Python):
from sys import stdin
N = int(stdin.readline().rstrip())
data = [int(x) for x in stdin.readline().rstrip().split()]
flag = True
syugo = set(sorted(data))
if len(syugo) == 1:
    syugo = list(syugo)
    if syugo[0] != 0:
        flag = False

elif len(syugo) == 2:
    syugo = list(syugo)
    if syugo[0] != 0:
        flag = False
    if data.count(syugo[1]) != data.count(0)*2:
        flag = False
        
elif len(set(data)) == 3:
    syugo = list(syugo)
    if syugo[0]^syugo[1] != syugo[2]:
        flag = False
    if len(set([data.count(i) for i in syugo])) != 1:
        flag = False
else:
    flag = False

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

Solution (Python):
from collections import Counter
N=int(input())
A=list(map(int,input().split()))
A=Counter(A).most_common()
A.sort(key=lambda x:x[0])
flag=1
if len(A)==3:
    for i in range(2):
        if A[i][1]==A[i+1][1]:
            continue
        else:
            flag=0
    for i in range(2):
        if i==0 :
            if A[i][0]==(A[i+1][0]^A[-1][0]):
                continue
            else:
                flag=0
        elif i==2:
            if A[i][0]==(A[i-1][0]^A[0][0]):
                continue
            else:
                flag=0
        else:
            if A[i][0]==(A[i-1][0]^A[i+1][0]):
                continue
            else:
                flag=0
    if flag==1:
        print("Yes")
    else:
        print("No")
else:
    if A[0][0]==0:
        if len(A)==1 or (len(A)==2 and A[0][1]==A[1][1]//2):
            print("Yes")
        else:
            print("No")
    else:
        print("No")

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

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

for i in range(a):
    if b[i] not in c:
        c.setdefault(b[i], 1)
    else:
        c[b[i]] += 1

if len(c) == 3:
    f = list(c.values())
    for i in range(1, len(f)):
        if f[i] != f[i-1]:
            print("No")
            exit()
    g = list(c.keys())
    if g[0] ^ g[1] == g[2]:
        print("Yes")
    else:
        print("No")
elif len(c) == 2:
    f = list(c.values())
    if f[0] != f[1]*2 and f[0]*2 != f[1]:
        print("No")
        exit()
    g = list(c.keys())
    if g[0] == 0 or g[1] == 0:
        print("Yes")
    else:
        print("No")
elif len(c) == 1:
    g = list(c.keys())
    if g[0] == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")
    exit()

Solution (Python):
n = int(input())
l = list(map(int,input().split()))
j = 0
u = []
v = [0]*4
for i in l:
    if not i in u :
        u.append(i)
    v[u.index(i)] += 1
    if len(u) > 3:
        break

if len(u) == 3:
    if ((n%3 == 0) and (u[0] ^ u[2] == u[1]) and (v[0] == v[1] and v[1] == v[2]) and not len(u) > 3 and not 0 in u):
        j = 1
elif len(u) == 2:
    if 0 in u:
        if u[0] == 0 :
            b = u[1]
        else :
            b = u[0]
        if v[u.index(0)] * 2 == v[u.index(b)]:
            j = 1
if len(u) == 1:
    if u[0] == 0:
        j = 1

if j == 1 :
    print("Yes")
else :
    print("No")


"""01
10
11
01
10
11

01
00
01
01
00
01
"""

Solution (Python):
import itertools
N=int(input())
an=[int(x) for x in map(int,input().split()[:N])]

ret=an[0]
for x in range(1,N):
    ret= an[x] ^ ret

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

Solution (Python):
import sys

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

l = a[0]
m = -1
n = -1
o = -1

for i in range(1,N):
    if a[i] != l and m == -1:
        m = a[i]
    elif a[i] != l and a[i] != m and n == -1 :
        n = a[i]
    elif a[i] != l and a[i] != m and a[i] != n and o == -1:
        print("No")
        sys.exit()

if (m == -1 and n == -1) and l^l == l and a.count(l) == N:
    print("Yes")
elif n == -1 and a.count(l)+a.count(m) == N and ( (a.count(l)*2==a.count(m) and l^m==m) or (a.count(l)==a.count(m)*2 and l^m == l)):
    print("Yes")
elif a.count(l)+a.count(m)+a.count(n) == N and a.count(l) == a.count(m) and a.count(m) == a.count(n) and l^m==n:
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
a=sorted([int(i) for i in input().split()])
m,k=n//3,0
for i in range(n):
  d=i%3*m+i//3
  if a[d]^a[(d+2*m)%n]!=a[(d+m)%n]:
    k=1
print('YNeos'[k::2])

Solution (Python):
def equal_list(lst1, lst2):
    lst = lst1.copy()
    for element in lst2:
        try:
            lst.remove(element)
        except ValueError:
            break
    else:
        if not lst:
            return True
    return False


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

if a == [0]*N:
    print("Yes")
    exit()

if N % 3 == 0:
    n = N // 3
    sets = list(set(a))
    order = max(a).bit_length()
    if len(sets) == 3:
        for s in sets:
            if a.count(s) != n:
                print("No")
                exit()

        for i in range(order):
            b = [sets[0] >> i & 1, sets[1] >> i & 1, sets[2] >> i & 1]
            if b == [0, 0, 0]:
                continue
            if not equal_list(b, [0, 1, 1]):
                print("No")
                exit()
    elif len(sets) == 2:
        if a.count(sets[0]) == n:
            for i in range(order):
                b = [sets[0] >> i & 1, sets[1] >> i & 1]
                if b == [0, 0]:
                    continue
                if b != [0, 1]:
                    print("No")
                    exit()
        elif a.count(sets[1]) == n:
            for i in range(order):
                b = [sets[0] >> i & 1, sets[1] >> i & 1]
                if b == [0, 0]:
                    continue
                if b != [1, 0]:
                    print("No")
                    exit()
        else:
            print("No")
            exit()
    else:
        print("No")
        exit()

    print("Yes")

else:
    print("No")
    exit()

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

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

a_unique = list(set(a))

if n == 3:
    if a_unique[0]^a_unique[1] == a_unique[2]:
        result = True
    
elif len(a_unique) == 3:
    if a_unique[0]^a_unique[1] == a_unique[2]: 
        if a.count(a_unique[0]) == a.count(a_unique[1]) and a.count(a_unique[1]) == a.count(a_unique[2]):
            result = True

elif len(a_unique) == 1:
    if a_unique[0]^a_unique[0] == a_unique[0]:
        result = True

elif len(a_unique) == 2:
    if a_unique.count(a_unique[0]) == 1:
        if a_unique[0]^a_unique[1] == a_unique[1]:
            if a_unique[1]^a_unique[1] == a_unique[0]:
                if a.count(a_unique[0])*2 == a.count(a_unique[1]):
                    result = True
    elif  a_unique.count(a_unique[1]) == 1:
        if a_unique[0]^a_unique[1] == a_unique[0]:
            if a_unique[0]^a_unique[0] == a_unique[1]:
                if a.count(a_unique[1])*2 == a.count(a_unique[0]):
                    result = True

if len(a_unique) > 3:
    result = False    
            
if result:
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
a=sorted([int(i) for i in input().split()])
m,k=n//3,0
for i in range(n):
  d=i%3*m+i//3
  if a[d]^a[(d+2*m)%n]!=a[(d+m)%n]:
    k=1
print(['Yes','No'][k])

Solution (Python):
n=int(input())
a=sorted([int(i) for i in input().split()])
m,k=n//3,0
for i in range(n):
    d=i%3*m+i//3
    if a[d]^a[(d+2*m)%n]!=a[(d+m)%n]:
        k=1
print(['Yes','No'][k])

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

Solution (Python):
from math import log2, floor
from operator import or_
from functools import reduce

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

if max(a) == 0 :
    bl = [0]
else :
    bl = [0 for _ in range(floor(log2(max(a)))+1)]
for ai in a :
    aj = ai
    if ai == 0 :
        pass
    else :
        for i in range(floor(log2(ai))+1) :
            if aj & 1 == 1 :
                bl[i] += 1
            aj >>= 1

ans = reduce(or_, map(lambda x : x&1, bl))
if ans :
    print("No")
else :
    print("Yes")

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
import collections
c=dict(collections.Counter(l))
d=list(c.values())
e=list(c.keys())
if len(d)==3:
    d.sort()
    e.sort()
    if d[0]==d[1]==d[2] and e[0]^e[2]==e[1]:
        print("Yes")
    else:
        print("No")
elif len(d)==2:
    d.sort()
    e.sort()
    if d[0]==d[1] and e[0]==0:
        print("Yes")
    elif d[0]*2==d[1] and e[0]==0 and c.get(0,-1)==d[0]:
        print("Yes")
    else:
        print("No")
elif len(d)==1 and e[0]==0:
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np
import cmath
N = input()
N = int(N)

nu = input().split()
nui = [int(s) for s in nu]
nus = set(nui)
nul = list(nus)
if((len(nul)==1) and (nul[0]==0)):
    print("Yes")
else:
    if(N%3==0):
        if(len(nul)==2):
            if(nul[0] < nul[1]):
                a = nul[0]
                b = nul[1]
            else:
                a = nul[1]
                b = nul[0]
            a_c = nui.count(a)
            b_c = nui.count(b)
            if(a_c*2 == b_c):
                print("Yes")
            else:
                print("No")

        elif(len(nul)==3):
            a = nul[0]
            b = nul[1]
            c = nul[2]
            a_c = nui.count(a)
            b_c = nui.count(b)
            c_c = nui.count(c)
            if((a_c == b_c) and (b_c==c_c)):
                a_s = list(format(a,"040b"))
                b_s = list(format(b,"040b"))
                c_s = list(format(c,"040b"))
                
                a_si = [int(s) for s in a_s]
                b_si = [int(s) for s in b_s]
                c_si = [int(s) for s in c_s]
                
                a_np = np.array(a_si)
                b_np = np.array(b_si)
                c_np = np.array(c_si)
                
                sumnp = a_np + b_np + c_np
                
                amari = sumnp%2
                
                ind = np.where(amari==1)
                
                if(len(ind[0])==0):
                    print("Yes")
                else:
                    print("No")
            else:
                print("No")
        else:
            print("No")
    else:
        print("No")

Solution (Python):

import collections
 
n = int(input())
a_list = list(map(int,input().split()))
 
c = collections.Counter(a_list)
 

ans_list = list(c.keys())
count_list = list(c.values())
 

if len(c.keys()) == 1:
    if list(c.keys()) == [0]:
        print("Yes")
        quit()
    else:
        print("No")
        quit()
elif len(c.keys()) == 2:
    if ans_list[0] == ans_list[0]^ans_list[1] and count_list[0]== 2*count_list[1]:
        print("Yes")
        quit()
    elif ans_list[1] == ans_list[0]^ans_list[1] and count_list[1]== 2*count_list[0]:
        print("Yes")
        quit()
    else:
        print("No")
        quit()
        
if len(c.keys()) != 3:
    print("No")
    quit()

count_list.sort()
if ans_list[0] == ans_list[1] ^ ans_list[2]:
    if count_list[0]==count_list[1]==count_list[2]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
from collections import Counter
n = int(input())
l = list(map(int, input().split()))
cnt = Counter(l)
res = len(cnt) == 1 and 0 in cnt
if not res and n % 3 == 0:
    if len(cnt) == 3 and all(v == n // 3 for v in cnt.values()):
        x = sorted(cnt.keys())
        res = x[0] ^ x[2] == x[1]
    if len(cnt) == 2 and cnt.get(0, 0) == n // 3:
        res = True
print("Yes" if res else "No")