Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())

if n % 2 == 1:
    print(0)
else:
    flg = 0
    ans = 0
    while n >= 5:
        if flg == 0:
            ans += n // 10
            n //= 10
            flg = 1
        else:
            ans += n // 5
            n //= 5

print(ans)

Fixed submission:
n = int(input())

if n % 2 == 1:
    print(0)
else:
    flg = 0
    ans = 0
    while n >= 5:
        if flg == 0:
            ans += n // 10
            n //= 10
            flg = 1
        else:
            ans += n // 5
            n //= 5

    print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())

if n % 2 == 1:
    print(0)
else:
    a = 10
    coef = 5
    cnt = 0
    ans = 0
    while a*coef**cnt <= n:
        ans += n // (a*coef**cnt)
        cnt += 1

print(ans)

Fixed submission:
n = int(input())

if n % 2 == 1:
    print(0)
else:
    flg = 0
    ans = 0
    while n >= 5:
        if flg == 0:
            ans += n // 10
            n //= 10
            flg = 1
        else:
            ans += n // 5
            n //= 5

    print(ans)
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
p = [int(N/1.08), math.ceil(N/1.08)]

for n in p:
    if int(n*1.08)==N:
        print(n)
        sys.exit()

print(":(")

Fixed submission:
import math, sys
N = int(input())
p = [int(N/1.08), math.ceil(N/1.08)]

for n in p:
    if int(n*1.08)==N:
        print(n)
        sys.exit()

print(":(")
Buggy python submission (verdict: Runtime Error):
import sys
X = int(input())

if X >= 2000:
    print(1)
else:
    limit, mods = divmod(X, 100)
    if mods / limit <= 5:
        print(1)
    else:
        print(0)

Fixed submission:
X = int(input())

if X >= 2000:
    print(1)
elif X < 100:
    print(0)
else:
    limit, mods = divmod(X, 100)
    if mods / limit <= 5:
        print(1)
    else:
        print(0)
Buggy python submission (verdict: Runtime Error):
from collections import deque
from collections import defaultdict
n = int(input())

graph = defaultdict(list)

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

max_c = max([len(x) for x in list(graph.values())])

colors = set(range(1, max_c + 1))


q = deque([1])
ans = [0] * (n + 1)
ans[1] = 1

while q:
    curr = q.popleft()
    can_use = colors - set([ans[curr]])
    for v in graph[curr]:
        if ans[v] == 0:
            ans[v] = min(can_use)
            can_use -= set([min(can_use)])
            q.append(v)

print(*ans[1:], sep="\n")

Fixed submission:
from collections import deque
from collections import defaultdict

n = int(input())
graph = defaultdict(list)

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

ans = [0] * (n - 1)

q = deque([[1, 0, 0]])
while q:
    v, pcol, root = q.popleft()
    cnt = 1
    for node in graph[v]:
        if node[0] == root:
            continue
        if cnt == pcol:
            cnt += 1
        ans[node[1]] = cnt
        q.append([node[0], cnt, v])
        cnt += 1

print(max(ans))
print(*ans, sep="\n")
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))

A_cs = A.cumsum()
A_cs = A_cs - A_cs[-1]/2
div = np.abs(A_cs).argmin()

print(abs(A[:div+1].sum - A[div+1:].sum()))

Fixed submission:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))

A_cs = A.cumsum()
A_cs = A_cs - A_cs[-1]/2
div = np.abs(A_cs).argmin()

print(abs(A[:div+1].sum() - A[div+1:].sum()))

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))

A_cs = A.cumsum()
A_cs = A_cs - A_cs[-1]/2
div = np.abs(A_cs).argmin()

print(abs(A[:div+1].sum()A - [div+1:].sum()))

Fixed submission:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))

A_cs = A.cumsum()
A_cs = A_cs - A_cs[-1]/2
div = np.abs(A_cs).argmin()

print(abs(A[:div+1].sum() - A[div+1:].sum()))
Buggy python submission (verdict: Runtime Error):
import sys
from collections import Counter

n = int(input())
arr = list(map(int, input().split()))

c = list(Counter(arr).items())

c.sort()

