Harryxun/stf_run huggingface dataset:
x = int(input())
z = list(map(int,input().split()))
i = 1
num = 0
while i+1 < x:
    if z[i-1] < z[i] < z[i+1]:
        num += 1
    elif z[i+1] < z[i] < z[i-1]:
        num += 1
    i += 1
print(num)

### FIXED CODE ###

y=input()
 
if y[0]==y[1] and y[2]==y[3]:
    if y[1]==y[2]:
        print("No")
    else:
        print("Yes")
elif y[0]==y[2] and y[1]==y[3]:
    if y[1]==y[2]:
        print("No")
    else:
        print("Yes")
elif y[0]==y[3] and y[1]==y[2]:
    if y[0]==y[2]:
        print("No")
    else:
        print("Yes")   
    
else:
    print("No")
S = input()
ret = ""
for i in range(len(S)):
    if i == K-1:
        ret += S[i].lower()
    else:
        ret += S[i]
print(ret)

### FIXED CODE ###

N,K = map(int, input().split())
S = input()
ret = ""
for i in range(len(S)):
    if i == K-1:
        ret += S[i].lower()
    else:
        ret += S[i]
print(ret)
N = int(input())
A = map(int, input().split())
A_score = 0
B_score = 0
for i in A:
  A_score += max(A)
  del max(A)
  B_score += max(A)
  del max(A)
  if lens(A) = 0:
    break
print(A_score - B_score)

### FIXED CODE ###

N=int(input())
A=int(input())
 
if N % 500 <= A:
  print("Yes")
else:
  print("No")
def cut(cake,s):
    ret_cake = [(0,0),(0,0)]
    w = cake[2]
    h = cake[1]
    s %= 2*(w+h)
    if w > s:
        ret_cake = [(h,s),(h,w-s)]
    elif w+h > s:
        ret_cake = [(s-w,w),(w+h-s,w)]
    elif 2*w+h > s:
        ret_cake = [(s-w-h,w),(2*w+h-s,w)]
    elif 2*w+2*h > s:
        ret_cake = [(s-2*w-h,w),(2*w+2*h-s,w)]

    return [ (c[0]*c[1],c[0],c[1]) for c in ret_cake]

while True:
    n,w,d = map(int,input().split())
    if n == 0  and w == 0 and d == 0:
        break
    p = [0] * n
    s = [0] * n
    for i in range(n):
        p[i],s[i] = map(int,input().split())
    cake = [ (w*d,d,w) ]

    for i in range(n):
        cake = cake[:p[i]-1] + cake[p[i]:] + cut(cake[p[i]-1],s[i])
    cake.sort()
    print( " ".join(map(str,[c[0] for c in cake])))

### FIXED CODE ###

def cut(cake,s):
    ret_cake = [ (-1,-1),(-1,-1) ]
    w = cake[2]
    h = cake[1]

    s %= 2*(w+h)

    if w > s:
        ret_cake = [(h,s),(h,w-s)]
    elif w+h > s:
        ret_cake = [(s-w,w),(w+h-s,w)]
    elif 2*w+h > s:
        ret_cake = [(h,s-w-h),(h,2*w+h-s)]
    elif 2*w+2*h > s:
        ret_cake = [(s-2*w-h,w),(2*w+2*h-s,w)]

    ret_cake =  [ (c[0]*c[1],c[0],c[1]) for c in ret_cake]
    ret_cake.sort()
    return ret_cake

while True:
    n,w,d = map(int,input().split())
    if n == 0  and w == 0 and d == 0:
        break
    p = [0] * n
    s = [0] * n
    for i in range(n):
        p[i],s[i] = map(int,input().split())
    cake = [ (w*d,d,w) ]

    for i in range(n):
        cake = cake[:p[i]-1] + cake[p[i]:] + cut(cake[p[i]-1],s[i])
    cake.sort()
    print( " ".join(map(str,[c[0] for c in cake])))
