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

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

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

h = {}
for i in a:
    if i in h:
        h[i] += 1
    else:
        h[i] = 1
if len(h) != 3:
    print("No")
    exit()
    
a = []
for i in h.keys():
    a.append(int(i))
if a[0] ^ a[1] == a[2]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
li = list(map(int, input().split()))
for i in range(1, n - 1):
    a = bin(li[i - 1])[2:]
    b = bin(li[i])[2:]
    c = bin(li[i + 1])[2:]
    if len(a) >= len(b) and len(a) >= len(c):
        b = b.zfill(len(a))
        c = c.zfill(len(a))
    elif len(b) >= len(a) and len(b) >= len(c):
        a = a.zfill(len(b))
        c = c.zfill(len(b))
    else:
        a = a.zfill(len(c))
        b = b.zfill(len(c))
    for j in range(len(a)):
        if a[j] == c[j]:
            if b[j] != '0':
                print('No')
                exit()
        else:
            if b[j] != '1':
                print('No')
                exit()
print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
import collections
c = collections.Counter(list(map(int,input().split())))
k = list(c.keys())
v = list(c.values())
#print(k,v)
if len(k)==3 and k[0]^k[1]==k[2] and k[1]^k[2]==k[0] and k[2]^k[0]==k[1] and v[0]==v[1]==v[2]:
  print("Yes")
elif len(k)==2 and k.count(0) and v[k.index(0)]==(sum(v)*2/3):
  print("Yes")
elif k == [0]:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
import collections
c = collections.Counter(list(map(int,input().split())))
k = list(c.keys())
v = list(c.values())
if len(k)==3 and k[0]^k[1]==k[2] and k[1]^k[2]==k[0] and k[2]^k[0]==k[1] and v[0]==v[1]==v[2]:
  print("Yes")
elif len(k)==2 and v[k.index(0)]==sum(v)*2/3:
  print("Yes")
elif k == [0]:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
import collections
c = collections.Counter(list(map(int,input().split())))
k = list(c.keys())
v = list(c.values())
if len(k)==3 and k[0]^k[1]==k[2] and k[1]^k[2]==k[0] and k[2]^k[0]==k[1]:
  print("Yes")
elif len(k)==2 and v[k.index(0)]==sum(v)*2/3:
  print("Yes")
elif k == [0]:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import copy
def exc_or(int1, int2):
  exc_or = bin(int1^int2)
  return int(exc_or, 2)

N = int(input())
alist = list(map(int, input().split()))
tmp_alist = copy.copy(alist)

exc_ors = []
for i in range(N-1, -1, -1):
  value = exc_or(alist[i-1], alist[i])
  if value in tmp_alist:
    tmp_alist.remove(value)
  else:
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    from collections import Counter
    ls = Counter(map(int, input().split()))
    print('YNeos'[not check(n, ls)::2])

def check(n, ls):
    key = list(ls.keys())
    val = list(ls.values())
    l = len(key)
    if key[0] == 0 and val[0] == n:
        return True
    elif l <= 3 and n % 3 == 0:
        for v in val:
            if v != n / 3: return False
        if l == 1:
            if key[0] ^ key[0] == key[0]: return True
        elif l == 2:
            if key[0] ^ key[1] in key[0:1]: return True
        elif l == 3:
            if key[0] ^ key[1] == key[2] or key[1] ^ key[2] == key[0] or key[2] ^ key[0] == key[1]: return True
        return False
    else:
        return False

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    from collections import Counter
    ls = Counter(map(int, input().split()))
    print('YNeos'[not check(n, ls)::2])

