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:
st = input()

sample = ['dream', 'dreamer', 'erase', 'eraser']
#sample_edit = ['dream', 'eraser','erase', 'er']
sample_edit = ['eraser','erase' , 'dreamer','dream']
sample_er = ['er']
sample_dr = ['dream']
sample_ase = ['ase', 'aser']

ret = 'No'
reg_len = 0
fd_word = ''
dream_flg = False
end_flg = False

while( len(st) != 0 ):
  if reg_len == len(st):
    break
  
  reg_len = len(st)
  for i in range(len(sample_edit)):
    fd = st.startswith(sample_edit[i])
    
    if fd > 0:
      
      #print(st,i,dream_flg)
      st = ''.join(st[len(sample_edit[i]):len(st)])
      break
    
        
  if end_flg == True:
    break
    
  if len(st) == 0:
    ret = 'Yes'
    
  #print(st)
  #print(len(st))

print( ret )

Submission status: Wrong Answer

Solution code:
st = input()

sample = ['dream', 'dreamer', 'erase', 'eraser']
#sample_edit = ['dream', 'eraser','erase', 'er']
sample_edit = ['erase', 'eraser', 'dreamer','dream']
sample_er = ['er']
sample_dr = ['dream']
sample_ase = ['ase', 'aser']

ret = 'No'
reg_len = 0
fd_word = ''
dream_flg = False
end_flg = False

while( len(st) != 0 ):
  if reg_len == len(st):
    break
  
  reg_len = len(st)
  for i in range(len(sample_edit)):
    fd = st.startswith(sample_edit[i])
    
    if fd > 0:
      
      #print(st,i,dream_flg)
      st = ''.join(st[len(sample_edit[i]):len(st)])
      break
    
        
  if end_flg == True:
    break
    
  if len(st) == 0:
    ret = 'Yes'
    
  #print(st)
  #print(len(st))

print( ret )

Submission status: Wrong Answer

Solution code:
st = input()

sample = ['dream', 'dreamer', 'erase', 'eraser']
#sample_edit = ['dream', 'eraser','erase', 'er']
sample_edit = ['dream', 'erase', 'eraser', 'dreamer']
sample_er = ['er']
sample_dr = ['dream']
sample_ase = ['ase', 'aser']

ret = 'No'
reg_len = 0
fd_word = ''
dream_flg = False
end_flg = False

while( len(st) != 0 ):
  if reg_len == len(st):
    break
  
  reg_len = len(st)
  for i in range(len(sample_edit)):
    fd = st.startswith(sample_edit[i])
    
    if fd > 0:
      
      #print(st,i,dream_flg)
      st = ''.join(st[len(sample_edit[i]):len(st)])
      break
    
        
  if end_flg == True:
    break
    
  if len(st) == 0:
    ret = 'Yes'
    
  #print(st)
  #print(len(st))

print( ret )

Submission status: Wrong Answer

Solution code:
st = input()

sample = ['dream', 'dreamer', 'erase', 'eraser']
sample_edit = ['dream', 'eraser','erase', 'er']
sample_er = ['er']
sample_dr = ['dream']
sample_ase = ['ase', 'aser']

ret = 'No'
reg_len = 0
fd_word = ''
dream_flg = False
end_flg = False

while( len(st) != 0 ):
  if reg_len == len(st):
    break
  
  reg_len = len(st)
  for i in range(len(sample_edit)):
    fd = st.startswith(sample_edit[i])
    
    if fd > 0:
      
      #print(st,i,dream_flg)
      st = ''.join(st[len(sample_edit[i]):len(st)])
        
      if sample_edit[i] == 'dream':
        dream_flg = True
          
      if sample_edit[i] == 'er':
        if dream_flg == False:
          end_flg = True
          break
        else:
          dream_flg = False
          break
          
      break
    
        
  if end_flg == True:
    break
    
  if len(st) == 0:
    ret = 'Yes'
    
  #print(st)
  #print(len(st))

print( ret )

Submission status: Wrong Answer

Solution code:
st = input()

