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

Fixed submission:
#coding:utf-8
N = int(input())
D = list(map(int,input().split()))
D = sorted(D)
#print (D)
a = D[int(len(D)/2)-1:int(len(D)/2)+1]
print (a[1]-a[0])

Buggy submission (verdict: Runtime Error):
#coding:utf-8
N = int(input())
D = list(map(int,input().split()))
D = sorted(D)
idx = len(D) // 2
print(D[idx] - D[odx-1])

Buggy submission (verdict: Runtime Error):
#coding:utf-8
N = int(input())
D = list(map(int,input().split()))
D = sorted(D)
idx = len(D) // 2
print(D[idx] - D[odx-1])
Problem p02990 (python)

Fixed submission:
import itertools
import math
MOD = 1000000007
def P(n, r):
  return math.factorial(n)//math.factorial(n-r)
def C(n, r):
  return P(n, r)//math.factorial(r)% MOD
def X(n, r):
  try:
    return C(n-1,n-r) 
  except:
    return 0
N,K = map(int,input().split())

for i in range(1,K+1):
  if (1==i and K==N):
    print (1)
  else:
    print (X(K,i)*((X(N-K,i+1)+2*X(N-K,i)+X(N-K,i-1)))% MOD)

Buggy submission (verdict: Runtime Error):
import itertools
import math
MOD = 1000000007
def P(n, r):
  return math.factorial(n)//math.factorial(n-r)
def C(n, r):
  return P(n, r)//math.factorial(r)% MOD
N,K = map(int,input().split())
for i in range(1,K+1):
    print ((C(N-K+1,i)*C(K-1,i-1))% MOD)

Buggy submission (verdict: Runtime Error):
import itertools
import math
MOD = 1000000007
def P(n, r):
  return math.factorial(n)//math.factorial(n-r)
def C(n, r):
  return P(n, r)//math.factorial(r)% MOD
def X(n, r):
  try:
    return C(n-1,n-r) 
  except:
    return 0
N,K = map(int,input().split())

for i in range(1,K+1):
  if (1==i and K==N):
    print (1)
  else:
    #print (X(K,i)*((X(N-K,i+1)+2*X(N-K,i)+X(N-K,i-1)))% MOD)
    print ((C(N-K+1,i)*C(K-1,i-1))% MOD)

Buggy submission (verdict: Runtime Error):
import itertools
import math
MOD = 1000000007
def P(n, r):
  return math.factorial(n)//math.factorial(n-r)
def C(n, r):
  return P(n, r)//math.factorial(r)% MOD
def X(n, r):
  try:
    return C(n-1,n-r) 
  except:
    return 0
N,K = map(int,input().split())

for i in range(1,K+1):
  if (1==i and K==N):
    print (1)
  else:
    #ßprint (X(K,i)*((X(N-K,i+1)+2*X(N-K,i)+X(N-K,i-1)))% MOD)
    print (C(N-K+1,i)*C(K-1,i-1)% MOD)
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
ng = set([int(input()) for _ in range(M)])
ans = [0, 1] 
for i in range(1, N+1):
  if i in ng:
    ans.append(0)
  else:
    ans.append((ans[-2] + ans[-1]) % MOD)
print(ans[-1] % MOD)

Buggy submission (verdict: Runtime Error):
#coding:utf-8
from math import *
def fib(n):
    return round(( ((1 + sqrt(5))/2)**n - ((1 - sqrt(5))/2)**n ) / sqrt(5))
F = 10001
MD = 1000000007
ls = [0,1]
for f in range(F-2):
    s = sum(ls[-2:])
    ls.append(s)
def fib2(n):
    return ls[n]
old_a = 0
diff = []
N,M = map(int, input().split())
for m in range(M):
    a = int(input())
    if a-old_a==1 and old_a != 0:
        print (0)
        exit()
    diff.append(a-old_a)
    old_a = a
diff.append(N - old_a)
    
#print (diff)
ans = 1
for i,d in enumerate(diff):
    if i!=0 and i!=len(diff)-1:
        d-=1
    ans *= fib2(d)
    #ans %= 1000000007
