Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
def gcd(x,y):
  while y!=0:
    x,y=y,x%y
  return x
C=((b-a+1)//c)+1
D=((b-a+1)//d)+1
CD=((b-a+1)//gcd(c,d if c>d else d,c))+1
print(b-a+1-C-D+CD)


Fixed submission:
import fractions
a,b,c,d=map(int,input().split())
CD=fractions.gcd(c,d)
cd=(c*d)//CD
width=b-a
cnt=0
if width%c==0:
  if a%c==0:
    cnt+=(width//c)+1
  else:
    cnt+=(width//c)
else:
  if c-(a%c)+b%c>=c:
    if a%c==0 or b%c==0:
      cnt+=(width//c)+1
    else:
      cnt+=(width//c)
  else:
    cnt+=(width//c)+1

if width%d==0:
  if a%d==0:
    cnt+=(width//d)+1
  else:
    cnt+=(width//d)
else:
  if d-(a%d)+b%d>=d:
    if a%d==0 or b%d==0:
      cnt+=(width//d)+1
    else:
      cnt+=(width//d)
  else:
    cnt+=(width//d)+1

if width%cd==0:
  if a%cd==0:
    cnt-=(width//cd)+1
  else:
    cnt-=(width//cd)
else:
  if cd-(a%cd)+b%cd>=cd:
    if a%cd==0 or b%cd==0:
      cnt-=(width//cd)+1
    else:
      cnt-=(width//cd)
  else:
    cnt-=(width//cd)+1

print(b-a+1-cnt)

Buggy python submission (verdict: Runtime Error):
import fractions
a,b,c,d=map(int,input().split())
yoso=b-a+1
kobai=fractions.lcm(c,d)
AC=c-(a%c)
if AC==c:
  AC=0
BC=b%c
AD=d-(a%d)
if AD==d:
  AD=0
BD=b%d
A_kobai=a%kobai
if A_kobai==kobai:
  A_kobai=0
B_kobai=b%kobai
C=0
if AC+BC>(yoso%c):
  C=yoso//c
else:
  C=(yoso//c)+1
D=0
if AD+BD>(yoso%d):
  D=yoso//d
else:
  D=(yoso//d)+1
CD=0
if A_kobai+B_kobai>(yoso%kobai):
  CD=yoso//kobai
else:
  CD=(yoso//kobai)+1
print(yoso+CD-C-D)
  


Fixed submission:
import fractions
a,b,c,d=map(int,input().split())
CD=fractions.gcd(c,d)
cd=(c*d)//CD
width=b-a
cnt=0
if width%c==0:
  if a%c==0:
    cnt+=(width//c)+1
  else:
    cnt+=(width//c)
else:
  if c-(a%c)+b%c>=c:
    if a%c==0 or b%c==0:
      cnt+=(width//c)+1
    else:
      cnt+=(width//c)
  else:
    cnt+=(width//c)+1

if width%d==0:
  if a%d==0:
    cnt+=(width//d)+1
  else:
    cnt+=(width//d)
else:
  if d-(a%d)+b%d>=d:
    if a%d==0 or b%d==0:
      cnt+=(width//d)+1
    else:
      cnt+=(width//d)
  else:
    cnt+=(width//d)+1

if width%cd==0:
  if a%cd==0:
    cnt-=(width//cd)+1
  else:
    cnt-=(width//cd)
else:
  if cd-(a%cd)+b%cd>=cd:
    if a%cd==0 or b%cd==0:
      cnt-=(width//cd)+1
    else:
      cnt-=(width//cd)
  else:
    cnt-=(width//cd)+1

print(b-a+1-cnt)

Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
yoso=b-a+1
kobai=math.gcd(c,d)
BC=b%c
BD=b%d
Bkobai=b%kobai
C=0
if BC>=(yoso%c):
  C=yoso//c
else:
  C=(yoso//c)+1
D=0
if BD>=(yoso%d):
  D=yoso//d
else:
  D=(yoso//d)+1
CD=0
if Bkobai>=(yoso%kobai):
  CD=yoso//kobai
else:
  CD=(yoso//kobai)+1
print(yoso+CD-C-D)
  


Fixed submission:
import fractions
a,b,c,d=map(int,input().split())
CD=fractions.gcd(c,d)
cd=(c*d)//CD
width=b-a
cnt=0
if width%c==0:
  if a%c==0:
    cnt+=(width//c)+1
  else:
    cnt+=(width//c)
else:
  if c-(a%c)+b%c>=c:
    if a%c==0 or b%c==0:
      cnt+=(width//c)+1
    else:
      cnt+=(width//c)
  else:
    cnt+=(width//c)+1

if width%d==0:
  if a%d==0:
    cnt+=(width//d)+1
  else:
    cnt+=(width//d)
else:
  if d-(a%d)+b%d>=d:
    if a%d==0 or b%d==0:
      cnt+=(width//d)+1
    else:
      cnt+=(width//d)
  else:
    cnt+=(width//d)+1

if width%cd==0:
  if a%cd==0:
    cnt-=(width//cd)+1
  else:
    cnt-=(width//cd)
else:
  if cd-(a%cd)+b%cd>=cd:
    if a%cd==0 or b%cd==0:
      cnt-=(width//cd)+1
    else:
      cnt-=(width//cd)
  else:
    cnt-=(width//cd)+1

print(b-a+1-cnt)