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()))
 
x = 0
y = 0
z = 0
 
if N % 3 != 0:
  print('No')
 
else:
 
  for i in range(N):
    if a[i] != x and a[i] != y and a[i] != z:
      if x == 0:
        x = a[i]
        continue
      elif y == 0:
        y = a[i]
        continue
      elif z == 0:
        z = a[i]
        continue
      else:
        print('No')
        sys.exit()
 
  if x ^ y == z:
    print('Yes')
  else:
    print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
 
N = int(input())
a = list(map(int, input().split()))
 
x = 0
y = 0
z = 0
 
if N % 3 != 0:
  print('No')
 
else:
 
  for i in range(N):
    if a[i] != x and a[i] != y and a[i] != z:
      if x == 0:
        x = a[i]
        continue
      elif y == 0:
        y = a[i]
        continue
      elif z == 0:
        z = a[i]
        continue
      else:
        print('No')
        sys.exit()
 
  if x != 0 and y != 0 and z != 0:
    print('Yes')
  else:
    print('No')
import sys

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

x = 0
y = 0
z = 0

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

else:

  for i in range(N):
    if a[i] != x and a[i] != y and a[i] != z:
      if x == 0:
        x = a[i]
        continue
      elif y == 0:
        y = a[i]
        continue
      elif z == 0:
        z = a[i]
        continue
      else:
        print('No')
        sys.exit()

  if x ^ y == z:
    print('Yes')
  else:
    print('No')
提出情報

Submission status: Runtime Error

Solution code:
N = int(input())
num_arr = sorted([int(i) for i in input().split()])
u_arr = list(set(num_arr))

if u_arr == [0]:
  print("Yes")
else:
  if N%3 != 0:
    print("No")
  else:
    if num_arr == u_arr*(N//3):
      print("Yes")
    else:
      print("No")

Submission status: Runtime Error

Solution code:
import numpy as np
N = input()
a = input().split()
a.extend(a)
for i in np.arange(int(N)):
    if (bin(int(a[i]) ^ int(a[i+2]))) == bin(int(a[i+1])):
        print(Yes)
    else:
        print(No)

Submission status: Runtime Error

Solution code:
num_hat = int(input())

numbers = [int(i) for i in input().split(' ')]
numbers.append(numbers[0])
numbers.append(numbers[1])

for i in range(1, num_hat+1+1):
    if numbers[i] != numbers[i-1] ^ numbers[i+1]:
        print("No")
        exit(0)

else:
    print("Yes")

exit(0)

Submission status: Runtime Error

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

#print(bin(a[N-1] ^ a[1]))
#print(bin(a[0]))

if bin(a[N-2] ^ a[0]) == bin(a[N-1]):
  if bin(a[N-1] ^ a[1]) == bin(a[0]):
    for i in range(0,N-3):
      #print(bin(a[N] ^ a[N+2]),bin(a[N+1]))
      if Flag:
        if bin(a[N] ^ a[N+2])!=bin(a[N+1]):
          Flag=False
          break  
    if Flag:
      print("Yes")
    else:
      print("No")
  else:
    print("No")    
else:
  print("No")

Submission status: Runtime Error

Solution code:
import math

N = int(input())

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

def xor(x1,x2):
    xdigit = math.ceil(math.log2(max(x1, x2)))
    num = 0
    for i in range(xdigit):
        dig_x1 = x1 // (2**(xdigit-i))
        dig_x2 = x2 // (2**(xdigit-i))
        
        if dig_x1 != dig_x2:
            num += 2**(xdigit-i)
            
        if dig_x1 == 1:
            x1 -= 2**(xdigit-i)
            
        if dig_x2 == 1:
            x2 -= 2**(xdigit-i)
    return num

is_exist = 0

for camel in range(N):
    if camel == N-1:
        furt = 0
    else:
        furt = camel + 1
        
    if camel == 0:
        prev = N-1
    else:
        prev = camel -1
         
    num_xor = xor(nums[prev], nums[furt])
    if num_xor != nums[camel]:
        is_exist += 1
        break


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

Submission status: Runtime Error

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


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 dic[ls[0]] == 2 * dic[ls[1]]:
        print("Yes")
    else:
        print("No")
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")

Submission status: Runtime Error

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')
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])) + (sum(x) == 0)

y(1,t)

Submission status: Runtime Error

