Harryxun/stf_run huggingface dataset:
from decimal import *
import math
a,b=map(str,input().split())
c=Decimal('a')
d=Decimal('b')
e=Decimal('c*d')
f=math.floor(e)
print(f)

### FIXED CODE ###

from decimal import *
import math
a,b=map(str,input().split())
c=Decimal(a)
d=Decimal(b)
e=Decimal(c*d)
f=math.floor(e)
print(f)
import math
def equation(a,b,n):
  return math.floor((a*x)/b)-A*math.floor(x/B)
d,e,f = map(int,input().split())
X = equation(d,e,f)
Y = equation(d,e,e-1)
print(max(X,Y))

### FIXED CODE ###

import math
def equation(a,b,n):
  return math.floor((a*n)/b)-a*math.floor(n/b)
d,e,f = map(int,input().split())
K = min(e-1,f)
print(equation(d,e,K))
n.m = map(int,input().split())
l = [int(input()) for _ in[0]*m]
l=set(l)
dp=[0]*(n+1)#0〜n段目までのn+1通り。
#1段目までは手動。
dp[0]=1
dp[1]=0 if 1 in l else 1
MOD =10**9+7
#dp 貰うタイプ
for i in range(2,n+1):
  if i not in l:#床が壊れてなければ
    dp[i] = (dp[i-1] + dp[i-2])%MOD
print(dp[n])

### FIXED CODE ###

n,m = map(int,input().split())
l = [int(input()) for _ in[0]*m]
l=set(l)
dp=[0]*(n+1)#0〜n段目までのn+1通り。
#1段目までは手動。
dp[0]=1
dp[1]=0 if 1 in l else 1
MOD =10**9+7
#dp 貰うタイプ
for i in range(2,n+1):
  if i not in l:#床が壊れてなければ
    dp[i] = (dp[i-1] + dp[i-2])%MOD
print(dp[n])
S = input()
  if S == int("ARC") :
     print("ABC")
  elif S == int('ABC'):
       print('ARC')


### FIXED CODE ###

S = input()
if S == "ARC":
   print("ABC")
elif S == "ABC":
     print("ARC")
k = int(input())
ans = 0
if k % 7 == 0:
    L = (9 * k) / 7
else:
    L = 9 * k
if L % 2 == 0 or L % 5 == 0:
    print(-1)
else:
    a = 1 % L
    for i in range(L):
        if (a * 10) % L == 1:
            ans = i + 1
            print(ans)
            break
        a = (a * 10) % L
    

### FIXED CODE ###

k = int(input())
ans = 0
if k % 7 == 0:
    L = int((9 * k) / 7)
else:
    L = 9 * k
if L % 2 == 0 or L % 5 == 0:
    print(-1)
else:
    a = 1 % L
    for i in range(L):
        if (a * 10) % L == 1:
            ans = i + 1
            print(ans)
            break
        a = (a * 10) % L
    if ans == 0:
        print(-1)
#!/usr/bin/env python3
import sys

def solve(N: int, A: int, x: "List[int]"):
    ## dp[i][j][k] = i番目までのカードからjマイ選んで合計kにする選び方の総数
    dp = [[[0]*2500 for _ in range(N+1)] for _ in range(N+1)]

    for i in range(N):
        dp[i][0][0] = 1

    for i in range(N):
        for j in range(N):
            for k in range(2500):
                if k-x[i] >= 0:
                    dp[i+1][j+1][k] = dp[i][j][k-x[i]]+dp[i][j+1][k]
                else:
                    dp[i+1][j+1][k] = dp[i][j+1][k]

    answer = 0
    for j in range(1,N+1):
        answer += dp[N][j][A*j]
    print(answer)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, x)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
# dp[j][t]=(y1,...,yj から 0 枚以上選んで yi の合計を t − 1250 にするような選び方の総数)

def solve(N: int, A: int, x: "List[int]"):
    x = [x[i]-A for i in range(N)]
    dp = [[0]*2500 for _ in range(N+1)]
    dp[0][1250] = 1

    for j in range(1,N+1):
        for t in range(2500):
            if t-x[j-1]>=0 and t-x[j-1]<2500:
                dp[j][t] = dp[j-1][t] + dp[j-1][t-x[j-1]]
            else:
                dp[j][t] = dp[j-1][t]
    print(dp[N][1250]-1)
    
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, x)

if __name__ == '__main__':
    main()
X, Y, A, B, C = map(int,input().split())
P = [int(_) for _ in input().split()]
Q = [int(_) for _ in input().split()]
R = [int(_) for _ in input().split()]

