Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03060 (python)

Fixed submission:
N = input()
V = list(map(int, input().split()))
C = list(map(int, input().split()))
XY = 0
for i in range(len(V)):
    if V[i] - C[i] > 0:
        XY += V[i] - C[i]

print(XY)

Buggy submission (verdict: Runtime Error):
N = input()
V = list(map(int, input().split()))
C = list(map(int, input().split()))
XY = 0
for i in range(len(V)):
    if V[i] - C[i] > 0:
        XY += V[i] - C[i]

print(XY)
Problem p03085 (python)

Fixed submission:
b = input()
if b == 'A':
    print('T')
if b == 'T':
    print('A')
if b == 'G':
    print('C')
if b == 'C':
    print('G')

Buggy submission (verdict: Runtime Error):
from collections import deque
N, Q = map(int, input().split())
S = input()
l = [0 for i in range(Q)]
r = [0 for i in range(Q)]

for i in range(Q):
    l[i], r[i] = map(int, input().split())

for i in range(Q):
    s = S[l[i]-1:r[i]]
    print(s.count('AC'))
Problem p03086 (python)

Fixed submission:
S = input()
list = []
counter = 0
for i in range(len(S)):
    if S[i] == 'A' or S[i] == 'T' or S[i] == 'G' or S[i] == 'C':
        counter += 1
    else:
        counter = 0
    list.append(counter)
print(max(list))

Buggy submission (verdict: Runtime Error):
S = input()
list = []
counter = 0
for i in range(len(S)):
    if S[i] == 'A' or S[i] == 'T' or S[i] == 'G' or S[i] == 'C':
        counter += 1
    else:
        list.append(counter)
        counter = 0
print(max(list))
Problem p03111 (python)

Fixed submission:
import sys
from collections import deque
input = sys.stdin.readline

N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10**9

def dfs(cur, a, b, c):
    if cur == N:
        if min(a, b, c) > 0:
            return abs(a-A) + abs(b-B) + abs(c-C) - 30
        else:
            return INF #長さ0になった場合
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque
input = sys.stdin.readline

N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10**9

def dfs(cur, a, b, c):
    if cur == N:
        if min(a, b, c) > 0:
            return abs(a-A) + abs(b-B) + abs(c-C) - 30　#最初の三回
        else:
            return INF #長さ0になった場合
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))
Problem p03206 (python)

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

D = int(input())
if D == 25:
    print('Christmas')
elif D == 24:
    print('Christmas Eve')
elif D == 23:
    print('Christmas Eve Eve')
elif D == 22:
    print('Christmas Eve Eve Eve')

Buggy submission (verdict: Runtime Error):
import sys
intput = sys.stdin.readline()

D = int(input())
if D == 25:
    print('Christmas')
elif D == 24:
    print('Christmas Eve')
elif D == 23:
    print('Christmas Eve Eve')
elif D == 22:
    print('Christmas Eve Eve Eve')
Problem p03262 (python)

Fixed submission:
import sys
from fractions import gcd

input = sys.stdin.readline

N, X = map(int, input().split())
x = list(map(int, input().split()))

if N == 1:
    print(abs(X - x[0]))
    exit()

x.append(X)
x.sort()
diff = []
ans = []

for i in range(N):
    diff.append(x[i+1] - x[i])

for i in range(N-1):
    ans.append(gcd(diff[i], diff[i+1]))

print(min(ans))

Buggy submission (verdict: Runtime Error):
import sys
from fractions import gcd

input = sys.stdin.readline

N, X = map(int, input().split())
x = list(map(int, input().split()))

if N == 1:
    print(abs(X - x[0]))
    exit()

x.append(X)
x.sort()
diff = []
ans = []

for i in range(N-1):
    diff.append(x[i+1] - x[i])

for i in range(N-2):
    ans.append(gcd(diff[i], diff[i+1]))

print(min(ans))

Buggy submission (verdict: Runtime Error):
import sys
from fractions import gcd

input = sys.stdin.readline

N, X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
diff = []
ans = []

for i in range(N-1):
    diff.append(x[i+1] - x[i])

for i in range(N-2):
    ans.append(gcd(diff[i], diff[i+1]))

print(min(ans))
Problem p03274 (python)

Fixed submission:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n, k = nm()
x = nl()

if 0 in x:
    k -= 1
if n == 1:
    print(x[0])
    exit()

zero = bisect_left(x, 0)
costs = []
#print(zero, max(zero - k, 0), min(zero + k, n - k) + 1)
for i in range(max(zero - k, 0), min(zero + k, n - k) + 1):
    if x[i] < 0 and x[i+k-1] > 0:
        costs.append(-2 * x[i] + x[i+k-1])
        costs.append(-1 * x[i] + 2 * x[i+k-1])
    else:
        costs.append(max(abs(x[i]), abs(x[i+k-1])))
    #print(i, x[i], costs)
