Buggy python submission (verdict: Runtime Error):
def lcm(a,b):
    return a*b//gcd(a,b)

def su(a,b,c,d):
    count = 0
    for _ in range(a//c, (b+1)//c):
        count += 1
    for _ in range(a//d, (b+1)//d):
        count += 1
    for _ in range(a//lcm(c,d), (b+1)//lcm(c,d)):
        count -= 1

    print(b+1-a-count)
    
def main():
    a,b,c,d = map(int,input().split())
    su(a,b,c,d)
    
if __name__ == '__main__':
    main()

Fixed submission:
def lcm(a,b):
    ab = a*b
    while b != 0:
        a, b = b, a%b
    return ab //a

def su(n,c,d):
    return n - n//c - n//d + n//lcm(c,d)
    
def main():
    a,b,c,d = map(int,input().split())
    print(su(b,c,d) - su(a-1,c,d))
    
if __name__ == '__main__':
    main()

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

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

count = 0
for _ in range(a//c, (b+1)//c):
    count += 1

for _ in range(a//d, (b+1)//d):
    count += 1
for _ in range(a//lcm(c,d), (b+1)//lcm(c,d)):
    count -= 1

print(b+1-a-count)

Fixed submission:
def lcm(a,b):
    ab = a*b
    while b != 0:
        a, b = b, a%b
    return ab //a

def su(n,c,d):
    return n - n//c - n//d + n//lcm(c,d)
    
def main():
    a,b,c,d = map(int,input().split())
    print(su(b,c,d) - su(a-1,c,d))
    
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d = map(int,input().split())
count = 0
for _ in range(a, b+1):
    if _%c != 0 and _%d != 0:
        count += 1

print(count)

Fixed submission:
def lcm(a,b):
    ab = a*b
    while b != 0:
        a, b = b, a%b
    return ab //a

def su(n,c,d):
    return n - n//c - n//d + n//lcm(c,d)
    
def main():
    a,b,c,d = map(int,input().split())
    print(su(b,c,d) - su(a-1,c,d))
    
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d = map(int,input().split())
cdm = [_ for _ in range(a, b+1) if _%c != 0 and _%d != 0]

print(len(cdm))

Fixed submission:
def lcm(a,b):
    ab = a*b
    while b != 0:
        a, b = b, a%b
    return ab //a

def su(n,c,d):
    return n - n//c - n//d + n//lcm(c,d)
    
def main():
    a,b,c,d = map(int,input().split())
    print(su(b,c,d) - su(a-1,c,d))
    
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d = map(int,input().split())
cdm = [_ for _ in range(a, b+1) if _%c == 0 or _%d == 0]

print(b-a-len(cdm)+1)

Fixed submission:
def lcm(a,b):
    ab = a*b
    while b != 0:
        a, b = b, a%b
    return ab //a

def su(n,c,d):
    return n - n//c - n//d + n//lcm(c,d)
    
def main():
    a,b,c,d = map(int,input().split())
    print(su(b,c,d) - su(a-1,c,d))
    
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d = map(int,input().split())
a_b = [_ for _ in range(a, b+1)]

cdm = list(filter(lambda x: x%c == 0 or x%d == 0, a_b))

print(len(a_b)-len(cdm))

Fixed submission:
def lcm(a,b):
    ab = a*b
    while b != 0:
        a, b = b, a%b
    return ab //a

def su(n,c,d):
    return n - n//c - n//d + n//lcm(c,d)
    
def main():
    a,b,c,d = map(int,input().split())
    print(su(b,c,d) - su(a-1,c,d))
    
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d = map(int,input().split())
a_b = [_ for _ in range(a, b+1)]

cm = list(filter(lambda x: x%c == 0, a_b))
dm = list(filter(lambda x: x%d == 0, a_b))
cdm = list(filter(lambda x: x%c == 0 and x%d == 0, a_b))

print(len(a_b)-(len(cm)+len(dm))+len(cdm))

Fixed submission:
def lcm(a,b):
    ab = a*b
    while b != 0:
        a, b = b, a%b
    return ab //a

def su(n,c,d):
    return n - n//c - n//d + n//lcm(c,d)
    
def main():
    a,b,c,d = map(int,input().split())
    print(su(b,c,d) - su(a-1,c,d))
    
if __name__ == '__main__':
    main()