def check(n, ls):
    key = list(ls.keys())
    val = list(ls.values())
    if key[0] == 0 and val[0] == n:
        return True
    elif len(key) <= 3 and n % 3 == 0:
        for v in val:
            if v != n / 3: return False
        if key[-2] ^ key[-1] == key[0] or key[-1] ^ key[0] == key[-2]: return True
        for i in range(len(key)-2):
            if key[i] ^ key[i+1] == key[i+2]: return True
        return False
    else:
        return False

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = map(int, input().split())
from collections import Counter
ls = Counter(a)
key = list(ls.keys())
val = list(ls.values())
if len(key) == 3 and n % 3 == 0:
    if key[0] ^ key[1] == key[2] or key[1] ^ key[2] == key[0] or key[2] ^ key[0] == key[1]:
        print('Yes')
    else:
        print('No')
elif key[0] == 0 and val[0] == n:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

flag="No"

count_by_kw = Counter()
for i in range(n):
    count_by_kw[a[i]]+=1

if count_by_kw.get(0) == n:
    flag="Yes"

if count_by_kw.get(0) == n/3 and len(count_by_kw.keys())==2:
    flag="Yes"

cl=list(count_by_kw.values())

if len(cl)==3:
    if cl[0] == cl[1] and cl[1] == cl[2]:
        flag="Yes"

print(flag)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

flag="No"

count_by_kw = Counter()
for i in range(n):
    count_by_kw[a[i]]+=1

print(count_by_kw)

if count_by_kw.get(0) == n:
    flag="Yes"

if count_by_kw.get(0) == n/3 and len(count_by_kw.keys())==2:
    flag="Yes"
    
if len(count_by_kw.values()) == 3:
    if count_by_kw.get(0) == count_by_kw.get(1) and count_by_kw.get(0) == count_by_kw.get(2):
        flag="Yes"
    
print(flag)

Submission status: Wrong Answer

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


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


import collections

c = collections.Counter(a)

klist = list(c.keys())
vlist = list(c.values())

if len(klist) == 1 and klist[0] == 0:
    print('Yes')
    sys.exit()

if len(klist) == 2:
    if (klist[0] == 0 and vlist[0] == N/3) or (klist[1] == 0 and vlist[1] == N/3):
        print('Yes')
        sys.exit()

if not len(klist) == 3:
    print('No')
    sys.exit()

if not (vlist[0] == vlist[1] and vlist[1] == vlist[2]):
    print('No')
    sys.exit()

if not (klist[0] ^ klist[1] ^ klist[2] == 0):
    print('No3')
    sys.exit()

print('Yes')

Submission status: Wrong Answer

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


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


import collections

c = collections.Counter(a)

klist = list(c.keys())
vlist = list(c.values())

if len(klist) == 1 and klist[0] == 0:
    print('Yes')
    sys.exit()

if len(klist) == 2:
    if (klist[0] == 0 and vlist[0] == N/3) or (klist[1] == 0 and vlist[1] == N/3):
        print('Yes')
        sys.exit()

if not len(klist) == 3:
    print('No')
    sys.exit()

if not (vlist[0] == vlist[1] and vlist[1] == vlist[2]):
    print('No')
    sys.exit()

if not (klist[0] ^ klist[1] == klist[2]):
    print('No3')
    sys.exit()

print('Yes')

Submission status: Wrong Answer

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


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


import collections

c = collections.Counter(a)

klist = list(c.keys())
vlist = list(c.values())

if len(klist) == 1 and klist[0] == 0:
    print('Yes')
    sys.exit()

if len(klist) == 2:
    if (0 in klist) and vlist[0] % (N/3) == 0:
        print('Yes')
        sys.exit()

if not len(klist) == 3:
    print('No')
    sys.exit()

if not (vlist[0] == vlist[1] and vlist[1] == vlist[2]):
    print('No')
    sys.exit()

if not (klist[0] ^ klist[1] == klist[2]):
    print('No3')
    sys.exit()

print('Yes')

Submission status: Wrong Answer

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


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


import collections

c = collections.Counter(a)

klist = list(c.keys())

if not len(klist) == 3:
    print('No')
    sys.exit()

vlist = list(c.values())
if not (vlist[0] == vlist[1] and vlist[1] == vlist[2]):
    print('No')
    sys.exit()

