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:
line=str(input())
fine=line[::-1]
for i in range(250000):
    if fine[0:5]=='esare':
        fine=fine.lstrip('esare')
    elif fine[0:7]=="remaerd":
        fine=fine.lstrip('remaerd')
    elif fine[0:6]=='resare':
        fine=fine.lstrip('resare')
    elif fine[0:5]=="maerd":
        fine=fine.lstrip("maerd")
    else:
        break
    
if len(fine)==0:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
line=str(input())
fine=line[::-1]
while len(fine)>0:
    if fine[0:5]=='esare':
        fine=fine.lstrip('esare')
    elif fine[0:7]=="remaerd":
        fine=fine.lstrip('remaerd')
    elif fine[0:6]=='resare':
        fine=fine.lstrip('resare')
    elif fine[0:5]=="maerd":
        fine=fine.lstrip("maerd")
    else:
        break
    
if len(fine)==0:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
line=str(input())
#print(line)
fine=line[::-1]
#print(fine)
while len(fine)>0:
    if fine[0:5]=='erase':
        fine=fine.lstrip('erase')
    elif fine[0:6]=='resare':
        fine=fine.lstrip('resare')
    elif fine[0:7]=="remaerd":
        fine=fine.lstrip('remaerd')
    elif fine[0:5]=="maerd":
        fine=fine.lstrip("maerd")
    else:
        break
    
if len(fine)==0:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
line=str(input())
#print(line)
fine=line[::-1]
#print(fine)
while len(fine)>0:
    if fine[0:5]=='erase':
        fine=fine.lstrip('erase')
    elif fine[0:7]=="remaerd":
        fine=fine.lstrip('remaerd')
    elif fine[0:5]=="maerd":
        fine=fine.lstrip("maerd")
    elif fine[0:6]=='resare':
        fine=fine.lstrip('resare')
    else:
        break
    
if len(fine)==0:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
line=str(input())
#print(line)
fine=line[::-1]
#print(fine)
while len(fine)>0:
    if fine[0:7]=="remaerd":
        fine=fine.lstrip('remaerd')
    elif fine[0:5]=="maerd":
        fine=fine.lstrip("maerd")
    elif fine[0:6]=='resare':
        fine=fine.lstrip('resare')
    elif fine[0:5]=='erase':
        fine=fine.lstrip('erase')
    else:
        break
    
if len(fine)==0:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
s = input()
t = s
keywords = ['dreameraser', 'dreamerase', 'eraseraser', 'eraserase', 'eraser', 'dream', 'erase', 'dreamer', 'eraser']

for keyword in keywords:
  t = t.replace(keyword, '')

if t != '':
  t = s
  for keyword in list(reversed(keywords)):
    t = t.replace(keyword, '')

print('YES') if t == '' else print('NO')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
s = input()
t = s
# keywords = ['dreameraseraser', 'dreameraserase', 'dreameraser', 'dreamerase', 'eraseraser', 'eraserase',
#            'dream', 'dreamer', 'erase', 'eraser']
keywords = ['eraser', 'dream', 'erase', 'dreamer', 'eraser']

for keyword in keywords:
  t = t.replace(keyword, '')

if t != '':
  t = s
  for keyword in list(reversed(keywords)):
    t = t.replace(keyword, '')

print('YES') if t == '' else print('NO')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
s = input()
t = s
keywords = ['eraser', 'dream', 'erase', 'dreamer', 'eraser']

for keyword in keywords:
  t = t.replace(keyword, '')

if t != '':
  for keyword in list(reversed(keywords)):
    t = t.replace(keyword, '')

print('YES') if t == '' else print('NO')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
s = input()
t = s
keywords = ['dreameraseraser', 'dreameraserase', 'dreameraser', 'dreamerase', 'eraseraser', 'eraserase',
            'dream', 'dreamer', 'erase', 'eraser']

for keyword in keywords:
  t = t.replace(keyword, '')

print('YES') if t == '' else print('NO')

Submission status: Wrong Answer

Solution code:
words = input()
word_list = [i for i in words[::-1]]
ans_a = ["dreamer","eraser","dream","erase"]
ans_b = [j[::-1] for j in ans_a]

