Problem:


Score : 300 points

Problem Statement

You are given a string S consisting of lowercase English letters.
Another string T is initially empty.
Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:

Append one of the following at the end of T: dream, dreamer, erase and eraser.

Constraints

1≦|S|≦10^5

S consists of lowercase English letters.

Input

The input is given from Standard Input in the following format:

S

Output

If it is possible to obtain S = T, print YES. Otherwise, print NO.

Sample Input 1

erasedream

Sample Output 1

YES

Append erase and dream at the end of T in this order, to obtain S = T.

Sample Input 2

dreameraser

Sample Output 2

YES

Append dream and eraser at the end of T in this order, to obtain S = T.

Sample Input 3

dreamerer

Sample Output 3

NO



Sample input:
erasedream


Sample output:
YES

Submission status: Wrong Answer

Solution code:
def main():
    s = input()
    s = s.replace("eraser","").replace("erase","").replace("dremamer","").replace("dream","")

    if s == "":
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import re

S = input()
t = re.findall('dreamer|dream|eraser|erase', S)
T = ''.join(t)
if S == T:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import re

S = input()
t = re.findall('dream|dremer|eraser|erase', S)
T = ''.join(t)
if S == T:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import re

S = input()
t = re.findall('dream|dremer|eraser|erase', S)
print(t)
T = ''.join(t)
if S == T:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
S = str(input())

S = S.replace('dreamerase', '5')
S = S.replace('eraser' , '2')
S = S.replace('dreamer' ,'1')

S = S.replace('erase','3')
S = S.replace('dream','4')

try:
	S = int(S)
	print('YES')
	
except:
	print('NO')

Submission status: Wrong Answer

Solution code:
S = str(input())

S = S.replace('eraser' , '2')
S = S.replace('dreamer' ,'1')

S = S.replace('erase','3')
S = S.replace('dream','4')

try:
	S = int(S)
	print('YES')
	
except:
	print('NO')

Submission status: Wrong Answer

Solution code:
# ABC049 C - 白昼夢 / Daydream
S = input()
S = S.replace('eraser','A').replace('dreamer','B').replace('dream','C').replace('erase','D')

E = set()

for s in S:
    E.add(s)

ans = 'YES'
for e in E:
    if not e in ('A','B','C','D'):
        ans = 'NO'
        break
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()

while True:
    if len(S) == 0:
        print("Yes")
        break
    elif S[-5:] == 'dream' or S[-5:] == 'erase':
        S = S[:-5]
    elif S[-6:] == 'eraser':
        S = S[:-6]
    elif S[-7:] == 'dreamer':
        S = S[:-7]
    else:
        print("No")
        break

Submission status: Wrong Answer

Solution code:
S=list(input())
l=0
while l!=len(S):
  l=len(S)
  if S[-1]=='m' and S[-2]=='a' and S[-3]=='e' and S[-4]=='r' and S[-5]=='d':
    del S[-5:]
  if len(S)==0:
    break
  if S[-1]=='e' and S[-2]=='s' and S[-3]=='a' and S[-4]=='r' and S[-5]=='e':
    del S[-5:]
  if len(S)==0:
    break
  if S[-1]=='r' and S[-2]=='e' and S[-3]=='s' and S[-4]=='a' and S[-5]=='r' and S[-6]=='e':
    del S[-6:]
  if len(S)==0:
    break
  if S[-1]=='r' and S[-2]=='e' and S[-3]=='m' and S[-4]=='a' and S[-5]=='e' and S[-6]=='r' and S[-7]=='d':
    del S[-7:]
  if len(S)==0:
    break

if len(S)==0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
S = input().replace('eraser', '').replace('erase', '').replace('dereamer', '').replace('dream', '')
if S == "":print('YES')
else :print('NO')

Submission status: Wrong Answer

Solution code:
s = input()

s1 = "".join(s.split('dreameraser'))

s2 = "".join(s1.split('dreamerase'))

s3 = "".join(s2.split('dreamer'))

s4 = "".join(s3.split('dream'))

s5 = "".join(s4.split('eraser'))

s6 = "".join(s5.split('erase'))

if s6 == '':
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()

s1 = "".join(s.split('dreameraser'))

s2 = "".join(s1.split('dreamerase'))

s3 = "".join(s2.split('dreamer'))

s4 = "".join(s3.split('dreame'))

