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

Fixed submission:
import sys
sys.setrecursionlimit(20000000)
#input = sys.stdin.readline
n = int(input())
g = [[] for i in range(n)]
for i in range(n-1):
    u,v,w = map(int,input().split())
    u-=1;v-=1
    g[u].append([v,w])
    g[v].append([u,w])
ans = [-1]*n
def dfs(x,y):
    for i,j in g[x]:
        if ans[i] == -1:
            ans[i] = (y+j)%2
            dfs(i,y+j)
dfs(0,0)
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):

Copy
Copy
import sys
sys.setrecursionlimit(20000000)
#input = sys.stdin.readline
n = int(input())
g = [[] for i in range(n)]
for i in range(n-1):
    u,v,w = map(int,input().split())
    u-=1;v-=1
    g[u].append([v,w])
    g[v].append([u,w])
ans = [-1]*n
def dfs(x,y):
    for i,j in g[x]:
        if ans[i] == -1:
            ans[i] = (y+j)%2
            dfs(i,y+j)
dfs(0,0)
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
def dfs(node, distance):
    for next_node, edge_size in G[node]:
        if ans[next_node] == -1:
            ans[next_node] = ((distance+edge_size) % 2)
            dfs(next_node, distance+edge_size)


N = int(input())

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

ans = [-1]*N
dfs(0, 0)
print(*ans, sep='\n')

Buggy submission (verdict: Runtime Error):
def dfs(node, distance, ans, G):
    for next_node, edge_size in G[node]:
        if ans[next_node] == -1:
            ans[next_node] = ((distance+edge_size) % 2)
            dfs(next_node, distance+edge_size, ans, G)
    return ans


N = int(input())

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

ans = [-1]*N
ans = dfs(0, 0, ans, G)
print(*ans, sep='\n')

Buggy submission (verdict: Runtime Error):
def dfs(node, distance, ans, G):
    for next_node, edge_size in G[node]:
        if ans[next_node] == -1:
            ans[next_node] = ((distance+edge_size) % 2)
            dfs(next_node, distance+edge_size, ans, G)
    return ans


N = int(input())

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

ans = [-1]*N
ans = dfs(0, 0, ans, G)
print(*ans, sep='\n')

Buggy submission (verdict: Runtime Error):
def dfs(node, distance, ans, G):
    for next_node, edge_size in G[node]:
        if ans[next_node] == -1:
            ans[next_node] = ((distance+edge_size) % 2)
            dfs(next_node, distance+edge_size, ans, G)
    return ans


N = int(input())

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

ans = [-1]*N
ans = dfs(0, 0, ans, G)
print(*ans, sep='\n')
Problem p03067 (python)

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

if (A[0] < A[2] < A[1]) or (A[1] < A[2] < A[0]):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
from itertools import accumulate


N = int(input())
S = input()

black = [0]*N
white = [0]*N

for i, s in enumerate(S):
    if s == '#':
        black[i] = 1
    else:
        white[i] = 1

# 累積和
black = [0] + black
black = list(accumulate(black))
white = [0] + white[::-1]
white = list(accumulate(white))[::-1]

ans = []
for i in range(N+1):
    ans.append(black[i] + white[i])

print(min(ans))
Problem p03074 (python)

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

S = S + 'E'   # 終端処理
ans = -1    # 答えの初期値（十分に小さい値）

# 立った人の連続の数
if (S[0] == '0'):
    stand = 1
else:
    stand = 0

L = 0
R = 0

# 尺取り法
while (R < N):
    # 右端を進めることが可能（立った人の連続の数がK以下）なら、右端を進める
    if (stand <= K):
        # 立った人の連続の集合数が増えるなら1足す
        if (S[R] == '1' and S[R + 1] == '0'):
            stand += 1
        ans = max(ans, R - L + 1)
        R += 1
    # 進められない場合、左端と右端が同じなら両者を進める
    # 左端が右端を追い越さないための処理
    elif (L == R):
        L += 1
        R += 1
    # それ以外は左端のみを進める
    else:
        # 立った人の連続の数が減るなら1減らす
        if (S[L] == '0' and S[L + 1] == '1'):
            stand -= 1
        L += 1

print(ans)

Buggy submission (verdict: Runtime Error):
N, K = list(map(int, input().split()))
S = input()

