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()
b=set(a)
l=len(b)
if l==2:
  c=sorted([b.pop(),b.pop()])
  if c[1]^c[0]==c[1] and a[(n+1)//2-1]==0:print("Yes")
  else:print("No")
  exit()
elif l==1:
  if a[0]==0:print("Yes")
  else:print("No")
  exit()
def ecount(X):
  c,ans=1,[]
  for i in range(len(X)-1):
    if X[i]==X[i+1]:c+=1
    else:
      ans.append(c);c=1
  ans.append(c)
  return ans
for i in range(n):
  if a[i]!=0:d=ecount(a[i:]);z=i;break
if l-(0 in b)!=3:print("No");exit()
if 0 in b:b.discard(0)
print(b)
for i in range(z):
  d.sort()
  d[-1]-=1
d.sort()
if d[0]>0 and b.pop()^b.pop()^b.pop()==0 and d[0]==d[2]:print("Yes")
else:print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
C = Counter(a)
if len(C) == 3:
    x = C[a[0]]
    for k in C:
        if C[k] != x:
            print('No')
            quit()
    print('Yes')
else:
    if 0 not in C:
        print('No')
        quit()
    for k in C:
        if k != 0:
            if C[k] == 2 * C[0]:
                print('Yes')
            else:
                print('No')
            break

Submission status: Wrong Answer

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

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
        if len(current_list == 1):
            for num in rest_list:
                current_list.append(num)
                rest_list.remove(num)
                if is_circle(current_list, rest_list):
                    return True
            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[0]], input_list[1:]):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int,input().split())))
ans=[]
ban=0
for i in range(n):
    for j in range(n):
         if ban>0:
            break
         if i<j:
            c=a[i]^a[j]
            if a.count(c)>0:
                ans.append(c)
            else:ban+=1
   
ans=sorted(ans)
print("Yes" if ans==a else "No")

Submission status: Wrong Answer

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

def all_zero(a):
    for e in a:
        if e != 0:
            return False
    return True

if N != 3:
    if all_zero(a):
        print("Yes")
    else:
        print("No")
else:
    lst = [0,1,2]
    p = itertools.permutations(lst, 3)
    for perm in p:
        good_perm = True
        for i in range(3):
            if a[perm[(i + 1) % 3]] != a[perm[i]] ^ a[perm[(i + 2) % 3]]:
                good_perm = False
        if good_perm:
            yes = True
            break
    if yes:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
num = list(map(int, input().split()))
l = num[0]
r = num[1]
sum_ = l ^ r
i = 0