if not (klist[0] ^ klist[1] == klist[2]):
    print('No3')
    sys.exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import Counter
N=int(input())
A=Counter(list(map(int,input().split())))
B=list(A.values())
if len(B)!=3:print("No")
elif B[0]!=B[1] or B[1]!=B[2]:print("No")
else:print("Yes")

Submission status: Wrong Answer

Solution code:
print('No')

Submission status: Wrong Answer

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

if len(a_unique) == 1 and a[0] == 0:
    ans = 'Yes'
elif len(a) % 3 == 0 :
    if len(a_unique) == 3:
        if bin(a_unique[0]) == bin(a_unique[1] ^ a_unique[2]) and bin(a_unique[1]) == bin(a_unique[0] ^ a_unique[2]) and bin(a_unique[2]) == bin(a_unique[1] ^ a_unique[0]):
            ans = 'Yes'
        else:
            ans = 'No'
    elif len(a_unique) == 2:
        if a_unique[0] == 0 and a.count(a_unique[1]) == N//3 * 2:
            ans = 'Yes'
        else:
            ans = 'No'
    else:
        ans = 'No'
else:
    ans = 'No'

print(ans)

Submission status: Wrong Answer

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

if a_unique == 1 and a[0] == 0:
    ans = 'Yes'
elif len(a) % 3 == 0 :
    if len(a_unique) == 3:
        if bin(a_unique[0]) == bin(a_unique[1] ^ a_unique[2]) and bin(a_unique[1]) == bin(a_unique[0] ^ a_unique[2]) and bin(a_unique[2]) == bin(a_unique[1] ^ a_unique[0]):
            ans = 'Yes'
        else:
            ans = 'No'
    elif len(a_unique) == 2:
        if a_unique[0] == 0 :
            ans = 'Yes'
        else:
            ans = 'No'
    else:
        ans = 'No'
else:
    ans = 'No'

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
a = [int(i) for i in input().split()]
for i in range(n - 1):
    if (a[i - 1] ^ a[i + 1] != a[i]):
        print('No')
        sys.exit(0)
print('Yes' if a[0] ^ a[-2] == a[-1] else 'No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a)
if len(c)>3:
    print('No')
elif len(c)==3 and n%3==0:
    f = 0
    for i in c.keys():
        f^=i
    if f==0:
        for i in c.values():
            if i!=c[a[0]]:
                print('No')
                break
        print('Yes')
elif len(c)==2:
    if c[0]==n//3:
        ans = 0
        for i in a:
            ans^=i
        if ans ==0:
            print('Yes')
elif len(c)==1:
    if c[0]==n:
        print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a)
if len(c)>3:
    print('No')
elif len(c)==3:
    f = 0
    for i in c.keys():
        f^=i
    if f==0:
        for i in c.values():
            if i!=c[a[0]]:
                print('No')
                break
        print('Yes')
elif len(c)==2:
    if c[0]==n//3:
        print('Yes')
elif len(c)==1:
    if c[0]==n:
        print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a)
if len(c)>3:
    print('No')
elif len(c)==3:
    f = 0
    for i in c.keys():
        f^=i
    if f==0:
        print('Yes')
elif len(c)==2:
    if c[0]==n//3:
        print('Yes')
elif len(c)==1:
    if c[0]==n:
        print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())    
data = list(map(lambda x: int(x), input().split(" ")))    
    
def yes():    
    print("Yes")    
    
def no():    
    print("No")    
    
dic = {}    
for i in data:    
    if i in dic:    
        dic[i] += 1    
    else:    
        dic[i] = 1    
    
keys = list(dic.keys())    
if len(keys) == 1 and keys[0] == 0:    
    yes()    
elif len(keys) == 3:    
    a = keys[0]    
    b = keys[1]    
    c = keys[2]    
    if a ^ b == c and dic[a] == dic[b] and dic[b] == dic[c]:    
        yes()    
    else:    
        no()    
