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

Fixed submission:
def fatora(n):
	ans = []
	for i in range(1, n+1):
		if i*i > n:
			break
		else:
			if n % i == 0:
				ans.append(i)
				ans.append(n//i)
	return set(ans)

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


def eh_primo(n):
	if n == 0:
		return False
	elif n == 1:
		return True
	elif n == 2:
		return True
	else:
		for i in range(2, n+10):
			if i*i > n:
				break
			else:
				if n % i == 0:
					return False
		return True



a, b = map(int, input().split())
print(len(list(filter(eh_primo, fatora(gcd(a, b))))))

Buggy submission (verdict: Runtime Error):
import math

def fatora(n):
	ans = []
	for i in range(1, n+1):
		if i*i > n:
			break
		else:
			if n % i == 0:
				ans.append(i)
				ans.append(n//i)
	return set(ans)

def eh_primo(n):
	if n == 0:
		return False
	elif n == 1:
		return True
	elif n == 2:
		return True
	else:
		for i in range(2, n+10):
			if i*i > n:
				break
			else:
				if n % i == 0:
					return False
		return True



a, b = map(int, input().split())
new_gcd = math.gcd(a,b)

primos_qtd = 0

for num in fatora(new_gcd):
	if eh_primo(num):
		primos_qtd += 1
print(primos_qtd)

Buggy submission (verdict: Runtime Error):
def fatora(n):
	ans = []
	for i in range(1, n+1):
		if i*i > n:
			break
		else:
			if n % i == 0:
				ans.append(i)
				ans.append(n//i)
	return set(ans)

def eh_primo(n):
	if n == 0:
		return False
	elif n == 1:
		return True
	elif n == 2:
		return True
	else:
		for i in range(2, n+10):
			if i*i > n:
				break
			else:
				if n % i == 0:
					return False
		return True


import math

a, b = map(int, input().split())
new_gcd = math.gcd(a,b)

primos_qtd = 0

for num in fatora(new_gcd):
	if eh_primo(num):
		primos_qtd += 1
print(primos_qtd)

Buggy submission (verdict: Runtime Error):
def fatora(n):
	ans = []
	for i in range(1, n+1):
		if i*i > n:
			break
		else:
			if n % i == 0:
				ans.append(i)
				ans.append(n//i)
	return set(ans)

def eh_primo(n):
	if n == 0:
		return False
	elif n == 1:
		return True
	elif n == 2:
		return True
	else:
		for i in range(2, n+10):
			if i*i > n:
				break
			else:
				if n % i == 0:
					return False
		return True


import math

a, b = map(int, input().split())
new_gcd = math.gcd(a,b)

print(len(list(filter(eh_primo, fatora(new_gcd)))))

Buggy submission (verdict: Runtime Error):
def fatora(n):
	ans = []
	for i in range(1, n+1):
		if i*i > n:
			break
		if n % i == 0:
			ans.append(i)
			ans.append(n//i)
	ans.sort()
	return set(ans)

def eh_primo(n):
	if n <= 1:
		return True
	elif n == 2:
		return True
	else:
		for i in range(2, n+1):
			if i*i > n:
				break
			else:
				if n % i == 0:
					return False
		return True
	


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

new_gcd = math.gcd(a, b)

list_div = fatora(new_gcd)
list_primes = list(filter(eh_primo, list_div))

print(len(list_primes))
Problem p02658 (python)

Fixed submission:
def main():
	N =int(input())
	A =list(map(int,input().split()))
	if 0 in A:
		print(0)
		return

	prod = 1 
	for a in A:
		prod *= a
		if prod > 1000000000000000000:
			print(-1)
			return

	print(prod)


main()

Buggy submission (verdict: Runtime Error):
defmain():N =int(input())A =list(map(int,input().split()))if0inA:print(0)returnprod = 1forainA:prod *= aifprod > 1000000000000000000:print(-1)returnprint(prod)main()
Problem p02573 (python)

Fixed submission:
class UnionFind:

    def __init__(self):
        self.parents = {}
        self.sz = {}
        self.size = 0


    def add(self, a):
        if a in self.parents:
            return
        self.size += 1
        self.sz[a] = 1
        self.parents[a] = a 

    def find(self, a):
        if self.parents[a] != a:
            self.parents[a] = self.find(self.parents[a])

        return self.parents[a]

    def join(self, a, b):
        pa, pb = self.find(a), self.find(b)
        if pa == pb:
            return
        if self.sz[pa] > self.sz[pb]:
            self.parents[pb] = pa
            self.sz[pa] += self.sz[pb]
        else:
            self.parents[pa] = pb 
            self.sz[pb] += self.sz[pa]

        self.size -= 1


n,m = list(map(int,input().split(" ")))
uf = UnionFind()
ans = 0
if m == 0:
    print(1)
else:
    for _ in range(m):
        x,y = list(map(int,input().split(" ")))
        uf.add(x)
        uf.add(y)
        uf.join(x,y)
        ans = max(ans, uf.sz[x])

    print(max(uf.sz.values()))

Buggy submission (verdict: Runtime Error):
class UnionFind:

    def __init__(self):
        self.parents = {}
        self.sz = {}
        self.size = 0


    def add(self, a):
        if a in self.parents:
            return
        self.size += 1
        self.sz[a] = 1
        self.parents[a] = a 

    def find(self, a):
        if self.parents[a] != a:
            self.parents[a] = self.find(self.parents[a])

        return self.parents[a]

    def join(self, a, b):
        pa, pb = self.find(a), self.find(b)
        if pa == pb:
            return
        if self.sz[pa] > self.sz[pb]:
            self.parents[pb] = pa
            self.sz[pa] += self.sz[pb]
        else:
            self.parents[pa] = pb 
            self.sz[pb] += self.sz[pa]

        self.size -= 1


n,m = list(map(int,input().split(" ")))
uf = UnionFind()
ans = 0
for _ in range(m):
    x,y = list(map(int,input().split(" ")))
    uf.add(x)
    uf.add(y)
    uf.join(x,y)
    ans = max(ans, uf.sz[x])


print(max(uf.sz.values()))
Problem p02900 (python)

Fixed submission:
def f(n):
    result = set()
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            result.add(i)

    if temp != 1:
        result.add(temp)

    return result


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

fa = f(a)
fb = f(b)

print(len(fa & fb)+1)

Buggy submission (verdict: Runtime Error):
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

set<ll> prime_factor(ll num) {
  set<ll> result;
  for (ll i = 2; i <= num; i++) {
    int j = 0;
    while (num % i == 0) {
      if (j == 0) {
        result.insert(i);
      }
      num /= i;
      j++;
    }
    if (num <= i) {
      break;
    }
  }
  return result;
}

ll calc(ll num, set<ll> s) {
  ll count = 0;
  for (ll i = 2; i <= num; i++) {
    int j = 0;
    while (num % i == 0) {
      if (j == 0) {
        if (s.find(i) != s.end()) {
          count++;
        }
      }
      num /= i;
      j++;
    }
    if (num <= i) {
      break;
    }
  }
  return count;
}

int main() {
  ll n1, n2;
  cin >> n1 >> n2;
  auto a1 = prime_factor(n1);
  cout << calc(n2, a1) + 1 << endl;
}
Problem p02548 (python)

Fixed submission:
n = int(input())
count = 0
for a in range(1,n):
    count += (n-1)//a
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
count = 0
for a in range(1,n):
    count += int((n-1)/a)
print(count)n = int(input())
count = 0
for a in range(1,n):
    count += int((n-1)/a)
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
count = 0
for c in range(n):
    ab = n - c
    if ab % a == 0:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
count = 0
for c in range(n):
	ab = n - c
    if ab % a = 0:
      count += 1
print(count)
Problem p03569 (python)

Fixed submission:
s = list(input())
l = 0
r = len(s)-1
ans = 0
while l < r:
    if s[l] == s[r]:
        l+=1
        r-=1
    elif s[l] == 'x':
        l+=1
        ans+=1
    elif s[r] == 'x':
        r-=1
        ans+=1
    else:
        print(-1)
        exit()
print(ans)

Buggy submission (verdict: Runtime Error):
def isPal(s):
    if s == s[::-1]:
        return True
    return False

s = list(input())
pal = ''
for ch in s:
    if ch != 'x':
        pal+=ch

if not isPal(pal):
    print(-1)
else:
    beg = s.index(pal[0])
    end = len(s)-1 - s[::-1].index(pal[-1])
    half = 0 if len(pal) == 1 else len(pal)//2 + 1
    cnt = 0
    for i in range(len(s)):
        if cnt == half:
            break
        if s[i] != 'x':
            cnt += 1
    print(abs(cnt-beg - (end-cnt)) + abs(beg - (len(s)-1-end)))
Problem p02621 (python)

Fixed submission:
a = int(input())
print(a * (1 + a * (1 + a)))

Buggy submission (verdict: Runtime Error):
a = int(input())
print(a * (a ** 3 - 1) / (a - 1))
Problem p02642 (python)

Fixed submission:
import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    arr = list(map(int, input().split()))
    arr.sort()
    s = set()
    cnt = collections.Counter(arr)
    for i in range(n):
        if arr[i] in s:
            continue
        elif cnt[arr[i]] >= 2:
            s.add(arr[i])
        for j in range(2, 10**6//arr[i]+1):
            s.add(arr[i]*j)
    ans = 0
    for i in arr:
        if i in s:
            continue
        ans += 1
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    arr = list(map(int, input().split()))
    arr.sort()
    s = set()
    cnt = collections.Counter(arr)
    for i in ragne(n):
        if arr[i] in s:
            continue
        elif cnt[arr[i]] >= 2:
            s.add(arr[i])
        for j in range(2, 10**6//arr[i]+1):
            s.add(arr[i]*j)
    ans = 0
    for i in arr:
        if i in s == False:
            ans += 1
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
def iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))

def solve():
    n = iput()
    a = lput()
    a.sort()
    ans = 0
    if a[0] == a[1]:
        ans += 1
    for i in range(1,n):
        for j in range(0, i):
            if a[i] % a[j] == 0:
                ans += 1
                break
    print(n - ans)
    return 0

if __name__ == "__main__":
    solve()
Problem p02663 (python)

Fixed submission:
def iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))

def solve():
    h1, m1, h2, m2, k = mput()
    hoge = h1*60+m1
    huga = h2*60+m2-k
    piyo = huga - hoge
    print(piyo)
    return 0

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
t = list(map(int, input()))
one = t.count(1)
print(one*(one+1)//2-2)
Problem p02677 (python)

Fixed submission:
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools

def hoge(n, m):
    n = n % 12
    b = 30*n+0.5*m
    s = 6*m
    ans = min(abs(b-s), 360-abs(b-s))
    if ans == 360:
        ans = 0
    return ans

def solve():
  a, b, h, n = map(int, input().split())
  p = hoge(h, n)
  ans = math.sqrt(a**2+b**2-(2*a*b*math.cos(math.radians(p))))
  print(ans)
  return 0
 
if __name__ == "__main__":
  solve()

Buggy submission (verdict: Runtime Error):
def hoge(n, m):
    n = n % 12
    b = 30*n+0.5*m
    s = 6*m
    ans = min(abs(b-s), 360-abs(b-s))
    if ans == 360:
        ans = 0
    return ans

def solve():
  a, b, h, n = map(int, input().split())
  p = hoge(h, n)
  ans = math.sqrt(a**2+b**2-(2*a*b*math.cos(math.radians(p))))
  print(ans)
  return 0
 
if __name__ == "__main__":
  solve()
Problem p02684 (python)

Fixed submission:
def main():
    N, K = map(int, input().split())
    A = [a-1 for a in map(int, input().split())]    # 0-indexed に変換
    B = [None]*N    # 何ステップ目に到達したかを記録。Noneなら未到達を表す
    now = 0         # 現在地
    step = 0        # ステップ数
    B[now] = 0      # 開始地点は、0ステップ目に到達済みとする
    while K:
        now = A[now]    # 現在地を更新 
        step += 1
        K -= 1
        if B[now] is not None:  # ループを検出したら...
            K %= (step - B[now])      # Kからループ長さを引けるだけ引く
        else:
            B[now] = step  # 到達したステップ数を記録
    print(now+1)    # 1-indexed に再変換
 
main()

Buggy submission (verdict: Runtime Error):
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools
 
def solve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    now = 0
    hoge= []
    bit = 0
    piyo = 0
    huga = []
    while True:
        hoge.append(now)
        now = a[now]-1
        if now in hoge:
            huga = hoge[hoge.index(now):len(hoge)]
            piyo = hoge.index(now)
            bit = 1
            break
    ans = huga[(k-piyo)%len(huga)]
    print(ans+1)
    return 0
 
if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools

def solve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    now = 0
    hoge= []
    bit = 0
    piyo = 0
    huga = []
    for i in range(k):
        hoge.append(now)
        now = a[now]-1
        if now in hoge:
            huga = hoge[hoge.index(now):len(hoge)]
            piyo = hoge.index(now)
            bit = 1
            break
    ans = huga[(k-piyo)%len(huga)]
    print(ans+1)
    return 0

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools

def solve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    now = 0
    print(now)
    hoge= []
    bit = 0
    piyo = 0
    huga = []
    for i in range(k):
        hoge.append(now)
        now = a[now]-1
        if now in hoge:
            huga = hoge[hoge.index(now):len(hoge)]
            piyo = hoge.index(now)
            bit = 1
            break
    ans = huga[(k-piyo)%len(huga)]
    print(ans+1)
    return 0

if __name__ == "__main__":
    solve()
Problem p02687 (python)

Fixed submission:
def solve():
  s = input()
  if s == "ABC":
    print("ARC")
  else:
    print("ABC")
  return 0

 
if __name__ == "__main__":
  solve()

Buggy submission (verdict: Runtime Error):
mport itertools
import math

def solve():
  s = input()
  if s == "ABC":
    print("ARC")
  else:
    print("ABC")
  return 0

 
if __name__ == "__main__":
  solve()
Problem p02696 (python)

Fixed submission:
import numpy as np
import math
import scipy
import itertools

def solve():
    a, b, n = map(int, input().split())
    x = min(b-1, n)
    print(math.floor(a*x/b)-a*math.floor(x/b))
    return 0

if __name__ == "__main__":
    solve()

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

def score(arr):
    hoge = 0
    for ai,bi,ci,di in zip(a, b, c, d):
        if arr[bi-1]-arr[ai-1] == ci:
            hoge += di
    return hoge

def dfs(arr):
    if len(arr) == n:
        return score(arr)
    last = arr[-1] if len(arr) > 0 else 0
    res = 0
    for i in range(last, m+1):
        arr.append(i)
        res = max(res, dfs(arr))
        arr.pop()
    return res

def solve():
    global a, b, c, d, n, m, q
    n, m, q = map(int, input().split())
    a, b, c, d = [0]*q, [0]*q, [0]*q, [0]*q
    for i in range(q):
        a[i], b[i], c[i], d[i] = map(int, input().split())
    print(dfs([]))
    return 0

if __name__ == "__main__":
    solve()
Problem p02708 (python)

Fixed submission:
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools

def solve():
    n, k = map(int, input().split())
    small = 0
    large = 0
    ans = 0
    mod = 10**9+7
    for i in range(0, n+1):
        small += i
        large += n-i
        if i+1 >= k:
            ans = (ans + (large - small + 1)) % mod
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools

def solve():
    n, k = map(int, input().split())
    small = 0
    large = 0
    ans = 0
    for i in range(0, n+1):
        small += i
        large += n-i
        if i+1 >= k:
            ans = (ans + (large - small + 1)) % mod
    print(ans)
    return 0

if __name__ == "__main__":
    solve()
Problem p02718 (python)

Fixed submission:
import numpy as np
import math
import collections
import fractions
import itertools

def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))
def iput(): return int(input())

def solve():
    n, m = mput()
    a = lput()
    line = sum(a) / (4 * m)
    bit = 0
    for i in a:
        if i >= line:
            bit += 1
    if bit >= m:
        print("Yes")
    else:
        print("No")
    return 0

if __name__ == "__main__":
    solve()

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

def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))
def iput(): return int(input())

