ZhenlongDai/ACPR huggingface dataset:
Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B, C, D = map(int, input().split())

def getLCM(a, b):
    r = -1

    if C > D:
        a = C
        b = D
    else:
        a = D
        b = C

    while True:
        r = a % b
        if r == 0:
            b = int(C*D/b)
            return b
        a = b
        b = r

E = 1
if C > D:
    E = getLCM(C, D)
else:
    E = getLCM(D, C)

c = int(B / C)
d = int(B / D)
e = int(B / E)
ans1 = (B-c-d+e)

c = int((A-1) / C)
d = int((A-1) / D)
e = int((A-1) / E)
ans2 = ((A-1)-c-d+e)

ans = ans1 - ans2
print(ans)


Failing test case input:
6354199306375155 38464981823067483 7 91372231

Expected output:
27523527570226360


Actual output:
27523527570226359


Fixed submission (verdict: Accepted):
A, B, C, D = map(int, input().split())

def getLCM(a, b):
    while True:
        r = a % b
        if r == 0:
            b = int(C*D
            return b
        a = b
        b = r

E = 1
if C != D:
    if C > D:
        E = getLCM(C, D)

    elif D > C:
        E = getLCM(D, C)

    c = int(B 
    d = int(B 
    e = int(B 
    ans1 = (B-c-d+e)

    c = int((A-1) 
    d = int((A-1) 
    e = int((A-1) 
    ans2 = ((A-1)-c-d+e)
else:
    c = int(B 
    ans1 = (B-c)

    c = int((A-1) 
    ans2 = ((A-1)-c)

ans = ans1 - ans2
if ans < 0:
    ans = 0
print(ans)

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

a,b,c,d=map(int,input().split())
cc=int((b-a+1)/c)
dd=int((b-a+1)/d)
i = 0
f = [c]
x = 10000000
k = [c, d]

while x != 0:
    x = max(k) % min(k)
    if x != 0:
        f.append(x)
    k.sort()
    k[1] = x
cd=int((b-a+1)/(c*d))
print(b-a+1-cc-dd+cd)

Failing test case input:
2755958446070485 108249065682174014 20 109641300

Expected output:
100218451874298354


Actual output:
100218450960240861


Fixed submission (verdict: Accepted):

a, b, c, d = map(int, input().split())


f = [c]
x = 1000000
k = [c, d]

while x != 0:
    x = max(k) % min(k)

    if x != 0:
        f.append(x)
    k.sort()
    k[1] = x


cc = (b 
dd = (b 
cd =(b 




print(int(b - a + 1 - cc - dd + cd))

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import fractions

a,b,c,d=map(int, input().split())

def lcm(x, y):
    return (x * y) 

x =int((b-1)/c)-int((a/c))
y =int((b-1)/d)-int((a/d))
n =lcm(c,d)
xy=int(b/n)-int((a/n))

ans = (b-a+1) - (x+y-xy)
print(ans)

Failing test case input:
4799622382541550 38464981823067483 7 46883758

Expected output:
28856021762113509


Actual output:
28856021762113508


Fixed submission (verdict: Accepted):
import fractions
 
a,b,c,d=map(int, input().split())
 
def lcm(x, y):
    return (x * y) 
 
x =(b
y =(b
n =lcm(c,d)
xy=(b
 
ans = (b-a+1) - (x+y-xy)
print(ans)
Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math


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


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


a, b, c, d = map(int, input().split())
ans = 0


cd = lcm(c, d)

cdiv = int(b / c) - int((a - 1) / c)
ddiv = int(b / d) - int((a - 1) / d)
cddiv = int(b / cd) - int((a - 1) / cd)
ans = b - a + 1 - cdiv - ddiv + cddiv

print(ans)


Failing test case input:
11519628362605307 5772277299890772 391 3058835041

Expected output:
-5732651953340016


Actual output:
-5732651953263129


Fixed submission (verdict: Accepted):
import math


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


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


a, b, c, d = map(int, input().split())
ans = 0


cd = lcm(c, d)

bdiv = (b 
adiv = ((a - 1) 
ans = (b - a) - (bdiv - adiv) + 1

print(ans)

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def u(a,b):
  if b == 0:
    return a
  return u(b, a%b)

a,b,c,d = map(int,input().split())

e=int(c/u(c,d)*d)
a=a-1
ac = int(a / c)
bc = int(b / c)
ad = int(a / d)
bd = int(b / d)
ae = int(a / e)
be = int(b / e)

print(b - a - (bc - ac + bd - ad ) + (be - ae))

Failing test case input:
4445144871656471 45404042833744343 8 85843371

Expected output:
35839035299333548


Actual output:
35839035299333547


Fixed submission (verdict: Accepted):
def u(a,b):
  if b == 0:
    return a
  return u(b, a%b)

a,b,c,d = map(int,input().split())

e=int(c/u(c,d)*d)
a=a-1
ac = (a 
bc = (b 
ad = (a 
bd = (b 
ae = (a 
be = (b 

print(b - a - (bc - ac + bd - ad ) + (be - ae))

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
A,B,C,D = map(int, input().split())

A = A-1
c_and_d=C*D

lcm =1


count_C =0
count_D =0
count_C_and_D =0

count_C = int(B/C)-int(A/C)
count_D = int(B/D)-int(A/D)
count_C_and_D = int(B/lcm)-int(A/lcm)
A = A+1
print((B-A+1) -(count_C + count_D - count_C_and_D))

Failing test case input:
2378114867615524 188107035759759287 33 70304397

Expected output:
180100769372579622


Actual output:
365829690024561354


Fixed submission (verdict: Accepted):
import fractions

A,B,C,D = map(int, input().split())


c_and_d=C*D

lcm = int(C*D


count_C =0
count_D =0
count_C_and_D =0

count_C = int(B
count_D = int(B
count_C_and_D = int(B

print(int((B-A+1) -(count_C + count_D - count_C_and_D)))

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A,B,C,D=list(map(int,input().split()))
x=max(C,D)
y=min(C,D)
if x%y==0:
    gcd=C*D
else:
    while x%y!=0:
        z=x%y
        x=y
        y=z
    gcd=C*D
print(B-A+1)

Failing test case input:
6354199306375155 20832163180120607 17 91372231

Expected output:
13626318790865960


Actual output:
14477963873745453


Fixed submission (verdict: Accepted):
A,B,C,D=list(map(int,input().split()))
x=max(C,D)
y=min(C,D)
if x%y==0:
    gcd=C*D
else:
    while x%y!=0:
        z=x%y
        x=y
        y=z
    gcd=C*D
print(B-A+1-(B
Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
def gcd(a,b):
  if a < b:
     a,b = b,a
  c = a%b
  if c == 0:
    return b
  return gcd(b,c)

A,B,C,D = map(int,input().split())
x = gcd(C,D)
count = 0
x = int(C*D/x)
a = (B/C)-((A-1)/C)
b = (B/D)-((A-1)/D)
c = (B/x)-((A-1)/x)
a = math.ceil(a)
b = math.ceil(b)
c = math.ceil(c)
ans = B-A+1 - (a+b-c)
print(ans)

Failing test case input:
2378114867615524 188107035759759287 33 70304397

Expected output:
180100769372579622


Actual output:
180100769372579620


Fixed submission (verdict: Accepted):
import math
def gcd(a,b):
  if a < b:
     a,b = b,a
  c = a%b
  if c == 0:
    return b
  return gcd(b,c)

A,B,C,D = map(int,input().split())
x = gcd(C,D)
count = 0
x = int(C*D/x)
a = (B
b = (B
c = (B
ans = B-A+1 - (a+b-c)
print(ans)

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def gcd(x, y):  
    if y == 0:
        return x
    else:
        return gcd(y, x % y) 


if __name__ == "__main__":
    a, b, c, d =  map(int, input().split())
    
    
    
    bai_c = b 
    bai_d = b 

    l  = (c * d) / gcd(c, d)
    b_duplicated = b 

    bai_c2 = (a - 1) 
    bai_d2 = (a - 1) 
    
    l2 = (c * d) / gcd(c, d)
    a_duplicated = (a - 1) 
    
    ans = (b - (bai_c + bai_d - b_duplicated)) - ((a - 1) - (bai_c2 + bai_d2 - a_duplicated))
    print(int(ans))

Failing test case input:
11519628362605307 5772277299890772 391 5732805158

Expected output:
-5732651954137286


Actual output:
0


Fixed submission (verdict: Accepted):
def gcd(x, y):  
    if y == 0:
        return x
    else:
        return gcd(y, x % y) 


if __name__ == "__main__":
    a, b, c, d =  map(int, input().split())
    
    
    
    bai_c = int(b 
    bai_d = int(b 

    l  = int((c * d) / gcd(c, d))
    b_duplicated = int(b 

    bai_c2 = int((a - 1) 
    bai_d2 = int((a - 1) 
    
    l2 = int((c * d) / gcd(c, d))
    a_duplicated = int((a - 1) 
    
    ans = (b - (bai_c + bai_d - b_duplicated)) - ((a - 1) - (bai_c2 + bai_d2 - a_duplicated))
    print(int(ans))
Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
logging.disable(logging.CRITICAL)


def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            z = x % y
            x = y
            y = z
        else:
            return z

def main():
    A, B, C, D = (int(x) for x in input().split())
    lcm_CD = C * D / gcd(C, D)
    
    div_C = int(B / C) - int((A - 1) / C)
    div_D = int(B / D) - int((A - 1) / D)
    div_lcm_CD = int(B / lcm_CD) - int((A - 1) / lcm_CD)
    
    answer = B - A + 1 - div_C - div_D + div_lcm_CD
    
    print(answer)

if __name__ == "__main__":
    main()


Failing test case input:
2755958446070485 170847880819691070 32 109641300

Expected output:
162839048457975697


Actual output:
162839048457975696


Fixed submission (verdict: Accepted):
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
logging.disable(logging.CRITICAL)


def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            z = x % y
            x = y
            y = z
        else:
            return z

def main():
    A, B, C_, D_ = (int(x) for x in input().split())

    if C_ > D_:
        C, D = D_, C_
    else:
        C, D = C_, D_
        

    lcm_CD = int(C * D / gcd(C, D))
    
    div_C = int(B 
    div_D = int(B 
    div_lcm_CD = int(B 
    
    answer = B - A + 1 - div_C - div_D + div_lcm_CD

    if A == 0:
        print(answer - 1)
    else:
        print(answer)

if __name__ == "__main__":
    main()

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

a, b, c, d = [int(i) for i in input().split()]
c1, d1 = [d if c < d else c, c if c < d else d]
while d1 > 0:
    e = d1
    d1 = c1 % d1
    c1 = e
e = c * d / e
print(e)
cnt = (b - a + 1) + int(b / e) - int((a-1) / e) - int(b / c) + int((a-1) / c) - int(b / d) + int((a-1) / d)
print(cnt)


Failing test case input:
10 40 10 8

Expected output:
24


Actual output:
40.0
24


Fixed submission (verdict: Accepted):

a, b, c, d = [int(i) for i in input().split()]
c1 = d if c < d else c
d1 = c if c < d else d
while d1 != 0:
    e = d1
    d1 = c1 % d1
    c1 = e
e = int((c * d) / e)
a -= 1
cnt = (b - a) + int(b 
print(cnt)
Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def gcd(x, y):  
    if y == 0:
        return x
    else:
        return gcd(y, x % y) 


if __name__ == "__main__":


    a, b, c, d = 4, 9, 2, 3
    
    
    
    bai_c = b 
    bai_d = b 

    l  = (c * d) / gcd(c, d)
    b_duplicated = b 

    bai_c2 = (a - 1) 
    bai_d2 = (a - 1) 
    
    l2 = (c * d) / gcd(c, d)
    a_duplicated = (a - 1) 
    
    ans = (b - (bai_c + bai_d - b_duplicated)) - ((a - 1) - (bai_c2 + bai_d2 - a_duplicated))
    print(int(ans))

Failing test case input:
4445144871656471 45404042833744343 8 85843371

Expected output:
35839035299333548


Actual output:
0


Fixed submission (verdict: Accepted):
def gcd(x, y):  
    if y == 0:
        return x
    else:
        return gcd(y, x % y) 


if __name__ == "__main__":
    a, b, c, d =  map(int, input().split())
    
    
    
    bai_c = int(b 
    bai_d = int(b 

    l  = int((c * d) / gcd(c, d))
    b_duplicated = int(b 

    bai_c2 = int((a - 1) 
    bai_d2 = int((a - 1) 
    
    l2 = int((c * d) / gcd(c, d))
    a_duplicated = int((a - 1) 
    
    ans = (b - (bai_c + bai_d - b_duplicated)) - ((a - 1) - (bai_c2 + bai_d2 - a_duplicated))
    print(int(ans))

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

a, b, c, d = [int(i) for i in input().split()]
c1 = d if c < d else c
d1 = c if c < d else d
while d1 != 0:
    e = d1
    d1 = c1 % d1
    c1 = e
e = c * d / e
a -= 1
cnt = (b - a) + b 
print(cnt)


Failing test case input:
3382646650741871 11488237810087203 7 5732805158

Expected output:
6947649563941232


Actual output:
19593828969432536


Fixed submission (verdict: Accepted):

a, b, c, d = [int(i) for i in input().split()]
c1 = d if c < d else c
d1 = c if c < d else d
while d1 != 0:
    e = d1
    d1 = c1 % d1
    c1 = e
e = int((c * d) / e)
a -= 1
cnt = (b - a) + int(b 
print(cnt)

Problem: p02995
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from math import gcd
a,b,c,d=list(map(int,input().split()))

def calculation(x,c,d):
	x-=x
	x-=x
	x+=x
	return x
	
print(calculation(b,c,d)-calculation(a,c,d))

Failing test case input:
6354199306375155 20832163180120607 9 91372231

Expected output:
12869301080262296


Actual output:
0


Fixed submission (verdict: Accepted):
from math import gcd
a,b,c,d=list(map(int,input().split()))
a-=1
def calculation(x,c,d):
	x=x-(x
	return x
	
print(calculation(b,c,d)-calculation(a,c,d))
Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys


scan = sys.stdin.readline


def main():
  a, b, c, d = map(int, scan().rstrip().split())
  
  
  if c > d:
    _ = c
    c = d
    d = _
  
  cd_mul_to_a = -(a-1) 
  cd_mul_to_b = -b 
  
  cd_mul_to_a += (a-1) 
  cd_mul_to_b += b 
  
  cd_mul_to_a += (a-1) 
  cd_mul_to_b += b 
  
  total = (b - a + 1) - (cd_mul_to_b - cd_mul_to_a)
  
  print(total)


main()


Failing test case input:
4445144871656471 45404042833744343 8 85843371

Expected output:
35839035299333548


Actual output:
0


Fixed submission (verdict: Accepted):
import sys
from fractions import gcd


scan = sys.stdin.readline


def lcm(x, y):
  return (x * y) 


def main():
  a, b, c, d = map(int, scan().rstrip().split())
  
  
  if c > d:
    _ = c
    c = d
    d = _
  
  cd_mul_to_a = -((a-1) 
  cd_mul_to_b = -(b 
  
  cd_mul_to_a += (a-1) 
  cd_mul_to_b += b 
  
  cd_mul_to_a += (a-1) 
  cd_mul_to_b += b 
  
  total = (b - a + 1) - (cd_mul_to_b - cd_mul_to_a)
  
  print(total)


main()

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,c,d=map(int,input().split())

def div(x,y):
  return y

def div2(x):
  return div(x,b)-div(x,a-1)
  
print(b-a+1-div2(c)-div2(d)+div2(c*d))

Failing test case input:
18199866983000874 11488237810087203 461 5732805158

Expected output:
-6697070323214204


Actual output:
0


Fixed submission (verdict: Accepted):
import fractions as fr
a,b,c,d=map(int,input().split())

def div(x,y):
  return y

def div2(x):
  return div(x,b)-div(x,a-1)
  
print(b-a+1-div2(c)-div2(d)+div2(c*d

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,c,d=map(int,input().split())
s=b-a
bc=b
if a%c==0:
    ac=a
else:
    ac=a
bd=b
if a%d==0:
    ad=a
else:
    ad=a
e=c
f=d
while f:
    e, f = f, e % f
gcd=e
l=c*d/gcd
bl=b
if a%l==0:
    al=a
else:
    al=a
print(int(b-a+1-(bc-ac+bd-ad-bl+al)))

Failing test case input:
10127406995146061 11488237810087203 7 5732805158

Expected output:
1166426412603228


Actual output:
1


Fixed submission (verdict: Accepted):
a,b,c,d=map(int,input().split())
bc=int(b
if a%c==0:
    ac=int(a
else:
    ac=int(a
bd=b
if a%d==0:
    ad=int(a
else:
    ad=int(a
e=c
f=d
while f:
    e, f = f, int(e % f)
gcd=int(e)
l=int(c*d/gcd)
bl=int(b
if a%l==0:
    al=int(a
else:
    al=int(a
s=int(b-a+1)
s2=int(bc-ac+bd-ad-bl+al)
print(s-s2)

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def u(a,b):
  if b == 0:
    return a
  return u(b, a%b)

a,b,c,d = map(int,input().split())

e=int(c*d/u(c,d))
a=a-1
ac = int(a / c)
bc = int(b / c)
ad = int(a / d)
bd = int(b / d)
ae = int(a / e)
be = int(b / e)

print(b - a - (bc - ac + bd - ad ) + (be - ae))

Failing test case input:
6354199306375155 38464981823067483 7 91372231

Expected output:
27523527570226360


Actual output:
27523527570226359


Fixed submission (verdict: Accepted):
def u(a,b):
  if b == 0:
    return a
  return u(b, a%b)

a,b,c,d = map(int,input().split())

e=int(c/u(c,d)*d)
a=a-1
ac = (a 
bc = (b 
ad = (a 
bd = (b 
ae = (a 
be = (b 

print(b - a - (bc - ac + bd - ad ) + (be - ae))
Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

a, b, c, d = map(int, input().split())
cc = int(b / c) - int(a / c)



dd = int(b / d) - int(a / d)

i = 0
f = [c]
x = 10000000
k = [c, d]

while x != 0:
    x = max(k) % min(k)

    if x != 0:
        f.append(x)
    k.sort()
    k[1] = x



cd = int(b / (c * d )) - int(a / (c * d ))

print(b - a+1 - cc - dd + cd)

Failing test case input:
2 40 8 8

Expected output:
34


Actual output:
29


Fixed submission (verdict: Accepted):

a, b, c, d = map(int, input().split())


f = [c]
x = 1000000
k = [c, d]

while x != 0:
    x = max(k) % min(k)

    if x != 0:
        f.append(x)
    k.sort()
    k[1] = x


cc = (b 
dd = (b 
cd =(b 




print(int(b - a + 1 - cc - dd + cd))

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B, C, D = map(int,input().split())

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

E = int(C*D / gcd(C, D))

def func(x):
    return x - (int(x/C) + int(x/D) - int(x/E))

print(func(B) - func(A-1))

Failing test case input:
6097942338975935 45404042833744343 8 85843371

Expected output:
34392837532275953


Actual output:
34392837532275952


Fixed submission (verdict: Accepted):
A, B, C, D = map(int,input().split())

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

lcm = int(C*D / gcd(C, D))

def func(x):
    return x - int(x

print(func(B) - func(A-1))

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def gcd(m,n):
    x=max(m,n)
    y=min(m,n)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x=y
            y=z
        else:
            return z
A,B,C,D=map(int,input().split())

if A%C==0:
    x=B
else:
    x=B
if A%D==0:
    y=B
else:
    y=B
E=C*D/gcd(C,D)
if A%E==0:
    z=B
else:
    z=B
print(round(B-A+1-(x+y-z)))


Failing test case input:
11519628362605307 5772277299890772 461 5732805158

Expected output:
-5734883922749497


Actual output:
-11519628362605306


Fixed submission (verdict: Accepted):
def g(m,n):
    x=max(m,n)
    y=min(m,n)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x=y
            y=z
        else:
            return z
from decimal import Decimal
A,B,C,D=map(lambda x:Decimal(int(x)),input().split())



if A%C==0:
    x=B
else:
    x=B
if A%D==0:
    y=B
else:
    y=B
E=Decimal(C*D
if A%E==0:
    z=B
else:
    z=B
print(B-A+1-(x+y-z))
Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
def lcm(a, b):
    return a * b / gcd(a,b)
a,b,c,d = map(int,input().split())
canC = b
canD = b
dbCD = b
print(int((b-a+1) -canC - canD + dbCD))


Failing test case input:
49672545627402475 2302290213945793 3450365 1839634861

Expected output:
-47370241658650554


Actual output:
-49672545627402474


Fixed submission (verdict: Accepted):

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
def lcm(a, b):
    return a * b 
a,b,c,d = map(int,input().split())
canC = int(b
canD = int(b
dbCD = int(b
print((b-a+1) -canC - canD + dbCD)

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import sys

import math









def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

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

def main():
    a, b, c, d = [int(x) for x in sys.stdin.readline().split()]
    divisors = 0
    divisors += b 
    divisors += b 
    cd = lcm(c, d)
    divisors -= b 
    ans = b - a + 1 - divisors
    print(ans)



if __name__ == "__main__":
    main()


Failing test case input:
8489283863195222 2302290213945793 161 4435795138

Expected output:
-6148565115880388


Actual output:
-8489283863195221


Fixed submission (verdict: Accepted):

import sys

import math









def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

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

def main():
    a, b, c, d = [int(x) for x in sys.stdin.readline().split()]
    res1 = b - (b 
    res2 = (a - 1) - ((a - 1) 
    ans = res1 - res2
    print(ans) 

if __name__ == "__main__":
    main()

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
import fractions
a,b,c,d=list(map(int,input().split()))
s=math.floor(b/c)-math.ceil(a/c)+1
e=math.floor(b/d)-math.ceil(a/d)+1
count=b-a-s-e+1
def lcm(x, y):
    return (x * y) 
    


com=lcm(c, d)
tmp=math.floor(b/com)-math.ceil(a/com)-1
print(count+tmp)

Failing test case input:
5292456474884197 170847880819691070 33 109641300

Expected output:
160538591931352243


Actual output:
160538591839838714


Fixed submission (verdict: Accepted):
import math
import fractions
a,b,c,d=list(map(int,input().split()))
a-=1
calc_c=(b-b
calc_d=(b-b
count=calc_c+calc_d
def lcm(x, y):
    
    return math.floor((x * y) /fractions.gcd(x, y))


com=lcm(c, d)
tmp=(b-b
print(count-tmp)
Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

a, b, c, d = map(int, input().split())


cc = int(b / c) - int((a-1) / c)
dd = int(b / d) - int((a-1) / d)


f = [c]
x = 10000000
k = [c, d]

while x != 0:
    x = max(k) % min(k)

    if x != 0:
        f.append(x)
    k.sort()
    k[1] = x



cd = int(b / (c * d/min(f) )) - int((a-1) / (c * d/min(f) ))

print(b - a+1 - cc - dd + cd)

Failing test case input:
4445144871656471 29010616170026159 8 114898937

Expected output:
21494787198997879


Actual output:
21494787198997878


Fixed submission (verdict: Accepted):

a, b, c, d = map(int, input().split())


f = [c]
x = 1000000
k = [c, d]

while x != 0:
    x = max(k) % min(k)

    if x != 0:
        f.append(x)
    k.sort()
    k[1] = x


cc = (b 
dd = (b 
cd =(b 




print(int(b - a + 1 - cc - dd + cd))

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys

def gcd(a, b):
    
    while b != 0:
        a, b = b, a % b
    return a


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


def main():
    input = sys.stdin.readline
    A, B, C, D = map(int, input().split())
    E = lcm(C, D)

    total = B - A + 1
    multi_c = (B - C + 1) 
    multi_d = (B - D + 1) 
    multi_e = (B - E + 1) 
    return total - (multi_c + multi_d - multi_e)


if __name__ == '__main__':
    print(main())


Failing test case input:
8489283863195222 2302290213945793 161 3502418455

Expected output:
-6148565115510992


Actual output:
-8489844250147861


Fixed submission (verdict: Accepted):
import sys

def gcd(a, b):
    
    while b != 0:
        a, b = b, a % b
    return a


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


def main():
    input = sys.stdin.readline
    A, B, C, D = map(int, input().split())
    E = lcm(C, D)

    total = B - A + 1
    multi_c = max(0, B 
    if A % C == 0:
        multi_c += 1
    multi_d = max(0, B 
    if A % D == 0:
        multi_d += 1
    multi_e = max(0, B 
    if A % E == 0:
        multi_e += 1
    return total - (multi_c + multi_d - multi_e)


if __name__ == '__main__':
    print(main())

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import fractions

a,b,c,d=map(int, input().split())

def lcm(x, y):
    return (x * y) 

x =int(b/c)-int(((a-1)/c))
y =int(b/d)-int(((a-1)/d))
n =lcm(c,d)
xy=int(b/n)-int(((a-1)/n))

ans = (b-a+1) - (x+y-xy)
print(ans)

Failing test case input:
2755958446070485 108249065682174014 32 109641300

Expected output:
102196446793080235


Actual output:
102196446702877191


Fixed submission (verdict: Accepted):
import fractions
 
a,b,c,d=map(int, input().split())
 
def lcm(x, y):
    return (x * y) 
 
x =(b
y =(b
n =lcm(c,d)
xy=(b
 
ans = (b-a+1) - (x+y-xy)
print(ans)
Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

def main():
    a, b, c, d = map(int, input().split())

    quotient = []
    quotient = []
    for i, x in enumerate([c, d, c*d]):
        temp1 = (b / x) - (a / x)
        temp2 = math.ceil(temp1)
        quotient.append(temp2)
    temp1 = b - a + 1
    ans = temp1 - (quotient[0] + quotient[1]) + quotient[2]
    print(ans)


if __name__ == '__main__':
    main()


Failing test case input:
20423853163581813 2302290213945793 3450365 1839634861

Expected output:
-18121557687714104


Actual output:
-18121557687714103


Fixed submission (verdict: Accepted):
import math
import fractions

def main():
    a, b, c, d = map(int, input().split())

    quotient = []
    temp_lcm = c * d 
    for i, x in enumerate([c, d, temp_lcm]):
        temp = (b 
        quotient.append(temp)
    temp1 = b - a + 1
    ans = temp1 - (quotient[0] + quotient[1]) + quotient[2]
    print(ans)


if __name__ == '__main__':
    main()

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, c, d = [int(i) for i in input().split()]
c1, d1 = [d if c < d else c, c if c < d else d]
while d1 > 0:
    e = d1
    d1 = c1 % d1
    c1 = e
e = c * d / e
cnt = (b - a + 1) + int(b / e) - int((a-1) / e) - int(b / c) + int((a-1) / c) - int(b / d) + int((a-1) / d)
print(cnt)


Failing test case input:
4445144871656471 55012421473280374 8 109641300

Expected output:
44246366795817683


Actual output:
44246366795817682


Fixed submission (verdict: Accepted):

a, b, c, d = [int(i) for i in input().split()]
c1 = d if c < d else c
d1 = c if c < d else d
while d1 != 0:
    e = d1
    d1 = c1 % d1
    c1 = e
e = int((c * d) / e)
a -= 1
cnt = (b - a) + int(b 
print(cnt)

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
import sys

fin = sys.stdin.readline
A, B, C, D = [int(elem) for elem in fin().split()]



def warikiru(A, B, C):
    return int(B / C) - math.ceil(A / C) + 1



def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a



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


warikiru_num = warikiru(A, B, C) + warikiru(A, B, D) - warikiru(A, B, lcm(C, D))

print(int(B - A + 1 - warikiru_num))


Failing test case input:
4445144871656471 60117910912501884 8 85843371

Expected output:
48713669718268193


Actual output:
48713669718268192


Fixed submission (verdict: Accepted):
import math
import sys
from decimal import *

fin = sys.stdin.readline
A, B, C, D = [Decimal(elem) for elem in fin().split()]



def warikiru(A, B, C):
    return (B 



def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a



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


warikiru_num = warikiru(A, B, C) + warikiru(A, B, D) - warikiru(A, B, lcm(C, D))

print(int(B - A + 1 - warikiru_num))
Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def gcd(x, y):  
    if y == 0:
        return x
    else:
        return gcd(y, x % y) 


if __name__ == "__main__":
    a, b, c, d =  map(int, input().split())
    
    
    
    bai_c = b 
    bai_d = b 

    l  = (c * d) / gcd(c, d)
    b_duplicated = b 

    bai_c2 = (a - 1) 
    bai_d2 = (a - 1) 
    
    l2 = (c * d) / gcd(c, d)
    a_duplicated = (a - 1) 
    
    ans = (b - (bai_c + bai_d - b_duplicated)) - ((a - 1) - (bai_c2 + bai_d2 - a_duplicated))
    print(int(ans))


Failing test case input:
6354199306375155 38464981823067483 7 91372231

Expected output:
27523527570226360


Actual output:
0


Fixed submission (verdict: Accepted):
def gcd(x, y):  
    if y == 0:
        return x
    else:
        return gcd(y, x % y) 


if __name__ == "__main__":
    a, b, c, d =  map(int, input().split())
    
    
    
    bai_c = int(b 
    bai_d = int(b 

    l  = int((c * d) / gcd(c, d))
    b_duplicated = int(b 

    bai_c2 = int((a - 1) 
    bai_d2 = int((a - 1) 
    
    l2 = int((c * d) / gcd(c, d))
    a_duplicated = int((a - 1) 
    
    ans = (b - (bai_c + bai_d - b_duplicated)) - ((a - 1) - (bai_c2 + bai_d2 - a_duplicated))
    print(int(ans))

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
def lcm(a, b):
    return a * b / gcd(a,b)
a,b,c,d = map(int,input().split())
canC = b/c - (a-1)/c
canD = b/d - (a-1)/d
dbCD = b/lcm(c,d) - (a-1)/lcm(c,d)
print(int((b-a+1) -canC - canD + dbCD))


Failing test case input:
13 40 14 8

Expected output:
22


Actual output:
23


Fixed submission (verdict: Accepted):

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
def lcm(a, b):
    return a * b 
a,b,c,d = map(int,input().split())
canC = int(b
canD = int(b
dbCD = int(b
print((b-a+1) -canC - canD + dbCD)

Problem: p02995
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
A,B,C,D=list(map(int, input().split()))

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

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

E=lcm(C,D)

Cmin=A-A%C
Cmax=B-B%C
Dmin=A-A%D
Dmax=B-B%D
Emin=A-A%E
Emax=B-B%E

num = ((Cmax-Cmin)/C)+((Dmax-Dmin)/D)-((Emax-Emin)/E)

print(int(B-A+1-num))


Failing test case input:
6354199306375155 38464981823067483 17 91372231

Expected output:
30221912626130906


Actual output:
30221912626130904


Fixed submission (verdict: Accepted):
A,B,C,D=list(map(int, input().split()))

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

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

E=lcm(C,D)

A-=1

Cmin=A-A%C
Cmax=B-B%C
Dmin=A-A%D
Dmax=B-B%D
Emin=A-A%E
Emax=B-B%E

num = ((Cmax-Cmin)



print(int(B-A-num))
Problem: p02995
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from math import gcd
a,b,c,d=list(map(int,input().split()))

def calculation(x,c,d):
	x-=x
	x-=x
	x+=x
	return x
	
print(calculation(b,c,d)-calculation(a-1,c,d))

Failing test case input:
11519628362605307 5791437507644555 391 3058835041

Expected output:
-5713540748681110


Actual output:
0


Fixed submission (verdict: Accepted):
from math import gcd
a,b,c,d=list(map(int,input().split()))
a-=1
def calculation(x,c,d):
	x=x-(x
	return x
	
print(calculation(b,c,d)-calculation(a,c,d))

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

a, b, c, d = map(int, input().split())
cc = int(b / c) - int(a / c)



dd = int(b / d) - int(a / d)

i = 0
f = [c]
x = 10000000
k = [c, d]

while x != 0:
    x = max(k) % min(k)

    if x != 0:
        f.append(x)
    k.sort()
    k[1] = x



cd = int(b / (c * d / min(f))) - int(a / (c * d / min(f)))

print(b - a+1 - cc - dd + cd)

Failing test case input:
4445144871656471 60117910912501884 8 85843371

Expected output:
48713669718268193


Actual output:
48713669718268192


Fixed submission (verdict: Accepted):

a, b, c, d = map(int, input().split())


f = [c]
x = 1000000
k = [c, d]

while x != 0:
    x = max(k) % min(k)

    if x != 0:
        f.append(x)
    k.sort()
    k[1] = x


cc = (b 
dd = (b 
cd =(b 




print(int(b - a + 1 - cc - dd + cd))

Problem: p02995
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
A,B,C,D = map(int,input().split())

sub = B - A + 1
cDivNum = int(sub / C)
dDivNum = int(sub / D)
cdDivNum = int(sub /(C*D))


print(sub - (cDivNum+dDivNum-cdDivNum))

Failing test case input:
18199866983000874 11488237810087203 461 5732805158

Expected output:
-6697070323214204


Actual output:
-6697070323214203


Fixed submission (verdict: Accepted):
from fractions import gcd

def lcm(x, y):
	return (x * y) 

A,B,C,D = map(int,input().split())

sub = B - A + 1
cDivNum = (B
dDivNum = (B
cdDivNum = (B


print(sub - (cDivNum+dDivNum-cdDivNum))

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import fractions

def lcm(x, y):
  return (x * y) 

A,B,C,D = map(int,input().split())

AtoB =  B - (A-1)

div_C = int(B/C) - int((A-1)/C)
div_D = int(B/D) - int((A-1)/D)
div_CD = int(B/lcm(C,D)) - int((A-1)/lcm(C,D))

print(AtoB - div_C - div_D + div_CD)

Failing test case input:
4445144871656471 45404042833744343 8 85843371

Expected output:
35839035299333548


Actual output:
35839035299333547


Fixed submission (verdict: Accepted):
import fractions

def lcm(x, y):
  return (x * y) 

A,B,C,D = map(int,input().split())

AtoB =  B - (A-1)

div_C = (B
div_D = (B
div_CD = (B

print(AtoB - div_C - div_D + div_CD)
Problem: p02995
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
A,B,C,D = map(int, input().split())

ac = int((A-1)/C)
ad = int((A-1)/D)
bc = int(B/C)
bd = int(B/D)

c = bc - ac
d = bd - ad


def gcd(x, y):
    while y != 0:
        x, y = y, x%y
    return x


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

baisu = lcm(C,D)
a_baisu = int((A-1)/baisu)
b_baisu = int(B/baisu)


print(B-A+1-c-d+(b_baisu-a_baisu))

Failing test case input:
2755958446070485 170847880819691070 46 109641300

Expected output:
164437748681656242


Actual output:
164437748648327814


Fixed submission (verdict: Accepted):
def gcd(x, y):
    while y != 0:
        x, y = y, x%y
    return x

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

A,B,C,D = map(int, input().split())

ac = int((A-1)
ad = int((A-1)
bc = int(B
bd = int(B

c = bc - ac
d = bd - ad

baisu = lcm(C,D)
a_baisu = int((A-1)
b_baisu = int(B
print(B-A+1-c-d+(b_baisu-a_baisu))

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
A,B,C,D=map(int,input().split())
c=C*D/gcd(C,D)
b=B
a=(A-1)
print(int((B-b)-(A-1-a)))

Failing test case input:
4445144871656471 29010616170026159 8 193372698

Expected output:
21494787290795791


Actual output:
0


Fixed submission (verdict: Accepted):
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
A,B,C,D=map(int,input().split())
c=int(C*D/gcd(C,D))
b=int(B
a=int((A-1)
print(int((B-b)-(A-1-a)))

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
def gcd(a, b):
  while b:
    a, b = b, a%b
  return a

a, b, c, d = map(int, input().split())

tmp_b= b - math.floor(b/c) - math.floor(b/d)
tmp_b += math.floor(b/(c*d/gcd(c, d)))

tmp_a= a - math.floor(a/c) - math.floor(a/d)
tmp_a += math.floor(a/(c*d/gcd(c, d)))

print(tmp_b-tmp_a+1)


Failing test case input:
4445144871656471 29010616170026159 8 114898937

Expected output:
21494787198997879


Actual output:
21494787198997878


Fixed submission (verdict: Accepted):
import math
from decimal import Decimal

a, b, c, d = map(Decimal, input().split())

def gcd(a, b):
  while b:
    a, b = b, a%b
  return a

def count(a, c, d):
    tmp_a= a - math.floor(a/c) - math.floor(a/d)
    tmp_a += math.floor(a/((c*d)/gcd(c, d)))
    return tmp_a

print(int(count(b,c,d))-int(count(a-1, c, d)))

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
A,B,C,D=map(int,input().split())
c=C*D/gcd(C,D)
b=B
a=(A-1)
print((B-b)-(A-1-a))

Failing test case input:
314159265358979323 84117665769283334 419716939 937510582

Expected output:
-230041598796233572


Actual output:
0


Fixed submission (verdict: Accepted):
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
A,B,C,D=map(int,input().split())
c=int(C*D/gcd(C,D))
b=int(B
a=int((A-1)
print(int((B-b)-(A-1-a)))
Problem: p02995
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import math
def lcm(x, y):return (x * y) 
a,b,c,d=map(int,input().split())

e = lcm(c,d)

s1 = b
s2 = a
print((b-a)-(s1-s2-1))

Failing test case input:
199886915867276350 12506909170924176 3258358 1839634861

Expected output:
-187379949086999938


Actual output:
1


Fixed submission (verdict: Accepted):
import math
def lcm(x, y):return (x * y) 
a,b,c,d=map(int,input().split())

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

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
a, b, c, d = map(int, input().split())

def gcd(a, b):
  while b:
    a, b = b, a%b
  return a

def count(a, c, d):
    tmp_a= a - math.floor(a/c) - math.floor(a/d)
    tmp_a += math.floor(a/math.floor((c*d)/gcd(c, d)))
    return tmp_a

print(count(b,c,d)-count(a-1, c, d))

Failing test case input:
2378114867615524 188107035759759287 33 70304397

Expected output:
180100769372579622


Actual output:
180100769372579621


Fixed submission (verdict: Accepted):
import math
from decimal import Decimal

a, b, c, d = map(Decimal, input().split())

def gcd(a, b):
  while b:
    a, b = b, a%b
  return a

def count(a, c, d):
    tmp_a= a - math.floor(a/c) - math.floor(a/d)
    tmp_a += math.floor(a/((c*d)/gcd(c, d)))
    return tmp_a

print(int(count(b,c,d))-int(count(a-1, c, d)))

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

def gcd(x,y):
  M=max(x,y)
  m=min(x,y)
  while(M%m!=0):
      r=M%m
      M=m
      m=r
  return m



def f(x,y):
  z=x
  return z


a,b,c,d=map(int,input().split())
g=gcd(c,d)
p=a-f(a,c)-f(a,d)+f(a,c*d/g)
q=b-f(b,c)-f(b,d)+f(b,c*d/g)
if(a%c!=0 and a%d!=0):
  print(q-p+1)
else:
  print(q-p)

Failing test case input:
6354199306375155 11488237810087203 9 91372231

Expected output:
4563589731132336


Actual output:
0


Fixed submission (verdict: Accepted):
import math

def gcd(x,y):
  M=max(x,y)
  m=min(x,y)
  while(M%m!=0):
      r=M%m
      M=m
      m=r
  return m



def f(x,y):
  z=int(x
  return z


a,b,c,d=map(int,input().split())
g=gcd(c,d)
p=a-f(a,c)-f(a,d)+f(a,int(c*d/g))
q=b-f(b,c)-f(b,d)+f(b,int(c*d/g))
if(a%c!=0 and a%d!=0):
  print(q-p+1)
else:
  print(q-p)

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

a,b,c,d=map(int,input().split())
cc=int((b-a)/c)
dd=int((b-a)/d)
cd=0

i = 0
f = [c]
x = 10000000
k = [c, d]

while x != 0:
    x = max(k) % min(k)

    if x != 0:
        f.append(x)
    k.sort()
    k[1] = x
cd=int((b-a)/(c*d/min(f)))
print(b-a-cc-dd+cd)

Failing test case input:
49672545627402475 2302290213945793 3450365 1839634861

Expected output:
-47370241658650554


Actual output:
-47370241658650555


Fixed submission (verdict: Accepted):

a, b, c, d = map(int, input().split())


f = [c]
x = 1000000
k = [c, d]

while x != 0:
    x = max(k) % min(k)

    if x != 0:
        f.append(x)
    k.sort()
    k[1] = x


cc = (b 
dd = (b 
cd =(b 




print(int(b - a + 1 - cc - dd + cd))
Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


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


a, b, c, d = map(int, input().split())

first_c = c * a 
last_c = c * b 
first_d = d * a 
last_d = d * b 
cd = lcm(c, d)
first_cd = cd * a 
last_cd = cd * b 

cnum = (last_c - first_c) 
dnum = (last_d - first_d) 
cdnum = (last_cd - first_cd) 

total = cnum + dnum - cdnum
print(b - a + 1 - total)


Failing test case input:
6354199306375155 20832163180120607 9 91372231

Expected output:
12869301080262296


Actual output:
10583070760028483212783681


Fixed submission (verdict: Accepted):
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


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


a, b, c, d = map(int, input().split())

first_c = c * (a 
if a % c == 0:
    first_c -= c
last_c = c * (b 

first_d = d * (a 
if a % d == 0:
    first_d -= d
last_d = d * (b 

cd = lcm(c, d)
first_cd = cd * (a 
if a % cd == 0:
    first_cd -= cd
last_cd = cd * (b 

cnum = 0
dnum = 0
cdnum = 0

if first_c <= b:
    cnum = (last_c - first_c) 

if first_d <= b:
    dnum = (last_d - first_d) 

if first_cd <= b:
    cdnum = (last_cd - first_cd) 

total = cnum + dnum - cdnum
print(b - a + 1 - total)

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
import math

def gcd(a, b):
  if b == 0:
    return a
  elif a > b:
    return gcd(b, a % b)
  else: 
    return gcd(a, b % a)

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


a,b,c,d = [int(x) for x in sys.stdin.readline().rstrip().split(" ")]
d = abs(d)
e = b - a + 1
f = int(b / c) - int((a - 1) / c)
g = int(b / d) - int((a - 1) / d)
cd = lcm(c, d)
h = int(b / cd) - int((a - 1) / cd)
n = e - f - g + h
print(n)


Failing test case input:
11519628362605307 4466928324079138 259 16098586728

Expected output:
-7025469536020663


Actual output:
-7025469536010514


Fixed submission (verdict: Accepted):
import sys
import math

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)

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

  
a,b,c,d = [int(x) for x in sys.stdin.readline().rstrip().split(" ")]
e = b - a + 1
if c == d:
  fgh = (b 
  n = e - fgh
  print(n) 
else:
  f = (b 
  g = (b 
  cd = lcm(c, d) 
  h = (b 
  n = e - f - g + h
  print(n)
Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def GCD(a,b):
  if a<b:
    tmp = a
    a = b
    b = tmp
 
  r = a % b
  while (r!=0): 
    a = b
    b = r
    r = a % b
  return b


A,B,C,D = map(int,input().split())

upperC = int(B / C)
upperD = int(B / D)
lowerC = int(A / C)
lowerD = int(A / D)

numC = upperC - lowerC 
numD = upperD - lowerD

gcd = GCD(C,D)

lcm = C * D / gcd
upperL = int(B / lcm)
lowerL = int(A / lcm)
numL = upperL - lowerL

print(str(B - A- (numC + numD - numL)))

Failing test case input:
2755958446070485 170847880819691070 29 109641300

Expected output:
162295647708081397


Actual output:
162295647708081396


Fixed submission (verdict: Accepted):
def GCD(a,b):
  if a<b:
    tmp = a
    a = b
    b = tmp
 
  r = a % b
  while (r!=0): 
    a = b
    b = r
    r = a % b
  return b


A,B,C,D = map(int,input().split())
A = A - 1
upperC = int(B 
upperD = int(B 
lowerC = int(A 
lowerD = int(A 

numC = upperC - lowerC
numD = upperD - lowerD

gcd = GCD(C,D)

lcm = C * D 
upperL = int(B 
lowerL = int(A 
numL = upperL - lowerL

print(str(B - A - (numC + numD - numL)))

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

a, b, c, d = map(int, input().split())

def calc_lcd(a, b):
    if a < b:
        temp = a
        a = b
        b = temp
    
    r = a % b
    x = a * b
    while r != 0:
        a = b
        b = r
        r = a % b
    
    return x / b

lcd = calc_lcd(c, d)
a -= 1

print(int(b - int(b / c) - int(b / d) + int(b / lcd) - (a - int(a / c) - int(a / d) + int(a / lcd))))


Failing test case input:
2378114867615524 188107035759759287 33 70304397

Expected output:
180100769372579622


Actual output:
180100769372579621


Fixed submission (verdict: Accepted):

a, b, c, d = map(int, input().split())

def calc_lcd(x, y):
    if x < y:
        temp = x
        x = y
        y = temp
    
    r = x % y
    z = x * y
    while r != 0:
        x = y
        y = r
        r = x % y
    
    return z 

lcd = calc_lcd(c, d)
a -= 1


print(b - b

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B, C, D = map(int, input().split())


def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b) 
    

div_c = int(B/C)

div_d = int(B/D)

mygcd = gcd(C, D)
l = int((C*D)/mygcd) 
div_gcd = int(B/l)
myansB = B - div_c -div_d + div_gcd


div_cA = int((A-1)/C)

div_dA = int((A-1)/D)

div_gcdl = int((A-1)/l)
myansA = A-1 - div_cA -div_dA + div_gcdl

print(myansB-myansA)

Failing test case input:
4445144871656471 55012421473280374 8 109641300

Expected output:
44246366795817683


Actual output:
44246366795817682


Fixed submission (verdict: Accepted):
A, B, C, D = map(int, input().split())


def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b) 
    

div_c = int(B

div_d = int(B

mygcd = gcd(C, D)
l = int((C*D)
div_gcd = int(B
myansB = B - div_c -div_d + div_gcd


div_cA = int((A-1)

div_dA = int((A-1)

div_gcdl = int((A-1)
myansA = A-1 - div_cA - div_dA + div_gcdl

print(myansB-myansA)
Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, c, d = map(int, input().split())

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x%y)

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

bb = b-int(b/c)-int(b/d)+int(b/lcm(c,d))   
aa = (a-1)-int((a-1)/c)-int((a-1)/d)+int((a-1)/lcm(c,d))
print(bb-aa)

Failing test case input:
10 40 6 8

Expected output:
23

Actual output:
22


Fixed submission (verdict: Accepted):
a, b, c, d = map(int, input().split())
 
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x%y)
 
def lcm(a, b):
	return a * b 
 
bb = b-int(b
aa = (a-1)-int((a-1)
print(bb-aa)

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
def gcd(a, b):
  while b:
    a, b = b, a%b
  return a

a, b, c, d = map(int, input().split())

tmp_b= b - math.floor(b/c) - math.floor(b/d)
tmp_b += math.floor(b/math.floor(c*d/gcd(c, d)))

tmp_a= a - math.floor(a/c) - math.floor(a/d)
tmp_a += math.floor(a/math.floor(c*d/gcd(c, d)))

print(tmp_b-tmp_a+1)

Failing test case input:
2378114867615524 188107035759759287 38 70304397

Expected output:
180841315138509718


Actual output:
180841315138509717


Fixed submission (verdict: Accepted):
import math
from decimal import Decimal

a, b, c, d = map(Decimal, input().split())

def gcd(a, b):
  while b:
    a, b = b, a%b
  return a

def count(a, c, d):
    tmp_a= a - math.floor(a/c) - math.floor(a/d)
    tmp_a += math.floor(a/((c*d)/gcd(c, d)))
    return tmp_a

print(int(count(b,c,d))-int(count(a-1, c, d)))

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,c,d=map(int,input().split())

def div(x,y):
  return y

def div2(x):
  return div(x,b)-div(x,a)
  
print(b-a+1-div2(c)-div2(d)+div2(c*d))

Failing test case input:
192279979219844935 84117665769283334 5369186 1839634861

Expected output:
-108162293246754626


Actual output:
1


Fixed submission (verdict: Accepted):
import fractions as fr
a,b,c,d=map(int,input().split())

def div(x,y):
  return y

def div2(x):
  return div(x,b)-div(x,a-1)
  
print(b-a+1-div2(c)-div2(d)+div2(c*d

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import fractions as fr
a, b, c, d = map(int, input().split())
lcm = (c*d)
ans = (b-a)
print(ans)

Failing test case input:
192279979219844935 84117665769283334 5369186 1839634861

Expected output:
-108162293246754626


Actual output:
-108162313450561601


Fixed submission (verdict: Accepted):
from fractions import gcd

a, b, c, d = map(int, input().split())

e = c * d 
rest = (b
ans = b-a+1 - rest

print(ans)
Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A,B,C,D = map(int, input().split())

def gcd(a, b):
  while b:
    a, b = b, a % b
  return a


def cnt(inp):
  min_ = inp * (int((A-1) / inp) + 1)
  max_ = inp * (int((B) / inp))
  num = (max_ - min_) / inp + 1
  return(int(num))

Ccnt = cnt(C)
Dcnt = cnt(D)
lcm = C*D / gcd(C,D)
CDcnt = cnt(int(lcm))

print((B+1-A)-Ccnt-Dcnt+CDcnt)


Failing test case input:
2378114867615524 188107035759759287 38 70304397

Expected output:
180841315138509718


Actual output:
180841315138509717


Fixed submission (verdict: Accepted):
A,B,C,D = map(int, input().split())

def gcd(a, b):
  while b:
    a, b = b, a % b
  return a


def cnt(inp):
  min_ = inp * (int((A-1) 
  max_ = inp * (int((B) 
  num = (max_ - min_) 

  return(int(num))

Ccnt = cnt(C)
Dcnt = cnt(D)
lcm = C*D 
CDcnt = cnt(lcm)


print((B+1-A)-Ccnt-Dcnt+CDcnt)

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B, C, D = map(int, input().split())

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

def lcm(x, y):
    return (x * y) 

allnum =  B -A +1
E = lcm(C, D)

Cnum = int(B/C) - int((A-1)/C)
Dnum = int(B/D) - int((A-1)/D)
Enum = int(B/E) - int((A-1)/E)

num = allnum - Cnum - Dnum + Enum
print(int(num))


Failing test case input:
11519628362605307 5791437507644555 391 3058835041

Expected output:
-5713540748681110


Actual output:
-5713540748604479


Fixed submission (verdict: Accepted):
A, B, C, D = map(int, input().split())

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

def lcm(x, y):
    return (x * y) 

allnum =  B -A +1
E = lcm(C, D)

Cnum = (B
Dnum = (B
Enum = (B

num = allnum - Cnum - Dnum + Enum
print(int(num))

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import fractions
a,b,c,d = map(int,input().split())
num = b-a+1
ac = int((a-1)/c)
ad = int((a-1)/d)
bc = int(b/c)
bd = int(b/d)
e = c*d
a = int(a/e)
b = int(b/e)
c = bc-ac
d = bd-ad
e = b-a
print(num-(c+d-e))

Failing test case input:
2 54 8 8

Expected output:
47


Actual output:
41


Fixed submission (verdict: Accepted):
import fractions
a,b,c,d = map(int,input().split())
num = b-a+1
ac = int((a-1)
ad = int((a-1)
bc = int(b
bd = int(b
e = c*d
a = int((a-1)
b = int(b
c = bc-ac
d = bd-ad
e = b-a
print(num-(c+d-e))

Problem: p02995
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
import fractions
a,b,c,d=list(map(int,input().split()))
s=math.floor(b/c)-math.ceil(a/c)+1
e=math.floor(b/d)-math.ceil(a/d)+1
count=b-a-s-e+1
def lcm(x, y):
    return (x * y) 
    


com=lcm(c, d)
tmp=math.floor(b/com)-math.ceil(a/com)+1
print(count+tmp)

Failing test case input:
11519628362605307 4466928324079138 391 3058835041

Expected output:
-7034662440314272


Actual output:
-7034662440219922


Fixed submission (verdict: Accepted):
import math
import fractions
a,b,c,d=list(map(int,input().split()))
a-=1
calc_c=(b-b
calc_d=(b-b
count=calc_c+calc_d
def lcm(x, y):
    
    return math.floor((x * y) /fractions.gcd(x, y))


com=lcm(c, d)
tmp=(b-b
print(count-tmp)