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

Fixed submission:
A, B = input().split()
A = int(A)
# B = int(B.replace(".", ""))
B = (int(B[0]) - 0) * 100 + (int(B[2]) - 0) * 10 + (int(B[3]) - 0)
print(A * B // 100)

Buggy submission (verdict: Runtime Error):
A, B = input().split()
A = int(A)
# B = int(B.replace(".", ""))
# B = (int(B[0]) - 0) * 100 + (int(B[2]) - 0) * 10 + (int(B[3]) - 0)
print(A * B // 100)

Buggy submission (verdict: Runtime Error):
A, B = input().split()
A = int(A)
B = int(B.replace(".", ""))
print(int(str(int(A * B))[:-2]))

Buggy submission (verdict: Runtime Error):
A, B = input().split()
A = int(A)
B = B.replace(".", "")
print(int(A * B / 100))
Problem p02689 (python)

Fixed submission:
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(M)]


low_set = set()
appear_set = set()

for i in range(M):
    a, b = AB[i]
    if H[a-1] > H[b-1]:
        low_set.add(b)
    elif H[a-1] < H[b-1]:
        low_set.add(a)
    else:
        low_set.add(a)
        low_set.add(b)

ans_set = set(range(1, N+1)) - low_set
print(len(ans_set))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
H = list(map(int, input().split))
AB = [list(map(int, input().split)) for _ in range(M)]

neighbor_max_heights = [0] * N

for i in range(M):
    a, b = AB[i]
    neighbor_max_heights[b-1] = max(neighbor_max_heights[b-1], H[a-1])
    neighbor_max_heights[a-1] = max(neighbor_max_heights[a-1], H[b-1])

ans = 0
for j in range(N):
    if H[j-1] > neighbor_max_heights[j-1]:
        ans += 1
print(ans)
Problem p02693 (python)

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

for i in range(A, B+1):
    if i % K == 0:
        print("OK")
        import sys
        sys.exit()
print("NG")

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

N, M, Q = map(int, input().split())

G = [list(map(int, input().split())) for _ in range(Q)]

ans = 0

# 可能な数列Aの全探索、そのままやとめちゃ多いからなんか工夫する？
# そもそもAの全探索方がいまいちわからん...

A = np.array(list(combinations_with_replacement(range(1, M + 1), N)))
scores = np.zeros(len(A))
for g in G:
    a, b, c, d = g
    cond = A[:, b - 1] - A[:, a - 1] == c
    scores += d * cond
print(scores.max())
Problem p02695 (python)

Fixed submission:
from itertools import combinations_with_replacement
import numpy as np

N, M, Q = map(int, input().split())

G = [list(map(int, input().split())) for _ in range(Q)]

ans = 0

# 可能な数列Aの全探索、そのままやとめちゃ多いからなんか工夫する？
# そもそもAの全探索方がいまいちわからん...

A = np.array(list(combinations_with_replacement(range(1, M + 1), N)))
scores = np.zeros(len(A), dtype=np.int32)
for g in G:
    a, b, c, d = g
    cond = A[:, b - 1] - A[:, a - 1] == c
    scores += d * cond

print(scores.max())

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

N, M, Q = map(int, input().split())

G = [list(map(int, input().split())) for _ in range(Q)]

ans = 0

# 可能な数列Aの全探索、そのままやとめちゃ多いからなんか工夫する？
# そもそもAの全探索方がいまいちわからん...

A = np.array(list(itertools.combinations_with_replacement(range(1, M + 1), N)))
scores = np.zeros(len(A))
for g in G:
    a, b, c, d = g
    cond = A[:, b - 1] - A[:, a - 1] == c
    scores += d * cond

print(scores.max())
Problem p02729 (python)

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

import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans = 0

if N >= 2:
    ans += combinations_count(N, 2)

if M >= 2:
    ans += combinations_count(M, 2)

print(ans)

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

import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


print(combinations_count(N, 2) + combinations_count(M, 2))
Problem p02753 (python)

Fixed submission:
S = input()
if "A" not in S or "B" not in S:
    print("No")
else:
    print("Yes")

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

reverse = False
cnt = 0
for i in range(Q):
    inp = input().split()
    if len(inp) == 1:
        cnt += 1
        reverse = (cnt % 2 != 0)
        #S = S[::-1]
    else:
        f, c = inp[1:]
        if int(f) == 1:
            if reverse:
                S = S + c
            else:
                S = c + S
        else:
            if reverse:
                S = c + S
            else:
                S = S + c
print(S[::-1] if reverse else S)

Buggy submission (verdict: Runtime Error):
S = input()
Q = int(input())
for i in range(Q):
    inp = input().split()
    if len(inp) == 1:
        S = S[::-1]
    else:
        f, c = inp[1:]
        if int(f) == 1:
            S = c + S
        else:
            S = S + c
print(S)
Problem p03107 (python)

Fixed submission:
s = input()
n = len(s)

one = s.count('1')
zero = s.count('0')

print(2*min(one, zero))

Buggy submission (verdict: Runtime Error):
S = input()
stack = []
cnt = 0

for s in S:
    if s == S[0]:
        stack.append(s)
    elif s != stack[-1]:
        stack.pop()
        cnt += 2
    else:
        stack.append(s)
        
print(cnt)

Buggy submission (verdict: Runtime Error):
S = input()
stack = []
cnt = 0

for s in S:
    if s == S[0]:
        stack.append(s)
    elif s == '0' and s != stack[-1]:
        stack.pop()
        cnt += 2
    elif s == '1' and s != stack[-1]:
        stack.pop()
        cnt += 2
    else:
        stack.append(s)
        
print(cnt)

Buggy submission (verdict: Runtime Error):
S = input()
stack = []
cnt = 0

for s in S:
    if s == S[0]:
        stack.append(s)
    elif s == '0' and s != stack[-1]:
        stack.pop()
        cnt += 2
    elif s == '1' and s != stack[-1]:
        stack.pop()
        cnt += 2
    else:
        stack.sppend(s)
        
print(cnt)
Problem p02990 (python)

Fixed submission:
from math import factorial

def comb(n, k):
    return factorial(n)//factorial(k)//factorial(n-k)

inp = input().split()

N = int(inp[0])
K = int(inp[1])

for i in range(1, K+1):
    if(i > N-K+1):
        print(0)
    else:
        print("%d"%(comb(N-K+1, i)*comb(K-1, i-1)%1000000007))

Buggy submission (verdict: Runtime Error):
for i in range(1, K+1):
    if(i > N-K+1):
        print(0)
    else:
        print("%d"%(comb(N-K+1, i)*comb(K-1, i-1)%1000000007))

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

def comb(n, k):
    return factorial(n)//factorial(k)//factorial(n-k)

inp = input().split()

N = int(inp[0])
K = int(inp[1])

for i in range(1, K+1):
    print("%d"%(comb(N-K+1, i)*comb(K-1, i-1)%1000000007))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb

inp = input().split()

N = int(inp[0])
K = int(inp[1])

for i in range(1, K+1):
    print("%d"%(comb(N-K+1, i)*comb(K-1, i-1)%1000000007))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb

N = int(input())
K = int(input())

for i in range(1, K+1):
    print("%d"%(comb(N-K+1, i)*comb(K-1, i-1)%1000000007))
Problem p02933 (python)

Fixed submission:
n = int(input())
s = input()

if n >= 3200:
  print(s)
else:
  print("red")

Buggy submission (verdict: Runtime Error):
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    String s = sc.next();

    if(a>=3200){
      System.out.println(s);
    }
    else{
      System.out.println("red");
    }
  }
}
Problem p02935 (python)

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

