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

import collections

n = int(input())
a = list(map(int, input().split()))
q = int(input())
bc = [list(map(int, input().split())) for i in range(q)]

ans = sum(a)
num = collections.Counter(a)

for i in range(q):
    before = bc[i][0]
    after = bc[i][1]
    ans += num[before] * (after - before)
    num[after] += num[before]
    num[before] = 0
    # print(a.count(before))
    # print(num(before))
    print(ans)


Error: TLE

Fixed submission:

n = int(input())
a = list(map(int, input().split()))
q = int(input())
b_c = [list(map(int, input().split())) for i in range(q)]

ans = 0

for i in range(q):
    before = b_c[i][0]
    after = b_c[i][1]
    while before in a:
        a[a.index(before)] = after
    ans = sum(a)
    print(ans)
Problem p02630 (Python) — buggy submission, verdict: Time Limit Exceeded

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

dictA = {}

for z in A:
    dictA.setdefault(z, 0)
    dictA[z] += 1

sumA = sum(A)

BC = [list(map(int, input().split())) for i in range(Q)]
for x in BC:
    if x[0] in dictA.keys():
        sumA += (x[1] - x[0]) * dictA[x[0]]
        dictA.setdefault(x[1], 0)
        dictA[x[1]] += dictA[x[0]]
        dictA.pop(x[0])
    print(sumA)


Error: TLE

Fixed submission:

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

dictA = {}

for z in A:
    dictA.setdefault(z, 0)
    dictA[z] += 1


BC = [list(map(int, input().split())) for i in range(Q)]
for x in BC:
    if x[0] in dictA.keys():
        dictA.setdefault(x[1], 0)
        dictA[x[1]] += dictA[x[0]]
        dictA.pop(x[0])
        # print(dictA)

    sumA = 0
    for k, v in dictA.items():
        sumA += k * v
    print(sumA)
Problem p02630 (Python) — buggy submission, verdict: Time Limit Exceeded

from collections import Counter

n = int(input())
a = list(map(int, input().split()))
sum_a = sum(a)
count_a = Counter(a)
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    tmp = count_a[b]
    new = {c: tmp}
    count_a.update(new)
    del count_a[b]
    sum_a = sum_a - b * tmp + c * tmp
    print(sum_a)


Error: TLE

Fixed submission:

n = int(input())
a = list(input().split())
q = int(input())
for i in range(q):
    b, c = input().split()
    replace_a = [i.replace(b, c) if i == b else i for i in a]
    print(sum(map(int, replace_a)))
    a = replace_a
Problem p02630 (Python) — buggy submission, verdict: Runtime Error

from collections import defaultdict

N, _A, Q, *val = [[*map(int, line.split())] for line in open(0)]
N = N[0]
Q = Q[0]

A = defaultdict(int)
for _a in _A:
    A[_a] += 1

ans = sum(_A)
for v in val:
    if v[0] in A.keys():
        num = A[v[0]]
        A[v[0]] = 0
        A[v[1]] += num
        ans += (v[1] - v[0]) * num
    print(ans)


Error: WA

Fixed submission:

from collections import defaultdict

N = int(input())
_A = [*map(int, input().split())]
Q = int(input())
val = [[*map(int, line.split())] for line in open(0)]

A = defaultdict(int)
for _a in _A:
    A[_a] += 1

ans = sum(_A)
for v in val:
    if v[0] in A.keys():
        num = A[v[0]]
        A[v[0]] = 0
        A[v[1]] += num
        ans += (v[1] - v[0]) * num
    print(ans)
Problem p02630 (Python) — buggy submission, verdict: Runtime Error

import collections

N = int(input())
A = list(map(int, input().split()))  # (N,)
Q = int(input())
B, C = zip(*[list(map(int, input().split())) for _ in range(Q)])  # (Q,), (Q,)

cur_sum = 0
value_count_map = collections.defaultdict(int)
for a in A:
    cur_sum += a
    value_count_map[a] += 1

for b, c in zip(B, C):
    b_cnt = value_count_map.get(b, 0)
    value_count_map[b] = 0
    value_count_map[c] += b_cnt
    cur_sum += b_cnt * (c - b)
    print(cur_sum)


Error: 0

Fixed submission:

import collections

