Problem:
 Score : 200 points    Problem Statement You have a digit sequence S of length 4 . You are wondering which of the following formats S is in:   YYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order  MMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order   If S is valid in only YYMM format, print YYMM ; if S is valid in only MMYY format, print MMYY ; if S is valid in both formats, print AMBIGUOUS ; if S is valid in neither format, print NA .      Constraints  S is a digit sequence of length 4 .         Input Input is given from Standard Input in the following format:  S       Output Print the specified string: YYMM , MMYY , AMBIGUOUS or NA .        Sample Input 1 1905      Sample Output 1 YYMM  May XX19 is a valid date, but 19 is not valid as a month. Thus, this string is only valid in YYMM format.       Sample Input 2 0112      Sample Output 2 AMBIGUOUS  Both December XX01 and January XX12 are valid dates. Thus, this string is valid in both formats.       Sample Input 3 1700      Sample Output 3 NA  Neither 0 nor 17 is valid as a month. Thus, this string is valid in neither format.

Solution (Python):
S = input()
S_bef = int(S[:2])
S_aft = int(S[-2:])

is_bef_yy = False
is_bef_mm = False
is_aft_yy = False
is_aft_mm = False

if S_bef >= 1 and S_bef <= 12:
    is_bef_mm = True
if S_bef >= 0:
    is_bef_yy = True
if S_aft >= 1 and S_aft <= 12:
    is_aft_mm = True
if S_aft >= 0:
    is_aft_yy = True

if is_bef_yy and is_bef_mm and is_aft_yy and is_aft_mm:
    print('AMBIGUOUS')
elif is_bef_yy and is_aft_mm:
    print('YYMM')
elif is_aft_yy and is_bef_mm:
    print('MMYY')
else:
    print('NA')

Solution (Python):
s = input()
print("AMBIGUOUS" if int((s[:2]))>0 and int((s[:2]))<13 and int(s[2:])>0 and int(s[2:])<13 else "YYMM" if int(s[2:])<13 and s[2:]!="00" else "MMYY"if int(s[:2])<13 and s[:2]!="00" else "NA")

Solution (Python):
S = input()

ans = ''
L, R = int(S[:2]), int(S[2:])
if L >0 and L < 13:
    if R > 0 and R < 13:
        ans = 'AMBIGUOUS'
    else:
        ans = 'MMYY'
else:
    if R > 0 and R < 13:
        ans = 'YYMM'
    else:
        ans = 'NA'
        
print("{}".format(ans))

Solution (Python):
s = input()

if 0 < (int(s[0] + s[1])) < 13:
    if 0 < (int(s[2] + s[3])) < 13:
        print("AMBIGUOUS")
    else:
        print("MMYY")

else:
    if 0 < (int(s[2] + s[3])) < 13:
        print("YYMM")
    else:
        print("NA")

Solution (Python):
def main():
    s = input()
    a = int(s[:2], 10)
    b = int(s[2:], 10)

    print(solve(a, b))

def solve(a, b):
    x = y = False

    if 1 <= a <= 12:
        x = True
    if 1 <= b <= 12:
        y = True
    
    if x and not y:
        return 'MMYY'
    if not x and y:
        return 'YYMM'
    if x and y:
        return 'AMBIGUOUS'
    return 'NA'

main()

Solution (Python):
date = input()

top = int(date[0:2])
bottom = int(date[2:4])

is_top_mm = False
is_top_yy = False
is_bottom_mm = False
is_bottom_yy = False

def print_result():
    global is_top_mm
    global is_top_yy
    global is_bottom_mm
    global is_bottom_yy

    
    if not is_top_mm and not is_top_yy:
        print('NA')
        return
    if not is_bottom_mm and not is_bottom_yy:
        print('NA')
        return


    
    if is_top_yy:
        if is_bottom_mm:
            print('YYMM')
            return
        if is_bottom_yy:
            print('NA')
            return

    
    if is_bottom_yy:
        if is_top_mm:
            print('MMYY')
            return
        if is_top_yy:
            print('NA')
            return

    print('AMBIGUOUS')


if 1 <= top <= 12:
    is_top_mm = True

if 13 <= top <= 99 or top == 0:
    is_top_yy = True

if 1 <= bottom <= 12:
    is_bottom_mm = True

if 13 <= bottom <= 99 or bottom == 0:
    is_bottom_yy = True

print_result()

Solution (Python):
s = list(input())
a = int("".join(s[:2]))
b = int("".join(s[2:]))

a_YY = 0
a_MM = 0
b_YY = 0
b_MM = 0

if a <= 12 and a >= 1:
    a_MM = 1
elif a == 0 or (a > 12 and a <= 99):
    a_YY = 1

if b <= 12 and b >= 1:
    b_MM = 1
elif b == 0 or (b > 12 and b <= 99):
    b_YY = 1

if a_MM == 1 and b_MM == 1:
    print("AMBIGUOUS")
elif a_MM == 1 and b_YY == 1:
    print("MMYY")