while i < n:
  if sum_ in num:
    l, r = r, sum_
    sum_ = l ^ r
    num.remove(r)
    i += 1
  else:
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

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

    flg = len(aa) % 3 == 0

    aa.sort()

    tmp1 = aa[0]
    tmp2 = aa[len(aa) // 2]
    tmp3 = aa[len(aa)-1]

    if flg:
        flg = tmp1 == tmp2 ^ tmp3 and tmp2 == tmp1 ^ tmp3 and tmp3 == tmp1 ^ tmp2

    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:
def main():
  n = int(input())
  alist = list(sorted(map(int, input().split())))
  aset = set(alist)
  tmpal = list(aset)
  if len(aset) > 3:
    print('No')
  elif len(aset) == 1:
    if tmpal[0] == 0:
      print('Yes')
    else:
      print('No')
  elif n % 3 != 0:
    print('No')
  else:
    if len(aset) == 2:
      if alist.count(0) == n // 3:
        print('Yes')
      else:
        print('No')
    else:
      if tmpal[0] ^ tmpal[2] == tmpal[1]:
        print('Yes')
      else:
        print('No')


if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import collections

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

def check(i,j):
    for k in range(len(a)-2):
        if c[i^j] == 0:
            return False
        i = j
        j = i^j
    return True

for  i in range(len(a)-1):
    for j in range(i+1,len(a)):
        if check(i,j):
            print("Yes")
            break
    else:
        continue
    break

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(np.mod(N - 1.5 * sum_array, 3) == 0):
            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:
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op


# globals
inf = float('inf')
input = stdin.readline


def main():
    n = get_int()
    A = get_li()
    if n % 3 != 0:
        if any(a != 0 for a in A):
            print('No')
            return
    else:
        cnt = Counter(A)
        if len(cnt.items()) > 3:
            print('No')
            return
        elif len(cnt.items()) == 3:
            a, b, c = cnt.most_common(3)
            if a[0] ^ b[0] ^ c[0] != 0:
                print('No')
                return
        elif len(cnt.items()) == 2:
            a, b = cnt.most_common(2)
            if b[0] != 0:
                print('No')
                return
        else:
            a = cnt.most_common(1)[0]
            if a[0] != 0:
                print(a)
                print('No')
                return
        for v, c in cnt.items():
            if c % (n // 3) != 0:
                print('No')
                return
    print('Yes')
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def gets(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for i in range(N):
    for j in range(i + 1, N):
      if int(bin(a[i]^a[j]),0) not in a:
        print('No')
        exit()
        
print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from functools import reduce
N = int(input())
A = [int(x) for x in input().split()]
def isExist(N, A):
  if N % 3 != 0:
    return 'No'
  AD = defaultdict(int)
  for a in A:
    AD[a] += 1
  keys = len(AD.keys())
  xor = reduce(lambda x, y: x^y, AD.keys())
  mlen = max([a for a in AD.values()])
  if keys !=3 and keys != 1:
    return 'No'
  if xor != 0:
    return 'No'
  if mlen != N and mlen != N // 3:
    return 'No'
  return 'Yes'
print(isExist(N, A))

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:
    if n % 3 != 0:
        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:
from sys import stdin


def main():
    N = int(input())
    a = [int(x) for x in stdin.readline().rstrip().split()]
    count = 0


    for i in range(N):
        if i == N-1:
            if a[i-1] ^ a[0] != a[i]:
                count += 1
        else:
            if a[i-1] ^ a[i+1] != a[i]:
                count += 1



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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
ans = "No"
Co = Counter(A)
if n%3 != 0:
    if len(Co.keys()) == 1:
        ans = "Yes"
else:
    tr = n//3
    Va = Co.values()
    if len(Va) == 3:
        if Co.most_common()[0][1] == Co.most_common()[1][1] == Co.most_common()[2][1]:
            ans = "Yes"
    elif len(Va) == 2 and Co.most_common()[0][1] == 2*tr:
        ans = "Yes"
    elif len(Va) == 1:
        ans = "Yes"

print(ans)

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]) == N//3:
            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]) == N//3*2:
            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()))
ans=0
for i in range(n):
  if i!=n-1:
    ai=a[i]
    x=a[i+1]^a[i-1]
    if x==ai:
      ans="Yes"
    else:
      ans="No"
  else:
    ai=a[i]
    x=a[0]^a[i-1]
    if x==ai and ans=="Yes":
      ans="Yes"
    else:
      ans="No"    
print(ans)

Submission status: Wrong Answer

Solution code:
#gcdは3.4.3だとfractionsにある
from fractions import gcd

from math import factorial as f

from math import ceil

from sys import exit

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 2:
        if n%3 or not 0 in aunique:
            print("No")
        else:
            l = []
            l.append(a.count(aunique[0]))
            l.append(a.count(aunique[1]))
            if aunique[0] == 0:
                if not l[0] == n//3:
                    print("No")
                else:
                    print("Yes")
            else:
                if not l[1] == n//3:
                    print("No")
                else:
                    print("Yes")


    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:
from collections import deque

N = int(input())
A = deque(map(int, input().split()))
first = A.popleft()


def round(a):
        B = set(A)
        eval = 0
        pre = first
        post = a
        B.discard(a)
        while len(B) != 0:
                c = pre ^ post
                if c in B:
                        B.discard(c)
                        pre = post
                        post = c
                else:
                        return 'No'
                        eval = 1
                        break
        
        if post ^ first == a:
                return 'Yes'
        elif eval == 0:
                return 'No'

for i in range(0, N - 1):
        ans = round(A[i])
        if ans == 'Yes':
                print('Yes')
                

if ans == 'No':
        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 != 0:
            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:
