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()+'#'
n=len(s)
i=0
while i<n:
  if s[i]=='#':
    i=n
  elif s[i:i+7]=='dreamer':
    i+=7
  elif s[i:i+6]=='eraser':
    i+=6
  elif s[i:i+5]=='dream' or s[i:i+5]=='erase':
    i+=5
  else:
    print('NO')
    exit()
print('YES')

Submission status: Wrong Answer

Solution code:
from itertools import permutations

s = input()

words = ["dream", "dreamer", "erase", "eraser"]
words_combinations = ["".join(j) for i in range(1, len(words)+1) for j in permutations(words, i)]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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:
T=[]
S=input()
Sr=''.join(list(reversed(S)))
w1=''.join(list(reversed('dream')))
w2=''.join(list(reversed('dreamer')))
w3=''.join(list(reversed('erase')))
w4=''.join(list(reversed('eraser')))

#print(w1,w2,w3,w4)
#print(Sr)
    
SS=list(Sr.replace(w1,'').replace(w2,'').replace(w3,'').replace(w4,''))        
#.strip()で()内の文字列の組み合わせの部分を削除できる。←組み合わせなので
#'abc'の場合に'a'単品で消したりするので没に
#replace()使います
#ただし非破壊的なのでforぶんで回したりするとSrに変化がなかったりする。
#なので４かい消す操作をした

#print(SS)
if SS==T:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
T=[]
S=input()
Sr=''.join(list(reversed(S)))
w1=''.join(list(reversed('dream')))
w2=''.join(list(reversed('dreamer')))
w3=''.join(list(reversed('erase')))
w4=''.join(list(reversed('eraser')))

#print(w1,w2,w3,w4)
#print(Sr)
    
SS=list(Sr.strip(w1).strip(w2).strip(w3).strip(w4))        
#.strip()で()内の文字列の組み合わせの部分を削除できる。
#ただし非破壊的なのでforぶんで回したりするとSrに変化がなかったりする。
#なので４かい消す操作をした

#print(SS)
if SS==T:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
data = ['dreamer','dream','eraser','erase']
word = input()
for i in data:
  while i in word:
    word = word.replace(i,"")
if word == "":
  print("YES")
else :
  print("NO")

Submission status: Wrong Answer

Solution code:
data = ['dream','dreamer','erase','eraser']
word = input()
for i in data:
  while i in word:
    word = word.replace(i,"")
if word == "":
  print("YES")
else :
  print("NO")

Submission status: Wrong Answer

Solution code:
data = ['dream','dreamer','erase','eraser']
word = input()
for i in data:
  while i in word:
    word = word.strip(i)
if word =="":
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
S = input()

i = 0
while i <= len(S) - 1:
    if S[i] == "d":
            if S[i:i+11] == "dreameraser":
                i += 11
            elif S[i:i+10] == "dreamerase":
                i += 10
            elif S[i:i+7] == "dreamer":
                i += 7
            elif S[i:i+6] == "dream":
                i += 6
            else:
                print("NO")
                exit()
    elif S[i] == "e":
            if S[i:i+6] == "eraser":
                i += 6
            elif S[i:i+5] == "erase":
                i += 5
            else:
                print("NO")
                exit()
    else:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

Solution code:
S = input()

i = 0
while i <= len(S) - 1:
    if S[i] == "d":
            if S[i:i+11] == "dreameraser":
                i += 11
            elif S[i:i+7] == "dreamer":
                i += 7
            elif S[i:i+6] == "dream":
                i += 6
            else:
                print("NO")
                exit()
    elif S[i] == "e":
            if S[i:i+6] == "eraser":
                i += 6
            elif S[i:i+5] == "erase":
                i += 5
            else:
                print("NO")
                exit()
    else:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

Solution code:
S = input()

candidate = ["dream", "dreamer", "erase", "eraser", "dreameraser"]

