alexjercan/bugnet huggingface dataset:
Problem p02952 (Python) — buggy submission, verdict: Runtime Error

n = int(input())
cnt = 0
for i in range(1, n + 1):
    if len(str(i)) % 2 == 1:
        cnt += 1
print(cnt)


Error: TypeError: not all arguments converted during string formatting
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02952/Python/s429203628.py", line 4, in <module>
    if str(i) % 2 == 1:
TypeError: not all arguments converted during string formatting


Fixed submission:

n = int(input())
cnt = 0
for i in range(1, n + 1):
    if str(i) % 2 == 1:
        cnt += 1
print(cnt)
Problem p02952 (Python) — buggy submission, verdict: Runtime Error

N = int(input())
ans = 0
for i in range(1, N + 1):
    if len(str(i)) % 2 == 1:
        ans += 1
print(ans)


Error: TypeError: object of type 'int' has no len()
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02952/Python/s356122342.py", line 4, in <module>
    if len(i) % 2 == 1:
TypeError: object of type 'int' has no len()


Fixed submission:

N = int(input())
ans = 0
for i in range(1, N + 1):
    if len(i) % 2 == 1:
        ans += 1
print(ans)
Problem p02953 (Python) — buggy submission, verdict: Runtime Error

n = int(input())
h = list(map(int, input().split()))
x = h[-1]
ans = "Yes"
for i in reversed(range(n - 1)):
    hi = h[i]
    if hi <= x:
        pass
    else:
        if abs(x - hi) >= 2:
            ans = "No"
        else:
            h[i] -= 1
    x = h[i]
print(ans)


Error: WA

Fixed submission:

n = int(input())
h = list(map(int, input().split()))
x = h[-1]
ans = "Yes"
for i in reversed(range(n - 1)):
    print(h)
    hi = h[i]
    if hi <= x:
        pass
    else:
        if abs(x - hi) >= 2:
            ans = "No"
        else:
            h[i] -= 1
    x = hi
print(ans)
Problem p02953 (Python) — buggy submission, verdict: Runtime Error

import sys

input = sys.stdin.readline


def main():
    n = int(input())
    H = [int(i) for i in input().split()]

    flg = True
    max_ = -1
    for h in H:
        if h < max_:
            flg = False
            break
        if h == max_:
            continue
        max_ = h - 1
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()


Error: IndexError: list index out of range
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02953/Python/s934436551.py", line 45, in <module>
    main()
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02953/Python/s934436551.py", line 27, in main
    c = H[i]
IndexError: list index out of range


Fixed submission:

import sys

input = sys.stdin.readline


def main():
    n = int(input())
    H = [int(i) for i in input().split()]
    # マスの高さを1つ引くくすること
    # なにもしない
    # 単調非減少ってなんだ
    # 左より低くならないようにすれば良いっぽいな
    # N = 10 ** 5
    # h = 10 ** 9
    # example:
    # 1 2 1 1 -> 1 1 1 1 -> Yes
    # 1 2 2 1 -> 1 2 1 1 -> No
    # 1 2 3 1 -> 1 2 2 1 -> No
    # 1 100 1 1 -> 1 99 1 1 -> No
    #

    cnt = 0
    # とりあえず、愚直に書いてみる
    a = None
    b = H[0]
    for i in range(1, n + 1):
        c = H[i]
        sa = c - b
        if sa < -1:
            cnt = 2
            break
        elif sa < 0:
            if a and a == b:
                cnt = 2
                break
            cnt += 1
        a = b
        b = c
        if cnt > 1:
            break
    print("Yes" if cnt <= 1 else "No")


if __name__ == "__main__":
    main()
Problem p02953 (Python) — buggy submission, verdict: Runtime Error

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

for i in reversed(range(1, n)):
    d = stair[i] - stair[i - 1]
    if d < -1:
        print("No")
        exit()
    elif d == -1:
        stair[i - 1] -= 1
print("Yes")


Error: WA

Fixed submission:

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

for i in reversed(range(1, n)):
    d = stair[i] - stair[i - 1]
    if d > 1:
        print("No")
        exit()
    elif d == 1:
        stair -= 1
print("Yes")
Problem p02953 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())

