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:
hoge = str(input())
a = int(hoge[:2])
b = int(hoge[2:4])
result = None

if 0 < a and a <= 12:
  result = "MMYY"
  if 0 < b and b <= 12:
    result = "AMBIGUOUS"
if 0 < b and b <= 12:
  result = "YYMM"
  if 0 < a and a <= 12:
    result = "AMBIGUOUS"
if result == None:
  result = "NA"

print(result)

Submission status: Accepted

Solution code:

def main():
    s = input()
    start = int(s[0:2])
    end = int(s[2:4])
    if start == 0 and (end > 0 and end <= 12):
        print("YYMM")
    elif (start > 0 and start <= 12) and end == 0:
        print("MMYY")
    elif 0 < start <= 12 and 0 < end <= 12:
        print("AMBIGUOUS")
    elif start > 12 and 0 < end <= 12:
        print("YYMM")
    elif 0 < start <= 12 and end > 12:
        print("MMYY")
    else:
        print("NA")
main()

Submission status: Accepted

Solution code:
S = input()

numlist = []
N = len(S)
for i in range(N):
    numlist.append(int(S[i]))

upper = numlist[0] * 10 + numlist[1]
lower = numlist[2] * 10 + numlist[3]

isMU = False
isML = False
if 0 < upper and upper <= 12:
    isMU = True
if 0 < lower and lower <= 12:
    isML = True

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

Submission status: Accepted

