Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(n):
    t, x, y = map(int, input().split())
    if x + y < t or (X + y) % 2 != t % 2:                                                                         
        print("No")
        exit()
print("Yes")

Fixed submission:
n = int(input())
for i in range(n):
    t, x, y = map(int, input().split())
    if x + y > t or ((x + y) % 2 != t % 2):                                                                       
        print("No")
        exit()
print("Yes")

Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(n):
    t, x, y = map(int, input().split())
    if x + y < t or (X + y + t) % 2:
        print("No")
        exit()
print("Yes") 

Fixed submission:
n = int(input())
for i in range(n):
    t, x, y = map(int, input().split())
    if x + y > t or ((x + y) % 2 != t % 2):                                                                       
        print("No")
        exit()
print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
n, y = map(int, input().split())

for a in range(n + 1):
   for b in range(n + 1):
       for c in range(n + 1):
           if y - (a * 10000 + b * 5000 + c * 1000) == 0 and a + b + c == n:                                      
               print(a, b, c)
               exit()

print("-1 -1 -1")

Fixed submission:
n, y = map(int, input().split())

for a in range(n + 1):
   for b in range(n - a + 1):
           if a * 10000 + b * 5000 + (n - a - b) * 1000 == y:
               print(a, b, n - a - b)
               exit()

print("-1 -1 -1")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import Counter

n = int(input())
l_list = [2, 1]
i = 2

while True:
    l_list.append(l_list[i-1] + l_list[i-2])
    if len(l_list) - 1 == n:
        print(l_list[-1])
        sys.exit()
    i += 1


Fixed submission:
import sys
from collections import Counter

n = int(input())
if n == 0:
    print(2)
    sys.exit()
elif n == 1:
    print(1)
    sys.exit()
l_list = [2, 1]
i = 2

while True:
    l_list.append(l_list[i-1] + l_list[i-2])
    if len(l_list) - 1 == n:
        print(l_list[-1])
        sys.exit()
    i += 1
Buggy python submission (verdict: Runtime Error):
import sys

n, m = map(int, input().split())
a_array = [input() for i in range(n)]
b_array = [input() for i in range(m)]

for ai in range(n):
    for aj in range(n):
        can = True
        for bi in range(m):
            if a_array[ai+bi][aj:aj+m] != b_array[bi]:
                can = False
                break
        if can:
            print('Yes')
            sys.exit()

print('No')


Fixed submission:
import sys

n, m = map(int, input().split())
a_array = [input() for i in range(n)]
b_array = [input() for i in range(m)]

for ai in range(n-m+1):
    for aj in range(n-m+1):
        can = True
        for bi in range(m):
            if a_array[ai+bi][aj:aj+m] != b_array[bi]:
                can = False
                break
        if can:
            print('Yes')
            sys.exit()

print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
#DEBUG=True
DEBUG=False
num=7
if DEBUG:
    f=open("C_input.txt")
else:
    f=sys.stdin
N=int(f.readline().strip())
mod_sum=0
ind=1
pdt=1
if N%2==0:
    print("-1")
else:
    mod_sum=num%N
    if not mod_sum:
        print(ind)
    else:
        while True:
            pdt*=10
            tmp=(num*pdt)%N
            mod_sum=(mod_sum+tmp)%N
            ind+=1
            if not mod_sum:
                print(ind)
                break
f.close()

Fixed submission:
import sys
#DEBUG=True
DEBUG=False
if DEBUG:
    f=open("C_input.txt")
else:
    f=sys.stdin
mod=1
ans=0
N=int(f.readline().strip())
if N%2==0 or N%5==0:
    print("-1")
else:
    if N%7==0:
        A=N*9/7
    else:
        A=N*9
    while True:
        ans+=1
        mod=(10*mod)%A
        if mod==1:
            print(ans)
            break
f.close()
Buggy python submission (verdict: Runtime Error):
import sys
#DEBUG=True
DEBUG=False
if DEBUG:
    f=open("202007_2nd/D_input.txt")
else:
    f=sys.stdin