elif b_MM == 1 and a_YY == 1:
    print("YYMM")
else:
    print("NA")

Solution (Python):
S = input()
YM = True
MY = True
former = int(S[0])*10 + int(S[1])
latter = int(S[2])*10 + int(S[3])
if latter == 0 or latter>=13:
    YM = False
if former == 0 or former>=13:
    MY = False
if YM and MY:
    print("AMBIGUOUS")
elif YM == False and MY:
    print("MMYY")
elif MY == False and YM:
    print("YYMM")
else:
    print("NA")

Solution (Python):
YM = False
MY = False

S = input()
S1 = int(S[:2])
S2 = int(S[2:])
if 0 < S1 < 13:
    MY = True
if 0 < S2 < 13:
    YM = True

if YM and MY:
    print('AMBIGUOUS')
elif YM:
    print('YYMM')
elif MY:
    print('MMYY')
else:
    print('NA')

Solution (Python):

a = input()
first = int(a[:2])
second = int(a[2:])

if first <= 12 and 0 < first:
    F = 'M'
else:
    F = 'Y'

if second <= 12 and 0 < second:
    S = 'M'
else:
    S = 'Y'

b = F + S
if b == "YM":
    print("YYMM")
elif b == 'MY':
    print('MMYY')
elif b == 'MM':
    print("AMBIGUOUS")
else:
    print('NA')

Solution (Python):
s = input()
a = int(s[:2])
b = int(s[-2:])
if 1 <= a <= 12 and 1 <= b <= 12:
    print('AMBIGUOUS')
elif 1 <= b <= 12:
    print('YYMM')
elif 1 <= a <= 12:
    print('MMYY')
else:
    print('NA')

Solution (Python):

def isMonth(num):
    return (1 <= num and num <= 12)

if __name__ == '__main__':
    s = input()
    s1 = int(s[:2])
    s2 = int(s[2:])

    if(isMonth(s1)):
        if(isMonth(s2)):
            print("AMBIGUOUS")
        else:
            print("MMYY")
    else:
        if(isMonth(s2)):
            print("YYMM")
        else:
            print("NA")

Solution (Python):
i = input()
x = int(i[0:2])
y = int(i[2:4])

def isMM(a):
  return 1 <= a and a <= 12

r = isMM(x) * 2 + isMM(y)

print(["NA", "YYMM", "MMYY", "AMBIGUOUS"][r])

Solution (Python):
s = str(input())
x = int(s[0:2])
y = int(s[2:])
a = ((1<=x)and(x<=12))
b = ((1<=y)and(y<=12))
if a and b:
  print("AMBIGUOUS")
elif a and (not b):
  print("MMYY")
elif (not a) and b:
  print("YYMM")
else:
  print("NA")

Solution (Python):
s = input()
ans = 0
if int(s[0:2]) <= 99 and int(s[0:2]) >= 00 and int(s[2:4]) > 00 and int(s[2:4]) <= 12:
  ans += 1
if int(s[0:2]) <= 12 and int(s[0:2]) > 00 and int(s[2:4]) >= 00 and int(s[2:4]) <= 99:
  ans += 2
if ans == 1:
  print("YYMM")
elif ans == 2:
  print("MMYY")
elif ans == 3:
  print("AMBIGUOUS")
else:
  print("NA")

Solution (Python):


def is_month(mm):
    if 1 <= mm <= 12:
        return True
    return False


s = input()
yy, mm = s[:2], s[2:]
yy = int(yy)
mm = int(mm)


if is_month(yy) and is_month(mm):
    print('AMBIGUOUS')
elif is_month(yy):
    print('MMYY')
elif is_month(mm):
    print('YYMM')
else:
    print('NA')

Solution (Python):
S = input()

M1 = False
M2 = False
if int(S[0]) <= 1:
    if S[0] == '0' and S[1] != '0':
        M1 = True
    elif S[0] == '1':
        if 0 <= int(S[1]) <= 2:
            M1 = True

if int(S[2]) <= 1:
    if S[2] == '0' and S[3] != '0':
        M2 = True
    elif S[2] == '1':
        if 0 <= int(S[3]) <= 2:
            M2 = True

if M1 and M2:
    print("AMBIGUOUS")
elif M1 and (not M2):
    print("MMYY")
elif (not M1) and M2:
    print("YYMM")
elif (not M1) and (not M2):
    print("NA")

Solution (Python):
S = str(input())
pri = ["YYMM","MMYY","AMBIGUOUS","NA"]
nt = ["01","10","11","00"]
Sz = S[0]+S[1]
Sa = S[2]+S[3]
flag = ""
Sz = int(Sz)
Sa = int(Sa)
if Sz > 0 and Sz <= 12:
 flag += "1"
else:
 flag += "0"
if Sa > 0 and Sa <= 12:
 flag += "1"
else:
 flag += "0"
print (pri[nt.index(flag)])