s5 = "".join(s4.split('eraser'))

s6 = "".join(s5.split('erase'))

if s6 == '':
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
c = ["dream","dreamer","erase","eraser"]

S = S[::-1]
c = [cc[::-1] for cc in c]

i=0
while i < len(c):
    if S[:len(c[i])] == c[i]:
        S = S[len(c[i]):]
        i = 0
        continue
    i += 1

if S=="":
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
S = input()
c = ["dream","dreamer","erase","eraser"]

S = S[::-1]
c = [cc[::-1] for cc in c]

i=0
while i < len(c):
    if S.startswith(c[i]):
        S = S[len(c[i]):]
        i = 0
        continue
    i = -~i

if S=="":
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
S = input()
c = ["dream","dreamer","erase","eraser"]

S = S[::-1]
c = [cc[::-1] for cc in c]

i=0
while i < len(c):
    if S.startswith(c[i]):
        S = S[len(c[i]):]
        i = 0
        continue
    i = -~i

print("NYoe s"[S==""::2])

Submission status: Wrong Answer

Solution code:
words = ['dream', 'dreamer' ,'erase' ,'eraser']
t = ''
s = input()

s = s[::-1]
words = [word[::-1] for word in words]

start=0
for i in range(1, len(s)+1):
  if s[start:i] in words:
    t+=s[start:i]
    start=i
    
if s==t:
  print('True')
else:
  print('False')

Submission status: Wrong Answer

Solution code:
S = [input()]
ans = 'NO'
while S:
    S_new = []
    for s in S:
        if s[:5]=='dream'  : S_new.append(s[5:])
        if s[:7]=='dreamer': S_new.append(s[7:])
        if s[:5]=='erase'  : S_new.append(s[5:])
        if s[:7]=='eraser' : S_new.append(s[7:])
    S = S_new
    if '' in S:
        ans = 'YES'
        break

print(ans)

Submission status: Wrong Answer

Solution code:
l=list(input())
a=[list('dream'),list('erase')]
b=[list('eraser')]
c=[list('dreamer')]
n=len(l)
r=0
while n<=4:
    f=0
    if n>=7:
        if l[len(l)-5:] in a:
            l[len(l)-5:]=[]
            n-=5
            f+=1
        if l[len(l)-6:] in b:
            l[len(l)-6:]=[]
            n-=6
            f+=1
        if l[len(l)-7:] in c:
            l[len(l)-7:]=[]
            n-=7
            f+=1
    elif n>=6:
        if l[len(l)-5:] in a:
            l[len(l)-5:]=[]
            n-=5
            f+=1
        if l[len(l)-6:] in b:
            l[len(l)-6:]=[]
            n-=6
            f+=1
    elif n>=5:
        if l[len(l)-5:] in a:
            l[len(l)-5:]=[]
            n-=5
            f+=1
    if f==0:
        r=1
        break
if r==1 or n>0:
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
l=list(input())
a=[list('dream'),list('erase')]
b=[list('dreamer'),list('eraser')]
n=len(l)
r=0
while n<=4:
    f=0
    if n>=6:
        if l[len(l)-5:] in a:
            l[len(l)-5:]=[]
            n-=5
            f+=1
        if l[len(l)-6:] in b:
            l[len(l)-6:]=[]
            n-=6
            f+=1
    elif n>=5:
        if l[len(l)-5:] in a:
            l[len(l)-5:]=[]
            n-=5
            f+=1
    if f==0:
        r=1
        break
if r==1 or n>0:
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
import sys

s = input()
s = s[::-1]
words = ['maerd', 'remaerd', 'esare', 'resare']
can = True

while can:
    for word in words:
        can = False
        if s.startswith(word):
            s = s[len(word):]
            can = True

if len(s) == 0:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
if input().replace("dream","").replace("dreamer","").replace("erase","").replace("eraser",""):
  print("NO")
else:
  print("YES")

Submission status: Wrong Answer

Solution code:
if input().replace("dream","").replace("dreamer","").replace("erase","").replace("eraser",""):
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
S = list(input())
tmp = ''
L = len(S)
S = S[-1:-L-1:-1]
Kouho = ['maerd','remared','esare','resare']
ans = 0
for i in range(L):
    tmp += str(S[i])
    if tmp in Kouho:
        ans += len(tmp)
        tmp = ''
