peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-

#110_c

S = input()
T = input()

combination = []
for i, j in zip(S,T):
    combination.append([i,j])

set_combination = []

for i,j in list(map(list, set(map(tuple, combination)))):
    set_combination.append(j)

if len(set_combination) == len(set(set_combination)):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N=int(input());A=int(input());print('Yes' if A>=(N%500) else ('No'))
# Judge status: Accepted
n,m = map(int,input().split())
ab = [[]]*n
for i in range(n):
  ab[i] = list(map(int,input().split()))
ab.sort()
cost = 0
for i in range(n):
  if m>0:
    bought = min(m,ab[i][1])
    m -= bought
    cost += bought*ab[i][0]
print(cost)
# Judge status: Accepted
a = [int(input()) for _ in range(5)]
k = int(input())

flag = True

for i in range(4):
    for j in range(i+1, 5):
        if abs(a[i] - a[j]) > k:
            flag = False
            break

if flag:
    print("Yay!")
else:
    print(":(")
# Judge status: Accepted
a, b, c = map(int, input().split())
left = b - a
right = c - b
if left == right:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
n=int(input())
a = list(map(int, input().split()))
a2=list(set(a))
a3=sorted(a2)
for i in a:
    p=0
    for j in a3:
        s=a.count(j)
        if j==i:
            s-=1
        p+=(s*(s-1))/2
    print(p)
# Judge status: Accepted
N, M = [int(i) for i in input().split()]
A = [[i for i in list(input())] for _ in range(N)]
B = [[i for i in list(input())] for _ in range(M)]

k = (N-1)-(M-1)+1

def judge(x, y):
    for i in range(M):
        for j in range(M):
            if not(A[x+i][y+j]==B[i][j]):
                return False
    return True


for i in range(k):
    for j in range(k):
        if judge(i, j):
            print("Yes")
            quit()

print("No")
# Judge status: Accepted
from sys import stdin

def main():
	inp=stdin.readline
	s,w=map(int, inp().split())
	if w>=s:
		print("unsafe")
	else:
		print("safe")
main()
# Judge status: Accepted
a,b,c=map(int,input().split())
d=a-b
if c-d<0:
    print(0)
else:
    print(c-d)
# Judge status: Accepted
N = int(input())
ans = 0
now = 0
for i in range(N):
    a = int(input())
    if a != 0:
        now += a
    else:
        ans += now // 2
        now = 0
ans += now // 2
print(ans)
# Judge status: Accepted
S=str(input())
if S[0]==S[1] and S[1]!=S[2] and S[2]==S[3]:
      print("Yes")
elif S[0]==S[2] and S[0]!=S[1] and S[1]==S[3]:
     print("Yes")
elif S[0]==S[3] and S[0]!=S[1] and S[1]==S[2]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
x = list(map(int, input().split()))
x2 = sorted(x)

