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()
q = [0]
flag = False
while len(s) > 0:
    if s[0:5] in ['dream','erase'] and flag == False:
        q.append(s[0:5])
        s = s[5:]
        flag = False
    elif s[0:6] == 'eraser':
        q.append(s[0:6])
        s = s[6:]
        flag = False
    elif s[0:7] == 'dreamer':
        q.append(s[0:7])
        s = s[7:]
        flag = False
    elif q[-1] in ['dream','erase']:
        s = q[-1] + s
        q.pop()
        flag = True
    else:
        print('NO')
        exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
s = input()[::-1]
while len(s) > 0 :
    if s[:7] == 'remaerd':
        s = s[7:]
    elif s[:6] == 'resare':
        s = s[6:]
    elif s[:5] == 'maerd':
        s = s[5:]
    elif s[:5] == 'esare':
        s = s[5:]
    else:
        break
print(('NO','Yes')[len(s)==0])

Submission status: Wrong Answer

Solution code:
s = input()[::-1]
while len(s) > 0 :
    if s[:7] == 'remaerd':
        s = s[7:]
    elif s[:7] == 'resare':
        s = s[7:]
    elif s[:5] == 'maerd':
        s = s[5:]
    elif s[:5] == 'esare':
        s = s[5:]
    else:
        break
print(('NO','Yes')[len(s)==0])

Submission status: Wrong Answer

Solution code:
s = input()
while len(s) > 0 :
    if s[:7] == 'dreamer':
        s = s[7:]
    elif s[:7] == 'eraser':
        s = s[7:]
    elif s[:5] == 'dream':
        s = s[5:]
    elif s[:5] == 'erase':
        s = s[5:]
    else:
        break
print(('NO','Yes')[len(s)==0])

Submission status: Wrong Answer

Solution code:
S = input()

div = ['dream', 'dreamer', 'erase', 'eraser']
end = 0
ans = "Yes"

while end < len(S):
    
    isExist = False
    
    for d in div:
        if d == S[len(S) - len(d) - end: len(S) - end]:
            end += len(d)
            isExist = True

    if isExist != True:
        ans = "No"
        break

print(ans)

Submission status: Wrong Answer

Solution code:
Cr = input()
while Cr:
    if Cr[-7:] == 'dreamer':
        Cr = Cr[0:-7]
    elif Cr[-6:] == 'eraser':
        Cr = Cr[0:-6]
    elif Cr[-5:] in ['dream', 'erase']:
        Cr = Cr[0:-8]
    else:
        print('NO')
        exit()
print('YES')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input().replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '')

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

Submission status: Wrong Answer

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

s = s.replace('maerd', '')
s = s.replace('remaerd', '')
s = s.replace('esare', '')
s = s.replace('resare', '')

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

Submission status: Wrong Answer

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


s = s.replace('resare', '')
s = s.replace('remaerd', '')
s = s.replace('esare', '')
s = s.replace('maerd', '')

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

Submission status: Wrong Answer

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

print(s)

s = s.replace('resare', '')
s = s.replace('remaerd', '')
s = s.replace('esare', '')
s = s.replace('maerd', '')

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

Submission status: Wrong Answer

Solution code:
S = input()
S = S[::-1]
l = ["dream","dreamer","erase","eraser"]
l = [e[::-1] for e in l]
for e in l:
  S = S.split(e)
  S = "".join(S)
if len(S) == 0:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
l = ["eraser","dreamer","erase","dream"]
for e in l:
  S = S.rsplit(e)
  S = "".join(S)
if len(S) == 0:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
l = ["eraser","dreamer","erase","dream"]
for e in l:
  S = S.split(e)
  S = "".join(S)
if len(S) == 0:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

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

for _ in range(len(s)):
    judge = 0
    for i in range(4):
        d = division[i]
        if s[:len(d)] == d or s == '':
            judge = 1
            s = s[len(d):]
            break
    if judge == 0 or s == '':
        break

if judge == 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
s = input()

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

while len(s) != 0:
    if s[-5:] == risuto[0] or s[-5:] == risuto[2]:
        s = s.replace(s[-5:], "")
    elif s[-6:] == risuto[3]:
        s = s.replace(s[-6:], "")
    elif s[-7:] == risuto[1]:
        s = s.replace(s[-7:], "")
    else:
        break

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

