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, 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()
    a_=a.copy()

    p=a.pop(0)
    q=a.pop(0)
    flag=True
    i=0
    while len(a)>0:
        #print(i)
        if i >= len(a):
            flag=False
            #print('out of range')
            break

        if p^q^a[i]==0:
            #print('mae',p,q)
            p,q=q,p^q
            #print('ato',p,q)
            a.pop(i)
        i+=1

    if flag == False:
        print('No')
    else:
        if p^q==a_[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()))

c = Counter(A)
K = c.keys()

ans = "No"
if len(K)==3:
    B = []
    for k in K:
        B.append(k)
    if c[B[0]]==c[B[1]] and c[B[1]]==c[B[2]] and B[0]^B[1]==B[2]:
        ans = "Yes"
elif len(K)==2:
    B = []
    for k in K:
        B.append(k)
    if c[B[0]]==2*c[B[1]]:
        ans = "Yes"
elif len(K)==1:
    for k in K:
        if k==0:
            ans = "Yes"

print(ans)

Submission status: Wrong Answer

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

res = "No"
a_set = list(set(a))
if len(a_set) == 3:
    if a_set[0] ^ a_set[1] == a_set[2]:
        if a.count(a_set[0]) == a.count(a_set[1]) and a.count(a_set[0]) == a.count(a_set[2]):
            res = "Yes"

print(res)

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:
  l, r = r, sum_
  sum_ = l ^ r
  try:
    num.remove(sum_)
  except:
    print("No")
    exit()
  else:
    i += 1
print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = set(a)
if len(b) == 3 and n % 3 == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if n ==3:
    if a[0]^a[1] == a[2]:
        result = True

elif a[0]^a[1] == a[2]:
    if a[1]^a[2] == a[3]:
        if a[n-2]^a[n-1] == a[0]:
            if a[n-1]^a[0] == a[1]:
                result = True

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

Submission status: Wrong Answer

Solution code:
import copy
N=int(input())
a_list=list(map(int,input().split()))
if N%3!=0:
  print("No")
else:
    a=set(a_list)
    a=list(a)
    if 0 in a:
            if len(a) ==2:
                if a_list.count(0)==len(a_list)//3:
                    while 1==1:
                        print("Yes")
                else:
                    print("No")
            else:
                print("No")
    else:
            if len(a)==3:
                a1=a[0]
                a2=a[1]
                a3=a[2]
                if a1 ^ a2 ==a3 and a1^a3==a2 and a2^a3==a1:
                    if a_list.count(a1) ==a_list.count(a2) ==a_list.count(a3):
                        print("Yes")
                    else:
                        print("No")
                else:
                    print("No")
            else:
                print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
A = list(map(int,input().split()))
if(N % 3 != 0):
    print('No')
else:
    a = -1
    b = -1
    c = -1
    aa = A[0]
    a = A.count(aa)

    bb = -1

    for i in A:
        if(aa != i):
            bb = i
            break
    if(bb != -1):
        b = A.count(bb)
        if(a == b):
            cc = -1

            for i in A:
                if(aa != i and bb != i):
                    cc = i
                    break
            if(cc != -1):
                c = A.count(cc)
                if(b == c and a + b + c == N):
                    print('Yes')
                else:
                    print('No')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
from collections import deque
from sys import stdin

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

    a = deque(A)
    for _ in range(N + 1):
        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:
def doMaths(one, two):
    i = max(len(one), len(two))
    ans = ""
    diffone = i - len(one)
    difftwo = i - len(two)
    nonzero = False
    for i2 in range(0, i):
        if len(one) < i - i2:
            ans += two[i2]
            nonzero = True
            continue
        if len(two) < i - i2:
            ans += one[i2]
            nonzero = True
            continue
        maths = (int(one[i2 - diffone]) + int(two[i2 - difftwo]))%2
        if not nonzero:
            if not maths == 0:
                ans += str(maths)
                nonzero = True
        else:
            ans += str(maths)
    return ans

