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:
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(set(a)))
l=len(b)
if l>=4:
    print("No")
    exit()
else:
    if l==1:
        if b[0]==0:
            print("Yes")
        else:
            print("No")
    elif l==2:
        if n%3!=0:
            print("No")
        else:
            if b[0]!=0:
                print("No")
            else:
                cnt1=a.count(b[0])
                cnt2=a.count(b[1])
                if cnt2==(n//3)*2:
                    print("Yes")
                else:
                    print("No")
    else:
        if n%3!=0:
            print("No")
        else:
            cnt1=a.count(b[0])
            cnt2=a.count(b[1])
            cnt3=a.count(b[2])
            if cnt1!=n//3 or cnt2!=n//3 or cnt3!=n//3:
                print("No")
            else:
                if b[0]^b[2]!=b[1]:
                    print("No")
                else:
                    print("Yes")

Submission status: Accepted

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

from collections import Counter

c = Counter(a)

if c[0] == N:
    print('Yes')
    exit()
if N % 3 != 0:
    print('No')
    exit()
if c[0] == N//3 and len(c) == 2:
    print('Yes')
    exit()
if len(c) != 3:
    print('No')
    exit()
A = list(c.values())
if not (A[0] == N//3 and A[1] == N//3 and A[2] == N//3):
    print('No')
    exit()
B = list(c.keys())
if B[0]^B[1] != B[2]:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

Solution code:
from collections import Counter

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


D = Counter(A)
A = set(A)
if len(A) == 1 and 0 in A:
	print("Yes")
elif len(A) == 2 and 0 in A and n % 3 == 0:
	for k, v in D.items():
		if k != 0:
			cnt_else = v
		
	if cnt_else == n * 2 // 3:
		print("Yes")
	else:
		print("No")
elif len(A) == 3 and n % 3 == 0:
	if len(set(D.values())) == 1:
		A = list(A)
		if A[0] ^ A[1] ^ A[2] == 0:
			print("Yes")
		else:
			print("No")
	else:
		print("No")		
else:
	print("No")

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    _ = int(input())
    a_lists = [int(x) for x in stdin.readline().rstrip().split()]
    z = 0

    for a in a_lists:
        z ^= a

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, *a = map(int, read().split())
for af in a[1:]:
    a[0] ^= af
print('Yes' if a[0] == 0 else 'No')

Submission status: Accepted

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

x=len(set(A))
if x==1:
  if A==[0]*N:
    print('Yes')
  else:
    print('No')
elif x==2:
  B=list(set(A))
  a,b=max(B),min(B)
  if b==0 and A.count(0)==(N//3):
    print('Yes')
  else:
    print('No')
elif x==3:
  B=list(set(A))
  a=max(B)
  c=min(B)
  b=sum(B)-a-c
  if A.count(a)==A.count(b) and A.count(b)==A.count(c):
    if a^b==c:
      print('Yes')
    else:
      print('No')
  else:
    print('No')
else:
  print('No')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = sorted(na())
x = [[0]*n for _ in range(30)]
 
if n%3:
    if max(a):
        print("No")
    else:
        print("Yes")
else:
    m = n//3
    if a[0] == a[m-1] and a[m] == a[2*m-1] and a[2*m] == a[3*m-1] and a[0]^a[m] == a[2*m]:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int,input().split()))
Ad = {}
for a in A:
  if a not in Ad:
    Ad[a] = 1
  else:
    Ad[a] += 1
a = len(Ad)
if a == 1:
  for i in Ad.keys():
    if i == 0:
      print('Yes')
    else:
      print('No')
elif n % 3:
  print('No')
elif a == 2:
  x = 0
  for k,v in Ad.items():
    if v != n//3 and v != n//3*2:
      print("No")
      break
    else:
      x ^= k
      if v == n//3*2:
        x ^= k
  else:
    if x == 0:
      print('Yes')
    else:
      print('No')
elif a == 3:
  x = 0
  for k,v in Ad.items():
    if v != n//3:
      print("No")
      break
    else:
      x ^= k
  else:
    if x == 0:
      print('Yes')
    else:
      print('No')
else:
  print('No')

Submission status: Accepted

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

now=A[0]
for i in range(1,N):
    now=now^A[i]

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

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter(a)

if c[0] == N:
    print("Yes")
elif N%3 == 0 and len(c) == 2:
    for A in a:
        if c[A] == (2*N)//3:
            print("Yes")
            break
    else:
        print("No")
elif N%3 == 0 and len(c) == 3:
    tmp = list(set(a))
    if c[tmp[0]] == c[tmp[1]] == c[tmp[2]] and tmp[0] ^ tmp[1] ^ tmp[2] == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter

def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    ac=Counter(A)
    aci=list(ac.items())
    aci.sort()
    ans="No"
    if aci[0]==(0,n):
        ans="Yes"
    elif n%3==0 and len(aci)==2:
        if aci[0]==(0,n//3) and aci[1][1]==n//3*2:
            ans="Yes"
    elif n%3==0 and len(aci)==3:
        if aci[0][1]==aci[1][1] and aci[1][1]==aci[2][1] and aci[0][0]^aci[1][0]^aci[2][0]==0:
            ans="Yes"  
    print(ans)


if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
n, *a = map(int, open(0).read().split())

set_a = set(a)
set_a = sorted(set_a)

ans = 'No'

if len(set_a) == 1 and a[0] == 0:
    ans = 'Yes'

if len(set_a) == 2 and n%3 == 0 and a.count(0) == n//3 and a.count(set_a[1]) == 2*n//3:
    ans = 'Yes'

if len(set_a) == 3 and n%3 == 0:
    if set_a[0] ^ set_a[1] ^ set_a[2] == 0:
        ans = 'Yes'
        for i in range(3):
            if a.count(set_a[i]) != n//3:
                ans = 'No'
                break
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
from functools import reduce
N = int(input())
a = list(map(int, input().split()))

def print_yes():
    print('Yes')
    exit(0)

def print_no():
    print('No')
    exit(0)

if not any(a):
    print('Yes')
else:
    if N % 3 == 0:
        counter = Counter(a)
        # print(counter)
        if len(counter) == 3:
            for i in counter.values():
                if i != N / 3:
                    print_no()
            if reduce(lambda a,b: a^b, list(counter.keys())) == 0:
                print_yes()
            else:
                print_no()
        elif len(counter) == 2:
            if a.count(0) == N/3:
                print_yes()
            else:
                print_no()
        else:
            print_no()
    else:
        print_no()

Submission status: Accepted

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

if len(num) == 1 and num[0] == 0:
    print('Yes')
elif N % 3 == 0:
    if len(num) == 3:
        s = a.count(num[0])
        t = a.count(num[1])
        u = a.count(num[2])
        if s == t and t == u and u == s and num[0] ^ num[1] == num[2]:
            print('Yes')
        else:
            print('No')
    elif len(num) == 2:
        if a.count(max(num)) == a.count(0) * 2:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

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

if len(a_set)==1:
    if sum(a_set)==0:
        print('Yes')
    else:
        print('No')
elif len(a_set)==2:
    a_1,a_2 = sorted(a_set)
    if a_1==0:
        if a.count(a_1)*3==n:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
elif len(a_set)==3:
    a_1,a_2,a_3= a_set
    if a.count(a_1)==a.count(a_2) and a.count(a_2)==a.count(a_3):
        if a_1^a_2==a_3:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from sys import stdin

n = int(stdin.readline().rstrip())
a = list(map(int, stdin.readline().rstrip().split()))
tmp = a[0]
for i in range(1, len(a)):
    tmp = tmp ^ a[i]
for i in range(1, len(a)):
    if a[i] ^ tmp == a[i]:
        print('Yes')
        sys.exit()
print('No')

Submission status: Accepted

Solution code:
n=int(input())
a=sorted(list(map(int,input().split())))
if n%3==0:
  d={}
  for ai in a:
    if ai not in d:
      d[ai]=a.count(ai)
      if len(d)==4:
        break
  sa=list(set(a))
  if len(sa)==3 and sa[0]^sa[1]==sa[2] and d[sa[0]]==d[sa[1]] and d[sa[0]]==d[sa[2]]:
    print('Yes')
    exit()
  if len(sa)==2 and 0 in d and 2*d[0]==max(d[sa[0]],d[sa[1]]):
    print('Yes')
    exit()

if n == a.count(0):
  print('Yes')
  exit()

print('No')

Submission status: Accepted

Solution code:
input()
a=[int(i) for i in input().split()]
ans=0
for i in a:
  ans^=i
print('Yes' if ans==0 else 'No')

Submission status: Accepted

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

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

cnt = {}
for a in A:
    if a not in cnt:
        cnt[a] = 1
    else:
        cnt[a] += 1

if len(cnt) == 2:
    if cnt[0] == N // 3:
        print("Yes")
        exit(0)

if len(cnt) == 3:
    k1, k2, k3 = cnt.keys()
    v1, v2, v3 = cnt.values()
    if not (k1 ^ k2 ^ k3):
        if v1 == v2 and v2 == v3:
            print("Yes")
            exit(0)

print("No")

Submission status: Accepted

Solution code:
# import bisect
from collections import Counter, deque  # https://note.nkmk.me/python-scipy-connected-components/
# from copy import copy, deepcopy
# from math import gcd
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys

sys.setrecursionlimit(10 ** 5 + 10)


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


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

        if all(a == 0 for a in A):
            return True
        if N % 3 != 0:
            return False

        AA = Counter(A)
        if len(AA) == 2:
            AAA = AA.most_common()
            if AAA[0][1] != N * 2 // 3:
                return False
            return AAA[1][0] == 0

        if len(AA) == 3:
            if any(v != N // 3 for v in AA.values()):
                return False
            k1, k2, k3 = AA.keys()
            return k1 ^ k2 == k3 or k1 ^ k3 == k2 or k2 ^ k3 == k1

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


resolve()

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))
from collections import Counter
cntr = Counter(A)
ans = 'No'
if len(set(A)) == 1 and A[0] == 0:
  ans = 'Yes'
elif n % 3 == 0:
  if len(cntr) == 3:
    k = list(cntr.keys())
    v = list(cntr.values())
    if k[0]^k[1]^k[2] == 0 and v[0] == v[1] and v[1] == v[2]:
      ans = 'Yes'
  elif len(cntr) == 2:
    if sorted(cntr.keys())[0] == 0 and cntr.get(0) == n//3:
      ans = 'Yes'
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = Counter(a)
c = list(b.items())
if all(i==0 for i in a):
    print("Yes")
elif len(b)==2 and n%3==0 and b[0]==n//3:
    print("Yes")
elif len(b)==3 and c[0][0]^c[1][0]^c[2][0]==0 and c[0][1]==c[1][1]==c[2][1]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
sa = sorted(set(a))
if len(sa) ==1 and sa[0] == 0:
  ans = "Yes"
elif len(sa) == 2 and sa[0] == 0 and a.count(sa[0])*2==a.count(sa[1]):
  ans = "Yes"
elif len(sa) == 3 and sa[0]^sa[1]^sa[2] == 0 and a.count(sa[0])==a.count(sa[1])==a.count(sa[2]):
  ans = "Yes"
else:
  ans = "No"
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter,OrderedDict

N=int(input())
a=list(map(int,input().split()))
d=OrderedDict(Counter(a))
e=list(d)
e.sort()

if len(d)>3:
    ans="No"
else:
    ans="No"
    if len(d)==1:
        if e[0]==0:
            ans="Yes"
    elif len(d)==2:
        if N%3==0:
            if e[0]==0 and d[0]==N//3 and d[e[1]]==2*N//3:
                ans="Yes"
    else:
        if N%3==0:
            if d[e[0]]==d[e[1]]==d[e[2]]:
                if e[0]^e[1]^e[2]==0:
                    ans="Yes"
                   
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

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

if 0 in ca and ca[0] == n:
    print("Yes")
elif n % 3 == 0 and 0 in ca and ca[0] == n // 3 and len(ca) == 2:
    print("Yes")
elif n % 3 == 0 and len(ca) == 3:
    values = []
    for c in ca:
        if ca[c] == n // 3:
            values.append(c)
    
    if len(values) != 3:
        print("No")
    else:
        ans = 0
        for k in values:
            ans ^= k
        if ans == 0:
            print("Yes")
        else:
            print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


n = onem()

a = l()

a.sort()

a = s(a)

if len(a) == 1:
    if a[0][0] == 0:
        print("Yes")
        exit()
elif len(a) == 2:
    if a[0][0] == 0:
        if a[0][1] == n//3 and a[1][1] == (2*n)//3:
            print("Yes")
            exit()

elif len(a) == 3:
    if not (a[0][0] ^ a[1][0] ^ a[2][0]):
        if (a[0][1] == n//3 and a[1][1] == n//3 and a[2][1] == n//3):
            print("Yes")
            exit()
            
print("No")

Submission status: Accepted

Solution code:
# Nが3の倍数かつ、配列が「aがm個とbがm個とcがm個」かつ、a^b == c ならTrue

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

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

if n % 3:
    print('No')
    exit()

m = n // 3
nums.sort()
for i in range(m-1):
    if nums[i] != nums[i+1] or nums[m+i] != nums[m+i+1] or nums[2*m+i] != nums[2*m+i+1]:
        print('No')
        exit()

if nums[0] ^ nums[m] == nums[2*m]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = LIST()

xor = lambda x, y: x^y
ret = reduce(xor, a)
print("No" if ret else "Yes")

Submission status: Accepted

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

xor=0#０ならOK -> 実際計算するときれいに0になる

for i in range(n):
    xor=xor^a[i]
if xor==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter(a)
if len(c) > 3:
    print('No')
else:
    if len(c) == 1 and c.get(0):
        print('Yes')
    elif len(c) == 2 and c.get(0) == n / 3:
        print('Yes')
    elif len(c) == 3:
        x, y, z = c.keys()
        if x^y^z == 0 and c.get(x) == c.get(y) == c.get(z) == n / 3:
            print('Yes')
        else:
            print('No')
    else:
        print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
N=int(input())
a=list(map(int,input().split()))
l=[]
if max(a)==0:
    print("Yes")
elif (N%3)==0:
    c=collections.Counter(a)
    values = list(c.values())  # aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
    key = list(c.keys())  # 先のvalue値に相当する要素のリスト(要素1,要素2,…)
    for i in range(len(key)):
        l.append([key[i], values[i]])  # lは[要素i,n_i]の情報を詰めたmatrix
    l.sort(key=lambda x:x[1],reverse=True)
    #print(l)
    if (len(l)==3)and(l[0][1]==l[1][1]==l[2][1])and(l[0][0]^l[1][0]==l[2][0]):
        print("Yes")
    elif (len(l)==2)and(l[0][1]==2*l[1][1])and(l[1][0]==0):
        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()))