par = []
for i in range(n):
    par.append(-1)  #初期親
rank = [1 for i in range(n)] #初期ランク
cut = []
def find(n): #親検索andランク短縮
    global cut
    if par[n] < 0:
        for i in range(len(cut)):
            par[cut[i]] = n
        cut = []
        return n
    else:
        cut.append(n)
        find(par[n])
        return find(par[n])
def shorten(n): # 根に直接接続する
    global cut
    if par[n] < 0:
        for i in range(len(cut)):
            par[cut[i]] = n
        cut = []
    else:
        cut.append(n)
        shorten(par[n])
def unite(a,b): #グループ併合
    x = find(a)
    y = find(b) #根っこ同士をくっつける
    if x == y: 
        return    #既に同一ユニオンなら何もしない
    if rank[x] < rank[y]:
        par[y] += par[x]
        par[x] = y 
    elif rank[x] == rank[y]:
        par[x] += par[y]
        par[y] = x
        rank[x] += 1
    else:
        par[x] += par[y]
        par[y] = x
def judge(a,b):
    return par[a] == par[b]
n,m = map(int,input().split())
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    unite(a,b)
ans = 0
for i in range(n):
    ans = max(ans,-par[i])
print(ans)

### FIXED CODE ###

n,m = map(int,input().split())
import sys
sys.setrecursionlimit(10**9)
rks = [None] *n
p = [set([]) for i in range(n)]
flist = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    flist[a-1].append(b-1)
    flist[b-1].append(a-1)
def dfs(graph,w,c):
    if rks[w] is None:
        rks[w] = 0
    for i in range(len(graph[w])):
        if rks[graph[w][i]] is not None:
            continue
        p[c].add(flist[w][i])
        dfs(graph, graph[w][i],c)
c = -1
for w in range(n):
    c += 1
    if rks[w] is None:
        dfs(flist,w,c)
ans = 0
for i in range(n):
    ans = max(ans,len(p[i])+1)
print(ans)
N=int(input())
a = list(map(int, input().split()))
a2= sort(a,reverse=True)

for i in range(N):
  if i%2==1:
    S+=a2[i]
    a.remove(max(a))
  else:
    S-=a2[i]
print(S)

### FIXED CODE ###

N=int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
S=0
for i in range(N):
  if i%2==0:
    S+=a[i]
  else:
    S-=a[i]
print(S)
N,M,K=map(int, input().split())
'''
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
'''

# 再帰制限に引っかかった場合に外す
# import sys
# sys.setrecursionlimit(100000)
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]


ans=0

for i in range(K+1):
  temp=(M*(M-1)**(N-1-i)*cmb(N-1,i))%998244353
  ans+=temp

print(ans%998244353)

### FIXED CODE ###

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

MOD=998244353

ans=0
temp2=1
#temp4=(M-1)**(N-1)%MOD

