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:
N = int(input())
a = list(map(int,input().split()))
a.sort()

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
if N % 2 == 0:
   print('No')
else:
   print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
c = list(map(int, input().split()))
c_set = set(c)
ans = 'no'

if n % 2 == 1 and len(c_set) == 3:
    if c[0] ^ c[1] == c[2]:
        ans = 'yes'


print(ans)

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
a_lis = [int(_) for _ in input().split()]

if set(a_lis) == {0}:
    print('Yes')
    sys.exit()
else:
    if len(a_lis) % 3 == 0:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

k = {}
for i in range(N):
    if i == 0:
        B = A[0]
        continue
    else:
        B = B ^ A[i]
    if not B in k:
        k[B] = 1
    else:
        k[B] += 1

OK = False
for key, val in k.items():
    if val == N // 3:
        OK = True

if N % 3 == 0 and  B == 0 and OK:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int,input().split()))
    if N % 2 == 0:
        return sum(A) == 0
    hoge = A[0]
    for i in A[1:]:
        hoge ^= i
    return hoge == 0

print(['False','True'][main()])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for ai in range(len(An)):
    post_index = ai + 1 if ai + 1 <= len(An) - 1 else 0
    pre = An[ai - 1]
    post = An[post_index]
    if (pre ^ post) != An[ai]:
        print("No")
        exit(0)

print("Yes")

Submission status: Wrong Answer

Solution code:
import sys

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

from collections import Counter
ac = Counter(a)

if len(ac) == 3 and len(Counter(ac.values())) == 1:
    print('Yes')
    sys.exit()
if len(ac) == 2 and ac.most_common()[0][1] == ac.most_common()[1][1] * 2 and ac.most_common()[0][0]^ac.most_common()[0][0] == ac.most_common()[1][0]:
    print('Yes')
    sys.exit()
if len(ac) == 1 and ac.most_common()[0][0] == 0:
    print('Yes')
    sys.exit()
print('No')

Submission status: Wrong Answer

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

ans = 'No'
if N%3 == 0:
    hat1 = max(a)
    hat2 = min(a)
    if hat1 == hat2 & a.count(hat1) == N:
        ans = 'Yes'
    if a.count(hat1) == int(N/3) & a.count(hat1) == int(N/3) & a.count(hat1^hat2) == int(N/2):
        ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
def is_circle(current_list, rest_list):
    if rest_list == []:
        if current_list[-1] ^ current_list[0] == current_list[1]:
            return True
        else:
            return False
    next_int = current_list[-1] ^ current_list[-2]
    if next_int in input_list:
        current_list.append(next_int)
        rest_list.remove(next_int)
        return is_circle(current_list, rest_list)
    else:
        return False
        

n = int(input())
input_list = [int(i) for i in input().split(' ')]

if is_circle(input_list, []):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

if n == 3:
  print("Yes")
else :
  print("No")

Submission status: Wrong Answer

Solution code:
a = int(input())
x = list(map(int,input().split()))
def Y(a,t = 0):
    if a==t : print('YES')
    else : print('NO')
def y(a, t =0):
    if a==t : print('Yes')
    else : print('No')
t = (len(x) == x.count(1) + x.count(2) + x.count(3)) * (x.count(1) == x.count(2) and x.count(2) == x.count(3))

y(1,t)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
if a[0] ^ a[1] and len(a) % 2 == 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    f=(i-1)%3
    b=(i+1)%3
    if a[f]^a[b]!=a[i]:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
j = 0
u = []
v = [0]*3
for i in l:
    if not i in u :
        u.append(i)
    else:
        v[u.index(i)] += 1
    if len(u) > 3:
        break
#print(u,v)
if ((n%3 == 0) and (l[0] ^ l[2] == l[1]) and (v[0] == v[1] and v[1] == v[2]) and not len(u) > 3):
    j = 1
if j == 1 :
    print("Yes")
else :
    print("No")
#print(l[0] ^ l[2] == l[1],n == 3)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = list(set(a))
flag = False
if len(b) == 3:
    if b[0] ^ b[1] == b[2]:
        flag = True
if len(b) == 1:
    if b[0] == 0:
        flag = True
