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:
# B - YYMM or MMYY
# https://atcoder.jp/contests/abc126/tasks/abc126_b

months = [_ for _ in range(1, 13)]
years = [_ for _ in range(0, 100)]

flug = [False] * 4

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


if l in years:
    flug[0] = True

if l in months:
    flug[1] = True

if r in years:
    flug[2] = True

if r in months:
    flug[3] = True

l_y = flug[0]
l_m = flug[1]
r_y = flug[2]
r_m = flug[3]

l_l = [flug[0], flug[1]]
r_r = [flug[2], flug[3]]

if all(flug):
    print('AMBIGUOUS')
elif all(l_l) and r_y == True and r_m == False:
    print('MMYY')
elif all(l_l) and r_y == False and r_m == True:
    print('YYMM')
elif all(r_r) and l_y == True and l_m == False:
    print('YYMM')
elif all(r_r) and l_y == False and l_m ==True:
    print('MMYY')
elif l_y == True and l_m == False and  r_y == False and r_m == True:
    print('YYMM')
elif l_y == False and l_m == True and r_y == True and r_m == False:
    print('MMYY')
else:
    print('NA')

Submission status: Accepted

Solution code:
a = input()

a = list(a)
b = a[0]+a[1]
c = a[2]+a[3]

b = int(b)
c = int(c)

if c >= 1 and c <= 12 and b >= 1 and b <= 12:
        print("AMBIGUOUS")

elif c >= 1 and c <= 12:
    print("YYMM")

elif b >= 1 and b <= 12:
    print("MMYY")
    
else:
    print('NA')

Submission status: Accepted

Solution code:
import sys


def input():
    return sys.stdin.readline()[:-1]


# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}
# b = list(map(lambda x: math.ceil(x/10)*10, a))

s = int(input())
YY = s // 100
MM = s % 100
if 1 <= YY <= 12 and 1 <= MM <= 12:
    print("AMBIGUOUS")
elif 0 < MM <= 12:
    print("YYMM")
elif 0 < YY <= 12:
    print("MMYY")
else:
    print("NA")

Submission status: Accepted

Solution code:
s = input()

first = int(s[:2])
second = int(s[2:])

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

Submission status: Accepted

Solution code:
S_line = [i for i in input()]
S_line_mae = [S_line[0],S_line[1]]
S_line_ushiro = [S_line[2],S_line[3]]
moji_mae = ''.join(S_line_mae)
moji_ushiro = ''.join(S_line_ushiro)

mae = int(moji_mae)
ushiro = int(moji_ushiro)
if (mae==0 or mae>=13) and ushiro>=1 and ushiro<=12:
  print('YYMM')
elif mae>=1 and mae<=12 and (ushiro==0 or ushiro>=13):
  print('MMYY')
elif mae>=1 and mae<=12 and ushiro>=1 and ushiro<=12:
  print('AMBIGUOUS')
else:
  print('NA')

Submission status: Accepted

Solution code:
#input
inpnum = int(input())

#下二桁
simo = inpnum % 100
#上二桁
kami = inpnum // 100

#入れ替え
swapflag = 0
if kami >= simo :
    kami, simo = simo, kami
    swapflag = 1
#判定
if kami == 0:
    if 1 <= simo <= 12 and swapflag == 0:
        print("YYMM")
    elif  1 <= simo <= 12 and swapflag == 1:
        print("MMYY")
    else:
        print("NA")

if 1 <= kami <= 12:
    if 1 <= simo <= 12:
        print("AMBIGUOUS")
    elif 13 <= simo and swapflag == 0:
        print("MMYY")
    elif 13 <= simo and swapflag == 1:
        print("YYMM")

if 13 <= kami:
    print("NA")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S=input()
XXX=int(S[0:2])
YYY=int(S[2:4])

YM=False
MY=False


if YYY<13 and YYY>0:
	MY=True


if XXX>0 and XXX<13:
	YM=True


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

Submission status: Accepted

Solution code:
from collections import defaultdict
from string import ascii_uppercase
import sys, bisect, math
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N = read_int()[0]

def solve():
    u = N // 100
    l = N % 100
    if u == 0 and l == 0:
        return 'NA'
    if u == 0:
        if l < 13:
            return 'YYMM'
        else: return 'NA'
    if l == 0:
        if u < 13:
            return 'MMYY'
        else: return 'NA'
    if u > 12:
        if l < 13:
            return 'YYMM'
        else: return 'NA'

    if u < 13:
        if l > 12:
            return 'MMYY'
        else: return 'AMBIGUOUS'
    else:
        return 'NA'

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