else:    
    no()

Submission status: Wrong Answer

Solution code:
n=int(input())

def xor(x,y):
    return ((x and y) or (not (x or y)))

def change(x):
    da=[True for i in range(31)]
    for i in da:
        da[i]=bool(x%2)
        x/=2
    return da

da=list(map(int,input().split()))
di={}
ans=False
for i in da:
    if i in di.keys():
        di[i]+=1
    else:
        di[i]=1
va=list(di.values())
ke=list(di.keys())
if len(di)==3:
    if va[0]==va[1] and va[0]==va[2]:
        if va[0]^va[1]==va[2]:
            ans=True
elif len(di)==2:
    if va[0]==va[1]*2 or va[1]==va[0]*2:
        ko=[change(i) for i in ke]
        for i in range(31):
            if not xor(xor(ko[0][i],ko[1][i]),ko[0][i]):
                break
            if i==30:
                ans=True
        for i in range(31):
            if not xor(xor(ko[0][i],ko[1][i]),ko[1][i]):
                break
            if i==30:
                ans=True

elif len(di)==1:
    if ke[0]==0:
        ans=True
if ans:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())

def xor(x,y):
    return ((x and y) or (not (x or y)))

def change(x):
    da=[True for i in range(31)]
    for i in da:
        da[i]=bool(x%2)
        x/=2
    return da

da=list(map(int,input().split()))
di={}
ans=False
for i in da:
    if i in di.keys():
        di[i]+=1
    else:
        di[i]=1
va=list(di.values())
ke=list(di.keys())
if len(di)==3:
    if va[0]==va[1] and va[0]==va[2]:
        ko=[change(i) for i in ke]
        for i in range(31):
            if not (xor(ko[0][i],ko[1][i]),ko[2][i]):
                break
            if i==30:
                ans=True
elif len(di)==2:
    if va[0]==va[1]*2 or va[1]==va[0]*2:
        ko=[change(i) for i in ke]
        for i in range(31):
            if not xor(xor(ko[0][i],ko[1][i]),ko[0][i]):
                break
            if i==30:
                ans=True
        for i in range(31):
            if not xor(xor(ko[0][i],ko[1][i]),ko[1][i]):
                break
            if i==30:
                ans=True

elif len(di)==1:
    if ke[0]==0:
        ans=True
if ans:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())

def xor(x,y):
    return ((x and y) or (not (x or y)))

def change(x):
    da=[True for i in range(31)]
    for i in da:
        da[i]=bool(x%2)
        x/=2
    return da

da=list(map(int,input().split()))
di={}
ans=False
for i in da:
    if i in di.keys():
        di[i]+=1
    else:
        di[i]=1
va=list(di.values())
ke=list(di.keys())
if len(di)==3:
    if va[0]==va[1] and va[0]==va[2]:
        ko=[change(i) for i in ke]
        for i in range(31):
            if not (xor(ko[0][i],ko[1][i]),ko[2][i]):
                break
            if i==29:
                ans=True
elif len(di)==2:
    if va[0]==va[1]*2 or va[1]==va[0]*2:
        ko=[change(i) for i in ke]
        for i in range(31):
            if not xor(xor(ko[0][i],ko[1][i]),ko[0][i]):
                break
            if i==29:
                ans=True
        for i in range(31):
            if not xor(xor(ko[0][i],ko[1][i]),ko[1][i]):
                break
            if i==29:
                ans=True

elif len(di)==1:
    if ke[0]==0:
        ans=True
if ans:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())

def xor(x,y):
    return ((x and y) or (not (x or y)))

def change(x):
    da=[True for i in range(30)]
    for i in da:
        da[i]=bool(x%2)
        x/=2
    return da

da=list(map(int,input().split()))
di={}
ans=False
for i in da:
    if i in di.keys():
        di[i]+=1
    else:
        di[i]=1