i = 0
while i <= len(S) - 1:
    if S[i] == "d":
        if i + 10 < len(S):
            if S[i + 10]  == "r":
                if not S[i:i+11] in candidate:
                    print("No")
                    exit()
                else:
                    i += 11
        elif i + 6 < len(S):
            if S[i+6] == "r":
                if not S[i:i+7] in candidate:
                    print("No")
                    exit()
                else:
                    i += 7
            elif not S[i:i+6] in candidate:
                print("No")
                exit()
            else:
                i += 6
        elif not S[i:i+6] in candidate:
                print("No")
                exit()
        else:
            i += 6
    elif S[i] == "e":
        if i + 5 < len(S):
            if S[i+5] == "r":
                if not S[i:i+6] in candidate:
                    print("No")
                    exit()
                else:
                    i += 6
            elif not S[i:i+5] in candidate:
                print("No")
                exit()
            else:
                i += 5
        elif not S[i:i+5] in candidate:
                print("No")
                exit()
        else:
            i += 5
    else:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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

print("YES" if len(rep_S)==0 else "NO")

Submission status: Wrong Answer

Solution code:
s = list(input())
t = ['dream','dreamer','erase','eraser']
ans = 0
for i in range(10):
    check = 0
    #print(s)
    for j in t:
        #print(str(s[-1 * (len(j)):]),list(j))
        if s[-1 * (len(j)):] == list(j):
            del s[-1 * (len(j)):]
            check = 1
            break
    if len(s) == 0:
        ans = 1
        break
if ans == 1:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000)

#S = input()
S = 'dreamerer' #'dreameraser' #'dreamerer' #'dreameraser'# 'dreameraser'

T = ['dream', 'dreamer', 'erase', 'eraser']
lenT = [len(i) for i in T]

def dayDream(pin):
    global isGoal               #;print('dayDream: ', pin, S[pin:])
    for i, d in enumerate(T):
        if isGoal:
            return
        #print('i, d:', i, d)
        if S[pin:pin+lenT[i]] == d:            
            pout = pin + lenT[i] #;print(d, pout)
            if pout == len(S):                
                isGoal = True    #;print('YES')
                return 
            else:
                dayDream(pout)
    #print('dayDream return', pin)
    return
    
isGoal = False
dayDream(0)
if isGoal:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
str = input()

str = str[::-1]

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

for i in range(4):
    str_list[i] = str_list[i][::-1]

result = "YES"

while len(str) >= 5:
    if str[:5] == str_list[0]:
        str = str[5:]
    elif str[:6] == str_list[1]:
        str = str[6:]
    elif str[:5] == str_list[2]:
        str = str[5:]
    elif str[:6] == str_list[3]:
        str = str[6:]
    else:
        result = "NO"
        break

if len(str) != 0:
    result = "NO"

print(result)

Submission status: Wrong Answer

Solution code:
str = input()

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

result = "YES"

while len(str) >= 5:
    if str[:5] == str_list[0]:
        str = str[5:]
    elif str[:6] == str_list[1]:
        str = str[6:]
    elif str[:5] == str_list[2]:
        str = str[5:]
    elif str[:6] == str_list[3]:
        str = str[6:]
    else:
        result = "NO"
        break
        
if len(str) != 0:
    result = "NO"

print(result)

Submission status: Wrong Answer

Solution code:
#逆にしないと別の組み合わせができてしまう．（動的計画法はかしこい）
S = input()
word = ["dream","dreamer","erase","eraser"]

S = S[::-1] #入力文字を反転
for i in range(len(word)): word[i] = word[i][::-1] #4つのワードを反転

print(S, S[5:], S[11:] == "")

while True:
    for i in range(len(word)):
        flag2 = False
        if word[i] == S[:len(word[i])]:
            flag2 = True
            S = S[len(word[i]):]
            break
    if S == "":
        print("YES")
        break #全て一致して空文字になる
    elif flag2 == False:
        print("NO")
        break #一致しなかったとき



#print(S[::-1], word[1][::-1])

Submission status: Wrong Answer