Solution code:
// finish date: 2019/06/30

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    int N;
    cin >> N;
    vi a(N);
    rep(i, N) cin >> a[i];

    map<int, int> check_is2;
    rep(i, N) check_is2[a[i]]++;
    if (check_is2.size() == 1) {
        if (a[0] == 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        return 0;
    }

    if (check_is2.size() == 2) {
        if (N % 3 == 0 && check_is2[0] == N / 3) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        return 0;
    }

    if (check_is2.size() == 3) {
        vi val(3);
        int i = 0;
        for (auto e:check_is2) {
            val[i] = e.first;
            i++;
        }
        if ((val[0] ^ val[1]) == val[2]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        return 0;
    }


    cout << "No" << endl;
    return 0;
}

Submission status: Runtime Error

Solution code:
import copy
n = int(input())
a = list(map(int,input().split()))
a2 = copy.copy(a)
c = 0
d = len(a)
for i in range(len(a)):
    if i+1 == len(a):
        ans = a[i-1] ^ a[0]
        if (ans in a):
            a2.remove(ans)
        else:
            break
    else:
        ans = a[i-1] ^ a[i+1]
        if (ans in a):
            a2.remove(ans)
        else:
            break
    c += 1

if c == d:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
import sys

N = int(input())
numbers = list(map(int, input().split())) 
numbers_2 = numbers
 
def foo(x,y, numbers):
    answer = 0
    if len(numbers) == 0:
        print("Yes")
        sys.exit()
    for i in numbers:
        if x ^ i == y:
            numbers.remove(x)
            numbers.remove(y)
            numbers.remove(i)
            foo(y,i,numbers)
        else:
            continue
    print("No")
    sys.exit()
    
  
 

for i in numbers:
    for j in numbers:
        foo(i,j,numbers)

Submission status: Runtime Error

Solution code:
import sys

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

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

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

print('Yes')

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
def doit(a):
    c = {}
    for ai in a:
        c[ai] = c.get(ai, 0) + 1
    if len(c) > 3:
	return "No"
    k = list(sorted(c.keys()))
    if len(k) == 1:
	if k[0] == 0:
            return "Yes"
    if len(k) == 2:
	if k[0] == 0 and c[k[0]] * 2 == c[k[1]]:
            return "Yes"
    if len(k) == 3:
	if c[k[0]] == c[k[1]] == c[k[2]] and k[0] ^ k[1] == k[2]:
            return "Yes"
    return "No"

print(doit(sorted(a)))

Submission status: Runtime Error

Solution code:
from collections import defaultdict
n = int(input())
aa = list(map(int, input().split()))

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

cnt_map = defaultdict(int)
for a in aa:
    cnt_map[a] += 1

if len(cnt_map.keys()) > 3:
    print('No')
    exit(0)

if len(cnt_map.keys()) == 1:
    k = cnt_map.keys()[0]
    if k == 0:
        print('Yes')
    else:
        print('No')
    exit(0)

if len(cnt_map.keys()) == 2:
    k1, k2 = cnt_map.keys()
    if k1 > k2:
        k1, k2 = k2, k1
    if k1 != 0:
        print('No')
        exit(0)
    if cnt_map[k1] != m:
        print('No')
        exit(0)
    print('Yes')
    exit(0)
if len(cnt_map.keys()) == 3:
    a, b, c = cnt_map.keys()
    if a != b ^ c:
        print('No')
        exit(0)
    if cnt_map[a] == m and cnt_map[b] == m and cnt_map[c] == m:
        print('Yes')
        exit(0)
    print('No')
    exit(0)

Submission status: Runtime Error

Solution code:

import math

N = int(input())

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

def xor(x1,x2):
    xdigit = math.ceil(math.log2(max(x1, x2)))
    num = 0
    for i in range(xdigit):
        dig_x1 = x1 // (2**(xdigit-i))
        dig_x2 = x2 // (2**(xdigit-i))
        
        if dig_x1 != dig_x2:
            num += 2**(xdigit-i)
            
        if dig_x1 == 1:
            x1 -= 2**(xdigit-i)
            
        if dig_x2 == 1:
            x2 -= 2**(xdigit-i)
    return num

is_exist = True

for camel in range(N):
    prev = camel - 1
    furt = camel + 1
    
    if camel == N-1:
        furt = 0
    if camel == 0:
        prev = N-1
         
    num_xor = xor(nums[prev], nums[furt])
    if num_xor != nums[camel]:
        is_exist = False
        break


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

Submission status: Runtime Error

Solution code:
n = int(input())
figure = list(map(int, input().split()))
cnt=0#最大n-2
for i in range(0,n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if figure[i] ^ figure[j] == figure[k]:
        cnt+=1
        figure[i], figure[j] = figure[j], figure[k]
        figure.remove(figure[k])
        i = 0
        j = 1
        k = 2
if(n-2)==cnt:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
import numpy as np

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

a = np.array(a)




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


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


if N % 3 == 0:
	a_1 = np.unique(a)
	for a_1_ in a_1:	
		if np.count_nonzero(a == a_1_) != int(N // 3):
			judge = False
		else:
			if judge_of_3(a_1):
				judge = True
			else:
				judge = False
else:
	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: Runtime Error

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 = []
if N%3!=0:
    if sum(A)==0:
        print("Yes")
    else:
        print("No")
else:
    for a in A:
        if a in L:
            continue

        if len(L)>=3:
            ans = "No"
            break
        L.append(a)

    l1, l2, l3 = L
    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)

Submission status: Runtime Error

Solution code:
import sys

N = int(input())
numbers = list(map(int, input().split())) 
numbers_2 = numbers
 
def foo(x,y, numbers):
    answer = 0
    if len(numbers) == 0:
        answer = "Yes"
        print(answer)
    for i in numbers:
        if x ^ i == y:
            numbers.remove(x)
            numbers.remove(y)
            numbers.remove(i)
            foo(y,i,numbers)
        else:
            continue
    print("No")
    sys.exit()
    
  
 

for i in numbers:
    for j in numbers:
        foo(i,j,numbers)

Submission status: Runtime Error

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

#print(bin(a[N-1] ^ a[1]))
#print(bin(a[0]))

if bin(a[N-2] ^ a[0]) == bin(a[N-1]):
  if bin(a[N-1] ^ a[1]) == bin(a[0]):
    for i in range(0,N-3):
      #print(bin(a[N] ^ a[N+2]),bin(a[N+1]))
      if Falg:
        if bin(a[N] ^ a[N+2])!=bin(a[N+1]):
          Flag=False
          break  
    else:
      print("Yes")
  else:
    print("No")
    
else:
  print("No")

Submission status: Runtime Error

Solution code:
from itertools import combinations


def main():
    N = int(input())
    an = list(map(int, input().split()))

    ans = False

    for (a, b) in combinations(an, 2):
        tmp_an = an[:]
        tmp_an.remove(a)
        tmp_an.remove(b)

        c = a + b
        init = a

        for _ in range(N - 2):
            c = a + b
            if c not in an:
                break
            tmp_an.remove(c)
            a, b = b, c
        else:
            if a ^ init == c:
                ans = True
                break

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


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

#print(bin(a[N-1] ^ a[1]))
#print(bin(a[0]))

if bin(a[N-2] ^ a[0]) == bin(a[N-1]):
  if bin(a[N-1] ^ a[1]) == bin(a[0]):
    for i in range(0,N-3):
      print(bin(a[N] ^ a[N+2]),bin(a[N+1]))
      if Falg:
        if bin(a[N] ^ a[N+2])!=bin(a[N+1]):
          Flag=False
          break  
    else:
      print("Yes")
  else:
    print("No")
    
else:
  print("No")

Submission status: Runtime Error

Solution code:
import math

N = int(input())

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

def xor(x1,x2):
    xdigit = math.ceil(math.log2(max(x1, x2)))
    num = 0
    for i in range(xdigit):
        dig_x1 = x1 // (2**(xdigit-i))
        dig_x2 = x2 // (2**(xdigit-i))
        
        if dig_x1 != dig_x2:
            num += 2**(xdigit-i)
            
        if dig_x1 == 1:
            x1 -= 2**(xdigit-i)
            
        if dig_x2 == 1:
            x2 -= 2**(xdigit-i)
    return num

is_exist = True

for camel in range(1, N-1):
    prev = camel - 1
    furt = camel + 1
    
    if camel == N-1:
        furt = 0
    if camel == 0:
        prev = N-1
         
    num_xor = xor(nums[prev], nums[furt])
    if num_xor != nums[camel]:
        is_exist = False
        break


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

Submission status: Runtime Error

Solution code:
import sys

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

#print(N)
#print(a)

for i in range(N):
	x = int(a[(i-1)%N])
	y = int(a[(i+1)%N])
'''
	print(i+1)
	print('↓')
	print(x, y)
	print('↓')
	print(x ^ y) 
	print(a[i%N])
'''
	if int(a[i%N]) != x^y:
		print('No')
		sys.exit(0);

print('Yes')

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
set_a=set(a)
if len(set_a)==3:
    set_a = list(set_a)
    num0 = a.count(set_a[0])
    num1 = a.count(set_a[1])
    num2 = a.count(set_a[2])
    if (set_a[0]^set_a[1]^set_a[2]==0) and (num0==num2) and (num1==num2):
        print('Yes')
    else:
        print('No')
elif len(set_a)==2:
    num0 = a.count(set_a[0])
    num1 = a.count(set_a[1])
    if (0 in set_a) and (num0==num1):
        print('Yes')
    else:
        print('No')
elif len(set_a)==1:
    if 0 in a:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Runtime Error

Solution code:
import sys

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

#print(N)
#print(a)

for i in range(N):
	x = int(a[(i-1)%N])
	y = int(a[(i+1)%N])
 '''
	print(i+1)
	print('↓')
	print(x, y)
	print('↓')
	print(x ^ y) 
	print(a[i%N])
'''
	if int(a[i%N]) != x^y:
		print('No')
		sys.exit(0);

print('Yes')

Submission status: Runtime Error

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)

l1, l2, l3 = L
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)