Submission status: Accepted

Solution code:
words = input()
words = list(words)

YYMM_or_MMYY = []
YYMM_or_MMYY.append(words[0]+words[1])
YYMM_or_MMYY.append(words[2]+words[3])

YYMM_or_MMYY[0] = int(YYMM_or_MMYY[0])
YYMM_or_MMYY[1] = int(YYMM_or_MMYY[1])


if (YYMM_or_MMYY[0] < 13) and (YYMM_or_MMYY[0] > 0) and (YYMM_or_MMYY[1] < 13) and (YYMM_or_MMYY[1] > 0):
    print('AMBIGUOUS')
elif (YYMM_or_MMYY[0] < 13) and (YYMM_or_MMYY[0] > 0):
    print('MMYY')
elif (YYMM_or_MMYY[1] < 13) and (YYMM_or_MMYY[1] > 0):
    print('YYMM')
else:
    print("NA")

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    s = input()
    ys = 00
    ye = 99
    ms = 1
    me = 12
    s1 = int(s[0:2])
    s2 = int(s[2:])
    yymm = False
    mmyy = False
    if (ys <= s1 <= ye) and (ms <= s2 <= me):
        yymm = True
    if (ms <= s1 <= me) and (ys <= s2 <= ye):
        mmyy = True
    if yymm and mmyy:
        print('AMBIGUOUS')
    elif yymm and not mmyy:
        print('YYMM')
    elif mmyy and not yymm:
        print('MMYY')
    else:
        print('NA')

Submission status: Accepted

Solution code:
S = list(input())

left = int(''.join(S[0:2]))
right = int(''.join(S[2:4]))

if (left > 0 and left < 13) and (right > 0 and right < 13):
  print('AMBIGUOUS')
elif left >= 0 and (right > 0 and right < 13):
  print('YYMM')
elif (left > 0 and left < 13) and right >= 0:
  print('MMYY')
else:
  print('NA')

Submission status: Accepted

Solution code:
n = input()
a = int(n[0])*10 + int(n[1])
b = int(n[2])*10 + int(n[3])

s = 0
t = 0

if a > 0 and a <= 12:
  s = 1
if b > 0 and b <= 12:
  t = 1
if s == 1 and t == 1:
  print("AMBIGUOUS")
elif s == 0 and t == 1:
  print("YYMM")
elif s == 1 and t == 0:
  print("MMYY")
elif s == 0 and t == 0:
  print("NA")

Submission status: Accepted

Solution code:
s = str(input())
f = int(s[:2])
r = int(s[2:])
if 1<=f<=12:
    if 1<=r<=12:
        ans = 'AMBIGUOUS'
    else:
        ans = 'MMYY'
else:
    if 1<=r<=12:
        ans = 'YYMM'
    else:
        ans = 'NA'
print(ans)

Submission status: Accepted

Solution code:
S = input()
s1, s2 = S[:2], S[2:]

MM = ["%02d"%i for i in range(1, 12+1)]

# 月のフォーマットの可能性
if s1 in MM:
    if s2 in MM:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if s2 in MM:
        print("YYMM")
    else:
        print("NA")

Submission status: Accepted

Solution code:
s=list(input())
flont=int(s[0]+s[1])
back=int(s[2]+s[3])

if 1<=flont<=12:
    if 1<=back<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif 1<=back<=12:
    if flont==0 or 13<=flont:
        print("YYMM")
else:
    print("NA")

Submission status: Accepted

Solution code:
S = input()

if(S[0] == 0):
    Z = int(S[1])
else:
    Z = S[0] + S[1]
    X = int(Z)

if(S[2] == 0):
    K = int(S[3])
else:
    K = S[2] + S[3]
    Y = int(K)

if(1 <= X <= 12):
    if(1 <= Y <= 12):
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if(1 <= Y <= 12):
        print("YYMM")
    else:
        print("NA")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = input()

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

Submission status: Accepted