sample = ['dream', 'dreamer', 'erase', 'eraser']
sample_edit = ['dream', 'eraser','erase', 'dreamer']
sample_er = ['er']
sample_dr = ['dream']
sample_ase = ['ase', 'aser']

ret = 'No'
reg_len = 0
fd_word = ''
er_flg = False

while( len(st) != 0 ):
  if reg_len == len(st):
    break
  er_flg = False
  reg_len = len(st)
  for i in range(len(sample_edit)):
    fd = st.startswith(sample_edit[i])
    #print(st,i)
    if fd > 0:
      st = ''.join(st[len(sample_edit[i]):len(st)])
      if len(st) == 0:
        break
        
      #if sample[i] == 'er':
      #  if er_flg == True:
      #    break
          
        er_flg = True
	
        
  if er_flg == True:
    break
    
  if len(st) == 0:
    ret = 'Yes'
    
  #print(st)
  #print(len(st))

print( ret )

Submission status: Wrong Answer

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

str_list = ['dream', 'dreamer', 'erase', 'eraser']
str_list = [s[::-1] for s in str_list]

can = True
for i in range(len(S)):
    can2 = False
    for j in range(len(str_list)):
        d = str_list[j]
        if S[:i] == d:
            can2 = True
            i += d.size()
    if not (can2):
        can = False
        break

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

Submission status: Wrong Answer

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

str_list = ['dream', 'dreamer', 'erase', 'eraser']
str_list = [s[::-1] for s in str_list]

can = True
for i in range(len(S)):
    can2 = False
    for j in range(len(str_list)):
        d = str_list[j]
        if S[:i] == d:
            can2 = True
            i += d.size()
    if not (can):
        can = False
        break

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

Submission status: Wrong Answer

Solution code:
import sys
inputs = input().rstrip()

lst = ["dream","dreamer","erase","eraser"]
for i in range(len(lst)):
    for j in range(len(lst)):
        if i == j:
            continue
        res = inputs.replace(lst[(i+j)%4],"").replace(lst[(i+j+1)%4],"").replace(lst[(i+j+2)%4],"").replace(lst[(i+j+3)%4],"")
        if res == "":
            print("YES")
            exit(0)

print("NO")

Submission status: Wrong Answer

Solution code:
import sys
inputs = input().rstrip()

lst = ["dream","dreamer","erase","eraser"]
for i in range(len(lst)):
    for j in range(len(lst)):
        res = inputs.replace(lst[(i+j)%4],"").replace(lst[(i+j+1)%4],"").replace(lst[(i+j+2)%4],"").replace(lst[(i+j+3)%4],"")
        if res == "":
            print("YES")
            exit(0)

print("NO")

Submission status: Wrong Answer

Solution code:
import sys
inputs = input().rstrip()

lst = ["dream","dreamer","erase","eraser"]
for i in range(len(lst)):
    for j in range(len(lst)):
        if i == j:
            continue
        res = inputs.replace(lst[(i+j)%4],"").replace(lst[(i+j+1)%4],"").replace(lst[(i+j+2)%4],"").replace(lst[(i+j+3)%4],"")
        print(str((i+j)%4)+str((i+1+j)%4)+str((i+2+j)%4)+str((i+3+j)%4))
        if res == "":
            print("YES")
            exit(0)

print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
i=1
while i<len(s):
	if s[-i-4:-i]+s[-i]=="erase" \
	or s[-i-4:-i]+s[-i]=="dream":
		i+=5
	elif s[-i-5:-i]+s[-i]=="eraser":
		i+=6
	elif s[-i-6:-i]+s[-i]=="deaamer":
		i+=7
	else:
		print("NO")
		exit()
print("YES")

Submission status: Wrong Answer

Solution code:
s=input()
i=1
while i<len(s)+1:
	if s[-i:-i-5:-1]=="erase" \
	or s[-i:-i-5:-1]=="dream":
		print(s[-i:-i-5:-1])
		i+=5
	elif s[-i:-i-6:-1]=="eraser":
		i+=6
	elif s[-i:-i-7:-1]=="deaamer":
		i+=7
	else:
		print("NO")
		exit()
