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: Wrong Answer

Solution code:
from collections import Counter
N=int(input())
a=list(map(int, input().split()))
flag=False
if N%3==0:
  c=Counter(a)
  if len(c.keys())==1:
    if 0 in c.keys():
      flag=True
  elif len(c.keys())==2:
    if 0 in c.keys():
      if c[0]*3==N:
        flag=True
  elif len(c.keys())==3:
    x, y, z=c.keys()
    if c[x]==c[y] and c[y]==c[z] and x^y==z:
      flag=True
if flag:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
def xor(x,y):
  bitx=[]
  bity=[]
  num1,num2=x,y
  while num1!=0:
    bitx.append(num1%2)
    num1//=2
  while num2!=0:
    bity.append(num2%2)
    num2//=2
  m=max(len(bitx),len(bity))
  while len(bitx)<m+1:
    bitx.append(0)
  while len(bity)<m+1:
    bity.append(0)
  ans=0
  for i in range(m):
    if bitx[i]!=bity[i]:
      ans+=2**i
  return ans
from collections import defaultdict
import sys
d=defaultdict(int)
l=list(map(int,input().split()))
if n%3!=0:
  for i in range(n):
    if l[i]!=0:
      print("No")
      sys.exit()
  print("Yes")
  sys.exit()
for i in l:
  d[i]+=1
if len(d)>3:
  print("No")
elif len(d)==3:
  b=True
  l1=[]
  for i in d:
    l1.append(i)
    if d[i]!=n/3:
      b=False
  if l[0]!=xor(l[1],l[2]) or l[1]!=xor(l[0],l[2]) or l[2]!=xor(l[0],l[1]):
    b=False
  if b:
    print("Yes")
  else:
    print("No")
elif len(d)==2:
  if d[0]!=n/3:
    print("No")
  else:
    print("Yes")
else:
  if d[0]==n:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
from collections import defaultdict
import sys
d=defaultdict(int)
l=list(map(int,input().split()))
if n%3!=0:
  for i in range(n):
    if l[i]!=0:
      print("No")
      sys.exit()
  print("Yes")
  sys.exit()
for i in l:
  d[i]+=1
if len(d)>3:
  print("No")
elif len(d)==3:
  b=True
  for i in d:
    if d[i]!=n/3:
      b=False
  if b:
    print("Yes")
  else:
    print("No")
elif len(d)==2:
  if d[0]!=n/3:
    print("No")
  else:
    print("Yes")
else:
  if d[0]==n:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
n=int(input())
a=list(map(int,input().split()))
c=max(a)
cnt=1
cc=[]
for i in range(n):
    for j in range(100):
        if a[i]<2**j:
            cc.append(j)
            break
if max(cc)-min(cc)==1:
    print('Yes')
else:
    print('No')
#print(cc)

Submission status: Wrong Answer

Solution code:
# 2019-11-24 00:33:09(JST)
import sys
import collections

def main():
    n, *a = map(int, sys.stdin.read().split())

    c = collections.Counter(a)

    ans = 'No'
    # if len(c) == 2 and 0 in c and c[0] == n / 3:
    #     ans = 'Yes'
    # elif len(c) == 3 and not 0 in c:
    #     for i in c.values():
    #         if i != n / 3:
    #             break
    #     else:
    #         ans = 'Yes'
    # elif 0 in c and c[0] == n:
    #     ans = 'Yes'

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# 2019-11-24 00:33:09(JST)
import sys
import collections

def main():
    n, *a = map(int, sys.stdin.read().split())

    c = collections.Counter(a)

    ans = 'No'
    if len(c) == 2 and 0 in c and c[0] == n / 3:
        ans = 'Yes'
    elif len(c) == 3 and not 0 in c:
        for i in c.values():
            if i != n / 3:
                break
        else:
            ans = 'Yes'
    elif 0 in c and c[0] == n:
        ans = 'Yes'

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# 2019-11-24 00:33:09(JST)
import sys
import collections

def main():
    n, *a = map(int, sys.stdin.read().split())

    c = collections.Counter(a)



    ans = 'No'
    if n % 3 == 0:
        if len(c) == 2 and 0 in c and c[0] == n // 3:
            ans = 'Yes'
        elif len(c) == 3 and not 0 in c:
            for i in c.values():
                if i != n // 3:
                    break
            else:
                ans = 'Yes'
    else:
        if 0 in c and c[0] == n:
            ans = 'Yes'

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# 2019-11-24 00:33:09(JST)
import sys