def check(hatnums2):
    for hatnum in hatnums2:
        for hatnum2 in hatnums2:
            if hatnum2 != hatnum:
                if not doMaths(hatnum, hatnum2) in hatnums2:
                    print('No')
                    return False
                else:
                    hatnums2.remove(doMaths(hatnum, hatnum2))
                    return True
    return True

n = int(input())
hats = input()
hatnums = hats.split(" ")
hatnums2 = []
for hat in hatnums:
    hatnums2.append(bin(int(hat))[2:])
if len(hatnums2)%2 == 0:
    print('No')
    exit()
while len(hatnums2) > 2:
    if not check(hatnums2):
        exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
P=int(input())
A=[int(i) for i in input().split(" ")]
ans=0

if len(set(A))==3:
	if P%3==0:
		if A.count(A[0])==P/3:
			n=A[0]
			A.remove(A[0])
			m=A[0]
			A.remove(A[0])
			l=A[0]
			if A.count(A[0])==P/3:
				if l==n|m:ans=1
if len(set(A))==1:
	if A[0]==0:ans=1



if ans==1:
	print("yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque, defaultdict
import copy
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

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


numnum=defaultdict(int)
for i in range(N):
    numnum[a[i]]+=1

if len(numnum) > 3:
    print("No")
    exit()


if len(numnum) == 1:
    for num in numnum:
        if num == 0:
            print("Yes")
        else:
            print("No")
        exit()


for num in numnum:
    if numnum[num] % (N//3) != 0:
        print(num)
        print("No")
        exit()

num3=[]
for num in numnum:
    num3.append(num)

if len(num3) == 2:

    if 0 in num3 and numnum[0] == N//3:
        print("Yes")
        exit()
    else:
        print("No")
        exit()


if num3[0]^num3[1] == num3[2]:
    print("Yes")
    exit()
else:
    print("No")
    exit()

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

c = Counter(A)
K = c.keys()

ans = "No"
if len(K)==3:
    B = []
    for k in K:
        B.append(k)
    if c[B[0]]==c[B[1]] and c[B[1]]==c[B[2]] and B[0]^B[1]==B[2]:
        ans = "Yes"
elif len(K)==2:
    B = []
    for k in K:
        B.append(k)
    if c[B[0]]==2*c[B[1]] and B[1]==0:
        ans = "Yes"
elif len(K)==1:
    for k in K:
        if k==0:
            ans = "Yes"

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

a = sorted([int(x) for x in input().split()],reverse=True)

for i in range(N):
    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 = [int(s) for s in input().split(" ")]
dic_a = {}
for aa in a:
  if aa in dic_a:
    dic_a[aa] += 1
  else:
    dic_a[aa] = 0
a_set = list(dic_a.keys())
n_set = len(a_set)

if (n < 3):
  ans = False
else:
  ans = False
  for i in range(n_set):
    for j in range(i + 1, n_set):
      aij = a_set[i] ^ a_set[j]
      if aij in a_set and \
         not (aij == a_set[i] and dic_a[a_set[i]] == 1) and \
         not (aij == a_set[j] and dic_a[a_set[j]] == 1):
        ans = True
        break
    if ans:
      break

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

Submission status: Wrong Answer

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

N = int(input())
a = list(map(int, input().split()))
tmp = set(a)
flag = True
if len(a) % 3 != 0 or len(tmp) != 3:
    flag = False
if flag:
    a = sorted(tmp)
    if not(a[0]^a[2] == a[1] and  a[1]^a[0] == a[2] and  a[2]^a[1] == a[0]):
        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.sort()
#print(n,a)

ans = 0
if n == 3:
    if a[0]^a[1] == a[2]:
        ans = 1
    else:
        ans = 0
elif n == 4:
    if a[0]==0 and a[1]==0 and a[2]==0 and a[3]==0:
        ans = 1
    else:
        ans = 0
else:
    tmp = []
    cnt = []
    for i in range(n):
        if i == 0:
            tmp.append(a[i])
            cnt.append(1)
        else:
            if a[i-1] == a[i]:
                cnt[-1] += 1
            else:
                tmp.append(a[i])
                cnt.append(1)
    if n % 3 != 0:
        if tmp[0] == 0 and cnt[0] == n:
            ans = 1
    else:
        if len(tmp) == 3:
            if cnt[0] == cnt[1] and cnt[1] == cnt[2]:
                ans = 1
        if len(tmp) == 2:
            if 0 in tmp:
                p = tmp.index(0)
                if cnt[p]*2 == cnt[p+1]:
                    ans = 1
        if len(tmp) == 1:
            if tmp[0] == 0:
                ans = 1
if ans == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    array = list(map(int, input().split()))
    set_array = list(set(array))
    if N != len(array):
        return "No"
    if N < 3:
        return "No"
    if len(set_array) == 1 and set_array[0] == 0:
        return "Yes"
    
    if N%3 != 0:
        return "No"
    if len(set_array) == 3:
        for i in range(2):
            if array.count(set_array[i]) != array.count(set_array[i+1]):
                return "No"
        x = set_array[0]
        y = set_array[1]
        z = set_array[2]
        if x ^ y == z and y ^ z == x and x ^ z == y:
            return "Yes" 
    if len(set_array) == 2:
        x = min(set_array)
        y = max(set_array)
        if y^y == x and x^y == x:
            return "Yes"
    return "No"

print(main())

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

Submission status: Wrong Answer

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

def main():
    if a[0] != a[-1] ^ a[1]:
        print("No")
        return
    for i in range(1, N - 1):
        if a[i] != a[i + 1] ^ a[i - 1]:
            print("No")
            return
    if a[-1] != a[0] ^ a[-2]:
        print("No")
        return
    print("Yes")

main()

Submission status: Wrong Answer

Solution code:
n = int(input())
figure = list(map(int, input().split()))
p=0
for i in range(1):
  for j in range(i+1,n-1):
    now = figure[i]^figure[j]
    for k in range(j+1,n):
      if now==figure[k]:
        print("Yes")
        p+=1
        break
    else: 
      continue
    break
  else:
    continue
  break
if p==0:
  print("No")

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc035/tasks/agc035_a
import numpy as np


def calc(N: int, values: np.ndarray) -> bool:
    return any([calc3(N, values), calc_0_1(N, values)])


def calc3(N: int, values: np.ndarray) -> bool:
    if N % 3 != 0:
        return False

    uniques = np.unique(values)
    if len(uniques) != 3:
        return False

    counts = [np.sum(values == v) for v in uniques]  # 各固有値の格納数
    if len(np.unique(counts)) != 1:
        return False

    sorted_uniques = np.sort(uniques)
    return all(
        [
            sorted_uniques[0] == np.bitwise_xor(sorted_uniques[1], sorted_uniques[2]),
            sorted_uniques[1] == np.bitwise_xor(sorted_uniques[2], sorted_uniques[0]),
            sorted_uniques[2] == np.bitwise_xor(sorted_uniques[0], sorted_uniques[1]),
        ]
    )


def calc_0_1(N: int, values: np.ndarray) -> bool:
    """
    0000...0 and 1111...1 only pattern
    """
    if N < 4:
        return False

    max_value = np.max(values)
    # max value must be 1111...1
    if not number_is_all_bit_1(max_value):
        return False

    uniques = np.unique(values)
    if set(uniques) != {0, max_value}:
        return False

    counts = [np.sum(values == v) for v in uniques]  # 各固有値の格納数
    if abs(counts[0] - counts[1]) > 1:
        return False

    return True


def number_is_all_bit_1(value: int) -> bool:
    if value == 0:
        return False
    if value == 1:
        return True
    ex = 1
    compare = 2
    while compare - 1 <= value:
        if value == compare - 1:
            return True
        ex += 1
        compare = 2 ** ex

    return False


def load_input_as_int_array():
    return np.array([int(v) for v in input().split(" ")])


N = int(input())
values = load_input_as_int_array()
result = calc(N, values)

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import collections

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

c = collections.Counter(a_list)

print(len(c.keys()))
ans_list = list(c.keys())
count_list = list(c.values())
count_list.sort()

print(c.keys())
if len(c.keys()) == 1:
    if list(c.keys()) == [0]:
        print("Yes")
        quit()

if len(c.keys()) != 3:
    print("No")
    quit()

if ans_list[0] == ans_list[1] ^ ans_list[2]:
    if count_list[0]==count_list[1]==count_list[2]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
dic = defaultdict(int)
N = int(input())
a = list(map(int,input().split()))
t = 0
for i in range(N):
    t ^= a[i]
    dic[a[i]] += 1

if t != 0:
    print("No")
else:
    if N == 3:
        print("Yes")
    else:
        ks = dic.keys()
        if N % 3 == 0:
            if len(ks) > 3:
                print("No")
            elif len(ks) == 2:
                print("No")
            elif len(ks) == 1:
                print(print("Yes" if all([0 == x for x in a]) else "No"))
            else:
                ls = [dic[k] for k in ks]
                print("Yes" if ls[0] == ls[1] == ls[2] else "No")
        else:
            print("Yes" if all([0 == x for x in a]) else "No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(input().split())
A=a.count(a[0])
ans="Yes"
if n%3==0 and n!=3:
    for i in range(n):
        if a.count(a[i])!=A or a.count(a[i])==1:
            ans="No"
            break
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
l3 = list(map(int,input().split()))
l = set(l3)
l2 = list(l)
if n % 3 != 0:
    print("No")
elif len(l) != 3:
  if len(l)==1 and l2[0]==0:
    print("Yes")
  elif len(l)==2:
    if l3.count(l2[0])//l3.count(l2[1])==2:
      if l2[0]^l2[1]==l2[0] and l2[0]^l2[0]==l2[1]:
        print("Yes")
      else:
        print("No")
    elif l3.count(l2[1])//l3.count(l2[0])==2:
      if l2[1]^l2[0]==l2[1] and l2[1]^l2[1]==l2[0]:
        print("Yes")
      else:
        print("No")
    else:
      print("No")
  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:
n = int(input())
a = list(map(int,input().split()))

flag = 0
for i in range(n):
    if((i+1) >= n):
        l = 0
    else:
        l = i + 1
        
    if((i-1) < 0):
        r = n - 1
    else:
        r = i - 1
    
    if(a[i] != int(bin(a[r] ^ a[l]) ,2)):
        flag = 1
        
if(flag == 0):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def solve(N, A):
    xor_a = 0
    for i in range(N):
        xor_a ^= A[i]
    if N % 3 == 0:
        return 1 if xor_a == 0 else 0
    elif N % 3 == 1:
        for i in range(N):
            if xor_a ^ A[i] == 0:
                return 1
        return 0
    elif N % 3 == 2:
        return 0
    raise ValueError()


if __name__ == '__main__':
    inputs = read()
    print('Yes' if solve(*inputs) else 'No')

Submission status: Wrong Answer

Solution code:
n = 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(a[i] != j):
    mes = ("No")
print(mes)

Submission status: Wrong Answer

Solution code:
n=int(input())
setting=set(map(int,input().split()))
ans=0
sign=0
l=len(setting)
for i in setting:
    ans=ans^i
if n==3 or l<n:
    if ans==0:
        print("Yes")
    else :
        print("No")
else:
    setting=list(setting)
    for i in range(l-1):
        for j in range(l-i-1):
            if ans==(setting[i]^setting[j]):
                print("Yes")
                sign=1
                break
        if sign==1:
            break
    if sign==0:
        print("No")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = inp()
aa = inpl()

def product():
    if N != 3:
        if sum(aa) == 0:
            return 'Yes'
        else:
            return 'No'
    else:
        if aa[0]^aa[1] != aa[2]:
            return 'No'
        if aa[1]^aa[2] != aa[0]:
            return 'No'
        if aa[2]^aa[0] != aa[1]:
            return 'No'
        return 'Yes'


print(product())

Submission status: Wrong Answer

Solution code:
N = int(input())
aLst = list(map(int, input().split()))
aLst.sort()
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:
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
ans = "No"
Co = Counter(A)
if n % 3 != 0 : #3の倍数でない
    if len(Co.keys()) == 1 and list(Co.keys())[0] == 0:
        ans = "Yes" #要素の種類は1つかつその要素は0の場合のみOK
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] == tr:
            ans = "Yes"
    elif len(Va) == 2 and Co.most_common()[0][1] == 2 * tr :
        ans = "Yes"
    elif len(Va) == 1 and Co.most_common()[0][0] == 1 :
        ans = "Yes"
ans = "No"
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
a.sort()
count = 0
if bin(a[0] + a[1]) == bin(a[2]) and bin(a[1] + a[2]) == a[0]:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
W = list(map(int, input().split()))
c = dict(collections.Counter(W))

if len(c.keys()) == 1:
  if c.get(0, False) == False:
    print('No')
  else:
    print('Yes')
if len(c.keys()) == 2:
  num = list(c.values())
  num = sorted(num)
  if 0 in c:
    if c[0]*2 == num[1]:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
if len(c.keys()) == 3:
  num = list(c.values())
  if num[0] == num[1]:
    if num[0] == num[2]:
      print("Yes")
  else:
    print("No")
if len(c.keys()) >= 4:
  print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(input().split())
A=a.count(a[0])
ans="Yes"
if n%3==0:
    for i in range(n):
        if a.count(a[i])!=A or a.count(a[i])==1:
            ans="No"
            break
print(ans)

Submission status: Wrong Answer

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

flag = 0
for i in range(n):
    if((i+1) >= n):
        l = 0
    else:
        l = i + 1
        
    if((i-1) < 0):
        r = n - 1
    else:
        r = i - 1
    
    if(a[i] != int(bin(a[r] ^ a[l]) ,2)):
        flag = 1
        break
        
if(flag == 0):
    print("Yes")
else:
    print("No")

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 : #3の倍数でない
    if len(Co.keys()) == 1 and list(Co.keys())[0] == 0:
        ans = "Yes" #要素の種類は1つかつその要素は0の場合のみOK
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] == tr:
            ans = "Yes"
    elif len(Va) == 2 and Co.most_common()[0][1] == 2 * tr :
        ans = "Yes"
    elif len(Va) == 1 and Co.most_common()[0][0] == 1 :
        ans = "Yes"
ans = "Yes"
print(ans)

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) :
  X = list(bin(A[i - 1]))
  Y = list(bin(A[i + 1]))
  di = abs(len(X) - len(Y))
  if(len(X) < len(Y)) :
    for k in range(di) :
      X[2 : 2] = ["0"]
  elif(len(X) > len(Y)) :
    for k in range(di) :
      Y[2 : 2] = ["0"]
  else :
    pass
  C = list()
  for j in range(max(len(X), len(Y)) - 1, 1, -1) :
    if((X[j] == "0" and Y[j] == "1") or (X[j] == "1" and Y[j] == "0")) :
      C.append("1")
    else :
      C.append("0")
  C = C[::-1]
  c = "".join(C)
  c = int(c, 2)
  if(c != A[i]) :
    print("No")
    break
  elif(i == N) :
    print("Yes")
    break
  else :
    pass

