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

"""
Created on Sun Jul 14 20:27:59 2019

@author: ctiuser
"""
import sys

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

A.sort()

if A[-1] == 0:
    print('Yes')
    sys.exit()

if N % 2 == 0:
    if A[0] == 0:
        flg = True
        if A[0] != A[N//2-1]:
            flg = False
        if A[N//2] != A[-1]:
            flg = False
        if flg:
            print('Yes')
            sys.exit()

flg = True
if N % 3 != 0:
    flg = False

if A[0] != A[N//3-1]:
    flg = False
if A[N//3] != A[(2*N)//3-1]:
    flg = False
if A[(2*N)//3] != A[(3*N)//3-1]:
    flg = False

if A[0] ^ A[N//3] != A[(2*N)//3]:
    flg = False

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

Solution (Python):
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]





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

d = {}
for e in a:
    if e not in d:
        d[e] = 1
    else:
        d[e] += 1

ans = ""


if len(d) > 3:
    ans = "No"
elif len(d) == 1:
    if 0 in d:
        ans = "Yes"
    else:
        ans = "No"
elif N % 3 == 0:
    if len(d) == 2:
        if 0 in d and d[0] == N // 3:
            ans = "Yes"
        else:
            ans = "No"
    elif len(d) == 3:
        keys = list(d.keys())
        if keys[0] ^ keys[1] == keys[2] and d[keys[0]] == N // 3 and d[keys[1]] == N // 3:
            ans = "Yes"
        else:
            ans = "No"
else:
    ans = "No"

print(ans)

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

Solution (Python):
from collections import Counter
n = int(input())
a = [int(item) for item in input().split()]
cnt = Counter(a)
length = len(cnt)
if length == 1:
    key = list(cnt.keys())[0]
    if key == key ^ key:
        print("Yes")
    else:
        print("No")
elif length == 2:
    val = []
    for key in cnt.keys():
        val.append(key)
    if cnt[0] == n // 3 and n % 3 == 0:
        print("Yes")
    else:
        print("No")
elif length == 3:
    val = []
    for key in cnt.keys():
        val.append(key)
    if (val[0] ^ val[1] != val[2]) or (val[1] ^ val[2] != val[0]) or (val[2] ^ val[0] != val[1]):
        print("No")
        exit()
    if n % 3 != 0:
        print("No")
        exit()
    if (cnt[val[0]] != n // 3) or (cnt[val[1]] != n // 3) or (cnt[val[2]] != n // 3):
        print("No")
        exit()
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
a=Counter(a)
v=list(a.values())
if len(v)>3:
    print("No")
elif len(v)==1:
    if a[0]>0:
        print("Yes")
    else:
        print("No")
elif n%3!=0:
    print("No")
elif len(v)==2:
    if a[0]==n//3:
        print("Yes")
    else:
        print("No")
else:
    if v==[n//3,n//3,n//3]:
        aa=list(a.keys())
        if aa[0]^aa[1]==aa[2] or aa[0]^aa[2]==aa[1] or aa[1]^aa[2]==aa[0]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Solution (Python):
n=int(input())
a=[int(j) for j in input().split()]
import collections
c=collections.Counter(a)
l=c.most_common()
ll=[]
for i,j in l:
    ll.append(i)
if sum(ll)==0:
    print("Yes")
    exit()
if 0 in ll:
    if len(l)==2:
        for i,j in l:
            if i==0:
                z=j
            else:
                t=j
        if 2*z==t:
            print("Yes")
            exit()
        else:
            print("No")
            exit()
    else:
        print("No")
        exit()

p=l[0][1]
q=[]
if len(l)==3:
    for i,j in l:
        if j==p:
            q.append(i)
        else:
            print("No")
            exit()
else:
    print("No")
    exit()
if q[0]^q[1]==q[2] and q[0]^q[2]==q[1] and q[2]^q[1]==q[0]:
    print("Yes")
else:
    print("No")

Solution (Python):
n = input()

a = list(map(lambda x: int(x), input().split()))

xor = 0

for i in a:
    xor = xor ^ i

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

Solution (Python):
import os, sys, re, math

N = int(input())

v = list(map(int, input().split(' ')))
s = 0
for i in range(len(v)):
    s = s ^ v[i]

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

Solution (Python):
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    a = [int(x) for x in stdin.readline().rstrip().split()]
    ans = {}
    for x in a:
        sbin = bin(x)[2:][::-1]
        for i, c in enumerate(sbin):
            if c != '1':
                continue
            if i in ans:
                ans[i] += 1
            else:
                ans[i] = 1
    for x in ans.values():
        if x % 2 != 0:
            print('No')
            return
    print('Yes')


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
if N == 3:
    if A[0]^A[1] == A[2]:
        print('Yes')
    else:
        print('No')
    exit()
a = A[0]
for i in range(1,N):
    a = a ^ A[i]
if a == 0:
    print('Yes')
else:
    print('No')

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

import collections
d = dict(collections.Counter(A))
ans = "No"
num = list(d.keys())
num.sort()
if len(d) == 1:
    if num[0] == 0:
        ans = "Yes"
elif len(d) == 2:
    if num[0] == 0 and d[0] * 3 == N:
        ans = "Yes"
elif len(d) == 3:
    if num[0] ^ num[1] == num[2] and d[num[0]] == d[num[1]] and d[num[2]] == d[num[1]]:
        ans = "Yes"
print(ans)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
setA = list(set(A))
if len(setA) == 1 and setA[0] == 0:
	print("Yes")
	exit()
if N % 3 != 0:
	print("No")
	exit()
if len(setA) == 1 or len(setA) > 3:
	print("No")
	exit()
if len(setA) == 2:
	if 0 in setA:
		setA.sort()
		if A.count(0) == N // 3 and A.count(setA[1]) == (N // 3) * 2:
			print("Yes")
			exit()
	print("No")
	exit()

if setA[0] ^ setA[1] != setA[2]:
	print("No")
	exit()
for a in setA:
	if A.count(a) != N // 3:
		print("No")
		exit()
print("Yes")
exit()

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

if N%3:
  if all([a==0 for a in A]):
    print('Yes')
  else:
    print('No')


else:
  c = Counter(A)
  temp = 0
  for k,v in c.items():
    if v % (N//3):
      print('No')
      exit()
    else:
      for i in range(v//(N//3)):
        temp = temp^k
  if temp==0:
    print('Yes')
  else:
    print('No')

Solution (Python):
from collections import Counter

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

res = 'Yes'

a_dict = Counter(a_list)


a_keys = list(a_dict.keys())
if len(a_keys) > 3:
    res = 'No'
elif len(a_keys) == 3:
    a, b, c = a_keys
    if a_dict[a] != a_dict[b]:
        res = 'No'
    if a_dict[a] != a_dict[c]:
        res = 'No'
    if a ^ b != c:
        res = 'No'
    if b ^ c != a:
        res = 'No'
    if c ^ a != b:
        res = 'No'
elif len(a_keys) == 2:
    a, b = a_keys
    if a_dict[a] == 2 * a_dict[b]:
        if b != 0:
            res = 'No'
    elif 2 * a_dict[a] == a_dict[b]:
        if a != 0:
            res = 'No'
    else:
        res = 'No'
else:
    a = a_keys[0]
    if a != 0:
        res = 'No'
print(res)

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

sum = 0
for a in alist:
    sum ^= a

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

Solution (Python):
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)


N = int(input())
a = list(map(int,input().split()))
C = Counter(a)
if len(C)>=4:
    print("No")
elif len(C)==1:
    if a[0]==0:
        print("Yes")
    else:
        print("No")
elif len(C)==2:
    key=[]
    for k in C.keys():
        key.append(k)
    key.sort()
    if key[0]==0 and C[key[1]] == 2*C[key[0]]:
        print("Yes")
    else:
        print("No")
elif len(C)==3:
    val = []
    key = []
    for k in C.keys():
        key.append(k)
    if key[0] ^ key[1] != key[2]:
        print("No")
        exit()
    for v in C.values():
        val.append(v)
    if val[0]==val[1]==val[2]:
        print("Yes")
    else:
        print("No")

Solution (Python):
from collections import Counter


def main():
    N = int(input())
    A = list(map(int, input().split()))
    C = Counter(A)
    if len(C) == 1 and 0 in C:
        print("Yes")
        return
    if N % 3 != 0:
        print("No")
        return
    if 0 in C and len(C) == 2:
        if C[0] * 3 == N:
            print("Yes")
            return
    elif 0 not in C and len(C) == 3:
        for c in C:
            if C[c] * 3 != N:
                print("No")
                return
            X = list(C)
            if X[0] ^ X[1] != X[2]:
                print("No")
                return
            print("Yes")
            return
    print("No")


if __name__ == "__main__":
    main()

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

a = A[0]^A[1]
for i in range(2, n):
    a = a ^ A[i]

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

Solution (Python):
n=int(input())
l=[int(i) for i in input().split()]
if 0 not in l:
    dic={}
    ll=[]
    for i in l:
        if i not in ll:
            ll.append(i)
            dic[i]=1
        else:
            dic[i]+=1
        if len(ll)>3:
            break
    if len(ll)==3:
        x,y,z=ll[0],ll[1],ll[2]
        nx,ny,nz=dic[x],dic[y],dic[z]
        if max(nx,ny,nz)-min(nx,ny,nz)<=1 and x^y==z:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    l.sort()
    if l[-1]==0:
        print("Yes")
    else:
        cnt=l.count(l[-1])
        zcnt=n-cnt
        if n%3==0:
            if cnt==zcnt*2:
                print("Yes")
            else:
                print("No")
        elif n%3==1:
            if zcnt==(n+2)//3 or zcnt==(n-1)//3:
                print("Yes")
            else:
                print("No")
        else:
            if zcnt==(n+1)//3 or zcnt==(n-2)//3:
                print("Yes")
            else:
                print("No")

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

Solution (Python):
def xor_circle(N: int, A: list)->bool:
    M = max(A)

    b = 1
    while b <= M:
        zero, one = 0, 0
        for a in A:
            if a & b:
                one += 1
            else:
                zero += 1

        if one != 2 * zero and one != 0:
            return False
        b <<= 1

    return True


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]

    yes = xor_circle(N, A)
    print('Yes' if yes else 'No')

Solution (Python):
import sys, collections
sys.setrecursionlimit(10000000)
alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", \
    "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

def solve():
    input = sys.stdin.readline
    mod = 7 + 10 ** 9
    N = int(input())
    A = [int(a) for a in input().split()]
    if len(set(A)) > 3: print("No")
    elif len(set(A)) == 3:
        B = list(set(A))
        count = [0, 0, 0]
        for a in A:
            if a == B[0]: count[0] += 1
            elif a == B[1]: count[1] += 1
            else: count[2] += 1
        if count[0] == count[1] and count[1] == count[2] and B[0] ^ B[1] == B[2]: print("Yes")
        else: print("No")
    elif len(set(A)) == 2:
        if 0 not in A: print("No")
        else:
            B = list(set(A))
            B.sort()
            count = [0, 0]
            for a in A:
                if a == 0: count[0] += 1
                else: count[1] += 1
            if count[0] * 2 == count[1]: print("Yes")
            else: print("No")
    else:
        if A[0] == 0: print("Yes")
        else: print("No")

    return 0

if __name__ == "__main__":
    solve()

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

R = {}
for i in a:
  if i in R:
    R[i] += 1
  else:
    R[i] = 1

ans = ["Yes", "No"]
if 0 in R:
  if len(R) == 1:
    print(ans[0])
  elif len(R) == 2:
    for i in R.keys():
      if i != 0:
        x = R[i]
      else:
        z = R[i]
    if x == z * 2:
      print(ans[0])
    else:
      print(ans[1])
  else:
    print(ans[1])
else:
  if len(R) != 3:
    print(ans[1])
  else:
    t = -1
    for i in R.values():
      if t == -1:
        t = i
      else:
        if i != t:
          print(ans[1])
          break
    else:
      a = b = c = -1
      for i in R.keys():
        if a == -1:
          a = i
        elif b == -1:
          b = i
        else:
          c = i
      if a ^ b == c:
        print(ans[0])
      else:
        print(ans[1])

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

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

from collections import defaultdict

A=defaultdict(int)
zero_count=0
for aa in a:
    A[aa]+=1
    if aa==0:
        zero_count+=1

if zero_count==N:
    print("Yes")
else:
    if N%3!=0:
        print("No")
    else:
        if len(list(A.keys()))>3:
            print("No")
        else:
            a_list=list(A.keys())
            a_list.sort()
            if len(a_list)==1:
                print("No")
            elif len(a_list)==2:
                if a_list[0]!=0:
                    print("No")
                else:
                    if A[0]==N//3:
                        print("Yes")
                    else:
                        print("No")
            else:
                if A[a_list[0]]==A[a_list[1]] and A[a_list[1]]==A[a_list[2]]:
                    if a_list[0]^a_list[1]==a_list[2]:
                        print("Yes")
                    else:
                        print("No")
                else:
                    print("No")

Solution (Python):
N=int(input())
a=[int(i) for i in input().split()]
b=list(set(a))
if len(b)==1:
    if b[0]==0:
        print("Yes")
    else:
        print("No")
else:
    if N%3==0 and len(b)==3:
        D={b[0]:0,b[1]:0,b[2]:0}
        for i in range(N):
            D[a[i]]+=1
        if D[b[0]]==D[b[1]] and D[b[1]]==D[b[2]] and b[0]^b[1]==b[2]:
            print("Yes")
        else:
            print("No")
    else:
        if N%3==0 and len(b)==2:
            D={b[0]:0,b[1]:0}
            for i in range(N):
                D[a[i]]+=1
            if D[b[0]]==D[b[1]]*2:
                if b[0]^b[0]==b[1]:
                    print("Yes")
                else:
                    print("No")
            elif D[b[1]]==D[b[0]]*2:
                if b[1]^b[1]==b[0]:
                    print("Yes")
                else:
                    print("No")
            else:
                print("No")
        else:
            print("No")

Solution (Python):
iter_num = int(input())
num = input().split()
num = sorted([int(i) for i in num])

num_bin = [format(int(i),'b') for i in num]
max_len = len(num_bin[-1])

num_bin = [format(i, '0>{}'.format(max_len)) for i in num_bin]

tmp = []
for i in range(len(num_bin[0])):
  tmp_num = 0
  for j in num_bin:
    tmp_num += int(j[i])
  if tmp_num%2==0: tmp_num=0
  tmp.append(tmp_num)

flg = 0
for i in tmp:
  if i==0: pass
  else:
    flg = 1
    print('No')
    break
if flg == 0: print('Yes')

Solution (Python):
from collections import defaultdict as dd, deque, Counter
n = int(input())
C = Counter(map(int,input().split()))

if len(C) == 1:
    if list(C)[0] == 0:
        print('Yes')
    else:
        print('No')
elif len(C) == 2:
    it = list(C.items())
    k1,v1 = it[0]
    k2,v2 = it[1]
    if v1 == 2*v2 or v2 == 2*v1 and 0 in [k1,k2]:
        print('Yes')
    else:
        print('No')
elif len(C) == 3:
    it = list(C.items())
    k1,v1 = it[0]
    k2,v2 = it[1]
    k3,v3 = it[2]

    if v1 == v2 == v3 and k1^k2 == k3:
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

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

if max(A)==0:
    print("Yes")
    sys.exit()

from collections import Counter
C=Counter(A)

flag=1

if len(C)==3:
    
    if N%3!=0:
        flag=0

    for v in C.values():
        if v!=N//3:
            flag=0

    A=0
    for k in C.keys():
        A^=k

    if A!=0:
        flag=0


elif len(C)==2:

    if N%3!=0:
        flag=0

    if not (0 in C.keys()):
        flag=0

    
    if C[0]!=N//3:
        flag=0

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

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

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import defaultdict

n = ni()
a = list(li())

dic = defaultdict(int)

for ai in a:
    dic[ai] += 1

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

elif len(dic) == 3:
    keys = []
    vals = []
    for k, v in dic.items():
        keys.append(k)
        vals.append(v)

    if vals[0] == vals[1] == vals[2] and keys[0] ^ keys[1] ^ keys[2] == 0:
        print("Yes")

    else:
        print("No")

elif len(dic) == 2:
    if not 0 in dic.keys():
        print("No")

    else:
        zero = dic[0]
        anot = 0
        for k, v in dic.items():
            if k != 0:
                anot = v

        if zero * 2 != anot:
            print("No")

        else:
            print("Yes")

elif len(dic) == 1:
    if not 0 in dic.keys():
        print("No")

    else:
        print("Yes")

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

M = {}
for t in a:
  if t not in M:
    M[t] = 0
  M[t] += 1

if N%3!=0:
  if 0 in M and M[0]==N:
    ans = "Yes"
  else:
    ans = "No"
else:
  V = list(M)
  if len(V)==1:
    if 0 in M and M[0]==N:
      ans = "Yes"
    else:
      ans = "No"
  elif len(V)==2:
    a = V[0]
    b = V[1]
    if M[a]*2==M[b]:
      if b^b==a:
        ans = "Yes"
      else:
        ans = "No"
    elif M[b]*2==M[a]:
      if a^a==b:
        ans = "Yes"
      else:
        ans = "No"
    else:
      ans = "No"
  elif len(V)==3:
    a = V[0]
    b = V[1]
    c = V[2]
    if M[a]==M[b]==M[c] and a^b==c:
      ans = "Yes"
    else:
      ans = "No"
  else:
    ans = "No"
print ans

Solution (Python):


import sys










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

check = []
for i in range(0,30):
	check.append(0)

for i in range(0,n):
	j=a[i]
	k=0
	while(j!=0):
		tmp = j%2
		check[k]+=tmp
		j = j//2
		k+=1

flg = 0;
for i in range(0,30):
	flg += check[i]%2






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

Solution (Python):



import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]

if n%3:
    p = a[0]
    for i in a:
        if i != p:
            print("No")
            exit()
    else:
        print("Yes")
        exit()


d = {}
for i in a:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1



if len(d) >= 4:
    print("No")
    exit()
elif len(d) == 3:
    res = 0
    for i in d:
         res ^= i
    if res != 0:
        print("No")
        exit()
    for i in d:
        if d[i] != n//3:
            print("No")
            exit()
    else:
        print("Yes")
        exit()
    
elif len(d) == 2:
    a.sort()
    p = a[0]
    q = a[-1]
    cp = d[p]
    cq = d[q]
    if cp != 2*n//3 and cq != 2*n//3:
        print("No")
        exit()
    elif cp == 2*n//3:
        if q != 0:
            print("No")
            exit()
        else:
            print("Yes")
            exit()
    elif cq == 2*n//3:
        if p != 0:
            print("No")
            exit()
        else:
            print("Yes")
            exit()
            
    
elif len(d) == 1:
    if a[0] != 0:
        print("No")
        exit()
    else:
        print("Yes")
        exit()

Solution (Python):
from math import *
from collections import deque, defaultdict, Counter
from itertools import product, permutations, combinations, accumulate
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappush, heappop
from copy import copy, deepcopy



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

cer = list(Counter(es).items())

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

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

elif len(cer)==1:
    if cer[0][0] == 0:
        print("Yes")
    else:
        print("No")

else:
    print("No")

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

A = list(map(int, input().split()))
if all(a == 0 for a in A):
        print('Yes')
elif N % 3:
    print('No')
else:
    n = N//3
    CA = Counter(A)
    ans = 'Yes'
    t = []
    for k, v in CA.items():
        if not v % n:
            t.append(k)
        
    if len(t) == 3 and (t[0]^t[1] == t[2] and t[2]^t[1] == t[0] and t[0]^t[2] == t[1]):
        ans = 'Yes'
    elif len(t) == 2 and (t[0] == 0 or t[1] == 0):
        ans = 'Yes'
    else:
        ans = 'No'
        
    print(ans)

Solution (Python):
def find(A):
    N=len(A)
    dic={}
    for i in range(len(A)):
        if A[i] in dic:
            dic[A[i]]+=1
        else:
            dic[A[i]]=1
            
    if len(dic)>3:
        return False
    
    if len(dic)==1:
        if 0 in dic:
            return True
        else:
            return False
    
    if len(dic)==2:
        if N%3!=0:
            return False
        temp=[]
        for x in dic:
            temp+=[dic[x]]
        n=N//3
        temp=sorted(temp)
        if (temp[0],temp[1])!=(n,2*n):
            return False
        
        if 0 not in dic:
            return False
        
        n1=dic[0]
        if n1==n:
            return True
        return False
    
    if len(dic)>3:
        return False
    
    if len(dic)==3 and N%3!=0:
        return False
    
    temp=[dic[x] for x in dic]
    if temp[0]!=temp[1] or temp[1]!=temp[2] or temp[2]!=temp[0]:
        return False
    
    a,b,c=[x for x in dic]
    if a^b==c or b^a==c or c^b==a:
        return True
    return False
    
input()
A=list(map(int,input().strip().split(' ')))
if find(A):
    print("Yes")
else:
    print("No")

Solution (Python):
def solve():
    n = int(input())
    a = list(map(int, input().split()))
    total = 0
    for i in range(n):
            total = total ^ a[i]
    if n % 3 == 1:
        total = total ^ a[0] ^ a[1]
    if n % 3 == 2:
        total = total ^ a[0]
    if total == 0:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    solve()

Solution (Python):
n = int(input())
a_s = [int(v) for v in input().split()]

total = 0;
for a in a_s:
  total ^= a

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

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

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

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

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

if len(memo) == 1:
    tmp = [i for i in memo]
    if tmp[0] == 0:
        print("Yes")
        exit()

if len(memo) == 2:
    tmp = [i for i in memo]
    if tmp[0] == 0:
        if memo[tmp[0]]*2 == memo[tmp[1]]:
            print("Yes")
            exit()
    if tmp[1] == 0:
        if memo[tmp[1]]*2 == memo[tmp[0]]:
            print("Yes")
            exit()
            
if len(memo) == 3:
    tmp = [i for i in memo]
    if memo[tmp[0]] == memo[tmp[1]] and memo[tmp[1]] == memo[tmp[2]]:
        if tmp[0] ^ tmp[1] ^ tmp[2] == 0:
            print("Yes")
            exit()

print("No")

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

if N%3==1:
  if a[0]==a[N-1]:
    ans = 'Yes'
  else:
    ans = 'No'
elif N%3==2:
  if a[0]==a[N-1]:
    ans = 'Yes'
  else:
    ans = 'No'
else:
  if a[0]==a[N//3-1] and a[N//3]==a[N//3*2-1] and a[N//3*2]==a[N-1] and a[0]^a[N//3]==a[N//3*2]:
    ans = 'Yes'
  else:
    ans = 'No'
print(ans)

Solution (Python):
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N = INT()
    A = LIST()

    all = A[0]
    for a in range(len(A) - 1):
        all = all ^ A[a + 1]

    for a in A:
        if a ^ all != a:
            No()
            exit()
    Yes()

if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter

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

def solve():
    if set(As) == {0}:
        print('Yes')
    elif N % 3:
        print('No')
    else:
        m = N//3
        cnt = Counter(As)
        vs = []
        for v in cnt.keys():
            if cnt[v] % m:
                print('No')
                return
            vs += [v] * (cnt[v]//m)

        A, B, C = vs

        if A^B^C:
            print('No')
        else:
            print('Yes')

solve()

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

tobe_0 = 0
for ai in a:
    tobe_0 ^= ai
print('Yes' if tobe_0 == 0 else 'No')

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

ans = a[0]
for i in range(1, N):
    ans = ans ^ a[i]

print("Yes" if ans == 0 else "No")

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

if len(ct) == 1 and ct.most_common(1)[0][0] == 0:
  print('Yes')
elif len(ct) == 2:
  mc = ct.most_common(3)
  m1 = mc[0]
  m2 = mc[1]
  if m2[0] == 0 and m1[1] == m2[1] * 2:
    print('Yes')
  else:
    print('No')
elif len(ct) == 3:
  mc = ct.most_common(3)
  m1 = mc[0]
  m2 = mc[1]
  m3 = mc[2]
  if m1[1] == m2[1] == m3[1] and m1[0] ^ m2[0] == m3[0]:
    print('Yes')
  else:
    print('No')
else:
  print('No')

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

ans = int(a[0], 2)
for el in a[1:]:
    ans = ans ^ int(el, 2)

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

Solution (Python):

import sys;
import string;
sys.setrecursionlimit(20000) 

import copy
import math
import itertools

from functools import lru_cache


PPP = 1000000007


n = int(input())


a = [int(x) for x in input().split()]
print("a", a, file=sys.stderr)


























import re
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

a.sort()
def doloop():
  res = 0
  for x in a:
    res ^= x
  
  return res == 0

def doit():
  if doloop():
    return "Yes"
  else:
    return "No"




try:
  print(doit())
except Exception as e:
  print("e", e, file=sys.stderr)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
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 I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  a=l[0]
  for x in l[1:]:
    a=a^x

  if a==0:
    return 'Yes'
  return 'No'


print(main())

Solution (Python):
N = int(input())
a_list = [int(x) for x in input().split()]
first = a_list[0]
tmp = 0
for a in a_list[1:]:
    tmp ^= a
if (first == tmp):
    print("Yes")
else:
    print("No")

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

S = 0

for a in A:
    S ^= a

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

Solution (Python):
def main():
    N = int(input())
    V = list(map(int, input().split()))

    n = 0
    for i in V:
        n = i ^ n
    if n == 0:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()

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

tmp = 0
A.sort(reverse=True)
for i in A:
    tmp ^= i

flag = False
if N % 3 == 0:
    if tmp == 0:
        flag = True
elif N % 3 == 1:
    if tmp == A[-1]:
        flag = True
elif N % 3 == 2:
    if tmp == (A[-1] ^ A[-2]):
        flag = True

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

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

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

tmp = 0
for a in l:
    tmp = a ^ tmp 
print("Yes" if tmp == 0 else "No")