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:
S = input()

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

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

Submission status: Wrong Answer

Solution code:
s = input()
s = s[::-1]
t = ['maerd', 'remaerd', 'esare', 'resare']
l = 0
for i in range(2):
    w1 = s[4*i+l:4*i+5+l]
    w2 = s[4*i+l:4*i+6+l]
    w3 = s[4*i+l:4*i+7+l]
    if w1 == t[0] or w1 == t[2]:
        l = 1
        continue
    elif w2 == t[3]:
        l = 2
        continue
    elif w3 == t[1]:
        l = 3
        continue
    else:
        print('NO')
        exit()
print('YES')

Submission status: Wrong Answer

Solution code:
s = input()
s = s[::-1]
t = ['maerd', 'remaerd', 'esare', 'resare']
l = len(s)
for i in range(2):
    l = 0
    if i != 0:
        l = 1
    w1 = s[4*i+l:4*i+5+l]
    w2 = s[4*i+l:4*i+6+l]
    w3 = s[4*i+l:4*i+7+l]
    if w1 == t[0] or w1 == t[2]:
        break
    elif w2 == t[3]:
        break
    elif w3 == t[1]:
        break
    else:
        print('NO')
        exit()
print('YES')

Submission status: Wrong Answer

Solution code:
s = input()
s = s[::-1]
t = ['maerd', 'remaerd', 'esare', 'resare']
l = len(s)
for i in range(2):
    l = 0
    if i != 0:
        l = 1
    w1 = s[4*i+l:4*i+5+l]
    w2 = s[4*i+l:4*i+6+l]
    if w1 == t[0] or w1 == t[2]:
        break
    elif w2 == t[1] or w2 == t[3]:
        break
    else:
        print('NO')
        exit()
print('YES')

Submission status: Wrong Answer

Solution code:
l=['dream','dreamer','erase','eraser']
s=input().rstrip()
x=list(s)
if len(x)<5:
    print("NO")
elif len(x)==5:
    if ''.join(x)=='dream' or ''.join(x)=='erase':
        print("YES")
    else:
        print("NO")
elif len(x)==6:
    print("NO")
elif len(x)==7:
    if ''.join(x)==l[1] or ''.join(x)==l[3]:
        print("YES")
    else:
        print("NO")
else:
    i=0;
    G=0;
    while(i<len(x)):
        #print(i)
        if x[i]=='d':
            t=x[i:i+5]
            p=x[i:i+7]
            if ''.join(p)=='dreamer':
                if (i+7)<len(x) and x[i+7]!='a':
                    i+=7;
                elif (i+7+1)>len(x):
                    break;
                elif (i+7)<len(x) and x[i+7]=='a':
                    i+=5;
            elif ''.join(t)=='dream':
                i+=5;
            else:
                G=1;
                break;
        elif x[i]=='e':
            t=x[i:i+5]
            p=x[i:i+7]
            if ''.join(p)==l[3]:
                i+=7;
            elif ''.join(t)==l[2]:
                i+=5;
            else:
                G=1;
                break;
        else:
            G=1;
            break;
    if G==0:
        print("YES")
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
i = 0
T = {"dream":0,"dreamer":0,"erase":0,"eraser":0}

ans = 'YES'
while i < len(S) - 1:
    if S[i:i+6] in T :
        i += 6
    elif S[i:i+5] in T:
        i += 5
    else:
        ans = 'NO'
        break
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
i = 0
T = {"dream":0,"dreamer":0,"erase":0,"eraser":0}

ans = 'YES'
while i <= len(S) - 1:
    if S[i:i+6] in T :
        i += 6
    elif S[i:i+5] in T:
        i += 5
    else:
        ans = 'NO'
        break
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
i = 0
T = {"dream":0,"dreamer":0,"erase":0,"eraser":0}

ans = 'YES'
while i <= len(S) - 1:
    if S[i:i+6] in T :
        i += 6
    elif S[i:i+5] in T:
        i += 5
    else:
        ans = 'NO'
        break
if i == len(S):
    print(ans)
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
i = 0
T = {"dream":0,"dreamer":0,"erase":0,"eraser":0}

ans = 'YES'
while i <= len(S) - 1:
    if S[i:i+6] in T :
        i += 6
    elif S[i:i+5] in T:
        i += 5
    else:
        ans = 'NO'
        break