Solution code:
s = input()
s_origin = s
t = ""
word_list = ["dream", "dreamer", "erase", "eraser"]
while True:
    flag = True
    if len(s) <= 4:
        break

    if len(s) == 5:
        s_child_1 = s[-5:]
        if s_child_1 in word_list:
            t = s[-5:] + t
            s = s[:-5]
        break
    
    if len(s) == 6:
        break

    s_child_2 = s[-7:]
    if s_child_2 in word_list:
        t = s[-7:] + t
        s = s[:-7]
        flag = False

    s_child_1 = s[-5:]
    if s_child_1 in word_list:
        t = s[-5:] + t
        s = s[:-5]
        flag = False
    
    if flag:
        break

if s_origin == t:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
s_origin = s
t = ""
word_list = ["dream", "dreamer", "erase", "eraser"]
while True:
    if len(s) <= 4:
        break

    if len(s) == 5:
        s_child_1 = s[-5:]
        if s_child_1 in word_list:
            t = s[-5:] + t
            s = s[:-5]
        break

    s_child_2 = s[-6:]
    if s_child_2 in word_list:
        t = s[-6:] + t
        s = s[:-6]
        flag = False

    flag = True
    s_child_1 = s[-5:]
    
    if s_child_1 in word_list:
        t = s[-5:] + t
        s = s[:-5]
        flag = False
    
    if flag:
        break

if s_origin == t:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
s_origin = s
t = ""
word_list = ["dream", "dreamer", "erase", "eraser"]
while True:
    if len(s) <= 4:
        break

    if len(s) == 5:
        s_child_1 = s[-5:]
        if s_child_1 in word_list:
            t = s[-5:] + t
            s = s[:-5]
        break

    s_child_2 = s[-6:]
    if s_child_2 in word_list:
        t = s[-6:] + t
        s = s[:-6]
        flag = False

    flag = True
    s_child_1 = s[-5:]
    
    if s_child_1 in word_list:
        t = s[-5:] + t
        s = s[:-5]
        flag = False
    
    if flag:
        break

print(t)
if s_origin == t:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
s_origin = s
t = ""
word_list = ["dream", "dreamer", "erase", "eraser"]
while True:
    if len(s) <= 4:
        break

    if len(s) == 5:
        s_child_1 = s[-5:]
        if s_child_1 in word_list:
            t += s[-5:]
            s = s[-5:]
        break

    s_child_2 = s[-6:]
    if s_child_2 in word_list:
        t += s[-6:]
        s = s[-6:]
        flag = False

    flag = True
    s_child_1 = s[-5:]
    
    if s_child_1 in word_list:
        t += s[-5:]
        s = s[-5:]
        flag = False

    if len(s) <= 5:
        break

    
    if flag:
        break

if s_origin == t:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
s_origin = s
t = ""
word_list = ["dream", "dreamer", "erase", "eraser"]
while True:
    if len(s) <= 4:
        break
    
    if len(s) == 5:
        s_child_1 = s[:5]
        if s_child_1 in word_list:
            t += s[:5]
            s = s[5:]
        break

    s_child_2 = s[:6]
    if s_child_2 in word_list:
        t += s[:6]
        s = s[6:]
        flag = False

    flag = True
    s_child_1 = s[:5]
    
    if s_child_1 in word_list:
        t += s[:5]
        s = s[5:]
        flag = False

    if len(s) <= 5:
        break

    
    if flag:
        break

if s_origin == t:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
s_origin = s
t = ""
word_list = ["dream", "dreamer", "erase", "eraser"]
while True:
    if len(s) <= 4:
        break

    flag = True
    s_child_1 = s[:5]
    
    if s_child_1 in word_list:
        t += s[:5]
        s = s[5:]
        flag = False

    if len(s) <= 5:
        break
    
    s_child_2 = s[:6]
    if s_child_2 in word_list:
        t += s[:6]
        s = s[6:]
        flag = False
    if flag:
        break

if s_origin == t:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
s_origin = s
t = ""
word_list = ["dream", "dreamer", "erase", "eraser"]
while True:
    flag = True
    s_child_1 = s[:5]
    
    if s_child_1 in word_list:
        t += s[:5]
        s = s[5:]
        flag = False
    s_child_2 = s[:6]
    if s_child_2 in word_list:
        t += s[:6]
        s = s[6:]
        flag = False
    if flag:
        break

