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()

start = 0

while start < len(S):
    print(start)
    if start == len(S)-8 or start > len(S)-5:
        print("NO")
        exit()
    elif start == len(S)-7 and S[start:start+7] == "dreamer":
        print("YES")
        exit()
    elif start == len(S)-6 and S[start:start+6] == "eraser":
        print("YES")
        exit()
    elif start == len(S)-5 and S[start:start+5] == "erase":
        print("YES")
        exit()
    elif start == len(S)-5 and S[start:start+5] == "dream":
        print("YES")
        exit()
    elif S[start:start+6] == "eraser":
        start +=6
    elif S[start:start+5] == "erase":
        start +=5
    elif S[start:start+8] == "dreamera":
        start +=5
    elif S[start:start+7] == "dreamer":
        start +=7
    elif S[start:start+5] == "dream":
        start +=5
    else:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

Solution code:
S = input()

start = 0

while start < len(S):
    if start == len(S)-8 or start > len(S)-5:
        print("NO")
        exit()
    elif start == len(S)-7 and S[start:start+7] == "dreamer":
        print("YES")
        exit()
    elif start == len(S)-6 and S[start:start+6] == "eraser":
        print("YES")
        exit()
    elif start == len(S)-5 and S[start:start+5] == "erase":
        print("YES")
        exit()
    elif start == len(S)-5 and S[start:start+5] == "dream":
        print("YES")
        exit()
    elif S[start:start+6] == "eraser":
        start =6
    elif S[start:start+5] == "erase":
        start =5
    elif S[start:start+8] == "dreamera":
        start =5
    elif S[start:start+7] == "dreamer":
        start =7
    elif S[start:start+5] == "dream":
        start =5
    else:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

Solution code:
S = input()

start = 0

while start < len(S):
    if start == len(S)-8 or start >= len(S)-4:
        print("NO")
        exit()
    elif start == len(S)-7 and S[start:start+7] == "dreamer":
        print("YES")
        exit()
    elif start == len(S)-6 and S[start:start+6] == "eraser":
        print("YES")
        exit()
    elif start == len(S)-5 and S[start:start+5] == "erase":
        print("YES")
        exit()
    elif start == len(S)-5 and S[start:start+5] == "dream":
        print("YES")
        exit()
    elif S[start:start+6] == "eraser":
        start =6
    elif S[start:start+5] == "erase":
        start =5
    elif S[start:start+8] == "dreamera":
        start =5
    elif S[start:start+7] == "dreamer":
        start =7
    elif S[start:start+5] == "dream":
        start =5
    else:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