Submission status: Wrong Answer

Solution code:
s = input()

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

while len(s) > 0:
    if s[-5:] == risuto[0] or s[-5:] == risuto[2]:
        s = s.replace(s[-5:], "")
    elif s[-6:] == risuto[3]:
        s = s.replace(s[-6:], "")
    elif s[-7:] == risuto[1]:
        s = s.replace(s[-7:], "")
    else:
        break

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

Submission status: Wrong Answer

Solution code:
s = input()

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

while len(s) > 0:
    if s[-5:] == risuto[0] or s[-5:] == risuto[2]:
        s = s.replace(s[-5:], "")
    elif s[-6:] == risuto[3]:
        s = s.replace(s[-6:], "")
    elif s[-7:] == risuto[1]:
        s = s.replace(s[-7:], "")
    else:
        break

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

Submission status: Wrong Answer

Solution code:
s = input()

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

while len(s) > 0:
    if s[-5:] in risuto:
        s = s.replace(s[-5:], "")
    elif s[-6:] in risuto:
        s = s.replace(s[-6:], "")
    elif s[-7:] in risuto:
        s = s.replace(s[-7:], "")
    else:
        break

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

Submission status: Wrong Answer

Solution code:
S = list(input())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

if input().rstrip().replace("dream","D").replace("erase","E").replace("Der","").replace("Eer","").replace("D","").replace("E","") == "":
    print( "YES" )
else:
    print( "NO" )

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l = ['resare', 'esare', 'maerd', 'remaerd']
s = input()[::-1]
for i in l:
    s = s.replace(i, '')

Submission status: Wrong Answer

Solution code:
S = input()

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

for s in String:
    S = S.replace(s,'')

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

Submission status: Wrong Answer

Solution code:
s = input()
flag = True
while len(s) > 0:
    if len(s) >= 8:
        if s[:8] == 'dreamerd' or s[:8] == 'dreamere':
            s = s[7:]
        elif s[:8] == 'dreamera':
            s = s[5:]
        elif s[:6] == 'eraser':
            s = s[6:]
        elif s[:5] == 'erase':
            s = s[5:]
        else:
            flag = False
            break
    elif len(s) == 7 and s == 'dreamer':
        break
    elif len(s) == 6 and s == 'eraser':
        break
    elif len(s) == 5:
        if s == 'dream' or s == 'erase':
            break
    else:
        flag = False
        break
if flag:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
flag = True
while len(s) > 0:
    if len(s) >= 8:
        if s[:8] == 'dreamerd' or s[:8] == 'dreamere':
            s = s[7:]
        elif s[:8] == 'dreamera':
            s = s[5:]
        elif s[:6] == 'eraser':
            s = s[6:]
        elif s[:5] == 'erase':
            s = s[5:]
        else:
            flag = False
            break
    elif len(s) == 7 and s == 'dreamer':
        break
    elif len(s) == 6 and s == 'eraser':
        break
    elif len(s) == 5:
        if s == 'dream' or s == 'erase':
            break
    else:
        flag = False
        break
if flag:
    print('OK')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = str(input())
list_s = list(s)
while len(list_s) > 0:
    if list_s[-5:] == list("dream") or list_s[-5:] == list("erase"):
        for i in range(5):
            list_s.pop()
    elif list_s[-6:] == list("dreamer") or list_s[-6:] == list("eraser"):
        for i in range(6):
            list_s.pop()
    else:
        ans = "NO"
        break
else:
    ans = "YES"
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()

flg = 0
try:
	while flg == 0:
		if s[0] == "d":
			if s[:5] == "dream":
				if s[5] == "d":
					s = s[5:]
				elif s[5:7] == "er":
					if s[7] == "a": # erase(r)
						s = s[5:]
					elif len(s) == 7 or s[7] == "d" or s[7] == "e": #dreamer
						s = s[7:]
					else:
						flg = 1
				else:
					flg = 2
			else:
				flg = 3
		elif s[0] == "e":
			if s[:5] == "erase" and (len(s) == 5 or s[5] == "d" or s[5] == "e"):
				s = s[5:]
			elif s[:6] == "eraser" and (len(s) == 6 or s[5] == "d" or s[5] == "e"):
				s = s[6:]
			else:
				flg = 4
		else:
			flg = 7
	if flg != 0:
		#print(flg)
		print("NO")