Solution code:
a=int(input())
if(0<a%100<13):
  if(0<a//100<13):
    print("AMBIGUOUS")
  else:
    print("YYMM")
else:
    if(0<a//100<13):
      print("MMYY")
    else:
      print("NA")

Submission status: Accepted

Solution code:
year = int(input())
i = year
lst = []
j=0
while j < 4:
    if(i%10==0):
        lst.append(0)
    else:
        lst.append(i%10)
    i //= 10 # 必須
    j+=1

a=lst[3]*10
b=lst[1]*10
c=a+lst[2]
d=b+lst[0]
if(c==0 and d==0):
    print("NA")
elif(c>0 and c<13 and d==0):
    print("MMYY")
elif(c==0 and d>0 and d<13):
    print("YYMM")
elif(c>0 and c<13 and d>0 and d<13):
    print("AMBIGUOUS")
elif(c>0 and c<13 and d>12):
    print("MMYY")
elif(c>12 and d>0 and d<13):
    print("YYMM")
elif(c>12 and d>12):
    print("NA")
elif(c>12 and d==0):
    print("NA")
elif(c==0 and d>12):
    print("NA")
else:
    print("NA")

Submission status: Accepted

Solution code:
a = input()
b = int(a[:2])
c = int(a[2:])
 
if b > 12 and c > 12:
  print("NA")
elif b > 12 or b == 0: # bがYY
  if c < 1:
    print("NA")
  else:
    print("YYMM")
elif c > 12 or c == 0: # cがYY
  if b < 1:
    print("NA")
  else:
    print("MMYY")
else:
  print("AMBIGUOUS")

Submission status: Accepted

Solution code:
S = input()
K = int(S[0]+S[1])
L = int(S[2]+S[3])
if 1<=K<=12 and 1<=L<=12:
    print("AMBIGUOUS")
if 1<=K<=12 and L == 0:
    print("MMYY")
if 1<=K<=12 and 13<=L<=99:
    print("MMYY")
if K ==0 and L == 0:
    print("NA")
if K == 0 and 1<=L<=12:
    print("YYMM")
if K == 0 and 13<=L<=99:
    print("NA")
if 13<=K<=99 and L == 0:
    print("NA")
if 13<=K<=99 and 1<=L<=12:
    print("YYMM")
if 13<=K<=99 and 13<=L<=99:
    print("NA")

Submission status: Accepted

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

S = input()

a = int(S[:2])
b = int(S[2:])
fa = 0
fb = 0

if 1<=a and a<=12:
    fa = 1

if 1<=b and b<=12:
    fb = 1

if fa==1 and fb==1:
    print("AMBIGUOUS")
elif fa==1 and fb==0:
    print("MMYY")
elif fa==0 and fb==1:
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

Solution code:
s = int(input())
a = 0
b = 0
if s%100 <= 12 and s%100 != 0:
  a = 1
if int(s/100) <= 12 and int(s/100) != 0:
  b = 1
if a == 1:
  if b == 1:
    print('AMBIGUOUS')
  else:
    print('YYMM')
else:
  if b == 1:
    print('MMYY')
  else:
    print('NA')

Submission status: Accepted

Solution code:
S = str(input())
F = int(S[0:2])
T = int(S[2:4])

def Greaterthan12(x):
    if x > 12:
        return 0
    else:
        if x == 0:
            return 0
        else:
            return 1
        
Fjudge = Greaterthan12(F)
Tjudge = Greaterthan12(T)
if Fjudge == 0:
    if Tjudge == 0:
        print("NA")
    else:
        print("YYMM")
else:
    if Tjudge == 0:
        print("MMYY")
    else:
        print("AMBIGUOUS")

Submission status: Accepted

Solution code:
judge_num = input()
 
bef = int(judge_num[:2])
aft = int(judge_num[2:])
 
if(bef <= 12 and aft <= 12 and bef >= 1 and aft >= 1):
  print("AMBIGUOUS")
elif(bef <= 12 and bef >= 1):
  print("MMYY")
elif(aft <= 12 and aft >= 1):
  print("YYMM")
else:
  print("NA")

Submission status: Accepted

Solution code:
def solve():
  S = input()
  front = int(S[0:2])
  back = int(S[2:4])
  if front == 0 and back == 0: return 'NA'
  f, b = False, False
  if front in range(1, 13): f = True
  if back in range(1, 13): b = True
  if front == 0 and b: return 'YYMM'
  if f and back == 0: return 'MMYY'
  if f and b: return 'AMBIGUOUS'
  if f and not b: return 'MMYY'
  if not f and b: return 'YYMM'
  if not f and not b: return 'NA'
  return 'NA'

print(solve())

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

S = list(input().strip())

y = int("{}{}".format(S[0], S[1]))
m = int("{}{}".format(S[2], S[3]))

c = 0

if m >= 1 and m <= 12:
    c += 1
if y >= 1 and y <= 12:
    c += 2

if c == 1:
    print("YYMM")
elif c == 2:
    print("MMYY")
elif c == 3:
    print("AMBIGUOUS")
elif c == 0:
    print("NA")

Submission status: Accepted

Solution code:
s=input()
strdata=list(s)
data=list(map(int,strdata))
FF=10*data[0]+data[1]
LL=10*data[2]+data[3]
if FF==0 and 0<LL and LL<13:
    print("YYMM")
elif LL==0 and 0<FF and FF<13:
    print("MMYY")
elif 12<FF and LL<13 and 0<LL:
    print("YYMM")
elif 12<LL and FF<13 and 0<FF:
    print("MMYY")
elif FF<13 and LL<13 and 0<FF and 0<LL:
    print("AMBIGUOUS")
else:
    print("NA")

Submission status: Accepted

Solution code:
s = input()
ue = int(s[:2])
sita = int(s[2:4])
if ue < 1 or ue > 12:
    if 1 <= sita <= 12:
        print('YYMM')
    if sita < 1 or sita > 12:
        print('NA')
elif sita < 1 or sita > 12:
    print('MMYY')
else:
    print('AMBIGUOUS')

Submission status: Accepted

Solution code:
def ans (n):
	a = int(n[:2])
	b = int(n[2:])
	flagA = True
	flagB = True
	if a >12 or a==0 : flagA = False
	if b>12 or b == 0 : flagB = False
	if flagA and flagB : return 'AMBIGUOUS'
	if flagA : return 'MMYY'
	if flagB : return 'YYMM'
	return 'NA'

s = input()
print(ans(s))

Submission status: Accepted

Solution code:
s=input()

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

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

flag=[1,2,3]

if a not in tuki:
    flag.remove(1)
    flag.remove(3)
if b not in tuki:
    flag.remove(2)
    if 3 in flag:
        flag.remove(3)

if flag==[]:
    print('NA')
elif flag[-1]==3:
    print('AMBIGUOUS')
elif flag[-1]==2:
    print('YYMM')
elif flag[-1]==1:
    print('MMYY')

Submission status: Accepted

Solution code:
def c(a, b):
    if a is '0':   
        if b is '0':
            return False
    elif a is '1':
        if b is '0'or b is '1' or b is '2':
            return True
        else:
            return False
    else:
        return False
    return True


s = (input())

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

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

Submission status: Accepted

Solution code:
S=list(input())
XXYY=[]
l=' '
for i in range(2):
    l+=S[i]
XXYY.append(int(l))
l=' '
for i in range(2,4):
    l+=S[i]
XXYY.append(int(l))

ans=[]
if XXYY[0]>12:
    if XXYY[1]<=12 and XXYY[1]>0:
        ans.append("YYMM")
    else:
        ans.append("NA")
elif XXYY[0]<=12 and XXYY[0]>0:
    if XXYY[1]>12:
        ans.append("MMYY")
    elif XXYY[1]<=12 and XXYY[1]>0:
        ans.append("AMBIGUOUS")
    else:
        ans.append("MMYY")
else:
    if XXYY[1]<=12 and XXYY[1]>0:
        ans.append("YYMM")
    else:
        ans.append("NA")
print(ans[0])

Submission status: Accepted

Solution code:
s = input()
s1 = int(s[:2])
s2 = int(s[2:])
yymm = False

mmyy = False

if 1 <= s2 <= 12:
    yymm = True
if 1 <= s1 <= 12:
    mmyy = True
if yymm and mmyy:
    print("AMBIGUOUS")
if yymm and not(mmyy):
    print("YYMM")
if not(yymm) and mmyy:
    print("MMYY")
if not(yymm) and not(mmyy):
    print("NA")

Submission status: Accepted

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


if 1 <= a <= 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:
string=input()
x=int(string[:2]);y=int(string[2:])
if 1<=x<=12 and 1<=y<=12:
    print("AMBIGUOUS")
elif 1<=x<=12:
    print("MMYY")
elif 1<=y<=12:
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

Solution code:
def check_yy(a, b):
    if a == "0":
        if b == "0":
            return True
    elif a == "1":
        if b in ["3", "4", "5", "6", "7", "8", "9"]:
            return True
    elif a in ["2", "3", "4", "5", "6", "7", "8", "9"]:
        return True
    return False


S = input()

if check_yy(S[0], S[1]):
    if check_yy(S[2], S[3]):
        print("NA")
    else:
        print("YYMM")
elif check_yy(S[2], S[3]):
    print("MMYY")
else:
    print("AMBIGUOUS")

Submission status: Accepted

Solution code:
s=input()
f=int(s[:2])
e=int(s[2:])
if 0 < f < 13 and 0 < e < 13: print('AMBIGUOUS')
elif 0 < f < 13: print('MMYY')
elif 0 < e < 13: print('YYMM')
else: print('NA')

Submission status: Accepted

Solution code:

def check(i):
  i = int(i)
  if 12 < i or i == 0:
    return "YY"
  else:
    return "MM"


S = input().strip()
l, r = map(check, (S[:2], S[2:]))

if l == r:
  if l == "MM":
    print("AMBIGUOUS")
  else:
    print("NA")
else:
  print(l + r)

Submission status: Accepted

Solution code:
year = int(input())
i = year
lst = []
j=0
while j < 4:
    if(i%10==0):
        lst.append(0)
    else:
        lst.append(i%10)
    i //= 10 # 必須
    j+=1

a=lst[3]*10
b=lst[1]*10
c=a+lst[2]
d=b+lst[0]
if(c==0 and d==0):
    print("NA")
if(c>0 and c<13 and d==0):
    print("MMYY")
if(c==0 and d>0 and d<13):
    print("YYMM")
if(c>0 and c<13 and d>0 and d<13):
    print("AMBIGUOUS")
if(c>0 and c<13 and d>12):
    print("MMYY")
if(c>12 and d>0 and d<13):
    print("YYMM")
if(c>12 and d>12):
    print("NA")
if(c>12 and d==0):
    print("NA")
if(c==0 and d>12):
    print("NA")

Submission status: Accepted

Solution code:
S=str(input())
n1=int(S[0:2])
n2=int(S[2:4])
 
YYMM = 0
MMYY = 0
 
if (n2 <= 12) and (n2 > 0):
    YYMM = 1
if (n1 <= 12) and (n1 > 0):
    MMYY = 1
if (MMYY == 1):
    if(YYMM == 1):
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif (YYMM == 1):
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

Solution code:
s  = input()
a = int(s[:2])
b = int(s[2:])
is_MMxx = is_xxMM = False
if 13 > a > 0:
  is_MMxx = True
if 13 > b > 0:
  is_xxMM = True
if is_MMxx and is_xxMM:
  print("AMBIGUOUS")
elif is_MMxx:
  print("MMYY")
elif is_xxMM:
  print("YYMM")
else:
  print("NA")

Submission status: Accepted

Solution code:
s = input()
a, b = int(s[:2]), int(s[2:])

def func(i):
  if (i==0) | (i>12):
    return 'YY'
  else:
    return 'MM'
  
ans  = func(a) + func(b)
if (ans=='YYMM') | (ans=='MMYY'):
  print (ans)
elif ans=='MMMM':
  print ('AMBIGUOUS')
else:
  print('NA')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys,datetime
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    S = lines.pop(0)
    front = int(S[:2])
    back  = int(S[2:])

    try:
        datetime.date(2000 + front, back, 1)
        datetime.date(2000 + back, front, 1)
        print('AMBIGUOUS')
        sys.exit(0)
    except ValueError:
        pass

    try:
        datetime.date(2000 + front, back, 1)
        print('YYMM')
        sys.exit(0)
    except ValueError:
        pass

    try:
        datetime.date(2000 + back, front, 1)
        print('MMYY')
        sys.exit(0)
    except ValueError:
        pass

    print('NA')

#
# main
#
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Submission status: Accepted

Solution code:
s=int(input())
a=(s-s%1000)+(s%1000-s%100)
b=s%100
if 100<=a<=1200 and 1<=b<=12:
  print('AMBIGUOUS')
elif 100<=a<=1200 and b>12:
  print('MMYY')
elif a>1200 and 1<=b<=12:
  print('YYMM')
elif a==100 and b==0:
  print('MMYY')
elif a==0 and b==1:
  print('YYMM')
else:
  print('NA')

Submission status: Accepted

Solution code:
n =  input()
f = n[:2]
a = n[2:]
#print(f,a)
month = ['01','02','03','04','05','06','07','08','09','10','11','12']
#print(type(f))
if   (f in month) & (a in month):
  print('AMBIGUOUS')
elif (f in month):
  print('MMYY')
elif (a in month):
#  a in month:
  print('YYMM')
else:
  print('NA')

Submission status: Accepted

Solution code:
# your code goes here\
s = input()
op = ''
first = s[0:2]
second = s[2:4]
if (0 < int(first) <= 12):
	op += 'MM'
else:
	op += 'YY'
if (0 < int(second) <= 12):
	op += 'MM'
else:
	op += 'YY'

if (len(s) != 4):
	op = 'NA'
elif (op == 'MMMM'):
	op = 'AMBIGUOUS'
elif (op == 'YYYY'):
	if ((second == '00' and first == '00') or int(second) > 12 or int(first) > 12):
		op = 'NA'
print(op)

Submission status: Accepted

Solution code:
#-*- coding: utf-8 -*-
"""
oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d
oj test -d test-d -c "python abc116d.py"
oj test -d test-d -c "python abc116d.py" test-d/sample-3.in
"""
from collections import defaultdict
import sys
import math
from datetime import datetime
import re

def sol(S):
    #YYMM, MMYY, AMBIGUOUS, NA のうち正しいものを出力せよ。
    if re.match("^[0][0][0][0]$", S):
        return 'NA'
    if re.match("^[0][0][0-1][0-2]$", S):
        return 'YYMM'
    if re.match("^[0-1][0-2][0][0]$", S):
        return 'MMYY'
    elif re.match("^[0-1][0-2][0-1][0-2]$", S):
        return 'AMBIGUOUS'
    elif re.match("^[0-9][0-9][1][0-2]$", S):
        return 'YYMM'
    elif re.match("^[0-9][0-9][0][1-9]$", S):
        return 'YYMM'
    elif re.match("^[1][0-2][0-9][0-9]$", S):
        return 'MMYY'
    elif re.match("^[0][1-9][0-9][0-9]$", S):
        return 'MMYY'
    else:
        return 'NA'


do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    print(parsed_lines)
    # n = int(parsed_lines[0][0])
    # k = int(parsed_lines[0][1])
    S = parsed_lines[0][0]
    return S


if not do_submit:
    S = input_parse("""
    1905
    """)
    print(sol(S))

    S = input_parse("""
    0112
    """)
    print(sol(S))

    S = input_parse("""
    1700
    """)
    print(sol(S))

    S = input_parse("""
    0000
    """)
    print(sol(S))

    S = input_parse("""
    1001
    """)
    print(sol(S))



else:
    #n, k = list(map(int, input().split()))
    S = input()
    print(sol(S))

    # S = input().strip()
    # print(sol(S))

Submission status: Accepted

Solution code:
sstr=list(input())
# s=[int(n) for n in sstr]
# print(sstr)
sf=[sstr[0],sstr[1]]
sb=[sstr[2],sstr[3]]
if sf[0]=="0":
  sf.pop(0)
if sb[0]=="0":
  sb.pop(0)
fws="".join(sf)
bks="".join(sb)
fwb=[int(n) for n in fws]
bkb=[int(n) for n in bks]
# print(fwb)
# print(bkb)
if len(fwb)==2:
    fw=(fwb[0]*10)+(fwb[1])
else:
    fw=fwb[0]
if len(bkb)==2:
    bk=(bkb[0]*10)+(bkb[1])
else:
    bk=bkb[0]
# print(fw)
# print(bk)
if 1<=fw<=12:
  if 1<=bk<=12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1<=bk<=12:
    print("YYMM")
  else:
    print("NA")
"""
sstr=list(input())
s=[int(n) for n in sstr]
if s[0]>=2: #前2桁の十の位が2より大きければ前は年
    if s[2]>=2: #後2桁の十の位が2以上ならば該当なし
        print("NA")
    elif s[2]==1: #後2桁の十の位が1なら一の位は0-2
        if s[3]>=3: #後2桁の一の位が3以上ならNA
            print("NA")
        else: #後2桁の一の位が0-2ならYYMM
            print("YYMM")
    else: #後2桁の十の位が0ならYYMMかNA
        if s[3]==0: #後2桁の一の位が0ならNA
            print("NA")
        else: #後2桁の一の位が0でなければYYMM
            print("YYMM")

elif s[0]==1: #前2桁の十の位が1なら場合分け
    if s[1]>=3: #前2桁の一の位が3以上ならYYMMかNA
        if s[2]>=2: #後2桁の十の位が2以上ならNA
            print("NA")
        elif s[2]==1: #後2桁の十の位が1なら一の位は0-2
            if s[3]>=3: #後2桁の一の位が3以上ならNA
                print("NA")
            else: #後2桁の一の位が2以下ならYYMM
                print("YYMM")
        else: #後2桁の十の位が0ならYYMMかNA
            if s[3]==0:
                print("NA")
            else:
                print("YYMM")
    else: #前2桁の一の位が0-2ならMMYYかAMBIGUOUS
        if s[2]>=2: #後2桁の十の位が2以上ならMMYY
            print("MMYY")
        elif s[2]==1: #後2桁の十の位が1なら場合分け
            if s[3]>=3: #後2桁の一の位が3以上ならMMYY
                print("MMYY")
            else: #後2桁の一の位が2以下ならAMBIGUOUS
                print("AMBIGUOUS")
        else: #後2桁の十の位が0ならAMBIGUOUS
            print("AMBIGUOUS")

else: #前2桁の十の位が0ならMMYYかAMBIGIOUS
    if s[2]>=2: #後2桁の十の位が2以上ならMMYY
        if s[1]==0:
            print("NA")
        else:
            print("MMYY")
    elif s[2]==1: #後2桁の十の位が1なら場合分け
        if s[3]<=2: #後2桁の一の位が0-2ならAMBIGUOUS
            print("AMBIGUOUS")
        else: #後2桁の一の位が3以上ならMMYY
            print("MMYY")
    else: #後2桁の十の位が0ならAMBIGUOUSかNA
        if s[3]==0: #後2桁の一の位が0なら0x00のxを調査
            if s[1]==0:
                print("NA")
            else:
                print("MMYY")
        else:
            print("AMBIGUOUS")
            """

Submission status: Accepted

Solution code:
S = input()
first_half = int(S[:2])
second_half = int(S[2:])

if 1 <= first_half <= 12 and 1 <= second_half <= 12:
    print('AMBIGUOUS')
elif not 1 <= first_half <= 12 and 1 <= second_half <= 12:
    print('YYMM')
elif 1 <= first_half <= 12 and not 1 <= second_half <= 12:
    print('MMYY')
else:
    print('NA')

Submission status: Accepted

Solution code:
S = str(input())
S = list(S)

for i in range(4):
    S[i] = int(S[i])

mae = S[0] * 10 + S[1]
usiro = S[2] * 10 + S[3]

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

Submission status: Accepted

Solution code:
S = input()
S = list(S)
front = S[0] + S[1]
back = S[2] + S[3]

front = int(front)
back = int(back)

hoge = False
onon = False

if front >= 13 or front == 0:
    hoge = True
if back >= 13 or back == 0:
    onon = True   

if hoge == True and onon == True:
    print("NA")
elif hoge == True:
    print("YYMM")
elif onon == True:
    print("MMYY")
else:
    print("AMBIGUOUS")

Submission status: Accepted

Solution code:
S = input()
if S[0:2] > '00' and S[0:2] <'13':
    if S[2:4] > '00' and S[2:4] <'13':
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif S[0:2] == '00':
    if S[2:4] > '00' and S[2:4] <'13':
        print('YYMM')
    else:
        print('NA')
    
elif S[0:2] >='13':
    if S[2:4] > '00' and S[2:4] <'13':
        print('YYMM')
    else:
        print('NA')

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/abc126
# -*- coding: utf-8 -*-
 
s = input()
MMYY = 0
YYMM = 0
s1 = int(s[0:2])
s2 = int(s[2:4])

if 1 <= s1 <= 12:
        MMYY = 1

if 1 <= s2 <= 12:
        YYMM = 1

if MMYY and YYMM:
        print("AMBIGUOUS")

if MMYY and not YYMM:
        print("MMYY")

if YYMM and not MMYY:
        print("YYMM")

if not YYMM and not MMYY:
        print("NA")

Submission status: Accepted

Solution code:
S = input()

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

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

Submission status: Accepted

Solution code:
def solve():
    S= input()
    ue = int(S[:2])
    sita = int(S[2:])

    ueok = 1 <= ue <= 12
    sitaok = 1 <= sita <= 12
    if ueok and sitaok:
        print("AMBIGUOUS")
    elif not ueok and sitaok:
        print("YYMM")
    elif ueok and not sitaok:
        print("MMYY")
    else:
        print("NA")

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
input = sys.stdin.readline
ymo = input()

a = int(ymo[0:2])
b = int(ymo[2:4])

ans = ""
#00
if a == 0 and b ==0:
    ans = "NA"

#YYMMのみ
elif (a > 12 or a == 0) and 0 < b < 13:
    ans = "YYMM"

#MMYYのみ
elif 0 < a < 13 and (b > 12 or b == 0):
    ans = "MMYY"

#どっちも
elif a <13 and b < 13:
    ans = "AMBIGUOUS"

else :
    ans = "NA"

print(ans)

Submission status: Accepted

Solution code:
S = input()
if ((int(S[:2]) == 0) and (int(S[2:4])) == 0):
    print("{}".format("NA"))
elif (int(S[:2]) == 0) and (12< int(S[2:4])):
    print("{}".format("NA"))
elif(12< (int(S[:2])) and (int(S[2:4]) == 0)):
    print("{}".format("NA"))
elif (12 < int(S[:2])) and (12 < int(S[2:4])):
      print("{}".format("NA"))
elif(int(S[:2]) == 0) and (int(S[2:4]) < 13):
    print("{}".format("YYMM"))
elif(int(S[:2]) < 13) and (int(S[2:4]) == 0):
    print("{}".format("MMYY"))
elif (0<(int(S[:2]) <13) and (0< int(S[2:4]) < 13)):
    print("{}".format("AMBIGUOUS"))
elif(int(S[:2]) < 13):
     print("{}".format("MMYY"))
else:
     print("{}".format("YYMM"))

Submission status: Accepted

Solution code:
ans = ''
fmt = input()
n1 = int(fmt[:2])
n2 = int(fmt[2:])

if n1 == 0:
    if n2 == 0:
        print("NA")
    elif n2 > 12:
        print("NA")
    else:
        print("YYMM")
elif n1 > 12:
    if n2 == 0:
        print("NA")
    elif n2 > 12:
        print("NA")
    else:
        print("YYMM")
else:
    if n2 == 0:
        print("MMYY")
    elif n2 > 12:
        print("MMYY")
    else:
        print("AMBIGUOUS")

Submission status: Accepted

Solution code:
s = input()
m = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]

a = 0
b = 0
if s[0:2] in m:
  a = 1
if s[2:] in m:
  b = 1
  
if a == 0 and b == 0:
  print("NA")
elif a == 1 and b == 0:
  print("MMYY")
elif a == 0 and b == 1:
  print("YYMM")
else:
  print("AMBIGUOUS")

Submission status: Accepted

Solution code:
S = input()
a = int(S[:2])
b = int(S[2:])
if 0 < a < 13:
    if 0 < b < 13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 0 < b < 13:
        print('YYMM')
    else:
        print('NA')

Submission status: Accepted

Solution code:
s = input()

x = int(s[:2])
y = int(s[2:])

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

Submission status: Accepted

Solution code:
S=input()
AB=int(S[:2])
CD=int(S[2:])
if  (1<=AB<=12) and  (1<=CD<=12):
    print('AMBIGUOUS')
elif (AB==0 or AB>=13) and  (1<=CD<=12):
    print('YYMM')
elif (1<=AB<=12) and (CD==0 or CD>=13):
    print('MMYY')
else:
    print('NA')

Submission status: Accepted

Solution code:
ls=list(input())
first=[ls[0],ls[1]]
second=[ls[2],ls[3]]

if ls[0]=="0":
    del first[0]
if ls[2]=="0":
    del second[0]

a=int("".join(first))
b=int("".join(second))

def can_be_month(n):
    if n>=1 and n<=12:
        return True
    else:
        return False

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = str(input())

left = int(s[:2])
right = int(s[-2:])
# print(left, right)

if left > 12 or left == 0:
  if right >= 1 and right <= 12:
    print('YYMM')
  else: # right == 0 or right > 12:
    print('NA')
else: # left 1~12
  if right >= 1 and right <= 12:
    print('AMBIGUOUS')
  else: # right == 0 or right > 12
    print('MMYY')

Submission status: Accepted

Solution code:
# YYMM
o1 = False

# MMYY
o2 = False

# AMBIGUOUS
o3 = False

s = input()
s1 = s[:2]
s2 = s[2:]

if int(s1) <= 12 and int(s1) > 0:
    if int(s2) <= 12 and int(s2) > 0:
        o3 = True
    else:
        o2 = True

if int(s2) <= 12 and int(s2) > 0:
    if int(s1) <= 12 and int(s1) > 0:
        pass
    else:
        o1 = True

if o1 is True:
    print("YYMM")
elif o2 is True:
    print("MMYY")
elif o3 is True:
    print("AMBIGUOUS")
else :
    print("NA")

Submission status: Accepted

Solution code:
a=input()
m=int(a[:2])
u=int(a[2:])
if (m<=12 and m>0) and (u<=12 and u>0):
    print("AMBIGUOUS")
    exit()
elif (m<=12 and m>0) and (u>12 or u==0):
    print("MMYY")
    exit()
elif (m>12 or m==0) and (u<=12 and u>0):
    print("YYMM")
    exit()
    
else:
    print("NA")
    exit()

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    s = int(input())
    y, m = s // 100, s % 100
    if (y == 0 or y > 12) and (m == 0 or m > 12):
        print('NA')
    elif y > 12 or y == 0:
        print('YYMM')
    elif m > 12 or m == 0:
        print('MMYY')
    else:
        print('AMBIGUOUS')

Submission status: Accepted

Solution code:
from sys import stdin
import numpy as np
# import math
# import random
# import fractions
# import sys
# sys.setrecursionlimit(100000)
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = stdin.readline().rstrip().split()[0]
N = int(stdin.readline().rstrip().split()[0])
aa = N//100
bb = N%100
a = False
b = False
if 1 <= aa <=12:
  a = True
if 1 <= bb <=12:
  b = True
if a and b:
  print("AMBIGUOUS")
elif not a and b:
  print("YYMM")
elif a and not b:
  print("MMYY")
elif not a and not b:
  print("NA")

Submission status: Accepted

Solution code:
S=input()
mozi_1=int(S[0:2])
mozi_2=int(S[2:4])
if 1<=mozi_1<=12 and 1<=mozi_2<=12:print("AMBIGUOUS")
elif 1<=mozi_1<=12 and (13<=mozi_2<=99 or mozi_2==0):print("MMYY")
elif 1<=mozi_2<=12 and (13<=mozi_1<=99 or mozi_1==0):print("YYMM")
else:print("NA")

#print(mozi_1)
#print(mozi_2)

Submission status: Accepted

Solution code:
n = input()

n1 = int(n[:2])
n2 = int(n[2:])

def date(n1, n2):
    if n1 == 0 and n2 == 0:
        return 'NA'
    if n1 >= 13 and n2 == 0:
        return 'NA'
    if n1 <= 12 and n2 == 0:
        return 'MMYY'
    if n1 == 0 and n2 >= 13:
        return 'NA'
    if n1 == 0 and n2 <= 12:
        return 'YYMM'
    if n1 >= 13 and n2 >= 13:
        return 'NA'
    if n1 >= 13 and n2 <= 12:
        return 'YYMM'
    if n1 <= 12 and n2 >= 13:
        return 'MMYY'
    if n1 <= 12 and n2 <= 12:
        return 'AMBIGUOUS'


print(date(n1, n2))

Submission status: Accepted

Solution code:
S = input()

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

if 0 < A <= 12 and 0 < B <= 12:
    print('AMBIGUOUS')
elif not (0 < A <= 12 or 0 < B <= 12):
    print('NA')
elif 0 < A <= 12:
    print('MMYY')
else:
    print('YYMM')

Submission status: Accepted

Solution code:
s = input()
#s = str(1213)

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

#print(s1)
#print(s2)

i1 = int(s1)
i2 = int(s2)

i1MM = True
i2MM = True

if i1 > 12 or i1 == 0:
    i1MM = False
if i2 > 12 or i2 == 0:
    i2MM = False

if i1MM and i2MM:
    print("AMBIGUOUS")

if not i1MM and i2MM:
    print("YYMM")

if i1MM and not i2MM:
    print("MMYY")

if not i1MM and not i2MM:
    print("NA")

Submission status: Accepted

Solution code:
s=[int(i) for i in list(input())]
s1=int(''.join(map(str,[s[0],s[1]])))
s2=int(''.join(map(str,[s[2],s[3]])))

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

Submission status: Accepted

Solution code:
S = input()
 
if 1<= int(S[0]+S[1])<=12:
  if 1<= int(S[2]+S[3]) <=12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 1<= int(S[2]+S[3]) <=12:
    print('YYMM')
  else:  
    print('NA')

Submission status: Accepted

Solution code:
S = int(input())
n1 = S // 100
n2 = S % 100
if n1 < 1 or 12 < n1:
    if n2 < 1 or 12 < n2:
        print('NA')
    else:
        print('YYMM')
elif n2 < 1 or 12 < n2:
    if n1 < 1 or 12 < n1:
        print('NA')
    else:
        print('MMYY')
else:
    print('AMBIGUOUS')

Submission status: Accepted

Solution code:
def is_available_yymm(s: str) -> bool:
    return 12 >= int(s[2] + s[3]) >= 1


def is_available_mmyy(s: str) -> bool:
    return 12 >= int(s[0] + s[1]) >= 1


def main():
    s = input()
    yymm = is_available_yymm(s)
    mmyy = is_available_mmyy(s)
    if yymm and mmyy:
        print("AMBIGUOUS")
    elif yymm:
        print("YYMM")
    elif mmyy:
        print("MMYY")
    else:
        print("NA")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def is_yy(st):
    st = int(st)
    if (0 <= st <= 99):
        return True
    return False
    
def is_mm(st):
    st = int(st)
    if (1 <= st <= 12):
        return True
    return False

def get_ans(head, tail):
    if (is_yy(head) and is_mm(tail)) and (is_yy(tail) and is_mm(head)):
        return 'AMBIGUOUS'
    elif (is_yy(head) and is_mm(tail)) and not (is_yy(tail) and is_mm(head)):
        return 'YYMM'
    elif not (is_yy(head) and is_mm(tail)) and (is_yy(tail) and is_mm(head)):
        return 'MMYY'
    else:
        return 'NA'

s = input()
head = s[0:2]
tail = s[2:]
print(get_ans(head, tail))

Submission status: Accepted

Solution code:
S = input()
a = int(S[:2])
b = int(S[2:])

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

Submission status: Accepted

Solution code:
s = int(input())

#フラグ
yymm = 0
mmyy = 0

if int(s / 100) <= 12 and int(s / 100) >= 1:
    mmyy = mmyy + 1

if s % 100 <= 12 and s % 100 >= 1:
    yymm = yymm + 1

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

Submission status: Accepted

Solution code:
S = input()
a = int(S[:2])
b = int(S[2:])

if a > 12:
	if b > 12:
		print("NA")
	elif b > 0:
		print("YYMM")
	else:
		print("NA")

if 0 < a <= 12:
	if b > 12 or b == 0:
		print("MMYY")
	else:
		print("AMBIGUOUS") 

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