Harryxun/stf_run huggingface dataset:
DIR = {">": (0, 1), "<": (0, -1), "^": (-1, 0), "v": (1, 0)}

while True:
    w, h = m(int, raw_input().split())
    if w == 0 and h == 0:
        break

    m = []
    for i in range(w):
        m.append([c for c in raw_input().strip()])

    x = 0
    y = 0
    while m[x][y] != '.':
        i = m[x][y]
        if i == 'x':
            break
        m[x][y] = 'x'
        x += DIR[i][0]
        y += DIR[i][1]

    if m[x][y] == '.':
        print("{} {}".format(y, x))
    else:
        print("LOOP")

### FIXED CODE ###

DIR = {'>': (0, 1),
       '<': (0, -1),
       '^': (-1, 0),
       'v': (1, 0)}

while True:
    w, h = map(int, raw_input().split())
    if w == 0 and h == 0:
        break

    m = [[] for i in range(w)]
    for i in range(w):
        m[i] = [c for c in raw_input().strip()]

    x = 0
    y = 0
    while m[x][y] != '.':
        if m[x][y] == 'x':
            break
        else:
            d = m[x][y]
            m[x][y] = 'x'
            x += DIR[d][0]
            y += DIR[d][1]

    if m[x][y] == '.':
        print("{} {}".format(y, x))
    else:
        print("LOOP")
s=list(input())
t=list(input())
ss=''.join(sorted(ss))
tt=''.join(sorted(tt,reverse=true))
if ss<tt:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

st=input().split()
a=int(st[0])
b=int(st[1])
if (a+b)%2==0:
    print((a+b)//2)
else:
    print((a+b+1)//2)
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]


N = int(input())
S = input()
r = []
g = []
b = []
for i in range(N):
    if S[i] == 'R':
        r.append(i+1)
    if S[i] == 'G':
        g.append(i+1)
    if S[i] == 'B':
        b.append(i+1)
c = [None]*100
for i in range(100):
    c[i] = [None]*100
cnt = 0
for i in range(len(r)):
    for j in range(len(g)):
        for k in range(len(b)):
            c[i][0] = r[i]
            c[i][1] = g[j]
            c[i][2] = b[k]

            if c[i][1]-c[i][0] != c[i][2]-c[i][1]:
                #print(c[i][0], c[i][1], c[i][2], 'Yes')
                cnt += 1

print(cnt)


### FIXED CODE ###

import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]


N = input()
if '7' in N:
    print("Yes")
else:
    print('No')
a=input()
if a[0]==0 and a[1]==0:
  print('NA')
elif a[2]==0 and a[3]==0:
  print('NA')
elif a[0]>=2:
  print ('YYMM')
elif a[0]>=1 and a[1]>=3:
  print('YYMM')
elif a[2]>=2:
  print ('MMYY')
elif a[2]>=1 and a[3]>=3:
  print('MMYY')

### FIXED CODE ###

S=input()
ab=int(S[0]+S[1])
cd=int(S[2]+S[3])
if ab==0:
  if cd==0:#0000
    print('NA')
  elif cd>=1 and cd<=12:
    #0001~0012
    print('YYMM')
  else: #0013~0099
    print('NA')
elif ab>=1 and ab<=12:
  if cd ==0:
    print('MMYY')
  elif cd>=1 and cd<=12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if cd>=1 and cd<=12:
    print('YYMM')
  else:
    print("NA")
import sys
sys.setrecursionlimit(10**7)

def f(a,b):
    if a==b:return a
    if not a<b:a,b=b,a
    return f(a,b-a)+2*a

N,X=map(int,input().split())
print(f(X,N-X)+N)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

