Harryxun/stf_run huggingface dataset:
while True:
    str_=input().split
    int_=[int(s) for s in str_]
    if int_[0]==0 and int_[1]==0:
        break
    if int_[0]<int_[1]:
        print("{} {}".format(int_[0],int_[1]))
    if int_[0]>int_[1]:
        print("{} {}".format(int_[1],int_[0]))


### FIXED CODE ###

while True:
    x=input().split()
    y=[int(x[0]),int(x[1])]
    if y[0]==0 and y[1]==0:
        break
    elif y[0]<y[1]:
        print("{} {}".format(y[0],y[1]))
    elif y[0]>y[1]:
        print("{} {}".format(y[1],y[0]))
    else:
        print("{} {}".format(y[0],y[1]))
a,b,c,d,e,f=map(int,input().split())

rmax=0
for a100 in range(0,f+1,100*a):
   for b100 in range(0,f-a100+1,100*b):
#   for b100 in range(0,f+1,100*b):
        if a100+b100>0:
            fcd=f-a100-b100
            for ci in range(0,fcd+1,c):
                for di in range(0,fcd+1,d):
                    if a100+b100+ci+di <=f:
                        if (a100+b100)/100*e>=ci+di:
                            if rmax<(ci+di)/(a100+b100):
                                rmax=(ci+di)/(a100+b100)
                                rab=a100+b100+ci+di
                                rcd=ci+di
print(rab,rcd)

### FIXED CODE ###

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

indxmax=0.0
wmax=0
emax=0
elimit=(100*e)/(100+e)
c31=int(f/c)+1
for ai in range(0,f+1,a):
    for bi in range(0,f-ai+1,b):
        w=100*ai+100*bi
#        print("a,b:",ai,bi,w)
        if w<=f and w>0:
#            c31=int(w/100*e/c)+1
#            c31=min(int(w/100*e/c)+1,31)
#            d31=int(w/100*e/d)+1
            c31=(w*e)//100+c
            for ci in range(0,c31,c):
#                for di in range(d31):
                for di in range(0,c31-ci,d):
                    indx=(ci+di)*100/w
                    if indxmax<indx and e-indx>=0.0 and w+ci+di<=f:
                        wmax=w+ci+di
                        indxmax=indx 
                        emax=ci+di
#                    print("c,d",ci,di,emax,wmax,diii)
if wmax>0:
    print(wmax,emax)
else:
    print(100*a,emax)
n = input()
a = list(map(double, input().split()))

for i in a:
	sum += i 
	double = i ** 2
print((sum**2-double)/2)

### FIXED CODE ###

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

if (a <= b * 2):
  print (0)
else:
  print (a - b * 2)
def sa(_a,_b):
    a = max(_a,_b)
    b = min(_a,_b)
    return a-b

n = int(input())
l = list(map(int,input().split()))
m = sum(l)
a = l[0]
b = m - a
ans = sa(a,b)
for i in range(1,len(l)-1):
    a += l[i]
    b -= l[i]
    ans = min(ans,sa(a,b))
print(ans)


### FIXED CODE ###

a,b = list(map(int,input().split()))
if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0:
    print('Possible')
else:
    print('Impossible')
p = int(input())
q = int(input())
r = int(input())
a = p + q
b = q + r
c = p + r
print(min(a,b,c))

### FIXED CODE ###

p,q,r = list(map(int,input().split()))
a = p + q
b = q + r
c = p + r
print(min(a,b,c))
a,b=map(int(input().split()))
s=[2,3,4,5,6,7,8,9,10,11,12,13,1]
if a.index=b.index:
    print('Draw')
elif a.index>b.index:
    print('Alice')
else:
    print('Bob')

### FIXED CODE ###

a,b=map(int,input().split())
s=[2,3,4,5,6,7,8,9,10,11,12,13,1]
if s.index(a)==s.index(b):
    print('Draw')
elif s.index(a)>s.index(b):
    print('Alice')
else:
    print('Bob')
N = int(input())
A = list(map(int, input().split()))

