Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, X, Y = map(int, input().split())

dis = []
for i in range(1, N):
    for j in range(i + 1, N + 1):
        d = min(abs(i - j),
                abs(i - X) + 1 + abs(j - Y),
                abs(i - Y) + 1 + abs(j - X))
        dis.append(d)

for k in range(1, N):
    print(dis.count(k))

Fixed submission:
N, X, Y = map(int, input().split())

dis = [0 for _ in range(N)]
for i in range(1, N):
    for j in range(i + 1, N + 1):
        d = min(abs(i - j),
                abs(i - X) + 1 + abs(j - Y),
                abs(i - Y) + 1 + abs(j - X))
        dis[d] += 1

for k in range(1, N):
    print(dis[k])

Buggy python submission (verdict: Time Limit Exceeded):
N, X, Y = map(int, input().split())

dis = []

for i in range(1, N):
    for j in range(i + 1, N + 1):
        d1 = abs(i - j)
        d2 = abs(i - X) + 1 + abs(j - Y)
        d3 = abs(i - Y) + 1 + abs(j - X)
        d = min(d1, d2, d3)

        dis.append(d)

for k in range(1, N):
    print(dis.count(k))

Fixed submission:
N, X, Y = map(int, input().split())

dis = [0 for _ in range(N)]
for i in range(1, N):
    for j in range(i + 1, N + 1):
        d = min(abs(i - j),
                abs(i - X) + 1 + abs(j - Y),
                abs(i - Y) + 1 + abs(j - X))
        dis[d] += 1

for k in range(1, N):
    print(dis[k])

Buggy python submission (verdict: Time Limit Exceeded):
N, X, Y = map(int, input().split())

dis = dict(zip(range(1, N), [0 for _ in range(1, N)]))

for i in range(1, N):
    for j in range(i + 1, N + 1):
        d1 = abs(i - j)
        d2 = abs(i - X) + 1 + abs(j - Y)
        d3 = abs(i - Y) + 1 + abs(j - X)
        d = min(d1, d2, d3)

        dis[d] += 1

for k in range(1, N):
    print(dis[k])

Fixed submission:
N, X, Y = map(int, input().split())

dis = [0 for _ in range(N)]
for i in range(1, N):
    for j in range(i + 1, N + 1):
        d = min(abs(i - j),
                abs(i - X) + 1 + abs(j - Y),
                abs(i - Y) + 1 + abs(j - X))
        dis[d] += 1

for k in range(1, N):
    print(dis[k])

Buggy python submission (verdict: Time Limit Exceeded):
N, X, Y = map(int, input().split())

dis = {}
for k in range(1, N):
    dis[k] = 0

for i in range(1, N):
    for j in range(i + 1, N + 1):
        d1 = abs(i - j)
        d2 = abs(i - X) + 1 + abs(j - Y)
        d3 = abs(i - Y) + 1 + abs(j - X)
        d = min(d1, d2, d3)

        dis[d] += 1

for k in range(1, N):
    print(dis[k])


Fixed submission:
N, X, Y = map(int, input().split())

dis = [0 for _ in range(N)]
for i in range(1, N):
    for j in range(i + 1, N + 1):
        d = min(abs(i - j),
                abs(i - X) + 1 + abs(j - Y),
                abs(i - Y) + 1 + abs(j - X))
        dis[d] += 1

for k in range(1, N):
    print(dis[k])
Buggy python submission (verdict: Runtime Error):
X, Y, A, B, C = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)

Red = p[:X]
Green = q[:Y]

Apple = sorted(Red + Green)
for i in range(C):
    print(Apple[i], r[i])
    if Apple[i] < r[i]:
        Apple[i] = r[i]
print(sum(Apple))

Fixed submission:
import heapq

X, Y, A, B, C = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = list(map(int, input().split()))

Red = p[:X]
Green = q[:Y]

h = sorted(Red + Green)
heapq.heapify(h)
for i in r:
    heapq.heappushpop(h, i)
print(sum(h))
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
query = []
for i in range(Q):
    query.append(list(map(str, input().split())))