if len(b) == 2:
    if 0 in b and a.count(0) == N // 3:
            flag = True


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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
c = [0, 0]
for i in range(n):	c[a[i]%2] += 1
if c[1] == 0 :				print("Yes")
elif ((n+1)//2) <= c[1] : 	print("Yes")
else :						print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter

N= int(input())

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

x = Counter(a)

ok = False
if len(x) == 3:
    for i in a:
        if x[i] != len(a) // 3:
            break
    else:
        w = 0
        for j in x:
            w ^= j
        if w == 0:
            ok = True
elif len(x) == 1:
    if x.get(0) is not None:
        ok = True

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

Submission status: Wrong Answer

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

for i in range(-2, N-2):
    x=int(bin(A[i] ^ A[i+2]), 0) -A[i+1]
    if not x == 0:
        flag=1
    if flag ==1:
        break
if flag==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if n == 3 and a[0] ^ a[1] == a[2]:
  print("Yes")
elif n >= 4 and set(a) == {0}:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
aLst = list(map(int, input().split()))
ansB = False
for i in range(N):
    if i == 0:
        if aLst[0] == (aLst[-1] ^ aLst[1]):
            ansB = True
            break
        else:
            continue
    elif i == (N - 1):
        if aLst[i] == (aLst[i - 1] ^ aLst[0]):
            ansB = True
            break
        else:
            continue
    else:
        if aLst[i] == (aLst[i - 1] ^ aLst[i + 1]):
            ansB = True
            break
        else:
            continue

if ansB:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def main():
	N = int(input())
	A = list(map(int, input().split()))
	if N & (N+1) != 0:
		print("No")
		return

	tmp = N
	n_len = 0
	while tmp:
		n_len += 1
		tmp >>= 1
	arr = [0]*n_len

	xor = 0
	for a in A:
		xor ^= a
		tmp = a
		for i in range(n_len):
			if tmp & 1 == 1:
				arr[i] += 1
			tmp >>= 1
	if xor != 0:
		print("No")
		return

	possible = True
	for i in range(n_len):
		if arr[i] != (N+1)//2:
			possible = False
			break
	if possible:
		print("Yes")
	else:
		print("No")


if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
s=0
a.sort()
if a[0]==0:
    if a.count(a[0])==n//3 and a.count(a[n//3])==n//3*2:
        s=1
else:
    if n%3==0:
        if a.count(a[0])==n//3 and a.count(a[n//3])==n//3 and a.count(a[n//3*2])==n//3:
            s=1
if s==1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin, exit

N = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]

if N % 3 != 0:
    print('No')
    exit()
else:
    num = []
    for k in a:
        if k not in num:
            num.append(k)
        if len(num) > 3:
            print('No')
            exit()
    if len(num) <= 2:
        print('No')
        exit()
    if num[0] ^ num[1] != num[2] and num[2] ^ num[1] != num[0] and num[0] ^ num[2] != num[1]:
        print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
r = list(map(int,input().rstrip().split(' ')))
if (r[1] ^ r[N-1]) != r[0]:
    f = 0
else:
    f = 1
for i in range(1,N-1):
    if (r[i-1] ^ r[i+1]) != r[i]:
        f = 0
        break
if (r[0] ^ r[N-2]) != r[N-1]:
    f = 0
if f == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
input()
a=list(map(int,input().split()))
b=list(set(a))
if len(b)==3:
    b=[format(i, '032b') for i in b]
    b=[(int(b[0][i])+int(b[1][i]))%2==int(b[2][i]) for i in range(32)]
    if False in b:
        print("No")
    else:
        print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
a = input().split()

#print(N)
#print(a)

for i in range(N):
	x = int(a[(i-1)%N])
	y = int(a[(i+1)%N])
	'''
	print(i+1)
	print('↓')
	print(x, y)
	print('↓')
	print(x ^ y) 
	'''
	if (i+1) != x^y:
		print('No')
		sys.exit(0);

