Problem:
 Score : 300 points    Problem Statement Snuke has N hats. The i -th hat has an integer a_i written on it.  There are N camels standing in a circle.
Snuke will put one of his hats on each of these camels.  If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print Yes ; otherwise, print No .   The bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself.    What is XOR? The bitwise XOR x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non-negative integers x_1, x_2, \ldots, x_n is defined as follows:

- When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k 's place ( k \geq 0 ) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k 's place is odd, and 0 if that count is even.

For example, 3 \oplus 5 = 6 .      Constraints  All values in input are integers.  3 \leq N \leq 10^{5}  0 \leq a_i \leq 10^{9}         Input Input is given from Standard Input in the following format:  N  a_1  a_2  \ldots  a_{N}       Output Print the answer.        Sample Input 1 3
1 2 3      Sample Output 1 Yes   If we put the hats with 1 , 2 , and 3 in this order, clockwise, the condition will be satisfied for every camel, so the answer is Yes .        Sample Input 2 4
1 2 4 8      Sample Output 2 No   There is no such way to distribute the hats; the answer is No .

Solution (Python):
def main(N):
	a = list(map(int, input().split()))
	if a.count(0) == N:
		print("Yes")
		return
	if N%3 != 0:
		print("No")
		return
	d={}
	for i in a:
		if i in d:
			d[i] = d[i] + 1
		else:
			d[i] = 1
	if 0 in d.keys():
		if d[0] == N//3:
			for i in d.keys():
				if i == 0:
					continue
				elif d[i] % 2 != 0:
					print("No")
					return
			print("Yes")
		else:
			print("No")
	else:
		for i in d.values():
			if i != N//3:
				print("No")
				return
		lst = list(d.keys())
		if (lst[0]^lst[2]!=lst[1]) or (lst[0] != lst[1]^lst[2]) or(lst[2]!=lst[1]^lst[0]):
			print("No")
			return
		print("Yes")
	return
		
	return

main(int(input()))

Solution (Python):
n = int(input())
A = list(map(int,input().split()))
p = [0]*100000
for a in A:
    n = bin(a)[::-1]
    l = len(n)
    for i in range(l-1):
        if n[i]=='b':
            break
        if n[i] == '1':
            p[i] +=1
for a in p:
    if a%2==1:
        print("No")
        exit()
print("Yes")

Solution (Python):
n=int(raw_input())
a=sorted(map(int, raw_input().split()))

if a.count(0) == n:
    print "Yes"
elif n % 3 != 0:
    print "No"
else:
    if len(set(a[0:n/3])) == 1 and len(set(a[n/3:n/3*2])) == 1 and len(set(a[n/3*2:n])) == 1:
        if a[0] ^ a[n/3] == a[n/3*2]:
            print "Yes"
        else:
            print "No"
    else:
        print "No"

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

st = set(a)
lst = list(st)

if n == 3 and a[0] ^ a[1] == a[2]:
  print("Yes")
elif n  >= 4 and st == {0}:
  print("Yes")
elif n % 3 == 0 and len(st) == 2 and a.count(0) == n /3:
  print("Yes")
elif n % 3 == 0 and len(st) == 3 and lst[0] ^ lst[1] == lst[2] and a.count(lst[0]) == n /3 and a.count(lst[1]) == n/3:
  print("Yes")
else:
  print("No")

Solution (Python):
from collections import defaultdict

N = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)
for i in a:
    d[i] += 1

if len(d) >= 4:
    print("No")
    exit()

if len(d) == 1:
    if 0 in d:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

