Harryxun/stf_run huggingface dataset:
x1, y1, x2, y2 = map(int, raw_input().split())
num = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)
xi = num
for _ in range(10):
   xi = (xi + (num / xi)) / 2.0
print xi

### FIXED CODE ###

x1, y1, x2, y2 = map(float, raw_input().split())
num = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)
if num == 0:
    print 0
else:
    xi = num
    for _ in range(100):
        xi = (xi + (num / xi)) / 2.0
    print xi
list = list(map(int,input().split()))
print(min(sum(list)-a,sum(list)-b,sum(list)-c))


### FIXED CODE ###

a,b,c = sorted(map(int,input().split()))
print(a+b)
N=int(input())
table=[[] for i in range(N)]
for i in range(N-1):
    w,v=map(int,input().split())
    table[w-1].append(v-1)
    table[v-1].append(w-1)
mod=10**9+7
f=[-1]*N
g=[-1]*N
def ser(par,son):
    if f[son]!=-1 and g[son]!=-1:
        return f[son],g[son]
    s=1
    t=1
    for grason in table[son]:
        if grason==par:
            continue
        x,y=ser(son,grason)
        s*=x
        s%=mod
        t*=(x+y)
        t%=mod
    f[son],g[son]=t,s
    return t,s
z=1
w=1
for i in table[0]:
    ser(0,i)
    z*=f[i]
    z%=mod
    w*=(f[i]+g[i])
    w%=mod
print((z+w)%mod)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
N=int(input())
table=[[] for i in range(N)]
for i in range(N-1):
    w,v=map(int,input().split())
    table[w-1].append(v-1)
    table[v-1].append(w-1)
mod=10**9+7
f=[-1]*N
g=[-1]*N
def ser(par,son):
    if f[son]!=-1 and g[son]!=-1:
        return f[son],g[son]
    s=1
    t=1
    for grason in table[son]:
        if grason==par:
            continue
        x,y=ser(son,grason)
        s*=x
        s%=mod
        t*=(x+y)
        t%=mod
    f[son],g[son]=t,s
    return t,s
z=1
w=1
for i in table[0]:
    ser(0,i)
    z*=f[i]
    z%=mod
    w*=(f[i]+g[i])
    w%=mod
print((z+w)%mod)
from sys import exit

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
for _ in range(M):
    BC.append(tuple(map(int, input().split())))
BC.sort(key=lambda x: -x[1])
A.sort()

i = 0
for b, c in BC:
    for x in range(b):
        if A[i] < c:
            A[i] = c
            i += 1
        else:
            print(sum(A))
            exit()
print(sum(A))

### FIXED CODE ###

from sys import exit

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
for _ in range(M):
    BC.append(tuple(map(int, input().split())))
BC.sort(key=lambda x: -x[1])
A.sort()

i = 0
for b, c in BC:
    for x in range(b):
        if i < N and A[i] < c:
            A[i] = c
            i += 1
        else:
            print(sum(A))
            exit()