Submission status: Runtime Error

Solution code:
import collections
N=int(input())
a=list(map(int,input().split()))
def judge(a):
    if sum(a)==0:
        return True
    else:
        a=dict(collections.Counter(a))
        a0=list(a.keys())[0]
        a1=list(a.keys())[1]
        a2=list(a.keys())[2]
        if a0^a1==a2:
            return True
    return False

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

Submission status: Runtime Error

Solution code:
import sys
N = int(input())
a_lis = [int(_) for _ in input().split()]

if set(b) == {0}:
    print('Yes')
    sys.exit()
else:
    if len(a_lis) % 3 == 0:
        print('Yes')
    else:
        print('No')

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
from collections import defaultdict

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, a: "List[int]"):
    A = defaultdict(lambda : 0)
    for x in a:
        A[x] += 1
    if len(A) == 1 and 0 in A:
        print(YES)
        return
    if N % 3 != 0:
        print(NO)
        return
    if len(A) == 2 and A[0] == N // 3:
        print(YES)
        return
    if len(A) > 3:
        print(NO)
        return
    L = list(A.keys())
    if L[0] ^ L[1] != L[2]:
        print(NO)
        return
    if A[L[0]] != A[L[1]] or A[L[0]] != A[L[2]]:
        print(NO)
        return
    print(YES)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