Submission status: Wrong Answer

Solution code:
N=int(input())
x=list(map(int,input().split()))
answer = "Yes"
for i in range(N) :
    if i == N-1:
        wk = bin(x[i-1] ^ x[0])
    else:
        wk = bin(x[i-1] ^ x[i+1])
    if bin(x[i]) != wk:
        answer = "No"
        break
print(answer)

Submission status: Wrong Answer

Solution code:
def check_exist(num_list):
    if num_list[0] ^ num_list[1] == num_list[2] or num_list[0] ^ num_list[2] == num_list[1]:
        return False
    return True

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

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

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    array = list(map(int, input().split()))
    set_array = list(set(array))
    if N != len(array):
        return "No"
    if N < 3:
        return "No"
    if len(set_array) == 1 and set_array[0] == 0:
        return "Yes"
    
    if N%3 != 0:
        return "No"
    if len(set_array) == 3:
        for i in range(2):
            if array.count(set_array[i]) != array.count(set_array[i+1]):
                return "No"
        x = set_array[0]
        y = set_array[1]
        z = set_array[2]
        if x ^ y == z and y ^ z == x and x ^ z == y:
            return "Yes" 
    if len(set_array) == 2:
        x = set_array[0]
        y = set_array[1]
        if x ^ x == y and x ^ y == x:
            return "Yes"
    return "No"

