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

Fixed submission:
#coding:utf-8
import sys

BAMB_NUM = 0
BAMB_A = 0
BAMB_B = 0
BAMB_C = 0
BAMB_LIST = []

def calcMP(idx, lenA, lenB, lenC):
    """
    calculate MP.
    """
    # when classified all bamboos
    if (idx == BAMB_NUM):
        return abs(lenA - BAMB_A) + abs(lenB - BAMB_B) + abs(lenC - BAMB_C) - 30 if min(lenA, lenB, lenC) > 0 else sys.maxsize
    
    # don't use idx-th bamboo
    mp1 = calcMP(idx + 1, lenA, lenB, lenC)
    # use idx-th bamboo
    mp2 = calcMP(idx + 1, lenA + BAMB_LIST[idx], lenB, lenC) + 10
    mp3 = calcMP(idx + 1, lenA, lenB + BAMB_LIST[idx], lenC) + 10
    mp4 = calcMP(idx + 1, lenA, lenB, lenC + BAMB_LIST[idx]) + 10

    return min(mp1, mp2, mp3, mp4)

if __name__ == "__main__":
    """
    http://drken1215.hatenablog.com/entry/2019/02/24/224100
    """
    # requested bamboo lengths
    BAMB_NUM, BAMB_A, BAMB_B, BAMB_C = map(lambda x: int(x), input().split())
    # available bamboo lengths
    for bamb in range(BAMB_NUM):
        BAMB_LIST.append(int(input()))

    mp = calcMP(0, 0, 0, 0)
    print(mp)

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

BAMB_NUM = 0
BAMB_A = 0
BAMB_B = 0
BAMB_C = 0
BAMB_LIST = []

def calcMP(int idx, int lenA, int lenB, int lenC):
    # classified all bamboos
    if (idx == BAMB_NUM):
        # exists a zero length bamboo
        if (lenA <= 0 or lenB <= 0 or lenC <= 0):
            return sys.maxsize
        return abs(lenA - BAMB_A) + abs(lenB - BAMB_B) + abs(lenc - BAMB_C)
    
    # don't use idx-th bamboo
    mp = calcMP(idx+1, lenA, lenB, lenC)

    # use idx-th bamboo
    mp = min(mp, calcMP(lenA + BAMB_LIST[idx], lenB, lenC) + (BAMB_A > 0 ? 10 : 0))
    mp = min(mp, calcMP(lenA, lenB + BAMB_LIST[idx], lenC) + (BAMB_B > 0 ? 10 : 0))
    mp = min(mp, calcMP(lenA, lenB, lenC + BAMB_LIST[idx]) + (BAMB_C > 0 ? 10 : 0))

    return mp

if __name__ == "__main__":
    """
    http://drken1215.hatenablog.com/entry/2019/02/24/224100
    """
    # requested bamboo lengths
    bamb_num, bambA, bambB, bambC = map(lambda x: int(x), input().split())
    # available bamboo lengths
    bamb_list = []
    for bamb in range(bamb_num):
        bamb_list.append(int(input()))

    mp = calcMP(0, 0, 0, 0)
    print(mp)
Problem p02783 (python)

Fixed submission:
import math
H, A = map(int, input().split(' '))
print(math.ceil(H / A))

Buggy submission (verdict: Runtime Error):
import math
H, A = input().split()
print(math.ceil(H / A))
Problem p02866 (python)

Fixed submission:
import math  # noqa
import bisect  # noqa
import queue  # noqa


if __name__ == '__main__':
    N = int(input())
    D = list(map(int, input().split()))

    # cnt[k] = v ... 深さkのノード数
    cnt = {}
    max_depth = 0
    for d in D:
        max_depth = max(max_depth, d)
        if d not in cnt:
            cnt[d] = 1
        else:
            cnt[d] += 1

    # 頂点1との距離が0になるノードは1つしか存在しない
    if D[0] != 0:
        print(0)
        exit(0)
    elif cnt[0] > 1:
        print(0)
        exit(0)

    ans = 1
    MOD = 998244353
    for i in range(0, max_depth):
        if (i not in cnt) or (i + 1 not in cnt):
            ans = 0
            break
        ans *= cnt[i] ** cnt[i + 1]
        ans %= MOD

    print(ans)

Buggy submission (verdict: Runtime Error):
import math  # noqa
import bisect  # noqa
import queue  # noqa