print(min(costs))

Buggy submission (verdict: Runtime Error):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n, k = nm()
x = nl()

if 0 in x:
    k -= 1
if n == 1:
    print(x[0])
    exit()

zero = bisect_left(x, 0)
costs = []

for i in range(min(zero - k, 0) + 1, min(zero + k, n - k)):
    if x[i] < 0 and x[i+k-1] > 0:
        costs.append(-2 * x[i] + x[i+k-1])
        costs.append(-1 * x[i] + 2 * x[i+k-1])
    else:
        costs.append(max(abs(x[i]), abs(x[i+k-1])))
    #print(i, x[i], costs)
print(min(costs))
Problem p03282 (python)

Fixed submission:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

s = ns()
k = ni()
i = 0
while i < len(s):
    if s[i] == '1':
        i += 1
    else:
        ans = int(s[i])
        break

if k <= i:
    ans = 1

print(ans)

Buggy submission (verdict: Runtime Error):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

s = ns()
k = ni()
i = 0
while True:
    if s[i] == '1':
        i += 1
    else:
        break

if k <= i:
    ans = 1
else:
    ans = int(s[i])

print(ans)
Problem p03338 (python)

Fixed submission:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
s = ns()

ans = [0]

for i in range(1, n-1):
    set_x = set(s[:i])
    set_y = set(s[i:])
    ans.append(len(set_x & set_y))

print(max(ans))

Buggy submission (verdict: Runtime Error):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
s = ns()

ans = []

for i in range(1, n-1):
    set_x = set(s[:i])
    set_y = set(s[i:])
    ans.append(len(set_x & set_y))

print(max(ans))
Problem p03351 (python)

Fixed submission:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    a, b, c, d = nm()
    if (abs(b-a) <= d and abs(c-b) <= d) or abs(c-a) <= d:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    a, b, c, d = nm()
    if abs(b-a) <= d or abs(c-b) <= d or abs(c-a) <=:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()
Problem p03385 (python)

Fixed submission:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    s = ns()
    
    if set(s) == set(['a', 'b', 'c']):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    s = ns()
    
    if set(s) == set([a, b, c]):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()
Problem p03262 (python)

Fixed submission:
import fractions

N,X=map(int,input().split())
x=map(int,input().split())
x=list(x)
for i in range(N):
    if i==0:
        ans=x[i]-X
    else:
        ans=fractions.gcd(ans,x[i]-X)
print(abs(ans))

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
N,X=map(int,input().split())
x=list(map(int,input().split()))
for i in range(N):
    if i==0:
        ans=x[i]-X
    else:
        ans=math.gcd(ans,x[i]-X)
print(ans)
Problem p02923 (python)

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
if N == 1:
    print(0)
    exit()
reverse_H = H[::-1]
ans = 0
result = []
for i in range(N-1):
    if reverse_H[i] <= reverse_H[i+1]:
        ans += 1
    else:
        result.append(ans)
        ans = 0
if ans > 0:
    result.append(ans)
if result:
    print(max(result))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
if N == 1:
    print(0)
    exit()
reverse_H = H[::-1]
ans = 0
result = []
for i in range(N-1):
    if reverse_H[i] <= reverse_H[i+1]:
        ans += 1
    else:
        result.append(ans)
        ans = 0
print(max(result))

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
reverse_H = H[::-1]
ans = 0
result = []
for i in range(N-1):
    if reverse_H[i] <= reverse_H[i+1]:
        ans += 1
    else:
        result.append(ans)
        ans = 0
print(max(result))
Problem p02947 (python)

Fixed submission:
from math import factorial

def comb(n, r):
    if n == 1:
        return 0
    return factorial(n) // factorial(r) // factorial(n - r)

N = int(input())
S = [input() for _ in range(N)]
str_dict = {}
for s in S:
    sorted_s = "".join(sorted(s))
    if sorted_s not in str_dict:
        str_dict[sorted_s] = 0
    str_dict[sorted_s] += 1
ans = sum([comb(v, 2) for v in str_dict.values()])
print(int(ans))

Buggy submission (verdict: Runtime Error):
from math import factorial

def comb(n, r):
    if n == 1:
        return 0
    return factorial(n) / factorial(r) / factorial(n - r)

N = int(input())
S = [input() for _ in range(N)]
if N == 1:
    print(0)
    exit()
    
str_dict = {}
for s in S:
    sorted_s = "".join(sorted(s))
    if sorted_s not in str_dict:
        str_dict[sorted_s] = 0
    str_dict[sorted_s] += 1
ans = sum([comb(v, 2) for v in str_dict.values()])
print(int(ans))

Buggy submission (verdict: Runtime Error):
from math import factorial

def comb(n, r):
    if n == 1:
        return 0
    return factorial(n) / factorial(r) / factorial(n - r)

