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:
S = input()
s1 = int(S[:2])
s2 = int(S[2:])
flag1 = False
flag2 = False

if s1 != 00 and s1 < 13:
    flag1 = True

if s2 != 00 and s2 < 13:
    flag2 = True
    
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:
s=input()
a=s[0:2]
b=s[2:]
if a != "00" and int(a) <= 12:
    if b != "00" and int(b) <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif b != "00" and int(b) <= 12:
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

Solution code:
s = input().strip()
yy, mm = int(s[:2]), int(s[2:])

yymm = False
mmyy = False
if 1 <= mm and mm <= 12:
    yymm = True
if 1 <= yy and yy <= 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()

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:
s=input()
a,b=int(s[:2]),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:
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


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


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


class UnionFind:

    def __init__(self, n):
        self.parent = [i for i in range(n)]

    def root(self, i):
        if (self.parent[i] == i):
            return i
        self.parent[i] = self.root(self.parent[i])
        return self.parent[i]

    def unite(self, i, j):
        rooti = self.root(i)
        rootj = self.root(j)
        if rooti == rootj:
            return
        if i < j:
            self.parent[rootj] = rooti
        else:
            self.parent[rooti] = rootj

    def same(self, i, j):
        return self.root(i) == self.root(j)


###############################################################################


def main():
    s = input()

    first = False
    second = False

    if 1 <= int(s[:2]) and int(s[:2]) <= 12:
        first = True
    if 1 <= int(s[2:]) and int(s[2:]) <= 12:
        second = True

    if first and second:
        print('AMBIGUOUS')
    if first and not second:
        print('MMYY')
    if not first and second:
        print('YYMM')
    if not first and not second:
        print('NA')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
x = input()
x1 = int(x[0:2])
x2 = int(x[2:4])

if 0 < x1 <= 12 and 0 < x2 <= 12:
    print("AMBIGUOUS")
elif 0 < x1 <= 12:
    print("MMYY")
elif 0 < x2 <= 12:
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


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


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S):
    h2 = int(S[:2])
    t2 = int(S[2:])
    hm = False
    tm = False
    if 1 <= h2 <= 12:
        hm = True
    if 1 <= t2 <= 12:
        tm = True

    if hm and tm:
        return 'AMBIGUOUS'
    elif hm:
        return 'MMYY'
    elif tm:
        return 'YYMM'
    return 'NA'


def main():
    S = read_str()
    print(slv(S))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

answer=0

if a>0 and a<13:
    answer+=2
if b>0 and b<13:
    answer+=1

if answer==0:
    print('NA')
elif answer==1:
    print('YYMM')
elif answer==2:
    print('MMYY')
else:
    print('AMBIGUOUS')

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
S = input()

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

canFirstMM = first >= 1 and first <= 12
canSecondMM = second >= 1 and second <= 12

if canFirstMM and not canSecondMM:
  result = "MMYY"
elif not canFirstMM and canSecondMM:
  result = "YYMM"
elif canFirstMM and canSecondMM:
  result = "AMBIGUOUS"
else:
  result = "NA"
  
print(result)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from datetime import date


S = input()

x = int(S[0:2])
y = int(S[2:4])

try:
    date1 = date(x + 2000, y, 1)
except ValueError:
    date1 = None

try:
    date2 = date(y + 2000, x, 1)
except ValueError:
    date2 = None

if date1 and date2:
    print('AMBIGUOUS')
elif date1 is None and date2 is None:
    print('NA')
elif date1:
    print('YYMM')
elif date2:
    print('MMYY')

Submission status: Accepted

Solution code:
s = input()
n1 = int(s[:2])
n2 = int(s[2:])

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

if f(n1) and f(n2):
    print("AMBIGUOUS")
elif f(n1) and (not f(n2)):
    print("MMYY")
elif f(n2) and (not f(n1)):
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

Solution code:
def is_month(v):
  return (v >= 1 and v <= 12)

#yymm = list(map(int, list(input())))
yymm = int(input())
a = yymm // 100
b = yymm % 100

# yy : 00-99
# month : 01-12
if (not is_month(a)) and (not is_month(b)):
  print('NA')
elif is_month(a) and is_month(b):
  print('AMBIGUOUS')
elif is_month(b):
  print('YYMM')