answer = "YES"
a = 0
b = 1
while True:
  if b > len(word_list):
    break
  else:
    now_word = "".join(word_list[a:b])
    if (now_word == ans_b[0])or(now_word == ans_b[1])or(now_word == ans_b[2])or(now_word == ans_b[3]): 
      answer = "YES"
      a = b
      break
    else:
      answer = "NO"
    b += 1

print(answer)

Submission status: Wrong Answer

Solution code:
words = input()
word_list = [i for i in words[::-1]]
ans_a = ["dreamer","eraser","dream","erase"]
ans_b = [j[::-1] for j in ans_a]

answer = "YES"
a = 0
b = 1
while True:
  if b > len(word_list):
    break
  else:
    now_word = "".join(word_list[a:b])
    if (now_word == ans_b[0])or(now_word == ans_b[1])or(now_word == ans_b[2])or(now_word == ans_b[3]): 
      answer = "YES"
      a = b
      break
    else:
      nswer = "NO"
    b += 1

print(answer)

Submission status: Wrong Answer

Solution code:
N = list(input())
n = len(N)
N.reverse()
ans = 0

i = 0

while i < n:
    if N[i] == 'm':
        if N[i+1]=='a' and N[i+2]=='e' and N[i+3]=='r' and N[i+4]=='d':
            i += 5
            continue
        else:
            ans = 1
            break

    elif N[i] == 'e':
        if N[i+1]=='s' and N[i+2]=='a' and N[i+3]=='r' and N[i+4]=='e':
            i += 5
            continue
        else:
            ans = 1
            break

    elif N[i] == 'r':
        if N[i+1]=='e' and N[i+2]=='m' and N[i+3]=='a' and N[i+4]=='e' and N[i+5]=='r'and N[i+6]=='d':
            i += 7
            continue
        else:
            ans = 1
            break

    elif N[i] == 'r':
        if N[i+1]=='e' and N[i+2]=='m':
            if N[i + 3] == 'a' and N[i + 4] == 'e' and N[i + 5] == 'r' and N[i + 6] == 'd':
                i += 7
                continue
            else:
                ans = 1
                break
        elif N[i+1]=='e' and N[i+2]=='s':
            if N[i + 3] == 's' and N[i + 4] == 'a' and N[i + 5] == 'r' and N[i + 6] == 'e':
                i += 7
                continue
            else:
                ans = 1
                break
        else:
            ans = 1
            break
    i += 1

if ans == 0:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
S = input()

S = S[::-1]

L = ['dream', 'dreamer', 'erase', 'eraser']
L = [l[::-1] for l in L]

can = True
ind = 0
S_max = len(S)

while can:
    
    # print(ind)
    if ind == S_max:
        break

    for l in L:
        if ind + len(l) > S_max:
            pass
        else:
    #        print(S[ind: ind+len(l)])
            if l == S[ind: ind+len(l)]:
                ind += len(l)
    #             print(1)
                break
    else:
    #     print(2)
        can = False

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

import itertools
s = input()
hantei_flg = 0
name_list = [ 'dream' ,'dreamer', 'erase', 'eraser' ]

for i in itertools.permutations(name_list):
    temp = ''
    for j in range(3):
        temp = temp +i[j]
        if(s == temp):
            hantei_flg = 1
            break
if(hantei_flg):
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()

s_2 = s[::-1]

t = []
count = 0

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

for i in range(10000):
    if count == len(s):
        break
    if s_2[count:count+5] in word_list:
        count += 5
        continue
    elif s_2[count:count+6] in word_list:
        count += 6
        continue
    else:
        print('NO')
        exit()


print('YES')

Submission status: Wrong Answer

Solution code:
s = input()

s_2 = s[::-1]



t = []
count = 0
# word_list = ['dream', 'dreamer', 'erase', 'eraser']
word_list = ['maerd', 'remaerd', 'esare', 'resare']

for i in range(10000):
    if count == len(s):
        break
    if s_2[count:count+5] in word_list:
        count += 5
        continue
    elif s_2[count:count+6] in word_list:
        count += 6
        continue
    else:
        print('No')
        exit()


print('Yes')

Submission status: Wrong Answer