#from 2nd count
def cnt_func(num):
    cnt=0
    while num:
        num%=bin(num).count("1")
        cnt+=1
    return cnt+1
n=int(f.readline().strip())
s=f.readline().strip()
input_val=int(s,2)
input_one_count=s.count("1")
#Base value
zero_first=input_val%(input_one_count+1)
one_first=input_val%(input_one_count-1) if input_one_count>1 else 0
ans=0
for idx,emt in enumerate(s):
    p=n-idx-1
    if emt=="0": #inverted to "1"
        ans=cnt_func((zero_first+(pow(2,p,input_one_count+1)))%(input_one_count+1))
    else: #inverted to "2"
        ans=cnt_func((one_first-(pow(2,p,input_one_count-1)))%(input_one_count-1))
    print(ans)
f.close()

Fixed submission:
import sys
#DEBUG=True
DEBUG=False
if DEBUG:
    f=open("202007_2nd/D_input.txt")
else:
    f=sys.stdin
#from 2nd count
def cnt_func(num):
    cnt=0
    while num:
        num%=bin(num).count("1")
        cnt+=1
    return cnt+1
n=int(f.readline().strip())
s=f.readline().strip()
input_val=int(s,2)
input_one_count=s.count("1")
#Base value
zero_first=input_val%(input_one_count+1)
one_first=input_val%(input_one_count-1) if input_one_count>1 else 0
ans=0
for idx,emt in enumerate(s):
    p=n-idx-1
    if emt=="0": #inverted to "1"
        ans=cnt_func((zero_first+(pow(2,p,input_one_count+1)))%(input_one_count+1))
    else: #inverted to "0"
        if input_one_count>1:
            ans=cnt_func((one_first-(pow(2,p,input_one_count-1)))%(input_one_count-1))
        else:
            ans=0
    print(ans)
f.close()
Buggy python submission (verdict: Runtime Error):
import sys
from itertools import combinations
#DEBUG = True
DEBUG = False
if DEBUG:
    f=open("202007_1st/C_input.txt")
else:
    f=sys.stdin
WHITE='.'
BLACK='#'
def count_black(H_index,W_index):
    count_tmp=0
    for H_entries in H_index:
        for _ in H_entries:
            if _==H_index:
                continue
            for W_entries in W_index:
                for __ in W_entries:
                    if __==W_index:
                        continue
                if S[_][__]==BLACK:
                    count_tmp+=1
    return count_tmp
ans=0
H,W,K=map(int,f.readline().split())
S=[f.readline().strip() for _ in range(H)]
H_indices=[_ for _ in range(0,H)]
W_indices=[_ for _ in range(0,W)]
combi_list_H=[(-1)]
combi_list_W=[(-1)]
for _ in range(1,H):
    combi_list_H.extend(list(combinations(H_indices,_)))
for _ in range(1,W):
    combi_list_W.extend(list(combinations(W_indices,_)))
for _ in combi_list_H:
    for __ in combi_list_W:
        if count_black(_,__)==5:
            ans+=1
print(ans)
f.close()

Fixed submission:
import sys
from itertools import combinations
#DEBUG = True
DEBUG = False
if DEBUG:
    f=open("202007_1st/C_input.txt")
else:
    f=sys.stdin
WHITE='.'
BLACK='#'
def count_black(H_index,W_index):
    count_tmp=0
    for _ in range(H):
        if _ in H_index:
            continue
        for __ in range(W):
            if __ in W_index:
                continue
            if S[_][__]==BLACK:
                count_tmp+=1
    return count_tmp
ans=0
H,W,K=map(int,f.readline().split())
S=[f.readline().strip() for _ in range(H)]
H_indices=[_ for _ in range(0,H)]
W_indices=[_ for _ in range(0,W)]
combi_list_H=[[-1]]
combi_list_W=[[-1]]
for _ in range(1,H):
    combi_list_H.extend(list(combinations(H_indices,_)))
for _ in range(1,W):
    combi_list_W.extend(list(combinations(W_indices,_)))
for _ in combi_list_H:
    for __ in combi_list_W:
        if count_black(_,__)==K:
            ans+=1
