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 defaultdict
n = int(input())
a = list(map(int, input().split()))

d = defaultdict(int)
for i in range(n):
    d[a[i]] += 1


if len(d) == 1 and 0 in d:
    ans = "Yes"
elif len(d) % 3 != 0:
    ans = "No"
else:
    key = list(d.keys())
    if len(d) == 2:
        if d[key[0]] == d[key[1]]*2 and key[0] ^ key[1] ^ key[1] == 0:
            ans = "Yes"
        elif d[key[1]] == d[key[0]]*2 and key[1] ^ key[0] ^ key[0] == 0:
            ans = "Yes"
        else:
            ans = "No"
    elif len(d) == 3:
        if d[key[0]] == d[key[1]] and d[key[1]] == d[key[2]] and key[0] ^ key[1] ^ key[2] == 0:
            ans = "Yes"
        else:
            ans = "No"
    else:
        ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = len(a)
a.append(a[0])
a.append(a[1])
c = 0
if max(a) == 0:
  print('Yes')
elif b/3 - b//3 != 0:
    print('No')
else:
  for i in range(b-1):
    if a[i]^a[i+1]^a[i+2] == 0 and a[i+1]^a[i+2]^a[i+3] == 0:
      c += 1
  if c != 0:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = len(a)
a.append(a[0])
a.append(a[1])
c = 0
if max(a) == 0:
  print('Yes')
elif b/3 - b//3 != 0:
    print('No')
else:
  for i in range(b-1):
    if a[i]^a[i+1]^a[i+2] != 0 and a[i+1]^a[i+2]^a[i+3] != 0:
      c += 1
  if c != 0:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = len(a)
a.append(a[0])
a.append(a[1])
c = 0
if max(a) == 0:
  print('Yes')
elif b/3 - b//3 != 0:
    print('No')
else:
  for i in range(b-1):
    if a[i]^a[i+1]^a[i+2]  != 0 or a[i+1]^a[i+2]^a[i+3] != 0:
      c += 1
  if c == 0:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = len(a)
a.append(a[0])
a.append(a[1])
c = 0
if max(a) == 0:
  print('Yes')
elif b/3 - b//3 != 0:
    print('No')
else:
  for i in range(b):
    if a[i]^a[i+1]^a[i+2]  != 0:
      c += 1
  if c == 0:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = len(a)
a.append(a[0])
a.append(a[1])
c = 0
if max(a)-min(a) == 0:
  print('Yes')
elif b/3 - b//3 != 0:
    print('No')
else:
  for i in range(b):
    if a[i]^a[i+1]^a[i+2]  != 0:
      c += 1
  if c == 0:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
import collections

N=int(input())
l=list(map(int,input().split()))
c=collections.Counter(l)
cv=list(c.values())
ck=list(c.keys())
if len(cv) == 3 and cv[0] == cv[1] and cv[1] == cv[2] and ck[0]==ck[1]^ck[2]:
    print("Yes")
elif len(cv) == 2 and ((cv[0] == cv[1]*2 and ck[0]==0) or (cv[1] == cv[0]*2 and ck[1]==0)):
    print("Yes")
elif len(cv) == 1 and ck[0] == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
l=list(map(int,input().split()))
s=list(set(l))
if len(s) == 3:
    if s[0]==s[1]^s[2]:
        print("Yes")
    else:
        print("No")
elif len(s) == 2:
    if s[0]==s[1]^s[1] and s[0]==0:
        print("Yes")
    elif s[1]==s[0]^s[0] and s[1]==0:
        print("Yes")
    else:
        print("No")
elif len(s) == 1 and s[0] == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
l=list(map(int,input().split()))
s=list(set(l))
if len(s) == 3:
    if s[0]==s[1]^s[2]:
        print("Yes")
    else:
        print("No")
elif len(s) == 2:
    if s[0]==s[1]^s[1] or s[1]==s[0]^s[0]:
        print("Yes")
    else:
        print("No")
elif len(s) == 1 and s[0] == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
l=list(map(int,input().split()))
s=list(set(l))
if len(s) == 3:
    if s[0]==s[1]^s[2]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
l=list(map(int,input().split()))
s=list(set(l))
if len(s) == 3:
  if s[0]==s[1]^s[2]:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter
