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

Fixed submission:
import sys
input = sys.stdin.readline
from operator import itemgetter

lis = []
n = 0
m = 0
ans = 0

def dfs(i, d, fr, used):
    global lis, ans
    if i in used:
        return
    if d == n - 1:
        ans += 1
        return
    for j in lis[i]:
        if j != fr:
            used.append(i)
            # print(i+1 , j+1)
            dfs(j, d+1, i, used)
            used.pop()


def main():
    global lis, n, m, ans
    n, m = map(int, input().strip().split())
    lis = [[] for _ in range(8)]
    for _ in range(m):
        a, b = list(map(lambda x: x-1, map(int, input().strip().split())))
        lis[a].append(b)
        lis[b].append(a)
    # print("##")
    dfs(0, 0, -1, [])
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from operator import itemgetter
import itertools

def main():
    n, m = map(int, input().strip().split())
    lis = [[] for _ in range(n)]
    for _ in range(m):
        a, b = list(map(lambda x: x-1, map(int, input().strip().split())))
        lis[a].append(b)
        lis[b].append(a)
    ans = 0
    for path in itertools.permutations(range(8), 8):
        if all(path[i+1] in lis[path[i]] for i in range(n-1)):
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from operator import itemgetter
import itertools

def main():
    n, m = map(int, input().strip().split())
    lis = [[] for _ in range(n)]
    for _ in range(m):
        a, b = list(map(lambda x: x-1, map(int, input().strip().split())))
        lis[a].append(b)
        lis[b].append(a)
    ans = 0
    for path in itertools.permutations(range(8), 8):
        if all(path[i+1] in lis[path[i]] for i in range(n-1)):
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()
Problem p02627 (python)

Fixed submission:
x=input()

if x.isupper() is True:
    print("A")
else:
    print("a")

Buggy submission (verdict: Runtime Error):
x=input()
if x.isupper() is True:
    print(A)
else:
    print(a)
Problem p02753 (python)

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

Buggy submission (verdict: Runtime Error):
S=input()
if S="AAA" or S="BBB":
    print("No")
else:
    print("Yes")
Problem p02935 (python)

Fixed submission:
n=int(input())
v1=map(int,input().split())
v=list(v1)
#価値の低いものから順に平均をとっていけばよい
for i in range(n):
    for j in range(i+1,n):
        if v[i]>v[j]:
            a=v[i]
            v[i]=v[j]
            v[j]=a
for l in range(n-1):
    v2=[]
    a=(v[0]+v[1])/2
    v2.append(a)
    v2=v2+v[2:n]
    v=v2
print(v[0])

Buggy submission (verdict: Runtime Error):
n=int(input())
v1=map(int,input().split())
v=list(v1)
for i in range(n):
    for j in range(i+1,n):
        if v[i]>v[j]:
            a=v[i]
            v[i]=v[j]
            v[j]=a
for l in range(n-1):
    a=(v[0]+v[1])/2
    v=a+v[2,n-l]
print(v[0])

Buggy submission (verdict: Runtime Error):
n=int(input())
v1=map(int,input().split())
v=list(v1)
#価値の低いものから順に平均をとっていけばよい
for i in range(n):
    for j in range(i+1,n):
        if v[i]>v[j]:
            a=v[i]
            v[i]=v[j]
            v[j]=a
for l in range(n-1):
    a=(v[0]+v[1])/2
    v=a+v[2,n-l]
print(v[0])
Problem p03041 (python)

Fixed submission:
n,k=map(int,input().split())
s=input()

s=s[:k-1]+s[k-1].lower()+s[k:]

print(s)

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

print(s[:k-1]+s[k-1]>lower()+s[k])

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

s1=s[:k+1]
s2=s[k+1]
s3=s[k+2:]

if s2=="A":
    s2="a"
elif s2=="B":
    s2="b"
else:
    s2="c"

print(s1+s2+s3)
Problem p02689 (python)