print(ans)
f.close()
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
input = stdin.buffer.readline
k = int(input())
t, c = 7, 1
while t % k:
    t = t * 10 + 7
    c += 1
print(c)


Fixed submission:
from sys import stdin
input = stdin.buffer.readline
k = int(input())
t = 7
for i in range(1, k + 1):
    if not t % k:
        print(i)
        exit()
    t = (t * 10 + 7) % k
print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
num = 7 
s = set()
cnt = 1
while(1):
    m = num%k
    if m == 0:
        print(cnt)
        break
    elif m in s:
        print(-1)
        break
    else:
        s.add(m)
    num = num*10+7
    cnt += 1

Fixed submission:
k = int(input())
m = 7 % k 
s = set()
cnt = 1
while(1):
    if m == 0:
        print(cnt)
        break
    elif m in s:
        print(-1)
        break
    else:
        s.add(m)
    m = ((m * (10 % k)) % k + 7 % k) % k
    cnt += 1
Buggy python submission (verdict: Runtime Error):
x = int(input)
if x<30:
  print('Yes')
 else:
  print('No')

Fixed submission:
x = int(input())
if x<30:
  print('No')
else:
  print('Yes')
Buggy python submission (verdict: Runtime Error):
N = int(input())
d = list(map(int, input().split()))
ans = 0
for i in range(N - 1):
  for j in range(i + 1, N):
    ans += d[i] * d[j]
print(ans)

Fixed submission:
A, B = map(int, input().split())
print(max(0, A - 2*B))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
l, r = 0, N-1


def can(m):
    for j in range(N - 2*m + 1):
        for k in range(j + m, N - m + 1):
            if S[j:j+m] == S[k:k+m]:
                return True
    return False


for i in range(13):
    m = (l + r + 1) // 2
    if can(m):
        l = m
    else:
        r = m
print(l)

Fixed submission:
N = int(input())
S = input()
r = 0
i = j = 0
while j < N:
  t = S[i:j]
  if t in S[j:]:
    r = max(r, j-i)
    j += 1
  else:
    i += 1
print(r)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
import sys
sys.setrecursionlimit(2*(10**5))

N, Q = map(int, input().split())
E = defaultdict(list)
for i in range(N-1):
    a, b = map(int, input().split())
    E[a-1].append(b-1)
visit = [False]*N
ans = [0]*N
for i in range(Q):
    p, x = map(int, input().split())
    ans[p-1] += x


def dfs(v):
    if not visit[v]:
        visit[v] = True
        for nxt in E[v]:
            ans[nxt] += ans[v]
            dfs(nxt)


dfs(0)
print(*ans)


Fixed submission:
from collections import defaultdict

N, Q = map(int, input().split())
E = defaultdict(list)
for i in range(N-1):
    a, b = map(int, input().split())
    E[a-1].append(b-1)
ans = [0]*N
for i in range(Q):
    p, x = map(int, input().split())
    ans[p-1] += x

for i in range(N):
    for t in E[i]:
        ans[t] += ans[i]
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
import sys
sys.setrecursionlimit(2*(10**5))

N, Q = map(int, input().split())
E = defaultdict(list)
for i in range(N-1):
    a, b = map(int, input().split())
    E[a-1].append(b-1)
visit = [False]*N
ans = [0]*N
for i in range(Q):
    p, x = map(int, input().split())
    ans[p-1] += x


def dfs(v, road):
    if not visit[v]:
        visit[v] = True
        for nxt in E[v]:
            ans[nxt] += ans[v]
            dfs(nxt, road[:])


dfs(0, [])
print(*ans)


Fixed submission:
from collections import defaultdict

N, Q = map(int, input().split())
E = defaultdict(list)
for i in range(N-1):
    a, b = map(int, input().split())
    E[a-1].append(b-1)
ans = [0]*N
for i in range(Q):
    p, x = map(int, input().split())
    ans[p-1] += x

for i in range(N):
    for t in E[i]:
        ans[t] += ans[i]
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right