elif is_month(a):
  print('MMYY')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()

ym = False
my = False
for i in range(12):
    if int(s[:2]) == (i + 1):
        my = True
    if int(s[2:]) == (i + 1):
        ym = True

if my and ym:
    print('AMBIGUOUS')
elif my:
    print('MMYY')
elif ym:
    print('YYMM')
else:
    print('NA')

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
s = input()
s1 = s[0] + s[1]
s2 = s[2] + s[3]
if int(s1) > 12 or int(s1) == 0:
    if int(s2) > 12 or int(s2) == 0:
        print("NA")
    else:
        print("YYMM")
else:
    if int(s2) > 12 or int(s2) == 0:
        print("MMYY")
    else:
        print("AMBIGUOUS")

Submission status: Accepted

Solution code:
S = input()

mm = ('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12')

head = S[0:2]
tail = S[2:4]
if head in mm and tail in mm:
    print('AMBIGUOUS')
elif head in mm and tail not in mm:
    print('MMYY')
elif head not in mm and tail in mm:
    print('YYMM')
else:
    print('NA')

Submission status: Accepted

Solution code:
s = input()
first = int(s[:2])
second = int(s[2:])
fv = (1 <= first <= 12)
sv = (1 <= second <= 12)
if fv and sv:
    print('AMBIGUOUS')
elif fv and not sv:
    print('MMYY')
elif not fv and sv:
    print('YYMM')