def start(S, x, flg):
    if flg == True:
        S = x + S
    else:
        S = S + x
    return S


def end(S, x, flg):
    if flg == True:
        S = S + x
    else:
        S = x + S
    return S


flg = True
for q in query:
    if len(q) == 1:
        flg = not flg
    else:
        if int(q[1]) == 1:
            S = start(S, q[2], flg)
        else:
            S = end(S, q[2], flg)
else:
    if flg == True:
        print(S)
    else:
        print(S[::-1])

Fixed submission:
S = input()
Q = int(input())
query = []
for i in range(Q):
    query.append(list(map(str, input().split())))


def start(S, x):
    S = x + S
    return S


def end(S, x):
    S = S + x
    return S


front = ''
back = ''
flg = True
for q in query:
    if len(q) == 1:
        flg = not flg
    else:
        if flg == True:
            if q[1] == '1':
                front = start(front, q[2])
            else:
                back = end(back, q[2])
        else:
            if q[1] == '1':
                back = end(back, q[2])
            else:
                front = start(front, q[2])
else:
    if flg == True:
        print(front + S + back)
    else:
        print(back[::-1] + S[::-1] + front[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
query = []
for i in range(Q):
    query.append(list(map(str, input().split())))

for q in query:
    if len(q) == 1:
        S = S[::-1]
    else:
        if int(q[1]) == 1:
            S = q[2] + S
        else:
            S = S + q[2]
print(S)

Fixed submission:
S = input()
Q = int(input())
query = []
for i in range(Q):
    query.append(list(map(str, input().split())))


def start(S, x):
    S = x + S
    return S


def end(S, x):
    S = S + x
    return S


front = ''
back = ''
flg = True
for q in query:
    if len(q) == 1:
        flg = not flg
    else:
        if flg == True:
            if q[1] == '1':
                front = start(front, q[2])
            else:
                back = end(back, q[2])
        else:
            if q[1] == '1':
                back = end(back, q[2])
            else:
                front = start(front, q[2])
else:
    if flg == True:
        print(front + S + back)
    else:
        print(back[::-1] + S[::-1] + front[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())
A = [0] * Q
for i in range(Q):
    A[i] = int(input())

for i in range(N):
    if K - Q + A.count(i + 1) > 0:
        print("Yes")
    else:
        print("No")

Fixed submission:
import collections

N, K, Q = map(int, input().split())
A = [0] * N
for i in range(Q):
    A[int(input()) - 1] += 1

for i in range(N):
    if K - Q + A[i] > 0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
cnt = 0
N = int(input())
s = [0] * N
for i in range(N):
    s[i] = str(sorted(input()))

cnt = 0
for i in set(s):
    n = s.count(i)
    cnt += n * (n - 1) // 2
print(cnt)

Fixed submission:
import collections

N = int(input())
s = [0] * N
for i in range(N):
    s[i] = sorted(input())
    s[i] = " ".join(s[i])

cnt = 0
for i in collections.Counter(s).values():
    cnt += i * (i - 1) // 2
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import collections

N = int(input())
s = [0] * N
for i in range(N):
    s[i] = input()

c = [0] * N
for i in range(N):
    c[i] = collections.Counter(s[i])

cnt = 0
for i in range(N):
    for j in range(i + 1, N):
        if c[i] == c[j]:
            cnt += 1
print(cnt)

Fixed submission:
import collections

N = int(input())
s = [0] * N
for i in range(N):
    s[i] = sorted(input())
    s[i] = " ".join(s[i])

cnt = 0
for i in collections.Counter(s).values():
    cnt += i * (i - 1) // 2
print(cnt)
Buggy python submission (verdict: Runtime Error):
mport math

N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]

cnt = 0
for i in range(N):
    for j in range(i + 1, N):
        dis = 0
        for d in range(D):
            dis += (X[i][d] - X[j][d])**2
        if math.sqrt(dis) == int(math.sqrt(dis)):
            cnt += 1

print(cnt)

Fixed submission:
import math

N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]

cnt = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        dis = 0
        for d in range(D):
            dis += (X[i][d] - X[j][d])**2
        if math.sqrt(dis) == int(math.sqrt(dis)):
            cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
L, R = map(int, input().split())
mod = 2019

lmod = L % mod
rmod = R % mod

if lmod <= rmod:
    list_ij = sorted(list(range(lmod, rmod + 1)))
    print(list_ij[0] * list_ij[1])
else:
    list_ij = sorted(list(range(lmod, rmod + 1)))
    print(list_ij[0] * list_ij[1])

Fixed submission:
L, R = map(int, input().split())
mod = 2019

if R - L >= 2018:
    print(0)
elif R - L == 1:
    print(((L % mod) * (R % mod)) % mod)
else:
    m = 2019
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            m = min(m, ((i % mod) * (j % mod)) % mod)
    print(m)

Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())
mod = 2019