Fixed submission:
def main():
    N, M, *HAB = map(int, open(0).read().split())
    H = [0]*N
    for i in range(N):
        H[i] = HAB[i]
    A, B = [0]*M, [0]*M
    for i in range(M):
        A[i] = HAB[N + 2 * i + 0] - 1
        B[i] = HAB[N + 2 * i + 1] - 1
    # print(N, M, H, A, B)
    ans = set()
    for i in range(M):
        a = A[i]
        b = B[i]
        ha = H[a]
        hb = H[b]
        if ha < hb:
            ans.add(a)
        elif hb < ha:
            ans.add(b)
        else:
            ans.add(a)
            ans.add(b)
    print(N - len(ans))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N, M, *HAB = map(int, open(0).read().split())
    H = [0]*N
    for i in range(N):
        H[i] = HAB[i]
    A, B = [0]*M, [0]*M
    for i in range(M):
        A[i] = HAB[N + 2 * i + 0] - 1
        B[i] = HAB[N + 2 * i + 1] - 1
    # print(N, M, H, A, B)
    ans = set()
    for i in range(M):
        a = A[i]
        b = B[i]
        ha = H[a]
        hb = H[b]
        if ha < hb:
            ans.add(a)
        elif hb < ha
            ans.add(b)
    print(N - len(ans))

if __name__ == '__main__':
    main()
Problem p02862 (python)

Fixed submission:
def gcd1(a, b):
    def calc(a, b, first, second):
        if a < b:
            a, b = b, a
        r = a % b
        q = -(a - r)//b
        if r == 0:
            return b, second
        # first += q * second
        first = [x + q * y for (x, y) in zip(first, second)]
        return calc(r, b, second, first)
    first = [1, 0]
    second = [0, 1]
    return calc(a, b, first, second)

def mod_inv(n, mod):
    table = gcd1(n, mod)
    inv = table[1][1]
    if inv < 0:
        inv += mod
    return inv

def cmb(n, r, mod):
    ans = 1
    for i in range(r):
        ans = (ans * n) % mod
        n -= 1
    ans1 = 1
    for i in range(1, r + 1):
        ans1 = (ans1 * i) % mod
    return ans * mod_inv(ans1, mod)

def main():
    m = 10**9 + 7
    X, Y = map(int, input().split())
    XY = X + Y
    min_xy = XY // 3
    max_xy = XY - min_xy
    if XY % 3 != 0:
        print(0)
        return
    if X < min_xy or X > max_xy or Y < min_xy or Y > max_xy:
        print(0)
        return
    index_x = X - min_xy
    index_y = Y - min_xy
    # print(index_x, index_y)
    ans = cmb(min_xy, index_x, m)
    print(ans % m)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
m = 10**9 + 7
X, Y = map(int, input().split())
t = [[0] * (X + 2) for i in range(Y + 2)]
for i in range(Y):
    for j in range(X):
        t[i + 1][j + 2] += t[i][j] + 1
        t[i + 2][j + 1] += t[i][j] + 1
        t[i + 1][j + 2] %= m
        t[i + 2][j + 1] %= m

print(t[Y - 1][X - 1])
Problem p03038 (python)

Fixed submission:
l = raw_input().split()
N = int(l[0])
M = int(l[1])

BC = []

l = raw_input().split()
A = [int(x) for x in l]

for i in range(M):
    l = raw_input().split()
    bc = [int(l[0]), int(l[1])]
    BC.append(bc)

A.sort()
BC.sort(key = lambda x: -x[1])
# print(N, M, A, BC)

i0 = 0
i1 = 0
for i in range(N):
    # print(BC[i0])
    b = BC[i0][0]
    c = BC[i0][1]

    if A[i] < c:
        A[i] = c
        i1 += 1
    if i1 == b:
        i0 += 1
        i1 = 0
    # print(A)
    if i0 == M:
        break

# print(A)
print(sum(A))

Buggy submission (verdict: Runtime Error):
l = raw_input().split()
N = int(l[0])
M = int(l[1])

BC = []

l = raw_input().split()
A = [int(x) for x in l]

for i in range(M):
    l = raw_input().split()
    bc = [int(l[0]), int(l[1])]
    BC.append(bc)

A.sort()
BC.sort(key = lambda x: -x[1])
# print(N, M, A, BC)