va=list(di.values())
ke=list(di.keys())
if len(di)==3:
    if va[0]==va[1] and va[0]==va[2]:
        ko=[change(i) for i in ke]
        for i in range(30):
            if not (xor(ko[0][i],ko[1][i]),ko[2][i]):
                break
            if i==29:
                ans=True
elif len(di)==2:
    if va[0]==va[1]*2 or va[1]==va[0]*2:
        ko=[change(i) for i in ke]
        for i in range(30):
            if not xor(xor(ko[0][i],ko[1][i]),ko[0][i]):
                break
            if i==29:
                ans=True
        for i in range(30):
            if not xor(xor(ko[0][i],ko[1][i]),ko[1][i]):
                break
            if i==29:
                ans=True

elif len(di)==1:
    if ke[0]==0:
        ans=True
if ans:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())

def xor(x,y):
    return ((x and y) or (not (x or y)))

def change(x):
    da=[True for i in range(30)]
    for i in da:
        da[i]=bool(x%2)
        x/=2
    return da

da=list(map(int,input().split()))
di={}
ans=False
for i in da:
    if i in di.keys():
        di[i]+=1
    else:
        di[i]=1
va=list(di.values())
ke=list(di.keys())
if len(di)==3:
    if va[0]==va[1] and va[0]==va[2]:
        ko=[change(i) for i in ke]
        for i in range(30):
            if not (xor(ko[0][i],ko[1][i]),ko[2][i]):
                break
            if i==29:
                ans=True
elif len(di)==2:
    if va[0]==va[1]*2 or va[1]==va[0]*2:
        ko=[change(i) for i in ke]
        for i in range(30):
            if (not xor(xor(ko[0][i],ko[1][i]),ko[0][i])) or (not xor(xor(ko[0][i],ko[1][i]),ko[1][i])):
                break
            if i==29:
                ans=True
elif len(di)==0:
    if ke[0]==0:
        ans=True
if ans:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
 
def main():
  n = int(input())
  numList = []
  numList = list(map(int,input().split()))
  count = int(n / 3)
  tmp =0
 
  result = 'No'
  
  if n%3 == 0 and len(numList) > 2:
    a = sum(i == numList[0] for i in numList)
    y = sum(j == numList[1] for j in numList)
    xor = sum(k == numList[2] for k in numList)
    if a  == count and y  == count and xor  == count:
      result = 'Yes'
  else:
    for num in numList:
      tmp += num
    
    if tmp == 0:
      result = 'Yes'
    
  print(result)
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
 
def main():
  n = int(input())
  numList = []
  numList = list(map(int,input().split()))
  tmp =0
 
  result = 'No'
  
  if n%3 == 0 and len(numList) > 2:
    xor = int(numList[0]) ^ int(numList[2])
    if xor == numList[1]:
      result = 'Yes'
  else:
    for num in numList:
      tmp += num
    
    if tmp == 0:
      result = 'Yes'
    
  print(result)
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
 
def main():
  n = int(input())
  numList = []
  numList = list(map(int,input().split()))
  tmp =0
 
  result = 'No'
  
  if n%3 == 0:
    xor = int(numList[0]) ^ int(numList[2])
    if xor == numList[1]:
      result = 'Yes'
  else:
    for n in numList:
      tmp += n
    
    if tmp == 0:
      result = 'Yes'
    
  print(result)
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
 
def main():
  n = int(input())
  numList = []
  numList = list(map(int,input().split()))
 
  result = 'No'
 
  xor = int(numList[0]) ^ int(numList[2])
  if xor == numList[1]:
    result = 'Yes'
 
  print(result)
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

if n%3 == 0:
    if len(b) == 1:
        if a[0] == 0:
            print('Yes')
        else:
            print('No')
    elif len(b) == 2:
        if a.count(0) == n//3:
            print('Yes')
        else:
            print('No')
    elif len(b) == 3:
        if b[0]^b[1] == b[2]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
