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: Runtime Error

Solution code:
s = input()
while True:
	S = s
	if len(S) < 5:
		print('NO')
		break
	if S == 'dream' or S == 'erase':
		print('YES')
		break
	else:
		if S[0] == 'd':
			if S[7] == 'a':
				T ='dream'
				if S[:5] == T:
					S = S[5:]
					T = ""
					if S == "":
						print('YES')
						break
					s = S
				else:
					print('NO')
					break
			else:
				T = 'dreamer'
				if S[:7] == T:
					S = S[7:]
					T = ""
					if S == "":
						print('YES')
						break
					s = S
				else:
					print('NO')
					break
		if S[0] == 'e':
			if len(S) >= 6 and S[5] == 'r':
				T = 'eraser'
				if S[:6] == T:
					S = S[6:]
					T = ""
					if S == "":
						print('YES')
						break
					s = S
				else:
					print('NO')
					break
			else:
				T = 'erase'
				if S[:5] == T:
					S = S[5:]
					T = ""
					if S == "":
						print('YES')
						break
					s = S
				else:
					print('NO')
					break
		else:
            print('NO')
            break

Submission status: Runtime Error

Solution code:
s = input()
while True:
	S = s
	if len(S) < 5:
		print('NO')
		break
	if S == 'dream' or S == 'erase':
		print('YES')
		break
	else:
		if S[0] == 'd':
			if S[7] == 'a':
				T ='dream'
				if S[:5] == T:
					S = S[5:]
					T = ""
					if S == "":
						print('YES')
						break
					s = S
				else:
					print('NO')
					break
			else:
				T = 'dreamer'
				if S[:7] == T:
					S = S[7:]
					T = ""
					if S == "":
						print('YES')
						break
					s = S
				else:
					print('NO')
					break
		if S[0] == 'e':
			if len(S) >= 6 and S[5] == 'r':
				T = 'eraser'
				if S[:6] == T:
					S = S[6:]
					T = ""
					if S == "":
						print('YES')
						break
					s = S
				else:
					print('NO')
					break
			else:
				T = 'erase'
				if S[:5] == T:
					S = S[5:]
					T = ""
					if S == "":
						print('YES')
						break
					s = S
				else:
					print('NO')
					break
		else:
			print('NO')
            break

Submission status: Runtime Error

Solution code:
s=input()
s=s.reverse()
voc=['dream','dreamer','erase','eraser']
for i in range(len(voc)):
  voc[i]=voc[i][::-1]
while True:
  flag=False
  for v in voc:
    if s[:len(v)]==v:
      s=s[len(v):]
      flag=True
  if s=='':
    print('Yes')
    break
  elif not flag:
    print('No')
    break

Submission status: Runtime Error

Solution code:
s=list(str(input()))
b=0
while len(s)>=5:
  if s[-1]=='r':
    sd=[s[-7],s[-6],s[-5],s[-4],s[-3],s[-2],s[-1]]
    se=[s[-6],s[-5],s[-4],s[-3],s[-2],s[-1]]
    if ''.join(sd)=='dreamer':
      del s[-7:]
    elif ''.join(se)=='eraser':
      del s[-6:]
    else:
      print('NO')
      b+=1
      break
  elif s[-1]=='m':
    sd=[s[-5],s[-4],s[-3],s[-2],s[-1]]
    if ''.join(sd)=='dream':
      del s[-5:]
    else:
      print('NO')
      b+=1
      break
  elif s[-1]=='e':
    sd=[s[-5],s[-4],s[-3],s[-2],s[-1]]
    if ''.join(sd)=='erase':
      del s[-5:]
    else:
      print('NO')
      b+=1
      break  
  else:
    print('NO')
    b+=1
    break
if len(s)==0:
  print('YES')
elif b!=1:
  print('NO')

Submission status: Runtime Error

Solution code:
S=input()
print(S)
while(len(S)>=5):
    if(S[len(S)-7:len(S)]=='dreamer'):
        S=S[:len(S)-7]
    elif(S[len(S)-6:len(S)]=='eraser'):
        S=S[:len(S)-6]
    elif(S[len(S)-5:len(S)]=='dream' or S[len(S)-5:len(S)]=='erase'):
        S=S[:len(S)-5]
    else:
        print("NO")
        exit()
    print(S)