print (ans % MD)
#print (ans)

Buggy submission (verdict: Runtime Error):
#coding:utf-8
from math import *
def fib(n):
    return round(( ((1 + sqrt(5))/2)**n - ((1 - sqrt(5))/2)**n ) / sqrt(5))
F = 1001
MD = 1000000007
ls = [0,1]
for f in range(F-2):
    s = sum(ls[-2:])
    ls.append(s)
def fib2(n):
    return ls[n]
old_a = 0
diff = []
N,M = map(int, input().split())
for m in range(M):
    a = int(input())
    if a-old_a==1 and old_a != 0:
        print (0)
        exit()
    diff.append(a-old_a)
    old_a = a
diff.append(N - old_a)
    
#print (diff)
ans = 1
for i,d in enumerate(diff):
    if i!=0 and i!=len(diff)-1:
        d-=1
    ans *= fib(d)
    #ans %= 1000000007
print (ans % MD)
#print (ans)
Problem p03208 (python)

Fixed submission:
#coding:utf-8
n,k = map(int,input().split())
ls = []
for i in range(n):
    ls.append(int(input()))
#ls = [100000-i for i in range(100000)]
#n = 100000
#k = 1000
ls = sorted(ls)
ans = 1000000000
for i in range(n-k+1):
    mx = ls[i+k-1]
    mn = ls[i]
    ans = min(ans,mx - mn)
print (ans)

Buggy submission (verdict: Runtime Error):
#coding:utf-8
n,k = map(int,input().split())
ls = []
for i in range(n):
    ls.append(int(input()))
ls = sorted(ls)
ans = 10000000
for i in range(n-k+1):
    mx = max(ls[i:k+1])
    mn = min(ls[i:k+1])
    ans = min(ans,mx - mn)
print (ans)
Problem p03286 (python)

Fixed submission:
#coding:utf-8
n = int(input())

if n==0:
    print ('0')
    exit()

i=0
s=''
while(n!=0):
    if n%(2**(i+1))!=0:
        s+='1'
        n-=(-2)**i
    else:
        s+='0'
    i+=1
print (s[::-1])

Buggy submission (verdict: Runtime Error):
#coding:utf-8
n = int(input())

if n=0:
    print ('0')
    exit()

i=0
s=''
while(n!=0):
    if n%(2**(i+1))!=0:
        s+='1'
        n-=(-2)**i
    else:
        s+='0'
    i+=1
print (s[::-1])
Problem p02627 (python)

Fixed submission:
if str(input()).islower():
  print("a")
else:
  print("A")

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
B = [list(map(int,input().split())) for _ in range(Q)]
numList = [0]*10**5
sum=0
for i in A:
    numList[i] += 1
    sum+=i



for i in range(Q):
    dev = B[i][1]-B[i][0]
    sum += numList[B[i][0]]*dev
    numList[B[i][1]] +=numList[B[i][0]]
    numList[B[i][0]] = 0
    print(sum)
Problem p02629 (python)

Fixed submission:
N = int(input())
result =[]
alphabet = "zabcdefghijklmnopqrstuvwxy"
while(N>0):
    t = N%26
    result.append(alphabet[t])
    N = N//26
    if t == 0:
        N -= 1
result.reverse()

print(''.join(result))

Buggy submission (verdict: Runtime Error):
N = int(input())
result =[]
while(N>=26):
    result.append(chr(N%26 + 96))
    N = int(N/26)12
result.append(chr(N + 96))
result.reverse()
print(''.join(result))
Problem p02915 (python)

Fixed submission:
N=int(input())
print(N*N*N)

Buggy submission (verdict: Runtime Error):
N = int(input())
B = list(map(int,input().split()))
s = B[N-2]+B[0]
for i in range(N-2):
    s+=min(B[i],B[i+1])

print(s)
Problem p02623 (python)

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0

a, b = [0], [0]
for i in range(N):
    a.append(A[i]+a[i])
for i in range(M):
    b.append(B[i]+b[i])

j = M