def f(a,b):
    if a==b:return a
    if not a<b:a,b=b,a
    return 2*(b//a)*a+f(a,b%a) if b%a else 2*(b//a)*a-a

N,X=map(int,input().split())
print(f(X,N-X)+N)
n = int(input())
ps = map(int, input().split())
p2 = ps[0] - 1
for p in ps:
    if p > p2:
        p2 = p

    else:
        print("NO")
if p2 == p[-1]:
    print("YES")

### FIXED CODE ###

n = input()
n = int(n)
ps = list(map(int, input().split()))
pp = sorted(ps)
remaind = 2
pt = False
for s,p in zip(ps,pp):
    if s != p:
        remaind -= 1

if remaind >= 0:
    print("YES")
else:
    print("NO")
def main():
    N, W = [int(n) for n in input().split()]
    baggages = [[int(n) for n in input().split()] for i in range(N)]

    VALUE, WEIGHT = 1, 0
    dp = [[-1] * (W+1) for n in range(N)]
    # dp[baggage][weight] := baggage番目までの荷物を使ってweight以下に抑える
    dp[0] = [0 if weight < baggages[0][WEIGHT] else baggages[0][VALUE] for weight in range(W+1)]

    for baggage in range(N):
        for max_weight in range(W+1):
            if dp[baggage][max_weight] != -1:
                continue
            bag_w = baggages[baggage][WEIGHT]
            bag_v = baggages[baggage][VALUE]
            val1 = dp[baggage-1][max_weight]
            val2 = dp[baggage-1][max_weight-bag_w]+bag_v if max_weight >= bag_w else 0
            dp[baggage][max_weight] = max(val1, val2)
            
    print(dp[N-1][W])



if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    N, W = [int(n) for n in input().split()]
    
    baggages = [[int(n) for n in input().split()] for i in range(N)]# 荷物1, 荷物2, ...と数え、荷物0は数合わせの(0, 0)
    baggages.insert(0, [0, 0])

    VALUE, WEIGHT = 1, 0
    VALUE_LIMIT = int(1e5)
    INF = int(1e15)

    
    dp = [[-1] * (VALUE_LIMIT+1) for n in range(N+1)]# 荷物は0~N, 価値は0~VALUE_LIMIT
    # dp[baggage][value] := baggage番目までの荷物を使ってvalueだけとる最小重量
    dp[0] = [INF] * (VALUE_LIMIT+1)
    dp[0][0] = 0
    
    for baggage in range(1, N+1):
        for value in range(VALUE_LIMIT+1):
            if dp[baggage][value] != -1:
                continue
            bag_w = baggages[baggage][WEIGHT]
            bag_v = baggages[baggage][VALUE]
            val1 = dp[baggage-1][value]
            val2 = (dp[baggage-1][value-bag_v] + bag_w) if value >= bag_v else INF
            dp[baggage][value] = min(val1, val2)
    
    max_val = 0
    for index, w in enumerate(dp[N]):
        if w <= W:
            max_val = index
    print(max_val)


if __name__ == "__main__":
    main()
import bisect
N = int(input())
S = input()
ans = S.count('.')
num = 0
for x in S:
    if x == '#':
        break
    else:
        num += 1
print(min(ans-num, S.count('#'))

### FIXED CODE ###

import sys
from itertools import accumulate
N = int(input())
S = input()

if S == '.'*N or S == '#'*N:
    print(0)
    sys.exit()

ind1 = 0
for i, x in enumerate(S):
    if x == '#':
        ind1 = i
        break
num = 0
for i, x in enumerate(S[::-1]):
    if x == '.':
        num = i
        break
ind2 = N - num
s = S[ind1:ind2]
if len(s) == 0:
    print(0)
    sys.exit()

a = s.split('.')
b = s.split('#')
aa = []
bb = []
for x in a:
    if len(x) != 0:
        aa.append(len(x))
for x in b:
    if len(x) != 0:
        bb.append(len(x))
c = [0] + list(accumulate(aa))
d = [0] + list(accumulate(bb))
ls = []
for i in range(len(c)):
    ls.append(c[i] + d[-1] - d[i])
print(min(ls))
li = list(map(int,input().split())
if li[0] % 2 == 0 or li[1] & 2 == 0:
    print("Evem")
else:
    print("Odd")
    

### FIXED CODE ###

a = list(map(int, input().split()))
if a[0] % 2 == 0 or a[1] % 2 == 0:
	print("Even")
else:
	print("Odd")
n,m = map(int,input().split())
#L= list(map(int, input().split()))
L = []
for i in range(m):
    a = list(map(int, input().split()))
    L.append(a)

s = [-1]*n
for i in range(m):
    s[L[i][0]-1] = L[i][1]

for i in range(m):
    if s[0] == 0:
        print(-1)
        exit()
    if s[i]==-1:
        s[i] = 0
ans = ""
for i in range(m):
    ans += str(s[i])
print(ans)

### FIXED CODE ###

n,m = map(int,input().split())
L = []
for i in range(m):
    L.append(list((map(int,input().split()))))

for i in range(1000):
    p = str(i)
    flag = False
    for j in range(m):
        if len(p) >= L[j][0]:
            if int(p[L[j][0]-1]) != L[j][1]:
                break
    else:
        if len(p) == n:
            flag = True

    if flag:
        print(i)
        exit()
print(-1)
import numpy as np
import math
K = int(input())
memo = np.zeros((K,K),int)
s = 0
for i in range(K):
  for j in range(i,K+1):
    for k in range(j,K+1):
      if memo[i][j] != 0:
        if memo[memo[i][j]-1][k] != 0:
          s += memo[memo[i][j]-1][k]
        else:
          memo[memo[i][j]-1][k] = math.gcd(memo[i][j],k+1)
          memo[k][memo[i][j]-1] = memo[memo[i][j]-1][k]
          s += memo[k][memo[i][j]-1]
      else:
        
        memo[i][j] = math.gcd(i+1,j+1)
        memo[j][i] = memo[i][j]
        if memo[memo[i][j]-1][k] != 0:
          s += memo[memo[i][j]-1][k]
        else:
          memo[memo[i][j]-1][k] = math.gcd(memo[i][j],k+1)
          memo[k][memo[i][j]-1] = memo[memo[i][j]-1][k]
          s += memo[k][memo[i][j]-1]
print(s)


### FIXED CODE ###

import numpy as np
import math
K = int(input())
memo = np.zeros((K,K),int)
s = 0
for i in range(K):
  for j in range(i,K):
    for k in range(j,K):
      if i == j and j == k:
        rate = 1
      elif i == j or j == k or i == k:
        rate = 3
      else:
        rate = 6
      s += math.gcd(math.gcd(i+1,j+1),k+1) * rate
print(s)
N,K,S = map(int, input().split())

sa = N-K+1
a = [1 for i in range(N)]
if S-sa+1 >0:
        
    a[0] = S - sa + 1

    for i in range(1,sa):
        a[i] = 1
    j = 0
    for i in range(sa,N):
        a[i] = a[j]

        j +=1
        j %= sa

    for x in a:
        print(x, end = " ")


else:
    for i in range(K):
        a[i] = S
    if S != 10**9:    
        for i in range(K,N):
            a[i] = 10**9
    else:
        for i in range(K,N):
            a[i] == 10**9 -1
    for x in a:
        print(x, end = " ")

### FIXED CODE ###

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

sa = N-K+1
a = [1 for i in range(N)]
if S-sa+1 >0:
        
    a[0] = S - sa + 1

    for i in range(1,sa):
        if i < N:
    
            a[i] = 1
    j = 0
    for i in range(sa,N):
        a[i] = a[j]

        j +=1
        j %= sa

    for x in a:
        print(x, end = " ")


else:
    for i in range(K):
        a[i] = S
    if S != 10**9:    
        for i in range(K,N):
            a[i] = 10**9
    else:
        for i in range(K,N):
            a[i] == 10**9 -1
    for x in a:
        print(x, end = " ")
N = int(input())
A = list(map(int,input().split()))
ans = "Yes"
if N % 3 != 0:
  if len(set(A)) != 1 or set(A)[0] != 0:
    ans = "No"
  print(ans)
else:
  if len(set(A)) == 2:
    if A.count(0) != N // 3:
      ans = "No"
  elif len(set(A)) == 3:
    A_s = list(set(A))
    for a in A_s:
      if A.count(a) != N // 3:
        ans = "No"
      elif A_s[0] ^ A_s[1] ^ A_s[2] != 0:
        ans = "No"
  else:
    ans = "No"
  print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
ans = "Yes"
if N % 3 != 0:
  if len(set(A)) != 1 or list(set(A))[0] != 0:
    ans = "No"
  print(ans)
else:
  if len(set(A)) == 1:
    if list(set(A))[0] != 0:
      ans = "No"
  elif len(set(A)) == 2:
    if A.count(0) != N // 3:
      ans = "No"
  elif len(set(A)) == 3:
    A_s = list(set(A))
    for a in A_s:
      if A.count(a) != N // 3:
        ans = "No"
      elif A_s[0] ^ A_s[1] ^ A_s[2] != 0:
        ans = "No"
  else:
    ans = "No"
  print(ans)
n, k = map(int, input().split())
lis = []
for i in range(k*2):
    lis.append(input().split())
lis2 = []
j = 1
while j < k2:
    for k in lis[j]:
        lis2.append(k)
    j += 2
lis2 = set(lis2)
print(n - len(lis2))

### FIXED CODE ###

n, k = map(int, input().split())
li = []
for x in range(k*2):
    li.append(input().split())
li2 = []
i = 1
while i < k*2:
    for j in li[i]:
        li2.append(j)
    i += 2
li2 = set(li2)
print(n - len(li2))
n = input()
if n%==0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n = int(input())
if n%9==0:
  print('Yes')
else:
  print('No')
n, x = map(int, input().split())
l = list(map(int, input().split()))
c = 0
total = 0
for i in range(n+2):
    if total <= x:
        c += 1
        total += l[i]
    else:
        break

print(c)

### FIXED CODE ###

n, x = map(int, input().split())
l = list(map(int, input().split()))
ans = 0
d = []
d.append(0)
for i in range(n):
    d.append(d[i] + l[i])

for i in range(len(d)):
    if d[i] <= x:
        ans += 1

print(ans)
***
「文字列」S を「文字列」X と 「文字列」Y に分割、X と Y 両方に含む文字種類数最大化

「文字列」S を 各位置 で 分割して、「集合」X と 「集合」Y に格納する。
「集合」X と 「集合」Y の 論理積(AND) の 要素数 を 最大化することで求めることができる。
「集合」X と 「集合」Y の 論理積(AND) は X & Y で求めることができる。
***

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

answer = 0
for L in range(N):
  left = S[:L]
  right = S[L:]
  both = set(left) & set(right)
  answer = max(answer, len(both))

print(answer)

### FIXED CODE ###

'''
「文字列」S を「文字列」X と 「文字列」Y に分割、X と Y 両方に含む文字種類数最大化

「文字列」S を 各位置 で 分割して、「集合」X と 「集合」Y に格納する。
「集合」X と 「集合」Y の 論理積(AND) の 要素数 を 最大化することで求めることができる。
「集合」X と 「集合」Y の 論理積(AND) は X & Y で求めることができる。
'''

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

answer = 0
for L in range(N):
  left = S[:L]
  right = S[L:]
  both = set(left) & set(right)
  answer = max(answer, len(both))

print(answer)
A = list[map(int, input().split())]
count = 0
for a in A:
  count += 1
  if a == 0:
    print(count)
    exit()

  

### FIXED CODE ###

A = list(map(int, input().split()))
count = 0
for a in A:
  count += 1
  if a == 0:
    print(count)
    exit()
a = [int(j) for i in range(3) for j in input().split(' ')]
n = int(input())
nn = [int(input()) for i in range(n)]

for ni in nn:
  if ni in a:
    a[a.index(ni)] = 0

judge = Yes
if a[4]!=0 and a[2]!=0 and a[6]!=0:
  judge = No
  
print(judge)

### FIXED CODE ###

n = int(input())
print(int(n/2)+n%2)
n=int(input())
XY=[]
for i in range(n):
    x,y=map(int,input().split())
    XY.append((x,y))
from itertools import permutations
perm=permutations(XY)

dists=[]
for i in perm:
    dist=0
    for j in range(1,3):
        dist+=((i[j][0]-i[j-1][0])**2+(i[j][1]-i[j-1][1])**2)**0.5
    dists.append(dist)
ans=sum(dists)/len(dists)
print(ans)


### FIXED CODE ###

n=int(input())
xy=[]
for i in range(n):
    xt,yt=map(int, input().split())
    xy.append((xt,yt))

from itertools import permutations

perms=permutations(xy)
dis=[]
for p in perms:
    d_tmp=[]
    for i in range(1,len(p)):
        d=((p[i][0]-p[i-1][0])**2+(p[i][1]-p[i-1][1])**2)**0.5
        d_tmp.append(d)
    dis.append(sum(d_tmp))
        
print(sum(dis)/len(dis))
n = int(input())
 
maxv = -2000000000
 
 
minv = int(intput())
 
for i in range(1, n):
   cur = int(input())
   maxv = max([maxv, cur - minv])
   minv = min([minv, cur])
 
print(maxv)


### FIXED CODE ###

n = int(input())
 
maxv = -2000000000
 
 
minv = int(input())
 
for i in range(1, n):
   cur = int(input())
   maxv = max([maxv, cur - minv])
   minv = min([minv, cur])
 
print(maxv)
#6
N = int(input())
a = reversed(sorted(list(map(int, input().split()))))
Alice_list = []
Bob_list = []
for i in range(N):
    if i%2==0:     
        Alice_list.append(a[i])
    else:
        Bob_list.append(a[i])
print(sum(Alice_list)-sum(Bob_list))

### FIXED CODE ###

#6
N = int(input())
a = sorted(list(map(int, input().split())))
Alice_list = []
Bob_list = []
for i in range(1, N+1):
    if i%2==1:     
        Alice_list.append(a[-i])
    else:
        Bob_list.append(a[-i])
print(sum(Alice_list)-sum(Bob_list))
a,b,c=map(int,input().split())
print("YNeos"[!(a<=c<=b)::2])

### FIXED CODE ###

a,b,c=map(int,input().split())
print("YNeos"[not (a<=c<=b)::2])
A = int(input())
B = int(input())
C = int(input())
K = int(input())
if K <= A + B:
  print(K)
else:
  print(A * 2 + B - K)

### FIXED CODE ###

import math
A, B, C, K = list(map(int, input().split()))
if K <= A:
  print(K)
if A < K <= A + B:
  print(A)
if A + B < K <= A + B + C:
  print(A * 2 + B - K)
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
S = list(input())

sublist = []
for i in range(len(s)-2):
    num =  int("".join(S[i:i+3]))
    sublist.append(num)

print(min(sublist))

### FIXED CODE ###

#! /usr/bin/env python3
# -*- coding: utf-8 -*-
S = list(input())

sublist = []
for i in range(len(S)-2):
    num =  int("".join(S[i:i+3]))
    sublist.append(abs(num-753))

print(min(sublist))
n, q = [int(x) for x in input().split()]

tree = [[] for _ in range(n + 1)]
cnt = [0] * (n + 1)

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

def walk(p, x):
    cnt[p] += x
    for n in tree[p]:
        walk(n, x)

for _ in range(q):
    p, x = [int(x) for x in input().split()]
    walk(p, x)

for i in range(1, n + 1):
    print(cnt[i], end=" ")


### FIXED CODE ###

from sys import stdin, setrecursionlimit

setrecursionlimit(1000000)


def main():
    def read_tree(n):
        parents = [0 for _ in range(n + 1)]
        for _ in range(n - 1):
            a, b = [int(x) for x in input().split()]
            parents[b] = a
        return parents

    n, q = [int(x) for x in input().split()]

    parents = read_tree(n)
    cnt = [0] * (n + 1)

    for _ in range(q):
        p, x = [int(x) for x in input().split()]
        cnt[p] += x
    
    for i in range(1, n + 1):
        cnt[i] += cnt[parents[i]]

    for i in range(1, n + 1):
        print(cnt[i], end=" ")


main()
N,K,S=[int(i) for i in input().split()]
res=[S%10**9+1]*N
for i in range(K):
    res[i]=S
print(*res)

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


### FIXED CODE ###

N,K,S=[int(i) for i in input().split()]
res=[S%10**9+1]*N
for i in range(K):
    res[i]=S
print(*res)
def nmx(x):
    r = 0
    for a in As:
        r += d2[max(0, x-a)]
    return -r
def bsearch(target, min_i, max_i, func):
    # func(index) <= target < func(index+1) となるindexを返す
    if func(max_i) <= target:
        return max_i
    if target < func(min_i):
        return 0
    index = (max_i + min_i)//2
    while True:
        if func(index) <= target:
            if target < func(index+1):
                return index
            index, min_i = (index+1 + max_i)//2, index+1
            continue
        index, max_i = (index-1 + min_i)//2, index-1
N, M = map(int, input().split())
As = sorted(list(map(int, input().split())))
mn, mx = As[0], As[-1]

j = 0
n = N
d2 = []
for i in range(mx*2):
    while True:
        if j>=N:
            break
        if i <= As[j]:
            break
        j += 1
        n -= 1
    d2.append(n)
# d2[i] : i以上のaがいくつあるか
# nmx(x) : x以上のペアが何通りあるか
r = bsearch(-M, 1, mx*2, nmx)
r += 1
from itertools import accumulate
aas = list(accumulate([0]+As[::-1]))
rr = 0
c = 0
for a in As[::-1]:
    rr += a*d2[max(0, r-a)] + aas[d2[max(0, r-a)]]
    c += d2[max(0, r-a)]
rr += (r-1)*(M-c)
print(rr)


### FIXED CODE ###


def nmx(x):
    r = 0
    for a in As:
        r += d2[max(0, x-a)]
    return -r
def bsearch(target, min_i, max_i, func):
    # func(index) <= target < func(index+1) となるindexを返す
    if func(max_i) <= target:
        return max_i
    if target < func(min_i):
        return None
    index = (max_i + min_i)//2
    while True:
        if func(index) <= target:
            if target < func(index+1):
                return index
            index, min_i = (index+1 + max_i)//2, index+1
            continue
        index, max_i = (index-1 + min_i)//2, index-1
N, M = map(int, input().split())
As = sorted(list(map(int, input().split())))
mn, mx = As[0], As[-1]

j = 0
n = N
d2 = []
for i in range(mx*2):
    while True:
        if j>=N:
            break
        if i <= As[j]:
            break
        j += 1
        n -= 1
    d2.append(n)
# d2[i] : i以上のaがいくつあるか
# nmx(x) : x以上のペアが何通りあるか
r = bsearch(-M, 1, mx*2, nmx)
r += 1
from itertools import accumulate
aas = list(accumulate([0]+As[::-1]))
rr = 0
c = 0
for a in As[::-1]:
    idx = min(mx*2-1, max(0, r-a))
    rr += a*d2[idx] + aas[d2[idx]]
    c += d2[idx]
rr += (r-1)*(M-c)
print(rr)
N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print("Yes")
else:
    k = 0
    for i in range (N-1):
        if A[N-(1 + i)] < A[N-(2 + i)]:
            if (A[N-(2 + i)] - A[N-(1 + i)]) == 1:
                A[N-(2 + i)] -= 1
            else:
                k = 114514
                break
if k == 114514:
    print("No")
else:
    print("Yes")             

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N-1):
  if ans > A[i+1]:
    print('No')
    exit()
  if A[i+1]-A[i] >= -1:
    ans = max(A[i+1]-1,A[i]-1,ans)
    if A[i+1] >= A[i] and A[i+1] > ans :
      A[i+1] -=1
  else:
    print('No')
    exit()
print('Yes')
a,b=map(int,input().split())
s=input.split('-')
if len(s[0])==a and len(s[1])==b and len(s)==2:
  print('Yes')
else:
  print('No')


### FIXED CODE ###

a,b=map(int,input().split())
s=input().split('-')
if len(s[0])==a and len(s[1])==b and len(s)==2:
  print('Yes')
else:
  print('No')
n,d=map(int,input().split())
print(-(-n//2d))

### FIXED CODE ###

n,d=map(int,input().split())
print(-(-n//(2*d+1)))
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,m=map(int,input().split())
if (n<=1) and (m<=1):
  ans=0
elif (n==0) or (m==0):
  ans=0
else:
  ans=comb(n,2)+comb(m,2)
  
print(ans)

### FIXED CODE ###

import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,m=map(int,input().split())
if (n<=1) and (m<=1):
  ans=0
else:
  if n<=1:
    ans=comb(m,2)
  elif m<=1:
    ans=comb(n,2)
  else:
    ans=comb(n,2)+comb(m,2)
  
print(ans)
N,M = map(int,input().split())
Nlist = []
for i in range(1,N+1):
    Nlist.append(i)
count = 0
for i in range(N):
    count += 1
    if count>M:
        break
    print(Nlist[i],Nlist[-(i+1)])


### FIXED CODE ###

import math
X = int(input())
d = 100
year = 0
while True:
    year += 1
    if d+math.floor(d*0.01) >= X:
        print(year)
        exit()
    else:
        d += math.floor(d*0.01)
n,a=map(int,input().split())
if a >= n%500:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n=int(input())
a=int(input())
if a >= n%500:
  print('Yes')
else:
  print('No')
import math

a, b = map(int, input().split()) 
print(a*b/math.gcd(a,b))

### FIXED CODE ###

import fractions

a, b = map(int, input().split()) 
print(a*b//fractions.gcd(a,b))
S = list(input())
T = list(input())
flag = False

if "".join(map(str, T)) in "".join(map(str, S)):
  for i in range(len(S)):
      if S[i] == "?":
        S[i] = "a"
    print("".join(map(str,S)))

else:
  for i in reversed(range(len(S) - len(T) + 1)):
    if S[i] == (T[0] or "?"):
      for j in range(len(T)):
        if S[i + j] != T[j] and S[i + j] != "?":
          print(S[i + j])
          break
      else:
        flag = True
        S[i:i + len(T)] = T

  if flag == False:
    print("UNRESTORABLE")
  else:
    for i in range(len(S)):
      if S[i] == "?":
        S[i] = "a"
    print("".join(map(str,S)))


### FIXED CODE ###

sd = input()
t = input()

n = len(sd)
m = len(t)
s = []

# sd を後ろから見ていき、 t の入りそうな場所を探す
for i in range(n - m, -1, -1):
    t_kamo = sd[i:i + m]
    for j in range(m + 1):
        # 1文字ずつ順に入りうるか調べ、最後まで入るなら "?" を "a" に置き換えて出力
        if j == m:
            print((sd[:i] + t + sd[i + len(t):]).replace("?", "a"))
            exit()
        if t_kamo[j] == "?":
            continue
        elif t_kamo[j] != t[j]:
            break

print("UNRESTORABLE")
N = int(input())

dic = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]

old = ["a"]
new = []
for i in range(1, N):
    for word in old:
        for j in range(i+1):
            if word[-1] == dic[j] or word[-1] == dic[j-1]:
                new.append(word+dic[j])
    old = new.copy()
    new = []
for i in old:
    print(i)


### FIXED CODE ###

N = int(input())

S = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]

def dfs(s, i):
    if len(s) == N:
        return [s]
    result = []
    for j in range(i+1):
        if j == i:
            result += dfs(s+S[j], i+1)
        else:
            result += dfs(s+S[j], i)
    return result
print("\n".join(dfs("", 0)))