print(main())

Submission status: Wrong Answer

Solution code:
N = int(input())
Rakuda_data =  input().split(' ')
flag = 0

for n in range(0, N):
    if 0 < int(n) and int(n) < N-1:
        Flontstr = int(Rakuda_data[n-2])
        binstr = int(Rakuda_data[n-1])
        Afterstr = int(Rakuda_data[n])
        # XOR回路
        if bin(Flontstr ^ Afterstr) != bin(binstr):
            flag=1
            print('No')
            break
    elif int(n)==N-1 and flag==0:
        print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

a = A[0]
c = A[1]
b = a ^ c

f = True

for i in range(3, N):
    if i % 3 == 0 and a != A[i]:
        f = False
    elif i % 3 == 1 and b != A[i]:
        f = False
    elif i % 3 == 2 and c != A[i]:
        f = False

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys

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

an = np.array(A, dtype=np.int64)

for i in range(1,N):
   for j in range(i+1,N):
      if(an[0] == an[i]^an[j]):
         tmp = an[1]
         an[1] = an[i]
         an[i] = tmp

         tmp = an[2]
         an[2] = an[j]
         an[j] = tmp

         doo = 1
         break
      else:
         doo = 0

if(doo == 0):
   print('No')
   sys.exit()

for i in range(2,N):
   for j in range(i+1,N):
      if(an[i-1] == an[i]^an[j]):
         tmp = an[i+1]
         an[i+1] = an[j]
         an[j] = tmp
         doo=1
         break
      else:
         doo=0

   if(doo==0):
      print('No')
      sys.exit()