Solution code:
S = input()
# for i in range(10000):
#     S = str(i).zfill(4)
#     print(S, end=":")
# print(int(S[:2]), int(S[2:]))
if (int(S[:2]) == 0 and int(S[2:]) == 0) or (int(S[:2]) == 0 and int(S[2:]) >= 13) or (int(S[:2]) >= 13 and int(S[2:]) == 0) or (int(S[:2]) >= 13 and int(S[2:]) >= 13):
    print("NA")
elif int(S[:2]) < 13 and int(S[:2]) > 0 and int(S[2:]) < 13 and int(S[2:]) > 0:
    print("AMBIGUOUS")
elif int(S[:2]) < 13 and int(S[:2]) > 0:
    print("MMYY")
else:
    print("YYMM")
    # if i % 1000 == 0:
    #     input("STOP")

Submission status: Accepted

Solution code:
a = str(input())
a = list(a)
b = int(''.join(a[0: 2]))
c = int(''.join(a[2: 4]))
if (99 >= b > 12):
    if (c > 12):
        print('NA', end='')
    elif(12 >= c >= 1):
        print('YYMM', end='')
    else:
        print('NA', end='')
elif (12 >= b > 0):
    if (c > 12):
        print('MMYY', end='')
    elif(12 >= c > 0):
        print('AMBIGUOUS', end='')
    elif(c == 0):
        print('MMYY', end='')
    else:
        print('NA', end='')
elif (b == 0):
    if (99 >= c >= 1):
        print('YYMM', end='')
    else:
        print('NA', end='')

Submission status: Accepted

Solution code:
import sys
import math 
import numpy as np
ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input()
S=ns()

f=int(S[0:2])
r=int(S[2:4])
#print(f,r)

if(f<=12 and f>=1 and r<=12 and r>=1):
    print("AMBIGUOUS")
elif(f<=12 and f>=1):
    print("MMYY")
elif(r<=12 and r>=1):
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

Solution code:
s = str(input())

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

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

Submission status: Accepted

Solution code:
s=input()
a=0
b=0
if 10*int(s[0])+int(s[1])>=13 or 10*int(s[0])+int(s[1])==0:
    a=1
if 10*int(s[2])+int(s[3])>=13 or 10*int(s[2])+int(s[3])==0:
    b=1
if a==0 and b==0:
    print("AMBIGUOUS")
if a==0 and b==1:
    print("MMYY")
if a==1 and b==0:
    print("YYMM")
if a==1 and b==1:
    print("NA")

Submission status: Accepted

Solution code:
a, b, m, n = list(input())
ab = int(a+b)
mn = int(m+n)
if 1<=ab<=12 and 1<=mn<=12:
    print("AMBIGUOUS")
elif 1<=ab<= 12 and not 1<=mn<=12:
    print("MMYY")
elif not 1<=ab<=12 and 1<=mn<=12:
    print("YYMM")
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")

Submission status: Accepted

Solution code:
def check(c):
	if(48<=ord(c)<=57):
		return True
	return False

S=input()

if( (not check(S[0])) or (not check(S[1])) or (not check(S[2])) or (not check(S[3]))):
	print("NA")
else:
	v1=int(S[:2])
	v2=int(S[2:])

	y1=(v1>=0)
	m1=(12>=v2>0)
	b1=(y1 and m1)

	m2=(12>=v1>0)
	y2=(v2>=0)
	b2=(y2 and m2)

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

Submission status: Accepted

Solution code:
a = input()

a = list(a)
b = a[0]+a[1]
c = a[2]+a[3]

b = int(b)
c = int(c)

if c >= 1 and c <= 12 and b >= 1 and b <= 12:
        print("AMBIGUOUS")

elif c >= 1 and c <= 12:
    print("YYMM")

elif b >= 1 and b <= 12:
    if c >= 1 and c <= 12:
        print("AMBIGUOUS")
    print("MMYY")
    
else:
    print('NA')

Submission status: Accepted

Solution code:
a=input()

b = int(a[:2])
c = int(a[2:])

if 0< b < 13:
    a_month_flag = 1
    a_year_flag = 1
elif b == 0:
    a_month_flag = 0
    a_year_flag = 0
else:
    a_month_flag = 0
    a_year_flag = 1

if 0< c < 13:
    b_month_flag = 1
    b_year_flag = 1
elif c == 0:
    b_month_flag = 0
    b_year_flag = 0
else:
    b_month_flag = 0
    b_year_flag = 1

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

Submission status: Accepted

Solution code:
s = input()
s1, s2 = s[:2], s[2:]

