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 = list(input())

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

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

Submission status: Accepted

Solution code:
s = input()
before = int(s[:2])
after = int(s[2:])
if 1 <= before <= 12:
  if 1 <= after <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 1 <= after <= 12:
    print('YYMM')
  else:
    print('NA')

Submission status: Accepted

Solution code:
S=input()
months=['01','02','03','04','05','06','07','08','09','10','11','12']

if S[0:2] in months and S[2:4] in months:
    print('AMBIGUOUS')
elif S[0:2] in months:
    print('MMYY')
elif S[2:4] in months:
    print('YYMM')
else:
    print('NA')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

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

Submission status: Accepted

Solution code:
S = input()

heads = int(S[:2])
tails = int(S[2:])


def is_month(n):
    return n >= 1 and n <= 12


if is_month(heads) and (not is_month(tails)):
    print("MMYY")
elif (not is_month(heads)) and (not is_month(tails)):
    print("NA")
elif (not is_month(heads)) and is_month(tails):
    print("YYMM")
else:
    print("AMBIGUOUS")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=int(input())
s1=s//100
s2=s-s1*100
if 0<s1<=12 and 0<s2<=12:
    print("AMBIGUOUS")
elif (s1>12 or s1==0) and 0<s2<=12:
    print("YYMM")
elif 0<s1<=12 and (s2>12 or s2==0):
    print("MMYY")
else:
    print("NA")

Submission status: Accepted

Solution code:
# abc126_b.py
def mm(n):
    if 0 < n and n < 13:
        return True
    else:
        return False

S = input()

head = int(S[:2])
tail = int(S[2:])
head_mm = mm(head)
tail_mm = mm(tail)
if head_mm and tail_mm:
    print("AMBIGUOUS")
elif head_mm:
    print("MMYY")
elif tail_mm:
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

Solution code:
S=int(input())
x=S//100
y=S%100
yymm=1<=y<=12
mmyy=1<=x<=12
ans=""
if yymm and mmyy:
    ans="AMBIGUOUS"
elif yymm:
    ans="YYMM"
elif mmyy:
    ans="MMYY"
else:
    ans="NA"
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

s1 = int(s[0])*10 + int(s[1])
s2 = int(s[2])*10 + int(s[3])
#print(s1, s2)
if  (s1>12 or s1==0) and (s2>12 or s2==0):
  print('NA')
elif (s1>12 or s1==0) and 1<=s2<=12:
  print('YYMM')
elif (s2>12 or s2==0) and 1<=s1<=12:
  print('MMYY')
elif 1<=s1<=12 and 1<=s2<=12:
  print('AMBIGUOUS')

Submission status: Accepted

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

if S[0:2] in month_list:
    if S[2:4] in month_list:
        print("AMBIGUOUS")
    else:
        print("MMYY")

else:
    if S[2:4] in month_list:
        print("YYMM")
    else:
        print("NA")

Submission status: Accepted

Solution code:
n = int(input())

d2 = n % 100
u2 = n // 100

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S = input()
mm = ["0"+str(x) for x in range(1,10)]+["10","11","12"]
mmyy = (S[:2] in mm)
yymm = (S[2:] in mm)
a = "NA"

if yymm and mmyy:
  a = "AMBIGUOUS"
elif yymm:
  a = "YYMM"
elif mmyy:
  a = "MMYY"
  
print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

a = (1 <= int(s[:2]) <= 12)
b = (1 <= int(s[2:]) <= 12)

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

Submission status: Accepted

Solution code:
import re
s = input()
f = s[:2]
b = s[2:]
flg_fm = False
flg_bm = False

if f[0] == '0' and bool(re.search('[1-9]', f[1])) or f[0] == '1' and bool(re.search('[0-2]', f[1])):
    flg_fm = True
