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(int(i) for i in input().split())
chk = sum(a)
if a == [0] *N:
	print("Yes")
else:
	if N == 3:
			if (a[0]^a[1]) == a[2]:
				print("Yes")
			else:
				print("No")
	else:
		l = collections.Counter(a)
		if a.count(0) == 0:
			if list(l.values()) ==  [list(l.values())[0]] * len(l.values()) and len(l.keys()) == 3:
				if ((list(l.keys())[0])^(list(l.keys())[1])) == list(l.keys())[2]:
					print("Yes")
				else:
					print("No")
			else:
				print("No")
		else:
			if len(l.values()) == 2 and a.count(0) == N//3:
				print("Yes")
			else:
				print("No")

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

Solution (Python):
def f(n,aa):
    if sum(aa)==0:
        return "Yes"
    if n%3>0:
        return "No"
    sa=set(aa)
    if len(sa)>3 or len(sa)<2:
        return "No"
    n3 = n / 3
    if len(sa)==3:
        for sak in sa:
            if aa.count(sak)!=n3:
                return "No"
        sa = list(sa)
    elif len(sa)==2:
        for sak in sa:
            if sak!=0:
                k=sak
        if 0 not in sa:
            return "No"
        if aa.count(0)!=n3:
            return "No"
        if aa.count(k)!=n3*2:
            return "No"
        sa=[0,k,k]

    for i in range(3):
        if sa[i - 1] != sa[i - 2] ^ sa[i]:
            break
    else:
        return "Yes"
    return "No"

n=int(input())
aa=list(map(int,input().split()))
print(f(n,aa))

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

def mae(N, a):
    sum = a[0]
    for i in range(1, N):
        sum ^= a[i]
    return sum

if mae(N, a) == 0:
    print("Yes")
else:
    print("No")

Solution (Python):

N=int(input())
a=list(map(int,input().split()))
seta=set(a)
lista=list(seta)
if len(a)==a.count(0):
    print("Yes")
elif len(set(a))>4:
    print("No")        
elif N%3!=0:
    print("No")
elif len(seta)==3:
    if a.count(lista[0])==a.count(lista[1])==a.count(lista[2]) and \
        lista[0]^lista[1]==lista[2]:
        print("Yes")
    else:
        print("No")
elif len(seta)==2:
    if a.count(lista[0])*2==a.count(lista[1]) and \
        lista[1]^lista[1]==lista[0]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
