Harryxun/stf_run huggingface dataset:
m = input()
a = input()
x = int(0)
y1, y2 = int(0)

n, m = m.spilit()

for i in range(0, len(a), 2):
    x += int(a[i])
    y2 = y1 if y1 < int(a[i]) else y2
    y1 = int(a[i]) if y1 < int(a[i]) else y1

if not y1 // 4 * m or y2 // 4 * m:
    print('Yes')

else:
    print('No')


### FIXED CODE ###

m = input()
b = input()
x = int(0)
a = list()

n, m = m.split(' ')
n = int(n)
m = int(m)

b = b.split(' ')
for i in range(len(b)):
    a.append(int(b[i]))

list.sort(a, reverse = True)

for i in range(len(a)):
    x += int(a[i])

for i in range(m):
    if int(a[i]) < x / (4 * m):
        print('No')
        exit()

print('Yes')
#

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    X=input().strip("\n")
    cnt=[0]*N
    for i in range(1,N):
        n=i
        while(n>0):
            pc=0
            for j in range(19):
                if (n>>j)&1==1:
                    pc+=1
            n%=pc
            cnt[i]+=1
    pc=X.count("1")
    if pc==0:
        for i in range(N):
            print(1)
        exit()

    rp=[0]*N
    rn=[0]*N
    for i in range(N):
        rp[i]=pow(2,i,pc+1)
        if pc!=1:
            rn[i]=pow(2,i,pc-1)
    rp=rp[::-1]
    rn=rn[::-1]
            
    Xrp=0
    Xrn=0
    for i in range(N):
        if X[i]=="1":
            Xrp=(Xrp+rp[i])%(pc+1)
            Xrn=(Xrn+rn[i])%(pc-1)
            
    for i in range(N):
        if X[i]=="1":
            if pc==1:
                print(0)
                continue
            r=Xrn-rn[i]
            print(cnt[r%(pc-1)]+1)
        else:
            r=Xrp+rp[i]
            print(cnt[r%(pc+1)]+1)
    
    
    
if __name__=="__main__":
    main()

### FIXED CODE ###

#

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    X=input().strip("\n")
    cnt=[0]*N
    for i in range(1,N):
        n=i
        while(n>0):
            pc=0
            for j in range(19):
                if (n>>j)&1==1:
                    pc+=1
            n%=pc
            cnt[i]+=1
    pc=X.count("1")
    if pc==0:
        for i in range(N):
            print(1)
        exit()

    rp=[0]*N
    rn=[0]*N
    for i in range(N):
        rp[i]=pow(2,i,pc+1)
        if pc!=1:
            rn[i]=pow(2,i,pc-1)
    rp=rp[::-1]
    rn=rn[::-1]
            
    Xrp=0
    Xrn=0
    for i in range(N):
        if X[i]=="1":
            Xrp=(Xrp+rp[i])%(pc+1)
            if pc!=1:
                Xrn=(Xrn+rn[i])%(pc-1)
            
    for i in range(N):
        if X[i]=="1":
            if pc==1:
                print(0)
                continue
            r=Xrn-rn[i]
            print(cnt[r%(pc-1)]+1)
        else:
            r=Xrp+rp[i]
            print(cnt[r%(pc+1)]+1)
    
    
    
if __name__=="__main__":
    main()
retu = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"

retu = retu.split(",")
retuint=[]
for i in retu :
	retuint.append(int(i))

index=input()

print(retuint[int(index-1)])

### FIXED CODE ###

retu = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"

retu = retu.split(",")
retuint=[]
for i in retu :
	retuint.append(int(i))

index=input()

print(retuint[int(index)-1])
s = input()
a = s.rstrip()split()
b = a[1]
print('A'+b+'C')

### FIXED CODE ###

s = input()
b = s[8]
print('A'+b+'C')
S = list(input())[::-1]
T = list(input())[::-1]

i, c = 0, False

while True:
	f = False
	for j, t in enumerate(T):
		if t == S[i + j]:
			f = True
			continue
		if "?" == S[i + j]:
			continue
		break
	else:
		if f:
			S[i:i + len(T)] = T
			i += len(T) - 1
			c = True
			#print(S)
	i += 1
	if (len(S) - len(T)) <= i:
		break

if c:
	print("".join(S[::-1]).replace("?", "a"))
else:
	print("UNRESTORABLE")