i0 = 0
i1 = 0
for i in range(N):
    # print(BC[i0])
    b = BC[i0][0]
    c = BC[i0][1]

    if A[i] < c:
        A[i] = c
        i1 += 1
    if i1 == b:
        i0 += 1
        i1 = 0
    # print(A)

# print(A)
print(sum(A))
Problem p03108 (python)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0]*(n + 1)

    def root(self, x):
        if self.par[x] == x:
            return x
        r = self.root(self.par[x])
        self.par[x] = r
        return r

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return
        if self.rank[rx] < self.rank[ry]:
            self.par[x] = ry
            self.par[rx] = ry
        else:
            self.par[y] = rx
            self.par[ry] = rx
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

def main():
    N, M, *AB = map(int, open(0).read().split())
    uf = UnionFind(N)
    elems = [1] * (N + 1)
    ans = N * (N - 1) // 2
    ANS = [0]*M
    for i in range(M):
        # print(ans)
        ANS[M - i - 1] = ans
        a = AB[2 * M - i * 2 - 2 + 0]
        b = AB[2 * M - i * 2 - 2 + 1]
        ra = uf.root(a)
        rb = uf.root(b)
        uf.unite(ra, rb)
        r = uf.root(ra)
        if ra != rb:
            era = elems[ra]
            erb = elems[rb]
            ans -= era * erb
            elems[r] = era + erb
    for ans in ANS:
        print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]

    def root(self, x):
        if self.par[x] == x:
            return x
        r = self.root(self.par[x])
        self.par[x] = r
        return r

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return
        self.par[x] = ry
        self.par[rx] = ry

def main():
    N, M, *AB = map(int, open(0).read().split())
    uf = UnionFind(N)
    elems = [1] * (N + 1)
    ans = N * (N - 1) // 2
    ANS = [0]*M
    for i in range(M):
        # print(ans)
        ANS[M - i - 1] = ans
        a = AB[2 * M - i * 2 - 2 + 0]
        b = AB[2 * M - i * 2 - 2 + 1]
        ra = uf.root(a)
        rb = uf.root(b)
        uf.unite(ra, rb)
        r = uf.root(ra)
        if ra != rb:
            era = elems[ra]
            erb = elems[rb]
            ans -= era * erb
            elems[r] = era + erb
    for ans in ANS:
        print(ans)


if __name__ == '__main__':
    main()
Problem p03776 (python)

Fixed submission:
import math

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

# print(N, A, B, V)

V.sort(reverse=True)

max_list = V[:A]
max_sum = sum(max_list)
print(max_sum / A)

replace = max_list[-1]

num_replace = 0
for v in V:
    if v == replace:
        num_replace += 1

if num_replace == 1:
    print(1)
    exit()

num_replace_in_list = 0
for v in max_list:
    if v == replace:
        num_replace_in_list += 1

if replace * A != max_sum:
    ans = math.factorial(num_replace) // (math.factorial(num_replace - num_replace_in_list) * math.factorial(num_replace_in_list))
    print(ans)
    exit()


ans = 0
for i in range(A, B + 1):
    if i > num_replace:
        break
    ans += math.factorial(num_replace) // (math.factorial(num_replace - i) * math.factorial(i))

print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

# print(N, A, B, V)

V.sort(reverse=True)

max_list = V[:A]
max_sum = sum(max_list)
print(max_sum / A)

replace = max_list[-1]

num_replace = 0
for v in V:
    if v == replace:
        num_replace += 1

if num_replace == 1:
    print(1)
    exit()

num_replace_in_list = 0
for v in max_list:
    if v == replace:
        num_replace_in_list += 1

if replace * A != max_sum:
    ans = 0
    for i in range(A, B + 1):
        # print(i, num_replace_in_list, num_replace)
        if i - A + num_replace_in_list > num_replace:
            break
        ans += math.factorial(num_replace) // (math.factorial(num_replace - i) * math.factorial(i))
    print(ans)
    exit()


ans = 0
for i in range(A, B + 1):
    if i > num_replace:
        break
    ans += math.factorial(num_replace) // (math.factorial(num_replace - i) * math.factorial(i))

print(ans)
Problem p03805 (python)

Fixed submission:
l = input().split()
N = int(l[0])
M = int(l[1])

C = [[] for i in range(N)]