if ans == L:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
S = list(input())
tmp = ''
L = len(S)
S.append('0')
S.append('0')
ans = 0
for i in range(L):
    tmp += str(S[i])
    if tmp=='dream':
        if tmp+str(S[i+1])+str(S[i+2])=='dreamer':
            ans += len(tmp)+2
            tmp = ''
            i+=2
        else:
            ans += len(tmp)
            tmp = ''
    if tmp == 'erase':
        if tmp+str(S[i+1])=='eraser':
            ans += len(tmp)+1
            tmp  = ''
            i+=1
        else:
            ans += len(tmp)
            tmp = ''
if ans == L:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
S = list(input())
tmp = ''
L = len(S)
S.append('0')
S.append('0')
ans = 0
for i in range(L):
    tmp += str(S[i])
    if tmp=='dream':
        if tmp+str(S[i+1])+str(S[i+2])=='dreamer':
            ans += len(tmp)+2
            tmp = ''
            i+=2
        else:
            ans += len(tmp)
            tmp = ''
    if tmp == 'erase':
        if tmp+str(S[i+1])=='eraser':
            ans += len(tmp)+1
            tmp  = ''
            i+=1
if ans == len(S):
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc049/tasks/arc065_a
s=input().replace("eraser", "").replace("erase","").replace("dreamer","").replace("dream","")
if s:
    print("NO")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
s=input()
i=len(s)-1
ans=True
while 3<=i:
    print(i)
    if s[i-7:i]=='dreamer':
        i-=7
    elif s[i-5:i]=='dream':
        i-=5
    elif s[i-6:i]=='eraser':
        i-=6
    elif s[i-5:i]=='erase':
        i-=5
    else:
        ans=False
        break
if ans:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s=input()
i=0
ans=True
while i<=len(s)-1:
    if s[i:i+7]=='dreamer':
        i+=7
    elif s[i:i+5]=='dream':
        i+=5
    elif s[i:i+6]=='eraser':
        i+=6
    elif s[i:i+5]=='erase':
        i+=5
    else:
        ans=False
        break
if ans:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s=input()
i=0
ans=True
while i<=len(s)-1:
    if s[i:i+7]=='dreamer':
        i+=7
    elif s[i:i+5]=='dream':
        i+=5
    elif s[i:i+6]=='eraser':
        i+=6
    elif s[i:i+5]=='erase':
        i+=5
    else:
        ans=False
        break
if ans:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
S=str(input()) 
while len(S)!=0:
  if S[0:7]=="dreamer":
    M=list(S)
    del M[0:7]
    S="".join(M)
  elif S[0:6]=="eraser":
    M=list(S)
    del M[0:6]
    S="".join(M)
  elif S[0:5]=="dream" or S[0:5]=="erase":
    M=list(S)
    del M[0:5]
    S="".join(M)
  else:
    print("NO")
    break
if len(S)==0:
  print("YES")

Submission status: Wrong Answer

Solution code:
S=str(input()) 
while len(S)!=0:
  if S[0:5]=="dream" or S[0:5]=="erase":
    M=list(S)
    del M[0:5]
    S="".join(M)
  elif S[0:7]=="dreamer":
    M=list(S)
    del M[0:7]
    S="".join(M)
  elif S[0:6]=="eraser":
    M=list(S)
    del M[0:6]
    S="".join(M)
  else:
    print("NO")
    break
if len(S)==0:
  print("YES")

Submission status: Wrong Answer

Solution code:
S=str(input()) 
while len(S)!=0:
  if S[0:5]=="dream" or S[0:5]=="erase":
    M=list(S)
    del M[0:5]
    S="".join(M)
  elif S[0:7]=="dreamer":
    M=list(S)
    del M[0:5]
    S="".join(M)
  elif S[0:6]=="eraser":
    M=list(S)
    del M[0:6]
    S="".join(M)
  else:
    print("NO")
    break
if len(S)==0:
  print("YES")

Submission status: Wrong Answer

Solution code:
s = input()
t = ''
add_list = ['dream', 'dreamer', 'erase', 'eraser']
cur = len(s)
for i in range(len(s)):
    if s[-1 - i:cur] in add_list:
        cur = i
if cur == len(s) - 1:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
t = ''
add_list = ['dream', 'dreamer', 'erase', 'eraser']
cur = len(s)
for i in range(len(s)):
    if s[-1 - i:cur] in add_list:
        cur = i