### FIXED CODE ###

S = list(input())[::-1]
T = list(input())[::-1]

for n in range(0, len(S) - len(T) + 1):
	for i, t in enumerate(T):
		if "?" == S[n + i]:
			continue
		if t != S[n + i]:
			break
	else:
		S[n:n + len(T)] = T
		print("".join(S[::-1]).replace("?", "a"))
		break
else:
	print("UNRESTORABLE")
sys.setrecursionlimit(10000)

n=int(input())
a=[[0]*(n-1) for i in range(n)]
id=[[-1]*(n) for i in range(n)]
MAXV=n*(n-1)//2
to=[[]*(n) for i in range(MAXV)]
  
def toId(i,j):
  if (i>j):
    i,j=j,i
  return id[i][j]


visited=[False]*MAXV
calculated=[False]*MAXV
dp=[0]*MAXV
def dfs(v):
  if visited[v]:
    if not calculated[v]:
      return -1
    return dp[v]
  visited[v]=True
  dp[v]=1
  for u in to[v]:
    res = dfs(u)
    if res==-1:
      return -1
    dp[v]=max(dp[v], res+1)
  calculated[v]=True
  return dp[v]


def main():
  for i in range(n):
    a[i]=list(map(lambda x:int(x)-1,input().split()))
  v=0
  for i in range(n):
    for j in range(n):
      if i<j:
        id[i][j]=v
        v+=1
  for i in range(n):
    for j in range(n-1):
      a[i][j]=toId(i,a[i][j])
    for j in range(n-2):
      to[a[i][j+1]].append(a[i][j])
      
  ans=0
  for i in range(v):
    res=dfs(i)
    if res==-1:
      print(-1)
      exit(0)
    ans=max(ans, res)

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

### FIXED CODE ###

from collections import deque

def main():
  n=int(input())
  a=[0]*n
  for i in range(n):
    a[i]=deque(list(map(lambda x:int(x)-1,input().split())))
  q=deque([])
  tmp=set()
  for idx,i in enumerate(a):
    x=idx
    y=i[0]
    if x == a[y][0]:
      tmp.add(x)
      tmp.add(y)
  q=deque(tmp)
  for i in tmp:
    a[i].popleft()
  
  
  day=0
  while True:
    day+=1
    t=q.copy()
    q=deque()
    tmp=set()
    while t:
      x=t.popleft()
      if len(a[x])==0: continue;
      y=a[x][0]
      if x == a[y][0]:
        tmp.add(x)
        tmp.add(y)
    q=deque(tmp)
    for i in tmp:
      a[i].popleft()
    if len(q)==0: break;

  for i in range(n):
    if len(a[i])!=0:
      print(-1)
      exit()
  print(day)


if __name__=='__main__':
  main()
n,m,p=map(int,input().split())
p=list(map(int,input().split()))
par=[i for i in range(n)]

def find(x):
  if par[x]==x:
    return par[x]
  else:
    par[x]=find(par[x])
    return par[x]

def union(x,y):
  fx=find(x)
  fy=find(y)
  if fx!=fy:
    par[fx]=fy

f=lambda x:int(x)-1
for mm in range(m):
  x,y=map(f,input().split())
  union(x,y)

ans=0
for i in range(n):
  if find(p[i])==i:
    ans+=1
print(ans)
  

### FIXED CODE ###

n,m=map(int,input().split())
f=lambda x:int(x)-1
p=list(map(f,input().split()))
par=[j for j in range(n)]
def find(x):
  if x==par[x]:
    return x
  else:
    par[x]=find(par[x])
    return par[x]
 
def union(a,b):
  ra=find(a)
  rb=find(b)
  if ra!=rb:
    par[ra]=rb
 
for i in range(m):
  v,w=map(f,input().split())
  union(v,w)
 
ans=0
for j in range(n):
  if find(j)==find(p[j]):
    ans+=1
print(ans)
a, b, c = map(str, input().split())
if b == "+":
  print(int(a)+int(b))
else:
  print(int(a)-int(b))

### FIXED CODE ###

a, b, c = map(str, input().split())
if b == "+":
  print(int(a)+int(c))
else:
  print(int(a)-int(c))
import copy
s = list(input())
def make1d(n):
    return [copy.deepcopy(1) for i in range(0,n)]
t = make1d(26)
for i in range(0, len(s)):
    t[ord(s[i]) - 97] = t[ord(s[i]) - 97] * (-1)
