Harryxun/stf_run huggingface dataset:
H, W = [int(_) for _ in input().split()]
S = [input() for _ in range(H)]

move = ((1, 0), (-1, 0), (0, 1), (0, -1))

visited = [[False] * W for _ in range(H)]

b, w = 0, 0

def dfs(i, j):
    global b, w

    if visited[i][j]:
        return
    visited[i][j] = True

    if S[i][j] == '#':
        b += 1
    else:
        w += 1

    for di, dj in move:
        ni, nj = i + di, j + dj
        if 0 <= ni < H and 0 <= nj < W and S[i][j] != S[ni][nj]:
            dfs(ni, nj)


result = 0
for i in range(H):
    for j in range(W):
        b, w = 0, 0
        dfs(i, j)
        result += b * w
print(result)



### FIXED CODE ###

from collections import deque


H, W = [int(_) for _ in input().split()]
S = [input() for _ in range(H)]


di = (1, 0, -1, 0)
dj = (0, 1, 0, -1)

def is_valid(i, j, d):
    ni = i + di[d]
    nj = j + dj[d]
    if not (0 <= ni < H and 0 <= nj < W):
        return False
    if S[i][j] == S[ni][nj]:
        return False
    return True


result = 0
visited = [[False] * W for _ in range(H)]
for i in range(H):
    for j in range(W):

        if visited[i][j]:
            continue
        visited[i][j] = True

        b = 0
        w = 0
        que = deque()
        que.append((i, j))
        while que:
            (ci, cj) = que.pop()
            if S[ci][cj] == '#':
                b += 1
            else:
                w += 1

            for d in range(4):
                if not is_valid(ci, cj, d):
                    continue
                ni = ci + di[d]
                nj = cj + dj[d]
                if visited[ni][nj]:
                    continue
                visited[ni][nj] = True
                que.append((ni, nj))

        result += b * w


print(result)
def getmax(x,y):
    if x>y:
        return x
    else:
        return y
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a,b = [0],[0]
for i in range(N):   #a[i]にはAの本をi冊読んだ時の時間がそれぞれ保存されている．
    a.append(a[i]+A[i])  #計算量を減らすため，a[i]（1冊前までにかかる時間）を用いる
for i in range(M):
    b.append(b[i]+B[i])

ans,j = 0,M
for i in range(N+1):
    if a[j]>K:
        break
    while b[j] > K-a[i]:    #Bの本を読んだ場合の処理はここで実行される．
        j -=1
    ans = max(ans, i+j)
print(ans)

### FIXED CODE ###

def getmax(x,y):
    if x>y:
        return x
    else:
        return y
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a,b = [0],[0]
for i in range(N):   #a[i]にはAの本をi冊読んだ時の時間がそれぞれ保存されている．
    a.append(a[i]+A[i])  #計算量を減らすため，a[i]（1冊前までにかかる時間）を用いる
for i in range(M):
    b.append(b[i]+B[i])

ans,j = 0,M
for i in range(N+1):
    if a[i]>K:
        break
    while b[j] > K-a[i]:    #Bの本を読んだ場合の処理はここで実行される．
        j -=1
    ans = max(ans, i+j)
print(ans)
N,A,B,C=map(int,input().split())
L=[int(input()) for _ in range(N)]

#for i in range(N):
#    L.append(int(input())

ans=10**18
def cost_calc(pp,TAKEs):
    if TAKEs==[]:
        return 10**8
    
    else:
        ans=0
        ans+=(len(TAKEs)-1)*10
        ans+=abs(pp-sum(TAKEs))
        return ans

assign=[]#[A,B,C,none]

for pattern in product([0,1,2,3],repeat=N):
    MP=0
    take=[0]*3
    for index,length in zip(pattern,l):
        if index==3:
            continue
        if take[index]!=0:
            MP+=10
        take[index]+=length
    if take[0]!=0 and take[1]!=0 and take[2]!=0:
        MP+=abs(A-take[0])
        MP+=abs(B-take[1])
        MP+=abs(C-take[2])
        ans=min(MP,ans)
print(ans)

### FIXED CODE ###

N,A,B,C=map(int,input().split())
L=[int(input()) for _ in range(N)]
from itertools import product

ans=10**18

