Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]
set_s = sorted(set(s))
max_num = 0
for i in set_s:
    max_num = max(max_num, s.count(i))
for i in set_s:
    if s.count(i) == max_num:
        print(i)


Fixed submission:
from collections import Counter
n = int(input())
s = sorted([input() for i in range(n)])

counter = Counter(s)
max_num = max(counter.values())
ans_list = [i for i in counter if counter[i] == max_num]
for i in sorted(ans_list):
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]
set_s = set(s)
max_count = max([s.count(i) for i in set_s])
for i in sorted(set_s):
    if s.count(i) == max_count:
        print(i)


Fixed submission:
from collections import Counter
n = int(input())
s = sorted([input() for i in range(n)])

counter = Counter(s)
max_num = max(counter.values())
ans_list = [i for i in counter if counter[i] == max_num]
for i in sorted(ans_list):
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]
dic = {}
set_s = sorted(set(s))
[dic.update({i:s.count(i)}) for i in set_s]
max_num = max(dic.values())
for i in set_s:
    if dic[i] == max_num:
        print(i)

Fixed submission:
from collections import Counter
n = int(input())
s = sorted([input() for i in range(n)])

counter = Counter(s)
max_num = max(counter.values())
ans_list = [i for i in counter if counter[i] == max_num]
for i in sorted(ans_list):
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]
dist = set(s)
dic = {}
ans = []
[dic.update({i: s.count(i)}) for i in dist]
max_num = max(dic.values())
[ans.append(i) for i in dic if dic[i] == max_num]
for i in sorted(ans):
    print(i)

Fixed submission:
from collections import Counter
n = int(input())
s = sorted([input() for i in range(n)])

counter = Counter(s)
max_num = max(counter.values())
ans_list = [i for i in counter if counter[i] == max_num]
for i in sorted(ans_list):
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]
dist = set(s)
dic = {}
ans = []

for i in dist:
    dic.update({i: s.count(i)})

max_num = max(dic.values())

for i in dic:
    if dic[i] == max_num:
        ans.append(i)

ans = sorted(ans)
for i in ans:
    print(i)


Fixed submission:
from collections import Counter
n = int(input())
s = sorted([input() for i in range(n)])

counter = Counter(s)
max_num = max(counter.values())
ans_list = [i for i in counter if counter[i] == max_num]
for i in sorted(ans_list):
    print(i)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
print(sum(sorted(list(map(int, input().split())))[:0 if n<=k else n-k]))

Fixed submission:
h, a = map(int, input().split())
ans = 0
while h>0:
    h -= a
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
import itertools

input = sys.stdin.readline
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

l = list(itertools.permutations([i for i in range(1, n+1)], 3))
x = sorted([l.index(p)+1, l.index(q)+1], reverse=True)
print(x[0] - x[1])

Fixed submission:
import sys
import itertools

input = sys.stdin.readline
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

l = list(itertools.permutations([i for i in range(1, n+1)], n))
x = sorted([l.index(p)+1, l.index(q)+1], reverse=True)
print(x[0] - x[1])
Buggy python submission (verdict: Time Limit Exceeded):
A, B, K = map(int, input().split())

while K != 0:
    if A >= 1:
        A -= 1
    elif B >= 1:
        B -= 1
    else:
        break
    K -= 1

print(A, B)




Fixed submission:
A, B, K = map(int, input().split())

a = A - K
k = K - A
if k <= 0:
    k = 0
b = B - k

if a <= 0:
    a = 0
if b <= 0:
    b = 0

print(a, b)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, K = map(int, input().split())

while K != 0:
    if A >= 1:
        A -= 1
    elif B >= 1:
        B -= 1
    K -= 1

print(A, B)


Fixed submission:
A, B, K = map(int, input().split())

a = A - K
k = K - A
if k <= 0:
    k = 0
b = B - k

if a <= 0:
    a = 0
if b <= 0:
    b = 0

print(a, b)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, K = map(int, input().split())

for i in range(K):
    if A >= 1:
        A -= 1
    elif B >= 1:
        B -= 1
    else:
        break

print(A, B)



Fixed submission:
A, B, K = map(int, input().split())

a = A - K
k = K - A
if k <= 0:
    k = 0
b = B - k

if a <= 0:
    a = 0
if b <= 0:
    b = 0