N = int(input())
a = list(map(int, input().split()))
seta = list(set(a))
if len(seta) == 3 and 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")
elif len(seta) == 2:
  sseta = sorted(seta)
  if sseta[0] == 0 and (a.count(sseta[1])//2)*3 == N:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
from random import shuffle
n = int(input())
lst = list(map(int,input().split()))
flg = 1
for j in range(5):
  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
    shuffle(lst)
  if flg == 0:
    break
if flg == 1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n = int(input())
result = False
if n % 3 == 0:
    numbers = defaultdict(int)
    inputNum = list(input().split())
    for i in range(n):
        numbers[inputNum[i]] += 1
    if len(numbers) == 3:
        vals = list(numbers.values())
        if vals[0] == vals[1] and vals[1] == vals[2]:
            keys = list(numbers.keys())
            if int(keys[0]) ^ int(keys[1]) == int(keys[2]):
                result = True

if result == True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import collections
import sys

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

if len(c) != 3:
    print('No')
    sys.exit()

value = list(c.values())
if value[0] != value[1] or value[1] != value[2] or value[2] != value[0]:
    print('No')
    sys.exit()

key = list(c.keys())
if key[0] ^ key[1] ^ key[2] != 0:
    print('No')
    sys.exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
#!venv/bin/python
#from collections import defaultdict 
from itertools import combinations
import math
import datetime
N = int(input())
A = [int(x) for x in input().split()]

cnt = {}

kind = 0
for a in A:
    if not a in cnt:
        kind += 1
        cnt[a] = 0
    if kind > 3:
        break
    cnt[a] += 1

nums = list(cnt.keys())
if kind == 3 and cnt[nums[0]] == cnt[nums[1]] == cnt[nums[2]] and nums[0] ^ nums[1] == nums[2]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
ans = "Yes"
flag = 0
for k in range(N):
    for i in range(N - 1):
        if i == k:
            continue
        for j in range(i + 1, N):
            if j == k:
                continue
            if (a[i] ^ a[j]) == a[k]:
                flag = 1
                break
        if flag == 1:
            break
    if flag != 1:
        ans = "No"
        break
print(ans)

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
    if right >= input_size:
      right = 0
#     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:
import sys

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

for i in range(N//2):
	x = int(a[(i-1)%N])
	y = int(a[(i+1)%N])

	if int(a[i%N]) != x^y:
		print('No')
		sys.exit(0);

print('Yes')

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()]

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

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)
count_a0=a_list.count(a[0])
count_a1=a_list.count(a[1])
count_a2=a_list.count(a[2])
print(a)
if count_a0!=count_a1 or count_a1!=count_a2 or count_a2!=count_a0:
  print("No")
  exit()
if a[0]==a[1]^a[2] and a[1]==a[0]^a[2] and a[2]==a[1]^a[0]:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import sys
import collections


def input():
    return sys.stdin.readline()[:-1]


