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

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
edges = {}
p = {}
done_nodes = set()

def dfs(target_node, keisyo_point):
    global p
    done_nodes.add(target_node)
    p[target_node] += keisyo_point
    next_node = edges[target_node]
    if not next_node:
        return
    else:
        for next in next_node:
            #edges[next].pop(edges[next].index(target_node))
            #dfs(next, p[target_node])
            if next in done_nodes:
                pass
            else:
                dfs(next, p[target_node])

def main():
    global edges, p
    n, q = map(int, input().split())
    edges = {e: [] for e in range(1, n+1)}
    for _ in range(n - 1):
        a, b = tuple(map(int, input().split()))
        edges[a].append(b)
        edges[b].append(a)
    p = {e: 0 for e in range(1, n+1)}
    for _ in range(q):
        p1, x1 = map(int, input().split())
        p[p1] += x1

    dfs(1, 0)
    for i1 in range(1, n + 1):
        print(p[i1], end=' ')

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
sys.setrecursionlimit(10**6)
edges = {}
p = []

def dfs(target_node, keisyo_point):
    global p
    p[target_node] += keisyo_point
    next_node = edges[target_node]
    if not next_node:
        return
    else:
        for next in next_node:
            dfs(next, p[target_node])

def main():
    global edges, p
    n, q = map(int, input().split())
    edges = {e: [] for e in range(1, n+1)}
    for _ in range(n - 1):
        a, b = tuple(map(int, input().split()))
        edges[a].append(b)
    p = [0] * (n + 1)
    for _ in range(q):
        p1, x1 = map(int, input().split())
        p[p1] += x1

    dfs(1, 0)
    for i1 in range(1, n + 1):
        print(p[i1], end=' ')

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

sys.setrecursionlimit(10**6)
edges = {}
p = []

def dfs(target_node, keisyo_point):
    global p
    p[target_node] += keisyo_point

    next_node = edges[target_node]

    if not next_node:
        return
    else:
        for next in next_node:
            dfs(next, p[target_node])

def main():
    global edges, p
    n, q = map(int, input().split())
    #edges = [tuple(map(int, input().split())) for _ in range(n - 1)]
    edges = {e: [] for e in range(1, n+1)}
    for _ in range(n - 1):
        a, b = tuple(map(int, input().split()))
        edges[a].append(b)
    p = [0] * (n + 1)
    for _ in range(q):
        p1, x1 = map(int, input().split())
        p[p1] += x1

    dfs(1,0)
    for i1 in range(1, n + 1):
        print(p[i1], end=' ')

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

Fixed submission:
a, b = map(int, input().split())
 
if (a - b) % 2 == 0:
  r = int(abs(a - b)/2 + min(a, b))
else:
  r = 'IMPOSSIBLE'
print(r)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())

if (a - b) % 2 == 0:
  r = int(abs(a - b)/2 + min(a, b) )
else:
  r = 'IMPOSSIBLE'
print(r)
Problem p02993 (python)

Fixed submission:
S = input()
 
if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
  r = 'Bad'
else:
  r = 'Good'
 
print(r)

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

if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
  r = 'Bad'
else:
  r - 'Good'

print(r)
Problem p03001 (python)

Fixed submission:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    w, h, x, y = map(int, input().split())
    if x == 0 or y == 0:
        print(w * h / 2, 0)
    elif w / x == 2 and h / y == 2:
        r = x * h
        print(r, 1)
    elif w / x == 2 or h / y == 2:
        if w / x == 2:
            r = x * h
            print(r, 0)
        else:
            r = y * w
            print(r, 0)
    else:
        print(w * h / 2, 0)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import sqrt
def main():
    w, h, x, y = map(int, input().split())
    if w / x == 2 and h / y == 2:
        r = x * h
        print(r, 1)
    elif w / x == 2 or h / y == 2:
        if w / x == 2:
            r = x * h
            print(r, 0)
        else:
            r = y * w
            print(r, 0)
    else:
        print(w * h / 2, 0)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import sqrt