ans = -1    # 十分に小さい値
if (S[0] == '0'):
    stand = 1
else:
    stand = 0

L = 0
R = 0

# 尺取り法
while (R < N):
    # 右端を進めることが可能（進めたときの積がK以下）なら、右端を進める
    if (stand <= K):
        ans = max(ans, R - L + 1)
        if (S[R] == '1' and S[R + 1] == '0'):
            stand += 1
        R += 1
    # 進められない場合、左端と右端が同じなら両者を進める
    # 左端が右端を追い越さないための処理
    elif (L == R):
        L += 1
        R += 1
    # それ以外は左端のみを進める
    else:
        if (S[L] == '0' and S[L + 1] == '1'):
            stand -= 1
        L += 1

Buggy submission (verdict: Runtime Error):
N, K = list(map(int, input().split()))
S = input()

ans = -1    # 十分に小さい値
if (S[0] == '0'):
    stand = 1
else:
    stand = 0

l = 0
r = 0

# 尺取り法
while (r < N):
    # 右端を進めることが可能（進めたときの積がK以下）なら、右端を進める
    if (stand <= K):
        ans = max(ans, r - l + 1)
        if (S[r] == '1' and S[r + 1] == '0'):
            stand += 1
        r += 1
    # 進められない場合、左端と右端が同じなら両者を進める
    # 左端が右端を追い越さないための処理
    elif (l == r):
        l += 1
        r += 1
    # それ以外は左端のみを進める
    else:
        if S[l] == '0' and if S[l + 1] == '1':
            stand -= 1
        l += 1
Problem p03086 (python)

Fixed submission:
S = input()
N = len(S)

alp = 'BDEFHIJKLMNOPQRSUVWXYZ'

ans = []
cnt = []

for i in range(0, N):
    for j in range(i, N+1):
        tmp = S[i:j]
        flg = 1
        for a in alp:
            if a in tmp:
                flg = 0
        if flg:
            cnt.append(len(tmp))

print(max(cnt))

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

alp = 'ACGT'

cnt = []

for i in range(0, N):
    for j in range(i, N+1):
        tmp = S[i:j]
        flg = 0
        for a in alp:
            if a in tmp:
                flg = 1
        if flg:
            cnt.append(len(tmp))

print(max(cnt))
Problem p03095 (python)

Fixed submission:
N = int(input())
S = input()

M = 10**9 + 7
cnt = [0] * 26

for i in range(N):
    cnt[ord(S[i]) - ord('a')] += 1

ans = 1
for i in range(26):
    ans *= (cnt[i] + 1)
    ans %= M

print(ans - 1)

Buggy submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

long long N, ans, M, cnt[26];
char S;

int main() {
  M = 1e9 + 7;
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> S;
    cnt[S - 'a']++;
  }

  ans = 1;
  for (int i = 0; i < 26; i++) {
    ans *= (cnt[i] + 1);
    ans %= M;
  }

  cout << ans - 1 << '\n';

  return 0;
}
Problem p03111 (python)

Fixed submission:
import itertools
import numpy as np
import copy


ansl = []
N, A, B, C = list(map(int, input().split()))

a = []
for i in range(N):
    a.append(int(input()))

def get_ptn(la):
    ptn = []
    for i in range(1, len(la) + 1):
        ptn.append(list(itertools.combinations(la, i)))
    return ptn

takes = list(itertools.permutations([A, B, C]))

for take in takes:
    # print(take)
    # print(a)
    try:
        ta = copy.deepcopy(a)
        ans = 0
        for k in range(3):
            # print(a)
            ptn = get_ptn(ta)

            # print(ptn)
            cost = []
            tmp = []
            for i in range(len(ptn)):
                tmp.append([abs(take[k] - sum(j)) for j in ptn[i]])
                cost.append(min(tmp[i]) + 10 * i)
            ans += min(cost)
            ac = np.argmin(cost)
            # print(np.argmin(cost))
            # print(ptn[ac])
            # print(tmp[ac])
            at = np.argmin(tmp[ac])
            # print(ptn[ac][at])

            for _ in ptn[ac][at]:
                ta.remove(_)

        ansl.append(ans)
    except:
        pass

print(min(ansl))

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np
import copy