m = 2019
for i in range(L, R):
    for j in range(i + 1, R + 1):
        m = min(m, ((i % mod) * (j % mod)) % mod)

print(m)

Fixed submission:
L, R = map(int, input().split())
mod = 2019

if R - L >= 2018:
    print(0)
elif R - L == 1:
    print(((L % mod) * (R % mod)) % mod)
else:
    m = 2019
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            m = min(m, ((i % mod) * (j % mod)) % mod)
    print(m)
Buggy python submission (verdict: Runtime Error):
from scipy.special import perm, comb
N, K = map(int, input().split())
mod = 10**9 + 7

Atable = [0] * (K + 1)
for i in range(1, K + 1):
    Atable[i] = comb(K - 1, i - 1)
Btable = [0] * (K + 1)
for i in range(1, K + 1):
    Btable[i] = comb(N - K + 1, i)

for i in range(1, K + 1):
    print(int(((Atable[i] % mod) * (Btable[i] % mod)) % mod))

Fixed submission:
N, K = map(int, input().split())
mod = 10**9 + 7

factorial = [1]
inverse = [1]

for i in range(1, N + 2):
    factorial.append(factorial[i - 1] * i % mod)
    inverse.append(pow(factorial[i], mod - 2, mod))


def C(n, r):
    if n < r:
        return 0
    return (factorial[n] * inverse[r] * inverse[n - r]) % mod


Atable = [0] * (K + 1)
for i in range(1, K + 1):
    Atable[i] = C(K - 1, i - 1)
Btable = [0] * (K + 1)
for i in range(1, K + 1):
    Btable[i] = C(N - K + 1, i)

for i in range(1, K + 1):
    print(int(((Atable[i] % mod) * (Btable[i] % mod)) % mod))

Buggy python submission (verdict: Runtime Error):
from scipy.special import perm, comb
N, K = map(int, input().split())
mod = 10**9 + 7

for i in range(1, K + 1):
    print(int(((comb(K - 1, i - 1) % mod) * (comb(N - K + 1, i) % mod)) % mod))

Fixed submission:
N, K = map(int, input().split())
mod = 10**9 + 7

factorial = [1]
inverse = [1]

for i in range(1, N + 2):
    factorial.append(factorial[i - 1] * i % mod)
    inverse.append(pow(factorial[i], mod - 2, mod))


def C(n, r):
    if n < r:
        return 0
    return (factorial[n] * inverse[r] * inverse[n - r]) % mod


Atable = [0] * (K + 1)
for i in range(1, K + 1):
    Atable[i] = C(K - 1, i - 1)
Btable = [0] * (K + 1)
for i in range(1, K + 1):
    Btable[i] = C(N - K + 1, i)

for i in range(1, K + 1):
    print(int(((Atable[i] % mod) * (Btable[i] % mod)) % mod))

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
mod = 10**9 + 7

for i in range(1, K + 1):
    print(int(((comb(K - 1, i - 1) % mod) * (comb(N - K + 1, i) % mod)) % mod))

Fixed submission:
N, K = map(int, input().split())
mod = 10**9 + 7

factorial = [1]
inverse = [1]

for i in range(1, N + 2):
    factorial.append(factorial[i - 1] * i % mod)
    inverse.append(pow(factorial[i], mod - 2, mod))


