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())
num = list(map(int,input().split()))
c = True
lim = 10 ** 6
nn = num[-1::lim]+num+num[0::lim]
for i in range(1,N+1):
  if nn[i-1] ^ nn[i+1] != nn[i]:
    c = False
    break
if c:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

ans = 'Yes'

if n % 2 == 0:
    ans = 'No'

if ans == 'Yes':
    a = sorted(a)
    for i in range(n-1):
        if bin(a[i]) == bin(a[i-1] ^ a[i+1]):
            pass
        else:
            ans = 'No'
            break

if ans == 'Yes':
    if bin(a[n-1]) == bin(a[n-2] ^ a[0]):
        pass
    else:
        ans = 'No'

print(ans)

Submission status: Wrong Answer

Solution code:
import collections
n=int(input())
a=list(map(int,input().split()))
f=0
ct=0
C=collections.Counter(a)
D=C.most_common()
for i in range(n):
  if a[i]==0:
    ct=1
    f=1
for i in range(n):
  a[i]=format(a[i],'020b')
l=[0 for i in range(20)]
for i in range(n):
  for j in range(20):
    if a[i][j]=='1':
      l[j]+=1
for j in range(20):
  l[j]=l[j]%2

if f==0:
  if 1 in l:
    print('No')
  else:
    print('Yes')
elif f==1:
  if len(D)==1:
    print('Yes')
  elif len(D)==2 and D[0][0]!=0 and D[0][1]==D[1][1]*2:
    print('Yes')
  else:
    print('Yes')

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 == 0 & a.count(0) == N:
        ans = 'Yes'
    if a.count(hat1) == int(N/3) & a.count(hat2) == int(N/3) & a.count(hat1^hat2) == int(N/3):
        ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int ,input().split()))
a.extend(a[:3])

ans = 'Yes'
for x in range(N+1):
    if int(bin(a[x]^a[x+2]), 0) != a[x+1]:
        ans = 'No'
        break
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)

import numpy as np


