qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import sys

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


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


def main():
    input = sys.stdin.readline
    A, B, C, D = map(int, input().split())
    E = lcm(C, D)
    print(E)
    total = B - A + 1
    multi_c = max(0, B // C) - max(0, A // C)
    if A % C == 0:
        multi_c += 1
    multi_d = max(0, B // D) - max(0, A // D)
    if A % D == 0:
        multi_d += 1
    multi_e = max(0, B // E) - max(0, A // E)
    if A % E == 0:
        multi_e += 1
    print(total, multi_c, multi_d, multi_e)
    return total - (multi_c + multi_d - multi_e)


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


Fixed code:
import sys

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


def lcm(a, b):
    return (a * b) // gcd(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 // C) - max(0, A // C)
    if A % C == 0:
        multi_c += 1
    multi_d = max(0, B // D) - max(0, A // D)
    if A % D == 0:
        multi_d += 1
    multi_e = max(0, B // E) - max(0, A // E)
    if A % E == 0:
        multi_e += 1
    return total - (multi_c + multi_d - multi_e)


if __name__ == '__main__':
    print(main())
Buggy code:
a, b, c, d = map(int, input().split())

def gcd(c, d):
    while d:
        c, d = d, c % d
    return c

lcm = c * d / gcd(c, d)
b_num = b - ((b // c) + (b // d) - (b // lcm))
a_num = a - 1 - (((a - 1) // c) + ((a - 1) // d) - ((a - 1) // lcm))
print(int(b_num - a_num))

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

def gcd(c, d):
    while d:
        c, d = d, c % d
    return c

lcm = c * d // gcd(c, d)
b_num = b - (b // c) - (b // d) + (b // lcm)
a_num = a - 1 - ((a - 1) // c) - ((a - 1) // d) + ((a - 1) // lcm)
print(int(b_num - a_num))
Buggy code:
a,b,c,d=map(int,input().split())
def gcd(x,y):
  if x%y==0:
    print(y)
  else:
    gcd(x%y,y)
    
r=gcd(c,d)    
s=(b//c)-((a-1)//c)
t=(b//d)-((a-1)//d)
u=(b//r)-((a-1)//r)

print(b-a+1-s-t+u)

Fixed code:
a,b,c,d=map(int,input().split())
def gcd(x,y):
  if x%y==0:
    return y
  else:
    return gcd(y,x%y)
    
r=int((c*d)/gcd(c,d)) 
s=(b//c)-((a-1)//c)
t=(b//d)-((a-1)//d)
u=(b//r)-((a-1)//r)

print(int(b-a+1-s-t+u))
Buggy code:
def gcd(x, y):
    while y > 0:
        x, y = y, x%y
    return x

A,B,C,D = map(int, input().split())
B_C = B // C
B_D = B // D
g = gcd(C,D)
l = C * D / g
duplicate_B = B // l
answer_B = B - B_C - B_D + duplicate_B

A_C = (A - 1) // C
A_D = (A - 1) // D
duplicate_A = (A - 1) // l
answer_A = (A - 1) - A_C - A_D + duplicate_A
print(int(answer_B - answer_A))


Fixed code:
def gcd(x, y):
    while y > 0:
        x, y = y, x%y
    return x

A,B,C,D = map(int, input().split())
B_C = B // C
B_D = B // D
g = gcd(C,D)
l = C * D // g
duplicate_B = B // l
answer_B = B - B_C - B_D + duplicate_B

A_C = (A - 1) // C
A_D = (A - 1) // D
duplicate_A = (A - 1) // l
answer_A = (A - 1) - A_C - A_D + duplicate_A
print(int(answer_B - answer_A))
Buggy code:
import math
a,b,c,d = map(int,input().split())
e = c*d / math.gcd(c,d)

def div(z):
    p = (z//c) + (z//d) - (z//e)
    return p

x = a-1 - div(a-1)
y = b - div(b)
print(y-x)

Fixed code:
import math
a,b,c,d = map(int,input().split())
e = math.floor(c*d / math.gcd(c,d))

def div(z):
    p = (z//c) + (z//d) - (z//e)
    return p

x = a-1 - div(a-1)
y = b - div(b)
print(y-x)
Buggy code:
i  = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

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

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

count = (b - b//c - b//d + b//l) - ((a-1) - (a-1)//c - (a-1)//d + (a-1)//l)
print(count)

Fixed code:
i  = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

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

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

count = (b - b//c - b//d + b//l) - ((a-1) - (a-1)//c - (a-1)//d + (a-1)//l)
print(count)
Buggy code:
def main():
    def gcd(a,b):
        while b!=0:
            a,b=b,a%b
        return a
    def lcm(a, b):
        return (a * b)//gcd(a,b)

    A,B,C,D = map(int,input().split())
    minus = B-A+1
    print(minus-(minus//C+minus//D-(minus//(lcm(C,D)))))
 
if __name__=="__main__":
    main()

Fixed code:
def main():
    def gcd(a,b):
        while b!=0:
            a,b=b,a%b
        return a
    def lcm(a, b):
        return (a * b)//gcd(a,b)
    def ans(N,C,D):
        return N-N//C-N//D+N//lcm(C,D)

    A,B,C,D = map(int,input().split())
    print(ans(B,C,D)-ans(A-1,C,D))
    
if __name__=="__main__":
    main()
Buggy code:
A, B, C, D = map(int, input().split())

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

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

C_ok = (B // C) - (A // C)
D_ok = (B // D) - (A // D)
C_D_ok = (B // lcm(C, D)) - (A // lcm(C, D))

print(B-A-C_ok-D_ok+C_D_ok+1)

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

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

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

C_ok = (B // C) - ((A-1) // C) 
D_ok = (B // D) - ((A-1) // D)
C_D_ok = (B // lcm(C, D)) - ((A-1) // lcm(C, D))
print((B-A+1)-C_ok-D_ok+C_D_ok)
Buggy code:
import numpy as np
import math
A, B, C, D = [int(i) for i in input().split()]

large = np.max([C, D])
small = np.min([C, D])
quo = large // small
rem = large % small
g = small
while rem != 0:
    large = small 
    small = rem
    quo = large // small
    rem = large % small

g = small
#print(g)

l = C / g * D

#num_B_1 = math.floor(B / C)
#num_B_2 = math.floor(B / D)
#num_B_3 = math.floor(B / l)
num_B_1 = B // C
num_B_2 = B // D
num_B_3 = B // l
num_B = B - (num_B_1 + num_B_2 - num_B_3)

#num_A_1 = math.floor((A - 1) / C)
#num_A_2 = math.floor((A - 1) / D)
#num_A_3 = math.floor((A - 1) / l)
num_A_1 = (A - 1) // C
num_A_2 = (A - 1) // D
num_A_3 = ((A - 1) // l
num_A = (A - 1) - (num_A_1 + num_A_2 - num_A_3)

print(num_B - num_A)

Fixed code:
import numpy as np
A, B, C, D = [int(i) for i in input().split()]

large = np.max([C, D])
small = np.min([C, D])

g = large
while small != 0:
    large, small = small, large % small

g = large

l = C * D // g

num_B_1 = B // C
num_B_2 = B // D
num_B_3 = B // l
num_B = B - (num_B_1 + num_B_2 - num_B_3)

num_A_1 = (A - 1) // C
num_A_2 = (A - 1) // D
num_A_3 = (A - 1) // l
num_A = (A - 1) - (num_A_1 + num_A_2 - num_A_3)

print(num_B - num_A)
Buggy code:
import numpy as np
import math
A, B, C, D = [int(i) for i in input().split()]

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

large = np.max([C, D])
small = np.min([C, D])

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

while small != 0:
    large, small = small, large % small
    print(large, small)
gcd = large

large = np.max([C, D])
small = np.min([C, D])


num_B_1 = B // C
num_B_2 = B // D
num_B_3 = B // lcm(large, small, gcd)

num_A_1 = (A-1) // C
num_A_2 = (A-1) // D
num_A_3 = (A-1) // lcm(large, small, gcd)

numB = num_B_1 + num_B_2 - num_B_3
numA = num_A_1 + num_A_2 - num_A_3

print((B-A+1) - (numB - numA))

Fixed code:
import numpy as np
import math
A, B, C, D = [int(i) for i in input().split()]

large = np.max([C, D])
small = np.min([C, D])

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

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

num_B_1 = B // C
num_B_2 = B // D
num_B_3 = B // lcm(large, small)

num_A_1 = (A-1) // C
num_A_2 = (A-1) // D
num_A_3 = (A-1) // lcm(large, small)

numB = num_B_1 + num_B_2 - num_B_3
numA = num_A_1 + num_A_2 - num_A_3

print((B-A+1) - (numB - numA))
Buggy code:
def gcd(a,b):
    while b != 0:
        temp = b
        b = a%b
        a = temp
    return a
A,B,C,D = map(int,input().split())
if C >=D ;
    lc = int(C*D/gcd(C,D))
else: lc = int(C*D/gcd(D,C))
A = A-1
A_n = A - (A//C + A//D - A//lc)
B_n = B - (B//C + B//D - B//lc)
print(int(B_n-A_n))

Fixed code:
def gcd(a,b):
    while b != 0:
        temp = b
        b = a%b
        a = temp
    return a
A,B,C,D = map(int,input().split())
if C >=D:
    lc = int(C*D/gcd(C,D))
else: lc = int(C*D/gcd(D,C))
A = A-1
A_n = A - (A//C + A//D - A//lc)
B_n = B - (B//C + B//D - B//lc)
print(int(B_n-A_n))
Buggy code:
import math
a,b,c,d=map(int,input().split())
def gcd(a,b):
    if b>a:
        b,a=a,b
    if b==0:
        return a
    else:
        return gcd(b,a%b)


def warikiri(n,c,d):
    koubai=(c*d)//gcd(c,d)
    return n-n//d-n//c+n//koubai)
print(warikiri(b,c,d)-warikiri(a-1,c,d))

Fixed code:
import math
a,b,c,d=map(int,input().split())
def gcd(a,b):
    if b>a:
        b,a=a,b
    if b==0:
        return a
    else:
        return gcd(b,a%b)
def warikiri(n,c,d):
    koubai=(c*d)//gcd(c,d)
    return n-n//d-n//c+n//koubai
print(warikiri(b,c,d)-warikiri(a-1,c,d))
Buggy code:
  while b!=0:
    a,b=b,a%b
  return a

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

c1=B//C
c2=(A-1)//C

cd1=B//((C*D)/gcd(C,D))
cd2=(A-1)//((C*D)/gcd(C,D))

d1=B//D
d2=(A-1)//D


print(int(B-A+1-(c1-c2)-(d1-d2)+(cd1-cd2)))


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

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

c1=B//C
c2=(A-1)//C

cd1=B//((C*D)//gcd(C,D))
cd2=(A-1)//((C*D)//gcd(C,D))

d1=B//D
d2=(A-1)//D


print(str(int(B-A+1-(c1-c2)-(d1-d2)+(cd1-cd2))))
Buggy code:
A,B,C,D = map(int, input().split())

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

lcm=C*D/gcd(C,D)
con1=B//C - A//C
con2=B//D - A//D
con3=B//lcm - A//lcm

print(B-(A-1)-(con1+con2-con3))

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

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

lcm=C*D//gcd(C,D)
con1=B//C - (A-1)//C
con2=B//D - (A-1)//D
con3=B//lcm - (A-1)//lcm

print(B-(A-1)-(con1+con2-con3))
Buggy code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C_fix
# CreatedDate:  2020-09-03 20:30:23 +0900
# LastModified: 2020-09-03 20:48:14 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


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


def main():
    a, b, c, d = map(int, input().split())
    if (a/c).is_integer():
        c_cnt = (b-a)//c + 1
    else:
        c_cnt = (b-a)//c
    if (a/d).is_integer():
        d_cnt = (b-a)//d + 1
    else:
        d_cnt = (b-a)//d

    lcm = c * d // gcd(max(c, d), min(c, d))
    if (a/lcm).is_integer():
        lcm_cnt = (b-a)//lcm + 1
    else:
        lcm_cnt = (b-a)//lcm
    print(b-a-c_cnt-d_cnt+lcm_cnt)


if __name__ == "__main__":
    main()


Fixed code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C_fix
# CreatedDate:  2020-09-03 20:30:23 +0900
# LastModified: 2020-09-03 21:14:03 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


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


def main():
    a, b, c, d = map(int, input().split())
    if (a/c).is_integer():
        c_cnt = b//c - a//c + 1
#        print(b//c, a//c)
    else:
        c_cnt = b//c - a//c
#        print(b//c, a//c)
    if (a/d).is_integer():
        d_cnt = b//d - a//d + 1
#        print(b//d, a//d)
    else:
        d_cnt = b//d - a//d
#        print(b//d, a//d)

    lcm = c * d // gcd(max(c, d), min(c, d))
    if (a/lcm).is_integer():
        lcm_cnt = b//lcm - a//lcm + 1
    else:
        lcm_cnt = b//lcm - a//lcm
#    print(c_cnt, d_cnt, lcm_cnt)
    print(b-a+1-c_cnt-d_cnt+lcm_cnt)


if __name__ == "__main__":
    main()
Buggy code:
A,B,C,D=map(int, input().split())

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

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

ans = (B - B//C - B//D + B//lcm(C,D) ) - ( (A-1) - (A-1)//C - (A-1)//D + (A-1)//lcm(C,D) )
print(int(ans))

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

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

def g(X):
  return X - X//C - X//D + X//lcm(C,D)

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

ans = g(B) - g(A-1)
print(ans)
Buggy code:
def gcd(x, y): 
	while(y): 
   		x, y = y, x % y 
	return x 
a,b,c,d=map(int,input().split())
m=((c*d)//(gcd(c,d)))
di=b-a
if a%c==0:
  c1=(b//c-a//c)+1
else:
  c1=(b//c-a//c)
if a%d==0:
  c2=(b//d-a//d)+1
else:
  c2=(b//d-a//d)
if a%m==0:
  c3=(b//m-a//m)+1
else:
  c3=(b//m-a//m)
print(di-(c1+c2-c3-c3))  

Fixed code:
def gcd(x, y): 
	while(y): 
   		x, y = y, x % y 
	return x 
a,b,c,d=map(int,input().split())
m=((c*d)//(gcd(c,d)))
di=b-a+1
c1=(b//c-(a-1)//c)
c2=(b//d-(a-1)//d)
c3=(b//m-(a-1)//m)
print(di-(c1+c2-c3))
Buggy code:
    if x==0:return y
    else:return gcd(y%x,x)
def lcm(x,y):
    return x*y//gcd(x,y)
 
a,b,c,d = map(int,input().split())
a -= 1
# print(gcd(c,d),lcm(c,d))
ba = b - b//c - b//d + b//lcm(c,d)
aa = a - a//c - a//d + a//lcm(c,d)
print(ba - aa)

Fixed code:
def gcd(x,y):
    if x==0:return y
    else:return gcd(y%x,x)
def lcm(x,y):
    return x*y//gcd(x,y)
 
a,b,c,d = map(int,input().split())
a -= 1
# print(gcd(c,d),lcm(c,d))
ba = b - b//c - b//d + b//lcm(c,d)
aa = a - a//c - a//d + a//lcm(c,d)
print(ba - aa)
Buggy code:
A, B, C, D = map(int, input().split())
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd(a, b)

lcm = lcm(C, D)
# A
Ax = A // lcm
Ay = A // C
Az = A // D
AA = Ay + Az -Ax
a = A - AA
# B
Bx = B // lcm
By = B // C
Bz = B // D
BB = By + Bz -Bx
b = B - BB

print(b - a)

Fixed code:
A, B, C, D = map(int, input().split())
A -= 1
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd(a, b)

lcm = lcm(C, D)
# A
Ax = A // lcm
Ay = A // C
Az = A // D
AA = Ay + Az -Ax
a = A - AA
# B
Bx = B // lcm
By = B // C
Bz = B // D
BB = By + Bz -Bx
b = B - BB

print(b - a)
Buggy code:
def gcd(a, b):
  while b:
    a, b = b, a % b
  return a

A, B, C, D = map(int, input().split())
L = C * D // gcd(C, D)
c = B // C - (A - 1) // C
d = B // D - (A - 1) // D
l = B // L - (A - 1) // L

print(A - B + 1 - c - d + l)

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

A, B, C, D = map(int, input().split())
L = C * D // gcd(C, D)
c = B // C - (A - 1) // C
d = B // D - (A - 1) // D
l = B // L - (A - 1) // L

print(B - A + 1 - c - d + l)
Buggy code:
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a

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

e=lcm(c,d)
a,b,c,d=map(int,input().split())
print((b-a+1)-(b//c-a//c)-(b//d-a//d)+(b//e-a//e))

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

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


a,b,c,d=map(int,input().split())
e=lcm(c,d)
print((b-a+1)-(b//c-(a-1)//c)-(b//d-(a-1)//d)+(b//e-(a-1)//e))
Buggy code:
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)

a, b, c, d = map(int, input().split())
x2 = b // c
x1 = (a - 1) // c
y2 = b // d
y1 = (a - 1) // d
t = c * d // gcd(c, d)
z2 = b // t
z1 = (a - 1) // t
print(x2, x1, y2, y1, z2, z1)
print(b - a + 1 - (x2 - x1) - (y2 - y1) + (z2 - z1))

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

a, b, c, d = map(int, input().split())
x2 = b // c
x1 = (a - 1) // c
y2 = b // d
y1 = (a - 1) // d
t = c * d // gcd(c, d)
z2 = b // t
z1 = (a - 1) // t
print(b - a + 1 - (x2 - x1) - (y2 - y1) + (z2 - z1))
Buggy code:
#C
import math
a, b, c, d = map(int, input().split())

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

s = b - a + 1
cc = b // c - (a - 1) // c
dd = b // d - (a - 1) // d
cd = b * a // gcd(a, b)
cd = b // cd + (a - 1) // cd
s -= cc + dd - cd
print(s)

Fixed code:
#C
import math
a, b, c, d = map(int, input().split())

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

s = b - a + 1
cc = b // c - (a - 1) // c
dd = b // d - (a - 1) // d
cd = c * d // gcd(c, d)
cd = b // cd - (a - 1) // cd
s -= cc + dd - cd
print(s)
Buggy code:
import math
A,B,C,D=map(int,input().split())

c=((B-B%C)-(A-1+C-(A-1)%C))/C+1
d=((B-B%D)-(A-1+D-(A-1)%D))/D+1
lcm=C*D/math.gcd(C,D)
candd=((B-B%lcm)-(A-1+lcm-(A-1)%lcm))/lcm+1
print(int(B-A+1-c-d+candd))

Fixed code:
import math
A,B,C,D=map(int,input().split())

c=((B-B%C)-(A-1+C-(A-1)%C))//C+1
d=((B-B%D)-(A-1+D-(A-1)%D))//D+1
lcm=C*D//math.gcd(C,D)
candd=((B-B%lcm)-(A-1+lcm-(A-1)%lcm))//lcm+1
print(int(B-A+1-c-d+candd))
Buggy code:
a, b, c, d = map(int, input().split())


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


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


def interval(a, b, c):
    a1 = a//c if a%c == 0 else a//c + 1
    b1 = b//c+1
    return b1 - a1


l = lcm(c, d)

print(int(b-a+1 - (interval(a, b, c) + interval(a, b, d) - interval(a, b, l))))


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


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


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


def interval(a, b, c):
    a1 = (a-1)//c
    b1 = b//c
    return b1 - a1


l = lcm(c, d)

print(int(b-a+1 - (interval(a, b, c) + interval(a, b, d) - interval(a, b, l))))
Buggy code:
import math
a,b,c,d=map(int, input().split())
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
	
e = (c * d // gcd(c, d))
 
 
f=(a-c)//c+1
g=b//c
h=(a-d)//d+1
k=b//d
l=(a-e)//e+1
m=b//e
x=b-a+1
y=g-f+1
z=k-h+1
w=m-l+1
print(x-y-z+w)


Fixed code:
import math
a,b,c,d=map(int, input().split())
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
	
e = (c * d // gcd(c, d))
 
 
f=(a+c-1)//c
g=b//c
h=(a+d-1)//d
k=b//d
l=(a+e-1)//e
m=b//e
x=b-a+1
y=g-f+1
z=k-h+1
w=m-l+1
print(x-y-z+w)
Buggy code:
import numpy as np

a, b, c, d = [int(i) for i in input().split()]
#
#num = np.arange(b - a + 1) + a
#
#if b < c and b < d:
#    print('0')
#    exit(0)
#
#m = min(c, d)
#div = max(c, d)
#tmp = []
#div = num[0] // div + div
#index = 0
#while True:
#    if n[index] % div != 0:
#        if index + div >
#        tmp += range(n[index], n[index])
#        index += 1
#    else:
#        index += div
#
#tmp = np.array(tmp)
#print(tmp[tmp % m == 0].shape[0])


size = b - a + 1
c_num_a = a // c
d_num_a = a // d
cd_num_a = a // (c * d)
c_num_b = b // c
d_num_b = b // d
cd_num_b = b // (c * d)

c_num = c_num_b - c_num_a
d_num = d_num_b - d_num_a
cd_num = cd_num_b - cd_num_a

if a % c == 0:
    c_num += 1
if a % d == 0:
    d_num += 1
if a % (c * d) == 0:
    cd_num += 1

print(size - c_num - d_num + cd_num)

Fixed code:
import numpy as np
import math

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

a, b, c, d = [int(i) for i in input().split()]
#
#num = np.arange(b - a + 1) + a
#
#if b < c and b < d:
#    print('0')
#    exit(0)
#
#m = min(c, d)
#div = max(c, d)
#tmp = []
#div = num[0] // div + div
#index = 0
#while True:
#    if n[index] % div != 0:
#        if index + div >
#        tmp += range(n[index], n[index])
#        index += 1
#    else:
#        index += div
#
#tmp = np.array(tmp)
#print(tmp[tmp % m == 0].shape[0])


size = b - a + 1
cd = int(c * d // gcd(c, d))
c_num_a = a // c
d_num_a = a // d
cd_num_a = a // cd
c_num_b = b // c
d_num_b = b // d
cd_num_b = b // cd

c_num = c_num_b - c_num_a
d_num = d_num_b - d_num_a
cd_num = cd_num_b - cd_num_a

if a % c == 0:
    c_num += 1
if a % d == 0:
    d_num += 1
if a % cd == 0:
    cd_num += 1

print(size - c_num - d_num + cd_num)
Buggy code:
from math import gcd
a,b,c,d=list(map(int,input().split()))

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

Fixed code:
from math import gcd
a,b,c,d=list(map(int,input().split()))
a-=1
def calculation(x,c,d):
	x=x-(x//c)-(x//d)+(x//((c*d)//gcd(c,d)))
	return x
	
print(calculation(b,c,d)-calculation(a,c,d))
Buggy code:
import math
#from decimal import Decimal
a, b, c, d = map(float, 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)))


Fixed code:
import math
from decimal import Decimal
#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)))
Buggy code:
from functools import reduce
A, B, C, D = map(int, input().split())

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

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

result = 0

result += (B-A+1) - (B//C - A//C) - (B//D - A//D)
l = lcm(C, D)
result += (B//l - A//l)

print("{}".format(result))

Fixed code:
from functools import reduce
A, B, C, D = map(int, input().split())
if C == 1 or D == 1:
  print(0)
  exit()

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

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

result = 0

if A%C == 0 or A%D == 0:
  A += 1

result += (B-A+1) - (B//C - A//C) - (B//D - A//D)
l = lcm(C, D)
result += (B//l - A//l)

print("{}".format(result))
Buggy code:
def gcd(a, b):
    tmp = a%b
    if tmp == 0:
        return b
    return gcd(b, tmp)

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

cd = (c * d) // gcd(c, d)
a_c = (a-1) // c
b_c = b // c
a_d = (a-1) // d
b_d = b // d
a_cd = (a-1) // cd
b_cd = b // cd

print(b - a + 1 - (b_c - a_c) - (b_d - a_c) + (b_cd - a_cd))


Fixed code:
def gcd(a, b):
    tmp = a%b
    if tmp == 0:
        return b
    return gcd(b, tmp)

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

cd = (c * d) // gcd(c, d)
a_c = (a-1) // c
b_c = b // c
a_d = (a-1) // d
b_d = b // d
a_cd = (a-1) // cd
b_cd = b // cd

print(b - a + 1 - (b_c - a_c) - (b_d - a_d) + (b_cd - a_cd))
Buggy code:
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)

Fixed code:
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 code:

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

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(x, y):
    return (x * y) // gcd(x, y)

div1 = b//c - a//c

div2 = b//d - a//d

e = lcm(c,d)
div3 = b//e - a//e
ans = b-a+1 - div1 - div2 + div3
print(ans)


Fixed code:

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

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(x, y):
    return (x * y) // gcd(x, y)

div1 = b//c - a//c

div2 = b//d - a//d

e = lcm(c,d)
div3 = b//e - a//e

if a%c==0:
    div1 += 1
if a%d==0:
    div2 += 1
if a%e==0:
    div3 += 1

ans = b-a+1 - div1 - div2 + div3
print(ans)
Buggy code:
A,B,C,D = map(int, input().split())

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

def count(n):
    c = n//C
    d = n//D
    g = gcd(C, D)
    l = C*D//gcd
    return n -c -d +n//l

print(count(B) - count(A-1))


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

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

def count(n):
    c = n//C
    d = n//D
    g = gcd(C, D)
    l = C*D//g
    return n -c -d +n//l

print(count(B) - count(A-1))
Buggy code:
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//C+B//D-B//c
a=(A-1)//C+(A-1)//D-(A-1)//c
print((B-b)-(A-1-a))

Fixed code:
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)
A,B,C,D= map(int, input().split())
print(B-A+1-B//C+(A-1)//C-B//D+(A-1)//D+B//lcm(C,D)-(A-1)//lcm(C,D))