def main():
    w, h, x, y = map(int, input().split())
    if w / x == 2 and h / y == 2:
        r = x * h
        print(r, 1)
    elif w / x == 2 or h / y == 2:
        if w / x == 2:
            r = x * h
            print(r, 0)
        else:
            r = y * w
            print(r, 0)
    else:
        print(w * h / 2, 0)

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

Fixed submission:
from copy import deepcopy
from collections import deque
def main():
    def find(x):
        if par[x] < 0:
            return x
        else:
            par[x] = find(par[x])
            return par[x]
    def unite(x, y):
        x = find(x)
        y = find(y)
        if x == y:
            return False
        else:
            if par[x] > par[y]:
                x, y = y, x
            par[x] += par[y]
            par[y] = x
            return True
    def roots():
        return [i for i, x in enumerate(par) if x < 0]

    n = int(input())
    par = [-1] * n
    uvw = {e:[] for e in range(n)}

    for _ in range(n - 1):
        u, v, w = map(int, input().split())
        u -= 1
        v -= 1
        uvw[u].append((u, v, w))
        uvw[v].append((v, u, w))
        unite(u, v)
    root_node = roots()[0]
    color = [-1] * n
    color[root_node] = 0
    node_next = deque()
    node_next.append(root_node)
    node_next_next = deque()
    node_seen = set()

    while len(node_seen) < n:
        while node_next:
            node_togo = node_next.popleft()
            if node_togo in node_seen:
                continue
            else:
                node_seen.add(node_togo)
            # 次の層のノード群情報を取得し、「次にみるノードlist」にいれる。
            node_adj = uvw[node_togo]
            node_next_next += [i[1] for i in node_adj]
            # 次の層を処理＝色塗りする
            for adj in node_adj:
                if adj[1] in node_seen or color[adj[1]] != -1:
                    continue
                if adj[2] % 2 == 0:
                    color[adj[1]] = color[node_togo]
                else:
                    color[adj[1]] = color[node_togo] ^ 1
        node_next = deepcopy(node_next_next)
        node_next_next = deque()
    print(*color, sep='\n')


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    def dfs(node):
        for adjnode in edges[node]:
            if colors[adjnode[0]] == -1:
                if adjnode[1] % 2 == 0:
                    colors[adjnode[0]] = colors[node]
                else:
                    colors[adjnode[0]] = colors[node] ^ 1
                dfs(adjnode[0])
    # input
    n = int(input())
    edges = {e: [] for e 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))
    # process
    colors = [-1] * n
    colors[0] = 0
    dfs(0)
    # output
    print(*colors, sep='\n')


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

Fixed submission:
import sys
read = sys.stdin.read
from math import gcd
def main():
    n, *a = map(int, read().split())
    if n == 1:
        print(a[0])
        sys.exit()
    l = [0] * (n + 1)
    for i1 in range(n):
        l[i1 + 1] = gcd(l[i1], a[i1])
    r = [0] * (n + 1)
    for j1 in range(n - 1, -1, -1):
        r[j1] = gcd(r[j1 + 1], a[j1])
    m = [0] * (n + 1)
    for k1 in range(n):
        m[k1] = gcd(l[k1], r[k1 + 1])
    r = max(m)
    print(r)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