print("YES")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import itertools
a = input()
add =['dreamer','eraser','erase','dream']
new = list(itertools.permutations(add,2))
for b,c in new:
    next = b+c
    add.append(next)
add = sorted(add,key=lambda x:len(x),reverse=True)
t = ''
i = 0
while(i<len(a)):
    p=0
    for v in add:
        if len(v)+i-1<= len(a):
            if a[i:i+len(v)]==v:
                t+=a[i:i+len(v)]
                i=i+len(v)
                p=1
    if p==0:
        break
print('YES' if t==a else 'NO')

Submission status: Wrong Answer

Solution code:
s = input()
s = s[::-1]
lst = ["eraser","erase","dream","dreamer"]
flag=True
while (len(s)!=0) or flag:
  for word in lst:
    word = word[::-1]
    #print(word)
    if word in s:
      s = s.replace(word,"")
      #print(s)
    else:
      flag=False
  break
      
if len(s)==0:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
lst = ["eraser","erase","dream","dreamer"]
flag=True
while (len(s)!=0) or flag:
  for word in lst:
    #print(word)
    if word in s:
      s = s.replace(word,"")
      #print(s)
    else:
      flag=False
  break
      
if len(s)==0:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:

import bisect
import collections
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))
def getint2d(rows): return [getints() for _ in range(rows)]
def getgrid(rows): return [input() for _ in range(rows)]
def array1d(n, value): return [value for _ in range(n)]
def array2d(n, m, value): return [array1d(m, value) for _ in range(n)]

s=input()

words = ["dream","dreamer","erase","eraser"]
def solve(s):
    for w in words:
        w_len = len(w)
        if len(s) < w_len: continue
        if w == s[0:w_len]:
            if solve(s[w_len:]):
                return True
    return False

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

Submission status: Wrong Answer

Solution code:
s = input()
words = ['dream', 'dreamer', 'erase', 'eraser']

n_chance = int(10e+5 / 5)
for i in range(n_chance):
    for j in words:
        if s[-len(j):] == j:
            s = s.replace(j, '')

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

Submission status: Wrong Answer

Solution code:
creds = [i for i in ['dreamer', 'eraser', 'dream', 'erase']]
s = input()
t = ""
index = 0
done_ = False
while len(s) != 0:
    done = False
    for cred in creds:
        if s.startswith(cred):
            s = s[len(cred):]
            done = True
            continue
    if not done:
        done_ = True
        break


if not done_:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
creds = ['dream', 'dreamer', 'erase', 'eraser']
s = input()
t = ""
for cred in creds:
    s = s.replace(cred, '')
if not s:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import re
s = input()
print('YES') if re.match('(maerd|remaerd|esare|resare)+', s[::-1]) else print('NO')

Submission status: Wrong Answer

Solution code:
s = input()

t = s.replace("eraser","4")
t = t.replace("erase","6")
t = t.replace("dreamer","3")
t = t.replace("dream","5")

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

Submission status: Wrong Answer

Solution code:
s = input()

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

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

Submission status: Wrong Answer

Solution code:
s = input()

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

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

Submission status: Wrong Answer

Solution code:
S = input()[::-1]
l = ["dream", "dreamer", "erase", "eraser"]
for i in range(len(l)):
    l[i] = l[i][::-1]

cut = 0
for n in range(len(S)):
    if cut == len(S):
        break
    for m in range(len(l)):
        div = l[m][:3]
        if S[cut:cut+3] == div:
            cut += len(l[m])
            break

print("YES" if cut == len(S) else "NO")

Submission status: Wrong Answer

Solution code:
def main():
    s = input()
    s = "".join(reversed(s))
    word = ["dreamer", "dream", "eraser", "erase"]
    t = ""
    for i in range(4):
        word[i] = "".join(reversed(word[i]))
    while len(s) > 0:
        for i in range(4):
            if s.startswith(word[i]):
                s = s[len(word[i]):]
                break
        else:
            print("No")
            break
    if s == "":
        print("Yes")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    s = input()
    s = "".join(reversed(s))
    word = ["dreamer", "dream", "eraser", "erase"]
    t = ""
    for i in range(4):
        word[i] = "".join(reversed(word[i]))
    while len(s) > 0:
        for i in range(4):
            if s.startswith(word[i]):
                s = s[len(word[i]):]
                break
        else:
            print("No")
            break
    if s == "":
        print("Yes")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import re
