Harryxun/stf_run huggingface dataset:
from functools import reduce
from operator import mul

mod = 10**9 + 7

N, K = map(int, input().split())

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

if N == K:
    print(reduce(mul, A)%mod)

else:

    AP = []
    AM = []
    for i in A:
        if i < 0:
            AM.append(i)
        else:
            AP.append(i)
            
    if len(AP) == 0 and K%2 != 0:
        AM.sort(reverse=True)
        AM = AM[:K]
        print(reduce(mul, AM)%mod)

    else:
        
        AP.sort(reverse=True)
        AM.sort()
        
        ans = 1
        p = 0
        m = 0
        cnt = 0
        while True:
            if (K - cnt) == 1:
                ans *= AP[p]
                print(ans%mod)
                break
                
            elif 2 <= (len(AM) - m) and 2 <= (len(AP) - p):   
                if AP[p]*AP[p+1] >= AM[m]*AM[m+1]:
                    ans *= (AP[p]*AP[p+1])%mod
                    p += 2
                    cnt += 2
                
                else:
                    ans *= (AM[m]*AM[m+1])%mod
                    m += 2
                    cnt += 2 
                    
            elif 1 >= (len(AP) - p) and 2 <= (len(AM) - m):
                ans *= (AM[m]*AM[m+1])%mod
                m += 2
                cnt += 2 
            
            elif 2 <= (len(AP) - p) and 1 >= (len(AM) - m):
                ans *= (AP[p]*AP[p+1])%mod
                p += 2
                cnt += 2
            
            

            if cnt == K:
                print(ans%mod)
                break


### FIXED CODE ###

from bisect import bisect_left,bisect_right
p=10**9+7
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
pi=1
ni=0
ans=1
i=0
while i<k-1:
  if a[ni]*a[ni+1]>a[-pi]*a[-pi-1]:
    ans=ans*a[ni]*a[ni+1]%p
    ni+=2
    i+=2
  else:
    ans=ans*a[-pi]%p
    pi+=1
    i+=1
if i==k-1:
  ans=ans*a[-pi]%p
if a[-1]<0 and k%2==1:
  ans=1
  for i in a[n-k:]:
    ans=ans*i%p
print(ans)
n,a = map(int,input().split())
x = list(map(int,input().split()))
t = [[0]*5001 for _ in range(n+1)]
ans = 0
for i in range(1, n+1):
  for y in x:
    for z in t[i-1]:
      t[z+y-a] += 1
  ans += t[i][0]
print(ans)

### FIXED CODE ###

n,a = map(int,input().split())
x = list(map(int,input().split()))
t = [[[0] * (50*(j+1)+1) for j in range(i+2)] for i in range(n+1)]
ans = 0
t[0][0][0] = 1

for i in range(1, n+1):
    for j in range(i+1):
        for k in range(50*j + 1):
            if j >= 1 and k >= x[i-1]:
                t[i][j][k] = t[i - 1][j - 1][k - x[i-1]] + t[i - 1][j][k]
            else:
                t[i][j][k] = t[i - 1][j][k]
for i in range(1,n+1):
    ans += t[n][i][i*a]
print(ans)
N = int(input())

if N[-1] == 3:
  print('bon')
elif N[-1] == 0 or N[-1] == 1 or N[-1] == 6 or N[-1] == 8:
  print('pon')
else:
  print('hon')

### FIXED CODE ###

N = input()
 
if N[-1] == '3':
  print('bon')
elif N[-1] == '0' or N[-1] == '1' or N[-1] == '6' or N[-1] == '8':
  print('pon')
else:
  print('hon')
N = int(input())
A = [0 for i in range(N)]
for i in range(N):
    A[i] = list(map(str,input().split()))
for i in range(N):
    A[i].append(str(i+1))
for i in range(N):
    A[i][1] = int(A[i][1]) 


B = sorted(A, key=lambda x: x[1], reverse=True)

C = sorted(B, key=lambda x: x[0])

for i in range(N):
    print(int(C[i][2]))


### FIXED CODE ###

input_AP = list(map(int, input().split()))
A = input_AP[0]
P = input_AP[1]

result = (A*3 + P)//2
print(result)
N = int(input())
deliciaus = list(map(int , input().split()))