if(len(S)!=0):
    print("NO")
else:
    print("YES")

Submission status: Runtime Error

Solution code:
S = input()

while(len(s)!=0):
    if s[-5:] == 'dream' or s[-5:] == 'erase':
        s = s[:-5]
    elif s[-6:]== 'eraser':
        s = s[:-6]
    elif s[-7:]=='dreamer':
        s = s[:-7]
    else:
        print('N0')
        break
else:
    print('YES')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S0 = input()
S = S0[::-1]
cands = ["dream"[::-1],"dreamer"[::-1],"erase"[::-1],"eraser"[::-1]]
i = 0
while i < len(S):
  f = False
  for word in cands:
    #print(S[i:],word)
    if S[i:].startswith(word):
        f = True
    	i += len(word)
    	break
  if f = False:
    print("NO")
    exit(0)
#print(i)
if i == len(S):
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
S = input()
S.reverse()
cands = map(reverse,["dream","dreamer","erase","eraser"])
i = 0
while i < len(S):
  for word in cands:
	S[i:].startsWith(word)
    i += len(word)
if i == len(S):
  return True
return False

Submission status: Runtime Error

Solution code:
s=input()
di={maerd,remaerd,esare,resare}
s.reverse()
for i in range(len(s)):
  for j in range(4):
    f=False
    t=di[j]
    if s[i:len(t)]==t:
      f=True
      i+=len(t)
  if (not f):
    print("NO")
    exit()
print("YES")

Submission status: Runtime Error

Solution code:
import sys
s = str(input())
i = 0
while i < len(s):
    if i + 5 <= len(s) and s[i:i+5] == 'dream': #now dream or dreamer
        if i + 6 < len(s) and s[i+5] == 'e' and s[i+6] == 'r': #now dreamer or now dream and next is erase or eraser
            if s[i+7] == 'a': #next erase or eraser, now dream
                i += 5
            else: #now dreamer
                i += 7
        else: #now dream
            i += 5
    elif i + 5 <= len(s) and s[i:i+5] == 'erase':
        if i + 5 < len(s) and s[i+5] == 'r': #now eraser
            i += 6
        else: #now erase
            i += 5
    else:
        print('NO')
        sys.exit()
print('YES')

Submission status: Runtime Error

Solution code:
import sys
s = str(input())
i = 0
while i < len(s):
    if i + 5 <= len(s) and s[i:i+5] == 'dream': #now dream or dreamer
        if i + 6 <= len(s) and s[i+5] == 'e' and s[i+6] == 'r': #now dreamer or now dream and next is erase or eraser
            if s[i+7] == 'a': #next erase or eraser, now dream
                i += 5
            else: #now dreamer
                i += 7
        else: #now dream
            i += 5
    elif i + 5 <= len(s) and s[i:i+5] == 'erase':
        if i + 5 <= len(s) and s[i+5] == 'r': #now eraser
            i += 6
        else: #now erase
            i += 5
    else:
        print('NO')
        sys.exit()
print('YES')

Submission status: Runtime Error

Solution code:
def main():
    target = input()
    string = ["eraser", "dreamer", "erase", "dream"]
    for i in range(len(target)):
        for s in string:
            if target[i - len(s):] == s:
                target = target[:i - len(s)]
                break
        print(target)
    print("YES" if target == "" else "NO")


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    s=input()
    string=('dream','erase')

    i=0
    n=len(s)
    while i<n:
        st=s[i:i+5]
        if st==string[0]:
            i+=5
            st=s[i:i+2]
            if st=='er':
                if s[i+2]!='a':
                    i+=2
        
        elif st==string[1]:
            i+=5
            if i==n:
              break
            if s[i]=='r':
                i+=1
        
        else:
            print('NO')
            exit()
    print('YES')
if  __name__=='__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    s=input()
    string=('dream','erase')

    i=0
    n=len(s)
    while i<n:
        st=s[i:i+5]
        if st==string[0]:
            i+=5
            st=s[i:i+2]
            if st=='er':
                if s[i+2]!='a':
                    i+=2
        
        elif st==string[1]:
            i+=5
            if s[i]=='r':
                i+=1
        
        else:
            print('NO')
            exit()
    print('YES')