Solution code:
#  S = input()[::-1]
#  S = "erasedream"[::-1]
S = "dreameraser"[::-1]
s1 = "dream"[::-1]
s2 = "dreamer"[::-1]
s3 = "erase"[::-1]
s4 = "eraser"[::-1]
index = 0
ret = False
while True:
    if S[index : index + len(s2) :] == s2:
        index += len(s2)
    elif S[index : index + len(s4) :] == s4:
        index += len(s4)
    elif S[index : index + len(s1) :] == s1 or S[index : index + len(s3) :] == s3:
        index += len(s1)
    else:
        break
    if index == len(S):
        ret = True
        break
print("YES" if ret else "NO")

Submission status: Wrong Answer

Solution code:
s = input()[::-1]
s = s.replace("maerd", "", 1)

while True:
    end_flg = False
    if s[:5] == "maerd":
        s = s.replace("maerd", "", 1)
        end_flg = True
    elif s[:5] == "esare":
        s = s.replace("esare", "", 1)
        end_flg = True
    elif s[:7] == "remaerd":
        s = s.replace("remaerd", "", 1)
        end_flg = True
    elif s[:6] == "resare":
        s = s.replace("resare", "", 1)
        end_flg = True    

    if end_flg == False:
        break
        
if s == "":
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
a = ['dreamer', 'dream', 'eraser', 'erase']
for i in range(4):
  s = s.replace(a[i], "")
print("YES" if s=="" else "NO")

Submission status: Wrong Answer

Solution code:
s = input()
a = ['dream', 'dreamer', 'erase', 'eraser']
for i in range(4):
  s = s.replace(a[i], "")
print("YES" if s=="" else "NO")

Submission status: Wrong Answer

Solution code:
s = input()
a = ['dream', 'dreamer', 'erase', 'eraser']
for _ in range(4):
  s = s.replace(a[_], "")
if s=="":
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
a = ['dream', 'dreamer', 'erase', 'eraser']
for _ in range(4):
  s.replace(a[_], "")
if s=="":
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
S = list(input())
re = ['dream','dreamer','erase','eraser']
devide = False

T = []

for l in range(len(S)):
    T.insert(0,S.pop(-1))
    if len(T) >= 5:
        if ''.join(T) in re:
            T = []
    if len(T) > 7:
        break

if T == []:
    devide = True

if devide == False:
    print('No')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
S = list(input())
re = ['dream','dreamer','erase','eraser']
devide = False

T = []

for l in range(len(S)):
    T.insert(0,S.pop(-1))
    print(T)
    if len(T) >= 5:
        if ''.join(T) in re:
            T = []
    if len(T) > 7:
        break

if T == []:
    devide = True

if devide == False:
    print('No')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
S = list(input())
re = ['dream','dreamer','erase','eraser']
devide = False

T = []

for l in range(len(S)):
    T.insert(0,S.pop(-1))
    if len(T) >= 5:
        if ''.join(T) in re:
            T = []
    if len(T) > 7:
        break
    if T == [] and S == []:
        devide = True

if devide == False:
    print('No')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
S = list(input())
re = ['dream','dreamer','erase','eraser']
devide = False

T = []

for l in range(len(S)):
    T.insert(0,S.pop(-1))
    if ''.join(T) in re:
        T = []
    if T == [] and S == []:
        devide = True

if devide == False:
    print('No')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
S = input()[::-1]
divide = [s[::-1] for s in ["dream", "dreamer", "erase", "eraser"]]

ret = True
i = 0
while i < len(S):
    can_divide = False
    for j in range(4):
        d = divide[j]
        d_len = len(d)
        if S[i:d_len] == d:
            can_divide = True
            i += d_len
    if not can_divide:
        ret = False
    break

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

Submission status: Wrong Answer

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

#整数の入力
S = input()

#置換
S1 = S.replace("dreamer", "")
S2 = S1.replace("eraser", "")
S3 = S2.replace("dream", "")
S4 = S3.replace("erase", "")

if len(S4) >= 1:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
import sys
s=input()
s=s[::-1]
l=list(["maerd","remaerd","esare","resare"])
i=0
ss=len(s)
while i < ss:
  ok=0
  for j in l:
    if s[i:len(j)] == j:
      ok=1
      i += len(j)
      break
  if ok == 0:
    print("NO")
    sys.exit()