for pattern in product(range(4),repeat=N):
    MP=0
    take=[0]*3
    for index,length in zip(pattern,L):
        if index==3:
            continue
        if take[index]!=0:
            MP+=10
        take[index]+=length
    if take[0]!=0 and take[1]!=0 and take[2]!=0:
        MP+=abs(A-take[0])
        MP+=abs(B-take[1])
        MP+=abs(C-take[2])
        ans=min(MP,ans)
print(ans)
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


a, b, c, d = Is()
def calc(num, x, y):
    l = (x*y)/gcd(x, y)
    return num - floor(num/x) - floor(num/y) + floor(num/l)

print(calc(b, c, d) - calc(a-1, c, d))


### FIXED CODE ###

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


a, b, c, d = Is()
def calc(num, x, y):
    l = (x*y)//gcd(x, y)
    return num - num//x - num//y + num//l

print(calc(b, c, d) - calc(a-1, c, d))
X, num = [int(i) for i in input().split(" ")]
l = [int(i) for i in input().split(" ")]

if num == 0:
  print(X)
else:
  for i in range(num):
    if X-i not in l:
      print(X-i):
      exit()
    elif X+i not in l:
      print(X+i)
      exit()
  print(X-num)

### FIXED CODE ###

X, num = [int(i) for i in input().split(" ")]

 
if num == 0:
  print(X)
else:
  l = [int(i) for i in input().split(" ")]
  for i in range(num):
    if X-i not in l:
      print(X-i)
      exit()
    elif X+i not in l:
      print(X+i)
      exit()
  print(X-num)
import math

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

_A = [A[i] - (i + 1) for i in range(len(A))]
_A.sort()
median = _A[math.ceil(len(A) / 2)]

sadness = 0
for i in range(len(A)):
    sadness += abs(A[i] - (i + 1 + median))

print(sadness)


### FIXED CODE ###

import math

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

_A = []
for i in range(len(A)):
    _A.append(A[i] - (i + 1))
_A.sort()
median = _A[math.floor(len(A) / 2)]

sadness = 0
for i in range(len(A)):
    sadness += abs(A[i] - (i + 1 + median))

print(sadness)
a, b = map(int, input().split())
c = int(a*b)

if(c%2==0)
   print("Even")
  else
   print("Odd")

### FIXED CODE ###

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

if ((a*b)%2==0):
    print('Even')
else:
    print('Odd')
print(int(r*r))

### FIXED CODE ###

r = int(input())
print(r**2)
import sympy

n =int(input())
ans = 0
for i in range(1,n+1,1):
    ans += i*len(sympy.divisors(i))


print(ans)

### FIXED CODE ###


n =int(input())

sum = 0
for i in range (1,n+1,1):
    k= n//i
    sum += int(i*k*(k+1)/2)

print(sum)
x, y = map(input().split())
print(x if x > y else y)

### FIXED CODE ###

x, y = map(ord, input().split())
if x == y:
    print("=")
elif x < y:
    print("<")
else:
    print(">")
r,g,b=map(int, input().split())

if (r*100 +g*10 +b)%4==0:
    print("Yes")

else:
    prinnt('No')

### FIXED CODE ###

r, g, b = map(int, input().split())
if (g * 10 + b) % 4 == 0:
  print("YES")
else:
  print("NO")
import sys
input=sys.stdin.buffer.readline
#####segfunc######
def segfunc(x,y):
    return x|y

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元######
ide_ele = set()

#num:n以上の最小の2のべき乗
n=int(input())
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num
s=input()
init([{s[i]}for i in range(n)])
q=int(input())
for _ in range(q):
  quer=input().split()
  if quer[0]=="1":
    i,c=quer[1],quer[2]
    update(int(i)-1,{c})
  else:
    l,r=quer[1],quer[2]
    print(len(query(int(l)-1,int(r))))

### FIXED CODE ###

import sys;input=sys.stdin.readline
n=int(input())
s=input()
num=2**(n-1).bit_length()
def segfunc(x,y):return x|y
seg=[0]*(2*num-1)
for i in range(n):seg[i+num-1]=2**(ord(s[i])-97)
for i in range(num-2,-1,-1):seg[i]=segfunc(seg[2*i+1],seg[2*i+2])
def update(i,x):
  i+=num-1;seg[i]=x
  while i:i=(i-1)//2;seg[i]=segfunc(seg[i*2+1],seg[i*2+2])
