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):
from collections import Counter

if __name__ == '__main__':
    n = int(input())
    l = list(map(int, input().split()))
    c = Counter(l)
    size = len(c.most_common())
    if size > 3:
        print("No")
        exit()
    if size == 1:
        a, b = c.most_common()[0]
        if a == 0 and b == n:
            print("Yes")
        else:
            print("No")
        exit()
    if size == 2:
        a1, b1 = c.most_common()[0]
        a2, b2 = c.most_common()[1]
        if b1 == 2 * n / 3 and a2 == 0 and b2 == n / 3:
            print("Yes")
        else:
            print("No")
        exit()
    a1, b1 = c.most_common()[0]
    a2, b2 = c.most_common()[1]
    a3, b3 = c.most_common()[2]
    if a1 ^ a2 ^ a3 == 0 and b1 == n / 3 and b2 == n / 3 and b3 == n / 3:
        print("Yes")
    else:
        print("No")
    exit()

Solution (Python):
from collections import Counter

def solve(a):
    counter = Counter(a)
    l = list(counter.values())
    if counter[0] > 0:
        if len(l) == 1:
            return True
        if len(l) != 2:
            return False
        return min(l) == counter[0] and counter[0] * 2 == max(l)
    ks = list(counter.keys())
    if len(l) != 3:
        return False
    return l[0] == l[1] and l[2] == l[0] and ks[0] ^ ks[1] == ks[2]



if __name__ == '__main__':
    n = int(input())
    a = [int(s) for s in input().split()]
    print('Yes' if solve(a) else 'No')

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    n = I()
    a = LI()
    if sum(a) == 0:
        print("Yes")
        return
    if n%3 != 0:
        print("No")
        return
    d = defaultdict(lambda : 0)
    for i in a:
        d[i] += 1
    if len(list(d.items())) == 2:
        if d[0] == n//3:
            print("Yes")
            return
        else:
            print("No")
            return
    k = 0
    for i,j in d.items():
        k ^= i
        if j != n//3:
            print("No")
            return
    if not k:
        print("Yes")
        return
    print("No")
    return


def B():
    n,m = LI()
    ans = []
    d = [0]*(n+1)
    for i in range(m):
        a,b = LI()
        ans.append([a,b])
        d[a] ^= 1
    for i in range(m):
        a,b = ans[i]
        if d[a]:
            ans[i] = [b,a]
            d[a] ^= 1
            d[b] ^= 1
    if sum(d):
        print(-1)
    else:
        for i in ans:
            print(*i)
    return