a = x2[n//2 - 1]
b = x2[n//2]

for i in range(n):
    if x[i] <= a:
        print(b)
    else:
        print(a)
# Judge status: Accepted
s=input()
t=input()
ans=len(t)
for i in range(len(s)-len(t)+1):
    s1=s[i:i+len(t)]
    sum=len(t)
    for j in range(len(t)):
        if t[j]==s1[j]:sum-=1
    ans=min(ans,sum)
print(ans)
# Judge status: Accepted
import sys
from collections import defaultdict

input = sys.stdin.readline
P = 998244353


def main():
    N = int(input())
    D = list(map(int, input().split()))

    count = defaultdict(int)
    for d in D:
        count[d] += 1

    if not(D[0] == 0 and count[0] == 1):
        print(0)
        exit()

    max_depth = max(count.keys())
    ans = 1
    for d in range(max_depth):
        ans = (ans * pow(count[d], count[d + 1], mod=P)) % P

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
n,k =map(int,input().split())
d =list(map(int,input().split()))
for i in range(n,10**n+1):
    for j in str(i):
        if int(j) in d:
            break
    else:
        print(i)
        exit()
# Judge status: Accepted
n = int(input())
lis = [0]*n
for i in range(1, n+1):
    j = 1
    while i*j <= n:
        lis[i*j-1] += 1
        j += 1
lis[0] = 1
ans = 0
for i in range(len(lis)):
    ans += (i+1)*lis[i]
print(ans)
# Judge status: Accepted
def Pair(k):

    return int((k / 2)**2) if k % 2 == 0 else int((k // 2) * (k // 2 + 1))

def main():
    k = int(input())
    print(Pair(k))

if __name__ == '__main__':
    main()
# Judge status: Accepted
n,x,t=map(int, input().split())
a=(n/x)
if a==type(int):
    a=str(a)
    b=int(a[:a.index(".")])
else:
    a=str(a)
    a2=a[a.index("."):]
    if a2=='.0':
        b=int(a[:a.index(".")])
        print(b*t)
    else:
        b=int(a[:a.index(".")])+1
        print(b*t)
# Judge status: Wrong Answer
# きりみんちゃん配信からきました
# 4で割りきれる数と奇数をぶつける（4で割り切れず2で割り切れるやつはまあはい）
n = int(input())
arr = list(map(int, input().split()))
dividable4 = 0
dividable2 = 0
odds = 0
for a in arr:
  if a % 4 == 0:
    dividable4 += 1
  elif a % 2 == 1:
    odds += 1
  elif a % 2 == 0:
    dividable2 += 1
print("Yes" if odds <= dividable4 or (odds - dividable4 == 1 and dividable2 == 9)  else "No")
# Judge status: Accepted
N,M = map(int,input().split())

A = []
for i in range(N):
  A.append(input())
B = []
for i in range(M):
  B.append(input()) 

ans = "No"
for i in range(N-M+1):
  for j in range(N-M+1):
    if A[i][j:j+M] == B[0]:
      cnt = 0
      for k in range(1,M):
        if A[i+k][j:j+M] == B[0+k]:
          continue
        else:
          cnt =1
          break
      if cnt == 0:
        ans = "Yes"
print(ans)
# Judge status: Accepted
from collections import defaultdict
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    pair = defaultdict(int)

    for i in range(N):
        pair[A[i]] += 1

    cnt = 0
    for num, count in pair.items():
        if count >= num:
            cnt += count - num
        else:
            cnt += count

    print(cnt)
if __name__ == "__main__":
    main()
# Judge status: Accepted
n,r=map(int,input().split())

if n>=10:
    print(r)
else:
    print(r+100*(10-n))
# Judge status: Accepted
a,b,c = map(int,input().split())
print("Yes" if a + b >= c else "No")
# Judge status: Accepted
n, m = map(int, input().split())

fail = False
result = {}

for i in range(0, m):
    s, c = map(int, input().split())
    key = n-s
    if key in result and result[key] != c:
        fail = True
        break
    result[key] = c

if n > 1:
    if n-1 in result and result[n-1] == 0:
       fail = True
    if not(n-1 in result):
        result[n-1] = 1

if fail:
    print(-1)
else:
    res = 0
    for i in range(0, n):
        if i in result:
            res += 10 ** i * result[i]
    print(res)
# Judge status: Accepted
A = int(input())
B = int(input())

C = 6 - A - B

print(C)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
import math
from functools import reduce


def read():
    N, X = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    return N, X, A


def solve(N, X, A):
    A = [a-X for a in A]
    ans = reduce(math.gcd, A)
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))
# Judge status: Accepted
n=int(input())
a=[int(i) for i in input().split()]
a.append(0)
x,y=1000,0
for i in range(n):
    if a[i]>=a[i+1]:
        x+=y*a[i]
        y=0
    else:
        y+=x//a[i]
        x=x%a[i]
print(x)
# Judge status: Accepted
s = input()
b = int(s[0:2])
a = int(s[2:])
if 0 < b < 13 and 0 < a < 13:
	print('AMBIGUOUS')
elif 0 < b < 13:
	print('MMYY')
elif 0 < a < 13:
  	print('YYMM')
else:
	print('NA')
# Judge status: Wrong Answer
import heapq

N, M = list(map(int,input().split()))
A = list(map(int,input().split()))
B = []
for i in range(M):  B.append(list(map(int,input().split())))
B = sorted(B, key = lambda x: x[1])

heapq.heapify(A)
cnt = 0
for i in range(M):
    for _ in range(B[i][0]):  heapq.heappush(A, max(heapq.heappop(A), B[i][1]))
    cnt += B[i][0]
    if cnt >= N:  break
print(sum(A))
# Judge status: Wrong Answer
x,a,b=map(int,input().split())
# a mae b go
syomi=b-a
if syomi <= 0:
  print("delicious")
elif syomi>=x:
  print("dangerous")
else:
  print("safe")
# Judge status: Wrong Answer
N = int(input())

if N == 1:
    print(0)
else:
    if N % 2 == 0:
        ans = N * (N/2 - 1) + N/2
    else:
        ans = N * (N-1)/2
    print(int(ans))
# Judge status: Accepted
s = list(input())
S = []
for i in range(len(s)):
    if s[i]=='B' and len(S)>0:
        del S[len(S)-1]
    elif s[i]!='B':
        S.append(s[i])
print(''.join(S))
# Judge status: Accepted
N = int(input())
l = list(map(int,input().split()))

new_l = sorted(l)
half1 = new_l[N//2-1]
half2 = new_l[N//2]

if half1 == half2:
    print(0)
else:
    print(half2-half1)
# Judge status: Wrong Answer
N=int(input())
S=list(input())
e,w=[0]*(N+1),[0]*(N+1)
for i in range(1,N+1):
    w[i] += w[i-1] + (1 if S[i-1]=='W' else 0)
    e[i] += e[i-1] + (1 if S[i-1]=='E' else 0)
ans=N
for i in range(N):
    ans=min(ans,w[i]+e[-1]-e[i])
print(ans)
# Judge status: Accepted
from collections import deque

k = int(input())
limit = 10#最大桁数

start = [i for i in range(1, 10)]#最初にスタートする数
ans = []
def DFS(num):
	if len(str(num))>11:#処理終了
		return 1
	ans.append(num)
	last=str(num)[-1]
	if last == "0":
		add = ['0', '1']
	elif last == '9':
		add = ['8',"9"] 
	else:
		add = [str(int(last) - 1), str(int(last)), str(int(last) + 1)]
	for i in add:
		DFS(int(str(num)+i))

for j in start:
	DFS(j)

ans = sorted(ans)
print(ans[k - 1])#k番目の答えを創出
# Judge status: Accepted
n=int(input())
cnt=0
ans=0
while(n>=1):
    ans+=2**cnt
    n//=2
    cnt+=1
print(ans)
# Judge status: Wrong Answer
x = int(input())

index = 0
for i in range(1,x+1):
  if (i+1)*2 < (x-index):
    index+=i
  elif i == (x-index):
    break
  print(i,index)
print(i)
# Judge status: Wrong Answer
a = int(input())
M = list(map(int,input().split()))
b = 0
max = 0
for i, v in enumerate(M):
    if i >= a-1:
        break
    if M[i] >= M[i+1]:
        b += 1
        if max < b:
            max = b
    elif M[i] < M[i+1]:
        if max <= b:
            max = b
            b = 0

print(max)
# Judge status: Accepted
N,M,K=map(int,input().split())

cand=[]
for i in range(N+1):
    for j in range(M+1):
        cand.append(i*(M-j)+j*(N-i))

if K in cand:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
s = int(input())
x = s % 10**9
y = s // 10**9
if x > 0:
    x -= 10**9
    y += 1
print(0,0,10**9,1,-x,y)
# Judge status: Accepted
a,b,k = map(int,input().split())
cnt = 0
for i in range(100,-1,-1):
  if a%i == b%i == 0:
    cnt += 1
  if cnt == k:
    print(i)
    exit()
# Judge status: Accepted
n = int(input())
w = [int(x) for x in input().split()]

diff = []
for t in range(1, n):
   diff.append(abs(sum(w[:t])-sum(w[t:])))

print(min(diff))
# Judge status: Accepted
import copy
n,W=map(int,input().split())
l=[0]*(W+1)
for _ in range(n):
	w,v=map(int,input().split())
	d=copy.deepcopy(l)
	for i in range(len(d)):
		if i-w>=0:
			d[i]=max(d[i],l[i-w]+v)
	l=d
	#print(l)

print(l[-1])
# Judge status: Wrong Answer
def core(s, t):
  if t in s:
    return 0
  for i in range(1, len(t)):
    for j in range(i+1):
      tempt = t[j:len(t)-i+j]
      temps = s[j:len(s)-i+j]
      if tempt in temps:
        return i
  return len(t)
  
if __name__ == "__main__":
  strings = [input() for i in range(2)]
  print(core(strings[0], strings[1]))
# Judge status: Wrong Answer
N, L = map(int, input().split())
S = {int(x) for x in input().split()}
flag = False
while flag == False:
    if N%10 in S:
        N += 1
        continue
    if int((N%100-N%10)/10) in S:
        N += 10
        continue
    if int((N%1000-N%100)/100) in S:
        N += 100
        continue
    if int((N%10000-N%1000)/1000) in S:
        N += 1000
        continue
    if int((N%100000-N%10000)/10000) in S:
        N += 10000
        continue
    flag = True
print(N)
# Judge status: Wrong Answer
n,x = map(int,input().split())
a = list(map(int,input().split()))

ans = 0
flg = 0
sum1 = 0
sum2 = 0
for i in range(n - 1):
  work = a[i] + a[i + 1]
  if i % 2 == 0:
    if work > x:
      sum1 = work - x
      flg = 0
  else:
    if work > x:
      sum2 = work - x
      flg = 1
  if flg == 1:
    if sum1 > sum2:
      ans += sum1
    else:
      ans += sum2

if flg == 0:
  ans += sum1
  
print(ans)
# Judge status: Wrong Answer
N=input()
A=int(N[0])
E=7-A
F=["-","-","-"]
for i in range(8):
 B=int(N[1])
 C=int(N[2])
 D=int(N[3])
 for j in range(3):
  if ((i >> j) & 1):
   F[j]="+"
 if F[0]=="-":
  B*=-1
 if F[1]=="-":
  C*=-1
 if F[2]=="-":
  D*=-1
 if B+C+D==E:
  print(str(A)+str(F[0])+str(B)+str(F[1])+str(C)+str(F[2])+str(D)+"=7")
  break
# Judge status: Accepted
s=input()
n=len(s)
l=[]
l.append(s[0])
i=1
k=0
while i < n:
    j=1

    if i==n-1 and l[k]==s[n-1]:
        break
    while l[k] == s[i:i+j]:
        j += 1

    l.append(s[i:i+j])
    i += j
    k += 1


print(k+1)
# Judge status: Wrong Answer
a = input()
print('a + a**2 + a**3')
# Judge status: Accepted
def main():
    n = int(input())
    a = list(map(int, input().split()))
    l = max(a)
    r = 0
    chk = 10**9+1
    for x in a:
        if abs(x-l//2) < chk and x != l:
            r = x
            chk = abs(x-l//2)
    print(l, r)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
import math
a,b,c,d=map(int,input().split())
lcm=c*d/math.gcd(c,d)
a1,a2,a3=int((a-1)/c),int((a-1)/d),int((a-1)/lcm)
b1,b2,b3=int(b/c),int(b/d),int(b/lcm)
ans=int(b-a+1-(b1+b2-b3-a1-a2+a3))
print(ans)
# Judge status: Accepted

n = int(input())
A = []
for i in range(n):
    x,l = map(int,input().split())
    a = x -l
    b = x + l
    A.append((b,a))
A.sort()

ans = 0
prev = -10**9 - 7

for i in range(n):
    if A[i][1] >= prev:
        prev = A[i][0]
        ans += 1
print(ans)
# Judge status: Accepted
n = int(input())

an = map(int, input().split())

if len(set(an)) == n :
    print("YES")
else :
    print("NO")
# Judge status: Accepted
n,m = map(int,input().split())
X = [list(map(int,input().split())) for i in range(m)]
a_list = []
b_list = []
for i in range(m):
  if X[i][0] == 1:
    a_list.append(X[i][1])
  elif X[i][1] == n:
    b_list.append(X[i][0])
c_set = set(a_list) & set(b_list)
if len(c_set) ==0:
  print("IMPOSSIBLE")
else:
  print("POSSIBLE")
# Judge status: Wrong Answer
c=str(input("please enter a string"))
list=list(c)
index=0
for x in list:
      list[index]='x'
      index+=1
s=''.join(list)
print(s)
# Judge status: Accepted
x,y=map(int,input().split())
a=(2*x)-y
b=(2*y)-x
if a%3==0 and b%3==0 and a>=0 and b>=0:
    a=a//3
    b=b//3
    c=a+b
    a1=1
    a2=1
    n3=10**9+7
    for i in range(a):
        a1*=c-i
        a2*=i+1
        a1%=n3
        a2%=n3
    a2=pow(a2,n3-2,n3)
    print((a1*a2)%n3)
else:
    print(0)
# Judge status: Accepted
N = int(input())
dp = [i for i in range(N+1+9**5)]
for i in range(N):
  dp[i+1] = min(dp[i+1], dp[i] + 1)
  for j in range(1, 7):
    dp[i+6**j] = min(dp[i+6**j], dp[i] + 1)
  for k in range(1, 6):
    dp[i+9**k] = min(dp[i+9**k], dp[i] + 1)
    
print(dp[N])
# Judge status: Wrong Answer
N = int(input())
print((10**N - 9**N - 9**N + 8**N)%(10**9 + 7))
# Judge status: Wrong Answer
N = int(input())
ans = 1
for i in range(1,31623):
    if N >= 2**i:
        ans = 2**i
print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline
def main():
    x = int(input())
    ans = (x//11)*2
    rest = x % 11
    if rest > 6:
        ans += 2
    elif 0 < rest <= 6:
        ans += 1
    print(ans)
if __name__ == "__main__":
    main()
# Judge status: Accepted
def LI():
	return [ int(s) for s in input().split() ]
  
N = int(input())
A = LI()
B = LI()

cnt = 0
for i in reversed(range(N)):
  if A[i+1]+A[i]-B[i] <= 0:
    cnt += A[i+1]+A[i]
    A[i] = 0
  else:
    cnt += B[i]
    if A[i+1] < B[i]:
      A[i]=A[i]-(B[i]-A[i+1])

print(cnt)
# Judge status: Wrong Answer
S = input()
cnt = 1
for i in range(1,len(S)):
    if S[i-1] != S[i]:
        cnt += 1

print(cnt+1)
# Judge status: Wrong Answer
n,k=map(int,input().split())
a=list(map(int,input().split()))
tmax=max(a)
tmin=0
t=(tmax+tmin)/2
import math
ans=tmax
if k==0:
  print(tmax)
else:
  while True:
    s=0
    for i in range(n):
      s=s+math.ceil(a[i]/t)-1
    if k>=s:
      ans=min(t,ans)
      tmax=t
      t=(tmin+t)/2
    else:
      tmin=t
      t=(t+tmax)/2
    if tmax-tmin<0.01:
      break
  print(math.ceil(ans))
# Judge status: Accepted
N,c = open(0).read().split()
N = int(N)
white_right = 0
red = 0
red_left = 0
for x in c:
    if x == 'R':
        red_left += 1
    else:
        break
c_altered = c[red_left:]
l = len(c_altered)
for x in c_altered:
    if x == 'R':
        red += 1
        white_right = 0
    else:
        white_right += 1
c_altered = c_altered[:l-white_right]
l = len(c_altered)
ans1 = red
ans2 = c_altered[:red].count('W')
print(min(ans1,ans2))
# Judge status: Wrong Answer
A, B, X = map(int, input().split())
print("YES" if X <= A+B <= X else "NO")
# Judge status: Accepted
s = input()
res = 0
for i in range(len(s)):
    if s[i] != s[-i-1]:
        res += 1
print(res//2)
# Judge status: Wrong Answer
s=input()
if s=="Sunny":
    print("Cloudy")
elif s=="Cloudy":
    print("Rainy")
else:
    print("Sundy")
# Judge status: Wrong Answer
n = int(input())

count = 0
while n >= 36:
    i = 0
    while 9**(i+1) <= n:
        i += 1

    j = 0
    while 6**(j+1) <= n:
        j += 1

    n -= max([9**i, 6**j])
    count += 1

def func(x, c, memo):
    if x == 0:
        memo.append(c)
    else:
        for i in [9, 6, 1]:
            if x >= i:
                func(x-i, c+1, memo)

memo = []
func(n, count, memo)

print(min(memo))
# Judge status: Wrong Answer
N = int(input())
ans = float('inf')
for i in range(1,N+1):
    j = i
    count = 0
    t=N-i
    while j > 0:
        count += j%6
        j=j//6
    while t > 0:
        count += t%9
        t=t//9
    ans = min(ans,count)
print(ans)
# Judge status: Accepted
n = int(input())
s = list(input())

# print(s)

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

# print('total RGB: ', r * g * b)

ans = r * g * b

for i in range(n):
  for j in range(i + 1, i + (n - i) // 2 + 1):
    if (j + (j-i)) < n:
      if s[i] != s[j]:
        if (s[j] != s[j + (j-i)]) and (s[i] != s[j + (j-i)]):
          # print(i, j, j + j-i, s[i], s[j], s[j + (j-i)])
          ans -= 1

print(ans)
# Judge status: Accepted
S=input()
dic={"Sunny":"Cloudy","Cloudy":"Rainy","Rainy":"Sunny"}
if S in dic:
  val=dic[S]
  print(val)
# Judge status: Accepted
N = int(input())
P = list(map(int,input().split()))
m = N + 1
ans = 0
for i in P:
  if i <= m:
    ans += 1
    m = i
  else:
    continue
print(ans)
# Judge status: Accepted
x=int(input())
if(x==0):
  print(1)
else:
  print(0)
# Judge status: Wrong Answer
import math

H = int(input())
n = math.ceil(math.log2(H))

if H < 8:
  if H==1:
    print(1)
  else:
  	print(2**(n+1)-1)
else:
  print(2**(n)-1)
# Judge status: Accepted
S = input()

count = 1
sentence = S[0]
i=1

while i < len(S):
    if sentence != S[i]:
        sentence = S[i]
        count += 1
        i+=1
    elif i==len(S)-1:
        break
    else:
        count += 1
        sentence = S[i:i+2]
        i+=2

print(count)
# Judge status: Accepted
s,t = input().split()

print(t+s)
# Judge status: Accepted
h, n = map(int, input().split())
ab = tuple(tuple(map(int, input().split())) for _ in range(n))

dp = [10 ** 20] * 10 ** 4 * 2
dp[0] = 0
for a, b in ab:
    for i in range(h):
        dp[i + a] = min(dp[i + a], dp[i] + b)
print(min(dp[h:]))
# Judge status: Accepted
from collections import deque
queue=deque()

n = int(input())
A = [int(i) for i in input().split()]

for i in range(n):
  if i % 2 == 0:
  	queue.append(A[i])
  else:
    queue.appendleft(A[i])

answer = []
if n % 2 == 1:
  for i in range(n):
    answer.append(queue.pop())
else:
  for i in range(n):
    answer.append(queue.popleft())
    
print(*answer)
# Judge status: Accepted
N = int(input())
box = [i for i in range(1,N+1) if i%3 != 0 and i%5 != 0 ]
print(sum(box))
# Judge status: Accepted
a = input().split()
ans = [a[0][0],a[1][0],a[0][2]]
print(''.join(ans))
# Judge status: Accepted
[N, K] = list(map(int, input().split()))
dList = []
AList = []
snuckSnack = {}
for i in range(K):
    dList.append(int(input()))
    AList.append(list(map(int, input().split())))
for i in range(1,N+1):
    snuckSnack[i] = set()
for i in range(K):
    for j in AList[i]:
        snuckSnack[j].add(dList[i])
vicCount = 0
for i in range(1,N+1):
    if snuckSnack[i] == set():
        vicCount += 1
print(vicCount)
# Judge status: Wrong Answer
W, a, b = map(int,input().split())
 
if a+W<=b:
  print(b-(a+W))
elif (a<= b)and (b<(a+W)):
  print(b-a)
elif (a<=b+W) and(b+W<a+W):
  print(a-b)
elif (b+W)<a:
  print(a-(b+W))
# Judge status: Accepted
s = input()

ans = True
while s != "":
    words = ["eraser", "dream", "erase", "dreamer"]

    found = False
    for word in words:
        if s[-len(word):] == word:
            s = s[:-len(word)]
            found = True
            break

    if not found:
        ans = False
        break

print("YES" if ans else "NO")
# Judge status: Wrong Answer
n,r=map(int,input().split())

if n>=10:
    print(r+100*(10-n))
else:
    print(r)
# Judge status: Accepted
n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(1,n-1):
  if p[i-1] >p[i] >p[i+1] or  p[i-1] <p[i] <p[i+1]:
    ans += 1
print(ans)
# Judge status: Accepted
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,M=map(int,input().split())
    l=[list(map(int,input().split())) for _ in range(N)]
    l.sort()
    c=0
    ans=0
    for i in range(N):
        if c>M:
            break
        ans+=min(M-c,l[i][1])*l[i][0]
        c+=l[i][1]
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

x.sort()
y.sort()

if x[n-1] < y[0] and y[0] >= x[n-1]:
    if x[n-1] > X and x[n-1] <= Y: print("No War")
    else: print("War")
else: print("War")
# Judge status: Accepted
from queue import deque

k=int(input())
que=deque()
for i in range(1,10):
  que.append(i)
for i in range(k):
  now=que.popleft()
  too=now%10

  if too!=0:
    que.append(now*10+too-1)

  que.append(now*10+too)

  if too!=9:
    que.append(now*10+too+1)

print(now)
# Judge status: Wrong Answer
w,h,x,y = map(int, input().split())
s = (w*h)/2
if(x == int(w/2) and y == int(h/2)):
    g = 1
else:
    g = 0
print(s,g)
# Judge status: Accepted
n = int(input())
l = [0] * (n // 2)
for i in range(1, n // 2 + 1):
    sum1 = sum([int(d) for d in str(i)])
    sum2 = sum([int(d) for d in str(n - i)])
    l[i - 1] = sum1 + sum2
print(min(l))
# Judge status: Wrong Answer
a, b = input().split()
x, y = int(a*int(b)), int(b*int(a))
if x >= y:
  print(y)
else:
  print(x)
# Judge status: Accepted
n = int(input())
trans = [ int(input()) for i in range(5) ]
trans = [ (n + i - 1) // i for i in trans]
print(max(trans) + 4)
# Judge status: Accepted
def resolve():
    MOD = 10 ** 9 + 7
    n, m = map(int, input().split())

    # i段目に到達するまでのルートの総数
    dp = [1] * (n + 1)

    for _ in range(m):
        dp[int(input())] = 0

    for i in range(2, n + 1):
        if dp[i] == 0:
            continue

        dp[i] = (dp[i - 1] + dp[i - 2]) % MOD

    print(dp[n])
    
resolve()
# Judge status: Wrong Answer
import sys
X = int(input())

for i in range(-100, 101):
    # print(i)
    for j in range(-100, 101):
        # print(i**5 - j**5)
        if (i**5 - j**5) == X:
            print(str(i) + ' ' + str(j))
            sys.exit()
# Judge status: Accepted
sa = list(input())
sb = list(input())
sc = list(input())
turn = "a"
tmp=sa
flag = True
while (flag):
    if len(tmp) == 0:
        print(turn.upper())
        exit()
    if tmp[0]=="a":
        turn=tmp.pop(0)
        tmp=sa
    elif tmp[0]=="b":
        turn=tmp.pop(0)
        tmp=sb
    else:
        turn=tmp.pop(0)
        tmp=sc
# Judge status: Accepted
import fractions
N=int(input())
L=list(map(int,input().split()))
ans=0
for i in range(1,N):
	if i==1:
		ans=fractions.gcd(L[0],L[i])
	else:
		ans=fractions.gcd(ans,L[i])
print(ans)
# Judge status: Accepted
n = int(input())
arr = list(map(int, input().split()))

ans = 0
for i in range(1, n - 1):
    a, b, c = arr[i - 1], arr[i], arr[i + 1]
    if a < b < c or a > b > c:
        ans += 1

print(ans)