else:
    print('NA')

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 = input()
x, y = int(s[:2]), int(s[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:
s = input()
a = int(s[:2])
b = int(s[2:])
yymm = True
mmyy = True
if a < 1 or a > 12:
    mmyy = False
if b < 1 or b > 12:
    yymm = False
if yymm and mmyy:
    print('AMBIGUOUS')
elif yymm:
    print('YYMM')
elif mmyy:
    print('MMYY')
else:
    print('NA')

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()
if 1 <= int(s[:2]) <= 12:
    if 1 <= int(s[2:]) <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")

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

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=input()
a=1
b=1
if int(s[:2])==0 or int(s[:2])>12:a=0
if int(s[2:])==0 or int(s[2:])>12:b=0
if a==1 and b==1:print('AMBIGUOUS')
elif a==0 and b==0:print('NA')
elif a==1:print('MMYY')
else:print('YYMM')

Submission status: Accepted

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


def solve(S: int):
    upper = int(S/100)
    lower = S%100
    
    if upper > 0 and upper < 13:
        if lower > 0 and lower < 13:
            print('AMBIGUOUS')
        else:
            print('MMYY')
    elif lower > 0 and lower < 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:
#!/usr/bin/env python3
import sys
a = 'YYMM'
b = 'MMYY'
c = 'AMBIGUOUS'
d = 'NA'

def solve(S: str):
    if 1 <= int(S[:2]) <= 12:
        if 1 <= int(S[2:]) <= 12:
            print(c)
        else:
            print(b)
    else:
        if 1 <= int(S[2:]) <= 12:
            print(a)
        else:
            print(d)
    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 = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
m = [i for i in range(1, 13)]
if int(s[2:]) in m and int(s[0:2]) in m:
  print("AMBIGUOUS")
elif int(s[2:]) in m:
  print("YYMM")
elif int(s[0:2]) in m:
  print("MMYY")
else:
  print("NA")

Submission status: Accepted

Solution code:
S = input()

s01 = int(S[0:2])
s23 = int(S[2:4])

a = False
if 0 <= s01 <= 99:
    if 1 <= s23 <= 12:
        a = True

b = False
if 0 <= s23 <= 99:
    if 1 <= s01 <= 12:
        b = True

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

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 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 a <= 12 and 0 < a:
    if b <= 12 and 0 < b:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if b <= 12 and 0 < b:
        print("YYMM")
    else:
        print("NA")

Submission status: Accepted

Solution code:
s = input()

x = s[:2]
y = s[2:]

mmyy = 1 <= int(x) <= 12 and 0 <= int(y) <= 99
yymm = 0 <= int(x) <= 99 and 1 <= int(y) <= 12
if mmyy:
    if yymm:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if yymm:
        print('YYMM')
    else:
        print('NA')

Submission status: Accepted

Solution code:
S = int(input())

top = S // 100
under = S % 100

if 0 < top and top <= 12:
    if 0 < under and under <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 0 < under and under <= 12:
        print('YYMM')
    else:
        print('NA')

Submission status: Accepted

Solution code:
s=input()
p=int(s[:2])
n=int(s[2:])
if 1<=p<=12 and 1<=n<=12:
    print("AMBIGUOUS")
elif 1<=p<=12:
    print("MMYY")
elif 1<=n<=12:
    print("YYMM")
else:
    print("NA")

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")
    exit()
if 1 <= a <= 12:
    print("MMYY")
    exit()
if 1 <= b <= 12:
    print("YYMM")
    exit()
print("NA")

Submission status: Accepted

Solution code:
S = input()

YYMM = 1 <= int(S[-2:]) <= 12
MMYY = 1 <= int(S[:2]) <= 12

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

Submission status: Accepted

Solution code:
import sys
range = xrange
input = raw_input

s = input()

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

fmonth = 1<=first<=12
smonth = 1<=second<=12

if fmonth and smonth:
    print 'AMBIGUOUS'
elif fmonth:
    print 'MMYY'
elif smonth:
    print 'YYMM'
else:
    print 'NA'

Submission status: Accepted

Solution code:
S = input()
mlist = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
if S[0:2] in mlist and S[2:] in mlist:
    print('AMBIGUOUS')
elif S[0:2] in mlist:
    print('MMYY')
elif S[2:] in mlist:
    print('YYMM')
else:
    print('NA')

Submission status: Accepted

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

if a1 in test and a2 in test:
    print("AMBIGUOUS")
elif a1 in test:
    print("MMYY")
elif a2 in test:
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

Solution code:
S=input()
flag1=True
flag2=True
if int(S[:2]) > 12 or int(S[:2])==0:
    flag1=False
if int(S[2:]) > 12 or int(S[2:])==0:
    flag2=False
if flag1:
    if flag2:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if flag2:
        print('YYMM')
    else:
        print('NA')

Submission status: Accepted

Solution code:
import math
from functools import reduce

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

s = input()

left = int(s[0:2])
right = int(s[2:4])

if left <= 12 and left != 0:
    if right <= 12 and right != 0:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if right <= 12 and right != 0:
        print("YYMM")
    else:
        print("NA")

Submission status: Accepted

Solution code:
s = input()

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

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

Submission status: Accepted

Solution code:
S = list(input())

X, Y = int(S[0] + S[1]), int(S[2] + S[3])

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

Submission status: Accepted

Solution code:
s = input()

ym = False
my = False

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

#first check if ym
if 0<=first<=99 and 1<=second<=12:
	ym = True
if 0<=second<=99 and 1<=first<=12:
	my = True

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

Submission status: Accepted

Solution code:
S = input()
A = int(S[:2])
B = int(S[2:])
flagAM = False
flagBM = False
if 1 <= A <= 12:
    flagAM = True

if 1 <= B <= 12:
    flagBM = True

if flagAM and flagBM:
    print('AMBIGUOUS')
elif flagAM:
    print('MMYY')
elif flagBM:
    print('YYMM')
else:
    print('NA')

Submission status: Accepted

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

S = input()
s1 = S[:2]
s2 = S[2:]
i1 = int(s1)
i2 = int(s2)

YYMM = False
MMYY = False

if 1 <= i1 <= 12:
    MMYY = True
if 1 <= i2 <= 12:
    YYMM = True

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

Submission status: Accepted

Solution code:
def is_month(n: int)->bool:
    return 1 <= n and n <= 12


def yymm_or_mmyy(S: str)->str:
    first = int(S[:2])
    second = int(S[2:])

    if is_month(first) and is_month(second):
        return "AMBIGUOUS"
    elif is_month(first):
        return "MMYY"
    elif is_month(second):
        return "YYMM"

    return "NA"


if __name__ == "__main__":
    S = input()

    ans = yymm_or_mmyy(S)
    print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(S: str):
    ab = int(S[:2])
    db = int(S[2:])

    yymm = False
    if (0 <= ab <= 99) and (1 <= db <= 12):
        yymm = True
    mmyy = False
    if (0 <= db <= 99) and (1 <= ab <= 12):
        mmyy = True

    if yymm and mmyy:
        return 'AMBIGUOUS'
    if not (yymm or mmyy):
        return 'NA'

    if yymm:
        return 'YYMM'

    return 'MMYY'


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = (next(tokens))  # type: int
    result = solve(S)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()

a, b = int(S[:2]), 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:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

S = input()

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

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

Submission status: Accepted

Solution code:
s=input()
mae=int(s[:2])
ato=int(s[2:])
if 1<=mae<=12:
    if 1<=ato<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=ato<=12:
        print("YYMM")
    else:
        print("NA")

Submission status: Accepted

Solution code:
s = input()

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

yymm = 0 < second <= 12
mmyy = 0 < first <= 12

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

Submission status: Accepted

Solution code:
s = input()
flag1 = False
flag2 = False
if s[0:2] == "01" or s[0:2] == "02" or s[0:2] == "03" or s[0:2] == "04" or s[0:2] == "05" or s[0:2] == "06" or s[0:2] == "07" or s[0:2] == "08" or s[0:2] == "09" or s[0:2] == "10" or s[0:2] == "11" or s[0:2] == "12":
    flag1 = True
if s[2:4] == "01" or s[2:4] == "02" or s[2:4] == "03" or s[2:4] == "04" or s[2:4] == "05" or s[2:4] == "06" or s[2:4] == "07" or s[2:4] == "08" or s[2:4] == "09" or s[2:4] == "10" or s[2:4] == "11" or s[2:4] == "12":
    flag2 = True
if flag1 and flag2:
    print("AMBIGUOUS")
elif flag1 and (not flag2):
    print("MMYY")
elif (not flag1) and flag2:
    print("YYMM")
elif (not flag1) and (not flag2):
    print("NA")

Submission status: Accepted

Solution code:
s = input().strip()

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

Submission status: Accepted

Solution code:
s=input()
s1=s[:2]
s2=s[2:]
l=set(['01','02','03','04','05','06','07','08','09','10','11','12'])
if s1 not in l and s2 not in l:
    print('NA')
elif s1 in l and s2 not in l:
    print('MMYY')
elif s1 not in l and s2 in l:
    print('YYMM')
else:
    print('AMBIGUOUS')

Submission status: Accepted

Solution code:
def yymm(S):
    return 1 <= int(S[2:]) <= 12


def mmyy(S):
    return 1 <= int(S[:2]) <= 12


def main():
    S = input()
    y = yymm(S)
    m = mmyy(S)
    if y and m:
        print("AMBIGUOUS")
    elif y:
        print("YYMM")
    elif m:
        print("MMYY")
    else:
        print("NA")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

s = input()
a,b = s[:2], s[2:]
if 1 <= int(a) <= 12:
    if 1 <= int(b) <= 12:
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"
else:
    if 1 <= int(b) <= 12:
        ans =   "YYMM"
    else:
        ans = "NA"

print(ans)

Submission status: Accepted

Solution code:
s = input()

def ismonth(s):
	return int(s) in range(1, 13)

flag = 0
if ismonth(s[2:]):
	flag |= 1
if ismonth(s[:2]):
	flag |= 2
a = ["NA", "YYMM", "MMYY", "AMBIGUOUS"]
print(a[flag])

Submission status: Accepted

Solution code:
S = input()
mae = S[0:2]
ato = S[2:4]
if '01' <= mae <= '12' and '01' <= ato <= '12':
    print('AMBIGUOUS')
elif '01' <= ato <= '12':
    print('YYMM')
elif '01' <= mae <= '12':
    print('MMYY')
else:
    print('NA')

Submission status: Accepted

Solution code:
s = list(input())
bottom = int(s[2])*10 + int(s[3])
up = int(s[0])*10 + int(s[1])
if 1 <= bottom <= 12 and 1 <= up <= 12:
    print("AMBIGUOUS")
elif 1 <= bottom <= 12:
    print("YYMM")
elif 1 <= up <= 12:
    print("MMYY")
else:
    print("NA")

Submission status: Accepted

Solution code:
S = input()
a = int(S[:2])
b = int(S[2:])
if 1 <= a <= 12:
    yy = True
else:
    yy = False
if 1 <= b <= 12:
    mm = True
else:
    mm = False
if yy and mm:
    print("AMBIGUOUS")
elif yy:
    print("MMYY")
elif mm:
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

Solution code:
t = input()
a = int( t[0])*10+int(t[1])
b = int( t[2])*10 + int( t[3])
if 1 <= a <= 12:
    if 1 <= b <= 12:
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"
else:
    if 1 <= b <= 12:
        ans = "YYMM"
    else:
        ans = "NA"
print(ans)

Submission status: Accepted

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

res = []

if 0<int(s[2:])<13: # YYMM
    res.append("YYMM")
if 0<int(s[:2])<13: # MMYY
    res.append("MMYY")

if len(res)==1:
    print(res[0])
elif len(res)==2:
    print("AMBIGUOUS")
else:
    print("NA")

Submission status: Accepted

Solution code:
# /usr/bin/python
# -*- coding: utf-8 -*-
import math
import string


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


yymm = str(input())
ym1 = yymm[0:2]
ym2 = yymm[2:4]
if check(ym1) and check(ym2):
  print('AMBIGUOUS')
elif check(ym1) and not check(ym2):
  print('MMYY')
elif not check(ym1) and check(ym2):
  print('YYMM')
else:
  print('NA')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(S: str):
    mae = int(S[0:2])
    ushiro = int(S[2:])
    if 1 <= mae <= 12 and 1 <= ushiro <= 12:
        print("AMBIGUOUS")
    elif 1 <= mae <= 12:
        print("MMYY")
    elif 1 <= ushiro <= 12:
        print("YYMM")
    else:
        print("NA")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))  # type: str
    solve(S)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