Solution code:
def check(str):
	for i in range(len(str)//5+1):
		if str=="":
			return "YES"
		elif str[-5:]=="dream" or str[-5:]=="erase" :
			str=str[:-5]
		elif str[-6:]=="dreamer" or str[-6:]=="eraser":
			str=str[:-6]
		else:
			return "NO"

str=input()
print(check(str))

Submission status: Wrong Answer

Solution code:
#C問題
import re
S = str(input())
p = re.match('(dream|dreamer|erase|eraser)+$',S)
if p:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
s = input()
t_list = ("dream", "dreamer", "erase", "eraser")
right = len(s)
left = 0
counter = 10
while counter > 0:
    for i in t_list:
        if s[left-len(i):right] == i:
            right -= len(i)
            left -= len(i)
        counter -= 1
if right == 0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

w = ['dream'[::-1], 'dreamer'[::-1], 'erase'[::-1], 'eraser'[::-1]]

current_position = 0


while current_position < len(s):
    if s[current_position:current_position+5] == w[0]:
        current_position += 5
    
    elif s[current_position:current_position+7] == w[1]:
        current_position += 7
    
    elif s[current_position:current_position+6] == w[3]:
        current_position += 6
    
    elif s[current_position:current_position+5] == w[2]:
        current_position += 5
    
    else:
        break
    
if current_position == len(s):
    print('YES')

Submission status: Wrong Answer

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

w = ['dream'[::-1], 'dreamer'[::-1], 'erase'[::-1], 'eraser'[::-1]]

current_position = 0


while current_position < len(s):
    if s[current_position] == 'm':
        current_position += 5
    
    elif s[current_position] == 'r' and s[current_position+2] == 'm':
        current_position += 7
    
    elif s[current_position] == 'r' and s[current_position+2] == 's':
        current_position += 6
    
    elif s[current_position] == 'e':
        current_position += 5
    
    else:
        break
    
if current_position == len(s):
    print('YES')

else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
t = ''
divide = ['dream','dreamer','erase','eraser']
#後ろから見るために文字列を反転
s = s[::-1]
for i in range(4):
    divide[i] = divide[i][::-1]
i = 0
while i < len(s):
    searched = True
    for j in range(4):
        div_str = divide[j]
        #print(s[i:i+len(div_str)])
        if s[i:i+len(div_str)] == div_str:
            t += s[i:i+len(div_str)]
            i += len(div_str)
        elif j == 3:
            searched = False
    if searched == False:
        break

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

Submission status: Wrong Answer

Solution code:
import re
print("YES" if re.match("^[dream,dreamer,erase,eraser]+$",input()) else "NO")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
S = input()
S=S.replace('dreamer','')
S=S.replace('eraser','')
S=S.replace('dream','')
S=S.replace('erase','')

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
S = input()
S=S.replace('dream','')
S=S.replace('dreamer','')
S=S.replace('erase','')
S=S.replace('eraser','')

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
S = input()
S.replace('dream','')
S.replace('dreamer','')
S.replace('erase','')
S.replace('eraser','')

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

Submission status: Wrong Answer

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

divide = ["esare","resare","maerd","remaerd"]
hantei = False
i = 0

while i < len(S):
    for j in range(len(divide)):
        if (len(S[j:]) >= len(divide[j])) and (S[i:i+len(divide[j])] == divide[j]):
            i += len(divide[j])
            break
    else:
         break
else:
    hantei = True

if hantei:
    print("YES")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
S = input()
S = S[::-1]
  
if 'esare' in S:
  S = S.replace('esare','')
  
if 'maerd' in S:
  S = S.replace('maerd','')

if 'remaerd' in S:
  S = S.replace('remaerd','')

if 'resare' in S:
  S = S.replace('resare','')
  
if len(S) == 0:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
S = S[::-1]
print(S)
  
if 'esare' in S:
  S = S.replace('esare','')
  
if 'maerd' in S:
  S = S.replace('maerd','')

if 'remaerd' in S:
  S = S.replace('remaerd','')

if 'resare' in S:
  S = S.replace('resare','')
  
if len(S) == 0:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
S = S[::-1]
print(S)
  
if 'esare' in S:
  S = S.replace('esare','')
  print(S)
  
if 'maerd' in S:
  S = S.replace('maerd','')
  print(S)

if 'remaerd' in S:
  S = S.replace('remaerd','')
  print(S)

if 'resare' in S:
  S = S.replace('resare','')
  print(S)
  
if len(S) == 0:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
words = ['dream', 'dreamer',  'erase', 'eraser']
# dream/dreamer
if 'dreamer' in S:
  S = S.replace('dreamer','')
  
if 'dream' in S:
  S = S.replace('dream','')

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

if 'erase' in S:
  S = S.replace('erase','')
  
if len(S) == 0:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
words = ['dream', 'dreamer',  'erase', 'eraser']
# dream/dreamer
if 'dreamer' in S:
  S = S.replace('dreamer','')
  
if 'dream' in S:
  S = S.replace('dream','')

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

if 'erase' in S:
  S = S.replace('erase','')
  
if len(S) == 0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

s = input()
i = 0
while i < len(s):
  nx = s[i:i+5]
  if nx != suf[0] and nx != suf[2]:
    print("NO")
    exit(0)
  i += 5
  if i < len(s) and s[i] == 'r':
    i += 1
    continue
  if s[i:i+2] == 'er':
    i += 2
print("YES")

Submission status: Wrong Answer

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

s = input()
i = 0
while i < len(s):
  nx = s[i:i+5]
  if nx != suf[0] and nx != suf[2]:
    print("NO")
    exit(0)
  i += 5
  if i < len(s) and s[i] == 'r':
    i += 1
print("YES")

Submission status: Wrong Answer

Solution code:
S = input()
S_original = S
S = S + "@" * 7
S_temp = []
i = 0
while (len(S_original) != len(S_temp) or len(S) > i):
    if S[i] == "d":
        if (S[i+5] == "e" and S[i+7] == "a") or S[i+5] == "d":
            S_temp.append("dream")
            i += 5
        elif S[i+5] == "e" and S[i+7] != "@":
            S_temp.append("dreamer")
            i += 7
        elif S[i+5] == "@":
            S_temp.append("dream")
            break
        elif S[i+5] == "e" and S[i+7] == "@":
            S_temp.append("dreamer")
            break
        else:
            break
    elif S[i] == "e":
        if S[i+5] == "r" and S[i+6] != "@":
            S_temp.append("eraser")
            i += 6
        elif S[i+5] == "d":
            S_temp.append("erase")
            i += 5
        elif S[i+5] == "@":
            S_temp.append("erase")
            break
        elif S[i+5] == "r" and S[i+6] == "@":
            S_temp.append("eraser")
            break
        else:
            break
    else:
        break

if S_original == "".join(S_temp):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()[::-1]
T = list(['maerd', 'remaerd', 'esare', 'resare'])
while(1):
    if len(S) == 0:
        print('YES')
        break
    elif S[:5] in T:
        S = S[5:]
    elif S[:6] in T:
        S = S[6:]
    else:
        print('NO')
        break

Submission status: Wrong Answer

Solution code:
S = input()[::-1]
T = list(['maerd', 'remaerd', 'esare', 'resare'])
start = 0
while(1):
    if start == len(S):
        print('YES')
        break
    elif S[start: start + 5] in T:
        start += 5
    elif S[start: start + 6] in T:
        start += 6
    else:
        print('NO')
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
l = ["dream","erase","dreamer", "eraser"]
for i in l:
        for j in l:
                word = i + j
                if word == s:
                        print("YES")
                        exit()
print("NO")

Submission status: Wrong Answer

Solution code:
import re
s=input()
if re.search(r"(dreamer|dream|erase|eraser)*",s):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

while 1:
    #dreamの逆
    if s[:5] == "maerd":
        s=s[5::]
    #dreamerの逆
    elif s[:6] == "remaerd":
        s=s[6::]
    #eraseの逆
    elif s[:5] == "esare":
        s=s[5::]
    #eraserの逆
    elif s[:6] == "resare":
        s=s[6::]
    #出来ない
    else:
        print("NO")
        break
    #全部できた
    if len(s)==0:
        print("YES")
        break

Submission status: Wrong Answer

Solution code:
S = input()
S_list = list(S)

while len(S_list) >= 5 :
    a = len(S_list)
    if S_list[0:5] == ['e', 'r', 'a', 's', 'e']:
        if a >= 6 :
            if S_list[5] == 'r' :
                del S_list[0:6]
            else:
                del S_list[0:5]
        else:
            del S_list[0:5]
    elif S_list[0:5] == ['d', 'r', 'e', 'a', 'm']:
        if a >= 8 :
            if S_list[5:8] == ['e', 'r', 'a'] :
                del S_list[0:5]
            else:
                del S_list[0:7]
        elif a >= 7 :
            if S_list[5:7] == ['e', 'r'] :
                del S_list[0:7]
            else:
                del S_list[0:5]
        else :
            del S_list[0:5]
    else:
        print('NO')
        break


if len(S_list) == 0:
    print('YES')
elif 0<len(S_list)<5:
    print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
S_list = list(S)

while len(S_list) >= 5 :
    a = len(S_list)
    if S_list[0:5] == ['e', 'r', 'a', 's', 'e']:
        if a >= 6 :
            if S_list[5] == 'r' :
                del S_list[0:6]
            else:
                del S_list[0:5]
        else:
            del S_list[0:5]
    elif S_list[0:5] == ['d', 'r', 'e', 'a', 'm']:
        if a >= 8 :
            if S_list[5:8] == ['e', 'r', 'a'] :
                del S_list[0:5]
            else:
                del S_list[0:5]
        elif a >= 7 :
            if S_list[5:7] == ['e', 'r'] :
                del S_list[0:7]
            else:
                del S_list[0:5]
        else :
            del S_list[0:5]
    else:
        print('NO')
        break


if len(S_list) == 0:
    print('YES')
elif 0<len(S_list)<5:
    print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
S_list = list(S)

while len(S_list) >= 5 :
    a = len(S_list)
    if S_list[0:5] == ['e', 'r', 'a', 's', 'e']:
        if a >= 6 :
            if S_list[5] == 'r' :
                del S_list[0:6]
            else:
                del S_list[0:5]
        else:
            del S_list[0:5]
    elif S_list[0:5] == ['d', 'r', 'e', 'a', 'm']:
        if a >= 8 :
            if S_list[5:8] == ['e', 'r', 'a'] :
                del S_list[0:5]
            else:
                del S_list[0:5]
        elif a >= 7 :
            if S_list[5:7] == ['e', 'r'] :
                del S_list[0:7]
            else:
                del S_list[0:7]
        else :
            del S_list[0:5]
    else:
        print('NO')
        break


if len(S_list) == 0:
    print('YES')
elif 0<len(S_list)<5:
    print('NO')

Submission status: Wrong Answer

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

last = ['mae', 'rem', 'esa', 'res']
length = [5, 7, 5, 6]

index = 0
while index < len(S):
    for i, tail in enumerate(last) :
        sub = S[index:index + 3]
        if sub == tail :
            index += length[i]
            break
    else :
        print('NO')
        break
else :
    print('YES')

Submission status: Wrong Answer

Solution code:
print("No")

Submission status: Wrong Answer

Solution code:
S = input()
r_S = S[::-1]
devide = ["dream", "dreamer", "erase", "eraser"]
r_devide = [d[::-1] for d in devide]
string = r_S
can = False

while string != '':
  can = False
  for d in r_devide:
    if string[:len(d)] == d:
      can = True
      string = string[len(d):]
  if can == False:
    break

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

Submission status: Wrong Answer

Solution code:
S = input()
r_S = S[::-1]
devide = ["dream", "dreamer", "erase", "eraser"]
r_devide = [d[::-1] for d in devide]
string = r_S

while string != '':
  can = False
  for d in r_devide:
    if string[:len(d)] == d:
      can = True
      string = string[len(d):]
  if can == False:
    break

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

Submission status: Wrong Answer

Solution code:
S = input()
r_S = S[::-1]
devide = ["dream", "dreamer", "erase", "eraser"]
r_devide = [d[::-1] for d in devide]
string = r_S

while string != '':
  can = False
  for d in r_devide:
    if string[:len(d)] == d:
      can = True
      string = string[len(d):]
  if can == False:
    break

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

S = input()

T = ""

while T in S and T != S:

    if S[len(T)] == "d":

        if len(S) == len(T) + 5:
            T += "dream"

        elif len(S) == len(T) + 7:
            T += "dreamer"

        elif len(S)>=len(T)+7 and (S[len(T) + 7] == "d" or S[len(T) + 7] == "e"):
            T += "dreamer"

        else:
            T += "dream"

    else:

        if len(S) == len(T) + 5:
            T += "erase"

        elif len(S)>=len(T)+6 and S[len(T) + 5] == "r":
            T += "eraser"

        else:
            T += "erase"

    #print (T)

#print (T)

if T == S:
    print ("YES")

else:
    print ("NO")

Submission status: Wrong Answer

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

def main():
    s = list(input())
    tmp = ''
    n_tmp=""
    max_s = len(s)
    cnt = 0
    flag = True
    while cnt < max_s:

        for i in range(cnt,cnt+5):
            tmp += s[i]
        if cnt +10 > max_s:
            for i in s[cnt+5:]:
                tmp += i
            if tmp == "dreamer" or tmp == "eraser":
                break
            else:
                flag = False
                break
        else:
            for j in range(cnt+5,cnt+10):
                n_tmp += s[j]
        if (tmp == "dream" or tmp == "erase") and (n_tmp == "dream" or n_tmp =="erase"):
            tmp = ""
            n_tmp = ""
            cnt += 5
        elif tmp == "dream" and (n_tmp=="erdre" or n_tmp == "erera"):
            tmp=""
            n_tmp=""
            cnt += 7
        elif tmp =="erase" and (n_tmp == "erdre" or n_tmp == "erera"):
            tmp=""
            n_tmp=""
            cnt += 6
        if len(s) - cnt <= 7:
            tmp = ""
            for i in s[cnt:]:
                tmp += i
            if tmp == "dream" or tmp == "dreamer" or tmp == "erase" or tmp == "eraser":
                break
            else:
                flag = False
                break
        flag = False
        break

    if flag:
        print('YES')
    else:
        print('NO')
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

def main():
    s = list(input())
    tmp = ''
    n_tmp=""
    max_s = len(s)
    cnt = 0
    flag = True
    while cnt < max_s:

        for i in range(cnt,cnt+5):
            tmp += s[i]
        if cnt +10 > max_s:
            for i in s[cnt+5:]:
                tmp += i
            if tmp == "dreamer" or tmp == "eraser":
                break
            else:
                flag = False
                break
        else:
            for j in range(cnt+5,cnt+10):
                n_tmp += s[j]
        if (tmp == "dream" or tmp == "erase") and (n_tmp == "dream" or n_tmp =="erase"):
            tmp = ""
            n_tmp = ""
            cnt += 5
        elif tmp == "dream" and (n_tmp=="erdre" or n_tmp == "erera"):
            tmp=""
            n_tmp=""
            cnt += 7
        elif tmp =="erase" and (n_tmp == "erdre" or n_tmp == "erera"):
            tmp=""
            n_tmp=""
            cnt += 6
        if len(s) - cnt <= 7:
            tmp = ""
            for i in s[cnt:]:
                tmp += i
            if tmp == "dream" or tmp == "dreamer" or tmp == "erase" or tmp == "eraser":
                break
            else:
                flag = False
                break
        flag = False
        break

    if flag:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
s = str(input())

def judge(s):
    if s.startswith("dream") or s.startswith("erase"):
        return True
    else:
        return False

while len(s) > 0:
    if s.startswith("dream"):
        s = s[5:]
        if judge(s) == False:
            if s.startswith("er"):
                s = s[2:]

    elif s.startswith("erase"):
        s = s[5:]
        if judge(s) == False:
            if s.startswith("er"):
                s = s[2:]

    else:
        print("NO")
        sys.exit()

print("YES")

Submission status: Wrong Answer

Solution code:
s = str(input())[::-1]
while True:
    if s[:5]=="maerd" or s[:5]=="esare":
        s=s[5:]
        if len(s)==0:
            print("YES")
            exit()
    elif s[:7]=="remaerd" or s[:7]=="resare":
        s=s[7:]
        if len(s)==0:
            print("YES")
            exit()
    else:
        print("NO")
        exit()

Submission status: Wrong Answer

Solution code:
S = input()

f = 0
while(1):
    #print(S)                                                                                                                                                                      
    if len(S) <= 4:
        break
    if S[:5] == "dream":
        if len(S) == 5:
            f = 1
            break
        elif len(S) == 6:
            break
        if S[:7] == "dreamer":
            if len(S) == 7:
                f = 1
                break
            if S[7] != "a":
                S = S[7:]
                continue
            else:
                S = S[5:]
        else:
            S = S[5:]
    elif S[:5] == "erase":
        if len(S) == 5:
            f = 1
            break
        if S[:6] == "eraser":
            if len(S) == 6:
                f = 1
                break
            if S[6] != "a":
                S = S[7:]
                continue
            else:
                S = S[:5]
        else:
            S = S[5:]
    else:
        break

if f == 0:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
S = input()

f = 0
while(1):
    print(S)
    if len(S) <= 4:
        break
    if S[:5] == "dream":
        if len(S) == 5:
            f = 1
            break
        elif len(S) == 6:
            break
        if S[:7] == "dreamer":
            if len(S) == 7:
                f = 1
                break
            if S[7] != "a":
                S = S[7:]
                continue
            else:
                S = S[5:]
        else:
            S = S[5:]
    elif S[:5] == "erase":
        if len(S) == 5:
            f = 1
            break
        if S[:6] == "eraser":
            if len(S) == 6:
                f = 1
                break
            if S[6] != "a":
                S = S[7:]
                continue
            else:
                S = S[:5]
        else:
            S = S[5:]
    else:
        break

if f == 0:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
S = input()
while True:
    if len(S)!=0:
        if S[len(S)-7:len(S)]=="dreamer":
            S = S.rstrip("dreamer")
        elif S[len(S)-6:len(S)]=="eraser":
            S = S.rstrip("eraser")
        elif S[len(S)-5:len(S)]=="dream":
            S = S.rstrip("dream")
        elif S[len(S)-5:len(S)]=="erase":
            S = S.rstrip("erase")
        else:
            print("NO")
            break
    else:
        print("YES")
        break

Submission status: Wrong Answer

Solution code:
S = input()

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

for i in range(len(S))[::-1]:
  for j in range(4):
    if S[i:] == words[j]:
      S = S.replace(words[j],'')
      i += len(words[j])
    if S == '':
      print('YES')
      exit()
      
print('NO')

Submission status: Wrong Answer

Solution code:
S = input()

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

result = 1
while result > 0:
    for fstr in fstrs:
        result = S.rfind(fstr)
        if result == len(S) - len(fstr):
            S = S[0:result]

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

Submission status: Wrong Answer

Solution code:
S = input()
ls = len(S)
i = 0
while True:
    if (ls-i-1>=4):
        if S[i:i+5]=='dream':
            if S[i:] == 'dream' or S[i:] == 'dreamer':
                print('YES')
                break
            elif ls-1>=i+7:
                if S[i+5] == 'd':
                    i+=5
                    continue
                elif S[i+7]=='a':
                    i+=5
                    continue
                elif S[i+7]=='d' or S[i+7]=='e':
                    i+=7
                    continue

        elif S[i:i+5]=='erase':
            if S[i:] == 'erase' or S[i:] =='eraser':
                print('YES')
                break
            elif ls-1>=i+5:
                if S[i+5]=='r':
                    i += 6
                    continue
                elif S[i+5]=='d' or S[i+5]=='e':
                    i += 5
                    continue
    print('NO')
    break

Submission status: Wrong Answer

Solution code:
S = input()
ls = len(S)
i = 0
while True:
    if (ls-i-1>=4):
        if S[i:i+5]=='dream':
            if (ls-i-1==4) or ((ls-i-1==6) and S[i+5:]=='er'):
                print('YES')
                break
            elif ls-i-1>6:
                if S[i+5] == 'd':
                    i+=5
                    continue
                elif S[i+7]=='a':
                    i+=5
                    continue
                elif S[i+7]=='d' or S[i+7] == 'e':
                    i+=7
                    continue

        elif S[i:i+5]=='erase':
            if ls-i-1==4 or ((ls-i-1==5) and S[i+5:]=='r'):
                print('YES')
                break
            elif ls-i-1>5:
                if S[i+5]=='r':
                    i += 6
                    continue
                elif S[i+5]=='d' or S[i+5]=='e':
                    i += 5
                    continue
    print('NO')
    break

Submission status: Wrong Answer

Solution code:
S = input()
ls = len(S)
i = 0
while True:
    if (ls-i-1>=4):
        if S[i:i+5]=='dream':
            if (ls-i-1==4) or ((ls-i-1==6) and S[i+5:]=='er'):
                print('YES')
                break
            elif ls-i-1>6:
                if S[i+5] == 'd':
                    i+=5
                elif S[i+7]=='a':
                    i+=5
                    continue
                elif S[i+7]=='d' or S[i+7] == 'e':
                    i+=7
                    continue

        elif S[i:i+5]=='erase':
            if ls-i-1==4 or ((ls-i-1==5) and S[i+5:]=='r'):
                print('YES')
                break
            elif ls-i-1>5:
                if S[i+5]=='r':
                    i += 6
                    continue
                elif S[i+5]=='d' or S[i+5]=='e':
                    i += 5
                    continue
    print('NO')
    break

Submission status: Wrong Answer

Solution code:
S = input()
ls = len(S)
i = 0
while True:
    if (ls-i-1>=4):
        if S[i:i+5]=='dream':
            if (ls-i-1==4) or ((ls-i-1==6) and S[i+5:]=='er'):
                print('YES')
                break
            elif ls-i-1>6:
                if S[i+7]=='a' or S[i+7:i+9] == 'ea':
                    i+=5
                    continue
                elif S[i+7]=='d' or S[i+7:i+9] == 'er':
                    i+=7
                    continue

        elif S[i:i+5]=='erase':
            if ls-i-1==4 or ((ls-i-1==5) and S[i+5:]=='r'):
                print('YES')
                break
            elif ls-i-1>5:
                if S[i+5]=='r':
                    i += 6
                    continue
                elif S[i+5]=='d' or S[i+5]=='e':
                    i += 5
                    continue
    print('NO')
    break

Submission status: Wrong Answer

Solution code:
S = input()
ls = len(S)
i = 0
while True:
    if (ls-i-1>=4):
        if S[i:i+5]=='dream':
            if (ls-i-1==4) or ((ls-i-1==6) and S[i+5:]=='er'):
                print('YES')
                break
            elif ls-i-1>6:
                if S[i+7]=='a' or S[i+7] == 'e':
                    i+=5
                    continue
                elif S[i+7]=='d':
                    i+=7
                    continue
                    
        elif S[i:i+5]=='erase':
            if ls-i-1==4 or ((ls-i-1==5) and S[i+5:]=='r'):
                print('YES')
                break
            elif ls-i-1>5:
                if S[i+5]=='r':
                    i += 6
                    continue
                elif S[i+5]=='d' or S[i+5]=='e':
                    i += 5
                    continue
    print('NO')
    break

Submission status: Wrong Answer

Solution code:
S = input()
ls = len(S)
i = 0
while True:
    if (ls-i-1>=4):
        if S[i:i+5]=='dream':
            if (ls-i-1==4) or ((ls-i-1==6) and S[i+5:]=='er'):
                print('YES')
                break
            elif ls-i-1>6:
                if S[i+7]=='a':
                    i+=5
                    continue
                elif S[i+7]=='d' or S[i+7]=='e':
                    i+=7
                    continue

        elif S[i:i+5]=='erase':
            if ls-i-1==4 or ((ls-i-1==5) and S[i+5:]=='r'):
                print('YES')
                break
            elif ls-i-1>5:
                if S[i+5]=='r':
                    i += 6
                    continue
                elif S[i+5]=='d' or S[i+5]=='e':
                    i += 5
                    continue
    print('NO')
    break

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# https://atcoder.jp/contests/abc049/tasks/arc065_a

s = input()
words = ['maerd', 'remaerd', 'resare', 'esare']

for word in words:
    if s[::-1].find(word) != -1:
        s = s.replace(word[::-1], '')

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# https://atcoder.jp/contests/abc049/tasks/arc065_a

s = input()
words = ['maerd', 'remaerd', 'resare', 'esare']

for word in words:
    if s[::-1].find(word) != -1:
        s = s.replace(word[::-1], '')
        print(s)

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

Submission status: Wrong Answer

Solution code:
s = input()
print(s)

Submission status: Wrong Answer

Solution code:
import re

S=input()[::-1]

while S:
    m=re.match(r'(maerd|remaerd|esare|resare)',S)
    if m:
        S=S.replace(m.group(),'')
    else:
        print('NO')
        exit()

print('YES')