print(i)
if i == len(S):
    print(ans)
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
i = 0
T = {"dream":0,"dreamer":0,"erase":0,"eraser":0}

ans = 'YES'
while i <= len(S) - 1:
    if S[i:i+5] in T :
        i += 5
    elif S[i:i+6] in T:
        i += 6
    else:
        ans = 'NO'
        break
if i == len(S):
    print(ans)
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
i = 0
T = {"dream":0,"dreamer":0,"erase":0,"eraser":0}

ans = 'YES'
while i <= len(S) - 1:
    if S[i:i+4] in T :
        i += 4
    elif S[i:i+5] in T:
        i += 5
    else:
        ans = 'NO'
        break
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()

while True:
  if S[-5:] == 'dream':
    S = S[:-5]
    continue
  elif S[:-7] == 'dreamer':
    S = S[:-7]
    continue
  elif S[-5:] == 'erase':
    S = S[:-5]
    continue
  elif S[-6:] == 'eraser':
    S = S[:-6]
    continue
  break

answer = 'YES' if not S else 'NO'
print(answer)

Submission status: Wrong Answer

Solution code:
S = input()

while True:
  if S[-5:] == 'dream':
    S = S[:-5]
    continue
  elif S[:-7] == 'dreamer':
    S = S[:-7]
    continue
  elif S[-5:] == 'erase':
    S = S[:-5]
    continue
  elif S[-7:] == 'eraser':
    S = S[:-7]
    continue
  break

answer = 'YES' if not S else 'NO'
print(answer)

Submission status: Wrong Answer

Solution code:
s=list(input())
t=[list("dream"), list("erase")]
n=len(s)
i=0
while i<=n-1:
	if i>n-5:
		print("NO")
		break
	if s[i:i+5] in t:
		i+=5
		if i>n-1:
			print("YES")
			break
		elif s[i]=="r":
			i+=1
	else:
		print("NO")
		break
else:
	print("YES")

Submission status: Wrong Answer

Solution code:
#ABC49-C
S=input()
divide=["dream","dreamer","erase","eraser"]
for i in range(4): #４つの文字群を反転
    divide[i]=divide[i][::-1]
len_s=len(S)
S=S[::-1]

check=0
i=0
a=[]
while check==0:
    if i==len_s: #ぴったり終わりの時
        a.append(1)
        break
    if len_s-i <5: #残りが５文字未満のとき、これ以上見つけられない。
        check=1
        a.append(2)
        break
    if S[i:i+5] == divide[0]:
        i=i+5
        a.append(3)
        continue
    if S[i:i+5] == divide[2]:
        i=i+5
        a.append(4)
        continue
    if len_s-i <7: #残りが７文字未満のとき、これ以上見つけられない。
        check=1
        a.append(5)
        break
    if S[i:i+7] == divide[1]:
        i=i+7
        a.append(6)
        continue
    if S[i:i+7] == divide[3]:
        i=i+7
        a.append(7)
        continue
    check=1 #上のif文どれにも引っかからなかったとき。

if check==0:
    print("YES")
else:
    print("NO")
#print(a)

Submission status: Wrong Answer

Solution code:
#ABC49-C
S=input()
divide=["dream","dreamer","erase","eraser"]
for i in range(4): #４つの文字群を反転
    divide[i]=divide[i][::-1]
len_s=len(S)
S=S[::-1]

check=0
i=0
a=[]
while check==0:
    if i==len_s: #ぴったり終わりの時
        a.append(1)
        break
    if len_s-i <5: #残りが５文字未満のとき、これ以上見つけられない。
        check=1
        a.append(2)
        break
    if S[i:i+5] == divide[0]:
        i=i+5
        a.append(3)
        continue
    if S[i:i+5] == divide[2]:
        i=i+5
        a.append(4)
        continue
    if len_s-i <7: #残りが７文字未満のとき、これ以上見つけられない。
        check=1
        a.append(5)
        break
    if S[i:i+7] == divide[1]:
        i=i+7
        a.append(6)
        continue
    if S[i:i+7] == divide[3]:
        i=i+7
        a.append(7)
        continue
    check=1 #上のif文どれにも引っかからなかったとき。

if check==0:
    print("YES")