N = int(input())
A = list(map(int, input().split()))  # (N,)
Q = int(input())
B, C = zip(*[list(map(int, input().split())) for _ in range(Q)])  # (Q,), (Q,)

value_count_map = collections.defaultdict(int)
value_sum_map = collections.defaultdict(int)
for a in A:
    value_count_map[a] += 1
    value_sum_map[a] += a

for b, c in zip(B, C):
    b_cnt = value_count_map[b]
    value_count_map[c] += b_cnt
    value_sum_map[c] += c * b_cnt
    if b in value_count_map:
        del value_count_map[b]
        del value_sum_map[b]
    print(sum(v for v in value_sum_map.values()))
Problem p02630 (Python) — buggy submission, verdict: Time Limit Exceeded

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

a = [0] * (10**5 + 1)
ans = sum(A)

for i in range(N):
    a[A[i]] += 1

for i in range(Q):
    B, C = map(int, input().split())
    ans += a[B] * (C - B)
    a[C] += a[B]
    a[B] = 0
    print(ans)


Error: TLE

Fixed submission:

N = int(input())
A = list(map(str, input().split()))
Q = int(input())
L = [list(map(str, input().split())) for i in range(Q)]

for j in range(Q):
    A = [k.replace(L[j][0], L[j][1]) for k in A]
    B = sum(map(int, A))
    print(B)
Problem p02630 (Python) — buggy submission, verdict: Time Limit Exceeded

from collections import Counter

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

cnt = Counter(a)

s = sum(a)

for i in range(q):
    b, c = map(int, input().split())
    s = s - b * cnt[b]
    s = s + c * cnt[b]
    cnt[c] += cnt[b]
    cnt[b] = 0
    print(s)


Error: TLE

Fixed submission:

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
for i in range(Q):
    B, C = map(int, input().split())
    for i in range(N):
        if A[i] == B:
            A[i] = C
    print(sum(A))
Problem p02630 (Python) — buggy submission, verdict: Time Limit Exceeded

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

dic = {}
for num in A:
    if num in dic:
        dic[num] += 1
    else:
        dic[num] = 1

prev_sum = 0

for key, value in dic.items():
    prev_sum += key * value

for _ in range(Q):
    B, C = map(int, input().split())
    if B in dic and C in dic:
        dic[C] += dic[B]
        dif = (C - B) * dic[B]
        prev_sum += dif
        del dic[B]
    elif B in dic and C not in dic:
        dic[C] = dic[B]
        dif = (C - B) * dic[B]
        prev_sum += dif
        del dic[B]
    print(prev_sum)


Error: TLE

Fixed submission:

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

dic = {}
for num in A:
    if num in dic:
        dic[num] += 1
    else:
        dic[num] = 1

for _ in range(Q):
    total = 0
    B, C = map(int, input().split())
    if B in dic and C in dic:
        dic[C] += dic[B]
        del dic[B]
    elif B in dic and C not in dic:
        dic[C] = dic[B]
        del dic[B]
    for mykey, myvalue in dic.items():
        total += mykey * myvalue
    print(total)
Problem p02630 (Python) — buggy submission, verdict: Time Limit Exceeded

import sys
import numpy as np
from collections import Counter

# 実行環境(0:vscode, 1:atcoder)
MODE = 1

# 入力の次元
DIMENSION = 2

# int型に変換
INT_TYPE = 1

if not (MODE):
    with open("input.txt", "r") as f:
        s = f.read()
else:
    s = sys.stdin.read()

if DIMENSION == 0:
    if INT_TYPE == 1:
        s = int(s)
elif DIMENSION == 1:
    if INT_TYPE == 0:
        s = s.split()
    elif INT_TYPE == 1:
        s = [int(x) for x in s.split()]
elif DIMENSION == 2:
    if INT_TYPE == 0:
        s = [x.split() for x in s.splitlines()]
    elif INT_TYPE == 1:
        s = [[int(y) for y in x.split()] for x in s.splitlines()]

N = s[0][0]
A = np.array(s[1])
Q = s[2][0]
BC = np.array(s[3:])
B = BC[:, 0]
C = BC[:, 1]

A_sum = np.sum(A)

D = Counter(A)

for i in range(Q):
    b = B[i]
    c = C[i]
    A_sum += D[b] * (c - b)
    print(A_sum)
    D[c] += D[b]
    D[b] = 0


