Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    MOD = 10 ** 9 + 7
    N, M = list(map(int, input().split(' ')))
    S = list(map(int, input().split(' ')))
    T = list(map(int, input().split(' ')))
    dp = [[0 for _ in range(M + 1)] for _ in range(N + 1)]
    sdp = [[0 for _ in range(M + 1)] for _ in range(N + 1)]
    for n, s in enumerate(S):
        for m, t in enumerate(T):
            sdp_val = sdp[n][m]
            new_dp_val = (sdp_val + 1) if s == t else 0
            dp[n + 1][m + 1] = new_dp_val % MOD
            sdp[n + 1][m + 1] = (sdp[n][m + 1] + sdp[n + 1][m] - sdp_val + new_dp_val) % MOD
    print((sdp[N][M] + 1) % MOD)  # 1: an empty sequence


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    MOD = 10 ** 9 + 7
    N, M = list(map(int, input().split(' ')))
    S = list(map(int, input().split(' ')))
    T = list(map(int, input().split(' ')))
    dp = [[0 for _ in range(M + 1)] for _ in range(N + 1)]
    sdp = [[0 for _ in range(M + 1)] for _ in range(N + 1)]
    for n, s in enumerate(S):
        for m, t in enumerate(T):
            sdp_val = sdp[n][m]
            new_dp_val = (sdp_val + 1) if s == t else 0
            dp[n + 1][m + 1] = new_dp_val % MOD
            sdp[n + 1][m + 1] = (sdp[n][m + 1] + sdp[n + 1][m] - sdp_val + new_dp_val) % MOD
    print((sdp[N][M] + 1) % MOD)  # 1: an empty sequence


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
INF = 10 ** 9


def calc(point_list, t):
    x_min, y_min, x_max, y_max = INF, INF, -INF, -INF
    for point in point_list:
        x, y, d = point
        dx = t if d == 'R' else (-t if d == 'L' else 0)
        dy = t if d == 'U' else (-t if d == 'D' else 0)
        x_min = min(x_min, x + dx)
        x_max = max(x_max, x + dx)
        y_min = min(y_min, y + dy)
        y_max = max(y_max, y + dy)
    return (x_max - x_min) * (y_max - y_min)


def main():
    N = int(input())
    point_list = list()
    x_min, y_min, x_max, y_max = INF, INF, -INF, -INF
    for _ in range(N):
        X, Y, D = input().split()
        X = int(X)
        x_min = min(x_min, X)
        x_max = max(x_max, X)
        Y = int(Y)
        y_min = min(y_min, Y)
        y_max = max(y_max, Y)
        point_list.append((X, Y, D))
    t_left, t_right = 0, max(x_max - x_min, y_max - y_max)
    while t_right - t_left > 10 ** (-8):
        t_in_left, t_in_right = (2 * t_left + t_right) / 3, (t_left + 2 * t_right) / 3
        if calc(point_list, t_in_left) < calc(point_list, t_in_right):
            t_right = t_in_right
        else:
            t_left = t_in_left
    print(calc(point_list, (t_in_left + t_in_right) / 2))


if __name__ == '__main__':
    main()

Fixed submission:
INF = 10**18


def calc(point_list, t):
    x_min, y_min, x_max, y_max = INF, INF, -INF, -INF
    for point in point_list:
        x, y, d = point
        dx = t if d == 'R' else (-t if d == 'L' else 0)
        dy = t if d == 'U' else (-t if d == 'D' else 0)
        x_min = min(x_min, x + dx)
        x_max = max(x_max, x + dx)
        y_min = min(y_min, y + dy)
        y_max = max(y_max, y + dy)
    return (x_max - x_min) * (y_max - y_min)