for i in range(N+1):
    if a[i]>K:
        break
    while b[j]>K-a[i]:
        j-=1
    ans = max(ans, i+j)
print(ans)

Buggy submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
c = 0
i = 0
l, s = len(A), len(B)
if s>l:
    l, s = len(B), len(A)
while ans<K and i <=l:
    l, h = A[0], B[0]
    if l>h:
        l, h = B[0], A[0]
    ans+=l
    if l == A[0]:
        A = A[1:]
    else:
        B = B[1:]
    c += 1

print(c-1)
Problem p02629 (python)

Fixed submission:
N = int(input())
ans = ""
for i in range(1,99):
    if N<=26**i:
        N-=1
        for j in range(i):
            ans += chr(ord("a")+ N%26)
            N//=26
        break
    else:
        N-=26**i
print(ans[::-1])

Buggy submission (verdict: Runtime Error):
1 N = int(input())
2 ans = ''
3 while N > 0:
4 N -= 1
5 ans += chr(ord('a') + N % 26)
6 N //= 26
7 print(ans[::-1])
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")
        exit()
print("NG")

Buggy submission (verdict: Runtime Error):
K = int(input())
A, B = map(int, input().split())
if K=1:
    print("OK")
elif B-A>=K:
    print("OK")
else:
    print("NG")
Problem p02622 (python)

Fixed submission:
S = input()
T = input()
count = 0
for i in range(len(S)):
    if S[i] != T[i]:
        count+= 1
print(count)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
count = 0
for i in len(S):
    if S[i] != T[i]:
        count+= 1
print(count)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
count = 0
for i in len(S):
    if S[i] != T[i]
        count+= 1
print(count)
Problem p02699 (python)

Fixed submission:
a = input().split()
S = int(a[0])
W = int(a[1])
if S <= W:
    print("unsafe")
else:
    print("safe")

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


N = int(input())
keihin = []
for i in range(N):
    keihin.append(input())
# 
# nn = np.array(keihin)
# 
# 
# print(np.unique(nn).size)

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


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

nn = np.array(keihin)


print(np.unique(nn).size)
Problem p02659 (python)

Fixed submission:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

i=input()

a,b=i.split(' ')
from decimal import Decimal
print(int(Decimal(a) * Decimal(b)))

Buggy submission (verdict: Runtime Error):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

a,b=getNM()

print(int(a*b))
Problem p02754 (python)

Fixed submission:
a=list(map(int,input().split()))
b=int(a[0]/(a[1]+a[2]))
c=a[0]-b*(a[1]+a[2])
if c>a[1]:
    print(b*a[1]+a[1])
else:
    print(b*a[1]+c)

Buggy submission (verdict: Runtime Error):
a=map(int,input().split())
b=int(a[0]/(a[1]+a[2]))
c=a[0]-b*(a[1]+a[2])
if c>a[1]:
  print(b*a[1]+a[1])
else:
  print(b*a[1]+c)
Problem p02759 (python)

Fixed submission:
a=int(input())
if a%2==0:
  print(int(a/2))
else:
  print(int(a/2)+1)

Buggy submission (verdict: Runtime Error):
a = [list(map(int, input().split())) for i in range(3)]
output =[[0,0,0],[0,0,0],[0,0,0]]
n = int(input())
check=False
for k in range(n):
    b=int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j]==b:
                output[i][j]=1
for i in range(3):
    if output[i][0]*output[i][1]*output[i][2]==1:
        check=True
    elif output[0][i]*output[1][i]*output[2][i]==1:
        check=True
if output[0][0]*output[1][1]*output[2][2]==1:
    check=True
elif output[2][0]*output[1][1]*output[0][2]==1:
    check=True
if check==True:
    print('Yes')
else:
    print('No')
Problem p02659 (python)

Fixed submission:
import math
import decimal

A, B = input().split(" ")
A = decimal.Decimal(A)
B = decimal.Decimal(B)

print(math.floor(A * B))

Buggy submission (verdict: Runtime Error):
import math

A, B = input().split(" ")
A = int(A)
B = int(B)

print(math.floor(A * B))

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