def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    c = collections.Counter(a)
    if len(c) != 3:
        print("No")
    else:
        s = list(c.keys())
        v = list(c.values())
        if s[0] == s[1] ^ s[2] or v[0] == v[1] == v[2]:
            print("Yes")
        else:
            print("No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
l = set(map(int,input().split()))
l2 = list(l)
if n % 3 != 0:
    print("No")
elif len(l) != 3:
  if len(l)==1 and l2[0]==0:
    print("Yes")
  else:
    print("No")
else:
    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:
from random import shuffle
n = int(input())
lst = list(map(int,input().split()))
flg = 1
for j in range(10):
  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
    shuffle(lst)
  if flg == 0:
    break
if flg == 1:
  print("Yes")
else:
  print("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
    if right > input_size:
      right = 0
#     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:
import numpy as np

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

a = np.array(a)




def make_Xor(a,b):
	d_ = []
	for i in range(len(a)):
		if a[i] == b[i]:
			d_.append("0")
		else:
			d_.append("1")
	return d_


def judge_of_3(a):
	a_ = []
	a_.append(list(format(a[0],'b')))
	a_.append(list(format(a[1],'b')))
	a_.append(list(format(a[2],'b')))
	max_len = max(len(a_[0]),len(a_[1]),len(a_[2]))
	for i in range(3):
		while len(a_[i]) < max_len:
			a_[i].insert(0,'0')
	if make_Xor(a_[0],a_[1]) == a_[2]:
		return True
	else:
		return False
	
	


if N % 3 == 0:
	a_1 = np.unique(a)
	if len(a_1) == 3:
		for a_1_ in a_1:	
			if np.count_nonzero(a == a_1_) != int(N // 3):
				judge = False
			else:
				if judge_of_3(a_1):
					judge = True
				else:
					judge = False
	else:
		judge = False
else:
	a_1 = np.unique(a)
	a_1 = list(a_1)
	if len(a_1) != 0:
		judge = False
	if a_1[0] != 0:
		judge = False

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

Submission status: Wrong Answer

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

flag = 0
even = []
odd = []
for i in a:
    if i%2 == 0:
        even.append(i)
    else:
        odd.append(i) 

if n%2 == 1:
    if len(odd) >= 1:
        flag = 1
    else:
        pass

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

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==0:
    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()
else:
    if len(C)==1 and C.get(0,0):
        Yes()
    else:No()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
res = []
for n in range(len(a)):
  if(n == (len(a) - 1)):
    res.append(a[n - 1]^a[0])
  else:
    res.append(a[n - 1]^a[n + 1])
mes = "Yes"
for i, j in enumerate(res):
  if(i+1 != j):
    mes = ("No")
    break
print(mes)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
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 II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    N = II()
    a = LI()

    from collections import Counter

    cnt = Counter(a)

    if len(cnt) == 1 and a[0] == 0:  # all elements are zero
        print('Yes')
        return
    

    if len(cnt) == 3:
        x, y, z = cnt.keys()
        if x^y==z and y^z==x and z^x==y and cnt[x]==cnt[y]==cnt[z]:
            print('Yes')
            return
    print('No')


main()

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
    elif val == N // 3 * 2:
        a += 2

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 = [int(x) for x in input().split(' ')]
a.sort()

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())
aLst = list(map(int, input().split()))
ansB = True
for i in range(N):
    if i == 0:
        if aLst[0] == (aLst[-1] ^ aLst[1]):
            continue
        else:
            ansB = False
            break
    elif i == (N) - 1:
        if aLst[i] == (aLst[i - 1] ^ aLst[0]):
            continue
        else:
            ansB = False
            break
    else:
        if aLst[i] == (aLst[i - 1] ^ aLst[i + 1]):
            continue
        else:
            ansB = False
            break

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

Submission status: Wrong Answer

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

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

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()) ==  [list(l.values())[0]] * len(l.values()):
		chk=chk//list(l.values())[0]
		if ((chk+2)&(chk+1)) == 0:
			print("Yes")
		else:
			print("No")
	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:
    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()
else:
    if len(C)==1 and C.get(0,0):
        Yes()
    else:No()

Submission status: Wrong Answer

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

nums = {}

for i in range(len(a)):
  if int(a[i]) not in nums:
    nums[int(a[i])] = 1
  else:
    nums[int(a[i])] += 1

#print(nums)

if len(nums) > 3:
  print("No")
else:
  snums = sorted(nums.items())
  #print(snums)
  
  if(snums[0][0] == 0 and len(snums) == 2 and snums[0][1]*2 == snums[1][1] ):
    print("Yes")
  elif(snums[0][0] != 0 and len(snums) == 3 
       and snums[0][1] == snums[1][1] == snums[2][1] ):
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
n = list(map(int, input().split()))
t = 0
for i in range(N):
  if i == 0:
    if n[N-1] ^ n[1] == n[0]:
      t += 1
  elif i == N-1:
    if n[N-2] ^ n[0] == n[N-1]:
      t += 1
  else:
    if n[i-1] ^ n[i+1] == n[i]:
      t += 1
if t == N:
  print("Yes")
else:
  print("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
    if right < input_size:
      right = 0
#     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:
import sys

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

for i in range(N-1):
	x = int(a[(i-1)%N])
	y = int(a[(i+1)%N])

	if int(a[i%N]) != x^y:
		print('No')
		sys.exit(0);

print('Yes')