def C(n, r):
    if n < r:
        return 0
    return (factorial[n] * inverse[r] * inverse[n - r]) % mod


Atable = [0] * (K + 1)
for i in range(1, K + 1):
    Atable[i] = C(K - 1, i - 1)
Btable = [0] * (K + 1)
for i in range(1, K + 1):
    Btable[i] = C(N - K + 1, i)

for i in range(1, K + 1):
    print(int(((Atable[i] % mod) * (Btable[i] % mod)) % mod))
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
L = [0 for _ in range(M)]
R = [0 for _ in range(M)]
for i in range(M):
    L[i], R[i] = map(int, input().split())

cards = range(N + 1)
u = set(cards[L[0]:R[0] + 1])
for i in range(1, M):
    u = u & set(cards[L[i]:R[i] + 1])
print(len(u))

Fixed submission:
N, M = map(int, input().split())
L = [0 for _ in range(M)]
R = [0 for _ in range(M)]
for i in range(M):
    L[i], R[i] = map(int, input().split())

l = max(L)
r = min(R)
print(r - l + 1 if l <= r else 0)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
L = []
R = []
for i in range(M):
    x, y = [int(i) for i in input().split()]
    L.append(x)
    R.append(y)

id = []
for i in range(M):
    id += [L[i:] + R[:i + 1]]
com = set(id[0])
for j in range(1, M):
    com = com & set(id[j])
com_max = max(com)
com_min = min(com)
print(com_max - com_min + 1)


Fixed submission:
N, M = map(int, input().split())
L = [0 for _ in range(M)]
R = [0 for _ in range(M)]
for i in range(M):
    L[i], R[i] = map(int, input().split())

l = max(L)
r = min(R)
print(r - l + 1 if l <= r else 0)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
L = []
R = []
for i in range(M):
    x, y = [int(i) for i in input().split()]
    L.append(x)
    R.append(y)
id = []
for i in range(M):
    id += [L[i:] + R[:i + 1]]
com = set(id[0]) & set(id[1])
for j in range(1, M):
    com = com & set(id[j])
print(len(com))

Fixed submission:
N, M = map(int, input().split())
L = [0 for _ in range(M)]
R = [0 for _ in range(M)]
for i in range(M):
    L[i], R[i] = map(int, input().split())

l = max(L)
r = min(R)
print(r - l + 1 if l <= r else 0)
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())

if S[0] == "1":
    print(S[1])
else:
    print(S[0])

Fixed submission:
S = input()
K = int(input())

ans = 1
for i in range(K):
    if S[i] != "1":
        ans = int(S[i])
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
print(2 * N // math.gcd(2, N))

Fixed submission:
N = int(input())
print(N if N % 2 == 0 else 2 * N)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np

N = int(input())
A = np.array(input().split(), np.int64)
A_cum = [0] + np.cumsum(A)

ans = 10**10
l = 0
r = 2
for i in range(1, N - 1):
    while A[l] < A[i] - A[l + 1]:
        l += 1
    while A[r] - A[i] < A[-1] - A[r + 1]:
        r += 1
    P = A[l]
    Q = A[i] - A[l]
    R = A[r] - A[i]
    S = A[-1] - A[r]
    tmp = max(P, Q, R, S) - min(P, Q, R, S)
    ans = min(ans, tmp)
print(ans)


Fixed submission:
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
S = [0]
for a in A:
    S += [S[-1] + a]

ans = float("inf")
l = 0
r = 2
for i in range(1, N - 1):
    while S[l] < S[i] - S[l + 1]:
        l += 1
    while S[r] - S[i] < S[N] - S[r + 1]:
        r += 1

    a = S[l]
    b = S[i] - S[l]
    c = S[r] - S[i]
    d = S[N] - S[r]

    ans = min(ans, max(a, b, c, d) - min(a, b, c, d))
print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))

c = [0] * N
for i in range(N):
    c[i] = A.count(i + 1)
c = sorted(c)

n = len(c)
if n - K > 0:
    cnt = sum(c[:n - K])