N, M = map(int, input().split())
w = sorted([tuple(map(int, input().split())) for _ in range(N)])
days = [x[0] for x in w]
pays = [x[0] for x in sorted(w[:], key=lambda x: x[1], reverse=True)]
ans = 0
for i in range(M):
    c = bisect_right(days, M-i) - 1
    if c < 0:
        break
    e = c
    for j in range(1, M-i):
        d = bisect_right(days, M - i - j) - 1
        e = e if w[e][1] >= w[d][1] else d
    ans += w[e][1]
    del w[e]
    del days[e]

print(ans)

Fixed submission:
import heapq

N, M = map(int, input().split())
w = [list(map(int, input().split())) for _ in range(N)]
ans = 0

daylist = [[] for _ in range(10**5)]
for a, b in w:
    daylist[a-1].append(b)

q = []
for i in range(M):
    for b in daylist[i]:
        heapq.heappush(q, -b)
    if q:
        ans += -heapq.heappop(q)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right

N, M = map(int, input().split())
w = sorted([tuple(map(int, input().split())) for _ in range(N)])
days = [x[0] for x in w]
pays = [x[0] for x in sorted(w[:], key=lambda x: x[1], reverse=True)]
ans = 0
for i in range(M):
    c = bisect_right(days, M-i) - 1
    if c < 0:
        break
    e = c
    for j in range(M-i):
        d = bisect_right(days, M - i - 1) - 1
        e = e if w[e][1] >= w[d][1] else d
    ans += w[e][1]
    del w[e]
    del days[e]

print(ans)

Fixed submission:
import heapq

N, M = map(int, input().split())
w = [list(map(int, input().split())) for _ in range(N)]
ans = 0

daylist = [[] for _ in range(10**5)]
for a, b in w:
    daylist[a-1].append(b)

q = []
for i in range(M):
    for b in daylist[i]:
        heapq.heappush(q, -b)
    if q:
        ans += -heapq.heappop(q)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M, P = map(int, input().split())
E = [None] * M
for i in range(M):
    a, b, c = map(int, input().split())
    E[i] = (a - 1, b - 1, P - c)

d = [float("inf") for _ in range(N)]
d[0] = 0
for i in range(2*N):
    for f, t, w in E:
        if d[f] != float("inf") and d[t] > d[f] + w:
            d[t] = d[f] + w
            if i >= N:
                d[t] = -float("inf")
    if i == N-1:
        dN = d[-1]
if dN != d[-1]:
    print(-1)
elif dN > 0:
    print(0)
else:
    print(-dN)

Fixed submission:
N, M, P = map(int, input().split())
E = [None] * M
for i in range(M):
    a, b, c = map(int, input().split())
    E[i] = (a - 1, b - 1, P - c)
INF = float("inf")
d = [INF for _ in range(N)]
d[0] = 0
for i in range(2*N):
    for f, t, w in E:
        if d[t] > d[f] + w:
            d[t] = d[f] + w
            if i >= N:
                d[t] = -INF
    if i == N-1:
        dN = d[-1]
if dN != d[-1]:
    print(-1)
elif dN > 0:
    print(0)
else:
    print(-dN)

Buggy python submission (verdict: Time Limit Exceeded):
N, M, P = map(int, input().split())
E = [None] * M
for i in range(M):
    a, b, c = map(int, input().split())
    E[i] = (a - 1, b - 1, P - c)

d = [float("inf") for _ in range(N)]
d[0] = 0
for i in range(N):
    for f, t, w in E:
        if d[f] != float("inf") and d[t] > d[f] + w:
            d[t] = d[f] + w
for i in range(N):
    for f, t, w in E:
        if d[f] != float("inf") and d[t] > d[f] + w:
            d[t] = -float("inf")
if d[-1] == -float("inf"):
    print(-1)
elif d[-1] > 0:
    print(0)
else:
    print(-d[-1])

Fixed submission:
N, M, P = map(int, input().split())
E = [None] * M
for i in range(M):
    a, b, c = map(int, input().split())
    E[i] = (a - 1, b - 1, P - c)