print(t)
u = 1
for i in range(0, len(s)):
    u = u * t[i]
if u == 1:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

import copy
s = list(input())
def make1d(n):
    return [copy.deepcopy(1) for i in range(0,n)]
t = make1d(26)
for i in range(0, len(s)):
    t[ord(s[i]) - 97] = t[ord(s[i]) - 97] * (-1)
u = 0
for i in range(0, len(t)):
    u = u + t[i]
if u == 26:
    print('Yes')
else:
    print('No')
import itertools
N=int(input())
candi=[str(i) for i in range(1,N+1)]
P="".join(input().split())
Q="".join(input().split())
count=0

#候補列挙
for j in itertools.permutations(candi,N):
  k="".join(list(j))
  count+=1
  if k==P:
    a=count
  elif k==Q:
    b=count
print(abs(a-b))

### FIXED CODE ###

import itertools
N=int(input())
candi=[str(i) for i in range(1,N+1)]
P="".join(input().split())
Q="".join(input().split())
count=0
#候補列挙
for j in itertools.permutations(candi,N):
  k="".join(list(j))
  count+=1
  if k==P:
    a=count
  if k==Q:
    b=count
print(abs(a-b))
A = list(map(int, input().split())
A.sort()
print(-A[0] + A[2])

### FIXED CODE ###

A = list(map(int, input().split()))
A.sort()
print(A[2] - A[0])
import math
import fractions
gcd = math.gcd

A, B = map(int, input().split())

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

g = gcd(A, B)

print(len(set(factorize(g)))+1)


### FIXED CODE ###

import math
import fractions
gcd = math.gcd if hasattr(math, "gcd") else fractions.gcd

A, B = map(int, input().split())

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

g = gcd(A, B)

print(len(set(factorize(g)))+1)
# encoding:utf-8
import math

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

	max_num = max(nums)
	min_num = min(nums)

	# 最大値が越えてたらだめ
	if K > max_num:
		return("IMPOSSIBLE")

	gcd_val = gcdList(nums)

	if K % gcd_val > 0:
		return("IMPOSSIBLE")
	else:
		return("POSSIBLE")

def gcdList(nums):
	tmp = nums[0]
	for x in nums[1:]:
		tmp = math.gcd(tmp, x)
	return(tmp)

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

### FIXED CODE ###

import functools as ft

def gcd(a,b):
    while b > 0:
        a, b = b, a % b
    return a

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

	max_num = max(nums)
	g = ft.reduce(lambda x, y: gcd(x, y), nums)

	if K <= max_num and K % g == 0:
		print("POSSIBLE")
	else:
		print("IMPOSSIBLE")

if __name__ == '__main__':
	main()
A = []
N,M = list(map(int,input().split()))
for i in range(M):
    A.append(list(input().split()))
for i in range(10 ** N):
    str_i = str(i)
    try:
        if N == len(str_i):
            for j,k in A:
                if str_i[int(j)-1] == k:
                    pass
                else:
                    break
            if str_i[int(j)-1] == k:
                print(i)
                exit()
    except IndexError:
        print("-1")
        exit()
print("-1")

### FIXED CODE ###

A = []
N,M = list(map(int,input().split()))
if M == 0:
    if N == 1:
        print(0)
        exit()
    else:
        print("1" + "0"*(N-1))
        exit()
for i in range(M):
    A.append(list(input().split()))
for i in range(10 ** N):
    str_i = str(i)
    try:
        if N == len(str_i):
            for j,k in A:
                if str_i[int(j)-1] == k:
                    pass
                else:
                    break
            if str_i[int(j)-1] == k:
                print(i)
                exit()
    except IndexError:
        print("-1")
        exit()
print("-1")
import sys


def gcd(a, b):
    return gcd(b, a % b) if a % b else b


def lcm(a, b):
    return a * b / gcd(a, b)

for line in sys.stdin:
    data = line.split()
    a, b, c, d, e, f = data
    ix = lcm(a, d) / a
    jx = lcm(a, d) / d
    iy = lcm(b, e) / b
    jy = lcm(b, e) / e
    x = (c*1.0*iy - f*jy) / (a*iy - d*jy)
    y = (c*1.0*ix - f*jx) / (b*ix - e*jx)
    print "%.3f %.3f" % (round(x, 4), round(y, 4))

### FIXED CODE ###

import sys


def gcd(a, b):
    return gcd(b, a % b) if a % b else b


def lcm(a, b):
    return a * b / gcd(a, b)

for line in sys.stdin:
    data = map(int, line.split())
    a, b, c, d, e, f = data
    if a == 0:
        y = c * 1.0 / b
        x = (f - e * y) * 1.0 / d
        print "%.3f %.3f" % (round(x, 4), round(y, 4))
        continue
    if b == 0:
        x = c * 1.0 / a
        y = (f - d * x) * 1.0 / e
        print "%.3f %.3f" % (round(x, 4), round(y, 4))
        continue
    if d == 0:
        y = f * 1.0 / e
        x = (c - b * y) * 1.0 / a
        print "%.3f %.3f" % (round(x, 4), round(y, 4))
        continue
    if e == 0:
        x = f * 1.0 / d
        y = (c - a * x) * 1.0 / b
        print "%.3f %.3f" % (round(x, 4), round(y, 4))
        continue

    ix = lcm(a, d) / a
    jx = lcm(a, d) / d
    iy = lcm(b, e) / b
    jy = lcm(b, e) / e
    x = (c*1.0*iy - f*jy) / (a*iy - d*jy)
    y = (c*1.0*ix - f*jx) / (b*ix - e*jx)
    print "%.3f %.3f" % (round(x, 4), round(y, 4))
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))