def main():
    N = int(input())
    point_list = list()
    x_min, y_min, x_max, y_max = INF, INF, -INF, -INF
    for _ in range(N):
        X, Y, D = input().split()
        X = int(X)
        x_min = min(x_min, X)
        x_max = max(x_max, X)
        Y = int(Y)
        y_min = min(y_min, Y)
        y_max = max(y_max, Y)
        point_list.append((X, Y, D))
    if N == 1:
        print(0)
        return
    t_left, t_right = 0, 2 * max(x_max - x_min, y_max - y_min)
    v_left, v_right = calc(point_list, t_left), calc(point_list, t_right)
    while True:
        dt = t_right - t_left
        if dt < 10 ** (-8):
            break
        t_in_left, t_in_right = t_left + dt / 3, t_right - dt / 3
        v_in_left, v_in_right = calc(point_list, t_in_left), calc(point_list, t_in_right)
        if v_in_left < v_in_right:
            t_right = t_in_right
            v_right = v_in_right
        else:
            t_left = t_in_left
            v_left = v_in_left
    print(v_left)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import heapq


def main():
    N, M = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    heapq.heapify(A)
    for _ in range(M):
        B, C = list(map(int, input().split(' ')))
        for _ in range(B):
            heapq.heappushpop(A, C)
    print(sum(A))


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N, M = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    updates = list()
    for _ in range(M):
        B, C = list(map(int, input().split(' ')))
        updates.append((B, C))
    updates.sort(key=lambda x: x[1], reverse=True)
    for B, C in updates:
        A.extend([C] * B)
        if len(A) > 2 * N:
            break
    A.sort(reverse=True)
    print(sum(A[:N]))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import itertools


def main():
    X, Y, Z, K = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    B = list(map(int, input().split(' ')))
    C = list(map(int, input().split(' ')))
    AB = list(map(sum, itertools.product(A, B)))
    AB.sort(reverse=True)
    AB = AB[:min([K, X * Y])]
    ABC = list(map(sum, itertools.product(AB, C)))
    ABC.sort(reverse=True)
    for ans in ABC[:K]:
        print(ans)


if __name__ == '__main__':
    main()

Fixed submission:
import numpy as np


def main():
    X, Y, Z, K = list(map(int, input().split(' ')))
    A = np.array(list(map(int, input().split(' '))))
    B = np.array(list(map(int, input().split(' '))))
    C = np.array(list(map(int, input().split(' '))))
    AB = np.array(np.meshgrid(A, B)).T.reshape(-1, 2).sum(axis=1)
    AB[::-1].sort()
    AB = AB[:min([K, X * Y])]
    ABC = np.array(np.meshgrid(AB, C)).T.reshape(-1, 2).sum(axis=1)
    ABC[::-1].sort()
    for ans in ABC[:K]:
        print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, K = list(map(int, input().split(' ')))
    H = list(map(int, input().split(' ')))
    dp = [0 for _ in range(N)]
    for i in range(1, N):
        dp[i] = abs(H[i] - H[i - 1]) + dp[i - 1]
        for d in range(2, K + 1):
            if i - d < 0:
                break
            dp[i] = min([
                dp[i],
                abs(H[i] - H[i - d]) + dp[i - d]
            ])
    print(dp[N - 1])


if __name__ == '__main__':
    main()


Fixed submission:
import numpy as np


def main():
    N, K = list(map(int, input().split(' ')))
    H = np.array(list(map(int, input().split(' '))))
    dp = np.full(N, 10 ** 10)
    dp[0] = 0
    for i in range(1, N):
        dp[i:(i + K)] = np.fmin(dp[i:(i + K)], dp[i - 1] + np.abs(H[i:(i + K)] - H[i - 1]))
    print(int(dp[N - 1]))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, W = list(map(int, input().split(' ')))
    items = [list(map(int, input().split(' '))) for _ in range(N)]
    dp = [[0 for _ in range(W + 1)] for _ in range(N)]
    for w in range(items[0][0], W + 1):
        dp[0][w] = items[0][1]
    for n in range(1, N):
        weight, value = items[n]
        for w in range(W + 1):
            if w - weight >= 0:
                dp[n][w] = max([dp[n - 1][w], value + dp[n - 1][w - weight]])
            else:
                dp[n][w] = dp[n - 1][w]
    print(dp[N - 1][W])


if __name__ == '__main__':
    main()