def query(l,r):
  l+=num-1;r+=num-1
  if l==r:return seg[l]
  s=seg[l];l+=1
  while r-l>1:
    if ~l%2:s=segfunc(seg[l],s)
    if r%2:s=segfunc(seg[r],s);r-=1
    l//=2;r=(r-1)//2
  if l==r:return segfunc(s,seg[l])
  return segfunc(s,segfunc(seg[l],seg[r]))
for _ in range(int(input())):
  quer=input().split()
  if quer[0]=="1":
    _,i,c=quer
    update(int(i)-1,2**(ord(c)-97))
  else:
    _,l,r=quer
    print(sum(map(int,bin(query(int(l)-1,int(r)-1))[2:])))
n = input()
a = list(map(int, input().split()))
for i in range(n):
    while True:
        a[i] *= 1/2
        if a[i]%2!=0 && a[i] > 0:
            break

print(min(a))


### FIXED CODE ###

print(input().count("1"))
n=input()

if 0==n/2:
  n=n/2
  print(n)
else:
  n=n/2+1
  print(n)

### FIXED CODE ###

n=int(input())

if n%2==0:
  n=n/2
  print(int(n))
else:
  n=n//2+1
  print(int(n))
s = input()
li = input().split()
t = 0
li2 = []
for i in li:
    t  = 0
    while True:
        if int(i) % 2 == 0:
            i = int(i) / 2
            t += 1
        else:
            li2.append(t)
            break

li2.sort()
ans = li2[0]
print(ans)

### FIXED CODE ###

li = list(input())
ans = 0
for i in li:
    if int(i) == 1:
        ans += 1

print(ans)
n = int(input())
    a = list(map(int, input().split()))
    import Counter
    x=Counter(a)
    for i in range(1,n+1):
      print(x[i])

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
from collections import Counter
x=Counter(a)
for i in range(1,n+1):
  print(x[i])
l = len(colors)
count1 = 0
for i in range(l):
	if colors[i] == i % 2:
		count1 += int(colors[i])
print(min(count1, l-count1))

### FIXED CODE ###

colors = input()
l = len(colors)
count1 = 0
for i in range(l):
	if int(colors[i]) == (i % 2):
		count1 += 1
print(min(count1, l-count1))
def resolve():
    import sys
    import math
    H, W, N = map(int, sys.stdin.read().split('\n'))
    m = max(H, W)
    print(math.ceil(N / m))

resolve()

### FIXED CODE ###