if cur == len(s) - 1:
    print('YES')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
s=input()
s=s.replace('dream','').replace('dreamer','').replace('erase','').replace('eraser','')
if s:print('NO')
else:print('YES')

Submission status: Wrong Answer

Solution code:
s = input()

for i in range(10 ** 5):
    if s[:5] == "dream":
        if s[:7] == "dreamer":
            s = s[7:]
        else:
            s = s[5:]
    elif s[:5] == "erase":
        if s[:6] == "eraser":
            s = s[6:]
        else:
            s = s[5:]
    else:
        if len(s) > 0:
            print("NO")
            break
        else:
            print("YES")
            break

Submission status: Wrong Answer

Solution code:
s = input()

# 先にeraser,erase を消さないとdreameraserでaserだけ残る
sub_s = s.replace('eraser', '')
sub_s = sub_s.replace('erase', '')
sub_s = sub_s.replace('dream', '')
sub_s = sub_s.replace('dreamer', '')

if len(sub_s) == 0:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
wordList =[ "eraser", "erase","dreamer", "dream"]
ansList = []
def ansFunc(s1, ansList):
    #ansCount = 0
    for w in wordList:
        #print(s1, w)
        if s1.startswith(w):
            s2 = s1.replace(w, "")
            if s2 == '':
                print("YES")
                ansList.append(1)
            else:
                ansFunc(s2, ansList)
ansFunc(s, ansList)
if len(ansList) ==0:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
wordList =["dreamer", "dream", "eraser", "erase"]
ansList = []
def ansFunc(s1, ansList):
    #ansCount = 0
    for w in wordList:
        #print(s1, w)
        if s1.startswith(w):
            s2 = s1.replace(w, "")
            if s2 == '':
                print("YES")
                ansList.append(1)
            else:
                ansFunc(s2, ansList)
ansFunc(s, ansList)
if len(ansList) ==0:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
wordList = ['dream', 'dreamer', 'erase', 'eraser']
ansList = []
def ansFunc(s1, ansList):
    #ansCount = 0
    for w in wordList:
        #print(s1, w)
        if s1.startswith(w):
            s2 = s1.replace(w, "")
            if s2 == '':
                print("YES")
                ansList.append(1)
            else:
                ansFunc(s2, ansList)
ansFunc(s, ansList)
if len(ansList) ==0:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
wordList = ['dream', 'dreamer', 'erase', 'eraser']
ansCount = 0
def ansFunc(s1, ansCount):
    for w in wordList:
        #print(s1, w)
        if s1.startswith(w):
            s2 = s1.replace(w, "")
            if s2 == '':
                print("YES")
                ansCount += 1
                exit()
            else:
                ansFunc(s2, ansCount)
aaa=ansFunc(s, ansCount)
print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
wordList = ['dream', 'dreamer', 'erase', 'eraser']
ansCount = 0
def ansFunc(s1):
    ansCount = 0
    for w in wordList:
        print(s1, w)
        if s1.startswith(w):
            s2 = s1.replace(w, "")
            print(s2)
            if s2 == '':
                print("YES")
                ansCount += 1
                exit()
            else:
                ansFunc(s2)
ansCount = ansFunc(s)
print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
wordList = ['dream', 'dreamer', 'erase', 'eraser']
ansCount = 0
def ansFunc(s1):
    for w in wordList:
        if s1.startswith(w):
            s1 = s1.replace(w, "")
            print(s1)
            if s1 == '':
                print("seikou")
                ansCount += 1
            else:
                ansFunc(s1)
        else:
            return
ansFlg = ansFunc(s)
if ansFlg != 0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
wordList = ['dream', 'dreamer', 'erase', 'eraser']
ansFlg = False
def ansFunc(s1, ansFlg):
    for w in wordList:
        if s1.startswith(w):
            s1 = s1.replace(w, "")
            print(s1)
            if s1 == '':
                ansFlg =True
                print("YES")
                exit()
            else:
                ansFunc(s1, ansFlg)