if b[0] == '0' and bool(re.search('[1-9]', b[1])) or b[0] == '1' and bool(re.search('[0-2]', b[1])):
    flg_bm = True

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from math import factorial, sqrt, ceil, gcd
from functools import lru_cache, reduce
from decimal import Decimal
from operator import mul

INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)


# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 組合せnCr
def combinations_count(n, r):
    if n < r:
        return 0
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定
def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True


# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

# ここから書き始める
s = input()
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 = 0
b = 0

if s[2] == '0': b = int(s[3])
else: b = int(s[2:])
if s[0] == '0': a = int(s[1])
else: a = int(s[:2])

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

Submission status: Accepted

Solution code:
s = input()
a = s[:2]
b = s[2:]
b1 = 0
a1 = 0

if b[0] == '0': b1 = int(b[1])
else: b1 = int(b)
if a[0] == '0': a1 = int(a[1])
else: a1 = int(a)

if (b1>=1 and b1<=12) and (a1>=1 and a1<=12): print("AMBIGUOUS")
elif b1>=1 and b1<=12: print("YYMM")
elif a1>=1 and a1<=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 (first<13) and (second>0) and (second<13):
    print("AMBIGUOUS")
elif (first>0) and (first<13) and ((second==0) or (second>=13)):
    print("MMYY")
elif (second>0) and (second<13) and ((first==0) or (first>=13)):
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s=list(input())
s1="".join(s[:2])
s2="".join(s[2:])
if 0<int(s1)<=12 and 0<int(s2)<=12:
    print("AMBIGUOUS")
elif 0<int(s1)<=12 and (int(s2)>12 or int(s2)==0):
    print("MMYY")
elif 0<int(s2)<=12 and (int(s1)>12 or int(s1)==0):
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

Solution code:
s = input()
mae = int(s[:2])
usiro = int(s[2:])

ym = 0
my = 0

if (1 <= usiro <= 12): ym = 1
if (1 <= mae <= 12): my = 1

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
s = input()
a=0<int(s[:2])<13
b=0<int(s[-2:])<13
if a and b:
    print('AMBIGUOUS')
elif b:
    print('YYMM')
elif a:
    print('MMYY')
else:
    print('NA')

Submission status: Accepted

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

if 1 <= n1 <= 12:
  if 1 <= n2 <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
elif 1 <= n2 <= 12:
  print('YYMM')
else:
  print('NA')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

f = (0 < int(s[:2]) < 13)
s = (0 < int(s[2:]) < 13)
ans = 'NA'
if f and s:
    ans = 'AMBIGUOUS'
elif s:
    ans = 'YYMM'
elif f:
    ans = 'MMYY'
print(ans)

Submission status: Accepted

Solution code:
s = input()
mmyy = (1 <= int(s[:2]) <= 12)
yymm = (1 <= int(s[2:]) <= 12)
if mmyy:
  if yymm:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if yymm:
    print('YYMM')
  else:
    print('NA')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
S = input()

if 0 < int(S[:2]) <= 12 and 0 < int(S[2:]) <= 12:
    print('AMBIGUOUS')
    exit()
elif 0 < int(S[:2]) <= 12:
    print('MMYY')
    exit()
elif 0 < int(S[2:]) <= 12:
    print('YYMM')
    exit()
else:
    print('NA')
    exit()

Submission status: Accepted

Solution code:
x = input()
a, b = int(x[0:2]), int(x[2:4])
flag = 0
ans = ["AMBIGUOUS", "YYMM", "MMYY", "NA"]

if (a >= 1 and a <= 12) and (b >= 1 and b <= 12):
    flag = 0
elif (a == 0 and b > 12) or (b == 0 and a > 12) or (b > 12 and a > 12) or (b == 0 and a == 0):
    flag = 3
elif ((a > 0 and a <= 12) and (b >= 13)) or (b == 0 and (a >= 1 and a <= 12)):
    flag = 2
elif ((a >= 13) and (b > 0 and b <= 12)) or (a == 0 and (b >= 1 and b <= 12)):
    flag = 1


