Problem:


Score : 300 points

Problem Statement

Snuke has N hats. The i-th hat has an integer a_i written on it.

There are N camels standing in a circle.
Snuke will put one of his hats on each of these camels.

If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print Yes; otherwise, print No.

The bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself.

What is XOR?

The bitwise XOR x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non-negative integers x_1, x_2, \ldots, x_n is defined as follows:

- When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.

For example, 3 \oplus 5 = 6.

Constraints

All values in input are integers.

3 \leq N \leq 10^{5}

0 \leq a_i \leq 10^{9}

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 \ldots a_{N}

Output

Print the answer.

Sample Input 1

3
1 2 3

Sample Output 1

Yes

If we put the hats with 1, 2, and 3 in this order, clockwise, the condition will be satisfied for every camel, so the answer is Yes.

Sample Input 2

4
1 2 4 8

Sample Output 2

No

There is no such way to distribute the hats; the answer is No.



Sample input:
3
1 2 3


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
import sys
# input = sys.stdin.readline
# inf = 10 ** 18
# P = 10 ** 9 + 7

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

if N % 3 > 0:
    print('No')
    sys.exit()

items = []
for ai in a:
    if ai not in items: items.append(ai)
    if len(items) >= 3: break

if len(items) == 1:
    if a.count(items[0]) == N:
        print('Yes')
    else:
        print('No')
elif len(items) == 2:
    cnt = [a.count(item) for item in items]
    if sum(cnt) < N:
        print('No')
    elif cnt[0] == cnt[1] * 2 or cnt[0] * 2 == cnt[1]:
        print('Yes')
    else:
        print('No')
else:
    cnt = [a.count(item) for item in items]
    if sum(cnt) < N:
        print('No')
    elif cnt[0] == cnt[1] == cnt[2]:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
from operator import xor

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

D = {}

for n in A :
    if n not in D :
        D[n] = 1
    else :
        D[n] += 1

if N == 3 :
    if xor(A[0], A[1]) == A[2] :
        ans = "Yes"
    else :
        ans = "No"
else :
    if D.get(0,0) >= N-1 :
        ans = "Yes"
    else :
        ans = "No"
print(ans)

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 N % 2 == 0:
    if 0 < k:
        print('No')
    else:
        print('Yes')
else:
    if k == 0 or (k == 2 and g == 1):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
c=0
c1=0
for i in l:
  c=0
  if i==1:
    c=1
  elif i==0:
    c=0
  else: 
    while i!=1:
      if i%2==1:
        c+=1
      i=i//2    
    c+=1
  if c%2==1:
    c1+=1
if c1==0:
  print("Yes")
elif n*2/3==c1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, a: "List[int]"):
    a = set(a)
    if len(a) == 1 and 0 in a:
        print(YES)
        return
    if N % 3 > 0:
        print(NO)
        return
    if len(a) != 3:
        print(NO)
        return
    a = list(a)
    if a[0] ^ a[1] == a[2]:
        print(YES)
        return
    print(NO)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

A_lis.sort()

for i in range(N):
	a_left = i-1
	if i == 0:
		a_left = N-1
	a_right = i+1
	if i == N-1:
		a_right = 0
	
	if A_lis[a_left] ^ A_lis[a_right] != A_lis[i]:
		print("No")
		exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
fl = input()
sl = input()
numofel = fl[0]
int(numofel)
slist = sl.split(" ")
firstnum = slist[0]
lastnum = slist[-1]
int(firstnum)
int(lastnum)
if firstnum == numofel or lastnum == numofel:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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


if(A[0]%2==(A[1]+A[-1])%2):
    flg += 1
    
A.append(A[0])


for i in range(1,N):
    if(A[i]%2 == (A[i-1]+A[i+1])%2):
        flg += 1



if(flg == N):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

a.insert(0, a[N-1])
a.append(a[1])

for i in range(N):
    if a[i+1]!=a[i]^a[i+2]:
        print("No")
        break
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
judge = True
if N == 0:
    judge = False
else :

    for i in range(N):
        if i == 0:
            if a[0] != a[1]^a[len(a)-1]:
                judge = False
                break
        elif i == len(a)-1:
            if a[len(a)-1] != a[len(a)-2]^a[0]:
                judge = False
                break
        else :
            if a[i] != a[i-1]^a[i+1]:
                judge = False
                break

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

Submission status: Wrong Answer

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