if c[0][0] != 0 or c[0][1] != 1:
    print(0)
    sys.exit()

prev_k = 0
prev_v = 1
ans = 1
mod = 998244353
for k, v in c[1:]:
    if k - prev_k > 1:
        print(0)
        sys.exit()
    else:
        ans *= pow(prev, i) % mod
        ans %= mod
        prev_k = k
        prev_v = v

print(ans)

Fixed submission:
from collections import Counter


def solve(n, arr):
    if arr[0] != 0:
        return 0

    c = Counter(arr)

    if c[0] != 1:
        return 0
    max_c = max(c)
    for i in range(max_c + 1):
        if i not in c:
            return 0

    c = list(c.items())
    c.sort()

    prev = 1
    ans = 1
    mod = 998244353

    for _, i in c[1:]:
        ans *= pow(prev, i) % mod
        ans %= mod
        prev = i

    return ans


n = int(input())
arr = list(map(int, input().split()))

print(solve(n, arr))

Buggy python submission (verdict: Runtime Error):
from collections import Counter


def solve(n, arr):
    if arr[0] != 0:
        return 0

    c = Counter(arr)
    c.sort()

    if len(c) != max(c.keys()) + 1:
        return 0

    c = list(c.values())

    prev = c[0]
    ans = 1
    mod = 998244353

    for i in c[1:]:
        ans *= pow(prev, i) % mod
        ans %= mod
        prev = i

    return ans


n = int(input())
arr = list(map(int, input().split()))

print(solve(n, arr))

Fixed submission:
from collections import Counter


def solve(n, arr):
    if arr[0] != 0:
        return 0

    c = Counter(arr)

    if c[0] != 1:
        return 0
    max_c = max(c)
    for i in range(max_c + 1):
        if i not in c:
            return 0

    c = list(c.items())
    c.sort()

    prev = 1
    ans = 1
    mod = 998244353

    for _, i in c[1:]:
        ans *= pow(prev, i) % mod
        ans %= mod
        prev = i

    return ans


n = int(input())
arr = list(map(int, input().split()))

print(solve(n, arr))
Buggy python submission (verdict: Runtime Error):
print("Yes" if sum([int(input()) == x * y for x in range(1, 10) for y in range(1, 10)]) else "No")

Fixed submission:
print("Yes") if int(input()) in [i*j for i in range(1, 10) for j in range(1, 10)] else print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())

for i in range(int(N**0.5), 1, -1):
    if (N / i).is_integer():
        a = N // i
        b = N // a
        break

print(a+b-2)

Fixed submission:
N = int(input())

for i in range(int(N**0.5), 0, -1):
    if (N / i).is_integer():
        a = N // i
        b = N // a
        break

print(a+b-2)
Buggy python submission (verdict: Runtime Error):
a, b, x = map(int, input().split())

if a**2 * b <= 2 * x:
    h = (a**2 * b - x) / a**2 * 2
    theta = h / (a**2 + h**2)**0.5
    ans = math.degrees(math.asin(theta))
else:
    h = 2 * x / a / b
    theta = h / (b**2 + h**2)**0.5
    ans = math.degrees(math.acos(theta))

print(ans)

Fixed submission:
import math
a, b, x = map(int, input().split())

if a**2 * b <= 2 * x:
    h = (a**2 * b - x) / a**2 * 2
    theta = h / (a**2 + h**2)**0.5
    ans = math.degrees(math.asin(theta))
else:
    h = 2 * x / a / b
    theta = h / (b**2 + h**2)**0.5
    ans = math.degrees(math.acos(theta))

print(ans)
Buggy python submission (verdict: Runtime Error):
N, K, Q = map(int, input().split())
A = np.array([int(input()) for _ in range(Q)])

ans = np.zeros(N)
ans += K

for a in A:
    ans[a-1] += 1

ans -= Q

for a in ans:
    if a>0:
        print("Yes")
    else:
        print("No")

Fixed submission:
import numpy as np
N, K, Q = map(int, input().split())
A = np.array([int(input()) for _ in range(Q)])

ans = np.zeros(N)
ans += K

for a in A:
    ans[a-1] += 1

ans -= Q

for a in ans:
    if a>0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