print(ans[flag])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = list(input())
first = 10 * int(x[0]) + int(x[1])
second = 10 * int(x[2]) + int(x[3])


def mc(num):
    if 1 <= num <= 12:
        return True
    else:
        return False


def yc(num):
    if 0 <= num <= 99:
        return True
    else:
        return False


if yc(first):
    if mc(second):
        if yc(second):
            if mc(first):
                print("AMBIGUOUS")
            else:
                print("YYMM")
        else:
            print("YYMM")
    elif yc(second):
        if mc(first):
            print("MMYY")
        else:
            print("NA")
    else:
        print("NA")
elif yc(second):
    if mc(first):
        print("MMYY")
    else:
        print("NA")
else:
    print("NA")

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

S = input()

f = int(S[:2])
s = int(S[2:])

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    s=input()
    a=int(s[0:2])
    b=int(s[2:4])
    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')






if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=input()

n1,n2=int(n[:2]),int(n[2:])
#if (n1>12 and n2>12) or (n1==0 and n2==0):
#   print("NA")
if (n1!=0 and n1<=12) and (n2!=0 and n2<=12):
    print("AMBIGUOUS")
elif n1!=0 and n1<=12:
    print("MMYY")
elif n2!=0 and n2<=12:
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

Solution code:
n=input()

n1,n2=int(n[:2]),int(n[2:])
if (n1>12 and n2>12) or (n1==0 and n2==0):
    print("NA")
elif (n1!=0 and n1<=12) and (n2!=0 and n2<=12):
    print("AMBIGUOUS")
elif n1!=0 and n1<=12:
    print("MMYY")
elif n2!=0 and n2<=12:
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S =int(input())
a = S // 100
b = S % 100
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()
a,b = int(s[:2]),int(s[2:])
yymm = False
mmyy = False
if b > 0 and b <= 12:
  yymm = True
if a <= 12 and 0 < a:
  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()
ans=[0]*2
a=int(s[:2])
b=int(s[2:])
if 1<=a<=12:
    ans[0]=1
if 1<=b<=12:
    ans[1]=1

if ans[0]==ans[1]==1:
    print('AMBIGUOUS')
elif ans[0]==ans[1]==0:
    print('NA')
elif ans[0]==1 and ans[1]==0:
    print('MMYY')
else:
    print('YYMM')

Submission status: Accepted

Solution code:
s = input()
first = 0 < int(s[:2]) < 13
second = 0 < int(s[2:]) < 13

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
ans = 0
for i in range(0,3,2):
  if s[i] == "0" and s[i+1] == "0":
    continue
  elif s[i] == "0":
    ans += i+1
  elif (s[i] == "1" and s[i+1] == "0") or (s[i] == "1" and s[i+1] == "1") or (s[i] == "1" and s[i+1] == "2"):
    ans += i+1
if ans == 1:
  print("MMYY")
elif ans == 3:
  print("YYMM")
elif ans == 4:
  print("AMBIGUOUS")
else:
  print("NA")

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)

#a = int(input())
#b = list(map(int, input().split()))
#n, m = map(int, input().split())
s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

l = [i for i in range(1,13)]
l = [str(i) if len(str(i))==2 else '0'+str(i) for i in l]

if s[:2] not in l and s[2:] not in l:
    print('NA')
elif s[:2] not in l and s[2:] in l:
    print('YYMM')
elif s[:2] in l and s[2:] not in l:
    print('MMYY')
else:
    print('AMBIGUOUS')

Submission status: Accepted

Solution code:
date=input()
if 1<=int(date[:2])<=12:
    if 1 <= int(date[2:]) <= 12:
        print("AMBIGUOUS")
        exit(0)
    else:
        print("MMYY")
        exit(0)
if int(date[2:])==0 or 13 <= int(date[2:]):
    print("NA")
    exit(0)
