Harryxun/stf_run huggingface dataset:
s = list(str(1234))
mae = s[:2]
usiro = s[2:]
if 0 < mae < 13:
    if 0 <usiro < 13:
        print("AMBIGUOUS")
    else:
         print("MMYY")
elif 0 < usiro < 13:
         print("YYMM")
else:
    print("NA")

### FIXED CODE ###

s = str(input())
mae = int(s[:2])
usiro = int(s[2:])
if 0 < mae < 13:
    if 0 <usiro < 13:
        print("AMBIGUOUS")
    else:
         print("MMYY")
elif 0 < usiro < 13:
         print("YYMM")
else:
    print("NA")
N=int(input())
Branch=[[] for i in range(N)]
for i in range(N-1):
  a,b,c=map(int,input().split())
  Branch[a-1].append([b-1,c])
  Branch[b-1].append([a-1,c])
Q,K=map(int,input().split())
DistK=[float("Inf") for i in range(N)]
flag = [0 for i in range(N)]

def dfs(s,dist):
  DistK[s]=dist
  flag[s]=1
  
  for branch in Branch[s]:
    if flag[branch[0]]==0:
      dfs(branch[0],dist+branch[1])
dfs(K-1,0)
      
for i in range(Q):
  x,y = map(int,input().split())
  print(DistK[x-1]+DistK[y-1])
  

### FIXED CODE ###

import collections
N=int(input())
Branch=[[] for i in range(N)]
for i in range(N-1):
  a,b,c=map(int,input().split())
  Branch[a-1].append([b-1,c])
  Branch[b-1].append([a-1,c])
Q,K=map(int,input().split())
Dist=[float("Inf") for i in range(N)]
flag = [0 for i in range(N)]

que=collections.deque()
que.append(K-1)
Dist[K-1]=0
while len(que):
  u=que.pop()
  for i,j in Branch[u]:
    if Dist[i]==float("Inf"):
      Dist[i]=Dist[u]+j
      que.append(i)

  
for i in range(Q):
  x,y = map(int,input().split())
  print(Dist[x-1]+Dist[y-1])
s = input()
n = len(s)
if n%2 == 1:
	print("No")
else:
	if s[:n/2] == s[n/2:]:
		print("Yes")
	else:
		print("No")

### FIXED CODE ###

m = input()
s = input()
n = len(s)
f = int(n/2)
if n%2 == 1:
	print("No")
else:
	if s[:f] == s[f:]:
		print("Yes")
	else:
		print("No")
ary = input().split(" ")
print(ary[0]*ary[1])
print((ary[0]*2) + (ary[1]*2))

### FIXED CODE ###

x, y = input().split()

a = int(x) * int(y)
b = int(x)*2 + int(y)*2
print("{} {}".format(a, b))
import numpy as np
import sys
input = sys.stdin.readline

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

for i in a:
    ans = ans*i
    if ans > 1000000000000000000:
        ans = -1
        exit
    elif ans == 0:
        exit

print(ans)

### FIXED CODE ###

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

print(a*b)
import math

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

def main(i):
  blue = int(math.factorial(k-1) / (math.factorial(i-1) * math.factorial(k-i)))
  red = int(math.factorial(n-k+1) / (math.factorial(n-k+1-i) * math.factorial(i)))
  print((blue*red) % (10**9 + 7))

for i in range(1, k+1):
  main(i)

### FIXED CODE ###

import math
 
n,k = map(int, input().split())
 
def main(i):
  blue = math.factorial(k-1) // (math.factorial(i-1) * math.factorial(k-i))
  red = math.factorial(n-k+1) // (math.factorial(n-k+1-i) * math.factorial(i))
  print((blue*red) % (10**9 + 7))
 
for i in range(1, k+1):
  if i > n-k+1:
    print('0')
  else:
   main(i)
a, b ,c= map(int, input().split())
if a+b+c > 22 
print("bust")
else:
  print("win")

### FIXED CODE ###