import bisect
from collections import deque

n, m = map(int, input().split())
arr = list(map(int, input().split()))

arr.sort()
arr = deque(arr)

for _ in range(m):
    q = arr.pop()
    bisect.insort_right(arr, q // 2)

print(sum(arr))

Fixed submission:
from heapq import heapify, heapreplace

n, m = map(int, input().split())
arr = [-x for x in map(int, input().split())]
heapify(arr)

for _ in range(m):
    heapreplace(arr, int(arr[0] / 2))

print(-sum(arr))

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

n, m = map(int, input().split())
arr = list(map(int, input().split()))

arr.sort()
arr = deque(arr)

for _ in range(m):
    q = arr.pop()
    bisect.insort_right(arr, q // 2)

print(sum(arr))

Fixed submission:
from heapq import heapify, heapreplace

n, m = map(int, input().split())
arr = [-x for x in map(int, input().split())]
heapify(arr)

for _ in range(m):
    heapreplace(arr, int(arr[0] / 2))

print(-sum(arr))

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

n, m = map(int, input().split())
arr = deque(map(int, input().split()))

arr.sort()

for _ in range(m):
    q = arr.pop()
    bisect.insort_right(arr, q // 2)

print(sum(arr))

Fixed submission:
from heapq import heapify, heapreplace

n, m = map(int, input().split())
arr = [-x for x in map(int, input().split())]
heapify(arr)

for _ in range(m):
    heapreplace(arr, int(arr[0] / 2))

print(-sum(arr))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n, m = map(int, input().split())
arr = list(map(int, input().split()))

arr.sort()

for _ in range(m):
    q = arr.pop()
    bisect.insort_right(arr, q // 2)

print(sum(arr))

Fixed submission:
from heapq import heapify, heapreplace

n, m = map(int, input().split())
arr = [-x for x in map(int, input().split())]
heapify(arr)

for _ in range(m):
    heapreplace(arr, int(arr[0] / 2))

print(-sum(arr))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n, m = map(int, input().split())
arr = list(map(int, input().split()))

arr.sort()

for _ in range(m):
    q = arr.pop()
    q = q // 2
    bisect.insort_left(arr, q)

print(sum(arr))

Fixed submission:
from heapq import heapify, heapreplace

n, m = map(int, input().split())
arr = [-x for x in map(int, input().split())]
heapify(arr)

for _ in range(m):
    heapreplace(arr, int(arr[0] / 2))

print(-sum(arr))
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
print((np.arange(N-1) + 1).sum())

Fixed submission:
import numpy as np
N = int(input())
print(N*(N-1)//2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
print(sum(i+1 for i in range(N-1)))

Fixed submission:
import numpy as np
N = int(input())
print(N*(N-1)//2)
Buggy python submission (verdict: Runtime Error):
S = input()

last = S[0]
ans = 1
cnt = 1

while cnt < len(S):
    if len(last)==1:
        if last != S[cnt]:
            last = S[cnt]
            ans += 1
            cnt += 1
        else:
            last = S[cnt:cnt+2]
            ans += 1
            cnt += 2
    if len(last)==2:
        last = S[cnt]
        ans += 1
        cnt += 1

print(ans)

Fixed submission:
S = input()

memo = []
memo.append(S[0])
p = 1

while p<len(S):
    if len(memo[-1])==2:
        memo.append(S[p])
        p += 1
    elif memo[-1]!=S[p]:
        memo.append(S[p])
        p += 1
    elif p+1==len(S):
        break
    else:
        memo.append(S[p:p+2])
        p += 2
print(len(memo))
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
H = np.array(list(map(int, input().split())))

ans_1 = min(H[np.where(H==H.max())[0].min():]) > max(H)-2

tmp = H[1:] - H[:-1]

ans_2 = all(tmp2 > -2)

print("Yes") if ans_1 & ans_2 else print("No")

Fixed submission:
import numpy as np
N = int(input())
H = np.array(list(map(int, input().split())))

tmp_1 = H[np.where(H==H.max())[0].min():]
ans_1 = min(tmp_1) > max(H)-2

tmp2 = H[1:] - H[:-1]

ans_2 = all(tmp2 > -2)

print("Yes") if ans_1 & ans_2 else print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sa = sum(A)

for i, b in enumerate(B):
    tmp = min(A[i], b)  # 削り取れる分
    A[i] -= tmp　　# 削り取る
    A[i + 1] -= min(A[i + 1], b - tmp)　　# i+1から削れる分はここで削っておく。b-tmpがi時点でのA[i+1]への攻撃力

print(sa - sum(A))　　# 全量から削れなかった分を引く

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

sa = sum(A)

for i, b in enumerate(B):
    tmp = min(A[i], b)  # 削り取れる分
    A[i] -= tmp  # 削り取る
    A[i + 1] -= min(A[i + 1], b - tmp)  # i+1から削れる分はここで削っておく。b-tmpがi時点でのA[i+1]への攻撃力

print(sa - sum(A))  # 全量から削れなかった分を引く
Buggy python submission (verdict: Time Limit Exceeded):
s = input()[::-1]
MOD = 10**9 + 7

dp = [[0] * 13 for _ in range(len(s))]

for i, x in enumerate(s):
    # 1, 10, 100, 1000...の剰余を順に計算し、各桁までの剰余を計算
    if i == 0:
        tmp = 1
    else:
        tmp = tmp * 10 % 13
    if x != "?":
        move = int(x) * tmp
        if i == 0:
            dp[i][move] = 1
        else:
            for j in range(13):
                dp[i][j] += dp[i - 1][(j - move + 13) % 13]
                dp[i][j] %= MOD
    else:
        for coef in range(10):
            move = coef * tmp
            if i == 0:
                dp[i][move] = 1
            else:
                for j in range(13):
                    dp[i][j] += dp[i - 1][(j - move + 13) % 13]
                    dp[i][j] %= MOD

print(dp[-1][5])

Fixed submission:
s = input()[::-1]
MOD = 10**9 + 7

dp = [[0] * 13 for _ in range(len(s))]

for i, x in enumerate(s):
    # 1, 10, 100, 1000...の剰余を順に計算し、各桁までの剰余を計算
    if i == 0:
        tmp = 1
    else:
        tmp = tmp * 10 % 13
    if x != "?":
        move = int(x) * tmp
        if i == 0:
            dp[i][move] = 1
        else:
            for j in range(13):
                dp[i][j] += dp[i - 1][(j - move + 13) % 13]
                dp[i][j] %= MOD
    else:
        for coef in range(10):
            move = coef * tmp
            if i == 0:
                dp[i][move] = 1
            else:
                for j in range(13):
                    dp[i][j] += dp[i - 1][(j - move + 13) % 13]
                    dp[i][j] %= MOD

print(dp[-1][5])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]
ans = [0]*N

ans[0] = max(A[1:])
ans[N-1] = max(A[:-1])

for i in range(1, N-1):
    ans[i] = max(max(A[:i]), max(A[i+1:]))

print(*ans, sep="\n")

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
ans = [0]*N

first = sorted(A)[-1]
second = sorted(A)[-2]

for i in range(N):
    if A[i]==first:
        ans[i] = second
    else:
        ans[i] = first

print(*ans, sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]
ans = [0]*N

ans[0] = max(A[1:])
ans[N-1] = max(A[:-1])

for i in range(1, N-1):
    ans[i] = max(max(A[:i]), max(A[i+1:]))

print(*ans, sep="\n")

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
ans = [0]*N

first = sorted(A)[-1]
second = sorted(A)[-2]

for i in range(N):
    if A[i]==first:
        ans[i] = second
    else:
        ans[i] = first

print(*ans, sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
A = np.array([int(input()) for i in range(N)])
ans = np.zeros(N, dtype=int)

ans[0] = A[1:].max()
ans[N-1] = A[:-1].max()

for i in range(1, N-1):
    left = A[:i].max()
    right = A[i+1:].max()
    ans[i] = max(left, right)

print(*ans, sep="\n")

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
ans = [0]*N

first = sorted(A)[-1]
second = sorted(A)[-2]

for i in range(N):
    if A[i]==first:
        ans[i] = second
    else:
        ans[i] = first

print(*ans, sep="\n")
Buggy python submission (verdict: Runtime Error):
import sympy

n = int(input())
arr = list(map(int, input().split()))

x = sympy.Symbol("x")

ex = [0] * n
ex[0] = x

for i in range(n - 1):
    ex[i + 1] = 2 * arr[i] - ex[i]

ans = sympy.solve(ex[0] + ex[-1] - 2 * arr[-1])[0]
ans = [y.subs(x, ans) for y in ex]

print(*ans)

Fixed submission:
import numpy as np
n = int(input())
arr = np.array(list(map(int, input().split())))

ans = np.zeros(n + 1, dtype=int)
for i, x in enumerate(arr):
    tmp = x * 2 - ans[i]
    ans[i + 1] += tmp

x = ans[-1] // 2
ans = ans[:-1]
ans[0::2] += x
ans[1::2] -= x

print(*ans)
Buggy python submission (verdict: Runtime Error):
S = list(input().rstrip())
ans = Counter(S)
print("Yes") if len(ans)==2 & list(ans.values())[0]==2 & list(ans.values())[1]==2 else print("No")

Fixed submission:
from collections import Counter
S = list(input().rstrip())
ans = Counter(S)
print("Yes") if len(ans)==2 & list(ans.values())[0]==2 & list(ans.values())[1]==2 else print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
d = [int(x) for x in input().split()]

d.sort()
length = len(d)
left = d[length//2-1]
right = d[length//2]

if left==right:
    print(0)
else:
    print(ans)

Fixed submission:
N = int(input())
d = [int(x) for x in input().split()]

d.sort()
length = len(d)
left = d[length//2-1]
right = d[length//2]

if left==right:
    print(0)
else:
    print(right - left)
Buggy python submission (verdict: Runtime Error):
from scipy.misc import comb

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

for i in range(k):
    print(int(comb(n - k + 1, i + 1) * comb(k - 1, i) % MOD))

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


def cmb(n, k, mod):
    if k > n or k < 0:
        return 0
    fact_n = factorial_mod(n, mod)
    fact_k = factorial_mod(k, mod)
    fact_n_k = factorial_mod(n - k, mod)
    return (fact_n * pow(fact_k, mod - 2, mod) * pow(fact_n_k, mod - 2, mod)) % mod


n, k = map(int, input().split())
MOD = 10**9 + 7

for i in range(k):
    print(int(cmb(n - k + 1, i + 1, MOD) * cmb(k - 1, i, MOD) % MOD))

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

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

for i in range(k):
    print(int(comb(n - k + 1, i + 1) * comb(k - 1, i) % MOD))

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


def cmb(n, k, mod):
    if k > n or k < 0:
        return 0
    fact_n = factorial_mod(n, mod)
    fact_k = factorial_mod(k, mod)
    fact_n_k = factorial_mod(n - k, mod)
    return (fact_n * pow(fact_k, mod - 2, mod) * pow(fact_n_k, mod - 2, mod)) % mod


n, k = map(int, input().split())
MOD = 10**9 + 7

for i in range(k):
    print(int(cmb(n - k + 1, i + 1, MOD) * cmb(k - 1, i, MOD) % MOD))

Buggy python submission (verdict: Runtime Error):
def prepare(n):

    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs


def f(i, facts, invs):
    a = n - k - i + 1
    if a < 0:
        return 0
    b = k - i
    ans = facts[i + a] * invs[i] * invs[a] % MOD
    ans *= facts[i + b - 1] * invs[i - 1] * invs[b] % MOD
    return ans


n, k = list(map(int, input().split()))
facts, invs = prepare(n)

ans = []
for i in range(1, k + 1):
    ans.append(f(i, facts, invs))

print(*ans, sep="\n")

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


def cmb(n, k, mod):
    if k > n or k < 0:
        return 0
    fact_n = factorial_mod(n, mod)
    fact_k = factorial_mod(k, mod)
    fact_n_k = factorial_mod(n - k, mod)
    return (fact_n * pow(fact_k, mod - 2, mod) * pow(fact_n_k, mod - 2, mod)) % mod


n, k = map(int, input().split())
MOD = 10**9 + 7

for i in range(k):
    print(int(cmb(n - k + 1, i + 1, MOD) * cmb(k - 1, i, MOD) % MOD))
Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())

def gcd(a, b):
    if (b==0):
        return a
    else:
        return gcd(b, a % b)

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

ans_c = (B - A) // C
ans_d = (B - A) // D
i = (B - A) // (C * D // gcd(C, D))

print(B - A - ans_c - ans_d + i)

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

def gcd(a, b):
    if (b==0):
        return a
    else:
        return gcd(b, a % b)

G = C * D // gcd(C, D)

ans_b = B - B//C - B//D + B//G
ans_a = A - 1 - (A-1)//C - (A-1)//D + (A-1)//G

print(ans_b - ans_a)

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

def gcd(a, b):
    if (b==0):
        return a
    else:
        return gcd(b, a % b)

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

print(a*b // gcd(a, b))

ans_c = (B - A) // C
ans_d = (B - A) // D
i = (B - A) // (C * D // gcd(C, D))

print(B - A - ans_c - ans_d + i)

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

def gcd(a, b):
    if (b==0):
        return a
    else:
        return gcd(b, a % b)

G = C * D // gcd(C, D)

ans_b = B - B//C - B//D + B//G
ans_a = A - 1 - (A-1)//C - (A-1)//D + (A-1)//G

print(ans_b - ans_a)

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

ans_c = (B - A) // C
ans_d = (B - A) // D
i = (B - A) // (C * D // math.gcd(C, D))

print(B - A - ans_c - ans_d + i)

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

def gcd(a, b):
    if (b==0):
        return a
    else:
        return gcd(b, a % b)

G = C * D // gcd(C, D)

ans_b = B - B//C - B//D + B//G
ans_a = A - 1 - (A-1)//C - (A-1)//D + (A-1)//G

print(ans_b - ans_a)

Buggy python submission (verdict: Runtime Error):
import numpy as np
A, B, C, D = map(int, input().split())
s = np.arange(A, B+1)

s = s[np.where(s%C != 0)]
s = s[np.where(s%D != 0)]

print(s.shape[0])

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

def gcd(a, b):
    if (b==0):
        return a
    else:
        return gcd(b, a % b)

G = C * D // gcd(C, D)

ans_b = B - B//C - B//D + B//G
ans_a = A - 1 - (A-1)//C - (A-1)//D + (A-1)//G

print(ans_b - ans_a)
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

n = int(input())

a = []
b = []

for i in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

a = np.array(a)
b = np.array(b)

diff = b - a

li = []
for x, y, z in zip(diff, a, b):
    li.append((x, y, z))

li = sort()
li = li[::-1]

stack = 0
for _, a, b in li:
    stack += a
    if stack > b:
        print("No")
        sys.exit()

print("Yes")

Fixed submission:
import sys

n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

ab.sort(key=lambda x: x[1])

now = 0

for a, b in ab:
    now += a
    if now > b:
        print("No")
        sys.exit()

print("Yes")

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

n = int(input())

a = []
b = []

for i in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

a = np.array(a)
b = np.array(b)

diff = b - a

li = []
for x, y, z in zip(diff, a, b):
    li.append((x, y, z))

li = sorted(reverse=True)

stack = 0
for _, a, b in li:
    stack += a
    if stack > b:
        print("No")
        sys.exit()

print("Yes")

Fixed submission:
import sys

n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

ab.sort(key=lambda x: x[1])

now = 0

for a, b in ab:
    now += a
    if now > b:
        print("No")
        sys.exit()

print("Yes")

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

n = int(input())

a = []
b = []

for i in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

a = np.array(a)
b = np.array(b)

diff = b - a

li = []
for x, y, z in zip(diff, a, b):
    li.append((x, y, z))

li = sortted(reverse=True)

stack = 0
for _, a, b in li:
    stack += a
    if stack > b:
        print("No")
        sys.exit()

print("Yes")

Fixed submission:
import sys

n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

ab.sort(key=lambda x: x[1])

now = 0

for a, b in ab:
    now += a
    if now > b:
        print("No")
        sys.exit()

print("Yes")