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()
word_list = ["eraser","dreamer","dream","erase"]

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

Submission status: Wrong Answer

Solution code:
S = str(input())
def detect_dream(string):
    assert string[0] == "d"
    if string[:5] != "dream":
        return False, ""
    if len(string) >= 8:
        if string[:8] in ["dreamere", "dreamerd"] or string == "dreamer":
            return True, "dreamer"
    return True, "dream"

def detect_erase(string):
    assert string[0] == "e"
    if string[:5] != "erase":
        return False, ""
    if len(string) >= 6:
        if string[:6] == "eraser":
            return True, "eraser"
    return True, "erase"

while len(S) >= 5:
    if S[0] == "d":
        result, string = detect_dream(S)
    elif S[0] == "e":
        result, string = detect_erase(S)
    else:
        break
    if result:
        S = S.replace(string,"",1)
    else:
        break
if len(S) == 0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = str(input())
def detect_dream(string):
    assert string[0] == "d"
    if string[:5] != "dream":
        return False, ""
    if len(string) >= 8:
        if string[:8] in ["dreamere", "dreamerd"]:
            return True, "dreamer"
    return True, "dream"

def detect_erase(string):
    assert string[0] == "e"
    if string[:5] != "erase":
        return False, ""
    if len(string) >= 6:
        if string[:6] == "eraser":
            return True, "eraser"
    return True, "erase"

while len(S) >= 5:
    if S[0] == "d":
        result, string = detect_dream(S)
    elif S[0] == "e":
        result, string = detect_erase(S)
    else:
        break
    if result:
        S = S.replace(string,"",1)
    else:
        break
if len(S) == 0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = str(input())
def detect_dream(string):
    assert string[0] == "d"
    if string[:5] != "dream":
        return False, ""
    if len(string) >= 8:
        if string[:8] in ["dreamere", "dreamerd"]:
            return True, "dreamer"
    return True, "dream"

def detect_erase(string):
    assert string[0] == "e"
    if string[:5] != "erase":
        return False, ""
    if len(string) >= 6:
        if string[:6] == "eraser":
            return True, "eraser"
    return True, "erase"

while len(S) >= 5:
    if S[0] == "d":
        result, string = detect_dream(S)
    elif S[0] == "e":
        result, string = detect_erase(S)
    else:
        break
    if result:
        S = S[len(string):]
    else:
        break
if len(S) == 0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S=input()
flag=True
words={'dream','dreamer','erase','eraser'}
while flag:
    if S=="" :
        break
    if S[-7:] in words:
        S=S[0:-7]
        continue
    elif S[-6:] in words:
        S=S[0:-6]
        continue
    elif S[-5:] in words:
        S=S[0:-5]
        continue
    else :
        flag=False
if flag:
    print("Yes")
