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

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

if n % 3 == 0:
  if len(v) == 3:
    if v[0] == v[1] == v[2] and k[0] ^ k[1] == k[2]:
      print("Yes")
    else:
      print("No")
  elif len(v) == 2:
    if (k[0] == 0 and v[0] * 2 == v[1]) or (k[1] == 0 and v[1] * 2 == v[0]):
      print("Yes")
    else:
      print("No")
  elif len(v) == 1:
    if k[0] == 0:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
elif len(v) == 1:
  if k[0] == 0:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
def doit(a):
    c = {}
    for ai in a:
        c[ai] = c.get(ai, 0) + 1
    if len(c) > 3:
        return "No"
    k = list(sorted(c.keys()))
    if len(k) == 1:
        if k[0] == 0:
            return "Yes"
    if len(k) == 2:
        if k[0] == 0 and c[k[0]] * 2 == c[k[1]]:
            return "Yes"
    if len(k) == 3:
        if c[k[0]] == c[k[1]] == c[k[2]] and k[0] ^ k[1] == k[2]:
            return "Yes"
    return "No"

print(doit(sorted(a)))

Solution (Python):


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

val1 = a[0]
val2 = a[0] ^ a[0]

for i in range(1, N):
    val1 = val1 ^ a[i]
    val2 = val2 ^ a[i] ^ a[i]

if( val1 == val2):
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
a = map(int,input().split())
a = list(map(bin,a))
a = [int(i,2) for i in a]
ans = a[0]
for i in range(n-1):
    ans = ans ^ a[i+1]

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

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

flag1 = True
flag2 = True

for i in range(n):
    if a[i] != 0:
        flag1 = False
        break