if(an[0] == an[1]^an[N-1]):
   doo=1
else:
   print('No')
   sys.exit()

if(doo==1):
   print('Yes')

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc035/tasks/agc035_a
import numpy as np


def calc(N: int, values: np.ndarray) -> bool:
    return any([calc3(N, values), calc_0_1(N, values)])


def calc3(N: int, values: np.ndarray) -> bool:
    if N % 3 != 0:
        return False

    uniques = np.unique(values)
    if len(uniques) != 3:
        return False

    counts = [np.sum(values == v) for v in uniques]  # 各固有値の格納数
    if len(np.unique(counts)) != 1:
        return False

    sorted_uniques = np.sort(uniques)
    return all(
        [
            sorted_uniques[0] == np.bitwise_xor(sorted_uniques[1], sorted_uniques[2]),
            sorted_uniques[1] == np.bitwise_xor(sorted_uniques[2], sorted_uniques[0]),
            sorted_uniques[2] == np.bitwise_xor(sorted_uniques[0], sorted_uniques[1]),
        ]
    )


def calc_0_1(N: int, values: np.ndarray) -> bool:
    """
    (0000...0) and (one of any) only pattern
    """
    if N < 4:
        return False

    max_value = np.max(values)
    if max_value == 0:
        return False

    uniques = np.unique(values)
    if set(uniques) != {0, max_value}:
        return False

    counts = [np.sum(values == v) for v in uniques]  # 各固有値の格納数
    if abs(counts[0] - counts[1]) > 1:
        return False

    return True


def number_is_all_bit_1(value: int) -> bool:
    if value == 0:
        return False
    if value == 1:
        return True
    ex = 1
    compare = 2
    while compare - 1 <= value:
        if value == compare - 1:
            return True
        ex += 1
        compare = 2 ** ex

    return False


def load_input_as_int_array():
    return np.array([int(v) for v in input().split(" ")])


N = int(input())
values = load_input_as_int_array()
result = calc(N, values)

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

Submission status: Wrong Answer

Solution code:
def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def solve(N, A):
    xor_a = 0
    for i in range(N):
        xor_a ^= A[i]
    if N % 3 == 0:
        return 1 if xor_a == 0 else 0
    elif N % 3 == 1:
        for i in range(N):
            if xor_a ^ A[i] == 0:
                return 1
        return 0
    elif N % 3 == 2:
        return 1
    raise ValueError()


if __name__ == '__main__':
    inputs = read()
    print('Yes' if solve(*inputs) else 'No')