for i in range(M):
    l = input().split()
    a = int(l[0]) - 1
    b = int(l[1]) - 1
    C[a].append(b)
    C[b].append(a)

# print(N, M, C)

def visit(cur, visited, ans, depth):
    depth += 1
    # print('depth={}, cur={}, visited={}, ans={}, C[cur]={}'.format(
    #     depth, cur, visited, ans, C[cur]))
    visited.append(cur)
    if len(visited) == N:
        # print('goal')
        return ans + 1
    for n in C[cur]:
        # print('n={}'.format(n))
        if n not in visited:
            v = [x for x in visited]
            ans = visit(n, v, ans, depth)
    return ans

ans = 0
for n in C[0]:
    visited = [0]
    ans += visit(n, visited, 0, 0)

print(ans)

Buggy submission (verdict: Runtime Error):
l = input().split()
N = int(l[0])
M = int(l[1])

A = []
B = []
C = [[] for i in range(N)]

for i in range(M):
    l = input().split()
    a = int(l[0]) - 1
    b = int(l[1]) - 1
    A.append(a)
    B.append(b)
    C[a].append(b)
    C[b].append(a)

# print(N, M, A, B, C)

def visit(cur, ans, visited):
    # print('cur={}, ans={}'.format(cur, ans))
    visited.append(cur)
    if cur == N - 1:
        # print('goal')
        return ans + 1
    for next in C[cur]:
        if next not in visited:
            return visit(next, ans, visited)

ans = 0
for next in C[0]:
    visited = []
    ans += visit(0, 0, visited)

print(ans)
Problem p03986 (python)

Fixed submission:
from collections import deque

X = input()

ret = deque([X[0]])
for i in range(1, len(X)):
    x = X[i]
    if x == 'S':
        ret.append(x)
    else:
        if len(ret) > 0 and ret[-1] == 'S':
            ret.pop()
        else:
            ret.append(x)
print(len(ret))

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

X = input()

ret = deque([X[0]])
for i in range(1, len(X)):
    x = X[i]
    if x == 'S':
        ret.append(x)
    else:
        if ret[-1] == 'S':
            ret.pop()
        else:
            ret.append(x)
print(len(ret))
Problem p02831 (python)