if s_origin == t:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
# dream + eraser なのに dreamer を消さないように
# 先に dreamerase(r)を消しておく
S = S.replace("dreameraser", "")
S = S.replace("dreamerase", "")
# S = S.replace("dreamer", "")
# S = S.replace("dream", "")
# eraserより先にdreamerを消すとWAになりました
# dreameraserのパターンは消去済みなのに、なんでだろ
S = S.replace("eraser", "")
S = S.replace("erase", "")
S = S.replace("dreamer", "")
S = S.replace("dream", "")

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

Submission status: Wrong Answer

Solution code:
S = input()
# dream + eraser なのに dreamer を消さないように
# 先に dreamerase(r)を消しておく
S = S.replace("dreameraser", "")
S = S.replace("dreamerase", "")
S = S.replace("dreamer", "")
S = S.replace("dream", "")
S = S.replace("eraser", "")
S = S.replace("erase", "")

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

Submission status: Wrong Answer

Solution code:
s = input()[::-1]
len_s = len(s)
start, end = 0,5
ans = "YES"
while end <= len_s:
  if s[start:end] == "maerd" or s[start:end] == "esare":
    start += 5
    end += 5
  elif s[start:end+1] == "resare":
    start += 6
    end += 6
  elif s[start:end+1] == "remaerd":
    start += 7
    end += 7
  else:
    ans = "NO"
    break
print(ans)

Submission status: Wrong Answer

Solution code:
s=input()[::-1]
for i in range(10**5):
  if s[:5]=="meard":
    s=s[5:]
  elif s[:7]=="ermeard":
    s=s[7:]
  elif s[:5]=="esare":
    s=s[5:]
  elif s[:6]=="resare":
    s=s[6:]
  elif s=="":
    print("YES")
    break
  else:
    print("NO")
    break

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

S = input()
S_copy = S
T = []
words = ['dream', 'dreamer', 'erase', 'eraser']

while True:
    match = False
    word_matched = ''
    # check if S_copy ends with word in words
    for word in words:
        if S_copy.endswith(word):
            match = True
            # print('S_copy is', f'{S_copy}')
            # print('ends with', f'{word}')
            if len(word) > len(word_matched):
                # print('this word is longer than previous word_matched')
                # print('word:', f'{word}')
                # print('previous word_matched:', f'{word_matched}')
                word_matched = word

    if match:
        T.insert(0, word_matched)
        # ends with dreamer
        # erasedreamer => erase
        S_copy = S_copy[:-len(word_matched)]
    else:
        break

# print(S)
# print(''.join(T))
if S == ''.join(T):
    print('YES')
else:
    print('No')

Submission status: Wrong Answer

Solution code:


S = input()
ans = "YES"

while(S):
    if S.startswith("dream") or S.startswith("dreamerase") or S.startswith("dreameraser") and False == S.startswith("dreamer"):
        S = S[5:]
    elif S.startswith("dreamer"):
        S = S[7:]
    elif S.startswith("erase") and False == S.startswith("eraser"):
        S = S[5:]
    elif S.startswith("eraser"):
        S = S[6:]
    else:
        ans = "NO"
        break
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
ans = "Yes"

while(S):
    if S.startswith("dream") or S.startswith("dreamerase") or S.startswith("dreameraser") and False == S.startswith("dreamer"):
        S = S[5:]
    elif S.startswith("dreamer"):
        S = S[7:]
    elif S.startswith("erase") and False == S.startswith("eraser"):
        S = S[5:]
    elif S.startswith("eraser"):
        S = S[6:]
    else:
        ans = "No"
        break
print(ans)

Submission status: Wrong Answer

Solution code:


S = input()
ans = "Yes"

while(S):
    if S.startswith("dream") or S.startswith("dreamerase") or S.startswith("dreameraser") and False == S.startswith("dreamer"):
        S = S[5:]
    elif S.startswith("dreamer"):
        S = S[7:]
    elif S.startswith("erase") and False == S.startswith("eraser"):
        S = S[5:]
    elif S.startswith("eraser"):
        S = S[6:]
    else:
        ans = "No"
        break
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 = str(input())
if s.replace("eraser","").replace("erase","").replace("dream","").replace("dreamer","")=="":
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

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