else :
    print("No")

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s) // 5
for i in range(n + 1):
   if len(s) == 0:
      print('YES')
      exit()
   if s[:6] == 'eraser':
      s = s[6:]
   elif s[:5] == 'erase':
      s = s[5:]
   elif ((s[:7] == 'dreamer') and (s[:10] != 'dreamerase') and (s[:11] != 'dreameraser')) or ((len(s) == 7) and (s == 'dreamer')):
      s = s[7:]
   elif (s[:5] == 'dream'):
      s = s[5:]
   else:
      print(s)
      print('NO')
      exit()

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s) // 5
for i in range(n + 1):
   if len(s) == 0:
      print('YES')
      exit()
   if s[:6] == 'eraser':
      s = s[6:]
   elif s[:5] == 'erase':
      s = s[5:]
   elif (s[:6] == 'dreamer') and (s[:10] != 'dreamerase') and (s[:11] != 'dreameraser') or ((len(s) == 6) and (s == 'dreamer')):
      s = s[6:]
   elif (s[:5] == 'dream'):
      s = s[5:]
   else:
      print('NO')
      exit()

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s) // 5
for i in range(n + 1):
   if len(s) == 0:
      print('YES')
      exit()
   if s[:6] == 'eraser':
      s = s[6:]
   elif s[:5] == 'erase':
      s = s[5:]
   elif (s[:6] == 'dreamer') and (s[:10] != 'dreamerase') and (s[:11] != 'dreameraser'):
      s = s[6:]
   elif (s[:5] == 'dream'):
      s = s[5:]
   else:
      print('NO')
      exit()

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s) // 5
for i in range(n + 1):
   if len(s) == 0:
      print('YES')
      exit()
   if s[:5] == 'erase':
      s = s[5:]
   elif s[:6] == 'eraser':
      s = s[6:]
   elif (s[:6] == 'dreamer') and ((s[:10] != 'dreamerase') or (s[:11] != 'dreameraser')):
      s = s[6:]
   elif (s[:5] == 'dream'):
      s = s[5:]
   else:
      print('NO')
      exit()

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s) // 5
for i in range(n + 1):
   if len(s) == 0:
      print('YES')
      exit()
   if s[:5] == 'erase':
      s = s[5:]
   elif s[:6] == 'easer':
      s = s[6:]
   elif (s[:6] == 'dreamer') and ((s[:10] != 'dreamerase') or (s[:11] != 'dreameraser')):
      s = s[6:]
   elif (s[:5] == 'dream'):
      s = s[5:]
   else:
      print('NO')
      exit()

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s) // 5
for i in range(n + 2):
   if len(s) == 0:
      print('YES')
      exit()
   if (s[:5] == 'dream') or (s[:5] == 'erase'):
      s = s[5:]
   elif (s[:6] == 'dreamer') or (s[:6] == 'easer'):
      s = s[6:]
   else:
      print('NO')
      exit()

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s) // 5
for i in range(n + 1):
   if len(s) == 0:
      print('YES')
      exit()
   if (s[:5] == 'dream') or (s[:5] == 'erase'):
      s = s[5:]
   elif (s[:6] == 'dreamer') or (s[:6] == 'easer'):
      s = s[6:]
   else:
      print('NO')
      exit()

Submission status: Wrong Answer

Solution code:
import re

if __name__ == '__main__':
    s = input()
    T = ''
    text_list = [ 'dream', 'dreamer', 'erase', 'eraser']
    next_list = []
    target_list = ['']

    while True:
        for target in target_list:
            for text in text_list:
                t = target+text
                if target+text == s:
                    print('YES')
                    exit()
                elif re.match(target+text, s):
                    next_list.append(target+text)
            if len(next_list) == 0:
                print('NO')
                exit()
        target_list = next_list
        next_list = []

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

S = input()
words = ['dream', 'dreamer', 'erase', 'eraser']
result = True

while len(S) != 0 and result == True:
  for i in list((5,7,8)):
    if i == 8:
      result = False
      break
    if S[-i:] == words[0]:
      S = S[:-i]
      break
    elif S[-i:] == words[1]:
      S = S[:-i]
      break
    elif S[-i:] == words[2]:
      S = S[:-i]
      break
    elif S[-i:] == words[3]:
      S = S[:-i]
      break
    else:
      continue

if result == True:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
S = input()

while(len(S) > 0):
    if S[0:6] == "eraser":
        S = S[6:]
    elif S[0:5] == "erase":
        S = S[5:]
    elif S[0:5] == "dream":
        tmp = S[5:8]
        if len(tmp) == 0:
            S = S[5:]
        elif tmp == "era":
            S = S[5:]
        elif tmp == "er":
            S = S[7:]
        elif tmp == "ere":
            S = S[7:]
        elif tmp == "erd":
            S = S[7:]
        else:
            print("NO")
            sys.exit()
    else:
        print("NO")
        sys.exit()
print("YES")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
S = input()

while(len(S) > 0):
    if S[0:6] == "eraser":
        S = S[6:]
    elif S[0:5] == "erase":
        S = S[5:]
    elif S[0:5] == "dream":
        tmp = S[5:8]
        if len(tmp) == 0:
            S = S[5:]
        elif tmp == "er":
            S = S[5:]
        elif tmp == "era":
            S = S[5:]
        elif tmp == "ere":
            S = S[7:]
        elif tmp == "erd":
            S = S[7:]
        else:
            print("NO")
            sys.exit()
    else:
        print("NO")
        sys.exit()
print("YES")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
S = input()