S = input()

S = re.sub(r'eraser', '', S)
S = re.sub(r'dreamer', '', S)
S = re.sub(r'dream', '', S)
S = re.sub(r'erase', '', S)

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

Submission status: Wrong Answer

Solution code:
x = input()
n = len(x)
ans = "NO"

def f(i):
    if n==i:
        global ans
        ans = "YES"
    else:
        if x[i:i*5] == "dream":
            f(i+5)
        if x[i:i+7] == "dreamer":
            f(i+7)
        if x[i:i+5] == "erase":
            f(i+5)
        if x[i:i+6] == "eraser":
            f(i+6)
f(0)
print(ans)

Submission status: Wrong Answer

Solution code:
x = input()
ans = "NO"
def f(s):
    if len(s)==0:
        global ans
        ans = "YES"
    else:
        if s[0:5] == "dream":
            f(s[5:])
        if s[0:7] == "dreamer":
            f(s[7:])
        if s[0:5] == "erase":
            f(s[5:])
        if s[0:7] == "eraser":
            f(s[7:])
f(x)
print(ans)

Submission status: Wrong Answer

Solution code:
x = input()
ans = "No"
def f(s):
    if len(s)==0:
        global ans
        ans = "Yes"
    else:
        if s[0:5] == "dream":
            f(s[5:])
        if s[0:7] == "dreamer":
            f(s[7:])
        if s[0:5] == "erase":
            f(s[5:])
        if s[0:7] == "eraser":
            f(s[7:])
f(x)
print(ans)

Submission status: Wrong Answer

Solution code:
a = input()
num = len(a)
ans = ''
while num>0:
    if a[num-1] == 'm':
        ans = 'dream' + ans
        num -= 5
    elif a[num-1] == 'e':
        ans = 'erase' + ans
        num -=5
    elif a[num-3:num] == 'mer':
        ans = 'dreamer'+ans
        num -=7
    elif a[num-3:num] == 'ser':
        ans = 'eraser'+ans
        num -= 7
    else:
        break
if ans == a:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
t = ''
last = ''
here = 0
er = 0
r = 0
flag = 1
while here < n:
  last = t
  if s[here] == 'e' and here + 5 < n:
    if s[here:here+3] == 'era':
      t += 'erase'
      here += 5
      er = 0
      r = 1
    elif s[here] == 'e' and er == 1:
      t += 'er'
      here += 2
      er = 0
      r = 0
  elif s[here] == 'e' and er == 1:
    t += 'er'
    here += 2
    er = 0
    r = 0
  elif s[here] == 'd':
    t += 'dream'
    here += 5
    er = 1
    r = 0
  elif s[here] == 'r' and r == 1:
    t += 'r'
    here += 1
    er = 0
    r = 0
  if t == last:
    flag = 0
    break
  #print(t,here,s[here],er,r,t,last)
if s == t and flag == 1:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
t = ''
here = 0
er = 0
r = 0
flag = 1
while here < n:
  if s[here] == 'e' and here + 2 < n:
    if s[here:here+3] == 'era':
      t += 'erase'
      here += 5
      er = 0
      r = 1
    elif er == 1:
      t += 'er'
      here += 2
      er = 0
      r = 0
  elif s[here] == 'd':
    t += 'dream'
    here += 5
    er = 1
    r = 0
  elif s[here] == 'r' and r == 1:
    t += 'r'
    here += 1
    er = 0
    r = 0
  else:
    flag = 0
    break
if s == t and flag == 1:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
t = ''
here = 0
flagrr = 1
while here < n:
  if s[here] == 'e':
    t += 'erase'
    here += 5
  elif s[here] == 'd':
    t += 'dream'
    here += 5
  else:
    t += 'r'
    here += 1
    try:
      if t[-2:] == 'rr':
        flagrr = 0
        break
    except:
      flagrr = 0
      break