def solve():
    n, m = mput()
    a = lput()
    line = sum(A) / (4 * m)
    bit = 0
    for i in a:
        if i >= line:
            bit += 1
    if bit >= m:
        print("Yes")
    else:
        print("No")
    return 0

if __name__ == "__main__":
    solve()
Problem p02732 (python)

Fixed submission:
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools

def solve():
  n = int(input())
  a = list(map(int, input().split()))
  c = collections.Counter(a)
  s = 0
  for i in list(c.values()):
    s += i*(i-1)//2
  for i in a:
    print(s-(c[i]-1))
  return 0
 
if __name__ == "__main__":
  solve()

Buggy submission (verdict: Runtime Error):
def solve():
  n = int(input())
  a = list(map(int, input().split()))
  c = collections.Counter(a)
  s = 0
  for i in list(c.values()):
    s += i*(i-1)//2
  print(c)
  for i in a:
    print(c[i])
    print(s-(c[i]-1))
  return 0
 
if __name__ == "__main__":
  solve()
Problem p02744 (python)

Fixed submission:
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def solve():
    n = int(input())
    sushi = ["a"]
    alt = [chr(ord("a") + i) for i in range(n)]
    for i in range(n-1):
        sushi = [ans + x for ans in sushi for x in alt[:len(set(ans)) + 1]]
    for i in sushi:
        print(i)
    return 0

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def solve():
    n = int(input())
    ans = ["a"]
    alt = [chr(ord("a") + i) for i in range(n)]
    for i in range(n-1):
        ans = [s+x for s in ans for x in alt [0:len(set(ans))+1]]
    for i in ans:
        print(ans)
    return 0

