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

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

n = b - a + 1
lcm =  (c*d) //(math.gcd(c, d))

n_c = b//c - (a-1)//c
n_d = b//d - (a-1)//d
n_cd = b//lcm - (a-1)//lcm

print(n - n_c - n_d + n_cd)

Fixed submission:
def gcd(a, b):
    return a if b == 0 else gcd(b, a%b)
 
def lcm(a, b):
    return a // gcd(a, b) * b

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

n = b - a + 1
n_c = b//c - (a-1)//c
n_d = b//d - (a-1)//d
n_cd = b//lcm(c,d) - (a-1)//lcm(c,d)

print(n - n_c - n_d + n_cd)

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

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

n = b - a + 1
lcm =  (c*d) //(math.gcd(c, d))

n_c = b // c - (a-1)//c
n_d = b // d - (a-1)//d
n_cd = b // lcm - (a-1)//lcm

print(n - n_c - n_d + n_cd)

Fixed submission:
def gcd(a, b):
    return a if b == 0 else gcd(b, a%b)
 
def lcm(a, b):
    return a // gcd(a, b) * b

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

n = b - a + 1
n_c = b//c - (a-1)//c
n_d = b//d - (a-1)//d
n_cd = b//lcm(c,d) - (a-1)//lcm(c,d)

print(n - n_c - n_d + n_cd)

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

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

ac_r = a % c
ad_r = a % d
lcm =  (c*d) // math.gcd(c, d)
acd_r = a % lcm
n = b - a + 1

if (ac_r == 0 and n % c == 1) or ((ac_r == 0 and n % c == 2) or (ac_r == 2 and n % c == 2)) :
    n_c = n // c + 1
else:
    n_c = n // c
    
if (ad_r == 0 and n % d == 1) or ((ad_r == 0 and n % d == 2) or (ad_r == 2 and n % d == 2)):
    n_d = n // d + 1
else:
    n_d = n // d
    
if (acd_r == 0 and n % (c*d) == 1) or ((acd_r == 0 and n % (c*d) == 2) or (acd_r == 2 and n % (c*d) == 2)):
    n_cd = n // lcm + 1
else:
    n_cd = n // lcm
    
print(n - (n_c + n_d - n_cd)) 
print(ac_r, ad_r, acd_r, n)

Fixed submission:
def gcd(a, b):
    return a if b == 0 else gcd(b, a%b)
 
def lcm(a, b):
    return a // gcd(a, b) * b

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

n = b - a + 1
n_c = b//c - (a-1)//c
n_d = b//d - (a-1)//d
n_cd = b//lcm(c,d) - (a-1)//lcm(c,d)

print(n - n_c - n_d + n_cd)

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

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

ac_r = a % c
ad_r = a % d
lcm =  (c*d) // math.gcd(c, d)
acd_r = a % lcm
n = b - a + 1

if (ac_r == 0 and n % c == 1) or ((ac_r == 0 and n % c == 2) or (ac_r == 2 and n % c == 2)) :
    n_c = n // c + 1
else:
    n_c = n // c
    
if (ad_r == 0 and n % d == 1) or ((ad_r == 0 and n % d == 2) or (ad_r == 2 and n % d == 2)):
    n_d = n // d + 1
else:
    n_d = n // d
    
if (acd_r == 0 and n % (c*d) == 1) or ((acd_r == 0 and n % (c*d) == 2) or (acd_r == 2 and n % (c*d) == 2)):
    n_cd = n // lcm + 1
else:
    n_cd = n // lcm
    
print(n - (n_c + n_d - n_cd)) 
print(ac_r, ad_r, acd_r, n)

Fixed submission:
def gcd(a, b):
    return a if b == 0 else gcd(b, a%b)
 
def lcm(a, b):
    return a // gcd(a, b) * b

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

n = b - a + 1
n_c = b//c - (a-1)//c
n_d = b//d - (a-1)//d
n_cd = b//lcm(c,d) - (a-1)//lcm(c,d)

print(n - n_c - n_d + n_cd)

Buggy python submission (verdict: Runtime Error):
a, b, c, d = list(map(int,input().split(" ")))

ac_r = a % c
ad_r = a % d
acd_r = a % (c*d)

if (ac_r == 0 and n % c == 1) or ((ac_r == 0 and n % c == 2) or (ac_r == 2 and n % c == 2)) :
    n_c = (b - a + 1) // c + 1
else:
    n_c = (b - a + 1) // c
    
if (ad_r == 0 and n % d == 1) or ((ad_r == 0 and n % d == 2) or (ad_r == 2 and n % d == 2)):
    n_d = (b - a + 1) // d + 1
else:
    n_d = (b - a + 1) // d
    
if (acd_r == 0 and n % (c*d) == 1) or ((acd_r == 0 and n % (c*d) == 2) or (acd_r == 2 and n % (c*d) == 2)):
    n_cd = (b - a + 1) // (c*d) + 1
else:
    n_cd = (b - a + 1) // (c*d)
    
print((b - a + 1) - (n_c + n_d - n_cd))    

Fixed submission:
def gcd(a, b):
    return a if b == 0 else gcd(b, a%b)
 
def lcm(a, b):
    return a // gcd(a, b) * b

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

n = b - a + 1
n_c = b//c - (a-1)//c
n_d = b//d - (a-1)//d
n_cd = b//lcm(c,d) - (a-1)//lcm(c,d)

print(n - n_c - n_d + n_cd)