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.



Sample input:
3
1 2 3


Sample output:
Yes

Submission status: Accepted

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

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

    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N=int(input())

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

from collections import defaultdict

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

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

from collections import Counter
C=Counter(A)

flag=1

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

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

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

    if A!=0:
        flag=0


elif len(C)==2:

    if N%3!=0:
        flag=0

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

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

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

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

from collections import defaultdict

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

dic = defaultdict(int)

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

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

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

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

    else:
        print("No")

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

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

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

        else:
            print("Yes")

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

    else:
        print("Yes")

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys

#def xcheck(n):
#	
#    m = int(n**.5)
#    return 1 if abs(m*m - n) < 1e-6 else 0
#	if(1):
#		#兵法数なら
#		return 1
#	return 0

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

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

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

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


#print(check)
#print(a)
#print(flg)

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

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

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


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

#print(d)

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

Submission status: Accepted

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

# def gyakugen(n,p): return pow(n,p-2,p) # == n**(-1) mod p # kurikaeshi jijou hou niyori kousoku

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

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

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

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

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

else:
    print("No")

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

print("No")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

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

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

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter

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

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

solve()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys;
import string;
sys.setrecursionlimit(20000) # 再起呼び出しの最大数をセット

import copy
import math
import itertools

from functools import lru_cache
#@lru_cache(maxsize = None)

PPP = 1000000007

# 整数の入力
n = int(input())

# スペース区切りの整数の入力
a = [int(x) for x in input().split()]
print("a", a, file=sys.stderr)
#n, d = map(int, input().split())
#print("sp", n, k, file=sys.stderr)
#p, q, r = map(int, input().split())
#s = [int(x) for x in input().split()]
#t = [int(x) for x in input().split()]

# 改行区切りの整数の入力
#a = []
#for x in range(n):
#  a.append(int(input()))
#  a.append([int(x) for x in input().split()])
#p = [int(x) for x in input().split()]
#a.sort()
#print(l, file=sys.stderr)

# 文字列の入力
#s = input()

# 出力
#print("{} {}".format(a+b+c, s))
#a.sort()
#print(set(a), file=sys.stderr)
#print(len(set(a)))

#cache = dict()

import re
import fractions

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

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

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

#print(doit([0] * 4))
#doit(s)
#print(doit())
try:
  print(doit())
except Exception as e:
  print("e", e, file=sys.stderr)

Submission status: Accepted

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

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

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

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

# main()
print(main())

Submission status: Accepted

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

Submission status: Accepted

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

S = 0

for a in A:
    S ^= a

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

Submission status: Accepted

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import Counter

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

C = Counter(a)
C_items = list(C.items())
if len(C_items) == 1:
    if C_items[0][0] == 0:
        print('Yes')
    else:
        print('No')
elif len(C_items) == 2:
    if C_items[0][0] == 0 and C_items[0][1] * 2 == C_items[1][1]:
        print('Yes')
    else:
        print('No')
elif len(C_items) == 3:
    if C_items[0][0] ^ C_items[1][0] == C_items[2][0] and C_items[0][1] == C_items[1][1] == C_items[2][1]:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()
n = int(n)
ls = list(map(int,input().split()))

ans = ls[0]
for i in range(1,n):
  ans = ans^ls[i]
  
if ans == 0:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
def solve():
    n = int(input())
    ans = 0
    for a in map(int, input().split()):
        ans ^= a
    print("No" if ans else "Yes")
solve()

Submission status: Accepted

Solution code:
N = int(input())
A = sorted([int(a) for a in input().split()])
X = [[0] * N for _ in range(30)]

if N % 3:
    if max(A):
        print("No")
    else:
        print("Yes")
else:
    n = N//3
    if A[0] == A[n-1] and A[n] == A[2*n-1] and A[2*n] == A[3*n-1] and A[0]^A[n] == A[2*n]:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
n=int(input())
#a, b, c = (int(_) for _ in input().split())
alist = list(map(int, input().split()))
alist=sorted(alist)

judge=0

if n%3!=0:
    if alist[-1]==0:
        judge=1
    else:
        judge=0