Error: TLE

Fixed submission:

import sys
import numpy as np

# 実行環境(0:vscode, 1:atcoder)
MODE = 1

# 入力の次元
DIMENSION = 2

# int型に変換
INT_TYPE = 1

if not (MODE):
    with open("input.txt", "r") as f:
        s = f.read()
else:
    s = sys.stdin.read()

if DIMENSION == 0:
    if INT_TYPE == 1:
        s = int(s)
elif DIMENSION == 1:
    if INT_TYPE == 0:
        s = s.split()
    elif INT_TYPE == 1:
        s = [int(x) for x in s.split()]
elif DIMENSION == 2:
    if INT_TYPE == 0:
        s = [x.split() for x in s.splitlines()]
    elif INT_TYPE == 1:
        s = [[int(y) for y in x.split()] for x in s.splitlines()]

N = s[0][0]
A = np.array(s[1])
Q = s[2][0]
BC = np.array(s[3:])
B = BC[:, 0]
C = BC[:, 1]

A_sum = np.sum(A)

D = np.array([np.count_nonzero(A == i) for i in range(100001)])
for i in range(Q):
    b = B[i]
    c = C[i]
    A_sum += D[b] * (c - b)
    print(A_sum)
    D[c] += D[b]
    D[b] = 0
Problem p02630 (Python) — buggy submission, verdict: Time Limit Exceeded

import bisect

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = [0] * Q
C = [0] * Q
for i in range(Q):
    B[i], C[i] = map(int, input().split())

DP = [0] * (10**5 + 1)

for i in range(len(A)):
    DP[A[i]] += 1

Sum = sum(A)

for i in range(Q):
    Sum += (C[i] - B[i]) * DP[B[i]]
    DP[C[i]] += DP[B[i]]
    DP[B[i]] = 0
    print(Sum)


Error: TLE

Fixed submission:

import bisect

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = [0] * Q
C = [0] * Q
for i in range(Q):
    B[i], C[i] = map(int, input().split())

A.sort()
Sum = sum(A)

for i in range(Q):
    L = bisect.bisect_left(A, B[i])
    R = bisect.bisect_right(A, B[i])
    num = R - L
    Sum += num * (C[i] - B[i])

    for j in range(L, R):
        A[j] = C[i]

    A.sort()
    print(Sum)
Problem p02630 (Python) — buggy submission, verdict: Runtime Error

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

B = []
C = []
for _ in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

d = [0] * (10**5 + 7)
for a in A:
    d[a] += 1
sum_a = sum(A)
for j in range(Q):
    before = d[C[j]]
    d[C[j]] += d[B[j]]
    sum_a -= d[B[j]] * B[j]

    sum_a += (d[C[j]] - before) * C[j]
    d[B[j]] = 0
    print(sum_a)


Error: 0

Fixed submission:

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

B = []
C = []
for _ in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

d = [0] * 10
for a in A:
    d[a] += 1
sum_a = sum(A)
for j in range(Q):
    d[C[j]] += d[B[j]]
    sum_a -= d[B[j]] * B[j]

    sum_a += (d[C[j]] - d[B[j]]) * C[j]
    d[B[j]] = 0
    print(sum_a)
Problem p02630 (Python) — buggy submission, verdict: Time Limit Exceeded

import sys
import numpy as np

_ = sys.stdin.readline()
A = list(map(int, sys.stdin.readline().split()))
Q = int(sys.stdin.readline())
replace_map = [list(map(int, sys.stdin.readline().split())) for _ in range(Q)]

nums = {}
for a in A:
    nums[a] = nums[a] + 1 if a in nums else 1

previous_sum = 0
for search, replace in replace_map:
    replaced_count = 0
    if search in nums:
        replaced_count = nums[search]
        nums[replace] = (
            nums[replace] + replaced_count if replace in nums else replaced_count
        )
        del nums[search]
    if previous_sum == 0:
        previous_sum = np.dot(list(nums.keys()), list(nums.values()))
    else:
        previous_sum += replaced_count * (replace - search)
    print(previous_sum)


Error: TLE

Fixed submission:

import sys
import numpy as np

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
Q = int(sys.stdin.readline())
replace_map = [list(map(int, sys.stdin.readline().split())) for _ in range(Q)]