H = int(l1[0])
N = int(l1[1])
A = int(sum(l2))
result = H - A
if result <= 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

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

def attack(l):
    H = l[0]
    A = l[1]
    cnt = 0
    while H > 0:
        H -= A
        cnt += 1
    return cnt

print(attack(l))
s=input()
t,u = 1000
for i in range(n):
  if s[i] == "C":
    t = i
    break
for i in range(n-1,-1,-1):
  if s[i] == "F":
    u = i
    break
if max(t,u) != 1000 and t<u:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s=input()
n=len(s)
t = 1000
u = 1000
for i in range(n):
  if s[i] == "C":
    t = i
    break
for i in range(n-1,-1,-1):
  if s[i] == "F":
    u = i
    break
if max(t,u) != 1000 and t<u:
  print("Yes")
else:
  print("No")
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float("inf")
EPS = 1e-6


def yes():
    print("YES")  # type: str


def no():
    print("NO")  # type: str


def main():
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())
    t = abs(A-B)/(V-W)
    if 0 <= t <= T+EPS:
        yes()
    else:
        no()

    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float("inf")
EPS = 1e-6


def yes():
    print("YES")  # type: str


def no():
    print("NO")  # type: str


def main():
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())
    if V-W <= 0:
        no()
        return

    t = abs(A-B)/(V-W)
    if t <= T:
        yes()
    else:
        no()

    return


if __name__ == '__main__':
    main()
import sys
n = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()                                                          
    return divisors
def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr

    # データの状態に左右されないためにrandom.choice()を用いることもある。      
    # ref = random.choice(arr)                                                 
    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right

a = quick_sort(make_divisors(n))
x = len(a)//2-1
y = x+1
xx = a[x]
yy= a[y]
print(xx-1+yy-1)

### FIXED CODE ###

import numpy as np
n = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()                                                          
    return divisors

a = np.sort(make_divisors(n))
#print(a)                                                                      
if len(a)//2==0:
    x = len(a)//2-1
else:
    x = len(a)//2

xx = a[x]
yy= n//xx

print(xx-1+yy-1)
A,B,K = map(int, input().split())
if A >= K:
  print(A-K,B)
  else:
  print(0,B-(K-A))
  

### FIXED CODE ###

A,B,K = map(int, input().split())
if A >= K:
  	print(A-K,B)
elif A+B >= K:
  	print(0,B-(K-A))
else:
	print(0,0)
n,k = map(int,input().split())
L = list(map(int,input().split()))
dp = [float("inf")]*(100)
dp[0] = 0

for i in range(1,n):
    for j in range(max(0,i-k),i):
        dp[i] = min(dp[i],dp[j]+abs(L[i]-L[j]))
        
print(dp[n-1])

### FIXED CODE ###

n,k = map(int,input().split())
L = list(map(int,input().split()))
dp = [float("inf")]*(n)
dp[0] = 0