else:
    print("NO")
print(a)

Submission status: Wrong Answer

Solution code:
#ABC49-C
S=input()
divide=["dream","dreamer","erase","eraser"]
for i in range(4): #４つの文字群を反転
    divide[i]=divide[i][::-1]
len_s=len(S)
S=S[::-1]

check=0
i=0
a=[]
while check==0:
    if i==len_s: #ぴったり終わりの時
        a.append(1)
        break
    if len_s-i <5: #残りが５文字未満のとき、これ以上見つけられない。
        check=1
        a.append(2)
        break
    if S[i:i+5] == divide[0]:
        i=i+5
        a.append(3)
        continue
    if S[i:i+5] == divide[2]:
        i=i+5
        a.append(4)
        continue
    if len_s-i <7: #残りが７文字未満のとき、これ以上見つけられない。
        check=1
        a.append(5)
        break
    if S[i:i+7] == divide[1]:
        i=i+7
        a.append(6)
        continue
    if S[i:i+7] == divide[3]:
        i=i+7
        a.append(7)
        continue


if check==0:
    print("YES")
else:
    print("NO")
print(a)

Submission status: Wrong Answer

Solution code:
def resolve():
    s = input()

    deviders = ['resare', 'esare', 'remaerd', 'maerd']

    s = s[::-1]
    i = 0

    if len(s) < 5:
        print('NO')
        return

    while i < len(s):

        flag = False

        for devider in deviders:

            if s[i:i+5] == devider[0:5]:

                i += len(devider)
                flag = True
                break

        if not flag:
            print('NO')
            return

    print('YES')

    return
  
resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    s = input()

    deviders = ['resare', 'esare', 'remaerd', 'maerd']

    s = s[::-1]
    i = 0

    while i < len(s):

        flag = False

        for devider in deviders:

            if s[i:i+5] == devider[0:5]:

                i += len(devider)
                flag = True
                break

        if not flag:
            print('NO')
            return

    print('YES')

    return
  
resolve()

Submission status: Wrong Answer

Solution code:
# デジャヴュ。ゼロから始めるのではなく消していってゼロにする
s = input()
flag = True
while len(s) > 0:
    if len(s) <= 4:
        flag = False
    elif len(s) >= 7:
        if s[-7:] == "dreamer":
            s = s[:-7]
        else:
            flag = False
    elif len(s) >= 6:
        if s[-6:] == "eraser":
            s = s[:-6]
        else:
            flag = False
    elif len(s) >= 5:
        if s[-5:] == "dream" or s[-5:] == "erase":
            s = s[:-5]
        else:
            flag = False
    else:
        flag = False

    if flag == False:
        break

print("YES" if flag else "NO")

Submission status: Wrong Answer

Solution code:
S=input()
S=S.replace("dreameraser","")
S=S.replace("dreamerase","")
S=S.replace("dreamer","")
S=S.replace("eraser","")
S=S.replace("dream","")
S=S.replace("erase","")

if S:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
import sys
S = str(input())
while S != '':
    if (S[:5] == 'dream' and S[5:11] == 'eraser') or (S[:5] == 'dream' and S[5: 10] == 'erase') or (S[:5] == 'dream' and S[5:] == ''):
        S = S[5:]
    elif S[:5] == 'erase' and S[5] != 'r':
        S = S[5:]
    elif S[:6] == 'eraser':
        S = S[6:]
    elif S[:7] == 'dreamer':
        S = S[7:]
    else:
        print('NO')
        sys.exit()
        break
        
print('YES')

Submission status: Wrong Answer

Solution code:
import sys
S = str(input())
while S != '':
    print(S)
    if (S[:5] == 'dream' and S[5:11] == 'eraser') or (S[:5] == 'dream' and S[5: 10] == 'erase') or (S[:5] == 'dream' and S[5:] == ''):
        S = S[5:]
    elif S[:5] == 'erase' and S[5] != 'r':
        S = S[5:]
    elif S[:6] == 'eraser':
        S = S[6:]
    elif S[:7] == 'dreamer':
        S = S[7:]
    else:
        print('NO')
        sys.exit()
        break
        
print('YES')

Submission status: Wrong Answer