stairs = list(map(int, input().split(" ")))
min = 0

for i in range(N):
    stair = stairs[i]
    if min > stair:
        print("No")
        exit(0)
    if stair - 1 > min:
        min = stair - 1

print("Yes")


Error: TLE

Fixed submission:

N = int(input())

stairs = list(map(int, input().split(" ")))

for i in range(N):
    stair = stairs[i]
    if stair - 2 >= min(stairs[i:]):
        print("No")
        exit(0)

print("Yes")
Problem p02954 (Python) — buggy submission, verdict: Time Limit Exceeded

s = input()
n = len(s)

square = [0 for _ in range(n)]
i = 0
while i < n:
    start = i
    char = s[i]
    i += 1
    while i < n and char == s[i]:
        i += 1

    if char == "L":
        num = i - start
        if num % 2 == 0:
            square[start - 1] += num // 2
            square[start] += num // 2
        else:
            square[start] += num // 2 + 1
            square[start - 1] += num // 2
    else:  # R
        num = i - start
        if num % 2 == 0:
            square[i] += num // 2
            square[i - 1] += num // 2
        else:
            square[i] += num // 2
            square[i - 1] += num // 2 + 1
    # if i == n - 1:
    #     i += 1


print(square[0], end="")
for i in range(1, n):
    print(" ", end="")
    print(square[i], end="")


Error: TLE

Fixed submission:

s = input()
n = len(s)

square = [0 for _ in range(n)]
for i in range(n):
    if s[i] == "L":
        add_num = -1
    else:
        add_num = 1
    j = i + add_num
    char = s[i]
    while j > -1 and j < n and char == s[j]:
        j += add_num
    if (i - j) % 2 == 0:
        square[j] += 1
    else:
        square[j - add_num] += 1

print(square[0], end="")
for i in range(1, n):
    print(" ", end="")
    print(square[i], end="")
Problem p02954 (Python) — buggy submission, verdict: Time Limit Exceeded

s = list(input())
kids = [0] * len(s)

for d in ["R", "L"]:
    c = 0
    for i in range(len(s)):
        if s[i] == d:
            c += 1
        else:
            kids[i] += c // 2
            kids[i - 1] += (c + 1) // 2
            c = 0
    s.reverse()
    kids.reverse()

print(" ".join([str(k) for k in kids]))


Error: TLE

Fixed submission:

s = input()
kids = [0] * len(s)
for i, c in enumerate(s):
    now = i
    if c == "R":
        while s[now + 1] == "R":
            now += 1
        diff = abs(now - i)
        if diff % 2:
            kids[now + 1] += 1
        else:
            kids[now] += 1
    else:
        while s[now - 1] == "L":
            now -= 1
        diff = abs(now - i)
        if diff % 2:
            kids[now - 1] += 1
        else:
            kids[now] += 1
print(" ".join([str(k) for k in kids]))
Problem p02955 (Python) — buggy submission, verdict: Time Limit Exceeded

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

