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

Fixed submission:
import sys  
sys.setrecursionlimit(200000)
n=int(raw_input())
tr=[[] for i in range(n)]
for i in range(n-1) :
  a,b,c=map(int,raw_input().split())
  a -= 1
  b -= 1
  tr[a].append((b,c))
  tr[b].append((a,c))
m,k=map(int,raw_input().split())
k -= 1
dis=[0 for i in range(n)]
def dfs(u,w=-1,l=0) :
  dis[u]=l
  for v,v1 in tr[u] :
    if v!=w :
      dfs(v,u,l+v1)
dfs(k)
for i in range(m) :
  x,y=map(int,raw_input().split())
  x-=1
  y-=1
  print dis[x]+dis[y]

Buggy submission (verdict: Runtime Error):
n=int(raw_input())
tr=[[] for i in range(n)]
for i in range(n-1) :
  a,b,c=map(int,raw_input().split())
  a -= 1
  b -= 1
  tr[a].append((b,c))
  tr[b].append((a,c))
m,k=map(int,raw_input().split())
k -= 1
dis=[0 for i in range(n)]
def dfs(u,w=-1,l=0) :
  dis[u]=l
  for v,v1 in tr[u] :
    if v!=w :
      dfs(v,u,l+v1)
dfs(k)
for i in range(m) :
  x,y=map(int,raw_input().split())
  x-=1
  y-=1
  print dis[x]+dis[y]
Problem p03805 (python)

Fixed submission:
N, M = map(int, input().split())
adj_matrix = [[0]* N for _ in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1

def dfs(v, used):
    if not False in used:
        return 1
    
    ans = 0
    for i in range(N):
        if not adj_matrix[v][i]:
            continue
        if used[i]:
            continue
        
        used[i] = True
        ans += dfs(i, used)
        used[i] = False
    
    return ans

used = [False] * N
used[0] = True

print(dfs(0, used))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000000)
n,m = map(int,input().split())
graph = [list(input().split(" ")) for i in range(n)]

result=0

def dfs(a, list, graph,  result):
  if len(list) == n:
    result = result + 1

  for g in graph:
    if g[0] == a and g[1] not in list:
      list.append(g[1])
      result = dfs(g[1], list, graph, result)
    if g[1] == a and g[0] not in list:
      list.append(g[0])
      result = dfs(g[0], list, graph, result)

  return result

for g in graph:
  list = []
  if g[0] == "1":
    list.append(1)
    result += dfs("1", list, graph, 0)

print(result)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)
n,m = map(int,input().split())
graph = [list(input().split(" ")) for i in range(n)]

result=0

def dfs(a, list, graph,  result):
  if len(list) == n:
    result = result + 1

  for g in graph:
    if g[0] == a and g[1] not in list:
      list.append(g[1])
      result = dfs(g[1], list, graph, result)
    if g[1] == a and g[0] not in list:
      list.append(g[0])
      result = dfs(g[0], list, graph, result)

  return result

for g in graph:
  list = []
  if g[0] == "1":
    list.append(1)
    result += dfs("1", list, graph, 0)

print(result)

Buggy submission (verdict: Runtime Error):
import sys
n,m = map(int,input().split())
graph = [list(input().split(" ")) for i in range(n)]

result=0

def dfs(a, list, graph,  result):
  print(list)
  if len(list) == n:
    result = result + 1

  for g in graph:
    if g[0] == a and g[1] not in list:
      list.append(g[1])
      result = dfs(g[1], list, graph, result)
    if g[1] == a and g[0] not in list:
      list.append(g[0])
      result = dfs(g[0], list, graph, result)

  return result

for g in graph:
  list = []
  if g[0] == "1":
    list.append(1)
    result += dfs("1", list, graph, 0)

print(result)

Buggy submission (verdict: Runtime Error):
import sys
n,m = map(int,input().split())
graph = [list(input().split(" ")) for i in range(n)]

result=0

def dfs(a, list, graph,  result):
  print(list)
  if len(list) == n:
    result = result + 1

  for g in graph:
    if g[0] == a and g[1] not in list:
      list.append(g[1])
      result = dfs(g[1], list, graph, result)
    if g[1] == a and g[0] not in list:
      list.append(g[0])
      result = dfs(g[0], list, graph, result)

  return result