Solution code:
import re  # 正規表現, findall('正規表現', 文字列), search('正規表現', 文字列)
import sys # プログラム終了：sys.exit()
# sys.setrecursionlimit(10**6) # 再帰呼び出しの上限を上げる

def i_input(): return int(input())
def s_input(): return map(int,input().split())
def l_input(): return list(map(int, input().split()))
# 文字列のまま受け取りたいときはinput()

def main():
    S = input()

    while 1:
        if S == '':
            print('YES')
            sys.exit()
        elif re.search('dreamer*', S):
            S = S[:-7]
        elif re.search('eraser*', S):
            S = S[:-6]
        elif re.search('dream*', S):
            S = S[:-5]
        elif re.search('erase*', S):
            S = S[:-5]
        else:
            print('NO')
            sys.exit()

    print('YES')

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-



def solve(s):
  while len(s) > 0:
    if len(s) >= 7 and s[:7]=="dreamer":
      s = s[7:]
    elif len(s) >= 6 and s[:6]=="eraser":
      s = s[6:]
    elif len(s) >= 5 and s[:5] in ["dream","erase"]:
      s = s[5:]
    else:
      return "NO"
  return "YES"


if __name__ == "__main__":
  S = str(input())
  print(solve(S))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-



def solve(s):
  while len(s) > 0:
    if len(s) >= 7 and s[-7:]=="dreamer":
      s = s[:-7]
    elif len(s) >= 6 and s[-6:]=="eraser":
      s = s[:-6]
    elif len(s) >= 5 and (s[-5:]=="dream" or s[-5:]=="erase"):
      s = s[:-5]
    else:
      return "NO"

    return "YES"


if __name__ == "__main__":
  S = str(input())
  print(solve(S))

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

S = str(input())

def check(T):

    adds = ["dream","dreamer","erase","eraser"]
    q = copy.deepcopy(adds)
    while len(q) > 0:
        t = q.pop()
        if t == S:
            return 1
        for add in adds:
            if S[len(t):len(t+add)+1] == add:
                q.append(t+add)

# print(check(""))
if check(""):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

S = str(input())

def check(T,S):
    if T == S:
        return 1
    adds = ["dream","dreamer","erase","eraser"]
    for i,add in enumerate(adds):
        if S[len(T):len(T)+len(add)] == add:
            return check(T+add,S)


if check("",S):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
T_list = ['dream', 'eraser', 'dreamer', 'erase']
S = S[::-1]
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:
        break
if len(S) > 0:
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
S = input()
T_list = ['dream', 'eraser', 'dreamer', 'erase']
S = S[::-1]
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]:
        S = S[7:]
    else:
        break
if len(S) > 0:
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()

while(1):
    if len(s) == 0:
        print('YES')
        break
    if s.startswith('dreamer') :
        s = s[7:]
    elif s.startswith('eraser'):
        s = s[6:]
    elif s.startswith('dream') or s.startswith('erase'):
        s = s[5:]
    else:
        print('NO')
        break

Submission status: Wrong Answer

Solution code:
S = input()

S = S[::-1]

word_list1 = "dream"
word_list2 = "dreamer"
word_list3 = "erase"
word_list4 = "eraser"

s = ""
ans = ""

word_list = [word_list1[::-1],word_list2[::-1],word_list3[::-1],word_list4[::-1]]

for i in S:
    s += i
    if s in word_list:
        ans += s
        s = ""

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

Submission status: Wrong Answer

Solution code:
import re

s = input()[::-1]
while len(s) > 0:
    for ptn in ['dream', 'dreamer', 'erase', 'eraser']:
        if re.match(ptn[::-1], s) is not None:
            s = s[len(ptn):]
            break
    else:
        break
print('Yes' if len(s) == 0 else 'No')

Submission status: Wrong Answer

Solution code:
import re
import sys
sys.setrecursionlimit(100000)

s = input()[::-1]

while len(s) > 0:
    for ptn in ['dream', 'dreamer', 'erase', 'eraser']:
        if re.match(ptn[::-1], s) is not None:
            s = s.replace(ptn[::-1], '')
            break
    else:
        break
print('YES' if len(s) == 0 else 'NO')

Submission status: Wrong Answer

Solution code:
import re

s = input()[::-1]