print(cnt)

Fixed submission:
import collections

N, K = map(int, input().split())
A = list(map(int, input().split()))

c = collections.Counter(A)
n = len(c)
c_sorted = sorted(c.values())
cnt = 0
for i in range(max(0, n - K)):
    cnt += c_sorted[i]
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import collections

N, K = map(int, input().split())
A = list(map(int, input().split()))

c = collections.Counter(A)
n = len(c)

cnt = 0
if n - K > 0:
    for i in range(n - K):
        cnt += c.most_common()[::-1][i][1]
print(cnt)

Fixed submission:
import collections

N, K = map(int, input().split())
A = list(map(int, input().split()))

c = collections.Counter(A)
n = len(c)
c_sorted = sorted(c.values())
cnt = 0
for i in range(max(0, n - K)):
    cnt += c_sorted[i]
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())


def Lucas(n):
    if n == 0:
        return 2
    elif n == 1:
        return 1
    return Lucas(n - 2) + Lucas(n - 1)


print(Lucas(N))

Fixed submission:
N = int(input())
L = [2, 1]
for i in range(2, N + 1):
    L.append(L[-2] + L[-1])
print(L[-1])
Buggy python submission (verdict: Runtime Error):
R, G = map(int, input().split())

print(2 * G - R)

Fixed submission:
R = int(input())
G = int(input())

print(2 * G - R)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list([int(input()) for _ in range(N)])

p = []
for a in A:
    if a in set(p):
        p.remove(a)
    else:
        p.append(a)

print(len(p))

Fixed submission:
import collections

N = int(input())
A = [int(input()) for _ in range(N)]
A = collections.Counter(A)

cnt = 0
for key, value in A.items():
    if value % 2 == 0:
        pass
    else:
        cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
p = list(map(int, input().split()))
p.insert(0, -1)

j = [0] * N
for i in range(1, N + 1):
    if p[i] == i and j[i - 1] == 0:
        j[i] = 1
print(sum(j))

Fixed submission:
N = int(input())
p = list(map(int, input().split()))
p.insert(0, -1)

j = [0] * (N + 1)
for i in range(1, N + 1):
    if p[i] == i and j[i - 1] == 0:
        j[i] = 1
print(sum(j))
Buggy python submission (verdict: Runtime Error):
import math
from fractions import gcd
from functools import reduce

N = int(input())
T = [int(input()) for i in range(N)]


def gcd(numbers):  # "numbers" is list
    return reduce(gcd, numbers, 1)


def lcm_base(x, y):
    return (x * y) // gcd(x, y)


def lcm(numbers):  # "numbers" is list
    return reduce(lcm_base, numbers,
                  1)  # [third argument] return 1 if "numbers" is empty


print(lcm(T))

Fixed submission:
import math
from functools import reduce

N = int(input())
T = [int(input()) for i in range(N)]

# def gcd(numbers):  # "numbers" is list
#     return reduce(math.gcd, numbers)

# def lcm_base(x, y):
#     return (x * y) // math.gcd(x, y)


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


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


def lcm(numbers):  # "numbers" is list
    return reduce(lcm_base, numbers,
                  1)  # [third argument] return 1 if "numbers" is empty


print(lcm(T))

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

N = int(input())
T = [int(input()) for i in range(N)]


def gcd(numbers):  # "numbers" is list
    return reduce(math.gcd, numbers,1)


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm(numbers):  # "numbers" is list
    return reduce(lcm_base, numbers,
                  1)  # [third argument] return 1 if "numbers" is empty


print(lcm(T))

Fixed submission:
import math
from functools import reduce

N = int(input())
T = [int(input()) for i in range(N)]

# def gcd(numbers):  # "numbers" is list
#     return reduce(math.gcd, numbers)

# def lcm_base(x, y):
#     return (x * y) // math.gcd(x, y)


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


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


def lcm(numbers):  # "numbers" is list
    return reduce(lcm_base, numbers,
                  1)  # [third argument] return 1 if "numbers" is empty


print(lcm(T))

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