print('Yes')

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
a_list = [int(i) for i in input().split()]
# for a_ in a:
#     print(a_)
#     print(type(a_))
for i in range(N):
    if i == 0:
        a = bin(a_list[N-1])
        b = bin(a_list[1])
    elif i == N-1:
        a = bin(a_list[i-1])
        b = bin(a_list[0])
    else:
        a = bin(a_list[i-1])
        b = bin(a_list[i+1])
    c = int(a, 0) ^ int(b, 0)
    if c != a_list[i]:
        print("No")
        sys.exit(0)
print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
l = list(map(int,input().split(' ')))
dp = {}
k = True
for i in range(N):
    tmp = l[i]
    if tmp in dp:
        dp[tmp] +=1
    else:
        if len(dp)==3:
            k = False
            break
        else:
            dp[tmp] = 1

flag = False
if k:
    if len(dp)==3:
        num_l = []
        ans_l = []
        for key,val in dp.items():
            num_l.append(key)
            ans_l.append(val)
        if ans_l[0]==ans_l[1] and ans_l[0]==ans_l[2]:
            if num_l[0]^num_l[1]==num_l[2]:
                flag = True
if flag:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

if n == 3:
    if a[0] ^ a[2] == a[1] and a[1] ^ a[2] == a[0] and a[0] ^ a[1] == a[2]:
        print('Yes')
    else:
        print('No')
elif n % 3 == 0:
    d = defaultdict(int)
    for aa in a:
        d[aa] += 1
    m = n // 3
    bl = True
    for v in d.values():
        if v != m:
            bl = False
            break
    print('Yes' if bl else 'No')


else:
    if len(set(a)) == 1:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
import itertools

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

for s in list(itertools.permutations(l)):
    for i in range(n):
        if [s[(i-1)%n]^s[(i+1)%n] for i in range(n)]==s:
            print('Yes')
            exit()
        else:pass
print('No')

Submission status: Wrong Answer

Solution code:
import sys

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

from collections import Counter
ac = Counter(a)

if len(ac) == 3 and len(Counter(ac.values())) == 1:
    print('Yes')
    sys.exit()
if len(ac) == 2 and ac.most_common()[0][1] == ac.most_common()[1][1] * 2 and ac.most_common()[0][0]^ac.most_common()[0][0] == ac.most_common()[1][0]:
    print('Yes')
    sys.exit()
if len(ac) == 1 and ac.most_common()[0][1] == 0:
    print('Yes')
    sys.exit()
print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
aLst = list(map(int, input().split()))
ansB = False
for i in range(N):
    if i == 0:
        if aLst[0] == (aLst[-1] ^ aLst[1]):
            ansB = True
            break
        else:
            continue
    elif i == (N - 1):
        if aLst[i] == (aLst[i - 1] ^ aLst[0]):
            ansB = True
            break
        else:
            continue
    else:
        if aLst[i] == (aLst[i - 1] ^ aLst[i + 1]):
            ansB = True
            break
        else:
            break

if ansB:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter 
import sys
def No():
    print("No")
    sys.exit()
N=int(input())
A = [int(i) for i in input().split()]
C=Counter(A)
if N%3:No()
if len(C)!=3:No()
bits = [format(a,"040b") for a in C.keys()]
if all([z.count("0")%2 for z in zip(*bits)]):
    print("Yes")
else:No()

Submission status: Wrong Answer

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

a.sort()

lll = len(a) - 1
pre = a[lll]
rtn = "Yes"

for i,ai in enumerate(a):
    if (i == lll):
        #print(ai,pre ^ a[0])
        if (ai != (pre ^ a[0])):
            rtn = "No"
            break
    else:
        #print(ai,pre ^ a[i+1])
        if (ai != (pre ^ a[i+1])):
            rtn = "No"
            break
    pre = ai