def resolve():
    n = int(input())
    aa = list(map(int, input().split()))

    if min(aa) == max(aa) == 0:
        flg = True
    else:
        flg = len(aa) % 3 == 0

        aa.sort()

        if flg:
            flg = aa[0]            == aa[len(aa)//3  -1] \
              and aa[len(aa)//3]   == aa[len(aa)//3*2-1] \
              and aa[len(aa)//3*2] == aa[len(aa)     -1]

        tmp1 = aa[0]
        tmp2 = aa[len(aa)//3]
        tmp3 = aa[len(aa)-1]

        if flg:
            flg = tmp1 == tmp2 ^ tmp3 and tmp2 == tmp1 ^ tmp3 and tmp3 == tmp1 ^ tmp2

    print('Yes' if flg else 'No')
    
resolve()

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
  A[i] = bin(A[i])
max_len = len(A[N-1]) - 2
for i in range(N):
  A[i] = A[i][2:].zfill(max_len)
check = True
for i in range(max_len):
  count0 = 0
  count1 = 0
  for j in range(N):
    if(A[j][i] == '0'):
      count0 += 1
    else:
      count1 += 1
  if(count1 == 0):
    continue
  elif(count1 == count0 * 2):
    continue
  else:
    check = False
    break
if(check):
  print('Yes')
else:
  print('No')

Solution (Python):

from collections import defaultdict, deque
import math
from math import factorial
import fractions
import re

BIGNUM = 10 ** 9 + 7

def convtobit(x):
    b = bin(x)
    bits = list(map(int, b[2:]))
    bits = [0] * (32 - len(bits)) + bits
    return tuple(bits)

def minus(x, y):
    b = []
    for xb, yb in zip(x, y):
        bit = 1 if xb != yb else 0
        b.append(bit)
    return tuple(b)

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

    
    Adict = defaultdict(int)
    for a in As:
        b = convtobit(a)
        Adict[b] += 1

    assert convtobit(2) == tuple([0]*30 + [1, 0])
    assert convtobit(7) == tuple([0]*29 + [1, 1, 1])

    if len(Adict) > 3:
        print("No")
        return

    for first in Adict:
        for second in Adict:
            third = minus(first, second)
            if not third in Adict:
                continue
            forth = minus(second, third)
            if forth != first:
                continue

            if N % 3 == 0:
                adict = dict(Adict)
                for elem in [first, second, third]:
                    adict[elem] -= N // 3
                if all([adict[elem] == 0 for elem in [first, second, third]]):
                    print("Yes")
                    return

            if N % 3 == 1:
                adict = dict(Adict)
                for elem in [first, second, third]:
                    adict[elem] -= (N - 1) // 3
                adict[first] -= 1
                if all([adict[elem] == 0 for elem in [first, second, third]]):
                    print("Yes")
                    return

            if N % 3 == 2:
                adict = dict(Adict)
                for elem in [first, second, third]:
                    adict[elem] -= (N - 2) // 3
                adict[first] -= 1
                adict[second] -= 1
                if all([adict[elem] == 0 for elem in [first, second, third]]):
                    print("Yes")
                    return

    print("No")

if __name__ == '__main__':
    main()

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

Solution (Python):
def resolve():
    n = int(input())
    a = list(map(int,input().split()))
    sa = list(set(a))
    num = {}

    if sum(sa)==0:
        print("Yes")
        exit(0)
    if (n%3)!=0:
        print("No")
        exit(0)
    for i in a:
        num[i] = num.get(i,0) + 1
    
    OK = False
    if len(num)==3:
        i,j,k = num.values()
        if i==j and j==k and sa[0]==(sa[1]^sa[2]):
            OK = True
    elif len(num)==2:
        i,k = num.keys()
        j,l = num.values()
        if i==0 and j*2==l:
            OK = True
        elif k==0 and l*2==j:
            OK = True
    if(OK):
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    resolve()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
if n % 3 == 0:
    d = {}
    for x in a:
        d.setdefault(x, 0)
        d[x] += 1
    if len(d) > 3 or any([d[x] % (n//3) for x in d]):
        print("No")
        quit()
    if len(d) == 1 and 0 not in d:
        print("No")
        quit()
    if len(d) == 2 and d.get(0) != n//3:
        print("No")
        quit()
    if len(d) == 3:
        b = [x for x in d]
        if b[0]^b[1] != b[2] or b[1]^b[2] != b[0] or b[0]^b[2] != b[1]:
            print("No")
            quit()
    print("Yes")
else:
    print("Yes" if all([x == 0 for x in a]) else "No")

Solution (Python):
n = int(input().strip())
hat =  list(map(int,input().split()))
xor_sum = hat[0]
for x in hat[1:n]:
    xor_sum = xor_sum ^ x
                
if xor_sum == 0:
    print('Yes')
else:
    print('No')

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

cnt = [1, 1, 1]
ind = 0
b = []
t = False

for i in range(n):
    if (a[i] != 0):
        break
    if i == n - 1:
        t = True

if t == True:
    print('Yes')
elif n % 3 != 0:
    print('No')
else:
    a.sort()
    if a[0] != 0:
        b.append(a[0])
        for i in range(n - 1):
            if a[i] == a[i + 1]:
                cnt[ind] += 1
            else:
                ind += 1
                if ind > 2:
                    break
                b.append(a[i + 1])
        if (ind == 2) and (cnt[0] == n // 3) and (cnt[1] == n // 3) and (cnt[2] == n // 3):
            if (b[0] ^ b[1] == b[2]):
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    else:
        for i in range(n - 1):
            if a[i] == a[i + 1]:
                cnt[ind] += 1
            else:
                ind += 1
                if ind > 1:
                    break
        if (ind == 1) and (cnt[0] == n // 3) and (cnt[1] == 2 * (n // 3)):
            print('Yes')
        else:
            print('No')

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
sum=0
realsum=0
if N%3!=0:
    for j in a:
        realsum+=j
    if realsum==0:
        print('Yes')
    else:
        print('No')
else:
    for i in a:
        sum=sum^i
    if sum==0:
        print('Yes')
    else:
        print('No')

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

q = n // 3 
r = n % 3

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

res = "No"

if len(dic) == 1:
    if a[0] == 0:
        res = "Yes"
elif len(dic) == 2:
    x,y = tuple(dic.keys())
    if (x == 0 or y == 0) and r == 0:
        if x == 0:
            x = y
        if dic[x] == 2 * q and dic[0] == q:
            res = "Yes"
elif len(dic) == 3:
    x,y,z = tuple(dic.keys())
    if x ^ y == z:
        count1 = 0
        count2 = 0
        for i in (x,y,z):
            if dic[i] == q:
                count1 += 1
            elif dic[i] == q + 1:
                count2 += 1
        if count1 == 3 - r and count2 == r:
            res = "Yes"
print(res)

Solution (Python):


n=int(input())
s=list(map(int,input().split()))
a=bin(s[0]^s[1])

ans=bin(s[0])


i=1
while i!=n:
    ans=int(ans,2)
    ans=bin(ans^s[i])
    i+=1

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

Solution (Python):
R = lambda: map(int, input().split())

n = int(input())
if n % 3:
    ans = 'YNeos'[any(R())::2]
else:
    a = sorted(map(int, input().split()))
    m = n // 3
    if a[0] ^ a[m] ^ a[2 * m]:
        ans = 'No'
    elif any(len(set(a[i:i + m])) > 1 for i in range(0, n, m)):
        ans = 'No'
    else:
        ans = 'Yes'
print(ans)

Solution (Python):
import collections



def XORC(a,b,p):
    for i in range(len(a)):
        if (int(a[i])+int(b[i]))%2 == int(p[i]):
            continue
        else:
            return False
        
    return True
            
def Solve():
    N=int(input())
    AL=[("0"*34+bin(int(x))[2:])[-33:] for x in input().split()]

    ALC=collections.Counter(AL)

    keys=list(ALC.keys())
    vals=list(ALC.values())

    if len(keys)>3:
        return 'No'
    if len(keys)==1:
        if "1" in keys[0]:
            return 'No'
        return 'Yes'
    
    if len(keys)==2:
        if "1" in keys[0] and "1" in keys[1]:
            return 'No'

        if vals[0]*2==vals[1] and ("1" not in keys[0]):
            return 'Yes'
        
        if vals[0]==vals[1]*2 and ("1" not in keys[1]):
            return 'Yes'
        
        return 'No'
    if len(keys)==3:
        if vals[0]==vals[1]==vals[2]:
            if XORC(keys[0],keys[1],keys[2]) and XORC(keys[0],keys[2],keys[1]) and XORC(keys[1],keys[2],keys[0]):
                return 'Yes'
        
        return 'No'
print(Solve())

Solution (Python):
N = int(input())
A = [int(a) for a in input().split()]
c = N-1
A.sort()
num = A[0]^A[c]
pre_num = A[c]
B = [A[0],A[c],num]
while len(B) < N:
    box = num
    num = num^pre_num
    pre_num = box
    B.append(num)
B.sort()
if A == B:
    print("Yes")
else:
    print("No")

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

if len(seta) == 3 and a.count(seta[0]) == a.count(seta[1]) and a.count(seta[1]) == a.count(seta[2]) and a.count(seta[2]) == a.count(seta[0]):
  if seta[0]^seta[1] == seta[2] and seta[1]^seta[2] == seta[0] and seta[0]^seta[2] == seta[1]:
    print("Yes")
  else:
    print("No")
elif len(seta) == 2:
  sseta = sorted(seta)
  if sseta[0] == 0 and a.count(sseta[1]) == a.count(sseta[0])*2:
    print("Yes")
  else:
    print("No")
elif len(seta) == 1 and seta[0] == 0:
  print("Yes")
else:
  print("No")

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

Solution (Python):
from operator import xor

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

D = {}

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

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

Solution (Python):
import collections
N = int(input())

num = list(map(int,input().split()))
c = collections.Counter(num)
if len(c) == 3:
  if c.most_common()[0][1] == c.most_common()[1][1]:
    if (c.most_common()[0][0])^(c.most_common()[1][0]) == c.most_common()[2][0]:
      print('Yes')
    else:
      print('No')
  else:
    print('No')
elif len(c) == 2:
  if c.most_common()[0][1] == 2*c.most_common()[1][1]:
    if c.most_common()[1][0] == 0:
      print('Yes')
    else:
      print('No')
  else:
    print('No')
elif len(c) == 1:
  if c.most_common()[0][0] == 0:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Solution (Python):
import sys
sys.setrecursionlimit(4100000)
 
import numpy as np
 
 
def resolve():
    N = [int(x) for x in sys.stdin.readline().split()][0]
    a_list = [int(x) for x in sys.stdin.readline().split()]
 
    max_len = len(format(max(a_list), 'b'))
    
    bin_array = np.array([[int(b) for b in format(a, 'b').zfill(max_len)]
                          for a in a_list])
 
    
 
    sum_array = bin_array.sum(axis=0)
    
    minus_array = N - 1.5 * sum_array
    if np.all(sum_array == 0) or (np.all(minus_array >= 0) and np.all(np.mod(minus_array, 3) == 0)):
        print("Yes")
    else:
        print("No")
 
 
if __name__ == "__main__":
    resolve()
 



 
import sys
from io import StringIO
import unittest
 
 
class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
 
    def test_入力例_1(self):
        input = """3
1 2 3"""
        output = """Yes"""
        self.assertIO(input, output)
 
    def test_入力例_2(self):
        input = """4
1 2 4 8"""
        output = """No"""
        self.assertIO(input, output)

Solution (Python):
from collections import defaultdict
from functools import reduce
N = int(input())
A = [int(x) for x in input().split()]
def isExist(N, A):
  AD = defaultdict(int)
  for a in A:
    AD[a] += 1
  keys = len(AD.keys())
  xor = reduce(lambda x, y: x^y, A)
  mlen = min([a for a in AD.values()])
  if xor != 0:
    return 'No'
  if keys == 1:
    return 'Yes'
  if keys == 2 and N % 3 == 0 and mlen == N // 3:
    return 'Yes'
  if keys == 3 and N % 3 == 0 and mlen == N // 3:
    return 'Yes'
  return 'No'
print(isExist(N, A))

Solution (Python):
import sys

fin = sys.stdin.readline
N = [int(elem) for elem in fin().split()][0]
a_list = [int(elem) for elem in fin().split()]

a_set = set(a_list)

all_xor = 0
for each_a in a_list:
    all_xor = all_xor ^ each_a

if len(a_list) % 3 == 0:
    if all_xor == 0:
        print('Yes')
    else:
        print('No')
else:
    if len(a_set) == 1:
        print('Yes')
    else:
        print('No')

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

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

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

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

cur = A[0]
for a in A[1:]:
    cur ^= a

print('Yes' if cur==0 else 'No')

Solution (Python):
inp = input()
n = int(inp)
inp = input()
split_inp = inp.split()





numbers = {}
for str_number in split_inp:
    int_number = int(str_number)
    if int_number not in numbers:
        numbers[int_number] = 1
    else:
        numbers[int_number] += 1
    if len(numbers) > 3:
        print("No")
        exit()

if len(numbers) == 2:
    number_values = [i for i in numbers.values()]
    max_number = max(number_values[0], number_values[1])
    small_number = min(number_values[0], number_values[1])
    if small_number * 2 != max_number:
        print("No")
        exit()
    n_list = []
    for item in numbers.items():
        if item[1] == small_number:
            n_list.append(item[0])
        else:
            n_list.append(item[0])
            n_list.append(item[0])
elif len(numbers) == 3:
    
    number_list = [i for i in numbers.values()]
    if number_list[0] != number_list[1] or number_list[1] != number_list[2]:
        print("No")
        exit()
    n_list = [i for i in numbers.keys()]
else:
    number_key = [i for i in numbers.keys()]
    for key in number_key:
        if key != 0:
            print("No")
            exit()
    print("Yes")
    exit()


def number_count(k1, k2, k3, count_n):
    count = 0
    if k1 == count_n:
        count += 1
    if k2 == count_n:
        count += 1
    if k3 == count_n:
        count += 1
    return count




n1 = int(n_list[0])
n2 = int(n_list[1])
n3 = int(n_list[2])
while n1 != 0 or n2 != 0 or n3 != 0:
    
    c1 = n1 % 2
    c2 = n2 % 2
    c3 = n3 % 2
    n1 = n1 // 2
    n2 = n2 // 2
    n3 = n3 // 2
    
    count1 = number_count(c1, c2, c3, 1)
    count0 = number_count(c1, c2, c3, 0)
    if (count1 != 2 or count0 != 1) and count0 != 3:
        print("No")
        exit()
print("Yes")

Solution (Python):
from collections import deque

N = int(input())
A = deque(map(int, input().split()))
first = A.popleft()


def round(a):
        B = list(A)
        eval = 0
        pre = first
        post = a
        B.remove(a)
        num = N - 2
        while num != 0:
                c = pre ^ post
                try:
                        B.remove(c)
                        pre = post
                        post = c
                        num -= 1
                except:
                        return 0
                        eval = 1
                        break
        
        if eval == 0 and post ^ first == a:
                return 1
        elif eval == 0:
                return 0

val = first
for i in range(N - 1):
        val = val ^ A[i]

if val != 0:
        print('No')
else:
        ans = 0
        for i in range(0, N - 1):
                ans = round(A[i])
                if ans == 1:
                        print('Yes')
                        break
                        

        if ans == 0:
                print('No')

Solution (Python):
import sys

input = sys.stdin.readline

N = int(input().strip())
As = list(map(int, input().strip().split(' ')))
candidates = list(set(As))

if len(candidates) == 1:
    if candidates[0] == 0:
        print('Yes')
    else:
        print('No')
elif len(candidates) == 2:
    a, zero = candidates
    if a < zero:
        a, zero = zero, a

    if zero == 0:
        count_a = 0
        count_zero = 0
        for element in As:
            if element == a:
                count_a += 1
            elif element == zero:
                count_zero += 1
        else:
            if count_a == count_zero * 2:
                print('Yes')
            else:
                print('No')
    else:
        print('No')
elif len(candidates) > 3:
    print('No')
else:
    a, b, c = candidates[0], candidates[1], candidates[2]
    if a ^ b != c:
        print('No')
    else:
        count_a = 0
        count_b = 0
        count_c = 0
        for element in As:
            if element == a:
                count_a += 1
            elif element == b:
                count_b += 1
            elif element == c:
                count_c += 1
        else:
            if count_a == count_b == count_c:
                print('Yes')
            else:
                print('No')

Solution (Python):
n = int(input())
als = list(map(int,input().split()))
ans = 'No'
sett = n//3
als.sort()
if als[0] == 0:
    if als[n-1] == 0:
        ans = 'Yes'
    else:
        cc = [0]*(n//2) + [als[n-1]]*(n//2)
        if cc == als:
            ans = 'Yes'
if n%3 == 0:
    co = [als[0]]*sett + [(als[0]^als[n-1])]*sett + [als[n-1]]*sett
    if co == als:
        ans = 'Yes'
print(ans)

Solution (Python):
n = int(input())
l = list(map(int,input().split()))
if not any(l):
  print("Yes")
elif n%3 != 0:
  print("No")
else:
  nx = n//3
  d = dict()
  for x in l:
    if x not in d:
      d[x] = 0
    d[x] += 1
  for x in d:
    if d[x] != nx and d[x] !=2*nx:
      print("No")
      break
  else:
    s = 0
    for x in d:
      if d[x] == nx:
        s ^= x
    if s == 0:
      print("Yes")
    else:
      print("No")

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N = _I()
A = LI()





set_A = set(A)
if len(set_A) > 3:
    print('No')
    exit()

if len(set_A) == 1:
    if A[0] == 0:
        print('Yes')
    else:
        print('No')
elif len(set_A) == 2:
    
    A_list = list(set_A)
    if 0 in A_list:
        non_zero = [i for i in A_list if i != 0][0]
        if A_list[0] ^ A_list[1] == non_zero:
            
            if A.count(0) * 2 == A.count(non_zero) and N % 3 == 0:
                
                print("Yes")
                exit()
            else:
                print('No')
                exit()
        else:
            print("No")
            exit()
    else:
        print('No')
        exit()
elif len(set_A) == 3:
    A_list = list(set_A)
    if A_list[0] ^ A_list[1] == A_list[2] and A_list[0] ^ A_list[2] == A_list[1] and A_list[1] ^ A_list[2] == A_list[0]:
        
        if A.count(A_list[0]) == A.count(A_list[1]) == A.count(A_list[2]) and N % 3 == 0:
            print('Yes')
        else:
            print("No")
    else:
        print('No')

Solution (Python):


n=int(input())
a=list(map(int,input().split()))
A=set(a[1:])
res=[-1]*n

dct={}
for e in a:
    dct[e]=dct.get(e,0)+1
tmp=a[0]
res[0]=tmp
dct[tmp]-=1

for i in range(1,n):
    tmp=res[0]^a[i]
    if  dct.get(tmp,0)>0:
        res[1]=a[i]
        res[-1]=res[0]^a[i]
        dct[res[1]]-=1
        dct[res[-1]]-=1
        break
else:
    print('No')
    exit()


for i in range(1,n-2):
    x=res[i]
    y=res[i-1]
    tmp=x^y
    if dct.get(tmp,0)>0:
        res[i+1]=tmp
        dct[tmp]-=1
    else:
        print('No')
        exit()

if res[-2]^res[-3]==res[-1]:
    print('Yes')
else:
    print('No')

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

XOR = A[0]
for i in range(1, N):
  XOR ^= A[i]

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

Solution (Python):
N=int(input())
A=list(map(int, input().split()))
A.sort()
ONE=0
TWO=0
THREE=0
Ne=0
ZERO=0
AA=A[0]
BB=A[N//3]
CC=A[(N*2)//3]
AAA=bin(AA)
BBB=bin(BB)
CCC=bin(CC)
X=bin(AA^BB)
Y=bin(BB^CC)
Z=bin(CC^AA)
i=0
if A[0]==0:
    for x in range(0,N):
        if A[x]==0:
            ZERO=ZERO+1
        if A[x]==BB:
            Ne=Ne+1
    if ZERO==N:
        i=1
    if N%3==0 and ZERO==N//3 and Ne==(N*2)//3:
        i=1

if X==CCC and Y==AAA and Z==BBB:
    if N%3==0:
        for x in range(0,N):
            if AA==A[x]:
                ONE=ONE+1
            if BB==A[x]:
                TWO=TWO+1
            if CC==A[x]:
                THREE=THREE+1
        if ONE==TWO and TWO==THREE and THREE==N//3:
            i=1
if i==0:
    print("No")
if i==1:
    print("Yes")

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

nums = {}

for i in range(N):
    if A[i] in nums:
        nums[A[i]] += 1
    else:
        nums[A[i]] = 1

if len(nums) == 1:
    if '0' in nums:
        print('Yes')
    else:
        print('No')
elif len(nums) == 2:
    if '0' in nums and nums['0'] * 3 == len(A):
        print('Yes')
    else:
        print('No')
elif len(nums) == 3:
    keys = [x for x in nums]
    a = keys[0]
    b = keys[1]
    c = keys[2]
    if nums[a] == nums[b] and nums[a] == nums[c] and int(a) ^ int(b) == int(c) and int(b) ^ int(c) == int(a) and int(a) ^ int(c) == int(b):
        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=int(bin(x ^ A[i]), 0)
    
if x==0:
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
lista = [int(i) for i in input().split()]

list0 = [0]*30
list1 = [0]*30

for mm in range(n):
    m = lista[mm]
    bin_str = format(m, '030b')
    

    for i in range(30):
        t = bin_str[i]
        if t == "1":
            list1[i] += 1
        else:
            list0[i] += 1




ans = "Yes"
for i in range(30):
    if list1[i]==0:
        continue
    
    num0 = list0[i]
    num1 = list1[i]
    if num0*2 != num1:
        ans = "No" 
        break
print(ans)

Solution (Python):


from itertools import combinations
import math
import datetime
N = int(input())
A = [int(x) for x in input().split()]

cnt = {}

kind = 0
for a in A:
    if not a in cnt:
        kind += 1
        cnt[a] = 0
    if kind > 3:
        break
    cnt[a] += 1

nums = list(cnt.keys())

if kind == 2:
    cnt0 = 0
    cnt_not0 = 0
    for n in [nums[0], nums[1]]:
        if n == 0:
            cnt0 += cnt[n]
        else:
            cnt_not0 = cnt[n]
    if cnt0 * 2 == cnt_not0:
        print("Yes")
    else:
        print("No")
elif kind == 3 and cnt[nums[0]] == cnt[nums[1]] == cnt[nums[2]] and nums[0] ^ nums[1] == nums[2]:
    print("Yes")
elif kind == 1 and nums[0] == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import defaultdict

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

if n == 3:
    if a[0] ^ a[2] == a[1] and a[1] ^ a[2] == a[0] and a[0] ^ a[1] == a[2]:
        print('Yes')
    else:
        print('No')
elif n % 3 == 0:
    d = defaultdict(int)
    for aa in a:
        d[aa] += 1
    m = n // 3
    bl = True
    t = []
    for k, v in d.items():
        if v % m != 0:
            bl = False
            break
        else:
            q = v // m
            t.append((k, q))

    if len(t) == 3:
        if t[0][0] ^ t[1][0] == t[2][0] and t[1][0] ^ t[2][0] == t[0][0] and t[2][0] ^ t[0][0] == t[1][0]:
            pass
        else:
            bl = False
    elif len(t) == 2:
        if t[0][1] > t[1][1]:
            if t[0][0] ^ t[0][0] == t[1][0] and t[0][0] ^ t[1][0] == t[0][0]:
                pass
            else:
                bl = False
        else:
            if t[1][0] ^ t[1][0] == t[0][0] and t[0][0] ^ t[1][0] == t[1][0]:
                pass
            else:
                bl = False


    elif len(t) == 1:
        if t[0][0] != 0:
            bl = False

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

else:
    if all(aa == 0 for aa in a):
        print('Yes')
    else:
        print('No')

Solution (Python):
import collections

n=int(input())

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

c = collections.Counter(a_list)


values=list(c.values())
values.sort()


keys=list(c.keys())
keys.sort()


ans="No"
if len(values)==3:
  if values[0]==values[1] and values[1]==values[2]:
    if keys[0] ^ keys[1]==keys[2]:
      ans="Yes"
  
if len(values)==2:
  if keys[0] == 0:
    if values[0]*2==values[1]:
      ans="Yes"

if len(values)==1:
  if keys[0] == 0:
      ans="Yes"

print(ans)

Solution (Python):
from sys import stdin,stdout
n=int(stdin.readline())
l=map(int,stdin.readline().split())
ans=0
for i in l:
  ans^=i
if ans:
  stdout.write("No")
else:
  stdout.write("Yes")

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

A = sorted(A, reverse=True)
xor = A[0]
for a in A[1:]:
  xor ^= a 
if (xor == 0):
  print('Yes')
else:
  print('No')

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

a.sort()
s = set(a)
if a[0] != 0:
    if (len(s) > 3) or (len(s) == 1) or (len(s) == 2):
        print('No')
        exit()

    l = [a[0]]
    c = []
    count = 1
    for i in range(n - 1):
        if a[i + 1] != a[i]:
            l.append(a[i + 1])
            c.append(count)
            count = 1
        else:
            count += 1
    c.append(count)

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

    c.sort()
    if c[0] != c[1] or c[1] != c[2]:
        print('No')
        exit()

    if (l[0] ^ l[1]) == l[2]:
        print('Yes')
        exit()
    print('No')
else:
    if len(s) == 1:
        print('Yes')
        exit()
    if len(s) > 3:
        print('No')
        exit()
    if len(s) == 3:
        print('No')
        exit()

    c = []
    count = 1
    for i in range(n - 1):
        if a[i + 1] != a[i]:
            c.append(count)
            count = 1
        else:
            count += 1
    c.append(count)

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

    if c[0] * 2 == c[1]:
        print('Yes')
        exit()
    print('No')
    exit()