Problem:


Score : 300 points

Problem Statement

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.

Constraints

1\leq A\leq B\leq 10^{18}

1\leq C,D\leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B C D

Output

Print the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Sample Input 1

4 9 2 3

Sample Output 1

2

5 and 7 satisfy the condition.

Sample Input 2

10 40 6 8

Sample Output 2

23

Sample Input 3

314159265358979323 846264338327950288 419716939 937510582

Sample Output 3

532105071133627368



Sample input:
4 9 2 3


Sample output:
2

Submission status: Time Limit Exceeded

Solution code:
def main(A,B,C,D):
    count = 0    
    for i in range(A,B+1):
        if i % C != 0 and i % D !=0:
            count += 1
    return count
A,B,C,D = map(int, input().split())
print(main(A,B,C,D))

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d = map(int, input().split())
ans = 0
for i in range(a,b+1):
    if ((i%c) * (i%d)) !=0:
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
A,B,C,D=map(int,input().split())
count = 0
for i  in range(A,B+1):
  if i % C != 0 and i % D != 0:
    count += 1
print(count)

Submission status: Time Limit Exceeded

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

count = 0
for i in range(a, b+1, 1):
    if (i % c != 0) and (i % d != 0):
        count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
A,B,C,D=map(int,input().split())
cnt=0
for i in range(A,B+1):
    if i%C!=0 and i%D!=0:
        cnt+=1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
data = list(map(int, input().split()))
A = data[0]
B = data[1]
C = data[2]
D = data[3]
def antinum(t,bo,bi):
    n = 0
    kaesi = []
    while n <= len(t) - 1:
        if t[n] % bo != 0 and t[n] % bi != 0:
            kaesi += [t[n]]
        if n == len(t) - 1:
            return kaesi
        n += 1
src = []
sa = A
while sa <= B:
    src += [sa]
    sa += 1
nexts = len(antinum(src,C,D))
print(nexts)

Submission status: Time Limit Exceeded

Solution code:
a, b, c, d = [int(i) for i in input().split()]
n = {i for i in range(a, b+1) if i % c != 0 and i % d != 0}
ans = len(n)
print(ans)

Submission status: Time Limit Exceeded

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

x, y = max(c, d), min(c, d)
r = x - y
while r != 0:
    x, y = max(y, r), min(y, r)
    r = x - y
gcd = x
lcm = c * d // gcd

nc = b // c - (a - 1) // c
nd = b // d - (a - 1) // d
nlcm = b // lcm - (a - 1) // lcm

print((b - a + 1) - (nc + nd - nlcm))

Submission status: Time Limit Exceeded

Solution code:
z = list(map(int, input().split()))
a,b,c,d,cnt = z[0],z[1],z[2],z[3],0
while(a <= b):
    if (a%c != 0 and a%d != 0):
        cnt += 1
    a += 1
print(cnt)

Submission status: Time Limit Exceeded

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

for i in range(a,b+1):
    if i%c != 0 and i%d != 0:
        ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d=map(int,input().split())
l=[x for x in range(a,b+1)]
cnt=0
for i in l:
  if(i%c!=0 and i%d!=0):
    cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
def main():
	a,b,c,d = map(int,input().split())
	ans = 0
	i = int(a/c)
	t = int(a/d)
	while i*c < a:
		i += 1
	while t*d < a:
		t += 1
	ans_set = set()

	while a <= i * c <= b:
		ans_set.add(i*c)
		i += 1

	while a <= t * d <= b:
		ans_set.add(t*d)
		t += 1
	print(int(len(range(a,b+1)))-len(ans_set))

if __name__ == "__main__":
	main()

Submission status: Time Limit Exceeded

Solution code:
l=list(map(int,input().split()))
a=l[0]
b=l[1]
x=l[2]
y=l[3]
nums=[x for x in range(a,b+1)]
cnt=0
for num in nums:
  if(num%x!=0 and num%y!=0):
    cnt+=1
print (cnt)

Submission status: Time Limit Exceeded

Solution code:
A,B,C,D = map(int, input().split())
ans = 0
for i in range(A, B + 1):
    if i % C != 0 and i % D != 0:
        ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d=map(int,input().split())
