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: Runtime Error

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 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: Runtime Error

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

answer = "No"
for i in range(N - 1):
  if bin(a[i]) = bin(bin(a[i - 1]) ^ bin(a + 1)):
    answer = "Yes"
    
print(answer)

Submission status: Runtime Error

Solution code:
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

if len(A) % 3 == 0:
    c = Counter(A)
    k = c.keys()
    s = len(c.keys())
    if len(k) == 3:
        ok = len(Counter(c.values()).keys()) == 1
    if len(k) == 2:
        ok = min(c.values()) * 2 == max(c.values())
    if len(k) == 1:
        ok = True
else:
    ok = False
if ok:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
    n, = map(int, input())
    a = list(map(int, input().split()))
    flag = True
    for i in range(0, n):
        b = i - 1
        c = i + 1
        if b < 0:
            b = n - 1
        if c >= n:
            c = 0
        if a[b] ^ a[c] != a[i]:
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")