Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N,K =map(int,input().split())
R,S,P = map(int,input().split())
T =input()
ans = 0
for i in range(len(T)):
    if i < K:
        if T[i] == "r":
            ans += P
        elif T[i] == "s":
            ans += R
        else:
            ans += S
    else:
        if T[i] == T[i-K]:
            T = T[:i] + "R" + T[i+1:]
        if T[i] == "r":
            ans += P
        elif T[i] == "s":
            ans += R
        elif T[i] == "p":
            ans += S
print(ans)

Fixed submission:
N,K =map(int,input().split())
R,S,P = map(int,input().split())
T =input()
ans = 0
chk_list = [0] * len(T)
for i in range(len(T)):
    if i < K:
        if T[i] == "r":
            ans += P
        elif T[i] == "s":
            ans += R
        else:
            ans += S
    else:
        if T[i] == T[i-K]:
            if chk_list[i-K] == 0:
                chk_list[i] =1
                continue
        if T[i] == "r":
            ans += P
        elif T[i] == "s":
            ans += R
        elif T[i] == "p":
            ans += S
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K =map(int,input().split())
R,S,P = map(int,input().split())
T =input()
ans = 0
for i in range(len(T)):
    if T[i] == "r":
        ans += P
    elif T[i] == "s":
        ans += R
    else:
        ans += S
for i in range(len(T)-K):
    if T[i] == T[i+K] :
        if T[i] == "r":
            ans -= P
        elif T[i] == "s":
            ans -= R
        else:
            ans -= S
        T = T[:i+K] + "R" + T[i+K+1:]
print(ans)

Fixed submission:
N,K =map(int,input().split())
R,S,P = map(int,input().split())
T =input()
ans = 0
chk_list = [0] * len(T)
for i in range(len(T)):
    if i < K:
        if T[i] == "r":
            ans += P
        elif T[i] == "s":
            ans += R
        else:
            ans += S
    else:
        if T[i] == T[i-K]:
            if chk_list[i-K] == 0:
                chk_list[i] =1
                continue
        if T[i] == "r":
            ans += P
        elif T[i] == "s":
            ans += R
        elif T[i] == "p":
            ans += S
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
X,Y = map(int,input().split())
if X+Y == 2:
    print(1000000)
elif X+Y == 3:
    print(500000)
elif X+Y == 4:
    print(400000)
elif X == 3 or Y == 3:
  	if X == 2 or Y == 2:
    	print(300000)
    elif X == 3 and Y == 3:
      	print(200000)
    else:
    	print(100000)
elif X == 2 or Y ==2:
    print(200000)
elif X == 1 or Y == 1:
    print(300000)
else:
    print(0)

Fixed submission:
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
X,Y = map(int,input().split())
if X+Y == 2:
    print(1000000)
elif X+Y == 3:
    print(500000)
elif X+Y == 4:
    print(400000)
elif X == 3 or Y == 3:
    if X == 2 or Y == 2:
        print(300000)
    elif X == 3 and Y == 3:
        print(200000)
    else:
        print(100000)
elif X == 2 or Y ==2:
    print(200000)
elif X == 1 or Y == 1:
    print(300000)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
S = input()
if N%2 == 1:
  print(No)