def resolve():
    H = int(input())
    W = int(input())
    N = int(input())
    m = max(H, W)
    print(N // m if N / m == N//m else N // m + 1)
resolve()
H, W, K = map(int,input().split())
S = list(list(input())for i in range(H))
cake = [[0]*W for i in range(H)]

queue = []
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            queue.append([i,j])
            cake[i][j] = -1
for i in range(len(queue)):
    h,w = queue[i]
    U,D,L,R = 0,0,0,0
    while L < w:
        if cake[h][w-L-1]:
            break
        L += 1
    while R < W-w-1:
        if cake[h][w+R+1]:
            break
        R += 1
    while U < h:
        flag = False
        for k in range(w-L,w+R+1):
            if cake[h-U-1][k]:
                flag = True
        if flag:
            break
        U += 1
    while D < H-h-1:
        for k in range(w-L,w+R+1):
            if cake[h+D+1][k]:
                flag = True
        if flag:
            break
    for x in range(h-U,h+D+1):
        for y in range(w-L,w+R+1):
            cake[x][y] = i+1

for i in cake:
    print(*i)

### FIXED CODE ###

H, W, K = map(int,input().split())
S = list(list(input())for i in range(H))
cake = [[0]*W for i in range(H)]

queue = []
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            queue.append([i,j])
            cake[i][j] = -1
for i in range(len(queue)):
    h,w = queue[i]
    U,D,L,R = 0,0,0,0
    while L < w:
        if cake[h][w-L-1]:
            break
        L += 1
    while R+w < W-1:
        if cake[h][w+R+1]:
            break
        R += 1
    while U < h:
        flag = False
        for k in range(w-L,w+R+1):
            if cake[h-U-1][k]:
                flag = True
        if flag:
            break
        U += 1
    while D+h < H-1:
        flag = False
        for k in range(w-L,w+R+1):
            if cake[h+D+1][k] != 0:
                flag = True
                break
        if flag:
            break
        D += 1
    for x in range(h-U,h+D+1):
        for y in range(w-L,w+R+1):
            cake[x][y] = i+1

for i in cake:
    print(*i)
S, W = list(map(int, input().split))

if W >= S:
  print("unsafe")

else:
  print("safe")

### FIXED CODE ###

S, W = list(map(int, input().split()))
 
if W >= S:
  print("unsafe")
 
else:
  print("safe")
a,b,c=int(input())

print(c,a,b)

### FIXED CODE ###

a,b,c=map(int,input().split())
 
print(c,a,b)
a,b,c=map(int,input().split())
if a == b + c or b = c + a c = b + a:
  print("YES")
else:
  print("NO")
  

### FIXED CODE ###

a,b,c=map(int,input().split())
if a == b + c or b == c + a or c == b + a:
  print("Yes")
else:
  print("No")
N,K = map(int, input().split())
P = [int(p) for p in input().split()]

L = [0 for i in range(N-1)]
temp = P[0]
for i in range(1,N):
    if temp > P[i]:
        L[i-1] = 1
    temp = P[i]
    
cnt = 0
for i in range(K-2, N-K+1):
    if L[i] == 1:
        chk = 0
        for j in range(1,K):
            if L[i+j] == L[i-j]:
                chk += 1
            else:
                break
        if chk == K-1:
            cnt += 1
            
zero = []
z = 0
for i in range(N-1):
    if L[i] == 0:
        z += 1
    else:
        zero.append(z)
        z = 0

cnt2 = 0
for i in range(len(zero)):
    if zero[i] >= K-1:
        cnt2 += zero[i]-K+2
        
print(N-K+1-cnt-cnt2)

### FIXED CODE ###

import heapq

N,K = map(int, input().split())
P = [int(p) for p in input().split()]

h = []
H = []
for i in range(K):
    heapq.heappush(h, (P[i], i))
    heapq.heappush(H, (-P[i], i))
    
ans = 1
for i in range(N-K):
    while h[0][1] < i:
        heapq.heappop(h)
    while H[0][1] < i:
        heapq.heappop(H)
    heapq.heappush(h, (P[i+K], i+K))
    heapq.heappush(H, (-P[i+K], i+K))
    if h[0][0] == P[i] and -H[0][0] == P[i+K]:
        continue
    ans += 1
    
f = 0
cnt = 1
for i in range(N-1):
    if P[i] < P[i+1]:
        cnt += 1
    else:
        if cnt >= K and f == 1:
            ans -= 1
        elif cnt >= K and f == 0:
            f = 1
        cnt = 1
        
if cnt >= K and f == 1:
    ans -= 1
    
print(ans)
import fractions
N,M = map(int,input().split())
S = input()
T = input()
L = (N * M) // fractions.gcd(N,M)
div_N = L // N
div_M = L // M
tag = (div_N * div_M) // fractions.gcd(div_N,div_M)
s = [""] * L
t = [""] * L

for ss in range(N):
  if ss == 0:
    s[0] = S[0]
    if s[0] != T[0]:
      print(-1)
      exit()
  else:
    s[ss * (div_N)] = S[ss]

for tt in range(M):
  if tt == 0:
    t[0] = T[0]
  else:
    t[tt * (div_M)] = T[tt]
while tag < L:
  if s[tag] != "" and s[tag] != t[tag]:
      print(-1)
      exit()
  tag += tag
print(L)




### FIXED CODE ###

import fractions
N,M = map(int,input().split())
S = input()
T = input()
G = fractions.gcd(N,M)
L = (N * M) // G
div_N = N // G
div_M = M // G

i = 0
j = 0

while i < N and j < M:
  if S[i] != T[j]:
    print(-1)
    exit()
  else:
    i += div_N
    j += div_M
print(L)
A, B =map(int,input())
print(A*B)

### FIXED CODE ###

A, B =map(int,input().split())
print(A*B)
nm = input().split()
n = int(nm[0])
m = int(nm[1])

p = []
r = []

for i in range(m):
	pr = input().split()
	p.append(int(pr[0]))
	r.append(pr[1])

ac = 0
wa = 0
flg = [False for i in range(m)]

if m != 0:
	for l in range(m):
		if r[l] == 'AC' and flg[p[l]] == False :
			ac += 1
			flg[p[l]] = True
		elif  flg[p[l]] == False :
			wa += 1

print(ac)
print(wa)


### FIXED CODE ###

nm = input().split()
n = int(nm[0])
m = int(nm[1])

p = []
r = []

for i in range(m):
	pr = input().split()
	p.append(int(pr[0]))
	r.append(pr[1])

ac = 0
wa = 0
flg = [0 for i in range(n)]

if m != 0:
	for l in range(m):
		if r[l] == 'AC' and flg[p[l]-1] !=  'ac':
			ac += 1
			wa += flg[p[l]-1]
			flg[p[l]-1] = 'ac'
		elif  flg[p[l]-1] != 'ac' :
			flg[p[l]-1] += 1

print(ac)
print(wa)
for i in range(3000):
    x,y = (int,input().split)
    if x!=0 and y!=0:
        print(min([x,y]), max([x,y]))
    else:
        break



### FIXED CODE ###

while True:
    x,y = map(int,input().split())
    if (x,y) == (0,0):
        break
    else:
        if x < y:
            print(x,y)
        else:
            print(y,x)
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N,K = MI()
k = K.bit_length()
AB = []
for _ in range(N):
    a,b = MI()
    if a > K:
        continue
    else:
        AB.append(([(a >> i) & 1 for i in range(k-1,-1,-1)],b))

N = len(AB)
K = [(K >> i) & 1 for i in range(k-1,-1,-1)]

A = [[] for _ in range(k+1)]
B = [0]*(k+1)
for i in range(N):
    a,b = AB[i]
    for j in range(k):
        if a[j] == 1:
            B[j+1] -= b
        if a[j] > K[j]:
            A[j].append(b)
            break
    else:
        A[k].append(b)


for i in range(k+1):
    A[i] = sum(A[i])

for i in range(k-1,-1,-1):
    A[i] += A[i+1]

print(max(A[i]+B[i] for i in range(1,k+1)))


### FIXED CODE ###

import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N,K = MI()
K += 1
k = K.bit_length()

AB = []

for _ in range(N):
    a,b = MI()
    if a >= K:
        continue
    else:
        AB.append(([(a >> i) & 1 for i in range(k-1,-1,-1)],b))

N = len(AB)
K_bit = [(K >> i) & 1 for i in range(k-1,-1,-1)]

ANS = [0]*k  # 

for i in range(N):
    a,b = AB[i]
    for j in range(k):
        if K_bit[j] == 1:
            if a[j] == 0:
                ANS[j] += b
        else:
            if a[j] == 1:
                break

print(max(ANS))
S = input()
if len(S) > 0 and len(S.replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '')) == 0:
print('YES')
else:
print('NO')