for g in graph:
  list = []
  if g[0] == "1":
    list.append(1)
    result += dfs("1", list, graph, 0)

print(result)
Problem p03803 (python)

Fixed submission:
A, B = map(int, input().split())
if A < B:
  if A == 1:
    print('Alice')
  else:
    print('Bob')

elif A > B:
  if B == 1:
    print('Bob')
  else:
    print('Alice')
else:
  print('Draw')

Buggy submission (verdict: Runtime Error):
A, B = int(map, input().split())
if A <= B:
  if A == 1:
    print('Alice')
  else:
    print('Bob')
else:
  if B == 1:
    print('Bob')
  else:
    print('Alice')

Buggy submission (verdict: Runtime Error):
A, B = int(map, input().split())
if A <= B:
  if A = 1:
    print('Alice')
  else:
    print('Bob')
else:
  if B = 1:
    print('Bob')
  else:
    print('Alice')
Problem p03834 (python)

Fixed submission:
h = list(map(str, input().split(',')))
ans = ' '.join(h)
print(ans)

Buggy submission (verdict: Runtime Error):
h = list(map(str, input().split(,)))
ans = ' '.join(h)
print(ans)
Problem p03835 (python)

Fixed submission:
k, s = map(int, input().split())
count = 0
for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if z >= 0 and z <= k:
            count+=1

print(count)

Buggy submission (verdict: Runtime Error):
k, s = map(int, input_file[0].split())
count = 0
for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if z >= 0 and z <= k:
            count+=1

print(count)
Problem p03776 (python)

Fixed submission:
import math

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

v.sort(reverse = True)
total = 0

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

for i in range(A):
    total = total + v[i]
else:
    print(total / A)
    
count = 0
min = v[A-1]
number = v.count(min)

if(v.index(min) == 0):
    for i in range(A,number+1):
        if(i>B):
            break
        count = combinations_count(number,i) + count
    print(count)
else:
    print(combinations_count(number,A - v.index(min)))

Buggy submission (verdict: Runtime Error):
import math

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

v.sort(reverse = True)
total = 0

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

for i in range(A):
    total = total + v[i]
else:
    print(total / A)
    
count = 0
min = v[A-1]
number = v.count(min)

if(v.index(min) == 0):
    for i in range(A,B+1):
        count = combinations_count(number,i) + count
    print(count)
else:
    print(combinations_count(number,A - v.index(min)))

Buggy submission (verdict: Runtime Error):
import math

N,A,B = map(int,input().split())
v = [map(int,input().split())]

v.sort(reverse = True)
total = 0

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

for i in range(A):
    total = total + v[i]
else:
    print(total / A)
    
count = 0
min = v[A-1]
number = v.count(min)

if(v.index(min) == 0):
    for i in range(A,B+1):
        count = combinations_count(number,i) + count
    print(count)
else:
    print(combinations_count(number,A - v.index(min)))
Problem p03768 (python)

Fixed submission:
n,m=map(int,input().split())
e = []

for _ in range(1,m+1):
    a,b=map(int,input().split())
    e.append((a,b))

q = int(input())
cs = [0] * (q+1)
dp = [[0]*11 for _ in range(n+1)]
for i in range(1, q+1):
    v,d,c=map(int,input().split())
    cs[i] = c
    dp[v][d] = i

for d in range(9, -1, -1):
    for i in range(1,n+1):
        dp[i][d] = max(dp[i][d], dp[i][d+1])
    for a,b in e:
        dp[a][d] = max(dp[a][d], dp[b][d+1])
        dp[b][d] = max(dp[b][d], dp[a][d+1])

for i in range(1, n+1):
    print(cs[dp[i][0]])

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

n,m=map(int,input().split())
e = []

for _ in range(1,m+1):
    a,b=map(int,input().split())
    e.append((a,b))

q = int(input())
cs = [0] * (q+1)
dp = np.zeros((n+1, 11), int)
for i in range(1, q+1):
    v,d,c=map(int,input().split())
    cs[i] = c
    dp[v,d] = i