except IndexError:
	if len(s) == 0:
		print("YES")
	elif s == "dream" or s == "dreamer" or s == "erase" or s == "eraser":
		print("YES")
	else:
		print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
flag = True
i = 0
while (i <= len(S)-7):
  if (i > len(S)-5):
    flag = False
    break
  else:
    if (S[i] == 'd' and S[i+1] == 'r' and S[i+2] == 'e' and S[i+3] == 'a' and S[i+4] == 'm' and S[i+5] == 'e' and S[i+6] == 'r'):
      i += 7
    elif (S[i] == 'e' and S[i+1] == 'r' and S[i+2] == 'a' and S[i+3] == 's' and S[i+4] == 'e' and S[i+5] == 'r'):
      i += 6
    elif (S[i] == 'd' and S[i+1] == 'r' and S[i+2] == 'e' and S[i+3] == 'a' and S[i+4] == 'm'):
      i += 5
    elif (S[i] == 'e' and S[i+1] == 'r' and S[i+2] == 'a' and S[i+3] == 's' and S[i+4] == 'e'):
      i += 5
    else:
      flag = False
      break
if flag:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

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


def scan():
    for w in words:
        if revs.startswith(w):
            return len(w)
    print('NO')
    exit()


n = 0
while revs[n:] != '':
    n += scan()

print('YES')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    S = input()
    i = 0
    while i >= 0:
        ok = False
        for x in ["dreamer", "eraser", "dream", "erase"]:
            if S.endswith(x, i):
                i -= len(x)
                ok = True
                break
        if not ok:
            print(NO)
            return
    print(YES)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s = list(input())
s.reverse()
s=''.join(s)

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

tmp = []
arr2 = []
for i in range(4):
	tmp += list(arr[i])
	tmp.reverse()
	arr2.append(''.join(tmp))
	tmp = []

for y in arr2:
	s = s.replace(y,'')
		

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

Submission status: Wrong Answer

Solution code:
s = list(input())
s.reverse()
s=''.join(s)

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

tmp = []
arr2 = []
for i in range(4):
	tmp += list(arr[i])
	tmp.reverse()
	arr2.append(''.join(tmp))
	tmp = []

for y in arr2:
	if y in s:
		s = s.replace(y,'')
		

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

Submission status: Wrong Answer

Solution code:
s = list(input())
s.reverse()
s=''.join(s)

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

tmp = []
arr2 = []
for i in range(4):
	tmp += list(arr[i])
	tmp.reverse()
	arr2.append(''.join(tmp))
	tmp = []

for y in arr2:
	if y in s:
		s = s.replace(y,'')
		

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

Submission status: Wrong Answer

Solution code:
from sys import stdin

S = stdin.readline().rstrip()

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

while len(S) > 0:
    flag = False

    if S[0:5] == lst[0] or S[0:5] == lst[2]:
        S = S[5:]
        flag = True
    elif S[0:7] == lst[1]:
        S = S[7:]
        flag = True
    elif S[0:6] == lst[3]:
        S = S[6:]
        flag = True

    if (not flag):
        break

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

Submission status: Wrong Answer

Solution code:
S = input()
T = ["dream", "dreamer", "erase", "eraser"]
def main():
    i = len(S)
    while True:
        if i == 0:
            break
        elif i < 5:
            print("NO")
            return 0
        elif S[i - 5:i] == T[0] or S[i - 5:i] == T[2]:
            i -= 5
        elif i < 7:
            print("NO")
            return 0
        elif S[i - 6:i] == T[3]:
            i -= 6
        elif i < 7:
            print("NO")
            return 0
        elif S[i - 7:i] == T[1]:
            i -= 7
        else:
            print("NO")
            return 0
    print("YES")
    return 0
main()

Submission status: Wrong Answer

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

while len(S) > 0:
    if S[:6] == 'maerd':
        S = S[6:]
    elif S[:6] == 'esare':
        S = S[6:]
    elif S[:7] == 'resare':
        S = S[7:]
    elif S[:8] == 'remaerd':
        S = S[8:]
    else:
        print('NO')
        break

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

Submission status: Wrong Answer

Solution code:
S = input()

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

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

Submission status: Wrong Answer

Solution code:
S = input()
ls = len(S)
memo = [False] * (ls+1)

