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 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 a.count(0) == 0:
		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")
	else:
		if len(l.values()) == 2 and a.count(0) == N//3:
			print("Yes")
		else:
			print("No")

Submission status: Wrong Answer

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

if max(a) == 0:
    print('Yes')
    exit()

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

p = n // 3
if 0 in a:
    # a = sorted(a)
    zero = a.count(0)
    if zero != p:
        print('No')
        exit()
    if a.count(max(a)) != p * 2:
        print('No')
        exit()
    print('Yes')
    exit()

a = sorted(a)
# if a[0] == a[p] or a[p] == a[-1] or a[-1] == a[0]:
#     print('No')
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 = int(input())
a_lists = list(input().split())

cnt = 0
for i in range(int(n)):
    for j in range(i+1,int(n)-1):
        if int(a_lists[i]) != int(a_lists[j]) ^ int((a_lists[j+1])):
            print("No")
            exit()
print("Yes")

Submission status: Wrong Answer

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

N = int(input())
a = list(map(int, input().split()))
a = sorted(a)
tmp = [2**x for x in range(30)]
flag = True
cnt = 0
for x in a:
    if x in tmp:
        cnt += 1
        if cnt > 2:
            flag = False
            break

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
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)
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:
def f(n,aa):
    if sum(aa)==0:
        return "Yes"
    if n%3:
        return "No"
    sa=set(aa)
    if len(sa)!=3:
        return "No"
    n3=n/3
    for sak in sa:
        if aa.count(sak)!=n3:
            return "No"
    sa=list(sa)
    for i in range(3):
        if sa[i - 1] != sa[i - 2] ^ sa[i]:
            break
    else:
        return "Yes"
    return "No"

n=int(input())
aa=list(map(int,input().split()))
print(f(n,aa))