def main():
    n, *a = map(int, sys.stdin.read().split())
    a.sort()
    a.insert(0, a[-1])
    a.append(a[1])
    
    for i in range(1, n+1):
        if a[i-1] ^ a[i+1] != a[i]:
            ans = 'No'
            break
    else:
        ans = 'Yes'
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# 2019-11-24 00:33:09(JST)
import sys

def main():
    n, *a = map(int, sys.stdin.read().split())
    a.sort()
    a.insert(0, a[-1])
    a.append(1)
    
    for i in range(1, n+1):
        if a[i-1] ^ a[i+1] != a[i]:
            ans = 'No'
            break
    else:
        ans = 'Yes'
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# 2019-11-24 00:33:09(JST)
import sys

def main():
    n, *a = map(int, sys.stdin.read().split())
    a.sort()
    for i in range(1, n-1):
        if a[i+1] >= a[i] * 2:
            ans = 'No'
            break
    else:
        ans = 'Yes'
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(set(a))
b.sort()
if len(set(a))>=4:
    print('No')
elif b==[0]:
    print('Yes')
elif len(b)==2:
    c_1=a.count(0)
    c_2=a.count(b[1])
    if 2*c_1==c_2:
        print('Yes')
    else:
        print('No')
elif len(b)==3:
    c_1=a.count(b[0])
    c_2=a.count(b[1])
    c_3=a.count(b[2])
    if c_1==c_2==c_3 and b[0]^b[1]^b[2]:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(set(a))
b.sort()
if len(set(a))>=4:
    print('No')
elif b==[0]:
    print('Yes')
elif len(b)==2:
    c_1=a.count(0)
    c_2=a.count(b[1])
    if 2*c_1==c_2:
        print('Yes')
    else:
        print('No')
elif len(b)==3:
    c_1=a.count(b[0])
    c_2=a.count(b[1])
    c_3=a.count(b[2])
    if c_1==c_2==c_3:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(set(a))
b.sort()
if len(set(a))>=4:
    print('No')
elif b==[0]:
    print('Yes')
elif len(b)==2:
    c_1=a.count(0)
    c_2=a.count(b[1])
    if c_1==2*c_2:
        print('Yes')
    else:
        print('No')
elif len(b)==3:
    c_1=a.count(b[0])
    c_2=a.count(b[1])
    c_3=a.count(b[2])
    if c_1==c_2==c_3:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[a[-1]]+a+[a[0]]
#print(b)

for i in range(1,n+1):
    if b[i]!=b[i-1]^b[i+1]:
        print('No')
        break
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[a[-1]]+a+[a[0]]
#print(b)

for i in range(1,n+1):
        if b[i]!=b[i-1]^b[i+1]:
                print('No')
                break
else:
        print('Yes')

Submission status: Wrong Answer

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


count0 = aaa.count(0)
countleft = aaa.count(aaa[0])
countright = aaa.count(aaa[-1])
buff1 = aaa[0]
buff2 = aaa[-1]
aaa = [i for i in aaa if i!=buff1 and i!=buff2]
if aaa!=[]:
    buff3 = aaa[0]
    countmid = aaa.count(buff3)

if count0 == N:
    print("Yes")
    exit()
elif N%3==0 and count0 == N/3 and countright == N/3*2:
    print("Yes")
    exit()
elif N%3==0 and countleft == N/3 and countright == N/3 and countmid == N/3:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

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


count0 = aaa.count(0)
countleft = aaa.count(aaa[0])
countmid = aaa.count(aaa[int((len(aaa)+1)/2)])
countright = aaa.count(aaa[-1])
if count0 == N:
    print("Yes")
    exit()
elif count0 == N/3 and countright == N/3*2:
    print("Yes")
    exit()
elif countleft == N/3 and countright == N/3 and countmid == N/3:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

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

if N%3 != 0:
    print("No")
    exit()
else:
    count0 = aaa.count(0)
    countleft = aaa.count(aaa[0])
    countmid = aaa.count(aaa[int((len(aaa)+1)/2)])
    countright = aaa.count(aaa[-1])
    if count0 == N:
        print("Yes")
        exit()
    elif count0 == N/3 and countright == N/3*2:
        print("Yes")
        exit()
    elif countleft == N/3 and countright == N/3 and countmid == N/3:
        print("Yes")
        exit()