if __name__ == '__main__':
    N = int(input())
    D = list(map(int, input().split()))

    # cnt[k] = v ... 深さkのノード数
    cnt = {}
    max_depth = 0
    for d in D:
        max_depth = max(max_depth, d)
        if d not in cnt:
            cnt[d] = 1
        else:
            cnt[d] += 1

    # 頂点1との距離が0になるノードは1つしか存在しない
    if 0 not in cnt:
        print(0)
        exit(0)
    elif cnt[0] > 1:
        print(0)
        exit(0)

    ans = 1
    MOD = 998244353
    for i in range(0, max_depth):
        if (i not in cnt) and (i + 1 not in cnt):
            ans = 0
            break
        ans *= cnt[i] ** cnt[i + 1]
        ans %= MOD

    print(ans)

Buggy submission (verdict: Runtime Error):
import math  # noqa
import bisect  # noqa
import queue  # noqa


if __name__ == '__main__':
    N = int(input())
    D = list(map(int, input().split()))

    # cnt[k] = v ... 深さkのノード数
    cnt = {}
    max_depth = 0
    for d in D:
        max_depth = max(max_depth, d)
        if d not in cnt:
            cnt[d] = 1
        else:
            cnt[d] += 1

    # 頂点1との距離が0になるノードは1つしか存在しない
    if 0 not in cnt:
        print(0)
        exit(0)
    elif cnt[0] > 1:
        print(0)
        exit(0)

    ans = 1
    MOD = 998244353
    for i in range(0, max_depth):
        if i not in cnt:
            ans = 0
            break
        ans *= cnt[i] ** cnt[i + 1]
        ans %= MOD

    print(ans)
Problem p02882 (python)

Fixed submission:
import math

a,b,x=map(int,input().split())

if 2*x<=a*a*b:
    p1=a*b*b
    p2=2*x
else:
    p1=2*(a*a*b-x)
    p2=a*a*a

sit=math.atan(p1/p2)
print(math.degrees(sit))

Buggy submission (verdict: Runtime Error):
from math import atan, degrees


a, b, x = map(int, input().split())

if a * b / 2 * a < x:
    res = (a ** 3) / (2 * ((a ** 2) * b - x))
else:
    res = 2 * x / (a * b * b)

res = degrees(atan(1 / res))
print(res)

Buggy submission (verdict: Runtime Error):
from math import atan, pi


a, b, x = map(int, input().split())

if a * b / 2 * a < x:
    res = (a ** 3) / (2 * ((a ** 2) * b - x))
else:
    res = 2 * x / (a * b * b)

res = atan(1 / res) / pi * 180
print(res)

Buggy submission (verdict: Runtime Error):
from math import atan, pi


a, b, x = map(int, input().split())

if a * b / 2 * a < x:
    res = (a ** 3) / (2 * ((a ** 2) * b - x))
else:
    res = 2 * x / (a * b * b)

res = atan(1 / res) / pi * 180
print(res)

Buggy submission (verdict: Runtime Error):
# 過去のジャッジに言語アップデートが適用されればACする
# 2020.04.18

from math import atan, pi


a, b, x = map(int, input().split())

if a * b / 2 * a <= x:
    res = (a ** 3) / (2 * ((a ** 2) * b - x))
else:
    res = 2 * x / (a * b * b)

res = atan(1 / res) / pi * 180
print(res)

Buggy submission (verdict: Runtime Error):
from math import atan, pi


a, b, x = map(int, input().split())

if a * b / 2 * a <= x:
    res = (a ** 3) / (2 * ((a ** 2) * b - x))
else:
    res = 2 * x / (a * b * b)

res = atan(1 / res) / pi * 180
print(res)

Buggy submission (verdict: Runtime Error):
from math import atan, pi


a, b, x = map(int, input().split())

res = (a ** 3) / (2 * ((a ** 2) * b - x))

res = atan(1 / res) / pi * 180
print(res)

Buggy submission (verdict: Runtime Error):
from math import atan, pi


a, b, x = map(int, input().split())

res = (a ** 3) / (2 * ((a ** 2) * b - x))

res = atan(1 / res) / pi * 180
print(res)
Problem p02917 (python)

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

B = B + [B[-1]]
B = B[::-1]
A = []
for i in range(0, N - 1):
    A.append(min(B[i], B[i + 1]))