ansl = []
N, A, B, C = list(map(int, input().split()))

a = []
for i in range(N):
    a.append(int(input()))

def get_ptn(la):
    ptn = []
    for i in range(1, len(la) + 1):
        ptn.append(list(itertools.combinations(la, i)))
    return ptn

takes = list(itertools.permutations([A, B, C]))


for take in takes:
    # print(take)
    # print(a)
    ta = copy.deepcopy(a)
    ans = 0
    for k in range(3):

        # print(a)
        ptn = get_ptn(ta)

        # print(ptn)
        cost = []
        tmp = []

        for i in range(len(ptn)):
            tmp.append([abs(take[k] - sum(j)) for j in ptn[i]])
            cost.append(min(tmp[i]) + 10 * i)
        # print(cost)
        ans += min(cost)
        ac = np.argmin(cost)
        # print(np.argmin(cost))
        # print(ptn[ac])
        # print(tmp[ac])
        at = np.argmin(tmp[ac])
        # print(ptn[ac][at])

        for _ in ptn[ac][at]:
            ta.remove(_)

    ansl.append(ans)

print(min(ansl))
Problem p03485 (python)

Fixed submission:
import math

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

ans =math.ceil(((a + b) / 2))

print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()

s_dash = ''.join(sorted(s))
t_dash = ''.join(sorted(t)[::-1])

test = [s_dash, t_dash]

if s_dash == t_dash:
    print("No")
else:
    if sorted(test)[0] != s_dash:
        print("No")
    else:
        print("Yes")
Problem p03547 (python)

Fixed submission:
A, B = input().split()

if A < B:
    print("<")
elif A > B:
    print(">")
else:
    print("=")

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

if A < B:
    print("<")
elif A > B:
    print(">")
else:
    print("=")
Problem p03573 (python)

Fixed submission:
A, B, C = list(map(int, input().split()))

if A == B:
    print(C)
elif A == C:
    print(B)
else:
    print(A)

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

if A == B:
    print(C)
elif A == C
    print(B)
else:
    print(A)
Problem p03657 (python)

Fixed submission:
A, B = list(map(int, input().split()))

if A*B*(A+B) %3 == 0:
    print('Possible')
else:
    print('Impossible')

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))

X = sum(a)
b = [a[0]]
for i in range(1, N):
    b.append(b[i-1] + a[i])

ans = []
for i in range(1, N):
    ans.append(abs(X - 2*b[i]))

print(min(ans))
Problem p03659 (python)

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

X = sum(a)
b = [a[0]]
for i in range(1, N - 1):
    b.append(b[i-1] + a[i])

ans = []
for i in range(0, N - 1):
    ans.append(abs(X - 2*b[i]))

print(min(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))

a = sorted(a)
X = sum(a)

ans = []
for i in range(1, N - 1):
    ans.append(X - 2*sum(a[:i]))

print(min(ans))
Problem p03694 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
print(max(A) - min(A))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]
print(max(A) - min(A))
Problem p03729 (python)

Fixed submission:
a, b, c = input().split()
 
if (a[-1] == b[0]) and (b[-1] == c[0]):
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
a, b, c = input().split()

if (a[-1] == B[0]) and (B[-1] == C[0]):
    print("YES")
else:
    print("NO")
Problem p03814 (python)

Fixed submission:
S = input()
N = len(S)
for i, s in enumerate(S):
    if s == 'A':
        a_index = i
        break
for i, s in enumerate(S[::-1]):
    if s == 'Z':
        z_index = i
        break

print(N - z_index - a_index)

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
for s, i in enumerate(S):
    if s == 'A':
        a_index = i
        break
for s, i in enumerate(S[::-1]):
    if s == 'A':
        z_index = i
        break

print(N - z_index - a_index)
Problem p03844 (python)

Fixed submission:
a, b, c = input().split()
if (b == '+'):
    print(int(a) + int(c))
else:
    print(int(a) - int(c))

Buggy submission (verdict: Runtime Error):
a, b, c = list(map(float, input().split()))
if (b == '+'):
    print(a + c)
else:
    print(a - c)

Buggy submission (verdict: Runtime Error):
a, b, c = input().split()
if (b == '+'):
    print(a + c)
else:
    print(a - c)