while len(s) > 0:
    for ptn in ['dream', 'dreamer', 'erase', 'eraser']:
        if re.match(ptn[::-1], s) is not None:
            s = s.replace(ptn[::-1], '')
            break
    else:
        break
print('YES' if len(s) == 0 else 'NO')

Submission status: Wrong Answer

Solution code:
import re

s = input()[::-1]

while len(s) > 0:
    for ptn in ['dream', 'dreamer', 'erase', 'eraser']:
        if re.match(ptn[::-1], s) is not None:
            s = s.replace(ptn[::-1], '')
            break
    else:
        break
print('Yes' if len(s) == 0 else 'No')

Submission status: Wrong Answer

Solution code:

def main():
    S = input()
    while True:
        if S[:7] == "dreamer":
            S = S[7:]
        elif S[:6] == "eraser":
            S = S[6:]
        elif S[:5] == "erase":
            S = S[5:]
        elif S[:5] == "dream":
            S = S[5:]
        else:
            print("NO")
            break

        if len(S) == 0:
            print("YES")
            break


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:

def main():
    S = input()
    while True:
        if S[:5] == "dream":
            S = S[5:]
        elif S[:6] == "eraser":
            S = S[6:]
        elif S[:5] == "erase":
            S = S[5:]
        elif S[:6] == "dreamer":
            S = S[7:]
        else:
            print("NO")
            break

        if len(S) == 0:
            print("YES")
            break


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:

def main():
    S = input()
    while True:
        if S[:5] == "dream":
            S = S[5:]
        elif S[:6] == "eraser":
            S = S[6:]
        elif S[:5] == "erase":
            S = S[5:]
        elif S[:6] == "dreamer":
            S = S[7:]
        else:
            print("No")
            break

        if len(S) == 0:
            print("Yes")
            break


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
S = input()


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

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

Submission status: Wrong Answer

Solution code:
from sys import stdin, stdout
S = stdin.readline()
S = S.replace("eraser", "")
S = S.replace("erase", "")
S = S.replace("dreamer", "")
S = S.replace("dream", "")
print("YES") if not S else print("NO")

Submission status: Wrong Answer

Solution code:
from sys import stdin, stdout
S = stdin.readline()
S = S.replace("erase", "")
S = S.replace("eraser", "")
S = S.replace("dream", "")
S = S.replace("dreamer", "")
print("YES") if not S else print("NO")

Submission status: Wrong Answer

Solution code:
s = input()[::-1]
words = [w[::-1] for w in ['dream', 'dreamer', 'erase', 'eraser']]

can = 'Yes'
while s:
    match_any = False
    for w in words:
        if s.startswith(w):
            s = s.replace(w, '', 1)
            match_any = True
            break
    if not match_any:
        can = 'No'
        break
print(can)

Submission status: Wrong Answer

Solution code:
s = input()[::-1]
words = [w[::-1] for w in ['dream', 'dreamer', 'erase', 'eraser']]

can = 'Yes'
while True:
    match_any = False
    for w in words:
        if s.startswith(w):
            s = s.replace(w, '', 1)
            match_any = True
            break
    if not match_any:
        can = 'No'
        break
    break
print(can)

Submission status: Wrong Answer

Solution code:
from sys import stdin, stdout
S = stdin.readline()
S = S.replace("dream", "1")
S = S.replace("erase", "2")
S = S.replace("1er", "")
S = S.replace("2r", "")
S = S.replace("1", "")
S = S.replace("2", "")
print("YES") if not S else print("NO")

Submission status: Wrong Answer

Solution code:
from sys import stdin, stdout
S = stdin.readline()
S = S.replace("dream", "1")
S = S.replace("erase", "2")
S = S.replace("1er", "")
S = S.replace("2r", "")
S = S.replace("1", "")
S = S.replace("2", "")
print(S)
print("YES") if not S else print("NO")

Submission status: Wrong Answer

Solution code:
from sys import stdin, stdout
S = stdin.readline()
S = S.replace("dreamer", "")
S = S.replace("eraser", "")
S = S.replace("dream", "")
S = S.replace("erase", "")
print("YES") if not S else print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
T = ""
slist = ["maerd", "remaerd", "esare", "resare"]
S = S[::-1]
while True:
    if S[len(T) : len(T) + 5] == "maerd":
        T += "maerd"
    elif S[len(T) : len(T) + 6] == "remaerd":
        T += "remaerd"
    elif S[len(T) : len(T) + 5] == "esare":
        T += "esare"
    elif S[len(T) : len(T) + 6] == "resare":
        T += "resare"
    else:
        print("NO")
        break
    if S == T:
        print("YES")
        break