print("YES")

Submission status: Wrong Answer

Solution code:
import sys
s=input()
s=s[::-1]
l=list(["maerd","remaerd","esare","resare"])
i=0
ss=len(s)
while i < ss:
  print(i)
  ok=0
  for j in l:
    print(j)
    if s[i:len(j)] == j:
      ok=1
      i += len(j)
      break
  if ok == 0:
    print("NO")
    sys.exit()
print("YES")

Submission status: Wrong Answer

Solution code:
s=list(input())
s.reverse()
judge=True
i=0
while i<=len(s)-5:
	box=[]
	for j in range(5):
		box+=s[i+j]
	if box==["m","a","e","r","d"] or box==["e","s","a","r","e"]:
		i+=5
	else:
		box+=s[i+5]+s[i+6]
		if box==["r","e","m","a","e","r","d"] or box==["r","e","s","a","r","e"]:
			i+=7
		else:
			judge=False
			break
if judge:
	print("YES")
else:
	print("NO")

Submission status: Wrong Answer

Solution code:
s=list(input())
s.reverse()
judge=True
i=0
while i<=len(s)-5:
	box=[]
	for j in range(5):
		box+=s[i+j]
	if box==["m","a","e","r","d"] or box==["e","s","a","r","e"]:
		print(box)
		i+=5
	else:
		box+=s[i+5]+s[i+6]
		print(box)
		if box==["r","e","m","a","e","r","d"] or box==["r","e","s","a","r","e"]:
			i+=7
		else:
			judge=False
			break
if judge:
	print("YES")
else:
	print("NO")

Submission status: Wrong Answer

Solution code:
S = str(input())

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

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

k = 0
suc = True
while k < len(S):
    suc2 = False
    for t in tlist:
        if S[0:len(t)] == t:
            suc2 = True
            k += len(t)
    if not suc2:
        suc = False
        break

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

Submission status: Wrong Answer

Solution code:
s=input()
i=0 #文字の判定
while i==0:
  if len(s)==0:
    print("YES")
    exit()

  if s[0:5]=="dream":
    if s[0:7]=="dreamer":
      if s[5:11]=="eraser":
        s=s[12:]
      elif s[5:10]=="erase":
        s=s[10:]
      else:
        s=s[7:]
    else:
      s=s[5:]
  elif s[0:5]=="erase":
    if s[0:6]=="eraser":
      s=s[6:]
    else:
      s=s[5:]
  else:
    i+=1
print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
i=0 #文字の判定
while i==0:
  if len(s)==0:
    print("YES")
    exit()

  if s[0:5]=="dream":
    if s[0:7]=="dreamer":
      if s[6:12]=="eraser":
        s=s[12:]
      elif s[6:11]=="erase":
        s=s[11:]
      else:
        s=s[7:]
    else:
      s=s[5:]
  elif s[0:5]=="erase":
    if s[0:6]=="eraser":
      s=s[6:]
    else:
      s=s[5:]
  else:
    i+=1
print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
i=0 #文字の判定
while i==0:
  if len(s)==0:
    print("YES")
    exit()

  if s[0:5]=="dream":
    if s[0:6]=="dreamer":
      if s[5:11]=="eraser":
        s=s[11:]
      elif s[5:10]=="erase":
        s=s[10:]
      else:
        s=s[6:]
    else:
      s=s[5:]
  elif s[0:5]=="erase":
    if s[0:6]=="eraser":
      s=s[6:]
    else:
      s=s[5:]
  else:
    i+=1
print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
i=0 #文字の判定
while i==0:
  if len(s)==0:
    print("YES")
    exit()

  if s[0:5]=="dream":
    if s[0:6]=="dreamer":
      if s[6:12]=="eraser":
        s=s[12:]
      elif s[6:11]=="erase":
        s=s[11:]
      else:
        s=s[6:]
    else:
      s=s[5:]
  elif s[0:5]=="erase":
    if s[0:6]=="eraser":
      s=s[6:]
    else:
      s=s[5:]
  else:
    i+=1