Submission status: Wrong Answer

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
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 [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 _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N = _I()
A = LI()

# 001, 101, 1000の場合など、最大桁数のものが1つしかない場合、絶対に1000と作る数は1XXXになるので、絶対無理
# 1000, 1001, 0101, 0001の場合、0001が作れる。しかし、1000はどう頑張っても作れない
if N % 3 != 0:
    print('No')
    exit()

# 全数字を2進数に直す結局全部1が並ぶやつ、つまり、1/1/0, 10/01/11, 111/100/011, 111/101/010などの組み合わせが必要
# そもそも3種類以上ある場合は絶対成り立たない
set_A = set(A)
if len(set_A) > 3:
    print('No')
    exit()

if len(set_A) == 2:
    # 2種類で成り立つのは、全部1111が2つと、全部000が1つの場合のみ
    A_list = list(set_A)
    if 0 in A_list:
        non_zero = [i for i in A_list if i != 0][0]
        if A_list[0] ^ A_list[1] == non_zero:
            # 0と1の比率が1:2でないとだめ
            if A.count(0) * 2 == A.count(non_zero):
                # XORがA_listに入ってたら。
                print("Yes")
                exit()
            else:
                print('No')
                exit()
        else:
            print("No")
            exit()
    else:
        print('No')
        exit()
elif len(set_A) == 3:
    A_list = list(set_A)
    if A_list[0] ^ A_list[1] == A_list[2] and A_list[0] ^ A_list[2] == A_list[1] and A_list[1] ^ A_list[2] == A_list[0]:
        # それぞれの数が1:1:1でないとだめ
        if A.count(A_list[0]) == A.count(A_list[1]) == A.count(A_list[2]):
            print('Yes')
        else:
            print("No")
    else:
        print('No')

Submission status: Wrong Answer

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

if max(a) == 0:
    print('Yes')
    exit()

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

p = n // 3
if 0 in a:
    # a = sorted(a)
    zero = a.count(0)
    if zero != p:
        print('No')
        exit()
    if a.count(max(a)) != p * 2:
        print('No')
        exit()
    print('Yes')
    exit()

a = sorted(a)
if a[0] == a[p] or a[p] == a[-1] or a[-1] == a[0]:
    print('No')
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 = int(input().strip())
hat =  list(map(int,input().split()))

# listの1番目をx0として選ぶ
camel_order = []
camel_order.append([hat[0]])

#hatからx0を消す
hat = hat[1:n]

# 
for x in camel_order:
    if len(camel_order) == n:
        break
    if len(x) == 1:
        for h1 in hat:
            for h2 in hat:
                if h1 ^ h2 == x[0]:
                    camel_order.append([x[0], h1])
                    camel_order.append([x[0], h2])
                    hat.remove(h1)
                    hat.remove(h2)
                    break
    else:
        for h1 in hat:
            if x[1] ^ h1 == x[0]:
                camel_order.append([x[1], h1])
                hat.remove(h1)
                
if len(camel_order) == n:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import itertools

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

def q(line):
  flg = True
  for i in range(len(line)):
    max = i + 1
    min = i - 1
    if i + 1 > n - 1:
      max = 0
    elif i - 1 < 0:
      min = n - 1
    wa = line[min] ^ line[max]
    if line[i] != wa:
      flg = False
  return flg



for v in itertools.permutations(line,n):
  flg = q(list(v))
  if flg:
    print('Yes')

print('No')

Submission status: Wrong Answer

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

flag = 0
if len(As) == 1:
    if As[0] == 0:
        flag = 1
elif len(As) == 2:
    d = {}
    for a in A:
        if a in d.keys():
            d[a] += 1
        else:
            d[a] = 1
    if As[0] == 0 and list(set(bin(As[1])[2:]))[0] == 1 and d[As[0]]*2 == d[As[1]]:
        flag = 1
else:
    if len(As) == 3:
        if As[0]^As[1] == As[2]:
            flag = 1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import copy
N = int(input())
a = [int(x) for x in input().split()]
removelist = [0]*N
for i in range(N):
    for k in range(i):
        A = copy.deepcopy(a)
        removelist[0] = A.pop(i)
        removelist[1] = A.pop(k)
        for j in range(2, N):
            if (removelist[j - 1] ^ removelist[j - 2]) in A:
                removelist[j] = removelist[j - 1] ^ removelist[j - 2]
                A.remove(removelist[j - 1] ^ removelist[j - 2])
            else:
                print("No")
                exit()
if removelist[N - 1] ^ removelist[1] != removelist[0]:
    print("No")
    exit()
else:
    print("Yes")

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-1:
      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:
# -*- coding: utf-8 -*-

N = int(input())
a = list(map(int, input().split()))
a = sorted(a)
tmp = [2**x for x in range(30)]
flag = True
cnt = 0
for x in a:
    if x in tmp:
        cnt += 1
        if cnt > 1:
            flag = False
            break

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

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

Submission status: Wrong Answer

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

if 0 in a:
    if len(set(a))==2:
        print("Yes")
    else:
        print("No")

else:
    if n%3 != 0:
        print("No")
    
    else:
        if len(set(a)) != 3 or a.count(list(set(a))[0]) != int(n/3) or a.count(list(set(a))[1]) != int(n/3) or a.count(list(set(a))[2]) != int(n/3):
            print("No")
    
        else:
            set_a = list(set(a))
            if set_a[0] == set_a[1]^set_a[2] and set_a[1] == set_a[2]^set_a[0] and set_a[2] == set_a[1]^set_a[0]:
                print("Yes")
            else:
                print("No")

Submission status: Wrong Answer

Solution code:
import itertools

n = int(input()) # The number of camel
a = [int(i) for i in input().split()] # Hat's number

combs = list(itertools.permutations([i for i in range(n)]))

check = True
for comb in combs:
    for i in range(len(comb)):
        if check and comb[i] == 0:
            idx = i
            pre = i - 1
            if pre < 0:
                pre = n - 1
            
            nex = idx + 1
            if n == nex:
                nex = 0

            if a[comb[idx]] != a[comb[pre]]^a[comb[nex]]:
                check = False
        else:
            break
    
    if not check:
        break

if check:
    print("yes")
else:
    print("no")

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'))
    # 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:
n = int(input())
list1 = list(map(int,input().split()))
list1.insert(0,list1[n-1])
list1.append(list1[1])
flag = 0
for i in range(n):
  if list1[i]^list1[i+2] != list1[i+1]:
    flag = 1
    break;
if flag != 1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter

N= int(input())

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

x = Counter(a)

ok = False
if len(x) == 3 and len(a) % 3 == 0:
    for i in a:
        if x[i] != len(a) // 3:
            break
    else:
        w = 0
        for j in x:
            w ^= j
        if w == 0:
            ok = True
elif len(x) == 1:
    if x.get(0) is not None:
        ok = True

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

Submission status: Wrong Answer

Solution code:
size = int(input())
nums = list(map(int, input().split()))

numu = list(set(nums))
if size != 3:
  print("No")
  quit()

num = nums.count(numu[0])
if nums.count(nums[1]) != num or nums.count(nums[2]) != num:
  print("No")
  quit()

if numu[0] ^ numu[2] == numu[1] \
    and numu[1] ^ numu[0] == numu[2] \
    and numu[2] ^ numu[1] == numu[0]:
  print("Yes")
  quit()

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:
    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"

print(ans)

Submission status: Wrong Answer

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

#a_b = []
dic = {}
m = 0
for i in range(len(a)):
    if a[i] in dic.keys():
        dic[a[i]] += 1
    else:
        dic[a[i]] = 1

ls = list(dic.keys())

if len(ls) <= 2 and 0 in ls:
    ls.sort()
    if len(ls) == 2:
        if 2 * dic[ls[0]] == dic[ls[1]]:
            print("Yes")
        else:
            print("No")
    else:
        print("Yes")
elif len(ls) == 3:
    ls.sort()
    if  dic[ls[0]] == dic[ls[1]] and dic[ls[0]] == dic[ls[2]]:
        if list(ls)[0] ^ list(ls)[1] == list(ls)[2]:
            print("Yes")
        else:
            print("No")
else:
    print("No")

"""
for i in a:
    if i == max(a):
        m = i
    #print(bin(i))
for i in a:
    a_b.append(bin(i)[:2]+'0'*(len(bin(m))-len(bin(i)))+bin(i)[2:])

#for i in range(len(a_b)):
#    print(a_b[i])


a = int("0b" + "0" * (len(bin(m))-2),2)

for i in range(len(a_b)):
    a = a ^ int(a_b[i],2)
if a == 0:
    print("Yes")
else:
    print("No")
"""

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np
from operator import itemgetter

N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]