values = np.array(input().split(" "), dtype=np.int64)
result = np.prod(values)

print(math.floor(result))
Problem p02627 (python)

Fixed submission:
N = input()

if N.isupper():
    print("A")
else:
    print("a")

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

#A,B = map(int,input().split())

#A = [int(input()) for i in range(N)]

"""
    A = []
    for _ in range(N):
        A.append(list(map(int,input().split())))
"""

if N.isupper():
    print(A)
else:
    print(B)
Problem p02725 (python)

Fixed submission:
import numpy as np

K,N = map(int, input().split())
An_list = np.array(input().split(), dtype=int)

An_delta_list = np.diff(An_list)
An_delta_list = np.append(An_delta_list, (K - An_list[-1])+An_list[0])
An_delta_max = np.max(An_delta_list)
result = np.sum(An_delta_list) - An_delta_max
print(result)

Buggy submission (verdict: Runtime Error):
K,N = map(int, input().split())
An_list = np.array(input().split(), dtype=int)

An_delta_list = np.diff(An_list)
An_delta_list = np.append(An_delta_list, K - An_list[N-1])
An_delta_max = np.max(An_delta_list)
result = np.sum(An_delta_list) - An_delta_max
print(result)

Buggy submission (verdict: Runtime Error):
#入出力
K,N = map(int, input("K,N:").split())
An_list = np.array(input("An:").split(), dtype=int)

# ここの距離を求める
An_delta_list = np.array([], dtype=int)

# 差のリストをつくる
for i in range(len(An_list)-1):
    An_delta_list = np.append(An_delta_list, An_list[i+1] -An_list[i])
An_delta_list = np.append(An_delta_list, K - An_list[-1])

# 差が最大の部分を見つける
An_delta_max = np.max(An_delta_list)
result = np.sum(An_delta_list) - An_delta_max


print(result)

Buggy submission (verdict: Runtime Error):
#入出力
K,N = map(int, input("K,N:").split())
An_list = np.array(input("An:").split(), dtype=int)


"""
# 入出力
K = 20
N = 3
An_list = np.array([0, 5, 15], dtype=int)
"""


# ここの距離を求める
An_delta_list = np.array([], dtype=int)

# 差のリストをつくる
for i in range(len(An_list)-1):
    An_delta_list = np.append(An_delta_list, An_list[i+1] -An_list[i])
An_delta_list = np.append(An_delta_list, K - An_list[-1])

# 差が最大の部分を見つける
An_delta_max = np.max(An_delta_list)
result = np.sum(An_delta_list) - An_delta_max
print(result)

"""
print("全リスト：", An_delta_list)
print("差の最大の値：", An_delta_max)
print("結果：", result)
"""
Problem p02622 (python)

Fixed submission:
# coding: UTF-8

S = input()
T = input()

res = 0
for ss, tt in zip(S, T):
    if ss != tt:
        res += 1

print(res)

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

S = input()
T = input()

res = set()
for ss, tt in zip(S, T):
    if ss != tt:
        set[ss] = 1

print(len(res))
Problem p02685 (python)

Fixed submission:
from functools import reduce
mod = 998244353

N, M, K = map(int, input().split())
C = 1
ans = (M*pow(M-1, (N-1), mod))%mod
k = 1
while k <= K and k < N:
  C *= (N-k)*pow(k, mod-2, mod)
  C %= mod
  a = (C*M*pow(M-1, (N-k-1), mod))%mod
  ans = (ans+a)%mod
  k += 1
print(ans)

Buggy submission (verdict: Runtime Error):
from functools import reduce
mod = 998244353

def C(a, b, m):
  return 1 if b == 0 else reduce(lambda x, y:(x*y)%m, range(a-b+1, a+1))*pow(reduce(lambda x,y:(x*y)%m, range(1, b+1)), m-2, m)
  
N, M, K = map(int, input().split())
ans = (M*pow(M-1, (N-k-1), mod))%mod
k = 1
while k <= K and k < N:
  a = ((C(N, k, mod)-1)*M*pow(M-1, (N-k-1), mod))%mod
  ans += a
  k += 1
