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

Fixed submission:
mod = 10**9+7
K = input()
D = int(input())
N = len(K)
dp = [[0] * D for i in range(N)]
for i in range(int(K[0])):
    dp[0][i%D] += 1
tight = int(K[0])%D
for i in range(1, N):
    for j in range(D):
        for k in range(10):
            dp[i][j] += dp[i-1][(j-k)%D]
            dp[i][j] %= mod
    for k in range(int(K[i])):
        dp[i][(tight+k)%D] += 1
    tight = (tight+int(K[i]))%D
print((dp[N-1][0]+(tight==0)-1)%mod)

Buggy submission (verdict: Runtime Error):
K = input()
D = int(input())
N = len(K)
dp = [[0] * D for i in range(N)]
for i in range(int(K[0])):
    dp[0][i%D] += 1
tight = int(K[0])%D
for i in range(1, N):
    for j in range(D):
        for k in range(10):
            dp[i][j] += dp[i-1][(j-k)%D]
            dp[i][j] %= mod
    for k in range(int(K[i])):
        dp[i][(tight+k)%D] += 1
    tight = (tight+int(K[i]))%D
print((dp[N-1][0]+(tight==0)-1)%mod)
Problem p03220 (python)

Fixed submission:
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
ans, m = 0, 1e9
for i in range(N):
  if abs((T-H[i]*0.006) - A) < m:
    ans = i+1
    m = abs((T-H[i]*0.006) - A)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
ans, min = 0, 1e9
for i in range(N):
  if abs((T-H[i]*0.006) - A) < m:
    ans = i
    m = abs((T-H[i]*0.006) - A)
print(i)
Problem p03227 (python)

Fixed submission:
S = input()
if len(S) == 2:
    print(S)