v.sort()
ans = v[0]

for i in range(1, n):
  ans = (ans + v[i]) / 2.0
print(ans)

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

ans = v[0]
for n in range(1, n):
  ans = (ans + v[i]) / 2.0
  
print(ans)
Problem p02831 (python)

Fixed submission:
a=list(map(int,input().split()))
def cud(a,b):
  if a%b==0:
    return b
  else:
    return cud(b,a%b)
print(int(a[0]*a[1]/cud(a[0],a[1])))

Buggy submission (verdict: Runtime Error):
a=list(map(int,input().split()))
def cud(a,b):
  if a%b==0:
    return a/b
  else:
    cud(b,a%b)
print(a*b/cud(a[0],a[1]))
Problem p03208 (python)

Fixed submission:
a=list(map(int,input().split()))
b=list(sorted([int(input()) for i in range(a[0])]))
ans=[]
for i in range(a[0]-a[1]+1):
  ans+=[abs(b[a[1]-1+i]-b[i])]
print(min(ans))

Buggy submission (verdict: Runtime Error):
a=list(map(int,input().split()))
b=list(sorted([int(input()) for i in range(a[0])]))
ans=[]
for i in range(a[0]-a[1]+1):
  ans+=[b[i+2]-b[i]]
print(min(ans))

Buggy submission (verdict: Runtime Error):
a=list(map(int,input.split()))
lis=[]
for i in range(a[0]):
  lis+=int(input())