print(ans)
Problem p02699 (python)

Fixed submission:
S, W = map(int, input().split())
print( "unsafe" if S <= W else "safe" )

Buggy submission (verdict: Runtime Error):
S = list(map(int, input()))
if len(S) < 4:
  print(0)
else:
  N = len(S)
  x = 0
  d = [0]*2019
  d[0] = 1
  for i, s in enumerate(reversed(S)):
    x += s*(10**i)
    d[x%2019] += 1
  ans = 0
  for m in d:
    ans += m*(m-1)//2
  print(ans)
Problem p02819 (python)

Fixed submission:
prime_table = [True]*(2*(10**5)+1)
prime_table[0], prime_table[1] = False, False
i = 2
while i * i <= 2*(10**5):
  if prime_table[i]:
    j = i*i
    while j <= 2*(10**5):
      prime_table[j] = False
      j += i
  i += 1
x = int(input())
ans = x
while not prime_table[ans]:
  ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
def isPrime(x):
  i = 2
  while i*i <= x:
    if x % i == 0:
      return True
  return False

X = int(input())
ans = X
while not isPrime(x):
  ans += 1
print(ans)
Problem p02862 (python)

Fixed submission:
from functools import reduce
mod = 10**9+7

def P(n, k):
  return reduce(lambda x, y:x*y%mod, range(n-k+1, n+1))

def factorial(n):
  return P(n, n)

def C(n, k):
  k = min(k, n-k)
  if k == 0:
    return 1
  else:
    return (P(n, k)*pow(factorial(k), mod-2, mod))%mod

X, Y = map(int, input().split())
if (X+Y)%3 == 0:
  n = Y-(X+Y)//3
  m = X-(X+Y)//3
  if n < 0 or m < 0:
    print(0)
  else:
    print(C(n+m, n))
else:
  print(0)

Buggy submission (verdict: Runtime Error):
from functools import reduce
mod = 10**9+7

def P(n, k):
  return reduce(lambda x, y:x*y%mod, range(n-k+1, n+1))

def factorial(n):
  return 1 if n == 0 else P(n, n)

X, Y = map(int, input().split())
L, S = max(X, Y), min(Y, X)
if (S-(L-S))%3 != 0:
  print(0)
else:
  s = (S-(L-S))//3
  l = (S-(L-S))//3+(L-S)
  bunshi = factorial(s+l)
  bunbo = (factorial(s)*factorial(l))%mod
  print((bunshi*pow(bunbo,mod-2, mod))%mod)

Buggy submission (verdict: Runtime Error):
from functools import reduce
mod = 10**9+7

def P(n, k):
  return reduce(lambda x, y:x*y%mod, range(n-k+1, n+1))

def factorial(n):
  return P(n, n)

X, Y = map(int, input().split())
L, S = max(X, Y), min(Y, X)
if (S-(L-S))%3 != 0 or S-(L-S) < 0:
  print(0)
else:
  s = (S-(L-S))//3
  l = (S-(L-S))//3+(L-S)
  bunshi = factorial(s+l)
  bunbo = (factorial(s)*factorial(l))%mod
  print((bunshi*pow(bunbo,mod-2, mod))%mod)

Buggy submission (verdict: Runtime Error):
from functools import reduce
mod = 10**9+7

def P(n, k):
  return reduce(lambda x, y:x*y%mod, range(n-k+1, n+1))

def factorial(n):
  return P(n, n)

X, Y = map(int, input().split())
L, S = max(X, Y), min(Y, X)
if (S-(L-S))%3 != 0:
  print(0)
else:
  s = (S-(L-S))//3
  l = (S-(L-S))//3+(L-S)
  bunshi = factorial(s+l)
  bunbo = (factorial(s)*factorial(l))%mod
  print((bunshi*pow(bunbo,mod-2, mod))%mod)
Problem p02881 (python)

Fixed submission:
import math
N = int(input())
M = int(math.sqrt(N))
i = 1
j = 1
for x in reversed(range(M+1)):
  if N % x == 0:
    i = x
    j = N // x
    break