if __name__ == "__main__":
    solve()
Problem p02796 (python)

Fixed submission:
import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def solve():
    n = int(input())
    x, l = [0]*n, [0]*n
    for i in range(n):
        x[i], l[i] = map(int, input().split())
    hoge = []
    for i in range(n):
        hoge.append([x[i]+l[i], x[i]-l[i]])
    hoge.sort()
    t = -1000000000000000000000
    ans = 0
    for i in range(n):
        if t <= hoge[i][1]:
            ans += 1
            t = hoge[i][0]
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
n = int(input())
x, l = [0]*n, [0]*n
for i in range(n):
    x[i], l[i] = map(int, input().split())
hoge = []
for i in range(n):
    hoge.append(x+l)
t = 0
for i in range(n):
    if t < hoge[i]:
        ans += 1
        t = hoge[i]
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def solve():
    n = int(input())
    x, l = [0]*n, [0]*n
    for i in range(n):
        x[i], l[i] = map(int, input().split())
    hoge = []
    for i in range(n):
        hoge.append(x+l)
    t = 0
    for i in range(n):
        if t < hoge[i]:
            ans += 1
            t = hoge[i]
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def solve():
    n = int(input())
    x, l = [0]*n, [0]*n
    for i in range(n):
        x[i], l[i] = map(int, input().split())
    hoge = []
    for i in range(n):
        hoge.append(x+l)
    t = 0
    for i in range(n):
        if t < hoge[i]:
            ans += 1
    print(ans)
    return 0