print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
i=0 #文字の判定
while i==0:
  if len(s)==0:
    print("YES")
    exit()

  if s[0:5]=="dream":
    if s[0:6]=="dreamer":
      s=s[6:]
    else:
      s=s[5:]
  elif s[0:5]=="erase":
    if s[0:6]=="eraser":
      s=s[6:]
    else:
      s=s[5:]
  else:
    i+=1
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 = input()[::-1]
dream = "dream"[::-1]
dreamer = "dreamer"[::-1]
erase = "erase"[::-1]
eraser = "eraser"[::-1]
for _ in range(len(s) // 5 + 1) :
    try :
        if s.startswith(dream) :
            s = s[5:]
        elif s.startswith(dreamer) :
            s = s[7:]
        elif s.startswith(erase) :
            s = s[5:]
        elif s.startswith(eraser) :
            s = s[7:]
    except :
        break
if s == "" :
    print("YES")
else :
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
T = ''
count = len(S)
while True:
    if S[0:count].rfind('dream') == count-5:
        T = 'dream' + T
        count = count - 5
    elif S[0:count].rfind('dreamer') == count-7:
        T = 'dreamer' + T
        count = count - 7
    elif S[0:count].rfind('erase') == count-5:
        T = 'erase' + T
        count = count - 5
    elif S[0:count].rfind('eraser') == count-6:
        T = 'eraser' + T
        count = count - 6
    else:
        break

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

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

Submission status: Wrong Answer

Solution code:
s = str(input())[::-1]

while(len(s) >= 5):
    if s[:5] == 'maerd':
        s = s.replace('maerd', '')
    elif s[:7] == 'remaerd':
        s = s.replace('remaerd', '')
    elif s[:5] == 'esare':
        s = s.replace('esare', '')
    elif s[:6] == 'resare':
        s = s.replace('resare', '')
    else:
        print('NO')
        exit()

print('YES')

Submission status: Wrong Answer

Solution code:
s = str(input())[::-1]

while(len(s) >= 5):
    if s[:5] == 'maerd':
        s = s.replace('maerd', '')
    elif s[:7] == 'remaerd':
        s = s.replace('remaerd', '')
    elif s[:5] == 'esare':
        s = s.replace('esare', '')
    elif s[:6] == 'resare':
        s = s.replace('resare', '')
    else:
        print('NO')
        exit()

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

Submission status: Wrong Answer

Solution code:
s = str(input())[::-1]

while(len(s) >= 5):
    if s[:5] == 'maerd':
        s = s.replace('maerd', '')
    elif s[:7] == 'remaerd':
        s = s.replace('remerd', '')
    elif s[:5] == 'esare':
        s = s.replace('esare', '')
    elif s[:6] == 'resare':
        s = s.replace('resare', '')
    else:
        print('NO')
        exit()

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

Submission status: Wrong Answer

Solution code:
s = str(input())[::-1]

while(len(s) >= 5):
    if s[:5] == 'maerd':
        s = s.replace('maerd', '')
    elif s[:7] == 'remaerd':
        s = s.replace('remerd', '')
    elif s[:5] == 'esare':
        s = s.replace('esare', '')
    elif s[:6] == 'resare':
        s == s.replace('resare', '')
    else:
        break

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
t = ["dream","dreamer","erase","eraser"]
t_re = [0]*len(t)
for i,temp in enumerate(t):
    t_re[i] = temp[::-1]
s_re = s[::-1]

ans = s_re.replace(t_re[0],"").replace(t_re[1],"").replace(t_re[2],"").replace(t_re[3],"")

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

Submission status: Wrong Answer

Solution code:
s = input()
while len(s) != 0:
    if ((s[:5] == "dream") & (s[:7] != "dreamer")) | ((s[:5] == "erase") & (s[:6] != "eraser")):
        s = s[5:]
    elif s[:6] == "eraser":
        s = s[6:]
    elif s[:7] == "dreamer":
        s = s[7:]
    else:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

Solution code:
s = input()
while len(s) != 0:
    if (s[:5] == "dream") | ((s[:5] == "erase") & (s[:6] != "eraser")):
        s = s[5:]
    elif s[:6] == "eraser":
        s = s[6:]
    elif s[:7] == "dreamer":
        s = s[7:]
    else:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
while len(s)>4:
  if s[(len(s)-5):]=='dream' or 'erase':
    s=s[:(len(s)-5)]
  if s[(len(s)-6):]=='eraser':
    s=s[:(len(s)-6)]
  if s[(len(s)-7):]=='dreamer':
    s=s[:(len(s)-7)]
if len(s)>0:
  print('NO')
else:
  print('YES')

Submission status: Wrong Answer

Solution code:
S = input()

cands = ["dream", "dreamer", "erase", "eraser"]
searched = {}

queue = [""]
find_flag = 0
while len(queue) != 0:
    s = queue.pop(0)
    searched[s] = 1
    print(s)
    if s == S:
        find_flag = 1
        break
        
    s_ = cands[0]
    if (s+s_ == S[:len(s)+len(s_)]) & (not searched.get(s+s_)):
        queue.append(s+s_)

    s_ = cands[1]
    if (s+s_ == S[:len(s)+len(s_)]) & (not searched.get(s+s_)):
        queue.append(s+s_)
        
    s_ = cands[2]
    if (s+s_ == S[:len(s)+len(s_)]) & (not searched.get(s+s_)):
        queue.append(s+s_)
        
    s_ = cands[3]
    if (s+s_ == S[:len(s)+len(s_)]) & (not searched.get(s+s_)):
        queue.append(s+s_)

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

Submission status: Wrong Answer

Solution code:
S = input()

cands = ["dream", "dreamer", "erase", "eraser"]
searched = {}

queue = [""]
find_flag = 0
while len(queue) != 0:
    s = queue.pop(0)
    if s == S:
        find_flag = 1
        break
        
    for s_ in cands:
        if searched.get(s+s_):
            continue
        if (s+s_ == S[:len(s)+len(s_)]):
            searched[s+s_] = 1
            queue.append(s+s_)
            break


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

Submission status: Wrong Answer

Solution code:
S = input()

candidates = ["dream", "dreamer", "erase", "eraser"]

find_flag = 0
rest_S = S
while True:
#     print(rest_S[-5:], rest_S[-7:]) 
    if len(rest_S) == 0:
        find_flag = 1
        break
    elif (len(rest_S) >= 6) & (rest_S[-7:] in candidates):
        rest_S = rest_S[:-7]
    elif (len(rest_S) >= 5) & (rest_S[-5:] in candidates):
        rest_S = rest_S[:-5]
    else:
        break

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

Submission status: Wrong Answer

Solution code:
S = input()

candidates = ["dream", "dreamer", "erase", "eraser"]

find_flag = 0
rest_S = S
while True:
#     print(rest_S, rest_S[-5:], rest_S[-7:]) 
    if len(rest_S) == 0:
        find_flag = 1
        break
    elif (len(rest_S) >= 7) & (rest_S[-7:] in candidates):
        rest_S = rest_S[:-7]
    elif (len(rest_S) >= 5) & (rest_S[-5:] in candidates):
        rest_S = rest_S[:-5]
    else:
        break

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

Submission status: Wrong Answer

Solution code:
S = input()

candidates = ["dream", "dreamer", "erase", "eraser"]

find_flag = 0
rest_S = S
while True:
#     print(rest_S, rest_S[-6:], rest_S[-7:]) 
    if len(rest_S) == 0:
        find_flag = 1
        break
    elif (len(rest_S) >= 6) & (rest_S[-7:] in candidates):
        rest_S = rest_S[:-7]
    elif (len(rest_S) >= 5) & (rest_S[-6:] in candidates):
        rest_S = rest_S[:-6]

    else:
        break

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

Submission status: Wrong Answer

Solution code:
S = input()

candidates = ["dream", "dreamer", "erase", "eraser"]

find_flag = 0
rest_S = S
while True:
    print(rest_S, rest_S[-6:], rest_S[-7:]) 
    if len(rest_S) == 0:
        find_flag = 1
        break
    elif (len(rest_S) >= 6) & (rest_S[-7:] in candidates):
        rest_S = rest_S[:-7]
    elif (len(rest_S) >= 5) & (rest_S[-6:] in candidates):
        rest_S = rest_S[:-6]

    else:
        break

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

Submission status: Wrong Answer

Solution code:
S = input()

candidates = ["dream", "dreamer", "erase", "eraser"]

find_flag = 0
rest_S = S
while True:
#    print(rest_S, rest_S[-6:], rest_S[-7:]) 
    if len(rest_S) == 0:
        find_flag = 1
        break
    elif rest_S[-6:] in candidates:
        rest_S = rest_S[:-6]
    elif rest_S[-7:] in candidates:
        rest_S = rest_S[:-7]
    else:
        break

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

Submission status: Wrong Answer

Solution code:
S = input()

candidates = ["dream", "dreamer", "erase", "eraser"]

find_flag = 0
rest_S = S
while True:
    if len(rest_S) == 0:
        find_flag = 1
        break
    elif rest_S[-6:] in candidates:
        rest_S = rest_S[:-6]
    elif rest_S[-7:] in candidates:
        rest_S = rest_S[:-7]
    else:
        break

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

Submission status: Wrong Answer

Solution code:
S = input()

candidates = ["dream", "dreamer", "erase", "eraser"]

find_flag = 0
rest_S = S
while True:
    if len(rest_S) == 0:
        find_flag = 1
        break
    elif rest_S[-5:] in candidates:
        rest_S = rest_S[:-5]
    elif rest_S[-6:] in candidates:
        rest_S = rest_S[:-6]
    else:
        break

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

Submission status: Wrong Answer

Solution code:
import re

s = input()
s = re.sub('dream', '', s)
s = re.sub('dreamer', '', s)
s = re.sub('erase', '', s)
s = re.sub('eraser', '', s)
print('YES' if len(s) == 0 else 'NO')

Submission status: Wrong Answer

Solution code:
import re

s = input()
s = re.sub('dream', '', s)
s = re.sub('dreamer', '', s)
s = re.sub('erase', '', s)
s = re.sub('eraser', '', s)
if len(s) == 0:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
t = ["dream","dreamer","erase","eraser"]
t_re = [0]*len(t)
for i,temp in enumerate(t):
    t_re[i] = temp[::-1]
s_re = s[::-1]

for temp in t_re:
    s_re = s_re.replace(temp,"")

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

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]
    break

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