for i in range(b+1):
  if c*i>=a:
    clst=[c*i for i in range(i,(b-c*i)//c+i+1)]
    break
for i in range(b+1):
  if d*i>=a:
    dlst=[d*i for i in range(i,(b-d*i)//d+i+1)]
    break
lst=set(clst+dlst)
print(b-a+1-len(lst))

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d=map(int,input().split())
ans=0
for i in range(a,b+1):
  if i%c!=0 and i%d!=0:
    ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d=map(int,input().split())
for i in range(b+1):
  if c*i>=a:
    clst=[c*i for i in range(i,(b-c*i)//c+i+1)]
    break
for i in range(b+1):
  if d*i>=a:
    dlst=[d*i for i in range(i,(b-d*i)//d+i+1)]
    break
lst=set(clst+dlst)
print(b-a+1-len(lst))

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d=map(int,input().split())
if c>b and d>b:
  print(b-a+1)
  exit()
elif c>b:
  for i in range(b):
    if d*i>=a:
      d1=i*d
  print(b-a-(b-d1)//d)
  exit()
elif d>b:
  for i in range(b):
    if c*i>=a:
      c1=i*c
  print(b-a-(b-c1)//c)
  exit()
else :
  for i in range(b+1):
    if c*i>=a:
      clst=[c*i for i in range(i,(b-c*i)//c+i+1)]
      break
  for i in range(b+1):
    if d*i>=a:
      dlst=[d*i for i in range(i,(b-d*i)//d+i+1)]
      break
  lst=set(clst+dlst)
  print(b-a+1-len(lst))

Submission status: Time Limit Exceeded

Solution code:
a, b, c, d = map(int, input().split())
num = [i for i in range(b + 1) if i >= a]
cnt = 0
for i in num:
  if i % c != 0 and i % d != 0:
    cnt += 1
    
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
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 y

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

block=lcm(c,d)
block_c=block//c
block_d=block//d
ans_in_block=block-(block_c+block_d-1)

def count_ans(z,block,ans_in_block,p,q):
  z_amari=z%block
  z_ans=0
  for i in range(1,z_amari+1):
    if i%p!=0 and i%q!=0:
      z_ans+=1
  return (z//block)*ans_in_block+z_ans

print(count_ans(b,block,ans_in_block,c,d)-count_ans(a,block,ans_in_block,c,d)+(a%c!=0 and a%d!=0))

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d = map(int,input().split())
ans = 0
for i in range(a,b+1):
  if i % c != 0:
    if i % d != 0:
      ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!

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())
e=lcm(c,d)
a_1=a%e
b_1=b%e
cnt=0
if b-a<=e:
    for i in range(a,b+1):
        if i%c!=0 and i%d!=0:
            cnt+=1
    print(cnt)
    exit()
a_2=a//e
b_2=b//e
if b_2-a_2==1:
    for i in range(a,b+1):
        if i%c!=0 and i%d!=0:
            cnt+=1
    print(cnt)
    exit()
for i in range(0,e):
    if i%c!=0 and i%d!=0:
        cnt+=1

cnt*=b_2-a_2-1

for i in range(a,(a_2+1)*e):
    if i%c!=0 and i%d!=0:
        cnt+=1
for i in range(b_2*e,b+1):
    if i%c!=0 and i%d!=0:
        cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
a, b, c, d=(int(x) for x in input().split())
cnt=0
for i in range(a,b+1):
  if i%c!=0 and i%d!=0:
    cnt+=1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
A,B,C,D = map(int,input().split())
ab_list = []
ans = []
for i in range(A,B+1):
    ab_list.append(i)
    
for i in ab_list:
    if i % C == 0:     
        pass
    elif i % D == 0:
        pass
    else:
        ans.append(i)
print(len(ans))

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
input = sys.stdin.readline


def main():
    sc = Scan()
    a, b, c, d = sc.intarr()
    count = 0
    for i in range(a, b+1):
        if i % c != 0 and i % d != 0:
            count += 1
    print(count)


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


main()

Submission status: Time Limit Exceeded

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

minC = c
for i in range(a,b+1):
    if i % c == 0:
        minC = i
        break
minD = d
for i in range(a,b+1):
    if i % d == 0:
        minD = i
        break
clist =  [i for i in range(minC, b+1, c)]
dlist = [i for i in range(minD, b+1, d)]
clist.extend(dlist)
ans = len(list(set(clist)))
print(b-a-ans+1)

Submission status: Time Limit Exceeded

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

count = 0
for i in range(a,b+1):
    if i % c != 0 and i % d != 0:
        count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d=map(int,input().split())
h=0
for i in range(a,b+1):
  if i%c==0 or i%d==0:
    pass
  else:
    h+=1
    
print(h)

Submission status: Time Limit Exceeded

Solution code:
A,B,C,D = map(int,(input().split()))
count = 0
for i in range(A,B+1):
    if i%C!=0 and i%D!=0:
        count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d=map(int,input().split(" "))
co=0
for i in range(a,b+1):
    if i%c!=0 and i%d!=0:
        co+=1
print(co)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d=map(int,input().split())
cnt=0
for i in range(a,b+1):
  if i%c==0:
    cnt+=0
  elif i%d==0:
    cnt+=0
  else:
    cnt+=1
    
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d=map(int,input().split())
cnt=0
for i in range(a,b+1):
  if i%c!=0 and i%d!=0:
    cnt+=1
  else:
    cnt+=0
print(cnt)

Submission status: Time Limit Exceeded

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

cnt = 0
for i in range(a, b+1):
    if i%c != 0 and i%d != 0:
        cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

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

count = 0
for i in range(A, B+1):
  if i % C != 0 and i % D != 0:
    count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
A,B,C,D=map(int,input().split())
s=0
for j in range(A,B+1):
  if j%C!=0 and j%D!=0:
    s+=1
print(s)

Submission status: Time Limit Exceeded

Solution code:
A,B,C,D=map(int,input().split())
s=0
for j in range(A,B+1):
  if j%C==0 or j%D==0:
    s+=1
m=B-A+1
print(m-s)

Submission status: Time Limit Exceeded

Solution code:
A,B,C,D=map(int,input().split())
s=0
for j in range(A,B+1):
  if j%C==0 or j%D==0:
    s+=1
m=B-A+1
print(m-s)

Submission status: Time Limit Exceeded

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

##N=int(input())
##c=list(map(int, input().split()))

k=0
for i in range(A,B+1):
    if((i%C)and(i%D)):
        k=k+1
print(k)

Submission status: Time Limit Exceeded

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

ans = 0

for i in range(A, B+1):
  if i % C != 0 and i % D !=0:
    ans += 1
    
print(ans)

Submission status: Time Limit Exceeded

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

for i in range(a, b+1):
  if i%c > 0 and i%d > 0:
    ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
# 4 9 2 3
# 2

# 10 40 6 8
# 23
aaa_list = list(map(int,input().split()))
orcnt = 0
andcnt = 0

for i in range(aaa_list[0],aaa_list[1]+1):
    #if i % aaa_list[2] or i % aaa_list[3] :
    #    orcnt +=1
    if i % aaa_list[2] and i % aaa_list[3] :
        andcnt +=1
    else: pass

#print(orcnt)
print(andcnt)

Submission status: Time Limit Exceeded

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

sum = 0
for n in range(A, B+1):
    if (n % C != 0) and (n % D != 0):
        sum += 1
print(sum)

Submission status: Time Limit Exceeded

Solution code:
# 多分TLRE
a,b,c,d = map(int,input().split())

ans_L = []
for val in range(a,b+1):
    if val % c !=0 and val % d!=0:
        ans_L.append(val)
print(len(ans_L))

Submission status: Time Limit Exceeded

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

cList = []

dList = []

numList = []

supC = (B // C)
infC = (A // C)

supD = (B // D)
infD = (A // D)

for i in range(A,B+1):
	numList.append(i)


for i in range(infC,supC+1):
	cList.append(i * C)

for i in range(infD,supD+1):
	dList.append(i * D)
	
numList = len(set(numList) - set(cList) - set(dList))

print(numList)

Submission status: Time Limit Exceeded

Solution code:
A, B, C, D = map(int, input().split())
ans = 0
for i in range(A,B+1):
    if i%C == 0:
        continue
    else:
        if i%D == 0:
            continue
        else:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d=map(int, input().split())
div_c=[]
div_d=[]
div_cd=[]
for i in range(a,b+1):
    if i%c==0 and i%d==0:
        div_cd.append(i)
    if i%c==0:
        div_c.append(i)
    if i%d==0:
        div_d.append(i)
print(b-a+1-len(div_c)-len(div_d)+len(div_cd))

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d = map(int, input().split())
count = 0
for i in range(a,b+1):
  if i%c != 0 and i%d != 0:
    count+=1

print(count)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d=list(map(int,input().split()))
cnt=0
for i in range(a,b+1):
  if i%c!=0 and i%d!=0:
    cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import sys
input=sys.stdin.readline
a,b,c,d=list(map(int,input().split()))
cnt=0
for i in range(a,b+1):
  if i%c!=0 and i%d!=0:
    cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d=map(int,input().split())
print(len([1 for i in range(a,b+1) if i%c and i%d]))

Submission status: Time Limit Exceeded

Solution code:
A, B, C, D = map(int, input().split())
num = 0
for i in range(A, B+1):
    if i % C == 0:
        num += 1
    elif i % D == 0:
        num += 1
x_num = B - A + 1 - num
print(x_num)

Submission status: Time Limit Exceeded

Solution code:
A, B, C, D = map(int, input().split())
num = 0
for i in range(A, B+1):
    if i % C != 0 and i % D != 0:
        num += 1
print(num)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d=map(int,input().split())
ans=0
for i in range(a,b+1):
    if i%c!=0 and i%d!=0:
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d = map(int,input().split())
ans = 0
for i in range(a,b+1):
         if i%c != 0 and i%d != 0:
                  ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
A,B,C,D=list(map(int,input().split()))
sum=0
for i in range(A,B+1):
    if i%C!=0 and i%D!=0:
        sum+=1

print(sum)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d=map(int,input().split())
num=0
for i in range(a,b+1):
    if i%c==0:
        continue
    if i%d==0:
        continue
    else:
        num+=1
print(num)

Submission status: Time Limit Exceeded

Solution code:
#整数　a b c d が与えられる。この時a 以上b 以下の整数のうちで、ｃでもdでも割り切れないものの個数を求めてください。
a,b,c,d=map(int,input().split())
num=0
for i in range(a,b+1):
    if i%c==0 or i%d==0:
        num+=0
    else:
        num+=1
print(num)

Submission status: Time Limit Exceeded

Solution code:
A, B, C, D =list(map(int, input().split()))
No = [i for i in range(A, B +1)]

cnt = 0

for i in No:
    if i % C !=0 and  i % D !=0 :
        cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d = map(int,input().split())
cnt=0
for i in range(a,b+1):
    if i%c==0 or i%d==0:
        cnt +=1
print(b-a-cnt+1)

Submission status: Time Limit Exceeded

Solution code:
import fractions

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

f=fractions.gcd(c,d)
f2=c*d//f


ans = (f2-(f2//c+f2//d-1))*(b//f2)

for i in range(1,b%f2+1):
    if i%c!=0 and i%d!=0:
        ans+=1

ans -= (f2-(f2//c+f2//d-1))*(a//f2)
for i in range(a%f2):
    if i%c!=0 and i%d!=0:
        ans-=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
a,b,c,d=map(int,input().split())
countc=0
countd=0
countcd=0
n=b-a+1
imax=math.ceil(max(a,b)/min(c,d)+1)
imin=math.floor(min(a,b)/max(c,d))
for i in range(imin,imax):
    if a<=c*i<=b:
        countc+=1
        if c*i%d==0:
            countcd+=1
    if a<=d*i<=b:
        countd+=1
print(n-(countc+countd-countcd))

Submission status: Time Limit Exceeded

Solution code:
import fractions
a,b,c,d = map(int, input().split())
gcd = fractions.gcd(c,d)
lcm = c * d // gcd
num = [c,d,lcm]
l = b - a + 1
temp = []

for i in range(3):
  count = 0
  if l - num[i] >= 0:
    count += l // num[i]
    if l % num[i] != 0:
      if b % num[i] < (b - (l % num[i]) + 1) % num[i]:
        count += 1
  else:
    for j in range(a,b+1):
      if j % num[i] == 0:
        count += 1
  temp.append(count)

ans = l - (temp[0] + temp[1] - temp[2])
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a, b, c, d = map(int, input().split())
s = 0 
for i in range(a,b+1):
  if i % c != 0 and i % d != 0:
    s += 1
print(s)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d = map(int,input().split())
tmp = 0

for i in range(a,b+1):
  if i%c != 0 and i%d != 0:
    tmp += 1
    
print(tmp)

Submission status: Time Limit Exceeded

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

array = []
n = b - a + 1
for i in range(n):
    array.append(i+a)

ans = 0

for i in array:
    if (i % c != 0) and (i % d != 0):
        ans+=1
        
print (ans)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d=map(int,input().split())
ans = 0
for i in range(a,b+1):
  if i%c!=0 and i%d!=0:
    ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

cd = c * d
count = 0

a_d, a_m = divmod(a, cd)
b_d, b_m = divmod(b, cd)

left = cd * (a_d+1)
if left > b:
	left = b

for i in range(a, left):
	if i % c != 0 and i % d != 0:
		count += 1

right = cd * b_d

if right >= left + cd:
	count2 = 0
	for i in range(left, left + cd):
		if i % c != 0 and i % d != 0:
			count2 += 1
	
	count += count2 * (b_d - a_d - 1)
 
if right >= left:
	for i in range(right, b+1):
		if i % c != 0 and i % d != 0:
			count += 1
#print("{} {} {} {}".format(a, left, right, b))
print(count)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d = map(int,input().split())
ab_list = [i for i in range(a,b+1)]
ng_list = []
count = 0


for i in range(b+1):
    if i * c > b:
        break
    ng_list.append(i*c)
    
for i in range(b+1):
    if i * d > b:
        break
    ng_list.append(i*d)
    
ng_list = set(ng_list)
    
for i in ng_list:
    if i in ab_list:
        count += 1
        
print(len(ab_list) - count)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d = map(int, input().split())
p = 0
for i in range(a,b+1):
  if i % c != 0 and i % d != 0:
    p += 1
print(p)

Submission status: Time Limit Exceeded

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

arr = [n for n in range(A, B + 1) if n % C != 0 and n % D != 0]
print(len(arr))

Submission status: Time Limit Exceeded

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

ans = 0
j = A
while j <= B:
    count = 0
    if j%C:
        count += 1
    if j%D:
        count += 1

    if count == 2:
        ans += 1

    j+= 1

print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
for i in range (A, B+1):
    if (i%C)*(i%D) != 0:
        ans +=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
a,b,c,d = map(int,input().split())
lcm = int(c*d/gcd(c,d))
ans = 0
syou = (b-a)//lcm
nokori = a + lcm*syou
for i in range(a,a+lcm):
    if i%c != 0 and i%d != 0:
        ans += 1
ans *= syou
for j in range(nokori,b+1):
    if j%c != 0 and j%d != 0:
        ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a, b, c, d = map(int, input().split())
lst = []
cnt = 0
for i in range(a, b+1):
    if i%c != 0:
        lst.append(i)
for j in lst:
    if j%d != 0:
        cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d = map(int,input().split())
e = 0

for i in range(a,b+1):
  if i % c == 0 or i % d == 0:
    continue
  else:
    e += 1
print(e)

Submission status: Time Limit Exceeded

Solution code:
a, b, c, d = map(int, input().split())
m=0
for i in range(a,b+1):
    if (i%c == 0 or i%d == 0):
        continue
    m += 1
print(m)

Submission status: Time Limit Exceeded

Solution code:
a, b, c, d = map(int, input().split())
m=0
for i in range(a,b+1):
    if i%c == 0:
        continue
    elif i % d == 0:
        continue
    else:
        m += 1
print(m)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d = map(int,input().split())
m=b-a
cnt = 0
for i in range(m+1):
    if (a+i)%c!=0 and (a+i)%d!=0:
        cnt+= 1
        
print(cnt)

Submission status: Time Limit Exceeded

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

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

A, B, C, D = [s for s in input().split()]

count = 0

for i in range(int(A), int(B)+1):
  if i % int(C) != 0:
    if i % int(D) != 0:
      count = count + 1
    
print (count)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d=map(int,input().split())
count=0
for i in range(a,b+1):
    if i%c and i%d:
        count+=1
print(count)

Submission status: Time Limit Exceeded

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

count = 0
for i in range(a,b+1):
  if i%c != 0 and i%d != 0:
    count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d = map(int,input().split())
cnt=0
c_list=[]
d_list=[]

c_start = (a-1)//c+1
while c_start*c<=b:
  c_list.append(c_start*c)
  c_start+=1

d_start = (a-1)//d+1
while d_start*d<=b:
  d_list.append(d_start*d)
  d_start+=1

temp = set(c_list).union(set(d_list))
print(b-a+1-len(temp))

Submission status: Time Limit Exceeded

Solution code:
num = [int(i) for i in input().split()]
ans = 0
for i in range(num[0], num[1]+1):
  if i%num[2] != 0 and i%num[3] != 0:
    ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a, b, c, d = map(int,input().split())
ans = 0
for i in range(a, b+1):
    if i % c != 0:
        if i % d != 0:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

num = 0
for i in range(A,B+1):
    if i%C != 0 and i%D != 0:
        num += 1
    else:
        num += 0
print(num)

Submission status: Time Limit Exceeded

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

cnt = 0
for i in range(A, B + 1):
  if i % C != 0 and i % D != 0:
    cnt += 1
    
print (cnt)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d = map(int,input().split())
cnt = 0
for i in range(a,b+1):
  if i%c != 0 and i%d !=0:
    cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

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

    e = 0
    for i in range(a,b+1,1):
        if not i % c == 0:
            if not i % d == 0:
                e += 1

    print(e)
    
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d=map(int,input().split())
nums=[]
for i in range(a,b+1):
  if i%c!=0 and i%d!=0:
    nums.append(i)
    
print(len(nums))

Submission status: Time Limit Exceeded

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

for i in range(A,B+1):
    if i % C != 0 and i % D != 0:
        count += 1

print(count)

Submission status: Time Limit Exceeded

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

for i in range(a,b+1):
    if i%c!=0 and i%d!=0:
        count = count+1
    else:
        pass
print(count)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d = map(int,input().split())
u = b - a + 1
n_c = b//c - (a-1)//c
n_d = b//d - (a-1)//d
for i in range(1, c*d+1):
    if i % c == 0 and i % d == 0:
        cd = i
        break
n_cd = b//(cd) - (a-1)//(cd)
print(u - n_c - n_d + n_cd)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d = map(int,input().split())
count = 0
for i in range(a,b+1):
    if i % c != 0 and i % d != 0:
        count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
S = input()

S = list(map(int, S.split()))

A = S[0]
B = S[1]
C = S[2]
D = S[3]

count = 0

for i in range(A, B+1, 1):
    if (i % C) != 0 and (i % D) != 0:
        count = count + 1

print(count)

Submission status: Time Limit Exceeded

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

ans=0

for i in range(a,b+1):
    if i%c!=0 and i%d!=0:
        ans+=1
    else:
        ans+=0

print(ans)

Submission status: Time Limit Exceeded

Solution code:
a, b, c, d = map(int, input().split())
cnt = 0
for i in range(a, b + 1):
    if i % c != 0 and i % d != 0:
        cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

count = 0
for i in range(A,B+1):
	if i%C == 0:
		count += 1
	if i%D == 0:
		count += 1
	if i%C == 0 and i%D == 0:
		count -= 1

print(B-A+1-count)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d = input().split()

n = range(int(a), int(b)+1)

def diff_count(x):
  return x % int(c) != 0 and x % int(d)

counter = [1 for x in n if diff_count(x)]
print(sum(counter))

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d = input().split()

n = range(int(a), int(b)+1)
counter = 0

for x in n:
  diff_c = x % int(c)
  diff_d = x % int(d)
  if diff_c != 0 and diff_d:
    counter = counter + 1
    
print(counter)

Submission status: Time Limit Exceeded

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

count = 0

for i in range(A, B+1):
    if i % C != 0:
        if i % D != 0:
             count += 1

print(count)

Submission status: Time Limit Exceeded

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

count = 0

for i in range(A, B+1):
    if i % C != 0 and i % D != 0:
        count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d=map(int,input().split())
e=0
f=a%c
g=a%d
for j in range(b-a+1):
  if (f+j)%c!=0 and (g+j)%d!=0:
    e+=1
print(e)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
a,b,c,d = map(int,input().split())

ans = 0

for i in range(a,b+1):
    if(i%c!=0 and i%d!=0):
        ans +=1

#print(cnt)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a, b, c, d= list(map(int, input().split()))
m=0
for i in range(a,b+1):
	if i%c!=0 and i%d!=0:
		m+=1
print(m)

Submission status: Time Limit Exceeded

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

count = 0
for i in range(A, B+1):
    if i % C != 0 and i % D != 0:
        count+=1

print(count)

Submission status: Time Limit Exceeded

Solution code:
A, B, C, D = map(int, input().split())
numstr = []
ans = 0

for i in range(B - A + 1):
  numstr.append(i + A)

for i in numstr:
  if i % C != 0 and i % D != 0:
    ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
if __name__ == "__main__":
    A,B,C,D = (int(x) for x in input().split())
    cnt = 0
    offset = 10000000
    for i in range(int((B - A) / offset)+1):
        startnum = A + i*offset
        endnum = min(A+(i+1)*offset,B)
        numlist = np.array(range(startnum,endnum + 1))
        numlist = numlist[numlist % C != 0]
        numlist = numlist[numlist % D != 0]
        cnt = cnt + len(numlist)
    print(cnt)

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(A, B+1):
    if i%C!=0 and i%D!=0:
        ans+=1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
A, B, C, D = list(map(int, input().split()))
count = 0

for i in range(A,B+1):
    if i % C != 0 and i % D != 0:
        count += 1
print(count)

Submission status: Time Limit Exceeded

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

cnt = 0
for i in range(A, B + 1):
    #print(i)
    if i % C != 0 and i % D != 0:
        #print("CONT!")
        cnt = cnt + 1

print(cnt)

Submission status: Time Limit Exceeded

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

ans = 0

for i in range(a, b+1):
  if i % c != 0 and i % d != 0:
    ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
A,B,C,D=map(int, input().split())
def lcm(a, b):
    if a>b:
        grater = a
    else:
        grater = b
    while(True):
        if((grater%a == 0) and (grater%b == 0)):
            lcm = grater
            break
        else:
            grater += 1
    return lcm

def f(X, a, b):
    return (X - X//a - X//b + X//lcm(a, b))

sum = f(B, C, D) - f(A-1, C, D)
print(sum)

Submission status: Time Limit Exceeded

Solution code:
import fractions

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

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

comp = int(((lcm//C) + (lcm//D) - 1) * ((B-A+1)//lcm))

for i in range((B-A+1)%lcm):
    if (A+i)%C == 0 or (A+i)%D == 0:
        comp += 1

print(B-A+1-comp)

Submission status: Time Limit Exceeded

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

candiv = []
n = 0
while True:
    n += 1
    cn = C * n
    dn = D * n
    if (A <= cn and cn <= B):
        candiv.append(cn)
    if (A <= dn and dn <= B):
        candiv.append(dn)
    if cn > B and dn > B:
        break
count = len(list(set(candiv)))
print(B - A + 1 - count)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d = map(int,input().split())
n=0
for i in range(b-a+1):
    if (i+a)%c!=0 and (i+a)%d!=0:
        n+=1
print(n)

Submission status: Time Limit Exceeded

Solution code:
d = [int(x) for x in input().split()]
count = 0
for y in range(d[0], d[1] + 1):
  if y % d[2] != 0 and y % d[3] != 0:
    count += 1
   
print(count)

Submission status: Time Limit Exceeded

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

ans = B - A + 1

st = set()

i = 1
while i * C <= B:
  if i * C >= A:
    ans -= 1
    st.add(i*C)
  i+=1
  
i = 1
while i * D <= B:
  if i * D >= A:  
    if not i*D in st:
      ans -= 1
  i += 1
  
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d = map(int,input().split())
count = 0
for i in range(a,b+1):
        if i % c != 0:
                if i % d != 0:
                        count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
A, B, C, D = map(int, input().split())
AtoB = {i+A for i in range(B-A+1)}
Cmul = {(i+1)*C for i in range(B//C)}
Dmul = {(i+1)*D for i in range(B//D)}
print(len(AtoB-Cmul-Dmul))

Submission status: Time Limit Exceeded

Solution code:
A, B, C, D = map(int, input().split())
var = 0
for i in range(B-A+1):
  N = A+i
  if ((N%C)!=0) and ((N%D)!=0):
    var = var+1
print(var)

Submission status: Time Limit Exceeded

Solution code:
A,B,C,D = map(int,input().split())
#print(A,B,C,D)
adivc = A//C
if A%C != 0:
    adivc = A//C + 1
bdivc = B//C
listc=[]
for i in range(adivc,bdivc+1):
    listc.append(str(C*i))
setc = set(listc)
#print(setc)

adivd = A//D
if A%D != 0:
    adivd = A//D + 1
bdivd = B//D
listd=[]
for i in range(adivd,bdivd+1):
    listd.append(str(D*i))
setd = set(listd)
#print(setd)

setcd = setc | setd
#print(setcd)
#print(len(setcd))

print(B-A+1-len(setcd))

Submission status: Time Limit Exceeded

Solution code:
A,B,C,D = map(int,input().split())
#print(A,B,C,D)
count = 0
for i in range(A,B+1):
    if i%C != 0 and i%D != 0:
        count+=1
print(count)

Submission status: Time Limit Exceeded

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

count = 0
for i in range(A,B+1):
    if((i%C !=0) and (i%D !=0)):
        count+=1

print(count)