Problem: 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`.

Submission attempts (in order):
sstr=list(input())
s=[int(n) for n in sstr]
sf=[s[0],s[1]]
sb=[s[2],s[3]]
fw="".join(sf)
bk="".join(sb)
if fw[0]==0:
  fw.pop(0)
if bk[0]==0:
  bk.pop(0)
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: 
    if s[2]>=2: 
        print("NA")
    elif s[2]==1: 
        if s[3]>=3: 
            print("NA")
        else: 
            print("YYMM")
    else: 
        if s[3]==0: 
            print("NA")
        else: 
            print("YYMM")
elif s[0]==1: 
    if s[1]>=3: 
        if s[2]>=2: 
            print("NA")
        elif s[2]==1: 
            if s[3]>=3: 
                print("NA")
            else: 
                print("YYMM")
        else: 
            if s[3]==0:
                print("NA")
            else:
                print("YYMM")
    else: 
        if s[2]>=2: 
            print("MMYY")
        elif s[2]==1: 
            if s[3]>=3: 
                print("MMYY")
            else: 
                print("AMBIGUOUS")
        else: 
            print("AMBIGUOUS")
else: 
    if s[2]>=2: 
        if s[1]==0:
            print("NA")
        else:
            print("MMYY")
    elif s[2]==1: 
        if s[3]<=2: 
            print("AMBIGUOUS")
        else: 
            print("MMYY")
    else: かNA
        if s[3]==0: 
            if s[1]==0:
                print("NA")
            else:
                print("MMYY")
        else:
            print("AMBIGUOUS")

sstr=list(input())
s=[int(n) for n in sstr]
sf=[s[0],s[1]]
sb=[s[2],s[3]]
if sf[0]==0:
  sf.pop(0)
if sb[0]==0:
  sb.pop(0)
fw="".join(sf)
bk="".join(sb)
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: 
    if s[2]>=2: 
        print("NA")
    elif s[2]==1: 
        if s[3]>=3: 
            print("NA")
        else: 
            print("YYMM")
    else: 
        if s[3]==0: 
            print("NA")
        else: 
            print("YYMM")
elif s[0]==1: 
    if s[1]>=3: 
        if s[2]>=2: 
            print("NA")
        elif s[2]==1: 
            if s[3]>=3: 
                print("NA")
            else: 
                print("YYMM")
        else: 
            if s[3]==0:
                print("NA")
            else:
                print("YYMM")
    else: 
        if s[2]>=2: 
            print("MMYY")
        elif s[2]==1: 
            if s[3]>=3: 
                print("MMYY")
            else: 
                print("AMBIGUOUS")
        else: 
            print("AMBIGUOUS")
else: 
    if s[2]>=2: 
        print("MMYY")
    elif s[2]==1: 
        if s[3]<=2: 
            print("AMBIGUOUS")
        else: 
            print("MMYY")
    else: かNA
        if s[3]==0: 
            if s[1]==0:
                print("NA")
            else:
                print("MMYY")
        else:
            print("AMBIGUOUS")

sstr=list(input())
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]
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]
if 1<=fw<=12:
  if 1<=bk<=12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1<=bk<=12:
    print("YYMM")
  else:
    print("NA")

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Accepted