Solution (Python):
S = input()
S = list(S)
keta1 = int(S[3])
keta2 = int(S[2])*10
keta3 = int(S[1])
keta4 = int(S[0])*10
keta21 = keta1 + keta2
keta43 = keta3 + keta4



if (0 == keta43 or 13 <= keta43) and 1<= keta21 <= 12:
  print('YYMM')

elif 1 <= keta43 <= 12 and (0 == keta21 or 13 <= keta21):
  print('MMYY')

elif (0 == keta43 or 13 <= keta43)  and (0 == keta21 or 13 <= keta21):
  print('NA')
else:
  print('AMBIGUOUS')

Solution (Python):
S = list(input())

p = S[0]+S[1]
q = S[2]+S[3]

p_flag = 0
q_flag = 0

if int(p) == 0 and int(q) == 0:
    print('NA')
elif int(p) == 0:
    if int(q) < 13:
        print('YYMM')
    else:
        print('NA')
elif int(q) == 0:
    if int(p) < 13:
        print('MMYY')
    else:
        print('NA')
else:
    if int(p) > 12:
        p_flag = 1
    if int(q) > 12:
        q_flag = 1

    if p_flag and q_flag:
        print('NA')
    elif p_flag:
        print('YYMM')
    elif q_flag:
        print('MMYY')
    else:
        print('AMBIGUOUS')

Solution (Python):
S = input()
a = int(S[0:2])
b = int(S[2:4])

if a > 12 and 0 < b <= 12 or a == 0 and 0 < b <= 12:
  print('YYMM')
elif a > 12 and b > 12:
  print('NA')
elif a > 12 and b == 0 or a == 0 and b > 12:
  print('NA')
elif 0 < a <= 12 and 0 < b <= 12:
  print('AMBIGUOUS')
elif b > 12 and 0 < a <= 12 or b == 0 and 0 < a <= 12:
  print('MMYY')
else:
  print('NA')

Solution (Python):
S=str(input())
if int(S[0:2])>0 and int(S[0:2])<13 and int(S[2:4])>0 and int(S[2:4])<13:
  print("AMBIGUOUS")
elif int(S[0:2])>0 and int(S[0:2])<13:
  print("MMYY")
elif int(S[2:4])>0 and int(S[2:4])<13:
  print("YYMM")
else:
  print("NA")

Solution (Python):
s = str(input())
a = int(s[0])*10 + int(s[1])
b = int(s[2])*10 + int(s[3])
if (0 < a <= 12 and 0 <= b) and (0 <= a and 0 < b <= 12):
    print("AMBIGUOUS")
elif 0 < a <= 12:
    print("MMYY")
elif 0 < b <= 12:
    print("YYMM")
else:
    print("NA")

Solution (Python):


def is_yy(s):
    return s.isdigit()

def is_mm(s):
    if s[0] == '0':
        return s[1] in '123456789'
    else:
        return s[1] in '012'

def is_yymm(s):
    return is_yy(s[:2]) and is_mm(s[2:])

def is_mmyy(s):
    return is_mm(s[:2]) and is_yy(s[2:])

s = input()
  
if is_yymm(s):
    if is_mmyy(s):
        print('AMBIGUOUS')
    else:
        print('YYMM')
elif is_mmyy(s):
    print('MMYY')
else:
    print('NA')

Solution (Python):
s = input()
a = int(s[0 : 2])
b = int(s[2:])


if a<=12 and b<=12 and a>0 and b>0:
  print('AMBIGUOUS')

elif a<=12 and (b == 0 or b > 12) and a > 0:
  print("MMYY")
  
elif b<=12 and b > 0 and (a == 0 or a > 12):
  print("YYMM")
else:
  print("NA")

Solution (Python):
string=str(input())
upper=string[0]+string[1]
lower=string[2]+string[3]
if 0 < int(upper) <13:
  upper_may_mm=1
else:
  upper_may_mm=0

if 0 < int(lower) <13:
  lower_may_mm=1
else:
  lower_may_mm=0


if (lower_may_mm ==1) & (upper_may_mm ==1):
  print("AMBIGUOUS")
elif (lower_may_mm ==0) & (upper_may_mm ==1):
  print("MMYY")
elif (lower_may_mm ==1) & (upper_may_mm ==0):
  print("YYMM")
else:
  print("NA")

Solution (Python):
s=list(input())
ss=s[:2]
sss=s[2:]
x=int("".join(ss))
y=int("".join(sss))

if 1<=x<=12 and 1<=y<=12:
    print("AMBIGUOUS")
elif 1<=x<=12 :
    print("MMYY")
elif 1<=y<=12:
    print("YYMM")
elif x==0 and y==0:
    print("NA")
elif x>=13 and y==0:
    print("NA")
elif x==0 and y>=13:
    print("NA")
elif x>=13 and y>=13:
    print("NA")

Solution (Python):
S = int(input())
s = S // 1000
a = s * 10 + (S - s * 1000) // 100
b = S - a * 100
if(1 <= a and a <= 12) :
  if(1 <= b and b <= 12) :
    print("AMBIGUOUS")
  else :
    print("MMYY")