print("No")

Submission status: Wrong Answer

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

if N%3 != 0:
    print("No")
    exit()
else:
    count0 = aaa.count(0)
    if count0 == N:
        print("Yes")
        exit()
    bbb = [i for i in aaa if i != 0]
    if bbb.count(bbb[0])==N/3*2:
        print("Yes")
        exit()
    ccc = [i for i in aaa if i!=aaa[0]]
    ddd = [i for i in ccc if i!=ccc[0]]
    eee = [i for i in ddd if i!=ddd[0]]
    if eee==[] and len(aaa)-len(ccc)==len(ccc)-len(ddd) and len(ccc)-len(ddd)==len(ddd):
        print("Yes")
        exit()
    print("No")
    exit()

Submission status: Wrong Answer

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

if N%3 != 0:
    print("No")
    exit()
else:
    count0 = aaa.count(0)
    if count0 == N:
        print("Yes")
        exit()
    bbb = [i for i in aaa if i != 0]
    if bbb.count(bbb[0])==N/3:
        print("Yes")
        exit()
    ccc = [i for i in aaa if i!=aaa[0]]
    ddd = [i for i in ccc if i!=ccc[0]]
    eee = [i for i in ddd if i!=ddd[0]]
    if eee==[] and len(aaa)-len(ccc)==len(ccc)-len(ddd) and len(ccc)-len(ddd)==len(ddd):
        print("Yes")
        exit()
    print("No")
    exit()

Submission status: Wrong Answer

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

if N%3 != 0:
    print("No")
    exit()
else:
    count0 = aaa.count(0)
    if count0 == N:
        print("Yes")
        exit()
    bbb = [i for i in aaa if i != 0]
    if bbb.count(bbb[0])==N/3:
        print("Yes")
        exit()
    ccc = [i for i in aaa if i!=aaa[0]]
    ddd = [i for i in ccc if i!=ccc[0]]
    eee = [i for i in ddd if i!=ddd[0]]
    if eee==[]:
        print("Yes")
        exit()
    print("No")
    exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
a = list(map(int, input().split()))
A = set()
table = collections.defaultdict(int)

a.sort(reverse=True)
for i in range(1, N):
    table[a[i]] += 2
prev = a[0]
now = a[0]
last = a[0]
for i in range(1, N):
    if (a[0] ^ a[i]) in table and table[a[0] ^ a[i]] > 0:
        table[a[0] ^ a[i]] -= 1
        last = a[i]
        now = a[0] ^ a[i]
        break
    if i == N-1:
        print("No")
        exit(0)
for i in range(2, N-2):
    if prev ^ now in table and table[now ^ prev] > 0:
        prev = now
        now = now ^ prev
        table[now ^ prev] -= 1
    else:
        print("No")
        exit(0)
if (last ^ now) == a[0]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
a = list(map(int, input().split()))
A = set()
table = collections.defaultdict(int)

a.sort(reverse=True)
for i in range(1, N):
    table[a[i]] += 1
prev = a[0]
now = a[0]
last = a[0]
for i in range(1, N):
    if (a[0] ^ a[i]) in table and table[a[0] ^ a[i]] > 0:
        table[a[0] ^ a[i]] -= 1
        last = a[i]
        now = a[0] ^ a[i]
        break
    if i == N-1:
        print("No")
        exit(0)

for i in range(2, N-2):
    if prev ^ now in table and table[now ^ prev] > 0:
        prev = now
        now = now ^ prev
        table[now ^ prev] -= 1
    else:
        print("No")
        exit(0)
print(last, now)
if (last ^ now) == a[0]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
a = list(map(int, input().split()))
A = set()
table = collections.defaultdict(int)

a.sort(reverse=True)
for i in range(1, N):
    table[a[i]] += 2
prev = a[0]
now = a[0]
last = a[0]
for i in range(1, N):
    if (a[0] ^ a[i]) in table and table[a[0] ^ a[i]] > 0:
        table[a[0] ^ a[i]] -= 1
        last = a[i]
        now = a[0] | a[i]
        break
    if i == N-1:
        print("No")
        exit(0)
for i in range(2, N-2):
    if prev ^ now in table and table[now ^ prev] > 0:
        prev = now
        now = now ^ prev
        table[now ^ prev] -= 1
    else:
        print("No")
        exit(0)