else:
  if S == S[:N//2]+S[:N//2]:
      print("Yes")
  else:
      print("No")


Fixed submission:
import math
N = int(input())
S = input()
if N%2 == 1:
  print("No")
else:
  if S == S[:N//2]+S[:N//2]:
      print("Yes")
  else:
      print("No")
Buggy python submission (verdict: Runtime Error):
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
input = sys.stdin.readline
a,b,x= map(float,input().split())
if x > a*a*b/2:
    left = (x-a*a*b/2)/a
    tei = left*2/a
    left1 = b-tei
    ans = math.atan(a/left1)
    print(90-math.degrees(ans))
else:
    left = x/a
    tei = left*2/b
    ans = math.atan(b/tei)
    print(math.degrees(ans))


Fixed submission:
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
input = sys.stdin.readline
a,b,x= map(float,input().split())
if x == a*a*b:
    print(0)
else:
    if x > a*a*b/2:
        left = (x-a*a*b/2)/a
        tei = left*2/a
        left1 = b-tei
        ans = math.atan(a/left1)
        print(90-math.degrees(ans))
    else:
        left = x/a
        tei = left*2/b
        ans = math.atan(b/tei)
        print(math.degrees(ans))
Buggy python submission (verdict: Runtime Error):
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
input = sys.stdin.readline
N,K = map(int,input().split())
A.sort()
F.sort(reverse=True)
print(A)
print(F)
maxi = 0
for i in range(N):
    maxi = max(maxi,A[i]*F[i])
start=0
end = maxi
while True:
    count = 0
    value = (start+end)//2
    for i in range(N):
        count += max(0,A[i]-value//F[i])
    if count == K:
        break
    elif count > K :
        if 2 > end-start:
            value +=1
            break
        start = value
    else:
        if 2 > end-start:
            break
        end = value
print(value)

Fixed submission:
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
input = sys.stdin.readline
N,K = map(int,input().split())
A = [int(i) for i in input().split()]
F = [int(i) for i in input().split()]
A.sort()
F.sort(reverse=True)
maxi = 0
for i in range(N):
    maxi = max(maxi,A[i]*F[i])
start=0
end = maxi
while True:
    count = 0
    value = (start+end)//2
    for i in range(N):
        count += max(0,A[i]-value//F[i])
    if count > K :
        if 2 > end-start:
            value +=1
            break
        start = value
    else:
        if 2 > end-start:
            break
        end = value
print(value)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import collections
import copy
import math
from collections import Counter
def verify_anagrams(first_word, second_word):
    def get_counter(s):
        return Counter(s.upper().replace(' ', ''))

    return get_counter(first_word) == get_counter(second_word)
input = sys.stdin.readline
N = int(input())
ans_list=["test"]
ans_num=[1]
ans = 0
for i in range(N):
    chk = input().strip()
    for j in range(len(ans_list)):
        if verify_anagrams(ans_list[j],chk):
            ans+= ans_num[j]
            ans_num[j] +=1
            break
        if j == len(ans_list)-1:
            ans_list.append(chk)
            ans_num.append(1)
print(ans)


Fixed submission:
import math
N = int(input())
s_dict = {}
ans = 0
for i in range(N):
    s = input()
    s = "".join(sorted(s))
    if s not in s_dict:
        s_dict[s] = 0
        s_dict[s] += 1
    else:
        ans += s_dict[s]
        s_dict[s] += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import collections
import copy
import math
from collections import Counter

def verify_anagrams(first_word, second_word):
    def get_counter(s):
        return Counter(s.upper().replace(' ', ''))

    return get_counter(first_word) == get_counter(second_word)
input = sys.stdin.readline
N = int(input())
ans_list=["test"]
ans_num=[1]
for i in range(N):
    chk = input().strip()
    for j in range(len(ans_list)):
        if verify_anagrams(ans_list[j],chk):
            ans_num[j] +=1
            break
        if j == len(ans_list)-1:
            ans_list.append(chk)
            ans_num.append(1)
ans = 0
for i in range(len(ans_num)):
    ans += ans_num[i]*(ans_num[i]-1)//2
print(ans)


Fixed submission:
import math
N = int(input())
s_dict = {}
ans = 0
for i in range(N):
    s = input()
    s = "".join(sorted(s))
    if s not in s_dict:
        s_dict[s] = 0
        s_dict[s] += 1
    else:
        ans += s_dict[s]
        s_dict[s] += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
import collections
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
N = int(input())
a = list(int(i) for i in input().split())
ans_list = []
ans = 0
for i in range(N):
	if a[N-1-i] == 1:
		ans += 1
		ans_list.append(N-i)
		chk = make_divisors(N-i)
		for j in range(len(chk)):
			a[chk[j]-1] = (1+a[chk[j]-1])%2
print(ans)
if len(ans_list) != 0:
	print(*ans_list)


Fixed submission:
import sys
input = sys.stdin.readline
import collections
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
N = int(input())
a = list(int(i) for i in input().split())
ans_list = []
ans = 0
for i in range(N):
	if a[N-1-i] == 1:
		ans += 1
		ans_list.append(N-i)
		chk = make_divisors(N-i)
		for j in range(len(chk)):
			a[chk[j]-1] = (1+a[chk[j]-1])%2
print(ans)
if len(ans_list) != 0:
	print(*ans_list)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
N = int(input())
a = list(int(i) for i in input().split())
ans_list = []
ans = 0
for i in range(N):
	if a[N-1-i] == 1:
		ans += 1
		ans_list.append(N-i)
		chk = make_divisors(N-i)
		for j in range(len(chk)):
			a[chk[j]-1] = (1+a[chk[j]-1])%2
print(ans)
if len(ans_list) != 0:
	print(*ans_list)

Fixed submission:
import sys
input = sys.stdin.readline
import collections
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
N = int(input())
a = list(int(i) for i in input().split())
ans_list = []
ans = 0
for i in range(N):
	if a[N-1-i] == 1:
		ans += 1
		ans_list.append(N-i)
		chk = make_divisors(N-i)
		for j in range(len(chk)):
			a[chk[j]-1] = (1+a[chk[j]-1])%2
print(ans)
if len(ans_list) != 0:
	print(*ans_list)
Buggy python submission (verdict: Runtime Error):
S = input()
if S[0] == S [1]:
	if S[2] == S[3]:
		print("Yes")
	else:
		print("No")
elif S[0] == S[2]:
	if S[1] == S[3]:
		print("Yes")
	else:
		print("No")
elif S[0] == S[3]:
	if S[1] == S[2]:
		print("Yes")
	else:
		print("No")
else:

Fixed submission:
S = input()
if S[0]==S[1]==S[2]==S[3]:
	print("No")
else:
	if S[0] == S [1]:
		if S[2] == S[3]:
			print("Yes")
		else:
			print("No")
	elif S[0] == S[2]:
		if S[1] == S[3]:
			print("Yes")
		else:
			print("No")
	elif S[0] == S[3]:
		if S[1] == S[2]:
			print("Yes")
		else:
			print("No")
	else:
		print("No")
Buggy python submission (verdict: Runtime Error):
import math
N,K= map(int,input().split())
choose_count = 1
for i in range(K):
	left = K - choose_count
	if left < 0:
		break
	choose = math.factorial(N-K+1)//(math.factorial(choose_count)*math.factorial(N-K+1-choose_count))
	if left < 0:
		break
	else:
		ans = choose*math.factorial(left+choose_count-1)//(math.factorial(left)*math.factorial(choose_count-1))
		print(int(ans)%1000000007)
	choose_count += 1

Fixed submission:
import math
N,K= map(int,input().split())
choose_count = 1
for i in range(K):
	left = K - choose_count
	if left < 0:
		print(0)
		continue
	if N-K+1-choose_count<0:
		print(0)
		continue
	choose = math.factorial(N-K+1)//(math.factorial(choose_count)*math.factorial(N-K+1-choose_count))
	ans = choose*math.factorial(left+choose_count-1)//(math.factorial(left)*math.factorial(choose_count-1))
	print(int(ans)%1000000007)
	choose_count += 1

Buggy python submission (verdict: Runtime Error):
import math
N,K= map(int,input().split())
choose_count = 1
for i in range(N):
	left = K - choose_count
	if left < 0:
		break
	choose = math.factorial(N-K+1)//(math.factorial(choose_count)*math.factorial(N-K+1-choose_count))
	if left < 0:
		break
	else:
		ans = choose*math.factorial(left+choose_count-1)//(math.factorial(left)*math.factorial(choose_count-1))
		print(int(ans)%1000000007)
	choose_count += 1

Fixed submission:
import math
N,K= map(int,input().split())
choose_count = 1
for i in range(K):
	left = K - choose_count
	if left < 0:
		print(0)
		continue
	if N-K+1-choose_count<0:
		print(0)
		continue
	choose = math.factorial(N-K+1)//(math.factorial(choose_count)*math.factorial(N-K+1-choose_count))
	ans = choose*math.factorial(left+choose_count-1)//(math.factorial(left)*math.factorial(choose_count-1))
	print(int(ans)%1000000007)
	choose_count += 1

Buggy python submission (verdict: Runtime Error):
import math
N,K= map(int,input().split())
choose_count = 1
for i in range(N):
	left = K - choose_count
	if left < 0:
		break
	choose = math.factorial(N-K+1)/(math.factorial(choose_count)*math.factorial(N-K+1-choose_count))
	if left < 0:
		break
	else:
		ans = choose*math.factorial(left+choose_count-1)/(math.factorial(left)*math.factorial(choose_count-1))
		print(int(ans)%1000000007)
	choose_count += 1

Fixed submission:
import math
N,K= map(int,input().split())
choose_count = 1
for i in range(K):
	left = K - choose_count
	if left < 0:
		print(0)
		continue
	if N-K+1-choose_count<0:
		print(0)
		continue
	choose = math.factorial(N-K+1)//(math.factorial(choose_count)*math.factorial(N-K+1-choose_count))
	ans = choose*math.factorial(left+choose_count-1)//(math.factorial(left)*math.factorial(choose_count-1))
	print(int(ans)%1000000007)
	choose_count += 1
Buggy python submission (verdict: Runtime Error):
from collections import Counter
import math
A,B,C,D= map(int, input().split())
AC = (A-1)//C
AD = (A-1)//D
ACD =(A-1)//(C*D//math.gcd(C,D))
ans1 = A -1-AC -AD + ACD
BC = B//C
BD = B//D
BCD = B//(C*D//math.gcd(C,D))
ans2 = B - BC - BD +BCD
print(ans2-ans1)

Fixed submission:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
A,B,C,D= map(int, input().split())
AC = (A-1)//C
AD = (A-1)//D
ACD =(A-1)//(C*D//gcd(C,D))
ans1 = A -1-AC -AD + ACD
BC = B//C
BD = B//D
BCD = B//(C*D//gcd(C,D))
ans2 = B - BC - BD +BCD
print(ans2-ans1)
Buggy python submission (verdict: Runtime Error):
num1 = 2
num2 = 3
chk = 0
N,K =map(int,input().split())
if K > (N-1)*(N-2)//2:
	print(-1)
else:
	for i in range(2,N+1):
		print("1"+" "+str(i))
	left = (N-1)*(N-2)//2 - K
	for i in range(left):
			if N >= num2 :
				if chk == 1:
					num2 += 1
					chk = 0
				print(str(num1) + " " + str(num2))
				num2 += 1
			else:
				num1 +=1
				num2 = num1+1
				print(str(num1) + " " + str(num2))
				chk = 1

Fixed submission:
from collections import Counter
from operator import itemgetter
import math
N = int(input())
work_list = [[int(i) for i in input().split()] for i in range(N)]
new_worklist=sorted(work_list, key=itemgetter(1))
now_time = 0
for i in range (N):
	now_time += new_worklist[i][0]
	if now_time > new_worklist[i][1]:
		print("No")
		break
	if i == N-1:
		print("Yes")
Buggy python submission (verdict: Runtime Error):
N = int(input())
s_dict = {}
cood_list=[]
ans = 0
for i in range(N):
    a,b = map(int,input().split())
    for j in range(len(cood_list)):
        p = a - cood_list[j][0]
        q = b - cood_list[j][1]
        s = str(p)+","+str(q)
        if s not in s_dict:
            s_dict[s] = 1
        else:
            s_dict[s] += 1
    cood = [a,b]
    cood_list.append(cood)
print(N-max(s_dict.values()))


Fixed submission:
import math
N = int(input())
s_dict = {}
cood_list=[]
ans = 0
for i in range(N):
    a,b = map(int,input().split())
    for j in range(len(cood_list)):
        p = a - cood_list[j][0]
        q = b - cood_list[j][1]
        if 0 > p:
            p = -p
            q = -q
        elif p == 0:
            q = abs(q)
        s = str(p)+","+str(q)
        if s not in s_dict:
            s_dict[s] = 1
        else:
            s_dict[s] += 1
    cood = [a,b]
    cood_list.append(cood)
if N != 1:
    print(N-max(s_dict.values()))
else:
    print(1)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import math
N = int(input())
x,y = map(int, input().split())
dis_list = [[x,y]]
for i in range(N-1):
	x , y = map(int,input().split())
	for j in range(len(dis_list)):
		x = abs(x- dis_list[j][0])
		y = abs(y-dis_list[j][1])
		dis_list.append([x,y])
dis_list = dis_list[1:1+N*(N-1)//2]
counter = Counter(map(tuple, dis_list))
if N == 1:
    print(1)
else:
    print(N-counter.most_common()[0][1])

Fixed submission:
import math
N = int(input())
s_dict = {}
cood_list=[]
ans = 0
for i in range(N):
    a,b = map(int,input().split())
    for j in range(len(cood_list)):
        p = a - cood_list[j][0]
        q = b - cood_list[j][1]
        if 0 > p:
            p = -p
            q = -q
        elif p == 0:
            q = abs(q)
        s = str(p)+","+str(q)
        if s not in s_dict:
            s_dict[s] = 1
        else:
            s_dict[s] += 1
    cood = [a,b]
    cood_list.append(cood)
if N != 1:
    print(N-max(s_dict.values()))
else:
    print(1)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
import math
N = int(input())
x,y = map(int, input().split())
dis_list = [[x,y]]
for i in range(N-1):
	x , y = map(int,input().split())
	for j in range(len(dis_list)):
		x = abs(x- dis_list[j][0])
		y = abs(y-dis_list[j][1])
		dis_list.append([x,y])
dis_list = dis_list[1:1+N*(N-1)//2]
counter = Counter(map(tuple, dis_list))
print(N-counter.most_common()[0][1])


Fixed submission:
import math
N = int(input())
s_dict = {}
cood_list=[]
ans = 0
for i in range(N):
    a,b = map(int,input().split())
    for j in range(len(cood_list)):
        p = a - cood_list[j][0]
        q = b - cood_list[j][1]
        if 0 > p:
            p = -p
            q = -q
        elif p == 0:
            q = abs(q)
        s = str(p)+","+str(q)
        if s not in s_dict:
            s_dict[s] = 1
        else:
            s_dict[s] += 1
    cood = [a,b]
    cood_list.append(cood)
if N != 1:
    print(N-max(s_dict.values()))
else:
    print(1)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
if M != 0:
    chk = int(input())
else :
    chk = 0
ans1 = 1
count = 0
if chk == 1:
    ans2 = 0
    chk = int(input())
    count += 1
else:
    ans2 = 1
for i in range(N-1):
    if chk == i+2:
        ans1 = ans2
        ans2 = 0
        count += 1
        if count != M:
            chk = int(input())
    else:
        tempo = ans2
        ans2 = ans1 + ans2
        ans1 = tempo
print(ans2%1000000007)


Fixed submission:
N,M = map(int,input().split())
if M != 0:
    chk = int(input())
else :
    chk = 0
ans1 = 1
count = 0
if chk == 1:
    ans2 = 0
    if M != 1:
        chk = int(input())
    count += 1
else:
    ans2 = 1
for i in range(N-1):
    if chk == i+2:
        ans1 = ans2
        ans2 = 0
        count += 1
        if count != M:
            chk = int(input())
    else:
        tempo = ans2
        ans2 = ans1 + ans2
        ans1 = tempo
print(ans2%1000000007)

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
chk = int(input())
ans1 = 1
count = 0
if chk == 1:
    ans2 = 0
    chk = int(input())
    count += 1
else:
    ans2 = 1
for i in range(N-1):
    if chk == i+2:
        ans1 = ans2
        ans2 = 0
        count += 1
        if count != M:
            chk = int(input())
    else:
        tempo = ans2
        ans2 = ans1 + ans2
        ans1 = tempo
print(ans2%1000000007)

Fixed submission:
N,M = map(int,input().split())
if M != 0:
    chk = int(input())
else :
    chk = 0
ans1 = 1
count = 0
if chk == 1:
    ans2 = 0
    if M != 1:
        chk = int(input())
    count += 1
else:
    ans2 = 1
for i in range(N-1):
    if chk == i+2:
        ans1 = ans2
        ans2 = 0
        count += 1
        if count != M:
            chk = int(input())
    else:
        tempo = ans2
        ans2 = ans1 + ans2
        ans1 = tempo
print(ans2%1000000007)
Buggy python submission (verdict: Runtime Error):
S = input()
if S[:2] == "00":
  if S[2:] > 12:
  	print("NA")
  else:
    print("YYMM")
elif S[2:] == "00":
  if S[:2] > 12:
  	print("NA")
  else:
    print("MMYY")
elif int(S[:2]) > 12 and int(S[2:]) > 12:
  print("NA")
elif int(S[:2]) < 13 and int(S[2:]) < 13:
  print("AMBIGUOUS")
elif int(S[:2]) < 13:
  print("MMYY")
else:
  print("YYMM")

Fixed submission:
S = input()
if S[:2] == "00":
  if int(S[2:]) > 12 or S[2:] == "00":
  	print("NA")
  else:
    print("YYMM")
elif S[2:] == "00":
  if int(S[:2]) > 12:
  	print("NA")
  else:
    print("MMYY")
elif int(S[:2]) > 12 and int(S[2:]) > 12:
  print("NA")
elif int(S[:2]) < 13 and int(S[2:]) < 13:
  print("AMBIGUOUS")
elif int(S[:2]) < 13:
  print("MMYY")
else:
  print("YYMM")

Buggy python submission (verdict: Runtime Error):
S = input()
if S[:2] == "00":
  if S[2:] > 12:
  	print("NA")
  else:
    print("YYMM")
elif S[2:] == "00":
  if S[:2] > 12:
  	print("NA")
  else:
    print("MMYY")
elif int(S[:2]) > 12 and S[2:] > 12:
  print("NA")
elif int(S[:2]) < 13 and S[2:] < 13:
  print("AMBIGUOUS")
elif int(S[:2]) < 13:
  print("MMYY")
else:
  print("YYMM")

Fixed submission:
S = input()
if S[:2] == "00":
  if int(S[2:]) > 12 or S[2:] == "00":
  	print("NA")
  else:
    print("YYMM")
elif S[2:] == "00":
  if int(S[:2]) > 12:
  	print("NA")
  else:
    print("MMYY")
elif int(S[:2]) > 12 and int(S[2:]) > 12:
  print("NA")
elif int(S[:2]) < 13 and int(S[2:]) < 13:
  print("AMBIGUOUS")
elif int(S[:2]) < 13:
  print("MMYY")
else:
  print("YYMM")
Buggy python submission (verdict: Runtime Error):
N = int(input())
a_count =0
b_count =0
ab_count =0
ab_alt =0
for i in range(N):
    test = str(input())
    if test[0] == "B":
        b_count +=1
        flag =1
    if test[-1] == "A":
        a_count += 1
        if flag == 1:
            flag =0
            ab_alt +=1
    ab_count += test.count("AB")
if ab_alt == b_count:
    if ab_alt == a_count:
        a_count += -1
print(ab_count+min(a_count,b_count))

Fixed submission:
N = int(input())
a_count =0
b_count =0
ab_count =0
ab_alt =0
flag =0
for i in range(N):
    test = str(input())
    if test[0] == "B":
        b_count +=1
        flag =1
    if test[-1] == "A":
        a_count += 1
        if flag == 1:
            flag =0
            ab_alt +=1
    ab_count += test.count("AB")
if ab_alt != 0:
    if ab_alt == b_count:
        if ab_alt == a_count:
            a_count += -1
print(ab_count+min(a_count,b_count))