Buggy python submission (verdict: Runtime Error):
import math

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

adivc = A//C
if A%C != 0:
    adivc = A//C + 1
bdivc = B//C
countC = bdivc - adivc + 1

adivd = A//D
if A%D != 0:
    adivd = A//D + 1
bdivd = B//D
countD = bdivd - adivd + 1

lcm = (int)(C * (D / math.gcd(C, D)))
adivlcm = A // lcm
if A%lcm != 0:
    adivlcm = A // lcm + 1
bdivlcm = B // lcm
countlcm = bdivlcm - adivlcm + 1

print(B-A+1-(countC+countD-countlcm))

Fixed submission:
from fractions import gcd

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

adivc = A//C
if A%C != 0:
    adivc = A//C + 1
bdivc = B//C
countC = bdivc - adivc + 1

adivd = A//D
if A%D != 0:
    adivd = A//D + 1
bdivd = B//D
countD = bdivd - adivd + 1

lcm = (int)(C * D / gcd(C, D))
adivlcm = A // lcm
if A%lcm != 0:
    adivlcm = A // lcm + 1
bdivlcm = B // lcm
countlcm = bdivlcm - adivlcm + 1

print(B-A+1-(countC+countD-countlcm))

Buggy python submission (verdict: Runtime Error):
import math

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

adivc = A//C
if A%C != 0:
    adivc = A//C + 1
bdivc = B//C
countC = bdivc - adivc + 1

adivd = A//D
if A%D != 0:
    adivd = A//D + 1
bdivd = B//D
countD = bdivd - adivd + 1

lcm = (int)(C * D / math.gcd(C, D))
adivlcm = A // lcm
if A%lcm != 0:
    adivlcm = A // lcm + 1
bdivlcm = B // lcm
countlcm = bdivlcm - adivlcm + 1

print(B-A+1-(countC+countD-countlcm))

Fixed submission:
from fractions import gcd

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

adivc = A//C
if A%C != 0:
    adivc = A//C + 1
bdivc = B//C
countC = bdivc - adivc + 1

adivd = A//D
if A%D != 0:
    adivd = A//D + 1
bdivd = B//D
countD = bdivd - adivd + 1

lcm = (int)(C * D / gcd(C, D))
adivlcm = A // lcm
if A%lcm != 0:
    adivlcm = A // lcm + 1
bdivlcm = B // lcm
countlcm = bdivlcm - adivlcm + 1

print(B-A+1-(countC+countD-countlcm))

Buggy python submission (verdict: Runtime Error):
import math

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

adivc = A//C
if A%C != 0:
    adivc = A//C + 1
bdivc = B//C
countC = bdivc - adivc + 1

adivd = A//D
if A%D != 0:
    adivd = A//D + 1
bdivd = B//D
countD = bdivd - adivd + 1

lcm = (int)(C * D / math.gcd(C, D))
adivlcm = A // lcm
if A%lcm != 0:
    adivlcm = A // lcm + 1
bdivlcm = B // lcm
countlcm = bdivlcm - adivlcm + 1

print(B-A+1-(countC+countD-countlcm))

Fixed submission:
from fractions import gcd

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

adivc = A//C
if A%C != 0:
    adivc = A//C + 1
bdivc = B//C
countC = bdivc - adivc + 1

adivd = A//D
if A%D != 0:
    adivd = A//D + 1
bdivd = B//D
countD = bdivd - adivd + 1

lcm = (int)(C * D / gcd(C, D))
adivlcm = A // lcm
if A%lcm != 0:
    adivlcm = A // lcm + 1
bdivlcm = B // lcm
countlcm = bdivlcm - adivlcm + 1

print(B-A+1-(countC+countD-countlcm))

Buggy python submission (verdict: Runtime Error):
import math

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

adivc = A//C
if A%C != 0:
    adivc = A//C + 1
bdivc = B//C
print(adivc,bdivc)
countC = bdivc - adivc + 1