N = int(input())
S = [input() for _ in range(N)]
str_dict = {}
for s in S:
    sorted_s = "".join(sorted(s))
    if sorted_s not in str_dict:
        str_dict[sorted_s] = 0
    str_dict[sorted_s] += 1
ans = sum([comb(v, 2) for v in str_dict.values()])
print(int(ans))
Problem p02960 (python)

Fixed submission:
S = input()
dp = [[0] * 13 for _ in range(10 ** 5 + 5)]
MOD = 10 ** 9 + 7
dp[0][0] = 1
n = len(S)
for i in range(n):
    if S[i] == "?":
        c = -1
    else:
        c = int(S[i])

    for j in range(10):
        if c != -1 and c != j:
            continue
        for ki in range(13):
            dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki]

    for j in range(13):
        dp[i + 1][j] %= MOD

print(dp[n][5])

Buggy submission (verdict: Runtime Error):
S = input()
dp = [[0] * 13 for _ in range(10**5)]
MOD = 10 ** 9 + 7
dp[0][0] = 1
n = len(S)
for i in range(n):
    if S[i] == "?":
        c = -1
    else:
        c = ord(S[i]) - ord('0')

    for j in range(10):
        if c != -1 and c != j:
            continue
        for ki in range(13):
            dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki]

    for j in range(13):
        dp[i + 1][j] %= MOD

print(dp[n][5])

Buggy submission (verdict: Runtime Error):
S = input()
dp = [[0] * 13 for _ in range(10**5)]
MOD = 10 ** 9 + 7
dp[0][0] = 1
n = len(S)
for i in range(n):
    if S[i] == "?":
        c = -1
    else:
        c = ord(S[i]) - ord('0')

    for j in range(10):
        if c != -1 and c != j:
            continue
        for ki in range(13):
            dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki]

    for j in range(13):
        dp[i + 1][j] %= MOD

print(dp[n][5])
Problem p02985 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 6)
N, K = map(int, input().split())
mod = 10 ** 9 + 7
edges = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)


def dfs(K, u, p):
    if p == -1:
        can_use_color_num = K - 1
    else:
        can_use_color_num = K - 2

    # if K < len(edges[u]):
    #     return 0
    # else:
    case_num = 1
    for e in edges[u]:
        if e == p:
            continue
        case_num *= can_use_color_num
        can_use_color_num -= 1
        case_num %= mod
    for e in edges[u]:
        if e == p:
            continue
        case_num *= dfs(K, e, u)
        case_num %= mod
    return case_num

ans = K * dfs(K, 0, -1)
ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
mod = 10 ** 9 + 7
edges = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)


def dfs(K, u, p):
    if p == -1:
        can_use_color_num = K - 1
    else:
        can_use_color_num = K - 2

    # if K < len(edges[u]):
    #     return 0
    # else:
    case_num = 1
    for e in edges[u]:
        if e == p:
            continue
        case_num *= can_use_color_num
        can_use_color_num -= 1
        case_num %= mod
    for e in edges[u]:
        if e == p:
            continue
        case_num *= dfs(K, e, u)
        case_num %= mod
    return case_num

ans = K * dfs(K, 0, -1)
ans %= mod
print(ans)
Problem p02995 (python)

Fixed submission:

#最大公約数
def gcd(a,b):
    while b != 0:
        a, b = b, a%b
    return a
    # print(gcd(a,b))

#最小公倍数
def lcm(a,b):
    return a*b // gcd(a,b)
    # print(lcm(a,b))

def main():
    A, B, C, D = list(map(int, input().split()))

    count_c = B // C
    count_d = B // D
    count_union = B // lcm(C, D)

    total1 = B - count_c - count_d + count_union

    count_c = (A - 1) // C
    count_d = (A - 1) // D
    count_union = (A - 1) // lcm(C, D)

    total2 = A - 1 - count_c - count_d + count_union

    print(total1 - total2)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

def main():
    A, B, C, D = list(map(int, input().split()))

    diff = B - A
    count_c = diff // C
    count_d = diff // D
    count_union = diff // lcm(C, D)

    print(diff - count_c - count_d + count_union)

if __name__ == '__main__':
    main()
Problem p03006 (python)

Fixed submission:
from collections import defaultdict
N = int(input())
if N == 1:
    print(1)
    exit()
X, Y = [], []
for _ in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
d = defaultdict(int)
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        p = X[i] - X[j]
        q = Y[i] - Y[j]
        d[(p, q)] += 1
print(N - max(d.values()))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
N = int(input())
X, Y = [], []
for _ in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
d = defaultdict(int)
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        p = X[i] - X[j]
        q = Y[i] - Y[j]
        d[(p, q)] += 1
print(N - max(d.values()))
Problem p03026 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 9 + 7)