def C():
    n = I()
    p = [(1<<i) for i in range(100)]
    if n in p:
        print("No")
        quit()
    if n+1 in p:
        print("Yes")
        for i in range(1,2*n):
            print(i,i+1)
        quit()
    ans = []
    for i in range(1,3):
        ans.append((i,i+1))
    ans.append((3,n+1))
    for i in range(1,3):
        ans.append((i+n,i+n+1))
    u = 1
    d = 1
    for i in range(2,n//2+n%2):
        ans.append((u,2*i))
        ans.append((d,2*i+1))
        ans.append((2*i,2*i+n+1))
        ans.append((2*i+1,2*i+n))
        u = 2*i+n+1
        d = 2*i+n

    if n%2:
        print("Yes")
        for i,j in ans:
            print(i,j)
    else:
        ans.append((n-1,n))
        for i in range(n):
            if p[i]&n:
                break
        ans.append((p[i+1]-2,2*n))
        print("Yes")
        for i,j in ans:
            print(i,j)
    return


def D():
    n = I()

    return


def E():
    n = I()

    return


def F():
    n = I()

    return


if __name__ == "__main__":
    A()

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

Solution (Python):
import sys

input = sys.stdin.readline


def check(n, nums):
    kind = set(nums)

    if len(kind) > 3:
        return False

    if len(kind) == 1 and 0 in kind:
        return True
    if n % 3 != 0:
        return False
    if len(kind) == 3:
        a, b, c = kind
        return nums.count(a) == nums.count(b) == nums.count(c) and a ^ b ^ c == 0
    elif len(kind) == 2:
        a, b = kind
        a_c, b_c = nums.count(a), nums.count(b)
        if 0 not in kind:
            return False
        elif n / 3 != nums.count(0):
            return False
        else:
            return True


def main():
    n = int(input())
    a_list = [int(i) for i in input().split()]
    print("Yes" if check(n, a_list) else "No")


if __name__ == "__main__":
    main()

Solution (Python):
from functools import*;_,a=open(0);print('YNeos'[reduce(lambda x,y:x^y,map(int,a.split()))>0::2])

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

sums = 0
for i in range(N):
    sums = sums ^ a[i]

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

Solution (Python):
N = int(input())
nums = list(map(int, input().split()))
sums = 0

for i in range(len(nums)):
  sums ^= nums[i]

ans = True
for i in range(len(nums)):
  if nums[i] == sums ^ nums[i]:
    pass
  else:
    ans = False
    
if ans:
  print("Yes")
else:
  print("No")

Solution (Python):
import sys

input = sys.stdin.readline


def check(n, nums):
    kind = set(nums)

    if len(kind) > 3:
        return False

    if len(kind) == 1 and 0 in kind:
        return True

    if n % 3 != 0:
        return False

    if len(kind) == 3:
        if len(set([nums.count(k) for k in kind])) != 1:
            return False
        kind = list(kind)
        if kind[0] ^ kind[1] ^ kind[2] == 0:
            return True
        else:
            return False
    else:
        if 0 not in kind:
            return False
        elif n / 3 != nums.count(0):
            return False
        else:
            return True


def main():
    n = int(input())
    a_list = [int(i) for i in input().split()]
    print("Yes" if check(n, a_list) else "No")


if __name__ == "__main__":
    main()

Solution (Python):

 
import sys
 
n= int(sys.stdin.readline())
ai = [ int(x) for x in sys.stdin.readline().split() ]

a = list(set(ai))
na= len(a)
ans= "No"
if na==1 and a[0]==0: ans="Yes"
elif na==2 and 0 in a:
    x= a[0]
    if x==0: x= a[1]
    if ai.count(x)==2*ai.count(0): ans= "Yes"
elif na==3:
    x,y,z= a
    if x^y^z: pass
    else:
        n,l,m= [ ai.count(i) for i in a ]
        if n==l==m: ans="Yes"

print( ans )

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

Solution (Python):
from numpy import*;_,a=open(0);print('YNeos'[bitwise_xor.reduce(int32(a.split()))>0::2])

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

from collections import Counter

N = int(inputs[0])
a_list = list(map(int, inputs[1].split()))

def check(N, a_list):
    mc = Counter(a_list).most_common()
    n = len(mc)
    if n == 1:
        if mc[0][0] == 0:
            print('Yes')
            return
    elif n == 2:
        if mc[0][1] == 2*N // 3 and mc[1][0] == 0:
            print('Yes')
            return
    elif n == 3:
        if mc[0][1] == mc[1][1] == mc[2][1] and mc[0][0] ^ mc[1][0] ^ mc[2][0] == 0:
            print('Yes')
            return
    print('No')

check(N, a_list)

Solution (Python):

import numpy as np 

def make_bit(A):
    arr = np.zeros(31)
    i = 30
    while A:
        arr[i] = A % 2
        A = A // 2
        i -= 1

    return arr

def return_first_second_third(a_lst):
    first = [a_lst[0], 0]
    second = [-1, -1]
    third = [-1, -1]
    i = 0
    while i < len(a_lst) - 1:
        if a_lst[i] != a_lst[i+1]:
            second[0] = a_lst[i+1]
            second[1] = i+1
            i += 1
            break
        else:
            i += 1
    while i < len(a_lst) - 1:
        if a_lst[i] != a_lst[i+1]:
            third[0] = a_lst[i+1]
            third[1] = i+1
            i += 1
            break
        else:
            i += 1
    
    return first, second, third


N = int(input())

a_lst = list(map(int, input().split()))
a_lst.sort()
first, second, third = return_first_second_third(a_lst)

done = False
if second[0] == -1: 
    done = True
    if first[0] == 0: 
        print("Yes")
    else:
        print("No")
elif third[0] == -1:    
    done = True
    if N % 2 == 0 and second[1] == N // 2 and first[0] == 0:
        print("Yes")
    elif N % 3 == 0 and N != 3 and second[1] == N // 3:
        done = False
        a_lst = [ a_lst[0], a_lst[second[1]], a_lst[second[1]] ]
    else:
        print("No")
elif N % 3 == 0 and N != 3 and second[1] == N // 3:
    if third[1] == N * 2 // 3:
        a_lst = [ a_lst[0], a_lst[second[1]], a_lst[third[1]] ]
    elif third[1] == - 1:
        a_lst = [ a_lst[0], a_lst[second[1]], a_lst[third[1]] ]

a_lst.reverse()

if not done:
    if len(a_lst) == 3:

        a1 = make_bit(a_lst[0])
        a2 = make_bit(a_lst[1])
        a3 = make_bit(a_lst[2])
        bits_arr = np.array([a1, a2, a3])

        judge = True
        for i in range(31):
            if bits_arr[0][i] == bits_arr[1][i] and bits_arr[2][i] == 1:
                judge = False
                break

            elif bits_arr[0][i] != bits_arr[1][i] and bits_arr[2][i] == 0:
                judge = False
                break
                
        if judge:
            print("Yes")
        else:
            print("No")


    else:
        print("No")

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

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

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

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

if n % 3 == 0:
    a.sort()
    m = n // 3
    if a[0] == a[m - 1] and a[m] == a[2 * m - 1] and a[2 * m] == a[3 * m - 1]:
        if a[0] ^ a[m] ^ a[2 * m] == 0:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    if max(a) == 0:
        print('Yes')
    else:
        print('No')

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

result = 0

for num in nums:
    result ^= num

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

Solution (Python):
import sys

input = sys.stdin.readline


def check(n, nums):
    kind = set(nums)
    if len(kind) > 3:
        return False
    if len(kind) == 1 and 0 in kind:
        return True
    if n % 3 != 0:
        return False
    if len(kind) == 3:
        a, b, c = kind
        return nums.count(a) == nums.count(b) == nums.count(c) and a ^ b ^ c == 0
    else:
        return 0 in kind and n / 3 == nums.count(0)


def main():
    n = int(input())
    a_list = [int(i) for i in input().split()]
    print("Yes" if check(n, a_list) else "No")
    
    
    


if __name__ == "__main__":
    main()

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

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

if a[N -1] == 0:
    print("Yes")
    exit(0)

if N % 3 == 0:
    i = N // 3
    if a[0] ^ a[i] == a[2 * i]:
        if a[0] == a[i -1] and a[i] == a[2 * i - 1] and a[2 * i] == a[N -1]:
            print("Yes")
            exit(0)

print("No")

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

if A == [0 for i in range(n)]:
    print("Yes")
elif len(setA) == 2 and listSetA[0] == 0 and 2*A.count(0) == A.count(listSetA[1]):
    print("Yes")
elif len(setA) == 3 and listSetA[0] ^ listSetA[1] == listSetA[2] and A.count(listSetA[0]) == A.count(listSetA[1]) == A.count(listSetA[2]):
    print("Yes")
else:
    print("No")

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

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

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

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

Solution (Python):
n,a=int(input()),sorted(list(map(int,input().split())));b=set(a);l=len(b);print("Yes"if(l==3and b.pop()^b.pop()==b.pop()and n%3==0and a[n//3-1]!=a[n//3]and a[n//3*2-1]!=a[n//3*2])or(l==1and a[0]==0)or(l==2and a[0]==0and n%3==0and a[n//3-1]!=a[n//3])else"No")

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

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

Solution (Python):
from sys import stdin
from collections import defaultdict
def main():
    n = int(stdin.readline())
    a = map(int, stdin.readline().split())
    d = defaultdict(int)
    for x in a:
        d[x] += 1
    s = d.keys()
    if len(s) == 1:
        print 'Yes' if s[0] == 0 else 'No'
    elif len(s) == 2:
        print 'Yes' if (0 in s and n % 3 == 0 and d[0] == n / 3) else 'No'
    elif len(s) == 3:
        print 'Yes' if (s[0] ^ s[1] ^ s[2] == 0 and d[s[0]] == d[s[1]] == d[s[2]]) else 'No'
    else:
        print 'No'
main()

Solution (Python):
n,a=int(input()),sorted(list(map(int,input().split())));b=set(a);l=len(b)
if l!=3:print("Yes"if(l==1and a[0]==0)or(l==2and a[0]==0and n%3==0and a[n//3-1]!=a[n//3])else"No")
else:print("Yes"if b.pop()^b.pop()==b.pop()and n%3==0and a[n//3-1]!=a[n//3]and a[n//3*2-1]!=a[n//3*2]else"No")

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

Solution (Python):


N = input()
A = input().split()
n = int(N)
Int_A = [int(a) for a in A]

k = 0

for a in Int_A:
    k ^= a

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

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

xor = 1
for a in a_lists:
    xor ^= a

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

Solution (Python):
from collections import defaultdict
dic = defaultdict(int)
N = int(input())
a = list(map(int,input().split()))
t = 0
for i in range(N):
    t ^= a[i]
    dic[a[i]] += 1

if t != 0:
    print("No")
else:
    if N % 3 == 0:
        if len(dic.keys()) > 3:
            print("No")
        elif len(dic.keys()) == 3:
            print("Yes" if all([N//3 == x for x in dic.values()]) else "No")
        elif len(dic.keys()) == 2:
            k,l = dic.keys()
            if dic[k] == dic[l]*2:
                print("Yes" if l == 0 else "No")
            elif dic[k]*2 == dic[l]:
                print("Yes" if k == 0 else "No")
            else:
                print("No")
        else:
            print("Yes" if all([0 == x for x in a]) else "No")
    else:
        print("Yes" if all([0 == x for x in a]) else "No")

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

	if all(map(lambda a: a==0, A)):
		print("Yes")
		return

	ans_dict = defaultdict(int)
	for a in A:
		ans_dict[a] += 1
	if len(ans_dict) == 3:
		xor = 0
		num = [0, 0, 0]
		i = 0
		for k in ans_dict:
			num[i] = ans_dict[k]
			xor ^= k
			i += 1
		if num[0] == num[1] and num[1] == num[2] and xor == 0:
			print("Yes")
			return
	if len(ans_dict) == 2 and 0 in ans_dict:
		num = [ans_dict[0], 0]
		for k in ans_dict:
			if k == 0:
				continue
			num[1] = ans_dict[k]
		if num[0]*2 == num[1]:
			print("Yes")
			return
	print("No")


if __name__ == '__main__':
	main()

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

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

Solution (Python):
import collections

N = int(input())
A = [int(_) for _ in input().split()]
count = collections.defaultdict(int)
for x in A:
    count[x] += 1
if len(count) == 1:
    a = list(count.keys())[0]
    if a == 0:
        print('Yes')
        exit()
elif len(count) == 2:
    a, b = sorted(count.keys())
    if a == 0 and count[b] == count[a] * 2:
        print('Yes')
        exit()
elif len(count) == 3:
    a, b, c = count.keys()
    if a ^ b == c and count[a] == count[b] == count[c]:
        print('Yes')
        exit()
print('No')

Solution (Python):
from collections import Counter

def main():
    num = int(input())
    data = list(map(int, input().split()))

    num_c = Counter(data)
    if len(num_c) > 3:
        print('No')
    else:
        if len(num_c) == 1:
            if num_c[0] == num:
                print('Yes')
            else:
                print('No')
        elif num % 3 == 0:
            if len(num_c) == 2:
                if num_c[0] == num // 3:
                    print('Yes')
                else:
                    print('No')
            else:
                num_c = list(num_c.items())
                aaa = num_c[0][0] ^ num_c[1][0] ^ num_c[2][0]
                if aaa == 0 and num_c[0][1] == num_c[1][1] and num_c[1][1] == num_c[2][1]:
                    print('Yes')
                else:
                    print('No')
        else:
            print('No')







if __name__ == '__main__':
    main()

Solution (Python):
a = [input() for i in range(2)]
 
N = int(a[0])
data = a[1].split(' ')
 
data = [int(i) for i in data]
 
result = []
a = 0
for i in range(N):
    a = a ^ data[i]
    
if a == 0:
    print('Yes')
    exit()
    
print('No')

Solution (Python):
import math
n = int(input())
li = list(map(int,input().split()))
flag = "No"
li_uniq = list(set(li))
if(n % 3 == 0):
  if(len(li_uniq) == 3):
    check = li_uniq[0] ^ li_uniq[1]
    if(check == li_uniq[2]):
      a1 = li.count(li_uniq[0])
      a2 = li.count(li_uniq[1])
      a3 = li.count(li_uniq[2])
      if(a1 == a2 == a3):
        flag = "Yes"
  elif(len(li_uniq) == 2):
    bmax = max([li_uniq[0] , li_uniq[1]])
    bmin = min([li_uniq[0] , li_uniq[1]])
    b1 = max([li.count(li_uniq[0]) , li.count(li_uniq[1])])
    b2 = min([li.count(li_uniq[0]) , li.count(li_uniq[1])])
    if(b1 == 2 * b2):
      check2 = bmax ^ bmax
      if(check2 == bmin):
        flag = "Yes"
      
if(len(li_uniq) == 1):
  if(li_uniq[0] == 0):
    flag = "Yes"
print(flag)

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

xor = 0
for v in a_i:
    xor ^= v

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

Solution (Python):
import collections

N = int(input())

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

a_coll  = collections.Counter(a)
a_key   = list(a_coll.keys())
a_value = list(a_coll.values())

if N % 3 != 0:
    if len(a_key) == 1 and a_key[0] == 0:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

if len(a_key) == 1:
    if a_key[0] == 0:
        print("Yes")
        exit()

if len(a_key) == 2:
    if 0 in a_key:
        for key, count in zip(a_key,a_value):
            if key == 0:
                if count != int(N/3):
                    print("No")
                    exit()
            else:
                if count != int(2*N/3):
                    print("No")
                    exit()
        print("Yes")
        exit()
        
if len(a_key) == 3:
    for count in a_value:
        if count != int(N / 3):
            print("No")
            exit()
        
    if a_key[0] ^ a_key[1] == a_key[2]:
        print("Yes")
        exit()

print("No")

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

max_len = len((bin(max(A))[2:]))
for i in range(N):
    A[i] = '0' * (max_len - len(bin(A[i])[2:])) + bin(A[i])[2:]


flag = True
for i in range(len(A[0])):
    tmp = 0
    for j in range(N):

        if A[j][i] == '1':
            tmp += 1
            
    if tmp%2 == 0:
        flag = True
    else:
        flag = False
        break
               
if flag:
    print('Yes')
else:
    print('No')

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

xor = 1
for a in a_list:
    xor ^= a
    
if xor == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a_2=[]
for i in range(len(a)):
    a_2.append(bin(a[i]))
import collections
c = collections.Counter(a)
b=[]
d=[]
out=0
for i in c.values():
    b.append(i)
for i in c.keys():
    d.append(i)
if a.count(0)==0:
    if len(b)!=3:
        out=1
    elif b[0]!=b[1] or b[1]!=b[2]:
        out=1
    elif (d[0]^d[1]^d[2])!=0:
        out=1
else:
    if len(b)>2:
        out=1
    elif len(b)==1:
        pass
    elif len(b)==2:
        if a.count(0)*3==len(a):
            pass
        else:
            out=1
if out==0:
    print('Yes')
elif out==1:
    print('No')

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

    xor = 0

    for i in range(n):
        xor ^= dataset[i]

    if xor == 0:
        print('Yes')
    else:
        print('No')
        
resolve()

Solution (Python):


def main():
    num = int(input())
    data = list(map(int, input().split()))

    ans = 0
    for i in range(num):
        ans ^= data[i]

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



if __name__ == '__main__':
    main()

Solution (Python):
a = [input() for i in range(2)]
 
N = int(a[0])
data = a[1].split(' ')
 
data = [int(i) for i in data]
 
result = []
a = 0
for i in range(N):
    a = a ^ data[i]
    
if a == 0:
    print('Yes')
    exit()
    
print('No')

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

Solution (Python):
N = int(input())
*A, = map(int, input().split())
setA = set(A)
if len(setA) == 3:
    a, b, c = list(setA)
    print('Yes' if a ^ b ^ c == 0 and A.count(a) == A.count(b) == A.count(c) else 'No')
elif len(setA) == 2: print('Yes' if 2*A.count(0) == A.count(max(setA)) else 'No')
elif len(setA) == 1: print('Yes' if max(setA) == 0 else 'No')
else: print('No')

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

if all(i == 0 for i in a):
    print('Yes')
    exit()

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

if 0 in a:
    a = sorted(a)
    zero = a.count(0)
    if zero != p:
        print('No')
        exit()
    if a[p] != a[-1]:
        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):


import sys

sys.setrecursionlimit(10**7)


input = sys.stdin.readline


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


def main():
    n, = read_h()
    arr = read_h()
    

    s = 0
    for a in arr:
        s ^= a

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


if __name__ == '__main__':
    main()

Solution (Python):
import copy
N=int(input())
a_list=list(map(int,input().split()))
a=set(a_list)
a=list(a)
if 0 in a:
        if len(a) ==2:
            if a_list.count(0)==len(a_list)//3 or a_list.count(0)==len(a_list)//2:
                    print("Yes")
            else:
                    print("No")
        elif len(a)==1:
            print("Yes")
        else:
                print("No")
else:
        if len(a)==3:
            a1=a[0]
            a2=a[1]
            a3=a[2]
            if a1 ^ a2 ==a3 and a1^a3==a2 and a2^a3==a1:
                if a_list.count(a1) == a_list.count(a2) == a_list.count(a3):
                        print("Yes")
                else:
                        print("No")
            else:
                print("No")
        else:
            print("No")

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

Solution (Python):


from collections import Counter
def main():
    N = int( input())
    A = list( map( int, input().split()))
    CA = Counter(A)
    d = dict()
    if len(CA) > 3:
        print("No")
        return
    if len(CA) == 1:
        if CA[0] == N:
            print("Yes")
            return
        else:
            print("No")
            return
    if len(CA) == 2:
        for c in CA:
            if c != 0:
                t = c
        if N%3 == 0 and CA[t]== CA[0]*2:
            print("Yes")
        else:
            print("No")
        return
    ans = "Yes"
    s = 0
    for c in CA:
        s ^= c
        if CA[c] != N//3:
            ans = "No"
    if s != 0:
        ans = "No"
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
  a[i]=format(a[i],'030b')
l=[0 for i in range(30)]
for i in range(n):
  for j in range(30):
    if a[i][j]=='1':
      l[j]+=1
for j in range(30):
  l[j]=l[j]%2
 
if 1 in l:
  print('No')
else:
  print('Yes')

Solution (Python):
from collections import Counter

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

c = Counter(a)
x = sorted(c.keys())


ans = (
    'Yes' if (
        len(x) == 3 and x[0] ^ x[1] == x[2] and
        c[x[0]] == c[x[1]] == c[x[2]] or
        len(x) == 2 and x[0] == 0 and c[x[1]] == 2 * c[0] or
        len(x) == 1 and x[0] == 0
    ) else
    'No'
)

print(ans)

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

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
a.sort()
flag = True
if len(set(a)) == 1 and a[0] == 0:
    
    pass
elif N % 3 == 0:
    if len(set(a)) == 3:
        b = list(set(a))
        c = []
        for i in b:
            c.append(a.count(i))
        if a[0] != 0 and c[0] == c[1] and  c[1] == c[2] and c[2] == N//3 and b[0]^b[1]^b[2] == 0:
            
            pass
        else:
            
            flag = False
    elif len(set(a)) == 2:
        if a[0] == 0 and a.count(a[0])*2 == a.count(a[N-1]) and a.count(a[N-1]) == N//3*2:
            
            pass
        else:
            
            flag = False
    else:
        
        flag = False
else:
    
    flag = False
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):



N = int(input())
string = "No"
input_dict = {}
for i in map(int, input().split()):
    if(i in input_dict):
        input_dict[i] += 1
    else:
        input_dict[i] = 1
if((N % 3) == 0):
    num_count = len(input_dict.keys())
    if(num_count == 3 ):
        input_list = list(input_dict.keys())
        if(input_list[0] ^ input_list[1] == input_list[2] and input_dict[input_list[0]] == N//3 and input_dict[input_list[1]] == N//3):
            string = "Yes"
    elif(num_count == 2):
        if(0 in input_dict and input_dict[0] == N//3):
            string = "Yes"
    elif(num_count == 1):
        if(0 in input_dict):
            string = "Yes"
else:
    if(0 in input_dict and input_dict[0] == N):
        string = "Yes"
print(string)

Solution (Python):
import collections 

def is_loop(int_list):
    counter = collections.Counter(input_list)

    unique_list = list(counter.keys())
    counts = list(counter.values())

    if (all(num == 0 for num in unique_list)):
        return True
    else:
        if n % 3 == 0:
            zero_count = counter[0] 
            if zero_count == n / 3 and len(unique_list) == 2:
                return True
            else: 
                if len(unique_list) != 3:
                    return False
                if (unique_list[0] ^ unique_list[1] == unique_list[2]):
                    if (all(counts[0] == num for num in counts)):
                        return True
    return False

n = int(input())
input_list = [int(i) for i in input().split(' ')]
if is_loop(input_list):
    print('Yes')
else:
    print('No')

Solution (Python):
a = [input() for i in range(2)]
 
N = int(a[0])
data = a[1].split(' ')
 
data = [int(i) for i in data]
 
result = []
a = 0
for i in range(N):
    a = a ^ data[i]
    
if a == 0:
    print('Yes')
    exit()
    
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) == 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):
def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def solve(N, A):
    A = sorted(A)
    xor_a = 0
    
    if max(A) == 0:
        return 1
    if N % 3 == 0:
        if A[0] == 0:
            for i in range(N//3):
                if A[i] != 0:
                    return 0
            for i in range(N//3, N):
                if A[i] != A[N//3]:
                    return 0
            return 1
        else:
            for i in range(N//3):
                if A[i] != A[0]:
                    return 0
            for i in range(N // 3, 2 * N // 3):
                if A[i] != A[N // 3]:
                    return 0
            for i in range(2 * N // 3, N):
                if A[i] != A[2 * N // 3]:
                    return 0
            for i in range(N):
                xor_a ^= A[i]
            return 1 if xor_a == 0 else 0
    else:
        return 0


if __name__ == '__main__':
    inputs = read()
    print('Yes' if solve(*inputs) else 'No')