Problem p02995 (python)

Fixed submission:
from math import *
from fractions import *
a,b,c,d=map(int,input().split())

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

def f(a,b,c):
    return (b - a + 1) // c + (1 if b % c <= a % c else 0)

if c != 1 and d != 1:
    print ((b-a+1) - (b // c - ceil(a / c) + 1) - (b // d - ceil(a / d) + 1) + (b // lcm(c, d) - ceil(a / lcm(c, d)) + 1))
else:
    print (0)

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

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

def f(a,b,c):
    return (b - a + 1) // c + (1 if b % c <= a % c else 0)

if c != 1 and d != 1:
    if c != d:
        print ((b-a+1) - (b // c - ceil(a / c) + 1) - (b // d - ceil(a / d) + 1) + (b // lcm(c, d) - ceil(a / lcm(c, d)) + 1))
    else:
        print ((b - a + 1) - f(a, b, c))
else:
    print (0)

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

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

def f(a,b,c):
    return (b - a + 1) // c + (1 if b % c <= a % c else 0)

if c != 1 and d != 1:
    if c != d:
        print ((b-a+1) - f(a,b,c) - f(a,b,d) + f(a,b,lcm(c,d)))
    else:
        print ((b - a + 1) - f(a, b, c))
else:
    print (0)

Buggy submission (verdict: Runtime Error):
from math import *
from fractions import *
a,b,c,d=map(int,input().split())
lcm=lambda x,y: x*y//gcd(x,y)

def f(a,b,c):
    return (b - a + 1) // c + (1 if b % c <= a % c else 0)

if c != 1 and d != 1:
    if c != d:
        print (b-a+1) - f(a,b,c) - f(a,b,d) + f(a,b,lcm(c,d))
    else:
        print (b - a + 1) - f(a, b, c)
else:
    print 0

Buggy submission (verdict: Runtime Error):
from math import *
from fractions import *
a,b,c,d=map(int,raw_input().split())
lcm=lambda x,y: x*y//gcd(x,y)

print(b-a+1 - ((b-a+1)//c + (b-a+1)//d - (b-a+1)//lcm(c,d)))

Buggy submission (verdict: Runtime Error):
from math import *
from fractiosn import *
a,b,c,d=map(int,raw_input().split())
lcm=lambda x,y: x*y//gcd(x,y)

def f(a,b,c):
    return (b - a + 1) // c + (1 if b % c <= a % c else 0)

if c != 1 and d != 1:
    print (b-a+1) - f(a,b,c) - f(a,b,d) + f(a,b,lcm(c,d))
else:
    print 0

Buggy submission (verdict: Runtime Error):
from math import *
a,b,c,d=map(int,input().split())
lcm=lambda x,y:x*y//gcd(x,y)
def f(a,b,c):
    return (b - a + 1) // c + (1 if b % c <= a % c else 0)

if c != 1 and d != 1:
    print ((b-a+1) - f(a,b,c) - f(a,b,d) + f(a,b,lcm(c,d)))
else:
    print (0)

Buggy submission (verdict: Runtime Error):
from math import *
a,b,c,d=map(int,input().split())
lcm=lambda x,y:x*y//gcd(x,y)
def f(a,b,c):
    return (b - a + 1) // c + (1 if b % c <= a % c else 0)
if b >= a:
    if c != 1 and d != 1:
        print ((b-a+1) - f(a,b,c) - f(a,b,d) + f(a,b,lcm(c,d)))
    else:
        print (0)
else:
    print (0)

Buggy submission (verdict: Runtime Error):
from math import *
a,b,c,d=map(int,input().split())
lcm=lambda x,y:x*y//gcd(x,y)
def f(a,b,c):
    return (b - a + 1) // c + (1 if b % c <= a % c else 0)
if c != 1 and d != 1:
    print ((b-a+1) - f(a,b,c) - f(a,b,d) + f(a,b,lcm(c,d)))
else:
    print (0)

Buggy submission (verdict: Runtime Error):
from math import *
a,b,c,d=map(int,input().split())
lcm=lambda x,y:x*y//gcd(x,y)
def f(a,b,c):
    return (b - a + 1) // c + (1 if b % c <= a % c else 0)
print ((b-a+1) - f(a,b,c) - f(a,b,d) + f(a,b,lcm(c,d)))