P.sort()
Q.sort()
R.sort()
R.reverse()

P = P[A-X:]
Q = Q[B-Y:]

i = 0
j = 0

while min(P[i],Q[j])<R[i+j]:
    if P[i] < Q[j]:
        i += 1
        if i+j == C:
            break
        if i == X-1:
            if Q[j] > R[i+j]:
                break
    else:
        j += 1
        if i+j == C:
            break
        if j == Y-1:
            if P[i] > R[i+j]:
                break
    if i+j == C:
        break

ans = 0
for e in P[i:]:
    ans = ans + e
for e in Q[j:]:
    ans = ans + e
for a in range(i+j):
    ans = ans + R[a]

print(ans)

### FIXED CODE ###

X, Y, A, B, C = map(int,input().split())
P = [int(_) for _ in input().split()]
Q = [int(_) for _ in input().split()]
R = [int(_) for _ in input().split()]

P.sort()
Q.sort()
R.sort()
R.reverse()

P = P[A-X:]
Q = Q[B-Y:]

P.append(10**9+1)
Q.append(10**9+1)
R.append(0)


i = 0
j = 0


while min(P[i],Q[j])<R[i+j]:
    if P[i] < Q[j]:
        i += 1
    else:
        j += 1
    if i+j == C:
        break

P.remove(10**9+1)
Q.remove(10**9+1)
R.remove(0)

ans = 0
for e in P[i:]:
    ans = ans + e
for e in Q[j:]:
    ans = ans + e
for a in range(i+j):
    ans = ans + R[a]

print(ans)
N = int(input())
A = int(input())
a = 0

for i in A:
  if A%2 == 0:
    a += 1
  else:
    brake:
      print a

### FIXED CODE ###

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

ans = 0
while all(i%2 == 0 for i in A):
  A = [i/2 for i in A]
  ans += 1

print (ans)
A1,A2,A3 = int(input().split(""))
result = A1+A2+A3
if result>= 22:
  print("bust")
else:
  print("win")

### FIXED CODE ###

inp = input()
inpLi = inp.split()
A1 = int(inpLi[0])
A2 = int(inpLi[1])
A3 = int(inpLi[2])

if (A1+A2+A3) >= 22:
  print("bust")
else:
  print("win")
n = int(input())
a = [int(i) for i in input().split()]
dic = {}
flag = 1
ls = [0] * (max(a)+1)
for i in range(n):
    if ls[a[i]] == 1:
        flag = 0
        print("NO")
        break
    else:
        ls[a[i]] = 1

if flag:
    print("YES")


### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
dic = {}
for i in range(n):
	try:
		dic[a[i]] += 1
	except:
		dic[a[i]] = 1
if max(dic.values()) > 1:
	print("NO")
else:
  	print("YES")
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
b=list(Counter(a).values())
lst=[]
for i in range(len(b)):
  if b[i]>1:
    c=Counter(a).keys()
    lst.append(int(c[i]))
Lst=list(set(lst.sort(reverse=True)))
if len(Lst)<2:
  print(0)
else:
  print(Lst[0]*Lst[1])
    


### FIXED CODE ###

import collections
n=int(input())
a=map(int,input().split())
b=list(collections.Counter(a).items())
lst=[]
Lst=[]
for i in range(len(b)):
  if b[i][1]>1:
    lst.append(int(b[i][0]))  
    if b[i][1]>3:
      Lst.append(int(b[i][0]))
if len(lst)<2 and len(Lst)==0:
  print(0)
else:
  if len(lst)==1:
    Lst.sort(reverse=True)
    print(Lst[0]**2)
  else:
    if len(Lst)>0:
      lst.sort(reverse=True)
      Lst.sort(reverse=True)
      print(max(lst[0]*lst[1],Lst[0]**2))     
    else:
      lst.sort(reverse=True)
      print(lst[0]*lst[1])
mod = 10 ** 9 + 7
x, y = [int(i) for i in input().split()]
if (2*x - y) % 3 != 0 or (2*y - x) % 3 != 0:
  print(0)
a = (2*x - y) // 3
b = (2*y - x) // 3
def mygcd(a_b, b, mod):
    b = min(a_b, b)
    cnt = 1
    for i in range(b):
        cnt = cnt * (a_b - i) * pow(i+1, mod-2, mod) % mod
    return cnt
print(mygcd(a+b, b, mod))

### FIXED CODE ###

