Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d = map(int,input().split())
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
if c <=0 or d <= 0:
    print("No")
ans = c * d // gcd(c,d)
i = a
j = a
while True:
    if i % c == 0:
        break
    i += 1
while True:
    if j % d == 0:
        break
    j += 1
k = min(i,j)
while True:
    if k % ans == 0:
        break
    k += 1
ii = (b-i)//c 
jj = (b-j)//d 
kk = (b-k)//ans 
print(b-a-ii-jj+kk)


Fixed submission:
a,b,c,d = map(int,input().split())
cc = b//c -(a-1)//c
dd = b//d -(a-1)//d
#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

#a,bの最小公倍数
def lcm(a, b):
	return a * b // gcd (a, b)
cd = lcm(c, d)
cdcd = b//cd -(a-1)//cd
print(b-a+1-cc-dd+cdcd)

Buggy python submission (verdict: Runtime Error):
from fractions import gcd
a,b,c,d = map(int,input().split())
ls = [e for e in range(a,b+1)]
y = lambda x,z = c:x%z
ss = ls[:]
cmil = list(map(y,ss))
cmin = cmil.index(0) + a
bb = ls[::-1]
cmal = list(map(y,bb))
cmax = b - cmal.index(0) 
y = lambda x,z = d:x%z
dmil = list(map(y,ss))
dmin = dmil.index(0) + a
dmal = list(map(y,bb))
dmax = b - dmal.index(0)
y = lambda x,z = (c*d)/gcd(c,d):x%z
cdmil = list(map(y,ss))
cdmin = cdmil.index(0) + a
cdmal = list(map(y,bb))
cdmax = b - cdmal.index(0)
ca = (cmax - cmin)/c +1
da = (dmax - dmin)/d +1
cda = (cdmax - cdmin)/((c*d)/gcd(c,d)) +1
print(int(b-a+1-ca-da+cda))

Fixed submission:
a,b,c,d = map(int,input().split())
cc = b//c -(a-1)//c
dd = b//d -(a-1)//d
#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

#a,bの最小公倍数
def lcm(a, b):
	return a * b // gcd (a, b)
cd = lcm(c, d)
cdcd = b//cd -(a-1)//cd
print(b-a+1-cc-dd+cdcd)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
a,b,c,d = map(int,input().split())
if c <=0 or d <= 0:
    print("No")
ans = c * d // gcd(c,d)
i = a
j = a
while True:
    if i % c == 0:
        break
    i += 1
while True:
    if j % d == 0:
        break
    j += 1
k = min(i,j)
while True:
    if k % ans == 0:
        break
    k += 1
ii = (b-i)//c 
jj = (b-j)//d 
kk = (b-k)//ans 
print(b-a-ii-jj+kk)


Fixed submission:
a,b,c,d = map(int,input().split())
cc = b//c -(a-1)//c
dd = b//d -(a-1)//d
#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

#a,bの最小公倍数
def lcm(a, b):
	return a * b // gcd (a, b)
cd = lcm(c, d)
cdcd = b//cd -(a-1)//cd
print(b-a+1-cc-dd+cdcd)

Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
if c <=0 or d <= 0:
    print("No")
ans = c * d // math.gcd(c,d)
i = a
j = a
while True:
    if i % c == 0:
        break
    i += 1
while True:
    if j % d == 0:
        break
    j += 1
k = min(i,j)
while True:
    if k % ans == 0:
        break
    k += 1
ii = (b-i)//c 
jj = (b-j)//d 
kk = (b-k)//ans 
print(b-a-ii-jj+kk)


Fixed submission:
a,b,c,d = map(int,input().split())
cc = b//c -(a-1)//c
dd = b//d -(a-1)//d
#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

#a,bの最小公倍数
def lcm(a, b):
	return a * b // gcd (a, b)
cd = lcm(c, d)
cdcd = b//cd -(a-1)//cd
print(b-a+1-cc-dd+cdcd)

Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
ans = c * d // math.gcd(c,d)
i = a
j = a
while True:
    if i % c == 0:
        break
    i += 1
while True:
    if j % d == 0:
        break
    j += 1
k = min(i,j)
while True:
    if k % ans == 0:
        break
    k += 1
ii = (b-i)//c 
jj = (b-j)//d 
kk = (b-k)//ans 
print(b-a-ii-jj+kk)


Fixed submission:
a,b,c,d = map(int,input().split())
cc = b//c -(a-1)//c
dd = b//d -(a-1)//d
#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

#a,bの最小公倍数
def lcm(a, b):
	return a * b // gcd (a, b)
cd = lcm(c, d)
cdcd = b//cd -(a-1)//cd
print(b-a+1-cc-dd+cdcd)