Fixed submission:
import numpy as np


def main():
    N, W = list(map(int, input().split(' ')))
    items = np.array([list(map(int, input().split(' '))) for _ in range(N)])
    dp = np.zeros((N, W + 1))
    dp[0, items[0, 0]:] = items[0, 1]
    for n in range(1, N):
        weight, value = items[n, 0], items[n, 1]
        dp[n, :] = dp[n - 1, :]
        dp[n, weight:] = np.fmax(
            dp[n, weight:],
            value + dp[n - 1, :(- weight)]
        )
    print(int(dp[N - 1, W]))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque


def main():
    S = input()
    LS = len(S)
    T = input()
    LT = len(T)
    # LCS
    dp = [[0 for _ in range(LT + 1)] for _ in range(LS + 1)]
    for s in range(LS):
        for t in range(LT):
            if S[s] == T[t]:
                dp[s + 1][t + 1] = 1 + dp[s][t]
            else:
                dp[s + 1][t + 1] = max([dp[s][t + 1], dp[s + 1][t]])
    # recover
    s, t = LS, LT
    que = deque()
    que.appendleft('')
    while s > 0 and t > 0:
        if dp[s][t] == dp[s - 1][t]:
            s -= 1
        elif dp[s][t] == dp[s][t - 1]:
            t -= 1
        else:
            que.appendleft(S[s - 1])
            s -= 1
            t -= 1
    print(''.join(list(que)))


if __name__ == '__main__':
    main()

Fixed submission:
import numpy as np


def main():
    S = np.array(list(input()))
    LS = len(S)
    T = np.array(list(input()))
    LT = len(T)
    # LCS
    dp = np.zeros((LS + 1, LT + 1))
    match = S.reshape(-1, 1) == T.reshape(1, -1)
    for s in range(LS):
        dp[s + 1, 1:] = np.fmax(dp[s, :(-1)] + match[s], dp[s, 1:])
        dp[s + 1] = np.maximum.accumulate(dp[s + 1])
    # recover
    s, t = LS, LT
    ans = ''
    while s > 0 and t > 0:
        if dp[s, t] == dp[s - 1, t]:
            s -= 1
        elif dp[s, t] == dp[s, t - 1]:
            t -= 1
        else:
            ans = S[s - 1] + ans
            s -= 1
            t -= 1
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict


def main():
    N, M = list(map(int, input().split(' ')))
    adj_nodes = defaultdict(list)
    for _ in range(M):
        x, y = list(map(int, input().split(' ')))
        x -= 1
        y -= 1
        adj_nodes[x].append(y)
    dp = [-1 for _ in range(N)]

    def rec(v):
        if dp[v] >= 0:
            return dp[v]
        ret = 0
        for nv in adj_nodes[v]:
            ret = max([ret, rec(nv) + 1])
        dp[v] = ret
        return ret

    ans = 0
    for v in range(N):
        ans = max([ans, rec(v)])
    print(ans)


if __name__ == '__main__':
    main()

Fixed submission:
from collections import defaultdict
import sys

sys.setrecursionlimit(100000)


