Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

i = 1
while True:
  max = a * i + 1 - i
  if max >= b:
    break
    
  i += 1
  

print(i)

Fixed submission:
predict_weather = str(input())
real_weather = str(input())

predict_list = list(predict_weather)
real_list = list(real_weather)

cnt = 0
for i in range(3):
  if predict_list[i] == real_list[i]:
    cnt += 1
    
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
a,b = map(int, input().split())

cnt = 1
while True:
  if b<= 1:
    cnt = 0
  elif b <= (a-1)*cnt+1:
    break
  cnt += 1
  
print(cnt)

Fixed submission:
import sys
input = sys.stdin.readline
a,b = map(int, input().split())

cnt = 1
while True:
  if b<= 1:
    cnt = 0
    break
  elif b <= (a-1)*cnt+1:
    break
  cnt += 1
  
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

answer = sum([i for i in range(n)])

print(answer)

Fixed submission:
import sys
input = sys.stdin.readline

a = int(input())

print(int((a-1)*(a)//2))
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
a_list = np.array(list(map(int, input().split())))

a_array = np.zeros((N,N))

for i in range(N):
  a_array[i-1][i] = 0.5
  a_array[i-1][i-1] = 0.5
  
a = np.linalg.solve(a_array, a_list).astype(int)
print(*a)

Fixed submission:
N = int(input())
a_list = list(map(int, input().split()))

ans_list = [0]*N

not1_list = [ a_list[i] for i in range(1, N, 2) ]
ans_list[0] = sum(a_list) - 2 * sum(not1_list)
for i in range(1,N):
  ans_list[i] = a_list[i-1] * 2 - ans_list[i-1]
print(*ans_list)
Buggy python submission (verdict: Runtime Error):
import heapq

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

ans = []
for i in range(min(N, K)+1):
  for j in range(i+1):
    #print(i-j, j)
    # i-j個左から、i個右から取る
    lst = V[:i-j] + V[2*N-j:]
    #print(lst)
    heapq.heapify(lst)
    for _ in range(K-i):
      if len(lst) == 0:
        break
      elif min(lst) >= 0:
        ans.append(sum(lst))
        break
      else:
        heapq.heappop(lst)
        ans.append(sum(lst))
        #print(ans)
print(max(ans))

Fixed submission:
import heapq

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

ans = [V[0]]
for i in range(min(N, K)+1):
  for j in range(i+1):
    #print(i-j, j)
    # i-j個左から、i個右から取る
    lst = V[:i-j] + V[2*N-j:]
    #print(lst)
    heapq.heapify(lst)
    for _ in range(K-i):
      if len(lst) == 0:
        break
      elif min(lst) >= 0:
        ans.append(sum(lst))
        break
      else:
        heapq.heappop(lst)
        ans.append(sum(lst))
        #print(ans)
print(max(ans))

Buggy python submission (verdict: Runtime Error):
import heapq

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

ans = []
for i in range(min(N, K)):
  for j in range(i+1):
    # i-j個左から、i個右から取る
    lst = V[:i-j] + V[N-j:]
    #print(lst)
    heapq.heapify(lst)
    for _ in range(K-i):
      if len(lst) == 0:
        break
      elif min(lst) >= 0:
        ans.append(sum(lst))
        break
      else:
        heapq.heappop(lst)
        ans.append(sum(lst))
        #print(ans)
print(max(ans))

Fixed submission:
import heapq

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

ans = [V[0]]
for i in range(min(N, K)+1):
  for j in range(i+1):
    #print(i-j, j)
    # i-j個左から、i個右から取る
    lst = V[:i-j] + V[2*N-j:]
    #print(lst)
    heapq.heapify(lst)
    for _ in range(K-i):
      if len(lst) == 0:
        break
      elif min(lst) >= 0:
        ans.append(sum(lst))
        break
      else:
        heapq.heappop(lst)
        ans.append(sum(lst))
        #print(ans)
print(max(ans))

Buggy python submission (verdict: Runtime Error):
import heapq

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

ans = []
for i in range(min(N, K)):
  for j in range(i+1):
    #print(i-j, j)
    # i-j個左から、i個右から取る
    lst = V[:i-j] + V[N-j:]
    #print(lst)
    heapq.heapify(lst)
    for _ in range(K-i):
      if len(lst) == 0:
        break
      elif heapq.heappop(lst) >= 0:
        break
      else:
        ans.append(sum(lst))
print(max(ans))

Fixed submission:
import heapq

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

ans = [V[0]]
for i in range(min(N, K)+1):
  for j in range(i+1):
    #print(i-j, j)
    # i-j個左から、i個右から取る
    lst = V[:i-j] + V[2*N-j:]
    #print(lst)
    heapq.heapify(lst)
    for _ in range(K-i):
      if len(lst) == 0:
        break
      elif min(lst) >= 0:
        ans.append(sum(lst))
        break
      else:
        heapq.heappop(lst)
        ans.append(sum(lst))
        #print(ans)
print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N, M = map(int, input().split())
A_list = sorted( list( int(i) for i in input().split() ))
BC_list = sorted(
  list( list( int(i) for i in input().split() ) for _ in range(M) ),
  key=lambda x:-x[1]
)

n = N
for bc in BC_list:
  for i in range(bc[0]):
    if bisect.bisect_right(A_list, bc[1]) < len(A_list) - N :
      pass
    bisect.insort_right(A_list, bc[1])
L = len(A_list)
print(sum(A_list[L:L-N-1:-1]))

Fixed submission:
N, M = map(int, input().split())
A_list = sorted( list( int(i) for i in input().split() ))
BC_list = sorted(
  list( list( int(i) for i in input().split() ) for _ in range(M) ),
  key=lambda x:-x[1]
)

change_list = []
for bc in BC_list:
  change_list += [bc[1]] *  bc[0]
  if len(change_list) >= N :
    break
A_list += change_list
A_list.sort()
L = len(A_list)
print(sum(A_list[L:L-N-1:-1]))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N, M = map(int, input().split())
A_list = sorted( list( int(i) for i in input().split() ))
BC_list = sorted(
  list( list( int(i) for i in input().split() ) for _ in range(M) ),
  key=lambda x:-x[1]
)

n = N
for bc in BC_list:
  for i in range(bc[0]):
    bisect.insort_right(A_list, bc[1])
L = len(A_list)
print(sum(A_list[L:L-N-1:-1]))

Fixed submission:
N, M = map(int, input().split())
A_list = sorted( list( int(i) for i in input().split() ))
BC_list = sorted(
  list( list( int(i) for i in input().split() ) for _ in range(M) ),
  key=lambda x:-x[1]
)

change_list = []
for bc in BC_list:
  change_list += [bc[1]] *  bc[0]
  if len(change_list) >= N :
    break
A_list += change_list
A_list.sort()
L = len(A_list)
print(sum(A_list[L:L-N-1:-1]))
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = str(input())
 
ac = [1 if S[i] == 'A' and S[i+1] == 'C' else 0 for i in range(N-1) ]

for _ in range(Q):
  l, r = map(int, input().split())
  print(sum(ac[l-1:r-1]))

Fixed submission:
N, Q = map(int, input().split())
S = str(input())
 
#ac = [1 if S[i] == 'A' and S[i+1] == 'C' else 0 for i in range(N-1) ]
a = 0
lst = [0]
for i in range(1, N):
  if S[i-1] == 'A' and S[i] == 'C':
    a += 1
  lst.append(a)
for _ in range(Q):
  l, r = map(int, input().split())
  print(lst[r-1] - lst[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = str(input())

def main(s):
  ans = 0
  for i in range(len(s)-1):
    if s[i] == 'A' and s[i+1] == 'C':
      ans += 1
  return ans

for _ in range(Q):
  l, r = map(int, input().split())
  print(main(S[l-1:r]))

Fixed submission:
N, Q = map(int, input().split())
S = str(input())
 
#ac = [1 if S[i] == 'A' and S[i+1] == 'C' else 0 for i in range(N-1) ]
a = 0
lst = [0]
for i in range(1, N):
  if S[i-1] == 'A' and S[i] == 'C':
    a += 1
  lst.append(a)
for _ in range(Q):
  l, r = map(int, input().split())
  print(lst[r-1] - lst[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 0

for a in range(1, N):
    for b in range(1, N):
        c = N - a * b
        if c <= 0:
            break
        ans += 1  # 打ち切り判定より先に足すと、おかしくなります

print(ans)

Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    ans = 0

    for a in range(1, N):
        for b in range(1, N):
            x = a * b
            if x >= N:
                break
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

ans = 1000000  # 適当に1001以上を初期値にしておきます

# Tが1文字のときlen(S)回、2文字のときlen(S) - 1回 …… なので、
# len(S) - len(T) + 1 パターンあります

for i in range(len(S) - len(T) + 1):
    score = 0
    U = S[i:i + len(T)]  # Sのi文字目から連続するlen(T)文字を、Uとします
    for j in range(len(T)):
        if U[j] != T[j]:
            score += 1
    ans = min(ans, cur)

print(ans)


Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    S = input()
    T = input()
    ls = len(S)
    lt = len(T)

    ans = INF
    for i in range(ls - lt + 1):
        cur = 0
        for j in range(lt):
            if S[i + j] != T[j]:
                cur += 1
        ans = min(ans, cur)

    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n = input()
cur = 0

for x in n:
  cur += int(x)

  if cur % 9 == 0:
    print("Yes")
    else:
      print("No")

Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = input()
    cur = 0

    for x in n:
        cur += int(x)

    if cur % 9 == 0:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, k = map(int, readline().split())
    p = list(map(int, readline().split()))
    p = [x - 1 for x in p]
    c = list(map(int, readline().split()))
    ans = -INF

    for i in range(n):
        cur = i
        nx = -1
        cnt = 0
        score_dict = dict()
        score_dict[0] = 0
        score = 0
        rem = k
        while rem > 0 and nx != i:
            cnt += 1
            rem -= 1
            nx = p[cur]
            score += c[nx]
            score_dict[cnt] = score
            ans = max(ans, score)
            cur = nx

        if rem > 0 and score > 0:
            loop = (rem // cnt) - 1
            if loop > 0:
                score += score * loop
                rem -= loop * cnt
            for j in range(rem + 1):
                st = score + score_dict[j]
                ans = max(ans, st)

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, k = map(int, readline().split())
    p = list(map(int, readline().split()))
    p = [x - 1 for x in p]
    c = list(map(int, readline().split()))
    ans = -INF

    for i in range(n):
        cur = i
        nx = -1
        cnt = 0
        score_dict = dict()
        score_dict[0] = 0
        score = 0
        rem = k
        while rem > 0 and nx != i:
            cnt += 1
            rem -= 1
            nx = p[cur]
            score += c[nx]
            score_dict[cnt] = score
            ans = max(ans, score)
            cur = nx

        if rem > 0 and score > 0:
            loop = (rem - 1) // cnt
            if loop > 0:
                score += score * loop
                rem -= loop * cnt
            for j in range(rem + 1):
                st = score + score_dict[j]
                ans = max(ans, st)

    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    def enum_divisors(n):
        # 約数列挙

        divisors = []

        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n // i)

        return divisors

    import fractions
    from collections import Counter, defaultdict
    n = int(readline())
    a = [readline().rstrip("\n") for _ in range(n)]
    d = dict()
    ans = 0
    for x in a:
        fr = fractions.Fraction(x)
        num, den = fr.numerator, fr.denominator
        num_divs = enum_divisors(num)
        for div in num_divs:
            if d.get(div):
                c = d[div]
                ans += c[den]

        if not d.get(den):
            d[den] = Counter()
        d[den].update(num_divs)

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import Counter
    n = int(readline())
    c = Counter()
    ans = 0

    for _ in range(n):
        x = input()
        if "." in x:
            p, q = x.split(".")
            l = 9 - len(q)
            y = int(p + q + "0" * l)
        else:
            p = x
            y = int(p + "0" * 9)

        i = 0
        while i < 18:
            if y % (2 ** (i + 1)) != 0:
                break
            i += 1

        j = 0
        while j < 18:
            if y % (5 ** (j + 1)) != 0:
                break
            j += 1

        for k in range(18 - i, 19):
            for l in range(18 - j, 19):
                ans += c[(k, l)]

        c[(i, j)] += 1

    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n, d = map(int, input().split())

ans = 0

for _ in range(n):
    x, y = map(int, readline().split())
    if x ** 2 + y ** 2 <= d ** 2:
        ans += 1

print(ans)

Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, d = map(int, readline().split())

    ans = 0

    for _ in range(n):
        x, y = map(int, readline().split())
        if (x ** 2 + y ** 2) <= d ** 2:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
x = int(readline())
y = x // 200
print(10 - y)

Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    x = int(readline())
    kyu = 0

    if 400 <= x <= 599:
        kyu = 8
    if 600 <= x <= 799:
        kyu = 7
    if 800 <= x <= 999:
        kyu = 6
    if 1000 <= x <= 1199:
        kyu = 5
    if 1200 <= x <= 1399:
        kyu = 4
    if 1400 <= x <= 1599:
        kyu = 3
    if 1600 <= x <= 1799:
        kyu = 2
    if 1800 <= x <= 1999:
        kyu = 1

    print(kyu)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
k = int(input())

cnt = 0

while a >= b:
  b *= 2
  cnt += 1

  while b >= c:
    c *= 2
    cnt += 1

    if cnt <= k:
      print("Yes")
      else:
        print("No")

Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c = map(int, readline().split())
    k = int(readline())
    cnt = 0

    while a >= b:
        b *= 2
        cnt += 1

    while b >= c:
        c *= 2
        cnt += 1

    if cnt <= k:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

    if 0 in a:
        print(0)
    else:
        cur = 1
        for x in a:
            cur *= x
        if cur > 10 ** 18:
            print(-1)
        else:
            print(cur)


if __name__ == '__main__':
    main()


Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(input())
    a = list(map(int, readline().split()))
    a.sort()
    
    cur = 1
    for x in a:
        cur *= x
        if cur > 10 ** 18:
            print(-1)
            sys.exit()

    print(cur)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from copy import copy

    n, s = list(map(int, readline().split()))
    a = list(map(int, readline().split()))

    # iである個数
    dp = [[0] * (s + 1) for _ in range(n)]
    dp[0][0] = 2
    if a[0] <= s:
        dp[0][a[0]] = 1

    for i, x in enumerate(a[1:], 1):
        dp[i] = [y * 2 for y in dp[i-1]]
        for j in range(s + 1):
            cur = j + x
            if cur > s:
                continue
            dp[i][cur] += dp[i - 1][j]

    print(dp[-1][-1] % 998244353)


if __name__ == '__main__':
    main()


Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 998244353
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from copy import copy

    n, s = list(map(int, readline().split()))
    a = list(map(int, readline().split()))

    # iである個数
    dp = [[0] * (s + 1) for _ in range(n)]
    dp[0][0] = 2
    if a[0] <= s:
        dp[0][a[0]] = 1

    for i, x in enumerate(a[1:], 1):
        dp[i] = [y * 2 % MOD for y in dp[i - 1]]
        for j in range(s + 1):
            cur = j + x
            if cur > s:
                break
            dp[i][cur] += dp[i - 1][j]

    print(dp[-1][-1] % MOD)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
h1, m1, h2, m2, k = list(map(int, readline().split()))

x = (h2 - h1) * 60 + (m2 - m1)  # 起きている時間の長さ（分）
print(x - k)

Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c, d, e = list(map(int, readline().split()))

    x = a * 60 + b
    y = c * 60 + d
    z = y - x

    print(z-e)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import math
a, b, h, m = list(map(int, readline().split()))
deg_a = (60*h + m) * 0.5
deg_b = 6 * m
deg = abs(deg_a-deg_b)
rad = math.radians(deg)

c2 = a ** 2 + b ** 2 - 2 * a * b * math.cos(rad)
print(c2 ** 0.5)

Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, h, m = list(map(int, readline().split()))
    deg_a = 30 * h + (m / 60) * 30
    deg_b = 6 * m
    if deg_a > deg_b:
        deg = deg_a - deg_b
    else:
        deg = deg_b - deg_a
    import math
    if deg > 180:
        deg = 360 - deg

    c2 = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(deg))
    print(c2 ** 0.5)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c, k = list(map(int, readline().split()))
    s = [1] * a + [0] * b + [-1] * c
    ans = sum(s[:k])
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c, k = list(map(int, readline().split()))
    if a + b >= k:
        print(min(a, k))
    else:
        print(a - (k - a - b))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c, k = list(map(int, readline().split()))
    s = [1] * a + [0] * b + [-1] * c
    print(s)
    ans = sum(s[:k])
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c, k = list(map(int, readline().split()))
    if a + b >= k:
        print(min(a, k))
    else:
        print(a - (k - a - b))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c, k = list(map(int, readline().split()))
    s = [1] * a + [0] * b + [-1] * c
    ans = sum(s[::k])
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c, k = list(map(int, readline().split()))
    if a + b >= k:
        print(min(a, k))
    else:
        print(a - (k - a - b))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import time

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(input())
    a = list(map(int, readline().split()))

    import networkx as nx
    G = nx.Graph()

    for _ in range(n - 1):
        u, v = map(int, readline().split())
        u, v = u - 1, v - 1
        G.add_edge(u, v)

    ans = [0] * n
    dp = [INF] * n
    dp[0] = a[0]

    from collections import deque, namedtuple
    import bisect

    stack = deque()
    Params = namedtuple("Params", ["node", "dp_index", "prev_value", "new_value"])
    par = 0
    stack.append(Params(0, 0, INF, a[0]))

    for prev, cur in nx.algorithms.edge_dfs(G, source=0):
        if par != prev:
            while stack:
                params = stack.pop()
                if params.node == prev:
                    stack.append(params)
                    break
                ans[params.node] = bisect.bisect_left(dp, INF)
                dp[params.dp_index] = params.prev_value
        new_val = a[cur]
        index = bisect.bisect_left(dp, new_val)
        prev_val = dp[index]
        dp[index] = new_val
        stack.append(Params(cur, index, prev_val, new_val))
        par = cur

    while stack:
        params = stack.pop()
        ans[params.node] = bisect.bisect_left(dp, INF)
        dp[params.dp_index] = params.prev_value

    print(*ans, sep="\n")


if __name__ == '__main__':
    main()


Fixed submission:
import sys
import time

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10**5)


def main():
    n = int(input())
    a = list(map(int, readline().split()))
    node = {i: [] for i in range(n)}

    for _ in range(n - 1):
        u, v = map(int, readline().split())
        u, v = u - 1, v - 1
        node[u].append(v)
        node[v].append(u)

    ans = [0] * n
    dp = [INF] * n
    dp[0] = a[0]
    visited = [False] * n

    from collections import deque
    import bisect

    def dfs(cur):
        visited[cur] = True
        nv = a[cur]
        index = bisect.bisect_left(dp, nv)
        pv = dp[index]
        dp[index] = nv
        suc = node[cur]

        for nx in suc:
            if not visited[nx]:
                dfs(nx)

        ans[cur] = bisect.bisect_left(dp, INF)
        dp[index] = pv

    dfs(0)
    print(*ans, sep="\n")


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
s, t = [str(i) for i in input().split()]
a , b =[int(i) for i in input().split()]
u = str(input())

if u == s:
    a = a - 1
else:
    b = b - 1

print(f'{a} {b}')

Fixed submission:
s , t = [str(i) for i in input().split()]
a , b =[int(i) for i in input().split()]
u = str(input())

if u == s:
    a = a - 1
else:
    b = b - 1

print(a, b)
Buggy python submission (verdict: Runtime Error):
n =int(input())
a = [int(i) for i in input().split()]
is_same = False

for i in range(n):
    for j in range(i+1, n+1):
        if a[i] == a[j]:
            is_same = True

if is_same:
    print('NO')
else:
    print('YES')

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

a.sort()

for i in range(n-1):
    if a[i] == a[i+1]:
        print('NO')
        break
else:
    print('YES')