memo[0] = True
for i in range(ls):
    if memo[i] == False:
        continue
    else:
        if S[i: i+5] == "dream" or S[i: i+5] == "erase":
            memo[i+5] = True
        if S[i: i+6] == "eraser":
            memo[i+6] = True
        if S[i: i+7] == "dreamer":
            memo[i+7] == True

if memo[ls]:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()

result = S.replace("eraser", "").replace("dream", "").replace("dreamer", "").replace("erase", "")
if len(result) == 0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import sys
s = input()
i = 1 
s1 = ''
while i <= len(s):
  s1 += s[-i]
  i += 1
s2 = s1
while s2 != '':
  if s2[0:5] == 'maerd':
    s2 = s2[6:]
  elif s2[0:7] == 'remaerd':
    s2 = s2[8:]
  elif s2[0:5] == 'esare':
    s2 = s2[6:]
  elif s2[0:6] == 'resare':
    s2 = s2[7:]
  else:
    print('NO')
    sys.exit()
print('YES')

Submission status: Wrong Answer

Solution code:
import sys
s = input()
i = 1 
s1 = ''
while i <= len(s):
  s1 += s[-i]
  i += 1
s2 = s1
while s2 != '':
  if s2[0:5] == 'maerd':
    s2 = s2[6:]
  elif s2[0:7] == 'remaerd':
    s2 = s2[8:]
  elif s2[0:5] == 'esare':
    s2 = s2[6:]
  elif s2[0:6] == 'resare':
    s2 = s2[7:]
  else:
    print('No')
    sys.exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
s = input()
# curs = [index1, index2] 
curs = [0]
while True:
  next_curs = []
  break_ = False
  for c in curs:
    #print(c)
    if s[c:c+5] == 'dream':
      next_curs.append( c+5 )
      if len(s) == c+5:
        break_ = True
    if s[c:c+7] == 'dreamer':
      next_curs.append( c+7 )
      if len(s) == c+7:
        break_ = True
    if s[c:c+5] == 'erase':
      next_curs.append( c+5 )
      if len(s) == c+5:
        break_ = True
    if s[c:c+6] == 'eraser':
      next_curs.append( c+6 )
      if len(s) == c+6:
        break_ = True
  if next_curs == []:
    print('No')
    break
  if break_: 
    print('Yes')
    break
  curs = next_curs

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
s_list = list(s)
while True:
    l5 = s_list[-5:]
    l6 = s_list[-6:]
    l7 = s_list[-7:]
    s5 = s6 = s7 = ''

    for ch in l5:
        s5 += ch

    for ch in l6:
        s6 += ch

    for ch in l5:
        s7 += ch


    if (s5 == 'erase') | (s5 == 'dream'): 
        s_list = s_list[:-5]
    elif s6 == 'eraser':
        s_list = s_list[:-6]
    elif s7 == 'dreamer':
        s_list = s_list[:-7]
    else:
        print('NO')
        exit()

    if  s_list == []:
        print('YES')
        exit()

Submission status: Wrong Answer

Solution code:
s = input()

s = s.replace("eraser","").replace("dreamer","").replace("erase","").replace("dream","")

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

Submission status: Wrong Answer

Solution code:
s = input()

s = s.replace("erase","").replace("eraser","").replace("dream","").replace("dreamer","")

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

Submission status: Wrong Answer

Solution code:
s = input()
a = ('dream', 'dreamer', 'erase', 'eraser')

i = len(s)
ans = 'YES'
while i>0:
    if s[-5:] == a[0] or s[-5:] == a[2]:
        i -= 5
        s = s[:i]
    elif s[-6:] == a[1] or s[-6:] == a[3]:
        i -= 6
        s = s[:i]
    else:
        ans = 'NO'
        break
    #print(s)
print(ans)

Submission status: Wrong Answer

Solution code:
s  = input().replace("eraser", "").replace("erase", "").replace("dream", "").replace("dreamer", "")

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

Submission status: Wrong Answer

Solution code:
s  = input().replace("eraser", "").replace("erase", "").replace("dream", "").replace("dreamer", "")

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()[::-1]
print(s)
s=s.replace('maerd',"")
s=s.replace('remaerd',"")
s=s.replace('resare',"")
s=s.replace('esare',"")
if len(s) == 0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
text = input().replace("dreamer", "").replace("dreame", "").replace("eraser", "").replace("erase", "")
if text:  # this is wrong: text == ""
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()