def getInvs(n, MOD):
  invs = [1] * (n+1)
  for x in range(2, n+1):
    invs[x] = (-(MOD//x) * invs[MOD%x]) % MOD
  return invs

invs = getInvs(max(N+3,M-1), MOD)

Vec=[0]*N
#inv=1
#for i in range(MOD-2):
#  inv*=M-1
#  inv%=MOD

'''
for i in range(K+1):
  if i == 0:
    temp1=M
    temp1*=(M-1)**(N-1)%MOD
    temp1%=MOD
    ans+=temp1*temp2%MOD
    #print(cmb)
  else:
    temp1*=invs[M-1]%MOD
    temp2*=(N-i)*invs[i]
    temp2%=MOD
    ans+=temp1*temp2%MOD
    cmb=cmb*(N-i-1)*i*invs[i]%MOD
    #print(cmb)
'''
for i in range(N):
  if i == 0:
    temp1=M
    Vec[N-i-1]=temp1
  else:
    temp1*=(M-1)*(N-i)
    temp1*=invs[i]
    temp1%=MOD
    Vec[N-i-1]=temp1


ans=sum(Vec[:K+1])

print(ans%MOD)
import sys
def input(): return sys.stdin.readline().split()
def main():
    _ = input()
    A = (map(int, input().split()))
    print("second") if all(( a%2==0 for a in A)) else print("first")
if __name__ == "__main__":
    main()


### FIXED CODE ###

import numpy as np

def main():
    stdin = np.fromstring(open(0).read(), dtype=np.int32, sep=' ')
    N = stdin[0]
    A = stdin[1:]
    A = np.mod(A, 2)
    print("first") if np.count_nonzero(A) else print("second")
if __name__ == "__main__":
    main()
n, x = map(int,input().split())
ans = [-1]*(2*n - 1)
if x == 1 or x == 2*n - 1:
    print('No')
else:
    if n == 3:
        if x == 3:
            print('No')
        else:
            print(1 + '¥n' + 2 + '¥n' + 3)
    else:
        print('Yes')
        t = 0
        if x == 2:
            ans[n - 3] = 4
            ans[n - 2] = 1
            ans[n - 1] = 2
            ans[n] = 3
            t, i = 1, 0
            for rep in range(10**6):
                if i >= 2*n - 1:
                    break
                if ans[i] == -1:
                    if t > 4:
                        ans[i] = t
                        i += 1
                    t += 1 
                else:
                    i += 1
        else:
            ans[n - 3] = x - 2
            ans[n - 2] = x + 1
            ans[n - 1] = x
            ans[n] = x - 1
            t, i = 1, 0
            for rep in range(10**6):
                if i >= 2*n - 1:
                    break
                if ans[i] == -1:
                    if t < x - 2 or t > x + 1:
                        ans[i] = t
                        i += 1
                    t += 1 
                else:
                    i += 1

        for i in ans:
            print(i)

### FIXED CODE ###

n, x = map(int,input().split())
ans = [-1]*(2*n - 1)
if x == 1 or x == 2*n - 1:
    print('No')
else:
    if n == 2:
        if x == 3:
            print('No')
        else:
            print('Yes')
            print('1\n2\n3')
    else:
        print('Yes')
        t = 0
        if x == 2:
            ans[n - 3] = 4
            ans[n - 2] = 1
            ans[n - 1] = 2
            ans[n] = 3
            t, i = 1, 0
            for rep in range(10**6):
                if i >= 2*n - 1:
                    break
                if ans[i] == -1:
                    if t > 4:
                        ans[i] = t
                        i += 1
                    t += 1 
                else:
                    i += 1
        else:
            ans[n - 3] = x - 2
            ans[n - 2] = x + 1
            ans[n - 1] = x
            ans[n] = x - 1
            t, i = 1, 0
            for rep in range(10**6):
                if i >= 2*n - 1:
                    break
                if ans[i] == -1:
                    if t < x - 2 or t > x + 1:
                        ans[i] = t
                        i += 1
                    t += 1 
                else:
                    i += 1

        for i in ans:
            print(i)
#Day of Takahashi

#入力
a, b = map(int, input().split())

#計算
if a > b:
	ans = a-1

if a < b:
	ans = a

#出力
print("{}".format(ans))

### FIXED CODE ###

#Day of Takahashi

#入力
a, b = map(int, input().split())

#計算
if a > b:
	ans = a-1

if a <= b:
	ans = a

#出力
print("{}".format(ans))
a,b,c=map(int,input().split())
print('delicious' if b<c else 'safe' if c-b<a else 'dengerous'))

### FIXED CODE ###

a,b,c=map(int,input().split())
print('delicious' if c<=b else 'safe' if c-b<=a else 'dangerous')
import sys

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

#print(a, b, c)
ab = a == b
ac = a == c
bc = b == c

if ab and bc:A
  print('No')
  sys.exit()

if not ab and not ac and not bc:
  print('No')
  sys.exit()

print('Yes')

### FIXED CODE ###

import sys

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

#print(a, b, c)
ab = a == b
ac = a == c
bc = b == c

if ab and bc:
  print('No')
  sys.exit()

if not ab and not ac and not bc:
  print('No')
  sys.exit()

print('Yes')
print(int(input()*int(input()))

### FIXED CODE ###

#!/usr/bin/env python3
import bisect
import collections
import sys

sys.setrecursionlimit(1000000)
ACMOD = 1000000007
INF = 1 << 62



def solve(A: int, B: int):
    print(A*B)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()
import fractions
N=int(input())
A=list(map(int,input().split()))
c=1
a=0
w=10**9+7
for A_ in A:
    c_=c*A_//fractions.gcd(c,A_)
    a=(a*c_//c+c_/A_)%w
    c=c_
print(int(a))

### FIXED CODE ###

import fractions
N=int(input())
A=list(map(int,input().split()))
c=1
a=0
w=10**9+7
for A_ in A:
    c=c*A_//fractions.gcd(c,A_)
for A_ in A:
    a+=c//A_
print(int(a%w))
N, M = map(int, input().split())
X = list(map(int, input().split()))

if M <= N:
    print(0)
else:
    X.sort()
    dX = np.diff(X)
    dX.sort()
    print(sum(dX[:N+1]))

### FIXED CODE ###

import numpy as np
N, M = map(int, input().split())
X = list(map(int, input().split()))

if M <= N:
    print(0)
else:
    X.sort()
    # print("X =", X)
    dX = np.diff(X)
    # print("dX =", dX)
    dX.sort()
    print(sum(dX[:M-N]))
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  3 19:52:44 2019

@author: Yamazaki Kenichi
"""

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

counta = 0
for i in range(1,K):
    if len(str(A/i)) < 10**10 and len(str(B%i)) < 10**10:
        counta += 1
    if counta == K:
        ans = i
        break
print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Mar  3 19:52:44 2019

@author: Yamazaki Kenichi
"""

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

counta = 0
ans = []
for i in range(1,101):
    if A%i == 0 and B%i == 0:
        ans.append(i)
print(ans[-K])
N = int(input())
H = int(input())
W = int(input())
n = 0
while n<N:
    A = int(input())
    B = int(input())
    n +=1
if (H == A and W == B) or (H == A/2 and W == B/2):
    print(cnt = +1)

### FIXED CODE ###

n = str(input())
print(n.count('2'))
N,M = list(map(int, input().split()))
X = [list(map(int, input().split())) for i in range(N)]

l = M
result = 0
while l > 0:
    index_lis = [i for i, v in enumerate(X) if v[1] == max(X, key=lambda xx: xx[1])[1]]
    if len(index_lis) >= 2:
        a = max(X, key=lambda xx: xx[index_lis][0])
    else:
        a = X[index_lis[0]]
    if a[0] > l:
        X.remove(a)
    elif a[0] <= l:
        result += a[1]
        l -= 1
        X.remove(a)
print(result)

### FIXED CODE ###

import sys
import heapq
 
N, M = list(map(int, input().split()))
jobs = []

#上限内で報酬を得られる単発を一度リストに入れる。
for line in sys.stdin:
    A, B = map(int, line.split())
    if A > M:
        continue
    jobs.append((A, B))

#逆順にsort
jobs.sort(reverse=True)

#heatpqでpriority quene，最大値を取り出すときは-qを加えて挿入し，-1をかけて取り出す
q = []
ans = 0
#後ろの日にちから回す
for i in range(1, M + 1):
    #日数が足りる単発をheatpqのリストに加えていく
    while jobs and jobs[-1][0] <= i:
        A, B = jobs.pop()
        heapq.heappush(q, -B)
 
    if q:
        #できる仕事がある場合，最大の給料のを取り出す
        ans += -heapq.heappop(q)
print(ans)
import numpy as np

N=int(input())
print(np.arange(1,N).sum())

### FIXED CODE ###

N=int(input())
print((N)*(N-1)//2)
N = int(input())
X = list(map(int, input().split()))

s_X = soreted(X)
miX = s_X[N//2]
mi1X = s_X[N//2 + 1]

for a in X:
  if(a.find(s_X)<=N//2):
    print(mi1X)
  else:
    print(miX)

### FIXED CODE ###

# import copy

N = int(input())
X = list(map(int, input().split()))
# S_X = copy.copy(X)
S_X = sorted(X)
miX = S_X[N // 2 - 1]
mi1X = S_X[N // 2]
# print(S_X, X)
# print(miX, mi1X)

# print(miX, mi1X)
# print(X)
for a in X:
    if(a <= miX):
        print(mi1X)
    else:
        print(miX)
n=input()
if n(0)==n(2):
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n=input()
if n[0]==n[2]:
  print('Yes')
else:
  print('No')
class Job:

    def __repr__(self):
        return f'Job(reward={self.reward}, days={self.days})'

    def __init__(self, reward, days):
        self.reward = reward
        self.days = days


def dfs(jobs, remaing_days, selected_jobs):
    reward = 0

    # print(jobs, remaing_days)

    if remaing_days == 0:
        return 0

    for job in jobs:
        if job.days <= remaing_days:
            # print(
            #     f'trying {job} sum: {reward} remaing_days:{remaing_days} selected:{selected_jobs}')

            next_selected_jobs = selected_jobs | set([job])
            remaining_jobs = jobs - set([job])
            new_reward = job.reward + \
                dfs(remaining_jobs, remaing_days - 1, next_selected_jobs)

            # if reward < new_reward:
            #     print(
            #          f'pickup {job} sum: {new_reward} remaing_days:{remaing_days} selected:{selected_jobs}')
            reward = max(reward, new_reward)
        # else:
        #     print(
        #         f'fail to pickup {job} sum: {reward} remaing_days:{remaing_days} selected:{selected_jobs}')

    return reward


N, M = list(map(int, input().split()))
jobs = set()

for i in range(N):
    A, B = list(map(int, input().split()))
    jobs.add(Job(reward=B, days=A))

print(dfs(jobs, M, set()))


### FIXED CODE ###

import heapq


class Job:

    def __repr__(self):
        return "%d,%d".format(self.days, self.reward)

    def __lt__(self, other):
        return self.reward < other.reward

    def __init__(self, job_id, reward, days):
        self.id = job_id
        self.reward = reward
        self.days = days

N, M = list(map(int, input().split()))
h = []
jobs = []

for i in range(N):
    A, B = list(map(int, input().split()))
    jobs.append(Job(job_id=i, reward=B, days=A))


jobs = sorted(jobs, key=lambda j: j.days)
idx = 0
c = 0

for i in range(1, M+1):
    while idx < N and jobs[idx].days <= i:
        heapq.heappush(h, -jobs[idx].reward)
        idx += 1

    if len(h) != 0:
        c += -heapq.heappop(h)

print(c)
N = int(input())
bin_X = input()
int_X = int(bin_X, 2)

pop_cnt_1 = 0
for i in bin_X:
    if i == '1':
        pop_cnt_1 += 1
pop_cnt_0 = pop_cnt_1 + 1
pop_cnt_1 = pop_cnt_1 - 1

int_X_0 = int_X % pop_cnt_0
int_X_1 = int_X % pop_cnt_1

def pop_cnt(n):
    c = 0
    for i in bin(n):
        if i == '1':
            c += 1
    return c

for i in range(N):
    if bin_X == '0':
        print(0)
        continue
    
    z = 2 ** (N-i-1)
    if bin_X[i] == '1':
        n = (int_X-z)%pop_cnt_1
    else:
        n = (int_X+z)%pop_cnt_0
   
    cnt = 1
    while n != 0:
        n = n % pop_cnt(n)
        cnt += 1
    print(cnt)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def pop_cnt(n):
    return bin(n).count('1')


def f(n):
    cnt = 0
    while n != 0:
        n = n % pop_cnt(n)
        cnt += 1
    return cnt
 
n = int(readline())
x2 = list(readline().decode().rstrip())
x10 = int(''.join(x2), 2)

c = x2.count('1')
mod1 = x10 % (c + 1)
mod2 = x10 % (c - 1) if c-1 != 0 else 0

for i in range(n):
    ans = 0
    if x2[i] == '0':
        t = (mod1 + pow(2, n-i-1, c+1)) % (c+1)
    else:
        if c-1 != 0:
            t = (mod2 - pow(2, n-i-1, c-1)) % (c-1)
        else:
            print(0)
            continue
    
    ans = f(t) + 1
    print(ans)
N = input()
array= input().split()
left_array=array[:array/3+1]
mid_array= array[array/3+1:-array/3]
right_array= array[-array/3]
lst=0
for i in N:
    left_array=array[:array/3+i+1]
    l = left_array.sort()[i+1:]
    right_array=array[-array/3+i+1:]
    r = right_array.sort(reverse=True)[N-i-1:]
    ans = sum(abs(l-r))
    if ans > lst:
        lst= ans
print(lst)
    

### FIXED CODE ###

N = int(input())
array = [int(n) for n in input().split()]
import copy
import heapq
lst = [None for i in range(N + 1)]
left_lst = copy.deepcopy(lst)
right_lst = copy.deepcopy(lst)
left_array = array[:N]
right_array= [-n for n in array[-N:]]
l_sum = sum(left_array)
r_sum = sum(right_array)
heapq.heapify(left_array)
heapq.heapify(right_array)
left_lst[0] = l_sum
right_lst[0] = r_sum

for k in range(N, 2 * N):
    new_a, new_b = array[k], array[-k - 1]*-1
    heapq.heappush(left_array,new_a)
    heapq.heappush(right_array,new_b)
    old_a = heapq.heappop(left_array)
    l_sum += (new_a - old_a)
    left_lst[k - N + 1] = l_sum
    old_b = heapq.heappop(right_array)
    r_sum += (new_b - old_b)
    right_lst[k - N + 1] = r_sum
lst = [ a + b for a, b in zip(left_lst, list(reversed(right_lst)))]
print(max(lst))
MAX = int(2e5)


n = int(input())
lis = list(map(int,input().split()))
lis2 = [0]*MAX
# lis.sort()
# m = max(lis)
ans = 0
for num in lis:
    lis2[num] += 1

for num in lis:
    for i in range(num*2, MAX, num):
        if lis2[i] > 0:
            lis2[i] += 1

print(len([i for i in lis if lis2[i] == 1]))

### FIXED CODE ###

# MAX = int(1e6)+2


n = int(input())
lis = list(map(int,input().split()))
lis.sort()
MAX = lis[-1]
lis2 = [0]*(MAX+1)
# lis.sort()
# m = max(lis)
ans = 0

for num in lis:
    for i in range(num, MAX+1, num):
            lis2[i] += 1

for j in set(lis):
    if lis2[j] == 1:
        ans += 1
print(ans)
N = int(input())
A = list(map(int, input.split()))

def solve(N, A):
  if not A or A[0] != 1:
    print(-1)
    return

  prev = 1
  rt = 1
  for a in A[1:]:
    if a > prev * 2:
      print(-1)
      return
    rt += (prev * 2 - a) % (prev * 2)
    prev = a

  print(rt)

solve(N, A)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
  
def solve(N, A):
  
  if N == 0 and A[0] > 1 or N > 0 and A[0] > 0:
    print(-1)
    return

  total = sum(A[1:])
  #t = A[-1] + A[-2]
  par = 1 - A[0]
  rt = 1
  for i, a in enumerate(A[1:]):
    total -= a
    max_node = par * 2
    cur = max_node - a
    if cur < 0:
      print(-1)
      return
    cur = min(total, cur)
    #print(i+1, a, cur)
    rt += a
    if i + 1 < N:
      rt += cur
    par = cur  
   
  print(rt)
  
solve(N, A)
#YYMM, MMYY, AMBIGUOUS, NA
S = str(input())

s0 = int(S[0:2])
s1 = int(S[2:])

if s0>12:#YYMM or NA
    if s1>12:
        ans=="NA"
    else:
        ans=="YYMM"
elif s1>12:#MMYY
    ans="MMYY"
else:
    "AMBIGUOUS"
    
print(ans)

### FIXED CODE ###

#YYMM, MMYY, AMBIGUOUS, NA
S = str(input())

s0 = int(S[0:2])
s1 = int(S[2:])

if s0>12 or s0==0:#YYMM or NA
    if s1>12 or s1==0:
        ans="NA"
    else:
        ans="YYMM"
elif s1>12 or s1==0:#MMYY
    ans="MMYY"
else:
    ans="AMBIGUOUS"
    
print(ans)
A = int(input())
op = input()
B = int(input())

if op == '+':
  print(A + B)
else:
  print(A - B)


### FIXED CODE ###

a = input().split()
if a[1] == '+':
    print(int(a[0])+int(a[2]))
else:
    print(int(a[0])-int(a[-1]))
# coding: utf-8
# Here your code !
N, K = map(int, raw_input().split(" "))
D = map(int, raw_input().split(" "))
nums = range(0,10)
#好きな数字を昇順のリストに整理
like = list(set(nums).difference(set(D)))
like.sort()
print like
#数字を上から1文字づつ処理
grade = len(str(N))-1
ans = 0
flag = False #上の桁で嫌いな数字があるか
for i in str(N):
    if int(i) == 9 and 9 not in like and not flag:
        ans += 10**(grade+1)
        flag = True
    elif int(i) not in like and not flag:
        for j in like:
            if j > int(i):
                ans += j*10**(grade)
                flag = True
                break
    elif flag:
        ans += like[0]*10**(grade)
    grade -= 1
if ans < N:
    ans = N
print ans


### FIXED CODE ###

# coding: utf-8
# Here your code !
xyz = raw_input().split(" ")
c1, c2 = 0, 0
for i in xyz:
    if i == "5":
        c1 += 1
    elif i == "7":
        c2 += 1
if (c1 == 2 and c2 == 1):
    print "YES"
else:
    print "NO"
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7

def main():
    s = input()
    t = input()
    ls = len(s)
    lt = len(t)
    for i in t:
        if not i in s:
            print(-1)
            exit()
    s *= lt
    nm = 0
    for i,si in enumerate(s):
        if si == t[nm]:
            nm += 1
        if nm == lt:
            print(i+1)
            exit()

    return None

if __name__ == '__main__':
    main()


### FIXED CODE ###

'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7

def main():
    s = input()
    ls = len(s)
    t = input()
    if t[0] in s:
        idx = s.find(t[0])
    else:
        print(-1)
        exit()
    for i in t[1::]:
        nt = s.find(i,idx%ls+1)
        ntl = s.find(i)
        if ntl == -1:
            print(-1)
            exit()
        elif nt == -1:
            idx = (idx//ls)*ls+ls+ntl
        else:
            idx = (idx//ls)*ls+nt
    print(idx+1)
    return None

if __name__ == '__main__':
    main()
s = input()
w = input()
if w >= s:
  print("unsafe")
else:
  print('safe')

### FIXED CODE ###

s, w = map(int, input().split())
if w >= s:
  print('unsafe')
else:
  print("safe")