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.



Sample input:
1905


Sample output:
YYMM

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
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())

# 多次元配列の宣言（あとでintにすること。）（タプルにすること。）
dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
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)
# [3, 1, 4, 5, 2]
# [1, 2, 3, 4, 5]

#Distance Transformation
    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()

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
import numpy as np
S = str(input()) #strでまず受けた方が楽
forward = S[:2]
back	= S[2:]

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

# flagを作って、それで答えますかね
count = np.zeros((2)) # 0 : YYMM 1:MMYY
# 一発退場の00系 2000年代はいけるわ...
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:
  ## 西暦はなんでもオッケーなので、あとはMMに両方なれるかどうか
  ## 1以上も確定なので、12以下かだけでよい
  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")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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())

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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)

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
s=int(input())

f=int(s/100)
l=s%100
ans=""
#YYMM
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)

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:

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')

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
li = list(input())
#print(li)
#li2 = list(map(int,li))
#print(li2)

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

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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
# coding: UTF-8
# sample code

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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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)])

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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'

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
#coding:utf-8

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")

Submission status: Accepted

Solution code:
s=input()

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

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

Submission status: Accepted

Solution code:
S = input()
if (1 <= int(S[0:2]) <= 12):
  f = "M"
else:
  f = "Y"
if (1 <= int(S[2:4]) <= 12):
  b = "M"
else:
  b = "Y"
if(f=="Y")and(b=="M"):
  print("YYMM")
elif(f=="M")and(b=="Y"):
  print("MMYY")
elif(f=="M")and(b=="M"):
  print("AMBIGUOUS")
else:
  print("NA")

Submission status: Accepted

Solution code:
line = input()

digits = '0123456789'
chars = list(map(lambda x:digits.find(x), line))

def isMM(part):
    num = part[0] * 10 + part[1]
    if 0 < num and num < 13:
        return True

def test(chars):
    if -1 in chars:
        return 3
    partA = chars[0:2]
    partB = chars[2:4]
    
    resultA = isMM(partA)
    resultB = isMM(partB)
    
    if resultA is True:
        if resultB is True:
            return 2
        else:
            return 1
    else:
        if resultB is True:
            return 0
        else:
            return 3
    
    
result = test(chars)
if result == 0:
    print("YYMM")
elif result == 1:
    print("MMYY")
elif result == 2:
    print("AMBIGUOUS")
elif result == 3:
    print("NA")

Submission status: Accepted

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

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

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

Submission status: Accepted

Solution code:
s=input()
a=int(s[0])*10+int(s[1])
b=int(s[2])*10+int(s[3])
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")

Submission status: Accepted

Solution code:
S = input()
pre = int(S[0:2])
af = int(S[2:4])
if 1 <= pre <= 12:
    preM = 1
else:
    preM = 0
if 1 <= af <= 12:
    afM = 1
else:
    afM = 0
if preM == 1:
    if afM == 1:
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"
else:
    if afM == 1:
        ans = "YYMM"
    else:
        ans = "NA"
print(ans)

Submission status: Accepted

Solution code:
S = list(input())

s1 = int(S[0] + S[1])
s2 = int(S[2] + S[3])

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

Submission status: Accepted

Solution code:
def B():
    # M: 01 ~ 12, Y: 00 ~ 99
    S = input()
    ans = ['YYMM','MMYY','AMBIGUOUS','NA']
    YYMM = False
    MMYY = False
    AMB = False
    NA = False
    
    Sxx__ = S[0] + S[1]
    S__xx = S[2] + S[3]
    M = [str(i) if i >9 else '0' + str(i) for i in range(1,13)]
    Y = [str(i) if i >9 else '0' + str(i) for i in range(0,99)]
    if Sxx__ in M and S__xx in Y:
        MMYY = True
    if Sxx__ in Y and S__xx in M:
        YYMM = True

    if YYMM is True and MMYY is True:
        print(ans[2])
    elif YYMM is False and MMYY is False:
        print(ans[3])
    elif YYMM is True:
        print(ans[0])
    elif MMYY is True:
        print(ans[1])
        
 
if __name__ == '__main__':
    B()

Submission status: Accepted

Solution code:
S = input()

f = int(S[0]+S[1])
s = int(S[2]+S[3])

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

Submission status: Accepted

Solution code:
S = input()
L = int(S[:2])
R = int(S[2:])

if L!=0 and R!= 0 and L <=12 and R<=12:
    print("AMBIGUOUS")
elif L!=0 and L<=12:
    print("MMYY")
elif R!=0 and R<=12:
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

Solution code:
s = input()
yy = int(s[0]+s[1])
mm = int(s[2]+s[3])
if(1<=yy<=12 and 1<=mm<=12):
	print('AMBIGUOUS')
elif(0<=yy<=99 and 1<=mm<=12):
    print('YYMM')
elif(0<=mm<=99 and 1<=yy<=12):
  	print('MMYY')
else:
    print('NA')

Submission status: Accepted

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

MM = [1,2,3,4,5,6,7,8,9,10,11,12]

if S1 in MM and S2 in MM:
    print("AMBIGUOUS")
if S1 in MM and S2 not in MM:
    print("MMYY")
if S1 not in MM and S2 in MM:
    print("YYMM")
if S1 not in MM and S2 not in MM:
    print("NA")

Submission status: Accepted

Solution code:
import sys

s = input()

first_half = int(s[0:2])
second_half = int(s[2:4])