Problem p02748 (python)

Fixed submission:
A, B, M = [int(num) for num in input().split()]
a = [int(num) for num in input().split()]
b =  [int(num) for num in input().split()]
minimum = -1
for i in range(M):
    xi, yi, ci =  [int(num) for num in input().split()]
    ai = a[xi-1]
    bi = b[yi-1]
    sum = ai + bi - ci
    if minimum == -1 or sum < minimum:
        minimum = sum
a.sort()
b.sort()
sum = a[0]+b[0]
if minimum < sum:
    print(minimum)
else:
    print(sum)

Buggy submission (verdict: Runtime Error):
A, B, M = [int(num) for num in input().split()]
a = [int(num) for num in input().split()]
b =  [int(num) for num in input().split()]
minimum = -1
for i in range(M):
    xi, yi, ci =  [int(num) for num in input().split()]
    ai = a[xi]
    bi = b[yi]
    sum = ai + bi - ci
    if minimum == -1 or sum < minimum:
        minimum = sum
print(minimum)
Problem p02783 (python)

Fixed submission:
H , A = input().split()
H , A = int(H), int(A)
answer = H // A
if H % A == 0:
    print(answer)
else:
    print(answer + 1)

Buggy submission (verdict: Runtime Error):
H , A = input().split()
H , A = int(H), int(A)
answer = H // A
if H % A == 0:
    print(answer)
else:
    print(anser + 1)
Problem p02830 (python)

Fixed submission:
N = input()
S, T = input().split()
A = ""
for s, t in zip(S, T):
    A += s
    A += t
print(A)

Buggy submission (verdict: Runtime Error):
N = input()
S, T = input().split()
A = String()
for s, t in zip(S, T):
  A += s
  A += t
print(A)
Problem p02887 (python)

Fixed submission:
n = int(input())
s = input()
ans = ''
i = 0
prev = ''
while i < n - 1:
    if prev != s[i]:
        ans += s[i]
    prev = s[i]
    if s[i] == s[i+1]:
        i += 2
    else:
        i += 1
if not(i > n - 1):
    if prev != s[i]:
        ans += s[i] 