if s == t and flagrr == 1:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
t = ''
here = 0
flagrr = 1
while here < n:
  if s[here] == 'e':
    t += 'erase'
    here += 5
  elif s[here] == 'd':
    t += 'dream'
    here += 5
  else:
    t += 'r'
    here += 1
    try:
      if t[-2:] == 'rr':
        flagrr = 0
        break
    except:
      pass
if s == t and flagrr == 1:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
t = ''
here = 0
while here < n:
  if s[here] == 'e':
    t += 'erase'
    here += 5
  elif s[here] == 'd':
    t += 'dream'
    here += 5
  else:
    t += 'r'
    here += 1
if s == t:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
T = ["dreamer", "dream", "eraser", "erase"]
def daydream(S, T):
    for word in T:
        S = S.replace(word, " ")
    return "YES" if len(S.replace(" ", "")) == 0 else "NO"

print(daydream(S, T))

Submission status: Wrong Answer

Solution code:
S = input()
T = ["dreamer", "dream", "eraser", "erase"]
def daydream(S, T):
    def greedy(string, word):
        if string.find(word) != -1:
            return string.replace(word, " ")
        return string
    for word in T:
        S = greedy(S, word)
    return "YES" if len(S.replace(" ", "")) == 0 else "NO"

print(daydream(S, T))

Submission status: Wrong Answer

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

for tg in targets:
    print(S)
    S = S.replace(tg, '')

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

Submission status: Wrong Answer

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

i = len(S)
while True:
    if i == 0:
        print('Yes')
        exit()
    for tg in targets:
        if S[i - len(tg):i][::-1] == tg[::-1]:
            i -= len(tg)
            break
    else:
        print('No')
        exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
s=input()
l=["dream","erase"] #5文字ペア
m=["dreamer","eraser"] #6文字ペア
while True:
    for i in [0,1]:
        if s=="":
            print("YES")
            sys.exit()
        elif l[i] in s[-5:]:
            s=s[:-5]
        elif m[i] in s[-6:]:
            s=s[:-6]
        elif i==1:
            print("NO")
            sys.exit()

Submission status: Wrong Answer

Solution code:
s = input()
S = [s[i] for i in range(len(s))]

def flag(list_s):
    flag_yes = True
    if len(list_s)<=4:
        flag_yes=False
    else:
        flag_dreamer = False
        while len(list_s)>0 and flag_yes: #listが空でなく、まだ条件を満たしている時
            if flag_dreamer and len(list_s)>=4 and list_s[:4]==['a','s','e','r']: #dreameraser
                list_s = list_s[4:]
                flag_dreamer=False
            elif flag_dreamer and len(list_s)>=3 and list_s[:3]==['a','s','e']: #dreamerase
                list_s = list_s[3:]
                flag_dreamer=False
            elif len(list_s)>=5 and list_s[0:5]==['e','r','a','s','e']: #eraseまたはeraserなら消去して初期化
                flag_dreamer=False
                list_s = list_s[5:]
                if len(list_s)>0 and list_s[0]=='r':
                    list_s = list_s[1:]
            elif list_s == ['d', 'r', 'e', 'a', 'm']: #[dream]なら全消去
                flag_dreamer=False
                list_s = list_s[5:]
            elif len(list_s)>=6 and list_s[:6]==['d', 'r', 'e', 'a', 'm', 'd']: #dreamdream or dreamdreamerなら前半消去
                flag_dreamer=False
                list_s = list_s[5:]
            elif len(list_s)>=7 and list_s[:7]==['d', 'r', 'e', 'a', 'm', 'e', 'r']: #dreamerが面倒
                flag_dreamer=True
                list_s = list_s[7:]
            else:
                flag_yes = False
    return flag_yes
        
if flag(S):
    print('YES')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
s = input()

cpos = 0
while True:
  for b in ['dream', 'dreamer', 'erase', 'eraser']:
    pos = s.find(b)
    if pos == cpos:
      cpos += len(b)
      break
  if cpos == len(s)-1:
    print('YES')
    break
  elif pos == -1:
    print('NO')
    break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