else:
    tani=int(n/3)
    #print(alist)
    if alist[0]==alist[tani-1] and alist[tani]==alist[tani*2-1] and alist[tani*2]==alist[n-1]:
        #print(alist[0], alist[tani], alist[tani*2], alist[0]^alist[tani])
        if (alist[0]^alist[tani])==alist[tani*2]:
            judge=1
        else:
            judge=0
    else:
        judge=0

if judge==1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

print(ans)

Submission status: Accepted

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

m = a.pop(0)
for i in range(n-2):
    m = m ^ a[i]
print("YNeos"[m!=a[-1]::2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))
s = [0] * (n + 2)
rs = [0] * (n + 2)
for i in range(n):
    s[i + 1] = s[i] ^ a[i]
    rs[n - i] = rs[n - i + 1] ^ a[-i - 1]
ans = all(a[i] == rs[i + 2] ^ s[i] for i in range(n))
print(['No', 'Yes'][ans])

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N = int(input())
A = map(int, input().split(' '))

sum = 0
for a in A:
  sum = sum ^ a
  
if sum == 0:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
#    !/usr/bin/env python3
#    encoding: UTF-8
#    Modified: <14/Jul/2019 06:12:00 PM>


#    ✪ H4WK3yE乡
#    Mohd. Farhan Tahir
#    Indian Institute Of Information Technology (IIIT), Gwalior


import sys
import os
from io import IOBase, BytesIO


def main():
    n = int(input())
    arr = get_array()
    c = 0
    for i in range(n):
        c = c ^ arr[i]
    if c == 0:
        print('Yes')
    else:
        print('No')


BUFSIZE = 8192


class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        py2 = round(0.5)
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2 == 1:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode("ascii"))
            self.read = lambda: self.buffer.read().decode("ascii")
            self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def get_array(): return list(map(int, sys.stdin.readline().split()))


def get_ints(): return map(int, sys.stdin.readline().split())


def input(): return sys.stdin.readline().strip()


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import Counter

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

c = Counter(a)

ans = False
if len(c) == 1:
    ans = a[0] == 0
elif n % 3 == 0 and len(c) <= 3:
    nums = []
    for i in c:
        if c[i] % (n // 3) != 0:
            break
        else:
            nums += [i] * (c[i] // (n // 3))
    else:
        ans = (nums[0] ^ nums[1] ^ nums[2]) == 0

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

Submission status: Accepted

Solution code:

import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline
mii=lambda:map(int,input().split())

n=int(input())

a=list(mii())
a.sort()

if a[0]==a[n-1]:
    if a[0]==0:
        print("Yes")
    else:
        print("No")
elif n%3:
    print("No")
else:
    a1,a2,a3=a[0],a[n//3],a[n//3*2]
    if a1!=a[n//3-1] or a2!=a[n//3*2-1] or a3!=a[n-1]:
        print("No")
    elif a1^a2!=a3 or a1^a3!=a2 or a2^a3!=a1:
        print("No")
    else:
        print("Yes")

Submission status: Accepted

Solution code:
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import bisect

setrecursionlimit(10**6)

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

def answer(b):
  print("Yes" if b else "No")
  exit()

N = read()
a = reads()

d = Counter(a)
keys = list(d.keys())
keys.sort()

if len(keys) > 3:
  answer(False)

if len(keys) == 1:
  answer(keys[0] == 0)
elif len(keys) == 2:
  if keys[0] != 0:
    answer(False)
  v = keys[1]
  answer(d[0] * 2 == d[v])
else:
  assert len(keys) == 3
  v, w, x = keys
  if v ^ w == x and d[v] == d[w] == d[x]:
    answer(True)
  else:
    answer(False)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return list(map(float, sys.stdin.readline().split()))
def LS():return sys.stdin.readline().split()
def SR(n): return [list(sys.stdin.readline())[:-1] for i in range(n)]
def IR(n): return [int(sys.stdin.readline()) for i in range(n)]
def LIR(n): return [list(map(int, sys.stdin.readline().split())) for i in range(n)]
def LSR(n): return [list(map(list, sys.stdin.readline().split())) for i in range(n)]
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
INF = float('inf')
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

N = I()
a = LI()

ret = 0
for ai in a[1:]:
    ret ^= ai

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

Submission status: Accepted

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

xor = a[0]
for i in range(len(a)-1):
    xor = xor^a[i+1]
# print(xor)
if(xor == 0):
    print('Yes')
else:
    print('No')