from functools import reduce
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
if (len(c) == 0 and c[0] == n) or (len(c) == 2 and c[0] == n//3 and c[max(c.keys())] == 2*n//3) or (len(c) == 3 and reduce(lambda x, y: x^y, c.keys()) == 0 and set(c.values()) == set([n//3])):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter
from functools import reduce
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
if len(c) == 0 or (len(c) == 2 and c[0] == n//3 and c[max(c.keys())] == 2*n//3) or (len(c) == 3 and reduce(lambda x, y: x^y, c.keys()) == 0 and set(c.values()) == set([n//3])):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

for i in range(N):
    if a[i] == a[i-3] and a[i] == a[(i+3) % N]:
        ans += 1

print('Yes' if ans == N else 'No')

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
A.sort()
flag = True

for i in range(1,n):
  B = [A[0]]
  B.append(A[i])
  for j in range(2,n):
    c = B[j-2]^B[j-1]
    if B.count(c) == 0 and A.count(c) != 0:
      B.append(c)
    else:
      break
  if len(B) == n and B[0] == B[-1]^B[-2]:
    print('Yes')
    flag = False
    break
if flag:
  print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[int(x) for x in input().split()]
if N == 3:
  A.sort()
  if A[0]^A[1] == A[2]:
    print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N=int(input())

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

l=set(l)

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

Submission status: Wrong Answer

Solution code:
# your code goes here
n=int(input())
arr=list(map(int,input().split()))
f=True
arr.append(arr[0])
arr.append(arr[1])
arr.append(arr[2])
for i in range(n):
  if(arr[i]^arr[i+1]==arr[i+2]):
    continue
  else:
    f=False
    break
if f and n>=3:
  print("Yes")
elif f==False and n>=3:
  print("No")
if n==1:
  print("Yes")
elif n==2:
  print("No")

Submission status: Wrong Answer

Solution code:
# your code goes here
n=int(input())
arr=list(map(int,input().split()))
f=True
arr.append(arr[0])
arr.append(arr[1])
arr.append(arr[2])

for i in range(n):
  if(arr[i]^arr[i+1]==arr[i+2]):
    continue
  else:
    f=False
    break
if f:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

def XOR(x, y):
  u, i = 0, 0
  while x != 0 and y != 0:
    u += (((x % 2 + y % 2) % 2) * (2 ** i))
    x //= 2
    y //= 2
    i += 1
  return u
q = a[0]
for i in range(len(a)-1):
  q = XOR(q, a[i+1])
  
if q == 0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
import collections
n=int(input())
if n%3!=0:print("No");exit()
l=list(map(int,input().split()))
c=collections.Counter(l)
mc=c.most_common()
if len(mc)<3:print("No");exit()
if mc[0][1]==mc[1][1]==mc[2][1]==n//3:
    a,b,c=mc[0][0],mc[1][0],mc[2][0]
else:print("No");exit()
if a^b==c and b^c==a and c^a==b:
    print("Yes")
else:print("No")

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    d = dict()
    for a in A: d[a] = d.get(a, 0) + 1

    if len(d) == 1:
        a = list(d.keys())[0]
        if a == 0:
            return "Yes"
    elif len(d) == 2:
        a, b = list(d.keys())
        if (a == 0 or b == 0) and (d[a] == d[b]):
            return "Yes"
    elif len(d) == 3:
        a, b, c = list(d.keys())
        if d[a] == d[b] == d[c]:
            if (a^b == c and b^c == a and c^a == b) or (a^c == b and c^b == a and b^a == c):
                return "Yes"
    return "No"

if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = 0
l = list(map(int,input().split()))
i = 0 
while i+2 <= len(l)-1:
  if l[i+1] == l[i]^l[i+2]:
    print("ia am ",l[i])
    c=1
    i=i+1
  else:
    c=0
    i=i+1
if l[-1] == l[0]^l[-2]:
  print("ia am ",l[-1])
  c=1
if c==1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
s = 0
l = list(map(int,input().split()))
i = 0 
while i+2 <= len(l)-1:
  if l[i+1] == l[i]^l[i+2]:
    c=1
    i=i+1
  else:
    c=0
    i=i+1

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

Submission status: Wrong Answer

Solution code:

data = {}
N = int(input())
for i in input().split():
    if i not in data:
        data.update({i: 1})
    else:
        data[str(i)] += 1

ok = 0

if len(data.items()) > 3:
    pass
elif len(data.items()) == 1:
    if list(data.keys())[0] == "0":
        ok = 1
elif len(data.items()) == 2:
    print(data)
    if "0" in data.keys() and data["0"] == N/3:
        ok = 1
else:
    sum = 0
    for i, count in data.items():
        if not count == N/3:
            ok = -1
            break
        sum = sum ^ int(i)
    if ok == 0 and sum == 0:
        ok = 1

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

Submission status: Wrong Answer

Solution code:
import sys

data = {}
N = int(input())
for i in input().split():
    if i not in data:
        data.update({i: 1})
    else:
        data[str(i)] += 1

# print(data)
ok = 0

if len(data.items()) > 3:
    pass
elif len(data.items()) == 1:
    if list(data.items())[0][0] == "0":
        ok = 1
# elif not N%3 == 0:
#     pass
elif len(data.items()) == 2:
    if 0 in data.items() and data["0"] == N/3:
        ok = 1
else:
    sum = 0
    for i, count in data.items():
        if not count == N/3:
            ok = -1
            break
        sum = sum ^ int(i)
    if ok == 0 and sum == 0:
        ok = 1

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

Submission status: Wrong Answer

Solution code:
import sys

data = {}
N = int(input())
for i in input().split():
    if i not in data:
        data.update({i: 1})
    else:
        data[str(i)] += 1

# print(data)
ok = 0

if len(data.items()) > 3:
    pass
elif len(data.items()) == 1:
    if list(data.items())[0][0] == "0":
        ok = 1
elif not N%3 == 0:
    pass
elif len(data.items()) == 2:
    if 0 in data.items() and data["0"] == N/3:
        ok = 1
else:
    sum = 0
    for i, count in data.items():
        if not count == N/3:
            ok = -1
            break
        sum = sum ^ int(i)
    if ok == 0 and sum == 0:
        ok = 1

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

Submission status: Wrong Answer

Solution code:
import sys

data = {}
N = int(input())
for i in input().split():
    if i not in data:
        data.update({i: 1})
    else:
        data[str(i)] += 1
# print(data)
ok = 0

if not N % 3 == 0 or len(data.items()) > 3:
    pass
elif len(data.items()) == 1:
    if list(data.items())[0] == "0":
        ok = 1
elif len(data.items()) == 2:
    if 0 in data.items() and data["0"] == N/3:
        ok = 1
else:
    sum = 0
    for i, count in data.items():
        if not count == N/3:
            ok = -1
            break
        sum = sum ^ int(i)
    if ok == 0 and sum == 0:
        ok = 1

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

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
flag = True
for i in range(n):
  if i==0 and bin(A[-1]^A[1])!=bin(A[0]):
    flag = False
    break

  if i==n-1:
    if bin(A[0]^A[i-1])!=bin(A[i]):
      flag = False
      break
    else:
      break
  
  if not bin(A[i-1]^A[i+1])==bin(A[i]):
    flag = False
    break

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

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = collections.Counter(list(map(int, input().rstrip('\n').split()))).most_common()
    if len(a) == 3:
        if a[0][0] ^ a[1][0] ^ a[2][0] == 0 and a[0][1] == a[1][1] == a[2][1]:
            print("Yes")
            exit()
    elif len(a) == 2:
        if (a[0][0] == 0 and a[0][1] == a[1][1] ** 2) or (a[1][0] == 0 and a[1][1] == a[0][1] ** 2):
            print("Yes")
            exit()
    elif len(a) == 1 and a[0][0] == 0:
        print("Yes")
        exit()
    print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def one(L,param,num):
    tmp=0
    if(len(param)!=0):
        if(param[0]=="0"):
            num+="1"
            tmp=one(L,param[1:len(param)],num)
            if(tmp!=0):return tmp
        else:
            num+="0"
            tmp=one(L,param[1:len(param)],num)
            if(tmp!=0):return tmp
            num=num[0:len(num)-1]
            num+="1"
            tmp=one(L,param[1:len(param)],num)
            if(tmp!=0):return tmp
    else:
        if(L.count(int(num,2))!=0):
            return int(num,2)
        else:
            return 0
    return 0    

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

L.sort

MAX=max(L)
if(N%3!=0):
    if(MAX==0):
        print("Yes")
        exit()
    print("No")
    exit()

if((L.count(MAX)==(N/3))&(L.count(0)==(2*N/3))):
    print("Yes")
    exit()

K=len(str(format(max(L), 'b')))
L2=[0]*len(L)
for i in range(N):    
    tmp2=""
    tmp=str(format(L[i], 'b'))
    for j in range(K-len(tmp)):
        tmp2+="0"
    tmp2+=tmp
    L2[i]=tmp2
L3=[]
for i in range(2):
    num=one(L,L2[i],"")
    if(num==0) :
        print("No")
        exit()
    L.remove(num)
    L3.append(num)

i=0
while(True):
    if(len(L)==0):
        break
    tmp=int(bin(L3[i] ^ L3[i+1]),2)
    if(L.count(tmp)==0):
        print("No")
        exit()
    else:
        L.remove(tmp)
        L3.append(tmp)
    i+=1

print("Yes")

Submission status: Wrong Answer

Solution code:
def one(L,param,num):
    if(len(param)!=0):
        if(param[0]=="0"):
            num+="1"
            if(one(L,param[1:len(param)],num)==1):return 1
        else:
            num+="0"
            if(one(L,param[1:len(param)],num)):return 1
            num=num[0:len(num)-1]
            num+="1"
            if(one(L,param[1:len(param)],num)):return 1

    else:
        if(L.count(int(num,2))!=0):
            return 1
        else:
            return 0    

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

MAX=max(L)
if(N%3!=0):
    if(MAX==0):
        print("Yes")
        exit()
    print("No")
    exit()

if(L.count(MAX)==(N/3)):
    print("Yes")
    exit()

K=len(str(format(max(L), 'b')))
L2=[0]*len(L)
for i in range(N):    
    tmp2=""
    tmp=str(format(L[i], 'b'))
    for j in range(K-len(tmp)):
        tmp2+="0"
    tmp2+=tmp
    L2[i]=tmp2

for i in range(N):
    if(one(L,L2[i],"")!=1):
        print("No")
        exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
def one(L,param,num):
    if(len(param)!=0):
        if(param[0]=="0"):
            num+="1"
            if(one(L,param[1:len(param)],num)==1):return 1
        else:
            num+="0"
            if(one(L,param[1:len(param)],num)):return 1
            num=num[0:len(num)-1]
            num+="1"
            if(one(L,param[1:len(param)],num)):return 1

    else:
        if(L.count(int(num,2))!=0):
            return 1
        else:
            return 0    

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


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

K=len(str(format(max(L), 'b')))
L2=[0]*len(L)
for i in range(N):    
    tmp2=""
    tmp=str(format(L[i], 'b'))
    for j in range(K-len(tmp)):
        tmp2+="0"
    tmp2+=tmp
    L2[i]=tmp2

for i in range(N):
    if(one(L,L2[i],"")!=1):
        print("No")
        exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
def one(L,param,num):
    if(len(param)!=0):
        if(param[0]=="0"):
            num+="1"
            if(one(L,param[1:len(param)],num)==1):return 1
        else:
            num+="0"
            if(one(L,param[1:len(param)],num)):return 1
            num=num[0:len(num)-1]
            num+="1"
            if(one(L,param[1:len(param)],num)):return 1

    else:
        if(L.count(int(num,2))!=0):
            return 1
        else:
            return 0    

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


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

K=len(str(format(max(L), 'b')))
L2=[0]*len(L)
for i in range(N):    
    tmp2=""
    tmp=str(format(L[i], 'b'))
    for j in range(K-len(tmp)):
        tmp2+="0"
    tmp2+=tmp
    L2[i]=tmp2

for i in range(N):
    if(one(L,L2[i],"")!=1):
        print("No")
        exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
def one(L,param,num):
    if(len(param)!=0):
        if(param[0]=="0"):
            num+="1"
            if(one(L,param[1:len(param)],num)==1):return 1
        else:
            num+="0"
            if(one(L,param[1:len(param)],num)):return 1
            num=num[0:len(num)-1]
            num+="1"
            if(one(L,param[1:len(param)],num)):return 1

    else:
        if(L.count(int(num,2))!=0):
            return 1
        else:
            return 0    

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


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

K=len(str(format(max(L), 'b')))
L2=[0]*len(L)
for i in range(N):    
    tmp2=""
    tmp=str(format(L[i], 'b'))
    for j in range(K-len(tmp)):
        tmp2+="0"
    tmp2+=tmp
    L2[i]=tmp2

for i in range(N):
    if(one(L,L2[i],"")!=1):
        print("No")
        exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#AGC35 A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n = I()
a = LI()
if sum(a) == 0:
    print('Yes')
elif n % 3 != 0:
    print('No')
else:
    b = list(Counter(a).items())
    b.sort(key = itemgetter(0))
    if len(b) == 2:
        if b[0][0] == 0 and b[0][1] == n//3 and b[1][1] == n//3:
            print('Yes')
            quit()
    elif len(b) == 3:
        if b[0][0]^b[1][0]^b[2][0] == 0:
            if b[0][1] == n//3 and b[1][1] == n//3 and b[2][1] == n//3:
                print('Yes')
                quit()
    print('No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#AGC35 A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n = I()
a = LI()
if all(a) == 0:
    print('Yes')
else:
    b = list(Counter(a).items())
    b.sort(key = itemgetter(0))
    if len(b) == 2:
        if b[0][0] == 0 and b[0][1] == n//3:
            print('Yes')
            quit()
    k = 0
    for i,j in b:
        k ^= i
        if j != n//3:
            print('No')
            quit()
    if k == 0:
        print('Yes')
        quit()
    print('No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#AGC35 A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n = I()
a = LI()
if all(a) == 0:
    print('Yes')
else:
    b = list(Counter(a).items())
    b.sort(key = itemgetter(0))
    if len(b) == 2:
        if b[0][0] == 0 and b[0][1] == n//3:
            print('Yes')
            quit()
    elif len(b) == 3:
        if b[0][0]^b[1][0]^b[2][0] == 0:
            if b[0][1] == n//3 and b[1][1] == n//3 and b[2][1] == n//3:
                print('Yes')
                quit()
    print('No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#AGC35 A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n = I()
a = LI()
if all(a) == 0:
    print('Yes')
else:
    b = list(Counter(a).items())
    b.sort(key = itemgetter(0))
    if len(b) == 2:
        if b[0][0] == 0 and b[0][1] == n//3 and b[1][1] == n//3*2:
            print('Yes')
            quit()
    elif len(b) == 3:
        if b[0][0]^b[1][0]^b[2][0] == 0:
            if b[0][1] == n//3 and b[1][1] == n//3 and b[2][1] == n//3:
                print('Yes')
                quit()
    print('No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#AGC35 A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n = I()
a = LI()
if all(a) == 0:
    print('Yes')
else:
    b = list(Counter(a).items())
    b.sort(key = itemgetter(0))
    if len(b) == 2:
        if b[0][0] == 0 and b[0][1] == n//3 and b[1][1] == n//3*2:
            print('Yes')
            quit()
    elif len(b) == 3:
        if b[0][1] == n//3 and b[1][1] == n//3 and b[2][1] == n//3:
            print('Yes')
            quit()
    print('No')

Submission status: Wrong Answer

Solution code:
def getlist():
    return list(map(int, input().split()))

N = int(input())
a = getlist()
a = sorted(a)

if N % 3 != 0:
    if a[-1] >= 1:
        print("No")
    else:
        print("Yes")
else:
    m = int(N // 3)
    if a[0] == a[m - 1] and a[m] == a[2 * m - 1] and a[2 * m] == a[3 * m - 1]:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
a*=2
for i in range(n):
    x=bin(a[i])[2:]
    y=bin(a[i+2])[2:]
    if len(x)>len(y):
        y=(len(x)-len(y))*"0"+y
    else:
        x=(len(y)-len(x))*"0"+x
    if a[i+1]!=int("".join(["01"[(x[i]+y[i]).count("1")%2] for i in range(len(x))]),2):
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
a*=2
for i in range(n):
    if a[i+1]!=a[i]^a[i+2]:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

c = Counter(a)
k = list(c.keys())
v = list(c.values())
if len(c) == 3 and k[0] ^ k[1] == k[2] and v[0] == v[1] == v[2]:
    able = True
else:
    able = False
print('Yes' if able else 'No')

Submission status: Wrong Answer

Solution code:
n = int(input())
d = {}
for a in [int(x) for x in input().split()]:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1
ans = "No"
key = list(d.keys())
l_key = len(key)
if l_key == 1:
    if 0 in d:
        ans = "Yes"
elif l_key == 2:
    if 0 in d:
        if d[0] == n // 3:
            ans = "Yes"
elif l_key == 3:
    if key[0] ^ key[1] ^ key[2] == 0:
        ans = "Yes"

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
d = {}
for a in [int(x) for x in input().split()]:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1
ans = "No"
key = list(d.keys())
if 0 in d:
    if d[0] == n:
        ans = "Yes"
    elif len(key) == 2 and d[0] == n // 3:
        ans = "Yes"
else:
    if len(key) == 3:
        if key[0] ^ key[1] ^ key[2] == 0:
            ans = "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
nums = list(map(int, input().split()))
setNums = set(nums)

if len(setNums) == 3:
    nums = list(setNums)
    if (nums[0] ^ nums[2]) == nums[1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
nums = list(map(int, input().split()))
setNums = set(nums)

print("Yes") if len(setNums) == 3 else print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
nums = list(map(int, input().split()))
setNums = set(nums)

flag = True

for i in range(N):
    for j in range(i+1, N):
        if not nums[i] ^ nums[j] in setNums:
            flag = False

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
s = 1
for i in a:
    s ^= 1
if s == 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

for i in range(n):
  if i == 0:
    m = [l[-1], l[0], l[1]]
  elif i == n-1:
    m = [l[n-2], l[n-1], l[0]]
  else:
    m = [l[i-1], l[i], l[i+1]]
  p = len(bin(max(m)))-2
  for j in range(p):
    if ((j >> m[0]) + (j >> m[1]) + (j >> m[2]))%2 == 0:
      continue
    else:
      print('No')
      exit()
else:
  print('Yes')

Submission status: Wrong Answer

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

for i in range(n):
    if i==0:
        if (a[-1]^a[i+1])!=a[i]:
            print("No")
            exit()
    elif i==n-1:
        if (a[0]^a[-2])!=a[i]:
            print("No")
            exit()
    else:
        if (a[i-1]^a[i+1])!=a[i]:
            print("No")
            exit()

print(an)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a = collections.Counter(a)
a_list = list(a.items())
a_list = sorted(a_list,key = lambda a_list:a_list[0])

if len(a_list) == 1:
	if a_list[0][0] == 0:
		print("Yes")
	else:
		print("No")
elif len(a_list) == 2:
	if ((a_list[0][0] == 0) and (a_list[0][1] == int(N/3)) and \
		(a_list[1][1] == int(2*N/3))):
		print("Yes")
	else:
		print("No")
elif len(a_list) == 3:
	if (a_list[0][1] == int(N/3)) and \
		(a_list[1][1] == int(N/3) and \
			a_list[2][1] == int(N/3)):
		print("Yes")
	else:
		print("No")
else:
	print("No")

Submission status: Wrong Answer

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

a = collections.Counter(a)
a_list = list(a.items())
a_list = sorted(a_list,key = lambda a_list:a_list[0])
print(a_list)

if len(a_list) == 1:
	if a_list[0][0] == 0:
		print("Yes")
	else:
		print("No")
elif len(a_list) == 2:
	if ((a_list[0][0] == 0) and (a_list[0][1] == int(N/3)) and \
		(a_list[1][1] == int(2*N/3))):
		print("Yes")
	else:
		print("No")
elif len(a_list) == 3:
	if (a_list[0][1] == int(N/3)) and \
		(a_list[1][1] == int(N/3) and \
			a_list[2][1] == int(N/3)):
		print("Yes")
	else:
		print("No")
else:
	print("No")

Submission status: Wrong Answer

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

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

a.sort()
h = {}
for i in a:
    if i in h:
        h[i] += 1
    else:
        h[i] = 1
k = []
v = []
for i,j in h.items():
    k.append(i)
    v.append(j)

if len(h) == 1:
    if k[0] == 0:
        print("Yes")
elif len(h) == 2:
    if k[0] == 0 and 2*v[0] == v[1]:
        print("Yes")
elif len(h) == 3:
    if k[0] ^ k[1] == k[2] and v[0] == v[1] and v[1] == v[2]:
        print("Yes")
print("No")

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()
k = []
v = []
for i,j in h.items():
    k.append(i)
    v.append(j)
if k[0] ^ k[1] == k[2] and v[0] == v[1] and v[1] == v[2]:
    print("Yes")
else:
    print("No")

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()
k = []
v = []
for i,j in h.items():
    k.append(i)
    v.append(j)
if k[0] ^ k[1] == k[2] and v[0] == v[1] == v[2]:
    print("Yes")
else:
    print("No")