TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
  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)))


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))))

Verdicts: Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
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 - A + 1
ans -= (B // C + B // D) - (A // C + A // D)
E = lcm(C, D)
ans += B // E - A // E

print(ans)


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 - A + 1
ans -= (B // C + B // D) - ((A - 1) // C + (A - 1) // D)
E = lcm(C, D)
ans += B // E - (A - 1) // E

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
def gcd(x,y):
  if(y==0):
  	return x
  if(x<y):
    x,y=y,x
  return gcd(y,x % y)
def lllen(a,b,c):
  at=a//c
  at=at*c
  b=b//c *c
  ansc=0
  while(at<a):
    at+=c
  ansc=b-at
  if ansc<0 :
  	ansc=0
  else:
  	ansc=ansc//c + 1
  	return ansc

a,b,c,d=map(int , input().strip().split() )
tl=b-a+1

ansc=lllen(a,b,c)
ansd=lllen(a,b,d)
ansl=lllen(a,b,(c*d)//gcd(c,d))
print(ansc,ansl,ansd)
print(b-a+1 -ansc -ansd + ansl)


  

def gcd(x,y):
  if(y==0):
  	return x
  if(x<y):
    x,y=y,x
  return gcd(y,x % y)
def lllen(a,b,c):
  at=a//c
  at=at*c
  b=b//c *c
  ansc=0
  while(at<a):
    at+=c
  ansc=b-at
  if ansc<0 :
  	ansc=0
  else:
  	ansc=ansc//c + 1
  return ansc

a,b,c,d=map(int , input().strip().split() )
tl=b-a+1

ansc=lllen(a,b,c)
ansd=lllen(a,b,d)
ansl=lllen(a,b,(c*d)//gcd(c,d))
#print(ansc,ansl,ansd)
print(b-a+1 -ansc -ansd + ansl)


  

Verdicts: Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
import math
input = list(map(int,input().split()))
A = input[0]
B = input[1]
C = input[2]
D = input[3]

betweenAandB = B-A+1

cA = math.ceil(A/C)
cB = int(B/C)
cDiv = cB - cA + 1

dA = math.ceil(A/D)
dB = int(B/D)
dDiv = dB - dA + 1

GCD = math.gcd(C,D)
LCM = C*D/GCD

lcmA = math.ceil(A/LCM)
lcmB = int(B/LCM)
lcmDiv = max(lcmA, lcmB) - min(lcmA, lcmB) + 1

ans = betweenAandB - cDiv - dDiv + lcmDiv
print(betweenAandB)
print(cDiv)
print(dDiv)
print(lcmDiv)
print(ans)


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

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

betweenAandB = B-A+1

cA = (A-1)//C
cB = B//C
cDiv = cB - cA

dA = (A-1)//D
dB = B//D
dDiv = dB - dA

GCD = gcd(C,D)
LCM = C*D//GCD

lcmA = (A-1)//LCM
lcmB = B//LCM
lcmDiv = lcmB - lcmA

ans = betweenAandB - cDiv - dDiv + lcmDiv
print(ans)

Verdicts: Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
a,b,c,d=map(int,input().split())

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

b_c = b//c
b_d = b//d
b_e = b//e
a_c = (a-1)//c
a_d = (a-1)//d
a_e = (a-1)//e

print(b-a+1 - (b_c - a_c) - (b_d - a_d) + (b_e - a_e))

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

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

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

b_c = b//c
b_d = b//d
b_e = b//e
a_c = (a-1)//c
a_d = (a-1)//d
a_e = (a-1)//e

print(b-a+1 - (b_c - a_c) - (b_d - a_d) + (b_e - a_e))


Verdicts: Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
import math

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

lcm = c*d / math.gcd(c,d)

def num(i):
  ans = b//i - a//i
  if a % i == 0:
    ans +=1
  return ans

lcm_num = num(lcm)

cd_num  = num(c) + num(d)

num = cd_num - lcm_num

print(b-a+1-num)

import math

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

lcm = int(c*d / math.gcd(c,d))

def num(i):
  ans = b//i - a//i
  if a % i == 0:
    ans +=1
  return ans

lcm_num = num(lcm)

cd_num  = num(c) + num(d)

num = cd_num - lcm_num

print(b-a+1-num)

Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
def acinput():
    return list(map(int,input().split(" ")))


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(x,y):
    return math.floor(x*y /gcd(x, y))

a,b,c,d=acinput()


l=lcm(c,d)
n_CandD=int(b/l)-int((a-1)/l)
n_C=int(b/c)-int((a-1)/c)
n_D=int(b/d)-int((a-1)/d)

print(int(b-a+1-(n_C+n_D-n_CandD)))


def acinput():
    return list(map(int,input().split(" ")))


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

a,b,c,d=acinput()


l=lcm(c,d)
CD=int(b/l)-int((a-1)/l)
nC=int(b/c)-int((a-1)/c)
nD=int(b/d)-int((a-1)/d)

print(int(b-a+1-(nC+nD-CD)))


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


def acinput():
    return list(map(int, input().split(" ")))
def lcm(x, y):
    return x*y //gcd(x, y)

a, b, c, d = acinput()
l = lcm(c, d)
CD = b//l-(a-1)//l
nC = b//c-(a-1)//c
nD = b//d-(a-1)//d

res = b-a+1-(nC+nD-CD)
print(int(res))


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
from math import gcd
a,b,c,d=map(int,input().split())
e=c*d//gcd(c,d)
print((a-1)//c-b//c+(a-1)//d-b//d+b//e-(a-1)//e)

import math
a,b,c,d=map(int,input().split())
x=b-b//c-b//d+b//(c*d//math.gcd(c*d))
y=(a-1)-(a-1)//c-(a-1)//d+(a-1)//(c*d//math.gcd(c*d))
print(x-y)


n,l=map(int,input().split())
a=l
b=n+l-1
x=((a+b)*n)//2
if a<=0 and b<=0:
  print(x-b)
elif a<=0:
  print(x)
else:
  print(x-a)


import math
a,b,c,d=map(int,input().split())
x=b-b//c-b//d+b//(c*d//math.gcd(c,d))
y=(a-1)-(a-1)//c-(a-1)//d+(a-1)//(c*d//math.gcd(c,d))
print(x-y)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
from fractions import gcd

def x(k, c, d):
    rl1 = k
    lcm = c*d / math.gcd(c,d)
    ccount = int(rl1 // c)
    dcount = int(rl1 // d)
    if lcm != 0:
        cdcount = int(rl1 // lcm)
    else:
        cdcount = 0

    return int(rl1 - ccount - dcount + cdcount)

a, b, C, D = map(int, input().split())
print(x(b, C, D) - x(a-1, C, D))

import fractions

def x(k, c, d):
    rl1 = k
    lcm = c*d / fractions.gcd(c,d)
    ccount = int(rl1 // c)
    dcount = int(rl1 // d)
    if lcm != 0:
        cdcount = int(rl1 // lcm)
    else:
        cdcount = 0

    return int(rl1 - ccount - dcount + cdcount)

a, b, C, D = map(int, input().split())
print(x(b, C, D) - x(a-1, C, D))

import fractions

def x(k, c, d):
    rl1 = k
    lcm = c*d / fractions.gcd(c,d)
    ccount = int(rl1 // c)
    dcount = int(rl1 // d)
    if lcm != 0:
        cdcount = int(rl1 // lcm)
    else:
        cdcount = 0

    return int(rl1 - ccount - dcount + cdcount)

a, b, C, D = map(int, input().split())
print(x(b, C, D) - x(a-1, C, D))

import fractions

def x(k, c, d):
    rl1 = k
    lcm = c*d / fractions.gcd(c,d)
    ccount = rl1 // c
    dcount = rl1 // d
    cdcount = rl1 // lcm
    # if lcm != 0:
    #     cdcount = int(rl1 // lcm)
    # else:
    #     cdcount = 0

    return rl1 - ccount - dcount + cdcount

a, b, C, D = map(int, input().split())
print(x(b, C, D) - x(a-1, C, D))

import math
def lcm(a):
    LCM = a[0]
    for i in range(1, len(a)):
        LCM = LCM * a[i] // math.gcd(LCM, a[i])
    return LCM

def f(k):
    return b//k - (a-1)//k

a, b, c, d = map(int, input().split())
ALL = b - a + 1
ans = ALL - (f(c) + f(d) - f(lcm([c,d])))
print(ans)

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
a,b,c,d = map(int,input().split())
a1 = a // c
a2 = b // c
b1 = b // c
b2 = b // d
e = c
while c % d != 0:
    c += e
a3 = a // c
b3 = b // c
print((b - b1 - b2 + b3) - (a - a1 - a2 + a3))

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)

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)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
 
 
def lcd(a, b):
    return a*b // gcd(a, b)
  
a, b, c, d = map(int, input().split())
sum1 = (a - 1) // c + (a - 1) // d + (a - 1) // lcd(c, d)
sum2 = b // c + b // d + b // lcd(c, d)
print(sum2 - sum1)

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
 
 
def lcd(a, b):
    return a*b // gcd(a, b)
  
a, b, c, d = map(int, input().split())
sum1 = (a - 1) // c + (a - 1) // d + (a - 1) // lcd(c, d)
sum2 = b // c + b // d + b // lcd(c, d)
print(b - a  + 1 - (sum2 - sum1))

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
 
 
def lcd(a, b):
    return a*b // gcd(a, b)
  
a, b, c, d = map(int, input().split())
sum1 = (a - 1) // c + (a - 1) // d - (a - 1) // lcd(c, d)
sum2 = b // c + b // d - b // lcd(c, d)
print(b - a  + 1 - (sum2 - sum1))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
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())

if A % C ==0:
    c = (B//C) - (A//C) +1
else:
    c = (B//C) - (A//C)

if A % D ==0:
    d = (B//D) - (A//D) +1
else:
    d = (B//D) - (A//D)

E = lcm(C,D)

if A % E ==0:
    e = (B//E) - (A//E) +1
else:
    e = (B//E) - (A//E)

print(c,d,e)
print(B-A+1-c-d+e)

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())

if A % C ==0:
    c = (B//C) - (A//C) +1
else:
    c = (B//C) - (A//C)

if A % D ==0:
    d = (B//D) - (A//D) +1
else:
    d = (B//D) - (A//D)

E = lcm(C,D)

if A % E ==0:
    e = (B//E) - (A//E) +1
else:
    e = (B//E) - (A//E)

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

Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
A, B, C, D = list(map(int, input().split()))
nans = 0
import math
cs = A if A % C == 0 else math.ceil(A / C) * C
ds = A if A % D == 0 else math.ceil(A / D) * D
E = (C * D) // math.gcd(C, D)
print(E)
es = A if A % E == 0 else math.ceil(A / E) * E

ce = B // C * C
de = B // D * D
ee = B // E * E

nans = (ce - cs) // C + 1 + (de - ds) // D + 1 - ((ee - es) // E + 1)
print(B - A + 1 - nans)


A, B, C, D = list(map(int, input().split()))
c1 = (A - 1) // C
c2 = B // C
d1 = (A - 1) // D
d2 = B //D
import math
E = (C * D) // math.gcd(C, D)
e1 = (A - 1) // E
e2 = B //E

print(B - A + 1 -(c2 - c1 + d2 - d1 - (e2 - e1)))


Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):

import math

S = input().split()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

E = C * D / math.gcd(C, D)
X = (B//C)-(A//C)
Y = (B//D)-(A//D)
Z = (B//(E))-(A//(E))+1

print(int(B-A-X-Y+Z))


S = input().split()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

X = (B/C)-(A/C)
Y = (B/D)-(A/D)
Z = (B/(C*D))-(A/(C*D))

print(int(B-A-X-Y+Z))


S = input().split()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

X = int((B//C)-(A//C))
Y = int((B//D)-(A//D))
Z = int((B//(C*D))-(A//(C*D)))+1

print(int(B-A-X-Y+Z))


import math

S = input().split()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

CD = C * D / math.gcd(C, D)
X = (B//C)-(A//C)
Y = (B//D)-(A//D)
Z = (B//(CD))-(A//(CD))+1

print(B-A-X-Y+Z)


S = input().split()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

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

X = int(B/C)-int((A-1)/C)
Y = int(B/D)-int((A-1)/D)
Z = int(B/E)-int((A-1)/E)

print(B-A+1-X-Y+Z)




import math

S = input().split()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

E = int((C * D) / math.gcd(C, D))
X = (B//C)-(A//C)
Y = (B//D)-(A//D)
Z = (B//E)-(A//E)+1

print(int(B-A-X-Y+Z))


import sys
import collections
import copy
import math

S = input().split()
A = float(S[0])
B = float(S[1])
C = float(S[2])
D = float(S[3])

E = (C * D) / math.gcd(C, D)
X = math.floor(B/C) - math.floor(A/C)
Y = math.floor(B/D) - math.floor(A/D)
Z = math.floor(B/E) - math.floor(A/E)

print(int(B-A-X-Y+Z))


import math

S = input().split()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

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

X = (B//C)-(A-1//C)
Y = (B//D)-(A-1//D)
Z = (B//(E))-(A-1//(E))

print(int(B-A+1-X-Y+Z))


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

 


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


S = input().split()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

E = lcm(C, D)

X = int(B//C)-int((A-1)//C)
Y = int(B//D)-int((A-1)//D)
Z = int(B//E)-int((A-1)//E)

print(B-A+1-X-Y+Z)

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
a,b,c,d = map(int, input().split())
count = 0


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

gcd_num = lcm(c,d)

#a
a_count = a // c
a_count = a_count + (a//d)
a_count = a_count - (a//gcd_num)
a_count = a-a_count

#b
b_count = b // c
b_count = b_count + (b//d)
b_count = b_count - (b//gcd_num)
b_count = b-b_count

div = b-count-a_count
print(div)

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


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 calc_num(n, C, D):
    
    div_C = n//C
    div_D = n//D
    div_CD = n//(lcm(C, D))
    return n-div_C-div_D+div_CD


def solve():
    A, B, C, D = map(int, input().split())
    return calc_num(B, C, D)-calc_num(A-1, C, D)

print(solve())

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


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

gcd_num = lcm(c,d)

def calc_num(n, C, D):
    
    div_C = n//C
    div_D = n//D
    div_CD = n//(lcm(C, D))
    return n-div_C-div_D+div_CD


def solve():
    A, B, C, D = map(int, input().split())
    return calc_num(B, C, D)-calc_num(A-1, C, D)

print(solve())


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 calc_num(n, C, D):
    
    div_C = n//C
    div_D = n//D
    div_CD = n//(lcm(C, D))
    return n-div_C-div_D+div_CD


def solve():
    A, B, C, D = map(int, input().split())
    return calc_num(B, C, D)-calc_num(A-1, C, D)

print(solve())

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
a,b,c,d = map(int,input().split())
count = 0
d = (a + b) // 2
for i in range(a,d):
    print(i)
    if(i % c != 0 and i % d != 2):
        count += 1
for i in range(d,b + 1):
    print(i) 
    if(i % c != 0 and i % d != 2):
        count += 1

print(count) 

def gcd(c, d):
    if (d == 0): return c
    else: return gcd(d, c % d)

def f(n, c, d):
    return n - (n // c + n // d - n // (c * d // gcd(c, d)))

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

if __name__ == "__main__":
    main()


Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
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())
divC = B//C - A//C
divD = B//D - A//D
CD = lcm(C,D)
divCD = B//CD - A//CD
divsum=divC+divD-divCD
answer=B-A+1-divsum

print(answer)


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(A,B,C,D)
divC = B//C - A//C
divD = B//D - A//D
CD = lcm(C,D)
divCD = B//CD - A//CD
divsum=divC+divD-divCD
answer=B-A+1-divsum

print(answer)


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())
divC = B//C - (A-1)//C
divD = B//D - (A-1)//D
CD = lcm(C,D)
divCD = B//CD - (A-1)//CD
divsum=divC+divD-divCD
answer=B-A+1-divsum

print(answer)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
import fractions
a,b,c,d=map(int,input().split())

x1=b//c-a//c
x2=b//d-a//d
sks=c * d // fractions.gcd(c,d)
x3=b//sks-a//sks
ans=b-a-(x1+x2-x3)
print (ans)



import fractions
a,b,c,d=map(int,input().split())
x1=b//c-(a-1)//c 
x2=b//d-(a-1)//d　
sks=c * d // fractions.gcd(c,d)
x3=b//sks-(a-1)//sks
ans=b-a+1-(x1+x2-x3)
print (ans)


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

x1=b//c-a//c
x2=b//d-a//d
sks=c * d // math.gcd(c,d)
x3=b//sks-a//sks
ans=(x1+x2)-x3
print (ans)


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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)
a-=1
e=lcm(c,d)

ansb=0
ansb += b//c
ansb += b//d
ansb -= b//e



ansa=0
ansa += a//c
ansa += a//d
ansa -= a//e
print((b-a)-(ansb-ansa))

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
A,B,C,D = map(int,input().split())
def f(B,n):
  return B//n
def gcd(a,b):
  if b==0:return a
  return gcd(b,a%b)
E = C*D/gcd(C,D)
print(B - f(B,C) - f(B,D) + f(B,E) - (A-1 - f(A-1,C) - f(A-1,D) + f(A-1,E)))

A,B,C,D = map(int,input().split())
def f(B,n):
  return B//n
def gcd(a,b):
  if b==0:return a
  return gcd(b,a%b)
E = C*D//gcd(C,D)
print(B - f(B,C) - f(B,D) + f(B,E) - (A-1 - f(A-1,C) - f(A-1,D) + f(A-1,E)))

Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
A,B,C,D=map(int,input().split())
print(A,B,C,D)

from math import*
upto_B=B-(B//C+B//D-B//(C*D//gcd(C,D)))
upto_A=A-1-((A-1)//C+(A-1)//D-(A-1)//(C*D//gcd(C,D)))

print(upto_B-upto_A*(A>2))

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

from fractions import*
upto_B=B-(B//C+B//D-B//(C*D//gcd(C,D)))
upto_A=A-1-((A-1)//C+(A-1)//D-(A-1)//(C*D//gcd(C,D)))

print(upto_B-upto_A*(A>2))

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

from math import*
upto_B=B-(B//C+B//D-B//(C*D//gcd(C,D)))
upto_A=A-1-((A-1)//C+(A-1)//D-(A-1)//(C*D//gcd(C,D)))

print(upto_B-upto_A*(A>2))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
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))

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))

Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
import math
import fractions


def calc(x):
    aa = math.ceil(a/x)*x
    bb = math.floor(b/x)*x
    return int((bb - aa) // x + 1)


a, b, c, d = map(int, input().split())
cd = c * d / fractions.gcd(c, d)
# print(b - a + 1, calc(cd), calc(c), calc(d))
print(int(b - a + 1 + calc(cd) - calc(c) - calc(d)))


import math
import fractions


def calc(x):
    aa = math.ceil(a/x)*x
    bb = math.floor(b/x)*x
    return int((bb - aa) // x + 1)


a, b, c, d = map(int, input().split())
cd = c * d / fractions.gcd(c, d)
print(int(b - a + 1 + calc(cd) - calc(c) - calc(d)))


import math
import fractions


def calc(x):
    aa = math.ceil(a/x)*x
    bb = math.floor(b/x)*x
    return int((bb - aa) // x + 1)


a, b, c, d = map(int, input().split())
cd = c * d / fractions.gcd(c, d)
print(calc(c), calc(d), calc(cd))
print(int(b - a + 1 + calc(cd) - calc(c) - calc(d)))


import math
import fractions


def calc(x):
    aa = math.ceil(a/x)*x
    bb = math.floor(b/x)*x
    return int((bb - aa) // x + 1)


a, b, c, d = map(int, input().split())
cd = c * d / fractions.gcd(c, d)
print(int(b - a + 1 + calc(cd) - calc(c) - calc(d)))


import math
import fractions

a, b, c, d = map(int, input().split())
# print(b - a + 1)
e = c * d // fractions.gcd(c, d)
cMax = math.ceil(a / c)
cMin = math.floor(b / c)
# print(cMin - cMax + 1)
dMax = math.ceil(a / d)
dMin = math.floor(b / d)
# print(dMin - dMax + 1)
eMax = math.ceil(a / e)
eMin = math.floor(b / e)
# print(eMin - eMax + 1)

print(b - a + 1 + eMin - eMax + 1 - (cMin - cMax + 1) - (dMin - dMax + 1))


import math

a, b, c, d = map(int, input().split())
cd = (c * d) // math.gcd(c, d)
u = b//c + b//d - b//cd
l = (a-1)//c + (a-1)//d - (a-1)//cd

print(b - a + 1 - u + l)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
def gcd(c, d):
  if c <= d:
    c, d = d, c
  while c % d:
    c, d = d, c % d
  return d
def lcm(c, d):
  return c*d // gcd(c, d)

A, B, C, D = map(int, input().split())
c_or_d = (B//C - A//C) + (B // D - A // D) -(B // lcm(C, D) - A // lcm(C, D))
print(B - A + 1 - c_or_d)

def gcd(c, d):
  if c <= d:
    c, d = d, c
  while c % d:
    c, d = d, c % d
  return d
def lcm(c, d):
  return (c * d) // gcd(c, d)

A, B, C, D = map(int, input().split())
c_or_d = (B // C - A // C) + (B // D - A // D) -(B // lcm(C, D) - A // lcm(C, D))
print(B - A + 1 - c_or_d)


def gcd(c, d):
  if c <= d:
    c, d = d, c
  while c % d:
    c, d = d, c % d
  return d
def lcm(c, d):
  return (c * d) // gcd(c, d)

A, B, C, D = map(int, input().split())
c_or_d = ((B // C) - (A // C)) + ((B // D) - (A // D)) - ((B // lcm(C, D)) - (A // lcm(C, D)))
print(B - A + 1 - c_or_d)


def gcd(c, d):
  if c <= d:
    c, d = d, c
  while c % d:
    c, d = d, c % d
  return d
def lcm(c, d):
  return (c * d) // gcd(c, d)

A, B, C, D = map(int, input().split())
c_or_d = ((B // C) - ((A - 1) // C)) + ((B // D) - ((A - 1) // D)) - ((B // lcm(C, D)) - ((A - 1) // lcm(C, D)))
print(B - A + 1 - c_or_d)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
A, B, C, D = list(map(int, input().split()))

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

def f(X, C, D):
    return int(X // C) + int(X // D) - int(X // ((C * D ) / gcd(C, D)))

ans = int((B - A + 1)) - int(f(B, C, D)) + int(f(A, C, D))

print(ans)

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

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

def f(X, C, D):
    return int(X // C) + int(X // D) - int(X // ((C * D ) / gcd(C, D)))

ans = int((B - A + 1) - f(B, C, D) + f(A, C, D))

print(ans)

import math

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

def f(X, C, D):
    return int(X // C) + int(X // D) - int(X // ((C * D ) / math.gcd(C, D)))

ans = int((B - A + 1) - f(B, C, D) + f(A, C, D))

print(ans)

import math

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

def f(X, C, D):
    return int(X // C) + int(X // D) - int(X // ((C * D ) / math.gcd(C, D)))

ans = int((B - A + 1) - f(B, C, D) + f(A, C, D))

print("{}".format(ans, int))

from math import gcd, ceil
a, b, c, d = map(int, input().split())

def f(s, x, y):
    lcm = x * y // gcd(x, y)
    ret = s // x + s // y - s // lcm
    return ret

print(b-a+1-f(b, c, d)+f(a-1, c, d))

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
from math import ceil

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


Cdiff = ceil(B/C) - ceil((A-1)/C)
Ddiff = ceil(B/D) - ceil((A-1)/D)

CDdiff = ceil(B/(C*D) ) - ceil((A-1)/(C*D))

res = Cdiff+Ddiff-CDdiff
print((B-A)-res)

from math import floor

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

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

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

def n(n):
    c = n // C
    d = n // D
    cd = n // lcm(C,D)
    return n - c - d + cd

print(n(B)-n(A-1))



Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
def gcd(a,b):
    while b:
        a,b=b,a%b
        return a
    
def lcm(x,y):
    return int(x*y/gcd(x,y))

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

S=B-A+1
if(A%C==0):
    n_C=B//C-A//C+1
else:
     n_C=B//C-A//C

if(A%D==0):
    n_D=B//D-A//D+1
else:
    n_D=B//D-A//D

if(A%lcm(C,D)==0):
    n_CD=B//lcm(C,D)-A//lcm(C,D)+1
else:
    n_CD=B//lcm(C,D)-A//lcm(C,D)
    
print(S-n_C-n_D+n_CD)

def gcd(a,b):
    if(a<b):
        tmp=b
        b=a
        a=tmp
    while(a%b!=0):
        tmp_1=b
        tmp_2=a%b
        a=tmp_1
        b=tmp_2
    return b
    
def lcm(x,y):
    return int(x*y/gcd(x,y))

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

S=B-A+1
if(A%C==0):
    n_C=B//C-A//C+1
else:
     n_C=B//C-A//C

if(A%D==0):
    n_D=B//D-A//D+1
else:
    n_D=B//D-A//D

if(A%lcm(C,D)==0):
    n_CD=B//lcm(C,D)-A//lcm(C,D)+1
else:
    n_CD=B//lcm(C,D)-A//lcm(C,D)
    
print(S-n_C-n_D+n_CD)

Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
A, B, C, D = map(int, input().split())

if A%C==0:
    c_num = B//C - A//C + 1
else:
    c_num = B//C - A//C

if A%D==0:
    d_num = B//D - A//D + 1
else:
    d_num = B//D - A//D

print(B - A + 1 - c_num - d_num + cd_num)


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())

A = A -1
c_num = B//C - A//C
d_num = B//D - A//D
    
lcm_num = lcm(C, D)

cd_num = B//lcm_num - A//lcm_num
    
print(B - A - c_num - d_num + cd_num)

Verdicts: Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
A, B, C, D = map(int,input().split())
ans = 0
x1c = B // C
x1d = B // D
x2c = (A-1) // C
x2d = (A-1) // D
def gcd(x,y):
    while y != 0:
        x, y = y, x%y
    return x
g = gcd(C,D)
l = (C*D) / g
x1cd = B // l
x2cd = (A-1) // l
ans_B = B - (x1c+x1d-x1cd)
ans_A = (A-1) - (x2c+x2d-x2cd)
ans = ans_B - ans_A
print(ans)

A, B, C, D = map(int,input().split())
ans = 0
x1c = B // C
x1d = B // D
x2c = (A-1) // C
x2d = (A-1) // D
def gcd(x,y):
    if x < y:
        z = x
        x = y
        y = z
    while y != 0:
        x, y = y, x%y
    return x
g = gcd(C,D)
l = (C*D) // g
x1cd = B // l
x2cd = (A-1) // l
ans_B = B - (x1c+x1d-x1cd)
ans_A = (A-1) - (x2c+x2d-x2cd)
ans = ans_B - ans_A
ans = int(ans)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
# ABC131C

def euclid(m, n):
    m0 = m = abs(m)
    n0 = n = abs(n)
    while n != 0:
        m, n = n, m % n
    qm = m0 // m
    lcm = qm * n0
    return lcm


def check(a, b, c):
    x = a // c
    y = b // c
    if x * c < a:
        x += 1
    return y - x + 1

a, b, c, d = map(int, input().split())
nc = check(a, b, c)
nd = check(a, b, d)
ncd = check(a, b, lcm(c, d))
print(b - a + 1 -(nc + nd - ncd))


# ABC131C

def check(a, b, c):
    x = a // c
    y = b // c
    if x * c < a:
        x += 1
    return y - x + 1

a, b, c, d = map(int, input().split())
nc = check(a, b, c)
nd = check(a, b, d)
ncd = check(a, b, sp.lcm(c, d))
print(b - a + 1 -(nc + nd - ncd))


# ABC131C

def euclid(m, n):
    m0 = m = abs(m)
    n0 = n = abs(n)
    while n != 0:
        m, n = n, m % n
    qm = m0 // m
    lcm = qm * n0
    return lcm


def check(a, b, c):
    x = a // c
    y = b // c
    if x * c < a:
        x += 1
    return y - x + 1

a, b, c, d = map(int, input().split())
nc = check(a, b, c)
nd = check(a, b, d)
ncd = check(a, b, sp.lcm(c, d))
print(b - a + 1 -(nc + nd - ncd))


# ABC131C

def euclid(m, n):
    m0 = m = abs(m)
    n0 = n = abs(n)
    while n != 0:
        m, n = n, m % n
    qm = m0 // m
    lcm = qm * n0
    return lcm


def check(a, b, c):
    x = a // c
    y = b // c
    if x * c < a:
        x += 1
    return y - x + 1

a, b, c, d = map(int, input().split())
nc = check(a, b, c)
nd = check(a, b, d)
ncd = check(a, b, euclid(c, d))
print(b - a + 1 -(nc + nd - ncd))


Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
A,B,C,D = map(int,input().split())
 
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
 
ctr = 0
 
tmp1 = A // C
tmp2 = A // D
tmp3 = B // (C * D / gcd(C,D))
tmp4 = B // C
tmp5 = B // D
 
print(int(tmp4 + tmp5 - tmp3 - tmp1 -tmp2))
 

A,B,C,D = map(int,input().split())
 
def gcd( x, y ):
    while y != 0:
        x, y = y, x%y

ctr = 0

tmp1 = A // C
tmp2 = A // D
tmp3 = B // (C * D / gcd(C,D))
tmp4 = B // C
tmp5 = B // D

print(tmp4 + tmp5 - tmp3 - tmp1 -tmp2)



A,B,C,D = map(int,input().split())
 
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
 
ctr = 0
 
tmp1 = A // C # 1
tmp2 = A // D # 1
#tmp3 = B // int((C * D / gcd(C,D))) # 24
tmp4 = B // C
tmp5 = B // D
 
print(int(tmp4 + tmp5 - tmp2 - tmp1))
 

A,B,C,D = 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//gcd(a,b)

ctr = 0

tmp1 = B // int(lcm(C,D))
tmp4 = B // C
tmp5 = B // D
 
print(int(B - tmp4 - tmp5 + tmp1))
 

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())

b_num = B//C + B//D - B//lcm(C, D)
a_num = (A-1)//C + (A-1)//D - (A-1)//lcm(C, D)

print((B-A+1) -(b_num - a_num))

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
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 = list(map(int, input().split()))
 
lcmCD = lcm(C, D)
 
divB = (B // C) + (B // D) - (B // lcmCD)
divA_1 = ((A - 1) // C) + ((A - 1) // D) - ((A - 1) // lcmCD)
print((B - A) - (divB - divA_1) + 1)

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 = list(map(int, input().split()))

lcmCD = lcm(C, D)

divB = (B // C) + (B // D) - (B // lcmCD)
divA_1 = ((A - 1) // C) + ((A - 1) // D) - ((A - 1) // lcmCD)
print((B - A) - (divB - divA_1) + 1)


Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
a,b,c,d=map(int, input().split())
tc = b//c-a//c
td = b//d-a//d
tcd = b//(c*d)-a//(c*d)
print(b-a+1-tc-td+tcd)

a,b,c,d=map(int, input().split())
tc = b//c-a//c
td = b//d-a//d
tcd = b//(c*d)-a//(c*d)
print(b-a+1-tc-tc+tcd)

import fractions
a,b,c,d=map(int, input().split())
cdlcm= a*b//fractions.gcd(a,b)
a-=1
tc = b//c-a//c
td = b//d-a//d
tlcm = b//cdlcm-a//cdlcm
print(b-a-tc-td+tlcm)


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

def lcm(x,y):
  return x*y//gcd(x,y)
a,b,c,d=map(int,input().split())
a-=1
e=lcm(c,d)
tc=b//c-a//c
td=b//d-a//d
te=b//e-a//e
print(b-a-tc-td+te)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
a,b,c,d = map(int,input().split())

bc = b//c
bd = b//d

import math
bcd = c*d/math.gcd(c,d)

ac = (a-1)//c
ad = (a-1)//d
acd = c*d//math.gcd(c,d)

ans = (b-(bc+bd-bcd))-((a-1)-(ac+ad-acd))

print(int(ans))


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

bc = b//c
bd = b//d

import math
bcd = c*d//math.gcd(c,d)

ac = (a-1)//c
ad = (a-1)//d
acd = c*d//math.gcd(c,d)

ans = (b-(bc+bd-bcd))-((a-1)-(ac+ad-acd))

print(ans)


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

bc = b//c
bd = b//d

import math
bcd = b//(c*d/math.gcd(c,d))

ac = (a-1)//c
ad = (a-1)//d
acd = (a-1)//(c*d/math.gcd(c,d))

ans = (b-(bc+bd-bcd))-((a-1)-(ac+ad-acd))

print(ans)


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

import math

bc = b//c
bd = b//d
bcd = b//(c*d//math.gcd(c,d))

ac = (a-1)//c
ad = (a-1)//d
acd = (a-1)//(c*d//math.gcd(c,d))

ans = (b-bc-bd+bcd)-((a-1)-ac-ad+acd)

print(ans)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
a,b,c,d=map(int,input().split())

if c!=d:
    
    
    sma=min(c,d)
    big=max(c,d)
    
    while sma!=0 :
        cal=big%sma
        big=sma
        sma=cal
    
    euc=big
    ggg=c*d//euc
    
    #print(euc,ggg)
    
    def  cnt(n,ggg,c,d):
        exc=ggg//c + ggg//d
        if c<ggg or d<ggg:
            exc-=1
        ret=exc*(n//ggg)
        print(ggg,exc,ret)
        remain=n%ggg
        ret+= remain//c + remain//d
        return ret
    
    #print(cnt(b,ggg,c,d))
    #print(cnt(a-1,ggg,c,d))
    
    jog=cnt(b,ggg,c,d)-cnt(a-1,ggg,c,d)
    
    ans=(b-a+1)-jog
    
    print(ans)
    
else:
    jog=(b//c) -((a-1)//c)
    print(b-a+1-jog)    

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

if c!=d:
    
    
    sma=min(c,d)
    big=max(c,d)
    
    while sma!=0 :
        cal=big%sma
        big=sma
        sma=cal
    
    euc=big
    ggg=c*d//euc
    
    #print(euc,ggg)
    
    def  cnt(n,ggg,c,d):
        exc=ggg//c + ggg//d
        if c<ggg or d<ggg:
            exc-=1
        ret=exc*(n//ggg)
        #print(ggg,exc,ret)
        remain=n%ggg
        ret+= remain//c + remain//d
        return ret
    
    #print(cnt(b,ggg,c,d))
    #print(cnt(a-1,ggg,c,d))
    
    jog=cnt(b,ggg,c,d)-cnt(a-1,ggg,c,d)
    
    ans=(b-a+1)-jog
    
    print(ans)
    
else:
    jog=(b//c) -((a-1)//c)
    print(b-a+1-jog)    

Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
a,b,c,d=map(int,input().split())
zen=int(b-a)
c=int(zen//c)
d=int(zen//d)
kasa=int(zen/(c*d))

ans=zen-c-d+kasa

print(ans)

import math
a,b,c,d=map(int,input().split())
count=b-a+1
acou=((a-1)//c)+((a-1)//d)-int(((a-1)//(c*d//math.gcd(c,d))))
bcou=(b//c)+(b//d)-int((b//(c*d//math.gcd(c,d))))
print(count-(bcou-acou))


Verdicts: Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
import fraction
a,b,c,d = map(int,input().split())
lcm = c*d // fraction.gcd(c,d)
A = ((a-1) // c) + ((a-1) // d) - ((a-1) // lcm)
B = (b // c) + (b // d) - (b // lcm)
total = B - A
print(b - a + 1 - total)


a,b,c,d = map(int,input().split())
ans = b - a + 1
x = c * d
e = c
f = d
if e < f:
    e = f
    f = c
r = e % f
while r != 0:
    e = f
    f = r
    r = e % f
x //= f
ans -= b // c - (a-1) // c + b // d - (a-1) // d
ans += b // x - (a-1) // x
print(ans)

Verdicts: Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
from fractions import gcd 

l = list(map(int,input().split()))
A = l[0]
B = l[1]
C = l[2]
D = l[3]

E = C * D //math.gcd(C,D)

f = B//C - (A-1)//C
f = f+(B//D - (A-1)//D)
ans = B-A+1-f + B//E-(A-1)//E
print(ans)


import fractions

l = list(map(int,input().split()))
A = l[0]
B = l[1]
C = l[2]
D = l[3]

E = C * D //math.gcd(C,D)

f = B//C - (A-1)//C
f = f+(B//D - (A-1)//D)
ans = B-A+1-f + B//E-(A-1)//E
print(ans)


def gcd(m,n):
    i = max(m,n)
    j = min(m,n)
    return sgcd(i,j)

def sgcd(i,j):
    if j == 0:
        return i
    else:
        return sgcd(j,i%j)

l = list(map(int,input().split()))
A = l[0]
B = l[1]
C = l[2]
D = l[3]

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

f = B//C - (A-1)//C
f = f+(B//D - (A-1)//D)
ans = B-A+1-f + B//E-(A-1)//E
print(ans)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):

#include<string>

#include<algorithm>
#include<numeric>
#include<cmath>
#include<stdio.h>
//#include<array>

#define rep(i,n) for(int i=0;i<(n);i++)
#define LL long long int


using namespace std;

int main(void){
    LL a,b,c,d;
    cin >> a>>b>>c>>d;

    LL ans=0;
    /* 
    for(int i =a; i<b; i++){

        if(i%c!=0 && i%d!=0){
            ans++;
        }

    }*/

    LL C =b/c-a/c;
      LL D= b/d-a/d;
    /* vector<LL> lista(C);
    int h=0;
    for(LL i =a/c,h=0;i<b/c;h++,i++){
        lista[h]=i*a;
        cout<<lista[h]<< " " << h<< " " << i<< " " << i*a<<endl;
    }
    LL x;
  
    LL j=0;
    LL EX=0;
   for(LL i =a/d;i<b/d;i++){
        x=i*b;
         while(x>lista[j] )j++;
        cout<<x<< " " << lista[j]<< " " << h<< " " << j<<endl;
        if(lista[j]==x)EX++;
        if( h>j)break;

   }*/

    cout <<b-a+1-(C+D)<<endl;
    return 0;
}


#include<string>

#include<algorithm>
#include<numeric>
#include<cmath>
#include<stdio.h>
//#include<array>

#define rep(i,n) for(int i=0;i<(n);i++)
#define LL long long int


using namespace std;

int main(void){
    LL a,b,c,d;
    cin >> a>>b>>c>>d;

    LL ans=0;
    

    LL C =b/c-a/c;
    LL D= b/d-a/d;
      /* 
    for(int i =a; i<b; i++){

        if(i%c!=0 && i%d!=0){
            ans++;
        }

    }*/
    /* vector<LL> lista(C);
    int h=0;
    for(LL i =a/c,h=0;i<b/c;h++,i++){
        lista[h]=i*a;
        cout<<lista[h]<< " " << h<< " " << i<< " " << i*a<<endl;
    }
    LL x;
  
    LL j=0;
    LL EX=0;
   for(LL i =a/d;i<b/d;i++){
        x=i*b;
         while(x>lista[j] )j++;
        cout<<x<< " " << lista[j]<< " " << h<< " " << j<<endl;
        if(lista[j]==x)EX++;
        if( h>j)break;

   }*/

    cout <<b-a+1-(C+D)<<endl;
    return 0;
}

from math import gcd
def lcm( x, y):
    return (x*y)//gcd(x,y)
a,b,c,d=map(int,input().split())
C =b//c-a//c
D= b//d-a//d
EX=  lcm(c,d)
EX=b//EX-a//EX
print(b-a+1-(C+D)+EX)

def gcd(x,y):
    if x<y:
        x,y=y,x
    if y==0:
        return x
    c=x%y
    return gcd(y,c)   
def lcm( x, y):
    return (x*y)//gcd(x,y)
a,b,c,d=map(int,input().split())
C =b//c-(-(-a//c))
D= b//d-(-(-a//d))
EX=  lcm(c,d)
EX=b//EX+(-a//EX)
print(b-a-(C+D)+EX)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
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())
if A%C==0:
    #nc=int(B/C)-int(A/C)+1
    nc=B//C-A//C+1
else:
    #nc=int(B/C)-int(A/C)
    nc=B//C-A//C
if A%D==0:
    #nd=int(B/C)-int(A/C)+1
    #nd=int(B/D)-int(A/D)+1
    nd=B//D-A//D+1
else:
    #nd=int(B/D)-int(A/D)
    nd=B//D-A//D
cd=C*D/gcd(C,D)
if A%cd==0:
    #ncd=int(B/cd)-int(A/cd)+1
    ncd=B//cd-A//cd+1
else:
    #ncd=int(B/cd)-int(A/cd)
    ncd=B//cd-A//cd
#print("nc,nd,ncd",nc,nd,ncd)
print(B-A+1-nc-nd+ncd)


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())

nc=B//C-(A-1)//C
nd=B//D-(A-1)//D
cd=int(C*D/gcd(C,D))
ncd=B//cd-(A-1)//cd
print(B-A+1-nc-nd+ncd)


Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
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))

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))

Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
#C
import math
a, b, c, d = map(int, input().split())
bb = b - (b // c) - (b // d) + (b // (c * d / math.gcd(c, d)))
aa = a - (a // c) - (a // d) + (a // (c * d / math.gcd(c, d)))

print((bb-aa))

#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
a-=1
cd = c * d // gcd(c, d)
ans = b - (b // c) - (b // d) + (b // cd)
ans -= a - (a // c) - (a // d) + (a // cd)

print(ans)

C
import math
a, b, c, d = map(int, input().split())
a-=1
cd=c*d//math.gcd(c,d)
ans = b - (b // c) - (b // d) + (b // cd)
ans -= a - (a // c) - (a // d) + (a // cd)

print(ans)

#C
import math
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

a, b, c, d = map(int, input().split())
bb = b - (b // c) - (b // d) + (b // (c * d / gcd(c, d)))
aa = a - (a // c) - (a // d) + (a // (c * d / gcd(c, d)))

print((bb - aa))

#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)

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
#print(gcd(a,b))


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

a,b,c,d = list(map(int,input().split(" ")))
e = lcm(c,d)

p=a//c
o=b//c
i=a//d
u=b//d
y=a//e
t=b//e

print(b-a+1-(o-p+u-i-t+y))

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


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

a,b,c,d = list(map(int,input().split(" ")))
e = lcm(c,d)
p=a//c
o=b//c
i=a//d
u=b//d
y=a//e
t=b//e
C = max([0,o-p])
D = max([0,u-i])
E = max([0,t-y])
print( (b-a+1)-(C+D-E) )

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


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

a,b,c,d = list(map(int,input().split(" ")))
e = lcm(c,d)
p=a//c
o=b//c
i=a//d
u=b//d
y=a//e
t=b//e
C = max([0.o-p])
D = max([0,u-i])
E = max([0,t-y])
print( (b-a+1)-(C+D-E) )

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


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

a,b,c,d = list(map(int,input().split(" ")))
e = lcm(c,d)

p=a//c
o=b//c
i=a//d
u=b//d
y=a//e
t=b//e

C = max(0.o-p)
D = max(0,u-i)
E = max(0,t-y)
print((b-a+1)-(C+D-E))

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


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

a,b,c,d = list(map(int,input().split(" ")))
e = lcm(c,d)
p=(a-1)//c
o=b//c
i=(a-1)//d
u=b//d
y=(a-1)//e
t=b//e
C = max([0,o-p])
D = max([0,u-i])
E = max([0,t-y])
print( (b-a+1)-(C+D-E) )

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
import math

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


lcm = a * b / math.gcd(a, b)

num = b-a
c_1 = (b-a)//c
d_1 = (b-a)//d
cd_1 = (b-a)//(lcm)

ans = num - (c_1 + d_1) + cd_1
print(ans)

import math

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

lcm = c*d // math.gcd(c, d)

dif = b-a+1
div_c = b//c - (a-1)//c
div_d = b//d - (a-1)//d
div_cd = b//lcm - (a-1)//lcm

ans = dif - (div_c + div_d) + div_cd
print(int(ans))

Verdicts: Wrong Answer

Accepted