else :
  if(1 <= b and b <= 12) :
    print("YYMM")
  else :
    print("NA")

Solution (Python):


S = input()
Mflag = False
Yflag = False
li = [(i+j) for (i,j) in zip(S[::2],S[1::2])]


if 1 <= int(li[0]) <= 12:
    Mflag = True
else:
    pass

if 1 <= int(li[1]) <= 12:
    Yflag = True
else:
    pass

if Mflag and Yflag:
    print("AMBIGUOUS")
elif Mflag == True and Yflag == False:
    print("MMYY")
elif Mflag == False and Yflag == True:
    print("YYMM")
else:
    print("NA")

Solution (Python):
def main():
    line_input = input()
    head = int(line_input[:2])
    tail = int(line_input[2:])

    YYMM = True
    MMYY = True
    if 1 > head or head > 12:
        MMYY = False

    if 1 > tail or tail > 12:
        YYMM = False

    if not (MMYY or YYMM):
        print("NA")
    elif MMYY and YYMM:
        print("AMBIGUOUS")
    elif MMYY:
        print("MMYY")
    elif YYMM:
        print("YYMM")


if __name__ == "__main__":
    main()

Solution (Python):
S = input()
head, tail = int(S[:2]), int(S[2:])
head_mm = 1 <= head <= 12
tail_mm = 1 <= tail <= 12
if head_mm and tail_mm:
    print("AMBIGUOUS")
elif head_mm:
    print("MMYY")
elif tail_mm:
    print("YYMM")
else:
    print("NA")

Solution (Python):
format = ['YYMM', 'MMYY', 'AMBIGUOUS', 'NA']
s = input()
ft,bk = s[0:2],s[2:4]
if 1 <= int(ft) <= 12:
    if 1 <= int(bk) <= 12:
        print(format[2])
    else:
        print(format[1])
else:
    if 1 <= int(bk) <= 12:
        print(format[0])
    else:
        print(format[3])

Solution (Python):

"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""


"""
Created on Sat Apr 13 09:53:12 2019

@author: Owner
"""
import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
import bisect


def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   

def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


"""
N, X = map(int, input().split())

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

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())


dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')


ABT = zip(A, B, totAB)
result = 0

sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)


(x >> i) & 1


dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break

add = 1 
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)


li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    


org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)




    for h in range(0,H):
        for w in range(0,W):
            if h == 0 and w == 0:
                pass
            elif h == 0:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h-1][W-w]+1)
            elif w == 0:   
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1)
            else:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1, D[H-h-1][W-w]+1, D[H-h][W-w]+2)
            d_max = max(D[H-h-1][W-w-1], d_max)

"""

S = input()
S = list(S)
A = int("".join(S[0:2]))
B = int("".join(S[2:4]))


def main():
    AM_flg = False
    BM_flg = False
    if 1<= A and A <=12:
        AM_flg = True
    if 1<= B and B <=12:
        BM_flg = True
    
    if AM_flg == True and BM_flg == False:
        print("MMYY")
    elif AM_flg == False and BM_flg == True:
        print("YYMM")
    elif AM_flg == True and BM_flg == True:
        print("AMBIGUOUS")
    else:
        print("NA")

        
                
                
                
            
            
                

    
if __name__ == '__main__':
    main()

Solution (Python):
S = int(input())