print(sum(A))
a,b,c=map(int,input().split())
k=int(input())
print((max(a,b,c)*(2**k))+(a+b+c)-max(a,b,c)


### FIXED CODE ###

a,b,c=map(int,input().split())
k=int(input())
print((max(a,b,c)*(2**k))+(a+b+c)-max(a,b,c))
import math 
N = input().int()
A = map(int,input().split())
B = map(bin,A)
def Y(x):
  y = len(x)-x.rfind("1")-1
  return y
C = map(Y,B)
print(min(C))


### FIXED CODE ###

import math 
N = int(input())
A = map(int,input().split())
B = map(bin,A)
def Y(x):
  y = len(x)-x.rfind("1")-1
  return y
C = map(Y,B)
print(min(C))
n, x = list(map(int, input().split()))
L = list(map(int, input().split()))
length = 0
i = 0
while x >= length:
    length += L[i]
    i += 1
print(i)

### FIXED CODE ###

n, x = list(map(int, input().split()))
L = list(map(int, input().split()))
length = 0
i = 0
count = 1
while n > i:
    length += L[i]
    if length <= x:
        count += 1
    i += 1
print(count)
from itertools import product

N, M, X = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
ans = float("inf")

for now in product(range(2), N):
    res = 0
    An = [0 for _ in range(M)]
    for n in range(N):
        if now[n] == 1:
            res += A[n][0]
            An = [An[j] + A[n][j+1] for j in range(M)]
    if min(An) >= X:
        ans = min(ans, res)

if ans == float("inf"):
    print(-1)
else:
    print(ans)


### FIXED CODE ###

N, M, X = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
ans = float("inf")

for i in range(2**N):
    now = bin(i)[2:].zfill(N)  # now[i]: 参考書iを買う
    res = 0
    An = [0] * M
    for n in range(N):
        if now[n] == "1":
            res += A[n][0]
            An = [An[j] + A[n][j+1] for j in range(M)]
    if min(An) >= X:
        ans = min(ans, res)

if ans == float("inf"):
    print(-1)
else:
    print(ans)
if N%1000=0:
  print(0)
  else:
    print(1000-N%1000)

### FIXED CODE ###

N=int(input())
if  N % 1000 == 0:
  print(0)
else:
    print(1000 - N % 1000)
import math
t = []
for i in range(5):
  t.append(int(input()))
ct = [math.ceil(x/10)*10 for x in t]
fraction = [x%10 for x in t]
min_fraction = min(list(filter(lambda x: x > 0, fraction)))
print(sum(ct) - 10 + min_fraction)


### FIXED CODE ###

import math
t = []
for i in range(5):
  t.append(int(input()))
ct = [math.ceil(x/10)*10 for x in t]
fraction = [x%10 for x in t]
fraction = list(filter(lambda x: x > 0, fraction))
if len(fraction) > 0:
  min_fraction = min(fraction)
else:
  min_fraction = 10
print(sum(ct) - 10 + min_fraction)
while True:
    n = input()
    if n == 0:
        break
    dic = {}
    for _ in xrange(n):
        name, cost = raw_input().split()
        dic[name] = int(cost)
    for _ in xrange(input()):
        items = raw_input().split()
        dic[items[0]] = min(dic[items[0]], sum(map(lambda x:dic[x], items[2:])))
    print dic[raw_input()]

### FIXED CODE ###

INF = 1 << 29
while True:
    n = input()
    if n == 0:
        break
    dic = {}
    for _ in xrange(n):
        name, cost = raw_input().split()
        dic[name] = int(cost)
    m = input()
    recipe = []
    for _ in xrange(m):
        data = raw_input().split()
        if data[1] <= 0:
            m -= 1
            continue
        recipe.append([data[0]]+data[2:])
    for _ in xrange(m):
        for i in xrange(m):
            dic[recipe[i][0]] = min(dic[recipe[i][0]] if recipe[i][0] in dic else INF, 
                                    sum(map(lambda x:dic[x] if x in dic else INF, recipe[i][1:])))
    print dic[raw_input()]
while(1):
  count = int(input())
  if count == 0: break
  previous_cube = [1, 2, 3, 4, 5, 6]
  operation{'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left[1, 4, 2, 5, 3, 6]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for i in xrange(6):
      new_cube.append(previous_cube[operation[raw_input()][i]])
    sum += new_cube[0]
    previous_cube = new_cube
  print sum

### FIXED CODE ###

while 1:
  n = input()
  if n == 0:  break
  d = range(1, 7)
  ans = 1
  for i in range(n):
    c = raw_input()[0]
    if c == 'N': S = [1,5,2,3,0,4]
    elif c == "S": S = [4,0,2,3,5,1]
    elif c == "E": S = [3,1,0,5,4,2]
    elif c == "W": S = [2,1,5,0,4,3]
    elif c == "R": S = [0,2,4,1,3,5]
    elif c == "L": S = [0,3,1,4,2,5]
    d = [d[s] for s in S]
    ans += d[0]
  print ans
import math
r = float(input())

s = r * r * math.pi
a = r * 2 * math.pi

print("{0:.5f} {1:.5f}".format(s, l))

### FIXED CODE ###

import math
r = float(input())

s = r * r * math.pi
l = r * 2 * math.pi

print("{0:.5f} {1:.5f}".format(s, l))
N = int(input())
A = list(map(int, input().split()))

ans = 1

if 0 in A:
    print(0)
    exit()

for i in range(N):
    ans *= A[i]

    if ans > 10**18:
        ans = -1
        break

print(ans)


### FIXED CODE ###

A, B = map(int, input().split())
ans = A*B
print(ans)
import math
x = int(input())
a = 10*10*10*10*10*10*10*10*10+7
print(math.fanctional(x)%a)

### FIXED CODE ###

import math
x = int(input())
a = 10*10*10*10*10*10*10*10*10+7
print(math.factorial(x) % a)
N = int(input())
  minus_bit = ''
  if N == 0:
      minus_bit = '00'
  while N != 0:
      mod = N % 4
      if mod == 0:
          minus_bit = minus_bit + '00'
          N = N//4
      elif mod == 1:
          minus_bit = minus_bit + '10'
          N = (N-1)//4
      elif mod == 2:
          minus_bit = minus_bit + '01'
          N = (N+2)//4
      else:
          minus_bit = minus_bit + '11'
          N = (N+1)//4

  if minus_bit[-1] == '0':
      minus_bit = minus_bit[:-1]
  print(minus_bit[::-1])

### FIXED CODE ###

N = int(input())
minus_bit = ''
if N == 0:
    minus_bit = '00'
while N != 0:
    mod = N % 4
    if mod == 0:
        minus_bit = minus_bit + '00'
        N = N//4
    elif mod == 1:
        minus_bit = minus_bit + '10'
        N = (N-1)//4
    elif mod == 2:
        minus_bit = minus_bit + '01'
        N = (N+2)//4
    else:
        minus_bit = minus_bit + '11'
        N = (N+1)//4

if minus_bit[-1] == '0':
    minus_bit = minus_bit[:-1]
print(minus_bit[::-1])
n = int(input())
h = list(map(int, input().split()))

dp = [-1]*(n+1)

def helper(n):
    if n <= 0:
        return float('inf')
    elif n == 1:
        return 0
    elif dp[n] != -1:
        return dp[n]
    else:
        if n-1 >= 0 and n-2 >= 0:
            l = abs(h[n-1]-h[n-2])+helper(n-1)
        else:
            l = float('inf')
        if n-1 >= 0 and n-3 >= 0:
            r = abs(h[n-1]-h[n-3]) + helper(n-2)
        else:
            r = float('inf')
        dp[n] = min(l, r)
        return dp[n]

print(helper(n))


### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
dp = [1000000000+5 for i in range(n)]
dp[0] = 0
for i in range(n):
    for j in range(i+1, i+3):
        if j < n:
            dp[j] = min(dp[j], dp[i] + abs(h[i]-h[j]))
print(dp[n-1])
from math import factorial

N,M = map(int,input().split())

def foo(N,M):
	if N == M+1 or N+1 == M:
		tm = factorial(min(N,M))
		return(tm*max(N,M)+tm)

	elif N==M:
		return(2*factorial(N)*2)

	else:
		return(0)

print(foo(N,M)/(10**9+7))

### FIXED CODE ###

from math import factorial

N,M = map(int,input().split())

def foo(N,M):
	if N == M+1 or N+1 == M:
		tm = factorial(min(N,M))
		return(tm*max(N,M)*tm)

	elif N==M:
		return((factorial(N)**2)*2)

	else:
		return(0)

print(foo(N,M)%(10**9+7))
import numpy as np
N, M = map(int, input().split())
Alist = np.array(list(map(int, input().split())))
for _ in range(M):
    Alist[np.argmax(Alist)] /= 2
print(np.sum(Alist.astype(np.int64)))


### FIXED CODE ###

import heapq


def int_and_reverse(num):
    return int(num) * -1


N, M = map(int, input().split())
Alist = list(map(int_and_reverse, input().split()))
heapq.heapify(Alist)
for _ in range(M):
    x = (heapq.heappop(Alist) * -1) // 2
    heapq.heappush(Alist, -x)
print(-sum(Alist))
import math
N, a, b = map(int,input().split())
p = 10 ** 9 +7
def fc(t,k):
  if t == 0:
    return 1
  elif t % 2 == 1:
    return (fc(t//2,k)) **2 * k
  else:
    return (fc(t//2,k)) ** 2
A = math.factorial(a)
B = math.factorial(b)
n_c_a = 1
n_c_b = 1
for i in range(a):
  n_c_a *= n-i
for j in rnage(b):
  n_c_b *= n-j
m_a = fc(p-2,A) * n_c_a % p
m_b = fc(p-2,B) * n_c_b % p
print((fc(N,2) - 1 - m_a - m_b)%2)

### FIXED CODE ###

N, a, b = map(int,input().split())
p = pow(10,9) + 7
def comb(n,r):
  bunshi = 1
  for i in range(n-r+1, n+1):
    bunshi =bunshi * i % p
  bunbo = 1
  for i in range(1, r+1):
    bunbo = bunbo * i % p
  return bunshi * pow(bunbo, p-2, p)
print((pow(2,N, p) - 1 - comb(N,a) - comb(N,b)) % p)
s = list(input())
ans = []
for i in range(len(s)):
    if s[i] == '0' or s[i] == '1':
        ans.append(s[i])
    else:
        if len(ans) > 0:
            ans.pop(i-1)
print("".join(ans))

### FIXED CODE ###

s = list(input())
ans = []
for i in range(len(s)):
    if s[i] == '0' or s[i] == '1':
        ans.append(s[i])
    else:
        if len(ans) > 0:
            ans.pop(-1)
print("".join(ans))
s=input()*2;n=len(s)//2;X=[(0,0)]*4
for j in range(n+1):
 for k in range(3,-1,-1):
  a=int(s[n-j])
  X[k]=(X[k][0]+9*X[k-1][0],X[k][0]+(a-1)*X[k-1][0]+X[k-1][1]if a else X[k][1])if k else 1
print(X[int(input())][1])

### FIXED CODE ###

def f(s, t, k):
 n = len(s)
 if k > n: return 0
 a = max(t, int(s[0]))
 if a == 0: return f(s[1:], t, k)
 if k == 1: return a + (n - 1) * 9
 z = 0
 if k - 1 <= n: z += f(s[1:], 9, k)
 z += (a - 1) * f(s[1:], 9, k - 1)
 z += f(s[1:], t, k - 1)
 return z

s = input()
k = int(input())
print(f(s, 0, k))
2import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    a = I()
    print(a+a**2+a**3)

### FIXED CODE ###

import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    a = I()
    print(a+a**2+a**3)
n, d = map(int, input().split())
ans = [-1]*3
for x in range(n+1):
    for y in range(n-x+1):
        if d = 10000*x + 5000*y + 1000*(n-x-y):
            ans = [x, y, n-x-y]
        # if zd//1000 == n-x-y:
        #     ans[0] = x
        #     ans[1] = y
        #     ans[2] = zd//1000
        #     break
print(*ans)

### FIXED CODE ###

n, y = map(int,input().split())
ans = [-1,-1,-1]
for i in range(n+1):
    for j in range(n+1-i):
        if 10000*i + 5000*j + 1000*(n-i-j) == y:
            ans = [i,j,n-i-j]
print(*ans)
h, w = map(int,input().split())
li = [list(input()) for i in range(h)]

if h == 1 or w == 1:
    print("No")
    exit()

for i in range(h):
    for j in range(w):
        x = 0 #縦OK
        y = 0 #横OK
        if li[i][j] == "#":
            if i == 0:
                if li[i+1][j] == "#":
                    x = 1
            elif i == w-1:
                if li[i-1][j] == "#":
                    x = 1
            else:
                if li[i+1][j] == "#" or li[i-1][j] == "#":
                    x = 1
            if j == 0:
                if li[i][j+1] == "#":
                    y = 1
            elif j == h-1:
                if li[i][j-1] == "#":
                    y = 1
            else:
                if li[i][j+1] == "#" or li[i][j-1] == "#":
                    y = 1 

            if x == 0 and y == 0:
                print("No")
                exit()

print("Yes")

### FIXED CODE ###

h, w = map(int,input().split())
li = [list(input()) for i in range(h)]

if h == 1 or w == 1:
    print("No")
    exit()

for i in range(h):
    for j in range(w):
        x = 0 #縦OK
        y = 0 #横OK
        if li[i][j] == "#":
            if i == 0:
                if li[i+1][j] == "#":
                    x = 1
            elif i == h-1:
                if li[i-1][j] == "#":
                    x = 1
            else:
                if li[i+1][j] == "#" or li[i-1][j] == "#":
                    x = 1
            if j == 0:
                if li[i][j+1] == "#":
                    y = 1
            elif j == w-1:
                if li[i][j-1] == "#":
                    y = 1
            else:
                if li[i][j+1] == "#" or li[i][j-1] == "#":
                    y = 1 

            if x == 0 and y == 0:
                print("No")
                exit()

print("Yes")
def resolve():
    from collections import deque

    def checker(n):
        n = str(n)
        OK3 = False
        OK5 = False
        OK7 = False
        for i in n:
            if i == "3":
                OK3 = True
            elif i== "5":
                OK5 = True
            elif i == "7":
                OK7 = True
        if OK3 and OK5 and OK7:
            return True
        else:
            return False

    n = int(input())
    if n < 357:
        print(0)
    else:
        ans = 0
        nxt = [3, 5, 7]
        nxt = deque(nxt)
        OK = True
        while OK:
            a = nxt.popleft()
            if a > n:
                break
            nxt.append(a*10+3)
            nxt.append(a * 10 + 5)
            nxt.append(a * 10 + 7)
            if checker(a):
                ans += 1
    print(ans)
resolve()

### FIXED CODE ###

def resolve():
    from collections import deque
    n = int(input())
    ans = 0
    num = deque([3,5,7])
    while num[0] <= n:
        test = num.popleft()
        num.append(test * 10 + 3)
        num.append(test * 10 + 5)
        num.append(test * 10 + 7)
        if list(set([int(x) for x in list(str(test))])) == [3,5,7]:
            ans += 1
    print(ans)

resolve()
from fractions import gcd
def lcm(a, b):
    return a * b // gcd(a, b)

N, M = map(int, input().split())
B = set(map(int, input().split()))
power = 1
for b in B:
    power = lcm(power, b//2)

mn = min(B)

mn2 = mn // 2
p2 = power // mn2

if p2 % 2 == 0:
    print(0)
    exit()
ans1 = M // mn2 // p2
ans2 = M // mn2 // (p2*2)
print(ans1-ans2)


### FIXED CODE ###

from fractions import gcd
def lcm(a, b):
    return a * b // gcd(a, b)
N, M = map(int, input().split())
B = set(map(lambda x: int(x)//2, input().split()))
power = 1
for b in B:
    power = lcm(power, b)

mn = min(B)
p2 = power // mn

if p2 % 2 == 0:
    print(0)
    exit()
ans1 = M // mn // p2
ans2 = M // mn // (p2 * 2)
print(ans1-ans2)
import math
from functools import reduce

N = int(input())
A = list(map(int, input().split()))
print(A)
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
def has_duplicates(seq):
    return len(seq) != len(set(seq))


if gcd_list(A)==1 and has_duplicates(A) == False:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))

def has_duplicates(seq):
    return len(seq) != len(set(seq))


if has_duplicates(A) == False:
    print("YES")
else:
    print("NO")
n = int(input())
a = list(map(int, input().split()))
ans = [0 for in range(n)]
for i in range(n):
       ans[a[i]-1] = i+1
for j in range(len(ans):
       print(ans[j] , end = " ")

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
for i in range(n):
       ans[a[i]-1] = i+1
for j in range(len(ans)):
       print(ans[j] , end = " ")
import re

s = input()
p = re.compile(r'^([^L][^R])*[^L]?$')
if p.match(s):
	print("Yes")
else:
	print("No")


### FIXED CODE ###

import re

s = input()
p = re.compile(r'^([^L][^R])*[^L]?$')
if p.match(s):
	print("Yes")
else:
	print("No")
a = input()
s = ""
for i in range(a):
    if i == 3:s+=8
    else:s+=i
print(s)

### FIXED CODE ###

a = input()
s = ""
for i in range(len(a)):
    if i == 3:s+="8"
    else:s+=a[i]
print(s)
import itertools
from collections import defaultdict

N,M = map(int,input().split())
A = [int(x) for x in input().split()]
L = [None,2,5,5,4,5,6,3,7,6]

l_to_n = [[] for _ in range(10)]
for a in A[1:]:
  l_to_n[L[a]].append(a)
  
l_to_n = [(i,max(x)) for i,x in enumerate(l_to_n) if x]

se = {0} # 1000以下で作れる長さ

for l,_ in l_to_n:
  se = {x+y for x,y in itertools.product(se,range(0,1000,l)) if x+y < 1000}

answer = ''
m_L,x = l_to_n[0]
while N > 100:
  N -= m_L
  answer += str(x)
  
for l,x in l_to_n:
  while N-l in se:
    N -= l
    answer += str(x)
  if N == 0:
    break

answer = ''.join(sorted(answer,reverse=True))

print(answer)

### FIXED CODE ###

import itertools

N,M = map(int,input().split())
A = [int(x) for x in input().split()]
L = [100,2,5,5,4,5,6,3,7,6]

len_set = set(L[x] for x in A)

INF = 10**18
can_make = [-INF]*(N+1)
can_make[0] = 0 # 何桁で作れるか

for n in range(1,N+1):
  for x in len_set:
    if n-x >= 0 and can_make[n] < can_make[n-x] + 1:
        can_make[n] = can_make[n-x] + 1

answer = []

A.sort(reverse = True)
# なるべく大きいのを使いたい。作れる桁数が減らないようにする。
for a in A:
  x = L[a]
  while N-x >= 0 and can_make[N] == can_make[N-x]+1:
    answer.append(str(a))
    N -= x
      
answer = ''.join(answer)
print(answer)
N = int(input())
A = [int(a) for a in input().split()]
cnt = 0
while True:
  for i in range(N):
    if A[i] % 2 == 1:
      print cnt
      exit(0)
    else:
      A[i] = A[i] // 2
  cnt++

### FIXED CODE ###

N = int(input())
A = [int(a) for a in input().split()]
cnt = 0
while True:
  for i in range(N):
    if A[i] % 2 == 1:
      print(cnt)
      exit(0)
    else:
      A[i] = A[i] // 2
  cnt += 1
# C - Anti-Division

from math import gcd

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

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

total_C = B // C
total_D = B // D
total_CxD = B // CxD

sub_C = (A - 1) // C
sub_D = (A - 1) // D
sub_CxD = (A - 1) // CxD

print((B - (A - 1)) -
        (total_C + total_D - total_CxD) + (sub_C + sub_D - sub_CxD))


### FIXED CODE ###

# C - Anti-Division

from fractions import gcd

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

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

total_C = B // C
total_D = B // D
total_CxD = B // CxD

sub_C = (A - 1) // C
sub_D = (A - 1) // D
sub_CxD = (A - 1) // CxD

print((B - (A - 1)) -
        (total_C + total_D - total_CxD) + (sub_C + sub_D - sub_CxD))
if __name__ == "__main__":
    for i in range(200):
        a = list(map(int,input().strip().split()))
        if len(a) == 0 :break
        absum = a[0] + a[1]
        count = 1
        while 1:
            if absum < 10: break
            absum= absum /10
            count += 1
        print(count)

### FIXED CODE ###

import fileinput as fi
if __name__ == "__main__":
    for i in fi.input():
        a,b = list(map(int,i.strip().split()))
        print(len(str(a+b)))
cl = input()
l = int(l)
print(l **3 / 27)

### FIXED CODE ###

l = input()
l = int(l)
print(l **3 / 27)
n = int(input())
print(pow(10, n, mod) - 2*pow(9, n, mod) - pow(9, n, mod))

### FIXED CODE ###

n = int(input())
mod = 10**9 + 7
print((pow(10, n, mod) - 2*pow(9, n, mod) + pow(8, n, mod)) % mod)
import numpy as np

n=int(input())
A=np.ndarray(map(int,input().split()))
a=np.prod(A)
if a>10**18:
    print("-1")
else:
    print(a)

### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
prod=1
if 0 in A:
    prod=0
for i in A:
    prod*=i
    if prod>10**18:
        prod=-1
        break
print(prod)
n = int(input())
a = list(map(int,input().split()))
x = [0]*max(a)
for i in a:
    x[i-1]+=1


for i in range(1,n+1):
    x[a[i-1]-1]-=1
    count = 0
    x_ = [(k*k-1)/2 in x if k>=2]
    count = sum(x_)
    # for j in x:
    #     if j>=2:
    #         count += int((j*(j-1)/2))
    x[a[i-1]-1]+=1
    print(count)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
x = [0]*max(a)
for i in a:
    x[i-1]+=1
# print(x)
count = 0
# x_ = [(k*(k-1))/2 for k in x if k>=2]
# count = sum(x_)
for j in x:
    if j>=2:
        count += int((j*(j-1)/2))
for i in range(n):
    if x[a[i]-1]>=2:
        print(count-x[a[i]-1]+1)
    else:
        print(count)
my_rate = input()
if my_rate < 1200:
        print("ABC")
elif my_rate >=1200 and my_rate < 2800:
        print("ARC")
else:
        print("AGC")


### FIXED CODE ###

my_rate = int(input())
if my_rate < 1200:
        print("ABC")
elif my_rate >=1200 and my_rate < 2800:
        print("ARC")
else:
        print("AGC")
S = int(input())
if S == 'ABC':
    print('ARC')
else:
    print('ABC')
    

### FIXED CODE ###

S = input()
if S == 'ABC':
    print('ARC')
else:
    print('ABC')
n=int(input())
a_list=list(map(int,input().split()))
cnt = [0] * int(1e5 + 10)
sum=0
for i in a_list:
 cnt[i] +=1
 sum+=i
  
q=int(input())
ans=0
 
for j in range(q):
 x,y=map(int,input().split())
 sum+=(y-x)*cnt[x]
 print(sum)
 cnt[x]+=cnt[y]
 cnt[y]=0

### FIXED CODE ###

import re
a=input()
if re.sub(r'[A-Z]',"",a)=="":
  print('A')
else:
  print('a')
a, b = list(input().split())
c = int(a + b)
d = c ** 0.5
if isinstance(d,int):
  print(YES)
else:
  print(No)

### FIXED CODE ###

a, b = input().split()
c = int(a + b)
c = c ** 0.5
if isinstance(c,int) or c.is_integer():
  print("Yes")
else:
  print("No")
import sys
A,B = map(int,input(.split())
for i in range(1,20):
  if (1+(A-1)*i) >= B:
    print(i)
    sys.exit()


### FIXED CODE ###

import sys
A,B = map(int,input().split())
if B == 1:
  print(0)
  sys.exit()
  
for i in range(1,20):
  if (1+(A-1)*i) >= B:
    print(i)
    sys.exit()