def main():
    N, M = list(map(int, input().split(' ')))
    adj_nodes = defaultdict(list)
    for _ in range(M):
        x, y = list(map(int, input().split(' ')))
        x -= 1
        y -= 1
        adj_nodes[x].append(y)
    dp = [-1 for _ in range(N)]

    def rec(v):
        if dp[v] >= 0:
            return dp[v]
        ret = 0
        for nv in adj_nodes[v]:
            ret = max([ret, rec(nv) + 1])
        dp[v] = ret
        return ret

    ans = 0
    for v in range(N):
        ans = max([ans, rec(v)])
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    assert N % 2 == 1
    M = (N + 1) // 2
    P = list(map(float, input().split(' ')))
    dp = [[0 for _ in range(M + 1)] for _ in range(N)]
    dp[0][0] = 1 - P[0]
    dp[0][1] = P[0]
    for n in range(1, N):
        p = P[n]
        for m in range(M + 1):
            if m == M:
                dp[n][m] = dp[n - 1][m] + dp[n - 1][m - 1] * p
            elif m >= 1:
                dp[n][m] = dp[n - 1][m] * (1 - p) + dp[n - 1][m - 1] * p
            else:
                # m == 0
                dp[n][m] = dp[n - 1][m] * (1 - p)
    print(dp[-1][-1])


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    assert N % 2 == 1
    M = (N + 1) // 2
    P = list(map(float, input().split(' ')))
    dp = [[0 for _ in range(M + 1)] for _ in range(N)]
    dp[0][0] = 1 - P[0]
    dp[0][1] = P[0]
    for n in range(1, N):
        p = P[n]
        for m in range(min([n + 1, M]) + 1):
            if 1 <= m < M:
                dp[n][m] = dp[n - 1][m] * (1 - p) + dp[n - 1][m - 1] * p
            elif m == M:
                dp[n][m] = dp[n - 1][m] + dp[n - 1][m - 1] * p
            else:
                # m == 0
                dp[n][m] = dp[n - 1][m] * (1 - p)
    print(dp[-1][-1])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    MOD = 10 ** 9 + 7
    N, K = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    dp = [[0 for _ in range(K + 1)] for _ in range(N + 1)]
    for n in range(N + 1):
        dp[n][0] = 1
    for n in range(1, N + 1):
        dp_left = dp[n][0]  # dp[n][k - 1]
        for k in range(1, K + 1):
            val = dp_left + dp[n - 1][k]
            kk = k - A[n - 1] - 1
            if kk >= 0:
                val -= dp[n - 1][kk]
            val %= MOD
            dp[n][k] = val
            dp_left = val
    print(dp[N][K])


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    MOD = 10 ** 9 + 7
    N, K = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    dp = [[0 for _ in range(K + 1)] for _ in range(N + 1)]
    for n in range(N + 1):
        dp[n][0] = 1
    for n in range(1, N + 1):
        dp_left = dp[n][0]  # dp[n][k - 1]
        for k in range(1, K + 1):
            val = dp_left + dp[n - 1][k]
            kk = k - A[n - 1] - 1
            if kk >= 0:
                val -= dp[n - 1][kk]
            val %= MOD
            dp[n][k] = val
            dp_left = val
    print(dp[N][K])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    INF = 10 ** 12
    N = int(input())
    A = list(map(int, input().split(' ')))
    cumsum = [0 for _ in range(N)]
    cumsum[0] = A[0]
    for i in range(1, N):
        cumsum[i] = A[i] + cumsum[i - 1]
    dp = [[0 for _ in range(N)] for _ in range(N)]

    def solve(left, right):
        if left == right:
            return 0
        ret = dp[left][right]
        if ret > 0:
            return ret
        ret = INF
        for mid in range(left, right):
            ret = min([
                ret,
                solve(left, mid) + solve(mid + 1, right)
            ])
        ret += cumsum[right] - (cumsum[left - 1] if left > 0 else 0)
        dp[left][right] = ret
        return ret

    print(solve(0, N - 1))


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    INF = 10 ** 15
    N = int(input())
    A = list(map(int, input().split(' ')))
    cumsum = [0 for _ in range(N)]
    cumsum[0] = A[0]
    for i in range(1, N):
        cumsum[i] = A[i] + cumsum[i - 1]
    dp = [[0 for _ in range(N)] for _ in range(N)]

    def solve(left, right):
        if left == right:
            return 0
        ret = dp[left][right]
        if ret > 0:
            return ret
        ret = INF
        for mid in range(left, right):
            ret = min([
                ret,
                solve(left, mid) + solve(mid + 1, right)
            ])
        ret += cumsum[right] - (cumsum[left - 1] if left > 0 else 0)
        dp[left][right] = ret
        return ret

    print(solve(0, N - 1))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    MOD = 10 ** 9 + 7
    N = int(input())
    A = [list(map(int, input().split(' '))) for _ in range(N)]
    dp = [0 for _ in range(1 << N)]
    dp[0] = 1
    for s in range(1, 1 << N):
        man = sum(map(int, '{:b}'.format(s))) - 1  # count bits
        val = 0
        for woman in range(len('{:b}'.format(s))):
            if (s >> woman) & 1 == 0:
                continue
            if A[man][woman] == 1:
                val += dp[s - (1 << woman)]
                val %= MOD
        dp[s] += val
    print(dp[(1 << N) - 1])


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    MOD = 10 ** 9 + 7
    N = int(input())
    A = [list(map(int, input().split(' '))) for _ in range(N)]
    dp = [0 for _ in range(1 << N)]
    dp[0] = 1
    for s in range(1, 1 << N):
        women_list = [w for w in range(N) if (s >> w) & 1 == 1]
        man = len(women_list) - 1
        val = 0
        for woman in women_list:
            val += A[man][woman] * dp[s - (1 << woman)]
        val %= MOD
        dp[s] += val
    print(dp[(1 << N) - 1])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict


def main():
    MOD = 10 ** 9 + 7
    N = int(input())
    adj_nodes = defaultdict(list)
    for _ in range(N - 1):
        x, y = list(map(int, input().split(' ')))
        x -= 1
        y -= 1
        adj_nodes[x].append(y)
        adj_nodes[y].append(x)
    dp_b = [0 for _ in range(N)]
    dp_w = [0 for _ in range(N)]

    def bfs(node, parent):
        black = 1
        white = 1
        for child in adj_nodes[node]:
            if child == parent:
                continue
            bfs(child, node)
            black *= dp_w[child]
            white *= dp_b[child] + dp_w[child]
            black %= MOD
            white %= MOD
        dp_b[node] = black
        dp_w[node] = white

    bfs(0, None)
    print(dp_b[0] + dp_w[0])


if __name__ == '__main__':
    main()

Fixed submission:
import sys
from collections import defaultdict


sys.setrecursionlimit(10 ** 6)


def main():
    MOD = 10 ** 9 + 7
    N = int(input())
    adj_nodes = defaultdict(list)
    for _ in range(N - 1):
        x, y = list(map(int, input().split(' ')))
        x -= 1
        y -= 1
        adj_nodes[x].append(y)
        adj_nodes[y].append(x)
    dp_b = [0 for _ in range(N)]
    dp_w = [0 for _ in range(N)]

    def bfs(node, parent):
        black = 1
        white = 1
        for child in adj_nodes[node]:
            if child == parent:
                continue
            bfs(child, node)
            black *= dp_w[child]
            white *= dp_b[child] + dp_w[child]
            black %= MOD
            white %= MOD
        dp_b[node] = black
        dp_w[node] = white

    bfs(0, None)
    print((dp_b[0] + dp_w[0]) % MOD)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def pow(mat, k, mod):
    n = len(mat)
    if k == 0:
        return [[1 if i == j else 0 for i in range(n)] for j in range(n)]
    if k % 2 == 0:
        sqrt_mat = pow(mat, k // 2, mod)
        # calculate 'sqrt_mat * sqrt_mat'
        ret = [[0 for _ in range(n)] for _ in range(n)]
        for i in range(n):
            for j in range(n):
                v = 0
                for k in range(n):
                    v += sqrt_mat[i][k] * sqrt_mat[k][j]
                    v %= mod
                ret[i][j] = v
        return ret
    else:
        powmat = pow(mat, k - 1, mod)
        # calculate 'mat * powmat'
        ret = [[0 for _ in range(n)] for _ in range(n)]
        for i in range(n):
            for j in range(n):
                v = 0
                for k in range(n):
                    v += mat[i][k] * powmat[k][j]
                    v %= mod
                ret[i][j] = v
        return ret


def main():
    MOD = 10 ** 9 + 7
    N, K = list(map(int, input().split(' ')))
    A = [list(map(int, input().split(' '))) for _ in range(N)]
    D = pow(A, K, MOD)
    ans = 0
    for i in range(N):
        for j in range(N):
            ans += D[i][j]
            ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()

Fixed submission:
def pow(mat, k, mod):
    n = len(mat)
    if k == 0:
        return [[1 if i == j else 0 for i in range(n)] for j in range(n)]
    if k % 2 == 0:
        sqrt_mat = pow(mat, k // 2, mod)
        # calculate 'sqrt_mat * sqrt_mat'
        ret = [[0 for _ in range(n)] for _ in range(n)]
        for i in range(n):
            for j in range(n):
                v = 0
                for k in range(n):
                    v += sqrt_mat[i][k] * sqrt_mat[k][j]
                    v %= mod
                ret[i][j] = v
        return ret
    else:
        powmat = pow(mat, k - 1, mod)
        # calculate 'mat * powmat'
        ret = [[0 for _ in range(n)] for _ in range(n)]
        for i in range(n):
            for j in range(n):
                v = 0
                for k in range(n):
                    v += mat[i][k] * powmat[k][j]
                    v %= mod
                ret[i][j] = v
        return ret


def main():
    MOD = 10 ** 9 + 7
    N, K = list(map(int, input().split(' ')))
    A = [list(map(int, input().split(' '))) for _ in range(N)]
    D = pow(A, K, MOD)
    ans = 0
    for i in range(N):
        for j in range(N):
            ans += D[i][j]
            ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import itertools


def main():
    N = int(input())
    A = [list(map(int, input().split(' '))) for _ in range(N)]
    dp = [0 for _ in range(1 << N)]
    for S in range(1, 1 << N):
        group = [r for r in range(N) if (S >> r) & 1 == 1]
        full_score = sum([A[i][j] for i, j in itertools.combinations(group, 2)])
        score = full_score
        T = S
        while (T - 1) & S > 0:
            T = (T - 1) & S
            score = max([score, dp[S ^ T] + dp[T]])
        dp[S] = score
    print(dp[(1 << N) - 1])


if __name__ == '__main__':
    main()

Fixed submission:
import itertools


def main():
    N = int(input())
    A = [list(map(int, input().split(' '))) for _ in range(N)]
    score_list = [0 for _ in range(1 << N)]
    for S in range(1, 1 << N):
        group = [r for r in range(N) if (S >> r) & 1 == 1]
        score_list[S] = sum([A[i][j] for i, j in itertools.combinations(group, 2)])
    dp = [0 for _ in range(1 << N)]
    for S in range(1, 1 << N):
        score = score_list[S]
        T = (S - 1) & S
        while T > 0:
            x = dp[S ^ T] + dp[T]
            score = max(score, x)
            T = (T - 1) & S
        dp[S] = score
    print(dp[(1 << N) - 1])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def f(n):
    # prime factorization of n!
    pf = [0 for _ in range(2, n + 1)]
    for i in range(1, n + 1):
        cur = i
        for j in range(2, i + 1):
            while cur % j == 0:
                pf[j] += 1
                cur //= j
    return pf


def num(m, pf):
    return len(list(filter(lambda x: x >= m - 1, pf)))


def main():
    N = int(input())
    pf = f(N)
    ans = num(75, pf)
    ans += num(25, pf) * (num(3, pf) - 1)
    ans += num(15, pf) * (num(5, pf) - 1)
    ans += num(5, pf) * (num(5, pf) - 1) * (num(3, pf) - 2) // 2
    print(ans)


if __name__ == '__main__':
    main()

Fixed submission:
def f(n):
    # prime factorization of n!
    pf = [0 for _ in range(n + 1)]
    for i in range(2, n + 1):
        cur = i
        for j in range(2, i + 1):
            while cur % j == 0:
                pf[j] += 1
                cur //= j
    return pf


def num(m, pf):
    return len(list(filter(lambda x: x >= m - 1, pf)))


def main():
    N = int(input())
    pf = f(N)
    ans = num(75, pf)
    ans += num(25, pf) * (num(3, pf) - 1)
    ans += num(15, pf) * (num(5, pf) - 1)
    ans += num(5, pf) * (num(5, pf) - 1) * (num(3, pf) - 2) // 2
    print(ans)


if __name__ == '__main__':
    main()