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

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

i_plus_Ai = [0 for i in range(N)]
dict = {}
for i in range(N):
    i_plus_Ai[i] = i + As[i]
    tmp = i - As[i]
    if tmp not in dict:
        dict[tmp] = [i]
    else:
        dict[tmp].append(i)

count = 0
for i in range(N):
    if i_plus_Ai[i] in dict:
        kouho = dict[i_plus_Ai[i]]
        for j in range(len(kouho)):
            if kouho[j] > i:
                count += len(kouho) - j
                break

print(count)


Error: TLE

Fixed submission:

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

i_plus_Ai = [0 for i in range(N)]
dict = {}
for i in range(N):
    i_plus_Ai[i] = i + As[i]
    tmp = i - As[i]
    if tmp not in dict:
        dict[tmp] = [i]
    else:
        dict[tmp].append(i)
    dict[tmp].sort()

count = 0
for i in range(N):
    if i_plus_Ai[i] in dict:
        kouho = dict[i_plus_Ai[i]]
        for j in range(len(kouho)):
            if kouho[j] > i:
                count += len(kouho) - j
                break

print(count)
Problem p02691 (Python) — buggy submission, verdict: Runtime Error

from collections import defaultdict


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

memo = defaultdict(int)
ans = 0
for i, x in enumerate(a, 1):
    ans += memo[i - x]
    memo[x + i] += 1

print(ans)


Error: WA

Fixed submission:

from collections import defaultdict


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

memo = defaultdict(int)
ans = 0
for i, x in enumerate(a, 1):
    print(memo)
    ans += memo[i - x]
    memo[x + i] += 1

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

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

b = [j - i for i, j in enumerate(a, start=1)]
# c = [-j - i for i, j in enumerate(a, start=1)]
count = {}
for i, j in enumerate(a, start=1):
    num = -i - j
    if num not in count:
        count[num] = 0
    count[num] += 1
result = sum([count.get(i, 0) for i in b])
print(result)


Error: TLE

Fixed submission:

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

b = [j - i for i, j in enumerate(a, start=1)]
c = [-j - i for i, j in enumerate(a, start=1)]
result = sum([c.count(i) for i in b])
print(result)
Problem p02692 (Python) — buggy submission, verdict: Runtime Error

n, a, b, c = (int(x) for x in input().split())
d = {"A": a, "B": b, "C": c}
S = [input() for _ in range(n)]
ANS = []

for i, s in enumerate(S):
    if d[s[0]] == 0 and d[s[1]] == 0:
        print("No")
        exit()
    else:
        if d[s[0]] > d[s[1]] or (
            d[s[0]] == d[s[1]] == 1 and i < n - 1 and s[1] in S[i + 1]
        ):
            d[s[1]] += 1
            d[s[0]] -= 1
            ANS.append(s[1])
        else:
            d[s[0]] += 1
            d[s[1]] -= 1
            ANS.append(s[0])
print("Yes")
for ans in ANS:
    print(ans)


Error: 0

Fixed submission:

n, a, b, c = (int(x) for x in input().split())
d = {"A": a, "B": b, "C": c}
S = [input() for _ in range(n)]
ANS = []

for i, s in enumerate(S):
    if d[s[0]] == 0 and d[s[1]] == 0:
        print("No")
        exit()
    else:
        if d[s[0]] > d[s[1]] or (d[s[0]] == d[s[1]] == 1 and i < n and s[1] in S[i + 1]):
            d[s[1]] += 1
            d[s[0]] -= 1
            ANS.append(s[1])
        else:
            d[s[0]] += 1
            d[s[1]] -= 1
            ANS.append(s[0])
print("Yes")
for ans in ANS:
    print(ans)
Problem p02692 (Python) — buggy submission, verdict: Runtime Error

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

value_dict = {"A": a, "B": b, "C": c}
result_list = []
input_list = []
flag = True

for i in range(n):
    input_list.append(input())

