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

A,B,C,D = map(int,input().split())
A -= 1
g = math.gcd(C, D)
l = C * D / g

sA = A // C
eA = A // D
lA = A - (eA + sA) + A // l

sB = B // C
eB = B // D
lB = B - (eB + sB) + B // l
print(int(lB - lA))


Fixed submission:
import fractions

A,B,C,D = map(int,input().split())
l = C*D // fractions.gcd(C,D)
x = (A-1) -(A-1)//C - (A-1)//D + (A-1)//l
y = B - B//C - B//D + B//l
print(y-x)

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

A = int(input())
B = int(input())
C = int(input())
D = int(input())

multi = C * D
multiGcd = int((C * D) // math.gcd(C, D))

nC = int((A - 1) // C)
nD = int((A - 1) // D)
mC = int(B // C)
mD = int(B // D)

nM = int((A - 1) // multi)
mM = int(B // multi)

wC = mC - nC
wD = mD - nD
wM = mM - nM
wCD = wC + wD - wM

nGcd = int((A - 1) // multiGcd)
mGcd = int(B // multiGcd)
wGcD = mGcd - nGcd

ans = B - (A - 1) - wCD
if multiGcd != multi:
    ans += wGcD
print(ans)


Fixed submission:
import fractions

A,B,C,D = map(int,input().split())
l = C*D // fractions.gcd(C,D)
x = (A-1) -(A-1)//C - (A-1)//D + (A-1)//l
y = B - B//C - B//D + B//l
print(y-x)

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

multi = C * D
multiGcd = int((C * D) // math.gcd(C, D))

nC = int((A - 1) // C)
nD = int((A - 1) // D)
mC = int(B // C)
mD = int(B // D)

nM = int((A - 1) // multi)
mM = int(B // multi)

wC = mC - nC
wD = mD - nD
wM = mM - nM
wCD = wC + wD - wM

nGcd = int((A - 1) // multiGcd)
mGcd = int(B // multiGcd)
wGcD = mGcd - nGcd

ans = B - (A - 1) - wCD
if multiGcd != multi:
    ans += wGcD
print(ans)


Fixed submission:
import fractions

A,B,C,D = map(int,input().split())
l = C*D // fractions.gcd(C,D)
x = (A-1) -(A-1)//C - (A-1)//D + (A-1)//l
y = B - B//C - B//D + B//l
print(y-x)

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

A, B, C, D = map(int, input().split())
multi = C * D
multiGcd = int(math.floor((C * D) / math.gcd(C, D)))

nC = int(math.floor((A - 1) / C))
nD = int(math.floor((A - 1) / D))
mC = int(math.floor(B / C))
mD = int(math.floor(B / D))

nM = int(math.floor((A - 1) / multi))
mM = int(math.floor(B / multi))

wC = mC - nC
wD = mD - nD
wM = mM - nM
wCD = wC + wD - wM

nGcd = int(math.floor((A - 1) / multiGcd))
mGcd = int(math.floor(B / multiGcd))
wGcD = mGcd - nGcd

ans = B - (A - 1) - wCD
if multiGcd != multi:
    ans += wGcD
print(ans)


Fixed submission:
import fractions

A,B,C,D = map(int,input().split())
l = C*D // fractions.gcd(C,D)
x = (A-1) -(A-1)//C - (A-1)//D + (A-1)//l
y = B - B//C - B//D + B//l
print(y-x)

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

A, B, C, D = map(int, input().split())
multi = C * D
multiGcd = int((C * D) // math.gcd(C, D))

nC = int(math.floor((A - 1) / C))
nD = int(math.floor((A - 1) / D))
mC = int(math.floor(B / C))
mD = int(math.floor(B / D))

nM = int(math.floor((A - 1) / multi))
mM = int(math.floor(B / multi))

wC = mC - nC
wD = mD - nD
wM = mM - nM
wCD = wC + wD - wM

nGcd = int(math.floor((A - 1) / multiGcd))
mGcd = int(math.floor(B / multiGcd))
wGcD = mGcd - nGcd

ans = B - (A - 1) - wCD
if multiGcd != multi:
    ans += wGcD
print(ans)


Fixed submission:
import fractions

A,B,C,D = map(int,input().split())
l = C*D // fractions.gcd(C,D)
x = (A-1) -(A-1)//C - (A-1)//D + (A-1)//l
y = B - B//C - B//D + B//l
print(y-x)