if __name__ == "__main__":
    solve()
Problem p02900 (python)

Fixed submission:
import sys
from fractions import gcd
from collections import Counter


def prime_factorization(n):
    """nを素因数分解する

    Return d(dict):
        素因数をキー、素因数の指数部を値とするディクショナリを返す

    Example:
        n=140 -> d = {2: 2, 5: 1, 7: 1}
    """
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m = m + 1 if m == 2 else m + 2  # m=3からは、m+=2する（偶数は明らかに素数ではないので）

    if n > 1:
        d[n] += 1
    return d


def solve():
    A, B = list(map(int, sys.stdin.readline().split()))
    cd = gcd(A, B)

    if cd == 1:  # コーナーケース
        print(1)
        return

    # (素因数分解の素因数の個数)+1が答え
    prime_d = prime_factorization(cd)
    print(len(prime_d)+1)


if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def trial_division(n):
    factor = []
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    if not factor:
        return n
    else:
        factor.append(n)
        return factor

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

def solve():
    a, b = map(int, input().split())
    ans = 0
    for i in trial_division(fractions.gcd(a, b)):
        if is_prime(i):
            ans += 1
    print(ans+1)
    return 0

if __name__ == "__main__":
    solve()
Problem p02995 (python)

Fixed submission:
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools
 