print(rtn)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
if n % 3 == 0:
    d = {}
    for x in a:
        d.setdefault(x, 0)
        d[x] += 1
    print("Yes" if all([d[x] % (n//3) == 0 for x in d]) else "No")
else:
    print("Yes" if all([x == 0 for x in a]) else "No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# 2019. 7/14
# AGC 035 A

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

is_ok = True

for i in range(N - 2):
    a = caps[i]
    b = caps[i + 1]
    c = caps[i + 2]

    if b != (a ^ c):
        is_ok = False
        break

a = caps[0]
b = caps[1]
c = caps[-1]

if a != (b ^ c):
    is_ok = False

a = caps[-2]
b = caps[-1]
c = caps[0]

if b != (a ^ c):
    is_ok = False

if is_ok:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

flg = 1
for i in range(len(lst)):
  if i+1 == len(lst):
    if bin(lst[i]) != bin(lst[i-1] ^ lst[0]):
      flg = 0
      break
  elif bin(lst[i]) != bin(lst[i-1] ^ lst[i+1]):
    flg = 0
    break
if flg == 1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

import collections
c = collections.Counter(a)

v = []
for k in c.keys():
    v.append(c[k])
v.sort()

flag = False
if n % 3 == 0:
    if v == [n // 3, n // 3, n // 3] or v == [n] or v == [n // 3, n // 3 * 2]:
        flag = True
else:
    if v == [n]:
        flag = True

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

Submission status: Wrong Answer

Solution code:
n = int(input())
als = list(map(int,input().split()))
ans = 'No'
sett = n//3
if n%3 == 0:
    for i in range(1,len(als)):
        if als.count(als[0]) == sett and als.count(als[i]) == sett and als.count(als[0]^als[i]) == sett:
            ans = 'Yes'
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N=int(input())
a=list(map(int,input().split()))
tmp=Counter(a)
if len(tmp.keys())!=3 or len(a)%3!=0:
    print("No")
else:
    key=list(tmp.keys())
    ans=list(tmp.values())
    #print(key)
    #print(ans)
    if ans[0]==ans[1] and ans[0]==ans[2]:
        if key[0]^key[1]==key[2]:
            print("Yes")
            exit()
print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if a[0] != a[1]^a[len(a)-1]:
    print('No')
    sys.exit()

for i in range(1,N-2):
    if a[i] != a[i-1]^a[i+1]:
        print('No')
        sys.exit()

if a[len(a)-1] != a[len(a)-2]^a[0]:
    print('No')
    sys.exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
from itertools import combinations

N = int(input())
*A, = map(int, input().split())
A = set(A)
if len(A) == 3:
    for a, b, c in combinations(A, 3):
        if a ^ c == b and b ^ a == c: print('Yes'); break;
    else: print('No')
elif len(A) <= 2: print('Yes' if 0 in A else 'No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def calc(N, A):
    _exist = False
    if (N % 3 == 0):
        A.sort()
        m = N // 3
        _exist = A.count(A[0]) == m and A.count(
            A[m]) == m and A.count(A[m * 2]) == m and A[m * 2] == A[0] ^ A[m]
    print('Yes' if _exist else 'No')


N = int(input())
A = [int(s) for s in input().split(' ')]
calc(N, A)

Submission status: Wrong Answer

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

ans = 'No'
if N%3 == 0:
    hat1 = max(a)
    hat2 = min(a)
    if a.count(hat1) == int(N/3) & a.count(hat1) == int(N/3) & a.count(hat1^hat2) == int(N/2):
        ans = 'Yes'

print(ans)

Submission status: Wrong Answer

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

def hat(_):
    for n in range(N):
        if n != N-1:
            if a[n-1] ^ a[n+1] != a[n]:
                return False
        else:
            if a[n-1] ^ a[0] != a[n]:
                return False
    return True
            
ans = True
for n in range(N):
    ans = hat(n)
    if ans == False:
        break

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

Submission status: Wrong Answer

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

flg = True
for i in range(len(line)):
  max = i + 1
  min = i - 1
  if i + 1 > n - 1:
    max = 0
  elif i - 1 < 0:
    min = n - 1
  wa = line[min] ^ line[max]
  if line[i] != wa:
    flg = False

if flg:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=set(map(int,input().split()))
if len(a)==3:
    a = list(a)
    if a[0]^a[1]^a[2]==0 and n%3 == 0:
        print('Yes')
    else:
        print('No')
elif len(a)==2:
    if 0 in a and n%2 ==0:
        print('Yes')
    else:
        print('No')
elif len(a)==1:
    if 0 in a:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

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

if(A[N-1]^A[1] == A[0] and A[0]^A[N-2] == A[N-1]):
    for i in range(1,N-2):
        if(A[i-1]^A[i+1] != A[i]):
            result = 'No'
            break
else:
    result = 'No'
print(result)

Submission status: Wrong Answer

Solution code:
def main():
	N = int(input())
	A = list(map(int, input().split()))
	if N & (N+1) != 0:
		print("No")
		return

	tmp = N
	n_len = 0
	while tmp:
		n_len += 1
		tmp >>= 1
	arr = [0]*n_len
	for a in A:
		tmp = a
		for i in range(n_len):
			if tmp & 1 == 1:
				arr[i] += 1
			tmp >>= 1
	possible = True
	for i in range(n_len):
		if arr[i] != (N+1)//2:
			possible = False
			break
	if possible:
		print("Yes")
	else:
		print("No")


if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
arr = list(map(int,input().split()))
d = {}

for a in arr:
    if a not in d:
        d[a] = 1

if len(d) != 3:
    print("No")
else:
    tar = [0,0,0]
    temp = 0
    for key in d.keys():
        tar[temp] = key
        temp+=1
    x1 = tar[0]^tar[1]
    x2 = tar[1]^tar[2]
    x3 = tar[0]^tar[2]

    if x1 == tar[2] or x2 == tar[0] or x3== tar[1]:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
c = [0, 0]
for i in range(n):		c[a[i]%2] += 1
if c[1] == 0 :			print("Yes")
elif (n//2) <= c[1] : 	print("Yes")
else :					print("No")

Submission status: Wrong Answer

Solution code:

N = int(input())
a_list = input().split(' ')

a = [int(i) for i in a_list]
a.sort()

delta = a[1]-a[0]
NG_flag = False
for i in range(1,N):
    if a[i]-a[i-1] != delta:
        NG_flag = True

if NG_flag:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
import collections
n=int(input())
A=[int(i) for i in input().split()]
AA=collections.Counter(A)
AK=AA.keys()
AV=AA.values()

ans=True
if n%3!=0:
  ans=False
else:
  nn=n//3
  if len(AK)>3:
    ans=False
  elif len(AK)==3:
    a,b,c=AK
    if AA[a]!=nn or AA[b]!=nn or AA[c]!=nn:
      ans=False
    else:
      if a^b!=c or b^c!=a:
        ans=False
  elif len(AK)==2:
    a,b=AK
    if a*b!=0:
      ans=False
    else:
      if a<b:
        a,b=b,a
      if AA[a]!=2*nn or AA[b]!=nn:
        ans=False
  else:
    for a in AK:
      if a!=0:
        ans=False
print("Yes" if ans==True else "No")

Submission status: Wrong Answer

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

if((a[0] ^ a[n-2] == a[-1]) and (a[1] ^ a[-1] == a[0])) :
        for k in range(n-2) :
                if (a[k] ^ a[k+2] != a[k+1]) :
                        print('No')                        
                        break
        else :
                print('Yes')        
                
else :
        print('No')

Submission status: Wrong Answer

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

k = 0
g = 0

for i in range(N):
    if A[i] % 2 == 0:
        g += 1
    else:
        k += 1

if k == 0 or (g * 2 == k):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
list1 = list(map(int,input().split()))
list1.append(list1[0])
list1.append(list1[1])
flag = 0
for i in range(n):
  if list1[i]^list1[i+2] != list1[i+1]:
    flag = 1
    break;
if flag != 1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
if n % 3:
    print('No')
else:
    a = sorted(map(int, input().split()))
    m = n // 3
    print('YNeos'[any(len(set(a[i:i + m])) > 1 for i in range(0, n, m))::2])

Submission status: Wrong Answer

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

sum_a_list = sum(a_list)
sum_a_xo_list = 0
sum_a_xo_list = ((a_list[n-1] ^ a_list[0]))
for i in range(n-1):
    sum_a_xo_list += ((a_list[i] ^ a_list[i+1]))
if sum_a_list == sum_a_xo_list:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def resolve():

    n = int(input())
    li = set(map(int, input().split()))

    if len(li) == 3 and n % 3 == 0:
        print('Yes')

    else:
        print('No')
        
resolve()

Submission status: Wrong Answer

Solution code:
import math

n = list(map(int, input().split()))
n = n[0]
b = list(map(int, input().split()))

b.sort()

if (n%3==0):
    flag = 1
    for i in range(3):
        for j in range(n//3-1):
            if(b[(n//3)*i + j] != b[(n//3)*i + j+1]):
                flag *= 0
            if(b[(n//3)*2]^b[n//3]!=b[0]):
                flag *= 0
    if(flag==1):
        ans="Yes"
    else:
        ans="No"
else:
    ans="No"
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

N = int(input().strip())
As = list(map(int, input().strip().split(' ')))
candidates = list(set(As))

if len(candidates) > 3 or len(candidates) == 1:
    print('No')
elif len(candidates) == 2:
    if 0 in candidates:
        print('Yes')
    else:
        print('No')
# len(candidates) == 3
else:
    a, b = candidates[:-1]
    c = candidates[-1]
    if a ^ b != c:
        print('No')
    else:
        count_a = 0
        count_b = 0
        count_c = 0
        for element in As:
            if element == a:
                count_a += 1
            elif element == b:
                count_b += 1
            else:
                count_c += 1
        else:
            if count_a == count_b and count_b == count_c:
                print('Yes')
            else:
                print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
if N!=3:
  print("No")
else:
    a,b,c=map(int,input().split())
    if a ^ b== c and a ^ c == b and b ^ c ==a:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:

from copy import deepcopy

def main():


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

    if len(aunique) == 1:
        if a[0] == 0:
            print("Yes")
        else:
            print("No")
    elif len(aunique) is not 3 or n%3:
        print("No")
    else:
        l = []
        l.append(a.count(aunique[0]))
        l.append(a.count(aunique[1]))
        l.append(a.count(aunique[2]))

        if not l[0] is n//3 or not l[1] is n//3:
            print("No")
        else:
            if (aunique[0] ^ aunique[1]) == aunique[2]:
                print("Yes")
            else:
                print("No")



main()

Submission status: Wrong Answer

Solution code:
N=int(input())
a=sorted(list(map(int, input().split())))
A=0
for i in range(N):
  x=a[0] if i==len(a) else a[i-1]
  A+=a[i]^x

if sum(a)==A:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
from itertools import permutations
n=int(input())
aa=list(map(int,input().split()))
if 2<n<6:
    for ap in permutations(aa):
        for i in range(n):
            if ap[i-1]!=ap[i-2]^ap[i]:
                break
        else:
            print("Yes")
            exit()
elif sum(aa)==0:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

k, v = list(Counter(a).keys()), list(Counter(a).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')
else :
    print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
li = list(map(int,input().split()))
flag="Yes"
for i in range(0,len(li)):
    if not(li[i]==(li[i-1]^li[(i+1)%len(li)])):
        flag="No"
print(flag)

Submission status: Wrong Answer

Solution code:
n = int(input())
list1 = list(map(int,input().split()))
list1.append(list1[0])
list1.append(list1[1])
flag = 0
for i in range(n):
  print(list1[i]^list1[i+2])
  if list1[i]^list1[i+2] != list1[i+1]:
    flag = 1
    break;
if flag != 1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
a=int(input())
li = list(map(int,input().split()))	
flag = True
if (a != len(li)):
    flag = False

if (li[a-1] ^ li[1] != li[0] ):
    flag = False

for i in range(1,a-1):
    if ((li[i-1] ^ li[i+1]) != li[i] ):
        flag = False
        break

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

Submission status: Wrong Answer

Solution code:
_input = [i for i in open(0).read().split('\n') if i]
n = int(_input[0])
a = [int(i) for i in _input[1].split()]

import functools
if functools.reduce(lambda a, b: a^b, a) == 0:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

for i in range(n-1):
  if an[i] != (an[i-1] ^ an[i+1]):
    print('No')
    exit()
if an[n-1] != (an[n-2] ^ an[0]):
  print('No')
else:
  print('Yes')

Submission status: Wrong Answer

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

is_done = False
for i in range(1, len(b)-1):
    if b[i] == b[i - 1] ^ b[i + 1]:
        pass
    else:
        print("No")
        is_done = True
        break
if is_done == False:
    if b[0] == b[1] ^ b[- 1] and b[-1] == b[0] ^ b[-2]:
        print("Yes")
    else:
        print("No")