Buggy python submission (verdict: Runtime Error):
A,B,C,D = map(int,input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a, b):
    gc = gcd(a, b)
    if gc != 0:
        return a * b // gcd (a, b)
    else:
        return a * b
CD = lcm(C,D)
c_div = 0
d_div = 0
cd_div = 0
ans = 0
if A % C == 0:
    first_C = A
else:
    first_C = A + C -(A%C)
last_C = B -(B%C)
c_div = (last_C - first_C)//C + 1

if A % D == 0:
    first_D = A
else:
    first_D = A + D -(A%D)
    last_D = B - (B%D)
d_div = (last_D - first_D)//D + 1

if A % CD == 0:
    first_CD =A
else:
    first_CD = A + CD -(A%CD)
    last_CD = B -(B%CD)
cd_div = (last_CD - first_CD)//CD + 1

ans = c_div + d_div -cd_div
print(B-A+1-ans)


Fixed submission:
A,B,C,D = map(int,input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a, b):
    return a * b // gcd (a, b)
CD = lcm(C,D)
c_div = 0
d_div = 0
cd_div = 0
ans = 0
if A % C == 0:
    first_C = A
else:
    first_C = A + C -(A%C)
last_C = B -(B%C)
c_div = (last_C - first_C)//C + 1

if A % D == 0:
    first_D = A
else:
    first_D = A + D -(A%D)
last_D = B - (B%D)
d_div = (last_D - first_D)//D + 1

if A % CD == 0:
    first_CD =A
else:
    first_CD = A + CD -(A%CD)
last_CD = B -(B%CD)
cd_div = (last_CD - first_CD)//CD + 1

ans = c_div + d_div -cd_div
print(B-A+1-ans)

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

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)

CD = lcm(C,D)
c_div = 0
d_div = 0
cd_div = 0
ans = 0
if A % C == 0:
    first_C = A
else:
    first_C = A + C -(A%C)
last_C = B -(B%C)
c_div = (last_C - first_C)//C + 1

if A % D == 0:
    first_D = A
else:
    first_D = A + D -(A%D)
    last_D = B - (B%D)
d_div = (last_D - first_D)//D + 1

if A % CD == 0:
    first_CD =A
else:
    first_CD = A + CD -(A%CD)
    last_CD = B -(B%CD)
cd_div = (last_CD - first_CD)//CD + 1

ans = c_div + d_div -cd_div
print(B-A+1-ans)


Fixed submission:
A,B,C,D = map(int,input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a, b):
    return a * b // gcd (a, b)
CD = lcm(C,D)
c_div = 0
d_div = 0
cd_div = 0
ans = 0
if A % C == 0:
    first_C = A
else:
    first_C = A + C -(A%C)
last_C = B -(B%C)
c_div = (last_C - first_C)//C + 1

if A % D == 0:
    first_D = A
else:
    first_D = A + D -(A%D)
last_D = B - (B%D)
d_div = (last_D - first_D)//D + 1

if A % CD == 0:
    first_CD =A
else:
    first_CD = A + CD -(A%CD)
last_CD = B -(B%CD)
cd_div = (last_CD - first_CD)//CD + 1

ans = c_div + d_div -cd_div
print(B-A+1-ans)

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

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

CD = lcm(C,D)
c_div = 0
d_div = 0
cd_div = 0
ans = 0

if A % C == 0:
    first_C = A
else:
    first_C = A + C -(A%C)
last_C = B -(B%C)
c_div = (last_C - first_C)//C + 1

if A % D == 0:
    first_D = A
else:
    first_D = A + D -(A%D)
    last_D = B - (B%D)
d_div = (last_D - first_D)//D + 1

if A % CD == 0:
    first_CD =A
else:
    first_CD = A + CD -(A%CD)
    last_CD = B -(B%CD)
cd_div = (last_CD - first_CD)//CD + 1

ans = c_div + d_div -cd_div
print(B-A+1-ans)


Fixed submission:
A,B,C,D = map(int,input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a, b):
    return a * b // gcd (a, b)
CD = lcm(C,D)
c_div = 0
d_div = 0
cd_div = 0
ans = 0
if A % C == 0:
    first_C = A
else:
    first_C = A + C -(A%C)
last_C = B -(B%C)
c_div = (last_C - first_C)//C + 1

if A % D == 0:
    first_D = A
else:
    first_D = A + D -(A%D)
last_D = B - (B%D)
d_div = (last_D - first_D)//D + 1

if A % CD == 0:
    first_CD =A
else:
    first_CD = A + CD -(A%CD)
last_CD = B -(B%CD)
cd_div = (last_CD - first_CD)//CD + 1

ans = c_div + d_div -cd_div
print(B-A+1-ans)

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

CD = lcm(C,D)
c_div = 0
d_div = 0
cd_div = 0

if A % C == 0:
    first_C = A
else:
    first_C = A + C -(A%C)
last_C = B -(B%C)
c_div = (last_C - first_C)//C + 1

if A % D == 0:
    first_D = A
else:
    first_D = A + D -(A%D)
    last_D = B - (B%D)
d_div = (last_D - first_D)//D + 1

if A % CD == 0:
    first_CD =A
else:
    first_CD = A + CD -(A%CD)
    last_CD = B -(B%CD)
cd_div = (last_CD - first_CD)//CD + 1

ans = c_div + d_div -cd_div
print(B-A+1-ans)


Fixed submission:
A,B,C,D = map(int,input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a, b):
    return a * b // gcd (a, b)
CD = lcm(C,D)
c_div = 0
d_div = 0
cd_div = 0
ans = 0
if A % C == 0:
    first_C = A
else:
    first_C = A + C -(A%C)
last_C = B -(B%C)
c_div = (last_C - first_C)//C + 1

if A % D == 0:
    first_D = A
else:
    first_D = A + D -(A%D)
last_D = B - (B%D)
d_div = (last_D - first_D)//D + 1

if A % CD == 0:
    first_CD =A
else:
    first_CD = A + CD -(A%CD)
last_CD = B -(B%CD)
cd_div = (last_CD - first_CD)//CD + 1

ans = c_div + d_div -cd_div
print(B-A+1-ans)