N = int(input())
visited = [False] * N
edges = [[] for _ in range(N)]
AB = []
for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    AB.append((a, b))
    edges[a].append(b)
    edges[b].append(a)
C = list(map(int, input().split()))
C.sort(reverse=True)
scores = [-1] * N
i = 0

def dfs(v):
    if visited[v]:
        return

    visited[v] = True
    global i
    scores[v] = C[i]
    i += 1
    for e in edges[v]:
        if visited[e]:
            continue

        dfs(e)

dfs(0)

total = 0
for a, b in AB:
    total += min(scores[a], scores[b])
print(total)
print(*scores)

Buggy submission (verdict: Runtime Error):
N = int(input())
visited = [False] * N
edges = [[] for _ in range(N)]
AB = []
for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    AB.append((a, b))
    edges[a].append(b)
    edges[b].append(a)
C = list(map(int, input().split()))
C.sort(reverse=True)
scores = [-1] * N
i = 0

def dfs(v):
    if visited[v]:
        return

    visited[v] = True
    global i
    scores[v] = C[i]
    i += 1
    for e in edges[v]:
        if visited[e]:
            continue

        dfs(e)

dfs(0)

total = sum(C) - C[0]
print(total)
print(*scores)

Buggy submission (verdict: Runtime Error):
N = int(input())
visited = [False] * N
edges = [[] for _ in range(N)]
AB = []
for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    AB.append((a, b))
    edges[a].append(b)
    edges[b].append(a)
C = list(map(int, input().split()))
C.sort(reverse=True)
scores = [-1] * N
i = 0

def dfs(v):
    if visited[v]:
        return

    visited[v] = True
    global i
    scores[i] = C[i]
    i += 1
    for e in edges[v]:
        if visited[e]:
            continue

        dfs(e)

dfs(0)

total = 0
for a, b in AB:
    total += min(scores[a], scores[b])
print(total)
print(*scores)
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)

N = int(input())
visited = [False] * N
colors = [-1] * N
dist = [float('inf')] * N

def dfs(u):
    if visited[u]:
        return

    visited[u] = True
    for (v, w) in edges[u]:
        if visited[v]:
            continue
        if colors[v] != -1:
            continue

        dist[v] = dist[u] + w
        if dist[v] % 2 == 0:
            colors[v] = 0
        else:
            colors[v] = 1
        dfs(v)


edges = [[] for _ in range(N)]
for _ in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    edges[u].append((v, w))
    edges[v].append((u, w))


colors[0] = 0
dist[0] = 0
dfs(0)
for c in colors:
    print(c)

Buggy submission (verdict: Runtime Error):
#import sys
#sys.setrecursionlimit(10 ** 7)

N = int(input())
visited = [False] * N
colors = [-1] * N
dist = [float('inf')] * N

def dfs(u):
    if visited[u]:
        return

    visited[u] = True
    for (v, w) in edges[u]:
        if visited[v]:
            continue
        if colors[v] != -1:
            continue

        dist[v] = dist[u] + w
        if dist[v] % 2 == 0:
            colors[v] = 0
        else:
            colors[v] = 1
        dfs(v)


edges = [[] for _ in range(N)]
for _ in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    edges[u].append((v, w))
    edges[v].append((u, w))


colors[0] = 0
dist[0] = 0
dfs(0)
for c in colors:
    print(c)

Buggy submission (verdict: Runtime Error):
N = int(input())
visited = [False] * N
colors = [-1] * N
dist = [float('inf')] * N

def dfs(u):
    if visited[u]:
        return

    visited[u] = True
    for (v, w) in edges[u]:
        if visited[v]:
            continue
        if colors[v] != -1:
            continue

        dist[v] = dist[u] + w
        if dist[v] % 2 == 0:
            colors[v] = 0
        else:
            colors[v] = 1
        dfs(v)


edges = [[] for _ in range(N)]
for _ in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    edges[u].append((v, w))
    edges[v].append((u, w))


colors[0] = 0
dist[0] = 0
dfs(0)
for c in colors:
    print(c)
Problem p03086 (python)

Fixed submission:
def main():
    S = input()

    acgt = []
    flag = False
    count = 0
    for s in S:
        if s == "A" or s == "C" or s == "G" or s == "T":
            if flag:
                count += 1
            else:
                flag = True
                count = 1
        else:
            acgt.append(count)
            flag = False
            count = 0

    if count > 0:
        acgt.append(count)
        
    print(max(acgt))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    S = input()

    acgt = []
    flag = False
    count = 0
    for s in S:
        if s == "A" or s == "C" or s == "G" or s == "T":
            if flag:
                count += 1
            else:
                flag = True
                count = 1
        else:
            acgt.append(count)
            flag = False
            count = 0

    print(max(acgt))


if __name__ == '__main__':
    main()