lis=lis.sort()
print(lis)
Problem p03242 (python)

Fixed submission:
n = int(input())
if (n == 999):
   print("111")
elif (n == 991):
    print("119")
elif (n == 911):
    print("199")
elif (n == 919):
    print("191")
elif (n == 199):
    print("911")
elif (n == 191):
    print("919")
elif (n == 199):
    print("911")
elif (n == 119):
    print("991")
elif (n == 111):
    print("999")

Buggy submission (verdict: Runtime Error):
n = input()
if n == 999:
   print("111")
elif n == 991:
    print("119")
elif n == 911:
    print("199")
elif n == 919:
    print("191")
elif n == 199:
    print("911")
elif n == 191:
    print("919")
elif n == 199:
    print("911")
eise:
    print("999")

Buggy submission (verdict: Runtime Error):
n = input()
if n = 999:
   print("111")
elif n = 991:
    print("119")
elif n = 911:
    print("199")
elif n = 919:
    print("191")
elif n = 199:
    print("911")
elif n = 191:
    print("919")
elif n = 199:
    print("911")
eise:
    print("999")
Problem p03307 (python)

Fixed submission:
n = int(input())
if n % 2 == 1:
    print(n * 2)
else:
    print(n)

Buggy submission (verdict: Runtime Error):
n = input
if n % 2 = 1:
    print(n * 2)
else:
    print(n)
Problem p02659 (python)

Fixed submission:
# ABC 169
import math