nums = {}
for a in A:
    nums[a] = nums[a] + 1 if a in nums else 1

for search, replace in replace_map:
    if search in nums:
        nums[replace] = nums[replace] + nums[search] if replace in nums else nums[search]
        del nums[search]
    print(np.dot(list(nums.keys()), list(nums.values())))
Problem p02630 (Python) — buggy submission, verdict: Time Limit Exceeded

from collections import Counter

n = int(input())
a = list(map(int, input().split()))
q = int(input())
bc = [list(map(int, input().split())) for _ in range(q)]

x = Counter(a)
ans = sum(a)
for b, c in bc:
    ans += (c - b) * x[b]
    print(ans)
    x[c] += x[b]
    x[b] = 0


Error: TLE

Fixed submission:

from collections import Counter

n = int(input())
a = list(map(int, input().split()))
q = int(input())
bc = [list(map(int, input().split())) for _ in range(q)]

x = Counter(a)
for b, c in bc:
    x[c] += x[b]
    x[b] = 0

    ans = 0
    for key, value in x.most_common():
        ans += key * value
    print(ans)
Problem p02630 (Python) — buggy submission, verdict: Time Limit Exceeded

from collections import Counter

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

Q = int(input())
BC = [list(map(int, input().split())) for _ in range(Q)]

d = Counter(A)

sub_s = sum(A)

for b, c in BC:
    sub_s += d[b] * (c - b)
    d[c] += d[b]
    d[b] = 0

    print(sub_s)


Error: TLE

Fixed submission:

from collections import Counter

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

Q = int(input())
BC = [list(map(int, input().split())) for _ in range(Q)]

d = Counter(A)

for b, c in BC:
    d[c] += d[b]
    d[b] = 0

    li = [k * v for k, v in d.items()]
    print(sum(li))
Problem p02630 (Python) — buggy submission, verdict: Time Limit Exceeded

from collections import Counter

N = int(input())

target_list = list(map(int, input().split()))
check = Counter(target_list)
result = sum(target_list)


for index in range(int(input())):
    B, C = map(int, input().split())
    if B in check:
        result = result + (check[B]) * (C - B)
        if C in check:
            check[C] = check[C] + check[B]
        else:
            check[C] = check[B]
        check[B] = 0
    print(result)


Error: TLE

Fixed submission:

from collections import Counter
import copy

N = int(input())

target_list = list(map(int, input().split()))
check = [Counter(target_list)]
result_list = [sum(target_list)]


for index in range(int(input())):
    B, C = map(int, input().split())
    if B in check[index]:
        result = copy.deepcopy(check[index])
        change = result.pop(B)
        diff = change * (C - B)
        if C in result:
            result[C] = result[C] + change
        else:
            result[C] = change

    else:
        result = copy.deepcopy(check[index])
        diff = 0
    check.append(result)
    print(result_list[index] + diff)
    result_list.append(result_list[index] + diff)
Problem p02630 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BC = [map(int, input().split()) for _ in range(Q)]
B, C = [list(i) for i in zip(*BC)]

sum = 0
size = 10**5 + 1
list = [0] * size
for a in A:
    list[a] += 1
    sum += a

for i in range(Q):
    sum = sum + C[i] * list[B[i]] - B[i] * list[B[i]]
    list[C[i]] += list[B[i]]
    list[B[i]] = 0
    print(sum)


Error: TLE

Fixed submission:

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BC = [map(int, input().split()) for _ in range(Q)]
B, C = [list(i) for i in zip(*BC)]

for i in range(Q):
    A_replace = [C[i] if a == B[i] else a for a in A]
    A = A_replace
    print(sum(A))
Problem p02631 (Python) — buggy submission, verdict: Time Limit Exceeded

# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


def solve():
    N = int(input())
    As = list(map(int, input().split()))

    digits = dict()
    for d in range(30):
        digits[d] = 0
        for a in As:
            digits[d] += a >> d & 1

    oore = 0
    for k, v in digits.items():
        oore += (v % 2) << k

    nums = [0] * N

    for i, a in enumerate(As):
        nums[i] = a ^ oore

    return nums


def main():
    print(*solve())


if __name__ == "__main__":
    main()