flag = True
while flag:
	part = ''
	for s in S:
		part += s

		if part in template:
			break

		flag = False
		judge = 'NO'

	flag = False
	judge = 'YES'

print(judge)

Submission status: Wrong Answer

Solution code:
s = input()
s = s[::-1]
l = ['eraser','erase','dreamer','dream']
lst = []
for i in range(4):
    w = l[i]
    w = w[::-1]
    lst.append(w)

for word in lst:
    s = s.replace(word,'')
if len(s) == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
s = input()
s = s[::-1]
l = ['erase','eraser','dream','dreamer']
lst = []
for i in range(4):
    w = l[i]
    w = w[::-1]
    lst.append(w)

for word in lst:
    s = s.replace(word,'')
if len(s) == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
S=input()
l=len(S)
r=0
list5 = ['dream', 'erase']
list81 = ['dreamdre', 'dreamera', 'erasedre', 'eraseera']
list82 = ['dreamerd', 'dreamere']
list83 = ['eraserdr', 'eraserer']
if l<=4:
    print(False)

while l>=5:
    if S[r:r+5] in list5:
        if r+5==l:
            print(True)
            break
        elif r+5 == l-1:
            if S[r:r+6] == 'eraser':
                print(True)
            else:
                print(False)
            break
        elif r+5 == l-2:
             if S[r:r+7] == 'dreamer':
                 print(True)
             else:
                 print(False)
             break
        elif r+5 == l-3 or r+5 == l-4:
            print(False)
            break
        else:
            if S[r:r+8] in list81:
                r=r+5
            elif S[r:r+8] in list82:
                r=r+7
            elif S[r:r+8] in list83:
                r=r+6
            else:
                print(False)
                break
    else:
        print(False)
        break

Submission status: Wrong Answer

Solution code:
S=input()
l=len(S)
r=0
amari = [1,2,3,4]
list5 = ['dream', 'erase']
list81 = ['dreamdre', 'dreamera', 'erasedre', 'eraseera']
list82 = ['dreamerd', 'dreamere', 'eraserdre', 'eraserera']
if l<=4:
    print(False)

while l>=5:
    if S[r:r+5] in list5:
        if r+5==l:
            print(True)
            break
        elif r+5 == l-1:
            if S[r:r+6] == 'eraser':
                print(True)
            else:
                print(False)
            break
        elif r+5 == l-2:
             if S[r:r+7] == 'dreamer':
                 print(True)
             else:
                 print(False)
             break
        elif r+5 == l-3 or r+5 == l-4:
            print(False)
            break
        else:
            if S[r:r+8] in list81:
                r=r+5
            elif S[r:r+8] in list82:
                r=r+7
            else:
                print(False)
                break
    else:
        print(False)
        break

Submission status: Wrong Answer

Solution code:
S=input()
l=len(S)
r=0
amari = [1,2,3,4]
list5 = ['dream', 'erase']
list81 = ['dreamdre', 'dreamera', 'erasedre', 'eraseera']
list82 = ['dreamerd', 'dreamere', 'eraserdre', 'eraserera']
if l<=4:
    print(False)

while l>=5:
    if S[r:r+5] in list5:
        if r+5==l:
            print(True)
            break
        elif r+5 == l-1:
            if S[r:r+6] == 'eraser':
                print(True)
            else:
                print(False)
            break
        elif r+5 == l-2:
             if S[r:r+7] == 'dreamer':
                 print(True)
             else:
                 print(False)
             break
        elif r+5 == l-3 or r+5 == l-4:
            print(False)
            break
        else:
            if S[r:r+8] in list81:
                r=r+5
            elif S[r:r+8] in list82:
                r=r+7
            else:
                print(False)
                break
    else:
        print(False)
        break

Submission status: Wrong Answer

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

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:
import itertools
s = input()