lis = []
for a in A:
    stra = str(a)
    S = '0b'
    i = 0
    for s in stra:
        s = 0 | (a >> i)
        if i%2 == 0:
            S = s + S
        else:
            if s == '0':
                S = '1' + S
            else:
                S = '0' + S
        i += 1
    lis.append(int(S))
print(*S)

### FIXED CODE ###

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

X = 0
for a in A:
    X = X ^ a

lis = []
for a in A:
    Y = X ^ a
    lis.append(Y)
print(*lis)
from collections import Counter
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall

import sys
input = sys.stdin.readline

def flatten_2dim(array):
    return [item for sublist in array for item in sublist]

n, x, y = map(int, input().split())
f_inf = float('inf')
dist = [[f_inf] * n for _ in range(n)]

for i in range(n-1):
    dist[i][i+1] = 1
    dist[i+1][i] = 1

dist[x-1][y-1]=1
dist[y-1][x-1]=1

G = csgraph_from_dense(dist, null_value=10**9)
dist = floyd_warshall(G)

counter = Counter(flatten_2dim(dist))
counter = sorted(counter.most_common())[1:]

for key, val in counter:
    print(val//2)
for i in range(n - len(counter)-1):
    print(0)

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline

f_inf = float('inf')

def push(v, d):
    if dist[v] != f_inf: return
    dist[v] = d
    que.append(v)

n, x, y = map(int, input().split())
x -= 1
y -= 1

ans = [0]*n
for sv in range(n):
    dist = [f_inf] * n
    que = deque([])
    push(sv, 0)

    while que:
        v = que.popleft()
        d = dist[v]+1
        if v-1 >= 0: push(v-1, d)
        if v+1 < n: push(v+1, d)
        if v == x: push(y, d)
        if v == y: push(x, d)

    for i in range(n):
        ans[dist[i]] += 1
        
for i in range(n):
    ans[i] = ans[i]//2

for i in range(1, n):
    print(ans[i])
import math

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

#print(A)

lgcd=[A[0]]*N
for i in range(1,N):
    lgcd[i]=math.gcd(lgcd[i-1],A[i])

rgcd=[A[-1]]*N
for i in reversed(range(0,N-1)):
    rgcd[i]=math.gcd(rgcd[i+1],A[i])

#print(lgcd)
#print(rgcd)


ans=[0]*N
ans[0]=rgcd[1]
ans[N-1]=lgcd[N-2]
for i in range(1,N-1):
    ans[i]=math.gcd(lgcd[i-1],rgcd[i+1])
print(max(ans))


### FIXED CODE ###

import math

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

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

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

#print(A)
lgcd=[A[0]]*N
for i in range(1,N):
    lgcd[i]=gcd(lgcd[i-1],A[i])

rgcd=[A[-1]]*N
for i in reversed(range(0,N-1)):
    rgcd[i]=gcd(rgcd[i+1],A[i])

#print(lgcd)
#print(rgcd)

ans=[0]*N
ans[0]=rgcd[1]
ans[N-1]=lgcd[N-2]
for i in range(1,N-1):
    ans[i]=gcd(lgcd[i-1],rgcd[i+1])
print(max(ans))
N = int(input())
A = list(map(int, input().split()))
ans = 0
while len(d) > 1:
    current = d[0]
    for y in range(len(d)):
        ans += current * d[y]
#         print(ans)
    ans -= current ** 2
    d.pop(0)
print(ans)

### FIXED CODE ###

N = int(input())
d = list(map(int, input().split()))
ans = 0
while len(d) > 1:
    current = d[0]
    for y in range(len(d)):
        ans += current * d[y]
#         print(ans)
    ans -= current ** 2
    d.pop(0)
print(ans)
x,y = map(int,input().split())
a=np.count_nonzero([list(x)[i]==list(y)[i]  for i in range(len(list(x)))])
print(a)

### FIXED CODE ###

import numpy as np
hoge = []
for i in range(2):
    a = input()
    hoge.append(a)
a=np.count_nonzero([list(hoge[0])[i]==list(hoge[1])[i]  for i in range(3)])
print(a)
n,m=map(int,input().split())
a=[list(map(int,input().split()))for f in range(n)]
b=[int(input())for g in range(m)]
[print(sum([j*k for j,k in zip(a[i],b]))for i in range(n)]


### FIXED CODE ###

n,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
b=[int(input())for _ in range(m)]
[print(sum([j*k for j,k in zip(a[i],b)]))for i in range(n)]
s = list(map(int, list(str(input()))))
k = int(input())

if k == 1:
    ans = s[0]
if s[0] != 1:
    ans = s[0]
else:
    i = 0
    while i < k:
        i += 1
        ans = s[i]
        if s[i] != 1:
            break
print(ans)

### FIXED CODE ###

s = list(map(int, list(str(input()))))
k = int(input())

i = 0
while i + 1 <= k:
    ans = s[i]
    if s[i] != 1:
        break
    i += 1
print(ans)
def apply(a,b):
  if a>b:
	return a, a-1, b
  else:
    return b, a, b-1

if __name__ == '__main__':
  a,b = map(int,input().split())
  res = 0
  tmp, a, b = apply(a,b)
  res += tmp
  tmp, a, b = apply(a,b)
  res += tmp
  print(res)

### FIXED CODE ###

def apply(a,b):
  if a>b:
    return (a, a-1, b)
  else:
    return (b, a, b-1)

if __name__ == '__main__':
  a,b = map(int,input().split())
  res = 0
  tmp, a, b = apply(a,b)
  res += tmp
  tmp, a, b = apply(a,b)
  res += tmp
  print(res)
a,b,c,d,e,k= map(int, input().split())

A-B = b-a
A-C = c-a
A-D = d-a
A-E = e-a
B-C = c-b
B-D = d-b
B-E = e-b
C-D = d-c
C-E = e-c
D-E = e-d

if (A-B > k) or (A-C > k) or (A-D > k) or (A-E > k) or (B-C > k) or (B-E > k) or (C-D > k) or (C-E > k) or (D-E > k):
    print(":(")
else:
    print("Yay!")

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())



if e-a > k:
    print(":(")
else:
    print("Yay!")
N = str( input() )
if str[0] == "9" or str[1] == "9" :
   print( "Yes" )
else : 
   print( "No" )
   

### FIXED CODE ###

N = str( input() )
if N[0] == "9" or N[1] == "9" :
   print( "Yes" )
else : 
   print( "No" )
x = input()
s = t = 0
for i in range(200000):
    if x[i] == "T":
        t += 1
    if x[-i-1] == "S":
        s += 1
print(max(s, t))

### FIXED CODE ###

x = input()

st_sub = 0
count = 0
for char in x:

    if st_sub < 0 and char == "S":
        st_sub = 1
    elif char == "S":
        st_sub += 1
    else:
        st_sub -= 1
    
    if st_sub < 0:
        count += 1
    
print(count * 2)
dic = {}

def getX(x, y, cards, idx):
    if len(cards)==1:
        return abs(cards[0]-y)
    lgst = 0
    tmpcards = cards.copy()
    for ex, i in enumerate(cards):
        if(ex==len(cards)-1):
            return max(abs(i-y),lgst)
        tmpcards.remove(i)
        idx += 1
        if (i,y,idx) in dic:
            tmp = dic[(i,y,idx)]
        else:
            tmp = getY(i, y, tmpcards, idx)
            dic[(i,y,idx)]= tmp
        if tmp > lgst:
            lgst = tmp
    return lgst

def getY(x, y, cards, idx):
    if len(cards)==1:
        return abs(cards[0]-x)
    smlst = 0
    tmpcards = cards.copy()
    for ex, i in enumerate(cards):
        tmpcards.remove(i)
        if (ex==len(cards)-1):
            return min(abs(i - x), smlst)
        idx += 1
        if (x,i,idx) in dic:
            tmp = dic[(x,i,idx)]
        else:
            tmp = getX(x, i, tmpcards, idx)
            dic[(x,i,idx)]= tmp
        if tmp < smlst:
            smlst = tmp
    return smlst

n, z, w = map(int, input().split())
cards = list(map(int, input().split()))
print(getX(z, w, cards, 0))

### FIXED CODE ###

n, z, w = map(int, input().split())
cards = list(map(int, input().split()))
#print(getX(z, w, cards, 0))
if(abs(cards[len(cards)-1]-w)>abs(cards[len(cards)-1]-cards[len(cards)-2])):
    print(abs(cards[len(cards)-1]-w))
else:
    print(abs(cards[len(cards)-1]-cards[len(cards)-2]))
def muri(k, c, s):
  if k > s.count("o"):
    return True
  for j in range(len(s)):
    if s[j] == "o":
      return muri(k-1, c, s[j+c+1:])
  return False

n, k, c = map(int, input().split())
s = input()
s += "x"*c

for i in range(len(s)):
  if s[i] == "o":
    if muri(k, c, s[:i]+"x"+s[i+1:]):
      print(i+1)

### FIXED CODE ###

n, k, c = map(int, input().split())
s = input()
s2 = s
s += "x"*c
s2 = "x"*c+s2
k2 = k
kans = k
left = []
i = 0
while i < n:
  if s[i] == "o":
    left.append(i+1)
    i += c
  i += 1

right = []
i = len(s2)-1
while i >= c:
  if k2 == 0:
    break
  if s2[i] == "o":
    right.append(i+1-c)
    k2 -= 1
    i -= c
  i -= 1
if len(left) == kans:
  ans = sorted(list(set(left) & set(right)))
  for i in ans:
    print(i)
else:
  exit()
n = int(input())
s = input()
ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            for f in range(n):
                if p == 0 and s[f] == str(i):
                    p = 1
                elif p == 1 and s[f] == str(j):
                    p = 2
                elif p == 2 and s[f] == str(k):
                    ans += 1
                    break
print(ans)

### FIXED CODE ###

n = int(input())
s = input()
ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            p=0
            for f in range(n):
                if p == 0 and s[f] == str(i):
                    p = 1
                elif p == 1 and s[f] == str(j):
                    p = 2
                elif p == 2 and s[f] == str(k):
                    ans += 1
                    break
print(ans)
a, b = map(int, input().split())
print(x, y)
x = a * b
y = a + a + b + b


### FIXED CODE ###

a, b = map(int, input().split())
x = a * b
y = a + a + b + b
print(x, y)
import math
def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

N = int(input())

sum = 0
for i in range(2, N+1):
    basyo = permutations_count(N, i)/2  # 9と0が入る場所。i箇所。
    # zerokyuu = i*(i-1)*2(i-2)  # 入れる場所に0と9を入れる。
    zerokyuu = 2**i - 2  # 全部0と全部9を抜く。
    iti_hachi = 8**(N-2)  # 残った部分に1-8が入る全通り
    sum += basyo * zerokyuu * iti_hachi

print(int(sum%(10**9+7)))


### FIXED CODE ###

N = int(input())
print((10**N - 9**N - 9**N + 8**N) % (10**9+7))
n, k = map(int, input().split())
dt = sorted(tuple(map(int, input().split()))[::-1] for _ in range(n))[::-1]
r = v = 0
a = []
s = set()
for i, (d,t) in enumerate(dt, 1):
    if t in s:
        if i <= k:
            a.append(d)
            v += d
    else:
        if i > k:
            v -= a.pop()
            if not a:
                break
        v += d
        s.add(t)
    r = max(r, len(s)**2+v)
print(r)

### FIXED CODE ###

from collections import *
n, k = map(int, input().split())
d, t = zip(*sorted(tuple(map(int, input().split()))[::-1] for _ in range(n))[::-1])
c = Counter(t[:k])
x = len(c)
a = [sum(d[:k])]
for i in range(k)[::-1]:
    if c[t[i]] > 1:
        c[t[i]] -= 1
        a.append(a[-1] - d[i])
b = [0]
for i in range(k, n):
    if c[t[i]] <= 0:
        c[t[i]] += 1
        b.append(b[-1] + d[i])
r = 0
for i, (v, w) in enumerate(zip(a, b)):
    r = max(r, v+w+(x+i)**2)
print(r)
n = input()
for i in range(n):
    a,b,c = map(int, input().split())
    if a*a+b*b==c*c or a*a+c*c==b*b or b*b+c*c==a*a:
            print("YES")
        else:
            print("NO")

### FIXED CODE ###

n = int(input())
for i in range(0, n):
    a,b,c = map(int, input().split())
    if a*a+b*b==c*c or a*a+c*c==b*b or b*b+c*c==a*a:
        print("YES")
    else:
        print("NO")
n,k,q=map(int,input().split())
L= [ int(input()) for i in range(q)]
N = [k]*n
j = 0
while(j<len(L)):
    for i in range(len(N)):
        if i+1 != L[j]:
            N[i] -= 1
    j +=1

for i in range(N):
    if i>0:
        print('YES')
    else:
        print('NO')

### FIXED CODE ###

n, k, q = map(int, input().split())
N = [k]*n
L = [-q]*n
for _ in range(q): L[int(input())-1]+=1
N = map(lambda x,y:x+y, N,L)
for p in N: print("Yes" if p>0 else "No")
from operator import itemgetter
from operator import attrgetter
N = int(input())
li = []

for i in range(N):
    li.append(list(map(str, input().split())))
    li[i][1]  = int (li[i][1])


copyli = li.copy()
ans = []
##copyli.sort()
a = sorted(copyli, key = itemgetter(1),  reverse=True)
c = sorted(a, key = itemgetter(0))


##copyli.sort(key=attrgetter(1), reverse=True)

for i in range(N):
    for j in range(N):
        if (li[j][0] == c[i][0]) and (li[j][1] == c[i][1]):
            ans.append(j+1)

for i in range(N):
    print(ans[i])

### FIXED CODE ###


N = int(input())
li = []

for i in range(N):
    li.append(list(map(str, input().split())))
    li[i][1]  = int (li[i][1])


copyli = li.copy()
ans = []
##copyli.sort()
a = sorted(copyli, key = lambda copyli: copyli[1],  reverse=True)
c = sorted(a, key = lambda a: a[0])


##copyli.sort(key=attrgetter(1), reverse=True)

for i in range(N):
    for j in range(N):
        if (li[j][0] == c[i][0]) and (li[j][1] == c[i][1]):
            ans.append(j+1)

for i in range(N):
    print(ans[i])
l=input()
print((l/3)^3)

### FIXED CODE ###

l=float(input())
print((l/3)**3)
def burger_size(N):
    if N == 0:
        return 1
    return 3 + 2 * burger_size(N - 1)

def burger_patty_num(N):
    if N == 0:
        return 1
    return 1+ 2 * burger_patty_num(N - 1)

def patty_num(N, X):
    if X == 0:
        return 0
    if X <= 1 + burger_size(N - 1):
        return patty_num(N - 1, X - 1)
    elif X == 2 + burger_size(N - 1):
        return 1 + burger_patty_num(N - 1)
    elif X > 2 + burger_size(N - 1):
        return 1 + burger_patty_num(N - 1) + patty_num(N - 1, X - (2 + burger_size(N - 1)))
        
    
N, X = map(int, input().split())
print(patty_num(N, X))

### FIXED CODE ###

def patty_num(N):
    if N == 0:
        return 1
    return 1 + 2 * patty_num(N - 1)

def burger_height(N):
    if N == 0:
        return 1
    else:
        return 3 + 2 * burger_height(N - 1)
    
def f(N, X):
    if X == 1:
        if N == 0:
            return 1
        else:
            return 0
    elif 1 < X and X <= burger_height(N - 1) + 1:
        return f(N - 1, X - 1)
    elif X == burger_height(N - 1) + 2:
        return patty_num(N - 1) + 1
    elif burger_height(N - 1) + 2 < X and X <= 2 * burger_height(N - 1) + 2:
        return patty_num(N - 1) + 1 + f(N - 1, X - 2 - burger_height(N - 1))
    
    return 2 * patty_num(N - 1) + 1
    
N, X = map(int, input().split())
print(f(N, X))
a,b=input().split
print(int(a-b+1))

### FIXED CODE ###

a,b=input().split()
a=int(a)
b=int(b)
print(int(a-b+1))
a, b = map(int, input().split()
if a == b:
  print("Draw")
elif a == 1 or a > b:
    print("Alice")
else:
    print("Bob")

### FIXED CODE ###

a, b = map(int, input().split())
if a == 1:
  a = 14
if b == 1:
  b = 14
if a > b:
  print("Alice")
elif a < b:
  print("Bob")
else:
  print("Draw")
n=int(raw_input())
N=map(int,raw_input().split())
N.sort()
ans=1
for i in range(1,n):
	if N[i]!=N[i-1]:
		ans+=1
print ans

### FIXED CODE ###

n=int(raw_input())
N=[]
for i in range(n):
	N.append(int(raw_input()))
N.sort()
ans=1
for i in range(1,n):
	if N[i]!=N[i-1]:
		ans+=1
print ans
input1 = list(map(int,input("").split(" ")))
A = list(map(int,input("").split(" ")))
N = input1[0]
K = input1[1]
A.sort()
if K in A:
	flag = True
elif K > max(A):
	flag = False
else:
	flag = True
	for i in range(N-3):
		if abs(A[i]-A[i+1])%abs(A[i+2]-A[i+1]) != 0 or abs(A[i+2]-A[i+1])%abs(A[i]-A[i+1]) != 0:
			flag = False
			break

if flag==True:
	print('POSSIBLE')
else:
	print('IMPOSSIBLE')

### FIXED CODE ###

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

input1 = list(map(int,input("").split(" ")))
A = list(map(int,input("").split(" ")))
N = input1[0]
K = input1[1]

temp = A[0]
for i in range(1,N):
	temp = gcd(temp,A[i])

if K <= max(A) and K % temp == 0:
	print('POSSIBLE')
else:
	print('IMPOSSIBLE')
x,n=map(int,input().split())
try:
    p=list(map(int,input().split()))
    mina=100
    for i in range(min(p),max(p)):
        if i not in p:
            if mina>abs(i-x):
                mina=abs(i-x)
                ans=i
                if ans>x and (x-mina) not in p:
                    ans=x-mina
except:
    ans=x

print(ans)

### FIXED CODE ###

x, n = map(int, input().split())
a = [int(x) for x in input().split()]
b = [i for i in range(0,102) if i not in a] 
b_tmp = list(map(lambda s:abs(s-x), b)) 
address = b_tmp.index(min(b_tmp))
print(b[address])
N = input()
S = list(input())

Ans = 0

for i in range(len(S)):
	X = set(S[:i])
	Y=set(S[i:])
	numAND = len(X & Y)
	if numAND >= Ans:
		Ans = numAND
print(Ans)


### FIXED CODE ###

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

x = a+b
y= a-b
z = a *b

print(max(x,y,z))
a,b=list(map(input().split()))
if a>9 or b>9:
  print("-1")
else:
  print(a*b)

### FIXED CODE ###

a,b=list(map(int,input().split()))
if a>9 or b>9:
  print("-1")
else:
  print(a*b)
import sys
n = int(sys.stdin.readline().strip('\n'))
h = list(map(int, sys.stdin.readline().strip('\n').split()))
inf = float('inf')
dp = [inf for _ in range(n)]

# メモ化再帰（一度計算した結果はメモしておく）
def rec(i):
  # 値が既に更新されていたらそのまま返す（計算し直さない）
  if dp[i] < inf: return dp[i]
  if i==0: return 0
  res = inf
  res = min(res, rec(i-1) + abs(h[i]-h[i-1]))
  if i > 1: res = min(res, rec(i-2) + abs(h[i]-h[i-2]))
  dp[i] = res
  return res

ans = rec(n-1)
print(ans)

### FIXED CODE ###

import sys
n = int(sys.stdin.readline().strip('\n'))
h = list(map(int, sys.stdin.readline().strip('\n').split()))
dp = [float('inf') for _ in range(n)]
dp[0] = 0
dp[1] = abs(h[0]-h[1])
for i in range(2, n):
  dp[i] = min(dp[i-1] + abs(h[i-1]-h[i]), 
             dp[i-2] + abs(h[i-2]-h[i]))
print(dp[n-1])
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)

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


### FIXED CODE ###


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)
def main():
    import numpy as np
    import scipy.sparse.csgraph as sp
    n=int(input())
    p=np.array([np.array(list(map(int,input().split()))) for _ in [0]*n])
    ans=0
    d=np.full((n,n),0)
    for i in range(n):
        for j in range(i+1,n):
            b=p[i][j]
            if b!=np.sort(p[i]+p[j])[2]:
                d[i][j],d[j][i]=b,b
                ans+=b
    s=sp.shortest_path(d)
    if (s==p).all():
        print(ans)
    else:
        print(-1)