for d in range(9, -1, -1):
    for i in range(1,n+1):
        dp[i,d] = max(dp[i,d], dp[i,d+1])
    for a,b in e:
        dp[a,d] = max(dp[a,d], dp[b,d+1])
        dp[b,d] = max(dp[b,d], dp[a,d+1])

for i in range(1, n+1):
    print(cs[dp[i,0]])
Problem p03834 (python)

Fixed submission:
line = input()
print(line.replace(","," "))

Buggy submission (verdict: Runtime Error):
k,s = map(int,input().split())
count = 0
for i in range(k+1):
    for j in range(k+1):
        if s-(i+j) <= k and s-(i+j) >= 0:
            count += 1
print(count)

Buggy submission (verdict: Runtime Error):
k,s = map(int,input().split())
count = 0
for i in range(k+1):
    for j in range(k+1):
        if s-i-j <= k:
            count += 1
print(count)
Problem p03631 (python)

Fixed submission:
str = input()
print("Yes" if str == str[-1::-1] else "No")

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

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

n = int(input())
t_list = []
for x in range(n):
    t_list.append(int(input()))
result = 1
for t in t_list:
    result = lcm(result,t)
print(result)
Problem p03617 (python)

Fixed submission:
n025, n05, n1, n2 = map(int, raw_input().split())
n = input()
ans = 0

if n >= 2:
    arr = []
    arr.append(n025 * 8)
    arr.append(n05 * 4)
    arr.append(n1 * 2)
    arr.append(n2)
    ans += min(arr) * (n / 2)

arr = []
arr.append(n025 * 4)
arr.append(n05 * 2)
arr.append(n1)
ans += min(arr) * (n % 2)

print ans

Buggy submission (verdict: Runtime Error):
n025, n05, n1, n2 = map(int, raw_input().split())
n = input()
ans = [0 for i in range(4)]


if n >= 2:
    arr = []
    arr.append(n025 * 8)
    arr.append(n05 * 4)
    arr.append(n1 * 2)
    arr.append(n2)
    for i in range(n / 2):
        m = arr.index(min(arr))
        if m == 0:
            ans[m] += 8
        elif m == 1:
            ans[m] += 4
        elif m == 2:
            ans[m] += 2
        else:
            ans[m] += 1

n = (n % 2)

for i in range(n):
    arr = []
    arr.append(n025 * 4)
    arr.append(n05 * 2)
    arr.append(n1)
    for i in range(n):
        m = arr.index(min(arr))
        if m == 0:
            ans[m] += 4
        elif m == 1:
            ans[m] += 2
        else:
            ans[m] += 1
        
tmp = 0
tmp += ans[0] * n025
tmp += ans[1] * n05
tmp += ans[2] * n1
tmp += ans[3] * n2

print tmp
Problem p03631 (python)

Fixed submission:
def func(s):
    key = len(s)
    for i in range(len(s)):
        if s[key - i - 1] != s[i]:
            return -1
    return 0

s = raw_input()

n = func(s)

if n == 0:
    print "Yes"
else:
    print "No"

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

print a, b, c, d

if a >= c:
    ans = b - c
else:
    ans = d - a

if ans < 0:
    print 0
else:
    print ans
Problem p03803 (python)

Fixed submission:
#A One card Poker
A,B = [int(i) for i in input().split(" ")]
if A == B:
    print("Draw")
elif (A == 1) or (A>B and B!=1):
    print("Alice")
else:
    print("Bob")

Buggy submission (verdict: Runtime Error):
#A One card Poker
A,B = [int(i) for i in input().split(" ")]
if A == B:
    print("Draw")
elif (A == 1) or (A>B and B!=1):
    print("Alice")
else:
    print("Bob")
Problem p03834 (python)

Fixed submission:
#001
a = raw_input()
a=a.replace(',',' ')
print(a)

Buggy submission (verdict: Runtime Error):
#001
a = raw_input()
a=a.replace(',',' ')
print(a)
Problem p03835 (python)

Fixed submission:
K,S =map(int, input().split())
c=0
for i in range(K+1):
	for j in range(K+1):
		if 0<=S-i-j<=K:
			c+=1

print(c)

Buggy submission (verdict: Runtime Error):
K,S =map(int, input().split())
c=0
for i in range(K+1)
	for j in range(K+1)
		if 0<=S-i-j<=K
			c+=1