N = int(input())
T = [int(input()) for i in range(N)]


def gcd(numbers):  # "numbers" is list
    return reduce(math.gcd, numbers)


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm(numbers):  # "numbers" is list
    return reduce(lcm_base, numbers,
                  1)  # [third argument] return 1 if "numbers" is empty


print(lcm(T))

Fixed submission:
import math
from functools import reduce

N = int(input())
T = [int(input()) for i in range(N)]

# def gcd(numbers):  # "numbers" is list
#     return reduce(math.gcd, numbers)

# def lcm_base(x, y):
#     return (x * y) // math.gcd(x, y)


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


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


def lcm(numbers):  # "numbers" is list
    return reduce(lcm_base, numbers,
                  1)  # [third argument] return 1 if "numbers" is empty


print(lcm(T))
Buggy python submission (verdict: Runtime Error):
L = []
for _ in range(M):
    L.append(list(map(int, input().split())))

first = []
second = []
for a, b in L:
    if a == 1:
        first.append(b)
    if b == N:
        second.append(a)
print('POSSIBLE' if set(first) & set(second) else 'IMPOSSIBLE')


Fixed submission:
N, M = map(int, input().split())
L = []
for _ in range(M):
    L.append(list(map(int, input().split())))

first = []
second = []
for a, b in L:
    if a == 1:
        first.append(b)
    if b == N:
        second.append(a)
flg = len(set(first) & set(second))
print('POSSIBLE' if flg else 'IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = float('inf')
for i in range(1, N):
    ans = min(ans, abs(sum(A[:i]) - sum(A[i:])))
print(ans)


Fixed submission:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
sum_A = np.sum(A)
cumsum_A = np.cumsum(A)

ans = float('inf')
for i in range(N - 1):
    ans = min(ans, abs(sum_A - 2 * cumsum_A[i]))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
power = 1
for _ in range(1, N + 1):
    power *= _

print(power % (10**9 + 7))

Fixed submission:
N = int(input())
power = 1
for _ in range(1, N + 1):
    power *= _
    if power > 10**9 + 7:
        power %= (10**9 + 7)

print(power % (10**9 + 7))
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())

cnt = 0
for x in range(K + 1):
    for y in range(K + 1):
        for z in range(K + 1):
            if x + y + z == S:
                cnt += 1
print(cnt)

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

cnt = 0
for x in range(K + 1):
    for y in range(K + 1):
        if 0 <= S - x - y <= K:
            cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
a, b, c = str(input().split())
print(a[0], b[0], c[0])


Fixed submission:
[print(i[0], end="") for i in input().split()]
print()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

a, b, x = map(int, input().split())

cnt = 0
for _ in range(a, b + 1):
    if _ % x == 0:
        cnt += 1
print(cnt)

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

print(b // x - (a - 1) // x)

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

cnt = 0
for _ in range(a, b + 1):
    if _ % x == 0:
        cnt += 1
print(cnt)


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

print(b // x - (a - 1) // x)

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

cnt = [i for i in range(a, b + 1) if i % x == 0]
print(len(cnt))

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

print(b // x - (a - 1) // x)
Buggy python submission (verdict: Runtime Error):
N, T = map(int, input().split())
A = list(map(int, input().split()))

n = T // 2

d = -float("inf")
cnt = 1
l = 0
for r in range(1, N - 1):
    if A[l] < A[r]:
        if A[r] > A[r + 1]:
            if d == A[r] - A[l]:
                cnt += 1
            elif d < A[r] - A[l]:
                d = A[r] - A[l]
                cnt = 1
    else:
        l = r
        r += 1
else:
    if d == A[r] - A[l]:
        cnt += 1
    elif d < A[r] - A[l]:
        d = A[r] - A[l]
        cnt = 1
    print(cnt)

Fixed submission:
import numpy as np

N, T = map(int, input().split())
A = np.array(input().split(), dtype=np.int32)

# 自分より左にある最安値
A_cummin = np.minimum.accumulate(A)
# 差額
profit = A - A_cummin

ans = (profit == profit.max()).sum()
print(ans)