for i in range(1,n):
    for j in range(max(0,i-k),i):
        dp[i] = min(dp[i],dp[j]+abs(L[i]-L[j]))
        
print(dp[n-1])
def XOR(n):
    if n == 1:
        return 1
    else:
        return XOR(n-1)^n
    
A,B=map(int,input().split())
if A>1:
    print(XOR(B)^XOR(A-1))
else:
    print(XOR(B))


### FIXED CODE ###

#D問題
A,B = map(int,input().split())
def f(n):
    if n%2 == 0:
        if (n//2)%2 == 0:
            return n
        else:
            return n+1
    else:
        if ((n-1)//2)%2 == 0:
            return 1
        else:
            return 0
        
FB = f(B)
FA = f(A-1)
print(FB^FA)
s=input()
t=input()
ans=[]
for i in range(len(s)-len(t)):
  count=0
  for j in range(len(t)):
    if t[j]==s[i+j]:
      count+=1
  ans.append(count)
print(len(t)-max(ans))

  


### FIXED CODE ###

s=input()
t=input()
ans=[]
for i in range(len(s)-len(t)+1):
  count=0
  for j in range(len(t)):
    if t[j]==s[i+j]:
      count+=1
  ans.append(count)
print(len(t)-max(ans))
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 
        2, 2, 5, 4, 1, 4, 1, 51]

index = input()
print(list[index])


### FIXED CODE ###

list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 
        2, 2, 5, 4, 1, 4, 1, 51]

index = input()
index = int(index)
print(list[index-1])
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
L = [A,B,C,D,E]
L.sort()
if L[0] =>N:
  M = 1
else:
  K = N // L[0]
  M = K + 1
print(M + 4)



### FIXED CODE ###