adivd = A//D
if A%D != 0:
    adivd = A//D + 1
bdivd = B//D
print(adivd,bdivd)
countD = bdivd - adivd + 1

lcm = (int)(C * D / math.gcd(C, D))
adivlcm = A // lcm
if A%lcm != 0:
    adivlcm = A // lcm + 1
bdivlcm = B // lcm
countlcm = bdivlcm - adivlcm + 1

print(B-A+1-(countC+countD-countlcm))

Fixed submission:
from fractions import gcd

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

adivc = A//C
if A%C != 0:
    adivc = A//C + 1
bdivc = B//C
countC = bdivc - adivc + 1

adivd = A//D
if A%D != 0:
    adivd = A//D + 1
bdivd = B//D
countD = bdivd - adivd + 1

lcm = (int)(C * D / gcd(C, D))
adivlcm = A // lcm
if A%lcm != 0:
    adivlcm = A // lcm + 1
bdivlcm = B // lcm
countlcm = bdivlcm - adivlcm + 1

print(B-A+1-(countC+countD-countlcm))

Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,D = map(int,input().split())
#print(A,B,C,D)
adivc = A//C
if A%C != 0:
    adivc = A//C + 1
bdivc = B//C
listc=[]
for i in range(adivc,bdivc+1):
    listc.append(str(C*i))
setc = set(listc)
#print(setc)

adivd = A//D
if A%D != 0:
    adivd = A//D + 1
bdivd = B//D
listd=[]
for i in range(adivd,bdivd+1):
    listd.append(str(D*i))
setd = set(listd)
#print(setd)

setcd = setc | setd
#print(setcd)
#print(len(setcd))

print(B-A+1-len(setcd))

Fixed submission:
from fractions import gcd

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

adivc = A//C
if A%C != 0:
    adivc = A//C + 1
bdivc = B//C
countC = bdivc - adivc + 1

adivd = A//D
if A%D != 0:
    adivd = A//D + 1
bdivd = B//D
countD = bdivd - adivd + 1

lcm = (int)(C * D / gcd(C, D))
adivlcm = A // lcm
if A%lcm != 0:
    adivlcm = A // lcm + 1
bdivlcm = B // lcm
countlcm = bdivlcm - adivlcm + 1

print(B-A+1-(countC+countD-countlcm))

Buggy python submission (verdict: Runtime Error):
import math

A,B,C,D = map(int,input().split())
#print(A,B,C,D)
lcm = C * D / math.gcd(C,D)
count = 0
for i in range(A,B+1):
    if i%lcm != 0:
        count+=1
print(count)

Fixed submission:
from fractions import gcd

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

adivc = A//C
if A%C != 0:
    adivc = A//C + 1
bdivc = B//C
countC = bdivc - adivc + 1

adivd = A//D
if A%D != 0:
    adivd = A//D + 1
bdivd = B//D
countD = bdivd - adivd + 1

lcm = (int)(C * D / gcd(C, D))
adivlcm = A // lcm
if A%lcm != 0:
    adivlcm = A // lcm + 1
bdivlcm = B // lcm
countlcm = bdivlcm - adivlcm + 1

print(B-A+1-(countC+countD-countlcm))

Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,D = map(int,input().split())
#print(A,B,C,D)
count = 0
for i in range(A,B+1):
    if i%C != 0 and i%D != 0:
        count+=1
print(count)

Fixed submission:
from fractions import gcd

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

adivc = A//C
if A%C != 0:
    adivc = A//C + 1
bdivc = B//C
countC = bdivc - adivc + 1

adivd = A//D
if A%D != 0:
    adivd = A//D + 1
bdivd = B//D
countD = bdivd - adivd + 1

lcm = (int)(C * D / gcd(C, D))
adivlcm = A // lcm
if A%lcm != 0:
    adivlcm = A // lcm + 1
bdivlcm = B // lcm
countlcm = bdivlcm - adivlcm + 1

print(B-A+1-(countC+countD-countlcm))