print(a, b)
Buggy python submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())
print((a*b) // math.gcd(a, b))

Fixed submission:
from fractions import gcd

a, b = map(int, input().split())
print((a*b) // gcd(a, b))

Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())
ans = 1

while True:
    if ans % a == 0 and ans % b == 0:
        print(ans)
        break
    ans+=1

Fixed submission:
from fractions import gcd

a, b = map(int, input().split())
print((a*b) // gcd(a, b))
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = map(int, input().split())

sorted_list = sorted(a)
print(sorted_list)
num = 0
last_num = 0

for i in range(N):
    if len(sorted_list) == 1:
        if i == 0:
            last_num = sorted_list[num]
        last_num = (sorted_list[num] + last_num) / 2
        break
    x = sorted_list[num]
    y = sorted_list[num+1]
    z = (x + y) / 2
    last_num = z
    sorted_list.pop(num)
    sorted_list.pop(num)

print(last_num)


Fixed submission:
n = int(input())
v = sorted(list(map(int, input().split())))
ans = v[0]

for i in range(n-1):
    ans = (ans + v[i+1]) / 2
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = map(int, input().split())

sorted_list = sorted(a)
print(sorted_list)
num = 0
last_num = 0

for i in range(N):
    if len(sorted_list) == 1:
        if i == 0:
            last_num = sorted_list[num]
        last_num = (sorted_list[num] + last_num) / 2
        break
    x = sorted_list[num]
    y = sorted_list[num+1]
    z = (x + y) / 2
    last_sum = z
    sorted_list.pop(num)
    sorted_list.pop(num)

print(last_num)


Fixed submission:
n = int(input())
v = sorted(list(map(int, input().split())))
ans = v[0]

for i in range(n-1):
    ans = (ans + v[i+1]) / 2
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = map(int, input().split())

sorted_list = sorted(a)
print(sorted_list)
num = 0
last_sum = 0
for i in range(N):
    if len(sorted_list) == 1:
        last_sum = (sorted_list[num] + last_sum) / 2
        break
    x = sorted_list[num]
    y = sorted_list[num+1]
    z = (x + y) / 2
    last_sum = z
    sorted_list.pop(num)
    sorted_list.pop(num)

print(last_sum)


Fixed submission:
n = int(input())
v = sorted(list(map(int, input().split())))
ans = v[0]

for i in range(n-1):
    ans = (ans + v[i+1]) / 2
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())

ans = ((a-b)-c)*-1
if 0>ans:
    ans = 0
print(ans)

Fixed submission:
a, b, c = map(int, input().split())

ans = ((a-b)-c)*-1
if 0>ans:
    ans = 0
print(ans)
Buggy python submission (verdict: Runtime Error):
 s = input()
l = s[:2]
r = s[2:]
yy = [str(i).zfill(2) for i in range(100)]
mm = [str(i).zfill(2) for i in range(1, 13)]

if l in mm and r in mm:
    print("AMBIGUOUS")
elif l in yy and r in mm:
    print("YYMM")
elif l in mm and r in yy:
    print("MMYY")
else:
    print("NA")

Fixed submission:
s = input()
l = s[:2]
r = s[2:]
yy = [str(i).zfill(2) for i in range(100)]
mm = [str(i).zfill(2) for i in range(1, 13)]

if l in mm and r in mm:
    print("AMBIGUOUS")
elif l in yy and r in mm:
    print("YYMM")
elif l in mm and r in yy:
    print("MMYY")
else:
    print("NA")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 1

while True:
    if ans % n == 0 and ans % 2 == 0:
        print(ans)
        break
    ans += 1


Fixed submission:
n = int(input())

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

print(lcm(2, n))
Buggy python submission (verdict: Runtime Error):
n, y = map(int, input().split())

for i in range(n):
    for j in range(n):
        for k in range(n):
            a = i * 10000
            b = j * 5000
            c = k * 1000
            num = i + j + k
            price = a + b + c
            if num == 9 and price == y:
                print(i, j, k)
                exit()
print(-1, -1, -1)

Fixed submission:
print(input().replace("2017", "2018"))
Buggy python submission (verdict: Runtime Error):
print("Yes" if len(s) == a+b+1 and s[a] == "-" and s[a+1] != "-" and s[a-1] != "-" else "No")


Fixed submission:
a, b = map(int, input().split())
s = input()
ans = "No"
num = [i for i in range(10)]

if len(s) == a+b+1:
    if s[a] == "-":
        s = list(s)
        s.pop(a)
        s = "".join(s)
        if s.isdigit():
            ans = "Yes"
print(ans)
Buggy python submission (verdict: Runtime Error):
import sympy
print([sympy.lucas(i) for i in range(1, int(input())+1)][-1])

Fixed submission:
import functools

@functools.lru_cache()
def lucas(n):
    if n == 0:
        return 2
    if n == 1:
        return 1
    else:
        return lucas(n-1) + lucas(n-2)

N = int(input())
print([lucas(i) for i in range(1, N+1)][-1])
Buggy python submission (verdict: Runtime Error):
x = input()

if 'a' <= x and x <= 'z':
    print('a')
elif
    print('A')


Fixed submission:
x = input()

res = 'A' if x.isupper() else 'a'

print(res)
Buggy python submission (verdict: Runtime Error):
n, k = input().strip().split()
n, k = [int(n), int(k)]

p = list(map(int, input().strip().split()))

def calc_min(cur_id, cur_v, cur_num_select):
    if cur_num_select == k:
        return cur_v
    elif cur_id == n and cur_num_select < k:
        return 1000 * 1000

    l_v = calc_min(cur_id + 1, cur_v + p[cur_id], cur_num_select + 1)
    r_v = calc_min(cur_id + 1, cur_v, cur_num_select + 0)

    return min([l_v, r_v])


print(calc_min(0, 0, 0))

Fixed submission:
n, k = input().strip().split()
n, k = [int(n), int(k)]

p = list(map(int, input().strip().split()))

p.sort()

print(f'{sum(p[0:k])}')
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
 
answer = A - 2*B
if answer < 0:
  answer = 0
 
print(answer)

Fixed submission:
A,B=map(int, input().split()) 
answer = A - 2*B
if answer < 0:
  answer = 0
 
print(answer)

Buggy python submission (verdict: Runtime Error):
A = input()
B = input()

answer = A - 2B
if answer < 0:
  answer = 0

print(answer)

Fixed submission:
A,B=map(int, input().split()) 
answer = A - 2*B
if answer < 0:
  answer = 0
 
print(answer)
Buggy python submission (verdict: Runtime Error):
from sys import stdin, setrecursionlimit


a_list = 'abcdefghijklmnopqrstuvwxyz'


def base_convert(nl, ibase, obase):
    o = []
    while any(nl):
        c = 0
        for i in range(len(nl)):
            c = c * ibase + nl[i]
            nl[i], c = divmod(c, obase)
        o.append(c)
    o.reverse()
    return o


def main():
    input = stdin.buffer.readline
    n = int(input())
    if n == 1:
        print('a')
    else:
        n = [int(i) for i in list(str(n - 1))]
        idx = base_convert(n, 10, 26)
        for i in range(len(idx)):
            if i < len(idx) - 1:
                idx[i] -= 1
        if len(idx) > 1:
            j = idx.index(-1)
            idx = idx[j + 1:]
            idx = [-1] * j + idx
        print(*[a_list[i] for i in idx], sep='')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Fixed submission:
from sys import stdin, setrecursionlimit


a_list = 'abcdefghijklmnopqrstuvwxyz'


def base_convert(nl, ibase, obase):
    o = []
    while any(nl):
        c = 0
        for i in range(len(nl)):
            c = c * ibase + nl[i]
            nl[i], c = divmod(c, obase)
        o.append(c)
    o.reverse()
    return o


def main():
    input = stdin.buffer.readline
    N = int(input())
    if N == 1:
        print('a')
    else:
        arr = [1]
        tmp = 1
        while arr[-1] <= 1000000000000001:
            tmp *= 26
            arr.append(tmp)
        k = 0
        while N >= arr[k]:
            N -= arr[k]
            k += 1
        n = [int(i) for i in list(str(N))]
        idx = base_convert(n, 10, 26)
        idx = [0] * (k - len(idx)) + idx
        print(*[a_list[i] for i in idx], sep='')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
Buggy python submission (verdict: Runtime Error):
rom sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    arr = []
    for i in range(-100, 201):
        if not i in p:
            arr.append(i)
    ans = arr[0]
    for ai in arr:
        if abs(ai - x) < abs(ans - x):
            ans = ai
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Fixed submission:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    arr = []
    for i in range(-100, 201):
        if not i in p:
            arr.append(i)
    ans = arr[0]
    for ai in arr:
        if abs(ai - x) < abs(ans - x):
            ans = ai
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Buggy python submission (verdict: Runtime Error):
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    arr = []
    for i in range(1, 101):
        if not i in p:
            arr.append(i)
    ans = arr[0]
    for ai in arr:
        if abs(ai - x) < abs(ans - x):
            ans = ai
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Fixed submission:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    arr = []
    for i in range(-100, 201):
        if not i in p:
            arr.append(i)
    ans = arr[0]
    for ai in arr:
        if abs(ai - x) < abs(ans - x):
            ans = ai
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(k):
        tmp = [0] * n
        count = 0
        for j in range(n):
            for k in range(max(0, j - a[j]), min(n, j + a[j] + 1)):
                tmp[k] += 1
                if tmp[k] == n:
                    count += 1
        a = tmp
        if count == n:
            break
    print(*a)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Fixed submission:
from sys import stdin, setrecursionlimit
from itertools import accumulate


def main():
    input = stdin.buffer.readline
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(k):
        tmp = [0] * (n + 1)
        for j in range(n):
            tmp[max(0, j - a[j])] += 1
            tmp[min(n, j + a[j] + 1)] -= 1
        a = list(accumulate(tmp))[:n]
        for ai in a:
            if ai != n:
                break
        else:
            break
    print(*a)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    for _ in range(k):
        tmp = [0] * n
        for i in range(n):
            for j in range(max(0, i - a[i]), min(n, i + a[i] + 1)):
                tmp[j] += 1
        if a == tmp:
            break
        a = tmp
    print(*a)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Fixed submission:
from sys import stdin, setrecursionlimit
from itertools import accumulate


def main():
    input = stdin.buffer.readline
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(k):
        tmp = [0] * (n + 1)
        for j in range(n):
            tmp[max(0, j - a[j])] += 1
            tmp[min(n, j + a[j] + 1)] -= 1
        a = list(accumulate(tmp))[:n]
        for ai in a:
            if ai != n:
                break
        else:
            break
    print(*a)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    ans = 1
    for ai in a:
        ans *= ai

    if ans > 10 ** 18:
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Fixed submission:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    ans = 1
    for ai in a:
        ans *= ai
        if ans == 0:
            print(0)
            exit()
        elif ans > 10 ** 18:
            print(-1)
            exit()
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
Buggy python submission (verdict: Runtime Error):
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    ab = [list(map(int, input().split())) for _ in range(n)]
    if n % 2 != 0:
        a, b = ab[n // 2]
        print(b - a + 1)
    else:
        a1, b1 = ab[(n - 1) // 2]
        a2, b2 = ab[(n + 1) // 2]
        print(len(list(range(a1 + a2, b1 + b2 + 1))))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Fixed submission:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    ab = [list(map(int, input().split())) for _ in range(n)]
    min_arr = sorted(ab, key=lambda x: x[0])
    max_arr = sorted(ab, key=lambda x: x[1])
    if n % 2 != 0:
        a = min_arr[n // 2][0]
        b = max_arr[n // 2][1]
        print(b - a + 1)
    else:
        a1 = min_arr[(n - 1) // 2][0]
        b1 = max_arr[(n - 1) // 2][1]
        a2 = min_arr[(n + 1) // 2][0]
        b2 = max_arr[(n + 1) // 2][1]
        print(b1 + b2 - a1 - a2 + 1)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
Buggy python submission (verdict: Runtime Error):
from sys import stdin, setrecursionlimit
from collections import deque


def main():
    mod = 10 ** 9 + 7
    input = stdin.buffer.readline
    n = int(input())
    p = []
    m = []

    for _ in range(n):
        a, b = map(int, input().split())
        f = b / a
        if f < 0:
            m.append(-1 / f)
        elif f > 0:
            p.append(f)

    g_p = {}
    for k in p:
        if k in g_p:
            g_p[k] += 1
        else:
            g_p[k] = 1
    g_m = {}
    for k in m:
        if k in g_m:
            g_m[k] += 1
        else:
            g_m[k] = 1

    ans = 1

    for k in g_p:
        if k in g_m:
            ans *= (2 ** g_p[k] + 2 ** g_m[k] - 1)
        else:
            ans *= 2 ** g_p[k]
        ans %= mod
    for k in g_m:
        if not (k in g_p):
            ans *= 2 ** g_m[k]
            ans %= mod
    print((ans - 1) % mod)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Fixed submission:
from sys import stdin, setrecursionlimit


def gcd(x, y):
    if x % y == 0:
        return y
    return gcd(y, x % y)


def main():
    mod = 10 ** 9 + 7
    input = stdin.buffer.readline
    n = int(input())
    p = []
    m = []

    zz = 0

    for _ in range(n):
        a, b = map(int, input().split())
        if a != 0 and b != 0:
            g = gcd(a, b)
            f = b / a
            if b / a < 0:
                m.append(str(abs(a // g)) + ':' + str(abs(b // g)))
            elif f > 0:
                p.append(str(abs((b // g))) + ':' + str(abs((a // g))))
        elif a == 0 and b == 0:
            zz += 1
        elif a == 0:
            m.append(0)
        elif b == 0:
            p.append(0)

    g_p = {}
    for k in p:
        if k in g_p:
            g_p[k] += 1
        else:
            g_p[k] = 1
    g_m = {}
    for k in m:
        if k in g_m:
            g_m[k] += 1
        else:
            g_m[k] = 1

    ans = 1

    for k in g_p:
        if k in g_m:
            ans *= (2 ** g_p[k] + 2 ** g_m[k] - 1)
        else:
            ans *= 2 ** g_p[k]
        ans %= mod
    for k in g_m:
        if not (k in g_p):
            ans *= 2 ** g_m[k]
            ans %= mod
    print((ans + zz - 1) % mod)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, m, k = map(int, input().split())
    dp = [0] * (k + 1)

    dp[0] = m

    for i in range(1, n):
        tmp_dp = [0] * (k + 1)
        for j in range(k + 1):
            tmp_dp[j] = (m - 1) * dp[j]
            if j > 0:
                tmp_dp[j] += dp[j - 1]
            tmp_dp[j] %= 998244353
        dp = tmp_dp

    ans = 0
    for i in range(k + 1):
        ans += dp[i]
    print(ans % 998244353)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Fixed submission:
from sys import stdin, setrecursionlimit


def initialize_cmb(m, mod):
    fac = [0] * m
    finv = [0] * m
    inv = [0] * m
    fac[0] = 1
    finv[0] = 1
    if m > 1:
        fac[1] = 1
        finv[1] = 1
        inv[1] = 1
        for i in range(2, m):
            fac[i] = fac[i-1] * i % mod
            inv[i] = mod - inv[mod % i] * (mod // i) % mod
            finv[i] = finv[i - 1] * inv[i] % mod
    return fac, finv


def cmb(n, k, mod, fac, finv):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


def main():
    input = stdin.buffer.readline
    n, m, k = map(int, input().split())
    mod = 998244353

    fac, finv = initialize_cmb(n + 10, mod)

    c = [0] * (n + 1)
    c[0] = m
    for i in range(n):
        c[i + 1] = c[i] * (m - 1) % mod

    ans = c[n - 1]

    for i in range(k):
        ans += c[n - i - 2] * cmb(n - 1, i + 1, mod, fac, finv)
        ans %= mod

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    d = [0] * n
    ans = 0
    for i in range(n):
        ai = a[i]
        l, r = i + ai, i - ai
        if 0 <= l < n:
            d[l] += 1
        if 0 <= r < n:
            ans += d[r]
        print(d)
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    d = [0] * n
    ans = 0
    for i in range(n):
        ai = a[i]
        l, r = i + ai, i - ai
        if 0 <= l < n:
            d[l] += 1
        if 0 <= r < n:
            ans += d[r]
    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    a, b, n = map(int, input().split())

    ans = 0

    for x in range(min(b, n + 1)):
        ans = max(int(a * x / b) - a * int(x / b), ans)

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Fixed submission:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    a, b, n = map(int, input().split())

    ans = 0

    x = min(b - 1, n)
    ans = max(int(a * x / b) - a * int(x / b), ans)

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()