INF = float("inf")
d = [INF for _ in range(N)]
d[0] = 0
for i in range(2*N):
    for f, t, w in E:
        if d[t] > d[f] + w:
            d[t] = d[f] + w
            if i >= N:
                d[t] = -INF
    if i == N-1:
        dN = d[-1]
if dN != d[-1]:
    print(-1)
elif dN > 0:
    print(0)
else:
    print(-dN)

Buggy python submission (verdict: Time Limit Exceeded):
N, M, P = map(int, input().split())
E = [None] * M
for i in range(M):
    a, b, c = map(int, input().split())
    E[i] = (a - 1, b - 1, P - c)

d = [float("inf") for _ in range(N)]
d[0] = 0
for i in range(N):
    for (f, t, w) in E:
        if d[f] != float("inf") and d[t] > d[f] + w:
            d[t] = d[f] + w
            if i == N - 1 and t == N - 1:
                print(-1)
                exit()
if d[-1] > 0:
    print(0)
else:
    print(-d[-1])

Fixed submission:
N, M, P = map(int, input().split())
E = [None] * M
for i in range(M):
    a, b, c = map(int, input().split())
    E[i] = (a - 1, b - 1, P - c)
INF = float("inf")
d = [INF for _ in range(N)]
d[0] = 0
for i in range(2*N):
    for f, t, w in E:
        if d[t] > d[f] + w:
            d[t] = d[f] + w
            if i >= N:
                d[t] = -INF
    if i == N-1:
        dN = d[-1]
if dN != d[-1]:
    print(-1)
elif dN > 0:
    print(0)
else:
    print(-dN)
Buggy python submission (verdict: Time Limit Exceeded):
p = int(input())
A = list(map(int, input().split()))
comb = [0]*p
comb[0] = 1
for i in range(1, p):
    comb[i] = comb[i-1] * (p-i) * pow(i, p-2, p) % p

B = [0]*p
for i in range(p):
    if A[i] == 0:
        continue
    B[0] += 1
    Pow = 1
    for j in range(p):
        B[p - 1 - j] = (B[p - 1 - j] - comb[j] * Pow) % p
        Pow = Pow * (-i) % p
print(*[b % p for b in B])

Fixed submission:
p = int(input())
A = list(map(int, input().split()))
comb = [0]*p
comb[0] = 1
for i in range(1, p):
    comb[i] = comb[i-1] * (p-i) * pow(i, p-2, p) % p

B = [0]*p
for i in range(p):
    if A[i] == 0:
        continue
    B[0] += 1
    Pow = 1
    for j in range(p):
        B[p - 1 - j] = (B[p - 1 - j] - comb[j] * Pow) % p
        Pow = Pow * (-i) % p
print(*[b % p for b in B])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N = int(input())
a = [int(input()) for i in range(N)]

b = sorted(a)
for i in range(N):
    if i == a.index(max(a)):
        print(b[-2])
    else:
        print(b[-1])