if 1 <= first_half and first_half <= 12 :
  if second_half == 0 or 13 <= second_half:
    print("MMYY")
  else:
    print("AMBIGUOUS")
else:
  if second_half == 0 or 13 <= second_half:
    print("NA")
  else:
    print("YYMM")

Submission status: Accepted

Solution code:
miu = input()

sella = miu[0:2]
miu = miu[2:4]

delphine = [0,0]

if 1 <= int(sella) and int(sella) <= 12:
	delphine[0] += 1


if 1 <= int(miu) and int(miu) <= 12:
	delphine[1] += 1

if sum(delphine) == 0:
	print("NA")
elif sum(delphine) == 2:
	print("AMBIGUOUS")

elif delphine[0] == 1:
	print("MMYY")
else:
	print("YYMM")

Submission status: Accepted

Solution code:
s = input()
front = int(s[0:2])
back = int(s[2:4])


yymm = False
mmyy = False


if 1 <= front <= 12:
    if 0 <= back <= 99:
        mmyy = True

if 1 <= back <= 12:
    if 0 <= front <= 99:
        yymm = True

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

Submission status: Accepted

Solution code:
S = int(input())
YY = S // 100
MM = S % 100

if YY <= 12 and MM <= 12 and MM > 0 and YY > 0:
    print('AMBIGUOUS')
elif MM <= 12 and MM > 0:
    print('YYMM')
elif MM > 12 and YY <= 12:
    print('MMYY')
elif MM == 0 and YY <= 12 and YY > 0:
    print('MMYY')
else:
    print('NA')

Submission status: Accepted

Solution code:
S = input()
left = int(S[0:2])
right = int(S[2:])
if 1 <= left <= 12 and 1 <= right <= 12:
  print('AMBIGUOUS')
elif 0 <= left <= 99 and 1 <= right <= 12:
  print('YYMM')
elif 1 <= left <= 12 and 0 <= right <= 99:
  print('MMYY')
else:
  print('NA')

Submission status: Accepted

Solution code:

S=int(input())
y=S//100
m=S%100



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

Submission status: Accepted

Solution code:
S = input()

s_1 = int(S[0:2])
s_2 = int(S[2:])

YYMM = False
MMYY = False

if 1<=s_2<=12:
    YYMM = True
if 1<=s_1<=12:
    MMYY = True
    
if YYMM and MMYY:
    print('AMBIGUOUS')
elif YYMM:
    print('YYMM')
elif MMYY:
    print('MMYY')
else:
    print('NA')

Submission status: Accepted

Solution code:
s=input()
f=int(s[0]+s[1])
b=int(s[2]+s[3])

if 1<=f<=12:
    if 1<=b<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=b<=12:
        print("YYMM")
    else:
        print("NA")

Submission status: Accepted

Solution code:
S=input()
AA=int(S[:2])
BB=int(S[2:])
print(["NA","MMYY","YYMM","AMBIGUOUS"][
    (1<=AA<=12)+2*(1<=BB<=12)
    ])

Submission status: Accepted

Solution code:
s=input()
t=int(s[0]+s[1])
u=int(s[2]+s[3])
if 0<t<=12 and 0<u<=12:
  print('AMBIGUOUS')
elif (t>=13 or t==0) and (u>=13 or u==0):
  print('NA')
elif 0<u<=12:
  print('YYMM')
elif 0<t<=12: 
  print('MMYY')

Submission status: Accepted

Solution code:
s=input()
A=int(s[:2])
B=int(s[2:])
if (A>12 or A==0) and 0<B<=12:print("YYMM")
elif 0<A<=12 and (B>12 or B==0):print("MMYY")
elif 0<A<=12 and 0<B<=12:print("AMBIGUOUS")
else:print("NA")

Submission status: Accepted

Solution code:
def j(cont):
    if int(cont)>=1 and int(cont)<=12:
        return True
    else:
        return False

s = input()
l,r = s[:2],s[2:]
if j(l) is True and j(r) is True:
    print('AMBIGUOUS')
elif j(l) is False and j(r) is False:
    print('NA')
elif j(l) is False and j(r) is True:
    print('YYMM')
else:
    print('MMYY')

Submission status: Accepted

Solution code:
S=input()
mae=S[:2]
ato=S[2:]
mon_list=("01","02","03","04","05","06","07","08","09","10","11","12")
test=0
if mae in mon_list:
  test=test+1
if ato in mon_list:
  test=test+3

if test==0:
  print("NA")
if test==1:
  print("MMYY")
if test==3:
  print("YYMM")
if test==4:
  print("AMBIGUOUS")

Submission status: Accepted

Solution code:
s = input()

s1 = s[:2]
s2 = s[2:]

MM = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']

s1MM = False
s2MM = False

if s1 in MM:
    s1MM = True

if s2 in MM:
    s2MM = True


if s1MM & s2MM:
    print('AMBIGUOUS')
elif s1MM:
    print('MMYY')
elif s2MM:
    print('YYMM')
else:
    print('NA')

Submission status: Accepted

Solution code:
S=list(input())
A=int(S[0] + S[1])
B=int(S[2] + S[3])

FORMAT_S = ['AMBIGUOUS', 'YYMM', 'MMYY', 'NA']
format_flag = [True, True, True, True]

if A == 0 or 12 < A:
    format_flag[0] = False
    format_flag[2] = False
if B == 0 or 12 < B:
    format_flag[0] = False
    format_flag[1] = False

for i in range(4):
    if format_flag[i] == True:
        print(FORMAT_S[i])
        break