if (S//100>=13 or S//100==0) and 0<S%100<=12:
    print("YYMM")
elif (S%100>=13 or S%100==0) and 0<S//100<=12:
    print("MMYY")
elif 0<S//100<=12 and 0<S%100<=12:
    print("AMBIGUOUS")
else:
    print("NA")

Solution (Python):

input_ = input()

front = int(input_[0:2])
back = int(input_[2:])

is_front_month = False
is_back_month = False

if(front >= 1 and front <= 12):
    is_front_month = True
if(back >= 1 and back <= 12):
    is_back_month = True

if is_front_month and is_back_month:
    print('AMBIGUOUS')
elif not is_front_month and is_back_month:
    print('YYMM')
elif is_front_month and not is_back_month:
    print('MMYY')
elif not is_front_month and not is_back_month:
    print('NA')

Solution (Python):
s = list(input())

i = int(s[0] + s[1])
k = int(s[2] + s[3])

if 0 < i <= 12:
  if 0 < k <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 0 < k <= 12:
    print('YYMM')
  else:
    print('NA')

Solution (Python):
S = input()


if int(S[:2]) >= 1 and int(S[:2]) <= 12:
    if int(S[2:]) >= 1 and int(S[2:]) <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
        
else:
    if int(S[2:]) >= 1 and int(S[2:]) <= 12:
        print("YYMM")
    else:
        print("NA")

Solution (Python):
s = input()

former = s[0:2]
latter = s[2:4]

def is_month(string):
	number = int(string)
	if 1 <= number <= 12:
		return True
	else:
		return False

if is_month(former) and not is_month(latter):
	print('MMYY')
elif not is_month(former) and is_month(latter):
	print('YYMM')
elif is_month(former) and is_month(latter):
	print('AMBIGUOUS')
else:
	print('NA')

Solution (Python):
list1 = [i for i in input()]
h1=int(list1[0]+list1[1])
t1=int(list1[2]+list1[3])


y1="YYMM"
m1="MMYY"
u1="AMBIGUOUS"
n1="NA"


if h1 == 0 :
    if t1 == 0:
        print(n1)
    elif (1<=t1 and t1 <=12):
        print(y1)
    elif t1 >= 13:
        print(n1)
elif (h1>=1 and h1<=12):
    if t1 ==0:
        print(m1)
    elif (1<=t1 and t1 <=12):
        print(u1)
    elif t1 >= 13:
        print(m1)
elif h1>=13:
    if t1 ==0:
        print(n1)
    elif (1<=t1 and t1 <=12):
        print(y1)
    elif t1 >= 13:
        print(n1)

Solution (Python):
s = input()

ans = ''
if int(s[0:2])>12 and int(s[2:4])==0:
  ans = 'NA'
elif int(s[0:2])>12 and int(s[2:4])>12:
  ans = 'NA'
elif int(s[0:2])>12 and int(s[2:4])<=12:
  ans = 'YYMM'
elif 0<int(s[0:2]) and int(s[0:2])<=12 and int(s[2:4])==0:
  ans = 'MMYY'
elif 0<int(s[0:2]) and int(s[0:2])<=12 and int(s[2:4])<=12:
  ans = 'AMBIGUOUS'
elif 0<int(s[0:2]) and int(s[0:2])<=12 and int(s[2:4])>12:
  ans = 'MMYY'
elif 0==int(s[0:2]) and 0<int(s[2:4]) and int(s[2:4])<=12:
  ans = 'YYMM'
else:
  ans = 'NA'
print(ans)

Solution (Python):
import numpy as np
S = str(input()) 
forward = S[:2]
back	= S[2:]

def str2int(str_):
  if str_[0] == "0":
    return int(str_[1])
  else:
    return int(str_)


count = np.zeros((2)) 

if (forward=="00") and (back=="00") :
  print("NA")
  
elif (forward=="00") and (back!="00"):
  if str2int(back) <= 12:
    print("YYMM")
  else:
    print("NA")
elif (forward!="00") and (back=="00"):
  if str2int(forward) <= 12:
    print("MMYY")
  else:
    print("NA")
else:
  
  
  if str2int(forward) <= 12:
    count[0] += 1
  if str2int(back) <= 12:
    count[1] += 1 
  
  if np.sum(count) == 2:
    print("AMBIGUOUS")
  elif np.sum(count) == 1 and count[0] == 1:
    print("MMYY")
  elif np.sum(count) == 1 and count[1] == 1:
    print("YYMM")
  else:
    print("NA")

Solution (Python):

def solve(): 
    S =  input()
    res = ['NA', 'YYMM', 'MMYY', 'AMBIGUOUS'][2*(0 < int(S[:2]) < 13) + (0 < int(S[2:]) < 13)]
    return str(res)

if __name__ == '__main__':
    print(solve())

Solution (Python):
S = input()

if 1 <= int(S[0:2]) <= 12:
    if 1<= int(S[2:4]) <= 12: 
        print("AMBIGUOUS")
    else: print("MMYY")

elif 1<= int(S[2:4]) <= 12:
    print("YYMM")
else: print("NA")

Solution (Python):
def ismm(mm):
    mm = int(mm)
    if 0 < mm <= 12:
        return True
    else:
        return False


if __name__ == '__main__':
    S = input()
    s01 = S[0:2]
    s23 = S[2:4]

    yymm = ismm(s23)
    mmyy = ismm(s01)

    if yymm and mmyy:
        print('AMBIGUOUS')
    elif yymm:
        print('YYMM')
    elif mmyy:
        print('MMYY')
    else:
        print('NA')

Solution (Python):
S = input()
S1 = int(S[:2])
S2 = int(S[2:])
f1 = 0
f2 = 0

if S1 <= 12 and S1 > 0:
        f1 = 1
if S2 <= 12 and S2 > 0:
        f2 = 1
if f1 and f2:
        print("AMBIGUOUS")
elif f1 == 1 and f2 == 0:
        print("MMYY")
elif f1 == 0 and f2 == 1:
        print("YYMM")
else :
        print("NA")

Solution (Python):
s = input()
t = 0
u = 0
if 0 < int(s[:2]) < 13:
    t = 1
if 0 < int(s[2:]) < 13:
    u = 1

if u == 1 and t == 1:
    print('AMBIGUOUS')
elif u == 1 and t == 0:
    print('YYMM')
elif u == 0 and t == 1:
    print('MMYY')
else:
    print('NA')

Solution (Python):
S=int(input())
head=int(S/100)
tail=S-head*100
head_can_month = head<=12 and head>=1
tail_can_month = tail<=12 and tail>=1
if head_can_month:
    if tail_can_month:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if tail_can_month:
        print("YYMM")
    else:
        print("NA")

Solution (Python):
S = str(input())

A = int(S[:2])
B = int(S[2:4])

if A > 0 and A < 13:
    aa = True
else:
    aa = False

if B > 0 and B < 13:
    bb = True
else:
    bb = False

if aa == True and bb == True:
    print('AMBIGUOUS')
elif aa == True and bb == False:
    print('MMYY')
elif aa == False and bb == True:
    print('YYMM')
else:
    print('NA')

Solution (Python):
l = list(input())

ab = l[0] + l[1]
cd = l[2] + l[3]

if ab[0] == "0":
    ab = ab[1]
if cd[0] == "0":
    cd = cd[1]

ab = int(ab)
cd = int(cd)
if ab < 13 and cd < 13 and ab != 0 and cd != 0:
    print("AMBIGUOUS")
elif ab >= 13 and cd < 13 and ab != 0 and cd != 0:
    print("YYMM")
elif cd >= 13 and ab < 13 and ab != 0 and cd != 0:
    print("MMYY")
elif ab == 0 and cd == 0:
    print("NA")
elif ab >= 13 and cd >= 13:
    print("NA")
elif ab == 0 and cd < 13 and cd != 0:
    print("YYMM")
elif cd == 0 and ab < 13 and ab != 0:
    print("MMYY")
elif ab == 0 and cd >= 13 and cd != 0:
    print("NA")
elif cd == 0 and ab >= 13 and ab != 0:
    print("NA")

Solution (Python):


S = input()

s1 = int(S[0:2])
s2 = int(S[2:4])

mm_s1 = False
mm_s2 = False
output = ''

if s1 > 0 and s1 <= 12:
    mm_s1 = True
if s2 > 0 and s2 <= 12:
    mm_s2 = True

if mm_s1 == True and mm_s2 == True:
    output = 'AMBIGUOUS'
elif mm_s1 == True and mm_s2 == False:
    output = 'MMYY'
elif mm_s1 == False and mm_s2 == True:
    output = 'YYMM'
else:
    output = 'NA'

print (output)

Solution (Python):
S = list(input())

a =  10 * int(S[0]) +int( S[1])
b =  10 * int(S[2]) + int(S[3])

def judge(x):
    if (1 <= x <= 12):
        return "MM"
    else:
        return"YY"

if ((judge (a) == "YY" )and (judge (b) == "YY" )):
    print("NA")
elif ((judge (a) == "YY" )and (judge (b) == "MM" )):
    print("YYMM")
elif((judge (a) == "MM" )and (judge (b) == "YY" )):
    print("MMYY")
else:
    print("AMBIGUOUS")

Solution (Python):
S=input()
if 1<=int(S[:2])<=12 and (13<=int(S[2:]) or int(S[2:])==0):
    print("MMYY")
elif 1<=int(S[2:])<=12 and (13<=int(S[:2]) or int(S[:2])==0):
    print("YYMM")
elif 1<=int(S[2:])<=12 and 1<=int(S[:2])<=12:
    print("AMBIGUOUS")
elif (13<=int(S[2:]) or int(S[2:])==0) and (13<=int(S[:2]) or int(S[:])==0):
    print("NA")

Solution (Python):
S = input()
 
a = S[:2]
b = S[2:]
  
if (int(a) > 12 and int(b) <= 12 and int(b) > 0):
  print('YYMM')
elif (int(b) > 12 and int(a) <= 12 and int(a) > 0):
  print('MMYY')
elif (int(a) <= 12 and int(a) > 0 and int(b) <= 12 and int(b) > 0):
  print('AMBIGUOUS')
elif (int(a) == 0 and int(b) <= 12 and int(b) > 0):
  print('YYMM')
elif (int(b) == 0 and int(a) <= 12 and int(a) > 0):
  print('MMYY')  
else:
  print('NA')

Solution (Python):
S = input()
lead = int(S[:2])
back = int(S[2:])
answer = ""
if(lead > 12 and back <= 12 and back != 0 or lead == 0 and back <= 12 and back != 0):
    answer = "YYMM"
elif(back > 12 and lead <= 12 and lead != 0 or back == 0 and lead <= 12 and lead != 0):
    answer = "MMYY"
elif(back >= 1 and back <= 12 and lead >= 1 and lead <= 12):
    answer = "AMBIGUOUS"
else:
    answer = "NA"
print(answer)

Solution (Python):
S = input()

YYMM = 1
MMYY = 1

if int(S[0] + S[1]) == 0 or int(S[0] + S[1]) > 12:
    MMYY = 0
    if int(S[2] + S[3]) == 0 or int(S[2] + S[3]) > 12:
        YYMM = 0

if int(S[2] + S[3]) == 0 or int(S[2] + S[3]) > 12:
    YYMM = 0
    if int(S[0] + S[1]) == 0 or int(S[0] + S[1]) > 12:
        MMYY = 0

if YYMM and MMYY:
    print("AMBIGUOUS")
elif YYMM:
    print("YYMM")
elif MMYY:
    print("MMYY")
else:
    print("NA")

Solution (Python):
s=int(input())

f=int(s/100)
l=s%100
ans=""

if l>0 and l<13:
  if f>0 and f<13:
    ans="AMBIGUOUS"
  else:
    ans="YYMM"
else:
  if f>0 and f<13:
    ans="MMYY"
  else:
    ans="NA"
print(ans)

Solution (Python):
s=input()
if int(s[0]+s[1]) <= 12 and int(s[2]+s[3]) <= 12:
    if int(s[0]+s[1]) == 0 and int(s[2]+s[3]) != 0:
        print('YYMM')
    elif int(s[2]+s[3]) == 0 and int(s[0]+s[1]) != 0:
        print('MMYY')
    else:
        if int(s[0]+s[1]) == 0 and int(s[2]+s[3]) == 0:
            print('NA')
        else:
            print('AMBIGUOUS')
elif int(s[0]+s[1]) <= 12 and int(s[2]+s[3]) > 12:
    print('MMYY' if int(s[0]+s[1]) > 0 else 'NA')
elif int(s[0]+s[1]) > 12 and int(s[2]+s[3]) <= 12:
    print('YYMM' if int(s[2]+s[3]) > 0 else 'NA')
else:
    print('NA')

Solution (Python):
S = input()

front = int(S[:2])
back = int(S[2:])

if front > 12:
    if back>=1 and back<=12:
        print("YYMM")
    else:
        print("NA")
elif front>=1 and front<=12:
    if back>=1 and back<=12:
        print("AMBIGUOUS")
    elif back>12 or back==0:
        print("MMYY")
else:
    if back>=1 and back<=12:
        print("YYMM")
    elif back>12 or back==0:
        print("NA")

Solution (Python):

S = input()
S1 = int(S[0:2])
S2 = int(S[2:4])


if 0 < S1 < 13 and 0 < S2 < 13:
    print('AMBIGUOUS')
if (S1 >= 13 or S1 == 0) and (S2 >= 13 or S2 == 0):
    print('NA')
if 0 < S1 < 13 and (S2 >= 13 or S2 == 0):
    print('MMYY')
if (S1 >= 13 or S1 == 0) and 0 < S2 < 13:
    print('YYMM')

Solution (Python):
def main():
    S = input()
    mae = int(S[:2])
    ushiro = int(S[2:])
    if (mae == 0 or mae > 12) and (ushiro == 0 or ushiro > 12): print('NA')
    elif (mae == 0 or mae > 12): print('YYMM')
    elif (ushiro == 0 or ushiro > 12): print('MMYY')
    else: print('AMBIGUOUS')



if __name__ == '__main__':
    main()

Solution (Python):
S = input() 
front=int(S[:2])
back =int(S[2:4])
front_YY = 0
back_YY = 0
if(front == 0 or 12 < front):
 front_YY = 1
if(back == 0 or 12 < back):
 back_YY = 1

if(front_YY * back_YY == 1):
 print('NA')
elif(front_YY  + back_YY == 0):
 print('AMBIGUOUS')
elif(front_YY == 1):
 print('YYMM')
else:
 print('MMYY')

Solution (Python):
li = list(input())




f12=int(li[0]+li[1])
b34=int(li[2]+li[3])


if f12 > 0 and f12 <13:
    if b34 > 0 and b34 <13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if b34 > 0 and b34 < 13:
        print("YYMM")
    else:
        print("NA")

Solution (Python):
S = list(input())
a = int(S[0])*10 + int(S[1])
b = int(S[2])*10 + int(S[3])
flag1 = True
flag2 = True
if a > 12 or a == 0:
    flag1 = False
if b > 12 or b == 0:
    flag2 = False


if flag1 and flag2:
    print("AMBIGUOUS")
elif flag1 and not flag2:
    print("MMYY")
elif not flag1 and flag2:
    print("YYMM")
else:
    print("NA")

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()


s = ns()
s1 = int(s[:2])
s2 = int(s[2:])

if s1 == 0 and s2 > 12:
    ans = "NA"
elif s1 > 12 and s2 == 0:
    ans = "NA"
elif s1 == 0 and s2 == 0:
    ans = "NA"
elif s1 == 0:
    ans = "YYMM"
elif s2 == 0:
    ans = "MMYY"
elif s1 > 12 and s2 > 12:
    ans = "NA"
elif s1 > 12:
    ans = "YYMM"
elif s2 > 12:
    ans = "MMYY"
else:
    ans = "AMBIGUOUS"

print(ans)

Solution (Python):



s = input()

bf = s[0] + s[1]
af = s[2] + s[3]

bf_num = int(bf)
af_num = int(af)

if (bf_num >= 1) & (bf_num <= 12):
	if (af_num >= 1) & (af_num <= 12):
		print('AMBIGUOUS')
	else :
		print('MMYY')
else :
	if (af_num >= 1) & (af_num <= 12):
		print('YYMM')
	else :
		print('NA')

Solution (Python):
s = input()
l = int(s[:2])
r = int(s[2:])

if 1<=l<=12 and 1<=r<=12:
    print('AMBIGUOUS')
elif 1<=l<=12 and (r==0 or 12<r):
    print('MMYY')
elif (l==0 or 12<l) and 1<=r<=12:
    print('YYMM')
else:
    print('NA')

Solution (Python):
s=list(input())
flag=3;
if 1<=int(s[0])*10+int(s[1])<=12:
	flag-=2
if 1<=int(s[2])*10+int(s[3])<=12:
	flag-=1
print(["AMBIGUOUS","MMYY","YYMM","NA"][flag])

Solution (Python):
s=input()
sb=int(s[:2])
sa=int(s[2:])
if sb<=12 and sb!=0:
  if sa<=12 and sa!=0:
    print('AMBIGUOUS')
  else:
    print('MMYY')
elif sa<=12 and sa!=0:
  if sb<=12 and sb!=0:
    print('AMBIGOUS')
  else:
    print('YYMM')
else:
  print('NA')

Solution (Python):
S = int(input())
first = S // 100
end = S % 100

if (0 < first and first < 13) and (0 < end and end < 13):
    print('AMBIGUOUS')
elif (0 < first and first < 13) and (0 == end or end > 12):
    print('MMYY')
elif (0 == first or first > 12) and (0 < end and end < 13):
    print('YYMM')
else:
    print('NA')

Solution (Python):
S = list(input())
S1 = int(S[0] + S[1])
S2 = int(S[2] + S[3])
if S1>12 and S2>12:
    print("NA")
elif  S1 == 0 or S2 == 0:
    if 1 <= S2 <= 12:
        print("YYMM")
    elif 1<= S1 <= 12:
        print("MMYY")
    else:
        print("NA")
elif S2 <= 12 and S1 <= 12:
    print("AMBIGUOUS")
elif S2 <= 12:
    print("YYMM")
else:
    print("MMYY")

Solution (Python):
s = int(input())

l,r = False,False
if s%100 in range(1,12+1):
    r = True
if s//100 in range(1,12+1):
    l = True

f = {(False,False):'NA', (False,True):'YYMM', (True,False):'MMYY', (True,True):'AMBIGUOUS', }

print(f[(l,r)])

Solution (Python):
S=input()
F = S[:2]
B = S[2:]
 
F_m = 0<int(F)<13
F_y = 0<=int(F)<100
B_m = 0<int(B)<13
B_y = 0<=int(B)<100
YM = F_y + B_m
MY = B_y + F_m
if YM==2 & MY==2:
    print("AMBIGUOUS")
elif YM==2:
    print('YYMM')
elif MY==2:
    print('MMYY')
else:
    print('NA')

Solution (Python):
S = map(int, list(raw_input()))

large_num = S[0]*10 + S[1]
min_num = S[2]*10 + S[3]

if large_num <= 0 and min_num <= 0: print 'NA'
elif large_num <= 0 and min_num <= 12: print 'YYMM'
elif min_num <= 0 and large_num <= 12: print 'MMYY'
elif min_num <= 0 or large_num <= 0: print 'NA'
elif large_num <= 12 and min_num <= 12: print 'AMBIGUOUS'
elif large_num <= 12: print 'MMYY'
elif min_num <= 12: print 'YYMM'
else: print 'NA'

Solution (Python):
S = input()
if S[:2] == "00":
    if S[2:] == "00" or "12" < S[2:]:
        print("NA")
    elif "01" <= S[2:] <= "12":
        print("YYMM")
elif "01" <= S[:2] <= "12":
    if S[2:] == "00" or "12" < S[2:]:
        print("MMYY")
    elif "01" <= S[2:] <= "12":
        print("AMBIGUOUS")
else:
    if S[2:] == "00" or "12" < S[2:]:
        print("NA")
    elif "01" <= S[2:] <= "12":
        print("YYMM")

Solution (Python):
S = input()

head = int(S[0:2])
tail = int(S[2:4])

if head >= 1 and head <= 12:
    if tail >= 1 and tail <= 12:
        print('AMBIGUOUS')
    elif tail <=99:
        print('MMYY')
elif head <= 99:
    if tail >= 1 and tail <= 12:
        print('YYMM')
    elif tail <= 99:
        print('NA')

Solution (Python):


s = list(input())

a = int(s[0])*10 + int(s[1])
b = int(s[2])*10 + int(s[3])

if 0 < a < 13 and 0 < b < 13:
    print("AMBIGUOUS")
elif 0 < a < 13 and (b >= 13 or b == 0):
    print("MMYY")
elif ( a == 0 or a >= 13) and 0 < b < 13:
    print("YYMM")
else:
    print("NA")