if (last ^ now) == a[0]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
a = list(map(int, input().split()))
A = set()
table = collections.defaultdict(int)
for i in range(1, N):
    table[a[i]] += 2
a.sort(reverse = True)
prev = a[0]
now = a[0]
last = a[0]
for i in range(1, N):
    if (a[0] ^ a[i]) in table and table[a[0] ^ a[i]] > 0:
        table[a[0] ^ a[i]] -= 1
        last = a[i]
        now = a[0] | a[i]
        break
    if i == N-1:
        print("No")
        exit(0)
for i in range(2, N-2):
    if prev ^ now in table and table[now ^ prev] > 0:
        prev = now
        now = now ^ prev
        table[now ^ prev] -= 1
    else:
        print("No")
        exit(0)
if (last ^ now) == a[0]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
a = list(map(int, input().split()))
A = set()
table = collections.defaultdict(int)
for i in range(1, N):
    table[a[i]] += 2
a.sort()
prev = a[0]
now = a[0]
last = a[0]
for i in range(1, N):
    if (a[0] ^ a[i]) in table and table[a[0] ^ a[i]] > 0:
        table[a[0] ^ a[i]] -= 1
        last = a[i]
        now = a[0] | a[i]
        break
    if i == N-1:
        print("No")
        exit(0)
for i in range(2, N-2):
    if prev ^ now in table and table[now ^ prev] > 0:
        prev = now
        now = now ^ prev
        table[now ^ prev] -= 1
    else:
        print("No")
        exit(0)
if (last ^ now) == a[0]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
a = list(map(int, input().split()))
A = set()
table = collections.defaultdict(int)
for i in range(1, N):
    table[a[i]] += 2
a.sort()
prev = a[0]
now = a[0]
last = a[0]
for i in range(1, N):
    if (a[0] ^ a[i]) in table and table[a[0] ^ a[i]] > 0:
        table[a[0] ^ a[i]] -= 1
        last = a[i]
        now = a[0] | a[i]
        break
for i in range(2, N-2):
    if prev ^ now in table and table[now ^ prev] > 0:
        prev = now
        now = now ^ prev
        table[now ^ prev] -= 1
    else:
        print("No")
        exit(0)
if (last ^ now) == a[0]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
a = list(map(int, input().split()))
A = set()
table = collections.defaultdict(int)
for i in range(1, N):
    table[a[i]] += 2
a.sort()
prev = a[0]
now = a[0]
last = a[0]
for i in range(1, N):
    if (a[0] ^ a[i]) in table and table[a[0] ^ a[i]] > 0:
        table[a[0] ^ a[i]] -= 1
        last = a[i]
        now = a[0] | a[i]
        break
print(prev, now, last)
for i in range(2, N-2):
    if prev ^ now in table and table[now ^ prev] > 0:
        prev = now
        now = now ^ prev
        table[now ^ prev] -= 1
    else:
        print("No")
        exit(0)
if (last ^ now) == a[0]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys, collections
readline=sys.stdin.buffer.readline

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

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

if len(a)%3!=0:
  print("No")
else:
  if len(set(a))==2:
    aa=collections.Counter(a).items()
    aa=list(aa)
    aa.sort()
    #print(aa)
    if aa[0][0]==0 and aa[0][1]*2==aa[1][1]:
      print("Yes")
    else:
      print("No")
  elif len(set(a))==3:
    aa=collections.Counter(a).items()
    aa=list(aa)
    #print("aa1:",aa)
    if aa[0][1]==aa[1][1]==aa[2][1]:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
  #3の倍数でa,b,c

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = Counter(map(int,input().split()))
a = a.items()
a = sorted(a,key=lambda x: x[1],reverse=1)
if n % 3 != 0 or len(a) > 3:
  f = 1
elif len(a) == 3:
  b,c,d = a[0][0],a[1][0],a[2][0]
  if b^d != c or c^b != d or d^c != b:
    f = 1
  elif a[0][1] == a[1][1] == a[2][1]:
    f = 0
  else:
    f = 1
elif len(a) == 2:
  b,c,d = a[0][0],a[0][0],a[1][0]
  if b^d != c or c^b != d or d^c != b:
    f = 1
  elif a[0][1] == 2*a[1][1]:
    f = 0
  else:
    f = 1
else:
  b,c,d = a[0][0],a[0][0],a[0][0]
  if b^d != c or c^b != d or d^c != b:
    f = 1
  else:
    f = 0