a, b = input().split()
a = int(a)
b = int(round(float(b)*100))
print(a*b//100)

Buggy submission (verdict: Runtime Error):
# ABC 169
import math

a, b = map(np.float64, input().split())
c = math.floor(a*b)
print(c)
Problem p02773 (python)

Fixed submission:
# ABC 155 C
from collections import Counter
import numpy as np
N = int(input())
S = [str(input()) for i in range(N)]
S = np.array(S)

count = Counter(S)
max_num = max(count.values())
max_list = [i for i,j in count.items() if j==max_num]

max_list.sort()
print('\n'.join(max_list))

Buggy submission (verdict: Runtime Error):
# ABC 155 C
import numpy as np
N = int(input())
S = [str(input()) for i in range(N)]
S = np.array(S)
 
uni = np.unique(S) # return_counts is not available in numpy 1.8.2
uni = np.unique(S) 
count = np.zeros(len(uni))
for i,element in enumerate(uni):
    count[i] = (S==element).sum()
    
max_list = np.argwhere(count==np.max(count))
for index in max_list:
    print(str(uni[index][0]))

Buggy submission (verdict: Runtime Error):
# ABC 155 C
import numpy as np
N = int(input())
S = [str(input()) for i in range(N)]
S = np.array(S)
 
uni, count = np.unique(S, return_counts=True)
max_list = np.argwhere(count==np.max(count))
for index in max_list:
    print(str(uni[index][0]))

Buggy submission (verdict: Runtime Error):
# ABC 155 C
import numpy as np
N = int(input())
S = [str(input()) for i in range(N)]
S = np.array(S)

uni, count = np.unique(S, return_counts=True)
max_list = np.argwhere(count==np.max(count))
for index in max_list:
    print(uni[index][0])
Problem p02779 (python)

Fixed submission:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
A = np.array(A)

A_uni = np.unique(A)
if len(A_uni) < N:
    ans = 'NO'
else:
    ans = 'YES'
print(str(ans))

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

N = int(input())
A = list(map(int, input().split()))

res = np.zeros(N)
for i in range(N):
  res[i] = (A==A[i]).sum()

if (res>1).sum() > 0:
  ans = 'NO'
else:
  ans = 'YES'
  
print(str(ans))
Problem p02835 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys
a = [int(x) for x in sys.stdin.readline().rstrip().split()]
if sum(a) < 22:
    print("win")
else:
    print("bust")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

N=int(input())

ans_l=[1]*N

if N == 1:
    print("1")
else:
    for i in range(N):
        A=int(input())
        for j in range(A):
            a,b=map(int,input().split())
            ans_l[a-1]=ans_l[a-1]*b
    print(sum(ans_l))
Problem p02836 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys

a=input()
a_half=a[:len(a)//2:]
a_half_int=a[-(-len(a)//2)::]
a_half_int=a_half_int[::-1]
b=list(a_half)
c=list(a_half_int)
ans=0
for i in range(len(a)//2):
    if b[i] != c[i]:
        ans+=1

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
import Levenshtein

a=input()
a_half=a[:len(a)//2:]
a_half_int=a[-(-len(a)//2)::]
a_half_int=a_half_int[::-1]

ans=Levenshtein.distance(a_half,a_half_int)
print(ans)
Problem p02948 (python)

Fixed submission:
import heapq

N, M = map(int, input().split())
income = [[] for _ in range(M+1)]  # income[i]はi日後に報酬が得られる全ての仕事についての報酬のリスト
for _ in range(N):
    a, b = map(int, input().split())
    if a <= M:
        income[a].append(-b)

# 後ろから考える。残りi日のときに終了までに報酬が得られる仕事のうち報酬最大のものを選ぶ
ans = 0
tmp = []
heapq.heapify(tmp)

for rest_days in range(1, M+1):
    for x in income[rest_days]:
        heapq.heappush(tmp, x)
    if tmp:
        ans += heapq.heappop(tmp)

print(-ans)

Buggy submission (verdict: Runtime Error):
import heapq

N, M = map(int, input().split())
income = [[] for _ in range(M+1)]  # income[i]はi日後に報酬が得られる全ての仕事についての報酬のリスト
for _ in range(N):
    a, b = map(int, input().split())
    if a <= M:
        income[a].append(-b)

# 後ろから考える。残りi日のときに終了までに報酬が得られる仕事のうち報酬最大のものを選ぶ
ans = 0
tmp = []
for rest_days in range(1, M+1):
    tmp += income[rest_days]
    heapq.heapify(tmp)
    if tmp:
        ans += heapq.heappop(tmp)

print(-ans)v
Problem p03038 (python)

Fixed submission:
# D - Integer Cards

# 小さい数字から順になるべく大きい数字に書き換える

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
BC = [list(map(int, input().split())) for _ in range(M)]

BC = sorted(BC, key = lambda x : x[1], reverse = True)

idx = 0
for i in range(M):
    for _ in range(BC[i][0]):
        if idx <= N-1 and A[idx] < BC[i][1]:
            A[idx] = BC[i][1]
            idx += 1
        else:
            break
    else:
        continue
    break
    
print(sum(A))

Buggy submission (verdict: Runtime Error):
# D - Integer Cards

# 小さい数字から順になるべく大きい数字に書き換える

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
BC = [list(map(int, input().split())) for _ in range(M)]

BC = sorted(BC, key = lambda x : x[1], reverse = True)

idx = 0
for i in range(M):
    for _ in range(BC[i][0]):
        if A[idx] < BC[i][1]:
            A[idx] = BC[i][1]
            idx += 1
        else:
            break
    else:
        continue
    break
    
print(sum(A))
Problem p03209 (python)

Fixed submission:
# D - Christmas

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

height = [1] # レベルiバーガーの高さ
for _ in range(N):
    height.append(height[-1]*2 + 3)
    
patty = [1] # レベルiバーガーに含まれるパティの総数
for _ in range(N):
    patty.append(patty[-1]*2 + 1)

def dp(n,x): # レベルnバーガーの下からx個の層に含まれるパティの数
    if n == 0:
        return 1
    elif x == 1:
        return 0
    elif x <= 1 + height[n-1]:
        return dp(n-1, x-1)
    elif x == 2 + height[n-1]:
        return patty[n-1] + 1
    elif 2 + height[n-1] < x <= height[n] - 1:
        return patty[n-1] + 1 + dp(n-1, x - (height[n-1] + 2))
    else:
        return patty[n]
    
print(dp(N,X))

Buggy submission (verdict: Runtime Error):
# D - Christmas

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

height = [1] # レベルnバーガーの高さ
for _ in range(N):
    height.append(height[-1]*2 + 3)

# dp[i][j]はレベルiバーガーの下j層に含まれるパティの数。ただしレベルiバーガーの高さの範囲外には-1を格納
dp = [[0]+[-1]*height[-1] for _ in range(N+1)] 
dp[0][1] = 1
    
for level in range(1,N+1):
    for n_from_bottom in range(1,height[-1]+1):
        if n_from_bottom > height[level]:
            break
        elif n_from_bottom == 2 * height[level-1] + 3:
            dp[level][n_from_bottom] = dp[level-1][height[level-1]] * 2 + 1
        elif n_from_bottom > height[level-1] + 2: 
            dp[level][n_from_bottom] = dp[level-1][height[level-1]] + 1 + dp[level-1][n_from_bottom - (height[level-1] + 2)]
        elif n_from_bottom == height[level-1] + 2: # 前のバーガー+底のバン+パティ
            dp[level][n_from_bottom] = dp[level-1][height[level-1]] + 1
        else:
            dp[level][n_from_bottom] = dp[level-1][n_from_bottom-1]
    
print(dp[N][X])

Buggy submission (verdict: Runtime Error):
# D - Christmas

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

height = [1] # レベルnバーガーの高さ
for _ in range(N):
    height.append(height[-1]*2 + 3)

# dp[i][j]はレベルiバーガーの下j層に含まれるパティの数。ただしレベルiバーガーの高さの範囲外には-1を格納
dp = [[0]+[-1]*height[-1] for _ in range(N+1)] 
dp[0][1] = 1
    
for level in range(1,N+1):
    for n_from_bottom in range(1,height[-1]+1):
        if n_from_bottom > height[level]:
            break
        elif n_from_bottom == 2 * height[level-1] + 3:
            dp[level][n_from_bottom] = dp[level-1][height[level-1]] * 2 + 1
        elif n_from_bottom > height[level-1] + 2: 
            dp[level][n_from_bottom] = dp[level-1][height[level-1]] + 1 + dp[level-1][n_from_bottom - (height[level-1] + 2)]
        elif n_from_bottom == height[level-1] + 2: # 前のバーガー+底のバン+パティ
            dp[level][n_from_bottom] = dp[level-1][height[level-1]] + 1
        else:
            dp[level][n_from_bottom] = dp[level-1][n_from_bottom-1]
    
print(dp[N][X])
Problem p03634 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10000000)

N = int(sys.stdin.buffer.readline())

graph = [[]*N for _ in range(N)]

for _ in range(N-1):
    a, b, c = map(int, sys.stdin.buffer.readline().split())
    graph[a-1].append((b-1, c))
    graph[b-1].append((a-1, c))

Q, K = map(int, sys.stdin.buffer.readline().split())
dist_K = [-1]*N

def cal_dist_K(u = K-1, current_dist = 0):
    dist_K[u] = current_dist
    for v,c in graph[u]:
        if dist_K[v] == -1:
            cal_dist_K(v, current_dist + c)

cal_dist_K()

ans = []
for _ in range(Q):
    x, y = map(int, sys.stdin.buffer.readline().split())
    ans.append(int(dist_K[x-1] + dist_K[y-1]))

print("\n".join(map(str, ans)))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)

N = int(sys.stdin.buffer.readline())

graph = [[]*N for _ in range(N)]

for _ in range(N-1):
    a, b, c = map(int, sys.stdin.buffer.readline().split())
    graph[a-1].append((b-1, c))
    graph[b-1].append((a-1, c))

Q, K = map(int, sys.stdin.buffer.readline().split())
dist_K = [-1]*N

def cal_dist_K(u = K-1, current_dist = 0):
    dist_K[u] = current_dist
    for v,c in graph[u]:
        if dist_K[v] == -1:
            cal_dist_K(v, current_dist + c)

cal_dist_K()

ans = []
for _ in range(Q):
    x, y = map(int, sys.stdin.buffer.readline().split())
    ans.append(int(dist_K[x-1] + dist_K[y-1]))

print("\n".join(map(str, ans)))

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
from scipy.sparse.csgraph import dijkstra

N = int(sys.stdin.buffer.readline())

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

for _ in range(N-1):
    a, b, c = map(int, sys.stdin.buffer.readline().split())
    graph[a-1][b-1] = c
    graph[b-1][a-1] = c

Q, K = map(int, sys.stdin.buffer.readline().split())
dist_K = np.array(dijkstra(graph, indices=K-1))

ans = np.zeros(Q)
for i in range(Q):
    x, y = map(int, sys.stdin.buffer.readline().split())
    ans[i] = dist_K[x-1] + dist_K[y-1]

for x in ans:
    print(int(x))

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
from scipy.sparse.csgraph import dijkstra

N = int(sys.stdin.buffer.readline())

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

for _ in range(N-1):
    a, b, c = map(int, sys.stdin.buffer.readline().split())
    graph[a-1][b-1] = c
    graph[b-1][a-1] = c

Q, K = map(int, sys.stdin.buffer.readline().split())
dist_K = dijkstra(graph, indices=K-1)

ans = np.zeros(Q, dtype = np.int64)
for i in range(Q):
    x, y = map(int, sys.stdin.buffer.readline().split())
    ans[i] = dist_K[x-1] + dist_K[y-1]

print("\n".join(map(str, ans)))
Problem p03634 (python)

Fixed submission:
from collections import deque
N = int(input())
g = [[] for x in range(N+1)]
for i in range(N - 1):
  (a, b, c) = map(int, input().split())
  g[a].append([b, c])
  g[b].append([a, c])

(Q, K) = map(int, input().split())
d = [-1] * (N+1)
d[K] = 0
r = deque()

r.append(K)
while len(r) > 0:
  i = r.popleft()
  for v in g[i]:
    if(d[v[0]] == -1):
      d[v[0]] = d[i] + v[1]
      r.append(v[0])

q = list()
for i in range(Q):
  q.append(input())
for i in range(Q):
  (x, y) = map(int, q[i].split())
  print(d[x] + d[y])

Buggy submission (verdict: Runtime Error):
N = int(input())
g = [[] for x in range(N+1)]
for i in range(N - 1):
  (a, b, c) = map(int, input().split())
  g[a].append([b, c])
  g[b].append([a, c])

(Q, K) = map(int, input().split())
d = [-1] * (N+1)
d[K] = 0

def fill(i):
  for v in g[i]:
    if(d[v[0]] == -1):
      d[v[0]] = d[i] + v[1]
      fill(v[0])
  return
  
fill(K)

q = list()
for i in range(Q):
  q.append(input())
for i in range(Q):
  (x, y) = map(int, q[i].split())
  print(d[x] + d[y])
Problem p02831 (python)

Fixed submission:

def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if 0==x%y:
        return y
    else:
        while not 0==x%y:
            z = x%y
            x = y
            y = z
        return z

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

A, B = [int(i) for i in input().split(" ")]

print(lcm(A, B))

Buggy submission (verdict: Runtime Error):
import math

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

A, B = [int(i) for i in input().split(" ")]

print(lcm(A, B))

Buggy submission (verdict: Runtime Error):
import math

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

A, B = [int(i) for i in input().split(" ")]

print(lcm(A, B))
Problem p02659 (python)

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

print((A*B)//100)

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

print(int(A*B))
Problem p02682 (python)

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


if k <= a:
    print(k)
elif k <= a + b:
    print(a)
else:
    r = k - a - b
    print(a-r)

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

if k = 1:
    print(k)
elif k <= a + b:
    print(k)
else:
    r = k - a - b
    print(a-r)

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

val_a = [1] * a
val_b = [0] * b
val_c = [-1] * c

val_a.extend(val_b)
val_a.extend(val_c)
print(val_a)

print(sum(val_a[:k]))
Problem p02659 (python)

Fixed submission:
a,b=input().split()
a=int(a)
b=int(b.replace(".",""))
print(a*b//100)

Buggy submission (verdict: Runtime Error):
a,b=float(input().split())
ans=int(a*b+0.00001)
print(ans)
Problem p03127 (python)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
ans=0
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)
if n==1:
    ans=l[0]
else:
    element = gcd(l[0], l[1])
    if n==2:
      ans=element
    else:
        for i in range(2,n):
            element=gcd(element,l[i])
        ans=element
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
ans=0
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)
if n==1:
    ans=x[0]
else:
    element = gcd(x[0], x[1])
    if n==2:
      ans=element
    else:
        for i in range(2,n):
            element=gcd(element,x[i])
        ans=element
print(ans)
Problem p03242 (python)

Fixed submission:
l=list(input())
for i in range(3):
  if l[i]=='1':
    l[i]='9'
  else:
    l[i]='1'
l="".join(l)
print(l)

Buggy submission (verdict: Runtime Error):
l=list(map(int,input().split()))
for i in range(3):
  if l[i]==1:
    l[i]=9
  else:
    l[i]=1
print(l)
Problem p03250 (python)

Fixed submission:
l=list(map(int,input().split()))
l2=sorted(l)
print(10*l2[2]+l2[1]+l2[0])

Buggy submission (verdict: Runtime Error):
l=list(map(int,input().split()))
l2=sort(l)
print(10*l2[2]+l2[1]+l2[0])