Fixed submission:
n=int(input())
a = [int(input()) for i in range(n)]
b = sorted(a)
for i in a:
    print(b[-2] if i==b[-1] else b[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N = int(input())
a = [int(input()) for i in range(N)]

b = sorted(a)
for i in range(N):
    if i == a.index(max(a)):
        print(b[-2])
    else:
        print(b[-1])

Fixed submission:
n=int(input())
a = [int(input()) for i in range(n)]
b = sorted(a)
for i in a:
    print(b[-2] if i==b[-1] else b[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = [int(input()) for i in range(N)]

b = sorted(a)
for i in range(N):
    if i == a.index(max(a)):
        print(b[-2])
    else:
        print(b[-1])

Fixed submission:
n=int(input())
a = [int(input()) for i in range(n)]
b = sorted(a)
for i in a:
    print(b[-2] if i==b[-1] else b[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = [int(input()) for i in range(N)]

b = sorted(a)
for i in range(N):
    if i == a.index(max(a)):
        print(b[-2])
    else:
        print(b[-1])

Fixed submission:
n=int(input())
a = [int(input()) for i in range(n)]
b = sorted(a)
for i in a:
    print(b[-2] if i==b[-1] else b[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

maxa = max(A)

for i in range(N):
    if A[i] == maxa:
        if i == 0:
            print(max(A[1:]))
        elif i == N-1:
            print(max(A[:-1]))
        else:
            print(max(max(A[:i]), max(A[i+1:])))
    else:
        print(maxa)

Fixed submission:
n=int(input())
a = [int(input()) for i in range(n)]
b = sorted(a)
for i in a:
    print(b[-2] if i==b[-1] else b[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

print(max(A[1:]))
for i in range(1, N-1):
    print(max(max(A[:i]), max(A[i+1:])))
print(max(A[:-1]))


Fixed submission:
n=int(input())
a = [int(input()) for i in range(n)]
b = sorted(a)
for i in a:
    print(b[-2] if i==b[-1] else b[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import copy

N = int(input())
A = [int(input()) for _ in range(N)]

for i in range(N):
    B = copy.copy(A)
    del B[i]
    print(max(B))

Fixed submission:
n=int(input())
a = [int(input()) for i in range(n)]
b = sorted(a)
for i in a:
    print(b[-2] if i==b[-1] else b[-1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))

b = []

for i in range(1, N+1)[::-1]:
    if len(list(filter(lambda x: x % i == 0, b))) % 2 != a[i-1]:
        b += [i]

print(len(b))
ans = ""
for i in range(len(b) - 1):
    ans += str(b[i])
    ans += " "
ans += str(b[-1])
print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = [0 for _ in range(N + 1)]
x = []

for n in range(N):
    i = N - n
    BB = B[::i]
    if (sum(BB)) % 2 == A[i - 1]:
        B[i] = 0
    else:
        B[i] = 1
    if B[i] == 1:
        x.append(str(i))

if len(x) == 0:
    print(0)
else:
    print(len(x))
    print(' '.join(x))
Buggy python submission (verdict: Runtime Error):
def equal_list(lst1, lst2):
    lst = lst1.copy()
    for element in lst2:
        try:
            lst.remove(element)
        except ValueError:
            break
    else:
        if not lst:
            return True
    return False


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

if a == [0]*N:
    print("Yes")
    exit()

if N % 3 == 0:
    n = N // 3
    sets = list(set(a))
    if len(sets) != 3:
        print("No")
        exit()

    for s in sets:
        if a.count(s) != n:
            print("No")
            exit()

    order = max(a).bit_length()

    for i in range(order):
        b = [sets[0] >> i & 1, sets[1] >> i & 1, sets[2] >> i & 1]
        if not equal_list(b, [0, 1, 1]):
            print("No")
            exit()

    print("Yes")

else:
    print("No")


Fixed submission:
def equal_list(lst1, lst2):
    lst = lst1.copy()
    for element in lst2:
        try:
            lst.remove(element)
        except ValueError:
            break
    else:
        if not lst:
            return True
    return False


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

if a == [0]*N:
    print("Yes")
    exit()

if N % 3 == 0:
    n = N // 3
    sets = list(set(a))
    order = max(a).bit_length()
    if len(sets) == 3:
        for s in sets:
            if a.count(s) != n:
                print("No")
                exit()

        for i in range(order):
            b = [sets[0] >> i & 1, sets[1] >> i & 1, sets[2] >> i & 1]
            if b == [0, 0, 0]:
                continue
            if not equal_list(b, [0, 1, 1]):
                print("No")
                exit()
    elif len(sets) == 2:
        if a.count(sets[0]) == n:
            for i in range(order):
                b = [sets[0] >> i & 1, sets[1] >> i & 1]
                if b == [0, 0]:
                    continue
                if b != [0, 1]:
                    print("No")
                    exit()
        elif a.count(sets[1]) == n:
            for i in range(order):
                b = [sets[0] >> i & 1, sets[1] >> i & 1]
                if b == [0, 0]:
                    continue
                if b != [1, 0]:
                    print("No")
                    exit()
        else:
            print("No")
            exit()
    else:
        print("No")
        exit()

    print("Yes")

else:
    print("No")
    exit()