divs = []
maxA = sum(A)
for i in range(1, int(maxA**0.5) + 1):
    if maxA % i == 0:
        divs.append(i)
        divs.append(maxA // i)

divs.sort(reverse=True)

for d in divs:
    rest = [a % d for a in A]
    rest.sort(reverse=True)
    restSum = sum(rest) // d
    cnt = 0
    for i in range(restSum):
        cnt += d - rest[i]
    if cnt <= K:
        print(d)
        exit()


Error: TLE

Fixed submission:

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

divs = []
maxA = sum(A)
for i in range(1, maxA + 1):
    if maxA % i == 0:
        divs.append(i)
        divs.append(maxA // i)

divs.sort(reverse=True)

for d in divs:
    rest = [a % d for a in A]
    rest.sort(reverse=True)
    restSum = sum(rest) // d
    cnt = 0
    for i in range(restSum):
        cnt += d - rest[i]
    if cnt <= K:
        print(d)
        exit()
Problem p02957 (Python) — buggy submission, verdict: Runtime Error

# -*- coding: utf-8 -*-
a, b = map(int, input().split())
if (a + b) % 2 == 0:
    print((a + b) // 2)
else:
    print("IMPOSSIBLE")


Error: TypeError: isinstance expected 2 arguments, got 1
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02957/Python/s456363956.py", line 3, in <module>
    if isinstance((a + b) / 2):
TypeError: isinstance expected 2 arguments, got 1


Fixed submission:

# -*- coding: utf-8 -*-
a, b = map(int, input().split())
if isinstance((a + b) / 2):
    print((a + b) / 2)
else:
    print("IMPOSSIBLE")
Problem p02957 (Python) — buggy submission, verdict: Runtime Error

# -*- coding: utf-8 -*-

a, b = map(int, input().split(" "))
if a % 2 == b % 2:
    print(int((a + b) / 2))
else:
    print("IMPOSSIBLE")


Error: TypeError: not all arguments converted during string formatting
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02957/Python/s028842824.py", line 5, in <module>
    if a % 2 == b % 2:
TypeError: not all arguments converted during string formatting


Fixed submission:

#!/bin/python3

a, b = input().split(" ")

if a % 2 == b % 2:
    print((a + b) / 2)
else:
    print("IMPOSSIBLE")
Problem p02957 (Python) — buggy submission, verdict: Runtime Error

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

if a < b:
    A = a
    B = b
else:
    A = b
    B = a

if (B - A) % 2 != 0:
    print("IMPOSSIBLE")
else:
    K = int(B - (B - A) / 2)
    print(str(K))


Error: ValueError: invalid literal for int() with base 10: '2 16'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02957/Python/s043180059.py", line 1, in <module>
    a = int(input())
ValueError: invalid literal for int() with base 10: '2 16'


Fixed submission:

a = int(input())
b = int(input())

if (a + b) % 2 != 0:
    print("IMPOSSIBLE")
else:
    if a < b:
        A = a
        B = b
    else:
        A = b
        B = a

    K = int(B - (B - A) / 2)
    print(str(K))
Problem p02958 (Python) — buggy submission, verdict: Runtime Error

n = int(input())
p = list(map(int, input().split()))
sorted_p = sorted(p)
cnt = 0
for a, b in zip(p, sorted_p):
    if a != b:
        cnt += 1
if cnt > 2:
    print("NO")
else:
    print("YES")


Error: ValueError: too many values to unpack (expected 2)
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02958/Python/s135206060.py", line 5, in <module>
    for a, b in p, sorted_p:
ValueError: too many values to unpack (expected 2)


Fixed submission:

n = int(input())
p = list(map(int, input().split()))
sorted_p = sorted(p)
cnt = 0
for a, b in p, sorted_p:
    if a != b:
        cnt += 1
if cnt > 2:
    print("NO")
else:
    print("YES")
Problem p02958 (Python) — buggy submission, verdict: Runtime Error

N = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(N):
    if p[i] != i + 1:
        count += 1
if count == 0 or count == 2:
    print("YES")
else:
    print("NO")


Error: IndexError: list index out of range
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02958/Python/s761577453.py", line 5, in <module>
    if p[j - 1] < p[i] < p[j + 1] and p[i - 1] < p[j] < p[i + 1]:
IndexError: list index out of range


Fixed submission:

N = int(input())
p = list(map(int, input().split()))
for i in range(N):
    for j in range(i + 1, N):
        if p[j - 1] < p[i] < p[j + 1] and p[i - 1] < p[j] < p[i + 1]:
            print("YES")
            exit()
        else:
            continue
print("NO")
Problem p02958 (Python) — buggy submission, verdict: Runtime Error

N = int(input())
p = list(map(int, input().split()))
q = sorted(p)
k = 0
for i in range(N):
    if p[i] - q[i] != 0:
        k += 1

if k > 2:
    print("NO")
else:
    print("YES")


Error: IndexError: list index out of range
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02958/Python/s083953128.py", line 6, in <module>
    if p[i] - q[i] != 0:
IndexError: list index out of range


Fixed submission:

N = int(input())
p = list(map(int, input().split()))
q = sorted(p)
k = 0
for i in range(1, N + 1):
    if p[i] - q[i] != 0:
        k += 1

if k > 2:
    print("NO")
else:
    print("YES")
Problem p02959 (Python) — buggy submission, verdict: Runtime Error

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

count = 0
for i in range(n):
    if a[i] < b[i]:
        count += a[i]
        d = b[i] - a[i]

        if a[i + 1] < d:
            count += a[i + 1]
            a[i + 1] = 0
        else:
            count += d
            a[i + 1] -= d

    else:
        count += b[i]

print(count)


Error: 0

Fixed submission:

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

count = 0
for i in range(n):
    if a[i] < b[i]:
        count += a[i]
        d = b[i] - a[i]

        if a[i + 1] < d:
            count += a[i + 1]
            a[i + i] = 0
        else:
            count += d
            a[i + 1] -= d

    else:
        count += b[i]

print(count)
Problem p02959 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
monster = list(map(int, input().split()))
yuusha = list(map(int, input().split()))
a = sum(monster)
for i in range(n):
    if monster[i] < yuusha[i]:
        yuusha[i] -= monster[i]
        monster[i] = 0
        if monster[i + 1] < yuusha[i]:
            yuusha[i] -= monster[i + 1]
            monster[i + 1] = 0
        else:
            monster[i + 1] -= yuusha[i]
            yuusha[i] = 0
    else:
        monster[i] -= yuusha[i]
        yuusha[i] = 0
a -= sum(monster)
print(a)


Error: TLE

Fixed submission:

n = int(input())
monster = list(map(int, input().split()))
yuusha = list(map(int, input().split()))
a = sum(monster)
for i in range(n):
    while yuusha[i] != 0:
        if monster[i] > 0:
            yuusha[i] -= 1
            monster[i] -= 1
        elif monster[i + 1] > 0:
            yuusha[i] -= 1
            monster[i + 1] -= 1
        else:
            break
a -= sum(monster)
print(a)
Problem p02959 (Python) — buggy submission, verdict: Runtime Error

# coding:utf-8
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0

for i in range(n):
    if a[i] >= b[i]:
        ans += b[i]
    else:
        ans += a[i]
        b[i] -= a[i]
        if a[i + 1] >= b[i]:
            a[i + 1] -= b[i]
            ans += b[i]
        else:
            ans += a[i + 1]
            a[i + 1] = 0


print(ans)


Error: 0

Fixed submission:

# coding:utf-8
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0

for i in range(n):
    if a[i] >= b[i]:
        ans += b[i]
    else:
        ans += a[i]
        b[i] -= a[i]
        if a[i + 1] >= b[i]:
            a[i + 1] -= b[i]
            ans += b[i]
        else:
            ans += a[i + i]
            a[i + 1] = 0


print(ans)
Problem p02959 (Python) — buggy submission, verdict: Runtime Error

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

s1 = sum(a)
for i in range(n + 1):
    if i == 0:
        if a[i] < b[i]:
            b[i] -= a[i]
            a[i] = 0
        else:
            a[i] -= b[i]
            b[i] = 0
    elif i == n:
        if a[i] < b[i - 1]:
            a[i] = 0
        else:
            a[i] -= b[i - 1]
            b[i - 1] = 0
    else:
        if a[i] < b[i - 1]:
            a[i] = 0
        else:
            a[i] -= b[i - 1]
        if a[i] < b[i]:
            b[i] -= a[i]
            a[i] = 0
        else:
            a[i] -= b[i]
            b[i] = 0
print(s1 - sum(a))


Error: IndexError: list assignment index out of range
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02959/Python/s937691477.py", line 19, in <module>
    b[i] = 0
IndexError: list assignment index out of range


Fixed submission:

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

s1 = sum(a)
for i in range(n + 1):
    if i == 0:
        if a[i] < b[i]:
            b[i] -= a[i]
            a[i] = 0
        else:
            a[i] -= b[i]
            b[i] = 0
    elif i == n:
        if a[i] < b[i - 1]:
            a[i] = 0
        else:
            a[i] -= b[i - 1]
            b[i] = 0
    else:
        if a[i] < b[i - 1]:
            a[i] = 0
        else:
            a[i] -= b[i - 1]
        if a[i] < b[i]:
            b[i] -= a[i]
            a[i] = 0
        else:
            a[i] -= b[i]
            b[i] = 0
print(s1 - sum(a))
Problem p02960 (Python) — buggy submission, verdict: Time Limit Exceeded

S = str(input())
S_len = len(S)

DP = [[0 for j in range(13)] for i in range(S_len + 1)]
DP[S_len][0] = 1
num = 1

for i in reversed(range(S_len)):

    if S[i] != "?":
        for j in range(13):
            DP[i][(j + int(S[i]) * num) % 13] += DP[i + 1][j] % 1000000007
    else:
        for j in range(13):
            for k in range(10):
                DP[i][(j + k * num) % 13] += DP[i + 1][j] % 1000000007

    num = (num * 10) % 13

print(DP[0][5] % 1000000007)


Error: TLE

Fixed submission:

S = str(input())
S_len = len(S)

DP = [[0 for j in range(13)] for i in range(S_len + 1)]
DP[S_len][0] = 1

for i in reversed(range(S_len)):

    num = 10 ** (S_len - 1 - i) % 13

    if S[i] != "?":
        for j in range(13):
            DP[i][(j + int(S[i]) * num) % 13] += DP[i + 1][j] % 1000000007
    else:
        for j in range(13):
            for k in range(10):
                DP[i][(j + k * num) % 13] += DP[i + 1][j] % 1000000007

print(DP[0][5] % 1000000007)
Problem p02962 (Python) — buggy submission, verdict: Time Limit Exceeded

s = input()
t = input()

u = s * (len(t) // len(s) + 2)

t_add = t + "."


def partial_match_table(word):
    table = [0] * (len(word) + 1)
    table[0] = -1
    i, j = 0, 1

    while j < len(word):
        matched = word[i] == word[j]

        if not matched and i > 0:
            i = table[i]
        else:
            if matched:
                i += 1
            j += 1
            table[j] = i

    return table


table_tx = partial_match_table(t_add)

match = [0] * len(s)

i = j = 0
while i < len(u) and j < len(t_add):
    if u[i] == t_add[j]:
        i += 1
        j += 1
    elif j == 0:
        i += 1
    else:
        j = table_tx[j]
    if j == len(t_add) - 1:
        match[(i - j) % len(s)] = 1


# search
searched = [0] * len(s)
longest = 0
infinity = False
for i in range(len(s)):
    if searched[i]:
        continue
    searched[i] = 1
    p = i
    right = 0
    while match[p]:
        right += 1
        p = (p + len(t)) % len(s)
        searched[p] = 1
        if p == i:
            infinity = True
            break
    left = 0
    p = i
    while match[(p - len(t)) % len(s)]:
        left += 1
        p = (p - len(t)) % len(s)
        searched[p] = 1
        if p == i:
            infinity = True
            break
    if left + right > longest:
        longest = left + right

if infinity:
    print(-1)
else:
    print(longest)


Error: TLE

Fixed submission:

s = input()
t = input()

u = ""
while len(u) < len(s) + len(t):
    u = s * (len(t) // len(s) + 1)

t_add = t + "."


def partial_match_table(word):
    table = [0] * (len(word) + 1)
    table[0] = -1
    i, j = 0, 1

    while j < len(word):
        matched = word[i] == word[j]

        if not matched and i > 0:
            i = table[i]
        else:
            if matched:
                i += 1
            j += 1
            table[j] = i

    return table


table_tx = partial_match_table(t_add)

match = [0] * len(s)

i = j = 0
while i < len(u) and j < len(t_add):
    if u[i] == t_add[j]:
        i += 1
        j += 1
    elif j == 0:
        i += 1
    else:
        j = table_tx[j]
    if j == len(t_add) - 1:
        match[(i - j) % len(s)] = 1


# search
searched = [0] * len(s)
longest = 0
infinity = False
for i in range(len(s)):
    if searched[i]:
        continue
    searched[i] = 1
    p = i
    right = 0
    while match[p]:
        right += 1
        p = (p + len(t)) % len(s)
        searched[p] = 1
        if p == i:
            infinity = True
            break
    left = 0
    p = i
    while match[(p - len(t)) % len(s)]:
        left += 1
        p = (p - len(t)) % len(s)
        searched[p] = 1
        if p == i:
            infinity = True
            break
    if left + right > longest:
        longest = left + right

if infinity:
    print(-1)
else:
    print(longest)
Problem p02963 (Python) — buggy submission, verdict: Runtime Error

import math

s = int(input())

rot = int(math.sqrt(s) // 1)
if s == rot**2:
    print("0 0 " + str(rot) + " 0 0 " + str(rot))
    exit()

rot += 1
ans = (rot**2) - s
print("0 0 " + str(rot) + " 1 " + str(ans) + " " + str(rot))


Error: WA

Fixed submission:

import math

s = int(input())

rot = int(math.sqrt(s) // 1)
if s == rot**2:
    print(f"0 0 0 {rot} 0 0 {rot}")
    exit()

rot += 1
ans = (rot**2) - s
print(f"0 0 {rot} 1 {ans} {rot}")
Problem p02963 (Python) — buggy submission, verdict: Time Limit Exceeded

s = int(input())
a = [0, 0]

a.append(10**9)
a.append(1)

q, r = divmod(s, 10**9)
if r > 0:
    q += 1
    r -= 10**9
    r *= -1

a.append(r)
a.append(q)

print(*a)


Error: TLE

Fixed submission:

s = int(input())

t = int(pow(s, 0.5))
for i in range(t, 0, -1):
    if s % i == 0:
        x = i
        y = s // i
        break

ans = [0, 0, 0, y, x, 0]
print(*ans)
Problem p02965 (Python) — buggy submission, verdict: Time Limit Exceeded

def prepare(n, MOD):
    f = 1
    factorials = [1] * (n + 1)
    for m in range(1, n + 1):
        f = f * m % MOD
        factorials[m] = f
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv = inv * m % MOD
        invs[m - 1] = inv

    return factorials, invs


def get_nhr(n, facts, invs, MOD):
    def nhr(r):
        return facts[n + r - 1] * invs[r] * invs[n - 1] % MOD

    return nhr


def solve(n, m):
    MOD = 998244353
    facts, invs = prepare(n + 3 * m, MOD)
    fn = facts[n]
    nhr = get_nhr(n, facts, invs, MOD)
    nm2 = min(n, m - 1)
    ans = 0
    for odd in range(m % 2, min(m, n) + 1, 2):
        tmp = nhr((3 * m - odd) // 2)
        if odd > 0:
            tmp -= odd * nhr((m - odd) // 2)
        if odd < nm2:
            tmp -= (n - odd) * nhr((m - odd - 2) // 2)
        ans = (ans + fn * invs[odd] * invs[n - odd] % MOD * tmp) % MOD
    return ans


n, m = list(map(int, input().split()))
print(solve(n, m))


Error: TLE

Fixed submission:

from functools import lru_cache


def prepare(n, MOD):
    f = 1
    factorials = [1] * (n + 1)
    for m in range(1, n + 1):
        f = f * m % MOD
        factorials[m] = f
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv = inv * m % MOD
        invs[m - 1] = inv

    return factorials, invs


def get_nhr(n, facts, invs, MOD):
    @lru_cache(maxsize=None)
    def nhr(r):
        return facts[n + r - 1] * invs[r] * invs[n - 1] % MOD

    return nhr


def solve(n, m):
    MOD = 998244353
    facts, invs = prepare(n + 3 * m, MOD)
    fn = facts[n]
    nhr = get_nhr(n, facts, invs, MOD)
    ans = 0
    for odd in range(m % 2, min(m, n) + 1, 2):
        tmp = nhr((3 * m - odd) // 2)
        if odd > 0:
            tmp -= odd * nhr((m - odd) // 2)
        if odd < n and odd <= m - 2:
            tmp -= (n - odd) * nhr((m - odd - 2) // 2)
        ans = (ans + fn * invs[odd] * invs[n - odd] % MOD * tmp) % MOD
    return ans


n, m = list(map(int, input().split()))
print(solve(n, m))
Problem p02969 (Python) — buggy submission, verdict: Runtime Error

r = int(input())
print(3 * r * r)


Error: TypeError: can't multiply sequence by non-int of type 'str'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02969/Python/s048208097.py", line 2, in <module>
    print(3 * r * r)
TypeError: can't multiply sequence by non-int of type 'str'


Fixed submission:

r = input()
print(3 * r * r)