elif n%3 == 1:
    if b == [0]:
        print('Yes')
    else:
        print('No')
else:
    if b==[0]:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

if n%3 == 0:
    if len(b) == 1:
        if a[0] == 0:
            print('Yes')
        else:
            print('No')
    elif len(b) == 2:
        if a.count(0) == n//3:
            print('Yes')
        else:
            print('No')
    elif len(b) == 3:
        if b[0]^b[1] == b[2]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
elif n%3 == 1:
    if b == [0]:
        print('Yes')
    else:
        print('No')
else:
    if b==[0]:
        print('Yes')
    elif len(b) == 2:
        if a.count(0) == (n+1)//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))

if n%3 == 0:
    if len(b) == 1:
        if a[0] == 0:
            print('Yes')
        else:
            print('No')
    elif len(b) == 2:
        print('No')
    elif len(b) == 3:
        if b[0]^b[1] == b[2]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
elif n%3 == 1:
    if b == [0]:
        print('Yes')
    else:
        print('No')
else:
    if b==[0]:
        print('Yes')
    elif len(b) == 2:
        if a.count(0) == (n+1)//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))

if n%3 == 0:
    if len(b) == 1:
        if a[0] == 0:
            print('Yes')
        else:
            print('No')
    elif len(b) == 2:
        print('No')
    elif len(b) == 3:
        if b[0]^b[1] == b[2]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
elif n%3 == 1:
    if b == [0]:
        print('Yes')
    else:
        print('No')
else:
    if b==[0]:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
numbers = input().split()
circle = True

leftNumber = int(numbers[-1])
currentNumber = int(numbers[0])
rightNumber = int(numbers[1])
if currentNumber != leftNumber ^ rightNumber:
  circle = False

for i in range(N-2):
  leftNumber = int(numbers[i-1])
  currentNumber = int(numbers[i])
  rightNumber = int(numbers[i+1])
  if currentNumber != leftNumber ^ rightNumber:
    circle = False
    
leftNumber = int(numbers[N-2])
currentNumber = int(numbers[N-1])
rightNumber = int(numbers[0])
if currentNumber != leftNumber ^ rightNumber:
  circle = False
  
if circle == False:
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
N=int(input())
arr=list(map(int,input().split()))
def bin30(a):
    s=bin(a)[2:]
    return "0"*(30-len(s))+s
def rotate(arr,i):
    return arr[i:]+arr[:i]
def shrink(arr):
    ret=[]
    i=0
    while i<len(arr):
        tmp = arr[i]
        j=i
        while j<len(arr) and arr[j]==tmp:
            j+=1
        ret.append((tmp,j-i))
        i=j
    return ret
barr=[bin30(a) for a in arr]
for bits in zip(*barr):
    i=0
    while i<N and bits[i]=='1': i+=1
    for b,n in shrink(rotate(bits,i)):
        if b=='1' and n%2==1:
            print("No")
            exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
N=int(input())
arr=list(map(int,input().split()))
def bin30(a):
    s=bin(a)[2:]
    return "0"*(30-len(s))+s
def rotate(arr,i):
    return arr[i:]+arr[:i]
def shrink(arr):
    ret=[]
    i=0
    while i<len(arr):
        tmp = arr[i]
        j=i
        while j<N and arr[j]==tmp:
            j+=1
        ret.append((tmp,j-i))
        i=j
    return ret
barr=[bin30(a) for a in arr]
for bits in zip(*barr):
    i=0
    while i<N and bits[i]=='1': i+=1
    for b,n in shrink(rotate(bits,i)):
        if b=='1' and n%2==1:
            print("No")
            exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
N=int(input())
arr=list(map(int,input().split()))
def bin30(a):
    s=bin(a)[2:]
    return "0"*(30-len(s))+s
def rotate(arr,i):
    return arr[i:]+arr[:i]
def shrink(arr):
    ret=[]
    i=0
    while i<len(arr):
        tmp = arr[i]
        j=i
        while j<N and arr[j]==tmp:
            j+=1
        ret.append((tmp,j-i))
        i=j
    return ret