for next, input in enumerate(input_list, 1):
    if value_dict[input[0]] < value_dict[input[1]]:
        value_dict[input[0]] += 1
        value_dict[input[1]] -= 1
        result_list.append(input[0])
    elif value_dict[input[1]] < value_dict[input[0]]:
        value_dict[input[1]] += 1
        value_dict[input[0]] -= 1
        result_list.append(input[1])
    else:
        if value_dict[input[0]] == 0:
            flag = False
            break
        elif next == len(input_list):
            result_list.append(input[0])
        elif input[0] in input_list[next]:
            value_dict[input[0]] += 1
            value_dict[input[1]] -= 1
            result_list.append(input[0])
        else:
            value_dict[input[1]] += 1
            value_dict[input[0]] -= 1
            result_list.append(input[1])

if flag:
    print("Yes")
    for result in result_list:
        print(result)

else:
    print("No")


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


Fixed submission:

# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
h_list = input().split()
h_list = [int(h) for h in h_list]

count = 0

for i in range(n):
    a_height = h_list[i]
    if i + 21 < n:
        n_aa = i + 21
    else:
        n_aa = n
    for k in range(i + 1 + a_height, n_aa):
        b_height = h_list[k]
        if k - i == a_height + b_height:
            count += 1

print(count)
Problem p02692 (Python) — buggy submission, verdict: Runtime Error

N, A, B, C = map(int, input().split())
opts = []
for _ in range(N):
    opt = input()
    opts.append((ord(opt[0]) - ord("A"), ord(opt[1]) - ord("A")))

choices = []
nums = [A, B, C]
for i, opt in enumerate(opts):
    if nums[opt[0]] == 0 and nums[opt[1]] == 0:
        print("No")
        break
    if nums[opt[0]] == 1 and nums[opt[1]] == 1:
        if i < N - 1 and opt != opts[i + 1]:
            choice = (set(opt) & set(opts[i + 1])).pop()
            nums[choice] += 1
            nums[choice ^ opt[0] ^ opt[1]] -= 1
            choices.append(choice)
            continue
    if nums[opt[0]] >= nums[opt[1]]:
        choices.append(opt[1])
        nums[opt[1]] += 1
        nums[opt[0]] -= 1
    else:
        choices.append(opt[0])
        nums[opt[0]] += 1
        nums[opt[1]] -= 1
else:
    print("Yes")
    for c in choices:
        print(chr(c + ord("A")))


Error: 0

Fixed submission:

N, A, B, C = map(int, input().split())
opts = []
for _ in range(N):
    opt = input()
    opts.append((ord(opt[0]) - ord("A"), ord(opt[1]) - ord("A")))

choices = []
nums = [A, B, C]
for i, opt in enumerate(opts):
    if nums[opt[0]] == 0 and nums[opt[1]] == 0:
        print("No")
        break
    if nums[opt[0]] == 1 and nums[opt[1]] == 1:
        if i < N - 1 and opt != opts[i + 1]:
            choice = next(set(opt) ^ set(opts[i + 1]))
            nums[opt] += 1
            nums[opt ^ opt[0] ^ opt[1]] -= 1
            choices.append(choice)
            continue
    if nums[opt[0]] >= nums[opt[1]]:
        choices.append(opt[1])
        nums[opt[1]] += 1
        nums[opt[0]] -= 1
    else:
        choices.append(opt[0])
        nums[opt[0]] += 1
        nums[opt[1]] -= 1
else:
    print("Yes")
    for c in choices:
        print(chr(c + ord("A")))
Problem p02693 (Python) — buggy submission, verdict: Runtime Error