i = 0
res = 'No'
while i < len(s):
    p = i
    
    for t in t_list:
        if s[i:i+len(t)] == t:
            i += len(t)
            if i == len(s):
                res = 'Yes'
            break

    if p==i or res=='Yes':
        break 

print(res)

Submission status: Wrong Answer

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

res = 'No'
while i < len(s):
    p = i
    for t in t_list:
        if s[i:i+len(t)] == t:
            i += len(t)
            if i == len(s):
                res = 'Yes'
            break
    if p==i or res=='Yes':
        break 

print(res)

Submission status: Wrong Answer

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

res = 'No'
while i < len(s):
    p = i
    for j in range(4):
        if s[i:i+len(t_list[j])] == t_list[j]:
            i+=len(t_list[j])
            if i == len(s):
                res = 'Yes'
            break
    if p==i or res=='Yes':
        break 

print(res)

Submission status: Wrong Answer

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

while i <= len(s)+1:
    can = False
    for j in range(4):
        if s[:len(t_list[j])] == t_list[j]:
            i+=len(t_list[j])
            can = True
    if can == False:
        break

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

Submission status: Wrong Answer

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

while i <= len(t_list)+1:
    can = False
    for j in range(4):
        if s[:len(t_list[j])] == t_list[j]:
            i+=len(t_list[j])
            can = True
    if can == False:
        break

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

ans = 'NO'
i = 0
while i < len(s):
  p = -1
  for w in words_r:
    p = s.find(w,i)    
    if p == i:
      i = p + len(w)
      if i == len(s):
        ans ='YES'
  if (p == -1) or ans=='YES':
    break

print(ans)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
length_substring_S = len(S)
test_str_list = ['dream', 'dreamer', 'erase', 'eraser']
flag = True

while flag == True:
  for i in range(len(test_str_list)):
    if S[0:length_substring_S].endswith(test_str_list[i]):
      length_substring_S -= len(test_str_list[i])
      flag = True
      break
  flag = False

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

Submission status: Wrong Answer

Solution code:
S = input()
sr = ''
for i in S:
    sr = i + sr
lista = ['remaerd','resare','esare','maerd']
for i in lista:
    sr = sr.replace(i,'')

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

Submission status: Wrong Answer

Solution code:
n = input()

n = n.split("dream")

m = ""
for i in range(len(n)):
    m+=n[i]
m = m.split("dreamer")

n = ""
for i in range(len(m)):
    n+=m[i]
n = n.split("erase")

m = ""
for i in range(len(n)):
    m+=n[i]
m = m.split("eraser")

if m == [""]:
    print("YES")
else:print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
sr = ''
for i in S:
    sr = i + sr
lista = ['maerd','remaerd','resare','esare']
for i in lista:
    sr = sr.replace(i,'')

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

Submission status: Wrong Answer

Solution code:
S = input()
sr = ''
for i in S:
    sr = i + sr
lista = ['maerd','remaerd','resare','esare']
for i in lista:
    sr = sr.split(i)
    sr = ' '.join(sr)

sr = sr.split(' ')
sr = ''.join(sr)
if sr == '':
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
sr = ''
for i in S:
    sr = i + sr
lista = ['maerd','remaerd','resare','esare']
for i in lista:
    sr = sr.split(i)
    sr = ' '.join(sr)

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

Submission status: Wrong Answer

Solution code:
S = input()
sr = ''
for i in S:
    sr = i + sr
lista = ['maerd','remaerd','resare','esare']
for i in lista:
    sr = sr.split(i)
    sr = ''.join(sr)
if sr == '':
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
s2 = S.split('dream')
s21 = ''.join(s2)
s3 = s21.split('erase')
ans = 'YES'

for i in s3:
    if i != 'r' and i != 'er' and i != '':
        ans = 'NO'
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
s = s[::-1]
i = 0
while i < len(s):
  if s[:5] in ['maerd','esare']:
    i += 5
  elif s[:6] == 'resare':
    i += 6
  elif s[:7] == 'remaerd':
    i += 7
  else:
    print('NO')
    exit()
print('YES')

