Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
# ABC110d
import sys
from collections import Counter
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
MOD = 10**9+7


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def combinations_with_replacement_count(n, r):
    return combinations_count(n + r - 1, r)


ans = 1
pr = Counter(prime_factorize(m))
for i in pr.values():
    # print(i)
    t = combinations_count(n + i - 1, i)
    # print(t)
    ans = ans*t % MOD
# print(pr)
# print(len(pr))
print(ans)

Fixed submission:
# ABC110d
import sys
from collections import Counter
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
MOD = 10**9+7


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


dp = dict()


def combinations_count(n, r):
    if dp.get(n) != None and dp.get(n).get(r) != None:
        return dp[n][r]
    if dp.get(n) == None:
        dp[n] = dict()
    dp[n].update({r: math.factorial(
        n) // (math.factorial(n - r) * math.factorial(r))})
    return dp[n][r]


def combinations_with_replacement_count(n, r):
    return combinations_count(n + r - 1, r)


ans = 1
pr = Counter(prime_factorize(m))
for i in pr.values():
    # print(i)
    t = combinations_count(n + i - 1, i)
    # print(t)
    ans = ans*t % MOD
# print(pr)
# print(len(pr))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())

ans = set()
for i in range(len(s)+1):
    for j in range(i + 1, len(s)+1):
        ans.add(s[i:j])

# print(ans)
print(sorted(list(ans))[k-1])

Fixed submission:
s = input()
k = int(input())

ans = set()
for i in range(len(s)):
    for j in range(1, k+1):
        ans.add(s[i:i+j])

# print(ans)
print(sorted(list(ans))[k-1])
Buggy python submission (verdict: Runtime Error):
import collections
h, w = map(int, input().split())
queue = collections.deque()
maze = [list(input()) for _ in range(h)]

origin = 0
for i in maze:
    origin += i.count('#')
# print(origin)


def bfs(y, x, cnt):
    if (y < 0 or h <= y or x < 0 or w <= x):
        return
    if (maze[y][x] != '.'):
        return
    maze[y][x] = cnt
    if (y == h - 1 and x == w - 1):
        return cnt
    queue.append([y + 1, x, cnt + 1])
    queue.append([y - 1, x, cnt + 1])
    queue.append([y, x+1, cnt+1])
    queue.append([y, x-1, cnt+1])


queue.append([0, 0, 0])
while (len(queue) > 0):
    l = queue.popleft()
    bfs(l[0], l[1], l[2])

# print(ans)
print(h*w-origin-maze[h-1][w-1]-1)

Fixed submission:
import collections
h, w = map(int, input().split())
queue = collections.deque()
maze = [list(input()) for _ in range(h)]

origin = 0
for i in maze:
    origin += i.count('#')
# print(origin)


def bfs(y, x, cnt):
    if (y < 0 or h <= y or x < 0 or w <= x):
        return
    if (maze[y][x] != '.'):
        return
    maze[y][x] = cnt
    if (y == h - 1 and x == w - 1):
        return cnt
    queue.append([y + 1, x, cnt + 1])
    queue.append([y - 1, x, cnt + 1])
    queue.append([y, x+1, cnt+1])
    queue.append([y, x-1, cnt+1])


queue.append([0, 0, 0])
while (len(queue) > 0):
    l = queue.popleft()
    bfs(l[0], l[1], l[2])
if (maze[h - 1][w - 1] == '.'):
    print(-1)
    exit()

# print(ans)
print(h*w-origin-maze[h-1][w-1]-1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(20000)

n, y = map(int, input().split())

memo = {}


def unchi(maisu, kane, s):
    if(maisu == 0):
        if(kane == 0):
            return [0, 0, 0]
        else:
            return False
    elif(kane < 1000):
        return False

    if((maisu, kane) in memo):
        return memo[(maisu, kane)]

    if(s >= 10000):
        result1 = unchi(maisu - 1, kane - 10000, 10000)
        if (result1):
            result1[0] += 1
            memo[(maisu, kane)] = tuple(result1)
            return result1
    if(s >= 5000):
        result2 = unchi(maisu-1, kane-5000, 5000)
        if (result2):
            result2[1] += 1
            memo[(maisu, kane)] = tuple(result2)
            return result2
    if (kane == 1000 * maisu):
        result3 = [0, 0, maisu]
        memo[(maisu, kane)] = tuple(result3)
        return result3
    memo[(maisu, kane)] = False
    return False


result = unchi(n, y, 10000)
if(result):
    print(*result)
else:
    print(-1, -1, -1)

Fixed submission:
n, y = map(int, input().split())

for a in range(n + 1):
    for b in range(n - a + 1):
        if (y - a * 10000 - b * 5000 == (n - a - b)*1000):
            print(a, b, n - a - b)
            exit()
print(-1, -1, -1)
Buggy python submission (verdict: Runtime Error):
import math

n, m = map(int, input().split())
color = [-1]*n
edge = [list() for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

flag = True


def dfs(i, pre, c):
    if color[i] == c:
        return
    elif color[i] == 1-c:
        global flag
        flag = False
        return
    color[i] = c
    for v in edge[i]:
        dfs(v, i, 1-c)


dfs(0, -1, 0)
# print(color)
# print(flag)

if flag:
    print(color.count(1)*color.count(0)-m)
else:
    print(math.floor(n*(n-1)/2-m))


Fixed submission:
import math
import sys
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
color = [-1]*n
edge = [list() for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

flag = True


def dfs(i, pre, c):
    if color[i] == c:
        return
    elif color[i] == 1-c:
        global flag
        flag = False
        return
    color[i] = c
    for v in edge[i]:
        dfs(v, i, 1-c)


dfs(0, -1, 0)
# print(color)
# print(flag)

if flag:
    print(color.count(1)*color.count(0)-m)
else:
    print(math.floor(n*(n-1)/2-m))
Buggy python submission (verdict: Time Limit Exceeded):
# ABC073d
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, m, _ = map(int, input().split())
d = [[float("inf") for i in range(n)] for i in range(n)]
for i in range(n):
    d[i][i] = 0  # 自身のところに行くコストは０
r = list(map(int, input().split()))


def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d


for _ in range(m):
    a, b, c = map(int, input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c
warshall_floyd(d)

ans = 10**9
for i in itertools.permutations(r, len(r)):
    t = 0
    for j in range(1, len(i)):
        t += d[i[j]-1][i[j-1]-1]
    #print(i, t)
    ans = min(ans, t)
print(ans)


Fixed submission:
# ABC073d
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, m, _ = map(int, input().split())
d = [[float("inf") for i in range(n)] for i in range(n)]
for i in range(n):
    d[i][i] = 0  # 自身のところに行くコストは０
r = list(map(int, input().split()))


def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d


for _ in range(m):
    a, b, c = map(int, input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c
warshall_floyd(d)

ans = 10**9
for i in itertools.permutations(r, len(r)):
    t = 0
    for j in range(1, len(i)):
        t += d[i[j]-1][i[j-1]-1]
    #print(i, t)
    ans = min(ans, t)
print(ans)
Buggy python submission (verdict: Runtime Error):
# ABC072d
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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

ans = 0
for i in range(n):
    if p[i] == i+1:
        t = p[i]
        p[i] = p[i+1]
        p[i+1] = t
        ans += 1
print(ans)


Fixed submission:
# ABC072d
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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

ans = 0
for i in range(n):
    if p[i] == i+1:
        if i == n-1:
            ans += 1
            continue
        t = p[i]
        p[i] = p[i+1]
        p[i+1] = t
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
# ABC070c
from fractions import gcd
from functools import reduce
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())


def lcm_base(a, b):
    return a * b // fractions.gcd(a, b)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


t = [int(input()) for _ in range(n)]
print(lcm(*t))


Fixed submission:
# ABC070c
from fractions import gcd
from functools import reduce
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())


def lcm_base(a, b):
    return a * b // gcd(a, b)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def gcds(*numbers):
    return reduce(gcd, numbers)


t = [int(input()) for _ in range(n)]
print(lcm(*t))

Buggy python submission (verdict: Runtime Error):
# ABC070c
from functools import reduce
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())


def lcm_base(a, b):
    return a * b // math.gcd(a, b)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


t = [int(input()) for _ in range(n)]
print(lcm(*t))


Fixed submission:
# ABC070c
from fractions import gcd
from functools import reduce
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())


def lcm_base(a, b):
    return a * b // gcd(a, b)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def gcds(*numbers):
    return reduce(gcd, numbers)


t = [int(input()) for _ in range(n)]
print(lcm(*t))
Buggy python submission (verdict: Time Limit Exceeded):
# ABC070d
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
cost = [10**10]*n
edge = [dict() for _ in range(n)]
for _ in range(n-1):
    a, b, c = map(int, input().split())
    edge[a-1].update({b-1: c})
    edge[b-1].update({a-1: c})

Q, K = map(int, input().split())


def dfs(i, prev, d):
    cost[i] = d
    for j in edge[i].keys():
        if j == prev:
            continue
        dfs(j, i, d+edge[i][j])


dfs(K-1, -1, 0)

for _ in range(Q):
    x, y = map(int, input().split())
    print(cost[x-1]+cost[y-1])

Fixed submission:
# ABC070d
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
cost = [10**10]*n
edge = [dict() for _ in range(n)]
for _ in range(n-1):
    a, b, c = map(int, input().split())
    edge[a-1].update({b-1: c})
    edge[b-1].update({a-1: c})

Q, K = map(int, input().split())


def dfs(i, prev, d):
    cost[i] = d
    for j in edge[i].keys():
        if j == prev:
            continue
        dfs(j, i, d+edge[i][j])


dfs(K-1, -1, 0)

for _ in range(Q):
    x, y = map(int, input().split())
    print(cost[x-1]+cost[y-1])
Buggy python submission (verdict: Runtime Error):
#from fractions import gcd
from functools import reduce
from math import gcd
n, k = map(int, input().split())
a = list(map(int, input().split()))

if k > max(a):
    print('IMPOSSIBLE')
    exit(0)
if k in a:
    print('POSSIBLE')
    exit(0)


def gcds(*numbers):
    return reduce(gcd, numbers)


if k % gcds(*a) == 0:
    print('POSSIBLE')
    exit(0)
print('IMPOSSIBLE')


Fixed submission:
from fractions import gcd
from functools import reduce
#from math import gcd
n, k = map(int, input().split())
a = list(map(int, input().split()))

if k > max(a):
    print('IMPOSSIBLE')
    exit(0)
if k in a:
    print('POSSIBLE')
    exit(0)


def gcds(*numbers):
    return reduce(gcd, numbers)


if k % gcds(*a) == 0:
    print('POSSIBLE')
    exit(0)
print('IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
# ABC063c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
s = [int(input()) for _ in range(n)]


def dfs(i, su):
    if i == n:
        return su if su % 10 != 0 else 0
    return max(dfs(i+1, su+s[i]), dfs(i+1, su))


print(dfs(0, 0))


Fixed submission:
# ABC063c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
s = [int(input()) for _ in range(n)]

s.sort()
ans = sum(s)
if ans % 10 != 0:
    print(ans)
    exit(0)
for i in s:
    if i % 10 != 0:
        ans -= i
        print(ans)
        exit(0)
print(0)

Buggy python submission (verdict: Time Limit Exceeded):
# ABC063c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
s = [int(input()) for _ in range(n)]


def dfs(i, su):
    if i == n:
        return su if su % 10 != 0 else 0
    return max(dfs(i+1, su+s[i]), dfs(i+1, su))


print(dfs(0, 0))


Fixed submission:
# ABC063c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
s = [int(input()) for _ in range(n)]

s.sort()
ans = sum(s)
if ans % 10 != 0:
    print(ans)
    exit(0)
for i in s:
    if i % 10 != 0:
        ans -= i
        print(ans)
        exit(0)
print(0)
Buggy python submission (verdict: Runtime Error):
# ABC062a
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


# Union-Find木


class UnionFind:
    def __init__(self, n):
        self.tree = [i for i in range(n)]

    def root(self, x):
        if(self.tree[x] == x):
            return x
        self.tree[x] = self.root(self.tree[x])
        return self.tree[x]  # 経路圧縮

    def same(self, x, y):  # xとyが同じ木に属するか
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if(x == y):
            return
        self.tree[x] = y


uf = UnionFind(12)
uf.unite(0, 2)
uf.unite(0, 4)
uf.unite(0, 6)
uf.unite(0, 7)
uf.unite(0, 9)
uf.unite(0, 11)
uf.unite(3, 5)
uf.unite(3, 8)
uf.unite(3, 10)

print('YNeos'[uf.same(*tuple(map(int, input().split())))::2])


Fixed submission:
# ABC062a
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


# Union-Find木


class UnionFind:
    def __init__(self, n):
        self.tree = [i for i in range(n)]

    def root(self, x):
        if(self.tree[x] == x):
            return x
        self.tree[x] = self.root(self.tree[x])
        return self.tree[x]  # 経路圧縮

    def same(self, x, y):  # xとyが同じ木に属するか
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if(x == y):
            return
        self.tree[x] = y


uf = UnionFind(12)
uf.unite(0, 2)
uf.unite(0, 4)
uf.unite(0, 6)
uf.unite(0, 7)
uf.unite(0, 9)
uf.unite(0, 11)
uf.unite(3, 5)
uf.unite(3, 8)
uf.unite(3, 10)

x, y = map(int, input().split())
print('YNeos'[not uf.same(x-1, y-1)::2])
Buggy python submission (verdict: Runtime Error):
# ABC060b
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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

if c % math.gcd(a, b) == 0:
    print('YES')
else:
    print('NO')

Fixed submission:
# ABC060b
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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

for i in range(a, a * b+a, a):
    if (i % b == c):
        #print(i, b, i % b, c)
        print('YES')
        exit()
print('NO')

Buggy python submission (verdict: Runtime Error):
# ABC060b
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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

print('YES' if c % math.gcd(a, b) == 0 else 'NO')

Fixed submission:
# ABC060b
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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

for i in range(a, a * b+a, a):
    if (i % b == c):
        #print(i, b, i % b, c)
        print('YES')
        exit()
print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
# ABC056c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

x = int(input())


def calc(time, pos):
    if pos == x:
        return time
    if pos > x:
        return -1
    for i in range(time+1, x+1):
        result = calc(i, pos+i)
        if result != -1:
            return result
    return -1


print(calc(0, 0))


Fixed submission:
# ABC056c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

x = int(input())
w = 0
for i in range(1, 10**8):
    if x <= (i+1)*i//2:
        w = i
        break
print(w)
Buggy python submission (verdict: Time Limit Exceeded):
# AGC009a
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # map(int, input().split())
    n = int(input())

    a = list()
    b = list()
    for _ in range(n):
        aa, bb = map(int, input().split())
        a.append(aa)
        b.append(bb)

    ans = 0
    dif = 0
    for i in range(n-1, -1, -1):
        while True:
            if (a[i]+dif) % b[i] == 0:
                break
            ans += 1
            dif += 1
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
# AGC009a
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # map(int, input().split())
    n = int(input())

    a = list()
    b = list()
    for _ in range(n):
        aa, bb = map(int, input().split())
        a.append(aa)
        b.append(bb)

    ans = 0
    dif = 0
    for i in range(n-1, -1, -1):
        osu = b[i]-(a[i]+dif) % b[i] if (a[i]+dif) % b[i] != 0 else 0
        #print(a[i]+dif, b[i], osu, ans)
        ans += osu
        dif += osu
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#ABC051b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

k, s = map(int, input().split())
c = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            #print(x, y, z)
            if (x + y + z == s):
                c += 1
print(c)

Fixed submission:
#ABC051b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

k, s = map(int, input().split())
c = 0
for x in range(k + 1):
    for y in range(k + 1):
        if (0 <= s - x - y <= k):
            c += 1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    n = int(input())
    a = list(map(int, input().split()))
    if(n % 2 == 0):
        for i in range(1, n, 2):
            if(a.count(i) != 2):
                print(0)
                exit(0)
        print(2**(n//2))
        exit(0)
    for i in range(0, n, 2):
        if(i == 0 and a.count(i) != 1):
            print(0)
            exit(0)
        elif(i != 0 and a.count(i) != 2):
            print(0)
            exit(0)
    print(2**(n//2))


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    # print(a)
    if(n % 2 == 0):
        for i in range(n-1):
            if i % 2 == 0 and a[i] != a[i+1] or i % 2 == 1 and a[i]+2 != a[i+1]:
                print(0)
                exit(0)
        print(2**(n//2) % (10**9+7))
        exit(0)
    if a[0] != 0:
        print(0)
        exit(0)
    for i in range(1, n-1):
        if i % 2 == 0 and a[i]+2 != a[i+1] or i % 2 == 1 and a[i] != a[i+1]:
            print(0)
            exit(0)
    print(2**((n-1)//2) % (10**9+7))
    exit(0)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
HN = list(map(int, input().split()))
H = HN[0]; N = HN[1]
AB = [list(map(int, input().split())) for _ in range(N)]
 
DP = [[0]*H for i in range(N)]
 
for i in range(H):
    DP[0][i] = int((1+i//AB[0][0])*AB[0][1])
 
for i in range(1,N):
    for j in range(H):
        if j<AB[i][0]:
            DP[i][j] = int(min([DP[i-1][j], AB[i][1]]))
        else:
            DP[i][j] = min([DP[i-1][j], DP[i][j-AB[i][0]] + AB[i][1]])
 
print(int(DP[N-1][H-1]))

Fixed submission:
HN = list(map(int, input().split()))
H = HN[0]; N = HN[1]
AB = [list(map(int, input().split())) for _ in range(N)]
 
DP = [[0]*H for i in range(N)]
 
for i in range(H):
    DP[0][i] = int((1+i//AB[0][0])*AB[0][1])
 
for i in range(1,N):
    for j in range(H):
        if j<AB[i][0]:
            DP[i][j] = int(min([DP[i-1][j], AB[i][1]]))
        else:
            DP[i][j] = min([DP[i-1][j], DP[i][j-AB[i][0]] + AB[i][1]])
 
print(int(DP[N-1][H-1]))

Buggy python submission (verdict: Runtime Error):
import numpy as np
 
HN = list(map(int, input().split()))
H = HN[0]; N = HN[1]
AB = [list(map(int, input().split())) for _ in range(N)]
 
DP = np.zeros((N,H))
 
for i in range(H):
    DP[0][i] = int((1+i//AB[0][0])*AB[0][1])
 
for i in range(1,N):
    for j in range(H):
        if j<AB[i][0]:
            DP[i][j] = int(min([DP[i-1][j], AB[i][1]]))
        else:
            DP[i][j] = min([DP[i-1][j], DP[i][j-AB[i][0]] + AB[i][1]])
 
print(int(DP[N-1][H-1]))

Fixed submission:
HN = list(map(int, input().split()))
H = HN[0]; N = HN[1]
AB = [list(map(int, input().split())) for _ in range(N)]
 
DP = [[0]*H for i in range(N)]
 
for i in range(H):
    DP[0][i] = int((1+i//AB[0][0])*AB[0][1])
 
for i in range(1,N):
    for j in range(H):
        if j<AB[i][0]:
            DP[i][j] = int(min([DP[i-1][j], AB[i][1]]))
        else:
            DP[i][j] = min([DP[i-1][j], DP[i][j-AB[i][0]] + AB[i][1]])
 
print(int(DP[N-1][H-1]))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
 
HN = list(map(int, input().split()))
H = HN[0]; N = HN[1]
AB = [list(map(int, input().split())) for _ in range(N)]
 
DP = np.zeros((N,H))
 
for i in range(H):
    DP[0][i] = int((1+i//AB[0][0])*AB[0][1])
 
for i in range(1,N):
    for j in range(H):
        if j<AB[i][0]:
            DP[i][j] = int(min([DP[i-1][j], AB[i][1]]))
        else:
            DP[i][j] = min([DP[i-1][j], DP[i][j-AB[i][0]] + AB[i][1]])
 
print(int(DP[N-1][H-1]))

Fixed submission:
HN = list(map(int, input().split()))
H = HN[0]; N = HN[1]
AB = [list(map(int, input().split())) for _ in range(N)]
 
DP = [[0]*H for i in range(N)]
 
for i in range(H):
    DP[0][i] = int((1+i//AB[0][0])*AB[0][1])
 
for i in range(1,N):
    for j in range(H):
        if j<AB[i][0]:
            DP[i][j] = int(min([DP[i-1][j], AB[i][1]]))
        else:
            DP[i][j] = min([DP[i-1][j], DP[i][j-AB[i][0]] + AB[i][1]])
 
print(int(DP[N-1][H-1]))
Buggy python submission (verdict: Runtime Error):
a,b = input().split()

a = int(a)

b1,b2 = map(int, b.split('.'))
b = b1*100 + b2

ans = (a*b)//100

print(int(ans))

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

print(a*b)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

n = int(input())

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

ans = 1

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


if ans > 10**18:
    print(-1)
    sys.exit()

print(ans)


Fixed submission:
import sys

n = int(input())

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

ans = 1

if 0 in a:
    print(0)
    sys.exit()

for i in a:
    ans *= i
    
    if ans > 10**18:
        print(-1)
        sys.exit()

print(ans)