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

#
c_d = c * d / fractoins.gcd(c, d)

def check(cc):
    if a%cc == 0:
        tmp_a = a
    else:
        tmp_a = cc*(a//cc+1)
    if b%cc == 0:
        tmp_b = b
    else:
        tmp_b = cc*(b//cc)

    #print('a, b')
    #print(tmp_a, tmp_b)
    if tmp_a > b:
        return 0
    elif tmp_b < a:
        return 0
    tmp = tmp_b-tmp_a

    return (tmp // cc) + 1

# c
tmp_1 = check(c)
#d
tmp_2 = check(d)

tmp_3 = check(c_d)


#print(tmp_1, tmp_2, tmp_3)

print(int((b-a)-(tmp_1+tmp_2-tmp_3*2)))


Fixed submission:
import fractions

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

c_d = (c * d) // fractions.gcd(c, d)

a -= 1

tmp_b = b - (b//c + b//d - b//c_d)
tmp_a = a - (a//c + a//d - a//c_d)

print(tmp_b-tmp_a)

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

#
c_d = c * d / math.gcd(c, d)

def check(cc):
    if a%cc == 0:
        tmp_a = a
    else:
        tmp_a = cc*(a//cc+1)
    if b%cc == 0:
        tmp_b = b
    else:
        tmp_b = cc*(b//cc)

    #print('a, b')
    #print(tmp_a, tmp_b)
    if tmp_a > b:
        return 0
    elif tmp_b < a:
        return 0
    tmp = tmp_b-tmp_a

    return (tmp // cc) + 1

# c
tmp_1 = check(c)
#d
tmp_2 = check(d)

tmp_3 = check(c_d)


#print(tmp_1, tmp_2, tmp_3)


print(int((b-a)-(tmp_1+tmp_2-tmp_3*2)))


Fixed submission:
import fractions

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

c_d = (c * d) // fractions.gcd(c, d)

a -= 1

tmp_b = b - (b//c + b//d - b//c_d)
tmp_a = a - (a//c + a//d - a//c_d)

print(tmp_b-tmp_a)

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

# 最小公倍数
c_d = c * d / math.gcd(c, d)

def check(cc):
    if a%cc == 0:
        tmp_a = a
    else:
        tmp_a = cc*(a//cc+1)
    if b%cc == 0:
        tmp_b = b
    else:
        tmp_b = cc*(b//cc)

    #print('a, b')
    #print(tmp_a, tmp_b)
    if tmp_a > b:
        return 0
    elif tmp_b < a:
        return 0
    tmp = tmp_b-tmp_a

    return (tmp // cc) + 1

# c
tmp_1 = check(c)
#d
tmp_2 = check(d)

tmp_3 = check(c_d)


#print(tmp_1, tmp_2, tmp_3)


print(int((b-a)-(tmp_1+tmp_2-tmp_3*2)))


Fixed submission:
import fractions

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

c_d = (c * d) // fractions.gcd(c, d)

a -= 1

tmp_b = b - (b//c + b//d - b//c_d)
tmp_a = a - (a//c + a//d - a//c_d)

print(tmp_b-tmp_a)

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

# 最小公倍数
c_d = c * d / math.gcd(c, d)

def check(cc):
    if a%cc == 0:
        tmp_a = a
    else:
        tmp_a = cc*(a//cc+1)
    if b%cc == 0:
        tmp_b = b
    else:
        tmp_b = cc*(b//cc)

    #print('a, b')
    #print(tmp_a, tmp_b)
    if tmp_a > b:
        return 0
    elif tmp_b < a:
        return 0
    tmp = tmp_b-tmp_a

    return (tmp // cc) + 1

# c
tmp_1 = check(c)
#d
tmp_2 = check(d)

tmp_3 = check(c_d)


#print(tmp_1, tmp_2, tmp_3)


print(int((b-a)-(tmp_1+tmp_2-tmp_3*2)))


Fixed submission:
import fractions

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

c_d = (c * d) // fractions.gcd(c, d)

a -= 1

tmp_b = b - (b//c + b//d - b//c_d)
tmp_a = a - (a//c + a//d - a//c_d)

print(tmp_b-tmp_a)