print('YNeos'[f::2])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
B = set(A)
C = list(B)
k = len(C)
if N%3==0:
    if k==3 and C[0]^C[1]==C[2] and C.count(C[0])==C.count(C[1]) and C.count(C[0])==C.count(C[2]):
        print("Yes")
    elif k==2:
        C = sorted(C)
        if C[0]==0 and C.count(C[0])==N//3:
            print("Yes")
        else:
            print("No")
    elif k==1 and C[0] == 0:
        print("Yes")
    else:
        print("No")
else:
    if k==1 and C[0] ==0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
B = set(A)
C = list(B)
k = len(C)
if N%3==0:
    if k==3 and C[0]^C[1]==C[2] and C.count(C[0])==C.count(C[1]) and C.count(C[0])==C.count(C[2]):
        print("Yes")
    elif k==2:
        C = sorted(C)
        if C[0]==0 and C.count(C[0])==N//3:
            print("Yes")
        else:
            print("No")
    elif k==1 and C[0] == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
B = set(A)
C = list(B)
k = len(C)
if N%3==0 and k==3 and C[0]^C[1]==C[2]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from collections import  Counter
n=int(input())
a=list(map(int,input().split()))
a.sort()
tmp=Counter(a)
if len(tmp)>3:
    print("No")
if len(tmp)==1:
    if not 0 in a:
        print("No")
    else:
        print("Yes")
elif len(tmp)==2:
    if tmp[0]==n//3 :
        print("Yes")
    else:
        print("No")
else:
    values, counts=zip(*tmp.most_common())
    if counts[0]==counts[1]==counts[2] and values[0]^values[1]^values[2]==0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
from collections import  Counter

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

tmp=Counter(a)
if len(tmp)>3:
    print("No")
    exit()

if len(tmp)==1:
    if not 0 in a:
        print("No")
    else:
        print("Yes")
elif len(tmp)==2:
    if tmp['0']==n//3 :
        print("Yes")
    else:
        print("No")
else:
    values, counts=zip(*tmp.most_common())
    if counts[0]==counts[1]==counts[2] and values[0]^values[1]^values[2]==0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

if N!=3:
    print("No")
    exit()

S=[""]*3
for i in range(3):
    temp=A[i]
    while temp>0:
        S[i]=str(temp%2)+S[i]
        temp=temp//2

mx=max(len(S[0]),len(S[1]),len(S[2]))
S1=[""]*3
for i in range(3):
    S1[i]=S[i].zfill(mx)

temp=""
for i in range(mx):
    if S1[0][i]==S1[1][i]:
        temp=temp+"0"
    else:
        temp=temp+"1"

if S[2]==temp:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from collections import Counter

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

if max(al)==0:
    print("Yes")
    exit()

d = Counter(al)
keys = sorted(d.keys())
if len(keys)==2:
    if n%3==0 and keys[0]==0 and d[keys[0]]*2==d[keys[1]]:
        print("Yes")
        exit()

if len(keys)==3:
    if n%3==0 and keys[0]^keys[1]^keys[2]==0:
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

if N % 3:
    ans = all(a == 0 for a in A)
else:
    c = Counter(A)
    if len(c) != 3:
        ans = False
    else:
        x, y, z = c.keys()
        ans = (c[x] == c[y] == c[z]) and (x ^ y == z)
print('Yes' if ans else 'No')

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

if N % 3:
    ans = all(a == 0 for a in A)
else:
    c = Counter(A)
    if len(c) != 3:
        ans = False
    else:
        x, y, z = c.keys()
        ans = (c[x] == c[y] == c[z]) and (x | y == z)
print('Yes' if ans else 'No')

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

if N % 3:
    ans = all(a == 0 for a in A)
else:
    c = Counter(A)
    if len(c) != 3:
        ans = False
    else:
        x, y, z = c.keys()
        ans = (x | y == z)
print('Yes' if ans else 'No')

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

if N % 3:
    ans = len(set(A)) == 1
else:
    c = Counter(A)
    if len(c) != 3:
        ans = False
    else:
        x, y, z = c.keys()
        ans = (x | y == z)
print('Yes' if ans else 'No')

Submission status: Wrong Answer

Solution code:
import collections

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

c = collections.Counter(a_list)
c_set = set(a_list)
check = -1
check_list = []