f1 = (1 <= int(s1) <= 12)
f2 = (1 <= int(s2) <= 12)
ans = ""
if f1 and f2:
    ans = "AMBIGUOUS"
elif f1 and (not f2):
    ans = "MMYY"
elif (not f1) and f2:
    ans = "YYMM"
else:
    ans = "NA"

print(ans)

Submission status: Accepted

Solution code:
S = input()
SL = int(S[0:2])
SR = int(S[2:4])

if 1 <=SL <= 12:
    if 1<= SR<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif 1<=SR<=12:
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

Solution code:
s=int(input())
num=[]
while s > 0:
    num.append(s % 100)
    s //= 100

if len(num)==0:
    num.append(0)
if len(num)==1:
    num.append(0)
num.reverse()

if num[0]<=12 and num[0]>0:
    if num[1]<=12 and num[1]>0:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if num[1]<=12 and num[1]>0:
        print("YYMM")
    else:
        print("NA")

Submission status: Accepted

Solution code:

def main():
    S = input()

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

    if A != 0 and B <= 12 and B != 0 and A <= 12:
        print("AMBIGUOUS")

    elif (A != 0 and B <= 12) and B != 0:
        print("YYMM")

    elif (B != 0 and A <= 12) and A != 0:
        print("MMYY")

    elif (A == 0 and 1 <= B and B <= 12):
        print("YYMM")

    elif (B == 0 and 1 <= A and A <= 12):
        print("MMYY")

    else:
        print("NA")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


def check_format(num):
    if not num:
        return 0
    if num <= 12:
        return 1
    return 2


def main():
    s = input()
    f = int(s[:2])
    b = int(s[2:])
    f_format = check_format(f)
    b_format = check_format(b)
    format_ = "AMBIGUOUS"
    if set([f_format, b_format]) == {2}:
        format_ = "NA"
    if set([f_format, b_format]) == {0}:
        format_ = "NA"
    if [f_format, b_format] == [0, 2] or [f_format, b_format] == [2, 0]:
        format_ = "NA"
    if f_format == 1 and b_format in (0, 2):
        format_ = "MMYY"
    if f_format in (0, 2) and b_format == 1:
        format_ = "YYMM"
    print(format_)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = str(input())
first = s[0] + s[1]
second = s[2] + s[3]
if int(first) <= 12 and int(first) > 0 and (int(second) > 12 or int(second) == 0):
    print("MMYY")
elif int(second) <= 12 and int(second) > 0 and (int(first) > 12 or int(first) == 0):
    print("YYMM")
elif int(second) <= 12 and int(second) > 0 and int(first) <= 12 and int(first) > 0:
    print("AMBIGUOUS")
else:
    print("NA")

Submission status: Accepted

Solution code:
S = input()

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

if A<=12 and B<=12 and A>0 and B>0:
    print("AMBIGUOUS")
elif A<=12 and A>0:
    print("MMYY")
elif B<=12 and B>0:
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

Solution code:
s = list(input())
bef=int(s[0])*10+int(s[1])
aft=int(s[2])*10+int(s[3])

ans=''
if 0<aft<13 and 0<bef<13:
  ans='AMBIGUOUS'
elif (100>aft>12 or aft==0) and 0<bef<13:
  ans='MMYY'
elif (100>bef>12 or bef==0) and 0<aft<13:
  ans='YYMM'
else:
  ans='NA'
print(ans)

Submission status: Accepted

Solution code:
import re 
S=input()
def YM(S):
  if re.match("(00|1[3-9]|[2-9][0-9])(0[1-9]|1[0-2])",S):
    return "YYMM"
  elif re.match("(0[1-9]|1[0-2])(00|1[3-9]|[2-9][0-9])",S):
    return "MMYY"
  elif re.match("(0[1-9]|1[0-2])(0[1-9]|1[0-2])",S):
    return "AMBIGUOUS"
  else:
    return "NA"
print("{}".format(YM(S)))

Submission status: Accepted

Solution code:
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque
import heapq
import math
import bisect


def main():
    S = input()

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def is_mm(target):
    n = int(target)
    return 1 <= n <= 12


def get_result(first2_is_mm, last2_is_mm):
    if first2_is_mm and last2_is_mm:
        return "AMBIGUOUS"
    if not first2_is_mm and not last2_is_mm:
        return "NA"
    if first2_is_mm:
        return "MMYY"
    return "YYMM"


