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

Fixed submission:
import sys
from collections import deque

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
edges = [[] for _ in range(N + 1)]
for i in range(N - 1):
    a, b, c = [int(_) for _ in input().split()]
    edges[a].append((b, c))
    edges[b].append((a, c))

L = [-1] * (N + 1)


def w(k):
    que = deque()
    L[k] = 0
    que.append((k, -1))
    while que:
        n, p = que.popleft()
        for nn, nv in edges[n]:
            if nn == p: continue
            L[nn] = L[n] + nv
            que.append((nn, n))


def main():
    q, k = [int(_) for _ in input().split()]
    w(k)
    for i in range(q):
        a, b = [int(_) for _ in input().split()]
        print(L[a] + L[b])

if __name__ == '__main__':
    main()

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

N = int(input())

G = [[] for _ in range(N + 1)]
for i in range(N - 1):
    a, b, c = [int(_) for _ in input().split()]
    G[a].append((b, c))
    G[b].append((a, c))
Q, K = [int(_) for _ in input().split()]

# make tree
G2 = [-1] * (N + 1)


def f(v, c, p):
    if G2[v] != -1: return
    G2[v] = c

    for nv, nc in G[v]:
        if nv == p: continue
        f(nv, nc + c, v)


f(K, 0, 0)

for i in range(Q):
    x,y = [int(_) for _ in input().split()]
    print(G2[x]+G2[y])
Problem p02759 (python)

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

Buggy submission (verdict: Runtime Error):
s=input()
if s+%2==0:
  print(s/2)
  else:
    print((s+1)/2)
Problem p02881 (python)