def solve():
  a, b, c, d = map(int, input().split())
  a -= 1
  lc = (c*d)//fractions.gcd(c,d)
  ans = (b-a)-(b//c-a//c)-(b//d-a//d)+(b//lc-a//lc)
  print(ans)
  return 0
 
if __name__ == "__main__":
  solve()

Buggy submission (verdict: Runtime Error):
import math
def solve():
  a, b, c, d = map(int, input().split())
  a -= 1
  lc = (c*d)//math.gcd(c,d)
  ans = (b-a)-(b//c-a//c)-(b//d-a//d)+(b//lc-a//lc)
  print(ans)
  return 0
 
if __name__ == "__main__":
  solve()

Buggy submission (verdict: Runtime Error):
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools

def solve():
  a, b, c, d = map(int, input().split())
  a -= 1
  lc = (c*d)//math.gcd(c,d)
  ans = (b-a)-(b//c-a//c)-(b//d-a//d)+(b//lc-a//lc)
  print(ans)
  return 0
 
if __name__ == "__main__":
  solve()

Buggy submission (verdict: Runtime Error):
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools

def solve():
  a, b, c, d = map(int, input().split())
  a -= 1
  lc = (c*d)//math.gcd(c,d)
  ans = (b-a)-(b//c-a//c)-(b//d-a//d)+(b//lc-a//lc)
  print(ans)
  return 0
 
if __name__ == "__main__":
  solve()