if n == 3 and a[0] ^ a[1] == a[2]:
  print("Yes")
elif n >= 4 and set(a) = {0}:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:

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

a = [int(i) for i in a_list]
a.sort()

delta = a[1]-a[0]
NG_flag = False
for i in range(1,N+1):
    if a[i]-a[i-1] != delta:
        NG_flag = True

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

Submission status: Runtime Error

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

def foo(x,y, numbers):
    answer = 0
    if len(numbers) == 0:
        answer = "Yes"
        return answer
    for i in numbers:
        if x ^ i == y:
            numbers.remove(x)
            numbers.remove(y)
            numbers.remove(i)
            foo(y,i,numbers)
        else:
            continue
    return answer
  

for i in numbers:
  for j in numbers:
    numbers_2 = numbers
    numbers_2.remove(i)
    numbers_2.remove(j)
    foo(i,j,numbers_2)

Submission status: Runtime Error

Solution code:
import itertools
import numpy as np
import collections

N = int(input())
A = [int(_) for _ in input().split()]
count = collections.defaultdict(int)
for a in A:
    count[a] += 1
if len(count) == 1:
    a = count.keys()[0]
    if a ^ a == a:
        print('Yes')
        exit()
elif len(count) == 2:
    a, b = sorted(count.keys())
    if a == 0 and count[a] == 1 and count[b] == 2:
        print('Yes')
        exit()
elif len(count) == 3:
    a, b, c = count.keys()
    if a ^ b == c and count[a] == count[b] == count[c]:
        print('Yes')
        exit()
print('No')

