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 sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count




N = I()
L = IL()
b = 0
for l in L:
  b ^= l
if b:
  print("No")
else:
  print("Yes")

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

if s[0] == n:
    print("Yes")
elif len(s) == 2 and s[0] == n // 3:
    print("Yes")
elif len(s) == 3:
    res = 0
    num = set()
    for k, v in s.items():
        res ^= k
        num.add(v)
    if not res and len(num) == 1:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
from collections import defaultdict
n = int(input())
a = [int(i) for i in input().split()]
d = defaultdict(int)
for i in a:
    d[i] += 1
print("Yes"
if(
    (len(d) == 3 and len(set(d.values())) == 1 and n % 3 == 0 and (list(d.keys())[0] ^ list(d.keys())[1] ^ list(d.keys())[2] == 0))
    or (len(d) == 2 and n % 3 == 0 and d[0] == n // 3 and (0 in d.keys()))
    or (sum(a) == 0)
)
else "No")

Solution (Python):
import sys
from collections import Counter

input = sys.stdin.readline


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

    c = Counter(a)
    ans = "No"
    if len(c) == 3:
        v = list(c.values())
        if v[0] == v[1] == v[2]:
            k = list(c.keys())
            if (k[0] ^ k[1] == k[2]) and (k[1] ^ k[2] == k[0]) and (k[2] ^ k[0] == k[1]):
                ans = "Yes"
    elif len(c) == 2:
        v = list(c.values())
        k = list(c.keys())
        v[0], v[1] = min(v), max(v)
        k[0], k[1] = min(k), max(k)
        if k[0] == 0 and v[0] * 2 == v[1]:
            ans = "Yes"
    elif len(c) == 1:
        k = list(c.keys())
        if k[0] == 0:
            ans = "Yes"

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
if n % 3 == 0:
    a.sort()
    for i in range(n // 3 - 1):
        if a[i] != a[i + 1]:
            print('No')
            exit(0)
    for i in range(n // 3, n // 3 * 2 - 1):
        if a[i] != a[i + 1]:
            print('No')
            exit(0)
    for i in range(n // 3 * 2, n - 1):
        if a[i] != a[i + 1]:
            print('No')
            exit(0)
    if a[0] ^ a[n // 3] == a[n // 3 * 2]:
        print('Yes')
    else:
        print('No')
else:
    if any(a):
        print('No')
    else:
        print('Yes')

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

Solution (Python):
from collections import defaultdict

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

for num in a:
    dd[num] += 1
    if len(dd) >= 4:
        print("No")
        exit()

if len(dd) == 1:    
    if dd[0] > 0:
        print("Yes")
    else:
        print("No")
    exit()

if n % 3 != 0:
    print("No")
    exit()
    
    
if len(dd) == 2:
    if dd[0] == n // 3:
        print("Yes")
    else:
        print("No")
        
else:
    lst = []
    for i, j in dd.items():
        lst.append(i)
        if j != n // 3:
            print("No")
            exit()
    if lst[0] ^ lst[1] ^ lst[2] == 0:
        print("Yes")
    else:
        print("No")

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

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


N = int(input())
a = list(map(int, input().split()))
if N % 3 and a != [0] * N:
    print("No")
    exit()

nums = Counter(a)
ks = sorted(nums)
vs = sorted(nums.values())
if (
    (len(nums) == 1 and ks[0] == 0)
    or (len(nums) == 2 and ks[0] == 0 and vs[0] == N // 3)
    or (
        len(nums) == 3
        and all(v == N // 3 for v in vs)
        and reduce(lambda x, y: x ^ y, ks) == 0
    )
):
    print("Yes")
else:
    print("No")

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

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

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

def print_end(x):
    pr = ['No','Yes']
    print(pr[x])
    exit()

if(sum(a)==0):
    print_end(1)

if(n%3!=0):
    print_end(0)

set_a = set(a)
if(len(set_a)==1)|(len(set_a)>3):
    print_end(0)

if(len(set_a)==2):
    a0,a1 = sorted(list(set_a))
    if(a0!=0):
        print_end(0)
    if(a.count(a0) * 2 == a.count(a1)):
        print_end(1)
    print_end(0)
else:
    a0,a1,a2 = sorted(list(set_a))
    if(a.count(a0) == a.count(a1) == a.count(a2))&((a0^a1)==a2):
        print_end(1)
    print_end(0)

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

Solution (Python):
from collections import Counter

def solve():
    N = int(input())
    a = list(map(int, input().split()))
    
    if len(set(a)) == 1 and a[0] == 0:
        return 'Yes'
    
    if N % 3 == 0:
        s = list(set(a))
        c = Counter(a)
        if len(s) == 2:
            i = max(c.items(), key=lambda x: x[1])
            j = min(c.items(), key=lambda x: x[1])
            if i[0] ^ j[0] == i[0] and i[1] == (2 * N // 3) and j[1] == (N // 3):
                return 'Yes'
        if len(s) == 3:
            if c[s[0]] == c[s[1]] and c[s[1]] == c[s[2]] and s[0] ^ s[1] == s[2]:
                return 'Yes'
        
    return 'No'

print(solve())

Solution (Python):
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

INF = 10**18
eps = 10**-7

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

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

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

from collections import Counter

ac = Counter(a).most_common()

if len(ac) == 3 and ac[0][1] == ac[1][1] == ac[2][1] and ac[0][0] ^ ac[1][0] == ac[2][0]:
    print('Yes')

elif len(ac) == 2 and ac[0][1] == ac[1][1]*2 and ac[0][0] ^ ac[0][0] == ac[1][0]:
    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 c[0] == n:
        print('Yes')
    elif n % 3 == 0 and c[0] == n // 3 and len(set(A)) == 2:
        print('Yes')
    elif n % 3 == 0 and len(set(A)) == 3:
        x, y, z = list(set(A))
        if x ^ y ^ z == 0 and c[x] == c[y] == c[z]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')


if __name__ == '__main__':
    main()

Solution (Python):
from itertools import product

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

c = {}
for e in a:
    c.setdefault(e, 0)
    c[e] += 1

if len(set(c)) > 3:
    print('No')
    exit()

t = {}
for x, y in product(set(c), repeat=2):
    i = x
    j = y
    t[i] = 1
    if t[i] > c[i]:
        continue
    t.setdefault(j, 0)
    t[j] += 1
    if t[j] > c[j]:
        continue
    for _ in range(N - 2):
        k = i ^ j
        t.setdefault(k, 0)
        t[k] += 1
        c.setdefault(k, 0)
        if t[k] > c[k]:
            j = -1
            break
        i, j = j, k
    if j ^ x == y:
        print('Yes')
        exit()
print('No')

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

import sys
from collections import Counter
d = Counter(A)

if d[0] == N:
    print("Yes")
    sys.exit()

if d[0] == N // 3:
    for x in d.keys():
        if d[x] == 2 * N // 3:
            print("Yes")
            sys.exit()

third = N // 3
if len(d.keys()) == 3:
    a, b, c = d.keys()
    if d[a] == d[b] and d[b] == d[c]:
        if a ^ b ^ c == 0:
            print("Yes")
            sys.exit()

print("No")

Solution (Python):
from collections import Counter
n = int(input())
a = [int(x) for x in input().split()]

d = Counter()
for x in a:
    d[x] += 1

if d[0] == n:
    print('Yes')
elif len(d.keys()) == 2 and d[0] == n//3:
    print('Yes' if d[0] == n//3 else 'No')
elif len(d.keys()) == 3:
    p, q, r = d.keys()
    if d[p] == d[q] and d[q] == d[r] and p ^ q ^ r == 0:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Solution (Python):
from collections import Counter
n = int(input())
a = [int(x) for x in input().split()]

if n % 3:
    print('Yes' if len(set(a)) == 1 else 'No')
else:
    d = Counter()
    for x in a:
        d[x] += 1
    if len(d.keys()) == 1:
        print('Yes' if d[0] == n else 'No')
    elif len(d.keys()) == 2:
        print('Yes' if d[0] == n//3 else 'No')
    elif len(d.keys()) == 3:
        p, q, r = d.keys()
        if d[p] == d[q] and d[q] == d[r] and p ^ q ^ r == 0:
            print('Yes')
        else:
            print('No')
    else:
        print('No')

Solution (Python):
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() 
ni = lambda: int(readline().rstrip()) 
nm = lambda: map(int, readline().split()) 
nl = lambda: list(map(int, readline().split())) 

n = ni()
a = nl()

sa = set(a)
l = len(sa)

if l == 1:
    if a[0] == 0:
        print('Yes')
    else:
        print('No')
elif len(a) % 3 == 0:
    if l == 2:
        if a.count(0) == n // 3:
            print('Yes')
        else:
            print('No')
    elif l == 3:
        if all([a.count(ele) == n // 3 for ele in sa]):
            li = list(sa)
            if li[0] ^ li[1] ^ li[2] == 0:
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    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 ^= A[i]

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

Solution (Python):
_, *a = map(int, open(0).read().split());z = 0
for b in a:z ^= b
print("YNeos"[z>0::2])

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

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

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

Solution (Python):
n = int(input())
li = list(map(int,input().split()))
se = set(li)
if len(se) == 1:
    if sum(se) == 0:
        print('Yes')
    else:
        print('No')
elif len(se) == 2:
    a,b = sorted(se)
    if a == 0:
        if li.count(a) * 3 == n:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
elif len(se) == 3:
    a,b,c = se
    if li.count(a) == li.count(b) == li.count(c):
        if a^b == c:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Solution (Python):
from collections import Counter
from functools import reduce
from operator import xor
n = int(input())
a = Counter(map(int , input().split()))

if n % 3 == 0:
    if len(a) == 3:
        if 0 == reduce(xor, a) and all(v == n // 3 for v in a.values()):
            print("Yes")
        else:
            print("No")
    elif len(a) == 2:
        if 0 in a and a[0] == n // 3:
            print("Yes")
        else:
            print("No")
    else:
        if 0 in a:
            print("Yes")
        else:
            print("No")
else:
    if len(a) == 1 and 0 in a:
        print("Yes")
    else:
        print("No")

Solution (Python):
N = input()
a_list = [int(_c) for _c in input().split(" ")]

xor = 0
for a in a_list:
    xor = xor ^ a

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

Solution (Python):
def count(l):
    res = {}
    for d in l:
        if d in res:
            res[d] += 1
        else:
            res[d] = 1
    return res

n = float(input())
data = list(map(int, input().split()))
t = count(data)
if len(t) == 3:
    ks = list(t.keys())
    if 0 not in t and all(i == n/3 for i in t.values()) and ks[0]^ks[1] == ks[2]:
        print('Yes')
    else:
        print('No')

elif len(t) == 2:
    if 0 in t and t[0] == n/3:
        print('Yes')
    else:
        print('No')

elif len(t) == 1:
    if 0 in t:
        print('Yes')
    else:
        print('No')

else:
    print('No')

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



if all([x == 0 for x in a]):
    print("Yes")
    sys.exit()

    

if n % 3 != 0:
    print("No")
    sys.exit()

c = Counter(a)

cli = list(c.keys())
cval = list(c.values())



if len(cli) > 3 or len(cli) <2:
    print("No")
    sys.exit()


if len(cli) == 2 and 0 in cli:
    if c[0] == n // 3:
        print("Yes")
        sys.exit()
    else:
        print("No")
        sys.exit()


if not all([x == cval[0] for x in cval]):
    print("No")
    sys.exit()

ans_0 = cli[1] ^ cli[2] == cli[0]
ans_1 = cli[2] ^ cli[0] == cli[1]
ans_2 = cli[0] ^ cli[1] == cli[2]

print("Yes" if all([ans_0, ans_1, ans_2]) else "No")

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
from collections import deque,defaultdict,Counter

def main():
    N = int(input())
    A = list(map(int,input().split()))
    if N%3 == 0:
        C = Counter(A)
        flag = True
        if len(C) > 3:
            flag = False
        elif len(C) == 3:
            a,b,c = tuple(C.keys())
            for _ in range(3):
                if a^b == c:
                    a,b,c = b,c,a
                else:
                    flag = False
                    break
            if not all(v*3 == N for v in C.values()):
                flag = False
        elif len(C) == 2:
            a,b = tuple(C.keys())
            if a*b == 0:
                if C[0]*3 == N:
                    pass
                else:
                    flag = False
            else:
                flag = False
        else:
            if 0 not in C:
                flag = False
        print('Yes' if flag else 'No')
    else:
        if set(A) == {0}:
            print('Yes')
        else:
            print('No')
if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
al = list(map(int,input().split()))
bit = [0]*35

for i in range(N):
  for j in range(35):
    if (al[i]>>j)&1 == 1:
      bit[j] += 1
      
for j in range(35):
  if bit[j] %2 == 1:
    print("No")
    exit()
    
print("Yes")

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
count=0
for i in l:
    count^=i
flag=True
for j in l:
    if j!=j^count:
        flag=False
        break
if flag==True:
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import defaultdict

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

if len(set(a)) == 1 and list(set(a))[0] == 0:
    print('Yes')
    exit()

if n % 3 == 0 and len(set(a)) == 3:
    x = list(set(a))
    e = x[0]
    b = x[1]
    c = x[2]
    if e ^ b != c:
        print('No')
        exit()
    if b ^ c != e:
        print('No')
        exit()
    if c ^ e != b:
        print('No')
        exit()
    d = defaultdict(int)
    for i in a:
        d[i] += 1
    if d[e] != d[b] or d[b] != d[c] or d[c] != d[e]:
        print('No')
        exit()
    print('Yes')
elif n % 3 == 0 and len(set(a)) == 2:
    x = list(set(a))
    x.sort()
    if x[0] == 0:
        t = 1
    else:
        print('No')
        exit()
    d = defaultdict(int)
    for i in a:
        d[i] += 1
    if d[x[0]]*2 == d[x[1]]:
        print('Yes')
        exit()
    print('No')
else:
    print('No')

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    A = Counter(LI())
    ok = True
    if(N%3==0):
        B = []
        for a,c in A.items():
            if(c%(N//3)!=0):
                print("No")
                return 
                break
            for _ in range(c//(N//3)):
                B.append(a)
        if((B[0]^B[1]^B[2]) != 0):
            ok = False
    else:
        ok = len(A)==1
        
    if(ok):
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
s = set(a)
c = Counter(a)

if n%3 != 0:
  if s == {0}:
    print('Yes')
  else:
    print('No')
else:
  if len(c) > 3:
      print('No')
  elif len(c) == 3:
    a,b,q = list(s)
    if a^b == q and c[a] == n//3 and c[b] == c[q]:
      print('Yes')
    else:
      print('No')
  elif len(c) == 2:
    if not 0 in s:
      print('No')
    else:
      if c[0] == n//3:
        print('Yes')
      else:
        print('No')
  elif len(c) == 1:
    if s == {0}:
      print('Yes')
    else:
      print('No')

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

from functools import reduce
from operator import xor
ans = reduce(xor, A)

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

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

if 1:
    tmp=0
    for item in a:
        tmp=tmp^item
    if tmp==0:
        print("Yes")
    else:
        print("No")
else:
    tmp=0
    for item in a:
        tmp=tmp^item
    if tmp==2**len(str(bin(max(a))[2:]))-1:
        print(tmp)
        print("Yes")
    else:
        print("No")

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


As = set(A)

if len(As) == 3:
    k = 0
    x, y, z = As
    if x^y != z and x^z != y and y^z != x:
        print('No')
        k = 1
    n = N // 3
    if k == 0:
        for i in [x, y, z]:
            if A.count(i) != n and A.count(i) != n+1:
                k = 1
                print('No')
                break
        if k == 0:
            print('Yes')
elif len(As) == 2:
    k = 0
    if 0 in As:
        if A.count(0) == 2:
            pass
        elif A.count(0) == N//3 or A.count(0) == N//3 + 1:
            k = 1
            print('Yes')
    if k == 0:
        print('No')
elif len(As) == 1:
    if 0 in As:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Solution (Python):




n = int(input())
A = list(map(int, input().split()))
num = 0
for a in A:
    num = num ^ a

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

Solution (Python):
n = int(input())
A = list(map(int,input().split()))
ans = 0
for a in A:
    ans = a^ans
if ans==0:
    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^=A[i]
print('Yes' if ans==0 else 'No')

Solution (Python):
from collections import Counter
n = int(input())
A = list(map(int,input().split()))
S = set(A)
if len(S) == 1:
    if 0 in S:
        print("Yes")
    else:
        print("No")
elif len(S) == 2:
    K = Counter(A)
    if 0 in K and K[0] == n//3:
        print("Yes")
    else:
        print("No")
elif len(S) == 3:
    K = Counter(A)
    ans = []
    for i,j in K.items():
        ans.append([i,j])
    if ans[0][1] == ans[1][1] and ans[1][1] == ans[2][1] and ans[0][0]^ans[1][0]^ans[2][0] == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
n,*a=map(int,open(0).read().split())
ans=a[0]
for i in range(1,n):
  ans^=a[i]
print('Yes' if ans==0 else 'No')

Solution (Python):
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    A.sort()
    
    if A[-1] == 0:
        print('Yes')
        return
    
    if N % 3 == 0:
        if A[(2*N//3)-1] == 0 and A[-(N//3)] == A[-1]:
            print('Yes')
            return
    
    if N % 3 == 0:
        if A[0] == A[(N//3)-1] and A[N//3] == A[(2*N//3)-1] and A[2*N//3] == A[N-1] \
                and A[0] ^ A[N//3] ^ A[2*N//3] == 0:
            print('Yes')
            return
    print('No')


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter

def make_xor_sum(A):
    output = A[0]
    for i in range(1,len(A)):
        output = output ^ A[i]

    if output == 0:
        return True
    else:
        return False

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

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

if __name__ == "__main__":
    main()

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

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



D = [0] * 30
for a in A:
    bit = bin(a)[2:][::-1]
    for i in range(len(bit)):
        D[i] += int(bit[i])


ans = 'Yes' if all([d % 2 == 0 for d in D]) else 'No'
print(ans)

Solution (Python):


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

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

print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

sa = set(a)
sa = list(sa)

if len(sa)>3:
    print('No')
    exit()

if len(sa)==3:
    aa = sa[0]
    bb = sa[1]
    cc = sa[2]
    if a.count(aa) != n/3 or a.count(bb) != n/3 or a.count(cc) != n/3:
        print('No')
        exit()
    if aa^bb^cc!=0:
        print('No')
        exit()

if len(sa)==2:
    aa = sa[0]
    bb = sa[1]
    if bb != 0 and aa != 0:
        print('No')
        exit()
    else:
        if aa==0:
            aa = bb
    if a.count(0) != n/3 or a.count(aa)!=n/3*2:
        print('No')
        exit()

if len(sa)==1:
    aa = sa[0]
    if aa != 0:
        print('No')
        exit()

print('Yes')

Solution (Python):
from collections import deque,Counter

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

cnt = Counter(lisA)

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

if len(cnt) == 1:
    if lisA[0] == 0:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
elif len(cnt) == 2:
    if not 0 in cnt:
        print("No")
        exit()
    else:
        keys = sorted(list(cnt.keys()))
        another = keys[-1]
        if cnt[0]*2 == cnt[another]:
            print("Yes")
            exit()
        else:
            print("No")
            exit()
else:
    keys = sorted(list(cnt.keys()))
    if keys[0]^keys[1]^keys[2] != 0:
        print("No")
        exit()
    else:
        if cnt[keys[0]]==cnt[keys[1]]==cnt[keys[2]]:
            print("Yes")
            exit()
        else:
            print("No")
            exit()

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

if len(c) > 3:
    print("No")
    exit()
elif len(c) == 3:
    if n % 3 != 0:
        print("No")
        exit()
    p = []
    for k , v in c.items():
        if v != n//3:
            print("No")
            exit()
        p.append(k)
    if (p[0] ^ p[1]) ^ p[2] != 0:
        print("No")
        exit()
elif len(c) == 2:
    if n % 3 != 0:
        print("No")
        exit()
    for k,v in c.items():
        if k == 0:
            if v != n//3:
                print("No")
                exit()
        else:
            if v != 2*n//3:
                print("No")
                exit()
elif len(c) == 1:
    for k in c.keys():
        if k != 0:
            print("No")
            exit()
            
print("Yes")

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    for i in range(N):
        if i==0:
            a = A[i]
        else:
            a = a^A[i]
    if a == 0:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()

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

count=A[0]
i=1
while i<N:
    count=count^A[i]
    i+=1

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

Solution (Python):
import sys
input = sys.stdin.readline
n = int(input())
alist = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans = ans ^ alist[i]
if ans == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
di = {}
for i in a:
    if i in di:
        di[i] += 1
    else:
        di[i] = 1
k = list(di.keys())
v = list(di.values())
if n%3!=0 and len(di)>1:
    print('No')
elif len(di)==3 and v[0]==v[1]==v[2] and k[0]^k[1]^k[2]==0:
    print('Yes')
elif len(di)==2 and ((v[0]<v[1] and v[0]==n//3 and k[0]==0) or (v[0]>v[1] and v[1]==n//3 and k[1]==0)):
    print('Yes')
elif len(di)==1 and k[0]==0:
    print('Yes')
else:
    print('No')

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