Submission status: Wrong Answer

Solution code:
s = input()

dp = [0] * (len(s) + 1)
dp[0] = 1

for i in range(len(s) + 1):
    # check s[:i]
    if i >= 5 and s[i-5:i] == 'dream' and dp[i-5]:
        dp[i] = 1
    if i >= 7 and s[i-7:i] == 'dreamer' and dp[i-7]:
        dp[i] = 1
    if i >= 5 and s[i-5:i] == 'erase' and dp[i-5]:
        dp[i] = 1
    if i >= 7 and s[i-6:i] == 'eraser' and dp[i-6]:
        dp[i] = 1
if dp[-1]:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
line = s.replace("dream","").replace("dreamer","").replace("erase","").replace("eraser","")
if len(line) == 0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
s = input()

i = len(s)
while i > 0:
    for j in range(8):
        if j == 7:
            print("NO")
            exit()
        if s[i - j:i] in ["dream", "dreamer", "erase", "eraser"]:
            i -= j - 1
            break
    i -= 1

print("YES")

Submission status: Wrong Answer

Solution code:
s = input()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
T = ""
wlist = ["erase", "dream", "eraser", "dreamer"]
 
S_reverse = ''.join(list(reversed(S)))
for i in wlist:
    i_reverse = ''.join(list(reversed(i)))
    if S_reverse.startswith(i_reverse) == True:
        S_reverse = S_reverse.replace(i_reverse, "")

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

Submission status: Wrong Answer

Solution code:
S = input()
T = ""
wlist = ["eraser", "dreamer", "erase", "dream"]
 
S_reverse = ''.join(list(reversed(S)))
for i in wlist:
    i_reverse = ''.join(list(reversed(i)))
    if S_reverse.startswith(i_reverse) == True:
        S_reverse = S_reverse.replace(i_reverse, "")

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

Submission status: Wrong Answer

Solution code:
import random
S = input()
T = ""
list = ["eraser", "dreamer", "erase", "dream"]

for i in list:
  S = S.replace(i, "")

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

Submission status: Wrong Answer

Solution code:
import random
S = input()
T = ""
list = ["dream", "dreamer", "erase", "eraser"]

for i in list:
  S = S.replace(i, "")

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

Submission status: Wrong Answer

Solution code:
import random
S = input()
T = ""
list = ["dream", "dreamer", "erase", "eraser"]

for i in list:
  S.replace(i, "")

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

Submission status: Wrong Answer

Solution code:
import random
S = input()
T = ""
list = ["dream", "dreamer", "erase", "eraser"]

while len(T) <= 100000:
    T += random.choice(list)
    if T == S:
        print("YES")
        break
print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if len(s.replace('1','')) == 0:
    print("YES")
else :
    print("NO")

Submission status: Wrong Answer

Solution code:
S = list(input())
#S = list("dream" * 20000)
string = [list("dream") ,  list("dreamer") , list("erase") ,list("eraser")]
for i in range(4):
    string[i] = string[i][::-1]
#print(string)
S = S[::-1]
#print(S[0:5])
idx = 0
print(S[idx:5])
while idx != len(S):
    if S[idx:idx + 5] == string[0]:
        idx += 5
    elif S[idx:idx + 7] == string[1]:
        idx += 7
    elif S[idx:idx + 5] == string[2]:
        idx += 5
    elif S[idx:idx + 6] == string[3]:
        idx += 6
    else:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

Solution code:
S = input()
S = list(S)
s = ''.join(list(reversed(S)))
def main(s):
  l = ["esare", "maerd", "resare", "remaerd"]
  for i in l:
    s = s.replace(i, '')
  return s
if main(s) == '':
  print('YES')
elif main(s) != '':
  print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
S = list(S)
s = ''.join(list(reversed(S)))
def main(s):
  s = s.strip('esare' 'maerd' 'resare''remaerd')
  return s
if main(s) == '':
  print('YES')
elif main(s) != '':
  print('NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
S = list(S)
s = ''.join(list(reversed(S)))
def main(s):
  s = s.strip('esare' 'maerd' 'resare''remaerd')
  return s
if main(s) == '':
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

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