a, b ,c= map(int, input().split())
if a+b+c >= 22 :
  print("bust")
else:
  print("win")
a=int(input())
b=0
c=0
for i in range(1,10):
  if a%i==0:
    b=a/i
    if b<=9:
      c=1
      break
if c==1:
  print("Yes")
else:
  print("No")


### FIXED CODE ###


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

if (i[0] <= 9 and i[1] <= 9):
	print(i[0] * i[1])
else:
	print("-1");
import sys
from heapq import *
input = sys.stdin.readline

def main():
    n, q = map(int, input().split())
    
    key = []
    for i in range(n):
        s, t, x = map(int, input().split())
        l, r = max(0, s-x), max(0, t-x)
        key.append((l, -1, x))
        key.append((r, 1, x))

    key.sort()
    judge = []
    now = set()
    already = dict()
    search = []
    
    for i in range(n*2):
        s, j, x = key[i]
        
        if j == -1:
            heappush(judge, x)
            now.add(x)
        else:
            now.remove(x)
            if x in already:
                already[x] += 1
            else:
                already[x] = 1
        
        if i == n*2-1 or key[i][0] != key[i+1][0]:
            while judge:
                if judge[0] in already and already[judge[0]] > 0:
                    already[judge[0]] -= 1
                    heappop(judge)
                else:
                    break
            if judge:
                search.append((s, judge[0]))
            else:
                search.append((s, -1))

    size = len(search)
    index = 0
    answer = []
    for i in range(q):
        d = int(input())
        while index < size-1:
            if search[index+1][0] <= d:
                index += 1
            else:
                break
        print(search[index][1])

    
if __name__ == "__main__":
    main()





### FIXED CODE ###

import sys
from heapq import *
input = sys.stdin.readline

def main():
    n, q = map(int, input().split())
    
    key = []
    for i in range(n):
        s, t, x = map(int, input().split())
        l, r = max(0, s-x), max(0, t-x)
        key.append((l, 1, x))
        key.append((r, -1, x))
    
    for i in range(q):
        d = int(input())
        key.append((d, 2))

    key.sort()
    judge = []
    already = dict()
    
    for i in range(2*n+q):
        k = key[i]
        if k[1] == -1:
            if k[2] in already:
                already[k[2]] += 1
            else:
                already[k[2]] = 1
        elif k[1] == 1:
            heappush(judge, k[2])
        else:
            while judge:
                if judge[0] in already and already[judge[0]] > 0:
                    already[judge[0]] -= 1
                    heappop(judge)
                else:
                    break
            if judge:
                print(judge[0])
            else:
                print(-1)
    

    
if __name__ == "__main__":
    main()
from sys import stdin


class DFS():
    def __init__(self,A_B_arr,N,M):
        self.N = N
        self.M = M
        self.route = {i:[] for i in range(N+1)}
        for A, B in A_B_arr:
            self.route[A].append(B)
            self.route[B].append(A)

        self.dp = [[None,float('inf')] for i in range(N+1)]

    def dfs(self,i,rank):
        for r in self.route[i]:
            if rank<self.dp[r][1]:
                self.dp[r] = [i,rank]
                self.dfs(r,rank+1)
        return


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, M = list(map(int,_in[0].split(' ')))  # type:list(int)
    A_B_arr = []
    for i in range(M):
        _ = list(map(int,_in[i+1].split(' ')))  # type:list(int)
        A_B_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    dfs = DFS(A_B_arr,N,M)
    dfs.dfs(1,1)


    print(dfs.dp)
    ans = []
    for (i,_) in enumerate(dfs.dp):
        if i>1 and _[0] == None:
            TF = 'No'
            break
        else:
            ans.append(_[0])
    else:
        TF = 'Yes'
        ans = ans[2:]
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    if TF == 'Yes':
        print(TF)
        for _ in ans:
            print(_)
    else:
        print(TF)


### FIXED CODE ###

from sys import stdin
from collections import deque