for i in range(1, n):
  a[i] ^= a[i - 1]
if a[n - 1] == 0:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return list(map(str, input().split()))

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  n = int(input())
  a = input_list()
  ans = 0
  for i in a:
    ans ^= i
  if ans == 0:
    print('Yes')
  else:
    print('No')
    
import math
import fractions
import collections
import itertools
from functools import reduce
main()

Submission status: Accepted

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

a_set = set(a)

if len(a_set) > 3:
    print("No")
elif len(a_set) == 3:
    x, y, z = a_set
    if a.count(x) == a.count(y) == a.count(z):
        if x ^ y ^ z == 0:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
elif len(a_set) == 2:
    x, y = sorted(a_set)
    if x == 0:
        if a.count(x) * 3 == N:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    if sum(a_set) == 0:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    hats = int(input())
    number = list(map(int, input().split()))
    count = {}
    for n in number:
        if n in count:
            count[n] += 1
        else:
            count[n] = 1
    answer = False
    key = list(count.keys())
    val = list(count.values())
    if len(key) == 1 and key == [0]:
        answer = True
    elif len(key) == 2 and hats % 3 == 0:
        if (key[1] == 0 and val[0] == 2 * hats // 3 and val[1] == hats // 3) or \
                (key[0] == 0 and val[1] == 2 * hats // 3 and val[0] == hats // 3):
            answer = True
    elif len(key) == 3 and hats % 3 == 0:
        if key[0] ^ key[1] ^ key[2] == 0 and val[1] == val[2] == val[0] == hats // 3:
            answer = True
    print("Yes" if answer else "No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
a = sorted([int(i) for i in input().split()], reverse=True)
allzero = True
element = {}
for i in a:
    if i != 0:
        allzero = False
    if i not in element.keys():
        element[i] = 0
    element[i] += 1
if allzero:
    print('Yes')
else:
    if n % 3 != 0:
        print('No')
    elif len(element) == 2:
        if 0 in element.keys() and element[0] == n//3:
            print('Yes')
        else:
            print('No')
    elif len(element) == 3:
        judge = 0
        for k, v in element.items():
            judge ^= k
            if v != n//3:
                print('No')
                break
        else:
            if judge == 0:
                print('Yes')
            else:
                print('No')
    else:
        print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
L=list(map(int,input().split()))
LL=list(set(L))
ans="No"
if LL==[0]:
    ans="Yes"
elif len(LL)==2:
    if L.count(LL[0])==2*L.count(LL[1]) or L.count(LL[1])==2*L.count(LL[0]):
        ans="Yes"
elif len(LL)==3:
    if L.count(LL[0])==L.count(LL[1]) and L.count(LL[1])==L.count(LL[2]):
        if LL[0]^LL[1]^LL[2]==0:
            ans="Yes"
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    N = int(input())
    a_list = [int(x) for x in stdin.readline().rstrip().split()]
    a_set = set(a_list)

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

    elif len(a_set) == 2:
        a_1, _2 = sorted(a_set)
        if a_1 == 0:
            if a_list.count(a_1) * 3 == N:
                print("Yes")
            else:
                print("No")
        else:
            print("No")

    elif len(a_set) == 3:
        a_1, a_2, a_3 = a_set
        if a_list.count(a_1) == a_list.count(a_2) and a_list.count(a_2) == a_list.count(a_3):
            if a_1 ^ a_2 == a_3:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
def xored(a, b):
  y = 0
  base = 1
  while a != 0 or b != 0:
    y += ((a + b) % 2) * base
    base *= 2
    a //= 2
    b //= 2
  return y

if max(A) == 0:
  print("Yes")
else:
  if N % 3 != 0:
    print("No")
  else:
    D = {}
    for i in A:
      if i in D:
        D[i] += 1
      else:
        D[i] = 1
    if len(D) > 3:
      print("No")
    else:
      if len(D) == 3 and min(D[i] for i in D) == max(D[i] for i in D):
        L = [i for i in D]
        if xored(L[0], L[1]) == L[2]:
          print("Yes")
        else:
          print("No")
      elif len(D) == 2:
        if 0 not in D:
          print("No")
        else:
          if D[0] >= N // 3:
            print("Yes")
          else:
            print("No")
      else:
        print("No")

Submission status: Accepted

Solution code:
N=int(input())
a=list(map(int,input().split()))
x=set(a)
if len(x)==1:
    if 0 in x:
        ans=1
    else:
        ans=0
elif len(x)==2:
    if 0 in x:
        count0=0
        count1=0
        for i in range(len(a)):
            if a[i]==0:
                count0+=1
            else:
                count1+=1
        if count0*2==count1:
            ans=1
        else:
            ans=0
    else:
        ans=0
elif len(x)==3:
    y=list(x)
    t=y[0]^y[1]^y[2]
    if t==0:
        count0=0
        count1=0
        count2=0
        for i in range(len(a)):
            if a[i]==y[0]:
                count0+=1
            elif a[i]==y[1]:
                count1+=1
            else:
                count2+=1
        if count0==count1:
            if count1==count2:
                ans=1
            else:
                ans=0
        else:
            ans=0
    else:
        ans=0
else:
    ans=0
if ans:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n=int(input())
s=[int(i) for i in input().split()]
a=1
for l in s:
    a^=l
if a==1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
X = set(A)
if len(X) == 1:
    if 0 in X:
        ans = 1
    else:
        ans = 0
elif len(X) == 2:
    if 0 in X:
        Y = list(X)
        if A.count(Y[0]) * 2 == A.count(Y[1]):
            ans = 1
        else:
            ans = 0
    else:
        ans = 0
elif len(X) == 3:
    Y = list(X)
    if A.count(Y[0]) == A.count(Y[1]) == A.count(Y[2]):
        ans = 1
        for i in range(40):
            Z = list(map(lambda x: x % 2,Y))
            Y = list(map(lambda x: x // 2,Y))
            Z.sort()
            #print(Z)
            if Z != [0,1,1] and Z != [0,0,0]:
                ans = 0
                break
    else:
        ans = 0
elif len(X) >= 4:
    ans = 0
if ans == 0:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
def examA():
    N = I()
    A = LI()
    cur = 0
    for a in A:
        cur ^= a
    if cur==0:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)
    return

def examB():
    N, M = LI()
    V = [[]for _ in range(N)]
    for _ in range(M):
        a, b = LI()
        a -= 1; b -= 1
        V[a].append(b)
        V[b].append(a)
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examA()

"""

"""

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
x='No'
p=len(set(a))
if p==1:
  if a[0]==0:
    x='Yes'
elif p==2:
  if n%3==0:
    if a.count(0)==n//3:
      x='Yes'
elif p==3:
  if n%3==0:
    b=set(a)
    t=0
    f=1
    for i in b:
      t=t^i
      if a.count(i)!=n//3:
        f=0
    if t==0 and f:
      x='Yes'
print(x)