ans = "Yes"
L = []
for a in A:
    if a in L:
        continue

    if len(L)>=3:
        ans = "No"
        break
    L.append(a)
if len(L)==3:
    l1, l2, l3 = L
    if N%3!=0:
        ans="No"
    while ans=="Yes":
        sumL = l1%2 + l2%2 + l3%2
        if sumL!=0 and sumL!=2:
            ans = "No"
            break
        l1 = l1//2
        l2 = l2//2
        l3 = l3//2
        if l1+l2+l3==0:
            break
    print(ans)
elif len(L)==2:
    if N%3!=0:
        ans="No"
    if L[0]!=0 and L[1]!=0:
        ans="No"
    print(ans)
else:
    if sum(L)!=0:
        ans="No"
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

aArr.sort()
a = aArr[-1]
b = sum(aArr[:-1])

ans = ["No", "Yes"][a == b]
print(ans)

Submission status: Wrong Answer

Solution code:
from copy import copy

n=int(input())
s=list(map(int,input().split()))
a=bin(s[0]^s[1])

ans0=s[0]
ans1=s[0]
del s[0]
i=0
j=0
p=0
while i<len(s):
    if p==0:
        ans2=s[i]

    while j<len(s):
        if i!=j:
            #print(s)
            if s!=[]:
                if bin(ans1^ans2)==bin(s[j]):
                    ans1=ans2
                    ans2=s[j]
                    #print(ans1,ans2)
                    del s[j]
                    if p==0:
                        del s[i]
                        p=1
        j+=1
    i+=1
    j=0


if s==[]:
    print("yes")
else:
    print("no")

Submission status: Wrong Answer

Solution code:
import collections



def XORC(a,b,p):
    for i in range(len(a)):
        if (int(a[i])+int(b[i]))%2 == int(p[i]):
            continue
        else:
            return False
        
    return True
            
def Solve():
    N=int(input())
    AL=[("0"*31+bin(int(x))[2:])[-30:] for x in input().split()]

    ALC=collections.Counter(AL)

    keys=list(ALC.keys())
    vals=list(ALC.values())
    if len(keys)>3:
        return 'No'
    if len(keys)==1:
        if "1" in keys[0]:
            return 'No'
        return 'Yes'
    
    if len(keys)==2:
        if "1" in keys[0] and "1" in keys[1]:
            return 'No'
        
        if vals[0]==vals[1]*2 and "1" not in keys[0]:
            return 'Yes'
        
        if vals[0]*2==vals[1] and "1" not in keys[1]:
            return 'Yes'
        
        return 'No'
    if len(keys)==3:
        if vals[0]==vals[1]==vals[2]:
            if XORC(keys[0],keys[1],keys[2]) and XORC(keys[0],keys[2],keys[1]) and XORC(keys[1],keys[2],keys[0]):
                return 'Yes'
        
        return 'No'