else:
    print(S[::-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
if N & 1:
    ans1 = 2*sum(A[N//2:])-A[N//2]-A[N//2+1]-2*sum(A[:N//2])
    ans2 = 2*sum(A[N//2+1:])-2*sum(A[:N//2+1])+A[N//2]+A[N//2-1]
else:
    if N == 2:
        ans1 = ans2 = abs(A[0]-A[1])
    else:
        ans1 = 2*sum(A[N//2:])-A[N//2]-2*sum(A[:N//2])+A[N//2-1]
        ans2 = 2*sum(A[N//2+1:])-A[N//2+1]-2*sum(A[:N//2+1])+A[N//2]
print(max(ans1, ans2))
Problem p03229 (python)

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
if N & 1:
    ans1 = 2*sum(A[N//2:])-A[N//2]-A[N//2+1]-2*sum(A[:N//2])
    ans2 = 2*sum(A[N//2+1:])-2*sum(A[:N//2+1])+A[N//2]+A[N//2-1]
else:
    if N == 2:
        ans1 = ans2 = abs(A[0]-A[1])
    else:
        ans1 = 2*sum(A[N//2:])-A[N//2]-2*sum(A[:N//2])+A[N//2-1]
        ans2 = 2*sum(A[N//2+1:])-A[N//2+1]-2*sum(A[:N//2+1])+A[N//2]
print(max(ans1, ans2))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
if N & 1:
    ans1 = 2*sum(A[N//2:])-A[N//2]-A[N//2+1]-2*sum(A[:N//2])
    ans2 = 2*sum(A[N//2+1:])-2*sum(A[:N//2+1])+A[N//2]+A[N//2-1]
else:
    ans1 = 2*sum(A[N//2:])-A[N//2]-2*sum(A[:N//2])+A[N//2-1]
    ans2 = 2*sum(A[N//2+1:])-A[N//2+1]-2*sum(A[:N//2+1])+A[N//2]
print(max(ans1, ans2))

Buggy submission (verdict: Runtime Error):
from collections import deque
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
if N % 4 == 1:
    print(2*sum(A[N//2+1:])-2*sum(A[:N//2+1])+A[N//2-1]+A[N//2])
elif N % 4 == 3:
    print(2*sum(A[N//2:])-2*sum(A[:N//2])-A[N//2]-A[N//2+1])
else:
    print(2*sum(A[N//2:])-2*sum(A[:N//2])-A[N//2+1]+A[N//2])
Problem p03238 (python)

Fixed submission:
n = int(input())
if n == 1:
    print("Hello World")
else:
    a = int(input())
    b = int(input())
    print(a+b)

Buggy submission (verdict: Runtime Error):
def soinsuubunkai(n):
    i = 2
    list = [1]
    while i**2 <= n:
        if n%i == 0:
            list.append(i)
            if i != n//i:
                list.append(n//i)
        i += 1
    list.append(n)
    return list
n, m = map(int, input().split())
l = soinsuubunkai(m)
r = len(l)
for i in range(r):
    if m//l[r-i-1] >= n:
        print(l[r-i-1])
        quit()
Problem p03243 (python)

Fixed submission:
y = int(input())
for i in range(1, 10):
  x = i + i * 10 + i * 100
  if x >= y:
    print(x)
    break

Buggy submission (verdict: Runtime Error):
y = int(input())
for i in range(1, 10):
  x = i + i * 10 + i * 100
  if x >= y:
    print(x)
  	break
Problem p03251 (python)

Fixed submission:
N, M, X, Y = map(int, input().split())
x_lst = list(map(int, input().split()))
y_lst = list(map(int, input().split()))
if (X < Y and max(x_lst) < min(y_lst) and X < min(y_lst) and max(x_lst) < Y):
  print("No War")
else:
  print("War")

Buggy submission (verdict: Runtime Error):
N, M. X, Y = map(int, input().split())
x_lst = list(map(int, input().split()))
y_lst = list(map(int, input().split()))
if (X < Y and max(x_lst) < min(y_lst) and X < min(y_lst) and max(x_lst) < Y):
  print("No War")
else:
  print("War")

Buggy submission (verdict: Runtime Error):
N, M. X, Y = map(int, input().split())
x_lst = list(map(int, input().split()))
y_lst = list(map(int, input().split()))
if (X < Y and max(x_lst) < min(y_lst) and X < min(y_lst) and max(x_lst) < Y):
  print("No War")
else:
  print("War")
Problem p03261 (python)

Fixed submission:
from collections import defaultdict
dic = defaultdict(int)
n = int(input())
lst = [input() for _ in range(n)]
last = lst[0]
dic[last] = 1
flag = True
for i in range(1, n):
  if lst[i][0] != last[-1]:
    flag = False
    break
  dic[lst[i]] += 1
  if dic[lst[i]] > 1:
    flag = False
    break
  last = lst[i]
if flag:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
dic = defaultdict(str)
n = int(input())
lst = [input() for _ in range(n)]
last = lst[0]
flag = True
for i in range(1, n):
  if lst[i][0] != last[-1]:
  	flag = False
    break
  dic[lst[i]] += 1
  if dic[lst[i]] > 1
  	flag = False
    break
if flag:
  print("Yes")
else:
  print("No")
Problem p03273 (python)

Fixed submission:
H, W = map(int, input().split())
f = [list(input()) for _ in range(H)]
Y, X = [False for _ in range(H)], [False for _ in range(W)]
for y in range(H):
    for x in range(W):
        Y[y] |= f[y][x] == '#'
        X[x] |= f[y][x] == '#'
for y in range(H):
    flag = False
    for x in range(W):
        if Y[y] and X[x]:
            print(f[y][x], end = "")
            flag = True
    if flag:
        print()

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
f = [input() for _ in range(H)]
while True:
  flag = False
  for y in range(H):
    if '#' not in f[y]:
      del f[y]
      H -= 1
      flag = True
      break
  for x in range(W):
    for y in range(H):
      if f[y][x] == '#':
        break
    for y in range(H):
      del f[x][y]
    flag = True
    break
  if not flag:
    break

for i in range(H):
  print(f[i])
Problem p03290 (python)

Fixed submission:
import itertools as it
D, G = map(int, input().split())
P, C = [], []
for _ in range(D):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)
A = it.permutations([i for i in range(D)])
ans = 10**9
for a in A:
    S, i, sub_ans = 0, 0, 0
    while 1:
        if S + (a[i] + 1) * 100 * P[a[i]] < G:
            S += (a[i] + 1) * 100 * P[a[i]]
            sub_ans += P[a[i]]
        else:
            x = (G - S) // ((a[i] + 1) * 100)
            if S + (a[i] + 1) * 100 * x < G:
                x += 1
            sub_ans += x
            S += (a[i] + 1) * 100 * x
        S += C[a[i]]
        if S >= G:
            if sub_ans < ans:
                ans = sub_ans
            break
        i += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools as it
D, G = map(int, input().split())
P, C = [], []
for _ in range(D):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)
A = it.permutations([i for i in range(D)])
ans = 10**9
for a in A:
    S, i, sub_ans = 0, 0, 0
    while 1:
        if S + (a[i] + 1) * 100 * P[a[i]] < G:
            S += (a[i] + 1) * 100 * P[a[i]]
            sub_ans += P[a[i]]
            S += C[a[i]]
        else:
            x = (G - S) // ((a[i] + 1) * 100)
            if S + (a[i] + 1) * x < G:
                x += 1
            sub_ans += x
            S += (a[i] + 1) * x
        S += C[a[i]]
        if S >= G:
            if sub_ans < ans:
                ans = sub_ans
            break
        i += 1
print(ans)
Problem p03328 (python)

Fixed submission:
a, b = map(int, input().split())
print((b-a)*(b-a+1)//2-b)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
print((b − a) * (b − a + 1) // 2 − b)
Problem p03352 (python)

Fixed submission:
x=int(input())
l=[1]
for i in range(2,x+1):
  t=i*i
  while t <=x:
    l.append(t)
    t*=i
print(max(l))

Buggy submission (verdict: Runtime Error):
x=int(input())
l=[]
for i in range(2,x+1):
  t=i*i
  while t <=x:
    l.append(t)
    t*=i
print(max(l))
Problem p03380 (python)

Fixed submission:
import bisect as bs
l=int(input())
lst=sorted(list(map(int,input().split())))
n=lst[l-1]
lst[l-1]=float("inf")
m=bs.bisect_right(lst,n/2)
if n/2 - lst[m-1] <= lst[m] -n/2:
  print(n,lst[m-1])
else:
  print(n,lst[m])

Buggy submission (verdict: Runtime Error):
import bisect as bs
l=int(input())
lst=sorted(list(map(int,input().split())))
n=lst[l-1]
lst[l-1]=float("inf")
m=bs.bisect_left(lst,n/2)
if n/2 - lst[m] <= lst[m+1] -n/2:
  print(n,lst[m])
else:
  print(n,lst[m+1])

Buggy submission (verdict: Runtime Error):
import bisect as bs
l=int(input())
lst=sorted(list(map(int,input().split())))
n=lst[l-1]
m=bs.bisect_left(lst,n/2)
print(m)

if n/2 - lst[m] <= lst[m+1] -n/2:
  print(n,lst[m])
else:
  print(n,lst[m+1])

Buggy submission (verdict: Runtime Error):
import bisect as bs
l=int(input())
lst=sorted(list(map(int,input().split())))
n=lst[l-1]
m=bs.bisect_left(lst,n)
if n/2 - lst[m] <= lst[m+1] -n/2:
  print(n,lst[m])
else:
  print(n,lst[m+1])
Problem p03409 (python)

Fixed submission:
def bipertite_matching(N, edges):
    def dfs(v):
        used[v] = True
        for u in edges[v]:
            w = match[u]
            if w < 0 or (used[w] == False and dfs(w)):
                match[v] = u
                match[u] = v
                return True
        return False
    match = [-1 for _ in range(N)]
    ret = 0
    for v in range(N):
        if match[v] < 0:
            used = [False for _ in range(N)]
            if dfs(v):
                ret += 1
    return ret

N = int(input())
a, b = [None] * N, [None] * N
for i in range(N):
    a[i], b[i] = map(int, input().split())
c, d = [None] * N, [None] * N
for i in range(N):
    c[i], d[i] = map(int, input().split())
es = [[] for i in range(2 * N)]
for i in range(N):
    for j in range(N):
        if a[i] < c[j] and b[i] < d[j]:
            es[i].append(N+j)
            es[N+j].append(i)
print(bipertite_matching(2*N, es))

Buggy submission (verdict: Runtime Error):
n = int(input())
red, brue = [], []
for _ in range(n):
  x, y = map(int, input().split())
  red.append([x, y])
for _ in range(n):
  x, y = map(int, input().split())
  brue.append([x, y])
red, brue = sorted(red), sorted(brue)
used = [Flase for _ in range(n)]
ans = 0
for i in range(n):
  x, y = red[i][0], red[i][1]
  for j in range(n):
    if used[j] or x >= brue[j][0] or y >= brue[j][1]:
      continue
    used[j] = True
    ans += 1
print(ans)
Problem p03416 (python)

Fixed submission:
A, B = map(int, input().split())
cnt = 0
for i in range(A, B + 1):
  x = str(i)
  j, k = 0, len(x) - 1
  while j < k:
    if x[j] != x[k]:
      break
    j += 1
    k -= 1
  if k <= j:
    cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
cnt = 0
for i in range(A, B + 1):
  x = str(i)
  j, k = 0, len(x) - 1
  while j < k:
    if x[j] != x[k]:
      break
   	j += 1
    k -= 1
  if k <= j:
    cnt += 1
print(cnt)
Problem p03427 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from copy import *

N = input()
l = len(N)
if l == 1:
    print(N)
    exit()
x = int(N[0])*int(pow(10, l-1))+int('9'*(l-1))
if int(N) < x:
    x -= 1
ans = 0
while x > 0:
    ans += x%10
    x //= 10
print(ans)

Buggy submission (verdict: Runtime Error):
N = input()
l = len(N)
x = int(N[0])*int(pow(10, l-1))+int('9'*(l-1))
if int(N) < x:
    x -= 1
ans = 0
while x > 0:
    ans += x%10
    x //= 10
print(ans)
Problem p03450 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100001)
def input():
    return sys.stdin.readline()[:-1]

def dfs(v):
    ret = True
    for u, d in es[v]:
        if x[u] == None:
            x[u] = x[v] + d
            ret = ret and dfs(u)
        elif x[u] != x[v] + d:
            return False
    return ret

N, M = map(int, input().split())
es = [[] for i in range(N+1)]
for i in range(M):
    L, R, D = map(int, input().split())
    es[L].append((R, D))
    es[R].append((L, -D))
x = [None for i in range(N+1)]
flag = True
for v in range(1, N+1):
    if x[v] == None:
        x[v] = 0
        if dfs(v) == False:
            flag = False
            break
if flag:
    print("Yes")
else:
    print("No")

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

def dfs(v):
    for u, d in es[v]:
        if x[u] == None:
            x[u] = x[v] + d
            dfs(u)
        elif x[u] != x[v] + d:
            return False
    return True

N, M = map(int, input().split())
es = [[] for i in range(N+1)]
for i in range(M):
    L, R, D = map(int, input().split())
    es[L].append((R, D))
    es[R].append((L, -D))
x = [None for i in range(N+1)]
flag = True
for v in range(1, N+1):
    if x[v] == None:
        x[v] = 0
        if dfs(v) == False:
            flag = False
            break
if flag:
    print("Yes")
else:
    print("No")
Problem p03478 (python)

Fixed submission:
n, a, b = map(int, input().split())
ans = 0
for i in range(n + 1):
  x, j = 0, i
  while j > 0:
    x += j % 10
    j //= 10
  if a <= x <= b:
    ans += i
print(ans)

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
ans = 0
for i in range(n + 1):
  x = 0
  while i > 0:
    x += i % 10
    i //= 10
  if A <= x <= B:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
ans = 0
for i in range(n + 1):
  x = sum(list(str(i)))
  if A <= x <= B:
    ans += 1
print(ans)
Problem p03504 (python)

Fixed submission:
import sys

def main():
    input = sys.stdin.readline
    N, C = map(int, input().split())
    dic = [[] for _ in range(C + 1)]
    for _ in range(N):
        s, t, c = input().split()
        dic[int(c)].append([int(s), int(t)])
    for c in range(C + 1):
        l = len(dic[c])
        if l == 1:
            continue
        dic[c] = sorted(dic[c])
        i = 0
        while i < l - 1:
            if i < l - 1 and dic[c][i][1] == dic[c][i + 1][0]:
                dic[c][i + 1][0] += 1
            else:
                i += 1
    f = [0 for _ in range(100002)]
    for c in range(C + 1):
        for t in dic[c]:
            f[t[0]] += 1
            f[t[1] + 1] -= 1
    ans = 0
    for i in range(1, 100001):
        f[i] += f[i - 1]
        if ans < f[i]:
            ans = f[i]
    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]
ans = -float("inf")
for i in range(1, 2 ** 10):
    b, s = i, 0
    cnt = [0 for _ in range(N)]
    while b > 0:
        if b & 1:
            for j in range(N):
                cnt[j] += F[j][s]
        s += 1
        b >>= 1
    sub_ans = 0
    for j in range(N):
        sub_ans += P[j][cnt[j]]
    ans = max(ans, sub_ans)
print(ans)
Problem p03565 (python)

Fixed submission:
S = input()
T = input()
flag = False
for i in range(len(S)):
    k = len(S) - i - len(T)
    for j in range(len(T)):
        if k >= 0 and (S[k] == T[j] or S[k] == '?'):
            k += 1
            if j == len(T) - 1:
                flag = True
                st = len(S) - len(T) - i
        else:
            break
    if flag:
        break
ret = ""
if flag:
    for i in range(st):
        if S[i] == '?':
            ret += 'a'
        else:
            ret += S[i]
    ret += T
    for i in range(st + len(T), len(S)):
        if S[i] == '?':
            ret += 'a'
        else:
            ret += S[i]
else:
    ret = "UNRESTORABLE"
print(ret)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
flag = False
for i in range(len(S) - len(T) + 1):
    k = i
    for j in range(len(T)):
        if S[k] == T[j] or S[k] == '?':
            k += 1
        else:
            break
    if k == i + len(T):
        flag = True
        st = i
        break
ret = ""
print(st)
if flag:
    for i in range(st):
        if S[i] == '?':
            ret += 'a'
        else:
            ret += S[i]
    ret += T
    for i in range(st + len(T), len(S)):
        if S[i] == '?':
            ret += 'a'
        else:
            ret += S[i]
else:
    ret = "UNRESTORABLE"
print(ret)
Problem p03573 (python)

Fixed submission:
l = input().split()
for i in range(3):
  if l.count(l[i]) == 1:
    print(l[i])

Buggy submission (verdict: Runtime Error):
l = input().split()
for i in range(3):
  if l[i].count() == 1:
    print(l[i])
Problem p03574 (python)

Fixed submission:
h, w = map(int, input().split())
f = [input() for _ in range(h)]
for i in range(h):
  for j in range(w):
    if f[i][j] == '#':
      print('#', end = "")
      continue
    cnt = 0
    for k in range(i-1, i+2):
      if k < 0 or h <= k:
        continue
      for l in range(j-1, j+2):
        if l < 0 or w <= l:
          continue
        if f[k][l] == '#':
          cnt += 1
    print(cnt, end = "")
  print()

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
f = [input() for _ in range(h)]
for i in range(h):
  for j in range(w):
    if f[i][w] == '#':
      print('#', end = "")
      continue
    cnt = 0
    for k in range(i-1, i+2):
      if k < 0 or h <= k:
        continue
      for l in range(j-1, j+2):
        if l < 0 or w <= l:
          continue
        if f[k][l] == '#':
          cnt += 1
    print(cnt, end = "")
  print()
Problem p03598 (python)

Fixed submission:
n = int(input())
k = int(input())
s = 0
l = list(map(int, input().split()))
for _ in range(n):
  x = l[_]
  s += min(x * 2, (k - x) * 2)
print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())
k = int(input())
s = 0
for _ in range(n):
  x = int(input())
  s += min(x * 2, (k - x) * 2)
print(s)
Problem p03608 (python)

Fixed submission:
from itertools import permutations
N, M, R = map(int, input().split())
rs = map(lambda x: int(x) - 1, input().split())
dist = [[10**9 for _ in range(N)] for _ in range(N)]
for _ in range(M):
    v1, v2, d = map(int, input().split())
    dist[v1-1][v2-1] = dist[v2-1][v1-1] = d
for i in range(N):
    dist[i][i] = 0
for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
ans = 10**9
for r in permutations(rs):
    t = 0
    for i in range(R-1):
        t += dist[r[i]][r[i+1]]
        if t > 10**9:
            break
    ans = min(t, ans)
print(ans)

Buggy submission (verdict: Runtime Error):
N, M, R = map(int, input().split())
rs = permutations(map(lambda x: int(x) - 1, input().split()))
dist = [[10**9 for _ in range(N)] for _ in range(N)]
for _ in range(M):
    v1, v2, d = map(int, input().split())
    dist[v1-1][v2-1] = dist[v2-1][v1-1] = d
for i in range(N):
    dist[i][i] = 0
for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
ans = 10**9
for r in rs:
    t = 0
    for i in range(R-1):
        t += dist[r[i]][r[i+1]]
        if t > 10**9:
            break
    ans = min(t, ans)
print(ans)
Problem p03633 (python)

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

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

import sys
input = sys.stdin.readline
N = int(input())
if N == 1:
    print(input())
else:
    T = [int(input()) for _ in range(N)]
    ans = lcm(T[0], T[1])
    for i in range(2, N):
        ans = lcm(ans, T[i])
    print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

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

import sys
input = sys.stdin.readline
N = int(input())
T = [int(input()) for _ in range(N)]
if N == 1:
    ans = T[0]
else:
    ans = lcm(T[0], T[1])
    for i in range(2, N):
    ans = lcm(ans, T[i])
print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

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

import sys
input = sys.stdin.readline
N = int(input())
T = [int(input()) for _ in range(N)]
ans = lcm(T[0], T[1])
for i in range(2, N):
    ans = lcm(ans, T[i])
print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, b % a)

import sys
input = sys.stdin.readline
N = int(input())
T = [int(input()) for _ in range(N)]
ans = T[0] * T[1] // gcd(T[0], T[1])
for i in range(2, N):
    ans = ans * T[i] // gcd(ans, T[i])
print(ans)
Problem p03644 (python)

Fixed submission:
n = int(input())
M = 0
ans = 1
for i in range(1, n + 1):
  t = i
  s = 0
  while t % 2 == 0:
    t /= 2
    s += 1
  if M < s:
    M = s
    ans = i
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
M = 0
for i in range(1, n + 1):
  t = i
  s = 0
  while t % 2 == 0:
    t /= 2
    s += 1
  if M < s:
    M = s
    ans = i
print(ans)
Problem p03648 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *

def arc079():
    K = int(input())
    k = K//50
    a = [i+k*50 for i in range(50)]
    for i in range(K%50):
        a[i] += 51
    for i in range(50):
        a[i] -= K-k
    print(50)
    print(*a)

arc079()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *

def arc079():
    K = int(input())
    k = K//50
    a = [i+k*50 for i in range(50)]
    for i in range(K-k):
        a[i] += 51
    for i in range(50):
        a[i] -= K-k
    print(50)
    print(*a)

arc079()
Problem p03671 (python)

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

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print(a+b+c-max(a,b.c))
Problem p03679 (python)

Fixed submission:
X, A, B = map(int, input().split())
if B <= A:
  print("delicious")
else:
  if B - A <= X:
    print("safe")
  else:
    print("dangerous")

Buggy submission (verdict: Runtime Error):
X, A, B = input().split()
if B <= A:
  print("delicious")
else:
  if B - A <= X:
    print("safe")
  else:
    print("dangerous")
Problem p03680 (python)

Fixed submission:
from collections import defaultdict
N = int(input())
btn = [0] + [int(input()) for _ in range(N)]
i, ans = 1, 0
checked = defaultdict(int)
while 1:
  next = btn[i]
  ans += 1
  if next == 2:
    print(ans)
    break
  if checked[next] == 1:
    print(-1)
    break
  i = next
  checked[i] = 1

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
N = int(input())
btn = [int(input()) for _ in range(N)]
i, ans = 0, 0
checked = defaultdict(int)
while 1:
  next = btn[i]
  ans += 1
  if next == 2:
    print(ans)
  	break
  if checked[next] == 1:
    print(-1)
    break
  i = next
  checked[i] = 1