Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
import time
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = int(input())
a = list(map(int,input().split()))
q = int(input())
bc = [list(map(int,input().split())) for i in range(q)]

ans = 0
data = [0]*10
for i in a:
  data[i] += 1
  ans += i

for b,c in bc:
  ans += c*data[b] - b*data[b]
  data[c] += data[b]
  data[b] = 0
  print(ans)

Fixed submission:
import sys
import time
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = int(input())
a = list(map(int,input().split()))
q = int(input())
bc = [list(map(int,input().split())) for i in range(q)]

ans = 0
data = [0]*100010
for i in a:
  data[i] += 1
  ans += i

for b,c in bc:
  ans += c*data[b] - b*data[b]
  data[c] += data[b]
  data[b] = 0
  print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
import time
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = int(input())
a = list(map(int,input().split()))
q = int(input())
bc = [a = list(map(int,input().split())) for i in range(q)]

ans = 0
data = [0]*100020
for i in a:
  data[i] += 1
  ans += i

for b,c in bc:
  data[c] += data[b]
  data[b] = 0
  ans += c*data[b] - b*data[b]
  print(ans)

Fixed submission:
import sys
import time
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = int(input())
a = list(map(int,input().split()))
q = int(input())
bc = [list(map(int,input().split())) for i in range(q)]

ans = 0
data = [0]*100010
for i in a:
  data[i] += 1
  ans += i

for b,c in bc:
  ans += c*data[b] - b*data[b]
  data[c] += data[b]
  data[b] = 0
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
from collections import deque
import heapq
import itertools
MAX_INT = int(10e25)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = IL()

ans = 1
for i in range(N):
  ans *= a[i]

if ans > int(1e18):
  print(-1)
else:
  print(ans)

Fixed submission:
import sys
import math
from collections import deque
import heapq
import itertools
MAX_INT = int(10e25)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = IL()

ans = 1
cnt = a.count(0)
if cnt:
  print(0)
else:
  for i in range(N):
    ans *= a[i]
    if ans > int(1e18):
      print(-1)
      break
  else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
import math
from collections import deque
import heapq
import itertools
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

X = I()

a = [0,1]
for i in range(2,70):
  a.append(i**5)
#print(a)

for i,j in itertools.combinations(a, 2):
  #print(i,j)
  for k in [-1,1]:
    if j - i*k == X:
      print(int(j**0.2), int(i**0.2)*k)
      exit()
print(error)

Fixed submission:
import sys
import math
from collections import deque
import heapq
import itertools
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

X = I()

a = [0,1]
for i in range(2,300):
  a.append(i**5)
#print(a)

for i,j in itertools.combinations(a, 2):
  #print(i,j)
  for k in [-1,1]:
    if j - i*k == X:
      print(int(j**0.2), int(i**0.2)*k)
      exit()
print(error)
Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def judge(x):
  cnt = 0
  for i in range(N):
    tmp = a[i] - x//f[i]
    cnt += max(tmp, 0)
  else:
    if cnt <= K:
      return True
    else:
      return False

# 二分探索 #
def nibutan(): # MAX(A*F) ans
    left = -1
    ans = num
    while left+1 != ans:
        middle = (left+ans)//2
        if judge(middle):
            ans = middle
        else:
            left = middle
    return ans

N, K = IL()
a = IL()
f = IL()
a.sort()
f.sort(reverse=True)
num = 0
for i in range(N):
  num = max(num, a[i]*f[i])

print(nibutan())


Fixed submission:
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def judge(x):
  cnt = 0
  for i in range(N):
    tmp = a[i] - x//f[i]
    cnt += max(tmp, 0)
  else:
    if cnt <= K:
      return True
    else:
      return False

# 二分探索 #
def nibutan(): # MAX(A*F) ans
    left = -1
    ans = num
    while left+1 != ans:
        middle = (left+ans)//2
        if judge(middle):
            ans = middle
        else:
            left = middle
    return ans

N, K = IL()
a = IL()
f = IL()
a.sort()
f.sort(reverse=True)
num = 0
for i in range(N):
  num = max(num, a[i]*f[i])

print(nibutan())
Buggy python submission (verdict: Time Limit Exceeded):
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def tami(opened, res):
  global ans
  for i in range(1, N+1):
    if str(i) not in opened:
      for x in data[i]:
        tami(opened + " ".join(map(str, KeyID[x])), res + Value[x])
      break
  else:
    ans = min(ans, res)

N, M = IL()

KeyID = [[] for _ in range(M+1)]
data = [[] for _ in range(N+1)]
Value = [0 for _ in range(M+1)]
for i in range(1, M+1):
  a, b = IL()
  c = IL()

  KeyID[i].append(c)
  Value[i] = a
  for num in c:
    data[num].append(i)