ansFunc(s, ansFlg)
print("NO")

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
n = len(s)
i = n
while i > n:
    if s[i-7:i] == 'dreamer' and i-7 >= 0:
        i -= 7
    elif s[i-6:i] == 'eraser' and i-6 >= 0:
        i -= 6
    elif s[i-5:i] == 'dream' and i-5 >= 0:
        i -= 5
    elif s[i-5:i] == 'erase' and i-5 >= 0:
        i -= 5
    else:
        print('NO')
        break
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
n = len(s)
i = 0
while i < n:
    if s[i:i+7] == 'dreamer':
        i += 7
    elif s[i:i+6] == 'eraser':
        i += 6
    elif s[i:i+5] == 'dream':
        i += 5
    elif s[i:i+5] == 'erase':
        i += 5
    else:
        print('NO')
        break
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
s = input()
s = s.replace('eraser', '')
s = s.replace('erase', '')
s = s.replace('dreamer', '')
s = s.replace('dream', '')
if s == '':
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
s = input()

t = ''

ans = 'NO'

if s.find('dream') != -1:
    if s.find('erase') != -1:
        ans = 'YES'

print(ans)

Submission status: Wrong Answer

Solution code:
s = str(input())

t = s.replace('eraser','').replace('erase','').replace('dreamer','').replace('dream','')
if s == ['']:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin
# import numpy as np
# import sys
# sys.setrecursionlimit(10**4)

def _li(): return list(map(int, stdin.readline().split()))
def _li_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def _lf(): return list(map(float, stdin.readline().split()))
def _ls(): return stdin.readline().split()
def _i(): return int(stdin.readline())
def _f(): return float(stdin.readline())
def _s(): return stdin.readline()[:-1]


S = _s()[::-1]

flag = True
while True:
    if S.startswith('res'):
        S = S[6:]
    elif S.startswith('es'):
        S = S[5:]
    elif S.startswith('rem'):
        S = S[7:]
    elif S.startswith('ma'):
        S = S[5:]
    else:
        flag = False
        break

    if len(S) == 0:
        break

if flag:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
S=input()

while True:
    if len(S)==0:
        print("Yes")
        break
    elif len(S)<5:
        print("No")
        break
    else:
        if S[-5:]=="dream" or S[-5:]=="erase":
            S=S[:-5]
        elif S[-7:]=="dreamer":
            S=S[:-7]
        elif S[-6:]=="eraser":
            S=S[:-6]
        else:
            print("No")
            break

Submission status: Wrong Answer

Solution code:
s = input().replace("eraser", "").replace("erace", "").replace("dreamer", "").replace("dream", "")
if len(s) > 0:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
s = input().replace("eraser", "").replace("erace", "").replace("dreamer", "").replace("dream", "")
if s:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
s=str(input())
words = ['dreamer','dream','eraser','erase']
for word in words:
  s=s.replace(word,'')
if len(s) == 0 :
  print('YES')
else :
  print('NO')

Submission status: Wrong Answer

Solution code:
s=input()
words=["dream", "dreamer", "erase", "eraser"]

for word in words:
  s=s.replace(word," ")
if len(s)==0:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
words=["dream", "dreamer", "erase", "eraser"]

for word in words:
  s=s.replace(word,"")
if len(s)==0:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
s=str(input())
words=["dream", "dreamer", "erase", "eraser"]

for word in words:
  s=s.replace(word,"")

if len(s)==0:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
s=str(input())
words=["dream", "dreamer", "erase", "eraser"]
N=max(len(words[0]),len(words[1]),len(words[2]),len(words[3]))
flag=0
while len(s)>0:
  pos0=s[-N:].rfind(words[0])
  pos1=s[-N:].rfind(words[1])
  pos2=s[-N:].rfind(words[2])
  pos3=s[-N:].rfind(words[3])
  m=max(pos0,pos1,pos2,pos3)
  if m==-1:
    flag=1
    print("NO")
    break
  else:
    pos=N-m
    s=s[:-pos]

if flag!=1:
  print("YES")

Submission status: Wrong Answer

Solution code:
S=input()
s=S[::-1]
Word = ['resare','remaerd','esare','maerd']
for i in Word:
  s=s.replace(i,'')
if len(s) == 0 :
  print('YES')
else :
  print('No')

Submission status: Wrong Answer

Solution code:
S=input()
s=S[::-1]
Word = ['maerd','remaerd','esare','resare']
for i in Word:
  s=s.replace(i,'')
if len(s) == 0 :
  print('YES')
else :
  print('No')

Submission status: Wrong Answer

Solution code:
S=input()
Word = ['eraser','erase','dreamer','dream']
for i in Word:
  S=S.replace(i,'')