if len(c) == 1:
    if c[0] != 0:
        print("Yes")
        exit()
elif len(c) == 2:
    if c[0] == n//3:
        print("Yes")
        exit()
elif len(c) == 3:
    for i in c_set:
        check_list.append(i)
        if check == -1:
            check = c[i]
        else:
            if check != c[i]:
                print("No")
                exit()
    else:
        res = bin(check_list[0] ^ check_list[1] ^ check_list[2])
        if res == 0:
            print("Yes")
            exit()
        
print("No")

Submission status: Wrong Answer

Solution code:
import collections

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

# if n%3 != 0:
#     ans = sum(a_list)
#     if ans == 0:
#         print("Yes")
#     else:
#         print("No")
#     exit()


c = collections.Counter(a_list)
c_set = set(a_list)
check = -1

if len(c) == 1:
    if c[0] != 0:
        print("Yes")
        exit()
elif len(c) == 2:
    if c[0] == n//3:
        print("Yes")
        exit()
elif len(c) == 3:
    for i in c_set:
        if check == -1:
            check = c[i]
        else:
            if check != c[i]:
                print("No")
                exit()
    else:
        print("Yes")
        exit()
        
print("No")

Submission status: Wrong Answer

Solution code:
import collections

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

if n%3 != 0:
    ans = sum(a_list)
    if ans == 0:
        print("Yes")
    else:
        print("No")
    exit()


c = collections.Counter(a_list)
c_set = set(a_list)
check = -1

if len(c) == 1:
    if c[0] != 0:
        print("Yes")
        exit()
elif len(c) == 2:
    if c[0] == n//3:
        print("Yes")
        exit()
elif len(c) == 3:
    for i in c_set:
        if check == -1:
            check = c[i]
        else:
            if check != c[i]:
                print("No")
                exit()
    else:
        print("Yes")
        exit()
        
print("No")

Submission status: Wrong Answer

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

#3つ置きに一致する
S = {}
for ai in a:
    if ai in S:
        S[ai]+=1
    else:
        S[ai] = 1
A = list(S.keys())
#print(S)
#print(A)
    
if len(S) ==3:
    if A[0]==A[1]^A[2] and S[A[0]]==S[A[1]] and S[A[1]] == S[A[2]]:
        print("Yes")
    else:
        print("No")##漏れ


elif len(S)==2:#一番の漏れ
    if A[0]==0 and S[A[1]] == 2*S[A[0]]:#S[A[0]]==0じゃない
        print("Yes")
    elif A[1]==0 and S[A[0]] == 2*S[A[1]]:
        print("Yes")
    else:
        print("No")


elif len(S)==1:
    if S.values()==[0]:
        print("Yes")
    else:###
        print("No")
else:
    print("No")

Submission status: Wrong Answer

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

#3つ置きに一致する
S = {}
for ai in a:
    if ai in S:
        S[ai]+=1
    else:
        S[ai] = 1
A = list(S.keys())
if len(S)>3:
    print("No")
    sys.exit()
    
if len(S) ==3:
    if A[0]==A[1]^A[2] and S[A[0]]==S[A[1]] and S[A[1]] == S[A[2]]:
        print("Yes")


elif len(S)==2:
    if A[0]==0 and S[A[1]] == 2*S[A[0]]:#S[A[0]]==0じゃない
        print("Yes")
    elif A[1]==0 and S[A[0]] == 2*S[A[1]]:
        print("Yes")
    else:
        print("No")


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

Submission status: Wrong Answer

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

#3つ置きに一致する
S = {}
for ai in a:
    if ai in S:
        S[ai]+=1
    else:
        S[ai] = 1

if len(S)>3:
    print("No")
    sys.exit()
    
if len(S) ==3:
    A = list(S.keys())
    if A[0]==A[1]^A[2] and S[A[0]]==S[A[1]] and S[A[1]] == S[A[2]]:
        print("Yes")

elif len(S) == 2:
    A = list(S.keys())
    if A[0]== 0 or  A[1]==0 and S[A[0]] == S[A[1]]:
        print("Yes")
elif len(S)==1:
    if S.values()==[0]:
        print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys

n = int(input())
a = list(map(int, input().split( )))
#一意に決まるので試してしまう
b = [a[(i+1)%n]^a[(i-1+n)%n] for i in range(n)]

for i in range(n):
    if b[i]!=a[i]:
        print("No")
        sys.exit()

print("Yes")