barr=[bin30(a) for a in arr]
for bits in zip(*barr):
    i=0
    while i<N and bits[i]=='1': i+=1
    for b,n in shrink(rotate(bits,i)):
        if b=='1' and n%2==1:
            print("No")
print("Yes")

Submission status: Wrong Answer

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

a = Counter(a_array)

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


if len(a) == 3:
    i_array = []
    for i, x in a.items():
        i_array.append(i)
        if x != N // 3:
            print("No")
            exit()
    else:
        if i_array[0] ^ i_array[1] == i_array[2]:
            print("Yes")
            exit()
        else:
            print("No")
else:
    print("No")
    exit()

Submission status: Wrong Answer

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

a = Counter(a_array)

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


if len(a) == 3:
    for d in a.values():
        if d != N // 3:
            print("No")
            exit()
    else:
        print("Yes")
        exit()
else:
    print("No")
    exit()

Submission status: Wrong Answer

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

if N % 3 != 0:
    print("No")
    exit()
a = Counter(a_array)

if len(a) == 3:
    for d in a.values():
        if d != N // 3:
            print("No")
    else:
        print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def dfs(s,start,a,b):
    next_num = a ^ b
    if len(s) == 0:
        if start == next_num:
            print("Yes")
            exit()
        else:
            return -1
    if next_num in s:
        s.remove(next_num)
        dfs(s,start,b,next_num)
    else:
        return -1
    
def main():
    N = int(input())
    a_array = list(map(int,input().split()))
    a = a_array[0]
    for b in a_array[1:]:
        a_set = set(a_array[1:])
        a_set.remove(b)
        dfs(a_set,a,a,b)
    print("No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
D=dict()
for i in range(N):
    if a[i] in D:
        D[a[i]]+=1
    else:
        D[a[i]]=1
L=list(D.items())
L.sort()
#print(L)

if len(L)==1:
    print("Yes")
    exit()
elif len(L)==2:
    if L[0][0]==0 and L[1][1]==L[0][1]*2:
        print("Yes")
        exit()
elif len(L)==3:
    #print(1)
    if L[0][1]==L[1][1] and L[1][1]==L[2][1]:
        #print(2)
        if L[1][0]==L[0][0]^L[2][0] and L[2][0]==L[1][0]^L[0][0] and L[0][0]==L[1][0]^L[2][0]:
            print("Yes")
            exit()
print("No")

Submission status: Wrong Answer

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

D=dict()
for i in range(N):
    if a[i] in D:
        D[a[i]]+=1
    else:
        D[a[i]]=1
L=list(D.items())
L.sort()
#print(L)

if len(L)==1:
    print("YES")
    exit()
elif len(L)==2:
    if L[0][0]==0 and L[1][1]==L[0][1]*2:
        print("YES")
        exit()
elif len(L)==3:
    #print(1)
    if L[0][1]==L[1][1] and L[1][1]==L[2][1]:
        #print(2)
        if L[1][0]==L[0][0]^L[2][0] and L[2][0]==L[1][0]^L[0][0] and L[0][0]==L[1][0]^L[2][0]:
            print("YES")
            exit()
print("NO")

Submission status: Wrong Answer

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

s = set(a)

if len(s) == 1:
    if a[0] == 0:
        print("Yes")
    else:
        print("No")
elif len(s) == 2:
    if N > 3:
        print("No")
    else:
        if a[0] == 0 and a[1] != 0:
            print("Yes")
        else:
            print("No")
elif len(s) == 3:
    if a[0] == 0:
        print("No")
    else:
        L = []
        for i in s:
            L.append(i)
        
        if L[0]^L[1] == L[2] and N % 3 == 0:
            p = a.count(L[0])
            q = a.count(L[1])
            r = a.count(L[2])
            if p == q and q == r:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
else:
    print("No")