Submission status: Wrong Answer

Solution code:
S = input()

result = S.replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "")

if result:
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
s = input()
t = ''
while s:
    a = ''
    for i in ['eraser', 'erase', 'dreamer', 'dream']:
        if s.startswith(i) : a = i; break
    if a == '' : print('NO');exit()
    s = s[len(a):]
print('YES')

Submission status: Wrong Answer

Solution code:
s = input()
t = ''
while s:
    a = ''
    for i in ['dream', 'erase', 'eraser', 'dreamer']:
        if s.startswith(i) : a = i; break
    if a == '' : print('NO');exit()
    s = s[len(a):]
print('YES')

Submission status: Wrong Answer

Solution code:
s = input()
t = ''
while s:
    a = ''
    for i in ['dream', 'erase', 'eraser', 'dreamer']:
        if s.startswith(i) : a = i
    if a == '' : print('NO');exit()
    s = s[len(a):]
print('YES')

Submission status: Wrong Answer

Solution code:
s = input()
t = ''
while s:
    a = ''
    for i in ['dreamer', 'eraser', 'erase', 'dream']:
        if s.startswith(i) : a = i
    if a == '' : print('NO');exit()
    s = s[len(a):]
print('YES')

Submission status: Wrong Answer

Solution code:
s = input()
t = ''
while s:
    a = ''
    for i in ['dream', 'erase', 'dreamer', 'eraser']:
        if s.startswith(i) : a = i
    if a == '' : print('NO');exit()
    s = s[len(a):]
print('YES')

Submission status: Wrong Answer

Solution code:
s = input()
t = ''
while s:
    a = ''
    for i in ['dream', 'dreamer', 'erase', 'eraser']:
        if s.startswith(i) : a = i
    if a == '' : print('NO');exit()
    s = s[len(a):]
print('YES')

Submission status: Wrong Answer

Solution code:
word_list = ("dream", "dreamer", "erase", "eraser")

s = input()

i = 0
while i < len(s):
    if s[i:i+5] == word_list[0] or s[i:i+5] == word_list[2]:
        i += 5
    elif s[i:i+6] == word_list[1] or s[i:i+6] == word_list[3]:
        i += 6
    else:
        print("NO")
        exit()

print("YES")

Submission status: Wrong Answer

Solution code:
s = input()

str = ''
str_old = ''
added = []
f_cnt = 0


while(str != s):
  if s.startswith(str + 'dream') and not(f_cnt == 1 and 'dream' in added[:-2]):
    str_old = str
    added.append('dream')
    str = str + 'dream'
    f_cnt = 0
  elif s.startswith(str + 'dreamer') and not(f_cnt == 1 and 'dreamer' in added[:-2]):
    str_old = str
    added.append('dreamer')
    str = str + 'dreamer'
    f_cnt = 0
  elif s.startswith(str + 'erase') and not(f_cnt == 1 and 'erase' in added[:-2]):
    str_old = str
    added.append('erase')
    str = str + 'erase'
    f_cnt = 0
  elif s.startswith(str + 'eraser') and not(f_cnt == 1 and 'eraser' in added[:-2]):
    str_old = str
    added.append('eraser')
    str = str + 'eraser'
    f_cnt = 0
  else:
    f_cnt += 1
    str = str_old

    if f_cnt == 2:
      print('NO')
      exit()

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()
s = s.replace('erase','')
s = s.replace('eraser','')
s = s.replace('dreamer','')
s = s.replace('dream','')
if s:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

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=list(input())
divide=["dream","erase","eraser","dreamer"]
def dfs(n):
        if n==len(s):
                return True
        for i in divide:
                tmp="".join(s[n:n+len(i)-1])
                if n+len(i)<=len(s) and tmp==i:
                        if dfs(n+len(i)):
                                return True
        return False
print("YES") if dfs(0) else print("NO")

Submission status: Wrong Answer

Solution code:
s=list(input()[::-1])
divide=["dream","dreamer","erase","eraser"]
divided=[]
for i  in range(len(divide)):
    divided.append(divide[i][::-1])
