peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N,M = map(int, input().split())
a_list = [int(input()) for _ in range(M)]

MOD = 10**9+7

dp = [0] * (10**5 + 3)
dp[1] = 0
dp[2] = 1
dp[3] = 2
for i in range(3, len(dp)):
    dp[i] = dp[i-1] + dp[i-2] 

res = 1
bef = -1
if M > 0:
    for a in a_list:
        res *= dp[a-bef]
        res %= MOD
        bef = a
res *= dp[N-bef+1]
res %= MOD

print(res)
# Judge status: Accepted
n = int(input())
s = input()

num = 0
for i in range(n-1):
    x = s[:i+1]
    y = s[i+1:]

    setx = {i for i in x}
    sety = {i for i in y}
    common = setx & sety

    num = max(num, len(common))

print(num)
# Judge status: Accepted
s = input()
for i in range(5):
    if "R"*i not in s:
        print(i-1)
        break
# Judge status: Accepted
n=int(input())
h=list(map(int,input().split()))
cnt=0
a=0
for i in range(n-1):
    if h[i]>=h[i+1]:
        a+=1
    else:
        a=0
    cnt=max(cnt,a)
print(cnt)
# Judge status: Wrong Answer
a, b, x =map(int, input().split())

if 0 <= x-a and x-a <= b:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n = int(input())
w = list(map(int, input().split()))

ans = float('inf')
for i in range(n-1):
    weight = abs(sum(w[:i+1]) - sum(w[i+1:]))
    ans = min(ans, weight)

print(ans)
# Judge status: Accepted
s = input()
count = 0
sc = 0
for c in s:  
  if c=='S':
    sc+=1
  else:
    if sc > 0:
      sc -= 1
      count += 1
      
print(len(s) - count*2)
# Judge status: Wrong Answer
import sys

input = sys.stdin.readline
N,M = map(int,input().split())
PY = {n: [] for n in range(N + 1)}
for i in range(M):
  p,y = map(int,input().split())
  PY[p].append((y, i))
print(PY)
for p,y in PY.items():
  y.sort()
  for j, (z, i) in enumerate(y):
    top_number = '0'*(6-len(str(p)))+str(p)
    under_number = '0'*(6-len((str(j+1))))+str(j+1)
    print(top_number + under_number)
# Judge status: Accepted
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
a=sorted(lmp(),reverse=True)
a.append(0)
i=0
ans=[]
while i<n:
    if a[i]==a[i+1]:
        ans.append(a[i])
        i+=1
    i+=1
ans.append(0)
ans.append(0)
print(ans[0]*ans[1])
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 13 18:45:47 2020