U = int(S[0:2])
L = int(S[2:4])
if 0<U<=12 and 0<L<=12:
  print("AMBIGUOUS")
elif 0<U<=12:
  print("MMYY")
elif 0<L<=12:
  print("YYMM")
else:
  print("NA")

Submission status: Accepted

Solution code:
s = input()
mp_ok = int(s[0:2]) <= 12 and int(s[0:2]) > 0
mn_ok = int(s[2:]) <= 12 and int(s[2:]) > 0

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

Submission status: Accepted

Solution code:
S = input()
left =int(S[0:2])
right=int(S[2:])
# print(left,right)
leftM = left <= 12 and left >= 1
rightM = right <=12 and right >= 1

if leftM and rightM:
    ans = "AMBIGUOUS"
elif leftM:
    ans = "MMYY"
elif rightM:
    ans = "YYMM"
else:
    ans = "NA"

print(ans)

Submission status: Accepted

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

if 0<b<13:
    if 0<c<13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 0<c<13:
        print("YYMM")
    else:
        print("NA")

Submission status: Accepted

Solution code:
s = input()
first = s[:2]
second = s[2:]

f = int(first)
s = int(second)

# print(f,s)

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

Submission status: Accepted

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


def main():
  s = input().strip()
  x = 1 <= int(s[:2]) <= 12
  y = 1 <= int(s[2:]) <= 12

  if x and y:
    print('AMBIGUOUS')
  elif x and not y:
    print('MMYY')
  elif not x and y:
    print('YYMM')
  else:
    print('NA')


if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
def can_be_yymm(s):
    mm = int(s[2:])
    return 1 <= mm <= 12


def can_be_mmyy(s):
    mm = int(s[0:2])
    return 1 <= mm <= 12


def judge(s):
    yymm = can_be_yymm(s)
    mmyy = can_be_mmyy(s)
    if yymm and mmyy:
        return "AMBIGUOUS"
    elif yymm:
        return "YYMM"
    elif mmyy:
        return "MMYY"
    else:
        return "NA"


def main():
    s = input()
    print(judge(s))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def yymm(x):
    a = x[2]+x[3]
    return a in ['01','02','03','04','05','06','07','08','09','10','11','12']

def mmyy(x):
    a = x[0]+x[1]
    return a in ['01','02','03','04','05','06','07','08','09','10','11','12']

S = input()
if yymm(S) and mmyy(S):
    print("AMBIGUOUS")
elif not(yymm(S)) and mmyy(S):
    print("MMYY")
elif yymm(S) and not(mmyy(S)):
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

Solution code:
S = input()

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

flag_a = False
flag_b = True

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