Error: TLE

Fixed submission:

# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


def solve():
    N = int(input())
    As = list(map(int, input().split()))

    digits = dict()
    for d in range(30):
        digits[d] = 0
        for a in As:
            digits[d] += a >> d & 1

    oore = dict()
    for k, v in digits.items():
        oore[k] = v % 2

    nums = [0] * N

    for i, a in enumerate(As):
        for d in range(30):
            nums[i] += ((a >> d & 1) ^ (oore[d])) << d

    return nums


def main():
    print(*solve())


if __name__ == "__main__":
    main()
Problem p02631 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
a = [int(i) for i in input().split()]


ans = []
alld = 0

for aa in a:
    alld = alld ^ aa

for aa in a:
    ans.append(alld ^ aa)

ans = [str(i) for i in ans]
print(" ".join(ans))


Error: TLE

Fixed submission:

n = int(input())
a = [int(i) for i in input().split()]


ans = []
for i in range(n):
    temp = 0
    for j, aa in enumerate(a):
        if j == i:
            continue
        temp = temp ^ aa
    ans.append(temp)

ans = [str(i) for i in ans]
print(" ".join(ans))
Problem p02631 (Python) — buggy submission, verdict: Time Limit Exceeded

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

# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    n = int(input())
    a_list = input_to_int_tuple()

    all = 0
    for v in a_list:
        all ^= v

    ret = ""
    for v in a_list:
        ret += str(all ^ v) + " "

    print(ret.rstrip())


if __name__ == "__main__":
    main()


Error: TLE

Fixed submission:

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

# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    n = int(input())
    a_list = input_to_int_tuple()

    ret = ""
    for i in range(n):
        my = 0
        for j, v in enumerate(a_list):
            if i == j:
                continue

            my ^= v

        ret += str(my) + " "

    print(ret.rstrip())


if __name__ == "__main__":
    main()
Problem p02631 (Python) — buggy submission, verdict: Time Limit Exceeded

import numpy as np

N = int(input())
a = np.fromstring(input(), sep=" ", dtype=np.int64)
b = np.bitwise_xor.reduce(a)
c = np.bitwise_xor(a, b)
print(*c, sep=" ")


Error: TLE

Fixed submission:

import numpy as np

N = int(input())
a = np.fromstring(input(), sep=" ", dtype=np.int64)
# b = np.bitwise_xor.reduce(a)
# c = np.bitwise_xor(a, b)
# print(*c, sep=" ")
for n in range(N):
    print(np.bitwise_xor.reduce(a) ^ a[n])
Problem p02632 (Python) — buggy submission, verdict: Time Limit Exceeded

def comb(n, r, p):
    return fac[n] * facinv[r] * facinv[n - r] % p