s = str(input())
first2, last2 = ((i + j) for (i, j) in zip(s[::2], s[1::2]))
print(get_result(is_mm(first2), is_mm(last2)))

Submission status: Accepted

Solution code:
hoge=input()
ho=int(hoge[:2])
ge=int(hoge[2:])
ym=0
my=0
if(1<=ge and ge<=12):
  ym=1
  
if(1<=ho and ho<=12):
  my=1
  
if(ym==1 and my==1):
  print("AMBIGUOUS")
elif(ym==1):
  print("YYMM")
elif(my==1):
  print("MMYY")
else:
  print("NA")

Submission status: Accepted

Solution code:
s=input()

t=int(s[0:2])
u=int(s[2:4])

if t==0:
    if 1<=u and u<=12:
        print("YYMM")
    else:
        print("NA")

elif 1<=t and t<=12:
    if u==0 or 12<u:
        print("MMYY")
    else:
        print("AMBIGUOUS")

else:
    if u==0 or 12<u:
        print("NA")
    else:
        print("YYMM")

Submission status: Accepted

Solution code:
def main():
    S = input()
    S1 = S[0]+S[1]
    S2 = S[2]+S[3]
    
    isS1YY = True if 0 <= int(S1)  and int(S1) <= 99 else False
    isS2MM = True if 1 <= int(S2) and int(S2) <= 12 else False
    isS1MM = True if 1 <= int(S1) and int(S1) <= 12 else False
    isS2YY = True if 0 <= int(S2) and int(S2) <= 99 else False
    if isS1YY and isS2MM and isS1MM is False or isS2YY is False:
        print('YYMM')
        exit()
    if isS1MM and isS2YY:
        if isS1YY == False or isS2MM == False:
            print('MMYY')
            exit()
    if isS1YY and isS2MM and isS1MM and isS2YY:
        print('AMBIGUOUS')
        exit()
    print('NA')
main()

Submission status: Accepted

Solution code:
s = str(input())
mae = int(s[0:2])
ato = int(s[2:4])

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

Submission status: Accepted

Solution code:
S=input()
u = int(S[0:2])
l = int(S[2:4])

if u >= 1 and u <= 12:
    if l >= 1 and l <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif l >=1 and l <= 12:
    print('YYMM')
else:
    print('NA')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#B問題
S =input()
if "00" < S[0:2] <="12" and "13" <= S[2:4] <= "99":
    print("MMYY")
elif "13" <= S[0:2] <= "99" and "00" <S[2:4] <= "12":
    print("YYMM")
elif "00" < S[0:2] <= "12" and "00" < S[2:4] <= "12":
    print("AMBIGUOUS")
elif "00" == S[0:2] and "00" < S[2:4] <= "12":
    print("YYMM")
elif "00" < S[0:2] <= "12" and S[2:4] == "00":
    print("MMYY")
else:
    print("NA")

Submission status: Accepted

Solution code:
S = input()
S1 = int(S[0] + S[1])
S2 = int(S[2] + S[3])

if S1>=13 or S1==0:
  if S2>=13 or S2==0:
    print("NA")
  else:
    print("YYMM")
else:
  if S2>=13 or S2==0:
    print("MMYY")
  else:
    print("AMBIGUOUS")

Submission status: Accepted

Solution code:
def yymm_or_mmyy(s):
    yymm = 'YYMM'
    mmyy = 'MMYY'
    abmg = 'AMBIGUOUS'
    na = 'NA'

    top = s[0] + s[1]
    bot = s[2] + s[3]

    if is_mm(top):
        out = abmg if is_mm(bot) else mmyy
    else:
        out = yymm if is_mm(bot) else na

    return out

def is_mm(s):
    mm = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
    return s in mm

s = str(input())
out = yymm_or_mmyy(s)
print(out)

Submission status: Accepted

Solution code:
import sys

s = input()
s = s[:4]
a = s[:2]
b = s[2:]

	
if 0 <  int(a) <= 12 and 0 <  int(b) <= 12:

	print("AMBIGUOUS")
	sys.exit()


elif int(a) >= 0 and 0 < int(b) <= 12:

	print("YYMM")
	sys.exit()

elif 0 < int(a) <= 12 and int(b) >= 0:

	print("MMYY")
	sys.exit()