print(len(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
ans = ''
i = 0
prev = ''
while i < n - 1:
    if prev != s[i]:
        ans += s[i]
    prev = s[i]
    if s[i] == s[i+1]:
        i += 2
    else:
        i += 1
if prev != s[i]:
    ans += s[i] 
print(len(ans))
Problem p02922 (python)

Fixed submission:
a, b = (int(_) for _ in input().split())
total = 1
ans = 0
while total < b:
  total -= 1
  total += a
  ans += 1    
print(ans)

Buggy submission (verdict: Runtime Error):
a, b = (int(_) for _ in input().split())
total = 1
ans = 0
if b == 1:
    print(1)
else:
    while total < b:
      	total -= 1
        total += a
        ans += 1
        
print(ans)
Problem p02983 (python)

Fixed submission:
l, r = (int(_) for _ in input().split())

if abs(l - r) == 1:
    print(l * r % 2019)
else:
    lower = l // 2019
    upper = r // 2019
    start = l % 2019
    stop = r % 2019
    if 2019 * (lower + 1) < r:
        print(0)
    else:
        ans = 1000000
        if start == 0:
            print(0)
        elif stop == 0:
            print(0)
        elif stop < start:
            print(0)
        elif stop > start:
            for i in range(start, stop + 1):
                for j in range(i+1, stop + 1):
                    if i * j % 2019 < ans:
                        ans = i * j % 2019
            print(ans)

Buggy submission (verdict: Runtime Error):
l, r = (int(_) for _ in input().split())

if abs(l - r) == 1:
    print(l * r % 2019)
else:
    lower = l // 2019
    upper = r // 2019
    start = l % 2019
    stop = r % 2019
    if 2019 * (lower + 1) < r:
        print(0)
    else:
        if start == 0:
            print(0)
        elif stop == 0:
            print(0)
        elif stop < start:
            print(0)
        elif stop > start:
            while stop > start:
                total = stop * start % 2019
                if total < ans:
                    ans = total
                start += 1
            print(ans)
Problem p03062 (python)

Fixed submission:
n = int(input())
A = [int(_) for _ in input().split()]
total = sum(A)
neg = 0
pos = 0
neno = []
pono = []
for a in A:
    if a < 0:
        neg += 1
        neno.append(a)
    else:
        pos += 1
        pono.append(a)
neno.sort()
pono.sort()
noneg = -sum(neno) + sum(pono)
if n == 2:
    print(max(-total, total))
else:
    if neg % 2 == 0:
        print(noneg)
    else:
        if pos != 0:
            print(noneg - 2*min(-neno[-1],pono[0]))
        else:
            print(noneg + 2*(neno[-1]))

Buggy submission (verdict: Runtime Error):
n = int(input())
A = [int(_) for _ in input().split()]
total = sum(A)
neg = 0
neno = []
pono = []
for a in A:
    if a < 0:
        neg += 1
        neno.append(a)
    else:
        pono.append(a)
neno.sort()
pono.sort()
noneg = -sum(neno) + sum(pono)
if n == 2:
    print(max(-total, total))
else:
    if neg % 2 == 0:
        print(noneg)
    else:
        print(noneg - 2*min(-neno[-1],pono[0]))
Problem p03067 (python)

Fixed submission:
a, b, c = (int(_) for _ in input().split())  

if a > b:
    if b < c < a:
        print("Yes")
    else:
        print("No")
else:
    if a < c < b:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
start = s[0]
pattern = []

prev = ''
b = 0
w = 0
for i in s:
    if (i == '#' and prev == '#') or (i == '#' and prev ==''):
        b += 1
    elif (i == '.' and prev == '.') or (i == '.' and prev == ''):
        w += 1
    elif i == '#':
        b += 1
        pattern.append(w)
        w = 0
    else:
        w += 1
        pattern.append(b)
        b = 0
    prev = i
    
if prev == '#':
    pattern.append(b)
else:
    pattern.append(w)

totalb = 0
totalw = 0
for i in range(len(pattern)):
    if start == '.':
        if i % 2 == 0:
            totalw += pattern[i]
        else:
            totalb += pattern[i]
    else:
        if i % 2 == 0:
            totalb += pattern[i]
        else:
            totalw += pattern[i]
        
if len(pattern) == 1 or (len(pattern) == 2 and start == '.'):
    print(0)
elif (len(pattern) == 2 and start == '#'):
    print(min(totalw, totalb))
elif start == '.' and prev == "#":
    print(min(totalw - pattern[0], totalb - pattern[-1]))
elif start == '.':
    print(min(totalw - pattern[0], totalb))
else:
    print(min(totalw, totalb))
Problem p03071 (python)

Fixed submission:
a, b = (int(_) for _ in input().split())
if a - 2 >= b:
  print(a*2 -1)
elif b - 2 >= a:
  print(b*2 -1)
else:
  print(a+b)

Buggy submission (verdict: Runtime Error):
a, b = int(_) for _ in input().split()
if a - 2 > b:
  print(a*2)
elif b - 2 > a:
  print(b*2)
else:
  print(a+b)
Problem p03086 (python)

Fixed submission:
b = input()
let = 'ATGC'
prev = b[0]
high = 0
leng = 0
stop = False

if prev in let:
    leng = 1
    high = 1
    
for i in range(1,len(b)):
    if leng == 0 and b[i] in let:
        leng = 1
    if b[i] in let and prev in let:
        leng += 1
        stop = False
    else:
        stop = True
        if leng > high:
            high = leng
            leng = 0
    prev = b[i]
    
if not stop:
    if leng > high:
        high = leng
    
print(high)

Buggy submission (verdict: Runtime Error):
b = input()
let = 'ATGC'
prev = b[0]
high = 0
if prev in let:
    leng = 1
    high = 1
for i in range(1,len(b)):
    if leng == 0 and b[i] in let:
        leng = 1
    if b[i] in let and prev in let:
        print(b[i])
        leng += 1
    else:
        if leng > high:
            high = leng
    prev = b[i]

print(high)

Buggy submission (verdict: Runtime Error):
b = input()
let = 'ATGC'
prev = b[0]
if prev in let:
    leng = 1
lens = []
for i in range(1,len(b)):
    if leng == 0 and b[i] in let:
        leng = 1
    if b[i] in let and prev in let:
        print(b[i])
        leng += 1
    else:
        lens.append(leng)
        leng = 0
    prev = b[i]

print(max(lens))
Problem p03106 (python)

Fixed submission:
#0120
a, b, k = (int(_) for _ in input().split())
num = []
if a > b:
    for i in range(1, a + 1):
        if a % i == 0 and b % i == 0:
            num.append(i)
else:
    for i in range(1, b + 1):
        if a % i == 0 and b % i == 0:
            num.append(i)
if a == 1 and b == 1:
    num.append(1)
print(num[-k])

Buggy submission (verdict: Runtime Error):
#0120
a, b, k = (int(_) for _ in input().split())
num = []
if a > b:
    for i in range(1, a):
        if a % i == 0 and b % i == 0:
            num.append(i)
else:
    for i in range(1, b):
        if a % i == 0 and b % i == 0:
            num.append(i)
if a == 1 and b == 1:
    num.append(1)
print(num[-k])
Problem p03550 (python)

Fixed submission:
a,b,c = map(int, input().split())
z = [int(_) for _ in input().split()]
if a == 1:
  sco = abs(z[0]-c)
else:
  if abs(z[-1] - c) > abs(z[-2] - z[-1]):
    sco = abs(z[-1] - c)
  else:
    sco = abs(z[-2] - z[-1])
    
print(sco)

Buggy submission (verdict: Runtime Error):
a,b,c = int(input().split())
z = [int(input().split())]
if a == 1:
  sco = abs(z-c)
else:
  if abs(z[-1] - c) > abs(z[-2] - z[-1]):
    sco = abs(z[-1] - c)
  else:
    sco = abs(z[-2] - z[-1])
    
print(sco)
Problem p03633 (python)

Fixed submission:
n = int(input())
time = []

for i in range(n):
    time.append(int(input()))

def gcd(a,b):
    if a == 0:
        return b
    return gcd(b % a, a)

def lcm(a,b):
    return (a*b) // gcd(a,b)

ans = time[0]
for i in range(0, n):
    ans = lcm(ans, time[i])

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
time = []

for i in range(n):
    time.append(int(input()))

def gcd(a,b):
    if a == 0:
        return b
    return gcd(b % a, a)

def lcm(a,b):
    return (a*b) / gcd(a,b)

ans = time[0]
for i in range(0, n):
    ans = lcm(ans, time[i])
    
print(int(ans))
Problem p04031 (python)

Fixed submission:
n = int(input())
L = [int(_) for _ in input().split()]
L.sort()
total = 100000000000000000
num = 0
if L[0] == L[-1]:
    print(0)
else:
    for l in range(L[0], L[-1]):
        tot = 0
        for j in range(n):
            tot += abs(L[j] - l)**2
        if tot < total:
            num = l
            total = tot
            
    print(total)

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


found = False
pprev, prev = S[0],S[1]
t = {pprev, prev}

for i in range(2,len(S)):
    t.add(S[i])
    if len(t) == 2:
        print(i - 1, i + 1)
        found = True
    else:
        t.remove(pprev)
    pprev = prev
    prev = S[i]
    t = {pprev, prev}
    if found:
        break
    
if not found:
    print(-1, -1)
Problem p04045 (python)

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

found = False
bad = False
while not found:
    for i in str(n):
        if int(i) in a:
            bad = True
    if not bad:
        found = True
    bad = False
    n += 1

print(n - 1)

Buggy submission (verdict: Runtime Error):
n, k = (int(_) for _ in input().split())
a = [int(_) for _ in input().split()]
like = [i for i in range(10)]
pay = []
    
for i in str(n):
    while int(i)%10 in a:
            i = int(i) + 1
    pay.append(str(i%10))

total = ''
for i in pay:
    total += i

if n > int(total):
    total += str(like[0])
print(int(total))

Buggy submission (verdict: Runtime Error):
n, k = (int(_) for _ in input().split())
a = [int(_) for _ in input().split()]
like = [i for i in range(10)]
pay = []

for i in a:
    like.remove(i)

print(like)
    
for i in str(n):
    while int(i)%10 in a:
            i = int(i) + 1
    pay.append(str(i%10))

total = ''
for i in pay:
    total += i

if n > int(total):
    total += str(like[0])
print(int(total))