def resolve():
    N = [int(x) for x in sys.stdin.readline().split()][0]
    a_list = [int(x) for x in sys.stdin.readline().split()]

    max_len = len(format(max(a_list), 'b'))

    if N % 2 == 0:
        print("No")
    else:
        # print('{} {}'.format(N, a_list))
        bin_array = np.array([[int(b) for b in format(a, 'b').zfill(max_len)]
                              for a in a_list])

        # print(bin_array)

        sum_array = bin_array.sum(axis=0)
        # print(sum_array)

        if np.all(N * 2 / 3 == sum_array):
            print("Yes")
        else:
            print("No")


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
1 2 3"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4
1 2 4 8"""
        output = """No"""
        self.assertIO(input, output)

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
a = list(int(i) for i in input().split())
chk = sum(a)
if N == 3:
	if ((chk+2)&(chk+1)) == 0:
		print("Yes")
	else:
		print("No")
else:
	l = collections.Counter(a)
	if list(l.values()) == [2] * len(l.values()):
		chk=chk//2
		if ((chk+2)&(chk+1)) == 0:
			print("Yes")
		else:
			print("No")
	else:
		print("No")

Submission status: Wrong Answer

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

def main():
    N = input()
    A = [int(a) for a in input().split()]
    dic = {}     
    
    for a in A:
        dic[a] = dic.get(a,0)+1
        
    if len(dic)!=3:   
        print("No")
    else:
        key = []
        for k in dic:
            key.append(k)
        if key[0]^key[1] != key[2]:               
            print("No")
        else:
            if dic[key[0]]==dic[key[1]]==dic[key[2]]:                  
                print("Yes")
            else:
                print("No")
    
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
data = {}
for a in map(int, input().split()):
	if a in data:
		data[a] += 1
	else:
		data[a] = 1

def pop(data, a):
	if a in data:
		if data[a] == 1:
			del data[a]
		else:
			data[a] -= 1
		return a
	else:
		return None

def check2(data0, a1, a2):
	
	data = { k: data0[k] for k in data0 }
	a0 = a1
	pop(data, a1)
	pop(data, a2)
	
	while data:
		a3 = a1 ^ a2
		a4 = pop(data, a3)
		if a4 == None:
			return False
		a1 = a2
		a2 = a3
	return a0 == (a1 ^ a2)

def count1(a):
	count = 0
	while a:
		if a % 2 == 1:
			count += 1
		a = a // 2
	return count

def check(data):
	keys = list(data.keys())
	a1 = keys[0]
	
	if data[a1] == 1:
		keys = keys[1:]
	c1 = count1(a1)

	for a2 in keys:
		if (c1 + count1(a2)) % 2 == 0:
			if check2(data, a1, a2):
				return True
			break

	for a2 in keys:
		if (c1 + count1(a2)) % 2 == 1:
			if check2(data, a1, a2):
				return True
			break

if check(data):
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

xor = A[0]
for i in range(N-1):
    xor = xor ^ A[i+1]
    
if xor == 0:
    print("yes")
else:
    print("no")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter 
import sys
def No():
    print("No")
    sys.exit()

def Yes():
    print("Yes")
    sys.exit()

N=int(input())
A = [int(i) for i in input().split()]
C=Counter(A)
if N%3:No()
if len(C)==1:
    if C.get(0,0):
        Yes()
    else:No()
if len(C)==2:
    if C.get(0,0) == N//3:
        Yes()
    else: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:
_ = input()
input_num = [int(i) for i in input().split(" ")]

input_size = len(input_num)-1
for i in range(len(input_num)-1):
    left = i-1
    right = i+1
    if left < 0:
        left = input_size
#     print(input_num[left])
#     print(input_num[right])
    if input_num[left]^input_num[right] == input_num[i]:
        continue
    else:
        print("No")
        break
else:
    print("Yes")

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]
    else:
        B = B ^ A[i]
    if not A[i] in k:
        k[A[i]] = 1
    else:
        k[A[i]] += 1

a = 0
for key, val in k.items():
    if val == N // 3:
        a += 1

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

print(ans)

Submission status: Wrong Answer

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

A.insert(0, A[-1])
A.append(A[1])
answer = 'Yes'
for n in range(1, N+1):
    if (bin(A[n]) != bin(A[n-1] ^ A[n+1])):
        answer = 'No'

print(answer)

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np
import collections

N = int(input())
A = [int(_) for _ in input().split()]
count = collections.defaultdict(int)
for x in A:
    count[x] += 1
if len(count) == 1:
    a = list(count.keys())[0]
    #if a == 0:
    # print('Yes')
    #exit()
    print('No')
    exit()
elif len(count) == 2:
    a, b = sorted(count.keys())
    if a == 0 and count[a] == 1 and count[b] == 2:
        print('Yes')
        exit()
elif len(count) == 3:
    a, b, c = count.keys()
    if a ^ b == c and count[a] == count[b] == count[c]:
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

Solution code:
import sys

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

x = 0
y = 0
z = 0

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

else:

  for i in range(N):
    if a[i] != x and a[i] != y and a[i] != z:
      if x == 0:
        x = a[i]
        continue
      elif y == 0:
        y = a[i]
        continue
      elif z == 0:
        z = a[i]
        continue
      else:
        print('No')
        sys.exit()

  print('Yes')

Submission status: Wrong Answer

Solution code:
from itertools import combinations

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

c = collections.Counter(a)
k = list(c.keys())
v = list(c.values())

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
#n = 3
#a = [1,2,3]
if n >=4:
  if a.count(0) == n:
    print("Yes")
  else :
    print("No")
else:
  if a[0]^a[1] == a[2] and a[1]^a[2] == a[0] and a[2]^a[0] == a[1]:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import collections
n=input()
a=list(map(int,input().split()))
b=set(a)
c=list(b)
cnt=collections.Counter(a)
if len(b)==1:
  if a[0]==0:
    print('Yes')
if len(b)!=3:
  print('No')
if len(b)==3:
  if cnt[c[0]]==cnt[c[1]]==cnt[c[2]]:
    if c[0]^c[1]==c[2]:
      print('Yes')

Submission status: Wrong Answer

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

answer = "Yes"
for i in range(len(aa)):
  for j in range(len(aa[i]) - 1):
    if aa[i][j] == (aa[i][j - 1] ^ aa[i][j + 1]):
      answer = "No"
      break
    if answer == "No":
      break
    
print(answer)

Submission status: Wrong Answer

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


is_yes = False

if N % 3 == 0:
    a_n_unique = list(set(a_n))
    if len(a_n_unique) == 1:
        if a_n_unique[0] == 0:
            is_yes = True
    elif len(a_n_unique) == 2:
        if a_n_unique[0] == 0 or a_n_unique[1] == 0:
            if a_n.count(a_n_unique[0]) > a_n.count(a_n_unique[1]):
                if a_n.count(a_n_unique[0]) / a_n.count(a_n_unique[1]) ==2:
                    is_yes = True
            else:
                if a_n.count(a_n_unique[1]) / a_n.count(a_n_unique[0]) ==2:
                    is_yes = True
    elif len(a_n_unique) == 3:
        if a_n_unique[0] ^ a_n_unique[1] == a_n_unique[2]:
            is_yes = True


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [format(int(a), "b") for a in input().split()]

for n in range(N):
  my_nm = int(A[n])
  if n == N-1:
    total_neighbor_nm = int(A[N-2]) + int(A[0])
  else:
    total_neighbor_nm = int(A[n-1]) + int(A[n+1])
  TNN = [tnn for tnn in str(total_neighbor_nm)]
  for i in range(len(TNN)):
    if int(TNN[i]) % 2 == 0:
      TNN[i] = "0"
    else:
      TNN[i] = "1"
  if my_nm == int("".join(TNN)):
    continue
  else:
    print("No")
    break
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
import math

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

x = []
flag = 0
bit_mid = a[0]
for i in range(1, n-1):
    for j in range(i, n):
        if bit_mid == a[i]^a[j]:

            x.extend([a[i], bit_mid, a[j]])
            bit_left = bit_mid
            bit_mid = a[j]

            del a[j]
            del a[i]
            del a[0]
            flag = 1
            break
    if flag:
        break

if flag==0:
    print('No')
elif n==3:
    print('Yes')
else:

    while len(a) != 1:
        flag = 0
        for i in range(1, len(a)-1):
            if bit_mid == bit_left^a[i]:
                x.append(a[i])
                bit_left = bit_mid
                bit_mid = a[i]

                del a[i]
                flag = 1
                break

        if flag == 0:
            print('No')
            break

    if a[0] == bit_mid^x[0] and x[0] == a[0]^x[1] :
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np
import collections

N = int(input())
A = [int(_) for _ in input().split()]
count = collections.defaultdict(int)
for x in A:
    count[x] += 1
if len(count) == 1:
    a = list(count.keys())[0]
    #if a == 0:
    # print('Yes')
    #exit()
    print('Yes')
    exit()
elif len(count) == 2:
    a, b = sorted(count.keys())
    if a == 0 and count[a] == 1 and count[b] == 2:
        print('Yes')
        exit()
elif len(count) == 3:
    a, b, c = count.keys()
    if a ^ b == c and count[a] == count[b] == count[c]:
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

Solution code:
import collections
n=int(input())
a=list(map(int,input().split()))
f=0
ct=0
C=collections.Counter(a)
D=C.most_common()
for i in range(n):
  if a[i]==0:
    ct=1
    f=1
for i in range(n):
  a[i]=format(a[i],'020b')
l=[0 for i in range(20)]
for i in range(n):
  for j in range(20):
    if a[i][j]=='1':
      l[j]+=1
for j in range(20):
  l[j]=l[j]%2

if f==0:
  if 1 in l:
    print('No')
  else:
    print('Yes')
elif f==1:
  if len(D)==1:
    print('Yes')
  elif len(D)==2 and D[0][0]!=0 and D[0][1]==D[1][1]*2:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = set(a)
c = sorted(list(b))
if c[0]==0:
  if n%2==0 and a.count(c[0])==n//2 and a.count(c[1])==n//2:
    print("Yes")
    exit()
  elif n%2==1 and a.count(c[0])==n//2 and a.count(c[1])==n//2+1:
    print("Yes")
    exit()
if n%3!=0:
  print("No")
  exit()
if len(b)==2:
  if c[0]==0 and a.count(c[0])==n//3 and a.count(c[1])==(n//3)*2:
    print("Yes")
    exit()
if len(b)==3:
  p, q, r = c[0], c[1], c[2]
  if p^q==r or q^r==p or r^p==q:
    if a.count(c[0])==n//3 and a.count(c[1])==n//3 and a.count(c[2])==n//3:
      print("Yes")
      exit()
print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3

import math
import sys


DEBUG = False


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


def solve(N, A):
    d = {}
    for a in A:
        if a not in d:
            d[a] = 0
        d[a] += 1

    if N % 3 == 0:
        if len(d) > 3:
            return False

        if len(d) == 3:
            a, b, c = d
            if d[a] != d[b] or d[b] != d[c]:
                return False
            arr = [a, b, c]
        elif len(d) == 2:
            a, b = d
            if d[a] * 2 == d[b]:
                arr = [a, a, b]
            elif d[b] * 2 == d[a]:
                arr = [b, b, a]
            else:
                return False
        else:
            (a,) = d
            arr = [a, a, a]

        a, b, c = arr
        if a ^ b == c or a ^ c == b or b ^ c == a:
            return True
        return False

    if len(d) > 1:
        return False

    (a,) = d
    if a != 0:
        return False
    return True


def main():
    N = int(inp())
    A = [int(e) for e in inp().split()]

    print('Yes' if solve(N, A) else 'No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def resolve():
    n = int(input())
    aa = list(map(int, input().split()))

    flg = len(aa) % 3 == 0

    tmp1 = aa[0]
    tmp2 = aa[1]
    tmp3 = aa[2]

    if flg:
        for a1,a2,a3 in zip(aa,aa[1:],aa[2:]):
            if not(a1 == tmp1 and a2 == tmp2 and a3 == tmp3):
                flg = False
                break

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

pp = a.pop(0)
p = a.pop(0)
flag = True
for x in a:
    if x - p != pp:
        flag = False
        break
    pp = p
    p = x

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)

#debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    N = int(input())
    a_list = list(map(int, input().split()))

    # a[0] からスタート
    found = False
    start = a_list[0]
    second = 0
    third = 0
    for i in range(1, N):
        for j in range(i+1, N):
            ai = a_list[i]
            aj = a_list[j]
            b = start ^ ai
            if b == aj:
                found = True
                second = j
                third = i
                break
        if found == True:
            break

    if found == False:
        print("No")
        return

    # これで、0, second, third が決まったので、あとは順次決める

    hat_list = [a_list[0], a_list[second], a_list[third]]

    a_list[0] = None
    a_list[second] = None
    a_list[third] = None

    dprint(hat_list)

    cnt = 3
    while True:
        # N個作ったら終了
        if cnt == N:
            break

        left = hat_list[-2]
        center = hat_list[-1]

        # 次の数字
        right = left ^ center

        # 検索
        try:
            rid = a_list.index(right)
        except:
            print("No")
            return

        a_list[rid] = None
        hat_list.append(rid)
        cnt += 1


    # 最後に周期条件
    center = hat_list[0]
    right = hat_list[1]
    left = hat_list[-1]

    if right ^ left == center:
        print("Yes")
    else:
        print("No")


solve()

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

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


for i in range(N):
    
    if i == 0:
        bef = mylist[-1]
        aft = mylist[i+1]
        
    elif i == (N-1):
        bef = mylist[i-1]
        aft = mylist[0]
    else:
    #前
        bef = mylist[i-1]
    #後ろ
        aft = mylist[i+1]
    #xor
    if (bef^aft) == mylist[i]:
        continue
    else:
        print('No')
        sys.exit()    
  
print('Yes')

Submission status: Wrong Answer

Solution code:
input()
a=list(map(int,input().split()))
if len(a)%3==0:
    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")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
first = 0
pattern = True
for i in range(1,len(A)):
    last = i
    next = A[first] ^ A[last]
    # print(next)
    if next in A:
        first = last
        last = A.index(next)
    else:
        pattern = False
        break

if pattern == False:
    print("No")
else:
    print("yes")

Submission status: Wrong Answer

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

ret = 0
for i in range(n):
    ret ^= (i + 1)
    ret ^= a[i]

print('Yes' if ret == 0 else 'No')

Submission status: Wrong Answer

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

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:
n = int(input())
a = list(map(int,input().split()))
#n = 3
#a = [1,2,3]
if n >=4:
  if a.count(0) == n:
    print("yes")
  else :
    print("no")
else:
  if a[0]^a[1] == a[2] and a[1]^a[2] == a[0] and a[2]^a[0] == a[1]:
    print("yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
List=list(map(int,input().split()))
List.sort()
a = List[0]
b = List.count(a)
c = List[N//3]
d = List.count(c)
e = List[2*N//3]
f = List.count(e)
if a == c and c == e:
    if a == 0 and b == N and N % 3 == 0:
        print('Yes')
elif c == e:
    if a == 0  and N % 3 == 0 and b == N // 3 and d == 2 * N // 3:
        print('Yes')
elif (N % 3 == 0 and b == N // 3 and d == N //3 and f == N //3 and a + c == e) : 
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
x = input().split(" ")
x = [int(s) for s in x]
if(x[0] < 3 | x[0] > 10000 | len(x) < 1 | len(x) > 10^9 + 1):
    print("No")
else:
    for i in range(2,len(x)-1):
        if x[i] != x[i-1] ^ x[i+1]:
            print("No")
            break
    print("YES")

Submission status: Wrong Answer

Solution code:
n=int(input())
N=list(map(int,input().split()))
N.insert(0,N[-1])
N.append(N[1])
flag=0
for i in range(1,n):
    if N[i]==N[i-1]^N[i+1]:
        continue
    else:flag=1
if flag:print("No")
else:print("Yes")

Submission status: Wrong Answer

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

if all((i == 0) for i in a):
    print('Yes')
    exit()

if n % 3 != 0:
    print('No')
    exit()

p = n // 3
if 0 in a:
    a = sorted(a)
    zero = a.count(0)
    if zero != p:
        print('No')
        exit()
    if a[p] != a[-1]:
        print('No')
        exit()
    print('Yes')
    exit()

a = sorted(a)
if a.count(a[0]) != p or a.count(a[p]) != p or a.count(a[-1]) != p:
    print('No')
else:
    if a[0] == a[p] or a[p] == a[-1] or a[-1] == a[0]:
        print('No')
    else:
        print('Yes')

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:
        s=1
    if n%3==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:
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(hat2) == int(N/3) & a.count(hat1^hat2) == int(N/3):
        ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int ,input().split()))
a.extend(a[:2])

ans = 'Yes'
for x in range(N):
    if int(bin(a[x]^a[x+2]), 0) != a[x+1]:
        ans = 'No'
        break
print(ans)

Submission status: Wrong Answer

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

flag = True
for i in range(N-1):
    if a[i-1] ^ a[i+1] == a[i]:
        flag = True
    else:
        print("No")
        exit()

if a[N-2] ^ a[0] != a[N-1]:
    flag = False

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

Submission status: Wrong Answer

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

if n % 3 != 0:
    print "No"
else:
    if len(set(a[0:n/3])) == 1 and len(set(a[n/3:n/3*2])) == 1 and len(set(a[n/3*2:n])) == 1:
        print "Yes"
    else:
        print "No"

Submission status: Wrong Answer

Solution code:
from collections import Counter

# s = input()
N = int(input())
A = list(map(int, input().split()))
# a, b = map(int, input().split())

c = Counter()

for a in A:
    c[a] += 1

k = list(c.keys())
v = list(c.values())
if len(v) == 1:
    print("Yes")
    exit()

if len(v) == 2 and N%3 == 0:
    if v[0]*2 == v[1]:
        if k[1]^k[1] == k[0]:
            print("Yes")
            exit()
    if v[1]*2 == v[0]:
        if k[0]^k[0] == k[1]:
            print("Yes")
            exit()


if len(v) == 3:
    if v[0] == v[1] and v[1] == v[2]:
        if k[0]^k[1] == k[2]:
            print("Yes")
            exit()

print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(zz) for zz in input().split()]

B = set(A)
if N%3 == 0 and len(B) == 3:
    C = list(B)
    ans = 0
    for i in range(3):
        zz = A.count(C[i])
        if zz != (N//3):
            print('NO')
            exit()
        ans = ans^C[i]

    if ans == 0:
        print('Yes')
        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(hat2) == int(N/3) & a.count(hat1^hat2) == int(N/2):
        ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:

n = int(input())
ans = "No"
num_list = sorted([ int(v) for v in input().split() ])

if n % 3 == 0:
    m = n // 3
    a, b, c = num_list[0], num_list[m], num_list[2*m]
    if len(set(num_list[:m])) == 1 and len(set(num_list[m:2*m])) == 1 and len(set(num_list[2*m:])) == 1:
        if a ^ b == c:
            ans = "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np
import collections

N = int(input())
A = [int(_) for _ in input().split()]
count = collections.defaultdict(int)
for a in A:
    count[a] += 1
if len(count) == 1:
    a = list(count.keys())[0]
    if a == 0:
        print('Yes')
        exit()
elif len(count) == 2:
    a, b = sorted(count.keys())
    if a == 0 and count[a] == 1 and count[b] == 2:
        print('Yes')
        exit()
elif len(count) == 3:
    a, b, c = count.keys()
    if a ^ b == c and count[a] == count[b] == count[c]:
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
C = Counter(a[2:])
x = a[0] ^ a[1]
y = a[1]
for i in range(N-3):
    if C[x] > 1:
        C[x] -= 1
    else:
        print('No')
        quit()
    y = x
    x = x ^ y
for key in C:
    if C[key] == 1:
        if y ^ key == a[0]:
            print('Yes')
            break
        else:
            print('No')
            break

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(['No','Yes'][main()])

Submission status: Wrong Answer

Solution code:
from itertools import permutations
n=int(input())
aa=list(map(int,input().split()))
sa=set(aa)
if n%3==0 and len(sa)==3:
    for ap in permutations(sa):
        for i in range(3):
            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:
n = int(input())
l = list(map(int,input().split()))
if not any(l):
  print("Yes")
elif n%3:
  print("No")
else:
  nx = n//3 
  if len(set(l)) != 3:
    print("No")
  else:
    d = dict()
    for x in l:
      if x not in d:
        d[x] = 0
      d[x] += 1
    for x in d:
      if d[x] != nx:
        print("No")
        break
    else:
      s = 0
      for x in d:
        s ^= x
      if s == 0:
        print("Yes")
      else:
        print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
flag2 = 0
for i in range(N):
    flag = 0
    for j in range(N):
        if i == j:
            continue
        else:
            if (a[i] ^ a[j]) in a:
                flag = 1
                break
    if flag == 0:
        flag2 = 1
        break
if flag2 == 0:
    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)) + (sum(x) == 0)

y(1,t)