### FIXED CODE ###

S = input()
if len(S) == 0:
  print('NO')
else:
  if len(S.replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '')) == 0:
    print('YES')
  else:
    print('NO')
import numpy as np
K = int(input().split()[1])
As = [int(i) for i in input().split()]
As.sort(reverse=True)
bit_num = len(bin(K))-2
arr = np.array([[int(s) for s in format(val,'b').zfill(bit_num)] for val in As])
ans = int("".join(["0" if i>arr.shape[0]/2 else "1" for i in np.sum(arr, axis=0)]), 2)
ans = ans if ans < K else K
print(sum([ans^i for i in As]))

### FIXED CODE ###

str_ = input().split()
x = int(str_[0])
t = int(str_[1])
print(x/t)
# CとDの最小公倍数を求める
# CとDのそれぞれの倍数の数を求めて最小公倍数で割る
import math

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


A,B,C,D = map(int,input().split())
E = lcm(C,D)
c = (A-1)//C + 1 if A!=1 else 1
d = (A-1)//D + 1 if A!=1 else 1
e = (A-1)//E + 1 if A!=1 else 1
cde = [[c,C], [d,D], [e,E]]
cnt_cde = []
for x,y in cde:
    if x*y < B:
        cnt_cde.append((B-x*y)//y+1)
    elif x*y == B:
        cnt_cde.append(1)
    else :
        cnt_cde.append(0)
answer = B-A+1-(cnt_cde[0]+cnt_cde[1]-cnt_cde[2])
print(answer)
            

### FIXED CODE ###

import fractions
A,B,C,D = map(int,input().split())
c = B//C - (A-1)//C
d = B//D - (A-1)//D
E = (C*D)//fractions.gcd(C,D)
e = B//E - (A-1)//E
answer = B-A+1-(c+d-e)
print(answer)
n=raw_input()
A=map(raw_input.split())
q=raw_input()
m=map(raw_input.split())

def solve(i, m)
  if m == 0:
    return true
  if i >= n or sum(A)<m:
    return false
  res = solve(i + 1, m) || solve(i + 1, m - A[i])
  return res

for i range(0,q):
  if solve(0,m[i])==1:
    print yes
  else:
    print no

### FIXED CODE ###

n=int(raw_input())
A=map(int, raw_input().split())
q=int(raw_input())
m=map(int, raw_input().split())

def solve(j, m):
  if m == 0:
    return 1
  if j >= n or m > sum(A):
    return 0
  res = solve(j + 1, m) or solve(j + 1, m - A[j])
  return res

for i in range(0,q):
  if solve(0,m[i]):
    print "yes"
  else:
    print "no"
def age_check(age):
    if age ==3:
        print('YES')
    else age == 5:
        print('YES')
    else age == 7:
        print('YES')
    else:
        print('NO')

age = input()

age_check(age) 

### FIXED CODE ###

def age_check(age):
  if age == 3 or age == 5 or age == 7:
    print('YES')
  else:
    print('NO')
 
age = int(input())
 
age_check(age)
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n):
  b[a[i]-1]=i+1