print("NA")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def check(S) :
    mae = int(S[:2])
    ato = int(S[2:])
    
    if mae == 0 and ato <= 12 and ato > 0 :
        return "YYMM"
    if ato == 0 and mae <= 12 and mae > 0 :
        return "MMYY"
    
    if mae == 0 or ato == 0 :
        return "NA"
    if mae > 12 and ato > 12 :
        return "NA"
    if mae <= 12 and ato <= 12 :
        return "AMBIGUOUS"
    if mae > 12 :
        return "YYMM"

    return "MMYY"
    
    

S = input()
print(check(S))

Submission status: Accepted

Solution code:
s = input()

aa = int(s[:2])
bb = int(s[2:])

if 1 <= aa <= 12:
    print('AMBIGUOUS') if 1 <= bb <= 12 else print('MMYY')
else:
    print('YYMM') if 1 <= bb <= 12 else print('NA')

Submission status: Accepted

Solution code:
n = str(input())

#program = 'python'
a=int(n[0:2])
b=int(n[2:4])

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

Submission status: Accepted

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

S=list(str(input()))
S1=int("".join(S[0:2]))
S2=int("".join(S[2:4]))

if 1 <= S1 <= 12:
    s1="MM"
else:
    s1="YY"
    
if 1 <= S2 <= 12:
    s2="MM"
else:
    s2="YY"


if s1 != s2:
    print(s1+s2)
else:
    if s1 == "MM" and s2 == "MM":
        print("AMBIGUOUS")
    elif S1 == 0 and s2 =="MM":
        print("YYMM")
    elif s1 == "MM" and S1 == 0:
        print("MMYY")
    else:
        print("NA")

Submission status: Accepted

Solution code:
s=input()
sf,sl=int(s[:2]),int(s[2:])
if (sf>=1 and sf<=12):
    print("AMBIGUOUS" if (sl>=1 and sl<=12) else "MMYY")
else:
    print("YYMM" if (sl>=1 and sl<=12) else "NA")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
S = list(map(int,input()))
A = S[0] * 10 + S[1]
B = S[2] * 10 + S[3]
if A <= 12 and A > 0:
  if B <= 12 and B > 0:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if B <= 12 and B > 0:
    print("YYMM")
  else:
    print("NA")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S=input()

S_1=int(S[0]+S[1])
S_2=int(S[2]+S[3])

if S_1 in range(1, 13):
    #YYMM MMYY
    if S_2 in range(1,13):
        print("AMBIGUOUS")
    else :
        print("MMYY")

elif S_1 ==0:
    if S_2 in range(1,13):
        print("YYMM")
    else:
        print("NA")

elif S_1 >12:
    if S_2 in range(1,13):
        print("YYMM")
    else :
        print("NA")

Submission status: Accepted