K = int(input())
A, B = map(int, input().split())
large = (B // K) * K
if A <= large:
    print("OK")
else:
    print("NG")


Error: AttributeError: 'str' object has no attribute 'slice'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02693/Python/s877795440.py", line 2, in <module>
    A, B = map(int, input().slice())
AttributeError: 'str' object has no attribute 'slice'


Fixed submission:

K = int(input())
A, B = map(int, input().slice())
print("OK" if B - A >= K else "NG")
Problem p02693 (Python) — buggy submission, verdict: Runtime Error

K = int(input())
S = input().split()
A = int(S[0])
B = int(S[1])

for i in range(A, B + 1):
    if i % K == 0:
        print("OK")
        exit()
print("NG")


Error: EOFError: EOF when reading a line
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02693/Python/s140867426.py", line 3, in <module>
    B = int(input().split()[1])
EOFError: EOF when reading a line


Fixed submission:

K = int(input())
A = int(input().split()[0])
B = int(input().split()[1])

for i in range(A, B + 1):
    if i % K == 0:
        print("OK")
        break
        exit()
print("NG")
Problem p02693 (Python) — buggy submission, verdict: Runtime Error

K = int(input())

A, B = map(int, input().split())

if A // K == B // K:
    if A % K == 0 or B % K == 0:
        print("OK")
    else:
        print("NG")
elif A // K < B // K:
    print("OK")
else:
    print("NG")


Error: ValueError: too many values to unpack (expected 2)
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02693/Python/s485760562.py", line 3, in <module>
    A, B = map(int, input())
ValueError: too many values to unpack (expected 2)


Fixed submission:

K = int(input())

A, B = map(int, input())

if A // K <= B // K and B % K == 0:
    print("OK")
else:
    print("NG")
Problem p02693 (Python) — buggy submission, verdict: Time Limit Exceeded

k = int(input())
a, b = map(int, input().split())
i = 1
flag = False


while i < b:
    if k == 1:
        flag = True
        break
    dis = i * k
    if dis >= a and dis <= b:
        flag = True
        break

    i += 1


if flag:
    print("OK")
else:
    print("NG")


Error: TLE

Fixed submission:

k = int(input())
a, b = map(int, input().split())
i = 1
flag = False

while i < b:
    dis = i * k
    if dis >= a and dis <= b:
        flag = True
        break


if flag:
    print("OK")
else:
    print("NG")
Problem p02693 (Python) — buggy submission, verdict: Runtime Error

K = int(input())
arr = list(map(int, input().split()))
a = arr[1] % K
b = arr[1] - arr[0]
if a <= b:
    print("OK")
else:
    print("NG")


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


Fixed submission:

K = int(input())
arr = list(map(int, input()))
a = arr[1] % K
b = arr[1] - arr[0]
if a > b:
    print("OK")
else:
    print("NG")
Problem p02694 (Python) — buggy submission, verdict: Time Limit Exceeded

x = int(input())
nen = 0
a = 100
while a < x:
    a = int(a * 1.01)
    nen += 1
print(nen)


Error: TLE

Fixed submission:

mon = 100
nen = 0
moku = int(input())

while mon < moku:
    mon = mon // 100
    nen += 1

print(nen)
Problem p02695 (Python) — buggy submission, verdict: Runtime Error

from itertools import combinations_with_replacement

N, M, Q = map(int, input().split())
L = []
for _ in range(Q):
    L.append(tuple(map(int, input().split())))

ans = 0
_N = N
if N < M:
    _N = M

for A in combinations_with_replacement(range(1, M + 1), _N):
    tmp = 0
    for a, b, c, d in L:
        if a <= _N and b <= _N and A[b - 1] - A[a - 1] == c:
            tmp += d

    if tmp > ans:
        ans = tmp

print(ans)


Error: 0

Fixed submission:

from itertools import combinations_with_replacement

N, M, Q = map(int, input().split())
L = []
for _ in range(Q):
    L.append(tuple(map(int, input().split())))

ans = 0
for A in combinations_with_replacement(range(1, M + 1), min(N, M)):
    tmp = 0
    for a, b, c, d in L:
        if A[b - 1] - A[a - 1] == c:
            tmp += d

    if tmp > ans:
        ans = tmp

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

import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, M, Q, *abcd = map(int, read().split())
cand = [[0, 1]]

for _ in range(N - 1):
    new_cand = []
    for j in cand:
        for k in range(j[-1], M + 1):
            new_cand.append(j[:] + [k])
    cand = new_cand[:]

answer = 0
abcd = tuple(zip(*[iter(abcd)] * 4))
for seq in cand:
    t = 0
    for a, b, c, d in abcd:
        if seq[b] - seq[a] == c:
            t += d
    answer = max(answer, t)

print(answer)


Error: 0

Fixed submission:

import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, M, Q, *abcd = map(int, read().split())
cand = [[0, 1]]

for _ in range(M):
    new_cand = []
    for j in cand:
        for k in range(j[-1], M + 1):
            new_cand.append(j[:] + [k])
    cand = new_cand[:]

answer = 0
abcd = tuple(zip(*[iter(abcd)] * 4))
for seq in cand:
    t = 0
    for a, b, c, d in abcd:
        if seq[b] - seq[a] == c:
            t += d

    answer = max(answer, t)

print(answer)
Problem p02696 (Python) — buggy submission, verdict: Time Limit Exceeded

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

ans = 0
if b > n:
    x = n
    ans = int(a * x // b) - int(a * (x // b))
else:
    x = n
    ans1 = int(a * x // b) - int(a * (x // b))
    x = (n // b) * b - 1
    ans2 = int(a * x // b) - int(a * (x // b))
    ans = max(ans1, ans2)
print(ans)


Error: TLE

Fixed submission:

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

ans = 0
if b > n:
    x = n
    ans = int(a * x // b) - int(a * (x // b))
else:
    m = 0
    for i in range(b):
        if int(a * (n - i) // b) - int(a * ((n - i) // b)) > m:
            m = int(a * (n - i) // b) - int(a * ((n - i) // b))
    ans = m
print(ans)
Problem p02696 (Python) — buggy submission, verdict: Runtime Error

from math import floor

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

x = None
if N < B:
    x = N
else:
    x = B
    x = B - 1
    # max_diff = 0
    # for _x in range(B, N + 1):
    #     diff = (x / B) - floor(x / B)
    #     if max_diff <= diff:
    #         max_diff = diff
    #         x = _x

answer = floor(A * x / B) - A * floor(x / B)

print(answer)


Error: 0

Fixed submission:

from math import floor

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

x = None
if N < B:
    x = N

answer = floor(A * x / B) - A * floor(x / B)

print(answer)
Problem p02696 (Python) — buggy submission, verdict: Time Limit Exceeded

# coding:utf-8

import math

a, b, n = map(int, input().split())
x = min(b - 1, n)

ans = math.floor((a * x) / b) - a * (math.floor(x / b))

print(ans)


Error: TLE

Fixed submission:

# coding:utf-8
def main():
    import math

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

    for x in range(n, 0, -1):
        tmp = math.floor((a * x) / b) - a * (math.floor(x / b))
        ans = max(tmp, ans)

    print(ans)


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

A, B, N = map(int, input().split())
X = min(N, B - 1)
print(A * X // B - A * (X // B))


Error: TLE

Fixed submission:

A, B, N = map(int, input().split())
c = 0
t = -10
if N > 100000000:
    for i in range(100000000, N + 1):
        a = (i * A) // B - A * (i // B)
        c = max(c, a)
        if t > a or i > 1100000000:
            print(c)
            break
        t = a
    else:
        print(c)
else:
    for i in range(N + 1):
        a = (i * A) // B - A * (i // B)
        c = max(c, a)
        if t > a or i > 100000000:
            print(c)
            break
        t = a
    else:
        print(c)
Problem p02696 (Python) — buggy submission, verdict: Time Limit Exceeded

a, b, n = map(int, input().split())
ans = 0
# floor(a * x / b)
# = floor(a * floor(x / b) + a * (x / b - floor(x / b)))
# = a * floor(x / b) + floor(a * (x / b - floor(x / b))))
print(int(a * min(b - 1, n) / b))


Error: TLE

Fixed submission:

a, b, n = map(int, input().split())
ans = 0
# floor(a * x / b)
# = floor(a * floor(x / b) + a * (x / b - floor(x / b)))
# = a * floor(x / b) + floor(a * (x / b - floor(x / b))))
for i in range(min(b, n + 1)):
    ans = max(ans, int(a * i / b))
print(ans)
Problem p02696 (Python) — buggy submission, verdict: Time Limit Exceeded

from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    a, b, n = map(int, input().split())

    ans = 0

    x = min(b - 1, n)
    ans = max(int(a * x / b) - a * int(x / b), ans)

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Error: TLE

Fixed submission:

from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    a, b, n = map(int, input().split())

    ans = 0

    for x in range(min(b, n + 1)):
        ans = max(int(a * x / b) - a * int(x / b), ans)

    print(ans)


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

def f(a, b, n):
    if b == 1:
        print(0)
    else:
        Max = 0
        step = 1 if b // a == 0 else b // a
        for x in range(b // a, n + step, step):
            res = (a * x) // b - a * (x // b)
            if res > Max:
                Max = res
        print(Max)


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


Error: TLE

Fixed submission:

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

Max = 0
for x in range(1, n + 1):
    Max = max(Max, (a * x) // b - a * (x // b))
print(Max)
Problem p02696 (Python) — buggy submission, verdict: Runtime Error

def m():
    a, b, n = map(int, input().split())

    def calc(x):
        return int((a * x) / b) - (a * int(x / b))

    return calc(min(n, b - 1))


print(m())


Error: 0

Fixed submission:

def m():
    a, b, n = map(int, input().split())

    def calc(x):
        return int((a * x) / b) - (a * int(x / b))

    if calc(1) < calc(n // 2):
        return max([calc(i) for i in range(n // 2, n + 1)])
    else:
        return max([calc(i) for i in range(1, n // 2 + 1)])


print(m())
Problem p02696 (Python) — buggy submission, verdict: Time Limit Exceeded

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

maxFloor = 0


def floor(x):
    num = int(x // 1)
    return num


if B - 1 <= N:
    check = floor(A * (B - 1) / B) - A * floor((B - 1) / B)
    print(check)
else:
    check = floor(A * N / B) - A * floor(N / B)
    print(check)


Error: TLE

Fixed submission:

A, B, N = map(int, input().split())
maxFloor = 0


def floor(x):
    num = int(x // 1)
    return num


for x in range(N + 1):
    check = floor(A * x / B) - A * floor(x / B)
    maxFloor = max(maxFloor, check)
print(maxFloor)
Problem p02696 (Python) — buggy submission, verdict: Time Limit Exceeded

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

x = min(B - 1, N)
ans = (A * x) // B - A * (x // B)
print(ans)


Error: TLE

Fixed submission:

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

ans = 0

for i in range(1, N + 1):
    tmp = (A * i) // B - A * (i // B)
    ans = max(ans, tmp)

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

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

if b > n:
    x = n
else:
    x = b - 1

print((a * x) // b)


Error: TLE

Fixed submission:

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

for i in range(1, n + 1):
    num = (a * i) // b - a * (i // b)
    if ans < num:
        ans = num

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

import math


def f(A, B, x):
    return math.floor(A * x / B) - A * math.floor(x / B)


def main(A, B, N):
    if N < B:
        return f(A, B, N)
    else:
        return f(A, B, B - 1)


A, B, N = map(int, input().split())
print(main(A, B, N))


Error: TLE

Fixed submission:

import math


def f(A, B, x):
    return math.floor(A * x / B) - A * math.floor(x / B)


def main(A, B, N):
    last = 0
    x = 0
    while x <= N:
        tmp = f(A, B, x)
        if tmp < last:
            print(last)
            return
        else:
            last = tmp
            x += 1
    else:
        print(last)
        return


A, B, N = map(int, input().split())
main(A, B, N)
Problem p02696 (Python) — buggy submission, verdict: Time Limit Exceeded

def f(x):
    return (a * x) // b - a * (x // b)


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

k = (n + 1) // b

x = max(k * b - 1, 0)
ans = f(x)
ans = max(ans, f(n))
print(ans)


Error: TLE

Fixed submission:

def f(x):
    return (a * x) // b - a * (x // b)


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

k = (n + 1) // b

ans = 0
for x in range(max(0, k * b - 1), n + 1):
    ans = max(ans, f(x))

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

n, m = map(int, input().split())
if n % 2 == 1:
    for i in range(1, m + 1):
        print(i, n + 1 - i)
else:
    turning_point = (m + 1) // 2
    for i in range(1, turning_point + 1):
        print(i, n + 1 - i)
    for i in range(turning_point + 1, m + 1):
        print(i, n - i)


Error: WA

Fixed submission:

n, m = map(int, input().split())
if n % 2 == 1:
    for i in range(1, m + 1):
        print(i, n + 1 - i)
else:
    used = [False] * (n + 1)
    i = 1
    count = 0
    while count < m:
        while used[i]:
            i += 1
        print(i, i + count + 1)
        used[i] = True
        used[i + count + 1] = True
        count += 1
Problem p02697 (Python) — buggy submission, verdict: Runtime Error

N, M = map(int, input().split())

for i in range(1, M + 1):
    if i % 2 == 1:
        j = (i - 1) // 2
        print(1 + j, M + 1 - j)
    else:
        j = (i - 2) // 2
        print(M + 2 + j, 2 * M + 1 - j)


Error: WA

Fixed submission:

N, M = map(int, input().split())

sieve = [0] * (100000 + 1)
sieve[0] = -1
sieve[1] = -1
for i in range(2, 100000 + 1):
    if sieve[i] != 0:
        continue
    sieve[i] = i
    for j in range(i * i, 100000 + 1, i):
        if sieve[j] == 0:
            sieve[j] = i

p = []
for i in range(N - 1, -1, -1):
    if sieve[i] == i:
        p.append(i)
p.append(1)

t = set()
pp = 0
for i in range(M):
    x = i + 1
    y = x + p[pp]
    while y in t:
        pp += 1
        y = x + p[pp]
    t.add(x)
    t.add(y)
    print(x, y)
    pp += 1
Problem p02698 (Python) — buggy submission, verdict: Runtime Error

import bisect
import sys


N = int(input())
a = list(map(int, input().split()))
to = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    to[u].append(v)
    to[v].append(u)
del u, v

ans = [-1] * N


def dfs(v, dp):
    # dp は参照渡し
    if len(dp) == 0 or a[v] > dp[-1]:
        dp.append(a[v])
        back = -1
    else:
        pos = bisect.bisect_left(dp, a[v])
        back = dp[pos]
        dp[pos] = a[v]
    ans[v] = len(dp)

    for u in to[v]:
        if ans[u] == -1:
            dfs(u, dp)
    if back == -1:
        dp.pop()
    else:
        dp[pos] = back


sys.setrecursionlimit(10**6)
dfs(0, [])


for an in ans:
    print(an)


Error: 0

Fixed submission:

import bisect

N = int(input())
a = list(map(int, input().split()))
to = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    to[u].append(v)
    to[v].append(u)
del u, v

ans = [-1] * N


def dfs(v, prev_dp):
    dp = [*prev_dp]
    if len(dp) == 0 or a[v] > dp[-1]:
        dp.append(a[v])
    else:
        pos = bisect.bisect_left(dp, a[v])
        dp[pos] = a[v]
    ans[v] = len(dp)

    for u in to[v]:
        if ans[u] == -1:
            dfs(u, dp)


dfs(0, [])


for an in ans:
    print(an)
Problem p02699 (Python) — buggy submission, verdict: Runtime Error

s, w = map(int, input().split(" "))
res = "safe"
if w >= s:
    res = "unsafe"
print(res)


Error: ValueError: empty separator
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02699/Python/s552737943.py", line 1, in <module>
    s, w = map(int, input().split(""))
ValueError: empty separator


Fixed submission:

s, w = map(int, input().split(""))
res = "safe"
if w >= s:
    res = "unsafe"
print(res)
Problem p02700 (Python) — buggy submission, verdict: Time Limit Exceeded

A, B, C, D = list(map(int, input().split()))
t1 = (A + D - 1) // D
t2 = (C + B - 1) // B
print("Yes" if t2 <= t1 else "No")


Error: TLE

Fixed submission:

A, B, C, D = list(map(int, input().split()))
while A and C:
    A -= D
    C -= B
    if C <= 0:
        print("Yes")
    elif A <= 0:
        print("No")