while(len(S) > 0):
    if S[0:6] == "eraser":
        S = S[6:]
    elif S[0:5] == "erase":
        S = S[5:]
    elif S[0:5] == "dream":
        tmp = S[5:8]
        if len(tmp) == 0:
            S = S[5:]
        elif tmp == "era":
            S = S[5:]
        elif tmp == "ere":
            S = S[7:]
        elif tmp == "erd":
            S = S[7:]
        else:
            print("NO")
            sys.exit()
    else:
        print("NO")
        sys.exit()
print("YES")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
S = input()

five_sign1 = "dream"
five_sign2 = "erase"
six_sign = "eraser"
sevent_sign = "dreamer"



while(len(S) > 0):
    if S[0:6] == "eraser":
        S = S[6:]
    elif S[0:5] == "erase":
        S = S[5:]
    elif S[0:5] == "dream":
        tmp = S[5:8]
        if len(tmp) == 0:
            S = S[5:]
            continue
        elif tmp == "era":
            S = S[5:]
        elif tmp == "erd":
            S = S[7:]
        else:
            print("NO")
            sys.exit()
    else:
        print("NO")
        sys.exit()
print("YES")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
S = input()

five_sign1 = "dream"
five_sign2 = "erase"
six_sign = "eraser"
sevent_sign = "dreamer"



while(len(S) > 0):
    print("S {}".format(S))
    if S[0:6] == "eraser":
        S = S[6:]
    elif S[0:5] == "erase":
        S = S[5:]
    elif S[0:5] == "dream":
        tmp = S[5:8]
        if len(tmp) == 0:
            S = S[5:]
            continue
        elif tmp == "era":
            S = S[5:]
        elif tmp == "erd":
            S = S[7:]
        else:
            print("NO")
            sys.exit()
    else:
        print("NO")
        sys.exit()
print("YES")

Submission status: Wrong Answer

Solution code:
inp = input()
m = 0
n = 0
li = ['dream','dreamer','erase','eraser']
while True:
    for i in li:
        if inp.startswith(i):
    	    inpp = inp.replace(i,'',1)
    	    if inpp == '':
    		    m = 1
    		    break
    	    for k in li:
    	    	if inpp.startswith(k):
    		        inp = inpp
    		        n = 1
    		        break
    	    else:
                if k == 'eraser':
                	break
                continue
    	    break
    if m == 1:
    	print('YES')
    	break
    if n != 1:
    	print('NO')
    	break

Submission status: Wrong Answer

Solution code:
inp = input()
m = 0
n = 0
li = ['dream','dreamer','erase','eraser']
while True:
    for i in li:
        if inp.startswith(i):
    	    inpp = inp.lstrip(i)
    	    if inpp == '':
    		    m = 1
    		    break
    	    for k in li:
    		    if inpp.startswith(k):
    		        inp = inpp
    		        n = 1
    		        break
    	    else:
    		    continue
    	    break
    if n != 1:
    	print('NO')
    	break
    if m == 1:
    	print('YES')
    	break

Submission status: Wrong Answer

Solution code:
s = list(input())

while len(s) > 0:
    if ''.join(s[-7:]) == 'dreamer':
        del s[-7:]
    if ''.join(s[-6:]) == 'eraser':
        del s[-6:]
    if ''.join(s[-5:]) == 'dream' or ''.join(s[-5:]) == 'erase':
        del s[-5:]
    else:
        break
if len(s) == 0:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = list(input())
s = S.copy()
t = []
for i in range(len(s)):
    if ''.join(s[-7:]) == 'dreamer':
        t = s[-7:] + t
        del s[-7:]
    if ''.join(s[-6:]) == 'eraser':
        t = s[-6:] + t
        del s[-6:]
    if ''.join(s[-5:]) == 'dream' or ''.join(s[-5:]) == 'erase':
        t = s[-5:] + t
        del s[-5:]
    else:
        break
if S == t:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

divide = ["dream", "dreamer", "erase", "eraser"]
for i in range(4):
    divide[i] = divide[i][::-1]

length1 = 0
length2 = 0
can = 0
flag = True

while flag:
    length1 = length2
    for i in range(4):
        if S[length1:length1+len(divide[i])] == divide[i]:
            length2 = length1 + len(divide[i])
    if length1 == length2:
        flag = False