A.append(B[-1])

print(sum(A))

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

# a1 a2 a3 a4 a5
# b1 b2 b3 b4

# b1 b2 b3 b4 b4

A = (B + [B[-1]]).copy()
for i in range(0, N - 1):
    a1 = A[i]
    a2 = A[i + 1]
    if (a1 < a2 and a1 == B[i]):
        A[i + 1] = a1
A[-1] = B[-1]

print(sum(A))
Problem p02928 (python)

Fixed submission:
import bisect


if __name__ == '__main__':
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    # 自分より数値が小さい数の個数
    # 1, 3, 2 --> [0, 2, 1]
    B = A.copy()
    B.sort()
    cnt = [0 for _ in range(N)]
    for i, a in enumerate(A):
        idx = bisect.bisect_left(B, a)
        cnt[i] = idx

    ans = 0
    MOD = 1000000007
    for c in cnt:
        ans += c * (K - 1) * K // 2
        ans %= MOD

    # 自分より後ろに存在する自分より小さい数の個数
    # 1, 3, 2 --> [0, 1, 0]
    B = A.copy()
    B = B[::-1]
    cnt = [0 for _ in range(N)]
    array = []
    for i, b in enumerate(B):
        idx = bisect.bisect_left(array, b)
        cnt[i] = idx
        bisect.insort_left(array, b)
    cnt = cnt[::-1]

    for c in cnt:
        ans += c * K
        ans %= MOD

    print(ans)

Buggy submission (verdict: Runtime Error):
import bisect


if __name__ == '__main__':
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    # 自分より数値が小さい数の個数
    # 1, 3, 2 --> [0, 2, 1]
    B = A.copy()
    B.sort()
    cnt = [0 for _ in range(N)]
    for i, a in enumerate(A):
        idx = bisect.bisect_left(B, a)
        cnt[i] = idx

    ans = 0
    MOD = 1000000007
    for c in cnt:
        ans += c * (K - 1) * K // 2
        ans %= MOD

    # 自分より後ろに存在する自分より小さい数の個数
    # 1, 3, 2 --> [0, 1, 0]
    B = A.copy()
    B = B[::-1]
    cnt = [0 for _ in range(N)]
    array = []
    for i, b in enumerate(B):
        idx = bisect.bisect_left(array, b)
        cnt[i] = idx
        bisect.insort_left(array, b)
    cnt = cnt[::-1]

    for c in cnt:
        ans += c * K
        ans %= MOD

    print(ans)
Problem p02995 (python)

Fixed submission:
import fractions

A, B, C, D = map(int, input().split())
E = (C * D) // fractions.gcd(C, D)
num_c = B // C - A // C + (1 if A % C == 0 else 0)
num_d = B // D - A // D + (1 if A % D == 0 else 0)
num_e = B // E - A // E + (1 if A % E == 0 else 0)
num = B - A + 1 - (num_c + num_d - num_e)
print(num)

Buggy submission (verdict: Runtime Error):
import math

A, B, C, D = map(int, input().split())
E = (C * D) // math.gcd(C, D)
num_c = B // C - A // C + (1 if A % C == 0 else 0)
num_d = B // D - A // D + (1 if A % D == 0 else 0)
num_e = B // E - A // E + (1 if A % E == 0 else 0)
num = B - A + 1 - (num_c + num_d - num_e)
print(num)

Buggy submission (verdict: Runtime Error):
import math

A, B, C, D = map(int, input().split())
E = (C * D) // math.gcd(C, D)
# print(E)
num_c = B // C - A // C + (1 if A % C == 0 else 0)
num_d = B // D - A // D + (1 if A % D == 0 else 0)
num_e = B // E - A // E + (1 if A % E == 0 else 0)
# print(num_c)
# print(num_d)
# print(num_e)
num = B - A + 1 - (num_c + num_d - num_e)
print(num)
Problem p03001 (python)

Fixed submission:
W, H, x, y = map(float, input().split())

print('{} {}'.format(W*H/2, 1 if (x*2==W) & (y*2==H) else 0))

Buggy submission (verdict: Runtime Error):
W, H, x, y = map(float, input().split())

def calc_aspect_ratio(x, y):
    return max(x, y) / min(x, y)