memo = {}
for i in range(n):
    if a[i] not in memo:
        memo[a[i]] = 1
    else:
        memo[a[i]] += 1

if len(memo) == 1:
    tmp = [i for i in memo]
    if tmp[0] == 0:
        print("Yes")
        exit()

if len(memo) == 2:
    tmp = [i for i in memo]
    if tmp[0] == 0:
        if memo[tmp[0]]*2 == memo[tmp[1]]:
            print("Yes")
            exit()
    if tmp[1] == 0:
        if memo[tmp[1]]*2 == memo[tmp[0]]:
            print("Yes")
            exit()
            
if len(memo) == 3:
    tmp = [i for i in memo]
    if memo[tmp[0]] == memo[tmp[1]] and memo[tmp[1]] == memo[tmp[2]]:
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

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

ans = [b == a ^ c for a, b, c in zip([a[-1]] + a[:-1], a, a[1:] + [a[0]])]
if all(ans):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
an=list(map(int,input().split()))
odd_an=len([i for i in an if i%2==1])
print("Yes" if abs(N-odd_an)<=1 else "No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
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 1 in l:
  print('No')
else:
  print('Yes')

Submission status: Wrong Answer

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

ans = 'Yes'

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:
# -*- coding: utf-8 -*-
N = int(input())
a_list = list(map(int, input().split()))
ans = "No"
a_list.insert(0, a_list[-1])
a_list.append(a_list[1])
for i in range(1, N + 1):
    if a_list[i-1] ^ a_list[i+1] != a_list[i]:
        break
else:
    ans = "Yes"
print(ans)

Submission status: Wrong Answer

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

def sol() :
    for i in range(N) :  # 先頭
        for j in range(i+1, N) :  # 2頭目
            numbers = [0] * (N + 2)
            numbers[0] = A[i]
            numbers[1] = A[j]
            inA = set(A)
            for k in range(2, N+2) :
                numbers[k] = numbers[k-1] ^ numbers[k-2]
                if numbers[k] in inA :
                    inA.remove(numbers[k])
                else :
                    return -1
            if numbers[0] == numbers[-2] and numbers[1] == numbers[-1] :
                return numbers[:-2]
    return -1

ans = sol()

if ans == -1 :
    print('No')
else :
    print('Yes')

Submission status: Wrong Answer

Solution code:
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')
else:
    print('No')

Submission status: Wrong Answer

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

xorNeighbor = 0
for i in range(1, len(a)-1):
    xorNeighbor += ((a[i-1] ^ a[i] ^ a[i+1]) != 0)

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

Submission status: Wrong Answer

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

memo = {}
for i in range(n):
    if a[i] not in memo:
        memo[a[i]] = 1
    else:
        memo[a[i]] += 1

if len(memo) == 1:
    tmp = [i for i in memo]
    if tmp[0] == 0:
        print("YES")
        exit()

if len(memo) == 2:
    tmp = [i for i in memo]
    if tmp[0] == 0:
        if memo[tmp[0]]*2 == memo[tmp[1]]:
            print("YES")
            exit()
    if tmp[1] == 0:
        if memo[tmp[1]]*2 == memo[tmp[0]]:
            print("YES")
            exit()
            
if len(memo) == 3:
    tmp = [i for i in memo]
    if memo[tmp[0]] == memo[tmp[1]] and memo[tmp[1]] == memo[tmp[2]]:
        print("YES")
        exit()

print("NO")

Submission status: Wrong Answer

Solution code:
import sys, collections
sys.setrecursionlimit(10000000)
alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", \
    "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

def solve():
    input = sys.stdin.readline
    mod = 7 + 10 ** 9
    N = int(input())
    A = [int(a) for a in input().split()]
    if len(set(A)) > 3: print("No")
    elif len(set(A)) == 3:
        B = list(set(A))
        count = [0, 0, 0]
        for a in A:
            if a == B[0]: count[0] += 1
            elif a == B[1]: count[1] += 1
            else: count[2] += 1
        if count[0] == count[1] and count[1] == count[2] and B[0] ^ B[1] == B[2]: print("Yes")
        else: print("No")
    elif len(set(A)) == 2:
        if 0 not in A: print("No")
        else:
            A.sort()
            if A[N//2] == 0: print("No")
            else: print("Yes")
    else:
        if A[0] == 0: print("Yes")
        else: print("No")

    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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


if 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')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

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

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

if is_done == False:
    if b[0] == b[1] ^ b[len(b) - 1] and b[len(b) - 1] == b[0] ^ b[len(b) - 2]:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
SA=set(A)
if N%3==0:
    if len(SA)==3:
        x=[0,0,0]
        y=[0,0,0]
        for i,a in enumerate(SA):
            x[i]=A.count(a)
            y[i]=a
        if x[0]==x[1] and x[1]==x[2]:
            if y[0]^y[1]==y[2] and y[1]^y[2]==y[0] and y[2]^y[0]==y[1]:
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    elif len(SA)==2:
        x=[0,0]
        y=[0,0]
        for i,a in enumerate(SA):
            x[i]=A.count(a)
            y[i]=a
        if x[0]*2==x[1]:
            if y[1]==0:
                print('Yes')
            else:
                print('No')
        elif x[1]*2==x[0]:
            if y[0]==0:
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    elif  A[0]==0:
        print('Yes')
    else:
        print('No')
else:
    if len(SA)==1 and A[0]==0:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 14 20:27:59 2019

@author: ctiuser
"""
import sys

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

A.sort()

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

flg = True
if A[0] != A[N//3-1]:
    flg = False
if A[N//3] != A[(2*N)//3-1]:
    flg = False
if A[(2*N)//3] != A[(3*N)//3-1]:
    flg = False

if A[0] ^ A[N//3] != A[(2*N)//3]:
    flg = False

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

Submission status: Wrong Answer

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

ans = 'Yes'

for i in range(n-1):
    print(i)
    print(a[i],a[i-1],a[i+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 sys
input = sys.stdin.readline

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

from collections import Counter
C=Counter(A)

flag=1

if len(C)!=3:
    flag=0

if N%3!=0:
    flag=0

for v in C.values():
    if v!=N//3:
        flag=0

A=0
for k in C.keys():
    A^=k

if A!=0:
    flag=0

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

import sys, math, random
import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"
# S=numpp.assaray(S)=="#"
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LLS(): return [list(sys.stdin.readline().rstrip()) for _ in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()



def main():
    N=I()
    A = list(map(int,input().split()))
    out=True
    # for i in range(N):
    #     if i==0:
    #         last=N-1
    #     else:
    #         last=i-1
    #     if i==N-1:
    #         ne=0
    #     else:
    #         ne=i+1
    #     print(last,ne)
    #     if A[last]^A[ne]!=A[i]:
    #         print("No")
    #         # exit()
    # print("Yes")

    A.append(A[0])
    A.append(A[1])
    for i in range(1,N+1):
        # print(i-1,i+1)
        if A[i-1]^A[i+1]!=A[i]:
            print("No")
            exit()
    print("Yes")

    # print(A,B)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

flag = True
for i in range(a_len):

    next_n = (i+1) % a_len
    pre_n = i-1
    side = a_list[pre_n] ^ a_list[next_n]

    if side != a_list[i]:
        flag = False
        break

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

Submission status: Wrong Answer

Solution code:
N=int(input())
a=[int(i) for i in input().split()]
b=list(set(a))
if len(b)==1:
    if b[0]==0:
        print("Yes")
    else:
        print("No")
else:
    if N%3==0 and len(b)==3:
        c=[0,0,0]
        for i in range(N):
            for j in range(3):
                if b[j]==a[i]:
                    c[j]+=1
        if c[0]==c[1]==c[2] and b[0]^b[1]==b[2]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:

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

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

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

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

Submission status: Wrong Answer

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

tmp = 0
for i in A:
    tmp ^= i

flag = False
if N % 3 == 0:
    if tmp == 0:
        flag = True
elif N % 3 == 1:
    if tmp == A[-1]:
        flag = True
elif N % 3 == 2:
    if tmp == (A[-1] ^ A[-2]):
        flag = True

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

Submission status: Wrong Answer

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

for i in range(N):
    a = i - 1 if i - 1 >= 0 else -1
    b = i + 1 if i + 1 < N else 0
    if (A[a] ^ A[b]) != A[i]:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
flag = True
if(a[n-1]^a[1] != a[0]):
    flag = False
if(a[n-2]^a[0] != a[n-1]):
    flag = False

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

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())

A = list(map(int, input().split()))
if all(a == 0 for a in A):
        print('Yes')
elif N % 3:
    print('No')
else:
    n = N//3
    CA = Counter(A)
    ans = 'Yes'
    t = []
    for k, v in CA.items():
        if v != n:
            ans = 'No'
        t.append(k)
        
    if len(t) == 3 and not (t[0]^t[1] == t[2] and t[2]^t[1] == t[0] and t[0]^t[2] == t[1]):
        ans = 'No'
    print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque
from sys import stdin

def main():
    N = int(input())
    A = map(int, input().split())

    a = deque(A)
    for _ in range(N):
        if a[0] ^ a[2] == a[1]:
            a.rotate()
        else:
            print('No')
            break
    else:
        print('Yes')

input = lambda: stdin.readline()
main()

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]:
  if a[n-1] == a[n-2]^a[0]:
    for i in range(1,n-1):
      if a[i] == a[i-1]^a[i+1]:
        continue
      else:
        f = 1
        break
  else:
    f = 1
else:
  f = 1

if f == 0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter


def main():
    N = int(input())
    A = list(map(int, input().split()))
    C = Counter(A)
    if N % 3 != 0:
        print("No")
        return
    if 0 in C and len(C) == 2:
        if C[0] * 3 == N:
            print("Yes")
            return
    elif 0 not in C and len(C) == 3:
        ok = True
        for c in C:
            if C[c] * 3 != N:
                print("No")
                return
            print("Yes")
            return
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

ans = 0
for i in range(1, N-1):
    if a[i - 1] ^ a[i + 1] != a[i]:
        ans = 1
        break
if a[1] ^ a[N - 1] != a[0]:
    ans = 1

if a[0] ^ a[N - 2] != a[N-1]:
    ans = 1
if ans == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import Counter

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

c = Counter(a)

ans = False
if len(c) == 1:
    ans = True
elif n % 3 == 0 and len(c) <= 3:
    nums = []
    for i in c:
        if c[i] % (n // 3) != 0:
            break
        else:
            nums += [i] * (c[i] // (n // 3))
    else:
        ans = (nums[0] ^ nums[1] ^ nums[2]) == 0

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

Submission status: Wrong Answer

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

a.append(a[0])
a.append(a[1])

for i in range(1, n+1):
    if ((a[i-1] ^ a[i+1]) ^ a[i]) == 0:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

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

xorNeighbor = 0
for i in range(1, len(a)-1):
    xorNeighbor += (a[i-1] ^ a[i] ^ a[i+1])

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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')
else:
    if len(set(a)) == 1:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

    flg = aa[0] == aa[len(aa)-1] ^ aa[1] and aa[len(aa)-1] == aa[len(aa)-2] ^ aa[0]

    for a1,a2,a3 in zip(aa,aa[1:],aa[2:]):
        if a2 != a1 ^ a3:
            flg = False
            break

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

Submission status: Wrong Answer

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

def func(x, y):
    if (x == 1 and y == 1) or (x == 0 and y == 0):
        return 0
    elif (x == 0 and y == 1) or (x == 1 and y == 0):
        return 1

for i, a in enumerate(a_lis):
    if i == 0:
        ans = func(a_lis[N - 1] % 2, a_lis[1] % 2)
    elif i == N - 1:
        ans = func(a_lis[0] % 2, a_lis[N - 2] % 2)
    else:
        ans = func(a_lis[i - 1] % 2, a_lis[i + 1] % 2)
    if ans != (a_lis[i] % 2):
        print('No')
        sys.exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
#    !/usr/bin/env python3
#    encoding: UTF-8
#    Modified: <14/Jul/2019 06:09:45 PM>


#    ✪ H4WK3yE乡
#    Mohd. Farhan Tahir
#    Indian Institute Of Information Technology (IIIT), Gwalior


import sys
import os
from io import IOBase, BytesIO


def main():
    n = int(input())
    arr = get_array()
    from collections import Counter
    d = Counter(arr)
    for i in range(n - 1):
        x = arr[i] ^ arr[i + 1]
        if x not in d:
            print('No')
            return
        d[x] -= 1
        if d[x] == 0:
            del d[x]
    x = arr[0] ^ arr[-1]
    if x not in d:
        print('No')
        return
    print('Yes')


BUFSIZE = 8192


class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        py2 = round(0.5)
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2 == 1:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode("ascii"))
            self.read = lambda: self.buffer.read().decode("ascii")
            self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def get_array(): return list(map(int, sys.stdin.readline().split()))


def get_ints(): return map(int, sys.stdin.readline().split())


def input(): return sys.stdin.readline().strip()


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

if n % 3 == 0:
    a.sort()
    m = 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')
else:
    if max(a) == min(a):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(s) for s in input().split(" ")]
a_set = set(a)

ans = False
for i in range(n):
  for j in range(i, n):
    if a[i] ^ a[j] in a_set:
      ans = True
      break
  if ans:
    break

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

if N % 3:
    print('No')
else:
    cnt = Counter(As)
    if len(cnt) != 3:
        print('No')
    else:
        nums = [cnt[i] for i in cnt.keys()]
#        print(nums)
        if len(set(nums)) != 1:
            print('No')
        else:
            A, B, C = cnt.keys()
#            print(A, B, C)
            if A^B^C:
                print('No')
            else:
                print('Yes')

Submission status: Wrong Answer

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

def sol() :
    for i in range(N) :  # 先頭
        for j in range(i+1, N) :  # 2頭目
            numbers = [0] * (N + 2)
            numbers[0] = A[i]
            numbers[1] = A[j]
            for k in range(2, N+2) :
                numbers[k] = numbers[k-1] ^ numbers[k-2]

            if numbers[0] == numbers[-2] and numbers[1] == numbers[-1] :
                return numbers[:-2]
    return -1

ans = sol()

if ans == -1 :
    print('No')
else :
    ans.sort()
    A.sort()
    if ans == A :
        print('Yes')
    else :
        print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(x) for x in input().split()]
a = sorted(a)
a.append(a[0])
ans = 0
for i in range(1, N):
    if a[i - 1] ^ a[i + 1] != a[i]:
        ans = 1
        break
if a[1] ^ a[N - 1] != a[0]:
    ans = 1
if ans == 0:
    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 N % 2 == 0:
    if 0 < k:
        print('No')
    else:
        print('Yes')
else:
    if k == 0 or k - g == 1:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
flg = 0
#A = [1,2,4,8]

if(A[0]%2==(A[1]+A[-1])%2):
    flg += 1
    
A.append(A[0])


for i in range(1,N):
    if(A[i]%2 == (A[i-1]+A[i+1])%2):
        flg += 1
    else:
        print("No")
        break



if(flg == N):
    print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import Counter


def solve(n, aaa):
    if n % 3 != 0:
        return False

    cnt = list(Counter(aaa).items())
    if len(cnt) == 2:
        (a1, c1), (a2, c2) = cnt
        if c1 > c2:
            c1, c2 = c2, c1
        if c1 != n // 3 or c2 != n * 2 // 3:
            return False
        return a1 == 0

    if len(cnt) == 3:
        if any(c[1] != n // 3 for c in cnt):
            return False
        a1, a2, a3 = (c[0] for c in cnt)
        return a1 ^ a2 == a3
   
    return False


n = int(input())
aaa = list(map(int, input().split()))
print('Yes' if solve(n, aaa) else 'No')

Submission status: Wrong Answer

Solution code:
N = int(input())

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

ans = 0
for i in range(1,N-1):
    if((a[i-1] ^ a[i+1])==a[i]):
        ans +=1


if((a[N-1] ^ a[1])==a[0]):
    ans +=1

if((a[N-2] ^ a[0])==a[N-1]):
    ans +=1


if(ans==N):
    print('Yes')
else:
    print('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 == n - 1):
        if(a[0]^a[n-2] != a[n-1]):
            flag = False
    else:
        if (a[i-1] ^ a[i+1] != a[i]):
            flag = False

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

Submission status: Wrong Answer

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

a.append(a[0])
a.append(a[1])

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

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n=INT()
    a=LIST()
    ans='Yes'
    for i in range(-2,n-1):
        if a[i] != a[i-1] ^ a[i+1]:
            ans='No'
            break

    print(ans)

if  __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
a = int(input())
b = list(map(int, input().split()))
b.insert(0, b[len(b)-1])
b.append(b[1])
for i in range(1, len(b)-1):
    if b[i-1] ^ b[i+1] != b[i] ^ 0:
        print("No")
        exit()
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()

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

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:
    print('Yes')

Submission status: Wrong Answer

Solution code:
n=input()
l=map(int,raw_input().split())
flag=0
for i in xrange (n-1):
  if (l[i]^l[i+1]) not in l:
    flag=1
    break
if flag:
  print "No"
else:
  print "Yes"