alexjercan/bugnet huggingface dataset:
Problem p02732 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
data = [i for i in input().split()]

number_count = {}
for cmp in data:
    if cmp in number_count:
        number_count[cmp] += 1
        continue
    number_count[cmp] = 1

C_tot = 0
for cmp in number_count:
    C_tot += int(number_count[cmp] * (number_count[cmp] - 1) / 2)

for k in range(N):
    C = (
        C_tot
        - int(number_count[data[k]] * (number_count[data[k]] - 1) / 2)
        + int((number_count[data[k]] - 1) * (number_count[data[k]] - 2) / 2)
    )
    print(str(C))


Error: TLE

Fixed submission:

N = int(input())
data = [i for i in input().split()]

number_count = {}
for cmp in data:
    if cmp in number_count:
        number_count[cmp] += 1
        continue
    number_count[cmp] = 1

answer = {}
for i in range(N):
    if data[i] in answer:
        print(answer[data[i]])
        continue
    C = 0
    number_count_temp = number_count.copy()
    number_count_temp[str(data[i])] -= 1
    for cmp in number_count_temp:
        C += int(number_count_temp[cmp] * (number_count_temp[cmp] - 1) / 2)

    print(str(C))
    answer[data[i]] = str(C)
Problem p02732 (Python) — buggy submission, verdict: Time Limit Exceeded

from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
d = defaultdict(lambda: 0)
for i in range(len(A)):
    d[A[i]] += 1
total = 0
for k, v in d.items():
    total += v * (v - 1) // 2
for a in A:
    print(total - (d[a] - 1))


Error: TLE

Fixed submission:

from collections import defaultdict
import math

N = int(input())
A = list(map(int, input().split()))
d = defaultdict(lambda: 0)
for i in range(len(A)):
    d[A[i]] += 1

r = 2
total = 0
calc_dict = {}
for k, v in zip(d.keys(), d.values()):
    if v > 1:
        ans1 = math.factorial(v) // (math.factorial(v - r) * math.factorial(r))
    else:
        ans1 = 0
    if v > 2:
        ans2 = math.factorial(v - 1) // (math.factorial(v - 1 - r) * math.factorial(r))
    else:
        ans2 = 0
    total += ans1
    calc_dict[k] = ans1 - ans2
for i in range(N):
    print(total - calc_dict[A[i]])
Problem p02732 (Python) — buggy submission, verdict: Time Limit Exceeded

from collections import Counter