Fixed submission:
#c
a, b = map(int ,input().split())
from fractions import gcd
print(a*b//gcd(a, b))

Buggy submission (verdict: Runtime Error):
#c
a, b = map(int ,input().split())
from math import *
print(a*b//math.gcd(a, b))

Buggy submission (verdict: Runtime Error):
#c
a, b = map(int ,input().split())
import math
print(a*b//math.gcd(a, b))

Buggy submission (verdict: Runtime Error):
#c
a, b = map(int ,input().split())
import math
print(a*b//math.gcd(a, b))

Buggy submission (verdict: Runtime Error):
#c
a, b = map(int ,input().split())
from math import gcd
print(a*b//gcd(a, b))
Problem p02792 (python)

Fixed submission:
def check(a, b):
    k = 1
    res = 0
    if a == b and (a <= N): res += 1
    while True:
        if (a * (10 ** k) + b) > N:
            break
        else:
            if len(str(N)) > (k+1) or str(N)[0] > str(a):
                res += 10 ** (k - 1)
                k += 1
                continue

            else :
                Q = N - (a * (10 ** k) + b)
                p = 1
                if len(str(Q)) > 1 :
                    p += (int(str(Q)[:-1]))
                res += p
                k += 1
    return res


def main():
    global N
    N = int(input())
    ans = 0
    for i in range(1, 10, 1):
        for j in range(1, 10, 1):
            a = check(i, j)
            b = check(j, i)
            ans += a * b
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def check(a, b):
    k = 1
    res = 0
    if a == b and (a <= N): res += 1
    while True:
        if (a * (10 ** k) + b) > N:
            break
        else:
            if len(str(N)) > (k+1) or str(N)[0] > str(a):
                res += 10 ** (k - 1)
                k += 1
                continue

            else :
                Q = N - (a * (10 ** k) + b)
                p = (1 + int(str(Q)[:-1]))
                res += p
                k += 1
    return res


def main():
    global N
    N = int(input())
    ans = 0
    for i in range(1, 10, 1):
        for j in range(1, 10, 1):
            a = check(i, j)
            b = check(j, i)
            ans += a * b
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def check(a, b):
    k = 1
    res = 0
    if a == b and (a <= N): res += 1
    # print(res)
    while True:
        if (a * (10 ** k) + b) > N:
            break
        else:
            if str(N)[0] > str(a) or len(str(N)) > (k + 1):
                res += 10 ** (k - 1)
                k += 1
                continue
            p = 1
            Q = N - (a * (10 ** k) + b)
            keep = [0 for i in range(k - 2)]
            for i in range(len(str(Q)) - 1):
                keep[-1 - i] = int(str(Q)[-2 - i])
            for i in range(k - 2):
                p *= (keep[i] + 1)
            res += p
            k += 1
    return res


def main():
    global N
    N = int(input())
    ans = 0
    for i in range(1, 10, 1):
        for j in range(1, 10, 1):
            a = check(i, j)
            b = check(j, i)
            ans += a * b
    print(ans)


if __name__ == '__main__':
    main()
Problem p02847 (python)

Fixed submission:
list = ["SUN","MON","TUE","WED","THU","FRI","SAT"]
S = input()
for i in range(len(list)):
    if S == list[i] :
        print("{}".format(7 - i))

Buggy submission (verdict: Runtime Error):
N = int(input())
graph = [[] for _ in range(N)]
for i in range(N-1):
    a,b = map(int,input().split())
    graph[a-1].append((b-1,i))
    graph[b-1].append((a-1,i))
ans = 0
print(graph)
pos = 0
for i in range(N-1):
    if ans < len(graph[i]):
        ans = len(graph[i])
        pos = i
print(ans)

color = [-1 for i in range(N-1)]
def dps(now,pare,par_col=-1):
    col = 1
    for u,idx in graph[now]:
        if u != pare :
            if col == par_col :
                col += 1
            color[idx] = col
            dps(u,now,col)
            col += 1

dps(0,-1,-1)
print("\n".join(map(str,color)))
Problem p02915 (python)

Fixed submission:
N = int(input())
a = N * N * N
print("{}".format(a))

Buggy submission (verdict: Runtime Error):
N = int(input())
print("{}".foramt(N**3))
Problem p03634 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)
N = int(input())

class Edge:
    def __init__(self,to,cost):
        self.to = to
        self.cost = cost
#隣接グラフ
graph = [[] for i in range(N)]
for i in range(N-1):
    a,b,c = map(int,input().split())
    graph[a-1].append(Edge(b-1,c))
    graph[b-1].append(Edge(a-1,c))
dp = [0 for i in range(N)]

def dfs(s,pare):
    for i in graph[s]:
        if i.to != pare :
            dp[i.to] = dp[s] + i.cost
            dfs(i.to,s)
        else:
            continue 


Q,K = map(int,input().split())
dfs(K-1,-1)
for i in range(Q):
    x,y = map(int,input().split())
    print("{}".format(dp[x-1]+dp[y-1]))

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

class Edge:
    def __init__(self,to,cost):
        self.to = to
        self.cost = cost

graph = [[] for i in range(N)]
for i in range(N-1):
    a,b,c = map(int,input().split())
    graph[a-1].append(Edge(b-1,c))
    graph[b-1].append(Edge(a-1,c))
dp = [0 for i in range(N)]

def dfs(s,pare):
    for i in graph[s]:
        if i.to != pare :
            dp[i.to] = dp[s] + i.cost
            dfs(i.to,s)


Q,K = map(int,input().split())
dfs(K-1,-1)
print(dp)
for i in range(Q):
    x,y = map(int,input().split())
    print("{}".format(dp[x-1]+dp[y-1]))
Problem p03821 (python)

Fixed submission:
N = int(input())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
k = 0 
for i in range(N-1,-1,-1):
    A[i] += k
    if A[i] % B[i] == 0 :
        pass
    else :
        c = (B[i] - A[i] % B[i])
        k += c

print(k)

Buggy submission (verdict: Runtime Error):
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
k = 0 
for i in range(N-1,-1,-1):
    if A[i] % B[i] == 0 :
        continue
    else :
        c = (B[i] - A[i] % B[i])
        k += c
        for j in range(i):
            A[j] += c

print(k)
Problem p02984 (python)

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

sum_eve = sum(A[0::2])
sum_odd = sum(A[1::2])

x = [0] * n

x[0] = sum_eve - sum_odd

for num in range(1, n):
    x[num] = 2 * A[num-1] - x[num-1]
    
ans = " ".join(map(str,x))
print(ans)

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

sum_eve = sum(A[0::2])
sum_odd = sum(A[1::2])

x = [0] * n

x[0] = sum_eve - sum_odd

for num in range(1, n):
    x[num] = 2 * A[num-1] - x[num-1]
    
ans = " ".join(map(str,x))

pritn(ans)
Problem p03127 (python)

Fixed submission:
def read():
    return int(input())

def reads():
    return list(map(int, input().split()))

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

n = read()
a = reads()
ans = a[0]
for i in range(n):
    ans = gcd(ans,a[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
def read():
    return int(input())

def reads():
    return list(map(int, input().split()))

def gcd(numbers):
    return reduce(math.gcd, numbers)

n = read()
a = reads()
print(gcd(a))
Problem p03137 (python)

Fixed submission:
import numpy as np
n,m = map(int,input().split())
x = np.array(list(map(int, input().split())))
if n>= m:
    print(0)
    exit()
x.sort()
xd = sorted(np.diff(x))
print(sum(xd[:m-n]))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m = map(int,input().split())
x = np.array(list(map(int, input().split())))
if n>= m:
    print(0)
    exit()
x.sort()
xd = sorted(np.diff(x))
print(sum(xd[:m-n]))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m = map(int,input().split())
x = np.array(list(map(int, input().split())))
if n>= m:
    print(0)
    exit()
x.sort()
xd = np.diff(x)
xd2=xd.tolist()
for i in range(n-1):
    xd2.remove(max(xd2))
print(sum(xd2))
Problem p02862 (python)

Fixed submission:
import math
X, Y = map(int, input().split())
p = (((X+Y)/3)+Y-X)/2
m = p+X-Y


def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod


if p % 1 != 0 or p<0 or m<0:
    ans = 0

else:
    q = p+m
    q = int(q)
    p = int(p)
    ans = comb(q,p,10**9+7)
  

print(ans)

Buggy submission (verdict: Runtime Error):
import math
X, Y = map(int, input().split())
n = (((X+Y)/3)+Y-X)/2
m = n+X-Y

if n % 1 != 0 or n<0:
    ans = 0

else:
    q = n+m
    p = math.factorial(q) % (10**9+7)
    N = math.factorial(n) % (10**9+7)
    M = math.factorial(m) % (10**9+7)
    ans = p/(N*M)
    ans = ans % (10**9+7)

print(ans//1)
Problem p02881 (python)

Fixed submission:
import math
N = int(input())
ans = N-1
n = math.sqrt(N)
n = int(n)+1
for i in range(1, n):
    if N%i==0:
        tmp = N//i
        ans = (tmp-1)+(i-1)

    
print(ans)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
ans = N-1
n = math.sqrt(N)
n = int(n)+1
for i in range(1, n)
    if N%i==0:
        tmp = N//i
        ans = (tmp-1)+(i-1)

    
print(ans)
Problem p02987 (python)

Fixed submission:
S = input()
Slist=[]
for i in range(4):
    Slist.append(S[i])
Slist.sort()

if Slist[0] == Slist[1] and Slist[2] == Slist[3] and Slist[0]!=Slist[2]:
    ans = "Yes"
else:
    ans = "No"
print(ans)

Buggy submission (verdict: Runtime Error):
import math
N, K = map(int, input().split(" "))
mod = 10**9 + 7
#p = (N-K+1)!*(K-1)!
p = math.factorial(N-K+1) * math.factorial(K-1)

for j in range(K):
    i = j+1
    #q=i!*(N-K+1+i)!*(K-i)!*(i-1)!
    q = math.factorial(i) * math.factorial(N-K+1-i) * math.factorial(K-i) * math.factorial(i-1)
    a=int((p/q)%mod)
    print(a)