Fixed submission:
import math
N=int(input())
list=[]#素因数の格納
for i in range(1,int(math.sqrt(N))+2):
    if N//i==N/i:
        list.append(N//i+i)
print(min(list)-2)

Buggy submission (verdict: Runtime Error):
import math
N=int(input())
list=[]#素因数の格納
for i in range(1,int(math.sqrt(N))):
    if N//i==N/i:
        list.append(N//i+i)
print(min(list)-2)
Problem p02862 (python)

Fixed submission:
#組み合わせ総数
mod = 10 ** 9 + 7
def comb(n, k):
    res = 1
    for i in range(n - k + 1, n + 1):
        res = res * i % mod
    for i in range(1, k + 1):
        res = res * pow(i, mod - 2, mod) % mod
    return res

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

if (x + y) % 3 != 0:
    print(0)
    exit()

m = (2 * x - y) // 3
n = x - 2 * m

if n >= 0 and m >= 0:
    print(comb(m + n,min(m,n)))
else:
    print(0)

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

x,y = map(int,input().split())
dp = [[0] * (y + 1) for _ in range(x + 1)]
dp[0][0] = 1

que = deque()
a = 0
b = 0
que.append([a,b])

while a != x or b != y:
    if not que:
        break
    else:
        a,b = que.popleft()
    if a + 1 <= x and b + 2 <= y:
        que.append([a + 1,b + 2])
        dp[a + 1][b + 2]+=dp[a][b]
        dp[a + 1][b + 2]%=mod
    if a + 2 <= x and b + 1 <= y:
        que.append([a + 2,b + 1])
        dp[a + 2][b + 1]+=dp[a][b]
        dp[a + 2][b + 1]%=mod

print(dp[x][y]%mod)
Problem p02990 (python)

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

def modcomb(n, k):
    x, y = 1, 1
    for i in range(k):
        x = x * (n - i) % mod
        y = y * (k - i) % mod
    return x * pow(y, mod - 2, mod) % mod

n, k = map(int, input().split())

for i in range(1, k + 1):
    #入れる場所
    print(int(modcomb(n - k + 1, i) * modcomb(k - 1, i - 1)) % mod)
    #分け方

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

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n, k = map(int, input().split())

for i in range(1, k + 1):
    print(int(cmb(n - k + 1, i) * cmb(k - 1, i - 1)) % mod)
Problem p03072 (python)

Fixed submission:
N = int(input())
h = list(map(int,input().split()))
mx = 0
ans = 0
for i in h:
    if mx <= i:
        ans += 1
        mx = i
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
h = map(int,input().split())
mx = h[0]
ans = 1
for i in range(1,N):
    if h[i] >= mx:
        mx = h[i]
        ans += 1
print(ans)
Problem p03107 (python)

Fixed submission:
s = str(input())
cntz = 0
cnto = 0
for i in s:
    if i == '0':
        cntz += 1
    elif i == '1':
        cnto += 1
ans = 2*min(cnto,cntz)
print(ans)

Buggy submission (verdict: Runtime Error):
s = str(input())
n = s.size()
cntz = 0
cnto = 0
for i in range(n):
    if s[i] == '0':
        cntz += 1
    elif s[i] == '1':
        cnto += 1
print(min(cnto,cntz))
Problem p03135 (python)

Fixed submission:
import numpy as np
T,X = map(int, input().split())
print(T/X*1.00000)

Buggy submission (verdict: Runtime Error):
import numpy as np
T,X = map(int, input().split())
print(T/x*1.00000)
Problem p03250 (python)

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


ans = max(A*10 + B + C, B*10 + A + C, C*10 + A + B)
print(ans)

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


ans = max(A*10 + B + C, B*10 + A + C, C*10 + A + B)
print(ans)

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


int ans = max(A*10 + B + C, B*10 + A + C, C*10 + A + B)
print(ans)

Buggy submission (verdict: Runtime Error):
data = int(input().split())

int A = data[0]
int B = data[1]
int C = data[2]

int ans = max(A*10 + B + C, B*10 + A + C, C*10 + A + B)
print(ans)

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

int ans = max(A*10 + B + C, B*10 + A + C, C*10 + A + B)
print(ans)

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

int D = max(A, B, C)

if A == D :
  print(A * 10 + B + c)
  
elif B == D:
  print(B * 10 + A + C)
  
elif C == D
  print(C * 10 + A + B)

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

int D = max(A, B, C)

if A == D :
  print(A * 10 + B + c)
  
elif B == D:
  print(B * 10 + A + C)
  
elif C == D
  print(C * 10 + A + B)

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

int D = max(A, B, C)

if A == D :
  print(A * 10 + B + c)
  
elif B == D:
  print(B * 10 + A + C)
  
elif C == D
  print(C * 10 + A + B)

Buggy submission (verdict: Runtime Error):
A, B, C = int(input[])

int D = max(A, B, C)

if A == D :
  print(A * 10 + B + c)
  
elif B == D:
  print(B * 10 + A + C)
  
elif C == D
  print(C * 10 + A + B)

Buggy submission (verdict: Runtime Error):
A, B, C = (int(x) for x in input().split())

int D = max(A, B, C)

if A == D :
  print(A * 10 + B + c)
  
elif B == D:
  print(B * 10 + A + C)
  
elif C == D
  print(C * 10 + A + B)

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

int D = max(A, B, C)

if A == D :
  print(A * 10 + B + c)
  
elif B == D:
  print(B * 10 + A + C)
  
elif C == D
  print(C * 10 + A + B)

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

int D = max(A, B, C)

if A == D :
  print(A * 10 + B + c)
  
elif B == D:
  print(B * 10 + A + C)
  
elif C == D
  print(C * 10 + A + B)

Buggy submission (verdict: Runtime Error):
A, B, C = int(input())

int D = max(A, B, C)

if A == D :
  print(A * 10 + B + c)
  
elif B == D:
  print(B * 10 + A + C)
  
elif C == D
  print(C * 10 + A + B)

Buggy submission (verdict: Runtime Error):
A, B, C = int(input())

int D = max(A, B, C)

if A == D :
  print(A * 10 + B + c)
  
elif B == D:
  print(B * 10 + A + C)
  
else :
  print(C * 10 + A + B)

Buggy submission (verdict: Runtime Error):
A, B, C = int(input())

int D = max(A, B, C)

if A == D :
  print(A * 10 + B + c)
  
elif B == D:
  print(B * 10 + A + C)
  
else :
  print(C * 10 + A + B)
Problem p03221 (python)

Fixed submission:
N, M = map(int, input().split())
A = []
Plst = [list() for _ in range(N)]
dic = {}
for i in range(M):
    P, Y = map(int, input().split())
    A.append([i, P, Y])
    Plst[P - 1].append(Y)
    dic[(P, Y)] = 0
for i in range(N):
    Plst[i].sort()
    for j in range(len(Plst[i])):
        s = str(str(i + 1).zfill(6) + str(j + 1).zfill(6))
        dic[(i, Plst[i][j])] = s
for e in A:
    print(dic[(e[1] - 1, e[2])])

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <iomanip>
using namespace std;

int main()
{
    int N, M; cin >> N >> M;

    vector< pair<int, int> > rawInput(M);
    vector<vector<int> > prifList(N);
    map<pair<int, int>, int> answer;

    for(int i = 0; i < M; ++i)
    {
        int P, Y; cin >> P >> Y;
        rawInput.at(i) = make_pair(P, Y);
        prifList.at(P - 1).push_back(Y);
        answer[make_pair(P, Y)] = 0;
    }

    for(int i = 0; i < N; ++i)
    {
        sort(prifList.at(i).begin(), prifList.at(i).end());
        for(int j = 0; j < prifList.at(i).size(); ++j)
        {
            answer[make_pair(i+1, prifList[i][j])] = j + 1;
        }
    }
    for(int i = 0; i < M; ++i)
    {
        cout << setw(6) << setfill('0') << rawInput.at(i).first;
        cout << setw(6) << setfill('0') << answer[rawInput.at(i)] << '\n';
    }
    return 0;
}
Problem p03317 (python)

Fixed submission:
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
print(math.ceil((N - 1) / (K - 1)))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
count = 0
for i in range(int(N / (K - 1))):
    if i * (K - 1) + K <= N - 1:
        m = min(A[i * (K - 1):i * (K - 1) + K])
        for j in range(i * (K - 1), i * (K - 1) + K):
            A[j] = m
        count += 1
    else:
        m = min(A[N - K:N])
        for j in range(N - K, N):
            A[j] = m
    print(A)
count += 1
A.reverse()
a = 0
for i in range(1, N):
    if A[i] != A[0]:
        a = i
        break
if a != 0:
    count += int((N - a) / (K - 1))
print(count)
Problem p03634 (python)

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


class Solve():
    def __init__(self):
        self.N = int(input())
        self.route = [dict() for _ in range(self.N)]
        for _ in range(self.N - 1):
            a, b, c = map(int, input().split())
            self.route[a - 1][b - 1] = c
            self.route[b - 1][a - 1] = c
        self.Q, self.K = map(int, input().split())
        self.K -= 1
        self.query = []
        for _ in range(self.Q):
            x, y = map(int, input().split())
            self.query.append([x - 1, y - 1])
        self.depth = [0 for _ in range(self.N)]

    def DFS(self, v, p, d):
        self.depth[v] = d
        for dest, cost in self.route[v].items():
            if dest == p:
                continue
            self.DFS(dest, v, d + cost)

    def execute(self):
        self.DFS(self.K, -1, 0)
        for x, y in self.query:
            print(self.depth[x] + self.depth[y])


if __name__ == '__main__':
    Solve().execute()

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


class Solve():
    def __init__(self):
        self.N = int(input())
        self.route = [dict() for _ in range(self.N)]
        for _ in range(self.N - 1):
            a, b, c = map(int, input().split())
            self.route[a - 1][b - 1] = c
            self.route[b - 1][a - 1] = c
        self.Q, self.K = map(int, input().split())
        self.K -= 1
        self.query = []
        for _ in range(self.Q):
            x, y = map(int, input().split())
            self.query.append([x - 1, y - 1])
        self.depth = [0 for _ in range(self.N)]

    def DFS(self, v, p, d):
        self.depth[v] = d
        for dest, cost in self.route[v].items():
            if dest == p:
                continue
            self.DFS(dest, v, d + cost)

    def execute(self):
        self.DFS(self.K, -1, 0)
        for x, y in self.query:
            print(self.depth[x] + self.depth[y])


if __name__ == '__main__':
    Solve().execute()

Buggy submission (verdict: Runtime Error):
class Solve():
    def __init__(self):
        self.N = int(input())
        self.route = [dict() for _ in range(self.N)]
        for _ in range(self.N - 1):
            a, b, c = map(int, input().split())
            self.route[a - 1][b - 1] = c
            self.route[b - 1][a - 1] = c
        self.Q, self.K = map(int, input().split())
        self.K -= 1
        self.query = []
        for _ in range(self.Q):
            x, y = map(int, input().split())
            self.query.append([x - 1, y - 1])
        self.depth = [float('inf') for _ in range(self.N)]

    def DFS(self, v, p, d):
        self.depth[v] = d
        for dest, cost in self.route[v].items():
            if dest == p:
                continue
            self.DFS(dest, v, d + cost)

    def execute(self):
        self.DFS(self.K, -1, 0)
        for x, y in self.query:
            print(self.depth[x] + self.depth[y])


if __name__ == '__main__':
    ans = Solve()
    ans.execute()
Problem p03775 (python)

Fixed submission:
from math import sqrt, floor
N = int(input())
a = 1
for i in range(2, floor(sqrt(N)) + 10):
    if N % i == 0:
        a = i

print(max(len(str(a)), len(str(N // a))))

Buggy submission (verdict: Runtime Error):
from math import sqrt, floor
from functools import reduce


def factorization(N):
    s = floor(sqrt(N))
    result = []
    for i in range(2, s + 1):
        if N % i == 0:
            r = 0
            while(N % i == 0):
                N //= i
                r += 1
            result += [i] * r
    if result == []:
        result = [1, N]
    return result


N = int(input())
p = factorization(N)
a = int(reduce(lambda x, y: x * y, p[0::2]))
b = int(reduce(lambda x, y: x * y, p[1::2]))

print(max(len(str(a)), len(str(b))))
Problem p02753 (python)

Fixed submission:
total = input()
a = total[0]
b = total[1]
c = total[2]
if a != b:
  print("Yes")
elif b != c:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n, b_n, r_n = input().split()
b= "b" * int(b_n)
r = "r" * int(r_n)

total = (b + r) * int(n)
total = total[:int(n)]

b_n2 = 0
for _ in total:
  if _ == "b":
    b_n2 += 1
  
print(str(b_n2))
Problem p02754 (python)

Fixed submission:
n, b, r = map(int, input().split())

c = b + r

print(b*(n//c) + min(n % c, b))

Buggy submission (verdict: Runtime Error):
n, b_n, r_n = input().split()
b= "b" * int(b_n)
r = "r" * int(r_n)

total = (b + r) * int(n)
total = total[:int(n)]

b_n2 = 0
for _ in total:
  if _ == "b":
    b_n2 += 1
  
print(b_n2)

Buggy submission (verdict: Runtime Error):
n, b_n, r_n = input().split()
b= "b" * int(b_n)
r = "r" * int(r_n)

total = (b + r) * int(n)
total = total[:int(n)]

b_n2 = 0
for _ in total:
  if _ == "b":
    b_n2 += 1
  
print(b_n2)
Problem p02729 (python)

Fixed submission:
N,M=map(int,input().split())
ans=N*(N-1)//2+M*(M-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=list(map,int().split())
print(n*(n-1)//2+m*(m-1)//2)
Problem p02753 (python)

Fixed submission:
check=str(input())
if check=="AAA" or check=="BBB":
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
S=str(input())
Q=int(input())
which=0
front=""
back=""
for i in range(Q):
    a=list(map(str,input().split()))
    if a==["1"]:
        which+=1
        which%=2
        continue
    else:
        if which==0:
            if a[1]=="1":
                front=a[2]+front
            if a[1]=="2":
                back+=a[2]
        if which==1:
            if a[1]=="1":
                back+=a[2]
            if a[1]=="2":
                front=a[2]+front
S=front+S+back
if which==1:
    print(S[::-1])
if which==0:
    print(S)
Problem p02757 (python)

Fixed submission:
#E
N,P=map(int,input().split())
S=input()
ans=0
if P in (2,5):
    for i,s in enumerate(S):
        if int(s)%P==0:
            ans+=i+1
else:
    cnt=[0 for _ in range(P)]
    CS=0
    PLC=1
    for s in S[::-1]:
        tmp=(int(s)*PLC)%P
        CS=(CS+tmp)%P
        cnt[CS]+=1
        PLC=(PLC*10)%P
        # print(CS)
        # print(cnt)
    for c in cnt:
        ans+=c*(c-1)//2
    ans+=cnt[0]
print(ans)

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

if P!=2 and P!=5:
    for i in range(0,N):
        chec=S[i]
        j=0
        while i+j<N:
          　　　chec%=P
                if chec==0:
                    count+=1
                j+=1
                if i+j<N:
                    chec=chec*10+S[i+j]
if P==2:
    for i in range(N):
        if S[i]%2==0:
            count+=i+1
if P==5:
    for i in range(N):
        if S[i]==0 or S[i]==5:
            count+=i+1
print(count)
Problem p02831 (python)

Fixed submission:
A,B=map(int,input().split())
x=min(A,B)
y=max(A,B)
check=1
##x<=y
#####while break##############
if y%x==0:
    print(y)
#print(root)
else:
    #root=round((x**(1/2)))
    while True:
        through=0
        for i in range(2,int(x)):
            if x%i==0 and y%i==0:
                x/=i
                y/=i
                check*=i 
                through=1
                break
        if through==0:
            break
    print(int(check*x*y))

Buggy submission (verdict: Runtime Error):
A,B=map(int,input().split())
x=min(A,B)
y=max(A,B)
check=1
##x<=y
#####while break##############
if y%x==0:
    print(y)
root=round((x**(1/2)))
#print(root)
else:
    for i in range(2,root):
        if x%i==0 and y%i==0:
            x/=i
            y/=i
            check*=i 
       # print(check)
        i=2
    #print(x,y)
        root=round((x**(1/2)))
    print(int(check*x*y))
Problem p02862 (python)

Fixed submission:
X,Y=map(int,input().split())
mod=10**9+7
"""2a+b=X 2b+a=Yを満たすabの並び替え"""
###a+b=(X+Y)/3,a-b=X-Y
###a,b>=0 かつ X+Y(mod3)==0
if (X+Y)%3!=0:
    print("0")##immposible
else:
    a=min(((X+Y)//3+(X-Y))//2,((X+Y)//3-(X-Y))//2)
    b=max(((X+Y)//3+(X-Y))//2,((X+Y)//3-(X-Y))//2)
    ###(a+b)combination a
    c=1
    d=1
    if a>0 and b>=0:
        for i in range(a):
            c*=(a+b-i)
            c=c%mod
            d*=(i+1)
            d=d%mod
        print((c*pow(d,mod-2,mod))%mod)
    elif a==0 and b>0:
        print("1")
    else:
        print("0")

Buggy submission (verdict: Runtime Error):
X,Y=map(int,input().split())
mod=10**9+7
"""2a+b=X "2b+a=Yを満たすabの並び替え"""
###a+b=(X+Y)/3,a-b=X-Y
###a,b>=0 かつ X+Y(mod3)==0
if (X+Y)%3!=0:
    print("0")##immposible
else:
    a=((X+Y)//3+(X-Y))/2
    b=((X+Y)//3-(X-Y))/2
    ###(a+b)combination a!
    a=min(a,b)
    b=max(a,b)
    c=1
    d=1
    if a>0 and b>=0:
        for i in range(a):
            c*=(a+b-i)
            c=c%mod
            d*=(i+1)
            d=d%mod
        print((c*pow(d,mod-2,mod))%mod)
    elif a==0 and b>0:
        for i in range(b):
            c*=(b-i)
            c=c%mod
        print(c)
    else:
        print("0")

Buggy submission (verdict: Runtime Error):
X,Y=map(int,input().split())
mod=10**9+7
"""2a+b=X "2b+a=Yを満たすabの並び替え"""
###a+b=(X+Y)/3,a-b=X-Y
###a,b>=0 かつ X+Y(mod3)==0
if (X+Y)%3!=0:
    print("0")##immposible
else:
    a=((X+Y)//3+(X-Y))/2
    b=((X+Y)//3-(X-Y))/2
    ###(a+b)combination a!
    a=min(a,b)
    b=max(a,b)
    c=1
    d=1
    if a>0 and b>=0:
        for i in range(a):
            c*=(a+b-i)
            c=c%mod
            d*=(i+1)
            d=d%mod
        print((c*pow(d,mod-2,mod))%mod)
    elif a==0 and b>0:
        for i in range(b):
            c*=(b-i)
            c=c%mod
            print(c)
    else:
        print("0")
Problem p02836 (python)

Fixed submission:
S = input()
lis = list(S)
lis_rev = list(S)
lis_rev.reverse()
cnt = 0

for i in range(len(lis) // 2):
    if lis[i] != lis_rev[i]:
        cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
S = input()
lis = list(S)
lis_rev = list(S)
lis_rev.reverse()
cnt = 0

lgh = 

for i in range(len(lis) // 2):
    if lis[i] != lis_rev[i]:
        cnt += 1
print(cnt)
Problem p02847 (python)

Fixed submission:


S = input()


week = {
  "MON": 1,
  "TUE": 2,
  "WED": 3,
  "THU": 4,
  "FRI": 5,
  "SAT": 6
}

if S == "SUN":
  print(7)
else:
  print(7 - week[S])

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

week = {
  "MON": 1,
  "TUE": 2,
  "WED": 3,
  "THU": 4,
  "FRI": 5,
  "SAT": 6
}

if __name__ == "main":
  if S == "SUN":
    return 7
  else:
    return 7 - week[S]
Problem p02915 (python)

Fixed submission:
N = int(input())

print(N**3)

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

return N^3

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

return N^3
Problem p02729 (python)

Fixed submission:
def compute_fact(n):
    global f
    if(n < 2):
        f = [1,1]
    else:
        f = [0 for i in range(n+1)]
        f[0] = 1
        f[1] = 1
        for i in range(2,n+1):
            f[i] = f[i-1]*i

def compute_c(n,r):
    compute_fact(n)
    ans = f[n]/(f[r] * f[n-r])
    return ans

n,m = [int(s) for s in input().split()]
if n >= 2 and m >= 2:
    print(int(compute_c(n,2) + compute_c(m,2)))
elif n >= 2:
    print(int(compute_c(n,2)))
elif m >= 2:
    print(int(compute_c(m,2)))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
def compute_fact(n):
    global f
    f = [0 for i in range(n+1)]
    f[0] = 1
    f[1] = 1
    for i in range(2,n+1):
        f[i] = f[i-1]*i

def compute_c(n,r):
    compute_fact(n)
    ans = f[n]/(f[r] * f[n-r])
    return ans

n,m = [int(s) for s in input().split()]
print(int(compute_c(n,2) + compute_c(m,2)))
Problem p02729 (python)

Fixed submission:
s,t=(int(x) for x in input().split())
print(int(s*(s-1) /2 + t*(t-1)/2))

Buggy submission (verdict: Runtime Error):
s=input()
s = int(s)
t=input()
t = int(t)
print(s*(s-1) /2 + t*(t-1)/2)
Problem p02879 (python)

Fixed submission:
x,y =map(int,input().split())

if x > 9:
    print(-1)

elif y > 9:
    print(-1)

else:
    print(x*y)

Buggy submission (verdict: Runtime Error):
x = int(input())
y = int(input())
if x > 9:
    print(-1)

elif y > 9:
    print(-1)

else:
    print(x*y)
Problem p02862 (python)

Fixed submission:
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

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

mod = 10**9+7 #出力の制限
g1 = [1]*(x+y) # 元テーブル
g2 = [1]*(x+y) #逆元テーブル
inverse = [1]*(x+y)
inverse[0] = 1

if (x+y)%3 != 0 :
  print(0)
else:
  n = (x + y) // 3
  if x >= n and y >= n:
    a = x - n
    b = y - n
    
    for i in range(2, n + 1):
      g1[i]=( g1[i-1] * i ) % mod 
      inverse[i]=( -inverse[mod % i] * (mod//i) ) % mod 
      g2[i]=(g2[i-1] * inverse[i]) % mod
    
    answer = cmb(a+b,a,mod)
    print(answer)
  else:
    print(0)

Buggy submission (verdict: Runtime Error):
import math

X , Y =map(int,input().split())
X1=X
Y1=Y
x=0
y=0
if(X>Y):
    x=X-Y
    X1-=2*x
    Y1-=x
else:
    y=Y-X
    X1-=y
    Y1-=2*y
if(X1<0 or Y1<0 or X1%3!=0 or Y1%3!=0):
    print(0)
x+=X1//3
y+=X1//3


print((math.factorial(x+y)//(math.factorial(x)*math.factorial(y)))//((10**9)+7))

Buggy submission (verdict: Runtime Error):
import math

X , Y =map(int,input().split())
X1=X
Y1=Y
x=0
y=0
if(X>Y):
    x=X-Y
    X1-=2*x
    Y1-=x
else:
    y=Y-X
    X1-=y
    Y1-=2*y
if(X1<0 or Y1<0 or X1%3!=0 or Y1%3!=0):
    print(0)
x+=X1//3
y+=X1//3


print((math.factorial(x+y)//(math.factorial(x)+math.factorial(y)))//((10**9)+7))