words = ["dream", "dreamer", "erase", "eraser"]
for i in range(1, len(words)+1):
    word_permutations = list(itertools.permutations(words, i))
    for word in word_permutations:
        t = "".join(word)
        if s == t:
            print("YES")
            exit()
print("NO")

Submission status: Wrong Answer

Solution code:
word=input()

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



while 1:
  if word[len(word)-5:]==wordList[0]:
    word=word[:len(word)-5]
  elif word[len(word)-7:]==wordList[1]:
    word=word[:len(word)-7]
  elif word[len(word)-5:]==wordList[2]:
    word=word[:len(word)-5]
  elif word[len(word)-7:]==wordList[3]:
    word=word[:len(word)-7]
  else:
    print("NO")
    break
  if word=="":
    print("YES")
    break

Submission status: Wrong Answer

Solution code:
word=input()

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



while 1:
  if word[len(word)-5:]==wordList[0]:
    word=word[:len(word)-5]
  elif word[len(word)-7:]==wordList[1]:
    word=word[:len(word)-7]
  elif word[len(word)-5:]==wordList[2]:
    word=word[:len(word)-5]
  elif word[len(word)-7:]==wordList[3]:
    word=word[:len(word)-7]
  else:
    print("false")
    break
  if word=="":
    print("true")
    break

Submission status: Wrong Answer

Solution code:
S = str(input())
str_list = ['dream', 'dreamer', 'erase', 'eraser']
dp = [0] * 100010

for i in range(len(S)):
    for s in str_list:
        if S[i:i+len(s)] == s:
            dp[i+len(s)] = 1

if dp[len(S)] == 1:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import re
S = input()
Snew = S[::-1]
print(Snew)
if re.sub('^maerd|remaerd|resare|esare$',"",Snew) == "":
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
S = input()
while len(S)!=0:
  if S[-7:] == "dreamer":
    S = S.replace("dreamer", "")
  elif S[-5:] == "dream":
    S = S.replace("dream", "")
  elif S[-6:] == "eraser":
    S = S.replace("eraser", "")
  elif S[-5:] == "erase":
    S = S.replace("erase", "")
  else:
    print("NO")
    break
if len(S) == 0:
  print("YES")

Submission status: Wrong Answer

Solution code:
S = input()
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()
S = list(S)
print(S)
S.reverse()
print(S)
T = []
n = len(S)
for i in range(n):
  T.append(S[i])
  mojiretu = ''.join(T)
  m = len(mojiretu)
  if mojiretu == "maerd" or mojiretu == "remaerd" or mojiretu == "esare" or mojiretu == "resare":
    T =[]
  elif m==8:
      break
N = len(T)
if N == 0:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
S = list(input().split())
S.reverse()
T = []
n = len(S)
for i in range(n):
  T.append(S[i])
  mojiretu = ''.join(T)
  if mojiretu == "maerd" or mojiretu == "remaerd" or mojiretu == "esare" or mojiretu == "resare":
    T =[]

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

Submission status: Wrong Answer

Solution code:
S = list(input().split())
S.reverse()
T = []
n = len(S)
for i in range(n):
  T.append(S[i])
  mojiretu = ','.join(T)
  if mojiretu == ["maerd"] or mojiretu == ["remaerd"] or mojiretu == ["esare"] or mojiretu == ["resare"]:
    T =[]
if len(T) == 0:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
for k in range(int(len(S)/5)):
    for word in ["dream", "dreamer", "erase", "eraser"]:
        if S.endswith(word):
            S=S.rstrip(word)
if len(S)==0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

for word in words:
    s = s.replace(word, "")
    print(s)

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

Submission status: Wrong Answer

Solution code:
words = ["dream", "dreamer", "erase", "eraser"]
s = input()
dp = [0] * (len(s)+1)
dp[0] = 1

for i in range(len(s)+1):
  if dp[i]!=1: continue
  for word in words:
    if word in s[i:i+len(word)]:
      dp[i+len(word)] = 1
      
print("Yes" if dp[len(s)] else "No")

Submission status: Wrong Answer

Solution code:
S = input()

start = len(S)

while 0<start:

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

Submission status: Wrong Answer

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

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

print(ans)