print(" ",join(map(str,b)))

### FIXED CODE ###

n=int(input())
if n%2==0:
    print(1/2)
else:
    print((int(n/2)+1)/n)
n,u,v=map(int,input().split())
E=[[] for _ in range(n+1)]
for _ in range(n-1):
    a,b=map(int,input().split())
    E[a].append(b)
    E[b].append(a)
depth=[-1]*(n+1)
dis=[-1]*(n+1)
def dsf_1(p,d):
    depth[p]=d
    for c in E[p]:
        if depth[c]==-1:
            dsf_1(c,d+1)
dsf_1(v,0)
def dsf_2(p,d):
    dis[p]=d
    for c in E[p]:
        if depth[c]==-1:
            dsf_2(c,d+1)
dsf_2(u,0)
ans=0
for i in range(1,n+1):
    if len(E[i])==1 and i!=v:
        if dis[i]<depth[i]:
           ans=max(ans,depth[i]-1)
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
n,u,v=map(int,input().split())
E=[[] for _ in range(n+1)]
for _ in range(n-1):
    a,b=map(int,input().split())
    E[a].append(b)
    E[b].append(a)
depth=[-1]*(n+1)
dis=[-1]*(n+1)
def dsf_1(p,d):
    depth[p]=d
    for c in E[p]:
        if depth[c]==-1:
            dsf_1(c,d+1)
dsf_1(v,0)
def dsf_2(p,d):
    dis[p]=d
    for c in E[p]:
        if dis[c]==-1:
            dsf_2(c,d+1)
dsf_2(u,0)
ans=0
for i in range(1,n+1):
    if len(E[i])==1 and i!=v:
        if dis[i]<depth[i]:
           ans=max(ans,depth[i]-1)
print(ans)
import math
a, b, c, d = map(int, input().split())
a = a -1
e = (c * d) // math.gcd(c, d)
nc = b // c - a // c
nd = b // d - a // d
ne = b // e - a // e

print(b - a - (nc + nd - ne))




### FIXED CODE ###

import fractions
a, b, c, d = map(int, input().split())
a = a -1
e = (c * d) // fractions.gcd(c, d)
nc = b // c - a // c
nd = b // d - a // d
ne = b // e - a // e

print(b - a - (nc + nd - ne))
x = input()

if x:
    print 0
else:
    print 1

### FIXED CODE ###

x = int(input())
 
if x:
    print(0)
else:
    print(1)
x, y, z = map(int, input().split())
 
x, y, z = y, z, x
y, z, x = we
print(we)

### FIXED CODE ###

x, y, z = map(int, input().split())
 
x, y, z = y, z, x
print(y, z, x)