print(Solve())

Submission status: Wrong Answer

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

is_yes = False

a_n_unique = list(set(a_n))

if len(a_n_unique) == 1:
    if a_n_unique[0] == 0:
        is_yes = True

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


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

Submission status: Wrong Answer

Solution code:
N = input()
ai = [int(x) for x in input().split()]
bi = sum([int(bin(x)[2:]) for x in ai])
if list(set(str(bi)))[0] == "2":
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N, *a = map(int, open(0).read().split())

a.sort()
for i in reversed(range(N)):
    if a[i] > a[i - 1] + a[(i + 1) % N]:
        a[i], a[i - 1] = a[i - 1], a[i]
    else:
        break
        
if all(a[i] == a[i - 1]^a[(i + 1) % N] for i in range(N)):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split())) 
A.sort()
ONE=0
TWO=0
THREE=0
AA=A[0]
BB=A[N//3]
CC=A[(N*2)//3]
AAA=bin(AA)
BBB=bin(BB)
CCC=bin(CC)
X=bin(AA^BB)
Y=bin(BB^CC)
Z=bin(CC^AA)
if X==CCC and Y==AAA and Z==BBB:
    if N%3==0:
        for x in range(0,N):
            if AA==A[x]:
                ONE=ONE+1
            if BB==A[x]:
                TWO=TWO+1
            if CC==A[x]:
                THREE=THREE+1
        if ONE==TWO and TWO==THREE and THREE==N//3:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

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

cnt = [1, 1, 1]
ind = 0
if n % 3 != 0:
    print('No')
else:
    a.sort()
    for i in range(n - 1):
        if a[i] == a[i + 1]:
            cnt[ind] += 1
        else:
            ind += 1
            if ind > 2:
                break
    if (ind == 2) and (cnt[0] == n // 3) and (cnt[1] == n // 3) and (cnt[2] == n // 3):
        print('Yes')
    else:
        print('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) == 1):
    print("Yes")
  elif(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())
a = list(map(int, input().split()))

import collections
c = collections.Counter(a)
unique = list(set(a))

from operator import xor
v = []
for k in c.keys():
    v.append(c[k])
v.sort()

flag = False
if n % 3 == 0:
    if len(v) == 1:
        if v == [n]:
            flag = True
    elif len(v) == 2:
        if v == [n // 3, n // 3 * 2]:
            if c[unique[0]] == n // 3:
                if xor(unique[1], unique[0]) == unique[1] and xor(unique[1], unique[1]) == unique[0]:
                    flag = True
            else:
                if xor(unique[0], unique[1]) == unique[0] and xor(unique[0], unique[0]) == unique[1]:
                    flag = True
    elif len(v) == 3:
        if v == [n // 3, n // 3, n // 3]:
            if xor(unique[0], unique[1]) == unique[2] and xor(unique[1], unique[2]) == unique[0] and xor(unique[2], unique[0]) == unique[1]:
                flag = True
else:
    if v == [n]:
        flag = True

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

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
	
	
judge = True

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
		if judge:
			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:
def xor(n1, n2):
  if n2=="0":
    return n1
  elif n2=="1":
    if n1=="1":
      return "0"
    else:
      return "1"
      
def bitxor(n1, n2):

  bn1 = bin(n1)[2:]
  bn2 = bin(n2)[2:]
  if n1<n2:
    bn1 = bn1.zfill(len(bn2))
  else:
    bn2 = bn2.zfill(len(bn1))
    
  n3 = [xor(b1,b2) for b1,b2 in zip(bn1, bn2)]
  n3 = "".join(n3)
  return int(n3, 2)


n = int(input())
a = list(set([int(x) for x in input().split()]))
l = len(a)

if l==3 and (a[2]== bitxor(a[0], a[1])):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
def doMaths(one, two):
    i = max(len(one), len(two))
    ans = ""
    while i -1>= 0:
        if len(one) < i:
            i -= 1 
            ans += two[i -1]
            continue
        if len(two) < i:
            i -= 1
            ans += one[i -1]
            continue
        ans += str((int(one[i -1]) + int(two[i -1]))%2)
        i -= 1
    return ans

n = int(input())
hats = input()
hatnums = hats.split(" ")
hatnums2 = []
for hat in hatnums:
    hatnums2.append(bin(int(hat))[2:])
for hatnum in hatnums2:
    for hatnum2 in hatnums2:
        if hatnum2 != hatnum:
            if not doMaths(hatnum, hatnum2) in hatnums2:
                print('No')
                exit()
print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ok = False
if 0 not in A:
    c = Counter(A)
    k = c.keys()
    s = len(c.keys())
    if len(k) == 3:
        ok = len(Counter(c.values()).keys()) == 1
    elif len(k) == 2:
        ok = (min(c.values()) * 2 == max(c.values()) or
              min(c.values()) == max(c.values()))
    elif len(k) == 1:
        ok = True
else:
    counts = Counter(A)
    keys = counts.keys()
    zero = counts[0]
    del counts[0]
    if len(keys) >= 4:
        ok = False
    else:
        for k in keys:
            cnt = counts.copy()
            cnt[k] -= zero
            if len(keys) == 3:
                ok = len(Counter(cnt.values()).keys()) == 1
            elif len(keys) == 2:
                ok = (min(cnt.values()) * 2 == max(cnt.values()) or
                      min(cnt.values()) == max(cnt.values()))
            elif len(keys) == 1:
                ok = True
            if ok:
                break

# else:
#     c = dict(Counter(A))
#     s = len(c.keys())
#     ck = c.keys()
#     if len(c.keys()) > 4:
#         ok = False
#     else:
#         for k in c.keys():
#             if k == 0:
#                 continue
#             cc = c.copy()
#             cc[k] -= c[0]
#             if len(ck) == 4:
#                 ok = len(Counter(c.values()).keys()) == 1
#             elif len(ck) == 3:
#                 ok = (min(c.values()) * 2 == max(c.values()) or
#                       min(c.values()) == max(c.values()))
#             elif len(ck) == 2:
#                 ok = True
#             if ok:
#                 break
if ok:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
a.sort()
count = 0
for i in range(len(a)):
    if i == 0:
        left = -1
        right = i + 1
    elif i == len(a) - 1:
        left = i - 1
        right = 0
    else:
        left = i - 1
        right = i + 1

    number = bin(a[left] ^ a[right])
    if bin(a[i]) != number:
        print('No')
        break
    else:
        count += 1

if count == len(a):
    print('Yes')

Submission status: Wrong Answer

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

for n in range(N):
  my_nm = A[n]
  if n == N-1:
    total_neighbor_nm = A[N-2] ^ A[0]
  else:
    total_neighbor_nm = A[n-1] ^ A[n+1]
  
  if my_nm != total_neighbor_nm:
    print("No")
    break
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
arr=[]
for i in range(0,N+1):
    LF=(i-1)%N if (i-1) > (N-1) else (i-1)
    RI=(i+1)%N if (i+1) > (N-1) else (i+1)
    MI=i%N if i > (N-1) else i
    aaa = str(int(bin(A[LF]).split("b")[1])+int(bin(A[RI]).split("b")[1]))
    bbb = "".join(list(map(lambda x:str(int(x)%2),aaa)))
    arr.append(int(bbb)==int(bin(A[MI]).split("b")[1]))

print("Yes" if all(arr[1:N+1]) else "No")

Submission status: Wrong Answer

Solution code:
a = int(input())
x = list(map(int,input().split()))
ax = list(set(x))
def Y(a,t = 0):
    if a==t : print('YES')
    else : print('NO')
def y(a, t =0):
    if a==t : print('Yes')
    else : print('No')
if len(ax) < 3:
    if (sum(x) == 0) :
        print("Yes")
        exit()
    print("No")
    exit()
t = (len(x) == x.count(ax[0]) + x.count(ax[1]) + x.count(ax[2])) * (x.count(ax[1]) == x.count(ax[0]) and x.count(ax[0]) == x.count(ax[2]))

y(1,t)

Submission status: Wrong Answer

Solution code:
def acinput():
    return list(map(int,input().split(" ")))

N=int(input())
a=sorted(acinput())
#a.extend(a[:2])

res="Yes"
for i in range(N):
    if a[i]!=a[i-1]^a[(i+1)%N]:
        #print(a[i],a[i-1],a[i+1])
        #print(i)
        res="No"
        break

print(res)

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")
elif len(seta) == 1 and seta[0] == 0:
  print("Yes")
else:
  print("No")