peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
*o, = open(0)

import numpy as np

(n, m, x), *ca = map(lambda x: np.array(list(map(int, x.split()))), o)

INF = 1 << 31

ans = INF

for i in range(2**n):
    tmp = np.zeros(m+1, int)
    sel = []
    for j, dig in enumerate(bin(i)[2:][::-1]):
        if int(dig):
            tmp += ca[j]
            sel.append(j)
    if min(tmp[1:]) >= x:
        ans = min(ans, tmp[0])
        

if ans == INF:
    print(-1)
else:
    print(ans)
# Judge status: Accepted
from math import *

a = int(input())
t = gcd(360, a)
print(360//t)
# Judge status: Accepted

import math
import itertools
import statistics
#import collections
x = int(input())

s =  x//11

if 11*s == x:
    ans = s*2
elif 11*s < x:
    if 11*s+6 >= x:
        ans = s*2+1
    else:
        ans = s*2+2
else:
    ans = s*2-1

#print(11*s)
print(ans)
# Judge status: Wrong Answer
from unittest.mock import patch
import numpy as np

def takahashi_info():
    
    A = []
    for i in range(3):
        A += [int(j) for j in input().split()]

        
    if sum(A) % 3 == 0:
        print("Yes")
    
    else:
        print("No")
# Judge status: Accepted
n = int(input())
t, a = list(map(int, input().split()))
h = list(map(int, input().split()))

diff_temp = list(map(lambda x: abs(t - x * 0.006 - a), h))
print(diff_temp.index(min(diff_temp)) + 1)
# Judge status: Accepted
from collections import Counter

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

mod = 998244353
c = Counter(D)
m = max(c.keys())

if D[0] == 0 and c[0] == 1:
    ans = 1
    for i in D[1:]:
        ans *= c[i-1]
        ans %= mod
    print(ans)
else:
    print(0)
# Judge status: Wrong Answer
s=list(input())
t=list(input())
for i, _s in enumerate(s):
    if s == t:
        break
    else:
        if _s != t[i]:
            s[i] = t[i]
        else:
            continue

print(i)
# Judge status: Accepted
a,v = map(int, input().split())
b,w = map(int, input().split())
t = int(input())
if v <= w:
    print("NO")
elif abs(a-b) > t*(v-w):
    print("NO")
else:
    print("YES")
# Judge status: Accepted
a,b=map(int,input().split())
if b < a:
  a -= 1
print(a)
# Judge status: Accepted
n = int(input())
s = input()
n_s = ""
for i in range(len(s)):
    if ord(s[i])+n > 90:
        n_s+=chr(ord(s[i])+n-26)
    else:
        n_s+=chr(ord(s[i])+n)
    
print(n_s)
# Judge status: Accepted
import queue
K = int(input())

q = queue.Queue()

for i in range(1,10):
    q.put(i)

for i in range(K-1):
    x = q.get()

    if x%10 == 0:
        q.put(x*10 + 0)
        q.put(x*10 + 1)
    elif x%10 == 9:
        q.put(x*10 + 8)
        q.put(x*10 + 9)
    else:
        q.put(x*10 + x%10-1)
        q.put(x*10 + x%10)
        q.put(x*10 + x%10+1)
    
print(q.get())
# Judge status: Accepted
from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
flag = True
b = gcd(a[0], a[1])
for i in range(2, n):
    b = gcd(a[i], b)
print(b)
# Judge status: Accepted
N, M = list(map(int, input().split()))

A = [input().strip() for _ in range(N)]
B = [input().strip() for _ in range(M)]
temp = "".join(B)


ans = False

for j in range(N-M+1):
    for i in range(N-M+1):
        tmp = ""
        for y in range(M):
            tmp += A[j+y][i: i + M]
        if tmp == temp:
            ans = True

if ans:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
ans = -1
nearest = 10**18
for i in range(n):
    target = abs(t - h[i] * 0.006)
    if abs(a - nearest) > abs(a - target):
        nearest = target
        ans = i
print(ans + 1)
# Judge status: Accepted
S = input()
C = ["0","1"] 
count1=count2=0

for i in range(len(S)):
  # case 1
  if S[i] == C[i%2]:
    count1+=1
  # case 2
  if S[i] == C[(i+1)%2]:
    count2+=1

print(min([count1, count2]))
# Judge status: Accepted
N = int(input())
A = [10 ** 5 for _ in range(N)]
B = list(map(int, input().split()))
for i in range(N - 1):
    if B[i] < A[i]:
        A[i] = B[i]
    if B[i] < A[i + 1]:
        A[i + 1] = B[i]
print(sum(A))
# Judge status: Accepted
N, *X = map(int, open(0).read().split())

ans = float("inf")
for p in range(1, 101):
    ans = min(ans, sum((x - p) ** 2 for x in X))

print(ans)
# Judge status: Wrong Answer
list=input()
newlist=[list[i: i+1] for i in range(0,len(list))]
# Judge status: Accepted
q, h, s, d = map(int, input().split())
n = int(input())

l = min(q*4, h*2, s)
l2 = min(q*8, h*4, s*2, d)
if n % 2 == 0:
    ans = l2 * (n//2)
else:
    ans = l2 * (n//2) + l
print(ans)
# Judge status: Wrong Answer
A, B, C, D = map(int, input().split())

if D < B and C < B:
    print(D-C)
elif C < B:
    print(B-C)
else:
    print(0)
# Judge status: Accepted
n, x, y = map(int, input().split())
x, y = x-1, y-1

dist = [0] * n

for i in range(n):
    for j in range(i+1, n):
        dist[min(j-i, abs(y-j) + abs(x-i) + 1)] += 1

for k in range(1, n):
    print(dist[k])
# Judge status: Accepted
from collections import defaultdict

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

cnt = defaultdict(int)
for num in a:
    for i in [-1, 0, 1]:
        cnt[num + i] += 1
ans = 0
for i in cnt:
    ans = max(cnt[i], ans)
print(ans)
# Judge status: Accepted
N = int(input())

for i in range(10):
    if 111*i < N <= 111*(i+1):
        print(111*(i+1))
# Judge status: Wrong Answer
s=input()
f=int(s[:2])
b=int(s[2:4])

if (f>=13 or f==00)and b>=13 :
    print('NA')
elif (f>=13 or f==00)and b<=12 :
    print('YYMM')
elif f<=12 and (b>=13 or b==00) :
    print('MMYY')
else:
    print('AMBIGUOUS')
# Judge status: Accepted
n=input("")
s=int(n[-1])
if s==3:
    print("bon")
elif s==0 or s==1 or s==6 or s==8:
    print("pon")
else:
    print("hon")
# Judge status: Wrong Answer
N = int(input())

ans =N*(N+1)/2

print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-
x = int(input())

if x <= 6:
    print(1)
    exit()
if 6 < x <= 11:
    print(2)
    exit()
ans = (x // 11)
point = ans * 11
ans *= 2
#print(point, ans)
#print(point)
while point < x:
    if ans % 2 == 0:
        point += 6
        ans += 1
    elif ans % 2 == 1:
        point += 5
        ans += 1
print(ans)
# Judge status: Accepted
a, b, k = map(int, input().split())
ans = []
for i in range(1, max(a, b)+1):
    if a % i == 0 and b % i == 0:
        ans.append(i)
print(ans[-k])
# Judge status: Accepted
a, b, c = map(int, input().split())

ans = c - (a-b) 

if ans < 0:
  print(0)
else:
  print(ans)
# Judge status: Accepted
if __name__ == "__main__":
    a, b, c = list(map(int, input().split()))

    if a == b and b != c:
        print('Yes')
    elif a == c and a != b:
        print('Yes')
    elif b == c and a != c:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
S=input()
if S.isupper():
  print('A')
else:
  print('a')
# Judge status: Accepted
n,m = map(int,input().split())

l = [list(map(int,input().split())) for i in range(m)]

max_l = -1*float('INF')
min_r = float('INF')
for i in range(m):
    max_l = max(max_l,l[i][0])
    min_r = min(min_r,l[i][1])

ans = min_r - max_l + 1

if(ans < 0):
    print(0)
    exit()

if(ans <= n):
    print(ans)
else:
    print(n)
# Judge status: Accepted
r, g, b = map(int, input().split())
if (g*10 + b)% 4 == 0:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
a = input()
b = input()
if a[0] == b[-1] and a[1] == b[1] and a[-1] == b[0]:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
def p(S):
    D={}
    for i in range(len(S)):
        a=S[i]
        if a in D:
            D[a].add(i)
        else:
            D[a]={i}
    return D
S=input()
T=input()

A=sorted(p(S).values())
B=sorted(p(T).values())

if A==B:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
S = input()

if S == 'ARC':
  print('ABC')
elif S == 'ABC':
  print('ARC')
# Judge status: Accepted
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.append(0)
s=input()
ans=0
for i in range(k,n):
  if s[i]==s[i-k]:
    s=s[:i]+'z'+s[i+1:]
for i in range(n):
  ans+=a['sprz'.index(s[i])]
print(ans)
# Judge status: Wrong Answer
#二分探査かぁ…
from math import *
import fractions
import collections
import itertools
import pprint
from collections import deque
from heapq import *
N,K=map(int,input().split())
A=list(map(int,input().split()))
maxnum=10**9+20
minnum=1
while maxnum-minnum>1:
    cnt=0
    piv=(maxnum+minnum)//2
    for i in range(N):
        cnt=cnt+ceil(A[i]/piv)-1
    #print(cnt,piv)
    if cnt>K:
        minnum=piv
    else:
        maxnum=piv
    #print(maxnum,minnum)
    #input()
print(maxnum)
# Judge status: Accepted
n,k=map(int,input().split())
s=input()
c=0
for i in range(n-1):
  if s[i]==s[i+1]:
    c+=1
ans=c+2*k
if ans>n-1:
  ans=n-1
print(ans)
# Judge status: Accepted
#!/usr/bin/env python3
def main():
    def expected_val(limit):
        return (1 + limit) / 2

    N, K = map(int, input().split())
    P = [int(x) for x in input().split()]

    lst = [0]
    res = 0
    for p in P:
        res += p + 1
        lst.append(res)
    ans = 0
    for i in range(N - K + 1):
        res = lst[i + K] - lst[i]
        ans = res if res > ans else ans
    print(ans / 2)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n=int(input())
if n%2==1:
  print(str(((n-1)/2+1)/2)+"\n")
else:
  print(str(1/2)+"\n")
# Judge status: Wrong Answer
import math
S = int(input())

a = int(math.sqrt(S))
if S % a > 0:
  a += 1
b = a**2 - S
c = 1
while b > 10**9:
  for i in range(2, int(math.sqrt(b))+1):
    if b % i == 0:
      b %= i
      c *= i
      break
print(0, 0, a, b, c, a)
# Judge status: Wrong Answer
N=int(input())
a=list(map(int,input().split()))
#a=[i+1 for i in range(3*N)]
a.sort()
l=a[N:2*N]
print(int(sum(l)))
# Judge status: Accepted
N, A, B = map(int, input().split())
s = input()
 
x, y = 0, 0
for i, p in enumerate(s):
    if p=="a":
        if x < A+B:
            print("Yes")
            x+=1
        else:
            print("No")
    elif p=="b":
        if x < A+B and y < B:
            print("Yes")
            x+=1
            y+=1
        else:
            print("No")
    else:
        print("No")
# Judge status: Accepted
a=0
n=int(input())
for i in range(n+1):
    if i%3!=0 and i%5!=0:
        a += i
print(a)
# Judge status: Accepted
N = int(input())

ans = N * int(N - 1)

ans = ans // 2

print(ans)
# Judge status: Wrong Answer
n,k,q = map(int,input().split())

p = [k]*n
a = [0]*q

for i in range(0,q):
  a[i] = int(input())

for i in range(0,n):
  p[i] = p[i] - q
for i in range(0,q):
  p[a[i]-1] += 1
#print(p)

for i in range(0,n):
  if(p[i] <= 0):
    print("No")
  else:
    print("yes")
# Judge status: Accepted
A,B=map(int,input().split())

if A==B:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import math
a,b,h,m = map(int, input().split(" "))

hrad = h * 30 + m * 0.5
mrad = m * 6

l = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(math.radians(abs(hrad - mrad))))
print(l)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
b=0
c=0
for i in range(n):
  if a[i]%2==0:
    if a[i]%4==0:
      c+=1
    else:
      b+=1
print("Yes") if n<= b+3*c else print("No")
# Judge status: Accepted
S = input()
res = "Yes"
if "N" in S:
    if "S" not in S:
        res = "No"
if "W" in S:
    if "E" not in S:
        res = "No"
if "S" in S:
    if "N" not in S:
        res = "No"
if "E" in S:
    if "W" not in S:
        res = "No"
print(res)
# Judge status: Accepted
import math
N, M = map(int, input().split())

if abs(N - M) >= 2:
    ans = 0

elif N == M:
    ans = 2 * math.factorial(N) * math.factorial(M)

elif abs(N - M) == 1:
    ans = math.factorial(N) * math.factorial(M)

print(ans % (10**9 + 7))
# Judge status: Accepted
A,B,T=map(int,input().split())

print(B*(T//A))
# Judge status: Accepted
S=input()
if S[0]=='A' and S.count('C')==1 and 'C' in S[2:-1]:
    for c in S[1:len(S)]:
        if not (c.islower() or c=='C'):
            print("WA")
            break
    else:
        print("AC")
else:
    print("WA")
# Judge status: Accepted
a = list(map(int, input().split()))
if len(set(a)) == 2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
s = str(input())
n = len(s)
a = 0
b = 0
apple = ("10" * n)[:n]
orange = ("01" * n)[:n]
for i in range(n):
    if apple[i] != s[i]:
        a += 1
    if orange[i] != s[i]:
        b += 1
print(min(a, b))
# Judge status: Accepted
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
# from functools import lru_cache
# @lru_cache(maxsize=None)


n = int(input())
h = list(map(int, input().split()))
cost = [0]*n

cost[0] = 0
cost[1] = abs(h[1]-h[0])

for i in range(2,n):
    cost[i] = min(cost[i-1]+abs(h[i]-h[i-1]), cost[i-2]+abs(h[i]-h[i-2]))
print(cost[n-1])
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

ans = 0
pos = 0
pos1 = 0
pos2 = 0

while True:
    if pos==N:
        break
    pos1 = pos
    pos2 = pos
    while pos1<N-1 and A[pos1] <= A[pos1+1]:
        pos1 +=1
#     print(pos1)
    while pos2<N-1 and A[pos2] >= A[pos2+1]:
        pos2 +=1
#     print(pos2)
    large = max(pos1, pos2)
    pos = large+1
    ans += 1
print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
step = 0
for i in range(N - 1):
  step += max(0, A[i + 1] - A[i])
  A[i + 1] += max(0, A[i + 1] - A[i])
print(step)
# Judge status: Accepted
a, b = map(int, input().split())

cont = 0

for i in range(a, b+1):
    if str(i) == str(i)[::-1]:
        cont +=1
        
print(cont)
# Judge status: Accepted
n,m=map(int,input().split())
s=0
t=10**10
for i in range(m):
  l,r=map(int,input().split())
  s=max(s,l)
  t=min(t,r)

if s>t:
  print(0)
else:
  print(t-s+1)
# Judge status: Accepted
# AtCoder Beginner Contest 132
# B - Ordinary Number

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

ans=0

for i in range (n-2):
    a=pls[i]
    b=pls[i+1]
    c=pls[i+2]
    if a<b<c or c<b<a:
        ans+=1

print(ans)
# Judge status: Accepted
N,A,B = map(int, input().split())
S = input()
ok = 0
ok_b = 0

for i in range(N):
  if S[i] == 'a':
    if ok < A+B:
      print('Yes')
      ok += 1
    else:
      print('No')
  elif S[i] == 'b':
    if ok < A+B and ok_b < B:
      print('Yes')
      ok += 1
      ok_b += 1
    else:
      print('No')
  else:
    print('No')
# Judge status: Wrong Answer
i = list(map(int, input().split()))
n = i[0]
m = i[1]
dif = n -2*m
for num in range(m):
    print(n - num, num + dif)
# Judge status: Accepted
N,M=map(int,input().split())
L=[0]*N
c={}
mod=1000000007
for i in range(M):
  k=int(input())
  c[k]=0
for i in range(N):
  if i==0:
    L[i]=1
  elif i==1:
    if L[0]==0:
      L[i]=1
    else:
      L[i]=2
  else:
    L[i]=(L[i-1]+L[i-2])%mod
  if i+1 in c:
    L[i]=0
print(L[N-1])
# Judge status: Wrong Answer
ans=0
for i in list(input()):
    if i in {"A","G","C","T"}:ans+=1
print(ans)
# Judge status: Wrong Answer
N,M=map(int,input().split())
H=list(map(int,input().split()))
AB=[]
for i in range(M):
    AB.append(list(map(int,input().split())))

J=[0]*N
for i in range(M):
    if H[AB[i][0]-1]<=H[AB[i][1]-1]:
        J[AB[i][0]-1]+=1
    else:
        J[AB[i][1]-1]+=1
c=0
for i in J:
    if i == 0:
        c+=1

print(c)
# Judge status: Accepted
s = input()
for i in range(2**3):
    l=[]
    for j in range(3):
        if (i>>j)&1:
            l.append("+")
        else:
            l.append("-")
    x = ""
    for k,lp in zip(s,l):
        x+=k
        x+=lp
    x+=s[-1]
    if eval(x)==7:
        print(x+"=7")
        break
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

ans = 10**8 
sum_A = sum(A)
CumSum = 0


for i in range(N-1):
  CumSum = CumSum + A[i]
  ans = min(ans,(abs((sum_A - CumSum)-(CumSum))))

print(ans)
# Judge status: Accepted
n = int(input())
w = [input() for i in range(n)]
f = 0
for i in range(n-1):
    if w[i][len(w[i])-1] != w[i+1][0]:
        f = 1
    for j in range(n):
       if j != i:
            if w[i] == w[j]:
                f = 1
if f==1:
    print('No')
else:
    print('Yes')
# Judge status: Wrong Answer
def main():
  n,q=map(int,input().split())
  s=input()
  t = [0] * (n + 1)
  for i in range(n):
    t[i + 1] = t[i] + (1 if s[i : i + 2] == 'AC' else 0)
  for i in range(q):
    l, r = map(int, input().split())
  print(t[r-1] - t[l-1])
if __name__=='__main__':
  main()
# Judge status: Accepted
s = input()
k = int(input())

ans = ""
for si in s:
  if si == "a":
    ans += "a"
    continue
  num = ord("z") - ord(si) + 1
  if num <= k:
    ans += "a"
    k -= num
  else:
    ans += si

if k > 0:
  num = k % 26
  if ord(ans[-1]) + num <= ord("z"):
    new_c = chr(ord(ans[-1]) + num)
  else:
    num -= ord("z") - ord(ans[-1])
    new_c = chr(ord("a") - 1 + num)
  print(ans[:-1] + new_c)
else:
  print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse = True)
list = []

for i, j in enumerate(a):
    if i % 2 == 1:
        list.append(j)

answer = sum(list[0 : n])

print(answer)
# Judge status: Wrong Answer

s = list(map(int,input().split()))
SUM = s[0]+s[1]+s[2]

if SUM%2 ==0:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
N, M=map(int, input().split())
info=[]
for _ in range(N):
  a, b=map(int, input().split())
  info.append([a,b])

info.sort(key=lambda x:x[1])
ans=0
for a, b in info:
  if M>=b:
    ans+=a*b
    M-=b
  elif M<b and M>0:
    ans+=a*M
    break
  else:
    break
print(ans)
# Judge status: Accepted
w,a,b = map(int,input().split())
if b - a - w >= 0:
    print(b - a - w)
elif a - b - w>=0:
    print(a - b - w)
else:
    print(0)
# Judge status: Accepted
def resolve():
	n, m = map(int, input().split())
	v = [[] for i in range(n+1)]
	for i in range(m):
		a, b = list(map(int, input().split()))
		v[a].append(b)
	ans = 'IMPOSSIBLE'
	for i in range(len(v[1])):
		if n in v[v[1][i]]:
			ans = 'POSSIBLE'
			break
	print(ans)
resolve()
# Judge status: Accepted
import heapq
n,m = map(int, raw_input().split(' '))
ais = map(int, raw_input().split(' '))
ais.sort()
heap = []
for _ in range(m):
	u,v = map(int,raw_input().split(' ')) 
	heapq.heappush(heap, (-v,u))
res = 0
for j in range(n):
	
	if heap and -heap[0][0] > ais[j]:
		u,v = heapq.heappop(heap)
		v-=1
		res += -u
		if v >= 1: heapq.heappush(heap, (u,v))
	else:
		res += ais[j]
print res
# Judge status: Wrong Answer
x, a, b = (int(i) for i in input().split())
da = abs(x-a)
db = abs(x-b)
if da > db:
  print('A')
else:
  print('B')
# Judge status: Accepted
n = int(input())
lst = []

for i in range(n):
    x = int(input())
    lst.append(x)

a = max(lst)
b = []
for i in range(n):
    if (lst[i] == a):
        b.append(i)

if (len(b) > 1):
    for i in range(n):
        print(a)

else:
    lst[b[0]] = 0
    c = max(lst)
    for i in range(n):
        if (i == b[0]):
            print(c)
        else:
            print(a)
# Judge status: Accepted
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    if n % 2 != 0:
        print(0)
    else:
        f = [2] * 30
        for i in range(29):
            f[i + 1] = 5 * f[i]
        ans = 0
        for i in range(1, 30):
            ans += (n // f[i])
        print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
# Judge status: Accepted
import math
n = int(input())
sum = 0
for i in range(1,n+1):
    for j in range(i+1,n+1):
        for k in range(j+1,n+1):
            sum += math.gcd(math.gcd(k,j), i)
sum = sum * 6
sum_2 = 0
for i in range(1,n+1):
    for j in range(i+1,n+1):
         sum_2 += math.gcd(i,j)
     
sum_2= sum_2*3*2
sum_3 = n*(n+1)/2

sum= sum + sum_2+ sum_3
print(int(sum))
# Judge status: Accepted
n=int(input())
a=int(input())
b=min(a,int(input()))
c=min(b,int(input()))
d=min(c,int(input()))
e=min(d,int(input()))
import math
print(math.ceil(n/e)+4)
# Judge status: Wrong Answer
import numpy as np
MOD = 10 ** 9 + 7
N = int(input())
A = list(map(int,input().split()))
cnt = []
A = np.array(A)
for _ in range(60):
    ad = A % 2
    cnt.append(np.sum(ad))
    A = A // 2
ans = 0
for i in range(60):
    num0 = N - cnt[i]
    num1 = cnt[i]
    ans += ((num0 * num1) * (2 ** i)) % MOD
    ans %= MOD
print(ans)
# Judge status: Wrong Answer
a,b,c,d=map(int,input().split())
x=0
if b>=0 and d>=0:
  x=b*d
elif b>=0 and d<0:
  x=a*d
elif b<0 and d>=0:
  x=b*c
elif b<0 and d<0:
  x=a*c

print(x)
# Judge status: Accepted
n=int(input())
h=list(map(int,input().split()))
for i in range(n-2,-1,-1):
    if h[i]>h[i+1]:
        h[i]-=1
for i in range(n-1):
    if h[i]>h[i+1]:
        print("No")
        exit()
print("Yes")
# Judge status: Accepted
N, M = map(int, input().split())

pairs = []
for i in range(M):
    pairs.append(list(map(int, input().split())))

for i in range(1,N+1):
    s = 0
    for pair in pairs:
        if i in pair:
            s += 1
    print(s)
# Judge status: Accepted
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

import string

N = int(input())
S = list(input())

cnt = [0 for i in range(26)]

for i in range(N):
    mm = ord(S[i])-97
    cnt[mm] += 1

mod = 10**9+7
ans = 1
for i in range(26):
    ans *= cnt[i]+1
    ans %= mod
print(ans-1)
# Judge status: Accepted
A = list(map(int,input().split()))
if sum(A) >= 22:
  print('bust')
else:
  print('win')
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
x = int(input())

if 100 <= x and 0 <= x % 100 <= 5:
    print(1)
else:
    print(0)
# Judge status: Accepted
k = int(input())
if k%2 == 0:
    print((k//2)**2)
else:
    print((k//2)*(k//2+1))
# Judge status: Wrong Answer
K = int(input())
S = list(str(input()))

if len(S) <= K:
      print(S)

else:
         m = S[0:K]
         m.append('...')
         print("".join([str(n) for n in m]))
# Judge status: Wrong Answer
N = int(input())
X = list(map(int, input().split()))

ave = -1*(-1*sum(X)//len(X))
dist = [(i-ave)**2 for i in X]

print(sum(dist))
# Judge status: Accepted
A=int(input())
B=int(input())
List=[A,B]

print(6-sum(List))
# Judge status: Wrong Answer
def main():
    N, M, K = (int(i) for i in input().split())
    ans = set()
    for i in range(N+1):
        for j in range(M+1):
            if M-i > 0:
                ans.add(N*i + (M-i)*j - i*j)
            else:
                ans.add(0)
    if K in ans:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
number = input()
sum = 0
for i in number:
    sum += int(i)
if sum / 9:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N,X=map(int,input().split())
x=list(map(int,input().split()))
for i in range(N):
  x[i]=abs(x[i]-X)
x.sort()
for i in range(N):
  if x[i]%x[0]!=0:
    x[0]=x[0]-1
print(x[0])
# Judge status: Wrong Answer
X = int(input())
x1 = 100
r = 0.01
t = 0
while x1 <= X:
    R = int(x1 * r)
    x1 = R + x1
    t = t + 1
    #print(x1,R)
print(t)
# Judge status: Wrong Answer
n,a,b=map(int,input().split())
s=input()
passed=0
rank_b=1
for i in range(n):
    if s[i]=="a":
        if passed<a+b:
            print("yes")
            passed+=1
        else:
            print("No")
    elif s[i]=="b":
        if passed<a+b and rank_b<=b:
            print("Yes")
            rank_b+=1
            passed+=1
        else:
            print("No")
    else:
        print("No")
# Judge status: Accepted
K, N = map(int, input().split())
A = list(map(int, input().split()))

if N == 2:
    print(min(A[1] - A[0], K + A[0] - A[1]))

max_distance = 0

if N > 2:
    for i in range(N - 1):
        s = A[i + 1] - A[i]
        if s > max_distance:
            max_distance = s

    print(min(K - max_distance, A[N - 1] - A[0]))
# Judge status: Accepted
n,l = map(int,input().split())
p1 = [(l+i-1) for i in range(1,n+1)]
p2 = [i**2 for i in p1]
num = p2.index(min(p2))
sums = sum(p1)-p1[num]
print(sums)
# Judge status: Wrong Answer
L = int(input())
ans = 0

for i in range(0, L*10):
  for j in range(0, L):
    if (i / 10) + (j) < L:
      ans = max(ans, (i / 10) * (j) * (L - (i / 10) - (j)))
      
print(ans)
# Judge status: Wrong Answer
n,t = map(int,input().split())
ct = [list(map(int,input().split())) for i in range(n)]
ans = 10**3
for i in ct:
    if i[1] <= t:
        ans = min(ans,i[0])
print(ans)
# Judge status: Accepted
n = int(input())
a = sorted(list(map(int, input().split())))[::-1]
print(a[0] + sum(a[1:n // 2]) * 2 + sum(a[n // 2:n // 2 + n % 2]))