if len(S) == 0 :
  print('Yes')
else :
  print('No')

Submission status: Wrong Answer

Solution code:
s = input()

if len(s.replace("dreameraser","").replace("dreamererase","").replace("dreamer", "").replace("eraser","").replace("dream","").replace("erase","")) :
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
s = input()

if len(s.replace("dreamer", "").replace("eraser","").replace("dream","").replace("erase","")) :
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
s = input()
l = ['eraser', 'dreamer', 'erase', 'dream']
for i in l:
    s = s.replace(i, '')
if len(s) == 0:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
S = S[::-1]
while len(S) != 0:
  num = len(S)
  if S.find('maerd') == 0:
    S = S.replace('maerd', '')
  if S.find('remaerd') == 0:
    S = S.replace('remaerd', '')
  if S.find('esare') == 0:
    S = S.replace('esare', '')
  if S.find('resare') == 0:
    S = S.replace('resare', '')
  if num == len(S):
    print('NO')
    exit(0)
print('YES')

Submission status: Wrong Answer

Solution code:
s = input()

tc = ['dreamer', 'dream', 'eraser', 'erase']
start = 0
out = True

while out:
  if start >= len(s):
    break
  laststart = start
  for i in tc:
    if s[start:start+len(i)] == i:
      if i == 'dreamer' and s[start+7:start+8] in ('a'):
        start += 5
      else:
        start += len(i)
      break
  if start == laststart:
    out = False

if out:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
s = list(input())
while s:
    if s[-1] == "m":
        del(s[-5:])
    elif s[-1] == "e":
        del(s[-5:])
    elif s[-3] == "m":
        del(s[-7:])
    elif s[-3] == "s":
        del(s[-6:])
    else:
        print("NO")
        break
    
    if len(s) == 0:
        print("YES")

Submission status: Wrong Answer

Solution code:
S=input()
W=["dream","dreamer","erase","eraser"]

ans="Yes"
while len(S)>0:
  if S.endswith(W[0]):
    S=S[:-len(W[0])]
  elif S.endswith(W[1]):
    S=S[:-len(W[1])]
  elif S.endswith(W[2]):
    S=S[:-len(W[2])]
  elif S.endswith(W[3]):
    S=S[:-len(W[3])]
  else:
    ans="No"
    break
    
print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
s=s.replace('eraser','')
s=s.replace('erase','')
s=s.replace('dreamer','')
s=s.replace('dream','')
print(s)
if s :
	print('NO')
else:
	print('YES')

Submission status: Wrong Answer

Solution code:
import re
print('Yes' if re.match('^(dream|dreamer|erase|eraser)+$',input()) else 'No')

Submission status: Wrong Answer

Solution code:
s=input()
s=s.replace('eraser','')
s=s.replace('dreamer','')
s=s.replace('erase','')
s=s.replace('dream','')
#print(s)
if s :
	print('NO')
else:
	print('YES')

Submission status: Wrong Answer

Solution code:
S = input()

a = ['dream','dreamer','erase','eraser']
for i,ch in enumerate(a):
  a[i] = ch[::-1]

S = S[::-1]

flag = True
while flag:
  if len(S)==0:
    ans  = 'Yes'
    flag = False
  elif S[:5] in a:
    S = S[5:]
  elif S[:6] in a:
    S = S[6:]
  elif S[:7] in a:
    S = S[7:]
  else:
    ans  = 'No'
    flag = False
  
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()

a = ['dream','dreamer','erase','eraser']
for i,ch in enumerate(a):
  a[i] = ch[::-1]

T = ''

S = S[::-1]

flag = True
while flag:
  if S[:5] in a:
    S = S[5:]
  elif S[:6] in a:
    S = S[6:]
  elif S[:7] in a:
    S = S[7:]
  elif len(S)==0:
    ans  = 'Yes'
    flag = False
  else:
    ans  = 'No'
    flag = False
  
print(ans)

Submission status: Wrong Answer

Solution code:
s = input().replace("dream","").replace("dreamer","").replace("erase","").replace("eraser","")
if s:
  print("NO")
else:
  print("YES")

Submission status: Wrong Answer

Solution code:
s = input().replace("dream","").replace("dreamer","").replace("erase","").replace("eraser","")
if len(s) == 0:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
s = S.replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")
if s == "":
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
S_input = str(input())
remove_str_taple = ("dream", "dreamer", "erase", "eraser")