N = int(input())
A = list(map(int, input().split()))
C = Counter(A)
combinations = [0] + [c * (c - 1) // 2 for c in range(1, 1 + max(C.values()))]
_all = sum([combinations[c] for c in C.values()])
for a in A:
    print(_all - combinations[C[a]] + combinations[C[a] - 1])


Error: TLE

Fixed submission:

from collections import Counter
from math import factorial


def perm(n, r):
    return factorial(n) // factorial(n - r)


def comb(n, r):
    if n < r:
        return 0
    return perm(n, r) // factorial(r)


N = int(input())
A = list(map(int, input().split()))
C = Counter(A)
D = {k: comb(v, 2) for k, v in C.items()}
_all = sum(D.values())
for a in A:
    print(_all - D[a] + comb(C[a] - 1, 2))
Problem p02732 (Python) — buggy submission, verdict: Time Limit Exceeded

import collections as cl
import math


def combinations_count(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


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

cnt = cl.Counter(A)
ans = 0
for v in cnt.values():
    ans += combinations_count(v, 2)

for a in A:
    print(ans - cnt[a] + 1)


Error: TLE

Fixed submission:

import collections as cl
import math


def combinations_count(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


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

cnt = cl.Counter(A)
ans = 0
mem = {}

for a in A:
    if a in mem:
        print(mem[a])
        continue
    ans = 0
    cnt[a] -= 1
    for v in cnt.values():
        if v < 2:
            continue
        ans += combinations_count(v, 2)
    cnt[a] += 1
    print(ans)
    mem[a] = ans
Problem p02732 (Python) — buggy submission, verdict: Time Limit Exceeded

from collections import Counter

N = int(input())
lst = [int(x) for x in input().split()]
dic = dict(Counter(lst))

ret = 0
for k, v in dic.items():
    ret += v * (v - 1) // 2


for x in lst:
    n = dic[x]
    if n == 1:
        print(ret)
    else:
        print(ret - (n * (n - 1) // 2) + ((n - 1) * (n - 2) // 2))


Error: TLE

Fixed submission:

from collections import Counter

N = int(input())
lst = [int(x) for x in input().split()]
counters = Counter(lst)
dic = {}
for k, v in dict(counters).items():
    if v > 1:
        dic[k] = v

m = {}
for x in lst:
    n = m.get(x)
    if n is None:
        n = 0
        for k, v in dic.items():
            if k == x:
                v -= 1
            n += v * (v - 1) // 2

    m[x] = n
    print(n)
Problem p02733 (Python) — buggy submission, verdict: Time Limit Exceeded

from itertools import combinations, chain

H, W, K = map(int, input().split())
Sss = []
for _ in range(H):
    Sss.append(list(map(int, input())))


def h_divide(Sss, div_is):
    result = []
    for s, e in zip(chain([0], div_is), chain(div_is, [len(Sss)])):
        result.append(Sss[s:e])
    return result


def _v_end(Sss, start, K):
    count = 0
    for i in range(start, len(Sss[0])):
        s = sum(map(lambda Ss: Ss[i], Sss))
        if count + s > K:
            return i - 1
        count += s
    return len(Sss[0]) - 1


def v_end(Ssss, start, K):
    result = -1
    for Sss in Ssss:
        end = _v_end(Sss, start, K)
        if end < start:
            return -1
        if result < 0 or result > end:
            result = end
    return result


def v_div_count(Ssss, K):
    start, result = 0, 0
    while True:
        end = v_end(Ssss, start, K)
        if end < 0:
            return -1
        if end == len(Ssss[0][0]) - 1:
            break
        result += 1
        start = end + 1
    return result


h_cands = list(range(1, len(Sss)))
ans = -1
for n in range(len(h_cands) + 1):
    for comb in combinations(h_cands, n):
        if ans > 0 and n >= ans:
            continue
        Ssss = h_divide(Sss, list(comb))
        cnt = v_div_count(Ssss, K)
        if cnt < 0:
            continue
        if ans < 0 or ans > n + cnt:
            ans = n + cnt
print(ans)


Error: TLE

Fixed submission:

from itertools import combinations, chain

H, W, K = map(int, input().split())
Sss = []
for _ in range(H):
    Sss.append(list(map(int, input())))


def h_divide(Sss, div_is):
    result = []
    for s, e in zip(chain([0], div_is), chain(div_is, [len(Sss)])):
        result.append(Sss[s:e])
    return result


def _v_end(Sss, start, K):
    count = 0
    for i in range(start, len(Sss[0])):
        s = sum(map(lambda Ss: Ss[i], Sss))
        if count + s > K:
            return i - 1
        count += s
    return len(Sss[0]) - 1


def v_end(Ssss, start, K):
    result = -1
    for Sss in Ssss:
        end = _v_end(Sss, start, K)
        if end < start:
            return -1
        if result < 0 or result > end:
            result = end
    return result


def v_div_count(Ssss, K):
    start, result = 0, 0
    while True:
        end = v_end(Ssss, start, K)
        if end < 0:
            return -1
        if end == len(Ssss[0][0]) - 1:
            break
        result += 1
        start = end + 1
    return result


h_cands = list(range(1, len(Sss)))
ans = -1
for n in range(len(h_cands) + 1):
    for comb in combinations(h_cands, n):
        Ssss = h_divide(Sss, list(comb))
        cnt = v_div_count(Ssss, K)
        if cnt < 0:
            continue
        if ans < 0 or ans > n + cnt:
            ans = n + cnt
print(ans)
Problem p02733 (Python) — buggy submission, verdict: Time Limit Exceeded

import itertools

H, W, K = map(int, input().split())
A = [[int(x) for x in input()] for _ in range(H)]


def solve(blocks):
    n_block = len(blocks)
    n_cut = n_block - 1
    sums = [0 for _ in range(n_block)]

    for c in range(W):
        adds = [block[c] for block in blocks]
        if any(a > K for a in adds):
            return H * W

        sums = [s + a for s, a in zip(sums, adds)]
        if any(s > K for s in sums):
            n_cut += 1
            sums = adds

    return n_cut


ans = H * W
for mask in itertools.product([0, 1], repeat=H - 1):
    mask = [1] + list(mask) + [1]
    pivots = [r for r in range(H + 1) if mask[r]]
    blocks = [A[p1:p2] for p1, p2 in zip(pivots[:-1], pivots[1:])]
    blocks = [[sum(row[c] for row in block) for c in range(W)] for block in blocks]
    ans = min(ans, solve(blocks))
print(ans)


Error: TLE

Fixed submission:

import itertools
import numpy as np
from sys import stdin

H, W, K = map(int, stdin.readline().split())
A = np.int32([[int(x) for x in stdin.readline().strip()] for _ in range(H)])

ans = H * W
for mask in itertools.product([0, 1], repeat=H - 1):
    pivots = [r + 1 for r in range(H - 1) if mask[r]]
    if len(pivots) > ans:
        continue

    blocks = np.concatenate([block.sum(axis=0) for block in np.split(A, pivots)])
    blocks = blocks.reshape(len(pivots) + 1, W)
    if blocks.max() > K:
        continue

    n_block = blocks.shape[0]
    n_cut = n_block - 1
    sums = np.zeros(n_block, dtype=int)

    for c in range(W):
        adds = blocks[:, c]
        sums = sums + adds
        if np.any(sums > K):
            n_cut += 1
            sums = adds
            if n_cut >= ans:
                break

    ans = min(ans, n_cut)

print(ans)
Problem p02734 (Python) — buggy submission, verdict: Time Limit Exceeded

n, s = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353
dp = [[0] * (s + 1) for _ in range(n + 1)]
for i in range(n):
    dp[i][0] = 1
for i in range(n):
    ni = i + 1
    for j in range(s + 1):
        nj = j
        dp[ni][nj] += dp[i][j]
        dp[ni][nj] %= mod
        nj = j + A[i]
        if nj <= s:
            dp[ni][nj] += dp[i][j]
            dp[ni][nj] %= mod
ans = 0
for i in range(n + 1):
    ans += dp[i][s]
    ans %= mod
print(ans)


Error: TLE

Fixed submission:

import sys

input = sys.stdin.buffer.readline
n, s = map(int, input().split())
A = list(map(int, input().split()))
dp = [[0] * (s + 1) for _ in range(n + 1)]

mod = 998244353
# dp[i][s] A[i]まで見た時、合計sになる数。
# 各々の地点で新しく開始されるものも有るので毎回dp[i][0]は＋1
dp[0][0] = 1
ans = 0
for i in range(n):
    ni = i + 1
    for j in range(s + 1):
        nj = j
        dp[ni][nj] += dp[i][j]
        dp[ni][nj] %= mod
        nj = j + A[i]
        if nj <= s:
            dp[ni][nj] += dp[i][j]
            dp[ni][nj] %= mod
    dp[ni][0] += 1
    ans += dp[ni][s]
    ans %= mod
print(ans)
Problem p02734 (Python) — buggy submission, verdict: Time Limit Exceeded

n, s = map(int, input().split())
a = tuple(map(int, input().split()))
MOD = 998244353

# dp = [[0] * (s + 1) for _ in range(n + 1)]
# dp[0][0] = 1
# for i in range(n):  # ここをrange(i, n)にすると、f(i, r)の計算ができる
#     for j in range(s + 1):
#         dp[i + 1][j] += dp[i][j]  # do NOT use a[i]
#         if j + a[i] <= s:
#             dp[i + 1][j + a[i]] += dp[i][j]  # USE a[i]
# # f(1, n) = dp[n][s]
# # f(1, i) = dp[i][s] (i = 1, 2, ..., n)
# print('dp')
# print(*dp, sep='\\n')

dp0 = [[0] * (s + 1) for _ in range(n + 1)]
dp1 = [[0] * (s + 1) for _ in range(n + 1)]
dp0[0][0] = 1
ans = 0
for i in range(n):
    for j in range(s + 1):
        # i番目の要素は使わない
        dp0[i + 1][j] += dp0[i][j]
        dp0[i + 1][j] %= MOD
        dp1[i + 1][j] += dp0[i][j] + dp1[i][j]
        dp1[i + 1][j] %= MOD

        if j + a[i] <= s:
            dp1[i + 1][j + a[i]] += dp0[i][j] + dp1[i][j]
            dp1[i + 1][j + a[i]] %= MOD

    ans += dp1[i + 1][s]
    ans %= MOD
# dp[r][s][1] = \\sum_{i=1}^{r} f(i, r)

# print('dp[][][1]')
# for i in range(n + 1):
#     print([dp[i][j][1] for j in range(s + 1)])

print(ans)


Error: TLE

Fixed submission:

n, s = map(int, input().split())
a = tuple(map(int, input().split()))
MOD = 998244353

# dp0 = [[0] * (s + 1) for _ in range(n + 1)]
# dp0[0][0] = 1
# for i in range(n):  # ここをrange(i, n)にすると、f(i, r)の計算ができる
#     for j in range(s + 1):
#         dp0[i + 1][j] += dp0[i][j]  # do NOT use a[i]
#         if j + a[i] <= s:
#             dp0[i + 1][j + a[i]] += dp0[i][j]  # USE a[i]
# # f(1, n) = dp0[n][s]
# # f(1, i) = dp0[i][s] (i = 1, 2, ..., n)
# print('dp0')
# print(*dp0, sep='\\n')

dp = [[[0] * 2 for _ in range(s + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1
ans = 0
for i in range(n):
    for j in range(s + 1):
        # i番目の要素は使わない
        dp[i + 1][j][0] += dp[i][j][0]
        dp[i + 1][j][0] %= MOD
        dp[i + 1][j][1] += dp[i][j][0] + dp[i][j][1]
        dp[i + 1][j][1] %= MOD

        if j + a[i] <= s:
            dp[i + 1][j + a[i]][1] += dp[i][j][0] + dp[i][j][1]
            dp[i + 1][j + a[i]][1] %= MOD

    ans += dp[i + 1][s][1]
    ans %= MOD
# dp[r][s][1] = \\sum_{i=1}^{r} f(i, r)

# print('dp[][][1]')
# for i in range(n + 1):
#     print([dp[i][j][1] for j in range(s + 1)])

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

import numpy as np

n, s = map(int, input().split())
aaa = list(map(int, input().split()))

fwd_acc = np.zeros((n + 1, s + 1), dtype=np.int64)
fwd_acc[0][0] = 1

ans = 0
MOD = 998244353
for i, a in enumerate(aaa, start=1):
    fwd_acc[i] = fwd_acc[i - 1]
    fwd_acc[i][0] = i
    if a <= s:
        fwd_acc[i][a:] = fwd_acc[i][a:] + fwd_acc[i][:-a]
    fwd_acc[i] %= MOD
    ans = (ans + fwd_acc[i][s]) % MOD
    # print(fwd_acc)
    # print(ans)
print(ans)


Error: TLE

Fixed submission:

import numpy as np

n, s = map(int, input().split())
aaa = list(map(int, input().split()))

fwd_acc = np.zeros((n + 1, s + 1), dtype=np.int64)
fwd_acc[0][0] = 1

ans = 0
MOD = 998244353
for i, a in enumerate(aaa, start=1):
    fwd_acc[i] = fwd_acc[i - 1]
    fwd_acc[i][0] = i
    if a <= s:
        fwd_acc[i][a:] += fwd_acc[i][:-a]
    ans = (ans + fwd_acc[i - 1][s - a] * (n - i + 1)) % MOD
print(ans)
Problem p02734 (Python) — buggy submission, verdict: Time Limit Exceeded

N, S = map(int, input().split())
A = [0] + list(map(int, input().split()))
mod = 998244353

dp = [0] * (S + 1)
dp2 = [0] * (S + 1)

"""
dp[i][j] = (i個までの数を使ってj点とる組み合わせ)
としたはいいが、f(L, R)をf(1,L)とf(1, R)に分解できずに爆死したのが敗因。

各(L, R)に対してdpするとTLEになるから手詰まりになると思ったわけだけど、
上のdpテーブルを各iに対して使い回しつつ、新たなdpテーブル[1, 0, 0, ...]を
作成して「元のdpテーブルに加算しておけば」dpテーブル一個で1番目スタート、2番目スタート、
..., L番目スタートのdpテーブル全てを考えられる！
（解説放送前半を参考）
"""

# i == 0の時
dp[0] = 1
ans = 0

# i >= 1の時
for i in range(1, N + 1):
    for j in range(S + 1):
        if j - A[i] < 0:
            dp2[j] = dp[j]
        else:
            dp2[j] = dp[j] + dp[j - A[i]]
    ans += dp2[S]
    ans %= mod

    dp = dp2  # deepcopyしなくてもこれで十分なはずだし、ポインタ渡しなので高速？
    dp[0] += 1
    dp2 = [0] * (S + 1)

print(ans)


Error: TLE

Fixed submission:

from copy import deepcopy

N, S = map(int, input().split())
A = [0] + list(map(int, input().split()))
mod = 998244353

dp = [0] * (S + 1)
dp2 = [0] * (S + 1)

"""
dp[i][j] = (i個までの数を使ってj点とる組み合わせ)
としたはいいが、f(L, R)をf(1,L)とf(1, R)に分解できずに爆死したのが敗因。

各(L, R)に対してdpするとTLEになるから手詰まりになると思ったわけだけど、
上のdpテーブルを各iに対して使い回しつつ、新たなdpテーブル[1, 0, 0, ...]を
作成して「元のdpテーブルに加算しておけば」dpテーブル一個で1番目スタート、2番目スタート、
..., L番目スタートのdpテーブル全てを考えられる！
（解説放送前半を参考）
"""

# i == 0の時
dp[0] = 1
ans = 0

# i >= 1の時
for i in range(1, N + 1):
    for j in range(S + 1):
        if j - A[i] < 0:
            dp2[j] = dp[j]
        else:
            dp2[j] = dp[j] + dp[j - A[i]]
    ans += dp2[S]
    ans %= mod

    dp = deepcopy(dp2)
    dp[0] += 1
    dp2 = [0] * (S + 1)

print(ans)
Problem p02735 (Python) — buggy submission, verdict: Time Limit Exceeded

import sys


def input():
    return sys.stdin.readline().strip()


def main():
    H, W = map(int, input().split())

    S = [list(input()) for _ in range(H)]
    # print(S)
    check = [[10**9 for i in range(W)] for j in range(H)]
    if S[0][0] == "#":
        check[0][0] = 1
    else:
        check[0][0] = 0
    for i in range(1, W):
        left = check[0][i - 1]
        if S[0][i] == "#":
            if S[0][i - 1] == "#":
                check[0][i] = left
            else:
                check[0][i] = left + 1
        else:
            check[0][i] = left
    for i in range(1, H):
        up = check[i - 1][0]
        if S[i][0] == "#":
            if S[i - 1][0] == "#":
                check[i][0] = up
            else:
                check[i][0] = up + 1
        else:
            check[i][0] = up
    for i in range(1, H):
        for j in range(1, W):
            # print(S[i][j])
            left = check[i][j - 1]
            up = check[i - 1][j]
            if S[i][j] == "#":
                if S[i][j - 1] == "#" and S[i - 1][j] == "#":
                    check[i][j] = min(left, up)
                elif S[i][j - 1] != "#" and S[i - 1][j] == "#":
                    check[i][j] = min(left + 1, up)
                elif S[i][j - 1] == "#" and S[i - 1][j] != "#":
                    check[i][j] = min(left, up + 1)
                else:
                    check[i][j] = min(left, up) + 1
            else:
                check[i][j] = min(left, up)
    # print(check)
    print(check[-1][-1])


main()


Error: TLE

Fixed submission:

import sys
from itertools import permutations


def input():
    return sys.stdin.readline().strip()


def main():
    H, W = map(int, input().split())

    S = [list(input()) for _ in range(H)]
    C = [2 * i for i in range(H - 1)] + [2 * j + 1 for j in range(W - 1)]
    check = list(permutations(C))
    answer = float("inf")
    for chk in check:
        if S[0][0] == "#":
            cnt = 1
        else:
            cnt = 0
        now = [0, 0]
        for i in range(H + W - 2):
            if chk[i] % 2 == 0:
                now[0] += 1
            else:
                now[1] += 1
            if now[0] <= H - 1 and now[1] <= W - 1:
                if S[now[0]][now[1]] == "#":
                    cnt += 1
            # print(now)
            # print(cnt)
        if cnt < answer:
            answer = cnt
    print(answer)


main()
Problem p02735 (Python) — buggy submission, verdict: Time Limit Exceeded

#!/usr/bin/env python3
from collections import deque

h, w = map(int, input().split())
maze = [[i == "#" for i in input()] for _ in range(h)]

dx = [1, 0]
dy = [0, 1]

que = deque([])
que.append((0, 0, maze[0][0], 1 if maze[0][0] else 0))
count = [[h + w] * w for _ in range(h)]

while que:
    x, y, b, c = que.pop()
    if c >= count[x][y]:
        continue
    count[x][y] = c
    if x == h - 1 and y == w - 1:
        continue
    for i in range(2):
        nx = x + dx[i]
        ny = y + dy[i]

        if not (0 <= nx < h and 0 <= ny < w):
            continue
        que.append((nx, ny, maze[nx][ny], c + (not b and maze[nx][ny])))
print(count[h - 1][w - 1])


Error: TLE

Fixed submission:

#!/usr/bin/env python3
from collections import deque

h, w = map(int, input().split())
maze = [[i == "#" for i in input()] for _ in range(h)]

dx = [1, 0]
dy = [0, 1]

que = deque([])
que.append((0, 0, maze[0][0], 1 if maze[0][0] else 0))
count = 10**5

while que:
    x, y, b, c = que.pop()
    if x == h - 1 and y == w - 1:
        count = min(count, c)
    elif c < count:
        for i in range(2):
            nx = x + dx[i]
            ny = y + dy[i]

            if not (0 <= nx < h and 0 <= ny < w):
                continue
            que.append((nx, ny, maze[nx][ny], c + (not b and maze[nx][ny])))
print(count)
Problem p02741 (Python) — buggy submission, verdict: Runtime Error

list = [
    1,
    1,
    1,
    2,
    1,
    2,
    1,
    5,
    2,
    2,
    1,
    5,
    1,
    2,
    1,
    14,
    1,
    5,
    1,
    5,
    2,
    2,
    1,
    15,
    2,
    2,
    5,
    4,
    1,
    4,
    1,
    51,
]
firstInputText = input()
print(list[int(firstInputText) - 1])


Error: IndexError: list index out of range
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02741/Python/s436801336.py", line 6, in <module>
    b = int(inputList[1])
IndexError: list index out of range


Fixed submission:

import math

firstInputText = input()
inputList = firstInputText.split()
a = int(inputList[0])
b = int(inputList[1])
c = int(inputList[2])
x = math.sqrt(a) + math.sqrt(b)
y = math.sqrt(c)
# print(x)
# print(y)

# if math.isclose(x,y):
#     print("Yes")
# else:
#     print("No")
if x == y:
    print("No")
elif x < y:
    print("Yes")
else:
    print("No")
Problem p02741 (Python) — buggy submission, verdict: Runtime Error

num = [
    1,
    1,
    1,
    2,
    1,
    2,
    1,
    5,
    2,
    2,
    1,
    5,
    1,
    2,
    1,
    14,
    1,
    5,
    1,
    5,
    2,
    2,
    1,
    15,
    2,
    2,
    5,
    4,
    1,
    4,
    1,
    51,
]
input = int(input())
print(num[input - 1])


Error: WA

Fixed submission:

num = [
    1,
    1,
    1,
    2,
    1,
    2,
    1,
    5,
    2,
    2,
    1,
    5,
    1,
    2,
    1,
    14,
    1,
    5,
    1,
    5,
    2,
    2,
    1,
    15,
    2,
    2,
    5,
    4,
    1,
    4,
    1,
    51,
]
input = int(input())
print(num[input])
Problem p02742 (Python) — buggy submission, verdict: Runtime Error

H, W = map(int, input().split())

if H == 1 or W == 1:
    print(1)
else:
    if (H * W) % 2 == 1:
        ans = H * W // 2 + 1
    else:
        ans = H * W // 2
    print(ans)


Error: 0

Fixed submission:

H, W = map(int, input().split())

if H == 1 or W == 1:
    print(1)
else:
    if (H * W) % 2 == 1:
        ans = H * W // 2 + 1
    else:
        ans = H * W // 2
print(ans)
Problem p02742 (Python) — buggy submission, verdict: Runtime Error

import math

h, w = map(int, input().split())

if h == 1 or w == 1:
    ans = 1
elif (h * w) % 2 == 0:
    ans = (h * w) // 2
else:
    ans = (h // 2) * w + math.ceil(w / 2)

print(ans)


Error: 0

Fixed submission:

import math

h, w = map(int, input().split())

if h == 1 or w == 1:
    print(1)
elif (h * w) % 2 == 0:
    ans = (h * w) // 2
else:
    ans = (h // 2) * w + math.ceil(w / 2)

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

from math import sqrt
from decimal import Decimal, getcontext

a, b, c = map(int, input().split())
if c - a - b > 0 and (c - a - b) ** 2 > 4 * a * b:
    print("Yes")
else:
    print("No")


Error: 0

Fixed submission:

from math import sqrt, isclose

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

if isclose(sqrt(c) - (sqrt(a) + sqrt(b)), 0):
    print("Yes")
else:
    print("No")
Problem p02743 (Python) — buggy submission, verdict: Runtime Error

from decimal import Decimal

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

A = Decimal(a) ** k + Decimal(b) ** k
C = Decimal(c) ** k
if A < C:
    print("Yes")
else:
    print("No")


Error: TypeError: unsupported operand type(s) for ** or pow(): 'decimal.Decimal' and 'float'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02743/Python/s242676501.py", line 6, in <module>
    A = Decimal(a) ** (1 / 2) + Decimal(b) ** (1 / 2)
TypeError: unsupported operand type(s) for ** or pow(): 'decimal.Decimal' and 'float'


Fixed submission:

from decimal import Decimal

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


A = Decimal(a) ** (1 / 2) + Decimal(b) ** (1 / 2)
C = Decimal(c) ** (1 / 2)
if A < C:
    print("Yes")
else:
    print("No")
Problem p02743 (Python) — buggy submission, verdict: Runtime Error

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

if c - a - b > 0:
    if 4 * a * b < (c - a - b) ** 2:
        print("Yes")
    else:
        print("No")
else:
    print("No")


Error: TypeError: unsupported operand type(s) for -: 'str' and 'str'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02743/Python/s899697147.py", line 3, in <module>
    if c - a - b > 0:
TypeError: unsupported operand type(s) for -: 'str' and 'str'


Fixed submission:

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

if c - a - b > 0:
    if 4 * a * b < (c - a - b) ** 2:
        print("Yes")
    else:
        print("No")
else:
    print("No")