#print(Value)
#print(KeyID)

ans = MAX_INT
tami("", 0)
if ans == MAX_INT:
  print(-1)
else:
  print(ans)

Fixed submission:
MAX_INT = int(10e10)

N, M = list(map(int,input().split()))
Val = [0 for _ in range(M)]
Key = [0 for _ in range(M)]
for i in range(M):
  v, b = list(map(int,input().split()))
  k =  list(map(int,input().split()))
  Val[i] = v
  tmp = 0
  for num in k:
    tmp += 2**(num-1)
  Key[i] = tmp
#print(Val)
#print(Key)

dp = [MAX_INT for _ in range(1<<N)]
dp[0] = 0
for i in range(1<<N):
  for x in range(M):
    #print(i, i|Key[x])
    dp[i|Key[x]] = min(dp[i|Key[x]], dp[i] + Val[x])
#print(dp)
if dp[-1] == MAX_INT:
  print(-1)
else:
  print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def tami(n, opened, res):
  global ans
  for i in range(1, N+1):
    if str(i) not in opened:
      for x in data[i]:
        tami(x, opened + " ".join(map(str, KeyID[x])), res + Value[x])
      break
  else:
    ans = min(ans, res)

N, M = IL()

KeyID = [[] for _ in range(M+1)]
data = [[] for _ in range(N+1)]
Value = [0 for _ in range(M+1)]
for i in range(1, M+1):
  a, b = IL()
  c = IL()

  KeyID[i].append(c)
  Value[i] = a
  for num in c:
    data[num].append(i)
#print(Value)
#print(KeyID)

ans = MAX_INT
for i in range(1, N+1):
  tami(i, "", 0)
if ans == MAX_INT:
  print(-1)
else:
  print(ans)

Fixed submission:
MAX_INT = int(10e10)

N, M = list(map(int,input().split()))
Val = [0 for _ in range(M)]
Key = [0 for _ in range(M)]
for i in range(M):
  v, b = list(map(int,input().split()))
  k =  list(map(int,input().split()))
  Val[i] = v
  tmp = 0
  for num in k:
    tmp += 2**(num-1)
  Key[i] = tmp
#print(Val)
#print(Key)

dp = [MAX_INT for _ in range(1<<N)]
dp[0] = 0
for i in range(1<<N):
  for x in range(M):
    #print(i, i|Key[x])
    dp[i|Key[x]] = min(dp[i|Key[x]], dp[i] + Val[x])
#print(dp)
if dp[-1] == MAX_INT:
  print(-1)
else:
  print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