@author: kawati
"""

N = int(input())

MAX = 10**18
ans = 1
a = list(map(int, input().split())) #mapでintにしつつinputで取得

for x in a:
    if x == 0:
        print(0)
        exit(0)


for x in a:
    ans *= x
    if ans > MAX:
        print(-1)
        exit(0)
        
        #exit(0)
print(ans)
# Judge status: Accepted
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
first=a.pop(0)
ans=0
for i in range(n):
  if first+a[i]-b[i] <= 0:
    ans+=first+a[i]
    first=0
  elif first-b[i]>=0:
    ans+=b[i]
    first=a[i]
  else:
    ans+=b[i]
    first=a[i]-(b[i]-first)
print(ans)
# Judge status: Wrong Answer
import math
a,b,c=[int(i) for i in input().split()]
e=math.floor(a/c)
if(e<=b):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
l,r,d=map(int,input().split())
if l%d==0 and r%d==0:
    print(r//d-l//d+1)
else:
    print(r//d-l//d)
# Judge status: Wrong Answer
sx,sy,tx,ty = map(int,input().split())

dx=tx-sx
dy=ty-sy

s="U"*dy+"R"*dx+"D"*dy+"L"*(dx+1)+"U"*(dy+1)+"R"*(dx+1)+"D"+"R"+"D"*(dy+1)+"L"*(dx+1)

print(s)
# Judge status: Accepted
from decimal import Decimal
import math
a, b, c = map(int, input().split())

A = Decimal(str(a))**Decimal('0.5')
B = Decimal(str(b))**Decimal('0.5')
C = Decimal(str(c))**Decimal('0.5')
if A + B < C:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
from collections import Counter


w = input().strip()
c = Counter(list(w))

result = True
for i in c.values():
    if i % 2 == 1:
        result = False
        break

if result:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import random

d = int(input())  # 365
c = list(map(int, input().split()))

# 最低限のポイントを確認？
for i in range(d):
    s = list(map(int, input().split()))
    print(random.randint(1, 26))
# Judge status: Accepted
inp=list(map(int,input().split()))
x=inp[0]
y=inp[1]
if (x+y)%3!=0:
  print (0)
else:
  flag=0
  z=(x+y)//3
  n=x-z
  m=y-z
  if m<0 or n<0:
    print (0)
    flag=1
  else:
    arr=[1]
    v=pow(10,9)+7
    for i in range(1,m+n+1):
      arr.append((arr[-1]*i)%v)
    a=arr[m+n]
    b=(arr[m]*arr[n])%v
    print ((a*pow(b,v-2,v))%v)
# Judge status: Accepted
from math import *
a,b,c,d = map(int,input().split())
f =(c*d)//gcd(c,d)
r = f
rock = 2
compteur= (b//f)-(a//f)
if a%f==0:
  compteur +=1
div1 = ((b//c)-(a//c))
div2 = ((b//d)-(a//d))
if  a%c == 0:
  div1+=1
if a%d ==0:
  div2 +=1
roger =(div1+div2)-compteur
mm = (b-a)+1
print(mm-roger)
# Judge status: Accepted
import math
n=int(input())
l=[int(input()) for i in range(5)]

mini=min(l)
ans=4+math.ceil(n/mini)
print(ans)
# Judge status: Accepted
import re
a, b = input().split()
s = input()

if re.fullmatch("\d{%s}-\d{%s}" % (a, b), s):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import heapq
n,m = map(int,input().split())
B = [[] for _ in range(m)]
for i in range(n):
    a,b = map(int,input().split())
    if 1 <= a <= m:
        B[a-1].append(b)
task = []
heapq.heapify(task)
ans = 0
for i in range(m):
    for t in B[i]:
        heapq.heappush(task,-t)
    if task:
        ans += heapq.heappop(task)
print(-ans)
# Judge status: Wrong Answer
s = input()
n = len(s)
ans = "No"

sa = s[:(n-1)//2]
sb = s[((n+3)//2)-1:]

if sa == sa[::-1] and sb == sb[::-1]:
    ans = "Yes"

print(ans)
# Judge status: Accepted
N, M = map(int, input().split())
R = [0] * N
for _ in range(M):
    a, b = map(int, input().split())
    R[a-1] += 1
    R[b-1] += 1
for r in R: print(r)
# Judge status: Wrong Answer
a, b = map(int, input().split())
i = 1
c = 2
while i <= a:
    i += c
    c += 1
print(b-i)
# Judge status: Wrong Answer
n, m, x, y = map(int, input().split())
a, b = [list(map(int, input().split())) for i in range(2)]

for i in range(x + 1, y + 1):
  if all(j < i for j in a) and all(k >= i for k in b):
    print("No War")
else:
  print("War")
# Judge status: Accepted
x,y=map(int,input().split())

if x%y==0:
  print(-1)
else:
  print(x)
# Judge status: Accepted
def main():
    n = int(input())
    money = sorted([6 ** i for i in range(7)] + [9 ** i for i in range(1, 6)], reverse=True)
    dp = [0] + [1000000] * n
    for i in range(1, n + 1):
        dp[i] = min(dp[i], *[dp[i - j] + 1 for j in money if i - j >= 0])
    print(dp[n])

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
a,b,c = list(map(int, input().split()))
print((a + b) / 2)
# Judge status: Wrong Answer
Q, H, S, D = map(int, input().split())
N = int(input())

A = min(Q*4, H*2, S)
if N % 2 == 0:
    print(min(A*N, D*N//2))
else:
    if N == 1:
        print(A)
    else:
        print(min(A*N, D*(N+1)//2, D*(N//2)+A))
# Judge status: Wrong Answer
n = int(input())
min_s = []
max_s = []
for i in range(n):
    a, b = map(int, input().split())
    min_s.append(a)
    max_s.append(b)

min_s.sort()
max_s.sort()
if n % 2 == 0:
    min_med = (min_s[n//2-1] + min_s[n//2])/2
    max_med = (max_s[n//2-1] + max_s[n//2])/2
    print(int(max_med-min_med)*2+1)

else:
    min_med = min_s[(n+1)//2-1]
    max_med = max_s[(n+1)//2-1]
    print(int((max_med-min_med)+1))
# Judge status: Accepted
from collections import Counter
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n=int(input())
l=["".join(sorted(input())) for i in range(n)]
c=Counter(l).most_common()
ans=0
for i in range(len(c)):
    if c[i][1]>=2:
        ans+=combinations_count(c[i][1],2)
print(ans)
# Judge status: Accepted
n,k = map(int,input().split()) #入力
a = list(map(int,input().split())) #使用不可の数字
b = {0,1,2,3,4,5,6,7,8,9}-set(a) #使用可能な数字の集合
while set([int(i) for i in list(str(n))])-b !=set() : # 使用可能な数字のみでなければ
    n += 1
print(n)
# Judge status: Accepted
import sys

K = int(input())
A, B = map(int, input().split())
ans = 0
while True:
    ans += K
    if A <= ans <= B:
        print("OK")
        sys.exit()
    elif ans > B:
        print("NG")
        sys.exit()
    else:
        pass
# Judge status: Wrong Answer
import math
a,b,h,m=map(int,input().split())

t=60*h+m

d=(t%60)*b
e=0.5*(h*60)

f=abs(d-e)

if f>=180:
    f=f-180

theta=math.radians(f)
print(math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(theta)))
# Judge status: Accepted
X = int(input())
k = list(range(0,100000))
k5 = []
for i in k:
    k5.append(i**5)
for j in k5:
    if X + j in k5:
        print(k[k5.index(X+j)],k[k5.index(j)])
        exit()
    elif X - j in k5:
        print(k[k5.index(X-j)],-k[k5.index(j)])
        exit()
# Judge status: Accepted
N,M = map(int,input().split())
ans = 0

if 2*N >= M:
  ans = M//2
else:
  ans += N
  C = M-2*N
  ans += C//4
  
print(ans)
# Judge status: Wrong Answer
def main():
    n = int(input())
    a_lst1 = list(map(int, input().split()))
    a_lst2 = list(map(int, input().split()))
    candies_lst = []

    tmp = 1
    while tmp <= 7:
        a1_tmp = a_lst1[:tmp]
        a2_tmp = a_lst2[tmp-1:]
        a1 = sum(a1_tmp)
        a2 = sum(a2_tmp)

        tmp += 1
        candies = a1 + a2
        candies_lst.append(candies)

    maximum = max(candies_lst)
    print(maximum)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
def main():
    X,N  = map(int, input().split()) 
    c=list(map(int, input().split()))
    XY = [True]*(101)

    for i in range(len(c)):
        XY[c[i]]=False

    ans = 0
    sa = 10000

    for i in range(1,101):
        if XY[i]:
            if sa > abs(X-i) :
                ans = i
                sa = abs(X-i)
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
S = list(input())

S.sort()

for i in range(len(S)-1):
    if ord(S[i+1]) - ord(S[i]) == 0 or ord(S[i+1]) - ord(S[i]) == 1:
        pass
    else:
        res = ord(S[i]) + 1
        print(chr(res))
        exit()

res = ord(S[-1]) + 1

if S[0] == 'a' and S[-1] == 'z':
    print('None')
elif S[0] != 'a':
    print('a')
else:
    print(chr(res))
# Judge status: Accepted
s,y=(input() for i in range(2))
ans="{"*len(s);pa=ans
for i in range(len(s)-len(y)+1):
  for j in range(len(y)):
    if s[i+j]!='?' and s[i+j]!=y[j]:break
  else:ans=min(ans,s[:i].replace("?","a")+y+s[i+len(y):].replace("?","a"))
if pa==ans:print("UNRESTORABLE")
  
else:print(ans)
# Judge status: Accepted
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

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

if __name__ == '__main__':
    a = [int(i) for i in input().split()]

    if (a[0] < a[1] and a[0]<a[2] and a[2] <a[1]) or (a[0] > a[1] and a[0]>a[2] and a[2] >a[1]):
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
temp=sum(a)
temp1=a[0]
ans=abs(temp-temp1*2)
for i in range(1,n-1):
  temp1=temp1+a[i]
  ans=min(ans,abs(temp-temp1*2))
print(ans)
# Judge status: Accepted
def main():
    numbers = list(map(int, input().split(" ")))
    numbers.sort(reverse=True)
    print(numbers[0] * 10 + numbers[1] + numbers[2])


if __name__ == '__main__':
    main()
# Judge status: Accepted
s = input()
a = [int(c) for c in s]

print(sum(a))
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))
el = []
for i in a:
    if i % 2 == 0:
        el.append(i)

for i in range(len(el)):
    if el[i] % 3 == 0 or el[i] % 5 == 0:
        el[i] = True
    else:
        el[i] = False

if el.count(False):
    print("DENIED") 
else:
    print("APPROVED")
# Judge status: Wrong Answer
n,m=map(int,input().split())
xy=[list(map(int,input().split())) for i in range(m)]
num=[1]*n
red=[False]*n
red[1]=True
for i in range(m):
  x,y=xy[i]
  if red[x-1]:
    red[y-1]=True
  num[x-1]=num[x-1]-1
  num[y-1]=num[y-1]+1
  if num[x-1]==0:
    red[x-1]=False
print(red.count(True))
# Judge status: Wrong Answer
N,M = map(int,input().split())

tmp = M - N*2
print(tmp//4+N)
# Judge status: Accepted
def calc(a):
  ret = 0
  while a != 0:
    ret += a % 10
    a //= 10
  return ret

def resolve():
  n = int(input())
  ans = 1000000000
  for a in range(1, n):
    b = n - a
    ans = min(ans, calc(a) + calc(b))
  print(ans)
  return

if __name__ == "__main__":
  resolve()
# Judge status: Accepted
N = int(input())


hash = {}
end = int(N ** (1/2))
for i in range(2, end + 1):
    while N % i == 0:
        hash[i] = hash.get(i, 0) + 1
        N = N // i
if N != 1:
        hash[i] = hash.get(i, 0) + 1


count = 1
res = 0
for i in hash.values():
    count = 1
    while i >= count:
        res += 1
        i -= count
        count += 1

print(res)
# Judge status: Accepted
N, = list(map(int, input().split()))


def gen(path, maxOrd):
    if len(path) == N:
        print("".join(chr(ord("a") + x) for x in path))
    else:
        for x in range(maxOrd + 2):
            path.append(x)
            gen(path, max(maxOrd, x))
            path.pop()


gen([], -1)
# Judge status: Wrong Answer
S = input()
len = len(S)
ans = 0
for i in range(len//2):
	if S[i] != S[len-i-2]:
		ans = ans + 1
print(ans)
# Judge status: Accepted
R = float(input())
l = 3.14159*R*2
print(l)
# Judge status: Accepted
n, m = map(int, input().split())
ab = set()
bn = set()
for i in range(m):
    a, b = map(int, input().split())
    if a==1: ab.add(b)
    if b==n: bn.add(a)
print('POSSIBLE' if bn&ab else 'IMPOSSIBLE')
# Judge status: Wrong Answer
N = int(input())
if N < 1000:
    print('ABC' + str(N // 100) + str(N // 10)[-1] + str(N // 1)[-1])
else:
    print('ABD' + str((N - 999) // 100) + str((N - 999) // 10)[-1] + str((N - 999) // 1)[-1])
# Judge status: Wrong Answer
N,K = map(int,input().split())
sunuke_dict = {}
for i in range(K):
    d = int(input())
    sunuke_dict[d] = list(map(int,input().split()))
ans = [1]*(N+1)
ans[0]  =0
for v in sunuke_dict.values():
    for v_ in v:
        if ans[v_] == 1:
            ans[v_] =0
print(sum(ans))
# Judge status: Wrong Answer
L = int(input())

ans = 0
for i in range(1, 1001):
  for j in range(1, 1001):
    if i + j > 1000 or i + j > L:
      break
    for k in range(1, 1001):
      if i + j + k > 1000 or i + j + k > L:
        break
      ans = max(ans, i * j * k)
print(ans)
# Judge status: Wrong Answer
n,m=map(int,input().split())
lst=[int(input()) for i in range(m)]
DP=[0]*(n+1)
temp=0
DP[0]=1
for i in range(1, n+1):
  if i==1 and i not in lst:
    DP[i]=1
  elif i==1 and i in lst:
    DP[i]=0
  elif i in lst:
    DP[i]=0
  else:
    DP[i]=(DP[i-1]+DP[i-2])%(10*9+7)
print(DP[n])
# Judge status: Accepted
N,K,S = map(int,input().split())
t = [999999999]*N
for i in range(K):
    t[i] = S
print(*t)
# Judge status: Wrong Answer
n = int(input())
ns = list(map(int, input().split()))
count = 0
for i in range(n):
    if ns[i] != sorted(ns)[i]:
        count += 1
if count <= 2:
    print('YES')
else:
    print('No')
# Judge status: Accepted
def myAnswer(N:int,B:list) -> int:
   total = B[0]+B[-1]
   pre = B.pop(0)
   for b in B:
      total += min(pre,b)
      pre = b
   return total

def modelAnswer():
   tmp=1
def main():
   N = int(input())
   B = list(map(int,input().split()))

   print(myAnswer(N,B[:]))

if __name__ == '__main__':
   main()
# Judge status: Accepted
N = int(input())

ans = 0
n = 0
for i in range(N):
    a = int(input())
    if(a != 0 and n > 0):
        ans += 1
        a -= 1
        n = 0
    elif(a == 0):
        n = 0
        
    if(a > 1):
        ans += a//2
        n = a%2
    
print(ans)
# Judge status: Accepted
a, b, k = map(int, input().split())
n = b - a + 1

if n > k * 2:
  for i in range(k):
    print(a+i)
  for i in range(k):
    print(b-(k-i-1))
else:
  for i in range(a, b+1):
    print(i)
# Judge status: Accepted

N, A, B = list(map(int,input().split()))
S = input()
AB = A+B

pass_student = 0
B_pass_student = 0
for i in range(N):
  if S[i] == "a" and pass_student < AB:
    print("Yes")
    pass_student +=1
  elif S[i] =="b" and pass_student < AB and B_pass_student < B:
    print("Yes")
    pass_student += 1
    B_pass_student += 1
  else:
    print("No")
# Judge status: Accepted
a,b=map(int, input().split())

xa=int(12.5*a-0.0001)+1
xb=10*b
x=max(xa,xb)
ra=int(x*0.08)
rb=int(x*0.1)

if ra==a and rb==b:
    print(x)
else:
    print(-1)
# Judge status: Wrong Answer
a,b,c,d=map(int,input().split())
x=[]
x.append(max(a,b)*max(c,d))
x.append(max(a,b)*min(c,d))
x.append(min(a,b)*max(c,d))
x.append(min(a,b)*max(c,d))
print(max(x))
# Judge status: Wrong Answer
n = int(input())
ans = 0
for i in range(1,n+1):
    y = (n // i)
    ans += (1 + y)*y*i/2
print(ans)
# Judge status: Accepted
x,y=list(map(int,input().split()))
if x>=0 and y>0:
    if x>y:
        print(2+x-y)
    else:
        print(y-x)
elif x<0 and y>0:
    print(abs(x+y)+1)
elif x>=0 and y<0:
    print(abs(x+y)+1)
elif x<0 and y<0:
    if x>y:
        print(2+x-y)
    else:
        print(y-x)
elif y==0:
    if x<=0:
        print(abs(x))
    else:
        print(x+1)
# Judge status: Accepted
import math
A, B, H, M = map(int, input().split())

a = (H / 6 + M / 360) * math.pi
ax = math.cos(a) * A
ay = math.sin(a) * A

b = M / 30 * math.pi
bx = math.cos(b) * B 
by = math.sin(b) * B

print(math.sqrt((ax - bx)**2 + (ay - by)**2))
# Judge status: Wrong Answer
n = int(input())

ans = 0
ans1 = [0] * n
for i in range(1,n):
  for j in range(1,n):
    for k in range(1,n):
      ans = i**2 + j**2 +k**2 + i*j + j*k + k*i
      for l in range(6,n-1):
        if(l+1 == ans):
          ans1[l] += 1
for i in range(n):
  print(ans1[i])
# Judge status: Accepted
a,b,c = map(int, input().split())
if a + b == c or a + c == b or b + c == a:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n=int(input())
w=list(map(int,input().split()))
sum=sum(w)
sum1=0
for i in range(len(w)):
	sum-=w[i]*2  #総和をw[0]から引いて
	if sum<0:  #マイナスになったらグループの分かれ目
		sum1=sum+w[i]
		if abs(sum)<=abs(sum1):  #分かれ目のw[i]で比較
			print(sum)
		else:
			print(sum1)
# Judge status: Accepted

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    from collections import defaultdict
    dd = defaultdict(int)
    
    for _ in range(N):
        s=list(input())
        s.sort()
        s=''.join(map(str, s))
        dd[s]+=1
        
    ans=0
    
    for k,v in dd.items():
        ans+=(v*(v-1))//2
        
    print(ans)

main()
# Judge status: Accepted
N,M=map(int,input().split())
A=[input()for i in range(N)]
B=[input()for i in range(M)]
b=''
a='no'
for i in range(M):
    b+=B[i]
for i in range(N-M+1):
    if B[0]in A[i] :
        for j in range(N-M+1):
            a=''
            for k in range(M):
                a+=A[i+k][j:j+M]
            if a==b:
                print("Yes")
                exit()
print("No")
# Judge status: Accepted
a = [list(map(int,input().split())) for _ in range(3)]

n = int(input())

ans = "No"

for i in range(n):
	b = int(input())
	for j in range(3):
		for k in range(3):
			if a[j][k] == b:
				a[j][k] = -1

for i in range(3):
	if a[i][0] == a[i][1] == a[i][2] == -1:ans = "Yes"
	if a[0][i] == a[1][i] == a[2][i] == -1:ans = "Yes"
if a[0][0] == a[1][1] == a[2][2] == -1:ans = "Yes"
if a[0][2] == a[1][1] == a[0][2] == -1:ans = "Yes"
print(ans)
# Judge status: Wrong Answer
import sys

n=int(input())

if n%2 ==0:
    print(-1)
    sys.exit()

Ai=[7%n]
for i in range(1,n+1):
    res=(Ai[i-1]*10 + 7)%n
    if res ==0:
        print(i+1)
        sys.exit()
    Ai.append(res)
print(-1)
# Judge status: Accepted
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
sa = [0]*n
wa = [0]*n

ans = 0
for i in range(n):
    sa[i] = a[i]-i
    wa[i] = a[i]+i
b = Counter(wa)
c = Counter(sa)
    
for i in b:
    ans += b[i]*c[-i]
            
print(ans)
# Judge status: Wrong Answer
s = input()
s=s[::-1]
A=["dream","dreamer","erase","eraser"]
for i in range(len(A)):
    A[i]=A[i][::-1]

i=0
ans="Yes"
while True:
    if len(s)==i:
        break
    elif s[i:i+5]==A[0]:
        i+=5
    elif s[i:i+7]==A[1]:
        i+=7
    elif s[i:i+5]==A[2]:
        i+=5
    elif s[i:i+6]==A[3]:
        i+=6
    else:
        ans="No"
        break
print(ans)
# Judge status: Wrong Answer
n=int(input())

print(n//2*n)
# Judge status: Accepted
n = int(input())

ss = []
mins = 'a'*100
for _ in range(n):
  s = str(''.join(sorted(input())))
  ss.append(s)
  if len(mins) > len(s):
    mins = s
  
ans = ''
for w in mins:
  ok = True
  for i, s in enumerate(ss[:]):
    if w in s:
      wi = s.find(w)
      ss[i] = s[:wi] + s[wi+1:]
    else:
      ok = False
  if ok:
    ans += w
print(ans)
# Judge status: Accepted
A, B, K = map(int, input().split())
chk = 0
for x in range(min(A, B), 0, -1):
    if A % x == 0 and B % x == 0:
        chk += 1
    if chk == K:
        print(x)
        exit()
# Judge status: Accepted
c1=input()
c2=input()
if c1[0]==c2[2] and c1[1]==c2[1] and c1[2]==c2[0]:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
N = input()
ans = sum(int(c) for c in N)

for i in range(1,len(N)):
    t = sum(int(c) for c in N[:i]) - 1 + 9 * (len(N) - i)
    ans = max(ans, t)
print(ans)
# Judge status: Accepted
a = int(input())
b = int(input())
h = int(input())

area = (a + b)*h/2

print(int(area))
# Judge status: Wrong Answer
N = int(input())
A = [0]
A.extend(list(map(int, input().split())))

for i in range(N//2 + 1)[::-1]:
    wa = 0
    for j in range(2, N+1):
        if i * j > N:
            break
        wa += A[i*j]
    wa %= 2
    if A[i] != wa:
        A[i] = (A[i] + 1) % 2

A = A[1:]

print(A.count(1))
for i in A:
    if i == 1:
        print(i, end=' ')
# Judge status: Wrong Answer
import itertools
N, M, Q = map(int, input().split())
P = [[int(x) for x in input().split()] for _ in range(Q)]

li = [x for x in range(1, M+1)]
Com = itertools.combinations(li, N)

ans=0
for com in Com:
    reg=0
    for a,b,c,d in P:
        if com[b-1] - com[a-1] == c:
            reg += d
    ans = max(reg, ans)
print(ans)
# Judge status: Wrong Answer
H=int(input())
W=int(input())
N=int(input())

if W>H :
    k=int(N/W)+1
else:
    k=int(H/W)+1


print(k)
# Judge status: Accepted
n=int(input())
A=list(map(int,input().split()))
q=int(input())
dic={i+1:0 for i in range(10**5)}
for a in A:
  dic[a]+=1

s=sum(A)

for i in range(q):
  b,c=map(int,input().split())
  nom=dic[b]
  dic[c]+=nom
  dic[b]=0
  s+=nom*(c-b)
  print(s)
# Judge status: Accepted
import sys
N, M = map(int, input().split())
l = []
for i in range(M):
  l.append(list(map(int, input().split())))

ans = -1

if N == 1:
  start, stop = 0, 10  
elif N == 2:
  start, stop = 10, 100
else:
  start, stop = 100, 1000

for i in range(start, stop):
  temp = list(str(i))
  for j in range(N):
    temp[j] = int(temp[j])
  flag = 1
  for j in range(M):
    if temp[l[j][0]-1] != l[j][1]:
      flag = 0
  if flag == 1:
    ans = i
    break
print(ans)
# Judge status: Accepted
#abc163  Sum of Large Numbers
n, k = map(int, input().split())
def Funmy(a, N):
    return (8+3*a*N + 3*N -2*a*a)*a/6

total =Funmy(n+1,n) -Funmy(k-1,n)
m = 7 + 10**9
output = (total)%m
print(int(output))
# Judge status: Accepted
X = int(input())

if X == 3 or X == 5 or X == 7:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
N, K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N - K):
    if A[i] < A[i + K]: print("Yes")
    else: print("No")
# Judge status: Accepted
def yakusuu(n):
    cnt = 0
    for i in range(1,n+1):
        if n % i == 0:
            cnt += 1
    return cnt
        

N = int(input())
ans = 0
for i in range(1,N+1):
    if i % 2 != 0:
        if yakusuu(i) == 8:
            ans += 1
print(ans)
# Judge status: Wrong Answer
# シンプル貪欲

d=int(input())
c= list(map(int, input().split()))
D= [list(map(int, input().split())) for i in range(d)]

ans=[0]*d
for i in range(d):
    x=D[i].index(max(D[i]))
    ans[i]=x
for i in range(d):
    print(ans[i])