from math import gcd
from collections import deque
from operator import mul
from functools import reduce
def main():
    n = int(input())
    a = list(map(int, read().split()))
    if n == 2:
        print(max(a))
        sys.exit()
    from math import sqrt
    from math import ceil
    maxa = max(a)
    maxa2 = ceil(sqrt(maxa))
    maxa2 = max(6, maxa2)  # maxa2が6未満だとエラーになる
    p = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(maxa2)]
    p[0] = p[1] = False
    p[2] = p[3] = p[5] = True
    for is1 in range(3, maxa2, 2):
        for is2 in range(is1 ** 2, maxa2, is1):
            p[is2] = False
    prime_list = [i for i, b in enumerate(p) if b]
    div = []
    koho = -1
    for pe in prime_list:
        while True:
            check = [i % pe == 0 for i in a]
            if all(check):
                div.append(pe)
                a = [i // pe for i in a]
            else:
                if n - sum(check) == 1:
                    koho = pe
                break
    if koho > 0:
        div.append(koho)
    r = reduce(mul, div)
    print(r)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
from math import gcd
from collections import deque
from operator import mul
from functools import reduce
def main():
    n = int(input())
    a = list(map(int, read().split()))

    from math import sqrt
    from math import ceil
    maxa = max(a)
    maxa2 = ceil(sqrt(maxa))
    maxa2 = max(6, maxa2)  # maxa2が6未満だとエラーになる
    p = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(maxa2)]
    p[0] = p[1] = False
    p[2] = p[3] = p[5] = True
    for is1 in range(3, maxa2, 2):
        for is2 in range(is1 ** 2, maxa2, is1):
            p[is2] = False
    prime_list = [i for i, b in enumerate(p) if b]
    div = []
    koho = -1
    for pe in prime_list:
        while True:
            check = [i % pe == 0 for i in a]
            if all(check):
                div.append(pe)
                a = [i // pe for i in a]
            else:
                if n - sum(check) == 1:
                    koho = pe
                break
    if koho > 0:
        div.append(koho)
    r = reduce(mul, div)
    print(r)

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

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

def main():
    n, w_max = map(int, input().split())
    items = [tuple(map(int, input().split())) for _ in range(n)]
    inf = float('inf')
    dp = [[inf] * 100001 for _ in range(n + 1)]
    dp[0][0] = 0
    for i1 in range(1, n + 1):
        w, v = items[i1 - 1][0], items[i1 - 1][1]
        for col in range(1, 100001):
            if v >= col:
                tmp1 = w
            else:
                tmp1 = dp[i1 - 1][col - v] + w
            dp[i1][col] = min(dp[i1 - 1][col], tmp1)
    for i2 in range(100000, 0, -1):
        if dp[-1][i2] <= w_max:
            print(i2)
            sys.exit()

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n, w_max = map(int, input().split())
    dp = [[0] * (w_max + 1) for _ in range(n + 1)]
    items = [tuple(map(int, input().split())) for _ in range(n)]
    for i1 in range(1, n + 1):
        w, v = items[i1 - 1][0], items[i1 - 1][1]
        for col in range(1, w_max + 1):
            if w <= col:
                dp[i1][col] = max(dp[i1 - 1][col], dp[i1 - 1][col - w] + v)
            else:
                dp[i1][col] = dp[i1 - 1][col]

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

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
n, w = map(int, input().split())

dp = [0]*(w+1)

for _ in range(n):
  wei, v = map(int, input().split())
  dp_1 = dp[:]
  for j in range(w + 1):
    if j - wei >= 0:
      dp[j] = dp_1[j-wei] + v if (dp_1[j-wei] + v) > dp_1[j] else dp[j]
  
print(dp[w])
Problem p03168 (python)

Fixed submission:
def main():
    n = int(input())
    p = tuple(map(float, input().split()))
    # pr = [1 - pi for pi in p]
    # DPの二次元配列を行i1＝コインの枚数、列i2＝表がでたコインの枚数、で構築する。
    # DP[][]の初期値は0。ただし0列(表が0枚になる確率)をまず初期化する。
    # DP[i1][i2]の値は、DP[i1-1][i2] * pr + DP[i1-1][i2-1] * p
    # 「表の枚数＞裏の枚数になる確率」は、DPの最下行のX列から右の列の価の合計。
    dp = [[0.0] * (n + 1) for _ in range(n + 1)]
    # ０列目を初期化する。
    dp[0][0] = 1.0 #コイン0枚目で表が０枚の確率＝１
    for i0 in range(1, n + 1):
        dp[i0][0] = dp[i0-1][0] * (1 - p[i0-1])

    for i1 in range(1, n + 1):
        pe = p[i1 - 1]
        pre = 1 - pe
        for i2 in range(1, i1 + 1):
            dp[i1][i2] = dp[i1-1][i2] * pre + dp[i1-1][i2-1] * pe

    r = sum(dp[n][n//2+1:])
    print(r)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    p = tuple(map(float, input().split()))
    
    dp = [[0.0] * (n + 1) for _ in range(n + 1)]
    dp[0][0] = 1.0 
    for i0 in range(1, n + 1):
        dp[i0][0] = dp[i0-1][0] * pr[i0-1]

    for i1 in range(1, n + 1):
        pe = p[i1 - 1]
        pre = 1 - pe
        for i2 in range(1, i1 + 1):
            dp[i1][i2] = dp[i1-1][i2] * pre + dp[i1-1][i2-1] * pe

    r = sum(dp[n][n//2+1:])
    print(r)

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

Fixed submission:

import sys
sys.setrecursionlimit(10**6)
dp = []
train = []

def subq(l, r):
    global dp, train
    if l == 0 or r == 0:
        return 0
    else:
        tmp1 = dp[l][r]
        if tmp1 != -1:
            return tmp1
        else:
            tmp2 = train[l][r] + subq(l - 1, r) + subq(l, r - 1) -  subq(l - 1, r - 1)
            dp[l][r] = tmp2
            return tmp2

def main():
    global dp, train
    n, m, qn = map(int, input().split())
    dp = [[-1] * (n+1) for _ in range(n+1)]
    train = [[0] * (n+1) for _ in range(n+1)]
    for _ in range(m):
        l, r = map(int, input().split())
        train[int(l)][int(r)] += 1

    for _ in range(qn):
        p, q = map(int, input().split())
        r = subq(q, q) - subq(p-1, q) - subq(q, p-1) + subq(p-1, p-1)
        print(r)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

dp = []
train = []

def subq(l, r):
    global dp, train
    if l == 0 or r == 0:
        return 0
    else:
        tmp1 = dp[l][r]
        if tmp1 != -1:
            return tmp1
        else:
            tmp2 = train[l][r] + subq(l - 1, r) + subq(l, r - 1) -  subq(l - 1, r - 1)
            dp[l][r] = tmp2
            return tmp2

def main():
    global dp, train
    n, m, q = map(int, input().split())
    dp = [[-1] * (n+1) for _ in range(n+1)]
    train = [[0] * (n+1) for _ in range(n+1)]
    for _ in range(m):
        l, r = input().split()
        l = int(l)
        r = int(r)
        train[int(l)][int(r)] += 1


    for _ in range(q):
        p, q = input().split()
        p = int(p)
        q = int(q)
        r = subq(q, q) - subq(p-1, q) - subq(q, p-1) + subq(p-1, p-1)
        print(r)

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

Fixed submission:
R = int(input())
 
if R < 1200:
  r = 'ABC'
elif R < 2800:
  r = 'ARC'
else:
  r ='AGC'
 
print(r)

Buggy submission (verdict: Runtime Error):
R = int(input())
 
if R < 1200:
  r = 'ABC'
elif R < 2800:
  r = 'ARC':
else:
  r ='AGC'
print(r)

Buggy submission (verdict: Runtime Error):
R = int(input())

if R < 1200:
  r = 'ABC'
elif R < 2800:
  r = 'ARC':
else:
  r ='AGC'

print(r)
Problem p03292 (python)

Fixed submission:
a, b, c = map(int, input().split())
 
r = abs(a-b) + abs(a-c) + abs(b-c)
r = r - max(abs(a-b) , abs(a-c) , abs(b-c))
print(int(r))

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())

r = abs(a-b) + abs(a-c) + abs(b-c)
r = r - max(abs(a-b) , abs(a-c) , abs(b-c))
print(int(r))
Problem p03351 (python)

Fixed submission:
a, b, c, d = map(int, input().split())
if abs(a - c) <= d:
  r = 'Yes'
elif abs(a - b) <= d and abs(b - c) <= d:
  r = 'Yes'
else:
  r = 'No'
  
print(r)

Buggy submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
if abs(a - c) <= d:
  r = 'Yes'
elif abs(a - b) <= d and abs(b - c) <= d:
  r = 'Yes'
else:
  r = 'No'

print(int(r))
Problem p03449 (python)

Fixed submission:
def main():
    n = int(input())
    a1 = list(map(int, input().split()))
    a2 = list(map(int, input().split()))

    scores = []
    for i1 in range(n):
        score = sum(a1[:i1+1]) + sum(a2[i1:])
        scores.append(score)
    r = max(scores)
    print(r)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import accumulate
from itertools import chain
from collections import deque
def main():
    n = int(input())
    a1 = chain(tuple([0]), tuple(map(int, input().split())))
    a2 = chain(tuple([0]), tuple(map(int, input().split())))

    a1a = tuple(accumulate(a1))
    a2a = tuple(accumulate(a2))
    scores = deque()
    for i1 in range(1, n + 1):
        scores.append([i1] + a2a[n] - a2a[i1 - 1])
    r = max(scores)
    print(r)
if __name__ == '__main__':
    main()
Problem p03469 (python)

Fixed submission:
s = input()
s = s.replace('2017','2018')
print(s)

Buggy submission (verdict: Runtime Error):
S = input()
s[3] = '8'
print(s)
Problem p03504 (python)

Fixed submission:
import sys
read = sys.stdin.read
def main():
    n, c = map(int, input().split())
    d = {e: [0] * (c + 1) for e in range(100001)}
    d1 = [0] * 100001
    m = map(int, read().split())
    stc = zip(m, m, m)
    for s, t, c in stc:
        if d[s][c]:
            d1[s - 1] -= 1
            d1[s] += 1
        else:
            d[s][c] = 1
        if d[t][c]:
            d1[t - 1] -= 1
            d1[t] += 1
        else:
            d[t][c] = 1
        d1[s - 1] += 1
        d1[t] -= 1

    cur = 0
    r = 0
    for i1 in range(100001):
        cur += d1[i1]
        r = max(r, cur)
    print(r)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
def main():
    n, c = map(int, input().split())
    # cs[0]とcs[-1]はindex error除け。
    cs = [0] * 10002

    for _ in range(n):
        s, t, c = map(int, input().split())
        cs[s - 1] += 1
        cs[t + 1] -= 1
    cur = 0
    r = 0
    for cse in cs:
        cur += cse
        r = max(r, cur)
    print(r)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
def main():
    n, c = map(int, input().split())
    # cs[0]とcs[-1]はindex error除け。
    cs = [0] * 10001

    for _ in range(n):
        s, t, c = map(int, input().split())
        cs[s] += 1
        cs[t + 1] -= 1
    cur = 0
    r = 0
    for cse in cs:
        cur += cse
        r = max(r, cur)
    print(r)

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

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    a, b, c, d, e, f = map(int, input().split())
    a *= 100
    b *= 100

    # 濃度0%のケース
    if e == 0 or min(a, b) == f:
        print(a, 0)
        sys.exit()

    water = [0] * 6001
    water[0] = True
    for i1 in range(3001):
        if water[i1]:
            water[i1 + a] = True
            water[i1 + b] = True
    sugar = [0] * 6001
    sugar[0] = True
    for i1 in range(3001):
        if sugar[i1]:
            sugar[i1 + c] = True
            sugar[i1 + d] = True

    noudo = 0
    r1 = 0
    r2 = 0
    for i1 in range(1, f + 1):
        if water[i1]:
            for i2 in range(f + 1):
                if i1 + i2 > f:
                    break
                if sugar[i2]:
                    if i1 * e >= i2 * 100:
                        if noudo < i2 / (i1 + i2):
                            noudo = i2 / (i1 + i2)
                            r1 = int(i1 + i2)
                            r2 = int(i2)
                    else:
                        break
    if noudo == 0:
        print(a, 0)
    else:
        print(r1, r2)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import ceil
def main():
    a, b, c, d, e, f = map(int, input().split())
    a *= 100
    b *= 100

    # 濃度0%のケース
    if e == 0 or min(a, b) == f:
        print(a, 0)
        sys.exit()
    water = [0] * 6001
    water[0] = True
    for i1 in range(3001):
        if water[i1]:
            water[i1 + a] = True
            water[i1 + b] = True
    sugar = [0] * 6001
    sugar[0] = True
    for i1 in range(3001):
        if sugar[i1]:
            sugar[i1 + c] = True
            sugar[i1 + d] = True

    noudo = 0
    r1 = 0
    r2 = 0
    for i1 in range(1, f + 1):
        if water[i1]:
            for i2 in range(f + 1):
                if i1 + i2 > f:
                    break
                if sugar[i2]:
                    if i1 * e >= i2 * 100:
Problem p03607 (python)

Fixed submission:
from collections import Counter
def main():
    n = int(input())
    l1 = []
    for _ in range(n):
        l1.append(input())
    l1c = Counter(l1)
    l1c2 = [c for c in l1c if l1c[c]%2 != 0]
    print(len(l1c2))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    l1 = [0] * (10**9 + 1)
    print(n)
    for _ in range(n):
        i = int(input())
        l1[i] ^= 1
    print(sum(l1))


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

Fixed submission:
s = set(input())
abc = set('abcdefghijklmnopqrstuvwxyz')
nots = abc.difference(s)
if len(nots) == 0:
  print('None')
else:
  print(min(nots))

Buggy submission (verdict: Runtime Error):
s = set(input())
abc = set('abcdefghijklmnopqrstuvwxyz')
nots = abc.difference(s)
print(min(nots))
Problem p03625 (python)

Fixed submission:
from collections import Counter
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ac = Counter(a)
    acl = [i for i in ac if ac[i] >= 2]
    acl.sort(reverse=True)

    if len(acl) == 0:
        print(0)
    elif ac[acl[0]] >= 4:
        print(int(acl[0] * acl[0]))
    elif len(acl) <= 1:
        print(0)
    else:
        print(int(acl[0]*acl[1]))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from collections import Counter
def main():
    n = int(input())
    a = list(map(int,input().split()))
    a.sort(reverse=True)
    ac = Counter(a)
    acl = [i for i in ac if ac[i] >= 2]

    if ac[acl[0]] >= 4:
        print(int(acl[0] ** 2))
    else:
        print(int(acl[0]*acl[1]))

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

Fixed submission:
a, b, c, d = map(int, input().split())

start = max(a, c)
end = min(b, d)

r = max(0, end - start)
print(int(r))

Buggy submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
end = min((a + b),(c + d))
start max(a,c)
r = max(0, end - start)
print(r)
Problem p03680 (python)

Fixed submission:
n = int(input())
a = [0]
tmp = [int(input()) for _ in range(n)]
a = a + tmp

r = -1
cnt = 1
next = a[1]
while cnt < n:
  if next == 2:
    r = cnt
    break
  else:
    next = a[next]
    cnt += 1
print(r)

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, *a = map(int, read().split())
    if n == 2:
        print(1)
        sys.exit()
    r = 0
    x = 2
    while x != 1:
        r += 1
        x = a.index(x) + 1
        if x == 2 or r >= n:
            r = -1
            break
    print(r)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, *a = map(int, read().split())
    if n == 2:
        print(1)
        sys.exit()
    r = 0
    x = 2
    while x != 1:
        r += 1
        x = a.index(x) + 1
        if x == 2:
            r = -1
            break
    print(r)

if __name__ == '__main__':
    main()