class BFS():
    def __init__(self, con, val=None):
        # 隣接リスト表現
        self.con = con
        self.val = val
        self.N = len(self.con)
        # 1つ前の部屋(1-indexed)
        self.dist = [-1]*self.N
        self.que = deque()

        # 初期条件(0-indexed)
        self.dist[0] = 0
        self.que.append(0)

    def bfs(self):
        while self.que:
            v = self.que.popleft()
            for next_v in self.con[v]:
                if self.dist[next_v] != -1:
                    continue
                self.dist[next_v] = v+1
                self.que.append(next_v)


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, M = list(map(int,_in[0].split(' ')))  # type:list(int)
    A_B_arr = []
    for i in range(M):
        _ = list(map(int,_in[i+1].split(' ')))  # type:list(int)
        A_B_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    con = [[] for i in range(N)]
    for A,B in A_B_arr:
        A -= 1
        B -= 1
        con[A].append(B)
        con[B].append(A)

    bfs = BFS(con)
    bfs.bfs()
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    if -1 in bfs.dist[1:]:
        print('No')
    else:
        print('Yes')
        for _ in bfs.dist[1:]:
            print(_)
N, K = map(int, input().split())
S = list(map(int, input()))

Z = [j for j, s in enumerate(S) if (j > 0 and s == 0 and S[j] != S[j-1]) or (j == 0 and s == 0)] + [N]
Y = [j for j, s in enumerate(S) if (j > 0 and s == 1 and S[j] != S[j-1]) or (j == 0 and s == 1)]
result = 0
if len(Z) <= K:
  print(N)
else:
    for i in range(len(Z)-K):
      if i == 0:
        result = Z[i+K]
      else:
        result = max(result, Z[i+K] - Y[i if Y[0] < Z[0] else i-1])
    print(result)

### FIXED CODE ###

input_ = list(map(int,input().split()))
x = input_[0]
y = input_[1]
point = max(x,y)
if point == x:
  x -= 1
else:
    y -= 1
point += max(x,y)
print(point)
n, k = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
if max(a) < k:
    print("IMPOSSIBLE")
    exit()

for i in range(n-1):
    if k == a[i]:
        print("POSSIBLE")
        break
    if k % (a[i+1] - a[i]) == 0:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")

### FIXED CODE ###

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

a = [0] + a
a.sort()
if max(a) < k:
    print("IMPOSSIBLE")
    exit()

for i in range(len(a) - 1):
    if k == a[i]:
        print("POSSIBLE")
        break
    if a[i+1] - a[i] == 0: continue 
    if k % (a[i+1] - a[i]) == 0:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")
import numpy as np


N = int(input())
A = np.array(list(map(int,input().split())))


x = np.roll(np.eye(N),1)
x[0,0]=0
x[N-1,0]=1
x += np.eye(N)
x /= 2

print(" ".join( list(map(str,list(map(int,np.dot(np.linalg.inv(x),A).tolist()))))))

### FIXED CODE ###

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