if  __name__=='__main__':
    main()

Submission status: Runtime Error

Solution code:
import numpy as np

d = np.array([[0, 0, 0, 0, 0, 0],
            [2, 0, 9, 0, 0, 0],
            [0, 3, 0, 0, 0, 0],
            [0, 0, 4, 0, 0, 0],
            [0, 0, 0, 5, 0, 0],
            [0, 0, 0, 0, 6, 0],
            [2, 0, 7, 0, 0, 0],
            [0, 8, 0, 0, 0, 0],
            [2, 0, 9, 11, 0, 0],
            [0, 10, 0, 0, 0, 0],
            [0, 0, 0, 11, 0, 0],
            [0, 0, 0, 0, 0, 12],
            [0, 0, 13, 0, 0, 0],
            [2, 1, 9, 0, 0, 0]], dtype = 'int32')
s = 1
for c in input():
    s = d[s][id[c]] if c in {'d': 0, 'r': 1, 'e': 2, 'a': 3, 'm': 4, 's': 5} else 0
    if s == 0:
        break
print("YES" if s in {1, 6, 8, 13} else "NO")

Submission status: Runtime Error

Solution code:
import re

s = ainpu()
s = re.sub("eraser","",s)
s = re.sub("erase","",s)
s = re.sub("dreamer","",s)
s = re.sub("dream","",s)
print("Yes" if len(s) ==0 else "No")

Submission status: Runtime Error

Solution code:
word = input()
b = word
d = word
f = word
h = word
def gyaku(x):
  x = list(x)
  x.reverse()
  return ''.join(x)
if gyaku('eraser') in gyaku(word):
  a = gyaku(word).split(gyaku('eraser'))
  b = ''.join(a)
  h = gyaku(b)