heal = 0

for i in range(N):
    for j in range(i+1 , N):
        heal += deliciaus[i] * deliciaus[j]
    
print(heal)

### FIXED CODE ###

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

if a <= 2*b:
    print(0)
if a > 2*b:
    print(a - 2*b)
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
from collections import defaultdict
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N,M = map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
flag = 0
order = 0
while True:
    for i in range(N):
        if a[i] % 2 == 0:
            a[i] = a[i] // 2
        else:
            cnt += 1
    if cnt == 0:
        order += 1
        continue
    elif cnt == N:
        break
    else:
        print(0)
        flag = 1
        break
if flag == 0:
    S = a[0]
    for i in range(1,N):
        p = math.gcd(S,a[i])
        S = (S*a[i]) // p
    q = S*(2**(order-1))
    loc = M // q
    if loc % 2 == 1:
        loc += 1
    print(loc // 2)

### FIXED CODE ###

import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
from collections import defaultdict
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N,M = map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
flag = 0
order = 0
while True:
    for i in range(N):
        if a[i] % 2 == 0:
            a[i] = a[i] // 2
        else:
            cnt += 1
    if cnt == 0:
        order += 1
        continue
    elif cnt == N:
        break
    else:
        print(0)
        flag = 1
        break
if flag == 0:
    S = a[0]
    for i in range(1,N):
        p = fractions.gcd(S,a[i])
        S = (S*a[i]) // p
    q = S*(2**(order-1))
    loc = M // q
    if loc % 2 == 1:
        loc += 1
    print(loc // 2)
n = int(input())
arr = []
out = {}

for i in range(n):
	arr.append(int(input()))
	
	if out.get(arr[-1], False):
		out[arr[-1]] += 1
	else:
		out[arr[-1]] = 1

count = 0
for key in out:
	if key > out[key]:
		count += out[key]
	else:
		count += out[key] - key

print(count)

### FIXED CODE ###

from collections import Counter
a = int(input())
l = list(map(int, input().split()))
#i = 1

c=Counter(l)
d = dict(c)
kv = []
for k,v in d.items():
    if k>v:
        kv.append(v)
    elif k<v:
        t = v-k
        kv.append(t)
s = sum(kv)
print(s)
a,b=map(int, input().split()) 
if A % b !=0:
    print(a//b+1)
else:
    print(a//b)

### FIXED CODE ###

a,b=map(int, input().split()) 
if a % b !=0:
    print(a//b+1)
else:
    print(a//b)
def f(N,S):
    alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    ret_s = ""
    for s in S:
        num = (alpha.index(str(s)) + N)
        if num <= 25:
            pass
        else:
            num = num-(num//25)*25-1
        ret_s += alpha[num]
    return print(ret_s)

N = input()
S = input()
f(N,S)

### FIXED CODE ###

def f(N,S):
    alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    ret_s = ""
    for s in S:
        num = (alpha.index(str(s)) + int(N))
        if num <= 25:
            pass
        else:
            num = num-(num//26)*26
        ret_s += alpha[num]
    return print(ret_s)
  
a = input()#13#
b = input()#"ABCDEFGHIJKLMNOPQRSTUVWXYZ"#
 
f(a,b)
#! /usr/bin/env python3
import itertools
N, A, B = map(int, input().split())
t = B - A + 1
if B <= A or N < 2:
    if A == B:
        print(1)
    else:
        print(0)
else:
    s = set()
    print(len({sum(i) for i in itertools.product(range(t), repeat = N - 2)}))

### FIXED CODE ###

#! /usr/bin/env python3
import itertools
N, A, B = map(int, input().split())
if B <= A or N < 2:
    if A == B:
        print(1)
    else:
        print(0)
else:
    print((B - A) * (N - 2) + 1)
S = input()

ans = 0
def dfs(num_string, p):
  global ans
  if p > len(S) - 1:
    #終わり
    ans += eval(num_string)
    return 
  
  #先頭の数字だけ扱いが微妙
  if p == 0:
    num_string  = "" + S[0]
    p = 1
  
  tmp = 0
  
  dfs(num_string + "+" + S[p], p+1)
  dfs(num_string + S[p], p+1)
  
  return

dfs(0,0)
print(ans)

### FIXED CODE ###

S = input()

ans = 0
def dfs(num_string, p):

  global ans
  
  if len(S) == 1:
    ans = int(S)
    return
  
  if p > len(S) - 1:
    #終わり
    ans += eval(num_string)
    return 
  
  #先頭の数字だけ扱いが微妙
  if p == 0:
    num_string  = "" + S[0]
    p = 1
  
  tmp = 0
  
  dfs(num_string + "+" + S[p], p+1)
  dfs(num_string + S[p], p+1)
  
  return

dfs(0,0)
print(ans)
N = int(input())
S = input()
K = int(input())

ans = ''
for i in S:
    if i == S[K]:
        ans += i
    else:
        ans += '*'

print(ans)


### FIXED CODE ###

N = int(input())
S = input()
K = int(input()) - 1
s = S[K]
ans = ''

for i in S:
    if i == s:
        ans += i
    else:
        ans += '*'

print(ans)
A,B,C=map(int,input().split())

print ((C,A,B).split())


### FIXED CODE ###

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

print (C,A,B)
import math
import bisect

N,M = map(int,input().split())
S=input()
T=input()

A=(N//math.gcd(N,M))*M

NL=[0]*N
ML=[0]*M

for i in range(N):
    NL[i]=i*(A//N)


for i in range(M):
    ML[i]=i*(A//M)


ANDL = sorted(list(set(NL) & set(ML)))

for i in ANDL:
    St=bisect.bisect_left(NL,i)
    Tt=bisect.bisect_left(ML,i)
    if(S[St]!=T[Tt]):
        print("-1")
        exit()
print(A)


### FIXED CODE ###

import fractions
import bisect

N,M = map(int,input().split())
S=input()
T=input()

A=(N//fractions.gcd(N,M))*M

NL=[0]*N
ML=[0]*M

for i in range(N):
    NL[i]=i*(A//N)


for i in range(M):
    ML[i]=i*(A//M)


ANDL = sorted(list(set(NL) & set(ML)))

for i in ANDL:
    St=bisect.bisect_left(NL,i)
    Tt=bisect.bisect_left(ML,i)
    if(S[St]!=T[Tt]):
        print("-1")
        exit()
print(A)
mport collections
N , C = map(int, input().split())
ds =[list(map(int, input().split())) for i in range(C)]
cs =[list(map(int, input().split())) for i in range(N)]
c0 = collections.defaultdict(int)
c1 = collections.defaultdict(int)
c2 = collections.defaultdict(int)
for i in range(N):
    for j in range(N):
        if (i+j) % 3 == 0:
            c0[cs[i][j]] += 1
        elif (i+j) % 3 == 1:
            c1[cs[i][j]] += 1
        else:
            c2[cs[i][j]] += 1
            
d = 10**9
for i in range(C):
    for j in range(C):
        if i == j:
            continue
        for k in range(C):
            if i == k or j == k:
                continue
            d0 = 0
            for l in c0:
                if l != i:
                    d0 += c0[l] * ds[l-1][i]
            for l in c1:
                if l != j:
                    d0 += c1[l] * ds[l-1][j]
            for l in c2:
                if l != k:
                    d0 += c2[l] * ds[l-1][k]
            if d > d0:
                d = d0
print(d)

### FIXED CODE ###

import collections
N , C = map(int, input().split())
ds =[list(map(int, input().split())) for i in range(C)]
cs =[list(map(int, input().split())) for i in range(N)]
c0 = collections.defaultdict(int)
c1 = collections.defaultdict(int)
c2 = collections.defaultdict(int)
for i in range(N):
    for j in range(N):
        if (i+j) % 3 == 0:
            c0[cs[i][j]] += 1
        elif (i+j) % 3 == 1:
            c1[cs[i][j]] += 1
        else:
            c2[cs[i][j]] += 1
            
d = 10**9
for i in range(C):
    for j in range(C):
        if i == j:
            continue
        for k in range(C):
            if i == k or j == k:
                continue
            d0 = 0
            for l in c0:
                d0 += c0[l] * ds[l-1][i]
            for l in c1:
                d0 += c1[l] * ds[l-1][j]
            for l in c2:
                d0 += c2[l] * ds[l-1][k]
            if d > d0:
                d = d0
            
print(d)
import array;R=range;L=input;T=[0]*28;N=int(L());S=[];U=N*26**2*array.array('i',[0]);V=N*[0];Q=int(L())
for I in R(N):
	S+=[[ord(C)-95 for C in L()]];P=0
	for C in S[I]:
		if T[P+C]==0:T[P+C]=len(T);T+=[0]*28
		T[P]+=1;P=T[P+C]
	T[P]+=1;T[P+1]=1
while N:
	N-=1;P=0
	for C in S[N]:
		for A in R(26):
			X=T[P+A+2]
			if(A!=C-2)*X:U[676*N+26*A+C-2]+=T[X]
		V[N]+=T[P+1]
		P=T[P+C]
while Q:
	K,P=L().split();K=int(K)-1;P=[ord(C)-97 for C in P];X=1+V[K]
	for A in R(26):
		for B in R(A+1,26):
			X+=U[676*K+26*P[A]+P[B]]
	print(X);Q-=1

### FIXED CODE ###

from array import*;R=range;T=[0]*28;N=int(input());S=[[ord(C)-95 for C in input()]for _ in[0]*N];U=N*26**2*array('i',[0]);V=N*[0];Q=int(input())
for X in S:
	P=0
	for C in X:
		if T[P+C]==0:T[P+C]=len(T);T+=[0]*28
		T[P]+=1;P=T[P+C]
	T[P]+=1;T[P+1]=1
for I in R(N):
	P=0
	for C in S[I]:
		for A in R(26):
			X=T[P+A+2]
			if(A!=C-2)*X:U[676*I+26*A+C-2]+=T[X]
		V[I]+=T[P+1]
		P=T[P+C]
while Q:
	K,P=input().split();K=int(K)-1;P=[ord(C)-97 for C in P];X=1+V[K]
	for A in R(26):
		for B in R(A+1,26):
			X+=U[676*K+26*P[A]+P[B]]
	print(X);Q-=1
n, k = map(int, input().split())

x = [0 for _ in range(n)]
y = [0 for _ in range(n)]
for i in range(n):
    x[i], y[i] = map(int, input().split())

min_x = min(x)
min_y = min(y)
for i in range(n):
    x[i] -= min_x
    y[i] -= min_y

sx = sorted(x)
sy = sorted(y)

if n == k:
    print(sx[n - 1] * sy[n - 1])
    exit()

d = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
for i in range(n):
    d[sx.index(x[i]) + 1][sy.index(y[i]) + 1] = 1

#for p in d: print(p)

for i in range(n + 1):
    for j in range(1, n + 1):
        d[i][j] += d[i][j - 1]

for i in range(n + 1):
    for j in range(1, n + 1):
        d[j][i] += d[j - 1][i]

sx = [0] + sx
sy = [0] + sy

a = 0
b = 1
ans = sx[n] * sy[n]
temp = 0
for p in range(n):
    for q in range(p + 1, n + 1):
        for a in range(n):
            for b in range(a + 1, n + 1):
                temp = d[q][b] - d[q][a] - d[p][b] + d[p][a]
                if temp >= k:
                    break
            if temp >= k:
                ans = min(ans, max(1, (sx[b] - sx[a + 1])) * max(1, (sy[q] - sy[p + 1])))

print(ans)

### FIXED CODE ###

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

a = sorted(a)

if a[0] == a[1]:
    print(a[2])
else:
    print(a[0])
K = int(input())
print('ACL'*k)

### FIXED CODE ###

K = int(input())
print('ACL'*K)
s=input().split('')
one=s.count('1')
zero=s.count('0')
print(2*min(one,zero))

### FIXED CODE ###

s=list(input())
one=s.count('1')
zero=s.count('0')
print(2*min(one,zero))
n,m=map(int,input().split())
l=[set(map(int,input().split())) for _ in range(m)]
S=set()
G=set()
for x in l:
	if 1 in x:S=S+x
	elif n in x:G=G+x
print('POSSIBLE' if len(S&G)>0 else 'IMPOSSIBLE')

### FIXED CODE ###

n,m=map(int,input().split())
l=[set(map(int,input().split())) for _ in range(m)]
S=set()
G=set()
for x in l:
	if 1 in x:S.add(max(x))
	elif n in x:G.add(min(x))
S=sorted(S)
G=sorted(G)
i=0
Glen=len(G)
for x in S:
	if i==Glen:break
	elif G[i]<x:
		while i<Glen and G[i]<x:
			i+=1
	if i<Glen and x==G[i]:
		print('POSSIBLE')
		exit()
print('IMPOSSIBLE')
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
a = 9999999
for i in range(N):
    ans += B[A[i]]
    if A[i] == a + 1:
        ans += C[a]
    a = A[i]

print(ans)

### FIXED CODE ###

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

ans = 0
a = 9999999
for i in range(N):
    ans += B[A[i]-1]
    if A[i] == a + 1:
        ans += C[a-1]
    a = A[i]

print(ans)
import sys
input = sys.stdin.readline
import numpy as np

N, W = map(int, input().split())
dp = np.zeros(W+1, dtype=int)

for i in range(N):
    w, v = map(int, input().split())
    dp[w:] = np.maximum(dp[w:], dp[:-w]+v)
print(dp[-1])

### FIXED CODE ###

import sys
input = sys.stdin.readline

n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]

dp = [[0]*(w+1) for _ in range(n)]

for i in range(wv[0][0], w+1):
    dp[0][i] = wv[0][1]

for i in range(1, n):
    for j in range(w+1):
        if j-wv[i][0] < 0:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-wv[i][0]]+wv[i][1])
print(dp[n-1][w])
import math
from functools import reduce, gcd
import sys


def gcd(*numbers):
    return reduce(gcd,numbers)

n, x = list(map(lambda x : int(x),input().split()))

zahyo = list(map(lambda x : int(x),input().split()))

zahyo.append(x)
zahyo.sort()

min = zahyo[1] - zahyo[0]

is_odd = False
is_even = False

odds = list()

for i in range(n):
    diff = zahyo[i+1] - zahyo[i]

    if diff % 2 == 0:
        is_even == True
    else:
        is_odd = True
        odds.append(diff)

    if diff < min:
        min = zahyo[i+1] - zahyo[i]

# print(is_odd)
# print(is_even)
if is_odd == True and is_even == True or gcd(*odds) == 1:
    print(1)
    sys.exit()

# print(gcd(*odds))

print(min)


### FIXED CODE ###

import math
from functools import reduce
import fractions
import sys


def gcd(*numbers):
    return reduce(fractions.gcd,numbers)


n, x = list(map(lambda x : int(x),input().split()))

zahyo = list(map(lambda x : int(x),input().split()))

zahyo.append(x)
zahyo.sort()

min = zahyo[1] - zahyo[0]

is_odd = False
is_even = False

odds = list()

for i in range(n):
    diff = zahyo[i+1] - zahyo[i]

    if diff % 2 == 0:
        is_even == True
    else:
        is_odd = True
        odds.append(diff)

    if diff < min:
        min = zahyo[i+1] - zahyo[i]

# print(is_odd)
# print(is_even)
if is_odd == True and is_even == True:
    print(1)
    sys.exit()

elif is_odd == True:
    print(gcd(*odds))
else:

    print(min)
import heapq
INF=float('inf')

n,m=map(int,input().split())
adj=[[] for _ in range(n+1)]
for _ in range(m):
  x,y=map(int,input().split())
  adj[x].append(y)
  
dp=[-1 for _ in range(n+1)]

def f(k):
  if dp[k]!=-1:
    return dp[k]
  
  dp[k]=0
  if adj[k]:
    for v in adj[k]:
      dp[k]=max(dp[k],f(v)+1)
  return dp[k]

dp[0]=0
for i in range(1,n+1):
  dp[i]=-1

ans=-INF  
for i in range(1,n+1):
  ans=max(ans,f(i))

print(ans)



### FIXED CODE ###

import sys

sys.setrecursionlimit(10**9)
INF=float('inf')

n,m=map(int,input().split())
adj=[[] for _ in range(n+1)]
for _ in range(m):
  x,y=map(int,input().split())
  adj[x].append(y)
  
dp=[-1 for _ in range(n+1)]

def f(k):
  if dp[k]!=-1:
    return dp[k]
  
  dp[k]=0
  if adj[k]:
    for v in adj[k]:
      dp[k]=max(dp[k],f(v)+1)
  return dp[k]

ans=-INF  
for i in range(1,n+1):
  ans=max(ans,f(i))

print(ans)
#El Patron
S = list(input())

pre_list = []
tar_list = [S[0]]
count = 1
a = 1
try:
	while a < len(S):
		pre_list = tar_list 
		tar_list = []
		tar_list.append(S[i])
		a += 1
	
		while tar_list == pre_list:
			tar_list.append(S[i])
			a += 1
	
		count += 1

except IndexError:
	pass
print(count)

### FIXED CODE ###

S = list(input())

pre_list = []
tar_list = [S[0]]
count = 1
i = 1
try:
	while i < len(S):
		pre_list = tar_list 
		tar_list = []
		tar_list.append(S[i])
		i += 1
		
		while tar_list == pre_list:
			tar_list.append(S[i])
			i += 1
	
		count += 1

except IndexError:
	pass
print(count)
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
i=0
manzoku=0
j=0
while i<N:
    manzoku += B[i]
    i += 1
if A[0]=1:
    manzoku += sum(C)
else:
    manzoku += sum(C) - C[A[0]]

print('manzoku')


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
i = 1
manzoku = sum(B)
while N>i:
    if A[i]-A[i-1] == 1:
      j = A[i-1]
      manzoku += C[j-1]
    i += 1
print(manzoku)
from heapq import heappush, heappop

n, m = map(int, input().split())
edges = [[] for _ in range(n)]

for _ in range(n):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)

INF = 10**18
ans = []


def dijkstra(N, G, s):
    dist = [INF] * n
    que = [(0, s)]
    dist[s] = 0
    while que:
        c, v = heappop(que)
        if dist[v] < c:
            continue
        for t in G[v]:
            if dist[v] + 1 < dist[t]:
                dist[t] = dist[v] + 1
                heappush(que, (dist[t], t))
    ans.append(dist[0])


for i in range(1, n):
    dijkstra(n, edges, i)

if 0 in ans:
    print('No')
else:
    print('Yes')
    print(*ans, sep='\n')


### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
edges = [[]for _ in range(n)]
for _ in range(m):
    a, b = map(lambda x: int(x)-1, input().split())
    edges[a].append(b)
    edges[b].append(a)

next_v = deque([0])
prev = [-1]*n
while next_v:
    v = next_v.popleft()
    for v2 in edges[v]:
        if prev[v2] != -1:
            continue
        prev[v2] = v+1
        next_v.append(v2)

print('Yes')
for x in prev[1:]:
    print(x)
X=int(input())
if X==3 or x==5 or X==7:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

X=int(input())
if X==3 or X==5 or X==7:
  print("YES")
else:
  print("NO")
A, B = int(input().split())
if A >=10 or B >=10:
  print ("-1")
else:
  print (A*B)

### FIXED CODE ###

A, B = list(map(int,input().split()))
if A >=10 or B >=10:
  print ("-1")
else:
  print (A*B)
n = int(input())
height_lst = list(map(int,input().split()))
flag = True

if n==1:
    print('Yes')
else:
    if height_lst[0]==1:
        height1 = 1
    elif height_lst[0]>1:
        height1 = height_lst[i]-1

    for i in range(1,n):
        height = height_lst[i]
        if height==1:
            possible_lst = [1]
        elif height>1:
            possible_lst = [height-1,height]

        if max(possible_lst)<height1:
            flag = False
            break
        else:
            if min(possible_lst)>=height1:
                height1 = min(possible_lst)
            else:
                height1 = max(possible_lst)
                
    if flag:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

n = int(input())
height_lst = list(map(int,input().split()))
flag = True

if n==1:
    print('Yes')
else:
    if height_lst[0]==1:
        height1 = 1
    elif height_lst[0]>1:
        height1 = height_lst[0]-1

    for i in range(1,n):
        height = height_lst[i]
        if height==1:
            possible_lst = [1]
        elif height>1:
            possible_lst = [height-1,height]

        if max(possible_lst)<height1:
            flag = False
            break
        else:
            if min(possible_lst)>=height1:
                height1 = min(possible_lst)
            else:
                height1 = max(possible_lst)

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