def comb_pre(N_UNTIL, p):
    for i in range(2, N_UNTIL + 1):
        fac.append(fac[i - 1] * i % p)
        inv.append(-inv[p % i] * (p // i) % p)
        facinv.append(facinv[-1] * inv[-1] % p)


fac = [1, 1]
facinv = [1, 1]
inv = [0, 1]

K = int(input())
S = input()
N = len(S)
MOD = 1_000_000_007
comb_pre(N + K - 1, MOD)
ans = 0
for i in range(K + 1):
    tmp = pow(25, K - i, MOD)
    tmp *= comb(N + K - i - 1, K - i, MOD)
    tmp %= MOD
    tmp *= pow(26, i, MOD)
    tmp %= MOD
    ans += tmp
    ans %= MOD
print(ans)


Error: TLE

Fixed submission:

import numpy as np
from numba import njit


def comb(n, r, p):
    r = min(r, n - r)
    ret = fac[n]
    ret = ret * facinv[r] % p
    return ret * facinv[n - r] % p


@njit
def comb_init(N_UNTIL, p):
    N_UNTIL += 1
    inv = np.empty(N_UNTIL, np.int64)
    fac = np.empty(N_UNTIL, np.int64)
    facinv = np.empty(N_UNTIL, np.int64)
    inv[0] = 0
    inv[1] = 1
    fac[0] = 1
    facinv[0] = 1
    for i in range(2, N_UNTIL):
        inv[i] = -inv[p % i] * (p // i) % p
    for i in range(1, N_UNTIL):
        fac[i] = fac[i - 1] * i % p
    for i in range(1, N_UNTIL):
        facinv[i] = facinv[i - 1] * inv[i] % p
    return inv, fac, facinv


K = int(input())
S = input()
N = len(S)
MOD = 1_000_000_007
inv, fac, facinv = comb_init(N + K - 1, MOD)
ans = 0
for i in range(K + 1):
    tmp = pow(25, K - i, MOD)
    tmp *= comb(N + K - i - 1, K - i, MOD)
    tmp %= MOD
    tmp *= pow(26, i, MOD)
    tmp %= MOD
    ans += tmp
    ans %= MOD
print(ans)
Problem p02632 (Python) — buggy submission, verdict: Time Limit Exceeded

k = int(input())
n = len(input())
p = 10**9 + 7
a = 1
fct = [a]
for i in range(1, n + k + 1):
    a = (a * i) % p
    fct.append(a)
b = pow(fct[-1], p - 2, p)
inv = [b]
for i in range(1, n + k + 1)[::-1]:
    b = (b * i) % p
    inv.append(b)
inv.reverse()
ans = 0
pow25, pow26 = [1], [1]
for i in range(1, k + 1):
    pow25.append((pow25[-1] * 25) % p)
    pow26.append((pow26[-1] * 26) % p)
for i in range(k + 1):
    c = fct[i + n - 1] * inv[i] * inv[n - 1]
    ans += pow25[i] * pow26[k - i] * c
    ans %= p
print(ans)


Error: TLE

Fixed submission:

k = int(input())
n = len(input())
p = 10**9 + 7
fct, inv = [1], [1]
a, b = 1, 1
for i in range(1, n + k + 1):
    a = (a * i) % p
    b = (b * pow(i, p - 2, p)) % p
    fct.append(a)
    inv.append(b)
ans = 0
for i in range(k + 1):
    c = fct[i + n - 1] * inv[i] * inv[n - 1]
    ans += pow(25, i, p) * pow(26, k - i, p) * c
    ans %= p
print(ans)
Problem p02639 (Python) — buggy submission, verdict: Runtime Error

# -*- coding: utf-8 -*-
a, b, c, d, e = map(int, input().split())

suuji_list = ["", a, b, c, d, e]

print(suuji_list.index(0))


Error: TypeError: descriptor 'index' for 'list' objects doesn't apply to a 'int' object
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02639/Python/s072466363.py", line 6, in <module>
    print(list.index(0))
TypeError: descriptor 'index' for 'list' objects doesn't apply to a 'int' object


Fixed submission:

# -*- coding: utf-8 -*-
a, b, c, d, e = map(int, input().split())

suuji_list = ["", a, b, c, d, e]

print(list.index(0))
Problem p02639 (Python) — buggy submission, verdict: Runtime Error

nums = [int(x) for x in input().split(" ")]

for i in range(5):
    if nums[i] == 0:
        print(i + 1)
        exit(0)


Error: ValueError: invalid literal for int() with base 10: ' '
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02639/Python/s316600506.py", line 1, in <module>
    nums = [int(x) for x in input()]
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02639/Python/s316600506.py", line 1, in <listcomp>
    nums = [int(x) for x in input()]
ValueError: invalid literal for int() with base 10: ' '


Fixed submission:

nums = [int(x) for x in input()]

for i in range(5):
    if nums[i] == 0:
        print(i + 1)
        exit(0)
Problem p02640 (Python) — buggy submission, verdict: Time Limit Exceeded

X, Y = map(int, input().split())

crane = (4 * X - Y) / 2
turtle = (Y - 2 * X) / 2


def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False


if is_integer_num(crane) and crane >= 0 and is_integer_num(turtle) and turtle >= 0:
    print("Yes")

else:
    print("No")


Error: TLE

Fixed submission:

X, Y = map(int, input().split())


def checkY(N, count, X):
    if count == X and N == 0:
        print("Yes")
        exit(0)
    elif count == X and N != 0:
        return False

    if checkY(N - 2, count + 1, X):
        return True

    if checkY(N - 4, count + 1, X):
        return True

    return False


if 2 * X <= Y and Y <= 4 * X:
    if checkY(Y, 0, X):
        print("Yes")
    else:
        print("No")
else:
    print("No")