# 長方形の中心で対称
if (H-y) < y:
    y = H-y

if (W-x) < x:
    x = W-x

area = 0
dup = 0

# 頂点に乗る場合対角線で分断できる
# 上記の点移動の処理により(x,y)=(0,0)しかありえない
if (x == 0) & (y == 0):
    area = W * H / 2

# 辺xに点が乗っている場合
elif (x != 0) & (y == 0):
    area = x * H

# 辺yに点が乗っている場合
elif (y == 0) & (y != 0):
    area = y * W

# 内点の場合
else:
    aspect_rect = calc_aspect_ratio(W, H)
    aspect_point = calc_aspect_ratio(x, y)

    # 対角線上に点が乗っている場合は半分に分けられる
    if aspect_rect == aspect_point:
        area = W * H / 2

        # かつ点が長方形の中心に位置する場合は二通りの分割を達成できる
        if ((H-y) == y) & ((W-x) == x):
            dup = 1
    
    # 対角線外の点の場合
    else:
        area = max(y*W, x*H)

print('{} {}'.format(area, dup))
Problem p03006 (python)

Fixed submission:
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())

    if N == 1:
        return print(1)

    X = [0 for _ in range(N)]
    Y = [0 for _ in range(N)]
    for i in range(N):
        x, y = map(int, input().split())
        X[i] = x
        Y[i] = y

    cnt = {}
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            rx = X[i] - X[j]
            ry = Y[i] - Y[j]
            if (rx, ry) not in cnt:
                cnt[(rx, ry)] = 1
            else:
                cnt[(rx, ry)] += 1
            if (-rx, -ry) not in cnt:
                cnt[(-rx, -ry)] = 1
            else:
                cnt[(-rx, -ry)] += 1

    cnt = [[v, k] for k, v in cnt.items()]
    cnt.sort(reverse=True)
    res = N - cnt[0][0] // 2
    print(res)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    X = [0 for _ in range(N)]
    Y = [0 for _ in range(N)]
    for i in range(N):
        x, y = map(int, input().split())
        X[i] = x
        Y[i] = y

    cnt = {}
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            rx = X[i] - X[j]
            ry = Y[i] - Y[j]
            if (rx, ry) not in cnt:
                cnt[(rx, ry)] = 1
            else:
                cnt[(rx, ry)] += 1
            if (-rx, -ry) not in cnt:
                cnt[(-rx, -ry)] = 1
            else:
                cnt[(-rx, -ry)] += 1

    cnt = [[v, k] for k, v in cnt.items()]
    cnt.sort(reverse=True)
    res = N - cnt[0][0] // 2
    print(res)


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

Fixed submission:
import math  # noqa
import bisect  # noqa
import queue  # noqa


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    cnt_neg = 0
    abs_min = 1000000005
    for a in A:
        abs_min = min(abs_min, abs(a))
        if a < 0:
            cnt_neg += 1

    ans = 0
    for a in A:
        ans += abs(a)

    if cnt_neg % 2 != 0:
        ans -= 2 * abs_min

    print(ans)

Buggy submission (verdict: Runtime Error):
import math  # noqa
import bisect  # noqa
import queue  # noqa


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    cnt_neg = 0
    abs_min = 1_000_000_005
    for a in A:
        abs_min = min(abs_min, abs(a))
        if a < 0:
            cnt_neg += 1

    ans = 0
    for a in A:
        ans += abs(a)

    if cnt_neg % 2 != 0:
        ans -= 2 * abs_min

    print(ans)
Problem p03262 (python)

Fixed submission:
from fractions import gcd

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

dX = [abs(X - x) for x in X_list]
if len(dX) == 1:
    print(dX[0])
    exit(0)

D = [abs(X_list[i] - X_list[i + 1]) for i in range(0, N - 1)]
res = D[0]
for x in D[1:]:
    res = gcd(res, x)

ans = 0
for d in dX:
    ans = max(gcd(res, d), ans)
print(ans)

Buggy submission (verdict: Runtime Error):
from fractions import gcd

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

dX = [abs(X - x) for x in X_list]
if len(dX) == 1:
    print(dX[0])
    exit(0)

D = [abs(X_list[i] - X_list[i + 1]) for i in range(0, N - 1)]
res = gcd(D[0], D[1])
for x in D[2:]:
    res = gcd(res, x)