# A[0]は0と1の間に振ったものなので、
a = 0
for i in range(N//2):
  a +=  A[2*i] - A[2*i+1]

a0 = (a + A[-1]) //2

for i in A:
  print(a0*2,end=" ")
  a0 = i - a0
N, K = map(int, input().split())
*A, = map(int, input().split())
for _ in range(min(K, 50)):
    counter = [0] * (N+2)
    for i, a in enumerate(A, 1):
        counter[max(0, i - a)] += 1
        counter[min(N + 1, i + a + 1)] += -1
    for i in range(1, len(counter) - 1):
        counter[i] += counter[i-1]
    A = counter[1:N+1]
print(*A)


### FIXED CODE ###

S = input()
print(S[:3])
a, b, c, d = map(int, input().split())
e = []
for i in list[a, b]:
    for j in list[c, d]:
        e += [i * j]

print(max(e))

### FIXED CODE ###

a, b, c, d = map(int, input().split())
e = []
for i in [a, b]:
    for j in [c, d]:
        e += [i * j]

print(max(e))
s = input().split() #s_1 s_2を分割して取得し、sに値を入れる
five = 0
seven = 0
for i range(3):
    if s[i] == '5':
        five += 1
    if s[i] == '7':
        seven += 1
        
if five == 2 and seven == 1:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

s = input().split() #s_1 s_2を分割して取得し、sに値を入れる
five = 0
seven = 0
for i in range(3):
    if s[i] == '5':
        five += 1
    if s[i] == '7':
        seven += 1
        
if five == 2 and seven == 1:
    print('YES')
else:
    print('NO')
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

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

sold_day = set()
buy_day = set()

for i in range(1, n):
    if a[i] > a[i - 1]:
        sold_day.add(i)
        buy_day.discard(i - 1)

money = 1000
stock = 0

sold_day = list(sold_day)
sold_day.sort()

s = 0

for i in sold_day:
    temp = a[s:i]
    min_value = min(temp)
    x = money // min_value
    money -= min_value * x
    money += x * a[i]
    s = i + 1
print(money)


### FIXED CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

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

sold_day = set()
buy_day = set()

for i in range(1, n):
    if a[i] > a[i - 1]:
        sold_day.add(i)
        sold_day.discard(i - 1)

money = 1000
stock = 0

sold_day = list(sold_day)
sold_day.sort()

s = 0

for i in sold_day:
    temp = a[s:i]
    min_value = min(temp)
    x = money // min_value
    money -= min_value * x
    money += x * a[i]
    s = i + 1
print(money)
a,b = map(int,input().split())
cnt = 0
for i in range(b-a):
  cnt += i
print(cnt-a)

### FIXED CODE ###

x = int(input())
if x < 1000:
  print('ABC')
else:
  print('ABD')
S = input()
N = int(S)
X = 0
for i in len(S):
  res = S[i]
  X += int(res)
if N % X == 0:
  print('Yes')
else:
  print('No')
  


### FIXED CODE ###

import copy
S = input()
N = int(copy.copy(S))
X = 0
for i in range(len(S)):
  res = S[i]
  X += int(res)
if N % X == 0:
  print('Yes')
else:
  print('No')
import collections


def main():
    N, K = list(map(int, input().split(' ')))
    An  = list(map(int, input().split(' ')))
    
    dic = {}
    li = []
    STAMP = [0 for _ in range(N)]
    for i in range(len(An)):
        dic[str(i+1)] = An[i]

    status = 1
    ittatokoro = [status]
    for k in range(K):
        pre_s = status
        status = dic[str(status)]
        # print(k, pre_s, status)
        if pre_s == status:
            print(pre_s)
            return
        
        if status not in ittatokoro:
            ittatokoro.append(status)
        else:
            ittatokoro.append(status)
            break
    # print('最後の位置:', status) # 
    # print(ittatokoro, k)
    
    # c = collections.Counter(ittatokoro).most_common()[0] # nがk回数
    # K += 1 #  saisyo 1 ni irus
    START = 0
    for i, iku in enumerate(ittatokoro):
        if iku == status:
            START = i
            break
    # print('START:', START)
    
    S_ittatoko = ittatokoro[:START]
    junkan = ittatokoro[START:-1]
    len_junkan = len(junkan)
    # print('junkan:', junkan, len_junkan, S_ittatoko)
    
    junkannmadeno_hosuu = K - START
    num_junkan_kaisuu = junkannmadeno_hosuu // len_junkan
    amari_junkan_kaisuu = junkannmadeno_hosuu % len_junkan
    # print('循環回数:', num_junkan_kaisuu, amari_junkan_kaisuu)

    total = num_junkan_kaisuu * len_junkan + amari_junkan_kaisuu
    
    nokori = junkannmadeno_hosuu - total
    print(junkan[amari_junkan_kaisuu])
    
    
    
main()


# 7 4569534
# 6 5 2 5 5 3 2

### FIXED CODE ###

import collections


def main():
    N, K = list(map(int, input().split(' ')))
    A  = list(map(int, input().split(' ')))
    
    where_li = []
    pre = 0
    for i in range(N):
        where_li.append(A[pre])
        pre = A[pre]-1
    
    len_w = len(where_li)
    a = where_li.index(A[pre])
    # print(a)
    mod_s = len_w-a # ループにかかる歩数
    # print(where_li)
    if K<=len_w:
        print(where_li[K-1])
    else:
        nokori = K - len_w
        if nokori % mod_s==0:
            d = mod_s
        else:
            d = nokori % mod_s
        print(where_li[d-1+a])

main()
a,b = map(int,input().split)
print((a+b)/2)

### FIXED CODE ###

X,Y=map(int,input().split())
print(X+Y//2)
N = input()
B = False
kaisu = 0
array = map(int,input().split())
while B:
	for i in range(N):
  		if array[i]/2 == 1:
    	B = True
  	if B == False:
    	array = map(calc ,array)
    	kaisu += 1
  	else:
    	break
        
print(kaisu)

def calc(n):
  retuen n/2
    

    

### FIXED CODE ###

N = int(input())
B = False
kaisu = 0
array = list(map(int,input().split()))

def calc(n):
  return int(n) / 2
  
  
while not B:
  for i in range(N):
    if array[i] % 2 == 1:
      B = True
  if not B:
    array = list(map(calc, array))
    kaisu += 1
  else:
    break
        
print(kaisu)
import sys
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

n,m  = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]
d = {}
for i in l:
    if i[0] in d and d[i[0]] != i[1]:
        d[i[0]] += 1
        print("-1")
        sys.exit()
    else:
        d[i[0]] =i[1]

#ここまでが同一桁に複数の数字が指定されていた時の処理

l = get_unique_list(l) #重複削除
l.sort() #ソート
d = 0
if l[0][1]==0 and l[0][0]==1: #1桁目が0
    if n ==1: #1桁指定の時
        print("0")
        sys.exit()
    else:
        print("-1")
        sys.exit()
        
if l[0][0]!=1: #1桁目に指定がない
    d = 10**(n-1)
    for i in l:
        d += int(i[1])*10**(n-int(i[0]))
        
else:
    for i in l:
        d += i[1]*10**(n-i[0])    

print(d)

### FIXED CODE ###

import sys
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

n,m  = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]
d = {}
if m == 0 and n != 1:
    print(10**(n-1))
    sys.exit()