r = int(input())
print(r**2)
n = int(input())
factor = []

for i in range(1,int(n**1/2)):
    if n%i == 0:
        factor.append(i + n//i -2)
    else:
        continue

print(min(factor))

### FIXED CODE ###

n = int(input())
factor = []

for i in range(1,int(n**0.5)+1):
    if n%i == 0:
        factor.append(i + n//i)

factor.sort()
print(factor[0]-2)
N,M,Q=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(Q):
  ta,tb,tc,td=map(int,input().split())
  a+=[ta]
  b+=[tb]
  c+=[tc]
  d+=[td]
maxs=0
A=[0 for i in range(10)]
for i in range(10):
  for j in range(i,10):
    for k in range(j,10):
      for l in range(k,10):
        for m in range(l,10):
          for n in range(m,10):
            for o in range(n,10):
              for p in range(o,10):
                for q in range(p,10):
                  for r in range(q,10):
                    A[0]=i
                    A[1]=j
                    A[2]=k
                    A[3]=l
                    A[4]=m
                    A[5]=n
                    A[6]=o
                    A[7]=p
                    A[8]=q
                    A[9]=r
                    su=0
                    for i z in range(Q):
                      if A[b[i]]-A[a[i]]==c[i]:
                        su+=d[i]
                    if su>maxs:
                      maxs=su
print(maxs)


### FIXED CODE ###

N,M,Q=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(Q):
  ta,tb,tc,td=map(int,input().split())
  a+=[ta]
  b+=[tb]
  c+=[tc]
  d+=[td]
maxs=0
A=[0 for i in range(10)]
for i in range(M):
  for j in range(i,M):
    for k in range(j,M):
      for l in range(k,M):
        for m in range(l,M):
          for n in range(m,M):
            for o in range(n,M):
              for p in range(o,M):
                for q in range(p,M):
                  for r in range(q,M):
                    A[0]=i
                    A[1]=j
                    A[2]=k
                    A[3]=l
                    A[4]=m
                    A[5]=n
                    A[6]=o
                    A[7]=p
                    A[8]=q
                    A[9]=r
                    su=0
                    for z in range(Q):
                      if A[b[z]-1]-A[a[z]-1]==c[z]:
                        su+=d[z]
                    if su>maxs:
                      maxs=su
print(maxs)
import math

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

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

### FIXED CODE ###

from fractions import gcd

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

def lcm(x, y):
    return (x*y)//gcd(x,y)
    
tmp = lcm(a, b)
print(tmp)
from collections import deque, Counter
from itertools import chain, combinations
import json
import numpy as np
import bisect
import sys
import math

sys.setrecursionlimit(10 ** 8)
# mem = {}

M = 10 ** 9 + 7

mem = {}


def gcd(a, b, c):
    if (a, b, c) not in mem:
        mem[(a, b, c)] = math.gcd(math.gcd(a, b), c)
    return mem[(a, b, c)]


def main():
    K = int(input())
    t1 = 0
    for a in range(1, K + 1):
        for b in range(a + 1, K + 1):
            for c in range(b + 1, K + 1):
                t1 += gcd(a, b, c) * 6
    t2 = 0
    for ab in range(1, K + 1):
        for c in range(ab + 1, K + 1):
            t2 += math.gcd(ab, c) * 6
    t3 = 0
    for abc in range(1, K + 1):
        t3 += abc
    print(t1 + t2 + t3)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import deque, Counter
from itertools import chain, combinations
import json
import bisect
import sys
import math

sys.setrecursionlimit(10 ** 8)
# mem = {}

M = 10 ** 9 + 7

mem = {}


def gcd(a, b, c):
    if (a, b, c) not in mem:
        mem[(a, b, c)] = math.gcd(math.gcd(a, b), c)
    return mem[(a, b, c)]


def main():
    K = int(input())
    t1 = 0
    for a in range(1, K + 1):
        for b in range(a + 1, K + 1):
            for c in range(b + 1, K + 1):
                t1 += gcd(a, b, c) * 6
    t2 = 0
    for ab in range(1, K + 1):
        for c in range(ab + 1, K + 1):
            t2 += math.gcd(ab, c) * 6
    t3 = 0
    for abc in range(1, K + 1):
        t3 += abc
    print(t1 + t2 + t3)


if __name__ == "__main__":
    main()
import math

N = int(input())
num_list = [0] + [0] * N  # 0~N
pn_list = []
for i in range(2, int(math.sqrt(N))+1):
    if num_list[i] == 0:
        pn_list.append(i)
        num_list[i::i] = [1] * len(num_list[i::i])

count = 0
for pn in pn_list:
    e = 1
    while N%(pn**e)==0 and N//(pn**e)>=1:
        N //= (pn**e)
        e += 1
        count += 1
print(count)

### FIXED CODE ###

N = int(input())

div_counts = []
for i in range(2, int(N**0.5)+1):
  count = 0
  while N%i == 0:
    count += 1
    N //= i
    if N == 1:
      break
  div_counts.append(count)
  
if N != 1:
  div_counts.append(1)

ans = 0
for count in div_counts:
  for i in range(1, count+1):
    if count >= i:
      ans += 1
      count -= i
print(ans)
N, K = map(int, input().split())
A = set()
for _ in rnage(K):
  d = int(input())
  A.add(list(input().split()))
print(N - len(A))

### FIXED CODE ###

N, K = map(int, input().split())
A = set()
for _ in range(K):
  d = int(input())
  A.update(list(map(int, input().split())))
print(N - len(A))
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    YesNo(int(N:=input()[:3])%111==0 or int(N[1:])%111==0)

if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=input()
    YesNo(int(N[:3])%111==0 or int(N[1:])%111==0)

if __name__ == '__main__':
    main()
import itertools
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

permutations = list(itertools.permutations(range(1, N+1)))
p = permutations.index(P)
q = permutations.index(Q)
print(abs(p-q))

### FIXED CODE ###

import itertools
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

permutations = list(itertools.permutations(range(1, N+1)))
p = permutations.index(P)
q = permutations.index(Q)
print(abs(p-q))
S = input()
l = len(S)

S1 = S[0:(l-1)//2]
S2 = S[(l+3)//2]

def Kaibun(Str):
	if Str == Str[::-1]:
		return True
	else:
		return False

if Kaibun(S):
	if Kaibun(S1) and Kaibun(S2):
		print("Yes")
	else:
		print("No")
else: print("No")

### FIXED CODE ###

def f(x):
  return x==x[::-1]
S=input()
n=(len(S)-1)//2
S1,S2=S[:n],S[n+1:]
if f(S) and f(S1) and f(S2):
  print('Yes')
else:
  print('No')
n = int(input())
s = list(map(int,input().split()))
ans = 'Three'
for s_ in s:
    if s_=='Y':
        ans = 'Four'
print(ans)

### FIXED CODE ###

n = int(input())
s = list(input().split())
ans = 'Three'
for s_ in s:
    if s_=='Y':
        ans = 'Four'
print(ans)
n = int(input())
l = len(set(map(input().strip().split())))
print('Four' if l == 4 else 'Three')

### FIXED CODE ###

n = input()
l = len(set(input().strip().split()))
print('Four' if l == 4 else 'Three')
def f(m, s, g):
    v, t = {s}, set()
    for i in m:
        for j in v:
            t.update((j+i, j-i))
        v, t = t, set()
    return g in v
s = input()
x, y = map(int, input().split())
m = list(map(len, s.split('T')))
if f(m[::2][1::], m[0], x) and f(m[1::2], 0, y):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

def f(m, s, g):
    v, t = {s}, set()
    for i in m:
        for j in v:
            t.update((j+i, j-i))
        v, t = t, set()
    return g in v
s = input()
x, y = map(int, input().split())
m = list(map(len, s.split('T')))
if f(m[::2][1::], m[0], x) and f(m[1::2], 0, y):
    print('Yes')
else:
    print('No')
a, b = map(int, input().split()
ans = max(a+b), a-b)
ans = max(ans, a*b)
print(ans)

### FIXED CODE ###

a, b = map(int, input().split())
ans = max(a+b, a-b)
ans = max(ans, a*b)
print(ans)
import numpy as np

n = int(input())

a = np.array(list(map(int, input().split())))
d = [0] * n
s = {}

for i in a:
  d[i-1] += 1
  
sum = 0
for k in d:
  if k>1:
    sum += (k*(k-1))//2

for i in range(n):
  nd = d[a[i]]
  ans = sum-(nd*(nd-1))//2
  nd -= 1
  if nd>1:
    ans += (nd*(nd-1))//2
  print(ans)


### FIXED CODE ###

import numpy as np

n = int(input())

a = np.array(list(map(int, input().split())))
d = [0] * (n+1)
s = {}

for i in a:
  d[i] += 1
  
sum = 0
for k in d:
  if k>1:
    sum += (k*(k-1))//2

for i in range(n):
  ans=sum-d[a[i]]+1
  print(ans)
N=int(input())
mylist=list(map(int,input().split))
mymax=max(mylist)
mymin=min(mylist)
print(abs(mymax-mymin))



### FIXED CODE ###

n=int(input())
mylist=list(map(int,input().split()))
mymax=max(mylist)
mymin=min(mylist)
print(abs(mymax-mymin))
n,k= map(int,input().split())
h1=list(map(int,input().split()))
if k>=n-1:
    print(abs(h1[0]-h1[n-1]))
else:
    dp=[-1]*n
    dp[n-1]=0
    for y in range(n-k-1,n-1):
       dp[y]=abs(h1[n-1]-h1[y])    
    for u in range(k+1,n):
     i=(n-1-u)
     dp[i]=min([dp[i+h]+abs(h1[i+h]-h1[i]) for h in range(1,k+1)])
    print(dp[0])  

### FIXED CODE ###

n= int(input())
h1=list(map(int,input().split()))
dp=[-1 for i in range(n)]
def fun(i):
    if dp[i]!=-1:
        return dp[i]
    if i==n-1:
        best=0
    elif i==n-2:
        best=abs(h1[n-1]-h1[n-2])
    else:
        best=min(fun(i+1)+abs(h1[i+1]-h1[i]),fun(i+2)+abs(h1[i+2]-h1[i]))
    dp[i]=best
    return best
for k in range(n):
    fun(n-1-k)

print(fun(0))
import math

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

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

ans = 0
p = lcm(c, d)

print(p)

a_under = a-1

ans = (b - math.floor(b/c) - math.floor(b/d) + math.floor(b/p)) - (a_under - math.floor(a_under/c) - math.floor(a_under/d) + math.floor(a_under/p))

print(ans)

### FIXED CODE ###

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

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

a_under = a-1

ans = (b - b//c - b//d + b//p) - (a_under - a_under//c - a_under//d + a_under//p)

print(ans)
import numpy as np
import math

# input

r, D, x = [int(_) for _ in input().split()]

xans = np.ones(10)

def Linear_Recursive(x, r, D, N):
    
    if N==0:
        xans = x
        return xans
    
        
    
    xans = r*Linear_Recursive(x, r, D, N-1) - D # linear eq.
    
    return xans
  
for i in range(10):
    xans[i] = Linear_Recursive(x, r, D, i+1)
    
    pritnt(x[i])
    


### FIXED CODE ###

import numpy as np
import math

# input

r, D, x = [int(_) for _ in input().split()]

xans = x


for i in range(10):
    xans = r*xans - D
    
    print(xans)
a,b = map(int, input().split())
c = b - a
d = range(1, c, 1)
e = sum(d)
f = e - a
print(f)

### FIXED CODE ###

a,b = map(int, input().split())
c = b - a
d = range(1, c, 1)
e = sum(d)
f = e - a
print(f)
n,m  =map(int,input().split())
a = [int(i) for i in input().split()]

ans = 0

for _ in range(m):
		max(a)=max(a)//2


for i in range(n):
	ans+=a[i]

print(ans)


### FIXED CODE ###

import heapq

n,m = (int(x) for x in input().split())

a = [int(i)*(-1) for i in input().split()]
heapq.heapify(a)
for _ in range(m):

    b  = -(heapq.heappop(a))//2
    heapq.heappush(a,-b)


print(-sum(a))
import numpy as np
n,m = list(map(int, input().split()))
tmp_a = [list(input()) for _ in range(n)]
tmp_b = [list(input()) for _ in range(m)]

a = np.array(tmp_a)
b = np.array(tmp_b)

for a_i in range(n - m + 1):
    for a_j in range(n - m + 1):
        if((a[a_i:a_i + m, a_j:a_j + m] == b).all()):
          print("Yes")
          exit()
print("No")

### FIXED CODE ###

import numpy as np
n,m = list(map(int, input().split()))
tmp_a = [list(input()) for _ in range(n)]
tmp_b = [list(input()) for _ in range(m)]

a = np.array(tmp_a)
b = np.array(tmp_b)

for a_i in range(n - m + 1):
	for a_j in range(n - m + 1):
		if((a[a_i:a_i + m, a_j:a_j + m] == b).all()):
			print("Yes")
			exit()
print("No")
A=int(input())
B=int(input())
C=int(input())
X=int(input())
 
an=X//A
bn=X//B
cn=X//C
 
counter = 0
 
for i in range(an):
  for j in range(bn):
    for k in range(cn):
      x = 500*i+100*j+50*k
      if X == x:
        counter += 1
print(counter)

### FIXED CODE ###

A=int(input())
B=int(input())
C=int(input())
X=int(input())

 
counter = 0
 
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      x = 500*i+100*j+50*k
      if X == x:
        counter += 1
print(counter)
L=[]
R=[]
for _ in range(M):
	l,r=map(int, input().split())
	L.append(l)
	R.append(r)

l = max(L)
r = min(R)

res = 0
for i in range(1,N+1):
	if l<=i and i<=r:
		res+=1
print(res)


### FIXED CODE ###

N,M=map(int, input().split())
L=[]
R=[]
for _ in range(M):
	l,r=map(int, input().split())
	L.append(l)
	R.append(r)

l = max(L)
r = min(R)

res = 0
for i in range(1,N+1):
	if l<=i and i<=r:
		res+=1
print(res)
while 1:
    x, y = map(int, raw_input().split())
    if x == 0 and y == 0:
        break
    print min(x, y) max(x, y))

### FIXED CODE ###

while 1:
    x, y = map(int, raw_input().split())
    if x == 0 and y == 0:
        break
    print min(x, y), 
    print max(x, y)
while True:
    H,w = [int(i) for i in input().split()
    if H == W == 0:
        break
    for h in range(h):
        for w in range(w):
            print('#', end='')

        print()

    print()

### FIXED CODE ###

while True:
    H, W = [int(i) for i in input().split()]
    if H == W == 0:
        break
         
    for h in range(H):
        for w in range (W):
            print('#', end='')
         
        print()
     
    print()
N, K = map(int, input().split())
A = list( map(int, input().split() ) )

nums=[0] * 21000
var = [0] * 21000

for i in range(N):
    nums[A[i]] += 1
    var[A[i]] = 1
    
VAR = sum(var)
s_nums = sorted(nums, reverse = True)
ans = 0
# flag = 0
# for j in range(N):
if VAR <= K:
    print(0)
        
        
if VAR > K:
    for k in range(K):
        ans += s_nums[k]
    print(N - ans)
            

### FIXED CODE ###

N, K = map(int, input().split())
A = list( map(int, input().split()) ) #ここでN個受け取る

var = [0] * (N+1)


for i in A:
    var[i] += 1
    
var = sorted(var,  reverse = True )


count = 0
for j in range( K, N+1 ):
    if var[j] == 0:
        break
    
    if var[j] != 0:
        count += var[j]
        
print(count)
s = input()
 
ss = ""
for i in range(len(s)):
  if s[i] == "1"
  	ss += "9"	
  else:
    ss += "1"
    
print(ss)

### FIXED CODE ###

s = input()
 
ss = ""
for i in s:
  if i == "1":
  	ss += "9"	
  else:
    ss += "1"
    
print(ss)
A, B, N = map(int,input().split())

x = N
for x in reversed(range(N)):
  if x % B != 0:
    print(int(A*x/B)-A*int(x/B))
    exit()


### FIXED CODE ###

K = int(input())
A, B = map(int,input().split())

for i in range(A,B+1):
  if i % K == 0:
    print("OK")
    exit()
    
print("NG")
import sys
import math

line = []
for l in sys.stdin:
    for i in l.split(' '):
    	line.append(float(i))
a = (line[0]-line[2])**2+(line[1]-line[3])**2
print math.sqrt(a)

### FIXED CODE ###

import math

x1,y1,x2,y2 = map(float,raw_input().split())
a = math.sqrt((x1-x2)**2+(y1-y2)**2)
print '%f'%a
s = int(input())
print(min(abs(int(s[i:i+3]-753) for i in range(len(s))))

### FIXED CODE ###

a = input()
list1 = []
for i in range(len(a)):
  b = int(a[i:i+3])
  c = abs(753 - b)
  list1.append(c)
  if i == len(a)-3:
    break
print(min(list1))
def resolve():
	s = input()
	if re.search("^(dream|dreamer|erase|eraser)+$", s):
		print("YES")
	else:
		print("NO")
resolve()

### FIXED CODE ###

def resolve():
	s = input()
	w = ['dream', 'dreamer', 'erase', 'eraser']
	h = dict()
	for i in range(len(w)):
		h[w[i][::-1]] = True
	s = s[::-1]
	c = ''
	for i in s:
		c += i
		if h.get(c):
			c = ''
	if not len(c):
		print('YES')
	else:
		print('NO')
resolve()