if len(S) == length2:
    print("YES")
else:
    print("NO")

print(length2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()

s = s[::-1]

s = list(s)
#print(s)
count = 0
can = True
jm = []
j = 0
maxcount = 0

for i in s:
    jm.append(s[j])
    j += 1
    count += 1
    if count > 7:
        can = False
#        print(0)
        break
    elif "".join(jm) == "maerd":
        maxcount += count
        count,j = 0,0
        jm = []
#        print(1)
    elif "".join(jm) == "remaerd":
        maxcount += count
        count,j = 0,0
        jm = []
#        print(2)
    elif "".join(jm) == "esare":
        maxcount += count
        count,j = 0,0
        jm = []
#        print(3)
    elif "".join(jm) == "resare":
        maxcount += count
        count,j = 0,0
        jm = []
#        print(4)
    else:
#        print(5)
        pass


#print("forward bool is" + str(can))

if maxcount == 0:
    can = False

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

Submission status: Wrong Answer

Solution code:
s = input()

s = s[::-1]

s = list(s)
#print(s)
count = 0
can = True
jm = []
j = 0
maxcount = 0

for i in s:
    jm.append(s[j])
    j += 1
    count += 1
    if count > 7:
        can = False
#        print(0)
        break
    elif "".join(jm) == "maerd":
        maxcount += count
        count,j = 0,0
        jm = []
#        print(1)
    elif "".join(jm) == "remaerd":
        maxcount += count
        count,j = 0,0
        jm = []
#        print(2)
    elif "".join(jm) == "esare":
        maxcount += count
        count,j = 0,0
        jm = []
#        print(3)
    elif "".join(jm) == "resare":
        maxcount += count
        count,j = 0,0
        jm = []
#        print(4)
    else:
#        print(5)
        pass


#print("forward bool is" + str(can))

if maxcount < 5:
    can = False

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

Submission status: Wrong Answer

Solution code:
s = input()

s = s[::-1]

s = list(s)
#print(s)
count = 0
can = True
jm = []
j = 0
maxcount = 0

for i in s:
    jm.append(s[j])
    j += 1
    count += 1
    if count > 7:
        can = False
#        print(0)
        break
    elif "".join(jm) == "maerd":
        maxcount += count
        count,j = 0,0
#        print(1)
    elif "".join(jm) == "remaerd":
        maxcount += count
        count,j = 0,0
        jm = []
#        print(2)
    elif "".join(jm) == "esare":
        maxcount += count
        count,j = 0,0
        jm = []
#        print(3)
    elif "".join(jm) == "resare":
        maxcount += count
        count,j = 0,0
        jm = []
#        print(4)
    else:
#        print(5)
        pass


#print("forward bool is" + str(can))

if maxcount == 0:
    can = False

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

Submission status: Wrong Answer

Solution code:
s = input()

s = s[::-1]

s = list(s)
#print(s)
count = 0
can = True
jm = []
j = 0
maxcount = 0

for i in s:
    jm.append(s[j])
    j += 1
    count += 1
    if count > 7:
        can = False
#        print(0)
        break
    elif "".join(jm) == "maerd":
        maxcount += count
        count,j = 0,0
#        print(1)
    elif "".join(jm) == "remaerd":
        maxcount += count
        count,j = 0,0
        jm = []
#        print(2)
    elif "".join(jm) == "esare":
        maxcount += count
        count,j = 0,0
        jm = []
#        print(jm + 1)
    elif "".join(jm) == "rersare":
        maxcount += count
        count,j = 0,0
        jm = []
    else:
        pass


#print("forward bool is" + str(can))

if maxcount == 0:
    can = False

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

Submission status: Wrong Answer

Solution code:
s = input()

s = s[::-1]

s = list(s)
#print(s)
count = 0
can = True
jm = []
j = 0
maxcount = 0

for i in s:
    jm.append(s[j])
    j += 1
    count += 1
    if count > 7:
        can = False
#        print(0)
        break
    elif "".join(jm) == "maerd":
        maxcount += count
        count,j = 0,0
#        print(1)
    elif "".join(jm) == "remaerd":
        maxcount += count
        count,j = 0,0
        jm = []
#        print(2)
    elif "".join(jm) == "erase":
        maxcount += count
        count,j = 0,0
        jm = []
#        print(jm + 1)
    elif "".join(jm) == "erase":
        maxcount += count
        count,j = 0,0
        jm = []
    else:
        pass


#print("forward bool is" + str(can))

if maxcount == 0:
    can = False

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

Submission status: Wrong Answer

Solution code:

S = input()


DREAM = "dream"
DREAMER = "dreamer"
ERASE = "erase"
ERASER = "eraser"


def is_composable(s):
    print(s)
    if len(s) == 0:
        return True

    if s.startswith(DREAMER):
        dream_s = s[len(DREAM):]
        dreamer_s = s[len(DREAMER):]
        return is_composable(dream_s) or is_composable(dreamer_s)
    elif s.startswith(DREAM):
        dream_s = s[len(DREAM):]
        return is_composable(dream_s)
    elif s.startswith(ERASER):
        erase_s = s[len(ERASE):]
        eraser_s = s[len(ERASER):]
        return is_composable(erase_s) or is_composable(eraser_s)
    elif s.startswith(ERASE):
        erase_s = s[len(ERASE):]
        return is_composable(erase_s)
    else:
        return False


if len(S) > 0 and is_composable(S):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import sys
s = sys.stdin.readline()
s = s[::-1].replace("maerd", "").replace("remaerd", "")
s = s.replace("esare", "").replace("resare", "")
if s == "":
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
def check(s):
    x=s[-3:]
    if x=='eam':return 'dream'
    elif x=='mer':return 'dreamer'
    elif x=='ase':return 'erase'
    elif x=='ser':return 'eraser'
    else: return 'False'

count=0
while len(s)>0 and count==0:
    if check(s)=='False':
        count+=1
        print('NO')
    elif check(s)=='dream' or check(s)=='erase':
        if len(s)!=5:s=s[:-5]
        elif len(s)==5:s=''
    elif check(s)=='eraser':
        if len(s)!=6:s=s[:-6]
        elif len(s)==6:s=''
    elif check(s)=='dreamer':
        if len(s)!=7:s=s[:-7]
        elif len(s)==7:s=''

if count==0:print('YES')

Submission status: Wrong Answer

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_Beginning_Contest049-C
#  TODO https://atcoder.jp/contests/abc049/tasks/arc065_a
#  Dummy Wrong Answer
def solveProblem(givenStr):

	strT1temp = "dream"
	strT2temp = "dreamer"
	strT3temp = "erase"
	strT4temp = "eraser"
	searchingGivenStr = reversed(givenStr)
	strT1 = reversed(strT1temp)
	strT2 = reversed(strT2temp)
	strT3 = reversed(strT3temp)
	strT4 = reversed(strT4temp)

	answerYES = "YES"
	answerNO = "NO"



	answer = answerYES



	return answer


if __name__ == '__main__':
	S = str(input().strip())
	solution = solveProblem(S)
	print("{}".format(solution))

Submission status: Wrong Answer

Solution code:
s = input()
judge = "YES"

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

if not s.isdigit():
  judge = "NO"
print(s)
print(judge)

Submission status: Wrong Answer

Solution code:
s = input()
S = list(s)
N = len(S)
judge = 1
while judge == 1 and N > 0:
	judge = 0
	if str(S[max(0,N-7):N]) == list("dreamer"):
		del S[max(0,N-7):N]
		N -= 7
		judge = 1
	elif S[max(0,N-6):N] == list("eraser"):
		del S[max(0,N-6):N]
		N -= 6
		judge = 1
	elif S[max(0,N-5):N] == list("dream"):
		del S[max(0,N-5):N]
		N -= 5
		judge = 1
	elif S[max(0,N-5):N] == list("erase"):
		del S[max(0,N-5):N]
		N -= 5
		judge = 1
	
if judge == 1:
	print("YES")
else:
	print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
N = len(S)
judge = 1
while judge == 1 and N > 0:
	judge = 0
	if S[max(0,N-7):N] == "dreamer":
		S = S.replace("dreamer","")
		N -= 7
		judge = 1
	elif S[max(0,N-6):N] == "eraser":
		S = S.replace("eraser","")
		N -= 6
		judge = 1
	elif S[max(0,N-5):N] == "dream":
		S = S.replace("dream","")
		N -= 5
		judge = 1
	elif S[max(0,N-5):N] == "erase":
		S = S.replace("erase","")
		N -= 5
		judge = 1
	
if judge == 1:
	print("YES")
else:
	print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
N = len(S)
print(N)
judge = 1
print(S[max(0,N-7):N])
print(S[0:N])
while judge == 1 and N > 0:
	judge = 0
	print(S)
	print(N)
	if S[max(0,N-7):N] == "dreamer":
		S = S.replace("dreamer","")
		N -= 7
		judge = 1
	elif S[max(0,N-6):N] == "eraser":
		S = S.replace("eraser","")
		N -= 6
		judge = 1
	elif S[max(0,N-5):N] == "dream":
		S = S.replace("dream","")
		N -= 5
		judge = 1
	elif S[max(0,N-5):N] == "erase":
		S = S.replace("erase","")
		N -= 5
		judge = 1
	
if judge == 1:
	print("YES")
else:
	print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
tmp = s
flag=0
while tmp != '':
  if tmp[-6::] =='dreamer' or tmp[-6::] == 'eraser':
    tmp = tmp[0:-6]
  elif tmp[-5::] == 'dream' or tmp[-5::] == 'erase':
    tmp = tmp[0:-5]
  else:
    flag=1
    break
    
if flag ==0:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
tmp = s
flag=0
while tmp != '':
  if tmp[-6::] =='dreamer' or tmp[-6::] == 'eraser':
    tmp = tmp[0:-6]
  elif tmp[-5::] == 'dream' or tmp[-5::] == 'erase':
    tmp = tmp[0:-5]
  else:
    flag=1
    break
if flag ==0:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
tmp = s
flag=0
while tmp != '':
  if tmp[0:6] =='dreamer' or tmp[0:6] == 'eraser':
    tmp = tmp[6::]
  elif tmp [0:5] == 'dream' or tmp[0:5] == 'erase':
    tmp = tmp[5::]
  else:
    flag=1
    break
if flag ==0:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

words = ["dream", "dreamer", "erase", "eraser"]
words = [w[::-1] for w in words]
lens = [len(w) for w in words]

while True:
    for l, w in zip(lens, words):
        if s[:l] == w:
            s = s[l:]
            break
    else:
        print("No")
        break
    if len(s) == 0:
        print("Yes")
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def judge(S):
    #文字列を逆にする
    S = list(S)
    S.reverse()
    S = ''.join(S)
    
    candidates = ['maerd','remaerd','esare','resare']
    
    top_index = 0
    while(top_index < len(S)):
        flag = False
        for candidate in candidates:
            if(S[top_index:].startswith(candidate)):
                top_index += len(candidate)
                flag = True
        if (not flag):
            break
    if(top_index == len(S)):
        return print('Yes')
    else:
        return print('No')

if __name__ == '__main__':
    S = input()
    judge(S)

Submission status: Wrong Answer

Solution code:
def judge(S):
    S = list(S)
    S.reverse()
    S = ''.join(S)
    
    T = []
    candidates = ['maerd','remaerd','esare','resare']
    
    top_index = 0
    while(top_index < len(S)):
        flag = False
        for candidate in candidates:
            if(S[top_index:].startswith(candidate)):
                top_index += len(candidate)
                flag = True
        if (not flag):
            break
    if(top_index == len(S)):
        return print('Yes')
    else:
        return print('No')

if __name__ == '__main__':
    S = input()
    judge(S)

Submission status: Wrong Answer

Solution code:
def judge(S):
    #文字列を逆にする
    S = list(S)
    S.reverse()
    S = ''.join(S)
    
    T = []
    candidates = ['maerd','remaerd','esare','resare']
    
    top_index = 0
    while(top_index < len(S)):
        flag = False
        for candidate in candidates:
            if(S[top_index:].startswith(candidate)):
                top_index += len(candidate)
                flag = True
        if (not flag):
            break
    if(top_index == len(S)):
        return print('Yes')
    else:
        return print('No')

if __name__ == '__main__':
    S = input()
    judge(S)

Submission status: Wrong Answer

Solution code:
def DFS(S):
    word_list = ["dreamer", "dream", "eraser", "erase"]
    stack = ["dream", "dreamer", "erase", "eraser"]
    while stack:
        word = stack.pop()
        if word == S[0]:
            return "YES"
        for i in word_list:
            next_word = word + i
            check = S[0][:len(word + i)]
            if next_word != check:
                continue
            if next_word == check:
                stack.append(next_word)
    return "NO"

Submission status: Wrong Answer

Solution code:
def DFS(S):
    word_list = ["dreamer", "dream", "eraser", "erase"]
    stack = ["dream", "dreamer", "erase", "eraser"]
    while stack:
        word = stack.pop()
        if word == S[0]:
            return "YES"
        for i in word_list:
            next_word = word + i
            check = S[0][:len(word + i)]
            if next_word != check:
                continue
            if next_word == check:
                stack.append(next_word)
                print(stack)
    return "NO"

Submission status: Wrong Answer

Solution code:
from collections import deque
def DFS(S):
    word_list = ["dream", "dreamer", "erase", "eraser"]
    stack = deque(word_list)
    while stack:
        word = stack.pop()
        if word == S[0]:
            return "Yes"
        for i in word_list:
            next_word = word + i
            check = S[0][:len(word + i)]
            if next_word != check:
                continue
            if next_word == check:
                stack.append(next_word)
    return "NO"






if __name__ == "__main__":
    S = [input()]
    print(DFS(S))

Submission status: Wrong Answer

Solution code:
S = input()

dp = [False] * (len(S) + 1)
dp[0] = True
T = ['dream', 'dreamer', 'erase', 'eraser']
for i in range(1, len(S) + 1):
    tmp = []
    for t in T:
        if i < len(t):
            continue
        tmp.append(dp[i-len(t)] and t == S[i-len(t): i])
    if any(tmp):
        dp[i] = True
print('Yes' if dp[len(S)] else 'No')

Submission status: Wrong Answer

Solution code:
import queue


def check_dream(s):
    return s.startswith('dream')


def check_dreamer(s):
    return s.startswith('dreamer')


def check_erase(s):
    return s.startswith('erase')


def check_eraser(s):
    return s.startswith('eraser')


def check_sentence(s, q):
    if check_dream(s):
        q.put(s[5:])

    if check_dreamer(s):
        q.put(s[7:])

    if check_erase(s):
        q.put(s[5:])

    if check_eraser(s):
        q.put(s[7:])

    return q


def search():
    sentence_q = queue.Queue()
    initial_s = input()

    s = initial_s
    while(1):
        if s == '':
            return True

        sentence_q = check_sentence(s, sentence_q)
        if sentence_q.empty():
            return False

        s = sentence_q.get()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()

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

while any([w in S for w in words]):
    if S[:5] == 'dream':
        S = S[5:]
        if len(S) == 2 or (len(S) >= 3 and (S[:3] == 'erd' or S[:3] == 'ere')):
            S = S[2:]
    else:
        S = S[5:]
        if len(S) >= 1 and S[0] == 'r':
            S = S[1:]
        
print('YES' if len(S) == 0 else 'NO')

Submission status: Wrong Answer

Solution code:
#入力
S = input()

#使用する文字列リストを作成
str_list = ["dream", "dreamer", "erase", "eraser"]

#出力を1回にするためにflagを設定
flag = 0

for str1 in str_list:
    for str2 in str_list:
        for str3 in str_list:
            for str4 in str_list:
                
                T = str4
                if S==T and flag==0:
                    flag += 1
                    print("YES")
                    
                    break
                    
                T = str4+str3
                if S==T and flag==0:
                    flag += 1
                    print("YES")
                    
                    break
                    
                T = str4+str3+str2     
                if S==T and flag==0:
                    flag += 1
                    print("YES")
                    
                    break
                    
                T = str4+str3+str2+str1 
                if S==T and flag==0:
                    flag += 1
                    print("YES")
                    
                    break
                    
if not S==T and flag==0:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = str(input())
if s[0] != 'e' or 'd':
    print("NO")