if m == 0 and n == 1:
    print("0")
    sys.exit()
    
for i in l:
    if i[0] in d and  i[1] !=d[i[0]]:
        d[i[0]] += 1
        print("-1")
        sys.exit()
    else:
        d[i[0]] =i[1]
#ここまでが同一桁に複数の数字が指定されていた時の処理

l = get_unique_list(l) #重複削除
l.sort() #ソート
d = 0
if l[0][1]==0 and l[0][0]==1: #1桁目が0
    if n ==1: #1桁指定の時
        print("0")
        sys.exit()
    else:
        print("-1")
        sys.exit()
        
if l[0][0]!=1: #1桁目に指定がない
    d = 10**(n-1)
    for i in l:
        d += i[1]*10**(n-i[0])
        
else:
    for i in l:
        d += i[1]*10**(n-i[0])    

print(d)
S = input()
N = 0
for i in range(1,len(S))
  if S[i-1] == S[i]:
    N += 1
if N >= 2:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N = input()
if len(set(N[1:])) == 1 or len(set(N[:3])) == 1:
  print("Yes")
else:
  print("No")
while True:
    C == input()
    if '?' in C:
       break
    print(eval(C.replace('/','//')))

### FIXED CODE ###

while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == "+":
      print(a + b)
    elif op == "-":
      print(a - b)
    elif op == "*":
      print(a * b)
    elif op == "/":
      print(a // b)
    else:
      break
x, y = map(int, input().split())
    for i in range(x+1):
      if((i*2 + (x-i)*4) == y):
        print("Yes")
    	break
      else:
    	print("No")
    	break

### FIXED CODE ###

x, y = map(int, input().split())
res = 'No'
for i in range(x+1):
  k = x-i
  if(i*2 + k*4) == y:
    res = 'Yes'
print(res)
a,b,c,k=map(int,input())
if k=<a+b:
  max_value=a
else:
  max_value=a-k+a+b
print(max_value)


### FIXED CODE ###

a,b,c,k=map(int,input().split())
if a<=k<=a+b:
  max_value=a
elif k<a:
	max_value=k
else:
  max_value=a*2-k+b
print(max_value)
n, d = map(int, input().split())
canseerange = 2*d+1
if n % canseerange == 0:
    print(int(n/canseerange))
else:
    print(int(n/canseerange)+1

### FIXED CODE ###

#A
#n = int(input())
#print(3*n**2)
#B
n, d = map(int, input().split())
canseerange = 2*d+1
if n % canseerange == 0:
    print(int(n/canseerange))
else:
    print(int(n/canseerange)+1)
n = int(input())


def count_divisors():
  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)
  length = len(divisors)
  return length


l = []
for i in range(1, n + 1):
  if i % 2 == 0:
    continue
  else:
    if count_divisors(i) == 8:
      l.append(i)

      
print(len(l))


### FIXED CODE ###

n = int(input())


def count_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)
  length = len(divisors)
  return length