if len(d) == 2:
    if (N % 3) == 1 and 0 in d and d[0] == N // 3:
        print("Yes")
        exit()
    elif (N % 3) == 2 and 0 in d and d[0] == ((N // 3) + 1):
        print("Yes")
        exit()
    elif (N % 3) == 0 and 0 in d and d[0] == N // 3:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

if len(d) == 3:
    l = list(d.values())
    l.sort()
    if l[0] == l[-1]:
        keys = list(d.keys())
        if keys[0] ^ keys[1] == keys[2]:
            print("Yes")
            exit()

print("No")

Solution (Python):
n = int(input())
d = {}
for x in input().split():
    a = int(x)
    if a in d:
        d[a] += 1
    else:
        d[a] = 1
ans = "No"
if len(d) == 3 and len(set([d[key] for key in d]))== 1:
    a, b, c = d.keys()
    if a == b ^ c and b == a ^ c and c == b ^ a:
        ans = "Yes"
if len(d) == 2:
    a, b = sorted(list(d.keys()))
    if a == 0 and d[b] == 2 * d[a]:
        ans = "Yes"

if len(d) == 1:
    if list(d.keys())[0] == 0:
        ans = "Yes"
print(ans)

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

num = 0

for i in range(len(b)):
    num = num ^ b[i]


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

Solution (Python):
def solve():
    n = int(input())
    a = list(map(lambda x: int(x), input().split()))

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

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

solve()

Solution (Python):
import collections
n=int(input())
a=[int(_) for _ in input().split()]
c=collections.Counter(a)
l=len(c.keys())
k=list(c.keys())
v=list(c.values())
if l > 3:
    print("No")
elif l == 3:
    if k[0]^k[1]^k[2] == 0 and v[0]==v[1]==v[2] and n%3==0:
        print("Yes")
    else:
        print("No")
elif l == 2:
    if k[0] == 0:
        if v[1] == v[0]*2 and n%3==0:
            print("Yes")
        else:
            print("No")
    elif k[1] == 0:
        if v[0] == v[1]*2 and n%3==0:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
elif l == 1:
    if k[0] == 0:
        print("Yes")
    else:
        print("No")

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

x = False
k = {}
for i in range(N):
    if not A[i] in k:
        k[A[i]] = 1
    else:
        k[A[i]] += 1
B = 0
a = 0
if len(k.keys()) == 3:
    B = 0
    for key, val in k.items():
        if val == N // 3:
            a += 1
        B = B ^ key
elif len(k.keys()) == 2:
    for key, val in k.items():
        if val == N // 3 and key == 0:
            a += 1
        elif val == N // 3 * 2:
            a += 2
    B = 0
elif len(k.keys()) == 1:
    a = list(k.keys())
    if a[0] == 0:
        x = True

if (N % 3 == 0 and B == 0 and a == 3) or x:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

Solution (Python):
import sys
def InputToInt():
    A = input().split()
    for i in range(len(A)):
        A[i] = int(A[i])
    return A

if __name__ == '__main__':
    N = int(input())
    A = InputToInt()
    if set(A) == {0}:
        print('Yes')
        sys.exit()
    
    if N%3 != 0:
        print('No')
        sys.exit()
    A.sort()

    n = int(N/3)
    if 1 == len(set(A[0:n])) and 1 == len(set(A[n:2*n])) and 1 == len(set(A[2*n:3*n])) and A[0] == A[n] ^ A[2*n]:
        print('Yes')
    else:
        print('No')

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

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

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

Solution (Python):
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

ok = False
counts = dict(Counter(A))
keys = counts.keys()
if len(counts) <= 3:
    for k1, k2, k3 in itertools.product(keys, repeat=3):
        cnt = counts.copy()
        s = k1
        cnt[k1] -= 1
        cnt[k2] -= 1
        if k1 ^ k2 != k3:
            continue
        n = 2
        while n < N:
            cnt[k3] -= 1
            k1, k2, k3 = k2, k3, k2 ^ k3
            n += 1
        if s == k3 and not any(cnt.values()):
            ok = True
            break

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

Solution (Python):
import collections
import sys

n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
value = list(c.values())
key = list(c.keys())

if 0 in key:
    if len(c) == 1 and key[0] == 0:
        print('Yes')
        sys.exit()
    elif len(c) == 2:
        for num, count in c.items():
            if num == 0:
                num0 = count
            else:
                numelse = count
        if num0 * 2 == numelse:
            print('Yes')
            sys.exit()
    else:
        print('No')
        sys.exit()

if len(c) != 3:
    print('No')
    sys.exit()

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

if key[0] ^ key[1] ^ key[2] != 0:
    print('No')
    sys.exit()

print('Yes')

Solution (Python):
from collections import Counter

N= int(input())

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

x = Counter(a)

ok = False
if len(x) == 3 and len(a) % 3 == 0:
    for i in a:
        if x[i] != len(a) // 3:
            break
    else:
        w = 0
        for j in x:
            w ^= j
        if w == 0:
            ok = True
elif len(x) == 1:
    if x.get(0) is not None:
        ok = True
elif len(x) == 2 and len(a) % 3 == 0:
    if x.get(0) is not None and x[0] == len(a) // 3:
        ok = True

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

Solution (Python):
import numpy as np

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

a = np.array(a)




def make_Xor(a,b):
	d_ = []
	for i in range(len(a)):
		if a[i] == b[i]:
			d_.append("0")
		else:
			d_.append("1")
	return d_


def judge_of_3(a):
	a_ = []
	a_.append(list(format(a[0],'b')))
	a_.append(list(format(a[1],'b')))
	a_.append(list(format(a[2],'b')))
	max_len = max(len(a_[0]),len(a_[1]),len(a_[2]))
	for i in range(3):
		while len(a_[i]) < max_len:
			a_[i].insert(0,'0')
	if make_Xor(a_[0],a_[1]) == a_[2]:
		return True
	else:
		return False
	
	
judge = True

if N % 3 == 0:
	a_1 = np.unique(a)
	if len(a_1) <= 3:
		a = list(a)
		a.sort()
		div_3 = N // 3
		for i in range(3):
			if a[i * div_3] != a[(i+1) * div_3 - 1]:
				judge = False
		a_1 = [a[0],a[div_3],a[2*div_3]]
		if judge:
			if judge_of_3(a_1):
				judge = True
			else:
				judge = False
	else:
		judge = False
else:
	a_1 = np.unique(a)
	a_1 = list(a_1)
	if len(a_1) != 1:
		judge = False
	if a_1[0] != 0:
		judge = False

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

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

is_yes = False

a_n_unique = list(set(a_n))

if len(a_n_unique) == 1:
    if a_n_unique[0] == 0:
        is_yes = True

elif N % 3 == 0:
    if len(a_n_unique) == 2:
        if a_n_unique[0] == 0 or a_n_unique[1] == 0:
            if a_n.count(a_n_unique[0]) > a_n.count(a_n_unique[1]):
                if a_n.count(a_n_unique[0]) / a_n.count(a_n_unique[1]) ==2:
                    is_yes = True
            else:
                if a_n.count(a_n_unique[1]) / a_n.count(a_n_unique[0]) ==2:
                    is_yes = True
    elif len(a_n_unique) == 3:
        if a_n_unique[0] ^ a_n_unique[1] == a_n_unique[2]:
            if a_n.count(a_n_unique[0]) == a_n.count(a_n_unique[1]) and a_n.count(a_n_unique[0]) == a_n.count(a_n_unique[2]):
                is_yes = True


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

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

import collections
c = collections.Counter(a)
unique = list(set(a))

from operator import xor
v = []
for k in c.keys():
    v.append(c[k])
v.sort()

flag = False
if n % 3 == 0:
    if len(v) == 1:
        if v == [n] and unique[0] == 0:
            flag = True
    elif len(v) == 2:
        if v == [n // 3, n // 3 * 2]:
            if c[unique[0]] == n // 3:
                if xor(unique[1], unique[0]) == unique[1] and xor(unique[1], unique[1]) == unique[0]:
                    flag = True
            else:
                if xor(unique[0], unique[1]) == unique[0] and xor(unique[0], unique[0]) == unique[1]:
                    flag = True
    elif len(v) == 3:
        if v == [n // 3, n // 3, n // 3]:
            if xor(unique[0], unique[1]) == unique[2] and xor(unique[1], unique[2]) == unique[0] and xor(unique[2], unique[0]) == unique[1]:
                flag = True
else:
    if v == [n]:
        flag = True

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

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

if n % 3 != 0:
    if all(map(lambda x: x == 0, aa)):
        print('Yes')
    else:
        print('No')
else:
    m = n // 3

    cnt_map = {}
    for a in aa:
        if a not in cnt_map:
            cnt_map[a] = 0
        cnt_map[a] += 1

    if len(cnt_map.keys()) > 3:
        print('No')
    elif len(cnt_map.keys()) == 1:
        k = list(cnt_map.keys())[0]
        if k == 0:
            print('Yes')
        else:
            print('No')
    elif len(cnt_map.keys()) == 2:
        k1, k2 = cnt_map.keys()
        if k1 > k2:
            k1, k2 = k2, k1
        if k1 == 0 and cnt_map[k1] == m:
            print('Yes')
        else:
            print('No')
    elif len(cnt_map.keys()) == 3:
        a, b, c = cnt_map.keys()
        if a == b ^ c and cnt_map[a] == m and cnt_map[b] == m and cnt_map[c] == m:
            print('Yes')
        else:
            print('No')

Solution (Python):
a = int(input())
x = list(map(int,input().split()))
ax = list(set(x))
x.sort()
ax = list(set(x))
def ch(l):
    
    for i, j ,k in zip(l,l[1:] + [l[0]], l[2:] + [l[0]] +[l [1]]):
        if j != i ^ k: break
    else:
        return(1)
    return(0)
def Y(a,t = 0):
    if a==t : print('YES')
    else : print('NO')
def y(a, t =0):
    if a==t : print('Yes')
    else : print('No')
if len(ax) < 3:
    if (sum(x) == 0) :
        print("Yes")
        exit()
    if (len(ax)) <2:
        print("No")
        exit()
    if x.count(0)*2 == x.count(ax[1]) and len(x) == x.count(0) + x.count(ax[1]):
        print("Yes")
        exit()
        
    print("No")
    exit()
t = (len(x) == x.count(ax[0]) + x.count(ax[1]) + x.count(ax[2])) * (x.count(ax[1]) == x.count(ax[0]) and x.count(ax[0]) == x.count(ax[2]))*ch(ax)

y(1,t)

Solution (Python):
if __name__ == '__main__':
    N = int(input())
    a = [int(x) for x in input().split()]
    n0 = a.count(0)
    b = [x for x in a if x!=0]
    ans = 'No'
    if n0==N:
        ans = 'Yes'
    elif n0 != 0 and a.count(b[0])==n0*2 and N==n0*3:
        ans = 'Yes'
    elif len(set(b))==3:
        b1,b2,b3 = list(set(b))
        n1 = b.count(b1)
        n2 = b.count(b2)
        n3 = b.count(b3)
        if b1^b2==b3 and n1==n2==n3:ans = 'Yes'
    print(ans)

Solution (Python):
from sys import stdin
import numpy as np
from operator import itemgetter

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

ans = "Yes"
L = []
L_cnt = {}
for a in A:
    if a in L:
        L_cnt[a]+=1
        continue

    if len(L)>=3:
        ans = "No"
        break
    L.append(a)
    L_cnt[a]=1

if len(L)==3:
    l1, l2, l3 = L
    if N%3!=0:
        ans="No"
    if not L_cnt[l1]==L_cnt[l2]==L_cnt[l3]:
        ans="No"
    while ans=="Yes":
        sumL = l1%2 + l2%2 + l3%2
        if sumL!=0 and sumL!=2:
            ans = "No"
            break
        l1 = l1//2
        l2 = l2//2
        l3 = l3//2
        if l1+l2+l3==0:
            break
    print(ans)
elif len(L)==2:
    if N%3!=0:
        ans="No"
    if L_cnt[0]!=N//3:
        ans="No"
    if L[0]!=0 and L[1]!=0:
        ans="No"
    print(ans)
else:
    if sum(L)!=0:
        ans="No"
    print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
flag = True
ans = 0
for i in a:
    ans = i ^ ans

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

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

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

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

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

Solution (Python):
from collections import defaultdict
n = int(input())
result = False
numbers = defaultdict(int)
inputNum = list(input().split())
for i in range(n):
    numbers[inputNum[i]] += 1
if len(numbers) == 3:
    if n % 3 == 0:
        vals = list(numbers.values())
        if vals[0] == vals[1] and vals[1] == vals[2]:
            keys = list(numbers.keys())
            if int(keys[0]) ^ int(keys[1]) == int(keys[2]):
                result = True
elif len(numbers) == 2:
    if n % 3 == 0:
        vals = list(numbers.values())
        keys = list(numbers.keys())
        if keys[0] == "0":
            if vals[1] == vals[0] * 2:
                result = True
        elif keys[1] == "0":
            if vals[0] == vals[1] * 2:
                result = True
elif len(numbers) == 1:
    keys = list(numbers.keys())
    if keys[0] == "0":
        result = True

if result == True:
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
a_list=list(map(int,input().split()))
a=set(a_list)
if 0 not in a:
  if len(a)!=3:
    print("No")
    exit()
  a=list(a)
  count_a0=a_list.count(a[0])
  count_a1=a_list.count(a[1])
  count_a2=a_list.count(a[2])
  if count_a0!=count_a1 or count_a1!=count_a2 or count_a2!=count_a0:
    print("No")
    exit()
  if a[0]==a[1]^a[2]:
    print("Yes")
  else:
    print("No")
else:
  if len(a)==2:
    a=list(a)
    count_a0=a_list.count(0)
    count_a1=a_list.count(a[0]) if a[0]!=0 else a_list.count(a[1])
    if count_a0*2!=count_a1:
      print("No")
    else:
      print("Yes")
  elif len(a)==1:
    if 0 in a:
      print("Yes")
    else:
      print("No")
  else:
    print("No")

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

sum_xor = 0
for _a in a:
  sum_xor = sum_xor ^ _a

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

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

ans = 0
for i in range(N):
    ans = ans^A[i]

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

Solution (Python):
def main():
    n = int(input())
    a = list(map(int,input(' ').split(' ')))
    l = int(bin(a[-1]^a[1]),2)
    r = a[0]
    for i in range(1,n):
        l = int(bin(l^(a[i-1]^a[(i+1)%n])),2)
        r = int(bin(r^a[i]),2)
    return r==l

if __name__ == '__main__':
    if main():
        print('Yes')
    else:
        print('No')

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


dic = {}
m = 0
for i in range(len(a)):
    if a[i] in dic.keys():
        dic[a[i]] += 1
    else:
        dic[a[i]] = 1

ls = list(dic.keys())

if len(ls) <= 2 and 0 in ls:
    ls.sort()
    
    if len(ls) == 2:
        
        if 2 * dic[ls[0]] == dic[ls[1]]:
            print("Yes")
        else:
            print("No")
    
    else:
        print("Yes")

elif len(ls) == 3:
    ls.sort()
    if  dic[ls[0]] == dic[ls[1]] and dic[ls[0]] == dic[ls[2]]:
        if list(ls)[0] ^ list(ls)[1] == list(ls)[2]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

else:
    print("No")

"""
for i in a:
    if i == max(a):
        m = i
    
for i in a:
    a_b.append(bin(i)[:2]+'0'*(len(bin(m))-len(bin(i)))+bin(i)[2:])





a = int("0b" + "0" * (len(bin(m))-2),2)

for i in range(len(a_b)):
    a = a ^ int(a_b[i],2)
if a == 0:
    print("Yes")
else:
    print("No")
"""

Solution (Python):
n=input()
l=map(int,raw_input().split())
ans=0
for i in xrange (n):
  ans^=l[i]
if ans:
  print "No"
else:
  print "Yes"

Solution (Python):
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
C = Counter(a)
if len(C) == 1:
    if a[0] == 0:
        print('Yes')
    else:
        print('No')
elif len(C) == 3:
    v = list(C.keys())
    if v[0] ^ v[1] != v[2]:
        print('No')
        quit()
    x = C[a[0]]
    for k in C:
        if C[k] != x:
            print('No')
            quit()
    print('Yes')
else:
    if 0 not in C:
        print('No')
        quit()
    for k in C:
        if k != 0:
            if C[k] == 2 * C[0]:
                print('Yes')
            else:
                print('No')
            break

Solution (Python):
def main():
  n = int(input())
  alist = list(sorted(map(int, input().split())))
  aset = set(alist)
  tmpal = list(aset)
  if len(aset) > 3:
    print('No')
  elif len(aset) == 1:
    if tmpal[0] == 0:
      print('Yes')
    else:
      print('No')
  elif n % 3 != 0:
    print('No')
  else:
    if len(aset) == 2:
      if alist.count(0) == n // 3:
        print('Yes')
      else:
        print('No')
    else:
      if tmpal[0] ^ tmpal[2] == tmpal[1]:
        nd = {tmpal[0]: 0, tmpal[1]: 0, tmpal[2]: 0}
        for a in alist:
          nd[a] += 1
        if nd[tmpal[0]] == nd[tmpal[1]] and nd[tmpal[1]] == nd[tmpal[2]]:
          print('Yes')
        else:
          print('No')
      else:
        print('No')


if __name__ == '__main__':
  main()

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

def main():
    N = input()
    A = [int(a) for a in input().split()]
    dic = {}

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

    if len(dic)>3:
        print("No")
    else:
        key = [k for k in dic]
        key.sort(key=lambda x:dic[x])
        if len(dic)==1:
            if key[0] == 0:
                print("Yes")
            else:
                print("No")
        elif len(dic)==2:
            if key[0] == 0 and key[1]^key[1]==0 and dic[key[1]]==dic[key[0]]*2:
                print("Yes")
            else:
                print("No")
        else:
            if key[0]^key[1] != key[2]:
                print("No")
            else:
                if dic[key[0]]==dic[key[1]]==dic[key[2]]:
                    print("Yes")
                else:
                    print("No")


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
from collections import Counter
n = int(input())
a = list(map(int, input().split(" ")))


















c = Counter(a).most_common()
if len(c) == 3 and c[0][0] ^ c[1][0] == c[2][0] and c[0][1] == c[1][1] and c[1][1] == c[2][1]:
    ans = True
elif len(c) == 2 and c[0][0] ^ c[1][0] == c[0][0] and (c[0][1] * 2 == c[1][1] or c[0][1] == c[1][1] * 2):
    ans = True
elif len(c) == 1 and c[0][0] == 0:
    ans = True
else:
    ans = False
print("Yes" if ans else "No")

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

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

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

p = n // 3
if 0 in a:
    
    zero = a.count(0)
    if zero != p:
        print('No')
        exit()
    if a.count(max(a)) != p * 2:
        print('No')
        exit()
    print('Yes')
    exit()

a = sorted(a)


if a.count(a[0]) != p or a.count(a[p]) != p or a.count(a[-1]) != p:
    print('No')
else:
    if a[0] ^ a[p] == a[-1]:
        print('Yes')
    else:
        print('No')

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

res = A[0] ^ A[1]
for i in range(2, N):
    res ^= A[i]
if res == 0:
    print("Yes")
else:
    print("No")

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

nums = {}

for i in range(len(a)):
  if int(a[i]) not in nums:
    nums[int(a[i])] = 1
  else:
    nums[int(a[i])] += 1



if len(nums) > 3:
  print("No")
else:
  snums = sorted(nums.items())
  
  if(snums[0][0] == 0 and len(snums) == 1):
    print("Yes")
  elif(snums[0][0] == 0 and len(snums) == 2 and snums[0][1]*2 == snums[1][1] ):
    print("Yes")
  elif(snums[0][0] != 0 and len(snums) == 3 
       and snums[0][1] == snums[1][1] == snums[2][1] ):
    if snums[0][0] ^ snums[1][0] == snums[2][0]:
      print("Yes")
    else:
      print("No")
  else:
    print("No")

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
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 II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    N = II()
    a = LI()

    from collections import Counter

    cnt = Counter(a)

    if len(cnt) == 1 and a[0] == 0:  
        print('Yes')
        return

    if len(cnt) == 2:
        x, y = cnt.keys()
        if x^y==y and y^y==x and cnt[x]*2==cnt[y]:
            print('Yes')
            return
        if x^x==y and x^y==x and cnt[y]*2==cnt[x]:
            print('Yes')
            return

    if len(cnt) == 3:
        x, y, z = cnt.keys()
        if x^y==z and y^z==x and z^x==y and cnt[x]==cnt[y]==cnt[z]:
            print('Yes')
            return

    print('No')




main()

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

ans = 0
for i in a:
    ans ^= i
if ans == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter
N=int(input())
a=list(map(int,input().split()))
tmp=Counter(a)
if len(tmp.keys())!=3 or len(a)%3!=0:
    ans=list(tmp.values())
    if len(tmp.keys())==2 and 0 in tmp.keys():
        if tmp[0]*2 in ans:
            print("Yes")
            exit()
        
        
    if sum(a)==0:
        print("Yes")
        exit()
    print("No")
    exit()
else:
    
    key=list(tmp.keys())
    ans=list(tmp.values())
    
    
    if ans[0]==ans[1] and ans[0]==ans[2]:
        if key[0]^key[1]==key[2]:
            print("Yes")
            exit()
print("No")

Solution (Python):
N = int(input())
l = list(map(int,input().split(' ')))
dp = {}
k = True
for i in range(N):
    tmp = l[i]
    if tmp in dp:
        dp[tmp] +=1
    else:
        if len(dp)==3:
            k = False
            break
        else:
            dp[tmp] = 1

flag = False
num_l = []
ans_l = []
if k:
    if 0 in dp:
        if len(dp)==1:
            flag = True
        elif len(dp)==2:
            num_l = [None]*2
            ans_l = [None]*2
            for key,val in dp.items():
                if key==0:
                    num_l[0] = key
                    ans_l[0] = val
                else:
                    num_l[1] = key
                    ans_l[1] = val
            if ans_l[0]*2==ans_l[1]:
                flag = True
    else:
        if len(dp)==3:
            for key,val in dp.items():
                num_l.append(key)
                ans_l.append(val)
            if ans_l[0]==ans_l[1] and ans_l[0]==ans_l[2]:
                if num_l[0]^num_l[1]==num_l[2]:
                    flag = True
if flag:
    print('Yes')
else:
    print('No')

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

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

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

Solution (Python):
from collections import Counter 
import sys
def No():
    print("No")
    sys.exit()

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

N=int(input())
A = [int(i) for i in input().split()]
C=Counter(A)
if N%3==0:
    if len(C)==1:
        if C.get(0,0):
            Yes()
        else:No()
    if len(C)==2:
        if C.get(0,0) == N//3:
            Yes()
        else:No()
    if len(C)>3:No()
    if not all([v==N//3 for v in C.values()]):
        No()    
    bits = [format(a,"040b") for a in C.keys()]
    if all([z.count("0")%2 for z in zip(*bits)]):
        print("Yes")
    else:No()
else:
    if len(C)==1 and C.get(0,0):
        Yes()
    else:No()

Solution (Python):
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op



inf = float('inf')
input = stdin.readline


def main():
    n = get_int()
    A = get_li()
    if n % 3 != 0:
        if any(a != 0 for a in A):
            print('No')
            return
    else:
        cnt = Counter(A)
        if len(cnt.items()) > 3:
            print('No')
            return
        elif len(cnt.items()) == 3:
            a, b, c = cnt.most_common(3)
            if a[0] ^ b[0] ^ c[0] != 0:
                print('No')
                return
        elif len(cnt.items()) == 2:
            a, b = cnt.most_common(2)
            if b[0] != 0:
                print('No')
                return
        else:
            a = cnt.most_common(1)[0]
            if a[0] != 0:
                print('No')
                return
        for v, c in cnt.items():
            if c % (n // 3) != 0:
                print('No')
                return
    print('Yes')
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


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


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def gets(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()

Solution (Python):
import numpy as np

size=input()
arr=np.array(input().split(" "),dtype=np.int32)

bit_array=[]
length_array=[]

for x in arr:
    bit_array.append(bin(x))
    length_array.append(len(bin(x)))

max_length=max(length_array)

fixed_bit_array=[]
for x,y in zip(bit_array,length_array):
    if y==max_length:
        fixed_bit_array.append(x[2:])
    else:
        pad=max_length-y
        x="{}{}".format("0"*pad,x[2:])
        fixed_bit_array.append(x)


result=[]
for i in range(max_length-2):
    count=0
    for x in fixed_bit_array:
        if x[i]=="1":
            count+=1
    if count%2==0:
        result.append("0")
    else:
        result.append("1")

if "1" in "".join(result):
    print("No")
else:
    print("Yes")

Solution (Python):
N=int(input())
a=[0]*N


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

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