ans = 0
for d in dX:
    ans = max(gcd(res, d), ans)
print(ans)

Buggy submission (verdict: Runtime Error):
from fractions import gcd

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

dX = [abs(X - x) for x in X_list]
if len(dX) == 1:
    print(dX[0])
    exit(0)

D = [abs(X_list[i] - X_list[i + 1]) for i in range(0, N - 1)]
res = gcd(D[0], D[1])
for x in D[2:]:
    res = gcd(res, x)

ans = 0
for d in dX:
    ans = max(gcd(res, d), ans)
print(ans)
Problem p03274 (python)

Fixed submission:
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def solve(X, K):
    N = len(X)

    cumsum = [0 for _ in range(N)]
    for i in range(1, N):
        cumsum[i] = abs(X[i] - X[i - 1]) + cumsum[i - 1]

    idx_zero = bisect.bisect_left(X, 0)

    ret = 1000000005
    for i in range(0, N):
        if X[i] >= 0:
            break
        res = -X[i]
        k = idx_zero - i
        if (k < K) and (idx_zero + K - k - 1 < N):
            res += cumsum[idx_zero + K - k - 1] - cumsum[i]
            ret = min(ret, res)

    return ret


if __name__ == '__main__':
    N, K = map(int, input().split())
    X = list(map(int, input().split()))

    res = 1000000005
    if min(X) >= 0:
        print(X[K - 1])
    elif max(X) <= 0:
        X = X[::-1]
        print(-X[K - 1])
    else:
        res = min(res, solve(X, K))
        X = [-x for x in X]
        res = min(res, solve(X[::-1], K))
        print(res)

Buggy submission (verdict: Runtime Error):
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def solve(X, K):
    N = len(X)

    cumsum = [0 for _ in range(N)]
    for i in range(1, N):
        cumsum[i] = abs(X[i] - X[i - 1]) + cumsum[i - 1]

    idx_zero = bisect.bisect_left(X, 0)

    ret = 1000000005
    for i in range(0, N):
        if X[i] >= 0:
            break
        res = -X[i]
        k = idx_zero - i
        if k < K:
            res += cumsum[idx_zero + K - k - 1] - cumsum[i]
        ret = min(ret, res)

    return ret


if __name__ == '__main__':
    N, K = map(int, input().split())
    X = list(map(int, input().split()))

    res = 1000000005
    if min(X) >= 0:
        print(X[K - 1])
    elif max(X) <= 0:
        X = X[::-1]
        print(-X[K - 1])
    else:
        res = min(res, solve(X, K))
        X = [-x for x in X]
        res = min(res, solve(X[::-1], K))
        print(res)
Problem p03476 (python)

Fixed submission:
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


def input():
    return sys.stdin.readline().rstrip()