l = []
for i in range(1, n + 1):
  if i % 2 == 0:
    continue
  else:
    if count_divisors(i) == 8:
      l.append(i)

      
print(len(l))
import sys
input = sys.stdin.readline
#区間の管理は　[a, b)で管理していることに注意

# INT_MIN = -10 ** 18
# MAX_N = 4 * 10 ** 5
# MAX_N = 20


# def init(n_):
#     #簡単にするために2のべき乗に揃える
#     n = 1
#     while n <= n_:
#         n *= 2
#     return n

#初期化
N = int(input())
n = 1
while n <= N:
    n *= 2

data = [0] * (2 * n - 1)

def update(k, a):
    k += n - 1
    data[k] = a
    while k > 0:
        data[k] = max(a, data[k])
        k = (k - 1) // 2
        # data[k] = max(data[2 * k + 1], data[2 * k + 2])

def query(a, b, k = 0, l = 0, r = n):
    if r <= a or b <= l:
        return 0
    elif a <= l and r <= b:
        return data[k]
    else:
        return max(query(a, b, 2 * k + 1, l, (l + r)//2), query(a, b, 2 * k + 2, (l + r)//2, r))

H = tuple(map(int, input().split()))
A = tuple(map(int, input().split()))

# ans = 0

dp = [[A[0]]] + [0] * (N - 1)
update(H[0], A[0])
for i in range(1, N):
    # h = int(input())
    # a = int(input())
    dp[i] = query(1, H[i]) + A[i]
    # h = H[i]
    # a = A[i]
    # tmp = query(1, h + 1) #[1, h)での最大値
    # print (h, tmp)
    update(H[i], dp[i])
    # ans = max(ans, tmp + a)
    # print (data)

print (max(dp))

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline
    #区間の管理は　[a, b)で管理していることに注意

    # INT_MIN = -10 ** 18
    # MAX_N = 4 * 10 ** 5
    # MAX_N = 20


    # def init(n_):
    #     #簡単にするために2のべき乗に揃える
    #     n = 1
    #     while n <= n_:
    #         n *= 2
    #     return n

    #初期化
    N = int(input())
    # n = 1
    # while n <= N:
    #     n *= 2

    n = 262144
    data = [0] * (2 * n - 1)

    def update(k, a):
        k = k + n - 1
        # data[k] = a
        while k >= 0:
            data[k] = max(a, data[k])
            k = (k - 1) // 2
            # data[k] = max(data[2 * k + 1], data[2 * k + 2])

    def query(a, b, k, l, r):
        if r <= a or b <= l:
            return 0
        elif a <= l and r <= b:
            return data[k]
        else:
            return max(query(a, b, 2 * k + 1, l, (l + r)//2), query(a, b, 2 * k + 2, (l + r)//2, r))

    H = tuple(map(int, input().split()))
    A = tuple(map(int, input().split()))

    # ans = 0

    dp = [A[0]] + [0] * (N - 1)
    update(H[0] - 1, A[0])
    for i in range(1, N):
        # h = int(input())
        # a = int(input())
        dp[i] = query(0, H[i] - 1, 0, 0, n) + A[i]
        # h = H[i]
        # a = A[i]
        # tmp = query(1, h + 1) #[1, h)での最大値
        # print (h, tmp)
        update(H[i] - 1, dp[i])
        # ans = max(ans, tmp + a)
        # print (data)

    print (query(0, N, 0, 0, n))

if __name__ == '__main__':
    main()
a = int(input())
l = list(map(int,input().split()))

le,ri = 0,sum(l)
ans = 10**10
for i in range(len(l)-1):
    le += l[i]
    ri -= l[i]
    min(ans,abs(le-ri))
else:
    print(min(ans))

### FIXED CODE ###

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

le,ri = 0,sum(l)
ans = []
for i in range(len(l)-1):
    le += l[i]
    ri -= l[i]
    ans.append(abs(le-ri))
else:
    print(min(ans))
w, h, x, y = map(int,input().split())
area=w*h/2
awee=0
if x==w/2 or y==h/2:
    awee=0
    if x==w/2 and y==h/2:
        awee=1
else:
    awee=0

print(str(area)+" "+str(awee))

### FIXED CODE ###

x, a = map(int,input().split())
print(0) if x<a else print(10)
import sys
r=sys.stdin.readline
def s():
 def b(M,x,y,n=1):
  M[x][y]=0;a=n
  if M[x-1][y]:a=max(a,b(M,x-1,y,n+1))
  if M[x][y-1]:a=max(a,b(M,x,y-1,n+1))
  if M[x+1][y]:a=max(a,b(M,x+1,y,n+1))
  if M[x][y+1]:a=max(a,b(M,x,y+1,n+1))
  M[x][y]=1
  return a
 for e in iter(r,'0'):
  n,m=int(e),int(r())
  P=[[0]*(n+2)for _ in[0]*(m+2)]
  for i in range(m):P[i+1][1:-1]=map(int,r().split())
  print(max(b(P,i,j)for i in range(1,m+1)for j in range(1,n+1)if P[i][j]))
if'__main__'==__name__:s()


### FIXED CODE ###

def s():
 def b(M,x,y,n=1):
  M[x][y]=0;a=n
  if M[x-1][y]:
   t=b(M,x-1,y,n+1)
   if a<t:a=t
  if M[x][y-1]:
   t=b(M,x,y-1,n+1)
   if a<t:a=t
  if M[x+1][y]:
   t=b(M,x+1,y,n+1)
   if a<t:a=t
  if M[x][y+1]:
   t=b(M,x,y+1,n+1)
   if a<t:a=t
  M[x][y]=1
  return a
 for e in iter(input,'0'):
  n,m=int(e),int(input())
  P=[[0]*(n+2)for _ in[0]*(m+2)]
  for i in range(m):
   P[i+1][1:-1]=map(int,input().split())
  a=0
  for i in range(1,m+1):
   for j in range(1,n+1):
    if P[i][j]:
     t=b(P,i,j)
     if a<t:a=t
  print(a)
if'__main__'==__name__:s()
A, B, C = map(int, input().split())
print("YES" if (A<=C && B>=C) else "NO")

### FIXED CODE ###

A, B, C = map(int, input().split())
print("YES" if (A<=C and A+B>=C) else "NO")