main()

### FIXED CODE ###

def main():
    n=int(input())
    if n==1:
        print(0)
        return 0
    import numpy as np
    p=np.array([np.array(list(map(int,input().split()))) for _ in [0]*n])
    if n==2:
        print(p[0][1])
        return 0
    import scipy.sparse.csgraph as sp
    ans=0
    d=np.full((n,n),0)
    for i in range(n):
        for j in range(i+1,n):
            b=p[i][j]
            if b!=np.sort(p[i]+p[j])[2]:
                d[i][j],d[j][i]=b,b
                ans+=b
    s=sp.shortest_path(d)
    if (s==p).all():
        print(ans)
    else:
        print(-1)
main()
strings = input().split(' ')
A = int(strings[0])
B = int(strings[1])

i = min(A,B)
m = max(A,B)
n = min(A,B)
while m % n != 0:
    mt = m // n
    nt = m % n
    m = mt
    n = nt
    gmc = m // n
if gmc != 0:
    print(A*B//gmc)
else:
    print(A*B)
    

### FIXED CODE ###

strings = input().split(' ')
A = int(strings[0])
B = int(strings[1])

i = min(A,B)
m = max(A,B)
n = min(A,B)
while 1:
    mt = n
    n = m % n
    m = mt
    if n == 0:
        break
if m != 0:
    print(A*B//m)
else:
    print(A*B)
A,B,C = map(str,input().split("/"))
if int(A) <= 2018:
  print("Heisei")
elif int(A) = 2019,int(B) <=4,int(C)<=30:
  print("Heisei")
else:
print("TBD")

### FIXED CODE ###

A,B,C = map(str,input().split("/"))
if int(A) <= 2018:
  print("Heisei")
elif int(A) == 2019 and int(B) <=4 and int(C)<=30:
  print("Heisei")
else:
  print("TBD")
from itertools import product

k = int(input())
s = input()

temp_dict = {
    "R": [],
    "G": [],
    "B": [],
}
for i, c in enumerate(s):
    temp_dict[c].append(i)

ans = 0
temp_list = list(product(temp_dict["R"], temp_dict["G"], temp_dict["B"]))
for temp in temp_list:
    temp.sort()
    if temp[0] - temp[1] != temp[1] - temp[2]:
        ans += 1

print(ans)


### FIXED CODE ###

n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = s.count("B")

ans = r * g * b
for i in range(n - 2):
    for j in range(i + 2, n, 2):
        if s[i] != s[(i + j) >> 1] != s[j] != s[i]:
            ans -= 1
print(ans)
import sys

args = sys.argv
n = args[0]
l = args[1]

n = int(n)
l = int(l)

all = []
for i in range(n):
    all.append(l+i)
all_sum = sum(all)

minus = 10000
ans = 0
for i in range(len(all)):
    if abs(all_sum - (all_sum - all[i])) < abs(minus):
        minus = abs(all_sum - (all_sum -all[i]))
        ans = all_sum -all[i]
print(ans)

### FIXED CODE ###

import sys
import math

n, l = list(input().split())
n = int(n)
l = int(l)

all = []
for i in range(n):
    all.append(l+i)
all_sum = sum(all)

minus = 10000
ans = 0
for i in range(len(all)):
    if math.fabs(all_sum - (all_sum - all[i])) < math.fabs(minus):
        minus = math.fabs(all_sum - (all_sum -all[i]))
        ans = all_sum -all[i]
print(ans)