if not flag1:
    if n % 3 != 0:
        flag2 = False
    if flag2:
        a.sort()
        a11 = a[0: n // 3]
        a12 = a[n // 3: 2 * n // 3]
        a13 = a[2 * n // 3:]
        if not (a11.count(a11[0]) == a12.count(a12[0]) == a13.count(a13[0])):
            flag2 = False
    if flag2:
        a1, a2, a3 = a[0], a[n // 3], a[2 * n // 3]
        aa = [[], [], []]
        for i in range(30):

            aa[0].append(a1 % 2)
            aa[1].append(a2 % 2)
            aa[2].append(a3 % 2)
            a1 = a1 // 2
            a2 = a2 // 2
            a3 = a3 // 2

        for i in range(30):
            if aa[0][i] == 0 and aa[1][i] == 0 and aa[2][i] == 1:
                flag2 = False
                break
            if aa[0][i] == 0 and aa[1][i] == 1 and aa[2][i] == 0:
                flag2 = False
                break
            if aa[0][i] == 1 and aa[1][i] == 0 and aa[2][i] == 0:
                flag2 = False
                break
            if aa[0][i] == 1 and aa[1][i] == 1 and aa[2][i] == 1:
                flag2 = False
                break


if flag1 or flag2:
    print("Yes")
else:
    print("No")

Solution (Python):
import collections
N=int(input())
a=list(map(int,input().split()))
def judge(a):
    if sum(a)==0:
        return True
    else:
        a=dict(collections.Counter(a))
        if len(a.keys())==3:
            a0=list(a.keys())[0]
            a1=list(a.keys())[1]
            a2=list(a.keys())[2]
            if a0^a1==a2 and a[a0]==a[a1] and a[a1]==a[a2]:
                return True
        if len(a.keys())==2:
            a0=list(a.keys())[0]
            a1=list(a.keys())[1]
            if a0==0 or a1==0:
                if a[a0]==2*a[a1] or a[a1]==2*a[a0]:
                    return True
    return False

if judge(a):
    print("Yes")
else:
    print("No")

Solution (Python):
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
    
n=I()
a=LI()

a.sort()

def check(n,a):
    if n%3!=0:
        if a[-1]==0 and a[0]==0:
            return True
        else:
            return False
    else:
        m=n//3
        c=a[0]
        for i in range(m):
            if a[i]!=c:
                k=0
                return False
        c=a[m]
        for i in range(m):
            if a[m+i]!=c:
                k=0
                return False
                
        c=a[2*m]    
        for i in range(m):
            if a[2*m+i]!=c:
                k=0
                return False
        if a[0]^a[m]==a[m*2]:
            return True
            
if check(n,a):
    k=0
else:
    k=1
ans=['Yes','No']

print(['Yes','No'][k])

Solution (Python):
from collections import Counter

N = int(input())
c = Counter(int(s) for s in input().split())
if len(c) > 3:
    print("No")
elif len(c) == 1:
    print("Yes" if c.most_common()[0][0] == 0 else "No")
elif len(c) == 2:
    mc = sorted(c.most_common())
    if mc[0][0] == 0 and mc[0][1] * 2 == mc[1][1]:
        print("Yes")
    else:
        print("No")
else:
    mc = sorted(c.most_common())
    if mc[0][0] ^ mc[1][0] ^ mc[2][0] == 0 and mc[0][1] == mc[1][1] == mc[2][1]:
        print("Yes")
    else:
        print("No")

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a.sort()
x = a[0]
y = a[N // 3]
z = a[- N // 3]
if a[-1] == 0:
	print('Yes')
else:
	if N % 3 == 0:
		if a[N // 3 - 1] == 0 and y == a[-1]:
			print('Yes')
		else:
			if a.count(x) == N // 3 and a.count(y) == N // 3 and a.count(z) == N // 3: 
				if x ^ y == z and y ^ z == x and z ^ x == y:
					print('Yes')
				else:
					print('No')
			else:
				print('No')
	else:
		print('No')

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

if sum(A) == 0:
    print('Yes')
    exit()

B = set(A)
if N%3 == 0:
    C = list(B)
    ans = 0
    for i in range(N):
        ans = ans^A[i]

    if ans == 0:
        print('Yes')
        exit()

print('No')

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

if len(a.most_common()) > 3:
    print("No")
    sys.exit()

if len(a.most_common()) == 1:
    if a.most_common()[0][0] == 0:
        print("Yes")
        sys.exit()
    else:
        print("No")
        sys.exit()
    
if len(a.most_common()) == 2:
    if a.most_common()[1][0] == 0 and 2 * a.most_common()[1][1] == a.most_common()[0][1]:
        print("Yes")
        sys.exit()
    else:
        print("No")
        sys.exit()

if len(a.most_common()) == 3:
    if a.most_common()[0][1] == a.most_common()[1][1] == a.most_common()[2][1]:
        if a.most_common()[0][0] ^ a.most_common()[1][0] == a.most_common()[2][0]:
            print("Yes")
            sys.exit()
        else:
            print("No")
            sys.exit()
    else:
        print("No")
        sys.exit()

Solution (Python):

import sys
from bisect import bisect_left
from collections import Counter
INF = float("inf")

KETA_MAX = 10


def yes():
    print("Yes")  


def no():
    print("No")  


def solve(N: int, a: "List[int]"):
    keta = [Counter() for _ in range(KETA_MAX)]
    for i in range(N):
        x = a[i]
        for j in range(KETA_MAX):
            keta[j][x & 1] += 1
            x >>= 1

    for cnt in keta:
        if cnt[1] == 0:
            continue
        elif cnt[1] == cnt[0]*2:
            continue
        else:
            no()
            return
    yes()
    return

    
    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    


def main():

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


if __name__ == '__main__':
    main()

Solution (Python):

n = int(input())
ans = "No"
num_list = sorted([ int(v) for v in input().split() ])

if n % 3 == 0:
    m = n // 3
    a, b, c = num_list[0], num_list[m], num_list[2*m]
    if len(set(num_list[:m])) == 1 and len(set(num_list[m:2*m])) == 1 and len(set(num_list[2*m:])) == 1:
        if a ^ b == c:
            ans = "Yes"
elif num_list == [0] * n:
        ans = "Yes"
print(ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
set_a=set(a)
if len(set_a)==3:
    set_a = list(set_a)
    num0 = a.count(set_a[0])
    num1 = a.count(set_a[1])
    num2 = a.count(set_a[2])
    if (set_a[0]^set_a[1]^set_a[2]==0) and (num0==num2) and (num1==num2):
        print('Yes')
    else:
        print('No')
elif len(set_a)==2:
    set_a = list(set_a)
    num0 = a.count(set_a[0])
    num1 = a.count(set_a[1])
    if (set_a[0]==0 and num1 == num0*2)or(set_a[1]==0 and num0==num1*2):
        print('Yes')
    else:
        print('No')
elif len(set_a)==1:
    if 0 in set_a:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Solution (Python):
from collections import Counter


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


c = Counter()

for a in A:
    c[a] += 1

k = list(c.keys())
v = list(c.values())
if len(v) == 1:
    if k[0]^k[0] == k[0]:
        print("Yes")
        exit()


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


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

print("No")

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

def xorsum(X):
    x = X[0]
    for i in range(1,len(X)):
        x = x ^ X[i]
    return x

if xorsum(As) == 0:
    print("Yes")
else:
    print("No")

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

if max(A)==0:
    print('Yes')
    exit()

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

if (len(B)==3 and
    C[0]^C[1]==C[2] and
    A.count(C[0])==N//3 and
    A.count(C[1])==N//3 and
    A.count(C[2])==N//3):
    print('Yes')
    exit()

if (len(B)==2 and
    min(C)==0 and
    A.count(0)==N//3 and
    A.count(max(C))==2*N//3):
    print('Yes')
    exit()

print('No')

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

Solution (Python):

N = int(input())

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

maxi = max(oa)

keta = 1

while 2 ** keta < maxi:

    keta += 1


a = []
dic = {}

for i in oa:

    new = format(i,"b")
    new = new.zfill(keta)
    a.append(new)

    if new not in dic:
        dic[new] = 1
    else:
        dic[new] += 1

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

elif len(dic) == 1:

    flag = True

    for i in dic:

        if "1" in i:
            flag = False

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

elif len(dic) == 2:

    flag1 = -1
    flag2 = -1
    cnt = 0

    for i in dic:
        
        if cnt == 0:

            if "0" in i and "1" not in i:
                flag1 = 0
                
            key1 = i
            cnt += 1

        if cnt == 1:

            if "0" in i and "1" not in i:
                flag2 = 0

            key2 = i

    if flag1 != 0 and flag2 != 0:
        print ("No")
    elif flag1 == 0 and dic[key1] == dic[key2] * 2:
        print ("Yes")
    elif flag2 == 0 and dic[key2] == dic[key1] * 2:
        print ("Yes")
    else:
        print ("No")

elif len(dic) == 3:

    key = []
    for i in dic:
        key.append(i)

    if dic[key[0]] == dic[key[1]] and dic[key[1]] == dic[key[2]]:

        Flag = True


        for i in range(len(key[0])):

            ndic = {}
            ndic["0"] = 0
            ndic["1"] = 0

            for j in range(3):
                
                if key[j][i] == "0":
                    ndic["0"] += 1
                else:
                    ndic["1"] += 1

            if ndic["1"] == 1 or ndic["1"] == 3:
                Flag = False
                break

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

    else:
        print ("No")

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
aDict={}
for key in set(a):
    aDict[key]=0
for ai in a:
    aDict[ai]+=1

canPuton=False
if len(aDict)==1:
    if 0 in aDict.keys():
        canPuton=True

elif len(aDict)==2:
    if 0 in aDict.keys():
        if n%3==0:
            canPuton=True
            for key in aDict:
                if key==0:
                    if aDict[key]!=n//3:
                        canPuton=False
                else:
                    if aDict[key]!=2*n//3:
                        canPuton=False

elif len(aDict)==3:
    a,b,c=aDict.keys()
    if n%3==0:
        if (a^b)==c:
            canPuton=True
            for key in aDict.keys():
                if aDict[key]!=n//3:
                    canPuton=False
if canPuton:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
lista = list(map(int,input().split()))
list2 = []
ans = 0
for i in lista:
    ans = ans^i

ans = str(format(ans,"b"))

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

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

last = 0

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

if last == A[-1] :
    print('Yes')
else :
    print('No')

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

a.sort()

b = set(a)

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

if len(b) == 1:
	s = a[0]
	if s^s == s:
		print("Yes")
	else:
		print("No")
	exit()
if N % 3 != 0:
	print("No")
	exit()
n = N//3

if len(b) == 2:
	s = a[0]
	t = a[-1]
	if s^s == t and s^t == s:
		if a.count(s) == 2*n and a.count(t) == n:
			print('Yes')
			exit()
		else:
			print('No')
			exit()
	s,t = [t,s]
	if s^s == t and s^t == s:
		if a.count(s) == 2*n and a.count(t) == n:
			print('Yes')
			exit()
		else:
			print('No')
			exit()
	print('No')
	exit()
if len(b) == 3:
	s,t,u = list(b)
	if s^t == u and s^u == t and t^u == s:
		if a.count(s) == n and a.count(t) == n and a.count(u) == n:
			print('Yes')
			exit()
	print('No')
	exit()
print('No')
exit()

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

As.sort()
def main():
  if N%3 == 0:
    a, b, c = As[0], As[N//3], As[2*N//3]
    for i in range(0, N//3):
      if a != As[i]:
        return "No"
    for i in range(N//3, 2*N//3):
      if b != As[i]:
        return "No"
    for i in range(2*N//3, N):
      if c != As[i]:
        return "No"
    if a^b == c and b^c == a and c^a == b:
      return "Yes"
    else:
      return "No"
  else:
    if As[0] != As[N-1]:
      return "No"
    else:
      if As[0] == 0:
        return "Yes"
      else:
        return "No"
print(main())

Solution (Python):
_input = [i for i in open(0).read().split('\n') if i]
n = int(_input[0])
a = [int(i) for i in _input[1].split()]

import functools
if functools.reduce(lambda a, b: a^b, a) == 0:
    print('Yes')
else:
    print('No')

Solution (Python):


import math
import sys


DEBUG = False


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


def solve(N, A):
    d = {}
    for a in A:
        if a not in d:
            d[a] = 0
        d[a] += 1

    if N % 3 == 0:
        if len(d) > 3:
            return False

        if len(d) == 3:
            a, b, c = d
            if d[a] != d[b] or d[b] != d[c]:
                return False
            arr = [a, b, c]
        elif len(d) == 2:
            a, b = d
            if d[a] * 2 == d[b]:
                arr = [a, b, b]
            elif d[b] * 2 == d[a]:
                arr = [a, a, b]
            else:
                return False
        else:
            (a,) = d
            arr = [a, a, a]

        a, b, c = arr
        if a ^ b == c or a ^ c == b or b ^ c == a:
            return True
        return False

    if len(d) > 1:
        return False

    (a,) = d
    if a != 0:
        return False
    return True


def main():
    N = int(inp())
    A = [int(e) for e in inp().split()]

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


if __name__ == '__main__':
    main()

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

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

if a[0] == 0:
    print("Yes")
else:
    print("No")

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

a0 = A.__next__()
tmp = 0
for i, a in enumerate(A):
  tmp ^= a

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

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
b = list(set(a))
flag = False
if len(b) == 3:
    if b[0] ^ b[1] == b[2]:
        if a.count(b[0]) == N/3 and a.count(b[1]) == N/3 and a.count(b[2]) == N/3:
            flag = True
if len(b) == 1:
    if b[0] == 0:
        flag = True
if len(b) == 2:
    if 0 in b and a.count(0) == N / 3:
            flag = True


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

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
s=0
a.sort()
if a[0]==0:
    if a.count(a[0])==n:
        s=1
    if n%3==0:
        if (a.count(a[0])==n//3 and a.count(a[n//3])==n//3*2):
            s=1
else:
    if n%3==0:
        if a.count(a[0])==n//3 and a.count(a[n//3])==n//3 and a.count(a[n//3*2])==n//3:
            x=a[0]
            y=a[n//3]
            z=a[n//3*2]
            if x^y==z and y^z==x and z^x==y:
                s=1
if s==1:
    print("Yes")
else:
    print("No")

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

xor = A[0]
for i in range(N-1):
    xor = xor ^ A[i+1]
    
if xor == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
an = [int(i) for i in input().split()]
ax = 0
for i in range(n):
  ax ^= an[i]
if ax:
  print('No')
else:
  print('Yes')

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):
from sys import stdin
import numpy as np

N = int(stdin.readline())
a = [int(x) for x in stdin.readline().rstrip().split()]

tmp = None
for i in range(N):
    if i == 0:
        tmp = a[i]
    else:
        tmp = tmp ^ a[i]

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

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

ans = "No"
cnt = {}
for ai in a:
    if ai in cnt:
        cnt[ai] += 1
    else:
        cnt[ai] = 1
if len(cnt) == 1:
    if 0 in cnt:
        ans = "Yes"
elif len(cnt) == 2:
    k = list(sorted(cnt.keys()))
    if k[0] == 0 and 2 * cnt[0] == cnt[k[1]] and 3 * cnt[0] == n:
        ans = "Yes"
elif len(cnt) == 3:
    v = list(cnt.values())
    k = list(cnt.keys())
    if v[0] == v[1] == v[2] and k[0] ^ k[1] == k[2]:
        ans = "Yes"
print(ans)

Solution (Python):
import sys

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

from collections import Counter
ac = Counter(a)

if len(ac) == 3 and len(Counter(ac.values())) == 1 and ac.most_common()[0][0]^ac.most_common()[1][0] == ac.most_common()[2][0]:
    print('Yes')
    sys.exit()
if len(ac) == 2 and ac.most_common()[0][1] == ac.most_common()[1][1] * 2 and ac.most_common()[0][0]^ac.most_common()[0][0] == ac.most_common()[1][0]:
    print('Yes')
    sys.exit()
if len(ac) == 1 and ac.most_common()[0][0] == 0:
    print('Yes')
    sys.exit()
print('No')

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

def f(a, b, c):
    if a ^ b == c and a ^ c == b and b ^ c == a:
        return True
    else:
        return False

if N % 3 != 0:
    x = a[0]
    for i in range(len(a)):
        if a[i] != x:
            print("No")
            exit()
    if f(x, x, x):
        print("Yes")
    else:
        print("No")

else:
    flag = 0
    x = [-1, -1, -1]
    for i in range(len(a)):
        if a[i] not in x:
            if flag == 3:
                print("No")
                exit()

            x[flag] = a[i]
            flag += 1

    if flag == 3:
        if f(x[0], x[1], x[2]) and a.count(x[0]) == a.count(x[1]) == a.count(x[2]):
            print("Yes")
        else:
            print("No")
    elif flag == 1:
        if f(x[0], x[0], x[0]):
            print("Yes")
        else:
            print("No")
    else:
        if a.count(x[0]) == 2 * a.count(x[1]) and f(x[0], x[0], x[1]):
            print("Yes")
        elif a.count(x[1]) == 2 * a.count(x[0]) and f(x[0], x[1], x[1]):
            print("Yes")
        else:
            print("No")

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

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


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


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

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

if n % 3 != 0:
    if sum(a) == 0:
        print("Yes")
    else:
        print("No")
else:
    count = {}
    for i in range(n):
        count.setdefault(a[i], 0)
        count[a[i]] += 1
    num = list(count.keys())
    if len(num) > 3:
        print("No")
    elif len(num) == 3:
        if count[num[0]] == count[num[1]] and count[num[1]] == count[num[2]]:
            if num[0] ^ num[1] == num[2] and num[1] ^ num[2] == num[0] and num[2] ^ num[0] == num[1]:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    elif len(num) == 2:
        if count[num[0]] == (n // 3) and count[num[1]] == (n // 3) * 2:
            if num[0] ^ num[1] == num[1] and num[1] ^ num[1] == num[0]:
                print("Yes")
            else:
                print("No")
        elif count[num[0]] == (n // 3) * 2 and count[num[1]] == (n // 3):
            if num[0] ^ num[1] == num[0] and num[0] ^ num[0] == num[1]:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    elif len(num) == 1:
        if num[0] == 0:
            print("Yes")
        else:
            print("No")

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

if len(set(a)) == 1:
    if a[0] == 0:
        print("Yes")
    else:
        print("No")
elif len(set(a)) == 2:
    b = list(set(a))
    b.sort()
    if a.count(b[0]) == N//3 and N % 3 == 0:
        print("Yes")
    else:
        print("No")

elif len(set(a)) == 3:
    b = list(set(a))
    b.sort()
    if b[0] ^ b[2] == b[1] and a.count(b[0]) == N//3 and a.count(b[1]) == N//3 and N % 3 == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
import sys




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

if N % 3 > 0:
    if a.count(0) == N:
        print('Yes')
    else:
        print('No')
    sys.exit()

items = []
for ai in a:
    if ai not in items: items.append(ai)
    if len(items) >= 3: break
items.sort()

if len(items) == 1:
    if a.count(0) == N:
        print('Yes')
    else:
        print('No')
elif len(items) == 2:
    cnt = [a.count(item) for item in items]
    if sum(cnt) < N:
        print('No')
    if items[0] > 0:
        print('No')
    elif a.count(items[1]) == a.count(0) * 2:
        print('Yes')
    else:
        print('No')
else:
    cnt = [a.count(item) for item in items]
    if sum(cnt) < N:
        print('No')
    elif items[2] != items[0] ^ items[1]:
        print('No')
    elif cnt[0] == cnt[1] == cnt[2]:
        print('Yes')
    else:
        print('No')

Solution (Python):
import numpy as np

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

if N % 3 != 0:
    if (a_list != 0).any():
        print("No")
    else:
        print("Yes")
    exit()

if (a_list == 0).all():
    print("Yes")
    exit()

keta = 0
while (a_list != 0).any():
    s = (a_list & 1).sum()
    if s != 2 * len(a_list) // 3 and s != 0:
        print("No")
        exit()
    else:
        a_list >>= 1

print("Yes")

Solution (Python):
n=int(input())
arr=list(map(int,input().split()))
dict1={}
for i in range(n):
	try:
		dict1[arr[i]]+=1
	except:
		KeyError
		dict1[arr[i]]=1
if(0 in dict1.keys()):
	if(dict1[0]==n):
		print("Yes")
	elif(n%3==0 and dict1[0]==n//3):
		if(len(dict1)==2):
			print("Yes")
		else:
			print("No")
	else:
		print("No")
else:
	if(n%3==0 and len(dict1)==3):
		arr1=[]
		for i in dict1.keys():
			if(dict1[i]!=n//3):
				print("No")
				exit(0)
			arr1.append(i)
		
		if(arr1[0]^arr1[1]==arr1[2]):
			print("Yes")
		else:
			print("No")
	else:
		print("No")

Solution (Python):
import sys
from collections import Counter

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))

    c = Counter(A)
    if 0 in c and len(c) == 1:
        return 'Yes'

    if 0 in c and len(c) == 2:
        v0 = c[0]
        for k, v in c.items():
            if k != 0 and v == 2 * v0:
                return 'Yes'

    if len(c) == 3:
        keys = []
        for k in c.keys():
            keys.append(k)

        if keys[0] ^ keys[1] != keys[2]:
            return 'No'

        vals = set()
        for v in c.values():
            vals.add(v)

        if len(vals) == 1:
            return 'Yes'

    return 'No'


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

Solution (Python):
import collections
n=int(input())
A=[int(i) for i in input().split()]
AA=collections.Counter(A)
AK=AA.keys()
AV=AA.values()

ans=True
if n%3!=0:
  ans=False
else:
  nn=n//3
  if len(AK)>3:
    ans=False
  elif len(AK)==3:
    a,b,c=AK
    if AA[a]!=nn or AA[b]!=nn or AA[c]!=nn:
      ans=False
    else:
      if a^b!=c or b^c!=a:
        ans=False
  elif len(AK)==2:
    a,b=AK
    if a*b!=0:
      ans=False
    else:
      if a<b:
        a,b=b,a
      if AA[a]!=2*nn or AA[b]!=nn:
        ans=False
  else:
    for a in AK:
      if a!=0:
        ans=False
if len(AK)==1:
  for a in AK:
    if a==0:
      ans=True
print("Yes" if ans==True else "No")

Solution (Python):
import math
import fractions

n = list(map(int, input().split()))
n = n[0]
b = list(map(int, input().split()))

b.sort()

if (n%3==0):
    flag = 1
    for i in range(3):
        for j in range(n//3-1):
            if(b[(n//3)*i + j] != b[(n//3)*i + j+1]):
                flag *= 0
            if(b[(n//3)*2]^b[n//3]!=b[0]):
                flag *= 0
    if(flag==1):
        ans="Yes"
    else:
        ans="No"
else:
    if(sum(b)==0):
        ans="Yes"
    else:
        ans="No"
print(ans)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
a = 0
for i in range(N):
    a = a ^ A[i]

if a == 0:
    output = "Yes"
else:
    output = "No"

print(output)

Solution (Python):


def f(N, A):
    S = {}
    
    for a in A:
        if not a in S:
            S[a] = 1
        else:
            S[a] += 1


    if len(S) == 1:
        if 0 in S:
            return 'Yes'
        else:
            return 'No'
    elif N%3 > 0 or len(S) > 3:
        return 'No'

    keys = list(S)

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

        return 'No'

    if (keys[0] ^ keys[1]) != keys[2]:
        return 'No'

    if S[keys[0]] != S[keys[1]] or S[keys[0]] != S[keys[2]]:
        return 'No'

    return 'Yes'



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

    print(f(N, A))

 


if __name__ == '__main__':
    main()

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

for ai in range(len(a) - 1):
    all_xor = all_xor ^ a[ai + 1]

for ai in a:
    if ai ^ all_xor != ai:
        print('No')
        exit(0)

print('Yes')
exit(0)

Solution (Python):

import sys
from collections import defaultdict

YES = "Yes"  
NO = "No"  

def solve(N: int, a: "List[int]"):
    A = defaultdict(lambda : 0)
    for x in a:
        A[x] += 1
    if len(A) == 1 and 0 in A:
        print(YES)
        return
    if N % 3 != 0:
        print(NO)
        return
    if len(A) == 2 and A[0] == N // 3:
        print(YES)
        return
    if len(A) != 3:
        print(NO)
        return
    L = list(A.keys())
    if L[0] ^ L[1] != L[2]:
        print(NO)
        return
    if A[L[0]] != A[L[1]] or A[L[0]] != A[L[2]]:
        print(NO)
        return
    print(YES)
    return



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

if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
from collections import Counter

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

k, v = list(Counter(a).keys()), list(Counter(a).values())
if len(k) == 3 and k[0] ^ k[1] == k[2] and v[0] == v[1] == v[2] :
    print('Yes')
elif len(k) == 2 and ((k[0] == 0 and v[0] * 2 == v[1]) or (k[1] == 0 and v[1] * 2 == v[0])) :
    print('Yes')
elif len(k) == 1 and k[0] == 0 :
    print('Yes')
else :
    print('No')

Solution (Python):

import sys
import os


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

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

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


solve()