while s == "":
	is_match = False
	for word in ("dream", "dreamer", "erase", "eraser"):
		if s[-len(word):] == word:
			s = s[:-len(word)]
			is_match = True
	if is_match == False:
		print("NO")
		exit()
print("YES")

Submission status: Wrong Answer

Solution code:
s=input()[::-1]
i=0
f=True
while 1:
  p=s[i:i+5]
  if not p:break
  if p=="maerd" or p=="esare":
    i+=5
  elif p=="remae":
    i+=7
  elif p=="resar":
    i+=6
  else:
    f=False
    break
if f:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
s=input()[::-1]
i=0
f=True
while 1:
  p=s[i:i+3]
  if not p:break
  if p=="mae" or p=="esa":
    i+=5
  elif p=="rem":
    i+=7
  elif p=="res":
    i+=6
  else:
    f=False
    break
if f:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
i=0
f=True
while 1:
  o=s[5*i:5*(i+1)]
  if not o:break
  if not (o=="dream" or o=="erase" or o=="r" or o=="er"):
    print("NO")
    f=False
    break
  i+=1
if f:print("YES")

Submission status: Wrong Answer

Solution code:
S = input()

marker = 0
flag = True

while flag and (marker < len(S)):
    if S[marker:marker+5] == "dream":
        marker += 5
        if S[marker+5:marker+7] == "er":
            marker += 2
    elif S[marker:marker+5] == "erase":
        marker += 5
        if S[marker+5:marker+6] == "r":
            marker += 1
    else:
        flag = False
        
if flag:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()

marker = 0
flag = True

while flag and (marker < len(S)):
    if S[marker:marker+5] == "dream":
        marker += 5
        if S[marker+5:marker+7] == "er":
            marker += 2
    elif S[marker:marker+5] == "erase":
        marker += 5
        if S[marker+5:marker+6] == "r":
            marker += 1
    else:
        flag = False
        
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
S = input()
S = S[::-1]
C = ['maerd', 'remaerd', 'esare', 'resare']
flag = False

def  daydream(S,C,flag=None):
    if len(S) == 0:
        return True
    T = [S.split(i) for i in C]
    for i in range(len(T)):
        if T[i][0] in C:
            S = S[len(T[i][0]):len(S)]
            flag = True
            return daydream(S,C,True)
    return False

ans = daydream(S,C,False)
if ans:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

for i in range(len(T)):
    S = S.replace(T[i], '')
    
if len(S) == 0:
    re = 'YES'
else:
    re = 'NO'
    
print(re)

Submission status: Wrong Answer

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

for i in range(len(T)):
    S = S.replace(T[i], '')
    
if len(S) == 0:
    re = 'YES'
else:
    re = 'NO'
    
print(re)

Submission status: Wrong Answer

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

for i in range(len(T)):
    S = S.replace(T[i], '')
    
if len(S) == 0:
    re = 'YES'
else:
    re = 'NO'
    
print(re)

Submission status: Wrong Answer

Solution code:
S = input()

S = S[::-1]
i = 0
ans = 'YES'
while i < len(S):
    if S[i] == 'm':
        i += 5
    elif S[i] == 'e':
        i += 5
    elif S[i:i + 3] == 'rem':
        i += 7
    elif S[i:i + 3] == 'res':
        i += 6
    else:
        ans = 'NO'
        break
print(ans)

Submission status: Wrong Answer

Solution code:
def solve(s):
	if not s:
		return 'YES'
	s=s.rstrip('dream')
	if not s:
		return 'YES'
	s=s.rstrip('dreamer')
	if not s:
		return 'YES'
	s=s.rstrip('erase')
	if not s:
		return 'YES'
	s=s.rstrip('eraser')
	if not s:
		return 'YES'
	if s is s:
		return 'NO'
	solve(s)
	
s=input()
print(solve(s))

Submission status: Wrong Answer

Solution code:
words = ["dream", "dreamer", "erase","eraser"]
reverse_words = []
for word in words:
    reverse_words.append(word[::-1])
S = input()
S = S[::-1]

while len(S) !=0:
    flag = 0
    for word in reverse_words:
        if S.startswith(word):
            S = S[len(word):]
            flag=1
            break
    if (not flag):
        print("No")
        quit()