print(c)
Problem p03617 (python)

Fixed submission:
Q, H, S, D,= map(int, raw_input().split())
N = int(input())
if Q*2 > H:
    M1 = H
else:
    M1 = Q*2

if  M1*2 > S:
    M = S
else:
    M = M1*2
if M*2 < D:
    print(M*N)
else:
    if N%2 == 0:
        print(D*(N//2))
    else:
        print(D*(N//2) + M)

Buggy submission (verdict: Runtime Error):
l = map(int, raw_input().split())
N = raw_input
l[0] = Q
l[1] = H
l[2] = S
l[3] = D
if Q*2 > H:
    M1 = H
else:
    M1 = Q*2

if  M1*2 > S:
    M = S
else:
    M = M1*2
if M*2 < D:
    print(M*N)
else:
    if N%2 == 0:
        print(D*(N//2))
    else:
        print(D*(N//2) + M)

Buggy submission (verdict: Runtime Error):
Q, H, S, D, N = input(), input(), input(), input(), input()
if Q*2 > H:
    M1 = H
else:
    M1 = Q*2

if  M1*2 > S:
    M = S
else:
    M = M1*2
if M*2 < D:
    print(M*N)
else:
    if N%2 == 0:
        print(D*(N//2))
    else:
        print(D*(N//2) + M)
Problem p03803 (python)

Fixed submission:
A, B = map(int,input().split())
if A == B:
  print("Draw")
elif A > B or A == 1:
  if B == 1:
    print("Bob")
  else:
    print("Alice")
else:
  print("Bob")

Buggy submission (verdict: Runtime Error):
N = int(input())
bonus = N // 15 * 200
print(N * 800 - bonus)
Problem p03803 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Spyderエディタ

これは一時的なスクリプトファイルです
"""
alice = input().split()
alice[0] = int(alice[0])
alice[1] = int(alice[1])
if(alice[0] == alice[1]):
    print("Draw")
elif(alice[0] == 1):
    print("Alice")
elif(alice[1] == 1):
    print("Bob")
elif(alice[0] < alice[1]):
    print("Bob")
elif(alice[0] > alice[1]):
    print("Alice")

Buggy submission (verdict: Runtime Error):

alice = int(input())
bob = int(input())

if(alice == bob):
    print("Draw")
elif(alice == 1 and bob == 1):
    print("Draw")
    
elif(alice == 1):
    print("Alice")
elif(bob == 1):
    print("Bob")
elif(alice < bob):
    print("Bob")
elif(alice > bob):
    print("Alice")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Spyderエディタ

これは一時的なスクリプトファイルです
"""
alice = int(input())
bob = int(input())

if(alice == bob):
    print("Draw)
elif(alice == 1 and bob == 1):
    print("Draw")
    
elif(alice == 1):
    print("Alice")
elif(bob == 1):
    print("Bob")
elif(alice < bob):
    print("Bob")
elif(alice > bob):
    print("Alice")

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

alice = int(input())
bob = int(input())

if(alice == bob):
    print("Draw)
        elif(alice == 1 and bob == 1):
            print("Draw")
    
            elif(alice == 1):
                print("Alice")
                    elif(bob == 1):
                        print("Bob")
                        elif(alice < bob):
                            print("Bob")
                            elif(alice > bob):
                                print("Alice")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Spyderエディタ

これは一時的なスクリプトファイルです
"""
alice = int(input())
bob = int(input())

if(alice == bob):
    print("Draw)
    elif(alice == 1 and bob == 1):
        print("Draw")
    
        elif(alice == 1):
            print("Alice")
                elif(bob == 1):
                    print("Bob")
                    elif(alice < bob):
                        print("Bob")
                        elif(alice > bob):
                            print("Alice")
Problem p03775 (python)

Fixed submission:
def f(x,y):
    count_x, count_y = 1, 1
    while x/10>=1:
        x = x//10
        count_x += 1
    while y/10>=1:
        y = y//10
        count_y += 1
    return max(count_x, count_y)

pf = []
m = int(input())

for i in range(1,int(m**0.5)+1):
    if m%i == 0:
        pf.append(i)

print(f(pf[-1], m/pf[-1]))

Buggy submission (verdict: Runtime Error):
def f(x):
    count_x = 1
    while x/10>=1:
        x = x//10
        count_x += 1
    return count_x

pf = {}
m = int(input())
root_m = int(m**0.5)
for i in range(2,root_m+1):
    while m%i == 0:
        pf[i] = pf.get(i,0) + 1
        m//=i
if m>1:pf[m]=1

if root_m<max(pf.keys()):
    print(f(max(pf.keys())))
else:
    print(f(root_m))
Problem p03805 (python)

Fixed submission:
from itertools import permutations

n, m = map(int, input().split())
ans = 0

path = [[False]*n for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a][b] = True
    path[b][a] = True

for i in permutations(range(n), n):
    if i[0] == 0:
        for j in range(n):
            if j == n - 1:
                ans += 1
                break
            if not path[i[j]][i[j+1]]:
                break
print(ans)

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

n, m = map(int, input().split())
ans = 0

path = [[False]*n for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a][b] = True
    path[b][a] = True

for i in permutations(range(n), n):
    if i[0] == 0:
        for j in range(n):
            if j == n - 1:
                ans += 1
                break
            if not path[i[j]][i[j+1]]:
                break
print(ans)

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

n, m = map(int, input().split())
ans = 0

path = [[False]*n for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a][b] = True
    path[b][a] = True

for i in permutations(range(n), n):
    if i[0] == 0:
        for j in range(n):
            if j == 1:
                ans += 1
                break
            if not path[i[j]][i[j+1]]:
                break
print(ans)

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

n, m = map(int, input().split())
ans = 0

path = [[False]*n for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a][b] = True
    path[b][a] = True

for i in permutations(range(n), n):
    if i[0] == 0:
        for j in range(n):
            if not path[i[j]][i[j+1]]:
                break
            if j == n-1:
                ans += 1
                break
print(ans)
Problem p03775 (python)

Fixed submission:
import math

N = int(input())

def enum(N,A):
    if(N % A == 0):
        B = N // A
        return (A,B)
    else:
        return 'NULL'

def F(tupleX):
    t = max(tupleX)
    return int(math.log10(t) + 1)

X = []
hu = int(math.sqrt(N)) + 1
for n in range(1,hu):
    X.append(enum(N,n))

Y = []
for x in X:
    if (x == 'NULL'):
        continue
    else:
        y = F(x)
        Y.append(y)

print(min(Y))

Buggy submission (verdict: Runtime Error):
import math

N = int(input())

def enum(N,A):
	if(N % A == 0):
		B = N // A
		return (A,B)
	else:
		return 'NULL'

def F(tupleX):
	t = max(tupleX)
	return int(math.log10(t) + 1)

X = []  # 候補
for n in range(1,N):
	X.append(enum(N,n))

Y = [] 
for x in X:
    if (x == 'NULL'):
        continue
    else:
	    y = F(x)
	    Y.append(y)
	
print(min(Y))

Buggy submission (verdict: Runtime Error):
import math

N = int(input())

def solve(N,A):
	if(N % A == 0):
		B = N / A
		return int(math.log10(max(A,B)) + 1)
	else:
		return -1
		

ans = []
for A in range(1,N):
	ans.append(solve(N,A))
print(max(ans))
Problem p03634 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

n = int(input())
tree = [[] for i in range(n + 1)]
for i in range(n - 1):
    a, b, c = map(int, input().split())
    tree[a].append((b, c))
    tree[b].append((a, c))

depth = [0] * (n + 1)
def dfs(v, p, d):
    depth[v] = d
    for to, cost in tree[v]:
        if to != p:
            dfs(to, v, d + cost)

q, k = map(int, input().split())
dfs(k, 0, 0)
xy = [tuple(map(int, input().split())) for i in range(q)]

for x, y in xy:
    print(depth[x] + depth[y])

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

n = int(input())
tree = [[] for i in range(n + 1)]
for i in range(n - 1):
    a, b, c = map(int, input().split())
    tree[a].append((b, c))
    tree[b].append((a, c))

depth = [0] * (n + 1)
def dfs(v, p, d):
    depth[v] = d
    for to, cost in tree[v]:
        if to != p:
            dfs(to, v, d + cost)

q, k = map(int, input().split())
dfs(k, 0, 0)
xy = [tuple(map(int, input().split())) for i in range(q)]

for x, y in xy:
    print(depth[x] + depth[y])

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

depth = [0] * (n + 1)
def dfs(v, p, d):
    depth[v] = d
    for to, cost in tree[v]:
        if to != p:
            dfs(to, v, d + cost)

q, k = map(int, input().split())
dfs(k, 0, 0)
xy = [tuple(map(int, input().split())) for i in range(q)]

for x, y in xy:
    print(depth[x] + depth[y])

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

depth = [0] * (n + 1)
def dfs(v, p, d):
    depth[v] = d
    for to, cost in tree[v]:
        if to != p:
            dfs(to, v, d + cost)

q, k = map(int, input().split())
dfs(k, 0, 0)
for i in range(q):
    x, y = map(int, input().split())
    print(depth[x] + depth[y])

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

depth = [0] * (n + 1)
def dfs(v, p, d):
    depth[v] = d
    for to, cost in tree[v]:
        if to != p:
            dfs(to, v, d + cost)

q, k = map(int, input().split())
dfs(k, -1, 0)
for i in range(q):
    x, y = map(int, input().split())
    print(depth[x] + depth[y])

Buggy submission (verdict: Runtime Error):
tree = [[] for i in range(100001)]
depth = [0] * 100001

def dfs(v, p, d):
    depth[v] = d
    for to, cost in tree[v]:
        if to == p:
            continue
        dfs(to, v, d + cost)

n = int(input())
for i in range(n - 1):
    a, b, c = map(int, input().split())
    tree[a].append((b, c))
    tree[b].append((a, c))

q, k = map(int, input().split())
dfs(k, -1, 0)
for i in range(q):
    x, y = map(int, input().split())
    print(depth[x] + depth[y])
Problem p03631 (python)

Fixed submission:
N = input()
if N == N[::-1]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N = input()
if N = N[::-1]:
  print('Yes')
else:
  print('No')
Problem p03775 (python)

Fixed submission:
# coding: utf-8
import math

num_N = int(input())

min_num = 999999
sqrt_N = math.floor(math.sqrt(num_N))

for i in range(1, sqrt_N + 1):
    if num_N % i == 0:
        len_num_A = len(str(i))
        len_num_B = len(str(int(num_N / i)))
        min_num = min(min_num, max(len_num_A, len_num_B))

print(min_num)

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

num_N = int(input())

min_num = math.inf
sqrt_N = math.floor(math.sqrt(num_N))

for i in range(1, sqrt_N + 1):
    if num_N % i == 0:
        len_num_A = len(str(i))
        len_num_B = len(str(int(num_N / i)))
        min_num = min(min_num, max(len_num_A, len_num_B))

print(min_num)

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

num_N = int(input())

min_num = math.inf
sqrt_N = math.floor(math.sqrt(num_N))

for i in range(1, sqrt_N + 1):
    if num_N % i == 0:
        len_num_A = len(str(i))
        len_num_B = len(str(num_N // i))
        min_num = min(min_num, max(len_num_A, len_num_B))

print(min_num)

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

num_N = int(input())

min_num = math.inf

for i in range(1, math.floor(math.sqrt(num_N)) + 1):
    if num_N % i == 0:
        num_A = i
        num_B = int(num_N // i)
        len_num_A = len(list(str(num_A)))
        len_num_B = len(list(str(num_B)))
        min_num = min(min_num, max(len_num_A, len_num_B))

print(min_num)
Problem p04005 (python)

Fixed submission:
A, B, C = list(map(int, input().split()))
if (A*B*C)%2 == 0:
    print('0')
else:
    print('%s' % str(min(min(A*B, B*C),C*A)) )

Buggy submission (verdict: Runtime Error):
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
min_index = a.index(min(a))
index_list = list(range(min_index,N)) + list(range(min_index))
cost = a.copy()
c_count = [0]*N
for i in range(1,N):
    if cost[index_list[i]] > (cost[index_list[i-1]]+x):
        cost[index_list[i]] = cost[index_list[i-1]]+x
        c_count[index_list[i]] = c_count[index_list[i-1]]+1

print(sum(cost) - sum(c_count)*x + max(c_count)*x  )