print(i+j-2)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
M = int(math.sqrt(N))
i = 1
j = 1
for x in reversed(range(M)):
  if N % x == 0:
    i = x
    j = N // x
    break
print(i+j-2)
Problem p02912 (python)

Fixed submission:
import heapq

N, M = map(int, input().split())
A = list(map(lambda x:[-int(x),int(x)], input().split()))
heapq.heapify(A)

for m in range(M):
  x = heapq.heappop(A)
  x[1] //= 2
  x[0] = -x[1]
  heapq.heappush(A, x)
ans = 0
for a in A:
  ans += a[1]
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
import bisect

n, m = map(int, input().split())
a = deque(sorted(list(map(int, input().split()))))

for i in range(m):
  x = a.pop()//2
  a.insert(bisect.bisect_left(a, x),x)
print(sum(a))
Problem p03013 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

MOD = 10**9+7
memo = {}
def steps(n):
  if not(n in memo):
    if n == 0:
      memo[n] = 1
    elif n == 1:
      memo[n] = 1
    else:
      memo[n] = (steps(n-1)+steps(n-2))%MOD
  return memo[n]

N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
nowstep = 0
ans = 1
for a in A:
  if nowstep == a:
    ans = 0
    break
  ans = (ans * steps(a-1-nowstep))%MOD
  nowstep = a+1
ans = (ans * steps(N-nowstep))%MOD
print(ans)

Buggy submission (verdict: Runtime Error):
MOD = 10**9+7
memo = {}
def steps(n):
  if not(n in memo):
    if n == 0:
      memo[n] = 1
    elif n == 1:
      memo[n] = 1
    else:
      memo[n] = (steps(n-1)+steps(n-2))%MOD
  return memo[n]

N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
nowstep = 0
ans = 1
for a in A:
  if nowstep == a:
    ans = 0
    break
  ans = (ans * steps(a-1-nowstep))%MOD
  nowstep = a+1
ans = (ans * steps(N-nowstep))%MOD
print(ans)
Problem p03315 (python)

Fixed submission:
S = list(raw_input())
ans = 0
for s in S:
  ans += 1 if s == '+' else -1
print ans

Buggy submission (verdict: Runtime Error):
S = list(raw_input())
ans = 0
for s in S:
  ans += 1 if s == '+' else '-'
print ans
Problem p03634 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

def dfs(prev, now, fromK, t, d):
  d[now] = fromK
  for nl in (t[now]):
    if nl[0] != prev:
      dfs(now, nl[0], fromK+nl[1], t, d)

N = int(input())
T  = [[] for _ in range(N+1)]
for _ in range(N-1):
  a, b, l = map(int, input().split())
  T[a].append([b,l])
  T[b].append([a, l])
Q, K = map(int, input().split())
D = [0] * (N+1)
dfs(-1, K, 0, T, D)
for _ in range(Q):
  x, y = map(int, input().split())
  print(D[x]+D[y])

Buggy submission (verdict: Runtime Error):
def dfs(prev, now, fromK, t, d):
  d[now] = fromK
  for nl in (t[now]):
    if nl[0] != prev:
      dfs(now, nl[0], fromK+nl[1], t, d)

N = int(input())
T  = [[] for _ in range(N+1)]
for _ in range(N-1):
  a, b, l = map(int, input().split())
  T[a].append([b,l])
  T[b].append([a, l])
Q, K = map(int, input().split())
D = [0] * (N+1)
dfs(-1, K, 0, T, D)
for _ in range(Q):
  x, y = map(int, input().split())
  print(D[x]+D[y])
Problem p02659 (python)

Fixed submission:
#a, b = map(float, input().split())

a, b = input().split()
from decimal import Decimal
import math
print(math.floor(int(a)*Decimal(b)))

Buggy submission (verdict: Runtime Error):
#解放2
from decimal import Decimal
from floor import math
a, b = input().split()
a = int(a)
b = Decimal(b)
print(floor(a*b))