print("Yes")

Submission status: Wrong Answer

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

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()
d='dream'
de='erer'
e='erase'
i=0
while i<=len(s)-1:
    if len(s)-1-i<4:
        i=float('inf')
        break
    elif s[i]=='d':
        for j in range(5):
            if s[i+j]!=d[j]:
                i=float('inf')
                break
        else:    
            i+=5
    elif s[i]=='e':
        if s[i+2]=='e':
            for j in range(4):
                if s[i+j]!=de[j]:
                    i=float('inf')
                    break
            else:
                i+=2
        else:
            for j in range(5):
                if s[i+j]!=e[j]:
                    i=float('inf')
                    break
            else:
                if s[i+5]=='r':
                    i+=6
                else:
                    i+=5
    else:
        i=float('inf')
        break
if i==float('inf'):
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
s=input()
d='dream'
de='erer'
e='erase'
i=0
while i<=len(s)-1:
    if len(s)-1-i<4:
        i=float('inf')
        break
    elif s[i]=='d':
        for j in range(5):
            if s[i+j]!=d[j]:
                i=float('inf')
                break
        else:    
            i+=5
    elif s[i]=='e':
        if s[i+2]=='e':
            for j in range(4):
                if s[i+j]!=de[j]:
                    i=float('inf')
                    break
            else:
                i+=2
        else:
            for j in range(5):
                if s[i+j]!=e[j]:
                    i=float('inf')
                    break
            else:
                if s[i+5]=='r':
                    i+=6
                else:
                    i+=5
if i==float('inf'):
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
s = input()
stack = []

idx = 0
if s[:5] == 'dream':
    stack.append(5)
if s[:7] == 'dreamer':
    stack.append(7)
if s[:5] == 'erase':
    stack.append(5)
if s[:6] == 'eraser':
    stack.append(6)

ans = 'NO'
while True:
    # print(stack)
    for i in stack[::-1]:
        stack = stack[:-1]
        if i == len(s):
            ans = 'YES'
            break
        if s[i:i+5] == 'dream':
            stack.append(i+5)
        if s[i:i+7] == 'dreamer':
            stack.append(i+7)
        if s[i:i+5] == 'erase':
            stack.append(i+5)
        if s[i:i+6] == 'eraser':
            stack.append(i+6)
    if ans == 'YES':
        break
    if len(stack) == 0:
        break
    
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()

def solve(s):
    while len(s) > 0:
        if s[-5:] == 'dream':
            s = s[:-5]
        elif s[-6:] == 'dreamer':
            s = s[:-6]
        elif s[-5:] == 'erase':
            s = s[:-5]
        elif s[-6:] == 'eraser':
            s = s[:-6]
        else:
            print('NO')
            return 
    print('YES')
    return

solve(s)

Submission status: Wrong Answer

Solution code:
strings = input()

word_list = ["dream", "erase", "dreamer", "eraser"]
rev_list = ["maerd", "esare", "remaerd", "resare"]

match = ""

for s in reversed(strings):  
  match += s
  
  if match in rev_list:
    match = ""

if len(match) == 0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:

def judge(S):
    cursor = 0
    len_S = len(S)
    if len_S < 8:
        if S == ("dream" or "dreamer" or "erase" or "eraser"):
            return True
        else:
            return False
    
    while cursor < len_S:
        next_str = S[cursor:cursor+8]
        print(next_str)
        if next_str[:] == "dreamera":
            cursor += 5
        elif next_str[:7] == "dreamer":
            cursor += 7
        elif next_str[:6] == "eraser":
            cursor += 6
        elif next_str[:5] == ("dream" or "erase"):
            cursor += 5
        else:
            return False
        
    if cursor != len_S:
        return False
    
    return True


S = input()

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

Submission status: Wrong Answer

Solution code:

def judge(S):
    cursor = 0
    len_S = len(S)
    while cursor < len_S:
        next_str = S[cursor:cursor+8]
        if next_str[:] == "dreamera":
            cursor += 5
        elif next_str[:7] == "dreamer":
            cursor += 7
        elif next_str[:6] == "eraser":
            cursor += 6
        elif next_str[:5] == ("dream" or "erase"):
            cursor += 5
        else:
            return False
        
    if cursor != len_S:
        return False
    
    return True


S = input()

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