Submission status: Runtime Error

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

if n == 3 and a[0] ^ a[1] == a[2]:
  print("Yes")
elif n >= 4 and set(a) = set([1]):
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))
setA = list(set(A))
if len(setA) == and setA[0] == 0:
	print("Yes")
	exit()
if N % 3 != 0:
	print("No")
	exit()
if len(setA) == 1 or len(setA) > 3:
	print("No")
	exit()
if len(setA) == 2:
	if 0 in setA:
		setA.sort()
		if A.count(0) == N // 3 and A.count(setA[1]) == (N // 3) * 2:
			print("Yes")
			exit()
	print("No")
	exit()

if setA[0] ^ setA[1] != setA[2]:
	print("No")
	exit()
for a in setA:
	if A.count(a) != N // 3:
		print("No")
		exit()
print("Yes")
exit()

Submission status: Runtime Error

Solution code:
x = int(input().split(" "))
if(x[0] < 3 | x[0] > 10000 | len(x) < 1 | len(x) > 10^9 + 1):
    print("No")
else if:
    for i in range(2,len(x)-1):
        if x[i] != x[i-1] ^ x[i+1]:
            print("No")
            break
    print("YES")

Submission status: Runtime Error

Solution code:
N=int(input())
a,b,c=map(int,input().split())
if N!=3:
  print("No")
elif a ^ b== c and a ^ c == b and b ^ c ==a:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
#!/snap/bin/pypy3

from itertools import permutations


def main():
    N = int(input())
    an = list(map(int, input().split()))

    for (a, b) in permutations(an, 2):
        if a == b:
            continue

        tmp_an = an[:]
        tmp_an.remove(a)
        tmp_an.remove(b)

        c = a + b
        init = a

        for _ in range(N - 2):
            if c not in an:
                ans = False
                continue
            tmp_an.remove(c)
            a, b = b, c

        else:
            if a ^ init == c:
                ans = True
                break

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


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from sys import setrecursionlimit
from math import log2, floor
from operator import or_
from functools import reduce

setrecursionlimit(100000)

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

bl = [0 for _ in range(floor(log2(max(a)))+1)]
for ai in a :
    aj = ai
    for i in range(floor(log2(ai))+1) :
        if aj & 1 == 1 :
            bl[i] += 1
        aj >>= 1

ans = reduce(or_, map(lambda x : x&1, bl))
if ans :
    print("No")
else :
    print("Yes")

Submission status: Runtime Error

Solution code:
#!/snap/bin/pypy3

from itertools import permutations


def main():
    N = int(input())
    an = list(map(int, input().split()))

    for (a, b) in permutations(an, 2):
        if a == b:
            continue

        tmp_an = an.copy()
        tmp_an.remove(a)
        tmp_an.remove(b)

        c = a + b
        init = a

        for _ in range(N - 2):
            if c not in an:
                ans = False
                continue
            tmp_an.remove(c)
            a, b = b, c

        else:
            if a ^ init == c:
                ans = True
                break

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


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
  n = int(input())
  alist = list(sorted(map(int, input().split())))
  if n % 3 != 0:
    print('No')
  else:
    aset = set(alist)
    tmpal = list(aset)
    if tmpal[0] ^ tmpal[2] == tmpal[1]:
      print('Yes')
    else:
      print('No')


if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
iter_num = int(input())
num = input().split()

num_bin = [format(int(i),'b') for i in num]
max_len = len(num_bin[-1])

num_bin = [format(i, '0>{}'.format(max_len)) for i in num_bin]

tmp = []
for i in range(len(num_bin[0])):
  tmp_num = 0
  for j in num_bin:
    tmp_num += int(j[i])
  if tmp_num%2==0: tmp_num=0
  tmp.append(tmp_num)

flg = 0
for i in tmp:
  if i==0: pass
  else:
    flg = 1
    print('No')
    break
if flg == 0: print('Yes')

Submission status: Runtime Error

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

k = 0
g = 0

for i in range(N):
    if A[i] % 2 == 0:
        g += 1
    else:
        k += 1

if k == 0 or (k % g == 0 and k / g == 2):
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
from math import log2, floor
from operator import or_
from functools import reduce

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

bl = [0 for _ in range(floor(log2(max(a)))+1)]
for ai in a :
    aj = ai
    for i in range(floor(log2(ai))+1) :
        if aj & 1 == 1 :
            bl[i] += 1
        aj >>= 1