can=True
for i in range(len(s)):
    can2=False
    for j in range(4):
        d=divided[j]
        if "".join(s[i:i+len(d)+1])==d:
            can2=True
            i+=len(d)
    if not can2:
        can=False
        break
print("YES") if can else print("NO")

Submission status: Wrong Answer

Solution code:
moji = ["dream", "dreamer", "erase", "eraser"]

for i in range(len(moji)):
  moji[i] = moji[i][::-1]

s = input()[::-1]

for i in range(len(moji)):
  s = s.replace(moji[i], "")

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

Submission status: Wrong Answer

Solution code:
moji = ["dream", "dreamer", "erase", "eraser"]

for i in range(len(moji)):
  moji[i] = moji[i][::-1]

s = input()[::-1]

for i in range(len(moji)):
  s = s.replace(moji[i], "")

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

Submission status: Wrong Answer

Solution code:
s=list(input()[::-1])
divide=["dream","dreamer","erase","eraser"]
divided=[]
for i  in range(len(divide)):
    divided.append(divide[i][::-1])
can=True
for i in range(len(s)):
    can2=False
    for j in range(4):
        d=divided[j]
        if s[i:i+len(d)+1]==d:
            can2=True
            i+=len(d)
    if not can2:
        can=False
        break
print("YES") if can else print("NO")

Submission status: Wrong Answer

Solution code:
import sys

S = input()
chars = ['dreamer', 'eraser', 'dream', 'erase']


while 1:
    end_flag = 1
    for char in chars:
        if ( S.rfind(char) == len(S) - len(char)):
            S = S[:len(S) - len(char)]
            end_flag = 0

            if S == '':
                print('YES')
                sys.exit()
    if end_flag ==1:
            print('NO')
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

S = input()
chars = ['dreamer', 'eraser', 'dream', 'erase']


while 1:
    end_flag = 1
    for char in chars:
        if ( S.find(char) == len(S) - len(char)):
            S = S[:len(S) - len(char)]
            end_flag = 0

            if S == '':
                print('YES')
                sys.exit()
    if end_flag ==1:
            print('NO')
            sys.exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a=['dream','dreamer','erase','eraser']
def check(c):
    if c=='':
        return True
    size=len(c)
    n=len(c)
    while n<len(c):
        tmp=n
        for i in a:
            if size>=len(i) and c[n-len(i):n]==i:
                n+=len(i)
        if tmp==n:
            return False
    return True

print('YES' if check(input()) else 'NO')

Submission status: Wrong Answer

Solution code:
S = list(input())
while len(S) > 0:
    print(S)
    if ''.join(S[-5:]) == 'dream' or ''.join(S[-5:]) == 'erase':
        S = S[:-5]
    elif ''.join(S[-6:]) == 'eraser':
        S = S[:-6]
    elif ''.join(S[-7:]) == 'dreamer':
        S = S[-7:]
    else:
        print('NO')
        quit()
print('YES')

Submission status: Wrong Answer

Solution code:
import re
print("YES" if re.match("^(dream(er)|erase(r))+$",input()) else "NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()

while s:
    if s[:7] == "eraser":
        s = s[7:]
    elif s[:5] == "erase":
        s = s[5:]
    elif s[:5] == "dream":
        if s[5:8] == "era":
            s = s[5:]
        elif s[5:7] == "er":
            s = s[7:]
        else:
            s = s[5:]
    else:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def del_r(s):
    success = False
    for de in de_list:
        tmp = s.rfind(de)
        if tmp == len(s) - len(de) and tmp > -1:
            s = s[::-1].replace(de[::-1], '')[::-1]
            success = True
    return success, s

roop_flg = True
while(roop_flg):
    roop_flg, S = del_r(S)

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

Submission status: Wrong Answer

Solution code:
import re

S = input()
de_list = ['dream', 'dreamer', 'erase', 'eraser']

def del_r(s):
    success = False
    for de in de_list:
        tmp = s.rfind(de)
        if tmp >= len(s) - len(de) and tmp > -1:
            s = s[::-1].replace(de[::-1], '')[::-1]
            success = True
    return success, s

roop_flg = True
while(roop_flg):
    roop_flg, S = del_r(S)

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