def main():
    # [0 is True?, 1 is True?, ..., 10000 is True?]
    table = [False for _ in range(100001)]
    for i in range(1, 100001, 2):
        table[i] = is_prime(i) and is_prime((i + 1) // 2)

    cumsum = [0 for _ in range(100001)]
    for i in range(1, 100001):
        cumsum[i] = cumsum[i - 1]
        if table[i]:
            cumsum[i] += 1

    Q = int(input())
    for _ in range(Q):
        l, r = map(int, input().split())
        res = cumsum[r] - cumsum[l]
        if table[l]:
            res += 1
        print(res)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


def input():
    return sys.stdin.readline().rstrip()


def main():
    # [0 is True?, 1 is True?, ..., 10000 is True?]
    table = [False for _ in range(10001)]
    for i in range(1, 10001, 2):
        table[i] = is_prime(i) and is_prime((i + 1) // 2)

    cumsum = [0 for _ in range(10001)]
    for i in range(1, 10001):
        cumsum[i] = cumsum[i - 1]
        if table[i]:
            cumsum[i] += 1

    Q = int(input())
    for _ in range(Q):
        l, r = map(int, input().split())
        res = cumsum[r] - cumsum[l]
        if table[l]:
            res += 1
        print(res)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


def input():
    return sys.stdin.readline().rstrip()


def main():
    # [0 is True?, 1 is True?, ..., 10000 is True?]
    table = [False for _ in range(10001)]
    for i in range(1, 10001, 2):
        table[i] = is_prime(i) and is_prime((i + 1) // 2)

    cumsum = [0 for _ in range(10001)]
    for i in range(1, 10001):
        cumsum[i] = cumsum[i - 1]
        if table[i]:
            cumsum[i] += 1

    Q = int(input())
    for _ in range(Q):
        l, r = map(int, input().split())
        res = cumsum[r] - cumsum[l]
        if table[l]:
            res += 1
        print(res)


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

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

ans = 0
even = [a % 2 == 0 for a in A]
for i in range(2 ** N):
    tmp = even.copy()
    cnt = 0
    for j in range(N):
        if ((i >> j) & 1):
            tmp[j] = not tmp[j]
            cnt += 1
    if sum(tmp) > 0:
        ans += 2 ** cnt if i != 0 else 1

print(ans)

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

ans = 0
even = [a % 2 == 0 for a in A]
for i in range(2 ** N):
    tmp = even.copy()
    cnt = 0
    for j in range(N):
        if ((i >> j) & 1):
            tmp[j] = not tmp[j]
            cnt += 1
    if sum(tmp) > 0:
        ans += 2 ** cnt if i != 0 else 1

print(ans)
Problem p03681 (python)

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

MOD = 1000000007

if abs(N - M) > 1:
    print(0)
    exit(0)

dogs = 1
for i in range(1, N + 1):
    dogs *= i
    dogs %= MOD

monks = 1
for i in range(1, M + 1):
    monks *= i
    monks %= MOD

res = (dogs * monks) % MOD
if (N + M) % 2 == 0:
    res *= 2
    res %= MOD

print(res)

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

MOD = 1_000_000_007

if abs(N - M) > 1:
    print(0)
    exit(0)

dogs = 1
for i in range(1, N + 1):
    dogs *= i
    dogs %= MOD

monks = 1
for i in range(1, M + 1):
    monks *= i
    monks %= MOD

res = (dogs * monks) % MOD
if (N + M) % 2 == 0:
    res *= 2
    res %= MOD

print(res)

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

MOD = 1_000_000_007

if abs(N - M) > 1:
    print(0)
    exit(0)

dogs = 1
for i in range(1, N + 1):
    dogs *= i
    dogs %= MOD

monks = 1
for i in range(1, M + 1):
    monks *= i
    monks %= MOD

res = (dogs * monks) % MOD
if (N + M) % 2 == 0:
    res *= 2
    res %= MOD

print(res)
Problem p03845 (python)

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

for _ in range(M):
    t = T.copy()
    P, X = map(int, input().split())
    t[P - 1] = X
    print(sum(t))

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

for _ in range(M):
    t = T.copy()
    P, X = map(int, input().split())
    t[P - 1] = X
    print(sum(t))
Problem p03862 (python)

Fixed submission:
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, x = map(int, input().split())
    A = list(map(int, input().split()))

    A_origin = A.copy()

    if A[0] > x:
        A[0] = x

    for i in range(0, N - 1):
        if A[i] + A[i + 1] > x:
            A[i + 1] -= A[i] + A[i + 1] - x

    res = 0
    for i in range(N):
        res += abs(A_origin[i] - A[i])

    print(res)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, x = map(int, input().split())
    A = list(map(int, input().split()))

    A_origin = A.copy()

    if A[0] > x:
        A[0] = x

    for i in range(0, N - 1):
        if A[i] + A[i + 1] > x:
            A[i + 1] -= A[i] + A[i + 1] - x

    res = 0
    for i in range(N):
        res += abs(A_origin[i] - A[i])

    print(res)


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

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

if A > 8 or B > 8:
    print(":(")
else:
    print("Yay!")

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

if A > 8 or B > 8:
    print("Yay!")
else:
    print(":(")
Problem p03337 (python)

Fixed submission:
A, B = map(int, input().split())
print(max([A+B, A-B, A*B]))

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
print(max([A+B. A-B, A*B]))
Problem p03351 (python)

Fixed submission:
a, b, c, d = map(int, input().split())
x = sorted([a, b])
y = sorted([c, b])

if (max(a, c) - min(a, c)) <= d:
    print("Yes")
elif (x[-1] - x[0]) <= d and (y[-1] - y[0]) <= d:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
x = sorted(a, b)
y = sorted(c, b)

if (x[-1] - x[0]) <= d and (y[-1] - y[0]) <= d:
    print("Yes")
else:
    print("No")