Buggy submission (verdict: Runtime Error):
a, b = input().split()
b.replace(".", "")
print(int(a)*int(b)//100)

Buggy submission (verdict: Runtime Error):
#a, b = map(float, input().split())

a, b = input().split()

from decimal import Decimal
import math
print(math.floor(int(a)*Decimal(b))
Problem p02699 (python)

Fixed submission:
s, w = map(int, input().split())
if s > w:
    print("safe")
else:
    print("unsafe")

Buggy submission (verdict: Runtime Error):
s = input()
ans = 0
for i in range(len(s)-1):
    for j in range(i+1,len(s)):
        #print(i,j)
        num = int(s[i:j+1])

        if num % 2019 == 0:
            print(i,j, num)
            ans += 1

print(ans)
Problem p02726 (python)

Fixed submission:
from collections import deque

n, x, y = map(int, input().split())

ans = [0] * (n+1)

g = [[i+1, i-1] for i in range(n+1)]
#g[0].clear() pypyにclearなし
g[1].pop(1)
g[n].pop(0)

g[x].append(y)
g[y].append(x)

for i in range(1,n+1):
    q = deque()
    time = 0
    visit = [False] * (n+1)
    q.append((i, time))

    while(len(q) > 0):
        item = q.popleft()

        if visit[item[0]] == False:
            visit[item[0]] = True
            ans[item[1]] += 1
            for k in g[item[0]]:
                q.append((k, item[1]+1))

for i in range(1,n):
    print(ans[i]//2)

Buggy submission (verdict: Runtime Error):
from collections import deque

n, x, y = map(int, input().split())

ans = [0] * (n+1)

g = [[i+1, i-1] for i in range(n+1)]
g[0].clear()
g[1].pop(1)
g[n].pop(0)

g[x].append(y)
g[y].append(x)

for i in range(1,n+1):
    q = deque()
    time = 0
    visit = [False] * (n+1)
    q.append((i, time))

    while(len(q) > 0):
        item = q.popleft()

        if visit[item[0]] == False:
            visit[item[0]] = True
            ans[item[1]] += 1
            for k in g[item[0]]:
                q.append((k, item[1]+1))

for i in range(1,n):
    print(ans[i]//2)

Buggy submission (verdict: Runtime Error):
from collections import deque

if __name__ == '__main__':

    n, x, y = map(int, input().split())

    ans = [0] * (n+1)

    g = [[i+1, i-1] for i in range(n+1)]
    g[0].clear()
    g[1].pop(1)
    g[n].pop(0)

    g[x].append(y)
    g[y].append(x)

    for i in range(1,n+1):
        q = deque()
        time = 0

        visit = [False] * (n+1)

        q.append((i, time))

        while(len(q) > 0):
            item = q.popleft()

            if visit[item[0]] == False:
                visit[item[0]] = True
                ans[item[1]] += 1
                if item[1] == 5:
                    print(i,item)

                for k in g[item[0]]:
                    q.append((k, item[1]+1))

    for i in range(1,n):
        print(ans[i]//2)
Problem p02753 (python)

Fixed submission:
s = input()
if all(i == "A" for i in s):
    print("No")
elif all(i == "B" for i in s):
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
s = list(input())
q = int(input())
lines = [list(input().split()) for i in range(q)]
 
def q1(s):
    for i in range(len(s) // 2):
        s[i],s[-1-i] = s[-1-i],s[i]
    return s
 
def q2(s, l):
    if int(l[1]) == 1:
        s.insert(0,l[2])
    else:
        s.extend(l[2])
    return s
 
for l in lines:
    if int(len(l)) == 1:
        q1(s)
    else:
        q2(s, l)
 
print(*s, sep='')
s = list(input())
q = int(input())
lines = [list(input().split()) for i in range(q)]

def q1(s):
    for i in range(len(s) // 2):
        s[i],s[-1-i] = s[-1-i],s[i]
    return s

def q2(s, l):
    if int(l[1]) == 1:
        s.insert(0,l[2])
    else:
        s.extend(l[2])
    return s

for l in lines:
    if int(len(l)) == 1:
        q1(s)
    else:
        q2(s, l)

print(*s, sep='')