Buggy python submission (verdict: Runtime Error):
import math
a, b, c, d= list(map(int, input().split()))
m=0
x, y, z=[0,0,0]
def lcm(a, b):
	return int(a*b/math.gcd(a,b))
for i in range(a,b+1):
	if i%c==0:
		x=1+math.floor((b-i)/c)
		break
for i in range(a,b+1):
	if i%d==0:
		y=1+math.floor((b-i)/d)
		break
for i in range(a,b+1):
	if i%lcm(c,d)==0:
		z=1+math.floor((b-i)/lcm(c,d))
		break
print(b-a+1-x-y+z)
# print(x, y, z)
# print(lcm(c, d))
# print(math.gcd(c,d))


Fixed submission:
from fractions import gcd
a,b,c,d=map(int,input().split())
lenth=b-a+1

def lcm(m,n):
	return (m*n)//gcd(m,n)

def divnumber(c):
	ans=lenth//c
	rem1=a%c
	if rem1==0:rem1+=c
	rem2=lenth%c-1
	if rem1+rem2>=c:
		ans+=1
	return ans

print(lenth-divnumber(c)-divnumber(d)+divnumber(lcm(c,d)))

Buggy python submission (verdict: Runtime Error):
import math
a, b, c, d= list(map(int, input().split()))
m=0
x, y, z=[0,0,0]
def lcm(a, b):
	return int(a*b/math.gcd(a,b))
for i in range(a,b+1):
	if i%c==0:
		x=1+math.floor((b-i)/c)
		break
for i in range(a,b+1):
	if i%d==0:
		y=1+math.floor((b-i)/d)
		break
for i in range(a,b+1):
	if i%lcm(c,d)==0:
		z=1+math.floor((b-i)/lcm(c,d))
		break
print(b-a+1-x-y+z)
# print(x, y, z)
# print(lcm(c, d))
# print(math.gcd(c,d))


Fixed submission:
from fractions import gcd
a,b,c,d=map(int,input().split())
lenth=b-a+1

def lcm(m,n):
	return (m*n)//gcd(m,n)

def divnumber(c):
	ans=lenth//c
	rem1=a%c
	if rem1==0:rem1+=c
	rem2=lenth%c-1
	if rem1+rem2>=c:
		ans+=1
	return ans

print(lenth-divnumber(c)-divnumber(d)+divnumber(lcm(c,d)))

Buggy python submission (verdict: Runtime Error):
import math
a, b, c, d= list(map(int, input().split()))
m=0
for i in range(a,b+1):
	if i%c==0:
		x=1+math.floor((b-i)/c)
		break
for i in range(a,b+1):
	if i%d==0:
		y=1+math.floor((b-i)/d)
		break
for i in range(a,b+1):
	if i%(c*d)==0:
		z=1+math.floor((b-i)/(c*d))
		break
print(b-a+1-x-y+z)
# print(x, y, z)


Fixed submission:
from fractions import gcd
a,b,c,d=map(int,input().split())
lenth=b-a+1

def lcm(m,n):
	return (m*n)//gcd(m,n)

def divnumber(c):
	ans=lenth//c
	rem1=a%c
	if rem1==0:rem1+=c
	rem2=lenth%c-1
	if rem1+rem2>=c:
		ans+=1
	return ans

print(lenth-divnumber(c)-divnumber(d)+divnumber(lcm(c,d)))

Buggy python submission (verdict: Runtime Error):
import math
a, b, c, d= list(map(int, input().split()))
m=0
for i in range(a,b+1):
	if i%c==0:
		x=1+math.floor((b-i)/c)
		break
for i in range(a,b+1):
	if i%d==0:
		y=1+math.floor((b-i)/d)
		break
for i in range(a,b+1):
	if i%(c*d)==0:
		z=1+math.floor((b-i)/(c*d))
		break
print(b-a+1-x-y+z)
print(x, y, z)


Fixed submission:
from fractions import gcd
a,b,c,d=map(int,input().split())
lenth=b-a+1

def lcm(m,n):
	return (m*n)//gcd(m,n)

def divnumber(c):
	ans=lenth//c
	rem1=a%c
	if rem1==0:rem1+=c
	rem2=lenth%c-1
	if rem1+rem2>=c:
		ans+=1
	return ans

print(lenth-divnumber(c)-divnumber(d)+divnumber(lcm(c,d)))

Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d= list(map(int, input().split()))
m=0
for i in range(a,b+1):
	if i%c!=0 and i%d!=0:
		m+=1
print(m)

Fixed submission:
from fractions import gcd
a,b,c,d=map(int,input().split())
lenth=b-a+1

def lcm(m,n):
	return (m*n)//gcd(m,n)

def divnumber(c):
	ans=lenth//c
	rem1=a%c
	if rem1==0:rem1+=c
	rem2=lenth%c-1
	if rem1+rem2>=c:
		ans+=1
	return ans

print(lenth-divnumber(c)-divnumber(d)+divnumber(lcm(c,d)))