Submission status: Wrong Answer

Solution code:
s = input()

e = ["dream", "dreamer", "erase", "eraser"]

ans = "NO"
for _e in e:
    if s[len(_e):] == _e and s[:len(_e)] in e:
        ans = "YES"

print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
S = S[::-1]

T = ['dream'[::-1],'dreamer'[::-1],'erase'[::-1],'eraser'[::-1]]
size = 0


while size < len(S):
	if S[size:size+5] == T[0] or S[size:size+5] == T[2]:
		size += 5
	elif S[size:size+6] == T[3]:
		size += 6
	elif S[size:size+7] == T[1]:
		size += 7
	else :
		print("No")
		exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
S = input()[::-1]

T = ['dream'[::-1],'dreamer'[::-1],'erase'[::-1],'eraser'[::-1]]
size = 0


while size < len(S):
	if S[size:size+5] == T[0] or S[size:size+5] == T[2]:
		size += 5
	elif S[size:size+6] == T[3]:
		size += 6
	elif S[size:size+7] == T[1]:
		size += 7
	else :
		print('No')
		exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
S = input()[::-1]

T = ['dream'[::-1],'dreamer'[::-1],'erase'[::-1],'eraser'[::-1]]
size = 0


while size < len(S):
	if S[size:size+5] == T[0] or S[size:size+5] == T[2]:
		size += 5
	elif S[size:size+6] == T[3]:
		size += 6
	elif S[size:size+7] == T[1]:
		size += 7
	else :
		print('No')
		exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
S = input()
cursor = len(S)

while cursor:
    if S[cursor - 5: cursor] in ['dream', 'erase']:
        cursor -= 5
        continue
    elif S[cursor - 6: cursor] in ['dreamer', 'eraser']:
        cursor -= 6
        continue
    else:
        break

if cursor == 0:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()

ans = 1
while(len(s)>0):
    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:
        s = ""
        ans = 0
if ans > 0:
    print("Yes")
else:    
    print("No")