Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate
from bisect import bisect

n, m, k = map(int, input().split())
a = [*accumulate(map(int, input().split()), initial=0)]
b = [*accumulate(map(int, input().split()), initial=0)]
ans = 0
for i, x in enumerate(a):
    if x <= k:
        ans = max(i - 1 + bisect(b, k - x))
print(ans)


Fixed submission:
from itertools import accumulate
from bisect import bisect

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a = [0] + list(accumulate(a))
b = [0] + list(accumulate(b))
ans = 0
j = m
for i in range(n+1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
d = [0] * (n+1)
for i in range(1, n+1):
    for j in range(i, n+1, i):
        d[j] += 1
for i in range(n+1):
    ans += (i * d[i])
print(ans)


Fixed submission:
n = int(input())


def f(x):
    return x * (x + 1) // 2


ans = 0
for x in range(1, n + 1):
    if x * x > n:
        break
    ans += x * x
    y_high = n // x
    ans += 2 * x * (f(y_high) - f(x))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from numba import njit


n, k = map(int, input().split())
a = np.array(list(map(int, input().split())))
def update(a):
    b = np.zeros_like(a)
    for i, x in enumerate(a):
        l = max(0, i - x)
        r = min(n - 1, i + x)
        b[l] += 1
        if r + 1 < n:
            b[r + 1] -= 1
    b = np.cumsum(b)
    return b
k = min(k, 100)
for i in range(k):
    a = update(a)
print(' '.join(a.astype(str)))


Fixed submission:
import numpy as np
from numba import njit


n, k = map(int, input().split())
a = np.array(list(map(int, input().split())))
@njit('(i8[::1]),', cache=True)
def update(a):
    b = np.zeros_like(a)
    for i, x in enumerate(a):
        l = max(0, i - x)
        r = min(n - 1, i + x)
        b[l] += 1
        if r + 1 < n:
            b[r + 1] -= 1
    b = np.cumsum(b)
    return b
k = min(k, 100)
for i in range(k):
    a = update(a)
print(' '.join(a.astype(str)))
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict


n = int(input())
a = list(map(int, input().split()))

memo = defaultdict(int)
ans = 0
for i, x in enumerate(a, 1):
    print(memo)
    ans += memo[i - x]
    memo[x + i] += 1

print(ans)


Fixed submission:
from collections import defaultdict


n = int(input())
a = list(map(int, input().split()))

memo = defaultdict(int)
ans = 0
for i, x in enumerate(a, 1):
    ans += memo[i - x]
    memo[x + i] += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter


n = int(input())
a = list(map(int,input().split()))
a_cnt = Counter(a).most_common()
for i in range(1, n+1):
    if i in a:
        if a_cnt[i-1]:
            print(a_cnt[i-1][1])
        else:
            print(0)
    else:
        print(0)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a_cnt = [0] * (n+1)
for i in a:
    a_cnt[i] += 1
print('\n'.join(map(str, a_cnt[1:])))
Buggy python submission (verdict: Runtime Error):
k, n = map(int, input().split())
a = list(map(int, input().split()))
a.append(a[0] + k)
a_sub = [0] * (n - 1)
for i in range(n):
    a_sub[i] = a[i+1] - a[i]
print(k - max(a_sub))


Fixed submission:
k, n = map(int, input().split())
a = list(map(int, input().split()))
a.append(a[0] + k)
a_sub = [0] * (n)
for i in range(n):
    a_sub[i] = a[i+1] - a[i]
print(k - max(a_sub))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n, x, y = map(int, input().split())
ans = []
for i in range(1, n+1):
    for j in range(1, n+1):
        ans.append(min(abs(j - i),
                       abs(x - i)+1+abs(j - y),
                       abs(y - i)+1+abs(j - x)))
ans_cnt = Counter(ans)
for i in range(1, n):
    print(ans_cnt[i] // 2)


Fixed submission:
from collections import Counter

n, x, y = map(int, input().split())
ans = []
for i in range(1, n+1):
    for j in range(1, n+1):
        ans.append(min(abs(j - i),
                       abs(x - i)+1+abs(j - y),
                       abs(y - i)+1+abs(j - x)))
ans_cnt = Counter(ans)
for i in range(1, n):
    print(ans_cnt[i] // 2)
Buggy python submission (verdict: Time Limit Exceeded):
mod = 10 ** 9 + 7


def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod


n, a, b = map(int, input().split())
a_comb = comb(n,a,mod)
b_comb = comb(n,b,mod)
print(2 ** n -1 - a_comb - b_comb)


Fixed submission:
from functools import reduce

stdin = open(0)
N, A, B = map(int, stdin.read().split())
MOD = 10 ** 9 + 7


def f(A):
    num = reduce(lambda x, y: x * y % MOD, range(N, N - A, -1))
    den = reduce(lambda x, y: x * y % MOD, range(1, A + 1))
    return num * pow(den, MOD - 2, MOD) % MOD


answer = pow(2, N, MOD) - f(A) - f(B) - 1
answer %= MOD
print(answer)
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate
n, k = map(int, input().split())
p = list(map(int, input().split()))
p_acc = list(accumulate(p))
ans_max = p_acc[k-1]
ans = 0
for i in range(n-k):
    ans_max = max(ans_max, p_acc[i+k] - p_acc[i])
    if p_acc[i+k] - p_acc[i] == ans_max:
        ans = i
print((p_acc[ans+k] - p_acc[ans] + k) / 2)


Fixed submission:
from itertools import accumulate
n, k = map(int, input().split())
p = list(map(int, input().split()))
p_acc = list(accumulate(p))
ans_max = p_acc[k-1]
ans = 0
if n > k:
    for i in range(n-k):
        ans_max = max(ans_max, p_acc[i+k] - p_acc[i])
        if p_acc[i+k] - p_acc[i] == ans_max:
            ans = i
    print((p_acc[ans+k] - p_acc[ans] + k) / 2)
else:
    print((sum(p) + n) / 2)

Buggy python submission (verdict: Runtime Error):
from itertools import accumulate
n, k = map(int, input().split())
p = list(map(int, input().split()))
p_acc = list(accumulate(p))
ans_max = 0
for i in range(n-k):
    ans_max = max(ans_max, p_acc[i+k] - p_acc[i])
    if p_acc[i+k] - p_acc[i] == ans_max:
        ans = i
print((p_acc[i+k] - p_acc[i] + k) / 2)


Fixed submission:
from itertools import accumulate
n, k = map(int, input().split())
p = list(map(int, input().split()))
p_acc = list(accumulate(p))
ans_max = p_acc[k-1]
ans = 0
if n > k:
    for i in range(n-k):
        ans_max = max(ans_max, p_acc[i+k] - p_acc[i])
        if p_acc[i+k] - p_acc[i] == ans_max:
            ans = i
    print((p_acc[ans+k] - p_acc[ans] + k) / 2)
else:
    print((sum(p) + n) / 2)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = list(map(int, input().split()))
ans_max = 0
for i in range(n-2):
    ans_max = max(ans_max, sum(p[i:i+k]))
    if sum(p[i: i+k]) == ans_max:
        ans = i
print((sum(p[ans: ans+k]) + k) / 2)


Fixed submission:
from itertools import accumulate
n, k = map(int, input().split())
p = list(map(int, input().split()))
p_acc = list(accumulate(p))
ans_max = p_acc[k-1]
ans = 0
if n > k:
    for i in range(n-k):
        ans_max = max(ans_max, p_acc[i+k] - p_acc[i])
        if p_acc[i+k] - p_acc[i] == ans_max:
            ans = i
    print((p_acc[ans+k] - p_acc[ans] + k) / 2)
else:
    print((sum(p) + n) / 2)
Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np


H, W, K = map(int,readline().split())
grid = np.frombuffer(read(),'S1').reshape(H, -1)[:,:W]
X, Y = np.where(grid == b'#')
A = np.zeros((H, W),np.int32)
A[X, Y] = np.arange(1, kK1)
np.maximum.accumulate(A, axis=1, out=A)
for w in range(W-2,-1,-1):
    A[:,w] += A[:,w+1] * (A[:,w] == 0)
for h in range(1,H):
    if A[h,-1] == 0:
        A[h] += A[h-1]
for h in range(H-1,-1,-1):
    if A[h,-1] == 0:
        A[h] += A[h+1]
print('\n'.join(' '.join(row) for row in A.astype(str)))


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np


H, W, K = map(int,readline().split())
grid = np.frombuffer(read(),'S1').reshape(H, -1)[:,:W]
X, Y = np.where(grid == b'#')
A = np.zeros((H, W),np.int32)
A[X, Y] = np.arange(1, K+1)
np.maximum.accumulate(A, axis=1, out=A)
for w in range(W-2,-1,-1):
    A[:,w] += A[:,w+1] * (A[:,w] == 0)
for h in range(1,H):
    if A[h,-1] == 0:
        A[h] += A[h-1]
for h in range(H-1,-1,-1):
    if A[h,-1] == 0:
        A[h] += A[h+1]
print('\n'.join(' '.join(row) for row in A.astype(str)))
Buggy python submission (verdict: Time Limit Exceeded):
import bisect



def find_num(lst, num):
    insert_index = bisect.bisect_left(lst, num)
    return insert_index


n = int(input())
l = list(map(int, input().split()))
l.sort()
cnt = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        cnt += find_num(lst=l[j+1:], num=l[i] + l[j])
print(cnt)


Fixed submission:
import bisect



def find_num(lst, num):
    insert_index = bisect.bisect_left(lst, num)
    return insert_index


n = int(input())
l = list(map(int, input().split()))
l.sort()
cnt = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        cnt += find_num(lst=l[j+1:], num=l[i] + l[j])
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations


n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
cnt = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if l[k] + l[j] > l[i]:
                cnt += 1
print(cnt)


Fixed submission:
import bisect



def find_num(lst, num):
    insert_index = bisect.bisect_left(lst, num)
    return insert_index


n = int(input())
l = list(map(int, input().split()))
l.sort()
cnt = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        cnt += find_num(lst=l[j+1:], num=l[i] + l[j])
print(cnt)
Buggy python submission (verdict: Runtime Error):
from itertools import groupby


s = input()
s_doub = s + s
k = int(input())
s_sub = [[h, len(list(g))] for h, g in groupby(s)]
s_doub_sub = [[h, len(list(g))] for h, g in groupby(s_doub)]
cnt_s = 0
for i in range(len(s_sub)):
    cnt_s += s_sub[i][1] // 2
cnt_s_doub = 0
for i in range(len(s_doub_sub)):
    cnt_s_doub += s_doub_sub[i][1] // 2
if len(list(set(s))) == 1:
    if s_sub[0][1] % 2 == 1:
        ans = cnt_s * k + 1
    else:
        ans = cnt_s * k
else:
    if cnt_s_doub % cnt_s == 0:
        ans = cnt_s * k
    else:
        ans = cnt_s * k + k - 1
print(ans)




Fixed submission:
from itertools import groupby


s = input()
k = int(input())
s_sub = [[h, len(list(g))] for h, g in groupby(s)]
cnt_s = 0
if s[0] == s[-1]:
    if len(s_sub) == 1:
        ans = s_sub[0][1] * k // 2
    else:
        for i in range(1, len(s_sub)-1):
            cnt_s += s_sub[i][1] // 2
        ans = cnt_s * k + s_sub[0][1] // 2 + s_sub[-1][1] // 2 + ((s_sub[0][1] + s_sub[-1][1]) // 2) * (k - 1)
else:
    for i in range(len(s_sub)):
        cnt_s += s_sub[i][1] // 2
    ans = cnt_s * k
print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a_b = []
for i in range(n):
    a_b.append(list(map(int, input().split())))
a_b = sorted(a_b, key=lambda x:x[1], reverse=True)
ans = 0
for i in range(m):
    ans += a_b[i][1]
print(ans)

Fixed submission:
import heapq
n, m = map(int, input().split())
a_b = [[] for _ in range(m)]
for i in range(n):
    a, b = map(int, input().split())
    if a < m+1:
        a_b[a-1].append(-b)
h = []
heapq.heapify(h)
ans = 0
for i in range(m):
    for j in a_b[i]:
        heapq.heappush(h, j)
    if len(h) == 0:
        continue
    ans += heapq.heappop(h)*(-1)
print(ans)
Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = 0
a_ = []
for i in range(n):
    a_.append(a[i] + a[i+1])
for i in range(n):
    cnt += min(a_[i], b[i])
print(cnt)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = 0
dp_1 = [0]*(n)
dp_1[0] = min(a[0], b[0])
dp_2 = [0]*(n)
dp_2[0] = min(a[1], b[0]-min(a[0], b[0]))
for i in range(n-1):
    dp_1[i+1] = min(b[i+1], a[i+1] - dp_2[i])
    dp_2[i+1] = min(a[i+2], b[i+1] - dp_1[i+1])
print(sum(dp_1+dp_2))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
for i in range(n):
    print(max(a[:i]+a[i+1:]))

Fixed submission:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a_sort = list(sorted(a))
a_max = a_sort[-1]
a_second = a_sort[-2]
for i in range(n):
    if a[i] == a_max:
        print(a_second)
    else:
        print(a_max)
Buggy python submission (verdict: Runtime Error):
from fractions import gcd


l, r = map(int, input().split())
lr_ans = []
for i in range(l, r+1):
    lr_ans.append(i%2019)
lr_ans.sort()
print(int(lr_ans[0]*lr_ans[1]/gcd(lr_ans[0], lr_ans[1])))

Fixed submission:
l, r = map(int, input().split())
lr_ans = []
if r - l  >= 2019:
    print(0)
    exit()
for i in range(l, r+1):
    for j in range(i+1, r+1):
        lr_ans.append((i*j)%2019)
print(min(lr_ans))
Buggy python submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def comb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
inf = 10 ** 9 + 7
n, k = map(int, input().split())
for i in range(k):
    print(int(comb(n + 1 - k, i + 1) * comb(k - 1, i) % inf))

Fixed submission:
mod = 10 ** 9 + 7
n, k = map(int, input().split())
red, blue = n-k, k
ai = red + 1
print(ai)
for i in range(2, blue+1):
    ai = ai * (red-i+2) * (blue-i+1) // (i*(i-1))
    print(ai % mod)

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
inf = 10 ** 9 + 7
n, k = map(int, input().split())
for i in range(k):
    print(int(comb(n + 1 - k, i + 1) * comb(k - 1, i) % inf))

Fixed submission:
mod = 10 ** 9 + 7
n, k = map(int, input().split())
red, blue = n-k, k
ai = red + 1
print(ai)
for i in range(2, blue+1):
    ai = ai * (red-i+2) * (blue-i+1) // (i*(i-1))
    print(ai % mod)

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
inf = 10 ** 9 + 7
n, k = map(int, input().split())
for i in range(k):
    print(int(comb(n + 1 - k, i + 1) * comb(k - 1, i) % inf))

Fixed submission:
mod = 10 ** 9 + 7
n, k = map(int, input().split())
red, blue = n-k, k
ai = red + 1
print(ai)
for i in range(2, blue+1):
    ai = ai * (red-i+2) * (blue-i+1) // (i*(i-1))
    print(ai % mod)
Buggy python submission (verdict: Runtime Error):
from functools import reduce
import sys
import numpy as np


mod = 10 ** 9 + 7
buffer = sys.stdin.buffer
h, w = map(int, buffer.readline().split())
s = np.frombuffer(buffer.read(h*(w+1)), dtype='B') == ord('.')
s = s.reshape((h, w+1))[:, :-1]
l = np.empty((h, w), dtype='i4')
r = np.empty((h, w), dtype='i4')
u = np.empty((h, w), dtype='i4')
d = np.empty((h, w), dtype='i4')
l[:, 0] = s[:, 0]
for i in range(1, w):
    l[:, i] = (l[:, i-1] + 1) * s[:, i]
r[:, -1] = s[:, -1]
for i in range(1, w):
    r[:, -1-i] = (r[:, -i] + 1) * s[:, -1-i]
u[0] = s[0]
for i in range(a, h):
    u[i] = (u[i-1] + 1) * s[i]
d[-1] = s[-1]
for i in range(1, h):
    d[-1-i] = (d[-i] + 1) * s[-1-i]
score = l + r + u + d - 3
print(int(score.max()))

Fixed submission:
from functools import reduce
import sys
import numpy as np


mod = 10 ** 9 + 7
buffer = sys.stdin.buffer
h, w = map(int, buffer.readline().split())
s = np.frombuffer(buffer.read(h*(w+1)), dtype='B') == ord('.')
s = s.reshape((h, w+1))[:, :-1]
l = np.empty((h, w), dtype='i4')
r = np.empty((h, w), dtype='i4')
u = np.empty((h, w), dtype='i4')
d = np.empty((h, w), dtype='i4')
l[:, 0] = s[:, 0]
for i in range(1, w):
    l[:, i] = (l[:, i-1] + 1) * s[:, i]
r[:, -1] = s[:, -1]
for i in range(1, w):
    r[:, -1-i] = (r[:, -i] + 1) * s[:, -1-i]
u[0] = s[0]
for i in range(1, h):
    u[i] = (u[i-1] + 1) * s[i]
d[-1] = s[-1]
for i in range(1, h):
    d[-1-i] = (d[-i] + 1) * s[-1-i]
score = l + r + u + d - 3
print(int(score.max()))

Buggy python submission (verdict: Runtime Error):
from functools import reduce
import sys
import numpy as np


mod = 10 ** 9 + 7
buffer = sys.stdin.buffer
h, w = list(map(int, buffer.readline().split()))
s = np.frombuffer(buffer.read(h*(w+1)), dtype='B') == ord('.')
s = s.reshape((h, w+1))[:, :-1]
l = np.empty((h, w), dtype='i4')
r = np.empty((h, w), dtype='i4')
u = np.empty((h, w), dtype='i4')
d = np.empty((h, w), dtype='i4')
l[:, 0] = s[:, 0]
for i in range(1, w):
    l[:, i] = (l[:, i-1] + 1) * s[:, i]
r[:, -1] = s[:, -1]
for i in range(1, w):
    r[:, -1-i] = (r[:, -i] + 1) * s[:, -1-i]
u[0] = s[0]
for i in range(a, h):
    u[i] = (u[i-1] + 1) * s[i]
d[-1] = s[-1]
for i in range(1, h):
    d[-1-i] = (d[-i] + 1) * s[-1-i]
score = l + r + u + d - 3
print(int(score.max()))

Fixed submission:
from functools import reduce
import sys
import numpy as np


mod = 10 ** 9 + 7
buffer = sys.stdin.buffer
h, w = map(int, buffer.readline().split())
s = np.frombuffer(buffer.read(h*(w+1)), dtype='B') == ord('.')
s = s.reshape((h, w+1))[:, :-1]
l = np.empty((h, w), dtype='i4')
r = np.empty((h, w), dtype='i4')
u = np.empty((h, w), dtype='i4')
d = np.empty((h, w), dtype='i4')
l[:, 0] = s[:, 0]
for i in range(1, w):
    l[:, i] = (l[:, i-1] + 1) * s[:, i]
r[:, -1] = s[:, -1]
for i in range(1, w):
    r[:, -1-i] = (r[:, -i] + 1) * s[:, -1-i]
u[0] = s[0]
for i in range(1, h):
    u[i] = (u[i-1] + 1) * s[i]
d[-1] = s[-1]
for i in range(1, h):
    d[-1-i] = (d[-i] + 1) * s[-1-i]
score = l + r + u + d - 3
print(int(score.max()))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [list(map(int, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))
c = 0
for n in range(1 << n):
    for i, s in enumerate(a):
        if p[i] ^ sum(n >> s-1 & 1 for s_ in s) & 1:
            break
        else:
            c += 1
print(c)

Fixed submission:
n, m = map(int, input().split())
s_lists = [list(map(int, input().split()))[1:] for _ in range(m)]
P = list(map(int, input().split()))
count = 0
for i in range(2**n):
  l = 1
  for p, S in zip(P, s_lists):
    l *= (sum([int(bin(i)[2:].zfill(n)[s-1]) for s in S]) % 2 == p)
  count += l
print(count)
Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]
a = sorted(a)
bc = sorted(bc, key=lambda x: -x[1])
a_len = len(a)
i = 0
for one in bc:
    for j in range(one[0]):
        if i > a_len-1:
            break
        if a[i] > one[1]:
            break
        a[i] = one[1]
        i += 1
print(sum(a))

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]
a = sorted(a)
bc = sorted(bc, key=lambda x: -x[1])
a_len = len(a)
i = 0
for one in bc:
    for j in range(one[0]):
        if i > a_len-1:
            break
        if a[i] > one[1]:
            break
        a[i] = one[1]
        i += 1
print(sum(a))
Buggy python submission (verdict: Runtime Error):
zenhan = int(S[:2])
kouhan = int(S[2:])
if zenhan == 0 or kouhan == 0:
    print('NA')
elif zenhan > 12 and kouhan > 12:
    print('NA')
elif zenhan <= 12 and kouhan <= 12:
    print('AMBIGUOUS')
elif zenhan <= 12 and kouhan > 12:
    print('MMYY')
elif zenhan > 12 and kouhan <= 12:
    print('YYMM')

Fixed submission:
S = input()
zenhan = int(S[:2])
kouhan = int(S[2:])
if zenhan == 0 and kouhan != 0:
    if kouhan <= 12:
        print('YYMM')
    else:
        print('NA')
elif kouhan == 0 and zenhan != 0:
    if zenhan <= 12:
        print('MMYY')
    else:
        print('NA')
elif zenhan == 0 and kouhan == 0:
    print('NA')
elif zenhan > 12 and kouhan > 12:
    print('NA')
elif zenhan <= 12 and kouhan <= 12:
    print('AMBIGUOUS')
elif zenhan <= 12 and kouhan > 12:
    print('MMYY')
elif zenhan > 12 and kouhan <= 12:
    print('YYMM')
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = 0
for i in range(1, n+1):
    sum_ = i         range()
    j = 0
    while True:
        if sum_ >= k:
            break
        sum_ *= 2
        j += 1
    q = 1
    for x in range(j):
        q *= 0.5
    p += q
p /= n
print(p)

Fixed submission:
N, K = map(int, input().split())
coin_num_list = []
if N != K:
    for i in range(1, min(K, N+1)):
        dice_val = i
        j = 0
        while dice_val < K:
            dice_val *= 2
            j += 1
        coin_num_list.append(j)
else:
    for i in range(1, K):
        dice_val = i
        j = 0
        while dice_val < K:
            dice_val *= 2
            j += 1
        coin_num_list.append(j)
pro_sum = 0
for coin_val in coin_num_list:
    pro_sum += (1/2)**coin_val
if N >= K:
    print((N-K+1)/N + pro_sum/N)
else:
    print(pro_sum/N)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
R, G, B, N = map(int, input().split())
cnt = 0
for i in range(int(N/R)+1):
    r = i*R
    for j in range(int(N/G)+1):
        g = j*G
        b = N - g - r
        if b >= 0 and b % B == 0:
            cnt += 1
print(cnt)

Fixed submission:
R, G, B, N = map(int, input().split())
cnt = 0
for i in range(int(N/R)+1):
    r = i*R
    for j in range(int(N/G)+1):
        g = j*G
        b = N - g - r
        if b >= 0 and b % B == 0:
            cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())
cnt = 0
for i in range(int(N/R)+1):
    r = i*R
    for j in range(int(N/G)+1):
        g = j*G
        if N-g-r >= 0 and(N-g-r) % B == 0:
            cnt += 1
print(cnt)

Fixed submission:
R, G, B, N = map(int, input().split())
cnt = 0
for i in range(int(N/R)+1):
    r = i*R
    for j in range(int(N/G)+1):
        g = j*G
        b = N - g - r
        if b >= 0 and b % B == 0:
            cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque


H, W = map(int, input().split())
black_cells = []
for h in range(H):
    line = list(input())
    for w in range(W):
        if line[w] == '#':
            black_cells.append(h*W+w)
def r(p):
    q_list = []
    h = p // W
    w = p % W
    if h != 0:
        q_list.append(p-W)
    if h != H-1:
        q_list.append(p+W)
    if w != 0:
        q_list.append(p-1)
    if w != W-1:
        q_list.append(p+1)
    return q_list


queue = deque(black_cells)
d = [10000]*H*W
for i in black_cells:
    d[i] = 0
while len(queue) > 0:
    p = queue.popleft()
    for q in r(p):
        if d[q] > d[p]+1:
            d[q] = d[p] + 1
            queue.append(q)
print(max(d))

Fixed submission:
from scipy.ndimage import distance_transform_cdt


h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
n = [[1 if x == '.' else 0 for x in row] for row in a]
cnt = distance_transform_cdt(n, metric='taxicab')
print(cnt.max())