Problem:


Score : 300 points

Problem Statement

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

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

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

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

What is XOR?

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

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

For example, 3 \oplus 5 = 6.

Constraints

All values in input are integers.

3 \leq N \leq 10^{5}

0 \leq a_i \leq 10^{9}

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 \ldots a_{N}

Output

Print the answer.

Sample Input 1

3
1 2 3

Sample Output 1

Yes

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

Sample Input 2

4
1 2 4 8

Sample Output 2

No

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



Sample input:
3
1 2 3


Sample output:
Yes

Submission status: Runtime Error

Solution code:
n = int(input())
A = list(map(int, input().split()))
A.sort()
B = list(set(A))
if len(B) >= 4:
  print('No')
else:
  if B[-1] == 0:
    print('Yes')
  elif A.count(0) == n/3 and len(B) == 2:
    print('Yes')
  elif B[0]^B[1]^B[2] == 0 and A.count(B[0]) == A.count(B[1]) == n/3:
    print('Yes')
  else:
    print('No')

Submission status: Runtime Error

Solution code:
N=int(input())
A=[int(x) for x in int(input().split())]
if N == 3:
  A.sort()
  if A[0]^A[1] == A[2]:
    print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
n=int(input())
arr=list(map(int,input().split()))
f=True
arr.append(arr[0])
arr.append(arr[1])
arr.append(arr[2])

for ii in range(n):
  if(arr[i]^arr[i+1]==arr[i+2]):
    continue
  else:
    f=False
    break
if f:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!

N=int(input())

l=list(map(int,input().split()))
l.sort()

init=l.pop(-1)

left=init
center=0

ans=[left]

def find(left):
    if len(l)==1:
        ans.append(l.pop(0))
        pass
    elif len(l)==0:
        pass
        
    else:
        right=l.pop(-1)
        for i in range(len(l)):
            if l[i]==left^right:
                center=l.pop(i)
                ans.append(center)
                ans.append(right)
                find(right)
                break
            else:
                break
            
find(left)