MAX_INT = int(10e9)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def judge(a,b,i):
  if (a+b)%2 == 0:
    data.append([(a+b)//2,(a+b)//2])
  else:
    num = (a+b)//2
    num2 = (a+b)-(a+b)//2
    if a >= b:
      if (a-1)%2 == 0:
        data.append([num2,num])
      else:
        data.append([num,num2])
    else:
      if (b-1)%2 == 0:
        data.append([num,num2])
      else:
        data.append([num2,num])

s = S()
N = len(s)
ans = [0]*N
data = []

r = 0
l = 0
f = 0
for i in range(N):
  if f == 0:
    if s[i] == "R":
      r += 1
    else:
      l += 1
      f = 1
  else:
    if s[i] == "R":
      judge(r,l,i)
      r = 0
      l = 0
      r += 1
      f = 0
    else:
      l += 1
      f = 1
else:
  judge(r,l,i)

#print(data)
f = 0
for i in range(N):
  if f == 0:
    if s[i] == "R":
      f = 1
  else:
    if s[i] == "L":
      tmp = data.pop(0)
      ans[i-1] = tmp[0]
      ans[i] = tmp[1]
      f = 0

#print(data)
print(" ".join(map(str,ans)))

Fixed submission:
import sys
MAX_INT = int(10e9)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def judge(a,b,i,left,right):
  if (a+b)%2 == 0:
    ans[left] = (a+b)//2
    ans[right] = (a+b)//2
  else:
    num = (a+b)//2
    num2 = (a+b)-(a+b)//2
    if a >= b:
      if (a-1)%2 == 0:
        ans[left] = num2
        ans[right] = num
      else:
        ans[left] = num
        ans[right] = num2
    else:
      if (b-1)%2 == 0:
        ans[left] = num
        ans[right] = num2
      else:
        ans[left] = num2
        ans[right] = num

s = S()
N = len(s)
ans = [0]*N

r = 0
l = 0
f = 0

ll = 0
rr = 0
for i in range(N):
  if f == 0:
    if s[i] == "R":
      r += 1
    else:
      l += 1
      f = 1
      if s[i-1] == "R":
        rr = i-1
        ll = i
  else:
    if s[i] == "R":
      judge(r,l,i,rr,ll)
      r = 0
      l = 0
      r += 1
      f = 0
      indef = 0
    else:
      l += 1
      f = 1
else:
  judge(r,l,i,rr,ll)

print(" ".join(map(str,ans)))
Buggy python submission (verdict: Time Limit Exceeded):
N = input()
digit = len(N)
mod = 1000000007

# dp[i番目まで][未満かどうか][mod13]
dp = [[[0]*13 for _ in range(2)] for _ in range(digit+2)]
dp[0][0][0] = 1

for i in range(digit-1,-1,-1):
  ii = digit-i-1
  d = 10**(ii)
  for j in range(2):
    for k in range(13):
      if N[i] == "?":
        for n in range(9+1):
          dp[ii+1][j][(k + n*d)%13] += dp[ii][j][k] %mod
      else:
        n = int(N[i])
        dp[ii+1][j][(k + n*d)%13] += dp[ii][j][k] %mod

print((dp[digit][0][5] + dp[digit][1][5]) %mod)

Fixed submission:
#N = "?"*(100000)
N = input()
digit = len(N)
mod = 1000000007

# dp[i番目まで][未満かどうか][mod13], 計算量O(10**5 * 2 * 13 * 10)
dp = [[[0]*13 for _ in range(2)] for _ in range(digit+1)]
dp[0][0][0] = 1

d = 1/10
for i in range(digit-1,-1,-1):
  ii = digit-i-1
  d = int((d*10)%13)
  for j in range(2):
    for k in range(13):
      if N[i] == "?":
        for n in range(9+1):
          dp[ii+1][j][(k + n*d) %13] += dp[ii][j][k] %mod
      else:
        n = int(N[i])
        dp[ii+1][j][(k + n*d) %13] += dp[ii][j][k] %mod

print((dp[digit][0][5] + dp[digit][1][5]) %mod)
#print(dp[-10:])
Buggy python submission (verdict: Runtime Error):
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

import functools
@functools.lru_cache(maxsize=None)
def make_divisors(n):
  if n == 1:
    divisors.append(1)
    return divisors
  for i in range(int(n**0.5)+1,1,-1):
    if n % i == 0:
      divisors.append(i)
      break
  return make_divisors(n//i)

N = I()
a = IL()
cnt = [0]*N

ans = ""
M = 0
for i in range(N-1,-1,-1):
  if cnt[i]%2 == 0 and a[i] == 1 or cnt[i]%2 == 1 and a[i] == 0:
    M += 1
    ans += str(i+1) + " "
  if a[i] == 1:
    divisors = []
    l = make_divisors(i+1)
    for j in l:
      cnt[j-1] += 1

if ans == "":
  print(0)
else:
  print(M)
  print(ans[:-1])

Fixed submission:
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = IL()
cnt = [0]*(N+1)
ans = []
M = 0
for i in range(N-1,-1,-1):
  tmp = sum(cnt[i::i+1])
  if tmp%2 != a[i]:
    ans.append(str(i+1))
    cnt[i] = 1
    M += 1

if M == 0:
  print(0)
else:
  print(M)
  print(" ".join(ans))
Buggy python submission (verdict: Runtime Error):
import bisect
from operator import itemgetter
import math
import copy
import collections
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = [i for i in S()]

ss = list(set(s))

if s.count(ss[0]) == s.count(ss[1]) and len(ss) == 2:
  print("Yes")
else:
  print("No")

Fixed submission:
import bisect
from operator import itemgetter
import math
import copy
import collections
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = [i for i in S()]

ss = list(set(s))

if len(ss) == 1:
  print("No")
elif s.count(ss[0]) == s.count(ss[1]) and len(ss) == 2:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,K = IL()
if K == 1:
  print(0)
else:
  print(N-K)

Fixed submission:
import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,K = IL()
if K == 1:
  print(0)
else:
  print(N-K)
Buggy python submission (verdict: Runtime Error):
import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()
K = [IL() for i in range(M)]
p = IL()

data = []
for i in range(2**M):
    d = []
    for j in range(M):
        if ((i >> j) & 1) == 1:
            d.append(K[j])
    else:
        data.append(d)

ans = 0
for s in data:
    cnt = [0]*M
    for i in s:
        for j in i[1:]:
            cnt[j-1] += 1
    else:
        for k in range(M):
            if cnt[k]%2 == p[k]:
                continue
            else:
                break
        else:
            ans += 1

print(ans)

Fixed submission:
import numpy as np
import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()
K = [IL()[1:] for i in range(M)]
p = np.array(IL())

switch = np.array([[0]*M for i in range(N)])
for i in range(M):
    while K[i]:
        num = K[i].pop()
        switch[num-1][i] = 1

ans = 0
for i in range(1 << N):
    cnt = np.array([0]*M)
    for j in range(N):
        if ((i >> j) & 1) == 1:
            cnt += switch[j]
    else:
        if (p == (cnt%2)).all():
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()

A = IL()
BC = [IL() for i in range(M)]
A.sort()
BC.sort(key=itemgetter(1),reverse=True)

tmp = bisect.bisect_left(A,BC[0][1])
cnt = 0
j = 0
for b,c in BC:
    for i in range(b):
        if c > A[j]:
            A[j] = c
            j += 1
        else:
            break
    else:
        continue
    break

print(sum(A))

Fixed submission:
import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()

A = IL()
BC = [IL() for i in range(M)]
A.sort()
BC.sort(key=itemgetter(1),reverse=True)

tmp = bisect.bisect_left(A,BC[0][1])
cnt = 0
j = 0
for b,c in BC:
    for i in range(b):
        if c > A[j]:
            A[j] = c
            j += 1
            cnt += 1
            if cnt == tmp:
                break
        else:
            break
    else:
        continue
    break

print(sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()

A = IL()
BC = [IL() for i in range(M)]
A.sort()
BC.sort(key=itemgetter(1))
for b,c in BC:
    tmp = bisect.bisect_left(A,c)
    if b <= tmp:
        A = A[b:]
        for i in range(b):
            bisect.insort_left(A,c)
    else:
        A = A[tmp:]
        for i in range(tmp):
            bisect.insort_left(A,c)
print(sum(A))

Fixed submission:
import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()

A = IL()
BC = [IL() for i in range(M)]
A.sort()
BC.sort(key=itemgetter(1),reverse=True)

tmp = bisect.bisect_left(A,BC[0][1])
cnt = 0
j = 0
for b,c in BC:
    for i in range(b):
        if c > A[j]:
            A[j] = c
            j += 1
            cnt += 1
            if cnt == tmp:
                break
        else:
            break
    else:
        continue
    break

print(sum(A))
Buggy python submission (verdict: Runtime Error):
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()

f = 0
ff = 0
num = 12
if int(s[:2]) > num or int(s[:2]) == 0:
    f = 1
if int(s[2:]) > num or int(s[2:]) == 0:
    ff = 1

if f == 0 and ff == 0:
    print("AMBIGUOUS")
elif f == 1 and ff == 0:
    print("YYMM")
elif f == 0 and ff == 1:
    print("MMYY")
elif f == 1 and ff == 1:
    print("NA")

Fixed submission:
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()

f = 0
ff = 0
num = 12
if int(s[:2]) > num or int(s[:2]) == 0:
    f = 1
if int(s[2:]) > num or int(s[2:]) == 0:
    ff = 1

if f == 0 and ff == 0:
    print("AMBIGUOUS")
elif f == 1 and ff == 0:
    print("YYMM")
elif f == 0 and ff == 1:
    print("MMYY")
elif f == 1 and ff == 1:
    print("NA")
Buggy python submission (verdict: Runtime Error):
R,G,B,N = IL()

cnt = 0
num = N
for i in range(0,N+1,R):
    tmp = num - i
    for j in range(0,N+1,G):
        tmp2 = tmp - j
        if tmp2%B == 0 and tmp2 >= 0:
            cnt += 1

print(cnt)

Fixed submission:
R,G,B,N = list(map(int,input().split()))

cnt = 0
num = N
for i in range(0,N+1,R):
    tmp = num - i
    for j in range(0,N+1,G):
        tmp2 = tmp - j
        if tmp2%B == 0 and tmp2 >= 0:
            cnt += 1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
MAX_INT = int(10e10)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

R,G,B,N = IL()

cnt = 0
num = N
for i in range(0,N+1,R):
    tmp = num - i
    for j in range(0,N+1,G):
        tmp2 = tmp - j
        if tmp2%B == 0 and tmp2 >= 0:
            cnt += 1

print(cnt)

Fixed submission:
R,G,B,N = list(map(int,input().split()))

cnt = 0
num = N
for i in range(0,N+1,R):
    tmp = num - i
    for j in range(0,N+1,G):
        tmp2 = tmp - j
        if tmp2%B == 0 and tmp2 >= 0:
            cnt += 1

print(cnt)