N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
L = [A,B,C,D,E]
L.sort()
M = 0
H = N % L[0]
if(H == 0):
  print(N//L[0]+4)
else:
  print(N//L[0]+5)
if S[0] == S[1] == S[2]:
  print('No')
else:
  print('Yes')

### FIXED CODE ###

S = list(input())

if S[0] == S[1] == S[2]:
  print('No')
else:
  print('Yes')
a,b=map(int, input().split())

for i in range(a):
	for j in range(b):
		print("#")
		return
	/n


### FIXED CODE ###

while True:
    a,b=map(int,input().split())
    if a==0 and b==0:break
    for i in range (a):
        print('#'*b)
    print()
X = input()
if X < 30:
  print('No')
else:
  print('Yes')

### FIXED CODE ###

X = int(input())
if X < 30:
  print('No')
else:
  print('Yes')
from math import factorial as f
N, K = map(int,input().split())

WARU = 10**9+7

def nCr(n, r):
    return f(n)//(f(r)*f(n-r))


for i in range(K):
    print((nCr(K-1, i) * nCr(N-K+1, i+1)) % WARU)


### FIXED CODE ###

from math import factorial as f
N, K = map(int,input().split())

WARU = 10**9+7

def nCr(n, r):
    return f(n)//(f(r)*f(n-r))


for i in range(K):
    if i <= N-K:
        print((nCr(K-1, i) * nCr(N-K+1, i+1)) % WARU)
    else:
        print(0)
import math

def main():
    N, D = list(map(int, input().split()))
    ans = 0
    for i in range(0,N):
        A, B = list(map(int, input().split()))
        print(dist)
        if dist <= D:
            ans +=1
    print(ans)


if __name__ == '__main__':
    main()

### FIXED CODE ###

import math

def main():
    N, D = list(map(int, input().split()))
    ans = 0
    for i in range(0,N):
        A, B = list(map(int, input().split()))
        dist = math.sqrt(A**2 + B**2)
        if dist <= D:
            ans +=1
    print(ans)


if __name__ == '__main__':
    main()
n,x = map(int,input().split())

c = list(map(int,input().split()))
c.append(x)

from math import gcd

c.sort()
ans = c[1]-c[0]

for i in range(n-1):
    ans = gcd(ans,c[i+2]-c[i+1])

print(ans)


### FIXED CODE ###

n,x = map(int,input().split())

c = list(map(int,input().split()))
c.append(x)

def gcd(a,b):
    n = max(a,b)
    m = min(a,b)
    if n%m==0:
        return m
    else:
        return gcd(m,n%m)


c.sort()
ans = c[1]-c[0]

for i in range(n-1):
    ans = gcd(ans,c[i+2]-c[i+1])

print(ans)
password = list(input())
pw = set(password)
if len(pw) != 4:
  print("Bad")
  break
print("Good")


### FIXED CODE ###

password = list(input())
if password[0] == password[1] or password[1] == password[2] or password[2] == password[3]:
  print("Bad")
else:
  print("Good")
import copy

def print_list(A):
    print(*A, sep=" ")

def swap(a, b):
    return b, a

def val(str):
    return int(str[1])

def is_stable(_in, _out, n):
    for i in range(0, n):
        for j in range(i+1, n):
            for a in range(0, n):
                for b in range(a+1, n):
                    if val(_in[i]) == val(_in[j]) and _in[i] == _out[b] and _in[j] == _out[a]:
                        return False
    return True

def print_stable(_in, _out, n):
    if is_stable(_in, _out, n):
        print("Stable")
    else:
        print("Not stable")    

def find_minj(A, i, n):
    minj = i
    for j in range(i, n):
        if val(A[j]) < val(A[minj]):
            minj = j
    return minj        

def bubble_sort(A, n):
    A0 = copy.copy(A)
    flg = 1 #逆の隣接要素が存在する
    i = 0
    while flg:
        flg = 0
        for j in range(n-1, i, -1):
            if val(A[j-1]) > val(A[j]):
                A[j-1], A[j] = swap(A[j-1], A[j])
                flg = 1
        i += 1
    print_list(A)
    print_stable(A0, A, n)

def selection_sort(A, n):
    A0 = copy.copy(A)
    for i in range(0, n):
        minj = find_minj(A, i, n)
        if val(A[i]) > val(A[minj]):
            A[i], A[minj] = swap(A[i], A[minj])
    print_list(A)
    print_stable(A0, A, n)

n = int(input())
A = list(map(int,input().split()))
B = copy.copy(A)

bubble_sort(A, n)
selection_sort(B, n)


### FIXED CODE ###

import copy

def print_list(A):
    print(*A, sep=" ")

def swap(a, b):
    return b, a

def val(str):
    return int(str[1])

def is_stable(_in, _out, n):
    for i in range(0, n):
        for j in range(i+1, n):
            for a in range(0, n):
                for b in range(a+1, n):
                    if val(_in[i]) == val(_in[j]) and _in[i] == _out[b] and _in[j] == _out[a]:
                        return False
    return True

def print_stable(_in, _out, n):
    if is_stable(_in, _out, n):
        print("Stable")
    else:
        print("Not stable")    

def find_minj(A, i, n):
    minj = i
    for j in range(i, n):
        if val(A[j]) < val(A[minj]):
            minj = j
    return minj        

def bubble_sort(A, n):
    A0 = copy.copy(A)
    flg = 1 #逆の隣接要素が存在する
    i = 0
    while flg:
        flg = 0
        for j in range(n-1, i, -1):
            if val(A[j-1]) > val(A[j]):
                A[j-1], A[j] = swap(A[j-1], A[j])
                flg = 1
        i += 1
    print_list(A)
    print_stable(A0, A, n)

def selection_sort(A, n):
    A0 = copy.copy(A)
    for i in range(0, n):
        minj = find_minj(A, i, n)
        if val(A[i]) > val(A[minj]):
            A[i], A[minj] = swap(A[i], A[minj])
    print_list(A)
    print_stable(A0, A, n)

n = int(input())
A = list(map(str,input().split()))
B = copy.copy(A)

bubble_sort(A, n)
selection_sort(B, n)
a,b,c = map(int,input().split)

a = set(a,b,c)

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

### FIXED CODE ###

a,b,c = map(int,input().split())

s = set([a,b,c])

if len(s) == 2:
  print("Yes")
else:
  print("No")
a, b = map(int, input())

print((a-1)*(b-1))

### FIXED CODE ###

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

print((a-1)*(b-1))
N,K = map(int,input().split())
D  = {int(n) for n in input().split()}
for j in range(10000):
    if N <= j:
        L = {int(result) for result in str(j)}
        if D.isdisjoint(L):
            D_love = j
            break
print(D_love)


### FIXED CODE ###

N,K = map(int,input().split())
D  = {int(n) for n in input().split()}
for j in range(N,N*10):
    if N <= j:
        L = {int(result) for result in str(j)}
        if D.isdisjoint(L):
            D_love = j
            break    
print(D_love)