if gyaku('dreamer') in gyaku(h):
  g = gyaku(h).split(gyaku('dreamer')
  h = gyaku(''.join(g))
if gyaku('erase') in gyaku(h):
  c = gyaku(h).split(gyaku('erase'))
  d = ''.join(c)
  h = gyaku(d)
if gyaku('dream') in gyaku(h):
  e = gyaku(h).split(gyaku('dream'))
  f = ''.join(e)
  h = gyaku(f)
 
if h == (''):
  print('YES')
else:
  print('NO')

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
s = input()

while len(s) > 0:
  if s == "":
    print('YES')
    break
  s.replace('dreamer','')
  s.replace('eraser','')
  s.replace('dream','')
  s.replace('erase'v)
  
print('NO')

Submission status: Runtime Error

Solution code:
def main():
  s=input()
  q=[0]
  m=len(s)
  l=["dream","dreamer","erase","eraser"]
  while q:
    i=q.pop()
    if i==n:
      print("YES")
      return
    for j in l:
      nj=len(j)
      if i+nj<=m and s[i:i+nj]==j:
        q.append(i+nj)
  print("NO")

main()

Submission status: Runtime Error

Solution code:
def main():
  q=[input()]
  l=["dream","dreamer","erase","eraser"]
  while q:
    s=q.pop()
    if s="":
      print("YES")
      return
    for i in l:
      n=len(i)
      if s[:n]==i:
        q.append(s[n:])
  print("NO")

main()

Submission status: Runtime Error

Solution code:
flag = False
def check(sen,l,s):
    if len(sen)<l:
        check(sen+"dream",l,s)
        check(sen+"dreamer",l,s)
        check(sen+"erase",l,s)
        check(sen+"eraser",l,s)
    else:
        if sen==s:
            global flag
            flag = True

s = input()

check("",len(s),s)

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

Submission status: Runtime Error

Solution code:
flag = False
def check(sen,l,s):
    if len(sen)<l:
        check(sen+"dream",l,s)
        check(sen+"dreamer",l,s)
        check(sen+"erase",l,s)
        check(sen+"eraser",l,s)
    else:
        if sen==s:
            global flag
            flag = True

s = input()

check("",len(s),s)

if flag:
    print("yes")
else:
    print("no")

Submission status: Runtime Error

Solution code:
S=list(input())
yes_flag=0
in_flag=0
S=[s for s in S if s!=' ']
for i in range(len(S)):
  #print(S)
  if S[0:5] == list("erase"):
    in_flag=1
    del S[0:5]
    if S[0] == "r":
      del S[0]
    if len(S) == 0:
      yes_flag=1
      break
  if S[0:5] == list("dream"):
    in_flag=1
    del S[0:5]
    if S[0:2] == list("er"):
      if not len(S) == 2:
      	if not S[2] == "a":
          del S[:2]
      else :
        del S[:2]
    if len(S) == 0:
      yes_flag=1
      break
  
  if in_flag==0:
    break
  in_flag=0

if yes_flag == 1:
  print("YES")
else :
  print("NO")

Submission status: Runtime Error

Solution code:
S=list(input())
yes_flag=0
in_flag=0

for i in range(int(len(S)/2)):
  #print(S)
  if S[0:5] == list("erase"):
    in_flag=1
    del S[0:5]
    if S[0] == "r":
      del S[0]
    if len(S) == 0:
      yes_flag=1
      break
  if S[0:5] == list("dream"):
    in_flag=1
    del S[0:5]
    if S[0:2] == list("er"):
      if not len(S) == 2:
      	if not S[2] == "a":
          del S[:2]
      else :
        del S[:2]
    if len(S) == 0:
      yes_flag=1
      break
  
  if in_flag==0:
    break
  in_flag=0

if yes_flag == 1:
  print("YES")
else :
  print("NO")

Submission status: Runtime Error

Solution code:
S=list(input())
yes_flag=0
in_flag=0

for i in range(len(S)):
  #print(S)
  if S[0:5] == list("erase"):
    in_flag=1
    del S[0:5]
    if S[0] == "r":
      del S[0]
    if len(S) == 0:
      yes_flag=1
      break
  if S[0:5] == list("dream"):
    in_flag=1
    del S[0:5]
    if S[0:2] == list("er"):
      if not len(S) == 2:
      	if not S[2] == "a":
          del S[:2]
      else :
        del S[:2]
    if len(S) == 0:
      yes_flag=1
      break
  
  if in_flag==0:
    break
  in_flag=0

if yes_flag == 1:
  print("YES")
else :
  print("NO")

Submission status: Runtime Error

Solution code:
S=list(input())
yes_flag=0

for i in range(len(S)):
  #print(S)
  if S[0:5] == list("erase"):
    del S[0:5]
    if S[0] == "r":
      del S[0]
    if len(S) == 0:
      yes_flag=1
      break
  if S[0:5] == list("dream"):
    del S[0:5]
    if S[0:2] == list("er"):
      if not len(S) == 2:
      	if not S[2] == "a":
          del S[:2]
      else :
        del S[:2]
    if len(S) == 0:
      yes_flag=1
      break

if yes_flag == 1:
  print("YES")
else :
  print("NO")

Submission status: Runtime Error

Solution code:
S=list(input())
no_flag=0

for i in range(len(S)):
  #print(S)
  if S[0:5] == list("erase"):
    del S[0:5]
    if S[0] == "r":
      del S[0]
    if len(S) == 0:
      break
  if S[0:5] == list("dream"):
    del S[0:5]
    if S[0:2] == list("er"):
      if not len(S) == 2:
      	if not S[2] == "a":
          del S[:2]
      else :
        del S[:2]
    if len(S) == 0:
      break
  else:
    no_flag=1

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

Submission status: Runtime Error

Solution code:
S=list(input())
no_flag=0

for i in range(len(S)):
  if S[0:5] == list("erase"):
    del S[0:5]
    if S[0] == "r":
      del S[0]
    if len(S) == 0:
      break
  if S[0:5] == list("dream"):
    del S[0:5]
    if S[0:2] == list("er"):
      if not S[2] == "a":
        del S[:2]
    if len(S) == 0:
      break
  else:
    no_flag=1

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

Submission status: Runtime Error

Solution code:
s = input()

while s:
  if len(s) > 6 and s[0:7] == 'dreamer':
    s = s[7:]
    if s != [] and s[0] == 'a':
      s = 'er' + s
    continue
  elif len(s)>5 and s[0:6] == 'eraser':
    s = s[6:]
    continue
  elif len(s) > 4 and s[0:5] in ('dream', 'erase'):
    s = s[5:]
    continue
  else:
    print('NO')
    exit(0)
print('YES')

Submission status: Runtime Error

Solution code:
s = input()

while s:
  if s[0:7] == 'dreamer':
    s = s[7:]
    if s != [] and s[0] == 'a':
      s = 'er' + s
    continue
  elif s[0:6] == 'eraser':
    s = s[6:]
    continue
  elif s[0:5] in ('dream', 'erase'):
    s = s[5:]
    continue
  else:
    print('NO')
    exit(0)
print('YES')

Submission status: Runtime Error

Solution code:
s = input()

while s:
  if s[0:7] == 'dreamer':
    s = s[7:]
    if s[0] == 'a':
      s = 'er' + s
    continue
  elif s[0:6] == 'eraser':
    s = s[6:]
    continue
  elif s[0:5] in ('dream', 'erase'):
    s = s[5:]
    continue
  else:
    print('NO')
    exit(0)
print('YES')

Submission status: Runtime Error

Solution code:
s = input()
length = len(s)

i = 0
res = "YES"

while i < length: 
  if i+4 <= length and s[i:i+5] == "dream":
    i += 5
    if i+2 <= length and s[i:i+2] == "er" and s[i+2] != "a":
      i += 2
    #elif i+1 == length and s[i:i+2] == "er":
      #i += 2
  elif s[i] == "e":
  else:
    res = "NO"
    break
    
  if i+4 <= length and s[i:i+5] == "erase":
    i += 5
    if i+1 <= length and s[i] == "r" and s[i+1] != "a":
      i += 1
    #elif i == length and s[i] == "r":
     # i += 1
  elif s[i] == "d":
  else:
    res = "NO"
    break
        
print(res)

Submission status: Runtime Error

Solution code:
s = input()
length = len(s)

i = 0
res = "YES"

while i < length: 
  if i+4 <= length and s[i:i+5] == "dream":
    i += 5
    if i+2 <= length and s[i:i+2] == "er" and s[i+2] != "a":
      i += 2
    elif i+1 == length and s[i:i+2] == "er":
      i += 2
  elif s[i] == "e":
  else:
    res = "NO"
    break
    
  if i+4 <= length and s[i:i+5] == "erase":
    i += 5
    if i+1 <= length and s[i] == "r" and s[i+1] != "a":
      i += 1
    elif i == length and s[i] == "r":
      i += 2
  elif s[i] == "d":
  else:
    res = "NO"
    break
        
print(res)

Submission status: Runtime Error

Solution code:
s = input()
length = len(s)

i = 0
res = "YES"

while i < length: 
  if i+4 <= length and s[i:i+5] == "dream":
    i += 5
    if (i+2 <= length and s[i:i+2] == "er" and s[i+2] != "a") or (i+1 == length and s[i:i+2] == "er"):
      i += 2
  elif s[i] == "e":
  else:
    res = "NO"
    break
    
  if i+4 <= length and s[i:i+5] == "erase":
    i += 5
    if (i+1 <= length and s[i] == "r" and s[i+1] != "a") or (i == length and s[i] == "r"):
      i += 1
  elif s[i] == "d":
  else:
    res = "NO"
    break
        
print(res)

Submission status: Runtime Error

Solution code:
s = input()
length = len(s)

i = 0
res = "YES"

while i < length: 
  if i+4 <= length and s[i:i+5] == "dream":
    i += 5
    if (i+2 <= length and s[i:i+2] == "er" and s[i+2] != "a") or (i+1 == length and s[i:i+2] == "er"):
      i += 2
  else if s[i] == "e":
  else:
    res = "NO"
    break
    
  if i+4 <= length and s[i:i+5] == "erase":
    i += 5
    if (i+1 <= length and s[i] == "r" and s[i+1] != "a") or (i == length and s[i] == "r"):
      i += 1
  else if s[i] == "d":
  else:
    res = "NO"
    break
        
print(res)

Submission status: Runtime Error

Solution code:
s = input()
length = len(s)

i = 0
res = "YES"

while i < length: 
  if i+4 <= length and s[i:i+5] == "dream":
    i += 5
    if (i+2 <= length and s[i:i+2] == "er" and s[i+2] != "a")
    or (i+1 == length and s[i:i+2] == "er"):
      i += 2
  else if s[i] == "e":
  else:
    res = "NO"
    break
    
  if i+4 <= length and s[i:i+5] == "erase":
    i += 5
    if (i+1 <= length and s[i] == "r" and s[i+1] != "a")
    or (i == length and s[i] == "r"):
      i += 1
  else if s[i] == "d":
  else:
    res = "NO"
    break
        
print(res)

Submission status: Runtime Error

Solution code:
s = input()
length = len(s)

i = 0
res = "YES"

while i < length: 
  if i+4 <= length and s[i:i+5] == "dream":
    i += 5
    if i+2 <= length and s[i:i+2] == "er" and s[i+2] != "a":
      i += 2
    else if i+1 == length and s[i:i+2] == "er":
      i += 2
  else:
    res = "NO"
    break
    
  if i+4 <= length and s[i:i+5] == "erase":
    i += 5
    if i+1 <= length and s[i] == "r" and s[i+1] != "a":
      i += 1
    else if i == length and s[i] == "r"
      i += 1
  else if s[i] == "d":
  else:
    res = "NO"
    break
        
print(res)

Submission status: Runtime Error

Solution code:
s = input()
length = len(s)

i = 0
res = "YES"

while i < length: 
  if i+4 <= length and s[i:i+5] == "dream":
    i += 5
    if i+1 <= length and s[i:i+2] == "er" and s[i+2] != "a":
      i += 2
  else:
    res = "NO"
    break
    
  if i+4 <= length and s[i:i+5] == "erase":
    i += 5
    if i <= length and s[i] == "r" and s[i+1] != "a":
      i += 1
  else:
    res = "NO"
    break
        
print(res)

Submission status: Runtime Error

Solution code:
s = input()
length = len(s)

i = 0
res = "YES"

while i < length:
  if i+4 <= length and s[i:i+5] == "dream":
    i += 5
    if i+1 <= length and s[i:i+2] == "er" and s[i+2] != "a":
      i += 2
  else if i+4 <= length and s[i:i+5] == "erase":
    i += 5
    if i+1 <= length and s[i:i+2] == "er" and s[i+2] != "a":
      i += 2
  else:
    res ="NO"
    break
        
print(res)

Submission status: Runtime Error

Solution code:
s = input()
length = len(s)

i = 0
res = "YES"

while i < length:
  if i+4 <= length and s[i:i+5] == "dream":
    i += 5
    if i+1 <= length and s[i:i+2] == "er" and s[i+2] != "a":
      i += 2
  else if i+4 <= length and s[i:i+5] == "erase":
    i += 5
    if i+1 < length and s[i:i+2] == "er" and s[i+2] != "a":
      i += 2
  else:
    res ="NO"
    break
        
print(res)

Submission status: Runtime Error

Solution code:
s=input()
while len(s)>0:
  #初めがdreamの場合
  if s[:5]=="dream" and (len(s)==5 or s[5]=="d" or d[5:8]=="era"):
    s=s[5:]
  elif s[:7]=="dreamer" and (len(s)==7 or s[7]=="d" or s[7]=="e"):
    #初めがdreamerの場合
    s=s[7:]
  elif s[:5]=="erase" and (len(s)==5 or s[5]=="d" or s[5]=="e"):
    #初めがeraseの場合
    s=s[5:]
  elif s[:6]=="eraser" and (len(s)==6 or s[6]=="d" or s[6]=="e"):
    s=s[6:]
  else:
    print("NO")
    exit()
print("YES")

Submission status: Runtime Error

Solution code:
def dfs(si, t):
    for subs in ['dream', 'dreamer', 'erase', 'eraser']:
        if si + len(subs) <= N and S[si:si + len(subs)] == subs:
            if si + len(subs) == N:
                print('Yes')
                exit()
            else:
                dfs(si + len(subs), t + subs)


S = input()
N = len(S)
dfs(0, '')
print('No')

Submission status: Runtime Error

Solution code:
S = input()
string_list = ["dream", "dreamer", "erase", "eraser"]

dp = []

dp[0] = 1
for i in range(len(S)):
    if dp[i] != 1:
        continue
    for string in string_list:
        if S[i: i + len(string) - 1] == string:
            dp[i + len(string) - 1] = 1

if dp[len(S)] == 1:
    print("Yes")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
def isdreame(s) :
    res = -1

    if len(s) - 5 >= 0 and s[len(s)-5:len(s)] == "erase" :
      #print(s[0:len(s)-5])
      if len(s) - 5 > 0 :
        res = isdreame(s[0:len(s)-5])
      else :
          res = 1

    elif len(s) - 5 >= 0 and s[len(s)-5:len(s)] == "dream" :
      #print(s[0:len(s)-5])
      if len(s) - 5 > 0 :
        res = isdreame(s[0:len(s)-5])
      else :
          res = 1

    elif len(s) - 6 >= 0 and s[len(s)-6:len(s)] == "eraser" :
      #print(s[0:len(s)-6])
      if len(s) - 6 > 0 :
        res = isdreame(s[0:len(s)-6])
      else :
          res = 1

    elif len(s) - 7 >= 0 and s[len(s)-7:len(s)] == "dreamer" :
      #print(s[0:len(s)-7])
      if len(s) - 7 > 0 :
        res = isdreame(s[0:len(s)-7])
      else :
          res = 1

    else :
        res = 0

    return res

s = input()
res = isdreame(s)

if res==1 :
    print("YES")
else :
    #print(res)
    print("NO")

Submission status: Runtime Error

Solution code:
#import sys
#input = sys.stdin.buffer.readline

def main():
    S = str(input())
    five = ["dream","erase"]
    def dream(s):
        if len(s) == 0:
            return True
        elif len(s) < 5:
            return False
        else:
            if s[:5] not in five:
                return False
            else:
                if s[:5] == "dream":
                    sf = s[5:]
                    if s[:7] == "dreamer":
                        se = s[7:]
                        return (dream(sf) or dream(se))
                    else:
                        return dream(sf)
                if s[:5] == "erase":
                    sf = s[5:]
                    if s[:6] == "eraser":
                        ss = s[6:]
                        return (dream(sf) or dream(ss))
                    else:
                        return dream(sf)
                
    if dream(S):
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N=int(input())
t=0
x=0
y=0
for i in range(N):
    t_next,x_next,y_next=map(int,input().split())
    zikan=t_next - t
    kyori=abs(x_next-x)+abs(y_next-y)
    if kyori>zikan or (zikan-kyori)%2==1:
        print('NO')
        exit(0)
    t,x,y=t_next,x_next,y_next
print('YES')

Submission status: Runtime Error

Solution code:
s = input()

rtn="dream"and "dreamer" and "eraser" and "erase" in s #""内は探したい文字列，戻り値はtrue/false

    if (rtn) == True:
        print(YES)
    else:
        print(NO)

Submission status: Runtime Error

Solution code:
s = input()
s2 = s.split('dream')
s3 = ''.join(s2).split('erase')
s3.remove('er')
s3.remove('r')
if len(s3) != 0:
  print("NO")
else:
  print("YES")

Submission status: Runtime Error

Solution code:
s = input()

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

for i in range(len(str_list)):
    if len(str_list[i])==7 and s[-7:]=='dreamer':
	s = s[:-7]

    elif len(str_list[i])==6 and s[-6:]=='eraser':
	s = s[:-6]
	
    elif s[-5:]=='erase' or s[-5:]=='dream':
	s = s[:-5]

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S = input()

list = ["eraser","erase","dreamer","dream"]
for x in range(list):
    S = S.replace(x,"")

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

Submission status: Runtime Error

Solution code:
S = input()

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

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

print(ans)

Submission status: Runtime Error

Solution code:
S = input()

S = S.replace("dream",'"")
S = S.replace("dreamer","")
S = S.replace("erase","")
S = S.replace("eraser","")

if len(S) == 0:
    ans = "YES"
else:
    ans = "NO"

print(ans)

Submission status: Runtime Error

Solution code:
S = input()

S.replace("dream",'"")
S.replace("dreamer","")
S.replace("erase","")
S.replace("eraser","")

if len(S) == 0:
    ans = "YES"
else:
    ans = "NO"

print(ans)

Submission status: Runtime Error

Solution code:
S = input()

S.replace("dream",'')
S.replace("dreamer",'')
S.replace("erase",'')
S.replace("eraser",'')

if len(S)==0:
    ans = YES
else:
    ans = NO

print(ans)

Submission status: Runtime Error

Solution code:
S = input()

S.replace("dream",'')
S.replace("dreamer",'')
S.replace("erase",'')
S.replace("eraser",'')

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

Submission status: Runtime Error

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

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


def saiki(_s):
    if len(_s) == 0:
        return True

    for strng in T:
        if _s.endswith(strng):
            _s = _s[:len(_s)-len(strng):]
            return saiki(_s)

    return False


ret = False
if len(s) > 0:
    ret = saiki(s)

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

Submission status: Runtime Error

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

S = input()

s = S[::]  # DeepCopyと同じ
T = ['dream', 'dreamer', 'erase', 'eraser']


def saiki(_s):
    if len(_s) == 0:
        return True

    for strng in T:
        if _s.endswith(strng):
            _s = _s[:len(_s)-len(strng):]
            return saiki(_s)

    return False


ret = saiki(s)

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

Submission status: Runtime Error

Solution code:
# coding: utf-8

import sys

S = input()

i = 0
while i < len(S):
	if S[i : i + 5] == "dream":
		if S[i + 5 : i + 7] == "er":
			if S[i + 7 : i + 10] == "ase":
				if S[i + 10] == "r":
					i += 11
				else:
					i += 10
			else:
				i += 7
		else:
			i += 5
	else:
		if S[i : i + 5] == "erase":
			if S[i + 5] == "r":
				i += 6
			else:
				i += 5
		else:
			print("NO")
			sys.exit()

print("YES")

Submission status: Runtime Error

Solution code:
# coding: utf-8

import sys

S = input()

i = 0
while i < len(S):
	if S[i : i + 5] == "dream":
		if S[i + 5 : i + 7] == "er":
			if S[i + 7 : i + 10] == "ase":
				if S[i + 10] == "r":
					i += 11
				else:
					i += 10
			else:
				i += 7
		else:
			i += 5
	else:
		if S[i : i + 5] == "erase":
			if S[i + 5] == "r":
				i += 6
			else:
				i += 5
		else:
			sys.exit()

print("YES")

Submission status: Runtime Error

Solution code:
# coding: utf-8

import sys

S = input()

i = 0
while i < len(S):
	if S[i : i + 5] == "dream":
		print("dream")
		if S[i + 5 : i + 7] == "er":
			print("er")
			if S[i + 7 : i + 10] == "ase":
				print("ase")
				if S[i + 10] == "r":
					print("r")
					i += 11
				else:
					i += 10
			else:
				i += 7
		else:
			i += 5
	else:
		if S[i : i + 5] == "erase":
			print("erase")
			if S[i + 5] == "r":
				print("r")
				i += 6
			else:
				i += 5
		else:
			print("NO")
			sys.exit()

print("YES")

Submission status: Runtime Error

Solution code:
dr ="dream" 
dre = "dreamer" 
er ="erase" 
ere = "eraser" 
a = input()
ret = "YES"
while len(a) != 0:
    if (a.endswith(dr) or a.endswith(er)):
        a = a[:len(a)-5]
    elif(a.endswith(dre) ):
        a = a[:len(a)-7]
	elif(a.endswith(ere)):
        a = a[:len(a)-6]
    else:
        ret = "NO"
        break
        
print(ret)

Submission status: Runtime Error

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: Runtime Error

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

Submission status: Runtime Error

Solution code:
import re

regex = r'(dream|dreamer|erase|eraser)+$'

s = raw_input()

if re.match(regex, s):
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
S = input()
T = ['dream', 'dreamer', 'erase', 'eraser']
lenT = [len(i) for i in T]

def dayDream(Sres_in):
    global isDream     #;print('dayDream: ', Sres_in)
    for i, d in enumerate(T):
        #print('d:', d)
        if Sres_in[:lenT[i]] == d:            
            Sres_out = Sres_in[lenT[i]:]
            if Sres_out =='':                
                isDream = True   #; print('YES')
                return 
            else:
                dayDream(Sres_out)
    #print('return', Sres_in)
    return
    
isDream = False
dayDream(S)
if isDream:
    print('YES')
else:
    print('NO')