print("YYMM")

Submission status: Accepted

Solution code:
S = input()
l, r = int(S[:2]), int(S[2:])
if 0<l<13 and 0<r<13:
    print("AMBIGUOUS")
elif 0<l<13:
    print("MMYY")
elif 0<r<13:
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

Solution code:
s = list(input())
a = int("".join(s[:2]))
b = int("".join(s[2:]))
c = 0
d = 0
if a and a <= 12:
    c = 1
if b and b <= 12:
    d = 1
if c and d:
    print("AMBIGUOUS")
elif c:
    print("MMYY")
elif d:
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

Solution code:
s = int(input())

a = s % 100
b = (s-a) / 100

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

Submission status: Accepted

Solution code:
s = input()
s1 = int(s[0:2])
s2 = int(s[2:4])

s1m = False
s1y = False
s2m = False
s2y = False
if s1 <= 12 and s1 >= 1:
  s1y = True
  s1m = True
elif s1 > 12 or s1 == 0:
  s1y = True
  
if s2 <= 12 and s2 >= 1:
  s2y = True
  s2m = True
elif s2 > 12  or s2 == 0:
  s2y = True

if s1y and s2y and s1m and s2m:
  print("AMBIGUOUS")
elif s1y and s2m :
  print("YYMM")
elif s2y and s1m :
  print("MMYY")
else :
  print("NA")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
a, b = int(s[:2]), 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()
l, r = int(S[:2]), int(S[2:])
if 0<l<13 and 0<r<13:
    print("AMBIGUOUS")
elif 0<l<13:
    print("MMYY")
elif 0<r<13:
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

Solution code:
S = input()

first_two = int(S[:2])
last_two = int(S[-2:])

if first_two == 0 or first_two > 12:
    if last_two == 0:
        print('NA')
    elif last_two <= 12:
        print('YYMM')
    else:
        print('NA')
elif first_two <= 12:
    if last_two == 0:
        print('MMYY')
    elif last_two <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')

Submission status: Accepted

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = int(input())
a = S % 100
b = (S- (S % 100))/100
if   b <= 12 and  a<=12 and a!=0 and b!= 0:
       print("AMBIGUOUS")
elif b <= 12 and b!=0:
       print("MMYY")
elif a<=12 and a!=0  :
       print("YYMM")
else :
      print("NA")

Submission status: Accepted

Solution code:
S = input()
L, R =  map(int, [S[:2], S[2:]])
 
if 1 <= L <= 12 and 1 <= R <= 12:
  print("AMBIGUOUS")
elif 1 <= L <= 12 and (R == 0 or R > 12):
  print("MMYY")
elif (L == 0 or L > 12) and 1 <= R <= 12:
  print("YYMM")
else:
  print("NA")

Submission status: Accepted

Solution code:
s = input()
a, b = int(s[:2]), int(s[2:])
ym, my = False, False
if a > 0 and a <13:
    my = True
if b > 0 and b <13:
    ym = True
if ym and my:
    print('AMBIGUOUS')
elif ym and not my:
    print('YYMM')
elif not ym and my:
    print('MMYY')
else:
    print('NA')

Submission status: Accepted

Solution code:
a=int(input())
l=a/100
r=a%100
if 1<=l and l<=12:
    if 1<=r and  r<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=r and r<=12:
        print("YYMM")
    else:
        print("NA")

Submission status: Accepted

Solution code:
s = input()
s1 = int(s[:2])
s2 = int(s[2:])
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=int(input())
a=s//100
b=s%100
if a>0 and a<=12:
  if b>0 and b<=12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if b>0 and b<=12:
    print("YYMM")
  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
    
elif b == 0:
    a_month_flag = 0    
else:
    a_month_flag = 0
 
if 0< c < 13:
    b_month_flag = 1
    
elif c == 0:
    b_month_flag = 0
  
else:
    b_month_flag = 0
 
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:
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")