target_str = S_input

while 1:
    if target_str.startswith(remove_str_taple):
        for word in remove_str_taple:
            target_str_after_remove = target_str[len(word):]
            if target_str_after_remove == "":
                print("YES")
                exit()
            elif target_str_after_remove.startswith(remove_str_taple):
                target_str = target_str[len(word):]
            else:
                print("NO")
                exit()
    else:
        print("NO")
        exit()

Submission status: Wrong Answer

Solution code:
S=input()

T=''
bi,i=0,6
while S!=T:
  if S[bi:i]=='dreamer':
    T=T+'dreamer'
    bi=i-1
    i+=7
  elif S[bi:i]=='eraser':
    T=T+'eraser'
    bi=i-1
    i+=7
  elif S[bi:i-1]=='erase':
    T=T+'erase'
    bi=i-1
    i+=5
  elif S[bi:i-1]=='dream':
    T=T+'dream'
    bi=i-1
    i+=5
  else:
    print('NO')
    exit()
print('YES')

Submission status: Wrong Answer

Solution code:
S=input()

S.replace('eraser','')
S.replace('erase','')
S.replace('dreamer','')
S.replace('dream','')

if len(S)==0:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5) 
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

s = ns()[::-1]
ans = "YES"

def func(spart):
    if spart[:5] == "maerd":
        if len(spart) == 5:
            return "YES"
        else:
            return func(spart[5:])
    elif spart[:7] == "remaerd":
        if len(spart) == 7:
            return "YES"
        else:
            return func(spart[7:])
    elif spart[:5] == "esare":
        if len(spart) == 5:
            return "YES"
        else:
            return func(spart[5:])
    elif spart[:6] == "resare":
        if len(spart) == 6:
            return "YES"
        else:
            return func(spart[6:])
    else:
        return "No"

print(func(s))

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

s = ns()[::-1]
ans = "YES"

def func(spart):
    if spart[:5] == "maerd":
        if len(spart) == 5:
            return "YES"
        else:
            return func(spart[5:])
    elif spart[:6] == "remaerd":
        if len(spart) == 6:
            return "YES"
        else:
            return func(spart[6:])
    elif spart[:5] == "esare":
        if len(spart) == 5:
            return "YES"
        else:
            return func(spart[5:])
    elif spart[:6] == "resare":
        if len(spart) == 6:
            return "YES"
        else:
            return func(spart[6:])
    else:
        return "No"

print(func(s))

Submission status: Wrong Answer

Solution code:
S = input()

words = ['dream','dreamer','erase','eraser']

damm = True

T = ''

while damm:
    damm = False
    for test in words:
        if S.endswith(test+T):
            T = test + T
            damm = True
            break
    if S == T:
        damm = True
        break

if damm:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
S = input()

while 'eraser' in S:
    S = S.replace('eraser','')

while 'erase' in S:
    S = S.replace('erase','')

while 'dreamer' in S:
    S = S.replace('dreamer','')

while 'dream' in S:
    S = S.replace('dream','')

if S == '':
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# sys.stdin.readline
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        S = input().rstrip()

        while len(S) > 0:
            if S[:5] == 'dream' or S[:5] == 'erase':
                S = S[5:]
            elif S[:6] == 'eraser':
                S = S[6:]
            elif S[:7] == 'dreamer':
                S = S[7:]
            else:
                print('NO')
                exit()
        print('YES')


# Run main
if __name__ == '__main__':
    AtCoder().main()

Submission status: Wrong Answer

Solution code:
if input().replace("dreamer","").replace("dream","").replace("eraser","").replace("erase","")=="":
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
if input().replace("dream","").replace("dreamer","").replace("erase","").replace("eraser","")=="":
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
word_list =['eraser', 'dreamer', 'dream', 'erase']

for i in range(3):
        S = S.replace(word_list[i], '')
    
if S == '':
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
word_list =['eraser', 'dreamer', 'dream', 'erase']

for i in word_list:
        S = S.replace(i, '')
if S == '':
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
word_list =['dream', 'dreamer', 'erase', 'eraser']

S = S[::-1]
word_list = [i[::-1]for i in word_list]

for i in word_list:
        S = S.replace(i, '')

if S == '':
    print('YES')
else:
    print('NO')