Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b
def main():
    A,B,C,D=map(input().split())
    if A%C!=0:
        C_min=A-A%C+C
    else:
        C_min=A
    C_max=B-B%C
    if A%D!=0:
        D_min=A-A%D+D
    else:
        D_min=A
    D_max=B-B%D
    if A%(C*D/gcd(C,D))!=0:
        CD_min=A-A%(C*D/gcd(C,D))+(C*D/gcd(C,D))
    else:
        CD_min=A
    CD_max=B-B%(C*D/gcd(C,D))
    C_sum=(C_max-C_min)/C+1
    D_sum=(D_max-D_min)/D+1
    CD_sum=(CD_max-CD_min)/(C*D/gcd(C,D))+1
    sum= B-A+1-int(C_sum+D_sum-CD_sum)
    return sum
print(main())

Fixed submission:
def gcd(a,b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b
def main():
    A,B,C,D=map(int,input().split())
    if A%C!=0:
        C_min=A-A%C+C
    else:
        C_min=A
    C_max=B-B%C
    if A%D!=0:
        D_min=A-A%D+D
    else:
        D_min=A
    D_max=B-B%D
    mod=C*D//gcd(C,D)
    if A%mod!=0:
        CD_min=A-A%mod+mod
    else:
        CD_min=A
    CD_max=B-B%mod
    C_sum=(C_max-C_min)//C
    D_sum=(D_max-D_min)//D
    CD_sum=(CD_max-CD_min)//mod
    sum= B-A+1-int(C_sum+D_sum-CD_sum+1)
    return sum
print(int(main()))

Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b

def main():
    A,B,C,D=map(input().split())
    if A%C!=0:
        C_min=A-A%C+C
    else:
        C_min=A
    C_max=B-B%C
    if A%D!=0:
        D_min=A-A%D+D
    else:
        D_min=A
    D_max=B-B%D
    if A%(C*D/gcd(C,D))!=0:
        CD_min=A-A%(C*D/gcd(C,D))+(C*D/gcd(C,D))
    else:
        CD_min=A
    CD_max=B-B%(C*D/gcd(C,D))
    C_sum=(C_max-C_min)/C+1
    D_sum=(D_max-D_min)/D+1
    CD_sum=(CD_max-CD_min)/(C*D/gcd(C,D))+1
    sum= B-A+1-int(C_sum+D_sum-CD_sum)
    return sum
 
print(main())

Fixed submission:
def gcd(a,b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b
def main():
    A,B,C,D=map(int,input().split())
    if A%C!=0:
        C_min=A-A%C+C
    else:
        C_min=A
    C_max=B-B%C
    if A%D!=0:
        D_min=A-A%D+D
    else:
        D_min=A
    D_max=B-B%D
    mod=C*D//gcd(C,D)
    if A%mod!=0:
        CD_min=A-A%mod+mod
    else:
        CD_min=A
    CD_max=B-B%mod
    C_sum=(C_max-C_min)//C
    D_sum=(D_max-D_min)//D
    CD_sum=(CD_max-CD_min)//mod
    sum= B-A+1-int(C_sum+D_sum-CD_sum+1)
    return sum
print(int(main()))

Buggy python submission (verdict: Runtime Error):
def main():
    A,B,C,D=input().split()
    A=int(A)
    B=int(B)
    C=int(C)
    D=int(D)
    if A%C!=0:
        C_min=A-A%C+C
    else:
        C_min=A
    C_max=B-B%C
    if A%D!=0:
        D_min=A-A%D+D
    else:
        D_min=A
    D_max=B-B%D
    if A%(C*D/gcd(C,D))!=0:
        CD_min=A-A%(C*D/gcd(C,D))+(C*D/gcd(C,D))
    else:
        CD_min=A
    CD_max=B-B%(C*D/gcd(C,D))
    C_sum=(C_max-C_min)/C+1
    D_sum=(D_max-D_min)/D+1
    CD_sum=(CD_max-CD_min)/(C*D/gcd(C,D))+1
    sum= B-A+1-int(C_sum+D_sum-CD_sum)
    return sum

print(main())

Fixed submission:
def gcd(a,b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b
def main():
    A,B,C,D=map(int,input().split())
    if A%C!=0:
        C_min=A-A%C+C
    else:
        C_min=A
    C_max=B-B%C
    if A%D!=0:
        D_min=A-A%D+D
    else:
        D_min=A
    D_max=B-B%D
    mod=C*D//gcd(C,D)
    if A%mod!=0:
        CD_min=A-A%mod+mod
    else:
        CD_min=A
    CD_max=B-B%mod
    C_sum=(C_max-C_min)//C
    D_sum=(D_max-D_min)//D
    CD_sum=(CD_max-CD_min)//mod
    sum= B-A+1-int(C_sum+D_sum-CD_sum+1)
    return sum
print(int(main()))

Buggy python submission (verdict: Runtime Error):
import math
def main():
    A,B,C,D=input().split()
    A=int(A)
    B=int(B)
    C=int(C)
    D=int(D)
    if A%C!=0:
        C_min=A-A%C+C
    else:
        C_min=A
    C_max=B-B%C
    if A%D!=0:
        D_min=A-A%D+D
    else:
        D_min=A
    D_max=B-B%D
    if A%(C*D/math.gcd(C,D))!=0:
        CD_min=A-A%(C*D/math.gcd(C,D))+(C*D/math.gcd(C,D))
    else:
        CD_min=A
    CD_max=B-B%(C*D/math.gcd(C,D))
    C_sum=(C_max-C_min)/C+1
    D_sum=(D_max-D_min)/D+1
    CD_sum=(CD_max-CD_min)/(C*D/math.gcd(C,D))+1
    sum= B-A+1-(C_sum+D_sum-CD_sum)
    return sum

sum=main()
print(sum)

Fixed submission:
def gcd(a,b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b
def main():
    A,B,C,D=map(int,input().split())
    if A%C!=0:
        C_min=A-A%C+C
    else:
        C_min=A
    C_max=B-B%C
    if A%D!=0:
        D_min=A-A%D+D
    else:
        D_min=A
    D_max=B-B%D
    mod=C*D//gcd(C,D)
    if A%mod!=0:
        CD_min=A-A%mod+mod
    else:
        CD_min=A
    CD_max=B-B%mod
    C_sum=(C_max-C_min)//C
    D_sum=(D_max-D_min)//D
    CD_sum=(CD_max-CD_min)//mod
    sum= B-A+1-int(C_sum+D_sum-CD_sum+1)
    return sum
print(int(main()))