if len(ans)==N:
    if ans[0]==ans[1]^ans[-1] and ans[-1]==ans[0]^ans[1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!

N=int(input())

l=list(map(int,input().split()))
l.sort()

init=l.pop(-1)

left=init
center=0
judge=False

ans=[left]

def find(left):
    if len(l)<2:
        if len(l)==1:
            ans.append(l.pop(0))
        else:
            pass
        
    else:
        right=l.pop(-1)
        for i in range(len(l)):
            if l[i]==left^right:
                center=l.pop(i)
                ans.append(center)
                ans.append(right)
                find(right)
            else:
                break
            
find(left)

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

Submission status: Runtime Error

Solution code:
import collections
n=int(input())
if n%3!=0:print("No");exit()
l=list(map(int,input().split()))
c=collections.Counter(l)
mc=c.most_common()
if mc[0][1]==mc[1][1]==mc[2][1]==n//3:
    a,b,c=mc[0][0],mc[1][0],mc[2][0]
else:print("No");exit()
if a^b==c and b^c==a and c^a==b:
    print("Yes")
else:print("No")

Submission status: Runtime Error

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

A_sorted = sorted(A)
A_set = list(set(A))
A_cnt = dict()
for a in A:
    if not a in A_cnt.keys():
        A_cnt[a] = 1
    else:
        A_cnt[a] += 1

if A_cnt.get(0) == N:
    print("Yes")
    exit()

if len(A_set) > 3 or N%3 != 0:
    print("No")
    exit()

B = []
B.append(A_set[0])
B.append(A_set[1])
for _ in range(N-2):
    B.append(B[-1] ^ B[-2])

B_sorted = sorted(B)
if A_sorted == B_sorted:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

if len(aset) == 1:
  if all(i == 0 for i in a):
    print("Yes")
  else:
    print("No")
elif len(aset) == 2:
  a1, a2 = sorted(aset)
  if a1 == 0:
    if a.count(a1) * 3 == N:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
elif len(aset) == 3:
  a1, a2, a3 = aset
  if a.count(a1) == a.count(a2) == a.count(a3):
    if a1 ^ a2 == a3:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  print("No")

Submission status: Runtime Error

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

if len(aset) == 1:
  if all(i == 0 for i in a):
    print("Yes")
  else:
    print("No")
elif len(aset) == 2:
  a1, a2 = sorted(aset):
  if a1 == 0:
    if a.count(a1) * 3 == N:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
elif len(aset) == 3:
  a1, a2, a3 = aset
  if a.count(a1) == a.count(a2) == a.count(a3):
    if a1 ^ a2 = a3:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  print("No")

Submission status: Runtime Error

Solution code:
n = int(input())
li = list(map(int, input().split()))
for i in range(1, n - 1):
    a = bin(li[i - 1])[2:]
    b = bin(li[i])[2:]
    c = bin(li[i + 1])[2:]
    if len(a) > len(b) and len(a) > len(c):
        b = b.zfill(len(a))
        c = c.zfill(len(a))
    elif len(b) > len(a) and len(b) > len(c):
        a = a.zfill(len(b))
        c = c.zfill(len(b))
    else:
        a = a.zfill(len(c))
        b = b.zfill(len(c))
    for j in range(len(a)):
        if a[j] == c[j]:
            if b[j] != '0':
                print('No')
                exit()
        else:
            if b[j] != '1':
                print('No')
                exit()
print('Yes')

Submission status: Runtime Error

Solution code:
n = int(input())
li = list(map(int, input().split()))
for i in range(1, n - 1):
    a = bin(li[i - 1])[2:]
    b = bin(li[i])[2:]
    c = bin(li[i + 1])[2:]
    if len(a) > len(b) and len(a) > len(c):
        b = b.zfill(len(a))
        c = c.zfill(len(a))
    elif len(b) > len(a) and len(b) > len(c):
        a = a.zfill(len(b))
        c = c.zfill(len(b))
    else:
        a = a.zfill(len(c))
        b = b.zfill(len(c))
    for j in range(len(a)):
        print(a[j], c[j], b[j])
        if a[j] == c[j]:
            if b[j] != '0':
                print('No')
                exit()
        else:
            if b[j] != '1':
                print('No')
                exit()
print('Yes')

Submission status: Runtime Error

Solution code:
def exc_or(int1, int2):
  exc_or = bin(int1^int2)
  return int(exc_or, 2)

def is_same(start_index_excor, alist, exc_ors):
  for i in range(0, N):
    if alist[i] != exc_ors[start_index_excor+i]:
      return False
  return True

def is_same_reverse(start_index_excor, alist, exc_ors):
  for i in range(0, N):
    if alist[i] != exc_ors[start_index_excor-i]:
      return False
  return True

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

exc_ors = []
for i in range(N-1, -1, -1):
  exc_ors.append(exc_or(alist[i-1], alist[i]))

start_index_excors = [index for index, exc_or in enumerate(exc_ors) if exc_or == alist[0]]
if len(start_index_excors) == 0:
  print("No")
  exit()
else:
  for start_index_excor in start_index_excors:
    if is_same(start_index_excor, alist, exc_ors) is True or is_same_reverse(start_index_excor, alist, exc_ors) is True:
      print("Yes")
      exit()
    else:
      pass
  print("No")

Submission status: Runtime Error

Solution code:
from collections import Counter

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

flag="No"

count_by_kw = Counter()
for i in range(n):
    count_by_kw[a[i]]+=1

if count_by_kw.get(0) == n:
    flag="Yes"

if count_by_kw.get(0) == n/3 and len(count_by_kw.keys())==2:
    flag="Yes"

cl=list(count_by_kw.values())
ck=list(count_by_kw.values())

if len(cl)==3:
    if cl[0] == cl[1] and cl[1] == cl[2]:
        if ck[0]^ck[1]^ck[2]^ == 0
            flag="Yes"
        
print(flag)

Submission status: Runtime Error

Solution code:
n=int(input())
a=[int(x) for x in input().split()]
b=0
for i in a:
  b=b^a
if b==0:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
A = list(set(a))
A.sort()
if len(A) == 1:
    if A[0] == 0:
        ans = "Yes"
elif len(A) == 2:
    if A[0] == 0:
        if a.count(A[1]) == 2* (n // 3) :
            ans = "Yes"
elif len(A) == 3:
    if A[0]^A[1]^A[2] == 0:
        if a.count(A[0]) == n//3:
            if a.count(A[1]) == n//3:
                if a.count(A[2]) == n//3:
                    ans = "Yes"
else:
    ans = "No"

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
A = list(set(a))
A.sort()
if A == [0]:
    ans = "Yes"
elif len(A) == 2:
    if A[0] == 0:
        if a.count(A[1]) == 2* (n // 3) :
            ans = "Yes"
elif len(A) == 3:
    if A[0]^A[1]^A[2] == 0:
        if a.count(A[0]) == n//3:
            if a.count(A[1]) == n//3:
                if a.count(A[2]) == n//3:
                    ans = "Yes"
else:
    ans = "No"

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
A = list(set(a))
if A == (0):
    ans = "Yes"
elif len(A) == 2 and 0 in A:
    if a.count(A[1]) == (2*n // 3) :
        ans = "Yes"
elif len(A) == 3:
    if A[0]^A[1]^A[2] == 0:
        if a.count(A[0]) == n//3:
            if a.count(A[1]) == n//3:
                if a.count(A[2]) == n//3:
                    ans = "Yes"
else:
    ans = "No"

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
A = set(a)
if A == (0):
    ans = "Yes"
elif len(A) == 2 and 0 in A:
    b = list(A)
    if a.count(b[1]) == (2*n // 3) :
        ans = "Yes"
elif len(A) == 3:
    b = list(A)
    if b[0]^b[1]^b[2] == 0:
        if a.count(b[0]) == n//3:
            if a.count(b[1]) == n//3:
                if a.count(b[2]) == n//3:
                    ans = "Yes"
else:
    ans = "No"

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
A = set(a)
if A == (0):
    ans = "Yes"
elif len(A) == 2 and 0 in A:
    b = list(A)
    if a.count(b[1]) == (2*n // 3) :
        ans = "Yes"
elif len(A) == 3:
    b = list(A)
    if b[0]^b[1]^b[2] == 0:
        if a.count(b[0]) == n//3 and a.count(b[1]) == n//3 and a.count(b[2]) == n//3:
            ans = "Yes"
else:
    ans = "No"

print(ans)

Submission status: Runtime Error

Solution code:
import itertools
from unittest.mock import patch

def saiki(a,B):
    if len(B) > 0:
        for i in B:
            if a[2] == a[1] ^ i:
                a[1] = a[2]
                a[2] = i
                B.remove(i)
                saiki(a,B)

def check():
    N = int(input())
    A = [int(i) for i in input().split()]

    for a in itertools.permutations(A, 3):
        B = set(A)
        if a[1] == a[0] ^ a[2]:
            for i in a:
                B.remove(i)
            saiki(a,B)
            if len(B) == 0:
                if a[2] == a[1] ^ a[0]:
                    return "Yes"
    return "No"
print(check())

Submission status: Runtime Error

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


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

c = collections.Counter(A)

for v in c.values():
    if v % (N//3) != 0:
        print('No')
        exit()


if len(c) == 1 and c.most_common()[0][0] == 0:
    print('Yes')
    exit()
elif len(c) == 2 and c.most_common()[1][0] == 0 and c.most_common()[0][0] ^ 0 == c.most_common[0]:
    print('Yes')
    exit()
elif len(c) == 3 and \
        (c.most_common()[0][0] ^ c.most_common()[1][0] ^ c.most_common()[2][0]) == 0:
    print('Yes')
    exit()


else:
    print('No')
    exit()

Submission status: Runtime Error

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


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

c = collections.Counter(A)
# print(len(c))
# print(c.most_common()[0][0] ^ c.most_common()[1][0] ^ c.most_common()[2][0])

for v in c.values():
    # print(v)
    if v % (N//3) != 0:
        print('No')
        exit()


if len(c) == 1 and c.most_common[0] == 0:
    print('Yes')
    exit()
elif len(c) == 2 and c.most_common()[1][0] == 0 and c.most_common()[0][0] ^ 0 == c.most_common[0]:
    print('Yes')
    exit()
elif len(c) == 3 and \
        (c.most_common()[0][0] ^ c.most_common()[1][0] ^ c.most_common()[2][0]) == 0:
    print('Yes')
    exit()


else:
    print('No')
    exit()

Submission status: Runtime Error

Solution code:
N = int(input())
A = input().split()
for i in range(N):
  A[i] = int(A[i])
  
A_unique = list(set(A))
A_digit = [[],[],[]]
if A == [0] * N:
  ans = 'Yes'
elif len(A) %3 != 0:
  ans ='No'
elif len(A_unique) == 1:
  ans = 'No'
elif len(A_unique) == 2:
  if min(A_unique) ==0 and A.count(0) == N/3:
    ans = 'Yes'
else:
  for j in range(3):
    A_unique[j] = format(A_unique[j], '08b').zfill(30)
    s = str(A_unique[j])
    A_digit[j]  = list(map(int, s))
  for k in range(30):
    key = A_digit[0][k] + A_digit[1][k] + A_digit[2][k] 
    if key == 0 or key == 2:
      ans = 'Yes'
    else:
      ans = 'No'
      break

print(ans)

Submission status: Runtime Error

Solution code:
n, m = list(map(int, input().split()))
AB = [[int(x) for x in input().split()] for _ in range(m)]

# representation matrix
repn = [[] for j in range(n)]
for a, b in AB:
    a -= 1
    b -= 1
    repn[a].append(b)
    repn[b].append(a)


# Minimum Spanning Tree
tree = [[] for i in range(n)]
visited = [True] + [False] * (n - 1)
q = [0]

while q:
    u = q.pop()
    for v in repn[u]:
        if visited[v]:
            continue
        visited[v] = True
        tree[u].append(v)
        tree[v].append(u)
        q.append(v)


# define directions of the edges other than that of MST
degree = [0] * n
ans = []

for a, b in AB:
    a -= 1
    b -= 1
    if b in tree[a]:
        continue
    ans.append('{} {}'.format(a + 1, b + 1))
    degree[a] += 1


# defining orientations
def dfs(u = 0, parent = None):
    for v in tree[u]:
        if v == parent:
            continue
        dfs(v, u)
        if degree[v] % 2 == 0:
            ans.append('{} {}'.format(u + 1, v + 1))
            degree[u] += 1
        else:
            ans.append('{} {}'.format(v + 1, u + 1))
            degree[v] += 1

dfs()


# output answer
if degree[0] % 2 == 1:
    print(-1)
else:
    print('\n'.join(ans))

Submission status: Runtime Error

Solution code:
import itertools
input = sys.stdin.readline
 
def main():
  n = int(input())
  numList = []
  numList = list(map(int,input().split()))

  result = 'No'
  flag = True
  count = 0

  for wList in set(itertools.permutations(numList, n)):
    for v in set(itertools.permutations(wList, 3)):
      xor = int(v[0]) ^ int(v[2])
      if xor != v[1]:
        flag = False
        break

    if flag:
      count +=1
      break

    flag = True

  if count > 0:
    result = 'Yes'

  print(result)
  
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
keta_max = 30
def decimal_to_binary(number):
    ans = ""
    for i in range(keta_max):
        ans += str(number // 2**(keta_max - 1 - i))
        number = number % 2**(keta_max - 1 - i)
    return ans

def distance(left, right):
    ans = 0
    for i in range(keta_max):
        if(abs(int(left[i]) - int(right[i]))):
            ans += 2**(keta_max - 1 - i)
    return ans

def step(index, not_used_hat_set, current_hat_list):
    for j in range(N):
        if(distance(bynary_list[current_hat_list[index-1]], bynary_list[j])):
            current_hat_list[index] = j
            if(index == N - 1):
                return True
            else:
                step(index + 1, not_used_hat_set - set([j]), current_hat_list)
    return False

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

bynary_list = [decimal_to_binary(i) for i in a_list]
for n in range(N):
    hat = [0 for m in range(N)]
    not_used_hat_set = set([m for m in range(N)])
    hat[0] = n
    hat[1] = (n+1)%N
    ans = step(2, not_used_hat_set, hat)
if(ans == True):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = sorted(set(A))
if N % 3 == 0:
    if len(B) == 1 and B[0] == 0:
        print('Yes')
        exit()
    if len(B) == 2 and A.count(0) == N // 3 and A.count(B[1]) == 2 * N // 3:
        if B[0] ^ B[1] ^ B[2] == 0:
            print('Yes')
            exit()
    if len(B) == 3 and A.count(B[0]) == A.count(B[1]) == A.count(B[2]):
        print('Yes')
        exit()

print('No')

Submission status: Runtime Error

Solution code:
import sys
n = int(input())
a = list(map(int, input().split()))
a = bin(a)
for i in range(n):
    if i==0:
        if a[n-1]^a[1] != a[0]:
            print("No")
            sys.exit()
    elif 0 < i < n-1:
        if a[i-1]^a[i+1] != a[i]:
            print("No")
            sys.exit()
    elif i == n-1:
        if a[n-2]^a[0] != a[n-1]:
            print("No")
            sys.exit()
print("Yes")

Submission status: Runtime Error

Solution code:
from sys import*
n = int(input())
a = list(map, input().split())
a = sorted(a)
for i in range(n):
  if a[i] != i + 1:
    print("No")
    exit(0)
print("Yes")

Submission status: Runtime Error

Solution code:

n = map(int, raw_input().split())
n = n[0]
a = map(int, raw_input().split())


all_zero = True
for number in a:
	if number != 0:
		all_zero = False
		break

if all_zero:
	print 'Yes'
	return

a_dict = {}
for number in a:
	if number in a_dict.keys(): 
		a_dict[number] += 1
	else:
		a_dict[number] = 1

if len(a_dict.keys()) > 3:
	print 'No'
	return

if len(a_dict.keys()) == 3:
	result = True
	for keys in a_dict.keys():
		if not a_dict[keys] == n // 3:
			result = False
			break
	if result:
		print 'Yes'


if len(a_dict.keys()) == 2:
	if not '0' in a_dict.keys():
		print 'No'
		break
	for keys in a_dict.keys():
		if keys == 0:
			if not a_dict[keys] == n // 3:
				print 'No'
				return
		else: 
			if not a_dict[keys] == 2 * n // 3:
				print 'No'
				return
print 'Yes'

Submission status: Runtime Error

Solution code:
n = int(input())
A = list(map(int,input().split()))
l = [[0,0],[0,0],[0,0]]
flag = 0
for i in range(n):
  x = A[i]
  for j in range(3):
    if l[j] == [0,0]:
      l[j] = [x,1]
      break
    if x == l[j][0]:
      l[j][1] += 1
      break
  else:
    break
a = l[0][1]
b = l[1][1]
c = l[2][1]
aa = l[0][0]
bb = l[1][0]
cc = l[2][0]
if n % 3 == 0:
  m = n // 3
  if a == m:
    if b == m and c == m:
      if aa ^ bb ^ cc == 0:
        flag = 1
  if a == 2 * m and b == m:
    if bb == 0:
      flag = 1
  if a == m and b == 2 * m:
    if aa == 0:
      flag = 1
else:
  if a == n and aa == 0:
    flag = 1
if c == 0:
  if a == m or b == m:
    print('Yes')
else:
  ?

Submission status: Runtime Error

Solution code:
n = int(input())
A = list(map(int,input().split()))
l = [[0,0],[0,0],[0,0]]
flag = 0
for i in range(n):
  x = A[i]
  for j in range(3):
    if l[j] == [0,0]:
      l[j] = [x,1]
      break
    if x == l[j][0]:
      l[j][1] += 1
      break
  else:
    break
a = l[0][1]
b = l[1][1]
c = l[2][1]
aa = l[0][0]
bb = l[1][0]
cc = l[2][0]
if n % 3 == 0:
  m = n // 3
  if a == m:
    if b == m and c == m:
      if aa ^ bb ^ cc == 0:
        flag = 1
  if a == 2 * m and b == m:
    if bb == 0:
      flag = 1
  if a == m and b == 2 * m:
    if aa == 0:
      flag = 1
else:
  if a == n and aa == 0:
    flag = 1
if a == m:
  print('Yes')

Submission status: Runtime Error

Solution code:
n = int(input())
A = list(map(int,input().split()))
l = [[0,0],[0,0],[0,0]]
flag = 0
for i in range(n):
  x = A[i]
  for j in range(3):
    if l[j] == [0,0]:
      l[j] = [x,1]
      break
    if x == l[j][0]:
      l[j][1] += 1
      break
  else:
    break
a = l[0][1]
b = l[1][1]
c = l[2][1]
aa = l[0][0]
bb = l[1][0]
cc = l[2][0]
if n % 3 == 0:
  m = n // 3
  if a == m:
    if b == m and c == m:
      if aa ^ bb ^ cc == 0:
        flag = 1
  if a == 2 * m and b == m:
    if bb == 0:
      flag = 1
  if a == m and b == 2 * m:
    if aa == 0:
      flag = 1
else:
  if a == n and aa == 0:
    flag = 1
if a == m and b == 2 * m:
  print('Yes')

Submission status: Runtime Error

Solution code:
n = int(input())
A = list(map(int,input().split()))
l = [[0,0],[0,0],[0,0]]
flag = 0
for i in range(n):
  x = A[i]
  for j in range(3):
    if l[j] == [0,0]:
      l[j] = [x,1]
      break
    if x == l[j][0]:
      l[j][1] += 1
      break
  else:
    break
a = l[0][1]
b = l[1][1]
c = l[2][1]
aa = l[0][0]
bb = l[1][0]
cc = l[2][0]
if n % 3 == 0:
  m = n // 3
  if a == m:
    if b == m and c == m:
      if aa ^ bb ^ cc == 0:
        flag = 1
  if a == 2 * m and b == m:
    if bb == 0:
      flag = 1
  if a == m and b == 2 * m:
    if aa == 0:
      flag = 1
else:
  if a == n and aa == 0:
    flag = 1
if a == 2 * m:
  print('Yes')

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import collections
n = int(input())
a = [int(i) for i in input().split()]
b = collections.Counter(a)
ans = "No"
if (len(b) == 3):
    if (list(b.keys())[0] ^ list(b.keys())[1] ^ list(b.keys())[2]) == 0:
        if ((list(b.values())[0] == list(b.values())[1]) & (list(b.values())[0] == list(b.values())[2])):
            ans = "Yes"
        else:
            ans = "No"
    else:
        ans = "No"
elif (len(b) == 1):
    if list(k.keys())[0] == 0:
        ans = "Yes"
    else:
        ans = "No"
elif (len(b) == 2):
    if n % 3 == 0:
        dd = list(b.keys())
        dd.sort()
        if (dd[0] == 0) & ((b[0] * 2) == (b[1])):
            ans = "Yes"
        else:
            ans = "No"
    else:
        ans = "No"
else:
    ans = "No"
print(ans)

Submission status: Runtime Error

Solution code:
import collections
n = int(input())
a = [int(i) for i in input().split()]
b = collections.Counter(a)
ans = "No"
if (len(b) == 3):
    if (list(b.keys())[0] ^ list(b.keys())[1] ^ list(b.keys())[2]) == 0:
        if ((list(b.values())[0] == list(b.values())[1]) & (list(b.values())[0] == list(b.values())[2])):
            ans = "Yes"
elif (len(b) == 1):
    if list(k.keys())[0] == 0:
        ans = "Yes"
elif (len(b) == 2):
    if n % 3 == 0:
        dd = list(b.keys())
        dd.sort()
        if (dd[0] == 0) & ((b[0] * 2) == (b[1])):
            ans = "Yes"
print(ans)

Submission status: Runtime Error

Solution code:
import collections
n = int(input())
a = [int(i) for i in input().split()]
b = collections.Counter(a)
ans = "No"
if (len(b) == 3):
    if (list(b.keys())[0] ^ list(b.keys())[1] ^ list(b.keys())[2]) == 0:
        ans = "Yes"
elif (len(b) == 1):
    if list(k.keys())[0] == 0:
        ans = "Yes"
else:
    continue
print(ans)

Submission status: Runtime Error

Solution code:
import collections
n = int(input())
a = [int(i) for i in input().split()]
b = collections.Counter(a)
ans = "No"
if (len(b) == 3):
    if (list(b.keys())[0] ^ list(b.keys())[1] ^ list(b.keys())[2]) == 0:
        ans = "Yes"
elif (len(b) == 1):
    if list(k.keys())[0] == 0:
        ans = "Yes"
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
import sys

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

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

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

if(chk == 0):
   print('Yes')
else:
   print('No')

Submission status: Runtime Error

Solution code:
x,y,z,k = map(int,input().split())
Alist = list(map(int,input().split()))
Blist = list(map(int,input().split()))
Clist = list(map(int,input().split()))

Alist.sort(reverse=True)
Blist.sort(reverse=True)
Clist.sort(reverse=True)

ABlist = []
for i in Alist[:k]:
    for j in Blist[:k]:
        ABlist.append(i + j)

ABlist.sort(reverse=True)

ABClist = []
for i in ABlist[:k]:
    for j in Clist[:k]:
        ABClist.append(i + j)

ABClist.sort(reverse=True)

for i in range(k):
    print(ABClist[i])

Submission status: Runtime Error

Solution code:

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

a.sort()
import collections

count = collections.Counter(a)
modulo = (N%3)

L = len(count)

if modulo == 0:
    if L < 4:
        tmp = 0
        for i in count:
            tmp = tmp^i
        if tmp == 0:
            ans = 'Yes'
        else:
            ans = 'No'
    else:
        ans = 'No'
else :
    if L < 2:
        for i in count:
            tmp = tmp^i
        if tmp == 0:
            ans = 'Yes'
        else:
            ans = 'No'
    else:
        ans = 'No'
    
print(ans)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(100001)

n, m = map(int, input().split())
edges = [[] for _ in range(n)]
visited = [False] * n
for _ in range(m):
    a, b = map(int, input().split())
    la = len(edges[a - 1])
    lb = len(edges[b - 1])
    edges[a - 1].append([b - 1, lb])
    edges[b - 1].append([a - 1, la])

def dfs(p, v):
    visited[v] = True
    for (i, r) in edges[v]:
        if not visited[i] and r != -1 and i != p:
            dfs(v, i)
    odd = False
    pr = -1
    for (i, r) in edges[v]:
        if i != p:
            if r != -1:
                edges[i][r][1] = -1
                odd = not odd
        else:
            pr = r
    if odd:
        edges[p][pr][1] = -1

if m % 2 == 1:
    print(-1)
else:
    dfs(-1, 0)
    for v in range(n):
        for (i, r) in edges[v]:
            if r >= 0:
                print(v + 1, i + 1)

Submission status: Runtime Error

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

result=True
for i in range(N):
	l=i-1
	r=i+1
	if l<0:
		l=N-1
	if r==N:
		r=0
	
	x=a[r]^a[l]
	if a[i]!=x:
            result=False
            break
if break:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
from operator import xor

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

D = {}

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

if len(D) == 1 :
    if D.get(0, 0) == N :
        ans = "Yes"
    else :
        ans = "No"
elif len(D) == 2 :
    if D.get(0, 0) * 3 == N :
        ans = "Yes"
    else :
        ans = "No"
elif len(D) == 3 :
    K = list(D.keys())
    V = list(D.values())
    
    if (xor(K[0], K[1], K[2]) == 0) and (V[0] == V[1] == V[2]) :
        ans = "Yes"
    else :
        ans = "No"
else :
    ans = "No"

print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
al=list(map(int,input().split()))
s=set(al)
s=sorted(s)
if len(s)==1 and s[0]==0:
    print('Yes')
    exit()
if len(al)%3>0 or len(s)>3 or len(s)==1:
    print('No')
    exit()
if len(s)==2 and s[0]==0:
    if al.count(0)==n//3:
        print('Yes')
        exit()
if (s[0]^s[1]^s[2])==0:
    if al.count(s[0])==n//3 and al.count(s[1])==n//3:
        print('Yes')
        exit()
print('No')

Submission status: Runtime Error

Solution code:
from collections import Counter

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

C=Counter(A)

if len(C)%3==0:
	a,b,c=C.keys()
	if N%3==0:
		if a^b==c:
			print "Yes"
		else:
			print "No"
else:
	if len(C)==1:
		if C.keys()==[0]:
			print "Yes"
		else:
			print "No"
	else:
		print "No"

Submission status: Runtime Error

Solution code:
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var N = ReadInt();
            var A = ReadSplitLong();
            var set = new HashSet<long>();
            for (int i = 0; i < N; i++) set.Add(A[i]);
            var s = set.ToList();

            if (A.All(x => x == 0))
            {
                Println("Yes");
                return;
            }

            if (N % 3 != 0)
            {
                Println("No");
                return;
            }

            if ((s.Count == 2 && (s.Count(x => x == 0) == N / 2)) || (s.Count == 3 && (s[0] ^ s[1]) == s[2]))
            {
                Println("Yes");
                return;
            }

            Println("No");
        }


        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int,input().split()))
 
res = "No"
a_set = list(set(a))
 
a_set = [i for i in a_set if i != 0]
 
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"
if len(a_set) == 0:
    if a_set[0] == 0:
        res = "Yes"
print(res)