Solution code:
# coding: utf-8
status = ['NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'MMYY', 'MMYY', 'NA', 'YYMM', 'NA', 'YYMM', 'NA', 'YYMM', 'MMYY', 'AMBIGUOUS']

def isMonth(a):
    return a > 0 and a < 13

def isYear(a):
    return a > -1 and a < 100

t = input()
t1 = int(t[:2])
t2 = int(t[2:])

judge = isYear(t1) * 8 + isMonth(t1) * 4 + isYear(t2) * 2 + isMonth(t2)
print(status[judge])

Submission status: Accepted

Solution code:
def main():
    s = input()
    l = int(s[0:2])
    r = int(s[2:4])

    if check(l) == 2 and check(r) == 2:
        print("AMBIGUOUS")
        return
    elif check(l) != 2 and check(r) == 2:
        print("YYMM")
        return
    elif check(l) == 2 and check(r) != 2:
        print("MMYY")
        return
    else:
        print("NA")

def check(num):
    if num == 0:
        return 1
    elif 1 <= num and num <= 12:
        return 2
    else:
        return 3

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = input()

sf = int(s[:2])
sb = int(s[2:4])

ans = ""

if 1 <= sf <= 12:

    if 1 <= sb <= 12:
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"

else:

    if 1 <= sb <= 12:
        ans = "YYMM"
    else:
        ans = "NA"

print(ans)

Submission status: Accepted

Solution code:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    s = get_str()
    a, b = int(s[:2]), int(s[2:])
    if 1 <= a <= 12 and 1 <= b <= 12:
        print('AMBIGUOUS')
    elif 1 <= b <= 12 and (a == 0 or a > 12):
        print('YYMM')
    elif 1 <= a <= 12 and (b == 0 or b > 12):
        print('MMYY')
    else:
        print('NA')
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from datetime import date
s = str(input())
f = int(s[:2])
l = int(s[2:])

def validate_date(m):
  try:
    date(2000, int(m), 1)
    return True
  except ValueError:
    return False

f_month = 0
l_month = 0

if(validate_date(f)): f_month = 1
if(validate_date(l)): l_month = 1

if(l_month == 1 and f_month == 1):print('AMBIGUOUS')

if(l_month == 1 and f_month == 0):print('YYMM')

if(l_month == 0 and f_month == 1):print('MMYY')

if(l_month == 0 and f_month == 0):print('NA')

Submission status: Accepted

Solution code:
S = input()
s_list = list(S)
s_list_i = [int(s) for s in s_list ]
a = int(s_list[0] + s_list[1])
b = int(s_list[2] + s_list[3])

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

Submission status: Accepted

Solution code:
s =input()
ym=0
my=0
d1=int(s[0:2])
d2=int(s[2:4])
#print(d1,d2)

if 0<=d1:
    ym+=1
    if 0<d1<13:
        my+=1

if 0<=d2:
    my+=1
    if 0<d2<13:
        ym+=1
    
if ym==2 and my==2:
    print("AMBIGUOUS")    
elif ym==2:
    print("YYMM")
elif my==2:
    print("MMYY")
else:
    print("NA")

Submission status: Accepted

Solution code:
s = input()
my1 = int(s[0:2])
my2 = int(s[2:])
my1t = False
my2t = False
if my1 >= 13 or my1 == 0:
    my1t = True
if my2 >= 13 or my2 == 0:
    my2t = True
if my1t == True and my2t == False:
    print('YYMM')
elif my1t == False and my2t == True:
    print('MMYY')
elif my1t == False and my2t == False:
    print('AMBIGUOUS')
else:
    print('NA')

Submission status: Accepted

Solution code:
s=int(input())
a=s//100
b=s%100
if a>12 and b>12 or a==0 and b>12 or b==0 and a>12 or a==0 and b==0:print("NA")
elif a>12 or a==0:print("YYMM")
elif b>12 or b==0:print("MMYY")
else:print("AMBIGUOUS")

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

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

s=ns()
if (s[0:2]<="12")&(s[0:2]>"00")&((s[2:4]>"12")|(s[2:4]=="00")):
	print("MMYY")
elif (s[0:2]<="12")&(s[0:2]>"00")&(s[2:4]<="12")&(s[2:4]>"00"):
	print("AMBIGUOUS")
elif ((s[0:2]>"12")|(s[0:2]=="00"))&(s[2:4]<="12")&(s[2:4]>"00"):
	print("YYMM")
else:
	print("NA")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(S: int):
    S = '{:04}'.format(S)
    a = int(S[:2])
    b = int(S[2:])
    if 0<a and a<13 and 0<b and b<13:
        print('AMBIGUOUS')
    elif 0<a and a<13:
        print('MMYY')
    elif 0<b and b<13:
        print('YYMM')
    else:
        print('NA')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  # type: int
    solve(S)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = int(input())
yymm = True
mmyy = True


if S >= 1300 or S < 100:
    mmyy = False
if S%100 >= 13 or S%100 == 0:
    yymm = False

if yymm == True:
    if mmyy == True:
        print("AMBIGUOUS")
    else:
        print("YYMM")
else:
    if mmyy == True:
        print("MMYY")
    else:
        print("NA")

Submission status: Accepted

Solution code:

def YYMM(sub):
    if 1 <= sub <= 12:
        return True
    else:
        return False

def MMYY(up):
    if 1 <= up <= 12:
        return True
    else:
        return False

if __name__ == '__main__':
    S = input()
    up = int(''.join([S[0],S[1]]))
    sub = int(''.join([S[2],S[3]]))
    a = [YYMM(sub),MMYY(up)]
    if a[0] == a[1]:
        if a[0] == True and a[1] == True:
            ans = 'AMBIGUOUS'
        else:
            ans = 'NA'
    else:
        if a[0] == True:
            ans = 'YYMM'
        else:
            ans = 'MMYY'

    print(ans)