ans = reduce(or_, map(lambda x : x&1, bl))
if ans :
    print("No")
else :
    print("Yes")

Submission status: Runtime Error

Solution code:
if N = 3 and i = 1 and ai = 1:
    print("Yes")
    else:
      print("No")

Submission status: Runtime Error

Solution code:
def find(A):
    dic={}
    for i in range(len(A)):
        if A[i] in dic:
            dic[A[i]]+=1
        else:
            dic[A[i]]=1
    if len(dic)==1:
        if 0 in dic:
            return True
        else:
            return False
    
    if len(dic)==2:
        if N%3!=0:
            return False
        temp=[]
        for x in dic:
            temp+=[dic[x]]
        n=N//3
        temp=sorted(temp)
        if (temp[0],temp[1])!=(n,2*n):
            return False
        
        if 0 not in dic:
            return False
        
        n1=dic[0]
        if n1==n:
            return True
        return False
    
    if len(dic)>3:
        return False
    
    if len(dic)==3 and N%3!=0:
        return False
    
    temp=[dic[x] for x in dic]
    if temp[0]!=temp[1] or temp[1]!=temp[2] or temp[2]!=temp[0]:
        return False
    
    a,b,c=[x for x in dic]
    if a^b==c or b^a==c or c^b==a:
        return True
    return False
    
input()
A=list(map(int,input().strip().split(' ')))
if find(A):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
from collections import defaultdict as dd, deque, Counter
n = int(input())
C = Counter(map(int,input().split()))

if len(C) == 1:
    if C.values()[0] == 0:
        print('Yes')
    else:
        print('No')
elif len(C) == 2:
    it = list(C.items())
    k1,v1 = it[0]
    k2,v2 = it[1]
    if v1 == 2*v2 or v2 == 2*v1 and 0 in [k1,k2]:
        print('Yes')
    else:
        print('No')
elif len(C) == 3:
    it = list(C.items())
    k1,v1 = it[0]
    k2,v2 = it[1]
    k3,v3 = it[2]

    if v1 == v2 == v3 and k1^k2 == k3:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Runtime Error

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

c = collections.Counter(a)
v = list(c.values())
k = list(c.keys())

if n % 3 == 0 and v[0] == v[1] == v[2] and k[0] ^ k[1] == k[2]:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
n = int(input())
ls = list(map())
print(week_range)

Submission status: Runtime Error

Solution code:
A,B,C=map(int, input().split())

if (A+B)=C:
  print(Yes)
elif:
  print(No)

Submission status: Runtime Error

Solution code:
import itertools
import numpy as np
import collections

N = int(input())
A = [int(_) for _ in input().split()]
count = collections.defaultdict(int)
for a in A:
    count[a] += 1
if len(count) == 1:
    a = count.keys()[0]
    if a ^ a == a:
        print('Yes')
        exit()
elif len(count) == 2:
    a, b = count.keys()
    if a ^ a == b and b ^ b == a and count[a] == count[b]:
        print('Yes')
        exit()
elif len(count) == 3:
    a, b, c = count.keys()
    if a ^ b == c and count[a] == count[b] == count[c]:
        print('Yes')
        exit()
print('No')

Submission status: Runtime Error

Solution code:
A,B,C=map(int, input().split())

if A+B = C:
    print(Yes)
  
elif:
    print(No)

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
aSet=list(set(a))
if n%3!=0:
    if len(aSet)==1 and aSet[0]=0:
        print('Yes')
    else:
        print('No')
else:
    if len(aSet)==3:
        if (aSet[0]^aSet[1])==aSet[2]:
            print('Yes')
    elif len(aSet)<3:
        if 0 in aSet:
            print('Yes')
    else:
        print('No')

Submission status: Runtime Error

Solution code:

import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline
mii=lambda:map(int,input().split())

n=int(input())

a=list(mii())
a.sort()

if a[0]==a[n-1]:
    if 0 in b:
        print("Yes")
    else:
        print("No")
elif n%3:
    print("No")
else:
    a1,a2,a3=a[0],a[n//3],a[n//3*2]
    if a1!=a[n//3-1] or a2!=a[n//3*2-1] or a3!=a[n-1]:
        print("No")
    elif a1^a2!=a3 or a1^a3!=a2 or a2^a3!=a1:
        print("No")
    else:
        print("Yes")